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.
Files changed (170) hide show
  1. package/dist/commands/export/workflow.js +4 -1
  2. package/dist/commands/export/workflow.js.map +1 -1
  3. package/dist/commands/import/workflow.js +22 -5
  4. package/dist/commands/import/workflow.js.map +1 -1
  5. package/dist/commands/worker.js +3 -2
  6. package/dist/commands/worker.js.map +1 -1
  7. package/dist/config/index.d.ts +4 -0
  8. package/dist/config/schema.d.ts +14 -0
  9. package/dist/config/schema.js +16 -2
  10. package/dist/config/schema.js.map +1 -1
  11. package/dist/src/ActiveWorkflowRunner.d.ts +2 -1
  12. package/dist/src/ActiveWorkflowRunner.js +66 -6
  13. package/dist/src/ActiveWorkflowRunner.js.map +1 -1
  14. package/dist/src/CredentialsHelper.d.ts +2 -0
  15. package/dist/src/CredentialsHelper.js +13 -5
  16. package/dist/src/CredentialsHelper.js.map +1 -1
  17. package/dist/src/Interfaces.d.ts +41 -6
  18. package/dist/src/InternalHooks.d.ts +46 -4
  19. package/dist/src/InternalHooks.js +36 -6
  20. package/dist/src/InternalHooks.js.map +1 -1
  21. package/dist/src/PublicApi/index.d.ts +5 -0
  22. package/dist/src/PublicApi/index.js +122 -0
  23. package/dist/src/PublicApi/index.js.map +1 -0
  24. package/dist/src/PublicApi/swaggerTheme.css +26 -0
  25. package/dist/src/PublicApi/v1/handlers/credentials/credentials.handler.d.ts +7 -0
  26. package/dist/src/PublicApi/v1/handlers/credentials/credentials.handler.js +72 -0
  27. package/dist/src/PublicApi/v1/handlers/credentials/credentials.handler.js.map +1 -0
  28. package/dist/src/PublicApi/v1/handlers/credentials/credentials.middleware.d.ts +3 -0
  29. package/dist/src/PublicApi/v1/handlers/credentials/credentials.middleware.js +34 -0
  30. package/dist/src/PublicApi/v1/handlers/credentials/credentials.middleware.js.map +1 -0
  31. package/dist/src/PublicApi/v1/handlers/credentials/credentials.service.d.ts +14 -0
  32. package/dist/src/PublicApi/v1/handlers/credentials/credentials.service.js +180 -0
  33. package/dist/src/PublicApi/v1/handlers/credentials/credentials.service.js.map +1 -0
  34. package/dist/src/PublicApi/v1/handlers/executions/executions.handler.d.ts +8 -0
  35. package/dist/src/PublicApi/v1/handlers/executions/executions.handler.js +97 -0
  36. package/dist/src/PublicApi/v1/handlers/executions/executions.handler.js.map +1 -0
  37. package/dist/src/PublicApi/v1/handlers/executions/executions.service.d.ts +19 -0
  38. package/dist/src/PublicApi/v1/handlers/executions/executions.service.js +80 -0
  39. package/dist/src/PublicApi/v1/handlers/executions/executions.service.js.map +1 -0
  40. package/dist/src/PublicApi/v1/handlers/users/users.service.d.ts +4 -0
  41. package/dist/src/PublicApi/v1/handlers/users/users.service.js +16 -0
  42. package/dist/src/PublicApi/v1/handlers/users/users.service.js.map +1 -0
  43. package/dist/src/PublicApi/v1/handlers/workflows/workflows.handler.d.ts +12 -0
  44. package/dist/src/PublicApi/v1/handlers/workflows/workflows.handler.js +199 -0
  45. package/dist/src/PublicApi/v1/handlers/workflows/workflows.handler.js.map +1 -0
  46. package/dist/src/PublicApi/v1/handlers/workflows/workflows.service.d.ts +24 -0
  47. package/dist/src/PublicApi/v1/handlers/workflows/workflows.service.js +113 -0
  48. package/dist/src/PublicApi/v1/handlers/workflows/workflows.service.js.map +1 -0
  49. package/dist/src/PublicApi/v1/openapi.yml +703 -0
  50. package/dist/src/PublicApi/v1/shared/middlewares/global.middleware.d.ts +5 -0
  51. package/dist/src/PublicApi/v1/shared/middlewares/global.middleware.js +38 -0
  52. package/dist/src/PublicApi/v1/shared/middlewares/global.middleware.js.map +1 -0
  53. package/dist/src/PublicApi/v1/shared/services/pagination.service.d.ts +3 -0
  54. package/dist/src/PublicApi/v1/shared/services/pagination.service.js +33 -0
  55. package/dist/src/PublicApi/v1/shared/services/pagination.service.js.map +1 -0
  56. package/dist/src/ResponseHelper.d.ts +1 -1
  57. package/dist/src/ResponseHelper.js +2 -2
  58. package/dist/src/ResponseHelper.js.map +1 -1
  59. package/dist/src/Server.js +29 -13
  60. package/dist/src/Server.js.map +1 -1
  61. package/dist/src/TagHelpers.d.ts +3 -1
  62. package/dist/src/TagHelpers.js +47 -1
  63. package/dist/src/TagHelpers.js.map +1 -1
  64. package/dist/src/UserManagement/UserManagementHelper.js +1 -1
  65. package/dist/src/UserManagement/UserManagementHelper.js.map +1 -1
  66. package/dist/src/UserManagement/auth/jwt.d.ts +1 -1
  67. package/dist/src/UserManagement/routes/me.js +27 -0
  68. package/dist/src/UserManagement/routes/me.js.map +1 -1
  69. package/dist/src/UserManagement/routes/passwordReset.js +2 -0
  70. package/dist/src/UserManagement/routes/passwordReset.js.map +1 -1
  71. package/dist/src/UserManagement/routes/users.js +7 -1
  72. package/dist/src/UserManagement/routes/users.js.map +1 -1
  73. package/dist/src/WebhookHelpers.js +8 -7
  74. package/dist/src/WebhookHelpers.js.map +1 -1
  75. package/dist/src/WebhookServer.js.map +1 -1
  76. package/dist/src/WorkflowExecuteAdditionalData.d.ts +2 -1
  77. package/dist/src/WorkflowExecuteAdditionalData.js +45 -16
  78. package/dist/src/WorkflowExecuteAdditionalData.js.map +1 -1
  79. package/dist/src/WorkflowHelpers.js +2 -0
  80. package/dist/src/WorkflowHelpers.js.map +1 -1
  81. package/dist/src/WorkflowRunner.js +2 -0
  82. package/dist/src/WorkflowRunner.js.map +1 -1
  83. package/dist/src/api/credentials.api.js +4 -3
  84. package/dist/src/api/credentials.api.js.map +1 -1
  85. package/dist/src/databases/entities/User.d.ts +1 -0
  86. package/dist/src/databases/entities/User.js +7 -2
  87. package/dist/src/databases/entities/User.js.map +1 -1
  88. package/dist/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.d.ts +6 -0
  89. package/dist/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.js +28 -0
  90. package/dist/src/databases/mysqldb/migrations/1652905585850-AddAPIKeyColumn.js.map +1 -0
  91. package/dist/src/databases/mysqldb/migrations/index.js +2 -0
  92. package/dist/src/databases/mysqldb/migrations/index.js.map +1 -1
  93. package/dist/src/databases/postgresdb/migrations/1587669153312-InitialMigration.js +2 -0
  94. package/dist/src/databases/postgresdb/migrations/1587669153312-InitialMigration.js.map +1 -1
  95. package/dist/src/databases/postgresdb/migrations/1589476000887-WebhookModel.js +2 -0
  96. package/dist/src/databases/postgresdb/migrations/1589476000887-WebhookModel.js.map +1 -1
  97. package/dist/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.js +9 -2
  98. package/dist/src/databases/postgresdb/migrations/1594828256133-CreateIndexStoppedAt.js.map +1 -1
  99. package/dist/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.js +1 -0
  100. package/dist/src/databases/postgresdb/migrations/1607431743768-MakeStoppedAtNullable.js.map +1 -1
  101. package/dist/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.js +2 -0
  102. package/dist/src/databases/postgresdb/migrations/1611144599516-AddWebhookId.js.map +1 -1
  103. package/dist/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.js +2 -0
  104. package/dist/src/databases/postgresdb/migrations/1617270242566-CreateTagEntity.js.map +1 -1
  105. package/dist/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.js +2 -0
  106. package/dist/src/databases/postgresdb/migrations/1620824779533-UniqueWorkflowNames.js.map +1 -1
  107. package/dist/src/databases/postgresdb/migrations/1626176912946-AddwaitTill.js +2 -0
  108. package/dist/src/databases/postgresdb/migrations/1626176912946-AddwaitTill.js.map +1 -1
  109. package/dist/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.js +2 -0
  110. package/dist/src/databases/postgresdb/migrations/1630419189837-UpdateWorkflowCredentials.js.map +1 -1
  111. package/dist/src/databases/postgresdb/migrations/1644422880309-AddExecutionEntityIndexes.js +7 -6
  112. package/dist/src/databases/postgresdb/migrations/1644422880309-AddExecutionEntityIndexes.js.map +1 -1
  113. package/dist/src/databases/postgresdb/migrations/1646834195327-IncreaseTypeVarcharLimit.js +6 -1
  114. package/dist/src/databases/postgresdb/migrations/1646834195327-IncreaseTypeVarcharLimit.js.map +1 -1
  115. package/dist/src/databases/postgresdb/migrations/1646992772331-CreateUserManagement.js +5 -3
  116. package/dist/src/databases/postgresdb/migrations/1646992772331-CreateUserManagement.js.map +1 -1
  117. package/dist/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.js +1 -0
  118. package/dist/src/databases/postgresdb/migrations/1648740597343-LowerCaseUserEmail.js.map +1 -1
  119. package/dist/src/databases/postgresdb/migrations/1652367743993-AddUserSettings.js +2 -0
  120. package/dist/src/databases/postgresdb/migrations/1652367743993-AddUserSettings.js.map +1 -1
  121. package/dist/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.d.ts +6 -0
  122. package/dist/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.js +32 -0
  123. package/dist/src/databases/postgresdb/migrations/1652905585850-AddAPIKeyColumn.js.map +1 -0
  124. package/dist/src/databases/postgresdb/migrations/index.js +2 -0
  125. package/dist/src/databases/postgresdb/migrations/index.js.map +1 -1
  126. package/dist/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.d.ts +6 -0
  127. package/dist/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.js +58 -0
  128. package/dist/src/databases/sqlite/migrations/1652905585850-AddAPIKeyColumn.js.map +1 -0
  129. package/dist/src/databases/sqlite/migrations/index.js +2 -0
  130. package/dist/src/databases/sqlite/migrations/index.js.map +1 -1
  131. package/dist/test/integration/auth.api.test.js +11 -6
  132. package/dist/test/integration/auth.api.test.js.map +1 -1
  133. package/dist/test/integration/auth.mw.test.js +1 -1
  134. package/dist/test/integration/auth.mw.test.js.map +1 -1
  135. package/dist/test/integration/commands/reset.cmd.test.d.ts +1 -0
  136. package/dist/test/integration/commands/reset.cmd.test.js +59 -0
  137. package/dist/test/integration/commands/reset.cmd.test.js.map +1 -0
  138. package/dist/test/integration/credentials.api.test.js +1 -1
  139. package/dist/test/integration/credentials.api.test.js.map +1 -1
  140. package/dist/test/integration/me.api.test.js +78 -7
  141. package/dist/test/integration/me.api.test.js.map +1 -1
  142. package/dist/test/integration/owner.api.test.js +3 -2
  143. package/dist/test/integration/owner.api.test.js.map +1 -1
  144. package/dist/test/integration/passwordReset.api.test.js +1 -1
  145. package/dist/test/integration/passwordReset.api.test.js.map +1 -1
  146. package/dist/test/integration/publicApi/credentials.test.d.ts +1 -0
  147. package/dist/test/integration/publicApi/credentials.test.js +321 -0
  148. package/dist/test/integration/publicApi/credentials.test.js.map +1 -0
  149. package/dist/test/integration/publicApi/executions.test.d.ts +1 -0
  150. package/dist/test/integration/publicApi/executions.test.js +289 -0
  151. package/dist/test/integration/publicApi/executions.test.js.map +1 -0
  152. package/dist/test/integration/publicApi/workflows.test.d.ts +1 -0
  153. package/dist/test/integration/publicApi/workflows.test.js +948 -0
  154. package/dist/test/integration/publicApi/workflows.test.js.map +1 -0
  155. package/dist/test/integration/shared/constants.d.ts +1 -0
  156. package/dist/test/integration/shared/constants.js +2 -1
  157. package/dist/test/integration/shared/constants.js.map +1 -1
  158. package/dist/test/integration/shared/random.d.ts +1 -0
  159. package/dist/test/integration/shared/random.js +8 -2
  160. package/dist/test/integration/shared/random.js.map +1 -1
  161. package/dist/test/integration/shared/testDb.d.ts +115 -4
  162. package/dist/test/integration/shared/testDb.js +132 -10
  163. package/dist/test/integration/shared/testDb.js.map +1 -1
  164. package/dist/test/integration/shared/utils.d.ts +206 -3
  165. package/dist/test/integration/shared/utils.js +582 -18
  166. package/dist/test/integration/shared/utils.js.map +1 -1
  167. package/dist/test/integration/users.api.test.js +6 -4
  168. package/dist/test/integration/users.api.test.js.map +1 -1
  169. package/oclif.manifest.json +1 -1
  170. package/package.json +22 -15
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.categorize = exports.skipSmtpTest = exports.isTestSmtpServiceAvailable = exports.configureSmtp = exports.isInstanceOwnerSetUp = exports.getAuthToken = exports.prefix = exports.createAgent = exports.initConfigFile = exports.initTestLogger = exports.initTestTelemetry = exports.initTestServer = void 0;
29
+ exports.getPostgresSchemaSection = exports.categorize = exports.skipSmtpTest = exports.isTestSmtpServiceAvailable = exports.configureSmtp = exports.isInstanceOwnerSetUp = exports.getAuthToken = exports.prefix = exports.createAgent = exports.initConfigFile = exports.initBinaryManager = exports.initTestLogger = exports.initNodeTypes = exports.initCredentialsTypes = exports.gitHubCredentialType = exports.initActiveWorkflowRunner = exports.initTestTelemetry = exports.initTestServer = void 0;
30
30
  const crypto_1 = require("crypto");
