mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 04:04:06 -08:00
fix: Set '@typescript-eslint/return-await' rule to 'always' for node code (no-changelog) (#8363)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
parent
2eb829a6b4
commit
9a1cc56806
|
@ -252,15 +252,15 @@ export class Agent implements INodeType {
|
||||||
const agentType = this.getNodeParameter('agent', 0, '') as string;
|
const agentType = this.getNodeParameter('agent', 0, '') as string;
|
||||||
|
|
||||||
if (agentType === 'conversationalAgent') {
|
if (agentType === 'conversationalAgent') {
|
||||||
return conversationalAgentExecute.call(this);
|
return await conversationalAgentExecute.call(this);
|
||||||
} else if (agentType === 'openAiFunctionsAgent') {
|
} else if (agentType === 'openAiFunctionsAgent') {
|
||||||
return openAiFunctionsAgentExecute.call(this);
|
return await openAiFunctionsAgentExecute.call(this);
|
||||||
} else if (agentType === 'reActAgent') {
|
} else if (agentType === 'reActAgent') {
|
||||||
return reActAgentAgentExecute.call(this);
|
return await reActAgentAgentExecute.call(this);
|
||||||
} else if (agentType === 'sqlAgent') {
|
} else if (agentType === 'sqlAgent') {
|
||||||
return sqlAgentAgentExecute.call(this);
|
return await sqlAgentAgentExecute.call(this);
|
||||||
} else if (agentType === 'planAndExecuteAgent') {
|
} else if (agentType === 'planAndExecuteAgent') {
|
||||||
return planAndExecuteAgentExecute.call(this);
|
return await planAndExecuteAgentExecute.call(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NodeOperationError(this.getNode(), `The agent type "${agentType}" is not supported`);
|
throw new NodeOperationError(this.getNode(), `The agent type "${agentType}" is not supported`);
|
||||||
|
|
|
@ -102,5 +102,5 @@ export async function conversationalAgentExecute(
|
||||||
returnData.push({ json: response });
|
returnData.push({ json: response });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,5 +101,5 @@ export async function openAiFunctionsAgentExecute(
|
||||||
returnData.push({ json: response });
|
returnData.push({ json: response });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,5 +76,5 @@ export async function planAndExecuteAgentExecute(
|
||||||
returnData.push({ json: response });
|
returnData.push({ json: response });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,5 +94,5 @@ export async function reActAgentAgentExecute(
|
||||||
returnData.push({ json: response });
|
returnData.push({ json: response });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,5 +101,5 @@ export async function sqlAgentAgentExecute(
|
||||||
returnData.push({ json: response });
|
returnData.push({ json: response });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,6 +380,6 @@ export class OpenAiAssistant implements INodeType {
|
||||||
returnData.push({ json: response });
|
returnData.push({ json: response });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ async function getChain(
|
||||||
|
|
||||||
// If there are no output parsers, create a simple LLM chain and execute the query
|
// If there are no output parsers, create a simple LLM chain and execute the query
|
||||||
if (!outputParsers.length) {
|
if (!outputParsers.length) {
|
||||||
return createSimpleLLMChain(context, llm, query, chatTemplate);
|
return await createSimpleLLMChain(context, llm, query, chatTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's only one output parser, use it; otherwise, create a combined output parser
|
// If there's only one output parser, use it; otherwise, create a combined output parser
|
||||||
|
|
|
@ -126,6 +126,6 @@ export class ChainRetrievalQa implements INodeType {
|
||||||
const response = await chain.call({ query });
|
const response = await chain.call({ query });
|
||||||
returnData.push({ json: { response } });
|
returnData.push({ json: { response } });
|
||||||
}
|
}
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,6 +258,6 @@ export class ChainSummarizationV1 implements INodeType {
|
||||||
returnData.push({ json: { response } });
|
returnData.push({ json: { response } });
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,6 +415,6 @@ export class ChainSummarizationV2 implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(returnData);
|
return await this.prepareOutputData(returnData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ export class MemoryChatRetriever implements INodeType {
|
||||||
const messages = await memory?.chatHistory.getMessages();
|
const messages = await memory?.chatHistory.getMessages();
|
||||||
|
|
||||||
if (simplifyOutput && messages) {
|
if (simplifyOutput && messages) {
|
||||||
return this.prepareOutputData(simplifyMessages(messages));
|
return await this.prepareOutputData(simplifyMessages(messages));
|
||||||
}
|
}
|
||||||
|
|
||||||
const serializedMessages =
|
const serializedMessages =
|
||||||
|
@ -107,6 +107,6 @@ export class MemoryChatRetriever implements INodeType {
|
||||||
return { json: serializedMessage as unknown as IDataObject };
|
return { json: serializedMessage as unknown as IDataObject };
|
||||||
}) ?? [];
|
}) ?? [];
|
||||||
|
|
||||||
return this.prepareOutputData(serializedMessages);
|
return await this.prepareOutputData(serializedMessages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,6 +324,6 @@ export class MemoryManager implements INodeType {
|
||||||
result.push(...executionData);
|
result.push(...executionData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(result);
|
return await this.prepareOutputData(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ export class ToolCode implements INodeType {
|
||||||
|
|
||||||
const runFunction = async (query: string): Promise<string> => {
|
const runFunction = async (query: string): Promise<string> => {
|
||||||
const sandbox = getSandbox(query, itemIndex);
|
const sandbox = getSandbox(query, itemIndex);
|
||||||
return sandbox.runCode() as Promise<string>;
|
return await (sandbox.runCode() as Promise<string>);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -46,7 +46,7 @@ export const VectorStoreInMemory = createVectorStoreNode({
|
||||||
const memoryKey = context.getNodeParameter('memoryKey', itemIndex) as string;
|
const memoryKey = context.getNodeParameter('memoryKey', itemIndex) as string;
|
||||||
const vectorStoreSingleton = MemoryVectorStoreManager.getInstance(embeddings);
|
const vectorStoreSingleton = MemoryVectorStoreManager.getInstance(embeddings);
|
||||||
|
|
||||||
return vectorStoreSingleton.getVectorStore(`${workflowId}__${memoryKey}`);
|
return await vectorStoreSingleton.getVectorStore(`${workflowId}__${memoryKey}`);
|
||||||
},
|
},
|
||||||
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
||||||
const memoryKey = context.getNodeParameter('memoryKey', itemIndex) as string;
|
const memoryKey = context.getNodeParameter('memoryKey', itemIndex) as string;
|
||||||
|
|
|
@ -108,6 +108,6 @@ export class VectorStoreInMemoryInsert implements INodeType {
|
||||||
clearStore,
|
clearStore,
|
||||||
);
|
);
|
||||||
|
|
||||||
return this.prepareOutputData(serializedDocuments);
|
return await this.prepareOutputData(serializedDocuments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ export const VectorStorePinecone = createVectorStoreNode({
|
||||||
filter,
|
filter,
|
||||||
};
|
};
|
||||||
|
|
||||||
return PineconeStore.fromExistingIndex(embeddings, config);
|
return await PineconeStore.fromExistingIndex(embeddings, config);
|
||||||
},
|
},
|
||||||
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
||||||
const index = context.getNodeParameter('pineconeIndex', itemIndex, '', {
|
const index = context.getNodeParameter('pineconeIndex', itemIndex, '', {
|
||||||
|
|
|
@ -134,6 +134,6 @@ export class VectorStorePineconeInsert implements INodeType {
|
||||||
pineconeIndex,
|
pineconeIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.prepareOutputData(serializedDocuments);
|
return await this.prepareOutputData(serializedDocuments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ export const VectorStoreQdrant = createVectorStoreNode({
|
||||||
collectionName: collection,
|
collectionName: collection,
|
||||||
};
|
};
|
||||||
|
|
||||||
return QdrantVectorStore.fromExistingCollection(embeddings, config);
|
return await QdrantVectorStore.fromExistingCollection(embeddings, config);
|
||||||
},
|
},
|
||||||
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
async populateVectorStore(context, embeddings, documents, itemIndex) {
|
||||||
const collectionName = context.getNodeParameter('qdrantCollection', itemIndex, '', {
|
const collectionName = context.getNodeParameter('qdrantCollection', itemIndex, '', {
|
||||||
|
|
|
@ -76,7 +76,7 @@ export const VectorStoreSupabase = createVectorStoreNode({
|
||||||
const credentials = await context.getCredentials('supabaseApi');
|
const credentials = await context.getCredentials('supabaseApi');
|
||||||
const client = createClient(credentials.host as string, credentials.serviceRole as string);
|
const client = createClient(credentials.host as string, credentials.serviceRole as string);
|
||||||
|
|
||||||
return SupabaseVectorStore.fromExistingIndex(embeddings, {
|
return await SupabaseVectorStore.fromExistingIndex(embeddings, {
|
||||||
client,
|
client,
|
||||||
tableName,
|
tableName,
|
||||||
queryName: options.queryName ?? 'match_documents',
|
queryName: options.queryName ?? 'match_documents',
|
||||||
|
|
|
@ -122,6 +122,6 @@ export class VectorStoreSupabaseInsert implements INodeType {
|
||||||
queryName,
|
queryName,
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.prepareOutputData(serializedDocuments);
|
return await this.prepareOutputData(serializedDocuments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,6 @@ export class VectorStoreZepInsert implements INodeType {
|
||||||
|
|
||||||
await ZepVectorStore.fromDocuments(processedDocuments, embeddings, zepConfig);
|
await ZepVectorStore.fromDocuments(processedDocuments, embeddings, zepConfig);
|
||||||
|
|
||||||
return this.prepareOutputData(serializedDocuments);
|
return await this.prepareOutputData(serializedDocuments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,7 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
resultData.push(...serializedDocs);
|
resultData.push(...serializedDocs);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(resultData);
|
return await this.prepareOutputData(resultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode === 'insert') {
|
if (mode === 'insert') {
|
||||||
|
@ -267,7 +267,7 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.prepareOutputData(resultData);
|
return await this.prepareOutputData(resultData);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new NodeOperationError(
|
throw new NodeOperationError(
|
||||||
|
|
|
@ -8,4 +8,11 @@ module.exports = {
|
||||||
es6: true,
|
es6: true,
|
||||||
node: true,
|
node: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
/**
|
||||||
|
* https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/docs/rules/return-await.md
|
||||||
|
*/
|
||||||
|
'@typescript-eslint/return-await': ['error', 'always'],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -208,7 +208,7 @@ export abstract class AbstractServer {
|
||||||
// TODO UM: check if this needs validation with user management.
|
// TODO UM: check if this needs validation with user management.
|
||||||
this.app.delete(
|
this.app.delete(
|
||||||
`/${this.restEndpoint}/test-webhook/:id`,
|
`/${this.restEndpoint}/test-webhook/:id`,
|
||||||
send(async (req) => testWebhooks.cancelWebhook(req.params.id)),
|
send(async (req) => await testWebhooks.cancelWebhook(req.params.id)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,7 +178,7 @@ export class ActiveExecutions {
|
||||||
this.activeExecutions[executionId].workflowExecution!.cancel();
|
this.activeExecutions[executionId].workflowExecution!.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getPostExecutePromise(executionId);
|
return await this.getPostExecutePromise(executionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,7 +197,7 @@ export class ActiveExecutions {
|
||||||
|
|
||||||
this.activeExecutions[executionId].postExecutePromises.push(waitPromise);
|
this.activeExecutions[executionId].postExecutePromises.push(waitPromise);
|
||||||
|
|
||||||
return waitPromise.promise();
|
return await waitPromise.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -30,7 +30,7 @@ export class ActiveWebhooks implements IWebhookManager {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getWebhookMethods(path: string) {
|
async getWebhookMethods(path: string) {
|
||||||
return this.webhookService.getWebhookMethods(path);
|
return await this.webhookService.getWebhookMethods(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAccessControlOptions(path: string, httpMethod: IHttpRequestMethods) {
|
async findAccessControlOptions(path: string, httpMethod: IHttpRequestMethods) {
|
||||||
|
@ -120,7 +120,7 @@ export class ActiveWebhooks implements IWebhookManager {
|
||||||
throw new NotFoundError('Could not find node to process webhook.');
|
throw new NotFoundError('Could not find node to process webhook.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
const executionMode = 'webhook';
|
const executionMode = 'webhook';
|
||||||
void WebhookHelpers.executeWebhook(
|
void WebhookHelpers.executeWebhook(
|
||||||
workflow,
|
workflow,
|
||||||
|
|
|
@ -89,7 +89,7 @@ export class ActiveWorkflowRunner {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllWorkflowActivationErrors() {
|
async getAllWorkflowActivationErrors() {
|
||||||
return this.activationErrorsService.getAll();
|
return await this.activationErrorsService.getAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -305,7 +305,7 @@ export class ActiveWorkflowRunner {
|
||||||
};
|
};
|
||||||
|
|
||||||
const workflowRunner = new WorkflowRunner();
|
const workflowRunner = new WorkflowRunner();
|
||||||
return workflowRunner.run(runData, true, undefined, undefined, responsePromise);
|
return await workflowRunner.run(runData, true, undefined, undefined, responsePromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -121,7 +121,10 @@ export class CredentialsHelper extends ICredentialsHelper {
|
||||||
if (typeof credentialType.authenticate === 'function') {
|
if (typeof credentialType.authenticate === 'function') {
|
||||||
// Special authentication function is defined
|
// Special authentication function is defined
|
||||||
|
|
||||||
return credentialType.authenticate(credentials, requestOptions as IHttpRequestOptions);
|
return await credentialType.authenticate(
|
||||||
|
credentials,
|
||||||
|
requestOptions as IHttpRequestOptions,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof credentialType.authenticate === 'object') {
|
if (typeof credentialType.authenticate === 'object') {
|
||||||
|
|
|
@ -54,7 +54,7 @@ if (!inTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function transaction<T>(fn: (entityManager: EntityManager) => Promise<T>): Promise<T> {
|
export async function transaction<T>(fn: (entityManager: EntityManager) => Promise<T>): Promise<T> {
|
||||||
return connection.transaction(fn);
|
return await connection.transaction(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConnectionOptions(dbType: DatabaseType): ConnectionOptions {
|
export function getConnectionOptions(dbType: DatabaseType): ConnectionOptions {
|
||||||
|
|
|
@ -13,7 +13,7 @@ export class ExternalSecretsController {
|
||||||
@Get('/providers')
|
@Get('/providers')
|
||||||
@RequireGlobalScope('externalSecretsProvider:list')
|
@RequireGlobalScope('externalSecretsProvider:list')
|
||||||
async getProviders() {
|
async getProviders() {
|
||||||
return this.secretsService.getProviders();
|
return await this.secretsService.getProviders();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/providers/:provider')
|
@Get('/providers/:provider')
|
||||||
|
|
|
@ -134,7 +134,7 @@ export class ExternalSecretsService {
|
||||||
}
|
}
|
||||||
const { settings } = providerAndSettings;
|
const { settings } = providerAndSettings;
|
||||||
const newData = this.unredact(data, settings.settings);
|
const newData = this.unredact(data, settings.settings);
|
||||||
return Container.get(ExternalSecretsManager).testProviderSettings(providerName, newData);
|
return await Container.get(ExternalSecretsManager).testProviderSettings(providerName, newData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateProvider(providerName: string) {
|
async updateProvider(providerName: string) {
|
||||||
|
@ -143,6 +143,6 @@ export class ExternalSecretsService {
|
||||||
if (!providerAndSettings) {
|
if (!providerAndSettings) {
|
||||||
throw new ExternalSecretsProviderNotFoundError(providerName);
|
throw new ExternalSecretsProviderNotFoundError(providerName);
|
||||||
}
|
}
|
||||||
return Container.get(ExternalSecretsManager).updateProvider(providerName);
|
return await Container.get(ExternalSecretsManager).updateProvider(providerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,13 @@ export class ExternalSecretsManager {
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
resolve();
|
resolve();
|
||||||
this.initializingPromise = undefined;
|
this.initializingPromise = undefined;
|
||||||
this.updateInterval = setInterval(async () => this.updateSecrets(), updateIntervalTime());
|
this.updateInterval = setInterval(
|
||||||
|
async () => await this.updateSecrets(),
|
||||||
|
updateIntervalTime(),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return this.initializingPromise;
|
return await this.initializingPromise;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +110,8 @@ export class ExternalSecretsManager {
|
||||||
}
|
}
|
||||||
const providers: Array<SecretsProvider | null> = (
|
const providers: Array<SecretsProvider | null> = (
|
||||||
await Promise.allSettled(
|
await Promise.allSettled(
|
||||||
Object.entries(settings).map(async ([name, providerSettings]) =>
|
Object.entries(settings).map(
|
||||||
this.initProvider(name, providerSettings),
|
async ([name, providerSettings]) => await this.initProvider(name, providerSettings),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
).map((i) => (i.status === 'rejected' ? null : i.value));
|
).map((i) => (i.status === 'rejected' ? null : i.value));
|
||||||
|
|
|
@ -436,7 +436,7 @@ export class VaultProvider extends SecretsProvider {
|
||||||
await Promise.allSettled(
|
await Promise.allSettled(
|
||||||
listResp.data.data.keys.map(async (key): Promise<[string, IDataObject] | null> => {
|
listResp.data.data.keys.map(async (key): Promise<[string, IDataObject] | null> => {
|
||||||
if (key.endsWith('/')) {
|
if (key.endsWith('/')) {
|
||||||
return this.getKVSecrets(mountPath, kvVersion, path + key);
|
return await this.getKVSecrets(mountPath, kvVersion, path + key);
|
||||||
}
|
}
|
||||||
let secretPath = mountPath;
|
let secretPath = mountPath;
|
||||||
if (kvVersion === '2') {
|
if (kvVersion === '2') {
|
||||||
|
|
|
@ -56,11 +56,13 @@ export class InternalHooks {
|
||||||
eventsService: EventsService,
|
eventsService: EventsService,
|
||||||
private readonly instanceSettings: InstanceSettings,
|
private readonly instanceSettings: InstanceSettings,
|
||||||
) {
|
) {
|
||||||
eventsService.on('telemetry.onFirstProductionWorkflowSuccess', async (metrics) =>
|
eventsService.on(
|
||||||
this.onFirstProductionWorkflowSuccess(metrics),
|
'telemetry.onFirstProductionWorkflowSuccess',
|
||||||
|
async (metrics) => await this.onFirstProductionWorkflowSuccess(metrics),
|
||||||
);
|
);
|
||||||
eventsService.on('telemetry.onFirstWorkflowDataLoad', async (metrics) =>
|
eventsService.on(
|
||||||
this.onFirstWorkflowDataLoad(metrics),
|
'telemetry.onFirstWorkflowDataLoad',
|
||||||
|
async (metrics) => await this.onFirstWorkflowDataLoad(metrics),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +90,7 @@ export class InternalHooks {
|
||||||
license_tenant_id: diagnosticInfo.licenseTenantId,
|
license_tenant_id: diagnosticInfo.licenseTenantId,
|
||||||
};
|
};
|
||||||
|
|
||||||
return Promise.all([
|
return await Promise.all([
|
||||||
this.telemetry.identify(info),
|
this.telemetry.identify(info),
|
||||||
this.telemetry.track('Instance started', {
|
this.telemetry.track('Instance started', {
|
||||||
...info,
|
...info,
|
||||||
|
@ -98,7 +100,7 @@ export class InternalHooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onFrontendSettingsAPI(sessionId?: string): Promise<void> {
|
async onFrontendSettingsAPI(sessionId?: string): Promise<void> {
|
||||||
return this.telemetry.track('Session started', { session_id: sessionId });
|
return await this.telemetry.track('Session started', { session_id: sessionId });
|
||||||
}
|
}
|
||||||
|
|
||||||
async onPersonalizationSurveySubmitted(
|
async onPersonalizationSurveySubmitted(
|
||||||
|
@ -111,7 +113,7 @@ export class InternalHooks {
|
||||||
personalizationSurveyData[snakeCase(camelCaseKey)] = answers[camelCaseKey];
|
personalizationSurveyData[snakeCase(camelCaseKey)] = answers[camelCaseKey];
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.telemetry.track(
|
return await this.telemetry.track(
|
||||||
'User responded to personalization questions',
|
'User responded to personalization questions',
|
||||||
personalizationSurveyData,
|
personalizationSurveyData,
|
||||||
);
|
);
|
||||||
|
@ -459,7 +461,7 @@ export class InternalHooks {
|
||||||
user_id_list: userList,
|
user_id_list: userList,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.telemetry.track('User updated workflow sharing', properties);
|
return await this.telemetry.track('User updated workflow sharing', properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onN8nStop(): Promise<void> {
|
async onN8nStop(): Promise<void> {
|
||||||
|
@ -469,7 +471,7 @@ export class InternalHooks {
|
||||||
}, 3000);
|
}, 3000);
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.race([timeoutPromise, this.telemetry.trackN8nStop()]);
|
return await Promise.race([timeoutPromise, this.telemetry.trackN8nStop()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserDeletion(userDeletionData: {
|
async onUserDeletion(userDeletionData: {
|
||||||
|
@ -554,42 +556,42 @@ export class InternalHooks {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User retrieved user', userRetrievedData);
|
return await this.telemetry.track('User retrieved user', userRetrievedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserRetrievedAllUsers(userRetrievedData: {
|
async onUserRetrievedAllUsers(userRetrievedData: {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User retrieved all users', userRetrievedData);
|
return await this.telemetry.track('User retrieved all users', userRetrievedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserRetrievedExecution(userRetrievedData: {
|
async onUserRetrievedExecution(userRetrievedData: {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User retrieved execution', userRetrievedData);
|
return await this.telemetry.track('User retrieved execution', userRetrievedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserRetrievedAllExecutions(userRetrievedData: {
|
async onUserRetrievedAllExecutions(userRetrievedData: {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User retrieved all executions', userRetrievedData);
|
return await this.telemetry.track('User retrieved all executions', userRetrievedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserRetrievedWorkflow(userRetrievedData: {
|
async onUserRetrievedWorkflow(userRetrievedData: {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User retrieved workflow', userRetrievedData);
|
return await this.telemetry.track('User retrieved workflow', userRetrievedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserRetrievedAllWorkflows(userRetrievedData: {
|
async onUserRetrievedAllWorkflows(userRetrievedData: {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User retrieved all workflows', userRetrievedData);
|
return await this.telemetry.track('User retrieved all workflows', userRetrievedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserUpdate(userUpdateData: { user: User; fields_changed: string[] }): Promise<void> {
|
async onUserUpdate(userUpdateData: { user: User; fields_changed: string[] }): Promise<void> {
|
||||||
|
@ -649,7 +651,7 @@ export class InternalHooks {
|
||||||
message_type: 'Reset password' | 'New user invite' | 'Resend invite';
|
message_type: 'Reset password' | 'New user invite' | 'Resend invite';
|
||||||
public_api: boolean;
|
public_api: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track(
|
return await this.telemetry.track(
|
||||||
'Instance sent transactional email to user',
|
'Instance sent transactional email to user',
|
||||||
userTransactionalEmailData,
|
userTransactionalEmailData,
|
||||||
);
|
);
|
||||||
|
@ -661,7 +663,7 @@ export class InternalHooks {
|
||||||
method: string;
|
method: string;
|
||||||
api_version: string;
|
api_version: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User invoked API', userInvokedApiData);
|
return await this.telemetry.track('User invoked API', userInvokedApiData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onApiKeyDeleted(apiKeyDeletedData: { user: User; public_api: boolean }): Promise<void> {
|
async onApiKeyDeleted(apiKeyDeletedData: { user: User; public_api: boolean }): Promise<void> {
|
||||||
|
@ -709,7 +711,7 @@ export class InternalHooks {
|
||||||
}
|
}
|
||||||
|
|
||||||
async onInstanceOwnerSetup(instanceOwnerSetupData: { user_id: string }): Promise<void> {
|
async onInstanceOwnerSetup(instanceOwnerSetupData: { user_id: string }): Promise<void> {
|
||||||
return this.telemetry.track('Owner finished instance setup', instanceOwnerSetupData);
|
return await this.telemetry.track('Owner finished instance setup', instanceOwnerSetupData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserSignup(
|
async onUserSignup(
|
||||||
|
@ -963,7 +965,7 @@ export class InternalHooks {
|
||||||
users_synced: number;
|
users_synced: number;
|
||||||
error: string;
|
error: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('Ldap general sync finished', data);
|
return await this.telemetry.track('Ldap general sync finished', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onUserUpdatedLdapSettings(data: {
|
async onUserUpdatedLdapSettings(data: {
|
||||||
|
@ -980,15 +982,15 @@ export class InternalHooks {
|
||||||
loginLabel: string;
|
loginLabel: string;
|
||||||
loginEnabled: boolean;
|
loginEnabled: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('Ldap general sync finished', data);
|
return await this.telemetry.track('Ldap general sync finished', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onLdapLoginSyncFailed(data: { error: string }): Promise<void> {
|
async onLdapLoginSyncFailed(data: { error: string }): Promise<void> {
|
||||||
return this.telemetry.track('Ldap login sync failed', data);
|
return await this.telemetry.track('Ldap login sync failed', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async userLoginFailedDueToLdapDisabled(data: { user_id: string }): Promise<void> {
|
async userLoginFailedDueToLdapDisabled(data: { user_id: string }): Promise<void> {
|
||||||
return this.telemetry.track('User login failed since ldap disabled', data);
|
return await this.telemetry.track('User login failed since ldap disabled', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -998,7 +1000,7 @@ export class InternalHooks {
|
||||||
user_id: string;
|
user_id: string;
|
||||||
workflow_id: string;
|
workflow_id: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('Workflow first prod success', data);
|
return await this.telemetry.track('Workflow first prod success', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onFirstWorkflowDataLoad(data: {
|
async onFirstWorkflowDataLoad(data: {
|
||||||
|
@ -1009,7 +1011,7 @@ export class InternalHooks {
|
||||||
credential_type?: string;
|
credential_type?: string;
|
||||||
credential_id?: string;
|
credential_id?: string;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('Workflow first data fetched', data);
|
return await this.telemetry.track('Workflow first data fetched', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1023,11 +1025,11 @@ export class InternalHooks {
|
||||||
* Audit
|
* Audit
|
||||||
*/
|
*/
|
||||||
async onAuditGeneratedViaCli() {
|
async onAuditGeneratedViaCli() {
|
||||||
return this.telemetry.track('Instance generated security audit via CLI command');
|
return await this.telemetry.track('Instance generated security audit via CLI command');
|
||||||
}
|
}
|
||||||
|
|
||||||
async onVariableCreated(createData: { variable_type: string }): Promise<void> {
|
async onVariableCreated(createData: { variable_type: string }): Promise<void> {
|
||||||
return this.telemetry.track('User created variable', createData);
|
return await this.telemetry.track('User created variable', createData);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onSourceControlSettingsUpdated(data: {
|
async onSourceControlSettingsUpdated(data: {
|
||||||
|
@ -1036,7 +1038,7 @@ export class InternalHooks {
|
||||||
repo_type: 'github' | 'gitlab' | 'other';
|
repo_type: 'github' | 'gitlab' | 'other';
|
||||||
connected: boolean;
|
connected: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User updated source control settings', data);
|
return await this.telemetry.track('User updated source control settings', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onSourceControlUserStartedPullUI(data: {
|
async onSourceControlUserStartedPullUI(data: {
|
||||||
|
@ -1044,11 +1046,11 @@ export class InternalHooks {
|
||||||
workflow_conflicts: number;
|
workflow_conflicts: number;
|
||||||
cred_conflicts: number;
|
cred_conflicts: number;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User started pull via UI', data);
|
return await this.telemetry.track('User started pull via UI', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onSourceControlUserFinishedPullUI(data: { workflow_updates: number }): Promise<void> {
|
async onSourceControlUserFinishedPullUI(data: { workflow_updates: number }): Promise<void> {
|
||||||
return this.telemetry.track('User finished pull via UI', {
|
return await this.telemetry.track('User finished pull via UI', {
|
||||||
workflow_updates: data.workflow_updates,
|
workflow_updates: data.workflow_updates,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1057,7 +1059,7 @@ export class InternalHooks {
|
||||||
workflow_updates: number;
|
workflow_updates: number;
|
||||||
forced: boolean;
|
forced: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User pulled via API', data);
|
return await this.telemetry.track('User pulled via API', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onSourceControlUserStartedPushUI(data: {
|
async onSourceControlUserStartedPushUI(data: {
|
||||||
|
@ -1067,7 +1069,7 @@ export class InternalHooks {
|
||||||
creds_eligible_with_conflicts: number;
|
creds_eligible_with_conflicts: number;
|
||||||
variables_eligible: number;
|
variables_eligible: number;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User started push via UI', data);
|
return await this.telemetry.track('User started push via UI', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onSourceControlUserFinishedPushUI(data: {
|
async onSourceControlUserFinishedPushUI(data: {
|
||||||
|
@ -1076,7 +1078,7 @@ export class InternalHooks {
|
||||||
creds_pushed: number;
|
creds_pushed: number;
|
||||||
variables_pushed: number;
|
variables_pushed: number;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User finished push via UI', data);
|
return await this.telemetry.track('User finished push via UI', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async onExternalSecretsProviderSettingsSaved(saveData: {
|
async onExternalSecretsProviderSettingsSaved(saveData: {
|
||||||
|
@ -1086,6 +1088,6 @@ export class InternalHooks {
|
||||||
is_new: boolean;
|
is_new: boolean;
|
||||||
error_message?: string | undefined;
|
error_message?: string | undefined;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
return this.telemetry.track('User updated external secrets settings', saveData);
|
return await this.telemetry.track('User updated external secrets settings', saveData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ export const randomPassword = (): string => {
|
||||||
* Return the user role to be assigned to LDAP users
|
* Return the user role to be assigned to LDAP users
|
||||||
*/
|
*/
|
||||||
export const getLdapUserRole = async (): Promise<Role> => {
|
export const getLdapUserRole = async (): Promise<Role> => {
|
||||||
return Container.get(RoleService).findGlobalMemberRole();
|
return await Container.get(RoleService).findGlobalMemberRole();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +101,7 @@ export const escapeFilter = (filter: string): string => {
|
||||||
export const getAuthIdentityByLdapId = async (
|
export const getAuthIdentityByLdapId = async (
|
||||||
idAttributeValue: string,
|
idAttributeValue: string,
|
||||||
): Promise<AuthIdentity | null> => {
|
): Promise<AuthIdentity | null> => {
|
||||||
return Container.get(AuthIdentityRepository).findOne({
|
return await Container.get(AuthIdentityRepository).findOne({
|
||||||
relations: ['user', 'user.globalRole'],
|
relations: ['user', 'user.globalRole'],
|
||||||
where: {
|
where: {
|
||||||
providerId: idAttributeValue,
|
providerId: idAttributeValue,
|
||||||
|
@ -111,7 +111,7 @@ export const getAuthIdentityByLdapId = async (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getUserByEmail = async (email: string): Promise<User | null> => {
|
export const getUserByEmail = async (email: string): Promise<User | null> => {
|
||||||
return Container.get(UserRepository).findOne({
|
return await Container.get(UserRepository).findOne({
|
||||||
where: { email },
|
where: { email },
|
||||||
relations: ['globalRole'],
|
relations: ['globalRole'],
|
||||||
});
|
});
|
||||||
|
@ -190,10 +190,10 @@ export const processUsers = async (
|
||||||
toDisableUsers: string[],
|
toDisableUsers: string[],
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
await Db.transaction(async (transactionManager) => {
|
await Db.transaction(async (transactionManager) => {
|
||||||
return Promise.all([
|
return await Promise.all([
|
||||||
...toCreateUsers.map(async ([ldapId, user]) => {
|
...toCreateUsers.map(async ([ldapId, user]) => {
|
||||||
const authIdentity = AuthIdentity.create(await transactionManager.save(user), ldapId);
|
const authIdentity = AuthIdentity.create(await transactionManager.save(user), ldapId);
|
||||||
return transactionManager.save(authIdentity);
|
return await transactionManager.save(authIdentity);
|
||||||
}),
|
}),
|
||||||
...toUpdateUsers.map(async ([ldapId, user]) => {
|
...toUpdateUsers.map(async ([ldapId, user]) => {
|
||||||
const authIdentity = await transactionManager.findOneBy(AuthIdentity, {
|
const authIdentity = await transactionManager.findOneBy(AuthIdentity, {
|
||||||
|
@ -240,7 +240,7 @@ export const getLdapSynchronizations = async (
|
||||||
perPage: number,
|
perPage: number,
|
||||||
): Promise<AuthProviderSyncHistory[]> => {
|
): Promise<AuthProviderSyncHistory[]> => {
|
||||||
const _page = Math.abs(page);
|
const _page = Math.abs(page);
|
||||||
return Container.get(AuthProviderSyncHistoryRepository).find({
|
return await Container.get(AuthProviderSyncHistoryRepository).find({
|
||||||
where: { providerType: 'ldap' },
|
where: { providerType: 'ldap' },
|
||||||
order: { id: 'DESC' },
|
order: { id: 'DESC' },
|
||||||
take: perPage,
|
take: perPage,
|
||||||
|
@ -267,7 +267,7 @@ export const getMappingAttributes = (ldapConfig: LdapConfig): string[] => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createLdapAuthIdentity = async (user: User, ldapId: string) => {
|
export const createLdapAuthIdentity = async (user: User, ldapId: string) => {
|
||||||
return Container.get(AuthIdentityRepository).save(AuthIdentity.create(user, ldapId));
|
return await Container.get(AuthIdentityRepository).save(AuthIdentity.create(user, ldapId));
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createLdapUserOnLocalDb = async (role: Role, data: Partial<User>, ldapId: string) => {
|
export const createLdapUserOnLocalDb = async (role: Role, data: Partial<User>, ldapId: string) => {
|
||||||
|
@ -288,5 +288,5 @@ export const updateLdapUserOnLocalDb = async (identity: AuthIdentity, data: Part
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deleteAllLdapIdentities = async () => {
|
export const deleteAllLdapIdentities = async () => {
|
||||||
return Container.get(AuthIdentityRepository).delete({ providerType: 'ldap' });
|
return await Container.get(AuthIdentityRepository).delete({ providerType: 'ldap' });
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ export class LdapController {
|
||||||
@Get('/config')
|
@Get('/config')
|
||||||
@RequireGlobalScope('ldap:manage')
|
@RequireGlobalScope('ldap:manage')
|
||||||
async getConfig() {
|
async getConfig() {
|
||||||
return this.ldapService.loadConfig();
|
return await this.ldapService.loadConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/test-connection')
|
@Post('/test-connection')
|
||||||
|
@ -55,7 +55,7 @@ export class LdapController {
|
||||||
@RequireGlobalScope('ldap:sync')
|
@RequireGlobalScope('ldap:sync')
|
||||||
async getLdapSync(req: LdapConfiguration.GetSync) {
|
async getLdapSync(req: LdapConfiguration.GetSync) {
|
||||||
const { page = '0', perPage = '20' } = req.query;
|
const { page = '0', perPage = '20' } = req.query;
|
||||||
return getLdapSynchronizations(parseInt(page, 10), parseInt(perPage, 10));
|
return await getLdapSynchronizations(parseInt(page, 10), parseInt(perPage, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/sync')
|
@Post('/sync')
|
||||||
|
|
|
@ -59,13 +59,13 @@ export class License {
|
||||||
const offlineMode = !isMainInstance;
|
const offlineMode = !isMainInstance;
|
||||||
const autoRenewOffset = config.getEnv('license.autoRenewOffset');
|
const autoRenewOffset = config.getEnv('license.autoRenewOffset');
|
||||||
const saveCertStr = isMainInstance
|
const saveCertStr = isMainInstance
|
||||||
? async (value: TLicenseBlock) => this.saveCertStr(value)
|
? async (value: TLicenseBlock) => await this.saveCertStr(value)
|
||||||
: async () => {};
|
: async () => {};
|
||||||
const onFeatureChange = isMainInstance
|
const onFeatureChange = isMainInstance
|
||||||
? async (features: TFeatures) => this.onFeatureChange(features)
|
? async (features: TFeatures) => await this.onFeatureChange(features)
|
||||||
: async () => {};
|
: async () => {};
|
||||||
const collectUsageMetrics = isMainInstance
|
const collectUsageMetrics = isMainInstance
|
||||||
? async () => this.collectUsageMetrics()
|
? async () => await this.collectUsageMetrics()
|
||||||
: async () => [];
|
: async () => [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -78,7 +78,7 @@ export class License {
|
||||||
autoRenewOffset,
|
autoRenewOffset,
|
||||||
offlineMode,
|
offlineMode,
|
||||||
logger: this.logger,
|
logger: this.logger,
|
||||||
loadCertStr: async () => this.loadCertStr(),
|
loadCertStr: async () => await this.loadCertStr(),
|
||||||
saveCertStr,
|
saveCertStr,
|
||||||
deviceFingerprint: () => this.instanceSettings.instanceId,
|
deviceFingerprint: () => this.instanceSettings.instanceId,
|
||||||
collectUsageMetrics,
|
collectUsageMetrics,
|
||||||
|
|
|
@ -182,7 +182,7 @@ export class LoadNodesAndCredentials {
|
||||||
'node_modules',
|
'node_modules',
|
||||||
packageName,
|
packageName,
|
||||||
);
|
);
|
||||||
return this.runDirectoryLoader(PackageDirectoryLoader, finalNodeUnpackedPath);
|
return await this.runDirectoryLoader(PackageDirectoryLoader, finalNodeUnpackedPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async unloadPackage(packageName: string) {
|
async unloadPackage(packageName: string) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const isMfaFeatureEnabled = () => config.get(MFA_FEATURE_ENABLED);
|
||||||
const isMfaFeatureDisabled = () => !isMfaFeatureEnabled();
|
const isMfaFeatureDisabled = () => !isMfaFeatureEnabled();
|
||||||
|
|
||||||
const getUsersWithMfaEnabled = async () =>
|
const getUsersWithMfaEnabled = async () =>
|
||||||
Container.get(UserRepository).count({ where: { mfaEnabled: true } });
|
await Container.get(UserRepository).count({ where: { mfaEnabled: true } });
|
||||||
|
|
||||||
export const handleMfaDisable = async () => {
|
export const handleMfaDisable = async () => {
|
||||||
if (isMfaFeatureDisabled()) {
|
if (isMfaFeatureDisabled()) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class MfaService {
|
||||||
secret,
|
secret,
|
||||||
recoveryCodes,
|
recoveryCodes,
|
||||||
);
|
);
|
||||||
return this.userRepository.update(userId, {
|
return await this.userRepository.update(userId, {
|
||||||
mfaSecret: encryptedSecret,
|
mfaSecret: encryptedSecret,
|
||||||
mfaRecoveryCodes: encryptedRecoveryCodes,
|
mfaRecoveryCodes: encryptedRecoveryCodes,
|
||||||
});
|
});
|
||||||
|
|
|
@ -144,7 +144,7 @@ export const loadPublicApiVersions = async (
|
||||||
const apiRouters = await Promise.all(
|
const apiRouters = await Promise.all(
|
||||||
versions.map(async (version) => {
|
versions.map(async (version) => {
|
||||||
const openApiPath = path.join(__dirname, version, 'openapi.yml');
|
const openApiPath = path.join(__dirname, version, 'openapi.yml');
|
||||||
return createApiRouter(version, openApiPath, __dirname, publicApiEndpoint);
|
return await createApiRouter(version, openApiPath, __dirname, publicApiEndpoint);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { CredentialsRepository } from '@db/repositories/credentials.repository';
|
||||||
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
import { SharedCredentialsRepository } from '@db/repositories/sharedCredentials.repository';
|
||||||
|
|
||||||
export async function getCredentials(credentialId: string): Promise<ICredentialsDb | null> {
|
export async function getCredentials(credentialId: string): Promise<ICredentialsDb | null> {
|
||||||
return Container.get(CredentialsRepository).findOneBy({ id: credentialId });
|
return await Container.get(CredentialsRepository).findOneBy({ id: credentialId });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getSharedCredentials(
|
export async function getSharedCredentials(
|
||||||
|
@ -22,7 +22,7 @@ export async function getSharedCredentials(
|
||||||
credentialId: string,
|
credentialId: string,
|
||||||
relations?: string[],
|
relations?: string[],
|
||||||
): Promise<SharedCredentials | null> {
|
): Promise<SharedCredentials | null> {
|
||||||
return Container.get(SharedCredentialsRepository).findOne({
|
return await Container.get(SharedCredentialsRepository).findOne({
|
||||||
where: {
|
where: {
|
||||||
userId,
|
userId,
|
||||||
credentialsId: credentialId,
|
credentialsId: credentialId,
|
||||||
|
@ -64,7 +64,7 @@ export async function saveCredential(
|
||||||
|
|
||||||
await Container.get(ExternalHooks).run('credentials.create', [encryptedData]);
|
await Container.get(ExternalHooks).run('credentials.create', [encryptedData]);
|
||||||
|
|
||||||
return Db.transaction(async (transactionManager) => {
|
return await Db.transaction(async (transactionManager) => {
|
||||||
const savedCredential = await transactionManager.save<CredentialsEntity>(credential);
|
const savedCredential = await transactionManager.save<CredentialsEntity>(credential);
|
||||||
|
|
||||||
savedCredential.data = credential.data;
|
savedCredential.data = credential.data;
|
||||||
|
@ -85,7 +85,7 @@ export async function saveCredential(
|
||||||
|
|
||||||
export async function removeCredential(credentials: CredentialsEntity): Promise<ICredentialsDb> {
|
export async function removeCredential(credentials: CredentialsEntity): Promise<ICredentialsDb> {
|
||||||
await Container.get(ExternalHooks).run('credentials.delete', [credentials.id]);
|
await Container.get(ExternalHooks).run('credentials.delete', [credentials.id]);
|
||||||
return Container.get(CredentialsRepository).remove(credentials);
|
return await Container.get(CredentialsRepository).remove(credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function encryptCredential(credential: CredentialsEntity): Promise<ICredentialsDb> {
|
export async function encryptCredential(credential: CredentialsEntity): Promise<ICredentialsDb> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ export async function getUser(data: {
|
||||||
withIdentifier: string;
|
withIdentifier: string;
|
||||||
includeRole?: boolean;
|
includeRole?: boolean;
|
||||||
}): Promise<User | null> {
|
}): Promise<User | null> {
|
||||||
return Container.get(UserRepository).findOne({
|
return await Container.get(UserRepository).findOne({
|
||||||
where: {
|
where: {
|
||||||
...(uuidValidate(data.withIdentifier) && { id: data.withIdentifier }),
|
...(uuidValidate(data.withIdentifier) && { id: data.withIdentifier }),
|
||||||
...(!uuidValidate(data.withIdentifier) && { email: data.withIdentifier }),
|
...(!uuidValidate(data.withIdentifier) && { email: data.withIdentifier }),
|
||||||
|
|
|
@ -25,7 +25,7 @@ export async function getSharedWorkflow(
|
||||||
user: User,
|
user: User,
|
||||||
workflowId?: string | undefined,
|
workflowId?: string | undefined,
|
||||||
): Promise<SharedWorkflow | null> {
|
): Promise<SharedWorkflow | null> {
|
||||||
return Container.get(SharedWorkflowRepository).findOne({
|
return await Container.get(SharedWorkflowRepository).findOne({
|
||||||
where: {
|
where: {
|
||||||
...(!['owner', 'admin'].includes(user.globalRole.name) && { userId: user.id }),
|
...(!['owner', 'admin'].includes(user.globalRole.name) && { userId: user.id }),
|
||||||
...(workflowId && { workflowId }),
|
...(workflowId && { workflowId }),
|
||||||
|
@ -35,7 +35,7 @@ export async function getSharedWorkflow(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getWorkflowById(id: string): Promise<WorkflowEntity | null> {
|
export async function getWorkflowById(id: string): Promise<WorkflowEntity | null> {
|
||||||
return Container.get(WorkflowRepository).findOne({
|
return await Container.get(WorkflowRepository).findOne({
|
||||||
where: { id },
|
where: { id },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ export async function createWorkflow(
|
||||||
user: User,
|
user: User,
|
||||||
role: Role,
|
role: Role,
|
||||||
): Promise<WorkflowEntity> {
|
): Promise<WorkflowEntity> {
|
||||||
return Db.transaction(async (transactionManager) => {
|
return await Db.transaction(async (transactionManager) => {
|
||||||
const newWorkflow = new WorkflowEntity();
|
const newWorkflow = new WorkflowEntity();
|
||||||
Object.assign(newWorkflow, workflow);
|
Object.assign(newWorkflow, workflow);
|
||||||
const savedWorkflow = await transactionManager.save<WorkflowEntity>(newWorkflow);
|
const savedWorkflow = await transactionManager.save<WorkflowEntity>(newWorkflow);
|
||||||
|
@ -70,18 +70,18 @@ export async function setWorkflowAsActive(workflow: WorkflowEntity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setWorkflowAsInactive(workflow: WorkflowEntity) {
|
export async function setWorkflowAsInactive(workflow: WorkflowEntity) {
|
||||||
return Container.get(WorkflowRepository).update(workflow.id, {
|
return await Container.get(WorkflowRepository).update(workflow.id, {
|
||||||
active: false,
|
active: false,
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteWorkflow(workflow: WorkflowEntity): Promise<WorkflowEntity> {
|
export async function deleteWorkflow(workflow: WorkflowEntity): Promise<WorkflowEntity> {
|
||||||
return Container.get(WorkflowRepository).remove(workflow);
|
return await Container.get(WorkflowRepository).remove(workflow);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateWorkflow(workflowId: string, updateData: WorkflowEntity) {
|
export async function updateWorkflow(workflowId: string, updateData: WorkflowEntity) {
|
||||||
return Container.get(WorkflowRepository).update(workflowId, updateData);
|
return await Container.get(WorkflowRepository).update(workflowId, updateData);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parseTagNames(tags: string): string[] {
|
export function parseTagNames(tags: string): string[] {
|
||||||
|
|
|
@ -74,27 +74,27 @@ export class Queue {
|
||||||
}
|
}
|
||||||
|
|
||||||
async add(jobData: JobData, jobOptions: object): Promise<Job> {
|
async add(jobData: JobData, jobOptions: object): Promise<Job> {
|
||||||
return this.jobQueue.add(jobData, jobOptions);
|
return await this.jobQueue.add(jobData, jobOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getJob(jobId: JobId): Promise<Job | null> {
|
async getJob(jobId: JobId): Promise<Job | null> {
|
||||||
return this.jobQueue.getJob(jobId);
|
return await this.jobQueue.getJob(jobId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getJobs(jobTypes: Bull.JobStatus[]): Promise<Job[]> {
|
async getJobs(jobTypes: Bull.JobStatus[]): Promise<Job[]> {
|
||||||
return this.jobQueue.getJobs(jobTypes);
|
return await this.jobQueue.getJobs(jobTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
async process(concurrency: number, fn: Bull.ProcessCallbackFunction<JobData>): Promise<void> {
|
async process(concurrency: number, fn: Bull.ProcessCallbackFunction<JobData>): Promise<void> {
|
||||||
return this.jobQueue.process(concurrency, fn);
|
return await this.jobQueue.process(concurrency, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
async ping(): Promise<string> {
|
async ping(): Promise<string> {
|
||||||
return this.jobQueue.client.ping();
|
return await this.jobQueue.client.ping();
|
||||||
}
|
}
|
||||||
|
|
||||||
async pause(isLocal?: boolean): Promise<void> {
|
async pause(isLocal?: boolean): Promise<void> {
|
||||||
return this.jobQueue.pause(isLocal);
|
return await this.jobQueue.pause(isLocal);
|
||||||
}
|
}
|
||||||
|
|
||||||
getBullObjectInstance(): JobQueue {
|
getBullObjectInstance(): JobQueue {
|
||||||
|
|
|
@ -209,8 +209,9 @@ export class Server extends AbstractServer {
|
||||||
order: { createdAt: 'ASC' },
|
order: { createdAt: 'ASC' },
|
||||||
where: {},
|
where: {},
|
||||||
})
|
})
|
||||||
.then(async (workflow) =>
|
.then(
|
||||||
Container.get(InternalHooks).onServerStarted(diagnosticInfo, workflow?.createdAt),
|
async (workflow) =>
|
||||||
|
await Container.get(InternalHooks).onServerStarted(diagnosticInfo, workflow?.createdAt),
|
||||||
);
|
);
|
||||||
|
|
||||||
Container.get(CollaborationService);
|
Container.get(CollaborationService);
|
||||||
|
|
|
@ -101,7 +101,7 @@ export class TestWebhooks implements IWebhookManager {
|
||||||
throw new NotFoundError('Could not find node to process webhook.');
|
throw new NotFoundError('Could not find node to process webhook.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(async (resolve, reject) => {
|
return await new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const executionMode = 'manual';
|
const executionMode = 'manual';
|
||||||
const executionId = await WebhookHelpers.executeWebhook(
|
const executionId = await WebhookHelpers.executeWebhook(
|
||||||
|
@ -229,7 +229,10 @@ export class TestWebhooks implements IWebhookManager {
|
||||||
return false; // no webhooks found to start a workflow
|
return false; // no webhooks found to start a workflow
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeout = setTimeout(async () => this.cancelWebhook(workflow.id), TEST_WEBHOOK_TIMEOUT);
|
const timeout = setTimeout(
|
||||||
|
async () => await this.cancelWebhook(workflow.id),
|
||||||
|
TEST_WEBHOOK_TIMEOUT,
|
||||||
|
);
|
||||||
|
|
||||||
for (const webhook of webhooks) {
|
for (const webhook of webhooks) {
|
||||||
const key = this.registrations.toKey(webhook);
|
const key = this.registrations.toKey(webhook);
|
||||||
|
|
|
@ -53,7 +53,7 @@ export class UserManagementMailer {
|
||||||
async verifyConnection(): Promise<void> {
|
async verifyConnection(): Promise<void> {
|
||||||
if (!this.mailer) throw new ApplicationError('No mailer configured.');
|
if (!this.mailer) throw new ApplicationError('No mailer configured.');
|
||||||
|
|
||||||
return this.mailer.verifyConnection();
|
return await this.mailer.verifyConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
async invite(inviteEmailData: InviteEmailData): Promise<SendEmailResult> {
|
async invite(inviteEmailData: InviteEmailData): Promise<SendEmailResult> {
|
||||||
|
|
|
@ -122,7 +122,7 @@ export class WaitingWebhooks implements IWebhookManager {
|
||||||
|
|
||||||
const runExecutionData = execution.data;
|
const runExecutionData = execution.data;
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
const executionMode = 'webhook';
|
const executionMode = 'webhook';
|
||||||
void WebhookHelpers.executeWebhook(
|
void WebhookHelpers.executeWebhook(
|
||||||
workflow,
|
workflow,
|
||||||
|
|
|
@ -417,14 +417,15 @@ export class WorkflowRunner {
|
||||||
fullRunData.status = this.activeExecutions.getStatus(executionId);
|
fullRunData.status = this.activeExecutions.getStatus(executionId);
|
||||||
this.activeExecutions.remove(executionId, fullRunData);
|
this.activeExecutions.remove(executionId, fullRunData);
|
||||||
})
|
})
|
||||||
.catch(async (error) =>
|
.catch(
|
||||||
this.processError(
|
async (error) =>
|
||||||
error,
|
await this.processError(
|
||||||
new Date(),
|
error,
|
||||||
data.executionMode,
|
new Date(),
|
||||||
executionId,
|
data.executionMode,
|
||||||
additionalData.hooks,
|
executionId,
|
||||||
),
|
additionalData.hooks,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.processError(
|
await this.processError(
|
||||||
|
|
|
@ -276,7 +276,7 @@ class WorkflowRunnerProcess {
|
||||||
this.data.executionMode,
|
this.data.executionMode,
|
||||||
this.data.executionData,
|
this.data.executionData,
|
||||||
);
|
);
|
||||||
return this.workflowExecute.processRunExecutionData(this.workflow);
|
return await this.workflowExecute.processRunExecutionData(this.workflow);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
this.data.runData === undefined ||
|
this.data.runData === undefined ||
|
||||||
|
@ -289,7 +289,7 @@ class WorkflowRunnerProcess {
|
||||||
|
|
||||||
// Can execute without webhook so go on
|
// Can execute without webhook so go on
|
||||||
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode);
|
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode);
|
||||||
return this.workflowExecute.run(
|
return await this.workflowExecute.run(
|
||||||
this.workflow,
|
this.workflow,
|
||||||
startNode,
|
startNode,
|
||||||
this.data.destinationNode,
|
this.data.destinationNode,
|
||||||
|
@ -298,7 +298,7 @@ class WorkflowRunnerProcess {
|
||||||
}
|
}
|
||||||
// Execute only the nodes between start and destination nodes
|
// Execute only the nodes between start and destination nodes
|
||||||
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode);
|
this.workflowExecute = new WorkflowExecute(additionalData, this.data.executionMode);
|
||||||
return this.workflowExecute.runPartialWorkflow(
|
return await this.workflowExecute.runPartialWorkflow(
|
||||||
this.workflow,
|
this.workflow,
|
||||||
this.data.runData,
|
this.data.runData,
|
||||||
this.data.startNodes,
|
this.data.startNodes,
|
||||||
|
@ -383,7 +383,7 @@ class WorkflowRunnerProcess {
|
||||||
* @param {*} data The data
|
* @param {*} data The data
|
||||||
*/
|
*/
|
||||||
async function sendToParentProcess(type: string, data: any): Promise<void> {
|
async function sendToParentProcess(type: string, data: any): Promise<void> {
|
||||||
return new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
process.send!(
|
process.send!(
|
||||||
{
|
{
|
||||||
type,
|
type,
|
||||||
|
|
|
@ -80,7 +80,7 @@ export async function resolveJwt(token: string): Promise<User> {
|
||||||
const jwtPayload: JwtPayload = Container.get(JwtService).verify(token, {
|
const jwtPayload: JwtPayload = Container.get(JwtService).verify(token, {
|
||||||
algorithms: ['HS256'],
|
algorithms: ['HS256'],
|
||||||
});
|
});
|
||||||
return resolveJwtContent(jwtPayload);
|
return await resolveJwtContent(jwtPayload);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function issueCookie(res: Response, user: User): Promise<void> {
|
export async function issueCookie(res: Response, user: User): Promise<void> {
|
||||||
|
|
|
@ -59,8 +59,8 @@ export abstract class BaseCommand extends Command {
|
||||||
this.nodeTypes = Container.get(NodeTypes);
|
this.nodeTypes = Container.get(NodeTypes);
|
||||||
await Container.get(LoadNodesAndCredentials).init();
|
await Container.get(LoadNodesAndCredentials).init();
|
||||||
|
|
||||||
await Db.init().catch(async (error: Error) =>
|
await Db.init().catch(
|
||||||
this.exitWithCrash('There was an error initializing DB', error),
|
async (error: Error) => await this.exitWithCrash('There was an error initializing DB', error),
|
||||||
);
|
);
|
||||||
|
|
||||||
// This needs to happen after DB.init() or otherwise DB Connection is not
|
// This needs to happen after DB.init() or otherwise DB Connection is not
|
||||||
|
@ -71,8 +71,9 @@ export abstract class BaseCommand extends Command {
|
||||||
|
|
||||||
await this.server?.init();
|
await this.server?.init();
|
||||||
|
|
||||||
await Db.migrate().catch(async (error: Error) =>
|
await Db.migrate().catch(
|
||||||
this.exitWithCrash('There was an error running database migrations', error),
|
async (error: Error) =>
|
||||||
|
await this.exitWithCrash('There was an error running database migrations', error),
|
||||||
);
|
);
|
||||||
|
|
||||||
const dbType = config.getEnv('database.type');
|
const dbType = config.getEnv('database.type');
|
||||||
|
|
|
@ -120,7 +120,7 @@ export class ExecuteBatch extends BaseCommand {
|
||||||
const activeExecutionsInstance = Container.get(ActiveExecutions);
|
const activeExecutionsInstance = Container.get(ActiveExecutions);
|
||||||
const stopPromises = activeExecutionsInstance
|
const stopPromises = activeExecutionsInstance
|
||||||
.getActiveExecutions()
|
.getActiveExecutions()
|
||||||
.map(async (execution) => activeExecutionsInstance.stopExecution(execution.id));
|
.map(async (execution) => await activeExecutionsInstance.stopExecution(execution.id));
|
||||||
|
|
||||||
await Promise.allSettled(stopPromises);
|
await Promise.allSettled(stopPromises);
|
||||||
|
|
||||||
|
@ -410,7 +410,7 @@ export class ExecuteBatch extends BaseCommand {
|
||||||
this.initializeLogs();
|
this.initializeLogs();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise(async (res) => {
|
return await new Promise(async (res) => {
|
||||||
const promisesArray = [];
|
const promisesArray = [];
|
||||||
for (let i = 0; i < ExecuteBatch.concurrency; i++) {
|
for (let i = 0; i < ExecuteBatch.concurrency; i++) {
|
||||||
const promise = new Promise(async (resolve) => {
|
const promise = new Promise(async (resolve) => {
|
||||||
|
@ -623,7 +623,7 @@ export class ExecuteBatch extends BaseCommand {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise(async (resolve) => {
|
return await new Promise(async (resolve) => {
|
||||||
let gotCancel = false;
|
let gotCancel = false;
|
||||||
|
|
||||||
// Timeouts execution after 5 minutes.
|
// Timeouts execution after 5 minutes.
|
||||||
|
|
|
@ -174,7 +174,7 @@ export class Start extends BaseCommand {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
streams.push(createWriteStream(destFile, 'utf-8'));
|
streams.push(createWriteStream(destFile, 'utf-8'));
|
||||||
return pipeline(streams);
|
return await pipeline(streams);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ export class Reset extends BaseCommand {
|
||||||
|
|
||||||
await Container.get(UserRepository).save(user);
|
await Container.get(UserRepository).save(user);
|
||||||
|
|
||||||
return Container.get(UserRepository).findOneByOrFail({ globalRoleId: globalRole.id });
|
return await Container.get(UserRepository).findOneByOrFail({ globalRoleId: globalRole.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
async catch(error: Error): Promise<void> {
|
async catch(error: Error): Promise<void> {
|
||||||
|
|
|
@ -345,8 +345,9 @@ export class Worker extends BaseCommand {
|
||||||
Worker.jobQueue = Container.get(Queue);
|
Worker.jobQueue = Container.get(Queue);
|
||||||
await Worker.jobQueue.init();
|
await Worker.jobQueue.init();
|
||||||
this.logger.debug('Queue singleton ready');
|
this.logger.debug('Queue singleton ready');
|
||||||
void Worker.jobQueue.process(flags.concurrency, async (job) =>
|
void Worker.jobQueue.process(
|
||||||
this.runJob(job, this.nodeTypes),
|
flags.concurrency,
|
||||||
|
async (job) => await this.runJob(job, this.nodeTypes),
|
||||||
);
|
);
|
||||||
|
|
||||||
Worker.jobQueue.getBullObjectInstance().on('global:progress', (jobId: JobId, progress) => {
|
Worker.jobQueue.getBullObjectInstance().on('global:progress', (jobId: JobId, progress) => {
|
||||||
|
|
|
@ -9,7 +9,7 @@ export class ActiveWorkflowsController {
|
||||||
|
|
||||||
@Get('/')
|
@Get('/')
|
||||||
async getActiveWorkflows(req: ActiveWorkflowRequest.GetAllActive) {
|
async getActiveWorkflows(req: ActiveWorkflowRequest.GetAllActive) {
|
||||||
return this.activeWorkflowsService.getAllActiveIdsFor(req.user);
|
return await this.activeWorkflowsService.getAllActiveIdsFor(req.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/error/:id')
|
@Get('/error/:id')
|
||||||
|
@ -18,6 +18,6 @@ export class ActiveWorkflowsController {
|
||||||
user,
|
user,
|
||||||
params: { id: workflowId },
|
params: { id: workflowId },
|
||||||
} = req;
|
} = req;
|
||||||
return this.activeWorkflowsService.getActivationError(workflowId, user);
|
return await this.activeWorkflowsService.getActivationError(workflowId, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ export class AuthController {
|
||||||
authenticationMethod: usedAuthenticationMethod,
|
authenticationMethod: usedAuthenticationMethod,
|
||||||
});
|
});
|
||||||
|
|
||||||
return this.userService.toPublic(user, { posthog: this.postHog, withScopes: true });
|
return await this.userService.toPublic(user, { posthog: this.postHog, withScopes: true });
|
||||||
}
|
}
|
||||||
void this.internalHooks.onUserLoginFailed({
|
void this.internalHooks.onUserLoginFailed({
|
||||||
user: email,
|
user: email,
|
||||||
|
@ -150,7 +150,7 @@ export class AuthController {
|
||||||
}
|
}
|
||||||
|
|
||||||
await issueCookie(res, user);
|
await issueCookie(res, user);
|
||||||
return this.userService.toPublic(user, { posthog: this.postHog, withScopes: true });
|
return await this.userService.toPublic(user, { posthog: this.postHog, withScopes: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -57,7 +57,7 @@ export class DynamicNodeParametersController {
|
||||||
const additionalData = await getBase(req.user.id, currentNodeParameters);
|
const additionalData = await getBase(req.user.id, currentNodeParameters);
|
||||||
|
|
||||||
if (methodName) {
|
if (methodName) {
|
||||||
return this.service.getOptionsViaMethodName(
|
return await this.service.getOptionsViaMethodName(
|
||||||
methodName,
|
methodName,
|
||||||
path,
|
path,
|
||||||
additionalData,
|
additionalData,
|
||||||
|
@ -68,7 +68,7 @@ export class DynamicNodeParametersController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loadOptions) {
|
if (loadOptions) {
|
||||||
return this.service.getOptionsViaLoadOptions(
|
return await this.service.getOptionsViaLoadOptions(
|
||||||
jsonParse(loadOptions),
|
jsonParse(loadOptions),
|
||||||
additionalData,
|
additionalData,
|
||||||
nodeTypeAndVersion,
|
nodeTypeAndVersion,
|
||||||
|
@ -87,7 +87,7 @@ export class DynamicNodeParametersController {
|
||||||
const { path, methodName, filter, paginationToken } = req.query;
|
const { path, methodName, filter, paginationToken } = req.query;
|
||||||
const { credentials, currentNodeParameters, nodeTypeAndVersion } = req.params;
|
const { credentials, currentNodeParameters, nodeTypeAndVersion } = req.params;
|
||||||
const additionalData = await getBase(req.user.id, currentNodeParameters);
|
const additionalData = await getBase(req.user.id, currentNodeParameters);
|
||||||
return this.service.getResourceLocatorResults(
|
return await this.service.getResourceLocatorResults(
|
||||||
methodName,
|
methodName,
|
||||||
path,
|
path,
|
||||||
additionalData,
|
additionalData,
|
||||||
|
@ -106,7 +106,7 @@ export class DynamicNodeParametersController {
|
||||||
const { path, methodName } = req.query;
|
const { path, methodName } = req.query;
|
||||||
const { credentials, currentNodeParameters, nodeTypeAndVersion } = req.params;
|
const { credentials, currentNodeParameters, nodeTypeAndVersion } = req.params;
|
||||||
const additionalData = await getBase(req.user.id, currentNodeParameters);
|
const additionalData = await getBase(req.user.id, currentNodeParameters);
|
||||||
return this.service.getResourceMappingFields(
|
return await this.service.getResourceMappingFields(
|
||||||
methodName,
|
methodName,
|
||||||
path,
|
path,
|
||||||
additionalData,
|
additionalData,
|
||||||
|
|
|
@ -177,6 +177,9 @@ export class InvitationController {
|
||||||
await this.externalHooks.run('user.profile.update', [invitee.email, publicInvitee]);
|
await this.externalHooks.run('user.profile.update', [invitee.email, publicInvitee]);
|
||||||
await this.externalHooks.run('user.password.update', [invitee.email, invitee.password]);
|
await this.externalHooks.run('user.password.update', [invitee.email, invitee.password]);
|
||||||
|
|
||||||
return this.userService.toPublic(updatedUser, { posthog: this.postHog, withScopes: true });
|
return await this.userService.toPublic(updatedUser, {
|
||||||
|
posthog: this.postHog,
|
||||||
|
withScopes: true,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,8 @@ export class NodeTypesController {
|
||||||
|
|
||||||
const nodeTypes: INodeTypeDescription[] = [];
|
const nodeTypes: INodeTypeDescription[] = [];
|
||||||
|
|
||||||
const promises = nodeInfos.map(async ({ name, version }) =>
|
const promises = nodeInfos.map(
|
||||||
populateTranslation(name, version, nodeTypes),
|
async ({ name, version }) => await populateTranslation(name, version, nodeTypes),
|
||||||
);
|
);
|
||||||
|
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
|
|
@ -61,14 +61,14 @@ export abstract class AbstractOAuthController {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getAdditionalData(user: User) {
|
protected async getAdditionalData(user: User) {
|
||||||
return WorkflowExecuteAdditionalData.getBase(user.id);
|
return await WorkflowExecuteAdditionalData.getBase(user.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getDecryptedData(
|
protected async getDecryptedData(
|
||||||
credential: ICredentialsDb,
|
credential: ICredentialsDb,
|
||||||
additionalData: IWorkflowExecuteAdditionalData,
|
additionalData: IWorkflowExecuteAdditionalData,
|
||||||
) {
|
) {
|
||||||
return this.credentialsHelper.getDecrypted(
|
return await this.credentialsHelper.getDecrypted(
|
||||||
additionalData,
|
additionalData,
|
||||||
credential,
|
credential,
|
||||||
credential.type,
|
credential.type,
|
||||||
|
@ -105,6 +105,6 @@ export abstract class AbstractOAuthController {
|
||||||
|
|
||||||
/** Get a credential without user check */
|
/** Get a credential without user check */
|
||||||
protected async getCredentialWithoutUser(credentialId: string): Promise<ICredentialsDb | null> {
|
protected async getCredentialWithoutUser(credentialId: string): Promise<ICredentialsDb | null> {
|
||||||
return this.credentialsRepository.findOneBy({ id: credentialId });
|
return await this.credentialsRepository.findOneBy({ id: credentialId });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,20 +20,20 @@ export class OrchestrationController {
|
||||||
async getWorkersStatus(req: OrchestrationRequest.Get) {
|
async getWorkersStatus(req: OrchestrationRequest.Get) {
|
||||||
if (!this.licenseService.isWorkerViewLicensed()) return;
|
if (!this.licenseService.isWorkerViewLicensed()) return;
|
||||||
const id = req.params.id;
|
const id = req.params.id;
|
||||||
return this.singleMainSetup.getWorkerStatus(id);
|
return await this.singleMainSetup.getWorkerStatus(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequireGlobalScope('orchestration:read')
|
@RequireGlobalScope('orchestration:read')
|
||||||
@Post('/worker/status')
|
@Post('/worker/status')
|
||||||
async getWorkersStatusAll() {
|
async getWorkersStatusAll() {
|
||||||
if (!this.licenseService.isWorkerViewLicensed()) return;
|
if (!this.licenseService.isWorkerViewLicensed()) return;
|
||||||
return this.singleMainSetup.getWorkerStatus();
|
return await this.singleMainSetup.getWorkerStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequireGlobalScope('orchestration:list')
|
@RequireGlobalScope('orchestration:list')
|
||||||
@Post('/worker/ids')
|
@Post('/worker/ids')
|
||||||
async getWorkerIdsAll() {
|
async getWorkerIdsAll() {
|
||||||
if (!this.licenseService.isWorkerViewLicensed()) return;
|
if (!this.licenseService.isWorkerViewLicensed()) return;
|
||||||
return this.singleMainSetup.getWorkerIds();
|
return await this.singleMainSetup.getWorkerIds();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ export class OwnerController {
|
||||||
|
|
||||||
void this.internalHooks.onInstanceOwnerSetup({ user_id: userId });
|
void this.internalHooks.onInstanceOwnerSetup({ user_id: userId });
|
||||||
|
|
||||||
return this.userService.toPublic(owner, { posthog: this.postHog, withScopes: true });
|
return await this.userService.toPublic(owner, { posthog: this.postHog, withScopes: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/dismiss-banner')
|
@Post('/dismiss-banner')
|
||||||
|
|
|
@ -32,7 +32,7 @@ export class TagsController {
|
||||||
@Get('/')
|
@Get('/')
|
||||||
@RequireGlobalScope('tag:list')
|
@RequireGlobalScope('tag:list')
|
||||||
async getAll(req: TagsRequest.GetAll) {
|
async getAll(req: TagsRequest.GetAll) {
|
||||||
return this.tagService.getAll({ withUsageCount: req.query.withUsageCount === 'true' });
|
return await this.tagService.getAll({ withUsageCount: req.query.withUsageCount === 'true' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/')
|
@Post('/')
|
||||||
|
@ -40,7 +40,7 @@ export class TagsController {
|
||||||
async createTag(req: TagsRequest.Create) {
|
async createTag(req: TagsRequest.Create) {
|
||||||
const tag = this.tagService.toEntity({ name: req.body.name });
|
const tag = this.tagService.toEntity({ name: req.body.name });
|
||||||
|
|
||||||
return this.tagService.save(tag, 'create');
|
return await this.tagService.save(tag, 'create');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch('/:id(\\w+)')
|
@Patch('/:id(\\w+)')
|
||||||
|
@ -48,7 +48,7 @@ export class TagsController {
|
||||||
async updateTag(req: TagsRequest.Update) {
|
async updateTag(req: TagsRequest.Update) {
|
||||||
const newTag = this.tagService.toEntity({ id: req.params.id, name: req.body.name.trim() });
|
const newTag = this.tagService.toEntity({ id: req.params.id, name: req.body.name.trim() });
|
||||||
|
|
||||||
return this.tagService.save(newTag, 'update');
|
return await this.tagService.save(newTag, 'update');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete('/:id(\\w+)')
|
@Delete('/:id(\\w+)')
|
||||||
|
|
|
@ -102,8 +102,9 @@ export class UsersController {
|
||||||
const users = await this.userRepository.find(findManyOptions);
|
const users = await this.userRepository.find(findManyOptions);
|
||||||
|
|
||||||
const publicUsers: Array<Partial<PublicUser>> = await Promise.all(
|
const publicUsers: Array<Partial<PublicUser>> = await Promise.all(
|
||||||
users.map(async (u) =>
|
users.map(
|
||||||
this.userService.toPublic(u, { withInviteUrl: true, inviterId: req.user.id }),
|
async (u) =>
|
||||||
|
await this.userService.toPublic(u, { withInviteUrl: true, inviterId: req.user.id }),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -49,12 +49,12 @@ export class WorkflowStatisticsController {
|
||||||
|
|
||||||
@Get('/:id/counts/')
|
@Get('/:id/counts/')
|
||||||
async getCounts(req: ExecutionRequest.Get): Promise<WorkflowStatisticsData<number>> {
|
async getCounts(req: ExecutionRequest.Get): Promise<WorkflowStatisticsData<number>> {
|
||||||
return this.getData(req.params.id, 'count', 0);
|
return await this.getData(req.params.id, 'count', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/:id/times/')
|
@Get('/:id/times/')
|
||||||
async getTimes(req: ExecutionRequest.Get): Promise<WorkflowStatisticsData<Date | null>> {
|
async getTimes(req: ExecutionRequest.Get): Promise<WorkflowStatisticsData<Date | null>> {
|
||||||
return this.getData(req.params.id, 'latestEvent', null);
|
return await this.getData(req.params.id, 'latestEvent', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/:id/data-loaded/')
|
@Get('/:id/data-loaded/')
|
||||||
|
|
|
@ -102,7 +102,7 @@ EECredentialsController.post(
|
||||||
mergedCredentials.data = EECredentials.unredact(mergedCredentials.data, decryptedData);
|
mergedCredentials.data = EECredentials.unredact(mergedCredentials.data, decryptedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EECredentials.test(req.user, mergedCredentials);
|
return await EECredentials.test(req.user, mergedCredentials);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ credentialsController.get(
|
||||||
'/',
|
'/',
|
||||||
listQueryMiddleware,
|
listQueryMiddleware,
|
||||||
ResponseHelper.send(async (req: ListQuery.Request) => {
|
ResponseHelper.send(async (req: ListQuery.Request) => {
|
||||||
return CredentialsService.getMany(req.user, { listQueryOptions: req.listQueryOptions });
|
return await CredentialsService.getMany(req.user, { listQueryOptions: req.listQueryOptions });
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ credentialsController.post(
|
||||||
mergedCredentials.data = CredentialsService.unredact(mergedCredentials.data, decryptedData);
|
mergedCredentials.data = CredentialsService.unredact(mergedCredentials.data, decryptedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CredentialsService.test(req.user, mergedCredentials);
|
return await CredentialsService.test(req.user, mergedCredentials);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class EECredentialsService extends CredentialsService {
|
||||||
where.userId = user.id;
|
where.userId = user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Container.get(SharedCredentialsRepository).findOne({
|
return await Container.get(SharedCredentialsRepository).findOne({
|
||||||
where,
|
where,
|
||||||
relations,
|
relations,
|
||||||
});
|
});
|
||||||
|
@ -79,6 +79,6 @@ export class EECredentialsService extends CredentialsService {
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
return transaction.save(newSharedCredentials);
|
return await transaction.save(newSharedCredentials);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ export type CredentialsGetSharedOptions =
|
||||||
|
|
||||||
export class CredentialsService {
|
export class CredentialsService {
|
||||||
static async get(where: FindOptionsWhere<ICredentialsDb>, options?: { relations: string[] }) {
|
static async get(where: FindOptionsWhere<ICredentialsDb>, options?: { relations: string[] }) {
|
||||||
return Container.get(CredentialsRepository).findOne({
|
return await Container.get(CredentialsRepository).findOne({
|
||||||
relations: options?.relations,
|
relations: options?.relations,
|
||||||
where,
|
where,
|
||||||
});
|
});
|
||||||
|
@ -94,7 +94,7 @@ export class CredentialsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Container.get(SharedCredentialsRepository).findOne({ where, relations });
|
return await Container.get(SharedCredentialsRepository).findOne({ where, relations });
|
||||||
}
|
}
|
||||||
|
|
||||||
static async prepareCreateData(
|
static async prepareCreateData(
|
||||||
|
@ -180,7 +180,7 @@ export class CredentialsService {
|
||||||
|
|
||||||
// We sadly get nothing back from "update". Neither if it updated a record
|
// We sadly get nothing back from "update". Neither if it updated a record
|
||||||
// nor the new value. So query now the updated entry.
|
// nor the new value. So query now the updated entry.
|
||||||
return Container.get(CredentialsRepository).findOneBy({ id: credentialId });
|
return await Container.get(CredentialsRepository).findOneBy({ id: credentialId });
|
||||||
}
|
}
|
||||||
|
|
||||||
static async save(
|
static async save(
|
||||||
|
@ -231,7 +231,7 @@ export class CredentialsService {
|
||||||
credentials: ICredentialsDecrypted,
|
credentials: ICredentialsDecrypted,
|
||||||
): Promise<INodeCredentialTestResult> {
|
): Promise<INodeCredentialTestResult> {
|
||||||
const helper = Container.get(CredentialsHelper);
|
const helper = Container.get(CredentialsHelper);
|
||||||
return helper.testCredentials(user, credentials.type, credentials);
|
return await helper.testCredentials(user, credentials.type, credentials);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take data and replace all sensitive values with a sentinel value.
|
// Take data and replace all sensitive values with a sentinel value.
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class CreateIndex extends IndexOperation {
|
||||||
|
|
||||||
async execute(queryRunner: QueryRunner) {
|
async execute(queryRunner: QueryRunner) {
|
||||||
const { columnNames, isUnique } = this;
|
const { columnNames, isUnique } = this;
|
||||||
return queryRunner.createIndex(
|
return await queryRunner.createIndex(
|
||||||
this.fullTableName,
|
this.fullTableName,
|
||||||
new TableIndex({ name: this.customIndexName ?? this.fullIndexName, columnNames, isUnique }),
|
new TableIndex({ name: this.customIndexName ?? this.fullIndexName, columnNames, isUnique }),
|
||||||
);
|
);
|
||||||
|
@ -49,6 +49,9 @@ export class CreateIndex extends IndexOperation {
|
||||||
|
|
||||||
export class DropIndex extends IndexOperation {
|
export class DropIndex extends IndexOperation {
|
||||||
async execute(queryRunner: QueryRunner) {
|
async execute(queryRunner: QueryRunner) {
|
||||||
return queryRunner.dropIndex(this.fullTableName, this.customIndexName ?? this.fullIndexName);
|
return await queryRunner.dropIndex(
|
||||||
|
this.fullTableName,
|
||||||
|
this.customIndexName ?? this.fullIndexName,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ export class CreateTable extends TableOperation {
|
||||||
async execute(queryRunner: QueryRunner) {
|
async execute(queryRunner: QueryRunner) {
|
||||||
const { driver } = queryRunner.connection;
|
const { driver } = queryRunner.connection;
|
||||||
const { columns, tableName: name, prefix, indices, foreignKeys } = this;
|
const { columns, tableName: name, prefix, indices, foreignKeys } = this;
|
||||||
return queryRunner.createTable(
|
return await queryRunner.createTable(
|
||||||
new Table({
|
new Table({
|
||||||
name: `${prefix}${name}`,
|
name: `${prefix}${name}`,
|
||||||
columns: columns.map((c) => c.toOptions(driver)),
|
columns: columns.map((c) => c.toOptions(driver)),
|
||||||
|
@ -78,7 +78,7 @@ export class CreateTable extends TableOperation {
|
||||||
export class DropTable extends TableOperation {
|
export class DropTable extends TableOperation {
|
||||||
async execute(queryRunner: QueryRunner) {
|
async execute(queryRunner: QueryRunner) {
|
||||||
const { tableName: name, prefix } = this;
|
const { tableName: name, prefix } = this;
|
||||||
return queryRunner.dropTable(`${prefix}${name}`, true);
|
return await queryRunner.dropTable(`${prefix}${name}`, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export class AddColumns extends TableOperation {
|
||||||
async execute(queryRunner: QueryRunner) {
|
async execute(queryRunner: QueryRunner) {
|
||||||
const { driver } = queryRunner.connection;
|
const { driver } = queryRunner.connection;
|
||||||
const { tableName, prefix, columns } = this;
|
const { tableName, prefix, columns } = this;
|
||||||
return queryRunner.addColumns(
|
return await queryRunner.addColumns(
|
||||||
`${prefix}${tableName}`,
|
`${prefix}${tableName}`,
|
||||||
columns.map((c) => new TableColumn(c.toOptions(driver))),
|
columns.map((c) => new TableColumn(c.toOptions(driver))),
|
||||||
);
|
);
|
||||||
|
@ -114,7 +114,7 @@ export class DropColumns extends TableOperation {
|
||||||
|
|
||||||
async execute(queryRunner: QueryRunner) {
|
async execute(queryRunner: QueryRunner) {
|
||||||
const { tableName, prefix, columnNames } = this;
|
const { tableName, prefix, columnNames } = this;
|
||||||
return queryRunner.dropColumns(`${prefix}${tableName}`, columnNames);
|
return await queryRunner.dropColumns(`${prefix}${tableName}`, columnNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ class ModifyNotNull extends TableOperation {
|
||||||
const oldColumn = table.findColumnByName(columnName)!;
|
const oldColumn = table.findColumnByName(columnName)!;
|
||||||
const newColumn = oldColumn.clone();
|
const newColumn = oldColumn.clone();
|
||||||
newColumn.isNullable = isNullable;
|
newColumn.isNullable = isNullable;
|
||||||
return queryRunner.changeColumn(table, oldColumn, newColumn);
|
return await queryRunner.changeColumn(table, oldColumn, newColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class UniqueWorkflowNames1620821879465 implements ReversibleMigration {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
duplicates.map(async (workflow, index) => {
|
duplicates.map(async (workflow, index) => {
|
||||||
if (index === 0) return;
|
if (index === 0) return;
|
||||||
return runQuery(`UPDATE ${tableName} SET name = :name WHERE id = :id`, {
|
return await runQuery(`UPDATE ${tableName} SET name = :name WHERE id = :id`, {
|
||||||
name: `${workflow.name} ${index + 1}`,
|
name: `${workflow.name} ${index + 1}`,
|
||||||
id: workflow.id,
|
id: workflow.id,
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,11 +26,12 @@ export class AddJsonKeyPinData1659888469333 implements IrreversibleMigration {
|
||||||
const selectQuery = `SELECT id, ${columnName} FROM ${tableName} WHERE ${columnName} IS NOT NULL`;
|
const selectQuery = `SELECT id, ${columnName} FROM ${tableName} WHERE ${columnName} IS NOT NULL`;
|
||||||
await runInBatches<Workflow>(selectQuery, async (workflows) => {
|
await runInBatches<Workflow>(selectQuery, async (workflows) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
this.makeUpdateParams(workflows).map(async (workflow) =>
|
this.makeUpdateParams(workflows).map(
|
||||||
runQuery(`UPDATE ${tableName} SET ${columnName} = :pinData WHERE id = :id;`, {
|
async (workflow) =>
|
||||||
pinData: workflow.pinData,
|
await runQuery(`UPDATE ${tableName} SET ${columnName} = :pinData WHERE id = :id;`, {
|
||||||
id: workflow.id,
|
pinData: workflow.pinData,
|
||||||
}),
|
id: workflow.id,
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,13 +18,13 @@ export class RemoveWorkflowDataLoadedFlag1671726148419 implements ReversibleMigr
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
workflowIds.map(
|
workflowIds.map(
|
||||||
async ({ id, dataLoaded }) =>
|
async ({ id, dataLoaded }) =>
|
||||||
dataLoaded &&
|
await (dataLoaded &&
|
||||||
runQuery(
|
runQuery(
|
||||||
`INSERT INTO ${statisticsTableName}
|
`INSERT INTO ${statisticsTableName}
|
||||||
(${escape.columnName('workflowId')}, name, count, ${escape.columnName('latestEvent')})
|
(${escape.columnName('workflowId')}, name, count, ${escape.columnName('latestEvent')})
|
||||||
VALUES (:id, :name, 1, ${now})`,
|
VALUES (:id, :name, 1, ${now})`,
|
||||||
{ id, name: StatisticsNames.dataLoaded },
|
{ id, name: StatisticsNames.dataLoaded },
|
||||||
),
|
)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -47,10 +47,11 @@ export class RemoveWorkflowDataLoadedFlag1671726148419 implements ReversibleMigr
|
||||||
);
|
);
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
workflowsIds.map(async ({ workflowId }) =>
|
workflowsIds.map(
|
||||||
runQuery(`UPDATE ${workflowTableName} SET ${columnName} = true WHERE id = :id`, {
|
async ({ workflowId }) =>
|
||||||
id: workflowId,
|
await runQuery(`UPDATE ${workflowTableName} SET ${columnName} = true WHERE id = :id`, {
|
||||||
}),
|
id: workflowId,
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -47,10 +47,13 @@ export class PurgeInvalidWorkflowConnections1675940580449 implements Irreversibl
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update database with new connections
|
// Update database with new connections
|
||||||
return runQuery(`UPDATE ${workflowsTable} SET connections = :connections WHERE id = :id`, {
|
return await runQuery(
|
||||||
connections: JSON.stringify(connections),
|
`UPDATE ${workflowsTable} SET connections = :connections WHERE id = :id`,
|
||||||
id: workflow.id,
|
{
|
||||||
});
|
connections: JSON.stringify(connections),
|
||||||
|
id: workflow.id,
|
||||||
|
},
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,15 @@ export class AddUserActivatedProperty1681134145996 implements ReversibleMigratio
|
||||||
AND r.scope = 'workflow'`,
|
AND r.scope = 'workflow'`,
|
||||||
)) as UserSettings[];
|
)) as UserSettings[];
|
||||||
|
|
||||||
const updatedUsers = activatedUsers.map(async (user) =>
|
const updatedUserPromises = activatedUsers.map(async (user) => {
|
||||||
queryRunner.query(
|
await queryRunner.query(
|
||||||
`UPDATE "${tablePrefix}user" SET settings = '${JSON.stringify(
|
`UPDATE "${tablePrefix}user" SET settings = '${JSON.stringify(
|
||||||
user.settings,
|
user.settings,
|
||||||
)}' WHERE id = '${user.id}' `,
|
)}' WHERE id = '${user.id}' `,
|
||||||
),
|
);
|
||||||
);
|
});
|
||||||
|
|
||||||
await Promise.all(updatedUsers);
|
await Promise.all(updatedUserPromises);
|
||||||
|
|
||||||
if (!activatedUsers.length) {
|
if (!activatedUsers.length) {
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
|
|
|
@ -18,14 +18,14 @@ export class AddUserActivatedProperty1681134145996 implements ReversibleMigratio
|
||||||
AND r.scope = "workflow"`,
|
AND r.scope = "workflow"`,
|
||||||
)) as UserSettings[];
|
)) as UserSettings[];
|
||||||
|
|
||||||
const updatedUsers = activatedUsers.map(async (user) =>
|
const updatedUserPromises = activatedUsers.map(async (user) => {
|
||||||
queryRunner.query(
|
await queryRunner.query(
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||||
`UPDATE ${tablePrefix}user SET settings = '${user.settings}' WHERE id = '${user.id}' `,
|
`UPDATE ${tablePrefix}user SET settings = '${user.settings}' WHERE id = '${user.id}' `,
|
||||||
),
|
);
|
||||||
);
|
});
|
||||||
|
|
||||||
await Promise.all(updatedUsers);
|
await Promise.all(updatedUserPromises);
|
||||||
|
|
||||||
if (!activatedUsers.length) {
|
if (!activatedUsers.length) {
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
|
|
|
@ -20,11 +20,11 @@ export class CredentialsRepository extends Repository<CredentialsEntity> {
|
||||||
credentialsId: credentialId,
|
credentialsId: credentialId,
|
||||||
userId: Not(In(userIds)),
|
userId: Not(In(userIds)),
|
||||||
};
|
};
|
||||||
return transaction.delete(SharedCredentials, conditions);
|
return await transaction.delete(SharedCredentials, conditions);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findStartingWith(credentialName: string) {
|
async findStartingWith(credentialName: string) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['name'],
|
select: ['name'],
|
||||||
where: { name: Like(`${credentialName}%`) },
|
where: { name: Like(`${credentialName}%`) },
|
||||||
});
|
});
|
||||||
|
@ -37,7 +37,7 @@ export class CredentialsRepository extends Repository<CredentialsEntity> {
|
||||||
findManyOptions.where = { ...findManyOptions.where, id: In(credentialIds) };
|
findManyOptions.where = { ...findManyOptions.where, id: In(credentialIds) };
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.find(findManyOptions);
|
return await this.find(findManyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
private toFindManyOptions(listQueryOptions?: ListQuery.Options) {
|
private toFindManyOptions(listQueryOptions?: ListQuery.Options) {
|
||||||
|
@ -84,6 +84,6 @@ export class CredentialsRepository extends Repository<CredentialsEntity> {
|
||||||
findManyOptions.relations = ['shared', 'shared.user', 'shared.role'];
|
findManyOptions.relations = ['shared', 'shared.user', 'shared.role'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.find(findManyOptions);
|
return await this.find(findManyOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,10 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
* Permanently remove a single execution and its binary data.
|
* Permanently remove a single execution and its binary data.
|
||||||
*/
|
*/
|
||||||
async hardDelete(ids: { workflowId: string; executionId: string }) {
|
async hardDelete(ids: { workflowId: string; executionId: string }) {
|
||||||
return Promise.all([this.delete(ids.executionId), this.binaryDataService.deleteMany([ids])]);
|
return await Promise.all([
|
||||||
|
this.delete(ids.executionId),
|
||||||
|
this.binaryDataService.deleteMany([ids]),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateStatus(executionId: string, status: ExecutionStatus) {
|
async updateStatus(executionId: string, status: ExecutionStatus) {
|
||||||
|
@ -438,7 +441,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getIdsSince(date: Date) {
|
async getIdsSince(date: Date) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['id'],
|
select: ['id'],
|
||||||
where: {
|
where: {
|
||||||
startedAt: MoreThanOrEqual(DateUtils.mixedDateToUtcDatetimeString(date)),
|
startedAt: MoreThanOrEqual(DateUtils.mixedDateToUtcDatetimeString(date)),
|
||||||
|
@ -474,7 +477,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
|
|
||||||
const [timeBasedWhere, countBasedWhere] = toPrune;
|
const [timeBasedWhere, countBasedWhere] = toPrune;
|
||||||
|
|
||||||
return this.createQueryBuilder()
|
return await this.createQueryBuilder()
|
||||||
.update(ExecutionEntity)
|
.update(ExecutionEntity)
|
||||||
.set({ deletedAt: new Date() })
|
.set({ deletedAt: new Date() })
|
||||||
.where({
|
.where({
|
||||||
|
@ -516,7 +519,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteByIds(executionIds: string[]) {
|
async deleteByIds(executionIds: string[]) {
|
||||||
return this.delete({ id: In(executionIds) });
|
return await this.delete({ id: In(executionIds) });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getWaitingExecutions() {
|
async getWaitingExecutions() {
|
||||||
|
@ -534,7 +537,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
where.waitTill = LessThanOrEqual(DateUtils.mixedDateToUtcDatetimeString(waitTill));
|
where.waitTill = LessThanOrEqual(DateUtils.mixedDateToUtcDatetimeString(waitTill));
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.findMultipleExecutions({
|
return await this.findMultipleExecutions({
|
||||||
select: ['id', 'waitTill'],
|
select: ['id', 'waitTill'],
|
||||||
where,
|
where,
|
||||||
order: {
|
order: {
|
||||||
|
@ -606,7 +609,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
where = { ...where, workflowId: In(params.workflowIds) };
|
where = { ...where, workflowId: In(params.workflowIds) };
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.findMultipleExecutions(
|
return await this.findMultipleExecutions(
|
||||||
{
|
{
|
||||||
select: [
|
select: [
|
||||||
'id',
|
'id',
|
||||||
|
@ -636,7 +639,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
workflowIds: string[],
|
workflowIds: string[],
|
||||||
includeData?: boolean,
|
includeData?: boolean,
|
||||||
): Promise<IExecutionBase | undefined> {
|
): Promise<IExecutionBase | undefined> {
|
||||||
return this.findSingleExecution(id, {
|
return await this.findSingleExecution(id, {
|
||||||
where: {
|
where: {
|
||||||
workflowId: In(workflowIds),
|
workflowId: In(workflowIds),
|
||||||
},
|
},
|
||||||
|
@ -646,7 +649,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findIfShared(executionId: string, sharedWorkflowIds: string[]) {
|
async findIfShared(executionId: string, sharedWorkflowIds: string[]) {
|
||||||
return this.findSingleExecution(executionId, {
|
return await this.findSingleExecution(executionId, {
|
||||||
where: {
|
where: {
|
||||||
workflowId: In(sharedWorkflowIds),
|
workflowId: In(sharedWorkflowIds),
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,7 +9,7 @@ export class ExecutionDataRepository extends Repository<ExecutionData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByExecutionIds(executionIds: string[]) {
|
async findByExecutionIds(executionIds: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['workflowData'],
|
select: ['workflowData'],
|
||||||
where: {
|
where: {
|
||||||
executionId: In(executionIds),
|
executionId: In(executionIds),
|
||||||
|
|
|
@ -41,7 +41,7 @@ export class InstalledPackagesRepository extends Repository<InstalledPackages> {
|
||||||
|
|
||||||
installedPackage.installedNodes.push(installedNode);
|
installedPackage.installedNodes.push(installedNode);
|
||||||
|
|
||||||
return manager.save(installedNode);
|
return await manager.save(installedNode);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ export class RoleRepository extends Repository<Role> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findRole(scope: RoleScopes, name: RoleNames) {
|
async findRole(scope: RoleScopes, name: RoleNames) {
|
||||||
return this.findOne({ where: { scope, name } });
|
return await this.findOne({ where: { scope, name } });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,7 +34,7 @@ export class RoleRepository extends Repository<Role> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getIdsInScopeWorkflowByNames(roleNames: RoleNames[]) {
|
async getIdsInScopeWorkflowByNames(roleNames: RoleNames[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['id'],
|
select: ['id'],
|
||||||
where: { name: In(roleNames), scope: 'workflow' },
|
where: { name: In(roleNames), scope: 'workflow' },
|
||||||
}).then((role) => role.map(({ id }) => id));
|
}).then((role) => role.map(({ id }) => id));
|
||||||
|
|
|
@ -25,7 +25,7 @@ export class SharedCredentialsRepository extends Repository<SharedCredentials> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByCredentialIds(credentialIds: string[]) {
|
async findByCredentialIds(credentialIds: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
relations: ['credentials', 'role', 'user'],
|
relations: ['credentials', 'role', 'user'],
|
||||||
where: {
|
where: {
|
||||||
credentialsId: In(credentialIds),
|
credentialsId: In(credentialIds),
|
||||||
|
@ -34,7 +34,7 @@ export class SharedCredentialsRepository extends Repository<SharedCredentials> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async makeOwnerOfAllCredentials(user: User, role: Role) {
|
async makeOwnerOfAllCredentials(user: User, role: Role) {
|
||||||
return this.update({ userId: Not(user.id), roleId: role.id }, { user });
|
return await this.update({ userId: Not(user.id), roleId: role.id }, { user });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,11 +58,11 @@ export class SharedCredentialsRepository extends Repository<SharedCredentials> {
|
||||||
// If credential sharing is not enabled, get only credentials owned by this user
|
// If credential sharing is not enabled, get only credentials owned by this user
|
||||||
if (roleId) where.roleId = roleId;
|
if (roleId) where.roleId = roleId;
|
||||||
|
|
||||||
return this.find({ where });
|
return await this.find({ where });
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteByIds(transaction: EntityManager, sharedCredentialsIds: string[], user?: User) {
|
async deleteByIds(transaction: EntityManager, sharedCredentialsIds: string[], user?: User) {
|
||||||
return transaction.delete(SharedCredentials, {
|
return await transaction.delete(SharedCredentials, {
|
||||||
user,
|
user,
|
||||||
credentialsId: In(sharedCredentialsIds),
|
credentialsId: In(sharedCredentialsIds),
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
if (!user.hasGlobalScope('workflow:read')) {
|
if (!user.hasGlobalScope('workflow:read')) {
|
||||||
where.userId = user.id;
|
where.userId = user.id;
|
||||||
}
|
}
|
||||||
return this.exist({ where });
|
return await this.exist({ where });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSharedWorkflowIds(workflowIds: string[]) {
|
async getSharedWorkflowIds(workflowIds: string[]) {
|
||||||
|
@ -34,7 +34,7 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByWorkflowIds(workflowIds: string[]) {
|
async findByWorkflowIds(workflowIds: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
relations: ['role', 'user'],
|
relations: ['role', 'user'],
|
||||||
where: {
|
where: {
|
||||||
role: {
|
role: {
|
||||||
|
@ -68,11 +68,11 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
|
|
||||||
if (extraRelations) relations.push(...extraRelations);
|
if (extraRelations) relations.push(...extraRelations);
|
||||||
|
|
||||||
return this.findOne({ relations, where });
|
return await this.findOne({ relations, where });
|
||||||
}
|
}
|
||||||
|
|
||||||
async makeOwnerOfAllWorkflows(user: User, role: Role) {
|
async makeOwnerOfAllWorkflows(user: User, role: Role) {
|
||||||
return this.update({ userId: Not(user.id), roleId: role.id }, { user });
|
return await this.update({ userId: Not(user.id), roleId: role.id }, { user });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSharing(
|
async getSharing(
|
||||||
|
@ -90,7 +90,7 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
where.userId = user.id;
|
where.userId = user.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.findOne({ where, relations });
|
return await this.findOne({ where, relations });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSharedWorkflows(
|
async getSharedWorkflows(
|
||||||
|
@ -100,7 +100,7 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
workflowIds?: string[];
|
workflowIds?: string[];
|
||||||
},
|
},
|
||||||
): Promise<SharedWorkflow[]> {
|
): Promise<SharedWorkflow[]> {
|
||||||
return this.find({
|
return await this.find({
|
||||||
where: {
|
where: {
|
||||||
...(!['owner', 'admin'].includes(user.globalRole.name) && { userId: user.id }),
|
...(!['owner', 'admin'].includes(user.globalRole.name) && { userId: user.id }),
|
||||||
...(options.workflowIds && { workflowId: In(options.workflowIds) }),
|
...(options.workflowIds && { workflowId: In(options.workflowIds) }),
|
||||||
|
@ -123,11 +123,11 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return transaction.save(newSharedWorkflows);
|
return await transaction.save(newSharedWorkflows);
|
||||||
}
|
}
|
||||||
|
|
||||||
async findWithFields(workflowIds: string[], { fields }: { fields: string[] }) {
|
async findWithFields(workflowIds: string[], { fields }: { fields: string[] }) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
where: {
|
where: {
|
||||||
workflowId: In(workflowIds),
|
workflowId: In(workflowIds),
|
||||||
},
|
},
|
||||||
|
@ -136,7 +136,7 @@ export class SharedWorkflowRepository extends Repository<SharedWorkflow> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteByIds(transaction: EntityManager, sharedWorkflowIds: string[], user?: User) {
|
async deleteByIds(transaction: EntityManager, sharedWorkflowIds: string[], user?: User) {
|
||||||
return transaction.delete(SharedWorkflow, {
|
return await transaction.delete(SharedWorkflow, {
|
||||||
user,
|
user,
|
||||||
workflowId: In(sharedWorkflowIds),
|
workflowId: In(sharedWorkflowIds),
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ export class TagRepository extends Repository<TagEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findMany(tagIds: string[]) {
|
async findMany(tagIds: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['id', 'name'],
|
select: ['id', 'name'],
|
||||||
where: { id: In(tagIds) },
|
where: { id: In(tagIds) },
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,7 @@ export class UserRepository extends Repository<User> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findManybyIds(userIds: string[]) {
|
async findManybyIds(userIds: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
where: { id: In(userIds) },
|
where: { id: In(userIds) },
|
||||||
relations: ['globalRole'],
|
relations: ['globalRole'],
|
||||||
});
|
});
|
||||||
|
@ -22,11 +22,11 @@ export class UserRepository extends Repository<User> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getByIds(transaction: EntityManager, ids: string[]) {
|
async getByIds(transaction: EntityManager, ids: string[]) {
|
||||||
return transaction.find(User, { where: { id: In(ids) } });
|
return await transaction.find(User, { where: { id: In(ids) } });
|
||||||
}
|
}
|
||||||
|
|
||||||
async findManyByEmail(emails: string[]) {
|
async findManyByEmail(emails: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
where: { email: In(emails) },
|
where: { email: In(emails) },
|
||||||
relations: ['globalRole'],
|
relations: ['globalRole'],
|
||||||
select: ['email', 'password', 'id'],
|
select: ['email', 'password', 'id'],
|
||||||
|
@ -34,11 +34,11 @@ export class UserRepository extends Repository<User> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteMany(userIds: string[]) {
|
async deleteMany(userIds: string[]) {
|
||||||
return this.delete({ id: In(userIds) });
|
return await this.delete({ id: In(userIds) });
|
||||||
}
|
}
|
||||||
|
|
||||||
async findNonShellUser(email: string) {
|
async findNonShellUser(email: string) {
|
||||||
return this.findOne({
|
return await this.findOne({
|
||||||
where: {
|
where: {
|
||||||
email,
|
email,
|
||||||
password: Not(IsNull()),
|
password: Not(IsNull()),
|
||||||
|
|
|
@ -26,14 +26,14 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(where: FindOptionsWhere<WorkflowEntity>, options?: { relations: string[] }) {
|
async get(where: FindOptionsWhere<WorkflowEntity>, options?: { relations: string[] }) {
|
||||||
return this.findOne({
|
return await this.findOne({
|
||||||
where,
|
where,
|
||||||
relations: options?.relations,
|
relations: options?.relations,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllActive() {
|
async getAllActive() {
|
||||||
return this.find({
|
return await this.find({
|
||||||
where: { active: true },
|
where: { active: true },
|
||||||
relations: ['shared', 'shared.user', 'shared.user.globalRole', 'shared.role'],
|
relations: ['shared', 'shared.user', 'shared.user.globalRole', 'shared.role'],
|
||||||
});
|
});
|
||||||
|
@ -48,7 +48,7 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findById(workflowId: string) {
|
async findById(workflowId: string) {
|
||||||
return this.findOne({
|
return await this.findOne({
|
||||||
where: { id: workflowId },
|
where: { id: workflowId },
|
||||||
relations: ['shared', 'shared.user', 'shared.user.globalRole', 'shared.role'],
|
relations: ['shared', 'shared.user', 'shared.user.globalRole', 'shared.role'],
|
||||||
});
|
});
|
||||||
|
@ -61,7 +61,7 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||||
|
|
||||||
if (fields?.length) options.select = fields as FindOptionsSelect<WorkflowEntity>;
|
if (fields?.length) options.select = fields as FindOptionsSelect<WorkflowEntity>;
|
||||||
|
|
||||||
return this.find(options);
|
return await this.find(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActiveTriggerCount() {
|
async getActiveTriggerCount() {
|
||||||
|
@ -88,7 +88,7 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||||
workflowId: string,
|
workflowId: string,
|
||||||
userIds: string[],
|
userIds: string[],
|
||||||
): Promise<DeleteResult> {
|
): Promise<DeleteResult> {
|
||||||
return transaction.delete(SharedWorkflow, {
|
return await transaction.delete(SharedWorkflow, {
|
||||||
workflowId,
|
workflowId,
|
||||||
userId: Not(In(userIds)),
|
userId: Not(In(userIds)),
|
||||||
});
|
});
|
||||||
|
@ -96,7 +96,7 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||||
|
|
||||||
async updateWorkflowTriggerCount(id: string, triggerCount: number): Promise<UpdateResult> {
|
async updateWorkflowTriggerCount(id: string, triggerCount: number): Promise<UpdateResult> {
|
||||||
const qb = this.createQueryBuilder('workflow');
|
const qb = this.createQueryBuilder('workflow');
|
||||||
return qb
|
return await qb
|
||||||
.update()
|
.update()
|
||||||
.set({
|
.set({
|
||||||
triggerCount,
|
triggerCount,
|
||||||
|
@ -185,35 +185,35 @@ export class WorkflowRepository extends Repository<WorkflowEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findStartingWith(workflowName: string): Promise<Array<{ name: string }>> {
|
async findStartingWith(workflowName: string): Promise<Array<{ name: string }>> {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['name'],
|
select: ['name'],
|
||||||
where: { name: Like(`${workflowName}%`) },
|
where: { name: Like(`${workflowName}%`) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async findIn(workflowIds: string[]) {
|
async findIn(workflowIds: string[]) {
|
||||||
return this.find({
|
return await this.find({
|
||||||
select: ['id', 'name'],
|
select: ['id', 'name'],
|
||||||
where: { id: In(workflowIds) },
|
where: { id: In(workflowIds) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async findWebhookBasedActiveWorkflows() {
|
async findWebhookBasedActiveWorkflows() {
|
||||||
return this.createQueryBuilder('workflow')
|
return await (this.createQueryBuilder('workflow')
|
||||||
.select('DISTINCT workflow.id, workflow.name')
|
.select('DISTINCT workflow.id, workflow.name')
|
||||||
.innerJoin(WebhookEntity, 'webhook_entity', 'workflow.id = webhook_entity.workflowId')
|
.innerJoin(WebhookEntity, 'webhook_entity', 'workflow.id = webhook_entity.workflowId')
|
||||||
.execute() as Promise<Array<{ id: string; name: string }>>;
|
.execute() as Promise<Array<{ id: string; name: string }>>);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateActiveState(workflowId: string, newState: boolean) {
|
async updateActiveState(workflowId: string, newState: boolean) {
|
||||||
return this.update({ id: workflowId }, { active: newState });
|
return await this.update({ id: workflowId }, { active: newState });
|
||||||
}
|
}
|
||||||
|
|
||||||
async deactivateAll() {
|
async deactivateAll() {
|
||||||
return this.update({ active: true }, { active: false });
|
return await this.update({ active: true }, { active: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
async findByActiveState(activeState: boolean) {
|
async findByActiveState(activeState: boolean) {
|
||||||
return this.findBy({ active: activeState });
|
return await this.findBy({ active: activeState });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,6 @@ export class WorkflowHistoryRepository extends Repository<WorkflowHistory> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteEarlierThan(date: Date) {
|
async deleteEarlierThan(date: Date) {
|
||||||
return this.delete({ createdAt: LessThan(date) });
|
return await this.delete({ createdAt: LessThan(date) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,9 +118,9 @@ const createContext = (queryRunner: QueryRunner, migration: Migration): Migratio
|
||||||
namedParameters,
|
namedParameters,
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
return queryRunner.query(query, parameters) as Promise<T>;
|
return await (queryRunner.query(query, parameters) as Promise<T>);
|
||||||
} else {
|
} else {
|
||||||
return queryRunner.query(sql) as Promise<T>;
|
return await (queryRunner.query(sql) as Promise<T>);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
runInBatches: async <T>(
|
runInBatches: async <T>(
|
||||||
|
|
|
@ -121,7 +121,8 @@ export const registerController = (app: Application, controllerClass: Class<obje
|
||||||
const authRole = authRoles?.[handlerName] ?? authRoles?.['*'];
|
const authRole = authRoles?.[handlerName] ?? authRoles?.['*'];
|
||||||
const features = licenseFeatures?.[handlerName] ?? licenseFeatures?.['*'];
|
const features = licenseFeatures?.[handlerName] ?? licenseFeatures?.['*'];
|
||||||
const scopes = requiredScopes?.[handlerName] ?? requiredScopes?.['*'];
|
const scopes = requiredScopes?.[handlerName] ?? requiredScopes?.['*'];
|
||||||
const handler = async (req: Request, res: Response) => controller[handlerName](req, res);
|
const handler = async (req: Request, res: Response) =>
|
||||||
|
await controller[handlerName](req, res);
|
||||||
router[method](
|
router[method](
|
||||||
path,
|
path,
|
||||||
...(authRole ? [createAuthMiddleware(authRole)] : []),
|
...(authRole ? [createAuthMiddleware(authRole)] : []),
|
||||||
|
|
|
@ -171,7 +171,7 @@ export class SourceControlService {
|
||||||
await this.initGitService();
|
await this.initGitService();
|
||||||
}
|
}
|
||||||
await this.gitService.fetch();
|
await this.gitService.fetch();
|
||||||
return this.gitService.getBranches();
|
return await this.gitService.getBranches();
|
||||||
}
|
}
|
||||||
|
|
||||||
async setBranch(branch: string): Promise<{ branches: string[]; currentBranch: string }> {
|
async setBranch(branch: string): Promise<{ branches: string[]; currentBranch: string }> {
|
||||||
|
@ -182,7 +182,7 @@ export class SourceControlService {
|
||||||
branchName: branch,
|
branchName: branch,
|
||||||
connected: branch?.length > 0,
|
connected: branch?.length > 0,
|
||||||
});
|
});
|
||||||
return this.gitService.setBranch(branch);
|
return await this.gitService.setBranch(branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// will reset the branch to the remote branch and pull
|
// will reset the branch to the remote branch and pull
|
||||||
|
|
|
@ -95,7 +95,7 @@ export class SourceControlExportService {
|
||||||
owner: owners[e.id],
|
owner: owners[e.id],
|
||||||
};
|
};
|
||||||
this.logger.debug(`Writing workflow ${e.id} to ${fileName}`);
|
this.logger.debug(`Writing workflow ${e.id} to ${fileName}`);
|
||||||
return fsWriteFile(fileName, JSON.stringify(sanitizedWorkflow, null, 2));
|
return await fsWriteFile(fileName, JSON.stringify(sanitizedWorkflow, null, 2));
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ export class SourceControlExportService {
|
||||||
nodesAccess: sharedCredential.credentials.nodesAccess,
|
nodesAccess: sharedCredential.credentials.nodesAccess,
|
||||||
};
|
};
|
||||||
this.logger.debug(`Writing credential ${sharedCredential.credentials.id} to ${fileName}`);
|
this.logger.debug(`Writing credential ${sharedCredential.credentials.id} to ${fileName}`);
|
||||||
return fsWriteFile(fileName, JSON.stringify(sanitizedCredential, null, 2));
|
return await fsWriteFile(fileName, JSON.stringify(sanitizedCredential, null, 2));
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -232,7 +232,7 @@ export class SourceControlGitService {
|
||||||
}
|
}
|
||||||
await this.git.checkout(branch);
|
await this.git.checkout(branch);
|
||||||
await this.git.branch([`--set-upstream-to=${SOURCE_CONTROL_ORIGIN}/${branch}`, branch]);
|
await this.git.branch([`--set-upstream-to=${SOURCE_CONTROL_ORIGIN}/${branch}`, branch]);
|
||||||
return this.getBranches();
|
return await this.getBranches();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCurrentBranch(): Promise<{ current: string; remote: string }> {
|
async getCurrentBranch(): Promise<{ current: string; remote: string }> {
|
||||||
|
@ -253,7 +253,7 @@ export class SourceControlGitService {
|
||||||
const currentBranch = await this.getCurrentBranch();
|
const currentBranch = await this.getCurrentBranch();
|
||||||
if (currentBranch.remote) {
|
if (currentBranch.remote) {
|
||||||
const target = currentBranch.remote;
|
const target = currentBranch.remote;
|
||||||
return this.git.diffSummary(['...' + target, '--ignore-all-space']);
|
return await this.git.diffSummary(['...' + target, '--ignore-all-space']);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ export class SourceControlGitService {
|
||||||
const currentBranch = await this.getCurrentBranch();
|
const currentBranch = await this.getCurrentBranch();
|
||||||
if (currentBranch.remote) {
|
if (currentBranch.remote) {
|
||||||
const target = currentBranch.current;
|
const target = currentBranch.current;
|
||||||
return this.git.diffSummary([target, '--ignore-all-space']);
|
return await this.git.diffSummary([target, '--ignore-all-space']);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ export class SourceControlGitService {
|
||||||
if (!this.git) {
|
if (!this.git) {
|
||||||
throw new ApplicationError('Git is not initialized (fetch)');
|
throw new ApplicationError('Git is not initialized (fetch)');
|
||||||
}
|
}
|
||||||
return this.git.fetch();
|
return await this.git.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
async pull(options: { ffOnly: boolean } = { ffOnly: true }): Promise<PullResult> {
|
async pull(options: { ffOnly: boolean } = { ffOnly: true }): Promise<PullResult> {
|
||||||
|
@ -286,7 +286,7 @@ export class SourceControlGitService {
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
Object.assign(params, { '--ff-only': true });
|
Object.assign(params, { '--ff-only': true });
|
||||||
}
|
}
|
||||||
return this.git.pull(params);
|
return await this.git.pull(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async push(
|
async push(
|
||||||
|
@ -300,9 +300,9 @@ export class SourceControlGitService {
|
||||||
throw new ApplicationError('Git is not initialized ({)');
|
throw new ApplicationError('Git is not initialized ({)');
|
||||||
}
|
}
|
||||||
if (force) {
|
if (force) {
|
||||||
return this.git.push(SOURCE_CONTROL_ORIGIN, branch, ['-f']);
|
return await this.git.push(SOURCE_CONTROL_ORIGIN, branch, ['-f']);
|
||||||
}
|
}
|
||||||
return this.git.push(SOURCE_CONTROL_ORIGIN, branch);
|
return await this.git.push(SOURCE_CONTROL_ORIGIN, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
async stage(files: Set<string>, deletedFiles?: Set<string>): Promise<string> {
|
async stage(files: Set<string>, deletedFiles?: Set<string>): Promise<string> {
|
||||||
|
@ -316,7 +316,7 @@ export class SourceControlGitService {
|
||||||
this.logger.debug(`Git rm: ${(error as Error).message}`);
|
this.logger.debug(`Git rm: ${(error as Error).message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.git.add(Array.from(files));
|
return await this.git.add(Array.from(files));
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetBranch(
|
async resetBranch(
|
||||||
|
@ -326,9 +326,9 @@ export class SourceControlGitService {
|
||||||
throw new ApplicationError('Git is not initialized (Promise)');
|
throw new ApplicationError('Git is not initialized (Promise)');
|
||||||
}
|
}
|
||||||
if (options?.hard) {
|
if (options?.hard) {
|
||||||
return this.git.raw(['reset', '--hard', options.target]);
|
return await this.git.raw(['reset', '--hard', options.target]);
|
||||||
}
|
}
|
||||||
return this.git.raw(['reset', options.target]);
|
return await this.git.raw(['reset', options.target]);
|
||||||
// built-in reset method does not work
|
// built-in reset method does not work
|
||||||
// return this.git.reset();
|
// return this.git.reset();
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ export class SourceControlGitService {
|
||||||
if (!this.git) {
|
if (!this.git) {
|
||||||
throw new ApplicationError('Git is not initialized (commit)');
|
throw new ApplicationError('Git is not initialized (commit)');
|
||||||
}
|
}
|
||||||
return this.git.commit(message);
|
return await this.git.commit(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
async status(): Promise<StatusResult> {
|
async status(): Promise<StatusResult> {
|
||||||
|
|
|
@ -186,7 +186,7 @@ export class SourceControlImportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getLocalVariablesFromDb(): Promise<Variables[]> {
|
public async getLocalVariablesFromDb(): Promise<Variables[]> {
|
||||||
return this.variablesService.getAllCached();
|
return await this.variablesService.getAllCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getRemoteTagsAndMappingsFromFile(): Promise<{
|
public async getRemoteTagsAndMappingsFromFile(): Promise<{
|
||||||
|
|
|
@ -23,7 +23,7 @@ export class VariablesController {
|
||||||
@Get('/')
|
@Get('/')
|
||||||
@RequireGlobalScope('variable:list')
|
@RequireGlobalScope('variable:list')
|
||||||
async getVariables() {
|
async getVariables() {
|
||||||
return this.variablesService.getAllCached();
|
return await this.variablesService.getAllCached();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('/')
|
@Post('/')
|
||||||
|
|
|
@ -18,7 +18,7 @@ export class VariablesService {
|
||||||
async getAllCached(): Promise<Variables[]> {
|
async getAllCached(): Promise<Variables[]> {
|
||||||
const variables = await this.cacheService.get('variables', {
|
const variables = await this.cacheService.get('variables', {
|
||||||
async refreshFn() {
|
async refreshFn() {
|
||||||
return Container.get(VariablesService).findAll();
|
return await Container.get(VariablesService).findAll();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return (variables as Array<Partial<Variables>>).map((v) => this.variablesRepository.create(v));
|
return (variables as Array<Partial<Variables>>).map((v) => this.variablesRepository.create(v));
|
||||||
|
@ -49,7 +49,7 @@ export class VariablesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findAll(): Promise<Variables[]> {
|
async findAll(): Promise<Variables[]> {
|
||||||
return this.variablesRepository.find();
|
return await this.variablesRepository.find();
|
||||||
}
|
}
|
||||||
|
|
||||||
validateVariable(variable: Omit<Variables, 'id'>): void {
|
validateVariable(variable: Omit<Variables, 'id'>): void {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue