@crowdin/app-project-module 1.16.0 → 2.0.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 (99) hide show
  1. package/out/index.js +8 -15
  2. package/out/middlewares/auto-credentials-masker.js +5 -2
  3. package/out/middlewares/crowdin-client.d.ts +1 -1
  4. package/out/middlewares/crowdin-client.js +1 -1
  5. package/out/middlewares/export.d.ts +2 -2
  6. package/out/middlewares/export.js +4 -35
  7. package/out/middlewares/json-response.d.ts +1 -1
  8. package/out/middlewares/json-response.js +1 -1
  9. package/out/modules/ai-prompt-provider/index.js +6 -6
  10. package/out/modules/ai-provider/index.js +7 -7
  11. package/out/modules/ai-provider/types.d.ts +10 -0
  12. package/out/modules/ai-provider/types.js +12 -0
  13. package/out/modules/ai-provider/util/index.d.ts +0 -10
  14. package/out/modules/ai-provider/util/index.js +2 -13
  15. package/out/modules/ai-request-processors/index.js +4 -4
  16. package/out/modules/api/api.js +18 -18
  17. package/out/modules/auth-guard/index.js +4 -5
  18. package/out/modules/automation-action/index.js +4 -6
  19. package/out/modules/context-menu/index.js +4 -13
  20. package/out/modules/custom-mt/index.js +4 -4
  21. package/out/modules/custom-spell-check/index.js +11 -11
  22. package/out/modules/editor-right-panel/index.js +1 -1
  23. package/out/modules/external-qa-check/index.js +7 -7
  24. package/out/modules/file-processing/index.js +14 -14
  25. package/out/modules/integration/index.js +26 -26
  26. package/out/modules/integration/types.d.ts +4 -4
  27. package/out/modules/integration/util/files.js +1 -1
  28. package/out/modules/integration/util/types.d.ts +1 -1
  29. package/out/modules/manifest.js +70 -281
  30. package/out/modules/modal/index.js +4 -13
  31. package/out/modules/organization-menu/index.js +1 -1
  32. package/out/modules/organization-settings-menu/index.js +1 -1
  33. package/out/modules/profile-resources-menu/index.js +1 -1
  34. package/out/modules/profile-settings-menu/index.js +1 -1
  35. package/out/modules/project-menu/index.js +1 -1
  36. package/out/modules/project-menu-crowdsource/index.js +1 -1
  37. package/out/modules/project-reports/index.js +1 -1
  38. package/out/modules/project-tools/index.js +1 -1
  39. package/out/modules/webhooks/index.js +3 -6
  40. package/out/modules/workflow-step-type/index.js +6 -6
  41. package/out/storage/drizzle/d1/index.d.ts +7 -0
  42. package/out/storage/drizzle/d1/index.js +48 -0
  43. package/out/storage/drizzle/d1/migrations/init.d.ts +2 -0
  44. package/out/storage/drizzle/d1/migrations/init.js +122 -0
  45. package/out/storage/drizzle/d1/types.d.ts +13 -0
  46. package/out/storage/drizzle/d1/types.js +38 -0
  47. package/out/storage/{sqlite.d.ts → drizzle/index.d.ts} +37 -58
  48. package/out/storage/drizzle/index.js +939 -0
  49. package/out/storage/drizzle/postgresql/config.d.ts +5 -0
  50. package/out/storage/drizzle/postgresql/config.js +11 -0
  51. package/out/storage/drizzle/postgresql/index.d.ts +14 -0
  52. package/out/storage/drizzle/postgresql/index.js +144 -0
  53. package/out/storage/drizzle/postgresql/migrations/0000_init.sql +113 -0
  54. package/out/storage/drizzle/postgresql/migrations/0001_init_indexes.sql +28 -0
  55. package/out/storage/drizzle/postgresql/migrations/meta/0000_snapshot.json +646 -0
  56. package/out/storage/drizzle/postgresql/migrations/meta/0001_snapshot.json +646 -0
  57. package/out/storage/drizzle/postgresql/migrations/meta/_journal.json +20 -0
  58. package/out/storage/drizzle/postgresql/schema.d.ts +1410 -0
  59. package/out/storage/drizzle/postgresql/schema.js +106 -0
  60. package/out/storage/drizzle/sqlite/config.d.ts +5 -0
  61. package/out/storage/drizzle/sqlite/config.js +11 -0
  62. package/out/storage/drizzle/sqlite/index.d.ts +8 -0
  63. package/out/storage/drizzle/sqlite/index.js +63 -0
  64. package/out/storage/drizzle/sqlite/migrations/0000_init.sql +113 -0
  65. package/out/storage/drizzle/sqlite/migrations/meta/0000_snapshot.json +687 -0
  66. package/out/storage/drizzle/sqlite/migrations/meta/_journal.json +13 -0
  67. package/out/storage/drizzle/sqlite/schema.d.ts +1544 -0
  68. package/out/storage/drizzle/sqlite/schema.js +106 -0
  69. package/out/storage/index.d.ts +2 -88
  70. package/out/storage/index.js +12 -128
  71. package/out/storage/internal/backup.d.ts +3 -0
  72. package/out/storage/internal/backup.js +94 -0
  73. package/out/storage/types.d.ts +66 -0
  74. package/out/types.d.ts +43 -47
  75. package/out/util/credentials-masker.js +2 -2
  76. package/out/util/export.d.ts +1 -0
  77. package/out/util/export.js +2 -1
  78. package/out/util/index.d.ts +2 -1
  79. package/out/util/index.js +12 -9
  80. package/out/util/normalize-module.d.ts +0 -1
  81. package/out/util/normalize-module.js +0 -4
  82. package/package.json +18 -22
  83. package/out/modules/ai-tools/handlers/tool-calls.d.ts +0 -4
  84. package/out/modules/ai-tools/handlers/tool-calls.js +0 -52
  85. package/out/modules/ai-tools/index.d.ts +0 -10
  86. package/out/modules/ai-tools/index.js +0 -46
  87. package/out/modules/ai-tools/types.d.ts +0 -63
  88. package/out/modules/ai-tools/types.js +0 -2
  89. package/out/modules/ai-tools/util/index.d.ts +0 -5
  90. package/out/modules/ai-tools/util/index.js +0 -24
  91. package/out/storage/d1.d.ts +0 -107
  92. package/out/storage/d1.js +0 -837
  93. package/out/storage/export.d.ts +0 -1
  94. package/out/storage/export.js +0 -2
  95. package/out/storage/mysql.d.ts +0 -109
  96. package/out/storage/mysql.js +0 -984
  97. package/out/storage/postgre.d.ts +0 -124
  98. package/out/storage/postgre.js +0 -1027
  99. package/out/storage/sqlite.js +0 -786
