@crowdin/app-project-module 1.7.1 → 1.8.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.
@@ -4,6 +4,7 @@ exports.default = handle;
4
4
  const types_1 = require("../types");
5
5
  const util_1 = require("../util");
6
6
  const subscription_1 = require("../util/subscription");
7
+ const normalize_module_1 = require("../util/normalize-module");
7
8
  const api_1 = require("./api/api");
8
9
  const util_2 = require("./ai-tools/util");
9
10
  const util_3 = require("./workflow-step-type/util");
@@ -16,7 +17,7 @@ function normalizeEnvironments(environments) {
16
17
  return [environments];
17
18
  }
18
19
  function handle(config) {
19
- var _a, _b, _c;
20
+ var _a, _b;
20
21
  const modules = {};
21
22
  if (config.projectIntegration) {
22
23
  // prevent possible overrides of the other modules
@@ -28,190 +29,398 @@ function handle(config) {
28
29
  ];
29
30
  }
30
31
  if (config.customFileFormat) {
31
- // prevent possible overrides of the other modules
32
- config.customFileFormat = Object.assign(Object.assign({}, config.customFileFormat), { key: config.identifier + '-ff' });
33
- modules['custom-file-format'] = [
34
- {
35
- key: config.customFileFormat.key,
36
- type: config.customFileFormat.type,
37
- stringsExport: !!config.customFileFormat.stringsExport,
38
- multilingual: !!config.customFileFormat.multilingual,
39
- customSrxSupported: !!config.customFileFormat.customSrxSupported,
40
- extensions: config.customFileFormat.extensions,
41
- signaturePatterns: config.customFileFormat.signaturePatterns,
42
- multilingualExport: config.customFileFormat.multilingualExport,
43
- url: '/file/process',
44
- },
45
- ];
32
+ if (Array.isArray(config.customFileFormat)) {
33
+ config.customFileFormat = config.customFileFormat.map((item) => (Object.assign({}, item)));
34
+ }
35
+ else {
36
+ config.customFileFormat = Object.assign({}, config.customFileFormat);
37
+ }
38
+ const items = (0, normalize_module_1.normalizeToArray)(config.customFileFormat);
39
+ const isSingle = items.length === 1;
40
+ modules['custom-file-format'] = items.map((item, index) => {
41
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'ff', item, index, isSingle });
42
+ item.key = key;
43
+ return {
44
+ key,
45
+ type: item.type,
46
+ stringsExport: !!item.stringsExport,
47
+ multilingual: !!item.multilingual,
48
+ customSrxSupported: !!item.customSrxSupported,
49
+ extensions: item.extensions,
50
+ signaturePatterns: item.signaturePatterns,
51
+ multilingualExport: item.multilingualExport,
52
+ url: isSingle ? '/file/process' : `/file/${key}/process`,
53
+ };
54
+ });
55
+ config.customFileFormat = isSingle ? items[0] : items;
46
56
  }
47
57
  if (config.filePreImport) {
48
- // prevent possible overrides of the other modules
49
- config.filePreImport = Object.assign(Object.assign({}, config.filePreImport), { key: config.identifier + '-pri' });
50
- modules['file-pre-import'] = [
51
- {
52
- key: config.filePreImport.key,
53
- signaturePatterns: config.filePreImport.signaturePatterns,
54
- url: '/pre-import',
55
- },
56
- ];
58
+ if (Array.isArray(config.filePreImport)) {
59
+ config.filePreImport = config.filePreImport.map((item) => (Object.assign({}, item)));
60
+ }
61
+ else {
62
+ config.filePreImport = Object.assign({}, config.filePreImport);
63
+ }
64
+ const items = (0, normalize_module_1.normalizeToArray)(config.filePreImport);
65
+ const isSingle = items.length === 1;
66
+ modules['file-pre-import'] = items.map((item, index) => {
67
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'pri', item, index, isSingle });
68
+ item.key = key;
69
+ return {
70
+ key,
71
+ signaturePatterns: item.signaturePatterns,
72
+ url: isSingle ? '/pre-import' : `/pre-import/${key}`,
73
+ };
74
+ });
75
+ config.filePreImport = isSingle ? items[0] : items;
57
76
  }
58
77
  if (config.filePostImport) {
59
- // prevent possible overrides of the other modules
60
- config.filePostImport = Object.assign(Object.assign({}, config.filePostImport), { key: config.identifier + '-poi' });
61
- modules['file-post-import'] = [
62
- {
63
- key: config.filePostImport.key,
64
- signaturePatterns: config.filePostImport.signaturePatterns,
65
- url: '/post-import',
66
- },
67
- ];
78
+ if (Array.isArray(config.filePostImport)) {
79
+ config.filePostImport = config.filePostImport.map((item) => (Object.assign({}, item)));
80
+ }
81
+ else {
82
+ config.filePostImport = Object.assign({}, config.filePostImport);
83
+ }
84
+ const items = (0, normalize_module_1.normalizeToArray)(config.filePostImport);
85
+ const isSingle = items.length === 1;
86
+ modules['file-post-import'] = items.map((item, index) => {
87
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'poi', item, index, isSingle });
88
+ item.key = key;
89
+ return {
90
+ key,
91
+ signaturePatterns: item.signaturePatterns,
92
+ url: isSingle ? '/post-import' : `/post-import/${key}`,
93
+ };
94
+ });
95
+ config.filePostImport = isSingle ? items[0] : items;
68
96
  }
