@crowdin/app-project-module 1.2.1 → 1.3.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.
Files changed (214) hide show
  1. package/out/app-test/integration/get-integration-files.js +1 -1
  2. package/out/app-test/integration/index.js +6 -6
  3. package/out/app-test/integration/mocks/crowdin-storage.d.ts +16 -16
  4. package/out/app-test/integration/mocks/mock-crowdin-api-client.js +17 -7
  5. package/out/app-test/integration/update-crowdin.js +1 -1
  6. package/out/app-test/integration/update-integration.js +1 -1
  7. package/out/app-test/util/index.js +1 -2
  8. package/out/index.js +23 -13
  9. package/out/middlewares/api-call.js +1 -1
  10. package/out/middlewares/auto-credentials-masker.js +2 -3
  11. package/out/middlewares/crowdin-client.d.ts +1 -2
  12. package/out/middlewares/crowdin-client.js +5 -6
  13. package/out/middlewares/integration-credentials.d.ts +1 -2
  14. package/out/middlewares/integration-credentials.js +18 -8
  15. package/out/middlewares/json-response.js +1 -1
  16. package/out/middlewares/render-ui-module.d.ts +1 -2
  17. package/out/middlewares/render-ui-module.js +1 -1
  18. package/out/middlewares/ui-module.d.ts +1 -2
  19. package/out/middlewares/ui-module.js +1 -1
  20. package/out/modules/about.js +2 -3
  21. package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -2
  22. package/out/modules/ai-prompt-provider/handlers/compile.js +1 -1
  23. package/out/modules/ai-prompt-provider/index.js +1 -2
  24. package/out/modules/ai-prompt-provider/types.js +1 -1
  25. package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -2
  26. package/out/modules/ai-provider/handlers/chat-completions.js +2 -2
  27. package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -2
  28. package/out/modules/ai-provider/handlers/get-model-list.js +1 -1
  29. package/out/modules/ai-provider/index.js +1 -2
  30. package/out/modules/ai-provider/util/index.js +6 -6
  31. package/out/modules/ai-request-processors/handler.d.ts +1 -2
  32. package/out/modules/ai-request-processors/handler.js +1 -1
  33. package/out/modules/ai-request-processors/index.js +5 -5
  34. package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -2
  35. package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
  36. package/out/modules/ai-tools/index.js +2 -3
  37. package/out/modules/ai-tools/util/index.js +4 -5
  38. package/out/modules/api/api.js +4 -5
  39. package/out/modules/api/index.js +1 -2
  40. package/out/modules/api/types.js +1 -1
  41. package/out/modules/auth-guard/handlers/verify.d.ts +1 -2
  42. package/out/modules/auth-guard/handlers/verify.js +1 -1
  43. package/out/modules/auth-guard/index.js +1 -2
  44. package/out/modules/automation-action/handlers/execute.d.ts +1 -2
  45. package/out/modules/automation-action/handlers/execute.js +1 -1
  46. package/out/modules/automation-action/handlers/input-schema.d.ts +1 -2
  47. package/out/modules/automation-action/handlers/input-schema.js +1 -1
  48. package/out/modules/automation-action/handlers/output-schema.d.ts +1 -2
  49. package/out/modules/automation-action/handlers/output-schema.js +1 -1
  50. package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -2
  51. package/out/modules/automation-action/handlers/validate-settings.js +1 -1
  52. package/out/modules/automation-action/index.js +1 -2
  53. package/out/modules/automation-action/util/index.js +2 -3
  54. package/out/modules/automation-action/util/validate-input.js +1 -2
  55. package/out/modules/context-menu/index.js +1 -2
  56. package/out/modules/context-menu/types.js +2 -2
  57. package/out/modules/custom-mt/handlers/translate.d.ts +1 -2
  58. package/out/modules/custom-mt/handlers/translate.js +1 -1
  59. package/out/modules/custom-mt/index.js +1 -2
  60. package/out/modules/custom-mt/types.d.ts +0 -2
  61. package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -2
  62. package/out/modules/custom-spell-check/handlers/get-languages-list.js +1 -1
  63. package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -2
  64. package/out/modules/custom-spell-check/handlers/spell-check.js +1 -1
  65. package/out/modules/custom-spell-check/index.js +1 -2
  66. package/out/modules/editor-right-panel/index.js +1 -2
  67. package/out/modules/external-qa-check/handlers/validate.d.ts +1 -2
  68. package/out/modules/external-qa-check/handlers/validate.js +1 -1
  69. package/out/modules/external-qa-check/index.js +1 -2
  70. package/out/modules/file-processing/handlers/custom-file-format.d.ts +1 -2
  71. package/out/modules/file-processing/handlers/custom-file-format.js +9 -9
  72. package/out/modules/file-processing/handlers/file-download.d.ts +1 -2
  73. package/out/modules/file-processing/handlers/file-download.js +1 -1
  74. package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -2
  75. package/out/modules/file-processing/handlers/pre-post-process.js +1 -1
  76. package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -2
  77. package/out/modules/file-processing/handlers/translations-alignment.js +1 -1
  78. package/out/modules/file-processing/index.js +6 -7
  79. package/out/modules/file-processing/types.d.ts +0 -2
  80. package/out/modules/file-processing/types.js +1 -1
  81. package/out/modules/file-processing/util/defaults.js +18 -9
  82. package/out/modules/file-processing/util/files.d.ts +0 -2
  83. package/out/modules/file-processing/util/files.js +4 -4
  84. package/out/modules/form-data-display.d.ts +1 -2
  85. package/out/modules/form-data-display.js +18 -8
  86. package/out/modules/form-data-save.d.ts +1 -2
  87. package/out/modules/form-data-save.js +18 -8
  88. package/out/modules/install.d.ts +1 -2
  89. package/out/modules/install.js +2 -2
  90. package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -2
  91. package/out/modules/integration/handlers/crowdin-file-progress.js +1 -1
  92. package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +1 -2
  93. package/out/modules/integration/handlers/crowdin-files-target-languages.js +1 -1
  94. package/out/modules/integration/handlers/crowdin-files.d.ts +1 -2
  95. package/out/modules/integration/handlers/crowdin-files.js +1 -1
  96. package/out/modules/integration/handlers/crowdin-project.d.ts +1 -2
  97. package/out/modules/integration/handlers/crowdin-project.js +1 -1
  98. package/out/modules/integration/handlers/crowdin-update.d.ts +1 -2
  99. package/out/modules/integration/handlers/crowdin-update.js +1 -1
  100. package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -2
  101. package/out/modules/integration/handlers/crowdin-webhook.js +2 -2
  102. package/out/modules/integration/handlers/integration-data.d.ts +1 -2
  103. package/out/modules/integration/handlers/integration-data.js +1 -1
  104. package/out/modules/integration/handlers/integration-login.d.ts +1 -2
  105. package/out/modules/integration/handlers/integration-login.js +1 -1
  106. package/out/modules/integration/handlers/integration-logout.d.ts +1 -2
  107. package/out/modules/integration/handlers/integration-logout.js +18 -8
  108. package/out/modules/integration/handlers/integration-update.d.ts +1 -2
  109. package/out/modules/integration/handlers/integration-update.js +1 -1
  110. package/out/modules/integration/handlers/integration-webhook.d.ts +1 -2
  111. package/out/modules/integration/handlers/integration-webhook.js +1 -1
  112. package/out/modules/integration/handlers/invite-users.d.ts +1 -2
  113. package/out/modules/integration/handlers/invite-users.js +1 -1
  114. package/out/modules/integration/handlers/job-cancel.d.ts +1 -2
  115. package/out/modules/integration/handlers/job-cancel.js +1 -1
  116. package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -2
  117. package/out/modules/integration/handlers/job-info-deprecated.js +1 -1
  118. package/out/modules/integration/handlers/job-info.d.ts +1 -2
  119. package/out/modules/integration/handlers/job-info.js +1 -1
  120. package/out/modules/integration/handlers/job-list.d.ts +1 -2
  121. package/out/modules/integration/handlers/job-list.js +1 -1
  122. package/out/modules/integration/handlers/main.d.ts +1 -2
  123. package/out/modules/integration/handlers/main.js +1 -1
  124. package/out/modules/integration/handlers/oauth-login.d.ts +1 -2
  125. package/out/modules/integration/handlers/oauth-login.js +1 -1
  126. package/out/modules/integration/handlers/oauth-polling.d.ts +1 -2
  127. package/out/modules/integration/handlers/oauth-polling.js +1 -1
  128. package/out/modules/integration/handlers/oauth-url.d.ts +1 -2
  129. package/out/modules/integration/handlers/oauth-url.js +1 -1
  130. package/out/modules/integration/handlers/settings-save.d.ts +1 -2
  131. package/out/modules/integration/handlers/settings-save.js +1 -1
  132. package/out/modules/integration/handlers/settings.d.ts +1 -2
  133. package/out/modules/integration/handlers/settings.js +1 -1
  134. package/out/modules/integration/handlers/subscription-info.js +1 -1
  135. package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -2
  136. package/out/modules/integration/handlers/sync-settings-save.js +1 -1
  137. package/out/modules/integration/handlers/sync-settings.d.ts +1 -2
  138. package/out/modules/integration/handlers/sync-settings.js +1 -1
  139. package/out/modules/integration/handlers/user-errors.d.ts +1 -2
  140. package/out/modules/integration/handlers/user-errors.js +1 -1
  141. package/out/modules/integration/handlers/users.d.ts +1 -2
  142. package/out/modules/integration/handlers/users.js +4 -5
  143. package/out/modules/integration/index.js +1 -2
  144. package/out/modules/integration/types.js +4 -4
  145. package/out/modules/integration/util/cron.js +46 -37
  146. package/out/modules/integration/util/defaults.js +33 -24
  147. package/out/modules/integration/util/files.js +29 -30
  148. package/out/modules/integration/util/job.js +29 -20
  149. package/out/modules/integration/util/snapshot.js +7 -8
  150. package/out/modules/integration/util/types.js +3 -3
  151. package/out/modules/integration/util/webhooks.js +54 -44
  152. package/out/modules/manifest.js +1 -1
  153. package/out/modules/modal/index.js +1 -2
  154. package/out/modules/organization-menu/index.js +1 -2
  155. package/out/modules/organization-settings-menu/index.js +1 -2
  156. package/out/modules/profile-resources-menu/index.js +1 -2
  157. package/out/modules/profile-settings-menu/index.js +1 -2
  158. package/out/modules/project-menu/index.js +1 -2
  159. package/out/modules/project-menu-crowdsource/index.js +1 -2
  160. package/out/modules/project-reports/index.js +1 -2
  161. package/out/modules/project-tools/index.js +1 -2
  162. package/out/modules/status.d.ts +1 -2
  163. package/out/modules/status.js +1 -1
  164. package/out/modules/subscription-paid.d.ts +1 -2
  165. package/out/modules/subscription-paid.js +1 -1
  166. package/out/modules/uninstall.d.ts +1 -2
  167. package/out/modules/uninstall.js +1 -1
  168. package/out/modules/webhooks/handlers/webhook-handler.d.ts +1 -2
  169. package/out/modules/webhooks/handlers/webhook-handler.js +18 -9
  170. package/out/modules/webhooks/index.js +1 -2
  171. package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -2
  172. package/out/modules/workflow-step-type/handlers/delete-step.js +18 -8
  173. package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -2
  174. package/out/modules/workflow-step-type/handlers/step-settings-save.js +18 -8
  175. package/out/modules/workflow-step-type/index.js +1 -2
  176. package/out/modules/workflow-step-type/types.js +1 -1
  177. package/out/modules/workflow-step-type/util/index.js +2 -3
  178. package/out/static/ui/error.bundle.js +446 -379
  179. package/out/static/ui/error.bundle.js.map +1 -1
  180. package/out/static/ui/form.bundle.js +29793 -29989
  181. package/out/static/ui/form.bundle.js.map +1 -1
  182. package/out/static/ui/install.bundle.js +446 -379
  183. package/out/static/ui/install.bundle.js.map +1 -1
  184. package/out/static/ui/login.bundle.js +448 -379
  185. package/out/static/ui/login.bundle.js.map +1 -1
  186. package/out/static/ui/main.bundle.js +448 -379
  187. package/out/static/ui/main.bundle.js.map +1 -1
  188. package/out/static/ui/oauth.bundle.js +448 -379
  189. package/out/static/ui/oauth.bundle.js.map +1 -1
  190. package/out/storage/d1.d.ts +1 -1
  191. package/out/storage/d1.js +29 -27
  192. package/out/storage/index.d.ts +1 -1
  193. package/out/storage/index.js +25 -11
  194. package/out/storage/mysql.d.ts +1 -1
  195. package/out/storage/mysql.js +35 -33
  196. package/out/storage/postgre.d.ts +1 -1
  197. package/out/storage/postgre.js +46 -44
  198. package/out/storage/sqlite.d.ts +1 -1
  199. package/out/storage/sqlite.js +18 -16
  200. package/out/types.d.ts +0 -2
  201. package/out/types.js +8 -8
  202. package/out/util/connection.js +34 -25
  203. package/out/util/credentials-masker.d.ts +1 -2
  204. package/out/util/credentials-masker.js +3 -4
  205. package/out/util/cron.js +20 -10
  206. package/out/util/form-schema.js +2 -3
  207. package/out/util/index.js +38 -28
  208. package/out/util/jsx-renderer.js +2 -3
  209. package/out/util/logger.js +41 -31
  210. package/out/util/static-files.d.ts +0 -1
  211. package/out/util/static-files.js +2 -3
  212. package/out/util/subscription.js +11 -12
  213. package/out/views/FormPage.js +3 -3
  214. package/package.json +28 -33