@@ -6,8 +6,7 @@ const util_1 = require("../util");
6
6
  const subscription_1 = require("../util/subscription");
7
7
  const normalize_module_1 = require("../util/normalize-module");
8
8
  const api_1 = require("./api/api");
9
- const util_2 = require("./ai-tools/util");
10
- const util_3 = require("./workflow-step-type/util");
9
+ const util_2 = require("./workflow-step-type/util");
11
10
  const index_1 = require("./automation-action/util/index");
12
11
  const ai_request_processors_1 = require("./ai-request-processors");
13
12
  function normalizeEnvironments(environments) {
@@ -28,13 +27,8 @@ function handle(config) {
28
27
  ];
29
28
  }
30
29
  if (config.customFileFormat) {
31
- if (Array.isArray(config.customFileFormat)) {
32
- config.customFileFormat = config.customFileFormat.map((item) => (Object.assign({}, item)));
33
- }
34
- else {
35
- config.customFileFormat = Object.assign({}, config.customFileFormat);
36
- }
37
- const items = (0, normalize_module_1.normalizeToArray)(config.customFileFormat);
30
+ config.customFileFormat = config.customFileFormat.map((item) => (Object.assign({}, item)));
31
+ const items = config.customFileFormat;
38
32
  const isSingle = items.length === 1;
39
33
  modules['custom-file-format'] = items.map((item, index) => {
40
34
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'ff', item, index, isSingle });
@@ -51,16 +45,10 @@ function handle(config) {
51
45
  url: isSingle ? '/file/process' : `/file/${key}/process`,
52
46
  };
53
47
  });
54
- config.customFileFormat = isSingle ? items[0] : items;
55
48
  }
56
49
  if (config.filePreImport) {
57
- if (Array.isArray(config.filePreImport)) {
58
- config.filePreImport = config.filePreImport.map((item) => (Object.assign({}, item)));
59
- }
60
- else {
61
- config.filePreImport = Object.assign({}, config.filePreImport);
62
- }
63
- const items = (0, normalize_module_1.normalizeToArray)(config.filePreImport);
50
+ config.filePreImport = config.filePreImport.map((item) => (Object.assign({}, item)));
51
+ const items = config.filePreImport;
64
52
  const isSingle = items.length === 1;
65
53
  modules['file-pre-import'] = items.map((item, index) => {
66
54
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'pri', item, index, isSingle });
@@ -71,16 +59,10 @@ function handle(config) {
71
59
  url: isSingle ? '/pre-import' : `/pre-import/${key}`,
72
60
  };
73
61
  });
74
- config.filePreImport = isSingle ? items[0] : items;
75
62
  }
76
63
  if (config.filePostImport) {
77
- if (Array.isArray(config.filePostImport)) {
78
- config.filePostImport = config.filePostImport.map((item) => (Object.assign({}, item)));
79
- }
80
- else {
81
- config.filePostImport = Object.assign({}, config.filePostImport);
82
- }
83
- const items = (0, normalize_module_1.normalizeToArray)(config.filePostImport);
64
+ config.filePostImport = config.filePostImport.map((item) => (Object.assign({}, item)));
65
+ const items = config.filePostImport;
84
66
  const isSingle = items.length === 1;
85
67
  modules['file-post-import'] = items.map((item, index) => {
86
68
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'poi', item, index, isSingle });
@@ -91,16 +73,10 @@ function handle(config) {
91
73
  url: isSingle ? '/post-import' : `/post-import/${key}`,
92
74
  };
93
75
  });
94
- config.filePostImport = isSingle ? items[0] : items;
95
76
  }