69
97
  if (config.filePreExport) {
70
- // prevent possible overrides of the other modules
71
- config.filePreExport = Object.assign(Object.assign({}, config.filePreExport), { key: config.identifier + '-pre' });
72
- modules['file-pre-export'] = [
73
- {
74
- key: config.filePreExport.key,
75
- signaturePatterns: config.filePreExport.signaturePatterns,
76
- url: '/pre-export',
77
- },
78
- ];
98
+ if (Array.isArray(config.filePreExport)) {
99
+ config.filePreExport = config.filePreExport.map((item) => (Object.assign({}, item)));
100
+ }
101
+ else {
102
+ config.filePreExport = Object.assign({}, config.filePreExport);
103
+ }
104
+ const items = (0, normalize_module_1.normalizeToArray)(config.filePreExport);
105
+ const isSingle = items.length === 1;
106
+ modules['file-pre-export'] = items.map((item, index) => {
107
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'pre', item, index, isSingle });
108
+ item.key = key;
109
+ return {
110
+ key,
111
+ signaturePatterns: item.signaturePatterns,
112
+ url: isSingle ? '/pre-export' : `/pre-export/${key}`,
113
+ };
114
+ });
115
+ config.filePreExport = isSingle ? items[0] : items;
79
116
  }
80
117
  if (config.filePostExport) {
81
- // prevent possible overrides of the other modules
82
- config.filePostExport = Object.assign(Object.assign({}, config.filePostExport), { key: config.identifier + '-poe' });
83
- modules['file-post-export'] = [
84
- {
85
- key: config.filePostExport.key,
86
- signaturePatterns: config.filePostExport.signaturePatterns,
87
- url: '/post-export',
88
- },
89
- ];
118
+ if (Array.isArray(config.filePostExport)) {
119
+ config.filePostExport = config.filePostExport.map((item) => (Object.assign({}, item)));
120
+ }
121
+ else {
122
+ config.filePostExport = Object.assign({}, config.filePostExport);
123
+ }
124
+ const items = (0, normalize_module_1.normalizeToArray)(config.filePostExport);
125
+ const isSingle = items.length === 1;
126
+ modules['file-post-export'] = items.map((item, index) => {
127
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'poe', item, index, isSingle });
128
+ item.key = key;
129
+ return {
130
+ key,
131
+ signaturePatterns: item.signaturePatterns,
132
+ url: isSingle ? '/post-export' : `/post-export/${key}`,
133
+ };
134
+ });
135
+ config.filePostExport = isSingle ? items[0] : items;
90
136
  }
91
137
  if (config.fileTranslationsAlignmentExport) {
92
- // prevent possible overrides of the other modules
93
- config.fileTranslationsAlignmentExport = Object.assign(Object.assign({}, config.fileTranslationsAlignmentExport), { key: config.identifier + '-ftae' });
94
- modules['file-translations-alignment'] = [
95
- {
96
- key: config.fileTranslationsAlignmentExport.key,
97
- signaturePatterns: config.fileTranslationsAlignmentExport.signaturePatterns,
98
- url: '/translations-alignment',
99
- },
100
- ];
138
+ if (Array.isArray(config.fileTranslationsAlignmentExport)) {
139
+ config.fileTranslationsAlignmentExport = config.fileTranslationsAlignmentExport.map((item) => (Object.assign({}, item)));
140
+ }
141
+ else {
142
+ config.fileTranslationsAlignmentExport = Object.assign({}, config.fileTranslationsAlignmentExport);
143
+ }
144
+ const items = (0, normalize_module_1.normalizeToArray)(config.fileTranslationsAlignmentExport);
145
+ const isSingle = items.length === 1;
146
+ modules['file-translations-alignment'] = items.map((item, index) => {
147
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'ftae', item, index, isSingle });
148
+ item.key = key;
149
+ return {
150
+ key,
151
+ signaturePatterns: item.signaturePatterns,
152
+ url: isSingle ? '/translations-alignment' : `/translations-alignment/${key}`,
153
+ };
154
+ });
155
+ config.fileTranslationsAlignmentExport = isSingle ? items[0] : items;
101
156
  }
