@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
@@ -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,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
42
  });
33
43
  };
34
44
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.buildMenuItems = exports.groupFieldsByCategory = exports.getOAuthLoginFormId = exports.getOAuthPollingId = exports.constructOauthUrl = exports.applyIntegrationModuleDefaults = exports.getOauthRoute = exports.getRootFolder = void 0;
45
+ exports.getRootFolder = getRootFolder;
46
+ exports.getOauthRoute = getOauthRoute;
47
+ exports.applyIntegrationModuleDefaults = applyIntegrationModuleDefaults;
48
+ exports.constructOauthUrl = constructOauthUrl;
49
+ exports.getOAuthPollingId = getOAuthPollingId;
50
+ exports.getOAuthLoginFormId = getOAuthLoginFormId;
51
+ exports.groupFieldsByCategory = groupFieldsByCategory;
52
+ exports.buildMenuItems = buildMenuItems;
36
53
  const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
37
54
  const types_1 = require("../types");
38
55
  function getRootFolder(config, integration, client, projectId) {
@@ -51,16 +68,14 @@ function getRootFolder(config, integration, client, projectId) {
51
68
  return rootFolder;
52
69
  });
53
70
  }
54
- exports.getRootFolder = getRootFolder;
55
71
  function getOauthRoute(integration) {
56
72
  var _a;
57
73
  return ((_a = integration.oauthLogin) === null || _a === void 0 ? void 0 : _a.redirectUriRoute) || '/oauth/code';
58
74
  }