96
77
  if (config.filePreExport) {
97
- if (Array.isArray(config.filePreExport)) {
98
- config.filePreExport = config.filePreExport.map((item) => (Object.assign({}, item)));
99
- }
100
- else {
101
- config.filePreExport = Object.assign({}, config.filePreExport);
102
- }
103
- const items = (0, normalize_module_1.normalizeToArray)(config.filePreExport);
78
+ config.filePreExport = config.filePreExport.map((item) => (Object.assign({}, item)));
79
+ const items = config.filePreExport;
104
80
  const isSingle = items.length === 1;
105
81
  modules['file-pre-export'] = items.map((item, index) => {
106
82
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'pre', item, index, isSingle });
@@ -111,16 +87,10 @@ function handle(config) {
111
87
  url: isSingle ? '/pre-export' : `/pre-export/${key}`,
112
88
  };
113
89
  });
114
- config.filePreExport = isSingle ? items[0] : items;
115
90
  }
116
91
  if (config.filePostExport) {
117
- if (Array.isArray(config.filePostExport)) {
118
- config.filePostExport = config.filePostExport.map((item) => (Object.assign({}, item)));
119
- }
120
- else {
121
- config.filePostExport = Object.assign({}, config.filePostExport);
122
- }
123
- const items = (0, normalize_module_1.normalizeToArray)(config.filePostExport);
92
+ config.filePostExport = config.filePostExport.map((item) => (Object.assign({}, item)));
93
+ const items = config.filePostExport;
124
94
  const isSingle = items.length === 1;
125
95
  modules['file-post-export'] = items.map((item, index) => {
126
96
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'poe', item, index, isSingle });
@@ -131,16 +101,10 @@ function handle(config) {
131
101
  url: isSingle ? '/post-export' : `/post-export/${key}`,
132
102
  };
133
103
  });
134
- config.filePostExport = isSingle ? items[0] : items;
135
104
  }
136
105
  if (config.fileTranslationsAlignmentExport) {
137
- if (Array.isArray(config.fileTranslationsAlignmentExport)) {
138
- config.fileTranslationsAlignmentExport = config.fileTranslationsAlignmentExport.map((item) => (Object.assign({}, item)));
139
- }
140
- else {
141
- config.fileTranslationsAlignmentExport = Object.assign({}, config.fileTranslationsAlignmentExport);
142
- }
143
- const items = (0, normalize_module_1.normalizeToArray)(config.fileTranslationsAlignmentExport);
106
+ config.fileTranslationsAlignmentExport = config.fileTranslationsAlignmentExport.map((item) => (Object.assign({}, item)));
107
+ const items = config.fileTranslationsAlignmentExport;
144
108
  const isSingle = items.length === 1;
145
109
  modules['file-translations-alignment'] = items.map((item, index) => {
146
110
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'ftae', item, index, isSingle });
@@ -151,16 +115,10 @@ function handle(config) {
151
115
  url: isSingle ? '/translations-alignment' : `/translations-alignment/${key}`,
152
116
  };
153
117
  });
154
- config.fileTranslationsAlignmentExport = isSingle ? items[0] : items;
155
118
  }
156
119
  if (config.customMT) {
157
- if (Array.isArray(config.customMT)) {
158
- config.customMT = config.customMT.map((item) => (Object.assign({}, item)));
159
- }
160
- else {
161
- config.customMT = Object.assign({}, config.customMT);
162
- }
163
- const items = (0, normalize_module_1.normalizeToArray)(config.customMT);
120
+ config.customMT = config.customMT.map((item) => (Object.assign({}, item)));
121
+ const items = config.customMT;
164
122
  const isSingle = items.length === 1;
165
123
  modules['custom-mt'] = items.map((item, index) => {
166
124
  const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'mt', item, index, isSingle });
@@ -175,16 +133,10 @@ function handle(config) {
175
133
  environments: normalizeEnvironments(item.environments),
176
134
  }));
177
135
  });
178
- config.customMT = isSingle ? items[0] : items;
179
136
  }
180
137
  if (config.organizationMenu) {
181
- if (Array.isArray(config.organizationMenu)) {
182
- config.organizationMenu = config.organizationMenu.map((item) => (Object.assign({}, item)));
183
- }
184
- else {
185
- config.organizationMenu = Object.assign({}, config.organizationMenu);
186
- }
187
- const items = (0, normalize_module_1.normalizeToArray)(config.organizationMenu);
138
+ config.organizationMenu = config.organizationMenu.map((item) => (Object.assign({}, item)));
139
+ const items = config.organizationMenu;
188
140
  const isSingle = items.length === 1;
189
141
  modules['organization-menu'] = items.map((item, index) => {
190
142
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -203,16 +155,10 @@ function handle(config) {
203
155
  icon: (0, util_1.getLogoUrl)(config, item, isSingle ? '/resources' : `/organization-menu-${key}`),
204
156
  };
205
157
  });
206
- config.organizationMenu = isSingle ? items[0] : items;
207
158
  }
