@crowdin/app-project-module 0.43.1 → 0.45.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 (193) hide show
  1. package/out/index.d.ts +3 -3
  2. package/out/index.js +103 -219
  3. package/out/middlewares/crowdin-client.d.ts +1 -1
  4. package/out/middlewares/crowdin-client.js +3 -2
  5. package/out/middlewares/integration-credentials.d.ts +3 -2
  6. package/out/middlewares/render-ui-module.d.ts +2 -2
  7. package/out/middlewares/ui-module.d.ts +2 -2
  8. package/out/middlewares/ui-module.js +5 -1
  9. package/out/{util → modules}/api/api.d.ts +3 -2
  10. package/out/{util → modules}/api/api.js +22 -22
  11. package/out/modules/api/index.d.ts +6 -0
  12. package/out/modules/api/index.js +14 -0
  13. package/out/modules/api/types.d.ts +20 -0
  14. package/out/modules/api/types.js +11 -0
  15. package/out/modules/context-menu/index.d.ts +6 -0
  16. package/out/modules/context-menu/index.js +17 -0
  17. package/out/modules/context-menu/types.d.ts +27 -0
  18. package/out/modules/context-menu/types.js +18 -0
  19. package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
  20. package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
  21. package/out/modules/custom-mt/index.d.ts +6 -0
  22. package/out/modules/custom-mt/index.js +17 -0
  23. package/out/modules/custom-mt/types.d.ts +22 -0
  24. package/out/modules/custom-mt/types.js +2 -0
  25. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
  26. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
  27. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
  28. package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
  29. package/out/modules/custom-spell-check/index.d.ts +6 -0
  30. package/out/modules/custom-spell-check/index.js +32 -0
  31. package/out/modules/custom-spell-check/types.d.ts +56 -0
  32. package/out/modules/custom-spell-check/types.js +2 -0
  33. package/out/modules/editor-right-panel/index.d.ts +6 -0
  34. package/out/modules/editor-right-panel/index.js +17 -0
  35. package/out/modules/editor-right-panel/types.d.ts +7 -0
  36. package/out/modules/editor-right-panel/types.js +2 -0
  37. package/out/modules/editor-themes/index.d.ts +6 -0
  38. package/out/modules/editor-themes/index.js +11 -0
  39. package/out/modules/editor-themes/types.d.ts +17 -0
  40. package/out/modules/editor-themes/types.js +2 -0
  41. package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
  42. package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
  43. package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
  44. package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
  45. package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
  46. package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
  47. package/out/modules/file-processing/index.d.ts +22 -0
  48. package/out/modules/file-processing/index.js +57 -0
  49. package/out/modules/file-processing/types.d.ts +133 -0
  50. package/out/modules/file-processing/types.js +12 -0
  51. package/out/modules/file-processing/util/defaults.d.ts +3 -0
  52. package/out/modules/file-processing/util/defaults.js +30 -0
  53. package/out/modules/file-processing/util/files.d.ts +6 -0
  54. package/out/modules/file-processing/util/files.js +47 -0
  55. package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
  56. package/out/modules/form-data-save.d.ts +4 -0
  57. package/out/modules/install.d.ts +4 -0
  58. package/out/{handlers → modules}/install.js +3 -3
  59. package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
  60. package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
  61. package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
  62. package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
  63. package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
  64. package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
  65. package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
  66. package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +9 -9
  67. package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
  68. package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +19 -8
  69. package/out/modules/integration/handlers/integration-data.d.ts +4 -0
  70. package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +5 -5
  71. package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
  72. package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
  73. package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
  74. package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +14 -7
  75. package/out/modules/integration/handlers/integration-update.d.ts +5 -0
  76. package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +9 -8
  77. package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
  78. package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +9 -4
  79. package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
  80. package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +4 -4
  81. package/out/modules/integration/handlers/job-info.d.ts +3 -0
  82. package/out/{handlers/integration → modules/integration/handlers}/job-info.js +4 -4
  83. package/out/modules/integration/handlers/main.d.ts +5 -0
  84. package/out/{handlers/integration → modules/integration/handlers}/main.js +5 -5
  85. package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
  86. package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
  87. package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
  88. package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
  89. package/out/modules/integration/handlers/settings-save.d.ts +5 -0
  90. package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +28 -11
  91. package/out/modules/integration/handlers/settings.d.ts +3 -0
  92. package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
  93. package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
  94. package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +2 -2
  95. package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
  96. package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +16 -8
  97. package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
  98. package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
  99. package/out/modules/integration/handlers/user-errors.d.ts +3 -0
  100. package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
  101. package/out/modules/integration/index.d.ts +6 -0
  102. package/out/modules/integration/index.js +118 -0
  103. package/out/modules/integration/types.d.ts +435 -0
  104. package/out/modules/integration/types.js +19 -0
  105. package/out/modules/integration/util/cron.d.ts +27 -0
  106. package/out/{util → modules/integration/util}/cron.js +97 -28
  107. package/out/{util → modules/integration/util}/defaults.d.ts +2 -3
  108. package/out/{util → modules/integration/util}/defaults.js +1 -36
  109. package/out/modules/integration/util/files.d.ts +5 -0
  110. package/out/{util → modules/integration/util}/files.js +9 -40
  111. package/out/{util → modules/integration/util}/job.d.ts +1 -1
  112. package/out/{util → modules/integration/util}/job.js +11 -11
  113. package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -3
  114. package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +6 -65
  115. package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
  116. package/out/modules/integration/util/webhooks.d.ts +48 -0
  117. package/out/{util → modules/integration/util}/webhooks.js +95 -49
  118. package/out/modules/manifest.d.ts +3 -0
  119. package/out/{handlers → modules}/manifest.js +22 -16
  120. package/out/modules/modal/index.d.ts +6 -0
  121. package/out/modules/modal/index.js +17 -0
  122. package/out/modules/organization-menu/index.d.ts +6 -0
  123. package/out/modules/organization-menu/index.js +18 -0
  124. package/out/modules/profile-resources-menu/index.d.ts +6 -0
  125. package/out/modules/profile-resources-menu/index.js +18 -0
  126. package/out/modules/project-menu/index.d.ts +6 -0
  127. package/out/modules/project-menu/index.js +17 -0
  128. package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
  129. package/out/modules/project-menu-crowdsource/index.js +17 -0
  130. package/out/modules/project-reports/index.d.ts +6 -0
  131. package/out/modules/project-reports/index.js +18 -0
  132. package/out/modules/project-tools/index.d.ts +6 -0
  133. package/out/modules/project-tools/index.js +18 -0
  134. package/out/modules/subscription-paid.d.ts +3 -0
  135. package/out/{handlers → modules}/subscription-paid.js +2 -2
  136. package/out/modules/uninstall.d.ts +4 -0
  137. package/out/{handlers → modules}/uninstall.js +6 -2
  138. package/out/storage/index.d.ts +5 -3
  139. package/out/storage/mysql.d.ts +4 -2
  140. package/out/storage/mysql.js +3 -3
  141. package/out/storage/postgre.d.ts +4 -2
  142. package/out/storage/postgre.js +3 -3
  143. package/out/storage/sqlite.d.ts +4 -2
  144. package/out/storage/sqlite.js +3 -3
  145. package/out/storage/types.d.ts +9 -0
  146. package/out/storage/types.js +2 -0
  147. package/out/types.d.ts +374 -0
  148. package/out/types.js +59 -0
  149. package/out/util/connection.d.ts +2 -9
  150. package/out/util/connection.js +54 -150
  151. package/out/util/handlebars.d.ts +1 -0
  152. package/out/util/handlebars.js +34 -0
  153. package/out/util/index.d.ts +2 -2
  154. package/out/util/index.js +6 -6
  155. package/out/util/logger.d.ts +2 -2
  156. package/out/util/subscription.d.ts +9 -0
  157. package/out/util/subscription.js +111 -0
  158. package/package.json +1 -1
  159. package/out/handlers/file-processing/file-download.d.ts +0 -4
  160. package/out/handlers/form-data-display.d.ts +0 -3
  161. package/out/handlers/form-data-save.d.ts +0 -3
  162. package/out/handlers/install.d.ts +0 -4
  163. package/out/handlers/integration/crowdin-files.d.ts +0 -4
  164. package/out/handlers/integration/crowdin-update.d.ts +0 -4
  165. package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
  166. package/out/handlers/integration/integration-data.d.ts +0 -4
  167. package/out/handlers/integration/integration-logout.d.ts +0 -4
  168. package/out/handlers/integration/integration-update.d.ts +0 -4
  169. package/out/handlers/integration/integration-webhook.d.ts +0 -4
  170. package/out/handlers/integration/job-cancel.d.ts +0 -3
  171. package/out/handlers/integration/job-info.d.ts +0 -3
  172. package/out/handlers/integration/main.d.ts +0 -4
  173. package/out/handlers/integration/oauth-login.d.ts +0 -4
  174. package/out/handlers/integration/settings-save.d.ts +0 -4
  175. package/out/handlers/integration/settings.d.ts +0 -3
  176. package/out/handlers/integration/sync-settings-save.d.ts +0 -4
  177. package/out/handlers/integration/sync-settings.d.ts +0 -3
  178. package/out/handlers/integration/user-errors.d.ts +0 -3
  179. package/out/handlers/manifest.d.ts +0 -3
  180. package/out/handlers/subscription-paid.d.ts +0 -3
  181. package/out/handlers/uninstall.d.ts +0 -4
  182. package/out/models/index.d.ts +0 -1088
  183. package/out/models/index.js +0 -106
  184. package/out/util/cron.d.ts +0 -7
  185. package/out/util/files.d.ts +0 -9
  186. package/out/util/webhooks.d.ts +0 -28
  187. /package/out/{util → modules}/api/base.d.ts +0 -0
  188. /package/out/{util → modules}/api/base.js +0 -0
  189. /package/out/{util → modules}/api/components.d.ts +0 -0
  190. /package/out/{util → modules}/api/components.js +0 -0
  191. /package/out/{handlers → modules}/form-data-display.js +0 -0
  192. /package/out/{handlers → modules}/form-data-save.js +0 -0
  193. /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