102
157
  if (config.customMT) {
103
- // prevent possible overrides of the other modules
104
- config.customMT = Object.assign(Object.assign({}, config.customMT), { key: config.identifier + '-mt' });
105
- modules['custom-mt'] = [
106
- Object.assign(Object.assign(Object.assign(Object.assign({ key: config.customMT.key, name: config.name, logo: (0, util_1.getLogoUrl)(config, config.customMT, '/mt'), url: '/mt/translate', withContext: !!config.customMT.withContext }, ((0, util_1.isDefined)(config.customMT.splitStringsIntoChunks) && {
107
- splitStringsIntoChunks: config.customMT.splitStringsIntoChunks,
108
- })), ((0, util_1.isDefined)(config.customMT.batchSize) && {
109
- batchSize: config.customMT.batchSize,
110
- })), ((0, util_1.isDefined)(config.customMT.maskEntities) && {
111
- maskEntities: config.customMT.maskEntities,
112
- })), (!!config.customMT.environments && {
113
- environments: normalizeEnvironments(config.customMT.environments),
114
- })),
115
- ];
158
+ if (Array.isArray(config.customMT)) {
159
+ config.customMT = config.customMT.map((item) => (Object.assign({}, item)));
160
+ }
161
+ else {
162
+ config.customMT = Object.assign({}, config.customMT);
163
+ }
164
+ const items = (0, normalize_module_1.normalizeToArray)(config.customMT);
165
+ const isSingle = items.length === 1;
166
+ modules['custom-mt'] = items.map((item, index) => {
167
+ const key = (0, normalize_module_1.resolveInstanceKey)({ identifier: config.identifier, suffix: 'mt', item, index, isSingle });
168
+ item.key = key;
169
+ return Object.assign(Object.assign(Object.assign(Object.assign({ key, name: config.name, logo: (0, util_1.getLogoUrl)(config, item, isSingle ? '/mt' : `/mt-${key}`), url: isSingle ? '/mt/translate' : `/mt/${key}/translate`, withContext: !!item.withContext }, ((0, util_1.isDefined)(item.splitStringsIntoChunks) && {
170
+ splitStringsIntoChunks: item.splitStringsIntoChunks,
171
+ })), ((0, util_1.isDefined)(item.batchSize) && {
172
+ batchSize: item.batchSize,
173
+ })), ((0, util_1.isDefined)(item.maskEntities) && {
174
+ maskEntities: item.maskEntities,
175
+ })), (!!item.environments && {
176
+ environments: normalizeEnvironments(item.environments),
177
+ }));
178
+ });
179
+ config.customMT = isSingle ? items[0] : items;
116
180
  }
117
181
  if (config.organizationMenu) {
118
- // prevent possible overrides of the other modules
119
- config.organizationMenu = Object.assign(Object.assign({}, config.organizationMenu), { key: config.identifier + '-resources' });
120
- modules['organization-menu'] = [
121
- {
122
- key: config.organizationMenu.key,
123
- name: config.organizationMenu.name || config.name,
124
- url: '/organization-menu/' + (config.organizationMenu.fileName || 'index.html'),
125
- icon: (0, util_1.getLogoUrl)(config, config.organizationMenu, '/resources'),
126
- },
127
- ];
182
+ if (Array.isArray(config.organizationMenu)) {
183
+ config.organizationMenu = config.organizationMenu.map((item) => (Object.assign({}, item)));
184
+ }
185
+ else {
186
+ config.organizationMenu = Object.assign({}, config.organizationMenu);
187
+ }
188
+ const items = (0, normalize_module_1.normalizeToArray)(config.organizationMenu);
189
+ const isSingle = items.length === 1;
190
+ modules['organization-menu'] = items.map((item, index) => {
191
+ const key = (0, normalize_module_1.resolveInstanceKey)({
192
+ identifier: config.identifier,
193
+ suffix: 'resources',
194
+ item,
195
+ index,
196
+ isSingle,
197
+ });
198
+ item.key = key;
199
+ const basePath = isSingle ? '/organization-menu' : `/organization-menu-${key}`;
200
+ return {
201
+ key,
202
+ name: item.name || config.name,
203
+ url: basePath + '/' + (item.fileName || 'index.html'),
204
+ icon: (0, util_1.getLogoUrl)(config, item, isSingle ? '/resources' : `/organization-menu-${key}`),
205
+ };
206
+ });
207
+ config.organizationMenu = isSingle ? items[0] : items;
128
208
  }
129
209
  if (config.organizationSettingsMenu) {
130
- // prevent possible overrides of the other modules
131
- config.organizationSettingsMenu = Object.assign(Object.assign({}, config.organizationSettingsMenu), { key: config.identifier + '-organization-settings-menu' });
132
- modules['organization-settings-menu'] = [
133
- {
134
- key: config.organizationSettingsMenu.key,
135
- name: config.organizationSettingsMenu.name || config.name,
136
- url: '/organization-settings/' + (config.organizationSettingsMenu.fileName || 'index.html'),
137
- icon: (0, util_1.getLogoUrl)(config, config.organizationSettingsMenu, '/organization-settings'),
138
- },
139
- ];
210
+ if (Array.isArray(config.organizationSettingsMenu)) {
211
+ config.organizationSettingsMenu = config.organizationSettingsMenu.map((item) => (Object.assign({}, item)));
212
+ }
213
+ else {
214
+ config.organizationSettingsMenu = Object.assign({}, config.organizationSettingsMenu);
215
+ }
216
+ const items = (0, normalize_module_1.normalizeToArray)(config.organizationSettingsMenu);
217
+ const isSingle = items.length === 1;
218
+ modules['organization-settings-menu'] = items.map((item, index) => {
219
+ const key = (0, normalize_module_1.resolveInstanceKey)({
220
+ identifier: config.identifier,
221
+ suffix: 'organization-settings-menu',
222
+ item,
223
+ index,
224
+ isSingle,
225
+ });
226
+ item.key = key;
227
+ const basePath = isSingle ? '/organization-settings' : `/organization-settings-${key}`;
228
+ return {
229
+ key,
230
+ name: item.name || config.name,
231
+ url: basePath + '/' + (item.fileName || 'index.html'),
232
+ icon: (0, util_1.getLogoUrl)(config, item, isSingle ? '/organization-settings' : `/organization-settings-${key}`),
233
+ };
234
+ });
235
+ config.organizationSettingsMenu = isSingle ? items[0] : items;
140
236
  }