208
159
  if (config.organizationSettingsMenu) {
209
- if (Array.isArray(config.organizationSettingsMenu)) {
210
- config.organizationSettingsMenu = config.organizationSettingsMenu.map((item) => (Object.assign({}, item)));
211
- }
212
- else {
213
- config.organizationSettingsMenu = Object.assign({}, config.organizationSettingsMenu);
214
- }
215
- const items = (0, normalize_module_1.normalizeToArray)(config.organizationSettingsMenu);
160
+ config.organizationSettingsMenu = config.organizationSettingsMenu.map((item) => (Object.assign({}, item)));
161
+ const items = config.organizationSettingsMenu;
216
162
  const isSingle = items.length === 1;
217
163
  modules['organization-settings-menu'] = items.map((item, index) => {
218
164
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -231,16 +177,10 @@ function handle(config) {
231
177
  icon: (0, util_1.getLogoUrl)(config, item, isSingle ? '/organization-settings' : `/organization-settings-${key}`),
232
178
  };
233
179
  });
234
- config.organizationSettingsMenu = isSingle ? items[0] : items;
235
180
  }
236
181
  if (config.profileResourcesMenu) {
237
- if (Array.isArray(config.profileResourcesMenu)) {
238
- config.profileResourcesMenu = config.profileResourcesMenu.map((item) => (Object.assign({}, item)));
239
- }
240
- else {
241
- config.profileResourcesMenu = Object.assign({}, config.profileResourcesMenu);
242
- }
243
- const items = (0, normalize_module_1.normalizeToArray)(config.profileResourcesMenu);
182
+ config.profileResourcesMenu = config.profileResourcesMenu.map((item) => (Object.assign({}, item)));
183
+ const items = config.profileResourcesMenu;
244
184
  const isSingle = items.length === 1;
245
185
  modules['profile-resources-menu'] = items.map((item, index) => {
246
186
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -256,16 +196,10 @@ function handle(config) {
256
196
  environments: normalizeEnvironments(item.environments),
257
197
  }));
258
198
  });
259
- config.profileResourcesMenu = isSingle ? items[0] : items;
260
199
  }
261
200
  if (config.profileSettingsMenu) {
262
- if (Array.isArray(config.profileSettingsMenu)) {
263
- config.profileSettingsMenu = config.profileSettingsMenu.map((item) => (Object.assign({}, item)));
264
- }
265
- else {
266
- config.profileSettingsMenu = Object.assign({}, config.profileSettingsMenu);
267
- }
268
- const items = (0, normalize_module_1.normalizeToArray)(config.profileSettingsMenu);
201
+ config.profileSettingsMenu = config.profileSettingsMenu.map((item) => (Object.assign({}, item)));
202
+ const items = config.profileSettingsMenu;
269
203
  const isSingle = items.length === 1;
270
204
  modules['profile-settings-menu'] = items.map((item, index) => {
271
205
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -281,16 +215,10 @@ function handle(config) {
281
215
  environments: normalizeEnvironments(item.environments),
282
216
  }));
283
217
  });
284
- config.profileSettingsMenu = isSingle ? items[0] : items;
285
218
  }
286
219
  if (config.editorRightPanel) {
287
- if (Array.isArray(config.editorRightPanel)) {
288
- config.editorRightPanel = config.editorRightPanel.map((item) => (Object.assign({}, item)));
289
- }
290
- else {
291
- config.editorRightPanel = Object.assign({}, config.editorRightPanel);
292
- }
293
- const items = (0, normalize_module_1.normalizeToArray)(config.editorRightPanel);
220
+ config.editorRightPanel = config.editorRightPanel.map((item) => (Object.assign({}, item)));
221
+ const items = config.editorRightPanel;
294
222
  const isSingle = items.length === 1;
295
223
  modules['editor-right-panel'] = items.map((item, index) => {
296
224
  var _a;
@@ -307,16 +235,10 @@ function handle(config) {
307
235
  environments: normalizeEnvironments(item.environments),
308
236
  }));
309
237
  });
310
- config.editorRightPanel = isSingle ? items[0] : items;
311
238
  }
312
239
  if (config.projectMenu) {
313
- if (Array.isArray(config.projectMenu)) {
314
- config.projectMenu = config.projectMenu.map((item) => (Object.assign({}, item)));
315
- }
316
- else {
317
- config.projectMenu = Object.assign({}, config.projectMenu);
318
- }
319
- const items = (0, normalize_module_1.normalizeToArray)(config.projectMenu);
240
+ config.projectMenu = config.projectMenu.map((item) => (Object.assign({}, item)));
241
+ const items = config.projectMenu;
320
242
  const isSingle = items.length === 1;
321
243
  modules['project-menu'] = items.map((item, index) => {
322
244
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -332,16 +254,10 @@ function handle(config) {
332
254
  environments: normalizeEnvironments(item.environments),
333
255
  }));
334
256
  });
335
- config.projectMenu = isSingle ? items[0] : items;
336
257
  }
337
258
  if (config.projectMenuCrowdsource) {
338
- if (Array.isArray(config.projectMenuCrowdsource)) {
339
- config.projectMenuCrowdsource = config.projectMenuCrowdsource.map((item) => (Object.assign({}, item)));
340
- }
341
- else {
342
- config.projectMenuCrowdsource = Object.assign({}, config.projectMenuCrowdsource);
343
- }
344
- const items = (0, normalize_module_1.normalizeToArray)(config.projectMenuCrowdsource);
259
+ config.projectMenuCrowdsource = config.projectMenuCrowdsource.map((item) => (Object.assign({}, item)));
260
+ const items = config.projectMenuCrowdsource;
345
261
  const isSingle = items.length === 1;
346
262
  modules['project-menu-crowdsource'] = items.map((item, index) => {
347
263
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -359,16 +275,10 @@ function handle(config) {
359
275
  url: basePath + '/' + (item.fileName || 'index.html'),
360
276
  };
361
277
  });
362
- config.projectMenuCrowdsource = isSingle ? items[0] : items;
363
278
  }
