@crowdin/app-project-module 0.100.2 → 0.101.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/out/index.js +2 -0
  2. package/out/middlewares/render-ui-module.js +1 -0
  3. package/out/middlewares/ui-module.js +14 -10
  4. package/out/modules/api/api.js +2 -2
  5. package/out/modules/api/redoc-helper/redoc-html-template.d.ts +5 -0
  6. package/out/modules/api/redoc-helper/redoc-html-template.js +28 -0
  7. package/out/modules/automation-action/handlers/execute.d.ts +5 -0
  8. package/out/modules/automation-action/handlers/execute.js +78 -0
  9. package/out/modules/automation-action/handlers/input-schema.d.ts +5 -0
  10. package/out/modules/automation-action/handlers/input-schema.js +29 -0
  11. package/out/modules/automation-action/handlers/output-schema.d.ts +5 -0
  12. package/out/modules/automation-action/handlers/output-schema.js +29 -0
  13. package/out/modules/automation-action/handlers/validate-settings.d.ts +5 -0
  14. package/out/modules/automation-action/handlers/validate-settings.js +35 -0
  15. package/out/modules/automation-action/index.d.ts +6 -0
  16. package/out/modules/automation-action/index.js +45 -0
  17. package/out/modules/automation-action/types.d.ts +49 -0
  18. package/out/modules/automation-action/types.js +2 -0
  19. package/out/modules/automation-action/util/index.d.ts +3 -0
  20. package/out/modules/automation-action/util/index.js +15 -0
  21. package/out/modules/automation-action/util/validate-input.d.ts +9 -0
  22. package/out/modules/automation-action/util/validate-input.js +60 -0
  23. package/out/modules/install.js +19 -2
  24. package/out/modules/manifest.js +25 -0
  25. package/out/static/js/form.js +12 -20
  26. package/out/types.d.ts +11 -0
  27. package/out/types.js +1 -0
  28. package/out/util/connection.js +24 -3
  29. package/out/views/form.handlebars +1 -0
  30. package/package.json +9 -7
package/out/types.d.ts CHANGED
@@ -19,6 +19,7 @@ import { ExternalQaCheckModule } from './modules/external-qa-check/types';
19
19
  import { Webhook } from './modules/webhooks/types';
20
20
  import { WorkflowStepTypeModule } from './modules/workflow-step-type/types';
21
21
  import { AiRequestProcessorModule, AiStreamProcessorModule } from './modules/ai-request-processors/types';
22
+ import { AutomationActionModule } from './modules/automation-action/types';
22
23
  export interface ClientConfig extends ImagePath {
23
24
  /**
24
25
  * Authentication Crowdin App type: "authorization_code", "crowdin_app", "crowdin_agent". Default: "crowdin_app"
@@ -263,6 +264,10 @@ export interface ClientConfig extends ImagePath {
263
264
  * property that tells backend that AiProvider and AiPromptProvider modules can cooperate only with each one
264
265
  */
265
266
  restrictAiToSameApp?: boolean;
267
+ /**
268
+ * Automation action module
269
+ */
270
+ automationAction?: AutomationActionModule | AutomationActionModule[];
266
271
  }
267
272
  export interface Environments {
268
273
  environments?: Environment | Environment[];
@@ -283,6 +288,7 @@ export type UnauthorizedConfig = Omit<Config, 'clientId' | 'clientSecret'> & {
283
288
  export declare enum AuthenticationType {
284
289
  CODE = "authorization_code",
285
290
  APP = "crowdin_app",
291
+ APP_WITH_CODE = "crowdin_app_with_code",
286
292
  AGENT = "crowdin_agent",
287
293
  NONE = "none"
288
294
  }
@@ -419,6 +425,11 @@ export interface UiModule extends ModuleKey {
419
425
  * Endpoint should accept GET requests.
420
426
  */
421
427
  formGetDataUrl?: string;
428
+ /**
429
+ * URL to custom endpoint for patching form data.
430
+ * Endpoint should accept PATCH requests.
431
+ */
432
+ formPatchDataUrl?: string;
422
433
  /**
423
434
  * Additional attributes for react-jsonschema-doc
424
435
  */
package/out/types.js CHANGED
@@ -5,6 +5,7 @@ var AuthenticationType;
5
5
  (function (AuthenticationType) {
6
6
  AuthenticationType["CODE"] = "authorization_code";
7
7
  AuthenticationType["APP"] = "crowdin_app";
8
+ AuthenticationType["APP_WITH_CODE"] = "crowdin_app_with_code";
8
9
  AuthenticationType["AGENT"] = "crowdin_agent";
9
10
  AuthenticationType["NONE"] = "none";
10
11
  })(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));
@@ -49,7 +49,7 @@ const defaults_1 = require("../modules/integration/util/defaults");
49
49
  const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
50
50
  const axiosCustom = new axios_2.AxiosProvider().axios;
51
51
  function prepareCrowdinClient({ config, credentials, autoRenew = false, context, }) {
52
- var _a, _b;
52
+ var _a, _b, _c, _d, _e;
53
53
  return __awaiter(this, void 0, void 0, function* () {
54
54
  let userAgent;
55
55
  if (config.crowdinApiUserAgent) {
@@ -61,6 +61,27 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
61
61
  //2 min as an extra buffer
62
62
  const isExpired = +credentials.expire - 120 < Date.now() / 1000;
63
63
  const organization = credentials.type === types_1.AccountType.ENTERPRISE ? credentials.id : undefined;
64
+ if (config.authenticationType === types_1.AuthenticationType.APP_WITH_CODE) {
65
+ const code = (_a = context === null || context === void 0 ? void 0 : context.jwtPayload) === null || _a === void 0 ? void 0 : _a.code;
66
+ if (!code) {
67
+ throw new Error(`Missing code in JWT payload for ${types_1.AuthenticationType.APP_WITH_CODE} authentication`);
68
+ }
69
+ const freshToken = yield (0, crowdin_apps_functions_1.fetchAppWithCodeToken)({
70
+ appId: config.identifier,
71
+ appSecret: credentials.appSecret,
72
+ clientId: config.clientId,
73
+ clientSecret: config.clientSecret,
74
+ domain: credentials.domain || '',
75
+ userId: credentials.userId,
76
+ code,
77
+ url: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl,
78
+ });
79
+ const token = freshToken.accessToken;
80
+ return {
81
+ client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_c = config.crowdinUrls) === null || _c === void 0 ? void 0 : _c.apiUrl }, { userAgent }),
82
+ token,
83
+ };
84
+ }
64
85
  let token;
65
86
  let crowdinCreds;
66
87
  if (!isExpired) {
@@ -74,7 +95,7 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
74
95
  }
75
96
  if (!autoRenew) {
76
97
  return {
77
- client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_a = config.crowdinUrls) === null || _a === void 0 ? void 0 : _a.apiUrl }, { userAgent }),
98
+ client: new crowdin_api_client_1.default({ token, organization, baseUrl: (_d = config.crowdinUrls) === null || _d === void 0 ? void 0 : _d.apiUrl }, { userAgent }),
78
99
  token,
79
100
  };
80
101
  }