@@ -122,17 +122,19 @@ class SQLiteStorage {
122
122
  };
123
123
  this.config = config;
124
124
  }
125
- migrate() {
125
+ migrate(skipOnboarding) {
126
126
  return __awaiter(this, void 0, void 0, function* () {
127
127
  this.db = require('better-sqlite3')((0, path_1.join)(this.config.dbFolder, types_2.storageFiles.SQLITE));
128
- try {
129
- for (const [tableName, schema] of Object.entries(this.tables)) {
130
- this.db.prepare(`CREATE TABLE IF NOT EXISTS ${tableName} ${schema}`).run();
128
+ if (!skipOnboarding) {
129
+ try {
130
+ for (const [tableName, schema] of Object.entries(this.tables)) {
131
+ this.db.prepare(`CREATE TABLE IF NOT EXISTS ${tableName} ${schema}`).run();
132
+ }
133
+ }
134
+ catch (error) {
135
+ console.error('Error during database migration:', error);
136
+ throw error;
131
137
  }
132
- }
133
- catch (error) {
134
- console.error('Error during database migration:', error);
135
- throw error;
136
138
  }
137
139
  });
138
140
  }
@@ -516,8 +518,8 @@ class SQLiteStorage {
516
518
  return id;
517
519
  });
518
520
  }
519
- updateJob({ id, progress, status, info, data, attempt, errors, processedEntities, }) {
520
- return __awaiter(this, void 0, void 0, function* () {
521
+ updateJob(_a) {
522
+ return __awaiter(this, arguments, void 0, function* ({ id, progress, status, info, data, attempt, errors, processedEntities, }) {
521
523
  const updateFields = ['updated_at = ?'];
522
524
  const updateParams = [Date.now().toString()];
523
525
  if (progress) {
@@ -598,8 +600,8 @@ class SQLiteStorage {
598
600
  `).all(types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED);
599
601
  });
600
602
  }
601
- getAllJobs({ integrationId, crowdinId, limit, offset }) {
602
- return __awaiter(this, void 0, void 0, function* () {
603
+ getAllJobs(_a) {
604
+ return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, limit, offset }) {
603
605
  return this.db.prepare(`
604
606
  SELECT
605
607
  id,
@@ -624,8 +626,8 @@ class SQLiteStorage {
624
626
  });
625
627
  }
626
628
  saveTranslationCache(params) {
627
- var _a;
628
629
  return __awaiter(this, void 0, void 0, function* () {
630
+ var _a;
629
631
  this.db.prepare(`
630
632
  INSERT INTO translation_file_cache
631
633
  (integration_id, crowdin_id, file_id, language_id, etag)
@@ -709,9 +711,9 @@ class SQLiteStorage {
709
711
  this.db.prepare(insertQuery).run(...values);
710
712
  });
711
713
  }
712
- selectRecords(tableName, options = {}, params) {
713
- var _a;
714
- return __awaiter(this, void 0, void 0, function* () {
714
+ selectRecords(tableName_1) {
715
+ return __awaiter(this, arguments, void 0, function* (tableName, options = {}, params) {
716
+ var _a;
715
717
  const columns = ((_a = options.columns) === null || _a === void 0 ? void 0 : _a.length) ? options.columns.join(', ') : '*';
716
718
  const distinctKeyword = options.distinct ? 'DISTINCT ' : '';
717
719
  const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
package/out/types.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import Crowdin from '@crowdin/crowdin-api-client';
4
2
  import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
5
3
  import { Request } from 'express';
package/out/types.js CHANGED
@@ -8,7 +8,7 @@ var AuthenticationType;
8
8
  AuthenticationType["APP_WITH_CODE"] = "crowdin_app_with_code";
9
9
  AuthenticationType["AGENT"] = "crowdin_agent";
10
10
  AuthenticationType["NONE"] = "none";
11
- })(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));
11
+ })(AuthenticationType || (exports.AuthenticationType = AuthenticationType = {}));
12
12
  var Scope;
13
13
  (function (Scope) {
14
14
  Scope["ALL_SCOPES"] = "all";
@@ -36,17 +36,17 @@ var Scope;
36
36
  Scope["AI_PROMPTS"] = "ai.prompt";
37
37
  Scope["AI_PROXIES"] = "ai.proxy";
38
38
  Scope["APPLICATIONS"] = "application";
39
- })(Scope = exports.Scope || (exports.Scope = {}));
39
+ })(Scope || (exports.Scope = Scope = {}));
40
40
  var AccountType;
41
41
  (function (AccountType) {
42
42
  AccountType["NORMAL"] = "normal";
43
43
  AccountType["ENTERPRISE"] = "enterprise";
44
- })(AccountType = exports.AccountType || (exports.AccountType = {}));
44
+ })(AccountType || (exports.AccountType = AccountType = {}));
45
45
  var SubscriptionInfoType;
46
46
  (function (SubscriptionInfoType) {
47
47
  SubscriptionInfoType["TRIAL"] = "trial";
48
48
  SubscriptionInfoType["SUBSCRIPTION"] = "subscription";
49
- })(SubscriptionInfoType = exports.SubscriptionInfoType || (exports.SubscriptionInfoType = {}));
49
+ })(SubscriptionInfoType || (exports.SubscriptionInfoType = SubscriptionInfoType = {}));
50
50
  var EditorMode;
51
51
  (function (EditorMode) {
52
52
  EditorMode["ASSETS"] = "assets";
@@ -56,7 +56,7 @@ var EditorMode;
56
56
  EditorMode["COMFORTABLE"] = "comfortable";
57
57
  EditorMode["SIDE_BY_SIDE"] = "side-by-side";
58
58
  EditorMode["MULTILINGUAL"] = "multilingual";
59
- })(EditorMode = exports.EditorMode || (exports.EditorMode = {}));
59
+ })(EditorMode || (exports.EditorMode = EditorMode = {}));
60
60
  var UserPermissions;
61
61
  (function (UserPermissions) {
62
62
  UserPermissions["OWNER"] = "owner";
@@ -64,15 +64,15 @@ var UserPermissions;
64
64
  UserPermissions["ALL_MEMBERS"] = "all";
65
65
  UserPermissions["GUESTS"] = "guests";
66
66
  UserPermissions["RESTRICTED"] = "restricted";
67
- })(UserPermissions = exports.UserPermissions || (exports.UserPermissions = {}));
67
+ })(UserPermissions || (exports.UserPermissions = UserPermissions = {}));
68
68
  var ProjectPermissions;
69
69
  (function (ProjectPermissions) {
70
70
  ProjectPermissions["OWN"] = "own";
71
71
  ProjectPermissions["RESTRICTED"] = "restricted";
72
- })(ProjectPermissions = exports.ProjectPermissions || (exports.ProjectPermissions = {}));
72
+ })(ProjectPermissions || (exports.ProjectPermissions = ProjectPermissions = {}));
73
73
  var storageFiles;
74
74
  (function (storageFiles) {
75
75
  storageFiles["SQLITE"] = "app.sqlite";
76
76
  storageFiles["SQLITE_BACKUP"] = "backup_app.sqlite";
77
77
  storageFiles["DUMP"] = "dump_table_%s.sql";
78
- })(storageFiles = exports.storageFiles || (exports.storageFiles = {}));
78
+ })(storageFiles || (exports.storageFiles = storageFiles = {}));
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
46
  };
37
47
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.prepareIntegrationCredentials = exports.prepareCrowdinClient = void 0;
48
+ exports.prepareCrowdinClient = prepareCrowdinClient;
49
+ exports.prepareIntegrationCredentials = prepareIntegrationCredentials;
39
50
  const crowdin_api_client_1 = __importDefault(require("@crowdin/crowdin-api-client"));
40
51
  const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
41
52
  const axios_1 = __importDefault(require("axios"));
@@ -48,9 +59,9 @@ const os = __importStar(require("os"));
48
59
  const defaults_1 = require("../modules/integration/util/defaults");
49
60
  const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
50
61
  const axiosCustom = new axios_2.AxiosProvider().axios;
51
- function prepareCrowdinClient({ config, credentials, autoRenew = false, context, }) {
52
- var _a, _b, _c, _d, _e, _f, _g, _h;
53
- return __awaiter(this, void 0, void 0, function* () {
62
+ function prepareCrowdinClient(_a) {
63
+ return __awaiter(this, arguments, void 0, function* ({ config, credentials, autoRenew = false, context, }) {
64
+ var _b, _c, _d, _e, _f, _g, _h, _j;
54
65
  let userAgent;
55
66
  if (config.crowdinApiUserAgent) {
56
67
  userAgent = config.crowdinApiUserAgent;
@@ -62,7 +73,7 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
62
73
  const isExpired = +credentials.expire - 120 < Date.now() / 1000;
63
74
  const organization = credentials.type === types_1.AccountType.ENTERPRISE ? credentials.id : undefined;
64
75
  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;
76
+ const code = (_b = context === null || context === void 0 ? void 0 : context.jwtPayload) === null || _b === void 0 ? void 0 : _b.code;
66
77
  if (!code) {
67
78
  throw new Error(`Missing code in JWT payload for ${types_1.AuthenticationType.APP_WITH_CODE} authentication`);
68
79
  }
@@ -74,15 +85,15 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
74
85
  domain: credentials.domain || '',
75
86
  userId: credentials.userId,
76
87
  code,
77
- url: (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl,
88
+ url: (_c = config.crowdinUrls) === null || _c === void 0 ? void 0 : _c.accountUrl,
78
89
  });
79
90
  const token = freshToken.accessToken;
80
91
  return {
81
92
  client: new crowdin_api_client_1.default({
82
93
  token,
83
94
  organization,
84
- apiDomain: (_c = config.crowdinUrls) === null || _c === void 0 ? void 0 : _c.apiDomain,
85
- baseUrl: (_d = config.crowdinUrls) === null || _d === void 0 ? void 0 : _d.apiUrl,
95
+ apiDomain: (_d = config.crowdinUrls) === null || _d === void 0 ? void 0 : _d.apiDomain,
96
+ baseUrl: (_e = config.crowdinUrls) === null || _e === void 0 ? void 0 : _e.apiUrl,
86
97
  }, { userAgent }),
87
98
  token,
88
99
  };
@@ -103,8 +114,8 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
103
114
  client: new crowdin_api_client_1.default({
104
115
  token,
105
116
  organization,
106
- apiDomain: (_e = config.crowdinUrls) === null || _e === void 0 ? void 0 : _e.apiDomain,
107
- baseUrl: (_f = config.crowdinUrls) === null || _f === void 0 ? void 0 : _f.apiUrl,
117
+ apiDomain: (_f = config.crowdinUrls) === null || _f === void 0 ? void 0 : _f.apiDomain,
118
+ baseUrl: (_g = config.crowdinUrls) === null || _g === void 0 ? void 0 : _g.apiUrl,
108
119
  }, { userAgent }),
109
120
  token,
110
121
  };
@@ -135,8 +146,8 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
135
146
  client: new crowdin_api_client_1.default({
136
147
  token,
137
148
  organization,
138
- apiDomain: (_g = config.crowdinUrls) === null || _g === void 0 ? void 0 : _g.apiDomain,
139
- baseUrl: (_h = config.crowdinUrls) === null || _h === void 0 ? void 0 : _h.apiUrl,
149
+ apiDomain: (_h = config.crowdinUrls) === null || _h === void 0 ? void 0 : _h.apiDomain,
150
+ baseUrl: (_j = config.crowdinUrls) === null || _j === void 0 ? void 0 : _j.apiUrl,
140
151
  }, {
141
152
  httpClient: {
142
153
  get(url, httpConfig) {
@@ -248,7 +259,6 @@ function prepareCrowdinClient({ config, credentials, autoRenew = false, context,
248
259
  };
249
260
  });
250
261
  }
251
- exports.prepareCrowdinClient = prepareCrowdinClient;
252
262
  function prepareIntegrationCredentials(config, integration, integrationCredentials) {
253
263
  return __awaiter(this, void 0, void 0, function* () {
254
264
  const credentials = JSON.parse((0, _1.decryptData)(config, integrationCredentials.credentials));
@@ -259,7 +269,7 @@ function prepareIntegrationCredentials(config, integration, integrationCredentia
259
269
  if ((oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.refresh) || (integrationLogin === null || integrationLogin === void 0 ? void 0 : integrationLogin.refresh)) {
260
270
  const performRefreshTokenRequest = (oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.performRefreshTokenRequest) || (integrationLogin === null || integrationLogin === void 0 ? void 0 : integrationLogin.performRefreshTokenRequest);
261
271
  credentials.tokenProvider = {
262
- getToken: (force = false) => __awaiter(this, void 0, void 0, function* () {
272
+ getToken: (...args_1) => __awaiter(this, [...args_1], void 0, function* (force = false) {
263
273
  var _a, _b, _c, _d, _e, _f, _g;
264
274
  const { expireIn } = credentials;
265
275
  //2 min as an extra buffer
@@ -312,9 +322,8 @@ function prepareIntegrationCredentials(config, integration, integrationCredentia
312
322
  return credentials;
313
323
  });
314
324
  }
315
- exports.prepareIntegrationCredentials = prepareIntegrationCredentials;
316
- function refreshCrowdinCreds({ config, credentials }) {
317
- return __awaiter(this, void 0, void 0, function* () {
325
+ function refreshCrowdinCreds(_a) {
326
+ return __awaiter(this, arguments, void 0, function* ({ config, credentials }) {
318
327
  (0, logger_1.log)('Crowdin credentials have expired. Requesting a new credentials');
319
328
  const newCredentials = yield refreshToken(config, credentials);
320
329
  (0, logger_1.log)('Saving updated crowdin credentials in the database');
@@ -340,8 +349,8 @@ function refreshCrowdinCreds({ config, credentials }) {
340
349
  });
341
350
  }
342
351
  function refreshToken(config, credentials) {
343
- var _a, _b, _c;
344
352
  return __awaiter(this, void 0, void 0, function* () {
353
+ var _a, _b, _c;
345
354
  if (config.authenticationType === types_1.AuthenticationType.CODE) {
346
355
  const token = yield (0, crowdin_apps_functions_1.refreshOAuthToken)({
347
356
  clientId: config.clientId,
@@ -1,4 +1,3 @@
1
- /// <reference types="qs" />
2
1
  import { Request, Response } from 'express';
3
2
  import { CrowdinClientRequest, UiModule } from '../types';
4
3
  declare function maskKey(key: string): string;
@@ -10,5 +9,5 @@ declare function postRequestCredentialsMasker({ secret, moduleConfig, credential
10
9
  secret: string;
11
10
  moduleConfig: UiModule;
12
11
  credentialsExtractor?: Function;
13
- }): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
12
+ }): (req: Request | CrowdinClientRequest, res: Response, next: Function) => void;
14
13
  export { getRequestCredentialsMasker, maskKey, postRequestCredentialsMasker };
@@ -9,7 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.postRequestCredentialsMasker = exports.maskKey = exports.getRequestCredentialsMasker = void 0;
12
+ exports.getRequestCredentialsMasker = getRequestCredentialsMasker;
13
+ exports.maskKey = maskKey;
14
+ exports.postRequestCredentialsMasker = postRequestCredentialsMasker;
13
15
  const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
14
16
  const index_1 = require("../index");
15
17
  const crowdin_client_1 = require("../middlewares/crowdin-client");
@@ -20,7 +22,6 @@ function maskKey(key) {
20
22
  const repeatCount = key.length > unmaskedCharsAtEnd ? key.length - unmaskedCharsAtEnd : 0;
21
23
  return maskWith.repeat(repeatCount) + key.substring(key.length - 3);
22
24
  }
23
- exports.maskKey = maskKey;
24
25
  function getMaskableFieldsKeys(moduleConfig) {
25
26
  if (!moduleConfig.formUiSchema) {
26
27
  return [];
@@ -61,7 +62,6 @@ function getRequestCredentialsMasker({ moduleConfig, dataPath = 'formData', }) {
61
62
  return next();
62
63
  };
63
64
  }
64
- exports.getRequestCredentialsMasker = getRequestCredentialsMasker;
65
65
  function postRequestCredentialsMasker({ secret, moduleConfig, credentialsExtractor, }) {
66
66
  return (0, index_2.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
67
67
  var _a;
@@ -101,4 +101,3 @@ function postRequestCredentialsMasker({ secret, moduleConfig, credentialsExtract
101
101
  return getRequestCredentialsMasker({ moduleConfig })(req, res, next);
102
102
  }));
103
103
  }
104
- exports.postRequestCredentialsMasker = postRequestCredentialsMasker;
package/out/util/cron.js CHANGED
@@ -15,15 +15,27 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getCron = exports.initialize = exports.NodeCron = void 0;
36
+ exports.NodeCron = void 0;
37
+ exports.initialize = initialize;
38
+ exports.getCron = getCron;
27
39
  const logger_1 = require("./logger");
28
40
  /**
29
41
  * Default Node.js cron handler that uses node-cron
@@ -73,7 +85,6 @@ function initialize(config) {
73
85
  cron = new NodeCron();
74
86
  }
75
87
  }
76
- exports.initialize = initialize;
77
88
  /**
78
89
  * Get the initialized cron instance
79
90
  * @returns The cron instance
@@ -84,4 +95,3 @@ function getCron() {
84
95
  }
85
96
  return cron;
86
97
  }
87
- exports.getCron = getCron;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasFormSchema = exports.getLowCodeUiConfigFromModuleConfig = void 0;
3
+ exports.getLowCodeUiConfigFromModuleConfig = getLowCodeUiConfigFromModuleConfig;
4
+ exports.hasFormSchema = hasFormSchema;
4
5
  function getLowCodeUiConfigFromModuleConfig(moduleConfig) {
5
6
  var _a;
6
7
  if (typeof moduleConfig !== 'object' || moduleConfig === null) {
@@ -14,8 +15,6 @@ function getLowCodeUiConfigFromModuleConfig(moduleConfig) {
14
15
  }
15
16
  return null;
16
17
  }
17
- exports.getLowCodeUiConfigFromModuleConfig = getLowCodeUiConfigFromModuleConfig;
18
18
  function hasFormSchema(moduleConfig) {
19
19
  return !!getLowCodeUiConfigFromModuleConfig(moduleConfig);
20
20
  }
21
- exports.hasFormSchema = hasFormSchema;
package/out/util/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -32,7 +42,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
42
  });
33
43
  };
34
44
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.uniqBy = exports.snakeCase = exports.kebabCase = exports.getFormattedDate = exports.validateEmail = exports.prepareFormDataMetadataId = exports.getPreviousDate = exports.isString = exports.isDefined = exports.isJson = exports.isAuthorizedConfig = exports.serveLogo = exports.getLogoUrl = exports.executeWithRetry = exports.decryptData = exports.encryptData = exports.runAsyncWrapper = exports.extractBaseUrlFromRequest = exports.CodeError = void 0;
45
+ exports.CodeError = void 0;
46
+ exports.extractBaseUrlFromRequest = extractBaseUrlFromRequest;
47
+ exports.runAsyncWrapper = runAsyncWrapper;
48
+ exports.encryptData = encryptData;
49
+ exports.decryptData = decryptData;
50
+ exports.executeWithRetry = executeWithRetry;
51
+ exports.getLogoUrl = getLogoUrl;
52
+ exports.serveLogo = serveLogo;
53
+ exports.isAuthorizedConfig = isAuthorizedConfig;
54
+ exports.isJson = isJson;
55
+ exports.isDefined = isDefined;
56
+ exports.isString = isString;
57
+ exports.getPreviousDate = getPreviousDate;
58
+ exports.prepareFormDataMetadataId = prepareFormDataMetadataId;
59
+ exports.validateEmail = validateEmail;
60
+ exports.getFormattedDate = getFormattedDate;
61
+ exports.kebabCase = kebabCase;
62
+ exports.snakeCase = snakeCase;
63
+ exports.uniqBy = uniqBy;
36
64
  const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
37
65
  const crypto = __importStar(require("crypto"));
38
66
  const storage_1 = require("../storage");
@@ -60,7 +88,6 @@ function extractBaseUrlFromRequest(req) {
60
88
  const host = req.get('host');
61
89
  return `${protocol}://${host}`;
62
90
  }
63
- exports.extractBaseUrlFromRequest = extractBaseUrlFromRequest;
64
91
  function isCrowdinClientRequest(req) {
65
92
  return req.crowdinContext;
66
93
  }
@@ -100,7 +127,6 @@ function runAsyncWrapper(callback) {
100
127
  });
101
128
  };
102
129
  }
103
- exports.runAsyncWrapper = runAsyncWrapper;
104
130
  function encryptData(config, data) {
105
131
  const secret = config.cryptoSecret || config.clientSecret;
106
132
  const salt = crypto.randomBytes(8);
@@ -117,7 +143,6 @@ function encryptData(config, data) {
117
143
  const cipher = crypto.createCipheriv('aes-256-cbc', key, iv);
118
144
  return Buffer.concat([Buffer.from('Salted__', 'utf8'), salt, cipher.update(data), cipher.final()]).toString('base64');
119
145
  }
120
- exports.encryptData = encryptData;
121
146
  function decryptData(config, data) {
122
147
  const secret = config.cryptoSecret || config.clientSecret;
123
148
  const cypher = Buffer.from(data, 'base64');
@@ -135,9 +160,8 @@ function decryptData(config, data) {
135
160
  const decipher = crypto.createDecipheriv('aes-256-cbc', key, iv);
136
161
  return decipher.update(contents, undefined, 'utf-8') + decipher.final('utf-8');
137
162
  }
138
- exports.decryptData = decryptData;
139
- function executeWithRetry(func, numOfRetries = 2) {
140
- return __awaiter(this, void 0, void 0, function* () {
163
+ function executeWithRetry(func_1) {
164
+ return __awaiter(this, arguments, void 0, function* (func, numOfRetries = 2) {
141
165
  for (let i = 0; i <= numOfRetries; i++) {
142
166
  try {
143
167
  const result = yield func();
@@ -152,7 +176,6 @@ function executeWithRetry(func, numOfRetries = 2) {
152
176
  throw new Error('Failed to process request with retry');
153
177
  });
154
178
  }
155
- exports.executeWithRetry = executeWithRetry;
156
179
  function getLogoUrl(config, moduleConfig, modulePath) {
157
180
  // Extract file name from imagePath with fallback to config.imagePath
158
181
  const imagePath = (moduleConfig === null || moduleConfig === void 0 ? void 0 : moduleConfig.imagePath) || config.imagePath;
@@ -162,7 +185,6 @@ function getLogoUrl(config, moduleConfig, modulePath) {
162
185
  }
163
186
  return `/logo${modulePath}/${fileName}`;
164
187
  }
165
- exports.getLogoUrl = getLogoUrl;
166
188
  /**
167
189
  * Logo middleware with backwards compatibility
168
190
  * Serves both /logo.png (backwards-compatible) and actual file name
@@ -182,11 +204,9 @@ function serveLogo(config, moduleConfig) {
182
204
  next();
183
205
  });
184
206
  }
185
- exports.serveLogo = serveLogo;
186
207
  function isAuthorizedConfig(config) {
187
208
  return !!config.clientId && !!config.clientSecret && config.authenticationType !== types_1.AuthenticationType.NONE;
188
209
  }
189
- exports.isAuthorizedConfig = isAuthorizedConfig;
190
210
  function isJson(string) {
191
211
  try {
192
212
  JSON.parse(string);
@@ -196,21 +216,17 @@ function isJson(string) {
196
216
  }
197
217
  return true;
198
218
  }
199
- exports.isJson = isJson;
200
219
  function isDefined(value) {
201
220
  return value !== undefined && value !== null;
202
221
  }
203
- exports.isDefined = isDefined;
204
222
  function isString(value) {
205
223
  return typeof value === 'string' || value instanceof String;
206
224
  }
207
- exports.isString = isString;
208
225
  function getPreviousDate(days) {
209
226
  const date = new Date();
210
227
  date.setDate(date.getDate() - days);
211
228
  return date;
212
229
  }
213
- exports.getPreviousDate = getPreviousDate;
214
230
  function prepareFormDataMetadataId(req, config) {
215
231
  return __awaiter(this, void 0, void 0, function* () {
216
232
  const jwtToken = req.query.jwtToken;
@@ -226,7 +242,6 @@ function prepareFormDataMetadataId(req, config) {
226
242
  return id.join('-');
227
243
  });
228
244
  }
229
- exports.prepareFormDataMetadataId = prepareFormDataMetadataId;
230
245
  function validateEmail(email) {
231
246
  if (!isNaN(+email)) {
232
247
  return false;
@@ -237,7 +252,6 @@ function validateEmail(email) {
237
252
  const emailRegExp = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
238
253
  return emailRegExp.test(String(email).toLowerCase());
239
254
  }
240
- exports.validateEmail = validateEmail;
241
255
  // Format the date as 'MMM DD, YYYY HH:mm'
242
256
  function getFormattedDate({ date, userTimezone }) {
243
257
  if (!userTimezone) {
@@ -253,7 +267,6 @@ function getFormattedDate({ date, userTimezone }) {
253
267
  timeZone: userTimezone,
254
268
  }).format(date);
255
269
  }
256
- exports.getFormattedDate = getFormattedDate;
257
270
  function kebabCase(str) {
258
271
  if (!str) {
259
272
  return '';
@@ -271,11 +284,9 @@ function kebabCase(str) {
271
284
  // Lowercase everything
272
285
  .toLowerCase());
273
286
  }
274
- exports.kebabCase = kebabCase;
275
287
  function snakeCase(str) {
276
288
  return kebabCase(str).replace(/-/g, '_');
277
289
  }
278
- exports.snakeCase = snakeCase;
279
290
  function uniqBy(array, key) {
280
291
  if (!Array.isArray(array)) {
281
292
  return [];
@@ -292,4 +303,3 @@ function uniqBy(array, key) {
292
303
  }
293
304
  });
294
305
  }
295
- exports.uniqBy = uniqBy;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderJSXOnClient = exports.renderJSXOnServer = void 0;
3
+ exports.renderJSXOnServer = renderJSXOnServer;
4
+ exports.renderJSXOnClient = renderJSXOnClient;
4
5
  const server_1 = require("react-dom/server");
5
6
  const views_1 = require("../views");
6
7
  /**
@@ -11,7 +12,6 @@ function renderJSXOnServer(Component, props) {
11
12
  const element = Component(props);
12
13
  return '<!DOCTYPE html>' + (0, server_1.renderToStaticMarkup)(element);
13
14
  }
14
- exports.renderJSXOnServer = renderJSXOnServer;
15
15
  /**
16
16
  * Renders a React component to HTML string to be hydrated on client side
17
17
  */
@@ -32,4 +32,3 @@ function renderJSXOnClient({ name, props, withHead = true, }) {
32
32
  </html>
33
33
  `;
34
34
  }
35
- exports.renderJSXOnClient = renderJSXOnClient;