@crowdin/app-project-module 0.94.3 → 0.95.1

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.
@@ -10,8 +10,21 @@ const util_1 = require("../../util");
10
10
  function register({ config, app }) {
11
11
  var _a, _b;
12
12
  const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
13
- if (((_a = config.contextMenu) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.contextMenu) === null || _b === void 0 ? void 0 : _b.formSchema)) {
14
- app.use('/context', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.contextMenu.key }), (0, render_ui_module_1.default)(config.contextMenu));
13
+ if (!config.contextMenu) {
14
+ return;
15
+ }
16
+ if (Array.isArray(config.contextMenu)) {
17
+ config.contextMenu.forEach((contextMenu) => {
18
+ if ((contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.uiPath) || (contextMenu === null || contextMenu === void 0 ? void 0 : contextMenu.formSchema)) {
19
+ app.use(`/context-${contextMenu.key}`, (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: contextMenu.key }), (0, render_ui_module_1.default)(contextMenu));
20
+ }
21
+ });
22
+ }
23
+ else {
24
+ // backward compatibility will be removed after migration
25
+ if (((_a = config.contextMenu) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.contextMenu) === null || _b === void 0 ? void 0 : _b.formSchema)) {
26
+ app.use('/context', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.contextMenu.key }), (0, render_ui_module_1.default)(config.contextMenu));
27
+ }
15
28
  }
16
29
  }
17
30
  exports.register = register;
@@ -1,8 +1,9 @@
1
1
  import { SignaturePatterns } from '../../types';
2
- export interface ContextModule {
2
+ export interface ContextContent {
3
3
  location: ContextOptionsLocations;
4
4
  type: ContextOptionsTypes;
5
5
  module: string;
6
+ moduleKey?: string;
6
7
  /**
7
8
  * Context menu name
8
9
  */
@@ -472,6 +472,20 @@ function consumer({ channel, config, integration, }) {
472
472
  });
473
473
  };
474
474
  }
475
+ function isRetryableError(error) {
476
+ var _a;
477
+ if ((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) {
478
+ const status = error.response.status;
479
+ if (status >= 500) {
480
+ return true;
481
+ }
482
+ }
483
+ // Network errors, timeouts, and other non-HTTP errors are retryable
484
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ECONNRESET' || (error === null || error === void 0 ? void 0 : error.code) === 'ETIMEDOUT' || (error === null || error === void 0 ? void 0 : error.code) === 'ENOTFOUND') {
485
+ return true;
486
+ }
487
+ return false;
488
+ }
475
489
  function processMessages({ channel, messagesToAck, webhooksData, webhooksInfo, }) {
476
490
  return __awaiter(this, void 0, void 0, function* () {
477
491
  try {
@@ -504,14 +518,21 @@ function processMessages({ channel, messagesToAck, webhooksData, webhooksInfo, }
504
518
  }
505
519
  }
506
520
  catch (e) {
507
- (0, logger_1.logError)(`Error in processMessages: ${e}`);
508
- // On critical error, nack all messages to requeue them
521
+ (0, logger_1.log)(`Error in processMessages: ${e}`);
509
522
  for (const msg of messagesToAck) {
510
523
  try {
511
- channel.nack(msg, false, true); // requeue the message
524
+ if (isRetryableError(e)) {
525
+ // For retryable errors (5xx, network issues), requeue the message
526
+ channel.nack(msg, false, true);
527
+ }
528
+ else {
529
+ // For non-retryable errors (4xx client errors), acknowledge to remove from queue
530
+ (0, logger_1.log)(`Non-retryable error encountered, discarding message: ${e}`);
531
+ channel.ack(msg);
532
+ }
512
533
  }
513
- catch (nackError) {
514
- (0, logger_1.logError)(`Error nacking message: ${nackError}`);
534
+ catch (handleError) {
535
+ (0, logger_1.logError)(`Error handling message acknowledgment: ${handleError}`);
515
536
  }
516
537
  }
517
538
  }
@@ -210,19 +210,35 @@ function handle(config) {
210
210
  modules['modal'] = modals;
211
211
  }
212
212
  if (config.contextMenu) {
213
- // prevent possible overrides of the other modules
214
- config.contextMenu = Object.assign(Object.assign({}, config.contextMenu), { key: config.identifier + '-context-menu' });
215
- modules['context-menu'] = [
216
- 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
217
- ? {
218
- module: {
219
- [config.contextMenu.module]: modules[config.contextMenu.module][0].key,
220
- },
221
- }
222
- : {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }), signaturePatterns: config.contextMenu.signaturePatterns }, (!!config.contextMenu.environments && {
223
- environments: normalizeEnvironments(config.contextMenu.environments),
224
- })),
225
- ];
213
+ let contextMenus = [];
214
+ if (Array.isArray(config.contextMenu)) {
215
+ contextMenus = config.contextMenu.map((contextMenu, i) => {
216
+ const moduleKey = contextMenu.key || `${config.identifier}-context-menu-${i}`;
217
+ 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
218
+ ? {
219
+ module: {
220
+ [contextMenu.module]: contextMenu.moduleKey,
221
+ },
222
+ }
223
+ : {})), { url: `/context-${moduleKey}/` + (contextMenu.fileName || 'index.html') }), signaturePatterns: contextMenu.signaturePatterns }, (!!contextMenu.environments && {
224
+ environments: normalizeEnvironments(contextMenu.environments),
225
+ }));
226
+ });
227
+ }
228
+ else {
229
+ contextMenus = [
230
+ 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
231
+ ? {
232
+ module: {
233
+ [config.contextMenu.module]: modules[config.contextMenu.module][0].key,
234
+ },
235
+ }
236
+ : {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }), signaturePatterns: config.contextMenu.signaturePatterns }, (!!config.contextMenu.environments && {
237
+ environments: normalizeEnvironments(config.contextMenu.environments),
238
+ })),
239
+ ];
240
+ }
241
+ modules['context-menu'] = contextMenus;
226
242
  }
227
243
  if (config.api) {
228
244
  modules['api'] = (0, api_1.getApiManifest)(config, config.api);
@@ -21,6 +21,7 @@ function register({ config, app }) {
21
21
  });
22
22
  }
23
23
  else {
24
+ // backward compatibility will be removed after migration
24
25
  if (((_a = config.modal) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.modal) === null || _b === void 0 ? void 0 : _b.formSchema)) {
25
26
  app.use('/modal', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.modal.key }), (0, render_ui_module_1.default)(config.modal));
26
27
  }