55 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
77
8- import { PollingClient , StatusResult , Connection , Logger } from '@salesforce/core' ;
8+ import { PollingClient , StatusResult , Connection , Logger , SfError , Messages } from '@salesforce/core' ;
99import { Duration , ensureArray } from '@salesforce/kit' ;
1010import { retry , NotRetryableError , RetryError } from 'ts-retry-promise' ;
1111import { ensurePlainObject , ensureString , isPlainObject } from '@salesforce/ts-types' ;
@@ -14,6 +14,10 @@ import { standardValueSet } from '../registry/standardvalueset';
1414import { FileProperties , StdValueSetRecord , ListMetadataQuery } from '../client/types' ;
1515import { extName } from '../utils' ;
1616import { MetadataComponent } from './types' ;
17+
18+ Messages . importMessagesDirectory ( __dirname ) ;
19+ const messages = Messages . loadMessages ( '@salesforce/source-deploy-retrieve' , 'sdr' ) ;
20+
1721export interface ResolveConnectionResult {
1822 components : MetadataComponent [ ] ;
1923 apiVersion : string ;
@@ -49,14 +53,22 @@ export class ConnectionResolver {
4953 let componentType : MetadataType ;
5054 if ( typeof component . type === 'string' && component . type . length ) {
5155 componentType = this . registry . getTypeByName ( component . type ) ;
52- } else {
56+ } else if ( typeof component . fileName === 'string' && component . fileName . length ) {
5357 // fix { type: { "$": { "xsi:nil": "true" } } }
5458 componentType = ensurePlainObject (
5559 this . registry . getTypeBySuffix ( extName ( component . fileName ) ) ,
5660 `No type found for ${ component . fileName } when matching by suffix. Check the file extension.`
5761 ) ;
5862 component . type = componentType . name ;
63+ } else {
64+ // has no type and has no filename!
65+ throw new SfError (
66+ messages . getMessage ( 'error_could_not_infer_type' , [ component . fullName ] ) ,
67+ 'TypeInferenceError' ,
68+ [ messages . getMessage ( 'suggest_type_more_suggestions' ) ]
69+ ) ;
5970 }
71+
6072 Aggregator . push ( component ) ;
6173 componentTypes . add ( componentType ) ;
6274 const folderContentType = componentType . folderContentType ;
0 commit comments