364
279
  if (config.projectTools) {
365
- if (Array.isArray(config.projectTools)) {
366
- config.projectTools = config.projectTools.map((item) => (Object.assign({}, item)));
367
- }
368
- else {
369
- config.projectTools = Object.assign({}, config.projectTools);
370
- }
371
- const items = (0, normalize_module_1.normalizeToArray)(config.projectTools);
280
+ config.projectTools = config.projectTools.map((item) => (Object.assign({}, item)));
281
+ const items = config.projectTools;
372
282
  const isSingle = items.length === 1;
373
283
  modules['project-tools'] = items.map((item, index) => {
374
284
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -384,16 +294,10 @@ function handle(config) {
384
294
  environments: normalizeEnvironments(item.environments),
385
295
  }));
386
296
  });
387
- config.projectTools = isSingle ? items[0] : items;
388
297
  }
389
298
  if (config.projectReports) {
390
- if (Array.isArray(config.projectReports)) {
391
- config.projectReports = config.projectReports.map((item) => (Object.assign({}, item)));
392
- }
393
- else {
394
- config.projectReports = Object.assign({}, config.projectReports);
395
- }
396
- const items = (0, normalize_module_1.normalizeToArray)(config.projectReports);
299
+ config.projectReports = config.projectReports.map((item) => (Object.assign({}, item)));
300
+ const items = config.projectReports;
397
301
  const isSingle = items.length === 1;
398
302
  modules['project-reports'] = items.map((item, index) => {
399
303
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -413,23 +317,12 @@ function handle(config) {
413
317
  url: basePath + '/' + (item.fileName || 'index.html'),
414
318
  };
415
319
  });
416
- config.projectReports = isSingle ? items[0] : items;
417
320
  }
418
321
  if (config.modal) {
419
- let modals = [];
420
- if (Array.isArray(config.modal)) {
421
- modals = config.modal.map((modal, index) => {
422
- const moduleKey = modal.key || `${config.identifier}-modal-${index}`;
423
- return Object.assign({ key: moduleKey, name: modal.name || config.name, url: modal.url || `/modal-${moduleKey}/` + (modal.fileName || 'index.html') }, (!!modal.environments && { environments: normalizeEnvironments(modal.environments) }));
424
- });
425
- }
426
- else {
427
- modals = [
428
- Object.assign({ key: config.identifier + '-modal', name: config.modal.name || config.name, url: config.modal.url || '/modal/' + (config.modal.fileName || 'index.html') }, (!!config.modal.environments && {
429
- environments: normalizeEnvironments(config.modal.environments),
430
- })),
431
- ];
432
- }
322
+ const modals = config.modal.map((modal, index) => {
323
+ const moduleKey = modal.key || `${config.identifier}-modal-${index}`;
324
+ return Object.assign({ key: moduleKey, name: modal.name || config.name, url: modal.url || `/modal-${moduleKey}/` + (modal.fileName || 'index.html') }, (!!modal.environments && { environments: normalizeEnvironments(modal.environments) }));
325
+ });
433
326
  modules['modal'] = modals;
434
327
  }