@@ -104,7 +125,7 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
104
125
  client: new crowdin_api_client_1.default({
105
126
  token,
106
127
  organization,
107
- baseUrl: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.apiUrl,
128
+ baseUrl: (_e = config.crowdinUrls) === null || _e === void 0 ? void 0 : _e.apiUrl,
108
129
  }, {
109
130
  httpClient: {
110
131
  get(url, httpConfig) {
@@ -21,6 +21,7 @@
21
21
  /*<!--*/
22
22
  var formGetDataUrl = '{{formGetDataUrl}}';
23
23
  var formPostDataUrl = '{{formPostDataUrl}}';
24
+ var formPatchDataUrl = '{{formPatchDataUrl}}';
24
25
  var formSchema = {{{formSchema}}};
25
26
  var formUiSchema = {{{formUiSchema}}};
26
27
  /*-->*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.100.2",
3
+ "version": "0.101.0",
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",
@@ -13,8 +13,7 @@
13
13
  "prettier": "prettier --config .prettierrc src/**/*.ts --write",
14
14
  "lint-ci": "eslint \"{src,tests}/**/*.{js,ts}\"",
15
15
  "test-coverage": "jest --ci --reporters=jest-junit --reporters=default --coverage --coverageReporters=cobertura --coverageReporters=html",
16
- "test": "jest",
17
- "postinstall": "patch-package"
16
+ "test": "jest"
18
17
  },
19
18
  "files": [
20
19
  "out/**/*"
@@ -22,24 +21,27 @@
22
21
  "dependencies": {
23
22
  "@aws-sdk/client-s3": "^3.758.0",
24
23
  "@aws-sdk/s3-request-presigner": "^3.758.0",
25
- "@crowdin/crowdin-apps-functions": "^0.12.0",
26
- "@crowdin/logs-formatter": "^2.1.8",
24
+ "@crowdin/crowdin-apps-functions": "^0.12.4",
25
+ "@crowdin/logs-formatter": "^2.1.9",
27
26
  "@godaddy/terminus": "^4.12.1",
27
+ "@types/cors": "^2.8.19",
28
+ "@types/lodash.kebabcase": "^4.1.9",
29
+ "ajv": "^8.17.1",
28
30
  "amqplib": "^0.10.8",
31
+ "cors": "^2.8.5",
29
32
  "crypto-js": "^4.2.0",
30
33
  "express": "^4.21.2",
31
34
  "express-handlebars": "^5.3.5",
32
35
  "express-rate-limit": "^7.5.0",
33
36
  "lodash.get": "^4.4.2",
34
37
  "lodash.isstring": "^4.0.1",
38
+ "lodash.kebabcase": "^4.1.1",
35
39
  "lodash.snakecase": "^4.1.1",
36
40
  "lodash.uniqby": "^4.7.0",
37
41
  "minimatch": "^10.0.3",
38
42
  "mysql2": "^3.12.0",
39
43
  "node-cron": "^3.0.3",
40
- "patch-package": "^8.0.1",
41
44
  "pg": "^8.13.3",
42
- "redoc-express": "^2.1.0",
43
45
  "sqlite3": "^5.1.7",
44
46
  "swagger-jsdoc": "^6.2.8",
45
47
  "uuid": "^8.3.2"