@@ -0,0 +1,3 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ export default function handle(): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,9 +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
- const job_1 = require("../../models/job");
13
- const util_1 = require("../../util");
14
- const storage_1 = require("../../storage");
12
+ const types_1 = require("../util/types");
13
+ const util_1 = require("../../../util");
14
+ const storage_1 = require("../../../storage");
15
15
  function handle() {
16
16
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
17
17
  const id = req.query.job_id || req.body.job_id;
@@ -21,7 +21,7 @@ function handle() {
21
21
  return;
22
22
  }
23
23
  req.logInfo(`User has been canceled the job id: ${id}`);
24
- yield (0, storage_1.getStorage)().updateJob({ id, status: job_1.JobStatus.CANCELED });
24
+ yield (0, storage_1.getStorage)().updateJob({ id, status: types_1.JobStatus.CANCELED });
25
25
  res.sendStatus(204);
26
26
  }));
27
27
  }
@@ -0,0 +1,3 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ export default function handle(): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,9 +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
- const job_1 = require("../../models/job");
13
- const util_1 = require("../../util");
14
- const storage_1 = require("../../storage");
12
+ const types_1 = require("../util/types");
13
+ const util_1 = require("../../../util");
14
+ const storage_1 = require("../../../storage");
15
15
  function getHumanETA(ms) {
16
16
  const seconds = Math.floor(ms / 1000);
17
17
  let minutes = Math.floor(seconds / 60);
@@ -43,7 +43,7 @@ function handle() {
43
43
  }
44
44
  req.logInfo(`Get job info for id ${id}`);
45
45
  const job = yield (0, storage_1.getStorage)().getJob({ id });
46
- if (job && job.status === job_1.JobStatus.IN_PROGRESS && job.progress > 5 && job.updatedAt) {
46
+ if (job && job.status === types_1.JobStatus.IN_PROGRESS && job.progress > 5 && job.updatedAt) {
47
47
  job.eta = ((Date.now() - job.createdAt) / job.progress) * (100 - job.progress);
48
48
  job.info = getHumanETA(job.eta) + (job.info ? `\n${job.info}` : '');
49
49
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ import { Config } from '../../../types';
4
+ import { IntegrationLogic } from '../types';
5
+ export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../../util");
13
- const connection_1 = require("../../util/connection");
14
- const defaults_1 = require("../../util/defaults");
15
- const logger_1 = require("../../util/logger");
12
+ const util_1 = require("../../../util");
13
+ const logger_1 = require("../../../util/logger");
14
+ const subscription_1 = require("../../../util/subscription");
15
+ const defaults_1 = require("../util/defaults");
16
16
  function handle(config, integration) {
17
17
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
18
18
  var _a, _b;
@@ -57,7 +57,7 @@ function handle(config, integration) {
57
57
  : {};
58
58
  options.integrationOneLevelFetching = integration.integrationOneLevelFetching;
59
59
  options.integrationSearchListener = integration.integrationSearchListener;
60
- options.checkSubscription = !(0, connection_1.isAppFree)(config);
60
+ options.checkSubscription = !(0, subscription_1.isAppFree)(config);
61
61
  options.uploadTranslations = integration.uploadTranslations;
62
62
  options.sentryData = process.env.SENTRY_DSN
63
63
  ? {
@@ -0,0 +1,5 @@
1
+ /// <reference types="qs" />
2
+ import { Request, Response } from 'express';
3
+ import { Config } from '../../../types';
4
+ import { IntegrationLogic } from '../types';
5
+ export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -13,9 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const axios_1 = __importDefault(require("axios"));
16
- const util_1 = require("../../util");
17
- const defaults_1 = require("../../util/defaults");
18
- const logger_1 = require("../../util/logger");
16
+ const util_1 = require("../../../util");
17
+ const defaults_1 = require("../util/defaults");
18
+ const logger_1 = require("../../../util/logger");
19
19
  function handle(config, integration) {
20
20
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
21
21
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config, CrowdinClientRequest, IntegrationLogic } from '../../models';
3
+ import { Config, CrowdinClientRequest } from '../../../types';
4
+ import { IntegrationLogic } from '../types';
4
5
  export default function handle(config: Config, integration: IntegrationLogic): (req: CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../../util");
13
- const defaults_1 = require("../../util/defaults");
12
+ const util_1 = require("../../../util");
13
+ const defaults_1 = require("../util/defaults");
14
14
  function handle(config, integration) {
15
15
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
16
  req.logInfo('Received OAuth login url request');
@@ -0,0 +1,5 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ import { Config } from '../../../types';
4
+ import { IntegrationLogic } from '../types';
5
+ export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,12 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const models_1 = require("../../models");
13
- const storage_1 = require("../../storage");
14
- const util_1 = require("../../util");
15
- const cron_1 = require("../../util/cron");
16
- const file_snapshot_1 = require("../../util/file-snapshot");
17
- const webhooks_1 = require("../../util/webhooks");
12
+ const storage_1 = require("../../../storage");
13
+ const util_1 = require("../../../util");
14
+ const snapshot_1 = require("../util/snapshot");
15
+ const webhooks_1 = require("../util/webhooks");
16
+ const types_1 = require("../types");
17
+ const cron_1 = require("../util/cron");
18
18
  function handle(config, integration) {
19
19
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
20
20
  const appSettings = req.body.config;
@@ -28,19 +28,36 @@ function handle(config, integration) {
28
28
  yield (0, storage_1.getStorage)().updateIntegrationConfig(clientId, JSON.stringify(appSettings));
29
29
  }
30
30
  if (integration.webhooks) {
31
- yield (0, webhooks_1.registerWebhooks)(config, integration, req.crowdinApiClient, req.crowdinContext, req.integrationCredentials, appSettings);
31
+ yield (0, webhooks_1.registerWebhooks)({
32
+ config,
33
+ integration,
34
+ client: req.crowdinApiClient,
35
+ crowdinContext: req.crowdinContext,
36
+ apiCredentials: req.integrationCredentials,
37
+ appSettings,
38
+ });
32
39
  }
33
40
  else {
34
41
  if (appSettings['new-crowdin-files']) {
35
- (0, file_snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, models_1.Provider.CROWDIN);
42
+ (0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, types_1.Provider.CROWDIN);
36
43
  }
37
44
  if (appSettings['new-integration-files']) {
38
- (0, file_snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, models_1.Provider.INTEGRATION);
45
+ (0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, types_1.Provider.INTEGRATION);
39
46
  }
40
47
  }
41
48
  if (integration.syncNewElements) {
42
- yield (0, cron_1.createOrUpdateSyncSettings)(config, req, {}, models_1.Provider.CROWDIN, true);
43
- yield (0, cron_1.createOrUpdateSyncSettings)(config, req, [], models_1.Provider.INTEGRATION, true);
49
+ yield (0, cron_1.createOrUpdateSyncSettings)({
50
+ req,
51
+ files: {},
52
+ provider: types_1.Provider.CROWDIN,
53
+ onlyCreate: true,
54
+ });
55
+ yield (0, cron_1.createOrUpdateSyncSettings)({
56
+ req,
57
+ files: [],
58
+ provider: types_1.Provider.INTEGRATION,
59
+ onlyCreate: true,
60
+ });
44
61
  }
45
62
  res.status(204).end();
46
63
  }));
@@ -0,0 +1,3 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ export default function handle(): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const util_1 = require("../../util");
12
+ const util_1 = require("../../../util");
13
13
  function handle() {
14
14
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
15
15
  let settings = {};
@@ -1,3 +1,3 @@
1
1
  import { Request, Response } from 'express';
2
- import { Config } from '../../models';
2
+ import { Config } from '../../../types';
3
3
  export default function handle(config: Config): (req: Request, res: Response) => void;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const models_1 = require("../../models");
3
+ const types_1 = require("../../../types");
4
4
  function handle(config) {
5
5
  return (req, res) => {
6
6
  var _a;
7
7
  const subscriptionInfo = req.subscriptionInfo;
8
- let showInfo = (subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.type) === models_1.SubscriptionInfoType.TRIAL;
8
+ let showInfo = (subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.type) === types_1.SubscriptionInfoType.TRIAL;
9
9
  if (showInfo && ((_a = config.pricing) === null || _a === void 0 ? void 0 : _a.infoDisplayDaysThreshold)) {
10
10
  showInfo = config.pricing.infoDisplayDaysThreshold >= ((subscriptionInfo === null || subscriptionInfo === void 0 ? void 0 : subscriptionInfo.daysLeft) || 0);
11
11
  }
@@ -0,0 +1,5 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ import { Config } from '../../../types';
4
+ import { IntegrationLogic } from '../types';
5
+ export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -13,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const lodash_uniqby_1 = __importDefault(require("lodash.uniqby"));
16
- const util_1 = require("../../util");
17
- const cron_1 = require("../../util/cron");
18
- const file_snapshot_1 = require("../../util/file-snapshot");
19
- const files_1 = require("../../util/files");
20
- const job_1 = require("../../util/job");
16
+ const util_1 = require("../../../util");
17
+ const cron_1 = require("../util/cron");
18
+ const snapshot_1 = require("../util/snapshot");
19
+ const files_1 = require("../util/files");
20
+ const job_1 = require("../util/job");
21
21
  function handle(config, integration) {
22
22
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
23
23
  const { files, provider, expandIntegrationFolders } = req.body;
@@ -42,14 +42,22 @@ function handle(config, integration) {
42
42
  sync: false,
43
43
  type: node.type,
44
44
  }));
45
- yield (0, cron_1.createOrUpdateSyncSettings)(config, req, (0, lodash_uniqby_1.default)([...files, ...allFiles], 'id'), provider);
45
+ yield (0, cron_1.createOrUpdateSyncSettings)({
46
+ req,
47
+ files: (0, lodash_uniqby_1.default)([...files, ...allFiles], 'id'),
48
+ provider,
49
+ });
46
50
  }
47
51
  else {
48
- yield (0, cron_1.createOrUpdateSyncSettings)(config, req, files, provider);
52
+ yield (0, cron_1.createOrUpdateSyncSettings)({
53
+ req,
54
+ files,
55
+ provider,
56
+ });
49
57
  }
50
58
  const appSettings = req.integrationSettings || {};
51
59
  if (((_a = integration.syncNewElements) === null || _a === void 0 ? void 0 : _a[provider]) && appSettings[`new-${provider}-files`]) {
52
- yield (0, file_snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, provider);
60
+ yield (0, snapshot_1.createOrUpdateFileSnapshot)(config, integration, req, provider);
53
61
  }
54
62
  }),
55
63
  });
@@ -0,0 +1,3 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ export default function handle(): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const storage_1 = require("../../storage");
13
- const util_1 = require("../../util");
12
+ const storage_1 = require("../../../storage");
13
+ const util_1 = require("../../../util");
14
14
  function handle() {
15
15
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
16
  let files = {};
@@ -0,0 +1,3 @@
1
+ /// <reference types="qs" />
2
+ import { Response } from 'express';
3
+ export default function handle(): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const storage_1 = require("../../storage");
13
- const util_1 = require("../../util");
12
+ const storage_1 = require("../../../storage");
13
+ const util_1 = require("../../../util");
14
14
  function handle() {
15
15
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
16
  var _a;
@@ -0,0 +1,6 @@
1
+ import { Express } from 'express';
2
+ import { Config } from '../../types';
3
+ export declare function register({ config, app }: {
4
+ config: Config;
5
+ app: Express;
6
+ }): void;
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
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
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.register = void 0;
30
+ const cron = __importStar(require("node-cron"));
31
+ const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
32
+ const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
33
+ const json_response_1 = __importDefault(require("../../middlewares/json-response"));
34
+ const util_1 = require("../../util");
35
+ const defaults_1 = require("./util/defaults");
36
+ const webhooks_1 = require("./util/webhooks");
37
+ const crowdin_file_progress_1 = __importDefault(require("./handlers/crowdin-file-progress"));
38
+ const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
39
+ const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
40
+ const crowdin_update_1 = __importDefault(require("./handlers/crowdin-update"));
41
+ const crowdin_webhook_1 = __importDefault(require("./handlers/crowdin-webhook"));
42
+ const integration_data_1 = __importDefault(require("./handlers/integration-data"));
43
+ const integration_login_1 = __importDefault(require("./handlers/integration-login"));
44
+ const integration_logout_1 = __importDefault(require("./handlers/integration-logout"));
45
+ const integration_update_1 = __importDefault(require("./handlers/integration-update"));
46
+ const integration_webhook_1 = __importDefault(require("./handlers/integration-webhook"));
47
+ const job_cancel_1 = __importDefault(require("./handlers/job-cancel"));
48
+ const job_info_1 = __importDefault(require("./handlers/job-info"));
49
+ const main_1 = __importDefault(require("./handlers/main"));
50
+ const oauth_login_1 = __importDefault(require("./handlers/oauth-login"));
51
+ const oauth_url_1 = __importDefault(require("./handlers/oauth-url"));
52
+ const settings_save_1 = __importDefault(require("./handlers/settings-save"));
53
+ const subscription_info_1 = __importDefault(require("./handlers/subscription-info"));
54
+ const sync_settings_1 = __importDefault(require("./handlers/sync-settings"));
55
+ const sync_settings_save_1 = __importDefault(require("./handlers/sync-settings-save"));
56
+ const user_errors_1 = __importDefault(require("./handlers/user-errors"));
57
+ const cron_1 = require("./util/cron");
58
+ function register({ config, app }) {
59
+ var _a, _b, _c;
60
+ const integrationLogic = config.projectIntegration;
61
+ if (!integrationLogic) {
62
+ return;
63
+ }
64
+ (0, defaults_1.applyIntegrationModuleDefaults)(config, integrationLogic);
65
+ app.get((0, util_1.getLogoUrl)(integrationLogic, '/integration'), (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath));
66
+ app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
67
+ app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
68
+ app.get('/api/jobs', json_response_1.default, (0, crowdin_client_1.default)(config), (0, job_info_1.default)());
69
+ app.delete('/api/jobs', json_response_1.default, (0, crowdin_client_1.default)(config), (0, job_cancel_1.default)());
70
+ app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config, integrationLogic));
71
+ app.post('/api/login', (0, crowdin_client_1.default)(config, false, false), (0, integration_login_1.default)(config, integrationLogic));
72
+ app.post('/api/logout', (0, crowdin_client_1.default)(config, false, false), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_logout_1.default)(config, integrationLogic));
73
+ app.get('/api/crowdin/files', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_files_1.default)(config, integrationLogic));
74
+ app.get('/api/crowdin/project', json_response_1.default, (0, crowdin_client_1.default)(config), (0, crowdin_project_1.default)());
75
+ app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(integrationLogic));
76
+ app.get('/api/integration/data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_data_1.default)(integrationLogic));
77
+ app.post('/api/crowdin/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_update_1.default)(config, integrationLogic));
78
+ app.post('/api/integration/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_update_1.default)(config, integrationLogic));
79
+ app.get('/api/sync-settings/:provider', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_1.default)());
80
+ app.post('/api/sync-settings', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_save_1.default)(config, integrationLogic));
81
+ if (integrationLogic.oauthLogin) {
82
+ app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
83
+ app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
84
+ }
85
+ if (integrationLogic.cronJobs) {
86
+ integrationLogic.cronJobs.forEach((job) => {
87
+ cron.schedule(job.expression, () => (0, cron_1.runJob)({ config, integration: integrationLogic, job }).catch(console.error));
88
+ });
89
+ }
90
+ if (integrationLogic.withCronSync) {
91
+ cron.schedule('0 * * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '1' }).catch(console.error));
92
+ cron.schedule('0 */3 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '3' }).catch(console.error));
93
+ cron.schedule('0 */6 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '6' }).catch(console.error));
94
+ cron.schedule('0 */12 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '12' }).catch(console.error));
95
+ cron.schedule('0 0 * * *', () => (0, cron_1.filesCron)({ config, integration: integrationLogic, period: '24' }).catch(console.error));
96
+ }
97
+ if (integrationLogic.webhooks) {
98
+ app.post(`${integrationLogic.webhooks.crowdinWebhookUrl
99
+ ? integrationLogic.webhooks.crowdinWebhookUrl
100
+ : '/api/crowdin/webhook'}`, json_response_1.default, (0, crowdin_webhook_1.default)(config, integrationLogic));
101
+ if (((_a = integrationLogic.webhooks) === null || _a === void 0 ? void 0 : _a.integrationWebhookInterceptor) && !((_b = integrationLogic.webhooks) === null || _b === void 0 ? void 0 : _b.queueUrl)) {
102
+ app.post(`${integrationLogic.webhooks.integrationWebhookUrl
103
+ ? integrationLogic.webhooks.integrationWebhookUrl
104
+ : '/api/integration/webhook'}`, (0, integration_webhook_1.default)(config, integrationLogic));
105
+ }
106
+ if ((_c = integrationLogic.webhooks) === null || _c === void 0 ? void 0 : _c.queueUrl) {
107
+ (0, webhooks_1.listenQueueMessage)({
108
+ config,
109
+ integration: integrationLogic,
110
+ queueUrl: integrationLogic.webhooks.queueUrl,
111
+ queueName: config.identifier,
112
+ });
113
+ }
114
+ }
115
+ app.get('/api/user-errors', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, user_errors_1.default)());
116
+ cron.schedule('0 0 1 * *', () => (0, cron_1.removeFinishedJobs)());
117
+ }
118
+ exports.register = register;