435
328
  if (config.chat) {
@@ -440,47 +333,26 @@ function handle(config) {
440
333
  modules['chat'] = chats;
441
334
  }
442
335
  if (config.contextMenu) {
443
- let contextMenus = [];
444
- if (Array.isArray(config.contextMenu)) {
445
- contextMenus = config.contextMenu.map((contextMenu, index) => {
446
- const moduleKey = contextMenu.key || `${config.identifier}-context-menu-${index}`;
447
- return Object.assign({ key: moduleKey, name: contextMenu.name || config.name, description: config.description, options: Object.assign(Object.assign({ location: contextMenu.location, type: contextMenu.type }, (contextMenu.module && contextMenu.moduleKey
448
- ? {
449
- module: {
450
- [contextMenu.module]: contextMenu.moduleKey,
451
- },
452
- }
453
- : {})), { url: `/context-${moduleKey}/` + (contextMenu.fileName || 'index.html') }), signaturePatterns: contextMenu.signaturePatterns }, (!!contextMenu.environments && {
454
- environments: normalizeEnvironments(contextMenu.environments),
455
- }));
456
- });
457
- }
458
- else {
459
- contextMenus = [
460
- Object.assign({ key: config.identifier + '-context-menu', name: config.contextMenu.name || config.name, description: config.description, options: Object.assign(Object.assign({ location: config.contextMenu.location, type: config.contextMenu.type }, (config.contextMenu.module
461
- ? {
462
- module: {
463
- [config.contextMenu.module]: modules[config.contextMenu.module][0].key,
464
- },
465
- }
466
- : {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }), signaturePatterns: config.contextMenu.signaturePatterns }, (!!config.contextMenu.environments && {
467
- environments: normalizeEnvironments(config.contextMenu.environments),
468
- })),
469
- ];
470
- }
336
+ const contextMenus = config.contextMenu.map((contextMenu, index) => {
337
+ const moduleKey = contextMenu.key || `${config.identifier}-context-menu-${index}`;
338
+ return Object.assign({ key: moduleKey, name: contextMenu.name || config.name, description: config.description, options: Object.assign(Object.assign({ location: contextMenu.location, type: contextMenu.type }, (contextMenu.module && contextMenu.moduleKey
339
+ ? {
340
+ module: {
341
+ [contextMenu.module]: contextMenu.moduleKey,
342
+ },
343
+ }
344
+ : {})), { url: `/context-${moduleKey}/` + (contextMenu.fileName || 'index.html') }), signaturePatterns: contextMenu.signaturePatterns }, (!!contextMenu.environments && {
345
+ environments: normalizeEnvironments(contextMenu.environments),
346
+ }));
347
+ });
471
348
  modules['context-menu'] = contextMenus;
472
349
  }
473
350
  if (config.api) {
474
351
  modules['api'] = (0, api_1.getApiManifest)(config, config.api);
475
352
  }
476
353
  if (config.customSpellchecker) {
477
- if (Array.isArray(config.customSpellchecker)) {
478
- config.customSpellchecker = config.customSpellchecker.map((item) => (Object.assign({}, item)));
479
- }
480
- else {
481
- config.customSpellchecker = Object.assign({}, config.customSpellchecker);
482
- }
483
- const items = (0, normalize_module_1.normalizeToArray)(config.customSpellchecker);
354
+ config.customSpellchecker = config.customSpellchecker.map((item) => (Object.assign({}, item)));
355
+ const items = config.customSpellchecker;
484
356
  const isSingle = items.length === 1;
485
357
  modules['custom-spellchecker'] = items.map((item, index) => {
486
358
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -497,16 +369,10 @@ function handle(config) {
497
369
  environments: normalizeEnvironments(item.environments),
498
370
  })), (uiModule ? { url: `${base}/settings/` + (uiModule.fileName || 'index.html') } : {}));
499
371
  });
500
- config.customSpellchecker = isSingle ? items[0] : items;
501
372
  }
502
373
  if (config.aiProvider) {
503
- if (Array.isArray(config.aiProvider)) {
504
- config.aiProvider = config.aiProvider.map((item) => (Object.assign({}, item)));
505
- }
506
- else {
507
- config.aiProvider = Object.assign({}, config.aiProvider);
508
- }
509
- const items = (0, normalize_module_1.normalizeToArray)(config.aiProvider);
374
+ config.aiProvider = config.aiProvider.map((item) => (Object.assign({}, item)));
375
+ const items = config.aiProvider;
510
376
  const isSingle = items.length === 1;
511
377
  modules['ai-provider'] = items.map((item, index) => {
512
378
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -525,7 +391,6 @@ function handle(config) {
525
391
  environments: normalizeEnvironments(item.environments),
526
392
  })), (uiModule ? { url: `/settings${settingsBase}/` + (uiModule.fileName || 'index.html') } : {}));
527
393
  });
528
- config.aiProvider = isSingle ? items[0] : items;
529
394
  }
530
395
  [
531
396
  ...Object.values(ai_request_processors_1.AiRequestProcessorModuleWithoutStream),
@@ -536,13 +401,8 @@ function handle(config) {
536
401
  return;
537
402
  }
538
403
  const moduleSlug = (0, ai_request_processors_1.generateModuleSlugFromType)(moduleType);
539
- if (Array.isArray(moduleValue)) {
540
- config[moduleType] = moduleValue.map((item) => (Object.assign({}, item)));
541
- }
542
- else {
543
- config[moduleType] = Object.assign({}, moduleValue);
544
- }
545
- const items = (0, normalize_module_1.normalizeToArray)(config[moduleType]);
404
+ config[moduleType] = moduleValue.map((item) => (Object.assign({}, item)));
405
+ const items = config[moduleType];
546
406
  const isSingle = items.length === 1;
547
407
  modules[moduleSlug] = items.map((item, index) => {
548
408
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -560,16 +420,10 @@ function handle(config) {
560
420
  : `/ai-request-processor/${moduleSlug}/${key}`,
561
421
  };
562
422
  });
563
- config[moduleType] = isSingle ? items[0] : items;
564
423
  });
565
424
  if (config.aiPromptProvider) {
566
- if (Array.isArray(config.aiPromptProvider)) {
567
- config.aiPromptProvider = config.aiPromptProvider.map((item) => (Object.assign({}, item)));
568
- }
569
- else {
570
- config.aiPromptProvider = Object.assign({}, config.aiPromptProvider);
571
- }
572
- const items = (0, normalize_module_1.normalizeToArray)(config.aiPromptProvider);
425
+ config.aiPromptProvider = config.aiPromptProvider.map((item) => (Object.assign({}, item)));
426
+ const items = config.aiPromptProvider;
573
427
  const isSingle = items.length === 1;
574
428
  modules['ai-prompt-provider'] = items.map((item, index) => {
575
429
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -588,51 +442,11 @@ function handle(config) {
588
442
  ? { configuratorUrl: `${base}/settings/` + (item.fileName || 'index.html') }
589
443
  : {}));
590
444
  });
