diff --git a/src/resolve/connectionResolver.ts b/src/resolve/connectionResolver.ts index fe8e2ffea5..8cfb00acfd 100644 --- a/src/resolve/connectionResolver.ts +++ b/src/resolve/connectionResolver.ts @@ -53,51 +53,51 @@ export class ConnectionResolver { const componentTypes: Set = new Set(); const lifecycle = Lifecycle.getInstance(); - const componentPromises = this.mdTypeNames.map((type) => this.listMembers({ type })); - - (await Promise.all(componentPromises)).map(async (componentResult) => { - for (const component of componentResult) { - let componentType: MetadataType; - if (typeof component.type === 'string' && component.type.length) { - componentType = this.registry.getTypeByName(component.type); - } else if (typeof component.fileName === 'string' && component.fileName.length) { - // fix { type: { "$": { "xsi:nil": "true" } } } - componentType = ensurePlainObject( - this.registry.getTypeBySuffix(extName(component.fileName)), - `No type found for ${component.fileName} when matching by suffix. Check the file extension.` - ); - component.type = componentType.name; - } else if (component.type === undefined && component.fileName === undefined) { - // has no type and has no filename! Warn and skip that component. - // eslint-disable-next-line no-await-in-loop - await Promise.all([ - lifecycle.emitWarning(messages.getMessage('error_could_not_infer_type', [component.fullName])), - lifecycle.emitTelemetry({ TypeInferenceError: component, from: 'ConnectionResolver' }), - ]); - continue; - } else { - // it DOES have all the important info but we couldn't resolve it. - // has no type and has no filename! - throw new SfError( - messages.getMessage('error_could_not_infer_type', [component.fullName]), - 'TypeInferenceError', - [messages.getMessage('suggest_type_more_suggestions')] - ); - } + const componentFromDescribe = ( + await Promise.all(this.mdTypeNames.map((type) => this.listMembers({ type }))) + ).flat(); + + for (const component of componentFromDescribe) { + let componentType: MetadataType; + if (typeof component.type === 'string' && component.type.length) { + componentType = this.registry.getTypeByName(component.type); + } else if (typeof component.fileName === 'string' && component.fileName.length) { + // fix { type: { "$": { "xsi:nil": "true" } } } + componentType = ensurePlainObject( + this.registry.getTypeBySuffix(extName(component.fileName)), + `No type found for ${component.fileName} when matching by suffix. Check the file extension.` + ); + component.type = componentType.name; + } else if (component.type === undefined && component.fileName === undefined) { + // has no type and has no filename! Warn and skip that component. + // eslint-disable-next-line no-await-in-loop + await Promise.all([ + lifecycle.emitWarning(messages.getMessage('error_could_not_infer_type', [component.fullName])), + lifecycle.emitTelemetry({ TypeInferenceError: component, from: 'ConnectionResolver' }), + ]); + continue; + } else { + // it DOES have all the important info but we couldn't resolve it. + // has no type and has no filename! + throw new SfError( + messages.getMessage('error_could_not_infer_type', [component.fullName]), + 'TypeInferenceError', + [messages.getMessage('suggest_type_more_suggestions')] + ); + } - Aggregator.push(component); - componentTypes.add(componentType); - const folderContentType = componentType.folderContentType; - if (folderContentType) { - childrenPromises.push( - this.listMembers({ - type: this.registry.getTypeByName(folderContentType).name, - folder: component.fullName, - }) - ); - } + Aggregator.push(component); + componentTypes.add(componentType); + const folderContentType = componentType.folderContentType; + if (folderContentType) { + childrenPromises.push( + this.listMembers({ + type: this.registry.getTypeByName(folderContentType).name, + folder: component.fullName, + }) + ); } - }); + } for (const componentType of componentTypes) { const childTypes = componentType.children?.types;