141
237
  if (config.profileResourcesMenu) {
142
- // prevent possible overrides of the other modules
143
- config.profileResourcesMenu = Object.assign(Object.assign({}, config.profileResourcesMenu), { key: config.identifier + '-profile-resources-menu' });
144
- modules['profile-resources-menu'] = [
145
- Object.assign({ key: config.profileResourcesMenu.key, name: config.profileResourcesMenu.name || config.name, url: '/profile-resources/' + (config.profileResourcesMenu.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config, config.profileResourcesMenu, '/profile-resources') }, (!!config.profileResourcesMenu.environments && {
146
- environments: normalizeEnvironments(config.profileResourcesMenu.environments),
147
- })),
148
- ];
238
+ if (Array.isArray(config.profileResourcesMenu)) {
239
+ config.profileResourcesMenu = config.profileResourcesMenu.map((item) => (Object.assign({}, item)));
240
+ }
241
+ else {
242
+ config.profileResourcesMenu = Object.assign({}, config.profileResourcesMenu);
243
+ }
244
+ const items = (0, normalize_module_1.normalizeToArray)(config.profileResourcesMenu);
245
+ const isSingle = items.length === 1;
246
+ modules['profile-resources-menu'] = items.map((item, index) => {
247
+ const key = (0, normalize_module_1.resolveInstanceKey)({
248
+ identifier: config.identifier,
249
+ suffix: 'profile-resources-menu',
250
+ item,
251
+ index,
252
+ isSingle,
253
+ });
254
+ item.key = key;
255
+ const basePath = isSingle ? '/profile-resources' : `/profile-resources-${key}`;
256
+ return Object.assign({ key, name: item.name || config.name, url: basePath + '/' + (item.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config, item, isSingle ? '/profile-resources' : `/profile-resources-${key}`) }, (!!item.environments && {
257
+ environments: normalizeEnvironments(item.environments),
258
+ }));
259
+ });
260
+ config.profileResourcesMenu = isSingle ? items[0] : items;
149
261
  }
150
262
  if (config.profileSettingsMenu) {
151
- // prevent possible overrides of the other modules
152
- config.profileSettingsMenu = Object.assign(Object.assign({}, config.profileSettingsMenu), { key: config.identifier + '-profile-settings-menu' });
153
- modules['profile-settings-menu'] = [
154
- Object.assign({ key: config.profileSettingsMenu.key, name: config.profileSettingsMenu.name || config.name, url: '/profile-settings/' + (config.profileSettingsMenu.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config, config.profileSettingsMenu, '/profile-settings') }, (!!config.profileSettingsMenu.environments && {
155
- environments: normalizeEnvironments(config.profileSettingsMenu.environments),
156
- })),
157
- ];
263
+ if (Array.isArray(config.profileSettingsMenu)) {
264
+ config.profileSettingsMenu = config.profileSettingsMenu.map((item) => (Object.assign({}, item)));
265
+ }
266
+ else {
267
+ config.profileSettingsMenu = Object.assign({}, config.profileSettingsMenu);
268
+ }
269
+ const items = (0, normalize_module_1.normalizeToArray)(config.profileSettingsMenu);
270
+ const isSingle = items.length === 1;
271
+ modules['profile-settings-menu'] = items.map((item, index) => {
272
+ const key = (0, normalize_module_1.resolveInstanceKey)({
273
+ identifier: config.identifier,
274
+ suffix: 'profile-settings-menu',
275
+ item,
276
+ index,
277
+ isSingle,
278
+ });
279
+ item.key = key;
280
+ const basePath = isSingle ? '/profile-settings' : `/profile-settings-${key}`;
281
+ return Object.assign({ key, name: item.name || config.name, url: basePath + '/' + (item.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config, item, isSingle ? '/profile-settings' : `/profile-settings-${key}`) }, (!!item.environments && {
282
+ environments: normalizeEnvironments(item.environments),
283
+ }));
284
+ });
285
+ config.profileSettingsMenu = isSingle ? items[0] : items;
158
286
  }
159
287
  if (config.editorRightPanel) {
160
- // prevent possible overrides of the other modules
161
- config.editorRightPanel = Object.assign(Object.assign({}, config.editorRightPanel), { key: config.identifier + '-editor-panels' });
162
- modules['editor-right-panel'] = [
163
- Object.assign({ key: config.editorRightPanel.key, name: config.editorRightPanel.name || config.name, url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'), supportsMultipleStrings: (_a = config.editorRightPanel.supportsMultipleStrings) !== null && _a !== void 0 ? _a : false, modes: config.editorRightPanel.modes }, (!!config.editorRightPanel.environments && {
164
- environments: normalizeEnvironments(config.editorRightPanel.environments),
165
- })),
166
- ];
288
+ if (Array.isArray(config.editorRightPanel)) {
289
+ config.editorRightPanel = config.editorRightPanel.map((item) => (Object.assign({}, item)));
290
+ }
291
+ else {
292
+ config.editorRightPanel = Object.assign({}, config.editorRightPanel);
293
+ }
294
+ const items = (0, normalize_module_1.normalizeToArray)(config.editorRightPanel);
295
+ const isSingle = items.length === 1;
296
+ modules['editor-right-panel'] = items.map((item, index) => {
297
+ var _a;
298
+ const key = (0, normalize_module_1.resolveInstanceKey)({
299
+ identifier: config.identifier,
300
+ suffix: 'editor-panels',
301
+ item,
302
+ index,
303
+ isSingle,
304
+ });
305
+ item.key = key;
306
+ const basePath = isSingle ? '/editor-panels' : `/editor-panels-${key}`;
307
+ return Object.assign({ key, name: item.name || config.name, url: basePath + '/' + (item.fileName || 'index.html'), supportsMultipleStrings: (_a = item.supportsMultipleStrings) !== null && _a !== void 0 ? _a : false, modes: item.modes }, (!!item.environments && {
308
+ environments: normalizeEnvironments(item.environments),
309
+ }));
310
+ });
311
+ config.editorRightPanel = isSingle ? items[0] : items;
167
312
  }