591
- config.aiPromptProvider = isSingle ? items[0] : items;
592
- }
593
- if (config.aiTools) {
594
- // prevent possible overrides of the other modules
595
- if (Array.isArray(config.aiTools)) {
596
- config.aiTools = config.aiTools.map((aiTool) => (Object.assign({}, aiTool)));
597
- }
598
- else {
599
- config.aiTools = Object.assign({}, config.aiTools);
600
- }
601
- const tools = Array.isArray(config.aiTools) ? config.aiTools : [config.aiTools];
602
- modules['ai-tools'] = [];
603
- for (const tool of tools) {
604
- tool.key = config.identifier + '-' + (0, util_2.getAiToolName)(tool);
605
- modules['ai-tools'].push(Object.assign({ key: tool.key, toolType: tool.toolType || 'function', function: tool.function, url: (0, util_2.getAiToolUrl)(tool) }, (!!tool.environments && {
606
- environments: normalizeEnvironments(tool.environments),
607
- })));
608
- }
609
- }
610
- if (config.aiToolsWidget) {
611
- // prevent possible overrides of the other modules
612
- if (Array.isArray(config.aiToolsWidget)) {
613
- config.aiToolsWidget = config.aiToolsWidget.map((aiToolWidget) => (Object.assign({}, aiToolWidget)));
614
- }
615
- else {
616
- config.aiToolsWidget = Object.assign({}, config.aiToolsWidget);
617
- }
618
- const tools = Array.isArray(config.aiToolsWidget) ? config.aiToolsWidget : [config.aiToolsWidget];
619
- modules['ai-tools-widget'] = [];
620
- for (const tool of tools) {
621
- tool.key = config.identifier + '-' + (0, util_2.getAiToolName)(tool);
622
- modules['ai-tools-widget'].push(Object.assign({ key: tool.key, toolType: tool.toolType || 'function', function: tool.function, url: (0, util_2.getAiToolWidgetUrl)(tool, true) }, (!!tool.environments && {
623
- environments: normalizeEnvironments(tool.environments),
624
- })));
625
- }
626
445
  }
627
446
  if (config.webhooks) {
628
447
  // prevent possible overrides of the other modules
629
- if (Array.isArray(config.webhooks)) {
630
- config.webhooks = config.webhooks.map((webhook) => (Object.assign({}, webhook)));
631
- }
632
- else {
633
- config.webhooks = Object.assign({}, config.webhooks);
634
- }
635
- const webhooks = Array.isArray(config.webhooks) ? config.webhooks : [config.webhooks];
448
+ config.webhooks = config.webhooks.map((webhook) => (Object.assign({}, webhook)));
449
+ const webhooks = config.webhooks;
636
450
  modules['webhook'] = [];
637
451
  for (let i = 0; i < webhooks.length; i++) {
638
452
  webhooks[i].key = config.identifier + '-' + 'webhook-' + i;
@@ -644,13 +458,8 @@ function handle(config) {
644
458
  }
645
459
  }
646
460
  if (config.externalQaCheck) {
647
- if (Array.isArray(config.externalQaCheck)) {
648
- config.externalQaCheck = config.externalQaCheck.map((item) => (Object.assign({}, item)));
649
- }
650
- else {
651
- config.externalQaCheck = Object.assign({}, config.externalQaCheck);
652
- }
653
- const items = (0, normalize_module_1.normalizeToArray)(config.externalQaCheck);
461
+ config.externalQaCheck = config.externalQaCheck.map((item) => (Object.assign({}, item)));
462
+ const items = config.externalQaCheck;
654
463
  const isSingle = items.length === 1;
655
464
  modules['external-qa-check'] = items.map((item, index) => {
656
465
  const key = (0, normalize_module_1.resolveInstanceKey)({
@@ -665,45 +474,30 @@ function handle(config) {
665
474
  const uiModule = item.settingsUiModule;
666
475
  return Object.assign(Object.assign({ key, name: item.name || config.name, description: item.description || config.description, runQaCheckUrl: `${base}/validate` }, (item.batchSize ? { getBatchSizeUrl: `${base}/batch-size` } : {})), (uiModule ? { url: `${base}/settings/` + (uiModule.fileName || 'index.html') } : {}));
667
476
  });
668
- config.externalQaCheck = isSingle ? items[0] : items;
669
477
  }
670
478
  if (config.workflowStepType) {
671
479
  // prevent possible overrides of the other modules
672
- if (Array.isArray(config.workflowStepType)) {
673
- config.workflowStepType = config.workflowStepType.map((workflowStep) => (Object.assign({}, workflowStep)));
674
- }
675
- else {
676
- config.workflowStepType = Object.assign({}, config.workflowStepType);
677
- }
678
- const workflowSteps = Array.isArray(config.workflowStepType)
679
- ? config.workflowStepType
680
- : [config.workflowStepType];
480
+ config.workflowStepType = config.workflowStepType.map((workflowStep) => (Object.assign({}, workflowStep)));
481
+ const workflowSteps = config.workflowStepType;
681
482
  modules['workflow-step-type'] = [];
682
483
  for (const workflowStep of workflowSteps) {
683
484
  if (!workflowStep.key) {
684
- workflowStep.key = config.identifier + '-' + (0, util_3.getWorkflowStepKey)(workflowStep);
485
+ workflowStep.key = config.identifier + '-' + (0, util_2.getWorkflowStepKey)(workflowStep);
685
486
  }
686
487
  const uiModule = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule;
687
488
  modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name }, (workflowStep.imageUrl || workflowStep.imagePath
688
489
  ? { logo: (0, util_1.getLogoUrl)(config, workflowStep, `-${workflowStep.key}`) }
689
- : {})), { description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }), (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/workflow-step/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/workflow-step/delete', workflowStep) }), ((uiModule === null || uiModule === void 0 ? void 0 : uiModule.formSchema)
490
+ : {})), { description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }), (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_2.getWorkflowStepUrl)('/workflow-step/settings', workflowStep), deleteSettingsUrl: (0, util_2.getWorkflowStepUrl)('/workflow-step/delete', workflowStep) }), ((uiModule === null || uiModule === void 0 ? void 0 : uiModule.formSchema)
690
491
  ? {
691
- url: `${(0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep)}/${uiModule.fileName || 'index.html'}`,
492
+ url: `${(0, util_2.getWorkflowStepUrl)('/workflow-step', workflowStep)}/${uiModule.fileName || 'index.html'}`,
692
493
  }
693
494
  : {})));
