n8n 0.178.2 → 0.181.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/export/workflow.js +4 -1
- package/dist/commands/export/workflow.js.map +1 -1
- package/dist/commands/import/workflow.js +22 -5
- package/dist/commands/import/workflow.js.map +1 -1
- package/dist/commands/worker.js +3 -2
- package/dist/commands/worker.js.map +1 -1
- package/dist/config/index.d.ts +4 -0
- package/dist/config/schema.d.ts +14 -0
- package/dist/config/schema.js +16 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/src/ActiveWorkflowRunner.d.ts +2 -1
- package/dist/src/ActiveWorkflowRunner.js +66 -6
- package/dist/src/ActiveWorkflowRunner.js.map +1 -1
- package/dist/src/CredentialsHelper.d.ts +2 -0
- package/dist/src/CredentialsHelper.js +13 -5
- package/dist/src/CredentialsHelper.js.map +1 -1
- package/dist/src/Interfaces.d.ts +41 -6
- package/dist/src/InternalHooks.d.ts +46 -4
- package/dist/src/InternalHooks.js +36 -6
- package/dist/src/InternalHooks.js.map +1 -1
- package/dist/src/PublicApi/index.d.ts +5 -0
- package/dist/src/PublicApi/index.js +122 -0
- package/dist/src/PublicApi/index.js.map +1 -0
- package/dist/src/PublicApi/swaggerTheme.css +26 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.handler.d.ts +7 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.handler.js +72 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.handler.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.middleware.d.ts +3 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.middleware.js +34 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.middleware.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.service.d.ts +14 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.service.js +180 -0
- package/dist/src/PublicApi/v1/handlers/credentials/credentials.service.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/executions/executions.handler.d.ts +8 -0
- package/dist/src/PublicApi/v1/handlers/executions/executions.handler.js +97 -0
- package/dist/src/PublicApi/v1/handlers/executions/executions.handler.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/executions/executions.service.d.ts +19 -0
- package/dist/src/PublicApi/v1/handlers/executions/executions.service.js +80 -0
- package/dist/src/PublicApi/v1/handlers/executions/executions.service.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/users/users.service.d.ts +4 -0
- package/dist/src/PublicApi/v1/handlers/users/users.service.js +16 -0
- package/dist/src/PublicApi/v1/handlers/users/users.service.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/workflows/workflows.handler.d.ts +12 -0
- package/dist/src/PublicApi/v1/handlers/workflows/workflows.handler.js +199 -0
- package/dist/src/PublicApi/v1/handlers/workflows/workflows.handler.js.map +1 -0
- package/dist/src/PublicApi/v1/handlers/workflows/workflows.service.d.ts +24 -0
- package/dist/src/PublicApi/v1/handlers/workflows/workflows.service.js +113 -0
- package/dist/src/PublicApi/v1/handlers/workflows/workflows.service.js.map +1 -0
- package/dist/src/PublicApi/v1/openapi.yml +703 -0
- package/dist/src/PublicApi/v1/shared/middlewares/global.middleware.d.ts +5 -0
- package/dist/src/PublicApi/v1/shared/middlewares/global.middleware.js +38 -0
- package/dist/src/PublicApi/v1/shared/middlewares/global.middleware.js.map +1 -0
- package/dist/src/PublicApi/v1/shared/services/pagination.service.d.ts +3 -0
- package/dist/src/PublicApi/v1/shared/services/pagination.service.js +33 -0
- package/dist/src/PublicApi/v1/shared/services/pagination.service.js.map +1 -0
- package/dist/src/ResponseHelper.d.ts +1 -1
- package/dist/src/ResponseHelper.js +2 -2
- package/dist/src/ResponseHelper.js.map +1 -1
- package/dist/src/Server.js +29 -13
- package/dist/src/Server.js.map +1 -1
- package/dist/src/TagHelpers.d.ts +3 -1
- package/dist/src/TagHelpers.js +47 -1
- package/dist/src/TagHelpers.js.map +1 -1
- package/dist/src/UserManagement/UserManagementHelper.js +1 -1
- package/dist/src/UserManagement/UserManagementHelper.js.map +1 -1
- package/dist/src/UserManagement/auth/jwt.d.ts +1 -1
- package/dist/src/UserManagement/routes/me.js +27 -0
- package/dist/src/UserManagement/routes/me.js.map +1 -1
- package/dist/src/UserManagement/routes/passwordReset.js +2 -0
- package/dist/src/UserManagement/routes/passwordReset.js.map +1 -1
- package/dist/src/UserManagement/routes/users.js +7 -1
- package/dist/src/UserManagement/routes/users.js.map +1 -1
- package/dist/src/WebhookHelpers.js +8 -7
- package/dist/src/WebhookHelpers.js.map +1 -1
- package/dist/src/WebhookServer.js.map +1 -1
- package/dist/src/WorkflowExecuteAdditionalData.d.ts +2 -1
- package/dist/src/WorkflowExecuteAdditionalData.js +45 -16
- package/dist/src/WorkflowExecuteAdditionalData.js.map +1 -1
- package/dist/src/WorkflowHelpers.js +2 -0
- package/dist/src/WorkflowHelpers.js.map +1 -1
- package/dist/src/WorkflowRunner.js +2 -0
- package/dist/src/WorkflowRunner.js.map +1 -1
- package/dist/src/api/credentials.api.js +4 -3
- package/dist/src/api/credentials.api.js.map +1 -1
- package/dist/src/databases/entities/User.d.ts +1 -0
- package/dist/src/databases/entities/User.js +7 -2
- package/dist/src/databases/entities/User.js.map +1 -1
- package/dist/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.d.ts +6 -0
- package/dist/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.js +28 -0
- package/dist/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.js.map +1 -0
- package/dist/src/databases/mysqldb/migrations/index.js +2 -0
- package/dist/src/databases/mysqldb/migrations/index.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1587669153312-InitialMigration.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1587669153312-InitialMigration.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1589476000887-WebhookModel.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1589476000887-WebhookModel.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.js +9 -2
- package/dist/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.js +1 -0
- package/dist/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1626176912946-AddwaitTill.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1626176912946-AddwaitTill.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1644422880309-AddExecutionEntityIndexes.js +7 -6
- package/dist/src/databases/postgresdb/migrations/1644422880309-AddExecutionEntityIndexes.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1646834195327-IncreaseTypeVarcharLimit.js +6 -1
- package/dist/src/databases/postgresdb/migrations/1646834195327-IncreaseTypeVarcharLimit.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1646992772331-CreateUserManagement.js +5 -3
- package/dist/src/databases/postgresdb/migrations/1646992772331-CreateUserManagement.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.js +1 -0
- package/dist/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1652367743993-AddUserSettings.js +2 -0
- package/dist/src/databases/postgresdb/migrations/1652367743993-AddUserSettings.js.map +1 -1
- package/dist/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.d.ts +6 -0
- package/dist/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.js +32 -0
- package/dist/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.js.map +1 -0
- package/dist/src/databases/postgresdb/migrations/index.js +2 -0
- package/dist/src/databases/postgresdb/migrations/index.js.map +1 -1
- package/dist/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.d.ts +6 -0
- package/dist/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.js +58 -0
- package/dist/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.js.map +1 -0
- package/dist/src/databases/sqlite/migrations/index.js +2 -0
- package/dist/src/databases/sqlite/migrations/index.js.map +1 -1
- package/dist/test/integration/auth.api.test.js +11 -6
- package/dist/test/integration/auth.api.test.js.map +1 -1
- package/dist/test/integration/auth.mw.test.js +1 -1
- package/dist/test/integration/auth.mw.test.js.map +1 -1
- package/dist/test/integration/commands/reset.cmd.test.d.ts +1 -0
- package/dist/test/integration/commands/reset.cmd.test.js +59 -0
- package/dist/test/integration/commands/reset.cmd.test.js.map +1 -0
- package/dist/test/integration/credentials.api.test.js +1 -1
- package/dist/test/integration/credentials.api.test.js.map +1 -1
- package/dist/test/integration/me.api.test.js +78 -7
- package/dist/test/integration/me.api.test.js.map +1 -1
- package/dist/test/integration/owner.api.test.js +3 -2
- package/dist/test/integration/owner.api.test.js.map +1 -1
- package/dist/test/integration/passwordReset.api.test.js +1 -1
- package/dist/test/integration/passwordReset.api.test.js.map +1 -1
- package/dist/test/integration/publicApi/credentials.test.d.ts +1 -0
- package/dist/test/integration/publicApi/credentials.test.js +321 -0
- package/dist/test/integration/publicApi/credentials.test.js.map +1 -0
- package/dist/test/integration/publicApi/executions.test.d.ts +1 -0
- package/dist/test/integration/publicApi/executions.test.js +289 -0
- package/dist/test/integration/publicApi/executions.test.js.map +1 -0
- package/dist/test/integration/publicApi/workflows.test.d.ts +1 -0
- package/dist/test/integration/publicApi/workflows.test.js +948 -0
- package/dist/test/integration/publicApi/workflows.test.js.map +1 -0
- package/dist/test/integration/shared/constants.d.ts +1 -0
- package/dist/test/integration/shared/constants.js +2 -1
- package/dist/test/integration/shared/constants.js.map +1 -1
- package/dist/test/integration/shared/random.d.ts +1 -0
- package/dist/test/integration/shared/random.js +8 -2
- package/dist/test/integration/shared/random.js.map +1 -1
- package/dist/test/integration/shared/testDb.d.ts +115 -4
- package/dist/test/integration/shared/testDb.js +132 -10
- package/dist/test/integration/shared/testDb.js.map +1 -1
- package/dist/test/integration/shared/utils.d.ts +206 -3
- package/dist/test/integration/shared/utils.js +582 -18
- package/dist/test/integration/shared/utils.js.map +1 -1
- package/dist/test/integration/users.api.test.js +6 -4
- package/dist/test/integration/users.api.test.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +22 -15
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const CredentialsHelper_1 = require("../../../../CredentialsHelper");
|
|
3
|
+
const CredentialTypes_1 = require("../../../../CredentialTypes");
|
|
4
|
+
const global_middleware_1 = require("../../shared/middlewares/global.middleware");
|
|
5
|
+
const credentials_middleware_1 = require("./credentials.middleware");
|
|
6
|
+
const credentials_service_1 = require("./credentials.service");
|
|
7
|
+
module.exports = {
|
|
8
|
+
createCredential: [
|
|
9
|
+
(0, global_middleware_1.authorize)(['owner', 'member']),
|
|
10
|
+
credentials_middleware_1.validCredentialType,
|
|
11
|
+
credentials_middleware_1.validCredentialsProperties,
|
|
12
|
+
async (req, res) => {
|
|
13
|
+
try {
|
|
14
|
+
const newCredential = await (0, credentials_service_1.createCredential)(req.body);
|
|
15
|
+
const encryptedData = await (0, credentials_service_1.encryptCredential)(newCredential);
|
|
16
|
+
Object.assign(newCredential, encryptedData);
|
|
17
|
+
const savedCredential = await (0, credentials_service_1.saveCredential)(newCredential, req.user, encryptedData);
|
|
18
|
+
return res.json((0, credentials_service_1.sanitizeCredentials)(savedCredential));
|
|
19
|
+
}
|
|
20
|
+
catch ({ message, httpStatusCode }) {
|
|
21
|
+
return res.status(httpStatusCode !== null && httpStatusCode !== void 0 ? httpStatusCode : 500).json({ message });
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
deleteCredential: [
|
|
26
|
+
(0, global_middleware_1.authorize)(['owner', 'member']),
|
|
27
|
+
async (req, res) => {
|
|
28
|
+
const { id: credentialId } = req.params;
|
|
29
|
+
let credentials;
|
|
30
|
+
if (req.user.globalRole.name !== 'owner') {
|
|
31
|
+
const shared = await (0, credentials_service_1.getSharedCredentials)(req.user.id, credentialId, [
|
|
32
|
+
'credentials',
|
|
33
|
+
'role',
|
|
34
|
+
]);
|
|
35
|
+
if ((shared === null || shared === void 0 ? void 0 : shared.role.name) === 'owner') {
|
|
36
|
+
credentials = shared.credentials;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
credentials = (await (0, credentials_service_1.getCredentials)(credentialId));
|
|
43
|
+
}
|
|
44
|
+
if (!credentials) {
|
|
45
|
+
return res.status(404).json({
|
|
46
|
+
message: 'Not Found',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
await (0, credentials_service_1.removeCredential)(credentials);
|
|
50
|
+
credentials.id = Number(credentialId);
|
|
51
|
+
return res.json((0, credentials_service_1.sanitizeCredentials)(credentials));
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
getCredentialType: [
|
|
55
|
+
(0, global_middleware_1.authorize)(['owner', 'member']),
|
|
56
|
+
async (req, res) => {
|
|
57
|
+
const { credentialTypeName } = req.params;
|
|
58
|
+
try {
|
|
59
|
+
(0, CredentialTypes_1.CredentialTypes)().getByName(credentialTypeName);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return res.status(404).json({
|
|
63
|
+
message: 'Not Found',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
let schema = new CredentialsHelper_1.CredentialsHelper('').getCredentialsProperties(credentialTypeName);
|
|
67
|
+
schema = schema.filter((nodeProperty) => nodeProperty.type !== 'hidden');
|
|
68
|
+
return res.json((0, credentials_service_1.toJsonSchema)(schema));
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=credentials.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.handler.js","sourceRoot":"","sources":["../../../../../../src/PublicApi/v1/handlers/credentials/credentials.handler.ts"],"names":[],"mappings":";AACA,qEAAkE;AAClE,iEAA8D;AAK9D,kFAAuE;AACvE,qEAA2F;AAE3F,+DAS+B;AAE/B,iBAAS;IACR,gBAAgB,EAAE;QACjB,IAAA,6BAAS,EAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9B,4CAAmB;QACnB,mDAA0B;QAC1B,KAAK,EACJ,GAA6B,EAC7B,GAAqB,EACmC,EAAE;YAC1D,IAAI;gBACH,MAAM,aAAa,GAAG,MAAM,IAAA,sCAAgB,EAAC,GAAG,CAAC,IAAkC,CAAC,CAAC;gBAErF,MAAM,aAAa,GAAG,MAAM,IAAA,uCAAiB,EAAC,aAAa,CAAC,CAAC;gBAE7D,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;gBAE5C,MAAM,eAAe,GAAG,MAAM,IAAA,oCAAc,EAAC,aAAa,EAAE,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;gBAOrF,OAAO,GAAG,CAAC,IAAI,CAAC,IAAA,yCAAmB,EAAC,eAAe,CAAC,CAAC,CAAC;aACtD;YAAC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,EAAE;gBAErC,OAAO,G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AS,EAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9B,KAAK,EAAE,GAA8B,EAAE,GAAqB,EAA6B,EAAE;YAC1F,MAAM,EAAE,kBAAkB,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;YAE1C,IAAI;gBACH,IAAA,iCAAe,GAAE,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;aAChD;YAAC,OAAO,KAAK,EAAE;gBACf,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBAC3B,OAAO,EAAE,WAAW;iBACpB,CAAC,CAAC;aACH;YAED,IAAI,MAAM,GAAG,IAAI,qCAAiB,CAAC,EAAE,CAAC,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;YAEpF,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;YAEzE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAA,kCAAY,EAAC,MAAM,CAAC,CAAC,CAAC;QACvC,CAAC;KACD;CACD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validCredentialsProperties = exports.validCredentialType = void 0;
|
|
4
|
+
const jsonschema_1 = require("jsonschema");
|
|
5
|
+
const __1 = require("../../../..");
|
|
6
|
+
const credentials_service_1 = require("./credentials.service");
|
|
7
|
+
const validCredentialType = async (req, res, next) => {
|
|
8
|
+
const { type } = req.body;
|
|
9
|
+
try {
|
|
10
|
+
(0, __1.CredentialTypes)().getByName(type);
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return res.status(400).json({
|
|
14
|
+
message: 'req.body.type is not a known type',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
next();
|
|
18
|
+
};
|
|
19
|
+
exports.validCredentialType = validCredentialType;
|
|
20
|
+
const validCredentialsProperties = async (req, res, next) => {
|
|
21
|
+
const { type, data } = req.body;
|
|
22
|
+
let properties = new __1.CredentialsHelper('').getCredentialsProperties(type);
|
|
23
|
+
properties = properties.filter((nodeProperty) => nodeProperty.type !== 'hidden');
|
|
24
|
+
const schema = (0, credentials_service_1.toJsonSchema)(properties);
|
|
25
|
+
const { valid, errors } = (0, jsonschema_1.validate)(data, schema, { nestedErrors: true });
|
|
26
|
+
if (!valid) {
|
|
27
|
+
return res.status(400).json({
|
|
28
|
+
message: errors.map((error) => `request.body.data ${error.message}`).join(','),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
next();
|
|
32
|
+
};
|
|
33
|
+
exports.validCredentialsProperties = validCredentialsProperties;
|
|
34
|
+
//# sourceMappingURL=credentials.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.middleware.js","sourceRoot":"","sources":["../../../../../../src/PublicApi/v1/handlers/credentials/credentials.middleware.ts"],"names":[],"mappings":";;;AAGA,2CAAsC;AACtC,mCAAiE;AAEjE,+DAAqD;AAE9C,MAAM,mBAAmB,GAAmB,KAAK,EACvD,GAA6B,EAC7B,GAAG,EACH,IAAI,EACW,EAAE;IACjB,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAC1B,IAAI;QACH,IAAA,mBAAe,GAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;KAClC;IAAC,OAAO,KAAK,EAAE;QACf,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,mCAAmC;SAC5C,CAAC,CAAC;KACH;IACD,IAAI,EAAE,CAAC;AACR,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B;AAEK,MAAM,0BAA0B,GAAmB,KAAK,EAC9D,GAA6B,EAC7B,GAAG,EACH,IAAI,EACW,EAAE;IACjB,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC;IAEhC,IAAI,UAAU,GAAG,IAAI,qBAAiB,CAAC,EAAE,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAE1E,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAEjF,MAAM,MAAM,GAAG,IAAA,kCAAY,EAAC,UAAU,CAAC,CAAC;IAExC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAA,qBAAQ,EAAC,IAAI,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzE,IAAI,CAAC,KAAK,EAAE;QACX,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;YAC3B,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;SAC9E,CAAC,CAAC;KACH;IAED,IAAI,EAAE,CAAC;AACR,CAAC,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IDataObject, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
import { ICredentialsDb } from '../../../..';
|
|
3
|
+
import { CredentialsEntity } from '../../../../databases/entities/CredentialsEntity';
|
|
4
|
+
import { SharedCredentials } from '../../../../databases/entities/SharedCredentials';
|
|
5
|
+
import { User } from '../../../../databases/entities/User';
|
|
6
|
+
export declare function getCredentials(credentialId: number | string): Promise<ICredentialsDb | undefined>;
|
|
7
|
+
export declare function getSharedCredentials(userId: string, credentialId: number | string, relations?: string[]): Promise<SharedCredentials | undefined>;
|
|
8
|
+
export declare function createCredential(properties: Partial<CredentialsEntity>): Promise<CredentialsEntity>;
|
|
9
|
+
export declare function saveCredential(credential: CredentialsEntity, user: User, encryptedData: ICredentialsDb): Promise<CredentialsEntity>;
|
|
10
|
+
export declare function removeCredential(credentials: CredentialsEntity): Promise<ICredentialsDb>;
|
|
11
|
+
export declare function encryptCredential(credential: CredentialsEntity): Promise<ICredentialsDb>;
|
|
12
|
+
export declare function sanitizeCredentials(credentials: CredentialsEntity): Partial<CredentialsEntity>;
|
|
13
|
+
export declare function sanitizeCredentials(credentials: CredentialsEntity[]): Array<Partial<CredentialsEntity>>;
|
|
14
|
+
export declare function toJsonSchema(properties: INodeProperties[]): IDataObject;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.toJsonSchema = exports.sanitizeCredentials = exports.encryptCredential = exports.removeCredential = exports.saveCredential = exports.createCredential = exports.getSharedCredentials = exports.getCredentials = void 0;
|
|
15
|
+
const n8n_core_1 = require("n8n-core");
|
|
16
|
+
const __1 = require("../../../..");
|
|
17
|
+
const CredentialsEntity_1 = require("../../../../databases/entities/CredentialsEntity");
|
|
18
|
+
const SharedCredentials_1 = require("../../../../databases/entities/SharedCredentials");
|
|
19
|
+
const Server_1 = require("../../../../Server");
|
|
20
|
+
async function getCredentials(credentialId) {
|
|
21
|
+
return __1.Db.collections.Credentials.findOne(credentialId);
|
|
22
|
+
}
|
|
23
|
+
exports.getCredentials = getCredentials;
|
|
24
|
+
async function getSharedCredentials(userId, credentialId, relations) {
|
|
25
|
+
const options = {
|
|
26
|
+
where: {
|
|
27
|
+
user: { id: userId },
|
|
28
|
+
credentials: { id: credentialId },
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
if (relations) {
|
|
32
|
+
options.relations = relations;
|
|
33
|
+
}
|
|
34
|
+
return __1.Db.collections.SharedCredentials.findOne(options);
|
|
35
|
+
}
|
|
36
|
+
exports.getSharedCredentials = getSharedCredentials;
|
|
37
|
+
async function createCredential(properties) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const newCredential = new CredentialsEntity_1.CredentialsEntity();
|
|
40
|
+
Object.assign(newCredential, properties);
|
|
41
|
+
if (!newCredential.nodesAccess || newCredential.nodesAccess.length === 0) {
|
|
42
|
+
newCredential.nodesAccess = [
|
|
43
|
+
{
|
|
44
|
+
nodeType: `n8n-nodes-base.${(_b = (_a = properties.type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : 'unknown'}`,
|
|
45
|
+
date: new Date(),
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
newCredential.nodesAccess.forEach((nodeAccess) => {
|
|
51
|
+
nodeAccess.date = new Date();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return newCredential;
|
|
55
|
+
}
|
|
56
|
+
exports.createCredential = createCredential;
|
|
57
|
+
async function saveCredential(credential, user, encryptedData) {
|
|
58
|
+
const role = await __1.Db.collections.Role.findOneOrFail({
|
|
59
|
+
name: 'owner',
|
|
60
|
+
scope: 'credential',
|
|
61
|
+
});
|
|
62
|
+
await Server_1.externalHooks.run('credentials.create', [encryptedData]);
|
|
63
|
+
return __1.Db.transaction(async (transactionManager) => {
|
|
64
|
+
const savedCredential = await transactionManager.save(credential);
|
|
65
|
+
savedCredential.data = credential.data;
|
|
66
|
+
const newSharedCredential = new SharedCredentials_1.SharedCredentials();
|
|
67
|
+
Object.assign(newSharedCredential, {
|
|
68
|
+
role,
|
|
69
|
+
user,
|
|
70
|
+
credentials: savedCredential,
|
|
71
|
+
});
|
|
72
|
+
await transactionManager.save(newSharedCredential);
|
|
73
|
+
return savedCredential;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.saveCredential = saveCredential;
|
|
77
|
+
async function removeCredential(credentials) {
|
|
78
|
+
await Server_1.externalHooks.run('credentials.delete', [credentials.id]);
|
|
79
|
+
return __1.Db.collections.Credentials.remove(credentials);
|
|
80
|
+
}
|
|
81
|
+
exports.removeCredential = removeCredential;
|
|
82
|
+
async function encryptCredential(credential) {
|
|
83
|
+
const encryptionKey = await n8n_core_1.UserSettings.getEncryptionKey();
|
|
84
|
+
const coreCredential = new n8n_core_1.Credentials({ id: null, name: credential.name }, credential.type, credential.nodesAccess);
|
|
85
|
+
coreCredential.setData(credential.data, encryptionKey);
|
|
86
|
+
return coreCredential.getDataToSave();
|
|
87
|
+
}
|
|
88
|
+
exports.encryptCredential = encryptCredential;
|
|
89
|
+
function sanitizeCredentials(credentials) {
|
|
90
|
+
const argIsArray = Array.isArray(credentials);
|
|
91
|
+
const credentialsList = argIsArray ? credentials : [credentials];
|
|
92
|
+
const sanitizedCredentials = credentialsList.map((credential) => {
|
|
93
|
+
const { data, nodesAccess, shared } = credential, rest = __rest(credential, ["data", "nodesAccess", "shared"]);
|
|
94
|
+
return rest;
|
|
95
|
+
});
|
|
96
|
+
return argIsArray ? sanitizedCredentials : sanitizedCredentials[0];
|
|
97
|
+
}
|
|
98
|
+
exports.sanitizeCredentials = sanitizeCredentials;
|
|
99
|
+
function toJsonSchema(properties) {
|
|
100
|
+
const jsonSchema = {
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {},
|
|
104
|
+
allOf: [],
|
|
105
|
+
required: [],
|
|
106
|
+
};
|
|
107
|
+
const optionsValues = {};
|
|
108
|
+
const resolveProperties = [];
|
|
109
|
+
properties
|
|
110
|
+
.filter((property) => property.type === 'options')
|
|
111
|
+
.forEach((property) => {
|
|
112
|
+
var _a;
|
|
113
|
+
Object.assign(optionsValues, {
|
|
114
|
+
[property.name]: (_a = property.options) === null || _a === void 0 ? void 0 : _a.map((option) => option.value),
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
let requiredFields = [];
|
|
118
|
+
const propertyRequiredDependencies = {};
|
|
119
|
+
properties.forEach((property) => {
|
|
120
|
+
var _a, _b, _c, _d, _e;
|
|
121
|
+
requiredFields.push(property.name);
|
|
122
|
+
if (property.type === 'options') {
|
|
123
|
+
Object.assign(jsonSchema.properties, {
|
|
124
|
+
[property.name]: {
|
|
125
|
+
type: 'string',
|
|
126
|
+
enum: (_a = property.options) === null || _a === void 0 ? void 0 : _a.map((data) => data.value),
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
Object.assign(jsonSchema.properties, {
|
|
132
|
+
[property.name]: {
|
|
133
|
+
type: property.type,
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if ((_b = property.displayOptions) === null || _b === void 0 ? void 0 : _b.show) {
|
|
138
|
+
const dependantName = Object.keys((_c = property.displayOptions) === null || _c === void 0 ? void 0 : _c.show)[0] || '';
|
|
139
|
+
const displayOptionsValues = property.displayOptions.show[dependantName];
|
|
140
|
+
let dependantValue = '';
|
|
141
|
+
if (displayOptionsValues && Array.isArray(displayOptionsValues) && displayOptionsValues[0]) {
|
|
142
|
+
dependantValue = displayOptionsValues[0];
|
|
143
|
+
}
|
|
144
|
+
if (propertyRequiredDependencies[dependantName] === undefined) {
|
|
145
|
+
propertyRequiredDependencies[dependantName] = {};
|
|
146
|
+
}
|
|
147
|
+
if (!resolveProperties.includes(dependantName)) {
|
|
148
|
+
propertyRequiredDependencies[dependantName] = {
|
|
149
|
+
if: {
|
|
150
|
+
properties: {
|
|
151
|
+
[dependantName]: {
|
|
152
|
+
enum: [dependantValue],
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
then: {
|
|
157
|
+
oneOf: [],
|
|
158
|
+
},
|
|
159
|
+
else: {
|
|
160
|
+
allOf: [],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
(_d = propertyRequiredDependencies[dependantName].then) === null || _d === void 0 ? void 0 : _d.oneOf.push({ required: [property.name] });
|
|
165
|
+
(_e = propertyRequiredDependencies[dependantName].else) === null || _e === void 0 ? void 0 : _e.allOf.push({
|
|
166
|
+
not: { required: [property.name] },
|
|
167
|
+
});
|
|
168
|
+
resolveProperties.push(dependantName);
|
|
169
|
+
requiredFields = requiredFields.filter((field) => field !== property.name);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.assign(jsonSchema, { required: requiredFields });
|
|
173
|
+
jsonSchema.allOf = Object.values(propertyRequiredDependencies);
|
|
174
|
+
if (!jsonSchema.allOf.length) {
|
|
175
|
+
delete jsonSchema.allOf;
|
|
176
|
+
}
|
|
177
|
+
return jsonSchema;
|
|
178
|
+
}
|
|
179
|
+
exports.toJsonSchema = toJsonSchema;
|
|
180
|
+
//# sourceMappingURL=credentials.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.service.js","sourceRoot":"","sources":["../../../../../../src/PublicApi/v1/handlers/credentials/credentials.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,uCAAqD;AAErD,mCAAiD;AACjD,wFAAqF;AACrF,wFAAqF;AAErF,+CAAmD;AAG5C,KAAK,UAAU,cAAc,CACnC,YAA6B;IAE7B,OAAO,MAAE,CAAC,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACzD,CAAC;AAJD,wCAIC;AAEM,KAAK,UAAU,oBAAoB,CACzC,MAAc,EACd,YAA6B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ExecutionRequest } from '../../../types';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
deleteExecution: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: ExecutionRequest.Delete, res: express.Response) => Promise<express.Response>))[];
|
|
5
|
+
getExecution: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: ExecutionRequest.Get, res: express.Response) => Promise<express.Response>))[];
|
|
6
|
+
getExecutions: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: ExecutionRequest.GetAll, res: express.Response) => Promise<express.Response>))[];
|
|
7
|
+
};
|
|
8
|
+
export = _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const n8n_core_1 = require("n8n-core");
|
|
3
|
+
const executions_service_1 = require("./executions.service");
|
|
4
|
+
const __1 = require("../../../..");
|
|
5
|
+
const global_middleware_1 = require("../../shared/middlewares/global.middleware");
|
|
6
|
+
const workflows_service_1 = require("../workflows/workflows.service");
|
|
7
|
+
const pagination_service_1 = require("../../shared/services/pagination.service");
|
|
8
|
+
const InternalHooksManager_1 = require("../../../../InternalHooksManager");
|
|
9
|
+
module.exports = {
|
|
10
|
+
deleteExecution: [
|
|
11
|
+
(0, global_middleware_1.authorize)(['owner', 'member']),
|
|
12
|
+
async (req, res) => {
|
|
13
|
+
const { id } = req.params;
|
|
14
|
+
const sharedWorkflowsIds = await (0, workflows_service_1.getSharedWorkflowIds)(req.user);
|
|
15
|
+
if (!sharedWorkflowsIds.length) {
|
|
16
|
+
return res.status(404).json({
|
|
17
|
+
message: 'Not Found',
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const execution = await (0, executions_service_1.getExecutionInWorkflows)(id, sharedWorkflowsIds, false);
|
|
21
|
+
if (!execution) {
|
|
22
|
+
return res.status(404).json({
|
|
23
|
+
message: 'Not Found',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const binaryDataManager = n8n_core_1.BinaryDataManager.getInstance();
|
|
27
|
+
await binaryDataManager.deleteBinaryDataByExecutionId(execution.id.toString());
|
|
28
|
+
await (0, executions_service_1.deleteExecution)(execution);
|
|
29
|
+
execution.id = id;
|
|
30
|
+
return res.json(execution);
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
getExecution: [
|
|
34
|
+
(0, global_middleware_1.authorize)(['owner', 'member']),
|
|
35
|
+
async (req, res) => {
|
|
36
|
+
const { id } = req.params;
|
|
37
|
+
const { includeData = false } = req.query;
|
|
38
|
+
const sharedWorkflowsIds = await (0, workflows_service_1.getSharedWorkflowIds)(req.user);
|
|
39
|
+
if (!sharedWorkflowsIds.length) {
|
|
40
|
+
return res.status(404).json({
|
|
41
|
+
message: 'Not Found',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const execution = await (0, executions_service_1.getExecutionInWorkflows)(id, sharedWorkflowsIds, includeData);
|
|
45
|
+
if (!execution) {
|
|
46
|
+
return res.status(404).json({
|
|
47
|
+
message: 'Not Found',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const telemetryData = {
|
|
51
|
+
user_id: req.user.id,
|
|
52
|
+
public_api: true,
|
|
53
|
+
};
|
|
54
|
+
void InternalHooksManager_1.InternalHooksManager.getInstance().onUserRetrievedExecution(telemetryData);
|
|
55
|
+
return res.json(execution);
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
getExecutions: [
|
|
59
|
+
(0, global_middleware_1.authorize)(['owner', 'member']),
|
|
60
|
+
global_middleware_1.validCursor,
|
|
61
|
+
async (req, res) => {
|
|
62
|
+
const { lastId = undefined, limit = 100, status = undefined, includeData = false, workflowId = undefined, } = req.query;
|
|
63
|
+
const sharedWorkflowsIds = await (0, workflows_service_1.getSharedWorkflowIds)(req.user);
|
|
64
|
+
if (!sharedWorkflowsIds.length) {
|
|
65
|
+
return res.status(200).json({
|
|
66
|
+
data: [],
|
|
67
|
+
nextCursor: null,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const runningExecutionsIds = __1.ActiveExecutions.getInstance()
|
|
71
|
+
.getActiveExecutions()
|
|
72
|
+
.map(({ id }) => Number(id));
|
|
73
|
+
const filters = Object.assign(Object.assign({ status,
|
|
74
|
+
limit,
|
|
75
|
+
lastId,
|
|
76
|
+
includeData }, (workflowId && { workflowIds: [workflowId] })), { excludedExecutionsIds: runningExecutionsIds });
|
|
77
|
+
const executions = await (0, executions_service_1.getExecutions)(filters);
|
|
78
|
+
const newLastId = !executions.length ? 0 : executions.slice(-1)[0].id;
|
|
79
|
+
filters.lastId = newLastId;
|
|
80
|
+
const count = await (0, executions_service_1.getExecutionsCount)(filters);
|
|
81
|
+
const telemetryData = {
|
|
82
|
+
user_id: req.user.id,
|
|
83
|
+
public_api: true,
|
|
84
|
+
};
|
|
85
|
+
void InternalHooksManager_1.InternalHooksManager.getInstance().onUserRetrievedAllExecutions(telemetryData);
|
|
86
|
+
return res.json({
|
|
87
|
+
data: executions,
|
|
88
|
+
nextCursor: (0, pagination_service_1.encodeNextCursor)({
|
|
89
|
+
lastId: newLastId,
|
|
90
|
+
limit,
|
|
91
|
+
numberOfNextRecords: count,
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=executions.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executions.handler.js","sourceRoot":"","sources":["../../../../../../src/PublicApi/v1/handlers/executions/executions.handler.ts"],"names":[],"mappings":";AAEA,uCAA6C;AAC7C,6DAK8B;AAE9B,mCAA+C;AAC/C,kFAAoF;AAGpF,sEAAsE;AACtE,iFAA4E;AAC5E,2EAAwE;AAExE,iBAAS;IACR,eAAe,EAAE;QAChB,IAAA,6BAAS,EAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC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';
|
|
2
|
+
import { ExecutionStatus } from '../../../types';
|
|
3
|
+
export declare function getExecutions(data: {
|
|
4
|
+
limit: number;
|
|
5
|
+
includeData?: boolean;
|
|
6
|
+
lastId?: number;
|
|
7
|
+
workflowIds?: number[];
|
|
8
|
+
status?: ExecutionStatus;
|
|
9
|
+
excludedExecutionsIds?: number[];
|
|
10
|
+
}): Promise<IExecutionResponseApi[]>;
|
|
11
|
+
export declare function getExecutionsCount(data: {
|
|
12
|
+
limit: number;
|
|
13
|
+
lastId?: number;
|
|
14
|
+
workflowIds?: number[];
|
|
15
|
+
status?: ExecutionStatus;
|
|
16
|
+
excludedWorkflowIds?: number[];
|
|
17
|
+
}): Promise<number>;
|
|
18
|
+
export declare function getExecutionInWorkflows(id: number, workflows: number[], includeData?: boolean): Promise<IExecutionResponseApi | undefined>;
|
|
19
|
+
export declare function deleteExecution(execution: IExecutionResponseApi | undefined): Promise<void>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteExecution = exports.getExecutionInWorkflows = exports.getExecutionsCount = exports.getExecutions = void 0;
|
|
4
|
+
const flatted_1 = require("flatted");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const __1 = require("../../../..");
|
|
7
|
+
function prepareExecutionData(execution) {
|
|
8
|
+
if (execution === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
if (!execution.data) {
|
|
12
|
+
return execution;
|
|
13
|
+
}
|
|
14
|
+
return Object.assign(Object.assign({}, execution), { data: (0, flatted_1.parse)(execution.data) });
|
|
15
|
+
}
|
|
16
|
+
function getStatusCondition(status) {
|
|
17
|
+
const condition = {};
|
|
18
|
+
if (status === 'success') {
|
|
19
|
+
condition.finished = true;
|
|
20
|
+
}
|
|
21
|
+
else if (status === 'waiting') {
|
|
22
|
+
condition.waitTill = (0, typeorm_1.Not)((0, typeorm_1.IsNull)());
|
|
23
|
+
}
|
|
24
|
+
else if (status === 'error') {
|
|
25
|
+
condition.stoppedAt = (0, typeorm_1.Not)((0, typeorm_1.IsNull)());
|
|
26
|
+
condition.finished = false;
|
|
27
|
+
}
|
|
28
|
+
return condition;
|
|
29
|
+
}
|
|
30
|
+
function getExecutionSelectableProperties(includeData) {
|
|
31
|
+
const returnData = [
|
|
32
|
+
'id',
|
|
33
|
+
'mode',
|
|
34
|
+
'retryOf',
|
|
35
|
+
'retrySuccessId',
|
|
36
|
+
'startedAt',
|
|
37
|
+
'stoppedAt',
|
|
38
|
+
'workflowId',
|
|
39
|
+
'waitTill',
|
|
40
|
+
'finished',
|
|
41
|
+
];
|
|
42
|
+
if (includeData) {
|
|
43
|
+
returnData.push('data');
|
|
44
|
+
}
|
|
45
|
+
return returnData;
|
|
46
|
+
}
|
|
47
|
+
async function getExecutions(data) {
|
|
48
|
+
const executions = await __1.Db.collections.Execution.find({
|
|
49
|
+
select: getExecutionSelectableProperties(data.includeData),
|
|
50
|
+
where: Object.assign(Object.assign(Object.assign(Object.assign({}, (data.lastId && { id: (0, typeorm_1.LessThan)(data.lastId) })), (data.status && Object.assign({}, getStatusCondition(data.status)))), (data.workflowIds && { workflowId: (0, typeorm_1.In)(data.workflowIds.map(String)) })), (data.excludedExecutionsIds && { id: (0, typeorm_1.Not)((0, typeorm_1.In)(data.excludedExecutionsIds)) })),
|
|
51
|
+
order: { id: 'DESC' },
|
|
52
|
+
take: data.limit,
|
|
53
|
+
});
|
|
54
|
+
return executions.map((execution) => prepareExecutionData(execution));
|
|
55
|
+
}
|
|
56
|
+
exports.getExecutions = getExecutions;
|
|
57
|
+
async function getExecutionsCount(data) {
|
|
58
|
+
const executions = await __1.Db.collections.Execution.count({
|
|
59
|
+
where: Object.assign(Object.assign(Object.assign(Object.assign({}, (data.lastId && { id: (0, typeorm_1.LessThan)(data.lastId) })), (data.status && Object.assign({}, getStatusCondition(data.status)))), (data.workflowIds && { workflowId: (0, typeorm_1.In)(data.workflowIds) })), (data.excludedWorkflowIds && { workflowId: (0, typeorm_1.Not)((0, typeorm_1.In)(data.excludedWorkflowIds)) })),
|
|
60
|
+
take: data.limit,
|
|
61
|
+
});
|
|
62
|
+
return executions;
|
|
63
|
+
}
|
|
64
|
+
exports.getExecutionsCount = getExecutionsCount;
|
|
65
|
+
async function getExecutionInWorkflows(id, workflows, includeData) {
|
|
66
|
+
const execution = await __1.Db.collections.Execution.findOne({
|
|
67
|
+
select: getExecutionSelectableProperties(includeData),
|
|
68
|
+
where: {
|
|
69
|
+
id,
|
|
70
|
+
workflowId: (0, typeorm_1.In)(workflows),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
return prepareExecutionData(execution);
|
|
74
|
+
}
|
|
75
|
+
exports.getExecutionInWorkflows = getExecutionInWorkflows;
|
|
76
|
+
async function deleteExecution(execution) {
|
|
77
|
+
await __1.Db.collections.Execution.remove(execution);
|
|
78
|
+
}
|
|
79
|
+
exports.deleteExecution = deleteExecution;
|
|
80
|
+
//# sourceMappingURL=executions.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"executions.service.js","sourceRoot":"","sources":["../../../../../../src/PublicApi/v1/handlers/executions/executions.service.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAChC,qCAAmE;AACnE,mCAA6E;AAG7E,SAAS,oBAAoB,CAC5B,SAA0C;IAE1C,IAAI,SAAS,KAAK,SAAS,EAAE;QAC5B,OAAO,SAAS,CAAC;KACjB;IAED,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QACpB,OAAO,SAAS,CAAC;KACjB;IAED,uCACI,SAAS,KAEZ,IAAI,EAAE,IAAA,eAAK,EAAC,SAAS,CAAC,IAAI,CAAC,IAC1B;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAuB;IAClD,MAAM,SAAS,GAAkB,EAAE,CAAC;IAEpC,IAAI,MAAM,KAAK,SAAS,EAAE;QACzB,SAAS,CAAC,QAAQ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AE,EAAC,SAAS,CAAC;SACzB;KACD,CAAC,CAAC;IACH,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC;AAbD,0DAaC;AAEM,KAAK,UAAU,eAAe,CAAC,SAA4C;IACjF,MAAM,MAAE,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,SAAgC,CAAC,CAAC;AACzE,CAAC;AAFD,0CAEC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWorkflowOwnerRole = exports.isInstanceOwner = void 0;
|
|
4
|
+
const __1 = require("../../../..");
|
|
5
|
+
function isInstanceOwner(user) {
|
|
6
|
+
return user.globalRole.name === 'owner';
|
|
7
|
+
}
|
|
8
|
+
exports.isInstanceOwner = isInstanceOwner;
|
|
9
|
+
async function getWorkflowOwnerRole() {
|
|
10
|
+
return __1.Db.collections.Role.findOneOrFail({
|
|
11
|
+
name: 'owner',
|
|
12
|
+
scope: 'workflow',
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.getWorkflowOwnerRole = getWorkflowOwnerRole;
|
|
16
|
+
//# sourceMappingURL=users.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../../../../../src/PublicApi/v1/handlers/users/users.service.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAIjC,SAAgB,eAAe,CAAC,IAAU;IACzC,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC;AACzC,CAAC;AAFD,0CAEC;AAEM,KAAK,UAAU,oBAAoB;IACzC,OAAO,MAAE,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,UAAU;KACjB,CAAC,CAAC;AACJ,CAAC;AALD,oDAKC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import express = require('express');
|
|
2
|
+
import { WorkflowRequest } from '../../../types';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
createWorkflow: express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>[];
|
|
5
|
+
deleteWorkflow: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: WorkflowRequest.Get, res: express.Response) => Promise<express.Response>))[];
|
|
6
|
+
getWorkflow: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: WorkflowRequest.Get, res: express.Response) => Promise<express.Response>))[];
|
|
7
|
+
getWorkflows: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: WorkflowRequest.GetAll, res: express.Response) => Promise<express.Response>))[];
|
|
8
|
+
updateWorkflow: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: WorkflowRequest.Update, res: express.Response) => Promise<express.Response>))[];
|
|
9
|
+
activateWorkflow: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: WorkflowRequest.Activate, res: express.Response) => Promise<express.Response>))[];
|
|
10
|
+
deactivateWorkflow: (express.RequestHandler<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | ((req: WorkflowRequest.Activate, res: express.Response) => Promise<express.Response>))[];
|
|
11
|
+
};
|
|
12
|
+
export = _default;
|