168
313
  if (config.projectMenu) {
169
- // prevent possible overrides of the other modules
170
- config.projectMenu = Object.assign(Object.assign({}, config.projectMenu), { key: config.identifier + '-project-menu' });
171
- modules['project-menu'] = [
172
- Object.assign({ key: config.projectMenu.key, name: config.projectMenu.name || config.name, url: '/project-menu/' + (config.projectMenu.fileName || 'index.html') }, (!!config.projectMenu.environments && {
173
- environments: normalizeEnvironments(config.projectMenu.environments),
174
- })),
175
- ];
314
+ if (Array.isArray(config.projectMenu)) {
315
+ config.projectMenu = config.projectMenu.map((item) => (Object.assign({}, item)));
316
+ }
317
+ else {
318
+ config.projectMenu = Object.assign({}, config.projectMenu);
319
+ }
320
+ const items = (0, normalize_module_1.normalizeToArray)(config.projectMenu);
321
+ const isSingle = items.length === 1;
322
+ modules['project-menu'] = items.map((item, index) => {
323
+ const key = (0, normalize_module_1.resolveInstanceKey)({
324
+ identifier: config.identifier,
325
+ suffix: 'project-menu',
326
+ item,
327
+ index,
328
+ isSingle,
329
+ });
330
+ item.key = key;
331
+ const basePath = isSingle ? '/project-menu' : `/project-menu-${key}`;
332
+ return Object.assign({ key, name: item.name || config.name, url: basePath + '/' + (item.fileName || 'index.html') }, (!!item.environments && {
333
+ environments: normalizeEnvironments(item.environments),
334
+ }));
335
+ });
336
+ config.projectMenu = isSingle ? items[0] : items;
176
337
  }
177
338
  if (config.projectMenuCrowdsource) {
178
- // prevent possible overrides of the other modules
179
- config.projectMenuCrowdsource = Object.assign(Object.assign({}, config.projectMenuCrowdsource), { key: config.identifier + '-project-menu-crowdsource' });
180
- modules['project-menu-crowdsource'] = [
181
- {
182
- key: config.projectMenuCrowdsource.key,
183
- name: config.projectMenuCrowdsource.name || config.name,
184
- url: '/project-menu-crowdsource/' + (config.projectMenuCrowdsource.fileName || 'index.html'),
185
- },
186
- ];
339
+ if (Array.isArray(config.projectMenuCrowdsource)) {
340
+ config.projectMenuCrowdsource = config.projectMenuCrowdsource.map((item) => (Object.assign({}, item)));
341
+ }
342
+ else {
343
+ config.projectMenuCrowdsource = Object.assign({}, config.projectMenuCrowdsource);
344
+ }
345
+ const items = (0, normalize_module_1.normalizeToArray)(config.projectMenuCrowdsource);
346
+ const isSingle = items.length === 1;
347
+ modules['project-menu-crowdsource'] = items.map((item, index) => {
348
+ const key = (0, normalize_module_1.resolveInstanceKey)({
349
+ identifier: config.identifier,
350
+ suffix: 'project-menu-crowdsource',
351
+ item,
352
+ index,
353
+ isSingle,
354
+ });
355
+ item.key = key;
356
+ const basePath = isSingle ? '/project-menu-crowdsource' : `/project-menu-crowdsource-${key}`;
357
+ return {
358
+ key,
359
+ name: item.name || config.name,
360
+ url: basePath + '/' + (item.fileName || 'index.html'),
361
+ };
362
+ });
363
+ config.projectMenuCrowdsource = isSingle ? items[0] : items;
187
364
  }
188
365
  if (config.projectTools) {
189
- // prevent possible overrides of the other modules
190
- config.projectTools = Object.assign(Object.assign({}, config.projectTools), { key: config.identifier + '-tools' });
191
- modules['project-tools'] = [
192
- Object.assign({ key: config.projectTools.key, name: config.projectTools.name || config.name, description: config.description, logo: (0, util_1.getLogoUrl)(config, config.projectTools, '/tools'), url: '/tools/' + (config.projectTools.fileName || 'index.html') }, (!!config.projectTools.environments && {
193
- environments: normalizeEnvironments(config.projectTools.environments),
194
- })),
195
- ];
366
+ if (Array.isArray(config.projectTools)) {
367
+ config.projectTools = config.projectTools.map((item) => (Object.assign({}, item)));
368
+ }
369
+ else {
370
+ config.projectTools = Object.assign({}, config.projectTools);
371
+ }
372
+ const items = (0, normalize_module_1.normalizeToArray)(config.projectTools);
373
+ const isSingle = items.length === 1;
374
+ modules['project-tools'] = items.map((item, index) => {
375
+ const key = (0, normalize_module_1.resolveInstanceKey)({
376
+ identifier: config.identifier,
377
+ suffix: 'tools',
378
+ item,
379
+ index,
380
+ isSingle,
381
+ });
382
+ item.key = key;
383
+ const basePath = isSingle ? '/tools' : `/tools-${key}`;
384
+ return Object.assign({ key, name: item.name || config.name, description: config.description, logo: (0, util_1.getLogoUrl)(config, item, isSingle ? '/tools' : `/tools-${key}`), url: basePath + '/' + (item.fileName || 'index.html') }, (!!item.environments && {
385
+ environments: normalizeEnvironments(item.environments),
386
+ }));
387
+ });
388
+ config.projectTools = isSingle ? items[0] : items;
196
389
  }