694
495
  }
695
496
  }
696
497
  if (config.automationAction) {
697
498
  // prevent possible overrides of the other modules
698
- if (Array.isArray(config.automationAction)) {
699
- config.automationAction = config.automationAction.map((automationAction) => (Object.assign({}, automationAction)));
700
- }
701
- else {
702
- config.automationAction = Object.assign({}, config.automationAction);
703
- }
704
- const automationActions = Array.isArray(config.automationAction)
705
- ? config.automationAction
706
- : [config.automationAction];
499
+ config.automationAction = config.automationAction.map((automationAction) => (Object.assign({}, automationAction)));
500
+ const automationActions = config.automationAction;
707
501
  modules['automation-action'] = [];
708
502
  for (const automationAction of automationActions) {
709
503
  if (!automationAction.key) {
@@ -719,13 +513,8 @@ function handle(config) {
719
513
  }
720
514
  if (config.authGuard) {
721
515
  // prevent possible overrides of the other modules
722
- if (Array.isArray(config.authGuard)) {
723
- config.authGuard = config.authGuard.map((authGuard) => (Object.assign({}, authGuard)));
724
- }
725
- else {
726
- config.authGuard = Object.assign({}, config.authGuard);
727
- }
728
- const authGuards = Array.isArray(config.authGuard) ? config.authGuard : [config.authGuard];
516
+ config.authGuard = config.authGuard.map((authGuard) => (Object.assign({}, authGuard)));
517
+ const authGuards = config.authGuard;
729
518
  modules['auth-guard'] = [];
730
519
  for (let i = 0; i < authGuards.length; i++) {
731
520
  if (!authGuards[i].key) {
@@ -8,22 +8,13 @@ const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-
8
8
  const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
9
  const util_1 = require("../../util");
10
10
  function register({ config, app }) {
11
- var _a, _b;
12
11
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
13
12
  if (!config.modal) {
14
13
  return;
15
14
  }
16
- if (Array.isArray(config.modal)) {
17
- config.modal.forEach((modal) => {
18
- if ((modal === null || modal === void 0 ? void 0 : modal.uiPath) || (modal === null || modal === void 0 ? void 0 : modal.formSchema)) {
19
- app.use(`/modal-${modal.key}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: modal.key }), (0, render_ui_module_1.default)(modal, config));
20
- }
21
- });
22
- }
23
- else {
24
- // backward compatibility will be removed after migration
25
- if (((_a = config.modal) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.modal) === null || _b === void 0 ? void 0 : _b.formSchema)) {
26
- app.use('/modal', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.modal.key }), (0, render_ui_module_1.default)(config.modal, config));
15
+ config.modal.forEach((modal) => {
16
+ if ((modal === null || modal === void 0 ? void 0 : modal.uiPath) || (modal === null || modal === void 0 ? void 0 : modal.formSchema)) {
17
+ app.use(`/modal-${modal.key}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: modal.key }), (0, render_ui_module_1.default)(modal, config));
27
18
  }
28
- }
19
+ });
29
20
  }
@@ -14,7 +14,7 @@ function register({ config, app }) {
14
14
  if (!config.organizationMenu) {
15
15
  return;
16
16
  }
17
- const items = (0, normalize_module_1.normalizeToArray)(config.organizationMenu);
17
+ const items = config.organizationMenu;
18
18
  const isSingle = items.length === 1;
19
19
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
20
20
  for (const [index, item] of items.entries()) {
@@ -14,7 +14,7 @@ function register({ config, app }) {
14
14
  if (!config.organizationSettingsMenu) {
15
15
  return;
16
16
  }
17
- const items = (0, normalize_module_1.normalizeToArray)(config.organizationSettingsMenu);
17
+ const items = config.organizationSettingsMenu;
18
18
  const isSingle = items.length === 1;
19
19
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
20
20
  for (const [index, item] of items.entries()) {