59
- exports.getOauthRoute = getOauthRoute;
60
75
  function applyIntegrationModuleDefaults(config, integration) {
61
76
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
62
77
  if (!integration.getCrowdinFiles) {
63
- integration.getCrowdinFiles = ({ projectId, client, rootFolder, mode }) => __awaiter(this, void 0, void 0, function* () {
78
+ integration.getCrowdinFiles = (_a) => __awaiter(this, [_a], void 0, function* ({ projectId, client, rootFolder, mode }) {
64
79
  let options = {};
65
80
  if (rootFolder) {
66
81
  options = {
@@ -133,13 +148,13 @@ function applyIntegrationModuleDefaults(config, integration) {
133
148
  });
134
149
  }
135
150
  if (!integration.getFileProgress) {
136
- integration.getFileProgress = ({ projectId, client, fileId }) => __awaiter(this, void 0, void 0, function* () {
151
+ integration.getFileProgress = (_a) => __awaiter(this, [_a], void 0, function* ({ projectId, client, fileId }) {
137
152
  const progress = yield client.translationStatusApi.withFetchAll().getFileProgress(projectId, fileId);
138
153
  return { [fileId]: progress.data.map((e) => e.data) };
139
154
  });
140
155
  }
141
156
  if (!integration.updateFilesTargetLanguages) {
142
- integration.updateFilesTargetLanguages = ({ projectId, client, fileIds, excludedTargetLanguages }) => __awaiter(this, void 0, void 0, function* () {
157
+ integration.updateFilesTargetLanguages = (_a) => __awaiter(this, [_a], void 0, function* ({ projectId, client, fileIds, excludedTargetLanguages }) {
143
158
  for (const fileId of fileIds) {
144
159
  yield client.sourceFilesApi.editFile(projectId, fileId, [
145
160
  {
@@ -167,8 +182,8 @@ function applyIntegrationModuleDefaults(config, integration) {
167
182
  integration.filterByPathIntegrationFiles = true;
168
183
  }
169
184
  const getUserSettings = integration.getConfiguration;
170
- integration.getConfiguration = ({ projectId, client: crowdinClient, credentials, settings, clientId, }) => __awaiter(this, void 0, void 0, function* () {
171
- var _p, _q, _r;
185
+ integration.getConfiguration = (_a) => __awaiter(this, [_a], void 0, function* ({ projectId, client: crowdinClient, credentials, settings, clientId, }) {
186
+ var _b, _c, _d;
172
187
  let fields = [];
173
188
  const project = (yield crowdinClient.projectsGroupsApi.getProject(projectId));
174
189
  if (getUserSettings) {
@@ -228,7 +243,7 @@ function applyIntegrationModuleDefaults(config, integration) {
228
243
  });
229
244
  const userSchedule = fields.find((field) => 'key' in field && field.key === 'schedule');
230
245
  if (userSchedule) {
231
- userSchedule.position = (_p = userSchedule.position) !== null && _p !== void 0 ? _p : 0;
246
+ userSchedule.position = (_b = userSchedule.position) !== null && _b !== void 0 ? _b : 0;
232
247
  userSchedule.category = types_1.DefaultCategory.SYNC;
233
248
  }
234
249
  else {
@@ -268,7 +283,7 @@ function applyIntegrationModuleDefaults(config, integration) {
268
283
  ],
269
284
  });
270
285
  }
271
- if ((_q = integration.syncNewElements) === null || _q === void 0 ? void 0 : _q.crowdin) {
286
+ if ((_c = integration.syncNewElements) === null || _c === void 0 ? void 0 : _c.crowdin) {
272
287
  defaultSettings.push({
273
288
  key: 'new-crowdin-files',
274
289
  label: 'Automatically sync new translations from Crowdin',
@@ -278,7 +293,7 @@ function applyIntegrationModuleDefaults(config, integration) {
278
293
  position: 1,
279
294
  });
280
295
  }
281
- if ((_r = integration.syncNewElements) === null || _r === void 0 ? void 0 : _r.integration) {
296
+ if ((_d = integration.syncNewElements) === null || _d === void 0 ? void 0 : _d.integration) {
282
297
  defaultSettings.push({
283
298
  key: 'new-integration-files',
284
299
  label: `Automatically sync new content from ${config.name}`,
@@ -461,7 +476,6 @@ function applyIntegrationModuleDefaults(config, integration) {
461
476
  }
462
477
  integration.jobStoreType = integration.jobStoreType || 'db';
463
478
  }
464
- exports.applyIntegrationModuleDefaults = applyIntegrationModuleDefaults;
465
479
  function constructOauthUrl({ config, integration, clientId, loginForm, }) {
466
480
  var _a, _b, _c, _d, _e;
467
481
  const oauth = integration.oauthLogin;
@@ -494,15 +508,12 @@ function constructOauthUrl({ config, integration, clientId, loginForm, }) {
494
508
  }
495
509
  return url;
496
510
  }
497
- exports.constructOauthUrl = constructOauthUrl;
498
511
  function getOAuthPollingId(clientId) {
499
512
  return `oauth_${clientId}`;
500
513
  }
501
- exports.getOAuthPollingId = getOAuthPollingId;
502
514
  function getOAuthLoginFormId(clientId) {
503
515
  return `oauth_form_${clientId}`;
504
516
  }
505
- exports.getOAuthLoginFormId = getOAuthLoginFormId;
506
517
  function groupFieldsByCategory(fields) {
507
518
  const groupedFields = fields.reduce((acc, field) => {
508
519
  const category = (field === null || field === void 0 ? void 0 : field.category) || types_1.DefaultCategory.GENERAL;
@@ -547,7 +558,6 @@ function groupFieldsByCategory(fields) {
547
558
  fields,
548
559
  }));
549
560
  }
550
- exports.groupFieldsByCategory = groupFieldsByCategory;
551
561
  function buildMenuItems(integration, appName) {
552
562
  const integrationMenuItems = [];
553
563
  if (integration.matchCrowdinFilesToIntegrationFiles) {
@@ -608,4 +618,3 @@ function buildMenuItems(integration, appName) {
608
618
  crowdinButtonMenuItems: crowdinMenuItems.length > 0 ? JSON.stringify(crowdinMenuItems) : null,
609
619
  };
610
620
  }
611
- exports.buildMenuItems = buildMenuItems;
@@ -9,7 +9,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.filterSyncedData = exports.updateSyncedData = exports.filterFilesByPath = exports.filterFilesByPatterns = exports.getParentFiles = exports.getParentPaths = exports.buildPath = exports.prepareSyncFiles = exports.uniqueFileLanguages = exports.filterLanguages = exports.getExcludedTargetLanguages = exports.markUnsyncedFiles = exports.isMatchingResultType = exports.isExtendedResultType = exports.expandFilesTreeWithPagination = exports.attachFileStatus = exports.expandFilesTree = exports.skipFilesByRegex = exports.hasFolders = exports.isFolder = void 0;
12
+ exports.isFolder = isFolder;
13
+ exports.hasFolders = hasFolders;
14
+ exports.skipFilesByRegex = skipFilesByRegex;
15
+ exports.expandFilesTree = expandFilesTree;
16
+ exports.attachFileStatus = attachFileStatus;
17
+ exports.expandFilesTreeWithPagination = expandFilesTreeWithPagination;
18
+ exports.isExtendedResultType = isExtendedResultType;
19
+ exports.isMatchingResultType = isMatchingResultType;
20
+ exports.markUnsyncedFiles = markUnsyncedFiles;
21
+ exports.getExcludedTargetLanguages = getExcludedTargetLanguages;
22
+ exports.filterLanguages = filterLanguages;
23
+ exports.uniqueFileLanguages = uniqueFileLanguages;
24
+ exports.prepareSyncFiles = prepareSyncFiles;
25
+ exports.buildPath = buildPath;
26
+ exports.getParentPaths = getParentPaths;
27
+ exports.getParentFiles = getParentFiles;
28
+ exports.filterFilesByPatterns = filterFilesByPatterns;
29
+ exports.filterFilesByPath = filterFilesByPath;
30
+ exports.updateSyncedData = updateSyncedData;
31
+ exports.filterSyncedData = filterSyncedData;
13
32
  const types_1 = require("../types");
14
33
  const types_2 = require("./types");
15
34
  const storage_1 = require("../../../storage");
@@ -18,11 +37,9 @@ const minimatch_1 = require("minimatch");
18
37
  function isFolder(item) {
19
38
  return !item.type || item.node_type === '0';
20
39
  }
21
- exports.isFolder = isFolder;
22
40
  function hasFolders(files) {
23
41
  return Array.isArray(files) && files.some(isFolder);
24
42
  }
25
- exports.hasFolders = hasFolders;
26
43
  function skipFilesByRegex(files, skipIntegrationNodes) {
27
44
  if (!Array.isArray(files)) {
28
45
  return [];
@@ -40,10 +57,9 @@ function skipFilesByRegex(files, skipIntegrationNodes) {
40
57
  }
41
58
  return files;
42
59
  }
43
- exports.skipFilesByRegex = skipFilesByRegex;
44
60
  function expandFilesTree(nodes, req, integration, job) {
45
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
46
61
  return __awaiter(this, void 0, void 0, function* () {
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
47
63
  if (job && types_2.JobStatus.CANCELED === ((_a = (yield job.get())) === null || _a === void 0 ? void 0 : _a.status)) {
48
64
  throw new Error('Job canceled');
49
65
  }
@@ -91,10 +107,9 @@ function expandFilesTree(nodes, req, integration, job) {
91
107
  return files;
92
108
  });
93
109
  }
94
- exports.expandFilesTree = expandFilesTree;
95
110
  function attachFileStatus(files, clientId, crowdinId, integration) {
96
- var _a, _b, _c, _d, _e, _f, _g, _h;
97
111
  return __awaiter(this, void 0, void 0, function* () {
112
+ var _a, _b, _c, _d, _e, _f, _g, _h;
98
113
  const needsFileStatus = ((_b = (_a = integration.filtering) === null || _a === void 0 ? void 0 : _a.integrationFileStatus) === null || _b === void 0 ? void 0 : _b.isNew) ||
99
114
  ((_d = (_c = integration.filtering) === null || _c === void 0 ? void 0 : _c.integrationFileStatus) === null || _d === void 0 ? void 0 : _d.isUpdated) ||
100
115
  ((_f = (_e = integration.filtering) === null || _e === void 0 ? void 0 : _e.integrationFileStatus) === null || _f === void 0 ? void 0 : _f.notSynced) ||
@@ -139,10 +154,9 @@ function attachFileStatus(files, clientId, crowdinId, integration) {
139
154
  });
140
155
  });
141
156
  }
142
- exports.attachFileStatus = attachFileStatus;
143
157
  function expandFilesTreeWithPagination(nodes, req, integration, job) {
144
- var _a, _b;
145
158
  return __awaiter(this, void 0, void 0, function* () {
159
+ var _a, _b;
146
160
  if (job && types_2.JobStatus.CANCELED === ((_a = (yield job.get())) === null || _a === void 0 ? void 0 : _a.status)) {
147
161
  throw new Error('Job canceled');
148
162
  }
@@ -214,21 +228,18 @@ function expandFilesTreeWithPagination(nodes, req, integration, job) {
214
228
  return files;
215
229
  });
216
230
  }
217
- exports.expandFilesTreeWithPagination = expandFilesTreeWithPagination;
218
231
  function isExtendedResultType(data) {
219
232
  const dataTyped = data;
220
233
  return !!dataTyped && !Array.isArray(dataTyped);
221
234
  }
222
- exports.isExtendedResultType = isExtendedResultType;
223
235
  function isMatchingResultType(data) {
224
236
  return data !== undefined && data !== null && typeof data === 'object' && 'data' in data && 'errors' in data;
225
237
  }
226
- exports.isMatchingResultType = isMatchingResultType;
227
238
  function isFileLeaf(file) {
228
239
  return file.nodeType === '1' || !!file.type;
229
240
  }
230
- function markUnsyncedFiles({ integrationId, crowdinId, client, files, }) {
231
- return __awaiter(this, void 0, void 0, function* () {
241
+ function markUnsyncedFiles(_a) {
242
+ return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, client, files, }) {
232
243
  if (!Array.isArray(files)) {
233
244
  return [];
234
245
  }
@@ -271,15 +282,13 @@ function markUnsyncedFiles({ integrationId, crowdinId, client, files, }) {
271
282
  });
272
283
  });
273
284
  }
274
- exports.markUnsyncedFiles = markUnsyncedFiles;
275
- function getExcludedTargetLanguages({ client, projectId, languages, }) {
276
- return __awaiter(this, void 0, void 0, function* () {
285
+ function getExcludedTargetLanguages(_a) {
286
+ return __awaiter(this, arguments, void 0, function* ({ client, projectId, languages, }) {
277
287
  const projectData = yield client.projectsGroupsApi.getProject(projectId);
278
288
  const targetLanguages = projectData.data.targetLanguageIds;
279
289
  return targetLanguages.filter((language) => !languages.includes(language));
280
290
  });
281
291
  }
282
- exports.getExcludedTargetLanguages = getExcludedTargetLanguages;
283
292
  function filterLanguages(request, files) {
284
293
  const result = {};
285
294
  for (const fileId in request) {
@@ -294,7 +303,6 @@ function filterLanguages(request, files) {
294
303
  }
295
304
  return result;
296
305
  }
297
- exports.filterLanguages = filterLanguages;
298
306
  function uniqueFileLanguages(files) {
299
307
  const result = {};
300
308
  for (const fileId in files) {
@@ -303,7 +311,6 @@ function uniqueFileLanguages(files) {
303
311
  }
304
312
  return result;
305
313
  }
306
- exports.uniqueFileLanguages = uniqueFileLanguages;
307
314
  function prepareSyncFiles(files) {
308
315
  // If it's an array (Provider.INTEGRATION format), return as is
309
316
  if (Array.isArray(files)) {
@@ -317,7 +324,6 @@ function prepareSyncFiles(files) {
317
324
  }
318
325
  return files;
319
326
  }
320
- exports.prepareSyncFiles = prepareSyncFiles;
321
327
  function buildPath(file, files) {
322
328
  const filePath = `/${file.name}`;
323
329
  if (!file.parentId) {
@@ -330,7 +336,6 @@ function buildPath(file, files) {
330
336
  const parentPath = buildPath(parent, files);
331
337
  return `${parentPath}${filePath}`;
332
338
  }
333
- exports.buildPath = buildPath;
334
339
  function getParentPaths(filePath) {
335
340
  const parentPaths = new Set();
336
341
  const parts = filePath.split('/');
@@ -341,7 +346,6 @@ function getParentPaths(filePath) {
341
346
  }
342
347
  return parentPaths;
343
348
  }
344
- exports.getParentPaths = getParentPaths;
345
349
  function getParentFiles(allFiles, fileCollection) {
346
350
  const parentPaths = new Set();
347
351
  fileCollection
@@ -352,11 +356,9 @@ function getParentFiles(allFiles, fileCollection) {
352
356
  });
353
357
  return allFiles.filter((file) => file.path && parentPaths.has(file.path));
354
358
  }
355
- exports.getParentFiles = getParentFiles;
356
359
  function filterFilesByPatterns(files, patterns) {
357
360
  return files.filter((file) => patterns.some((pattern) => (0, minimatch_1.minimatch)(file.path || '', pattern.trim())));
358
361
  }
359
- exports.filterFilesByPatterns = filterFilesByPatterns;
360
362
  function filterFilesByPath(files, includePatterns, excludePatterns) {
361
363
  const filesWithPaths = files.map((file) => (Object.assign(Object.assign({}, file), { path: buildPath(file, files) })));
362
364
  let filteredFiles = [...filesWithPaths];
@@ -373,9 +375,8 @@ function filterFilesByPath(files, includePatterns, excludePatterns) {
373
375
  }
374
376
  return filteredFiles;
375
377
  }
376
- exports.filterFilesByPath = filterFilesByPath;
377
- function updateSyncedData(clientId, crowdinId, payload, provider = types_1.Provider.INTEGRATION) {
378
- return __awaiter(this, void 0, void 0, function* () {
378
+ function updateSyncedData(clientId_1, crowdinId_1, payload_1) {
379
+ return __awaiter(this, arguments, void 0, function* (clientId, crowdinId, payload, provider = types_1.Provider.INTEGRATION) {
379
380
  const existingSyncedData = yield (0, storage_1.getStorage)().getSyncedData(clientId, crowdinId, provider);
380
381
  const currentTimestamp = Date.now().toString();
381
382
  const filesWithTimestamp = (payload === null || payload === void 0 ? void 0 : payload.map((file) => (Object.assign(Object.assign({}, file), { syncedAt: currentTimestamp })))) || [];
@@ -389,10 +390,8 @@ function updateSyncedData(clientId, crowdinId, payload, provider = types_1.Provi
389
390
  }
390
391
  });
391
392
  }
392
- exports.updateSyncedData = updateSyncedData;
393
393
  function filterSyncedData(payload) {
394
394
  return __awaiter(this, void 0, void 0, function* () {
395
395
  return payload === null || payload === void 0 ? void 0 : payload.filter((file) => file.isUpdated !== false);
396
396
  });
397
397
  }
398
- exports.filterSyncedData = filterSyncedData;
@@ -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,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
42
  });
33
43
  };
34
44
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.reRunInProgressJobs = exports.runAsJob = void 0;
45
+ exports.runAsJob = runAsJob;
46
+ exports.reRunInProgressJobs = reRunInProgressJobs;
36
47
  const types_1 = require("./types");
37
48
  const storage_1 = require("../../../storage");
38
49
  const logger_1 = require("../../../util/logger");
@@ -49,8 +60,8 @@ const blockingJobs = {
49
60
  };
50
61
  const maxAttempts = 3;
51
62
  const store = {};
52
- function runAsJob({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, }) {
53
- return __awaiter(this, void 0, void 0, function* () {
63
+ function runAsJob(_a) {
64
+ return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, res, projectId, client, jobType, jobStoreType, jobCallback, onError, reRunJobId, forcePushTranslations, }) {
54
65
  let jobId;
55
66
  const storage = (0, storage_1.getStorage)();
56
67
  if (!reRunJobId) {
@@ -86,8 +97,8 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
86
97
  return yield storage.getJob({ id: jobId });
87
98
  });
88
99
  },
89
- update: function updateProgress({ progress, status, info, data, attempt, errors, processedEntities, }) {
90
- return __awaiter(this, void 0, void 0, function* () {
100
+ update: function updateProgress(_a) {
101
+ return __awaiter(this, arguments, void 0, function* ({ progress, status, info, data, attempt, errors, processedEntities, }) {
91
102
  const prevData = yield this.get();
92
103
  if ((prevData === null || prevData === void 0 ? void 0 : prevData.status) === types_1.JobStatus.CANCELED) {
93
104
  return { isCanceled: true };
@@ -106,8 +117,8 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
106
117
  });
107
118
  },
108
119
  type: jobType,
109
- fetchTranslation: ({ fileId, languageId, params }) => __awaiter(this, void 0, void 0, function* () {
110
- var _a, _b, _c;
120
+ fetchTranslation: (_a) => __awaiter(this, [_a], void 0, function* ({ fileId, languageId, params }) {
121
+ var _b, _c, _d;
111
122
  const translationCache = isDbStore
112
123
  ? yield storage.getFileTranslationCacheByLanguage({
113
124
  integrationId,
@@ -115,7 +126,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
115
126
  fileId,
116
127
  languageId,
117
128
  })
118
- : (_c = (_b = (_a = store[integrationId]) === null || _a === void 0 ? void 0 : _a[crowdinId]) === null || _b === void 0 ? void 0 : _b[fileId]) === null || _c === void 0 ? void 0 : _c[languageId];
129
+ : (_d = (_c = (_b = store[integrationId]) === null || _b === void 0 ? void 0 : _b[crowdinId]) === null || _c === void 0 ? void 0 : _c[fileId]) === null || _d === void 0 ? void 0 : _d[languageId];
119
130
  if (!translationCache) {
120
131
  if (isDbStore) {
121
132
  yield storage.saveTranslationCache({ integrationId, crowdinId, fileId, languageId });
@@ -150,7 +161,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
150
161
  }
151
162
  return translation;
152
163
  }),
153
- translationUploaded: ({ fileId, translationParams }) => __awaiter(this, void 0, void 0, function* () {
164
+ translationUploaded: (_a) => __awaiter(this, [_a], void 0, function* ({ fileId, translationParams }) {
154
165
  if (!isDbStore) {
155
166
  translationParams.forEach(({ languageId, etag }) => (store[integrationId][crowdinId][fileId][languageId] = { etag }));
156
167
  return;
@@ -176,7 +187,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
176
187
  }
177
188
  yield Promise.all([...updates, ...inserts]);
178
189
  }),
179
- markFilesAsUnsynced: ({ files }) => __awaiter(this, void 0, void 0, function* () {
190
+ markFilesAsUnsynced: (_a) => __awaiter(this, [_a], void 0, function* ({ files }) {
180
191
  const unsyncedFilesData = yield storage.getUnsyncedFiles({ integrationId, crowdinId });
181
192
  const updatedFileRecords = files.map((file) => ({
182
193
  id: file.fileId,
@@ -197,7 +208,7 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
197
208
  });
198
209
  }
199
210
  }),
200
- unmarkFilesAsUnsynced: ({ files }) => __awaiter(this, void 0, void 0, function* () {
211
+ unmarkFilesAsUnsynced: (_a) => __awaiter(this, [_a], void 0, function* ({ files }) {
201
212
  const unsyncedFilesData = yield storage.getUnsyncedFiles({ integrationId, crowdinId });
202
213
  if (unsyncedFilesData) {
203
214
  const existingUnsyncedFiles = (unsyncedFilesData === null || unsyncedFilesData === void 0 ? void 0 : unsyncedFilesData.files) ? JSON.parse(unsyncedFilesData.files) : [];
@@ -232,7 +243,6 @@ function runAsJob({ integrationId, crowdinId, type, title, payload, res, project
232
243
  }
233
244
  });
234
245
  }
235
- exports.runAsJob = runAsJob;
236
246
  function reRunInProgressJobs(config) {
237
247
  return __awaiter(this, void 0, void 0, function* () {
238
248
  const storage = (0, storage_1.getStorage)();
@@ -311,4 +321,3 @@ function reRunInProgressJobs(config) {
311
321
  })));
312
322
  });
313
323
  }
314
- exports.reRunInProgressJobs = reRunInProgressJobs;
@@ -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.createOrUpdateFileSnapshot = exports.getIntegrationSnapshot = exports.getCrowdinSnapshot = void 0;
12
+ exports.getCrowdinSnapshot = getCrowdinSnapshot;
13
+ exports.getIntegrationSnapshot = getIntegrationSnapshot;
14
+ exports.createOrUpdateFileSnapshot = createOrUpdateFileSnapshot;
13
15
  const types_1 = require("../types");
14
16
  const storage_1 = require("../../../storage");
15
17
  const defaults_1 = require("./defaults");
@@ -29,7 +31,6 @@ function getCrowdinSnapshot(config, integration, crowdinApiClient, projectId, in
29
31
  return files;
30
32
  });
31
33
  }
32
- exports.getCrowdinSnapshot = getCrowdinSnapshot;
33
34
  function getTreeItems(integrationData) {
34
35
  let files = [];
35
36
  if ((0, files_1.isExtendedResultType)(integrationData)) {
@@ -63,9 +64,9 @@ function getOneLevelFetchingFiles(integration, integrationCredentials, integrati
63
64
  return parentFiles;
64
65
  });
65
66
  }
66
- function getIntegrationSnapshot({ integration, integrationCredentials, integrationSettings, client, projectId, }) {
67
- var _a;
68
- return __awaiter(this, void 0, void 0, function* () {
67
+ function getIntegrationSnapshot(_a) {
68
+ return __awaiter(this, arguments, void 0, function* ({ integration, integrationCredentials, integrationSettings, client, projectId, }) {
69
+ var _b;
69
70
  let files = [];
70
71
  let integrationData = [];
71
72
  integrationData = yield integration.getIntegrationFiles({
@@ -81,7 +82,7 @@ function getIntegrationSnapshot({ integration, integrationCredentials, integrati
81
82
  files = yield getOneLevelFetchingFiles(integration, integrationCredentials, integrationSettings, files, client, projectId);
82
83
  }
83
84
  if ((integrationSettings === null || integrationSettings === void 0 ? void 0 : integrationSettings.skipIntegrationNodesToggle) === true ||
84
- ((integrationSettings === null || integrationSettings === void 0 ? void 0 : integrationSettings.skipIntegrationNodesToggle) === null && ((_a = integration.skipIntegrationNodesToggle) === null || _a === void 0 ? void 0 : _a.value))) {
85
+ ((integrationSettings === null || integrationSettings === void 0 ? void 0 : integrationSettings.skipIntegrationNodesToggle) === null && ((_b = integration.skipIntegrationNodesToggle) === null || _b === void 0 ? void 0 : _b.value))) {
85
86
  files = (0, files_1.skipFilesByRegex)(files, integration.skipIntegrationNodes);
86
87
  }
87
88
  // trick for compatibility in requests and set files
@@ -89,7 +90,6 @@ function getIntegrationSnapshot({ integration, integrationCredentials, integrati
89
90
  return files;
90
91
  });
91
92
  }
92
- exports.getIntegrationSnapshot = getIntegrationSnapshot;
93
93
  function createOrUpdateFileSnapshot(config, integration, req, provider) {
94
94
  return __awaiter(this, void 0, void 0, function* () {
95
95
  let files = [];
@@ -116,4 +116,3 @@ function createOrUpdateFileSnapshot(config, integration, req, provider) {
116
116
  }
117
117
  });
118
118
  }
119
- exports.createOrUpdateFileSnapshot = createOrUpdateFileSnapshot;
@@ -8,7 +8,7 @@ var JobType;
8
8
  JobType["UPDATE_TARGET_LANGUAGES"] = "updateTargetLanguages";
9
9
  JobType["CROWDIN_SYNC_SETTINGS_SAVE"] = "crowdinSyncSettingsSave";
10
10
  JobType["INTEGRATION_SYNC_SETTINGS_SAVE"] = "integrationSyncSettingsSave";
11
- })(JobType = exports.JobType || (exports.JobType = {}));
11
+ })(JobType || (exports.JobType = JobType = {}));
12
12
  var JobStatus;
13
13
  (function (JobStatus) {
14
14
  JobStatus["CREATED"] = "created";
@@ -16,10 +16,10 @@ var JobStatus;
16
16
  JobStatus["FINISHED"] = "finished";
17
17
  JobStatus["FAILED"] = "failed";
18
18
  JobStatus["CANCELED"] = "canceled";
19
- })(JobStatus = exports.JobStatus || (exports.JobStatus = {}));
19
+ })(JobStatus || (exports.JobStatus = JobStatus = {}));
20
20
  var JobClientType;
21
21
  (function (JobClientType) {
22
22
  JobClientType["CRON"] = "cron";
23
23
  JobClientType["MANUAL"] = "manual";
24
24
  JobClientType["RERUN"] = "rerun";
25
- })(JobClientType = exports.JobClientType || (exports.JobClientType = {}));
25
+ })(JobClientType || (exports.JobClientType = JobClientType = {}));