197
390
  if (config.projectReports) {
198
- // prevent possible overrides of the other modules
199
- config.projectReports = Object.assign(Object.assign({}, config.projectReports), { key: config.identifier + '-project-reports' });
200
- modules['project-reports'] = [
201
- {
202
- key: config.projectReports.key,
203
- name: config.projectReports.name || config.name,
391
+ if (Array.isArray(config.projectReports)) {
392
+ config.projectReports = config.projectReports.map((item) => (Object.assign({}, item)));
393
+ }
394
+ else {
395
+ config.projectReports = Object.assign({}, config.projectReports);
396
+ }
397
+ const items = (0, normalize_module_1.normalizeToArray)(config.projectReports);
398
+ const isSingle = items.length === 1;
399
+ modules['project-reports'] = items.map((item, index) => {
400
+ const key = (0, normalize_module_1.resolveInstanceKey)({
401
+ identifier: config.identifier,
402
+ suffix: 'project-reports',
403
+ item,
404
+ index,
405
+ isSingle,
406
+ });
407
+ item.key = key;
408
+ const basePath = isSingle ? '/reports' : `/reports-${key}`;
409
+ return {
410
+ key,
411
+ name: item.name || config.name,
204
412
  description: config.description,
205
- logo: (0, util_1.getLogoUrl)(config, config.projectReports, '/reports'),
206
- url: '/reports/' + (config.projectReports.fileName || 'index.html'),
207
- },
208
- ];
413
+ logo: (0, util_1.getLogoUrl)(config, item, isSingle ? '/reports' : `/reports-${key}`),
414
+ url: basePath + '/' + (item.fileName || 'index.html'),
415
+ };
416
+ });
417
+ config.projectReports = isSingle ? items[0] : items;
209
418
  }
210
419
  if (config.modal) {
211
420
  let modals = [];
212
421
  if (Array.isArray(config.modal)) {
213
- modals = config.modal.map((modal, i) => {
214
- const moduleKey = modal.key || `${config.identifier}-modal-${i}`;
422
+ modals = config.modal.map((modal, index) => {
423
+ const moduleKey = modal.key || `${config.identifier}-modal-${index}`;
215
424
  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) }));
216
425
  });
217
426
  }
