@crowdin/app-project-module 0.76.1 → 0.77.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.
@@ -83,10 +83,6 @@ function handle(config, integration, optional = false) {
83
83
  }
84
84
  return res.render('error', errorOptions);
85
85
  }
86
- const integrationConfig = yield (0, storage_1.getStorage)().getIntegrationConfig(clientId);
87
- if (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.config) {
88
- req.integrationSettings = JSON.parse(integrationConfig.config);
89
- }
90
86
  try {
91
87
  req.integrationCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
92
88
  }
@@ -94,6 +90,18 @@ function handle(config, integration, optional = false) {
94
90
  console.error(e);
95
91
  throw new util_1.CodeError('Credentials to integration either exprired or invalid', 401);
96
92
  }
93
+ const integrationConfig = yield (0, storage_1.getStorage)().getIntegrationConfig(clientId);
94
+ if (integrationConfig === null || integrationConfig === void 0 ? void 0 : integrationConfig.config) {
95
+ let integrationSettings = JSON.parse(integrationConfig.config) || {};
96
+ if (integration.normalizeSettings) {
97
+ integrationSettings = yield integration.normalizeSettings({
98
+ appSettings: integrationSettings,
99
+ apiCredentials: req.integrationCredentials,
100
+ client: req.crowdinApiClient,
101
+ });
102
+ }
103
+ req.integrationSettings = integrationSettings;
104
+ }
97
105
  next();
98
106
  }));
99
107
  }
@@ -19,17 +19,29 @@ function register({ config, app }) {
19
19
  app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.aiProvider.key }), (0, render_ui_module_1.default)(config.aiProvider.settingsUiModule));
20
20
  }
