@crowdin/app-project-module 0.65.0 → 0.65.2

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.
@@ -608,8 +608,8 @@ class MySQLStorage {
608
608
  SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status,
609
609
  title, info, data, attempt, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
610
610
  FROM job
611
- WHERE status = ? AND finished_at is NULL
612
- `, [types_1.JobStatus.IN_PROGRESS]);
611
+ WHERE status IN (?, ?) AND finished_at is NULL
612
+ `, [types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED]);
613
613
  return rows || [];
614
614
  }));
615
615
  });
@@ -640,8 +640,8 @@ class PostgreStorage {
640
640
  SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status,
641
641
  title, info, data, attempt, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
642
642
  FROM job
643
- WHERE status = $1 AND finished_at is NULL
644
- `, [types_1.JobStatus.IN_PROGRESS]);
643
+ WHERE status IN ($1, $2) AND finished_at is NULL
644
+ `, [types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED]);
645
645
  return (res === null || res === void 0 ? void 0 : res.rows) || [];
646
646
  }));
647
647
  });
@@ -612,8 +612,8 @@ class SQLiteStorage {
612
612
  return this.each(`
613
613
  SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
614
614
  FROM job
615
- WHERE status = ? AND finished_at is NULL
616
- `, [types_1.JobStatus.IN_PROGRESS]);
615
+ WHERE status IN (?,?) AND finished_at is NULL
616
+ `, [types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED]);
617
617
  });
618
618
  }
619
619
  saveTranslationCache({ integrationId, crowdinId, fileId, languageId, etag }) {
@@ -1,6 +1,9 @@
1
1
  /// <reference types="qs" />
2
2
  import { CrowdinClientRequest, UiModule } from '../types';
3
3
  import { Request, Response } from 'express';
4
- declare function getRequestCredentialsMasker(moduleConfig?: UiModule): (req: Request | CrowdinClientRequest, res: Response, next: Function) => any;
4
+ declare function getRequestCredentialsMasker({ moduleConfig, dataPath, }: {
5
+ moduleConfig?: UiModule;
6
+ dataPath?: string;
7
+ }): (req: Request | CrowdinClientRequest, res: Response, next: Function) => any;
5
8
  declare function postRequestCredentialsMasker(moduleConfig?: UiModule, credentialsExtractor?: Function): (req: CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
6
9
  export { getRequestCredentialsMasker, postRequestCredentialsMasker };
@@ -32,7 +32,7 @@ function getMaskableFieldsKeys(moduleConfig) {
32
32
  return (0, lodash_get_1.default)(moduleConfig, `formUiSchema[${fieldKey}]['ui:widget']`) === 'password';
33
33
  });
34
34
  }
35
- function getRequestCredentialsMasker(moduleConfig) {
35
+ function getRequestCredentialsMasker({ moduleConfig, dataPath = 'formData', }) {
36
36
  return function (req, res, next) {
37
37
  // we can't find "password" fields without ui schema
38
38
  if (!moduleConfig || !moduleConfig.formSchema || !moduleConfig.formUiSchema) {
@@ -48,13 +48,18 @@ function getRequestCredentialsMasker(moduleConfig) {
48
48
  }
49
49
  const originalSend = res.send;
50
50
  res.send = function (body) {
51
- if (body.formData) {
51
+ const maskFields = (target) => {
52
52
  maskableFieldsKeys.forEach((fieldKey) => {
53
- if (!body.formData[fieldKey]) {
54
- return;
53
+ if (target[fieldKey]) {
54
+ target[fieldKey] = maskKey(target[fieldKey]);
55
55
  }
56
- body.formData[fieldKey] = maskKey(body.formData[fieldKey]);
57
56
  });
57
+ };
58
+ if (body[dataPath]) {
59
+ maskFields(body[dataPath]);
60
+ }
61
+ if (dataPath === '') {
62
+ maskFields(body);
58
63
  }
59
64
  return originalSend.apply(res, [body]);
60
65
  };
@@ -98,7 +103,7 @@ function postRequestCredentialsMasker(moduleConfig, credentialsExtractor) {
98
103
  return acc;
99
104
  }, {}));
100
105
  // run getRequestCredentialsMasker to mask fields that can be in response
101
- return getRequestCredentialsMasker(moduleConfig)(req, res, next);
106
+ return getRequestCredentialsMasker({ moduleConfig })(req, res, next);
102
107
  }));
103
108
  }
104
109
  exports.postRequestCredentialsMasker = postRequestCredentialsMasker;
@@ -13,3 +13,4 @@ export declare function isAuthorizedConfig(config: Config | UnauthorizedConfig):
13
13
  export declare function hasFormSchema(moduleConfig: any): boolean;
14
14
  export declare function isJson(string: string): boolean;
15
15
  export declare function getPreviousDate(days: number): Date;
16
+ export declare function prepareFormDataMetadataId(req: CrowdinClientRequest, config: Config): Promise<string>;
package/out/util/index.js CHANGED
@@ -32,11 +32,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
32
  });
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.getPreviousDate = exports.isJson = exports.hasFormSchema = exports.isAuthorizedConfig = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.CodeError = void 0;
35
+ exports.prepareFormDataMetadataId = exports.getPreviousDate = exports.isJson = exports.hasFormSchema = exports.isAuthorizedConfig = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.CodeError = void 0;
36
36
  const crypto = __importStar(require("crypto-js"));
37
37
  const storage_1 = require("../storage");
38
38
  const types_1 = require("../types");
39
39
  const logger_1 = require("./logger");
40
+ const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
40
41
  class CodeError extends Error {
41
42
  constructor(message, code) {
42
43
  super(message);
@@ -142,3 +143,19 @@ function getPreviousDate(days) {
142
143
  return date;
143
144
  }
144
145
  exports.getPreviousDate = getPreviousDate;
146
+ function prepareFormDataMetadataId(req, config) {
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ const jwtToken = req.query.jwtToken;
149
+ const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret, config.jwtValidationOptions);
150
+ const context = jwtPayload.context;
151
+ const id = ['form-data'];
152
+ if (context.organization_id) {
153
+ id.push(`${context.organization_id}`);
154
+ }
155
+ if (context.project_id) {
156
+ id.push(`${context.project_id}`);
157
+ }
158
+ return id.join('-');
159
+ });
160
+ }
161
+ exports.prepareFormDataMetadataId = prepareFormDataMetadataId;
@@ -9,10 +9,17 @@ const job_1 = require("../modules/integration/util/job");
9
9
  express_1.default.application.baseListen = express_1.default.application.listen;
10
10
  express_1.default.application.listen = function (...args) {
11
11
  const [config, callback] = args;
12
- const server = this.baseListen.call(this, config.port);
12
+ let port;
13
+ if (typeof config === 'object') {
14
+ port = config.port;
15
+ (0, job_1.reRunInProgressJobs)(config);
16
+ }
17
+ else {
18
+ port = config;
19
+ }
20
+ const server = this.baseListen.call(this, port);
13
21
  if (callback) {
14
22
  callback();
15
- (0, job_1.reRunInProgressJobs)(config);
16
23
  }
17
24
  (0, terminus_1.createTerminus)(server, {
18
25
  timeout: Infinity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.65.0",
3
+ "version": "0.65.2",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -20,10 +20,10 @@
20
20
  "dependencies": {
21
21
  "@aws-sdk/client-s3": "^3.606.0",
22
22
  "@aws-sdk/s3-request-presigner": "^3.598.0",
23
- "@crowdin/crowdin-apps-functions": "0.8.0",
23
+ "@crowdin/crowdin-apps-functions": "0.8.1",
24
24
  "@crowdin/logs-formatter": "^2.1.4",
25
25
  "@godaddy/terminus": "^4.12.1",
26
- "amqplib": "^0.10.3",
26
+ "amqplib": "^0.10.4",
27
27
  "crypto-js": "^4.2.0",
28
28
  "express": "4.19.2",
29
29
  "express-handlebars": "^5.3.5",
@@ -41,17 +41,17 @@
41
41
  "@babel/preset-react": "^7.24.7",
42
42
  "@emotion/react": "^11.13.0",
43
43
  "@emotion/styled": "^11.11.5",
44
- "@mui/icons-material": "^5.16.6",
45
- "@mui/material": "^5.16.6",
46
- "@rjsf/core": "^5.19.4",
47
- "@rjsf/mui": "^5.19.4",
44
+ "@mui/icons-material": "^5.16.7",
45
+ "@mui/material": "^5.16.7",
46
+ "@rjsf/core": "^5.20.1",
47
+ "@rjsf/mui": "^5.20.1",
48
48
  "@rjsf/utils": "^5.18.4",
49
- "@rjsf/validator-ajv8": "^5.19.4",
49
+ "@rjsf/validator-ajv8": "^5.20.1",
50
50
  "@rollup/plugin-babel": "^6.0.4",
51
51
  "@rollup/plugin-commonjs": "^24.1.0",
52
52
  "@rollup/plugin-json": "^6.1.0",
53
53
  "@rollup/plugin-node-resolve": "^15.2.3",
54
- "@rollup/plugin-replace": "^5.0.5",
54
+ "@rollup/plugin-replace": "^5.0.7",
55
55
  "@rollup/plugin-terser": "^0.4.3",
56
56
  "@types/amqplib": "^0.10.4",
57
57
  "@types/crypto-js": "^4.2.2",