@@ -227,8 +436,8 @@ function handle(config) {
227
436
  if (config.contextMenu) {
228
437
  let contextMenus = [];
229
438
  if (Array.isArray(config.contextMenu)) {
230
- contextMenus = config.contextMenu.map((contextMenu, i) => {
231
- const moduleKey = contextMenu.key || `${config.identifier}-context-menu-${i}`;
439
+ contextMenus = config.contextMenu.map((contextMenu, index) => {
440
+ const moduleKey = contextMenu.key || `${config.identifier}-context-menu-${index}`;
232
441
  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
233
442
  ? {
234
443
  module: {
@@ -259,57 +468,121 @@ function handle(config) {
259
468
  modules['api'] = (0, api_1.getApiManifest)(config, config.api);
260
469
  }
261
470
  if (config.customSpellchecker) {
262
- // prevent possible overrides of the other modules
263
- config.customSpellchecker = Object.assign(Object.assign({}, config.customSpellchecker), { key: config.identifier + '-spellchecker' });
264
- const uiModule = config.customSpellchecker.settingsUiModule;
265
- modules['custom-spellchecker'] = [
266
- Object.assign(Object.assign({ key: config.customSpellchecker.key, name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/spellchecker/languages', checkSpellingUrl: '/spellchecker/spellcheck' }, (!!config.customSpellchecker.environments && {
267
- environments: normalizeEnvironments(config.customSpellchecker.environments),
268
- })), (uiModule ? { url: '/spellchecker/settings/' + (uiModule.fileName || 'index.html') } : {})),
269
- ];
471
+ if (Array.isArray(config.customSpellchecker)) {
472
+ config.customSpellchecker = config.customSpellchecker.map((item) => (Object.assign({}, item)));
473
+ }
474
+ else {
475
+ config.customSpellchecker = Object.assign({}, config.customSpellchecker);
476
+ }
477
+ const items = (0, normalize_module_1.normalizeToArray)(config.customSpellchecker);
478
+ const isSingle = items.length === 1;
479
+ modules['custom-spellchecker'] = items.map((item, index) => {
480
+ const key = (0, normalize_module_1.resolveInstanceKey)({
481
+ identifier: config.identifier,
482
+ suffix: 'spellchecker',
483
+ item,
484
+ index,
485
+ isSingle,
486
+ });
487
+ item.key = key;
488
+ const base = isSingle ? '/spellchecker' : `/spellchecker/${key}`;
489
+ const uiModule = item.settingsUiModule;
490
+ return Object.assign(Object.assign({ key, name: item.name || config.name, description: item.description || config.description, listSupportedLanguagesUrl: `${base}/languages`, checkSpellingUrl: `${base}/spellcheck` }, (!!item.environments && {
491
+ environments: normalizeEnvironments(item.environments),
492
+ })), (uiModule ? { url: `${base}/settings/` + (uiModule.fileName || 'index.html') } : {}));
493
+ });
494
+ config.customSpellchecker = isSingle ? items[0] : items;
270
495
  }
271
496
  if (config.aiProvider) {
272
- // prevent possible overrides of the other modules
273
- config.aiProvider = Object.assign(Object.assign({}, config.aiProvider), { key: config.identifier + '-aiprovider' });
274
- const uiModule = config.aiProvider.settingsUiModule;
275
- modules['ai-provider'] = [
276
- Object.assign(Object.assign({ key: config.aiProvider.key, name: config.aiProvider.name || config.name, description: config.aiProvider.description || config.description, logo: (0, util_1.getLogoUrl)(config, config.aiProvider, '/aiprovider'), chatCompletionsUrl: '/ai-provider/completions', modelsUrl: '/ai-provider/models' }, (!!config.aiProvider.environments && {
277
- environments: normalizeEnvironments(config.aiProvider.environments),
278
- })), (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
279
- ];
497
+ if (Array.isArray(config.aiProvider)) {
498
+ config.aiProvider = config.aiProvider.map((item) => (Object.assign({}, item)));
499
+ }
500
+ else {
501
+ config.aiProvider = Object.assign({}, config.aiProvider);
502
+ }
503
+ const items = (0, normalize_module_1.normalizeToArray)(config.aiProvider);
504
+ const isSingle = items.length === 1;
505
+ modules['ai-provider'] = items.map((item, index) => {
506
+ const key = (0, normalize_module_1.resolveInstanceKey)({
507
+ identifier: config.identifier,
508
+ suffix: 'aiprovider',
509
+ item,
510
+ index,
511
+ isSingle,
512
+ });
513
+ item.key = key;
514
+ const base = isSingle ? '/ai-provider' : `/ai-provider/${key}`;
515
+ const logoPath = isSingle ? '/aiprovider' : `/aiprovider-${key}`;
516
+ const settingsBase = isSingle ? '' : `/${key}`;
517
+ const uiModule = item.settingsUiModule;
518
+ return Object.assign(Object.assign({ key, name: item.name || config.name, description: item.description || config.description, logo: (0, util_1.getLogoUrl)(config, item, logoPath), chatCompletionsUrl: `${base}/completions`, modelsUrl: `${base}/models` }, (!!item.environments && {
519
+ environments: normalizeEnvironments(item.environments),
520
+ })), (uiModule ? { url: `/settings${settingsBase}/` + (uiModule.fileName || 'index.html') } : {}));
521
+ });
522
+ config.aiProvider = isSingle ? items[0] : items;
280
523
  }
281
524
  [
282
525
  ...Object.values(ai_request_processors_1.AiRequestProcessorModuleWithoutStream),
283
526
  ...Object.values(ai_request_processors_1.AiRequestProcessorModuleWithStream),
284
527
  ].forEach((moduleType) => {
285
- const module = config[moduleType];
286
- if (!module) {
528
+ const moduleValue = config[moduleType];
529
+ if (!moduleValue) {
287
530
  return;
288
531
  }
289
532
  const moduleSlug = (0, ai_request_processors_1.generateModuleSlugFromType)(moduleType);
290
- modules[moduleSlug] = [
291
- {
292
- key: config.identifier + '-' + moduleSlug,
293
- processorUrl: '/ai-request-processor/' + moduleSlug,
294
- },
295
- ];
533
+ if (Array.isArray(moduleValue)) {
534
+ config[moduleType] = moduleValue.map((item) => (Object.assign({}, item)));
535
+ }
536
+ else {
537
+ config[moduleType] = Object.assign({}, moduleValue);
538
+ }
539
+ const items = (0, normalize_module_1.normalizeToArray)(config[moduleType]);
540
+ const isSingle = items.length === 1;
541
+ modules[moduleSlug] = items.map((item, index) => {
542
+ const key = (0, normalize_module_1.resolveInstanceKey)({
543
+ identifier: config.identifier,
544
+ suffix: moduleSlug,
545
+ item,
546
+ index,
547
+ isSingle,
548
+ });
549
+ item.key = key;
550
+ return {
551
+ key,
552
+ processorUrl: isSingle
553
+ ? '/ai-request-processor/' + moduleSlug
554
+ : `/ai-request-processor/${moduleSlug}/${key}`,
555
+ };
556
+ });
557
+ config[moduleType] = isSingle ? items[0] : items;
296
558
  });
297
559
  if (config.aiPromptProvider) {
298
- // prevent possible overrides of the other modules
299
- config.aiPromptProvider = Object.assign(Object.assign({}, config.aiPromptProvider), { key: config.identifier + '-ai-prompt-provider' });
300
- modules['ai-prompt-provider'] = [
301
- Object.assign(Object.assign(Object.assign({ key: config.aiPromptProvider.key, name: config.aiPromptProvider.name || config.name, logo: (0, util_1.getLogoUrl)(config, config.aiPromptProvider, '/ai-prompt-provider'), compileUrl: '/prompt-provider/compile' }, ((0, util_1.isDefined)(config.aiPromptProvider.allowRetryOnQaIssues) && {
302
- allowRetryOnQaIssues: config.aiPromptProvider.allowRetryOnQaIssues,
303
- })), (config.aiPromptProvider.actions
304
- ? {
305
- actions: config.aiPromptProvider.actions,
306
- }
307
- : {})), (config.aiPromptProvider.formSchema || config.aiPromptProvider.uiPath
308
- ? {
309
- configuratorUrl: '/prompt-provider/settings/' + (config.aiPromptProvider.fileName || 'index.html'),
310
- }
311
- : {})),
312
- ];
560
+ if (Array.isArray(config.aiPromptProvider)) {
561
+ config.aiPromptProvider = config.aiPromptProvider.map((item) => (Object.assign({}, item)));
562
+ }
563
+ else {
564
+ config.aiPromptProvider = Object.assign({}, config.aiPromptProvider);
565
+ }
566
+ const items = (0, normalize_module_1.normalizeToArray)(config.aiPromptProvider);
567
+ const isSingle = items.length === 1;
568
+ modules['ai-prompt-provider'] = items.map((item, index) => {
569
+ const key = (0, normalize_module_1.resolveInstanceKey)({
570
+ identifier: config.identifier,
571
+ suffix: 'ai-prompt-provider',
572
+ item,
573
+ index,
574
+ isSingle,
575
+ });
576
+ item.key = key;
577
+ const base = isSingle ? '/prompt-provider' : `/prompt-provider/${key}`;
578
+ const logoPath = isSingle ? '/ai-prompt-provider' : `/ai-prompt-provider-${key}`;
579
+ return Object.assign(Object.assign(Object.assign({ key, name: item.name || config.name, logo: (0, util_1.getLogoUrl)(config, item, logoPath), compileUrl: `${base}/compile` }, ((0, util_1.isDefined)(item.allowRetryOnQaIssues) && {
580
+ allowRetryOnQaIssues: item.allowRetryOnQaIssues,
581
+ })), (item.actions ? { actions: item.actions } : {})), (item.formSchema || item.uiPath
582
+ ? { configuratorUrl: `${base}/settings/` + (item.fileName || 'index.html') }
583
+ : {}));
584
+ });
585
+ config.aiPromptProvider = isSingle ? items[0] : items;
313
586
  }
314
587
  if (config.aiTools) {
315
588
  // prevent possible overrides of the other modules
@@ -365,12 +638,28 @@ function handle(config) {
365
638
  }
366
639
  }
367
640
  if (config.externalQaCheck) {
368
- // prevent possible overrides of the other modules
369
- config.externalQaCheck = Object.assign(Object.assign({}, config.externalQaCheck), { key: config.identifier + '-qa-check' });
370
- const uiModule = config.externalQaCheck.settingsUiModule;
371
- modules['external-qa-check'] = [
372
- Object.assign(Object.assign({ key: config.externalQaCheck.key, name: config.externalQaCheck.name || config.name, description: config.externalQaCheck.description || config.description, runQaCheckUrl: '/qa-check/validate' }, (config.externalQaCheck.batchSize ? { getBatchSizeUrl: '/qa-check/batch-size' } : {})), (uiModule ? { url: '/qa-check/settings/' + (uiModule.fileName || 'index.html') } : {})),
373
- ];
641
+ if (Array.isArray(config.externalQaCheck)) {
642
+ config.externalQaCheck = config.externalQaCheck.map((item) => (Object.assign({}, item)));
643
+ }
644
+ else {
645
+ config.externalQaCheck = Object.assign({}, config.externalQaCheck);
646
+ }
647
+ const items = (0, normalize_module_1.normalizeToArray)(config.externalQaCheck);
648
+ const isSingle = items.length === 1;
649
+ modules['external-qa-check'] = items.map((item, index) => {
650
+ const key = (0, normalize_module_1.resolveInstanceKey)({
651
+ identifier: config.identifier,
652
+ suffix: 'qa-check',
653
+ item,
654
+ index,
655
+ isSingle,
656
+ });
657
+ item.key = key;
658
+ const base = isSingle ? '/qa-check' : `/qa-check/${key}`;
659
+ const uiModule = item.settingsUiModule;
660
+ 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') } : {}));
661
+ });
662
+ config.externalQaCheck = isSingle ? items[0] : items;
374
663
  }
375
664
  if (config.workflowStepType) {
376
665
  // prevent possible overrides of the other modules
@@ -388,7 +677,7 @@ function handle(config) {
388
677
  if (!workflowStep.key) {
389
678
  workflowStep.key = config.identifier + '-' + (0, util_3.getWorkflowStepKey)(workflowStep);
390
679
  }
391
- const uiModule = ((_b = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _b === void 0 ? void 0 : _b.formSchema) || ((_c = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _c === void 0 ? void 0 : _c.fileName);
680
+ const uiModule = ((_a = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _a === void 0 ? void 0 : _a.formSchema) || ((_b = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _b === void 0 ? void 0 : _b.fileName);
392
681
  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
393
682
  ? { logo: (0, util_1.getLogoUrl)(config, workflowStep, `-${workflowStep.key}`) }
394
683
  : {})), { 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 ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));