21
21
  app.get((0, util_1.getLogoUrl)(config.aiProvider, '/aiprovider'), (req, res) => { var _a; return res.sendFile(((_a = config.aiProvider) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
22
- app.get('/models', json_response_1.default, (0, crowdin_client_1.default)({
22
+ app.get('/ai-provider/models', json_response_1.default, (0, crowdin_client_1.default)({
23
23
  config,
24
24
  optional: false,
25
25
  checkSubscriptionExpiration: true,
26
26
  moduleKey: config.aiProvider.key,
27
27
  }), (0, get_model_list_1.default)(config.aiProvider));
28
- app.post('/completions', json_response_1.default, (0, crowdin_client_1.default)({
28
+ app.post('/ai-provider/completions', json_response_1.default, (0, crowdin_client_1.default)({
29
29
  config,
30
30
  optional: false,
31
31
  checkSubscriptionExpiration: true,
32
32
  moduleKey: config.aiProvider.key,
33
33
  }), (0, chat_completions_1.default)(config.aiProvider));
34
+ // TEMPORARY CODE: it needs to support old path
35
+ app.get('/models', json_response_1.default, (0, crowdin_client_1.default)({
36
+ config,
37
+ optional: false,
38
+ checkSubscriptionExpiration: true,
39
+ }), (0, get_model_list_1.default)(config.aiProvider));
40
+ app.post('/completions', json_response_1.default, (0, crowdin_client_1.default)({
41
+ config,
42
+ optional: false,
43
+ checkSubscriptionExpiration: true,
44
+ }), (0, chat_completions_1.default)(config.aiProvider));
45
+ // END TEMPORARY CODE
34
46
  }
35
47
  exports.register = register;
@@ -12,11 +12,18 @@ function register({ config, app }) {
12
12
  return;
13
13
  }
14
14
  app.get((0, util_1.getLogoUrl)(config.customMT, '/mt'), (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
15
- app.post('/translate', (0, crowdin_client_1.default)({
15
+ app.post('/mt/translate', (0, crowdin_client_1.default)({
16
16
  config,
17
17
  optional: false,
18
18
  checkSubscriptionExpiration: true,
19
19
  moduleKey: config.customMT.key,
20
20
  }), (0, translate_1.default)(config.customMT));
21
+ // TEMPORARY CODE: it needs to support old path
22
+ app.post('/translate', (0, crowdin_client_1.default)({
23
+ config,
24
+ optional: false,
25
+ checkSubscriptionExpiration: true,
26
+ }), (0, translate_1.default)(config.customMT));
27
+ // END TEMPORARY CODE
21
28
  }
22
29
  exports.register = register;
@@ -17,26 +17,48 @@ function register({ config, app }) {
17
17
  }
18
18
  if ((0, util_1.isAuthorizedConfig)(config)) {
19
19
  if (config.customSpellchecker.settingsUiModule) {
20
- app.use('/settings', (0, ui_module_1.default)({ config, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
20
+ app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
21
+ // TEMPORARY CODE: it needs to support old path
22
+ app.use('/settings', (0, ui_module_1.default)({ config }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
23
+ // END TEMPORARY CODE
21
24
  }
22
- app.get('/languages', json_response_1.default, (0, crowdin_client_1.default)({
25
+ app.get('/spellchecker/languages', json_response_1.default, (0, crowdin_client_1.default)({
23
26
  config,
24
27
  optional: false,
25
28
  checkSubscriptionExpiration: true,
26
29
  moduleKey: config.customSpellchecker.key,
27
30
  }), (0, get_languages_list_1.default)(config.customSpellchecker));
28
- app.post('/spellcheck', json_response_1.default, (0, crowdin_client_1.default)({
31
+ app.post('/spellchecker/spellcheck', json_response_1.default, (0, crowdin_client_1.default)({
29
32
  config,
30
33
  optional: false,
31
34
  checkSubscriptionExpiration: true,
32
35
  moduleKey: config.customSpellchecker.key,
33
36
  }), (0, spell_check_1.default)(config.customSpellchecker));
37
+ // TEMPORARY CODE: it needs to support old path
38
+ app.get('/languages', json_response_1.default, (0, crowdin_client_1.default)({
39
+ config,
40
+ optional: false,
41
+ checkSubscriptionExpiration: true,
42
+ }), (0, get_languages_list_1.default)(config.customSpellchecker));
43
+ app.post('/spellcheck', json_response_1.default, (0, crowdin_client_1.default)({
44
+ config,
45
+ optional: false,
46
+ checkSubscriptionExpiration: true,
47
+ }), (0, spell_check_1.default)(config.customSpellchecker));
48
+ // END TEMPORARY CODE
34
49
  return;
35
50
  }
36
51
  if (config.customSpellchecker.settingsUiModule) {
37
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
52
+ app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
53
+ // TEMPORARY CODE: it needs to support old path
54
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
55
+ // END TEMPORARY CODE
38
56
  }
57
+ app.get('/spellchecker/languages', json_response_1.default, (0, get_languages_list_1.default)(config.customSpellchecker));
58
+ app.post('/spellchecker/spellcheck', json_response_1.default, (0, spell_check_1.default)(config.customSpellchecker));
59
+ // TEMPORARY CODE: it needs to support old path
39
60
  app.get('/languages', json_response_1.default, (0, get_languages_list_1.default)(config.customSpellchecker));
40
61
  app.post('/spellcheck', json_response_1.default, (0, spell_check_1.default)(config.customSpellchecker));
62
+ // END TEMPORARY CODE
41
63
  }
42
64
  exports.register = register;
@@ -15,18 +15,33 @@ function register({ config, app }) {
15
15
  return;
16
16
  }
17
17
  if (qaCheck === null || qaCheck === void 0 ? void 0 : qaCheck.batchSize) {
18
+ app.use('/qa-check/batch-size', json_response_1.default, (req, res) => {
19
+ res.send({ data: { size: qaCheck.batchSize } });
20
+ });
21
+ // TEMPORARY CODE: it needs to support old path
18
22
  app.use('/batch-size', json_response_1.default, (req, res) => {
19
23
  res.send({ data: { size: qaCheck.batchSize } });
20
24
  });
25
+ // END TEMPORARY CODE
21
26
  }
22
- app.use('/validate', json_response_1.default, (0, crowdin_client_1.default)({
27
+ app.use('/qa-check/validate', json_response_1.default, (0, crowdin_client_1.default)({
23
28
  config,
24
29
  optional: false,
25
30
  checkSubscriptionExpiration: true,
26
31
  moduleKey: qaCheck.key,
27
32
  }), (0, validate_1.default)(qaCheck));
33
+ // TEMPORARY CODE: it needs to support old path
34
+ app.use('/validate', json_response_1.default, (0, crowdin_client_1.default)({
35
+ config,
36
+ optional: false,
37
+ checkSubscriptionExpiration: true,
38
+ }), (0, validate_1.default)(qaCheck));
39
+ // END TEMPORARY CODE
28
40
  if (qaCheck.settingsUiModule) {
29
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
41
+ app.use('/qa-check/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
42
+ // TEMPORARY CODE: it needs to support old path
43
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
44
+ // END TEMPORARY CODE
30
45
  }
31
46
  }
32
47
  exports.register = register;
@@ -15,12 +15,19 @@ function registerCustomFileFormat({ config, app }) {
15
15
  return;
16
16
  }
17
17
  (0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.customFileFormat);
18
- app.post('/process', (0, crowdin_client_1.default)({
18
+ app.post('/file/process', (0, crowdin_client_1.default)({
19
19
  config,
20
20
  optional: false,
21
21
  checkSubscriptionExpiration: true,
22
22
  moduleKey: config.customFileFormat.key,
23
23
  }), (0, custom_file_format_1.default)(config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder, config.customFileFormat));
24
+ // TEMPORARY CODE: it needs to support old path
25
+ app.post('/process', (0, crowdin_client_1.default)({
26
+ config,
27
+ optional: false,
28
+ checkSubscriptionExpiration: true,
29
+ }), (0, custom_file_format_1.default)(config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder, config.customFileFormat));
30
+ // END TEMPORARY CODE
24
31
  app.get('/file/download', (0, file_download_1.default)(config, config.customFileFormat, 'custom-file-format'));
25
32
  }
26
33
  exports.registerCustomFileFormat = registerCustomFileFormat;
@@ -64,6 +64,14 @@ export interface IntegrationLogic extends ModuleKey {
64
64
  * function to define configuration(settings) modal for you app (by default app will not have any custom settings)
65
65
  */
66
66
  getConfiguration?: (projectId: number, client: Crowdin, apiCredentials: any) => Promise<FormEntity[]>;
67
+ /**
68
+ * function to normalize saved settings
69
+ */
70
+ normalizeSettings?: ({ appSettings, apiCredentials, client, }: {
71
+ appSettings: FormEntity[];
72
+ apiCredentials: any;
73
+ client?: Crowdin;
74
+ }) => Promise<FormEntity[]>;
67
75
  /**
68
76
  * Logout hook for cleanup logic
69
77
  */
@@ -16,7 +16,8 @@ function handle(config) {
16
16
  var _a, _b;
17
17
  const modules = {};
18
18
  if (config.projectIntegration) {
19
- config.projectIntegration.key = config.identifier + '-int';
19
+ // prevent possible overrides of the other modules
20
+ config.projectIntegration = Object.assign(Object.assign({}, config.projectIntegration), { key: config.identifier + '-int' });
20
21
  modules['project-integrations'] = [
21
22
  Object.assign({ key: config.projectIntegration.key, name: config.name, description: config.description, logo: (0, util_1.getLogoUrl)(config.projectIntegration, '/integration'), url: '/' }, (!!config.projectIntegration.environments && {
22
23
  environments: normalizeEnvironments(config.projectIntegration.environments),
@@ -24,7 +25,8 @@ function handle(config) {
24
25
  ];
25
26
  }
26
27
  if (config.customFileFormat) {
27
- config.customFileFormat.key = config.identifier + '-ff';
28
+ // prevent possible overrides of the other modules
29
+ config.customFileFormat = Object.assign(Object.assign({}, config.customFileFormat), { key: config.identifier + '-ff' });
28
30
  modules['custom-file-format'] = [
29
31
  {
30
32
  key: config.customFileFormat.key,
@@ -35,12 +37,13 @@ function handle(config) {
35
37
  extensions: config.customFileFormat.extensions,
36
38
  signaturePatterns: config.customFileFormat.signaturePatterns,
37
39
  multilingualExport: config.customFileFormat.multilingualExport,
38
- url: '/process',
40
+ url: '/file/process',
39
41
  },
40
42
  ];
41
43
  }
42
44
  if (config.filePreImport) {
43
- config.filePreImport.key = config.identifier + '-pri';
45
+ // prevent possible overrides of the other modules
46
+ config.filePreImport = Object.assign(Object.assign({}, config.filePreImport), { key: config.identifier + '-pri' });
44
47
  modules['file-pre-import'] = [
45
48
  {
46
49
  key: config.filePreImport.key,
@@ -50,7 +53,8 @@ function handle(config) {
50
53
  ];
51
54
  }
52
55
  if (config.filePostImport) {
53
- config.filePostImport.key = config.identifier + '-poi';
56
+ // prevent possible overrides of the other modules
57
+ config.filePostImport = Object.assign(Object.assign({}, config.filePostImport), { key: config.identifier + '-poi' });
54
58
  modules['file-post-import'] = [
55
59
  {
56
60
  key: config.filePostImport.key,
@@ -60,7 +64,8 @@ function handle(config) {
60
64
  ];
61
65
  }
62
66
  if (config.filePreExport) {
63
- config.filePreExport.key = config.identifier + '-pre';
67
+ // prevent possible overrides of the other modules
68
+ config.filePreExport = Object.assign(Object.assign({}, config.filePreExport), { key: config.identifier + '-pre' });
64
69
  modules['file-pre-export'] = [
65
70
  {
66
71
  key: config.filePreExport.key,
@@ -70,7 +75,8 @@ function handle(config) {
70
75
  ];
71
76
  }
72
77
  if (config.filePostExport) {
73
- config.filePostExport.key = config.identifier + '-poe';
78
+ // prevent possible overrides of the other modules
79
+ config.filePostExport = Object.assign(Object.assign({}, config.filePostExport), { key: config.identifier + '-poe' });
74
80
  modules['file-post-export'] = [
75
81
  {
76
82
  key: config.filePostExport.key,
@@ -80,9 +86,10 @@ function handle(config) {
80
86
  ];
81
87
  }
82
88
  if (config.customMT) {
83
- config.customMT.key = config.identifier + '-mt';
89
+ // prevent possible overrides of the other modules
90
+ config.customMT = Object.assign(Object.assign({}, config.customMT), { key: config.identifier + '-mt' });
84
91
  modules['custom-mt'] = [
85
- Object.assign(Object.assign(Object.assign({ key: config.customMT.key, name: config.name, logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'), url: '/translate', withContext: !!config.customMT.withContext }, (config.customMT.batchSize !== null && {
92
+ Object.assign(Object.assign(Object.assign({ key: config.customMT.key, name: config.name, logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'), url: '/mt/translate', withContext: !!config.customMT.withContext }, (config.customMT.batchSize !== null && {
86
93
  batchSize: config.customMT.batchSize,
87
94
  })), (config.customMT.maskEntities !== null && {
88
95
  maskEntities: config.customMT.maskEntities,
@@ -92,45 +99,50 @@ function handle(config) {
92
99
  ];
93
100
  }
94
101
  if (config.organizationMenu) {
95
- config.organizationMenu.key = config.identifier + '-resources';
102
+ // prevent possible overrides of the other modules
103
+ config.organizationMenu = Object.assign(Object.assign({}, config.organizationMenu), { key: config.identifier + '-resources' });
96
104
  modules['organization-menu'] = [
97
105
  {
98
106
  key: config.organizationMenu.key,
99
107
  name: config.organizationMenu.name || config.name,
100
- url: '/resources/' + (config.organizationMenu.fileName || 'index.html'),
108
+ url: '/organization-menu/' + (config.organizationMenu.fileName || 'index.html'),
101
109
  icon: (0, util_1.getLogoUrl)(config.organizationMenu, '/resources'),
102
110
  },
103
111
  ];
104
112
  }
105
113
  if (config.organizationSettingsMenu) {
106
- config.organizationSettingsMenu.key = config.identifier + '-organization-settings-menu';
114
+ // prevent possible overrides of the other modules
115
+ config.organizationSettingsMenu = Object.assign(Object.assign({}, config.organizationSettingsMenu), { key: config.identifier + '-organization-settings-menu' });
107
116
  modules['organization-settings-menu'] = [
108
117
  {
109
118
  key: config.organizationSettingsMenu.key,
110
119
  name: config.organizationSettingsMenu.name || config.name,
111
- url: '/settings/' + (config.organizationSettingsMenu.fileName || 'index.html'),
112
- icon: (0, util_1.getLogoUrl)(config.organizationSettingsMenu, '/settings'),
120
+ url: '/organization-settings/' + (config.organizationSettingsMenu.fileName || 'index.html'),
121
+ icon: (0, util_1.getLogoUrl)(config.organizationSettingsMenu, '/organization-settings'),
113
122
  },
114
123
  ];
115
124
  }
116
125
  if (config.profileResourcesMenu) {
117
- config.profileResourcesMenu.key = config.identifier + '-profile-resources-menu';
126
+ // prevent possible overrides of the other modules
127
+ config.profileResourcesMenu = Object.assign(Object.assign({}, config.profileResourcesMenu), { key: config.identifier + '-profile-resources-menu' });
118
128
  modules['profile-resources-menu'] = [
119
- Object.assign({ key: config.profileResourcesMenu.key, name: config.profileResourcesMenu.name || config.name, url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources') }, (!!config.profileResourcesMenu.environments && {
129
+ 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.profileResourcesMenu, '/profile-resources') }, (!!config.profileResourcesMenu.environments && {
120
130
  environments: normalizeEnvironments(config.profileResourcesMenu.environments),
121
131
  })),
122
132
  ];
123
133
  }
124
134
  if (config.profileSettingsMenu) {
125
- config.profileSettingsMenu.key = config.identifier + '-profile-settings-menu';
135
+ // prevent possible overrides of the other modules
136
+ config.profileSettingsMenu = Object.assign(Object.assign({}, config.profileSettingsMenu), { key: config.identifier + '-profile-settings-menu' });
126
137
  modules['profile-settings-menu'] = [
127
- Object.assign({ key: config.profileSettingsMenu.key, name: config.profileSettingsMenu.name || config.name, url: '/settings/' + (config.profileSettingsMenu.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings') }, (!!config.profileSettingsMenu.environments && {
138
+ 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.profileSettingsMenu, '/profile-settings') }, (!!config.profileSettingsMenu.environments && {
128
139
  environments: normalizeEnvironments(config.profileSettingsMenu.environments),
129
140
  })),
130
141
  ];
131
142
  }
132
143
  if (config.editorRightPanel) {
133
- config.editorRightPanel.key = config.identifier + '-editor-panels';
144
+ // prevent possible overrides of the other modules
145
+ config.editorRightPanel = Object.assign(Object.assign({}, config.editorRightPanel), { key: config.identifier + '-editor-panels' });
134
146
  modules['editor-right-panel'] = [
135
147
  Object.assign({ key: config.editorRightPanel.key, name: config.editorRightPanel.name || config.name, url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'), modes: config.editorRightPanel.modes }, (!!config.editorRightPanel.environments && {
136
148
  environments: normalizeEnvironments(config.editorRightPanel.environments),
@@ -138,7 +150,8 @@ function handle(config) {
138
150
  ];
139
151
  }
140
152
  if (config.projectMenu) {
141
- config.projectMenu.key = config.identifier + '-project-menu';
153
+ // prevent possible overrides of the other modules
154
+ config.projectMenu = Object.assign(Object.assign({}, config.projectMenu), { key: config.identifier + '-project-menu' });
142
155
  modules['project-menu'] = [
143
156
  Object.assign({ key: config.projectMenu.key, name: config.projectMenu.name || config.name, url: '/project-menu/' + (config.projectMenu.fileName || 'index.html') }, (!!config.projectMenu.environments && {
144
157
  environments: normalizeEnvironments(config.projectMenu.environments),
@@ -146,7 +159,8 @@ function handle(config) {
146
159
  ];
147
160
  }
148
161
  if (config.projectMenuCrowdsource) {
149
- config.projectMenuCrowdsource.key = config.identifier + '-project-menu-crowdsource';
162
+ // prevent possible overrides of the other modules
163
+ config.projectMenuCrowdsource = Object.assign(Object.assign({}, config.projectMenuCrowdsource), { key: config.identifier + '-project-menu-crowdsource' });
150
164
  modules['project-menu-crowdsource'] = [
151
165
  {
152
166
  key: config.projectMenuCrowdsource.key,
@@ -156,7 +170,8 @@ function handle(config) {
156
170
  ];
157
171
  }
158
172
  if (config.projectTools) {
159
- config.projectTools.key = config.identifier + '-tools';
173
+ // prevent possible overrides of the other modules
174
+ config.projectTools = Object.assign(Object.assign({}, config.projectTools), { key: config.identifier + '-tools' });
160
175
  modules['project-tools'] = [
161
176
  Object.assign({ key: config.projectTools.key, name: config.projectTools.name || config.name, description: config.description, logo: (0, util_1.getLogoUrl)(config.projectTools, '/tools'), url: '/tools/' + (config.projectTools.fileName || 'index.html') }, (!!config.projectTools.environments && {
162
177
  environments: normalizeEnvironments(config.projectTools.environments),
@@ -164,7 +179,8 @@ function handle(config) {
164
179
  ];
165
180
  }
166
181
  if (config.projectReports) {
167
- config.projectReports.key = config.identifier + '-project-reports';
182
+ // prevent possible overrides of the other modules
183
+ config.projectReports = Object.assign(Object.assign({}, config.projectReports), { key: config.identifier + '-project-reports' });
168
184
  modules['project-reports'] = [
169
185
  {
170
186
  key: config.projectReports.key,
@@ -176,13 +192,15 @@ function handle(config) {
176
192
  ];
177
193
  }
178
194
  if (config.modal) {
179
- config.modal.key = config.identifier + '-modal';
195
+ // prevent possible overrides of the other modules
196
+ config.modal = Object.assign(Object.assign({}, config.modal), { key: config.identifier + '-modal' });
180
197
  modules['modal'] = [
181
198
  Object.assign({ key: config.modal.key, name: config.modal.name || config.name, url: config.modal.url || '/modal/' + (config.modal.fileName || 'index.html') }, (!!config.modal.environments && { environments: normalizeEnvironments(config.modal.environments) })),
182
199
  ];
183
200
  }
184
201
  if (config.contextMenu) {
185
- config.contextMenu.key = config.identifier + '-context-menu';
202
+ // prevent possible overrides of the other modules
203
+ config.contextMenu = Object.assign(Object.assign({}, config.contextMenu), { key: config.identifier + '-context-menu' });
186
204
  modules['context-menu'] = [
187
205
  Object.assign({ key: config.contextMenu.key, 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
188
206
  ? {
@@ -199,25 +217,28 @@ function handle(config) {
199
217
  modules['api'] = (0, api_1.getApiManifest)(config, config.api);
200
218
  }
201
219
  if (config.customSpellchecker) {
202
- config.customSpellchecker.key = config.identifier + '-spellchecker';
220
+ // prevent possible overrides of the other modules
221
+ config.customSpellchecker = Object.assign(Object.assign({}, config.customSpellchecker), { key: config.identifier + '-spellchecker' });
203
222
  const uiModule = config.customSpellchecker.settingsUiModule;
204
223
  modules['custom-spellchecker'] = [
205
- Object.assign(Object.assign({ key: config.customSpellchecker.key, name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck' }, (!!config.customSpellchecker.environments && {
224
+ 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 && {
206
225
  environments: normalizeEnvironments(config.customSpellchecker.environments),
207
- })), (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
226
+ })), (uiModule ? { url: '/spellchecker/settings/' + (uiModule.fileName || 'index.html') } : {})),
208
227
  ];
209
228
  }
210
229
  if (config.aiProvider) {
211
- config.aiProvider.key = config.identifier + '-aiprovider';
230
+ // prevent possible overrides of the other modules
231
+ config.aiProvider = Object.assign(Object.assign({}, config.aiProvider), { key: config.identifier + '-aiprovider' });
212
232
  const uiModule = config.aiProvider.settingsUiModule;
213
233
  modules['ai-provider'] = [
214
- 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.aiProvider, '/aiprovider'), chatCompletionsUrl: '/completions', modelsUrl: '/models' }, (!!config.aiProvider.environments && {
234
+ 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.aiProvider, '/aiprovider'), chatCompletionsUrl: '/ai-provider/completions', modelsUrl: '/ai-provider/models' }, (!!config.aiProvider.environments && {
215
235
  environments: normalizeEnvironments(config.aiProvider.environments),
216
236
  })), (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
217
237
  ];
218
238
  }
219
239
  if (config.aiPromptProvider) {
220
- config.aiPromptProvider.key = config.identifier + '-ai-prompt-provider';
240
+ // prevent possible overrides of the other modules
241
+ config.aiPromptProvider = Object.assign(Object.assign({}, config.aiPromptProvider), { key: config.identifier + '-ai-prompt-provider' });
221
242
  modules['ai-prompt-provider'] = [
222
243
  Object.assign({ key: config.aiPromptProvider.key, name: config.aiPromptProvider.name || config.name, logo: (0, util_1.getLogoUrl)(config.aiPromptProvider, '/ai-prompt-provider'), compileUrl: '/prompt-provider/compile' }, (!!config.aiPromptProvider.formSchema
223
244
  ? {
@@ -227,6 +248,13 @@ function handle(config) {
227
248
  ];
228
249
  }
229
250
  if (config.aiTools) {
251
+ // prevent possible overrides of the other modules
252
+ if (Array.isArray(config.aiTools)) {
253
+ config.aiTools = config.aiTools.map((aiTool) => (Object.assign({}, aiTool)));
254
+ }
255
+ else {
256
+ config.aiTools = Object.assign({}, config.aiTools);
257
+ }
230
258
  const tools = Array.isArray(config.aiTools) ? config.aiTools : [config.aiTools];
231
259
  modules['ai-tools'] = [];
232
260
  for (const tool of tools) {
@@ -237,6 +265,13 @@ function handle(config) {
237
265
  }
238
266
  }
239
267
  if (config.aiToolsWidget) {
268
+ // prevent possible overrides of the other modules
269
+ if (Array.isArray(config.aiToolsWidget)) {
270
+ config.aiToolsWidget = config.aiToolsWidget.map((aiToolWidget) => (Object.assign({}, aiToolWidget)));
271
+ }
272
+ else {
273
+ config.aiToolsWidget = Object.assign({}, config.aiToolsWidget);
274
+ }
240
275
  const tools = Array.isArray(config.aiToolsWidget) ? config.aiToolsWidget : [config.aiToolsWidget];
241
276
  modules['ai-tools-widget'] = [];
242
277
  for (const tool of tools) {
@@ -247,6 +282,13 @@ function handle(config) {
247
282
  }
248
283
  }
249
284
  if (config.webhooks) {
285
+ // prevent possible overrides of the other modules
286
+ if (Array.isArray(config.webhooks)) {
287
+ config.webhooks = config.webhooks.map((webhook) => (Object.assign({}, webhook)));
288
+ }
289
+ else {
290
+ config.webhooks = Object.assign({}, config.webhooks);
291
+ }
250
292
  const webhooks = Array.isArray(config.webhooks) ? config.webhooks : [config.webhooks];
251
293
  modules['webhook'] = [];
252
294
  for (let i = 0; i < webhooks.length; i++) {
@@ -259,13 +301,21 @@ function handle(config) {
259
301
  }
260
302
  }
261
303
  if (config.externalQaCheck) {
262
- config.externalQaCheck.key = config.identifier + '-qa-check';
304
+ // prevent possible overrides of the other modules
305
+ config.externalQaCheck = Object.assign(Object.assign({}, config.externalQaCheck), { key: config.identifier + '-qa-check' });
263
306
  const uiModule = config.externalQaCheck.settingsUiModule;
264
307
  modules['external-qa-check'] = [
265
- Object.assign(Object.assign({ key: config.externalQaCheck.key, name: config.externalQaCheck.name || config.name, description: config.externalQaCheck.description || config.description, runQaCheckUrl: '/validate' }, (config.externalQaCheck.batchSize ? { getBatchSizeUrl: '/batch-size' } : {})), (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
308
+ 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') } : {})),
266
309
  ];
267
310
  }
268
311
  if (config.workflowStepType) {
312
+ // prevent possible overrides of the other modules
313
+ if (Array.isArray(config.workflowStepType)) {
314
+ config.workflowStepType = config.workflowStepType.map((workflowStep) => (Object.assign({}, workflowStep)));
315
+ }
316
+ else {
317
+ config.workflowStepType = Object.assign({}, config.workflowStepType);
318
+ }
269
319
  const workflowSteps = Array.isArray(config.workflowStepType)
270
320
  ? config.workflowStepType
271
321
  : [config.workflowStepType];
@@ -275,7 +325,7 @@ function handle(config) {
275
325
  workflowStep.key = config.identifier + '-' + (0, util_3.getWorkflowStepKey)(workflowStep);
276
326
  }
277
327
  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);
278
- modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name }, ((workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.imagePath) ? { logo: (0, util_1.getLogoUrl)(workflowStep, `-${workflowStep.key}`) } : {})), { description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }), (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/delete', workflowStep) }), (uiModule ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));
328
+ modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name }, ((workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.imagePath) ? { logo: (0, util_1.getLogoUrl)(workflowStep, `-${workflowStep.key}`) } : {})), { 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) } : {})));
279
329
  }
280
330
  }
281
331
  const events = {
@@ -12,7 +12,11 @@ function register({ config, app }) {
12
12
  return;
13
13
  }
14
14
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
+ app.get((0, util_1.getLogoUrl)(config.organizationMenu, '/organization-menu'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
+ app.use('/organization-menu', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.organizationMenu.key }), (0, render_ui_module_1.default)(config.organizationMenu));
17
+ // TEMPORARY CODE: it needs to support old path
15
18
  app.get((0, util_1.getLogoUrl)(config.organizationMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
- app.use('/resources', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.organizationMenu.key }), (0, render_ui_module_1.default)(config.organizationMenu));
19
+ app.use('/resources', (0, ui_module_1.default)({ config, allowUnauthorized }), (0, render_ui_module_1.default)(config.organizationMenu));
20
+ // END TEMPORARY CODE
17
21
  }
18
22
  exports.register = register;
@@ -12,7 +12,11 @@ function register({ config, app }) {
12
12
  return;
13
13
  }
14
14
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
+ app.get((0, util_1.getLogoUrl)(config.organizationSettingsMenu, '/organization-settings'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
+ app.use('/organization-settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.organizationSettingsMenu.key }), (0, render_ui_module_1.default)(config.organizationSettingsMenu));
17
+ // TEMPORARY CODE: it needs to support old path
15
18
  app.get((0, util_1.getLogoUrl)(config.organizationSettingsMenu, '/settings'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
16
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.organizationSettingsMenu.key }), (0, render_ui_module_1.default)(config.organizationSettingsMenu));
19
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized }), (0, render_ui_module_1.default)(config.organizationSettingsMenu));
20
+ // END TEMPORARY CODE
17
21
  }
18
22
  exports.register = register;
@@ -11,8 +11,12 @@ function register({ config, app }) {
11
11
  if (!config.profileResourcesMenu) {
12
12
  return;
13
13
  }
14
- app.get((0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
14
+ app.get((0, util_1.getLogoUrl)(config.profileResourcesMenu, '/profile-resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
15
15
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
16
- app.use('/resources', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileResourcesMenu.key }), (0, render_ui_module_1.default)(config.profileResourcesMenu));
16
+ app.use('/profile-resources', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileResourcesMenu.key }), (0, render_ui_module_1.default)(config.profileResourcesMenu));
17
+ // TEMPORARY CODE: it needs to support old path
18
+ app.get((0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
19
+ app.use('/resources', (0, ui_module_1.default)({ config, allowUnauthorized }), (0, render_ui_module_1.default)(config.profileResourcesMenu));
20
+ // END TEMPORARY CODE
17
21
  }
18
22
  exports.register = register;
@@ -11,8 +11,12 @@ function register({ config, app }) {
11
11
  if (!config.profileSettingsMenu) {
12
12
  return;
13
13
  }
14
- app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings'), (req, res) => { var _a; return res.sendFile(((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
14
+ app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/profile-settings'), (req, res) => { var _a; return res.sendFile(((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
15
15
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
16
- app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileSettingsMenu.key }), (0, render_ui_module_1.default)(config.profileSettingsMenu));
16
+ app.use('/profile-settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileSettingsMenu.key }), (0, render_ui_module_1.default)(config.profileSettingsMenu));
17
+ // TEMPORARY CODE: it needs to support old path
18
+ app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings'), (req, res) => { var _a; return res.sendFile(((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
19
+ app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized }), (0, render_ui_module_1.default)(config.profileSettingsMenu));
20
+ // END TEMPORARY CODE
17
21
  }
18
22
  exports.register = register;
@@ -17,18 +17,30 @@ function register({ config, app }) {
17
17
  }
18
18
  const workflowSteps = Array.isArray(config.workflowStepType) ? config.workflowStepType : [config.workflowStepType];
19
19
  for (const workflowStep of workflowSteps) {
20
- app.post((0, util_1.getWorkflowStepUrl)('/settings', workflowStep), (0, crowdin_client_1.default)({
20
+ app.post((0, util_1.getWorkflowStepUrl)('/workflow-step/settings', workflowStep), (0, crowdin_client_1.default)({
21
21
  config,
22
22
  optional: true,
23
23
  checkSubscriptionExpiration: false,
24
24
  moduleKey: workflowStep.key,
25
25
  }), (0, step_settings_save_1.default)(workflowStep));
26
- app.delete((0, util_1.getWorkflowStepUrl)('/delete', workflowStep), (0, crowdin_client_1.default)({
26
+ app.delete((0, util_1.getWorkflowStepUrl)('/workflow-step/delete', workflowStep), (0, crowdin_client_1.default)({
27
27
  config,
28
28
  optional: true,
29
29
  checkSubscriptionExpiration: false,
30
30
  moduleKey: workflowStep.key,
31
31
  }), (0, delete_step_1.default)(workflowStep));
32
+ // TEMPORARY CODE: it needs to support old path
33
+ app.post((0, util_1.getWorkflowStepUrl)('/settings', workflowStep), (0, crowdin_client_1.default)({
34
+ config,
35
+ optional: true,
36
+ checkSubscriptionExpiration: false,
37
+ }), (0, step_settings_save_1.default)(workflowStep));
38
+ app.delete((0, util_1.getWorkflowStepUrl)('/delete', workflowStep), (0, crowdin_client_1.default)({
39
+ config,
40
+ optional: true,
41
+ checkSubscriptionExpiration: false,
42
+ }), (0, delete_step_1.default)(workflowStep));
43
+ // END TEMPORARY CODE
32
44
  if (workflowStep.imagePath) {
33
45
  app.get((0, util_2.getLogoUrl)(workflowStep, `-${workflowStep.key}`), (req, res) => res.sendFile(workflowStep.imagePath || config.imagePath));
34
46
  }