fix(core): Fix credentials lazy-loading (no-changelog) (#6615)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™ 2023-07-10 17:57:26 +02:00 committed by GitHub
parent d8909ab8b0
commit 07744986ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 32 deletions

View file

@ -26,16 +26,13 @@ export class CredentialTypes implements ICredentialTypes {
* Returns all parent types of the given credential type * Returns all parent types of the given credential type
*/ */
getParentTypes(typeName: string): string[] { getParentTypes(typeName: string): string[] {
const credentialType = this.getByName(typeName); const extendsArr = this.knownCredentials[typeName]?.extends ?? [];
if (credentialType?.extends === undefined) return []; if (extendsArr.length) {
extendsArr.forEach((type) => {
const types: string[] = []; extendsArr.push(...this.getParentTypes(type));
credentialType.extends.forEach((type: string) => { });
types.push(type); }
types.push(...this.getParentTypes(type)); return extendsArr;
});
return types;
} }
private getCredential(type: string): LoadedClass<ICredentialType> { private getCredential(type: string): LoadedClass<ICredentialType> {

View file

@ -331,7 +331,7 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
for (const loader of Object.values(this.loaders)) { for (const loader of Object.values(this.loaders)) {
// list of node & credential types that will be sent to the frontend // list of node & credential types that will be sent to the frontend
const { types, directory } = loader; const { known, types, directory } = loader;
this.types.nodes = this.types.nodes.concat(types.nodes); this.types.nodes = this.types.nodes.concat(types.nodes);
this.types.credentials = this.types.credentials.concat(types.credentials); this.types.credentials = this.types.credentials.concat(types.credentials);
@ -344,26 +344,30 @@ export class LoadNodesAndCredentials implements INodesAndCredentials {
this.loaded.credentials[credentialTypeName] = loader.credentialTypes[credentialTypeName]; this.loaded.credentials[credentialTypeName] = loader.credentialTypes[credentialTypeName];
} }
// Nodes and credentials that will be lazy loaded for (const type in known.nodes) {
if (loader instanceof PackageDirectoryLoader) { const { className, sourcePath } = known.nodes[type];
const { packageName, known } = loader; this.known.nodes[type] = {
className,
sourcePath: path.join(directory, sourcePath),
};
}
for (const type in known.nodes) { for (const type in known.credentials) {
const { className, sourcePath } = known.nodes[type]; const {
this.known.nodes[type] = { className,
className, sourcePath,
sourcePath: path.join(directory, sourcePath), nodesToTestWith,
}; extends: extendsArr,
} } = known.credentials[type];
this.known.credentials[type] = {
for (const type in known.credentials) { className,
const { className, sourcePath, nodesToTestWith } = known.credentials[type]; sourcePath: path.join(directory, sourcePath),
this.known.credentials[type] = { nodesToTestWith:
className, loader instanceof PackageDirectoryLoader
sourcePath: path.join(directory, sourcePath), ? nodesToTestWith?.map((nodeName) => `${loader.packageName}.${nodeName}`)
nodesToTestWith: nodesToTestWith?.map((nodeName) => `${packageName}.${nodeName}`), : undefined,
}; extends: extendsArr,
} };
} }
} }
} }

View file

@ -38,6 +38,10 @@ const generate = async (kind) => {
else obj[name] = { className, sourcePath }; else obj[name] = { className, sourcePath };
} }
if (kind === 'credentials' && Array.isArray(instance.extends)) {
obj[name].extends = instance.extends;
}
if (kind === 'nodes') { if (kind === 'nodes') {
const { credentials } = instance.description; const { credentials } = instance.description;
if (credentials && credentials.length) { if (credentials && credentials.length) {
@ -53,6 +57,7 @@ const generate = async (kind) => {
} }
return obj; return obj;
}, {}); }, {});
LoggerProxy.info(`Detected ${Object.keys(data).length} ${kind}`); LoggerProxy.info(`Detected ${Object.keys(data).length} ${kind}`);
await writeJSON(`known/${kind}.json`, data); await writeJSON(`known/${kind}.json`, data);
return data; return data;

View file

@ -167,6 +167,7 @@ export abstract class DirectoryLoader {
this.known.credentials[tempCredential.name] = { this.known.credentials[tempCredential.name] = {
className: credentialName, className: credentialName,
sourcePath: filePath, sourcePath: filePath,
extends: tempCredential.extends,
}; };
this.credentialTypes[tempCredential.name] = { this.credentialTypes[tempCredential.name] = {

View file

@ -1568,6 +1568,7 @@ export type LoadingDetails = {
export type CredentialLoadingDetails = LoadingDetails & { export type CredentialLoadingDetails = LoadingDetails & {
nodesToTestWith?: string[]; nodesToTestWith?: string[];
extends?: string[];
}; };
export type NodeLoadingDetails = LoadingDetails; export type NodeLoadingDetails = LoadingDetails;
@ -1983,11 +1984,11 @@ export interface IExecutionsSummary {
lastNodeExecuted?: string; lastNodeExecuted?: string;
executionError?: ExecutionError; executionError?: ExecutionError;
nodeExecutionStatus?: { nodeExecutionStatus?: {
[key: string]: IExceutionSummaryNodeExecutionResult; [key: string]: IExecutionSummaryNodeExecutionResult;
}; };
} }
export interface IExceutionSummaryNodeExecutionResult { export interface IExecutionSummaryNodeExecutionResult {
executionStatus: ExecutionStatus; executionStatus: ExecutionStatus;
errors?: Array<{ errors?: Array<{
name?: string; name?: string;