31
31
  const fs_1 = require("fs");
32
32
  const express_1 = __importDefault(require("express"));
@@ -37,7 +37,8 @@ const util_1 = __importDefault(require("util"));
37
37
  const nodemailer_1 = require("nodemailer");
38
38
  const n8n_workflow_1 = require("n8n-workflow");
39
39
  const n8n_core_1 = require("n8n-core");
40
- const config_1 = __importDefault(require("../../../config"));
40
+ const cron_1 = require("cron");
41
+ const config = require("../../../config");
41
42
  const constants_1 = require("./constants");
42
43
  const constants_2 = require("../../../src/constants");
43
44
  const routes_1 = require("../../../src/UserManagement/routes");
@@ -50,13 +51,15 @@ const passwordReset_1 = require("../../../src/UserManagement/routes/passwordRese
50
51
  const jwt_1 = require("../../../src/UserManagement/auth/jwt");
51
52
  const Logger_1 = require("../../../src/Logger");
52
53
  const credentials_api_1 = require("../../../src/api/credentials.api");
54
+ const PublicApi_1 = require("../../../src/PublicApi/");
55
+ const lodash_1 = require("lodash");
53
56
  const UserManagementMailer = __importStar(require("../../../src/UserManagement/email/UserManagementMailer"));
54
- function initTestServer({ applyAuth, endpointGroups, }) {
55
- const testServer = Object.assign({ app: (0, express_1.default)(), restEndpoint: constants_1.REST_PATH_SEGMENT }, ((endpointGroups === null || endpointGroups === void 0 ? void 0 : endpointGroups.includes('credentials')) ? { externalHooks: (0, src_1.ExternalHooks)() } : {}));
57
+ async function initTestServer({ applyAuth, endpointGroups, }) {
58
+ const testServer = Object.assign({ app: (0, express_1.default)(), restEndpoint: constants_1.REST_PATH_SEGMENT, publicApiEndpoint: constants_1.PUBLIC_API_REST_PATH_SEGMENT }, ((endpointGroups === null || endpointGroups === void 0 ? void 0 : endpointGroups.includes('credentials')) ? { externalHooks: (0, src_1.ExternalHooks)() } : {}));
56
59
  testServer.app.use(body_parser_1.default.json());
57
60
  testServer.app.use(body_parser_1.default.urlencoded({ extended: true }));
58
- config_1.default.set('userManagement.jwtSecret', 'My JWT secret');
59
- config_1.default.set('userManagement.isInstanceOwnerSetUp', false);
61
+ config.set('userManagement.jwtSecret', 'My JWT secret');
62
+ config.set('userManagement.isInstanceOwnerSetUp', false);
60
63
  if (applyAuth) {
61
64
  routes_1.addRoutes.apply(testServer, [constants_1.AUTHLESS_ENDPOINTS, constants_1.REST_PATH_SEGMENT]);
62
65
  }
@@ -64,11 +67,18 @@ function initTestServer({ applyAuth, endpointGroups, }) {
64
67
  return testServer.app;
65
68
  const [routerEndpoints, functionEndpoints] = classifyEndpointGroups(endpointGroups);
66
69
  if (routerEndpoints.length) {
70
+ const { apiRouters } = await (0, PublicApi_1.loadPublicApiVersions)(testServer.publicApiEndpoint);
67
71
  const map = {
68
72
  credentials: credentials_api_1.credentialsController,
73
+ publicApi: apiRouters
69
74
  };
70
75
  for (const group of routerEndpoints) {
71
- testServer.app.use(`/${testServer.restEndpoint}/${group}`, map[group]);
76
+ if (group === 'publicApi') {
77
+ testServer.app.use(...map[group]);
78
+ }
79
+ else {
80
+ testServer.app.use(`/${testServer.restEndpoint}/${group}`, map[group]);
81
+ }
72
82
  }
73
83
  }
74
84
  if (functionEndpoints.length) {
@@ -94,13 +104,550 @@ exports.initTestTelemetry = initTestTelemetry;
94
104
  const classifyEndpointGroups = (endpointGroups) => {
95
105
  const routerEndpoints = [];
96
106
  const functionEndpoints = [];
97
- endpointGroups.forEach((group) => (group === 'credentials' ? routerEndpoints : functionEndpoints).push(group));
107
+ endpointGroups.forEach((group) => (group === 'credentials' || group === 'publicApi' ? routerEndpoints : functionEndpoints).push(group));
98
108
  return [routerEndpoints, functionEndpoints];
99
109
  };
110
+ async function initActiveWorkflowRunner() {
111
+ const workflowRunner = src_1.ActiveWorkflowRunner.getInstance();
112
+ workflowRunner.init();
113
+ return workflowRunner;
114
+ }
115
+ exports.initActiveWorkflowRunner = initActiveWorkflowRunner;
116
+ function gitHubCredentialType() {
117
+ return {
118
+ name: 'githubApi',
119
+ displayName: 'Github API',
120
+ documentationUrl: 'github',
121
+ properties: [
122
+ {
123
+ displayName: 'Github Server',
124
+ name: 'server',
125
+ type: 'string',
126
+ default: 'https://api.github.com',
127
+ description: 'The server to connect to. Only has to be set if Github Enterprise is used.',
128
+ },
129
+ {
130
+ displayName: 'User',
131
+ name: 'user',
132
+ type: 'string',
133
+ default: '',
134
+ },
135
+ {
136
+ displayName: 'Access Token',
137
+ name: 'accessToken',
138
+ type: 'string',
139
+ default: '',
140
+ },
141
+ ],
142
+ };
143
+ }
144
+ exports.gitHubCredentialType = gitHubCredentialType;
145
+ async function initCredentialsTypes() {
146
+ const credentialTypes = (0, src_1.CredentialTypes)();
147
+ await credentialTypes.init({
148
+ githubApi: {
149
+ type: gitHubCredentialType(),
150
+ sourcePath: '',
151
+ },
152
+ });
153
+ }
154
+ exports.initCredentialsTypes = initCredentialsTypes;
155
+ async function initNodeTypes() {
156
+ const types = {
157
+ 'n8n-nodes-base.start': {
158
+ sourcePath: '',
159
+ type: {
160
+ description: {
161
+ displayName: 'Start',
162
+ name: 'start',
163
+ group: ['input'],
164
+ version: 1,
165
+ description: 'Starts the workflow execution from this node',
166
+ defaults: {
167
+ name: 'Start',
168
+ color: '#553399',
169
+ },
170
+ inputs: [],
171
+ outputs: ['main'],
172
+ properties: [],
173
+ },
174
+ execute() {
175
+ const items = this.getInputData();
176
+ return this.prepareOutputData(items);
177
+ },
178
+ },
179
+ },
180
+ 'n8n-nodes-base.cron': {
181
+ sourcePath: '',
182
+ type: {
183
+ description: {
184
+ displayName: 'Cron',
185
+ name: 'cron',
186
+ icon: 'fa:calendar',
187
+ group: ['trigger', 'schedule'],
188
+ version: 1,
189
+ description: 'Triggers the workflow at a specific time',
190
+ eventTriggerDescription: '',
191
+ activationMessage: 'Your cron trigger will now trigger executions on the schedule you have defined.',
192
+ defaults: {
193
+ name: 'Cron',
194
+ color: '#00FF00',
195
+ },
196
+ inputs: [],
197
+ outputs: ['main'],
198
+ properties: [
199
+ {
200
+ displayName: 'Trigger Times',
201
+ name: 'triggerTimes',
202
+ type: 'fixedCollection',
203
+ typeOptions: {
204
+ multipleValues: true,
205
+ multipleValueButtonText: 'Add Time',
206
+ },
207
+ default: {},
208
+ description: 'Triggers for the workflow',
209
+ placeholder: 'Add Cron Time',
210
+ options: [
211
+ {
212
+ name: 'item',
213
+ displayName: 'Item',
214
+ values: [
215
+ {
216
+ displayName: 'Mode',
217
+ name: 'mode',
218
+ type: 'options',
219
+ options: [
220
+ {
221
+ name: 'Every Minute',
222
+ value: 'everyMinute',
223
+ },
224
+ {
225
+ name: 'Every Hour',
226
+ value: 'everyHour',
227
+ },
228
+ {
229
+ name: 'Every Day',
230
+ value: 'everyDay',
231
+ },
232
+ {
233
+ name: 'Every Week',
234
+ value: 'everyWeek',
235
+ },
236
+ {
237
+ name: 'Every Month',
238
+ value: 'everyMonth',
239
+ },
240
+ {
241
+ name: 'Every X',
242
+ value: 'everyX',
243
+ },
244
+ {
245
+ name: 'Custom',
246
+ value: 'custom',
247
+ },
248
+ ],
249
+ default: 'everyDay',
250
+ description: 'How often to trigger.',
251
+ },
252
+ {
253
+ displayName: 'Hour',
254
+ name: 'hour',
255
+ type: 'number',
256
+ typeOptions: {
257
+ minValue: 0,
258
+ maxValue: 23,
259
+ },
260
+ displayOptions: {
261
+ hide: {
262
+ mode: ['custom', 'everyHour', 'everyMinute', 'everyX'],
263
+ },
264
+ },
265
+ default: 14,
266
+ description: 'The hour of the day to trigger (24h format).',
267
+ },
268
+ {
269
+ displayName: 'Minute',
270
+ name: 'minute',
271
+ type: 'number',
272
+ typeOptions: {
273
+ minValue: 0,
274
+ maxValue: 59,
275
+ },
276
+ displayOptions: {
277
+ hide: {
278
+ mode: ['custom', 'everyMinute', 'everyX'],
279
+ },
280
+ },
281
+ default: 0,
282
+ description: 'The minute of the day to trigger.',
283
+ },
284
+ {
285
+ displayName: 'Day of Month',
286
+ name: 'dayOfMonth',
287
+ type: 'number',
288
+ displayOptions: {
289
+ show: {
290
+ mode: ['everyMonth'],
291
+ },
292
+ },
293
+ typeOptions: {
294
+ minValue: 1,
295
+ maxValue: 31,
296
+ },
297
+ default: 1,
298
+ description: 'The day of the month to trigger.',
299
+ },
300
+ {
301
+ displayName: 'Weekday',
302
+ name: 'weekday',
303
+ type: 'options',
304
+ displayOptions: {
305
+ show: {
306
+ mode: ['everyWeek'],
307
+ },
308
+ },
309
+ options: [
310
+ {
311
+ name: 'Monday',
312
+ value: '1',
313
+ },
314
+ {
315
+ name: 'Tuesday',
316
+ value: '2',
317
+ },
318
+ {
319
+ name: 'Wednesday',
320
+ value: '3',
321
+ },
322
+ {
323
+ name: 'Thursday',
324
+ value: '4',
325
+ },
326
+ {
327
+ name: 'Friday',
328
+ value: '5',
329
+ },
330
+ {
331
+ name: 'Saturday',
332
+ value: '6',
333
+ },
334
+ {
335
+ name: 'Sunday',
336
+ value: '0',
337
+ },
338
+ ],
339
+ default: '1',
340
+ description: 'The weekday to trigger.',
341
+ },
342
+ {
343
+ displayName: 'Cron Expression',
344
+ name: 'cronExpression',
345
+ type: 'string',
346
+ displayOptions: {
347
+ show: {
348
+ mode: ['custom'],
349
+ },
350
+ },
351
+ default: '* * * * * *',
352
+ description: 'Use custom cron expression. Values and ranges as follows:<ul><li>Seconds: 0-59</li><li>Minutes: 0 - 59</li><li>Hours: 0 - 23</li><li>Day of Month: 1 - 31</li><li>Months: 0 - 11 (Jan - Dec)</li><li>Day of Week: 0 - 6 (Sun - Sat)</li></ul>.',
353
+ },
354
+ {
355
+ displayName: 'Value',
356
+ name: 'value',
357
+ type: 'number',
358
+ typeOptions: {
359
+ minValue: 0,
360
+ maxValue: 1000,
361
+ },
362
+ displayOptions: {
363
+ show: {
364
+ mode: ['everyX'],
365
+ },
366
+ },
367
+ default: 2,
368
+ description: 'All how many X minutes/hours it should trigger.',
369
+ },
370
+ {
371
+ displayName: 'Unit',
372
+ name: 'unit',
373
+ type: 'options',
374
+ displayOptions: {
375
+ show: {
376
+ mode: ['everyX'],
377
+ },
378
+ },
379
+ options: [
380
+ {
381
+ name: 'Minutes',
382
+ value: 'minutes',
383
+ },
384
+ {
385
+ name: 'Hours',
386
+ value: 'hours',
387
+ },
388
+ ],
389
+ default: 'hours',
390
+ description: 'If it should trigger all X minutes or hours.',
391
+ },
392
+ ],
393
+ },
394
+ ],
395
+ },
396
+ ],
397
+ },
398
+ async trigger() {
399
+ const triggerTimes = this.getNodeParameter('triggerTimes');
400
+ const parameterOrder = [
401
+ 'second',
402
+ 'minute',
403
+ 'hour',
404
+ 'dayOfMonth',
405
+ 'month',
406
+ 'weekday',
407
+ ];
408
+ const cronTimes = [];
409
+ let cronTime;
410
+ let parameterName;
411
+ if (triggerTimes.item !== undefined) {
412
+ for (const item of triggerTimes.item) {
413
+ cronTime = [];
414
+ if (item.mode === 'custom') {
415
+ cronTimes.push(item.cronExpression);
416
+ continue;
417
+ }
418
+ if (item.mode === 'everyMinute') {
419
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} * * * * *`);
420
+ continue;
421
+ }
422
+ if (item.mode === 'everyX') {
423
+ if (item.unit === 'minutes') {
424
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} */${item.value} * * * *`);
425
+ }
426
+ else if (item.unit === 'hours') {
427
+ cronTimes.push(`${Math.floor(Math.random() * 60).toString()} 0 */${item.value} * * *`);
428
+ }
429
+ continue;
430
+ }
431
+ for (parameterName of parameterOrder) {
432
+ if (item[parameterName] !== undefined) {
433
+ cronTime.push(item[parameterName]);
434
+ }
435
+ else if (parameterName === 'second') {
436
+ cronTime.push(Math.floor(Math.random() * 60).toString());
437
+ }
438
+ else {
439
+ cronTime.push('*');
440
+ }
441
+ }
442
+ cronTimes.push(cronTime.join(' '));
443
+ }
444
+ }
445
+ const executeTrigger = () => {
446
+ this.emit([this.helpers.returnJsonArray([{}])]);
447
+ };
448
+ const timezone = this.getTimezone();
449
+ const cronJobs = [];
450
+ for (const cronTime of cronTimes) {
451
+ cronJobs.push(new cron_1.CronJob(cronTime, executeTrigger, undefined, true, timezone));
452
+ }
453
+ async function closeFunction() {
454
+ for (const cronJob of cronJobs) {
455
+ cronJob.stop();
456
+ }
457
+ }
458
+ async function manualTriggerFunction() {
459
+ executeTrigger();
460
+ }
461
+ return {
462
+ closeFunction,
463
+ manualTriggerFunction,
464
+ };
465
+ },
466
+ },
467
+ },
468
+ 'n8n-nodes-base.set': {
469
+ sourcePath: '',
470
+ type: {
471
+ description: {
472
+ displayName: 'Set',
473
+ name: 'set',
474
+ icon: 'fa:pen',
475
+ group: ['input'],
476
+ version: 1,
477
+ description: 'Sets values on items and optionally remove other values',
478
+ defaults: {
479
+ name: 'Set',
480
+ color: '#0000FF',
481
+ },
482
+ inputs: ['main'],
483
+ outputs: ['main'],
484
+ properties: [
485
+ {
486
+ displayName: 'Keep Only Set',
487
+ name: 'keepOnlySet',
488
+ type: 'boolean',
489
+ default: false,
490
+ description: 'If only the values set on this node should be kept and all others removed.',
491
+ },
492
+ {
493
+ displayName: 'Values to Set',
494
+ name: 'values',
495
+ placeholder: 'Add Value',
496
+ type: 'fixedCollection',
497
+ typeOptions: {
498
+ multipleValues: true,
499
+ sortable: true,
500
+ },
501
+ description: 'The value to set.',
502
+ default: {},
503
+ options: [
504
+ {
505
+ name: 'boolean',
506
+ displayName: 'Boolean',
507
+ values: [
508
+ {
509
+ displayName: 'Name',
510
+ name: 'name',
511
+ type: 'string',
512
+ default: 'propertyName',
513
+ description: 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
514
+ },
515
+ {
516
+ displayName: 'Value',
517
+ name: 'value',
518
+ type: 'boolean',
519
+ default: false,
520
+ description: 'The boolean value to write in the property.',
521
+ },
522
+ ],
523
+ },
524
+ {
525
+ name: 'number',
526
+ displayName: 'Number',
527
+ values: [
528
+ {
529
+ displayName: 'Name',
530
+ name: 'name',
531
+ type: 'string',
532
+ default: 'propertyName',
533
+ description: 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
534
+ },
535
+ {
536
+ displayName: 'Value',
537
+ name: 'value',
538
+ type: 'number',
539
+ default: 0,
540
+ description: 'The number value to write in the property.',
541
+ },
542
+ ],
543
+ },
544
+ {
545
+ name: 'string',
546
+ displayName: 'String',
547
+ values: [
548
+ {
549
+ displayName: 'Name',
550
+ name: 'name',
551
+ type: 'string',
552
+ default: 'propertyName',
553
+ description: 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"',
554
+ },
555
+ {
556
+ displayName: 'Value',
557
+ name: 'value',
558
+ type: 'string',
559
+ default: '',
560
+ description: 'The string value to write in the property.',
561
+ },
562
+ ],
563
+ },
564
+ ],
565
+ },
566
+ {
567
+ displayName: 'Options',
568
+ name: 'options',
569
+ type: 'collection',
570
+ placeholder: 'Add Option',
571
+ default: {},
572
+ options: [
573
+ {
574
+ displayName: 'Dot Notation',
575
+ name: 'dotNotation',
576
+ type: 'boolean',
577
+ default: true,
578
+ description: `<p>By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.<p></p>If that is not intended this can be deactivated, it will then set { "a.b": value } instead.</p>
579
+ `,
580
+ },
581
+ ],
582
+ },
583
+ ],
584
+ },
585
+ execute() {
586
+ const items = this.getInputData();
587
+ if (items.length === 0) {
588
+ items.push({ json: {} });
589
+ }
590
+ const returnData = [];
591
+ let item;
592
+ let keepOnlySet;
593
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
594
+ keepOnlySet = this.getNodeParameter('keepOnlySet', itemIndex, false);
595
+ item = items[itemIndex];
596
+ const options = this.getNodeParameter('options', itemIndex, {});
597
+ const newItem = {
598
+ json: {},
599
+ };
600
+ if (keepOnlySet !== true) {
601
+ if (item.binary !== undefined) {
602
+ newItem.binary = {};
603
+ Object.assign(newItem.binary, item.binary);
604
+ }
605
+ newItem.json = JSON.parse(JSON.stringify(item.json));
606
+ }
607
+ this.getNodeParameter('values.boolean', itemIndex, []).forEach((setItem) => {
608
+ if (options.dotNotation === false) {
609
+ newItem.json[setItem.name] = !!setItem.value;
610
+ }
611
+ else {
612
+ (0, lodash_1.set)(newItem.json, setItem.name, !!setItem.value);
613
+ }
614
+ });
615
+ this.getNodeParameter('values.number', itemIndex, []).forEach((setItem) => {
616
+ if (options.dotNotation === false) {
617
+ newItem.json[setItem.name] = setItem.value;
618
+ }
619
+ else {
620
+ (0, lodash_1.set)(newItem.json, setItem.name, setItem.value);
621
+ }
622
+ });
623
+ this.getNodeParameter('values.string', itemIndex, []).forEach((setItem) => {
624
+ if (options.dotNotation === false) {
625
+ newItem.json[setItem.name] = setItem.value;
626
+ }
627
+ else {
628
+ (0, lodash_1.set)(newItem.json, setItem.name, setItem.value);
629
+ }
630
+ });
631
+ returnData.push(newItem);
632
+ }
633
+ return this.prepareOutputData(returnData);
634
+ },
635
+ },
636
+ },
637
+ };
638
+ const nodeTypes = (0, src_1.NodeTypes)();
639
+ await nodeTypes.init(types);
640
+ }
641
+ exports.initNodeTypes = initNodeTypes;
100
642
  function initTestLogger() {
101
643
  n8n_workflow_1.LoggerProxy.init((0, Logger_1.getLogger)());
102
644
  }
103
645
  exports.initTestLogger = initTestLogger;
646
+ async function initBinaryManager() {
647
+ const binaryDataConfig = config.getEnv('binaryDataManager');
648
+ await n8n_core_1.BinaryDataManager.init(binaryDataConfig, true);
649
+ }
650
+ exports.initBinaryManager = initBinaryManager;
104
651
  function initConfigFile() {
105
652
  const settingsPath = n8n_core_1.UserSettings.getUserSettingsPath();
106
653
  if (!(0, fs_1.existsSync)(settingsPath)) {
@@ -111,10 +658,18 @@ function initConfigFile() {
111
658
  exports.initConfigFile = initConfigFile;
112
659
  function createAgent(app, options) {
113
660
  const agent = supertest_1.default.agent(app);
114
- agent.use(prefix(constants_1.REST_PATH_SEGMENT));
115
- if ((options === null || options === void 0 ? void 0 : options.auth) && (options === null || options === void 0 ? void 0 : options.user)) {
116
- const { token } = (0, jwt_1.issueJWT)(options.user);
117
- agent.jar.setCookie(`${constants_2.AUTH_COOKIE_NAME}=${token}`);
661
+ if ((options === null || options === void 0 ? void 0 : options.apiPath) === undefined || (options === null || options === void 0 ? void 0 : options.apiPath) === 'internal') {
662
+ agent.use(prefix(constants_1.REST_PATH_SEGMENT));
663
+ if ((options === null || options === void 0 ? void 0 : options.auth) && (options === null || options === void 0 ? void 0 : options.user)) {
664
+ const { token } = (0, jwt_1.issueJWT)(options.user);
665
+ agent.jar.setCookie(`${constants_2.AUTH_COOKIE_NAME}=${token}`);
666
+ }
667
+ }
668
+ if ((options === null || options === void 0 ? void 0 : options.apiPath) === 'public') {
669
+ agent.use(prefix(`${constants_1.PUBLIC_API_REST_PATH_SEGMENT}/v${options === null || options === void 0 ? void 0 : options.version}`));
670
+ if ((options === null || options === void 0 ? void 0 : options.auth) && (options === null || options === void 0 ? void 0 : options.user.apiKey)) {
671
+ agent.set({ 'X-N8N-API-KEY': options.user.apiKey });
672
+ }
118
673
  }
119
674
  return agent;
120
675
  }
@@ -154,12 +709,12 @@ exports.isInstanceOwnerSetUp = isInstanceOwnerSetUp;
154
709
  const getSmtpTestAccount = util_1.default.promisify(nodemailer_1.createTestAccount);
155
710
  async function configureSmtp() {
156
711
  const { user, pass, smtp: { host, port, secure }, } = await getSmtpTestAccount();
157
- config_1.default.set('userManagement.emails.mode', 'smtp');
158
- config_1.default.set('userManagement.emails.smtp.host', host);
159
- config_1.default.set('userManagement.emails.smtp.port', port);
160
- config_1.default.set('userManagement.emails.smtp.secure', secure);
161
- config_1.default.set('userManagement.emails.smtp.auth.user', user);
162
- config_1.default.set('userManagement.emails.smtp.auth.pass', pass);
712
+ config.set('userManagement.emails.mode', 'smtp');
713
+ config.set('userManagement.emails.smtp.host', host);
714
+ config.set('userManagement.emails.smtp.port', port);
715
+ config.set('userManagement.emails.smtp.secure', secure);
716
+ config.set('userManagement.emails.smtp.auth.user', user);
717
+ config.set('userManagement.emails.smtp.auth.pass', pass);
163
718
  }
164
719
  exports.configureSmtp = configureSmtp;
165
720
  async function isTestSmtpServiceAvailable() {
@@ -185,4 +740,13 @@ const categorize = (arr, test) => {
185
740
  }, { pass: [], fail: [] });
186
741
  };
187
742
  exports.categorize = categorize;
743
+ function getPostgresSchemaSection(schema = config.getSchema()) {
744
+ for (const [key, value] of Object.entries(schema)) {
745
+ if (key === 'postgresdb') {
746
+ return value._cvtProperties;
747
+ }
748
+ }
749
+ return null;
750
+ }
751
+ exports.getPostgresSchemaSection = getPostgresSchemaSection;
188
752
  //# sourceMappingURL=utils.js.map