@crowdin/app-project-module 0.44.0 → 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 (149) hide show
  1. package/out/index.d.ts +3 -3
  2. package/out/index.js +52 -59
  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 +2 -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 +3 -3
  9. package/out/{util → modules}/api/api.d.ts +2 -1
  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 +1 -1
  16. package/out/modules/context-menu/index.js +2 -2
  17. package/out/modules/context-menu/types.d.ts +27 -0
  18. package/out/modules/context-menu/types.js +18 -0
  19. package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
  20. package/out/modules/custom-mt/index.d.ts +1 -1
  21. package/out/modules/custom-mt/types.d.ts +1 -1
  22. package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
  23. package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
  24. package/out/modules/custom-spell-check/index.d.ts +1 -1
  25. package/out/modules/custom-spell-check/index.js +2 -2
  26. package/out/modules/custom-spell-check/types.d.ts +1 -1
  27. package/out/modules/editor-right-panel/index.d.ts +1 -1
  28. package/out/modules/editor-right-panel/index.js +2 -2
  29. package/out/modules/editor-right-panel/types.d.ts +1 -1
  30. package/out/modules/editor-themes/index.d.ts +1 -1
  31. package/out/modules/editor-themes/types.d.ts +17 -0
  32. package/out/modules/editor-themes/types.js +2 -0
  33. package/out/modules/file-processing/handlers/custom-file-format.d.ts +1 -1
  34. package/out/modules/file-processing/handlers/custom-file-format.js +1 -1
  35. package/out/modules/file-processing/handlers/file-download.d.ts +2 -2
  36. package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
  37. package/out/modules/file-processing/handlers/pre-post-process.js +1 -1
  38. package/out/modules/file-processing/index.d.ts +1 -1
  39. package/out/modules/file-processing/index.js +1 -1
  40. package/out/modules/file-processing/types.d.ts +1 -1
  41. package/out/modules/file-processing/util/defaults.d.ts +3 -0
  42. package/out/modules/file-processing/util/defaults.js +30 -0
  43. package/out/modules/file-processing/util/files.d.ts +6 -0
  44. package/out/modules/file-processing/util/files.js +47 -0
  45. package/out/modules/form-data-display.d.ts +1 -1
  46. package/out/modules/form-data-save.d.ts +1 -1
  47. package/out/modules/install.d.ts +2 -2
  48. package/out/modules/install.js +3 -3
  49. package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
  50. package/out/modules/integration/handlers/crowdin-files.d.ts +2 -2
  51. package/out/modules/integration/handlers/crowdin-files.js +1 -1
  52. package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
  53. package/out/modules/integration/handlers/crowdin-update.d.ts +2 -2
  54. package/out/modules/integration/handlers/crowdin-update.js +7 -7
  55. package/out/modules/integration/handlers/crowdin-webhook.d.ts +2 -2
  56. package/out/modules/integration/handlers/crowdin-webhook.js +16 -5
  57. package/out/modules/integration/handlers/integration-data.d.ts +1 -1
  58. package/out/modules/integration/handlers/integration-data.js +2 -2
  59. package/out/modules/integration/handlers/integration-login.d.ts +1 -1
  60. package/out/modules/integration/handlers/integration-logout.d.ts +2 -2
  61. package/out/modules/integration/handlers/integration-logout.js +11 -4
  62. package/out/modules/integration/handlers/integration-update.d.ts +2 -2
  63. package/out/modules/integration/handlers/integration-update.js +7 -6
  64. package/out/modules/integration/handlers/integration-webhook.d.ts +2 -2
  65. package/out/modules/integration/handlers/integration-webhook.js +7 -2
  66. package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
  67. package/out/modules/integration/handlers/job-cancel.js +2 -2
  68. package/out/modules/integration/handlers/job-info.d.ts +1 -1
  69. package/out/modules/integration/handlers/job-info.js +2 -2
  70. package/out/modules/integration/handlers/main.d.ts +2 -2
  71. package/out/modules/integration/handlers/main.js +3 -3
  72. package/out/modules/integration/handlers/oauth-login.d.ts +2 -2
  73. package/out/modules/integration/handlers/oauth-login.js +1 -1
  74. package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
  75. package/out/modules/integration/handlers/oauth-url.js +1 -1
  76. package/out/modules/integration/handlers/settings-save.d.ts +2 -2
  77. package/out/modules/integration/handlers/settings-save.js +25 -8
  78. package/out/modules/integration/handlers/settings.d.ts +1 -1
  79. package/out/modules/integration/handlers/subscription-info.d.ts +1 -1
  80. package/out/modules/integration/handlers/subscription-info.js +2 -2
  81. package/out/modules/integration/handlers/sync-settings-save.d.ts +2 -2
  82. package/out/modules/integration/handlers/sync-settings-save.js +15 -7
  83. package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
  84. package/out/modules/integration/handlers/user-errors.d.ts +1 -1
  85. package/out/modules/integration/index.d.ts +1 -1
  86. package/out/modules/integration/index.js +15 -10
  87. package/out/modules/integration/types.d.ts +2 -13
  88. package/out/modules/integration/util/cron.d.ts +27 -0
  89. package/out/{util → modules/integration/util}/cron.js +92 -23
  90. package/out/{util → modules/integration/util}/defaults.d.ts +2 -6
  91. package/out/{util → modules/integration/util}/defaults.js +1 -46
  92. package/out/modules/integration/util/files.d.ts +5 -0
  93. package/out/{util → modules/integration/util}/files.js +9 -40
  94. package/out/{util → modules/integration/util}/job.d.ts +1 -1
  95. package/out/{util → modules/integration/util}/job.js +11 -11
  96. package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -4
  97. package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +4 -63
  98. package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
  99. package/out/modules/integration/util/webhooks.d.ts +48 -0
  100. package/out/{util → modules/integration/util}/webhooks.js +92 -46
  101. package/out/modules/manifest.d.ts +1 -1
  102. package/out/modules/manifest.js +6 -6
  103. package/out/modules/modal/index.d.ts +1 -1
  104. package/out/modules/modal/index.js +2 -2
  105. package/out/modules/organization-menu/index.d.ts +1 -1
  106. package/out/modules/organization-menu/index.js +1 -2
  107. package/out/modules/profile-resources-menu/index.d.ts +1 -1
  108. package/out/modules/profile-resources-menu/index.js +1 -2
  109. package/out/modules/project-menu/index.d.ts +1 -1
  110. package/out/modules/project-menu/index.js +2 -2
  111. package/out/modules/project-menu-crowdsource/index.d.ts +1 -1
  112. package/out/modules/project-menu-crowdsource/index.js +2 -2
  113. package/out/modules/project-reports/index.d.ts +1 -1
  114. package/out/modules/project-reports/index.js +1 -2
  115. package/out/modules/project-tools/index.d.ts +1 -1
  116. package/out/modules/project-tools/index.js +1 -2
  117. package/out/modules/subscription-paid.d.ts +1 -1
  118. package/out/modules/subscription-paid.js +2 -2
  119. package/out/modules/uninstall.d.ts +2 -2
  120. package/out/modules/uninstall.js +6 -2
  121. package/out/storage/index.d.ts +3 -2
  122. package/out/storage/mysql.d.ts +3 -2
  123. package/out/storage/mysql.js +3 -3
  124. package/out/storage/postgre.d.ts +3 -2
  125. package/out/storage/postgre.js +3 -3
  126. package/out/storage/sqlite.d.ts +3 -2
  127. package/out/storage/sqlite.js +3 -3
  128. package/out/storage/types.d.ts +9 -0
  129. package/out/storage/types.js +2 -0
  130. package/out/{models/index.d.ts → types.d.ts} +15 -83
  131. package/out/{models/index.js → types.js} +1 -24
  132. package/out/util/connection.d.ts +1 -9
  133. package/out/util/connection.js +54 -150
  134. package/out/util/handlebars.d.ts +1 -0
  135. package/out/util/handlebars.js +34 -0
  136. package/out/util/index.d.ts +2 -3
  137. package/out/util/index.js +6 -6
  138. package/out/util/logger.d.ts +1 -1
  139. package/out/util/subscription.d.ts +9 -0
  140. package/out/util/subscription.js +111 -0
  141. package/package.json +1 -1
  142. package/out/util/cron.d.ts +0 -8
  143. package/out/util/files.d.ts +0 -10
  144. package/out/util/webhooks.d.ts +0 -29
  145. /package/out/{util → modules}/api/base.d.ts +0 -0
  146. /package/out/{util → modules}/api/base.js +0 -0
  147. /package/out/{util → modules}/api/components.d.ts +0 -0
  148. /package/out/{util → modules}/api/components.js +0 -0
  149. /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.register = void 0;
7
7
  const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
8
8
  const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
- const defaults_1 = require("../../util/defaults");
9
+ const util_1 = require("../../util");
10
10
  function register({ config, app }) {
11
11
  if (!config.editorRightPanel) {
12
12
  return;
13
13
  }
14
- const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
14
+ const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
15
  app.use('/editor-panels', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.editorRightPanel));
16
16
  }
17
17
  exports.register = register;
@@ -1,4 +1,4 @@
1
- import { EditorMode, UiModule } from '../../models';
1
+ import { EditorMode, UiModule } from '../../types';
2
2
  export interface EditorPanels extends UiModule {
3
3
  /**
4
4
  * The Editor's mode list where the module will be available.
@@ -1,5 +1,5 @@
1
1
  import { Express } from 'express';
2
- import { Config, UnauthorizedConfig } from '../../models';
2
+ import { Config, UnauthorizedConfig } from '../../types';
3
3
  export declare function register({ config, app }: {
4
4
  config: Config | UnauthorizedConfig;
5
5
  app: Express;
@@ -0,0 +1,17 @@
1
+ import { EditorMode } from '../../types';
2
+ export interface EditorThemes {
3
+ /**
4
+ * Module name
5
+ */
6
+ name?: string;
7
+ /**
8
+ * Defines a set of CSS custom variables for theming purposes
9
+ */
10
+ styles: {
11
+ [key: string]: string;
12
+ };
13
+ /**
14
+ * The Editor's mode list where the module will be available.
15
+ */
16
+ modes: EditorMode[];
17
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest } from '../../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
4
  import { CustomFileFormatLogic } from '../types';
5
5
  export default function handle(baseUrl: string, folder: string, config: CustomFileFormatLogic): (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;
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const util_1 = require("../../../util");
18
- const files_1 = require("../../../util/files");
18
+ const files_1 = require("../util/files");
19
19
  const types_1 = require("../types");
20
20
  function handle(baseUrl, folder, config) {
21
21
  if (!fs_1.default.existsSync(path_1.default.join(folder, 'custom-file-format'))) {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Request, Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { FileProcessLogic } from '../types';
5
- export default function handle(config: Config, processingConfig: FileProcessLogic, folderName: string): (req: import("../../../models").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;
5
+ export default function handle(config: Config, processingConfig: FileProcessLogic, folderName: string): (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;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config, CrowdinClientRequest } from '../../../models';
3
+ import { Config, CrowdinClientRequest } from '../../../types';
4
4
  import { FileImportExportLogic } from '../types';
5
5
  export default function handle(baseConfig: Config, config: FileImportExportLogic, folderName: string): (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;
@@ -15,8 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
17
  const util_1 = require("../../../util");
18
- const files_1 = require("../../../util/files");
19
18
  const types_1 = require("../types");
19
+ const files_1 = require("../util/files");
20
20
  function handle(baseConfig, config, folderName) {
21
21
  const folderPath = config.filesFolder || baseConfig.dbFolder;
22
22
  if (!fs_1.default.existsSync(path_1.default.join(folderPath, folderName))) {
@@ -1,5 +1,5 @@
1
1
  import { Express } from 'express';
2
- import { Config } from '../../models';
2
+ import { Config } from '../../types';
3
3
  export declare function registerCustomFileFormat({ config, app }: {
4
4
  config: Config;
5
5
  app: Express;
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.registerFilePostExport = exports.registerFilePreExport = exports.registerFilePostImport = exports.registerFilePreImport = exports.registerCustomFileFormat = void 0;
7
7
  const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
8
- const defaults_1 = require("../../util/defaults");
9
8
  const custom_file_format_1 = __importDefault(require("./handlers/custom-file-format"));
10
9
  const file_download_1 = __importDefault(require("./handlers/file-download"));
11
10
  const pre_post_process_1 = __importDefault(require("./handlers/pre-post-process"));
12
11
  const types_1 = require("./types");
12
+ const defaults_1 = require("./util/defaults");
13
13
  function registerCustomFileFormat({ config, app }) {
14
14
  if (!config.customFileFormat) {
15
15
  return;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import Crowdin, { LanguagesModel, SourceStringsModel } from '@crowdin/crowdin-api-client';
3
- import { CrowdinContextInfo, SignaturePatterns } from '../../models';
3
+ import { CrowdinContextInfo, SignaturePatterns } from '../../types';
4
4
  export interface FileProcessLogic {
5
5
  /**
6
6
  * Folder where larger file will be temporary stored (default "{@link dbFolder}/custom-file-format")
@@ -0,0 +1,3 @@
1
+ import { Config } from '../../../types';
2
+ import { FileProcessLogic } from '../types';
3
+ export declare function applyFileProcessorsModuleDefaults(config: Config, fileModule: FileProcessLogic): void;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.applyFileProcessorsModuleDefaults = void 0;
13
+ const client_s3_1 = require("@aws-sdk/client-s3");
14
+ const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
15
+ function applyFileProcessorsModuleDefaults(config, fileModule) {
16
+ var _a, _b;
17
+ const AWS_TMP_BUCKET_NAME = (_a = config.awsConfig) === null || _a === void 0 ? void 0 : _a.tmpBucketName;
18
+ const AWS_REGION = (_b = config.awsConfig) === null || _b === void 0 ? void 0 : _b.region;
19
+ if (AWS_TMP_BUCKET_NAME && AWS_REGION && !fileModule.storeFile) {
20
+ const s3 = new client_s3_1.S3Client({ region: AWS_REGION });
21
+ fileModule.storeFile = (content) => __awaiter(this, void 0, void 0, function* () {
22
+ const fileName = `file-${config.identifier}-${Date.now()}`;
23
+ const command = new client_s3_1.PutObjectCommand({ Bucket: AWS_TMP_BUCKET_NAME, Key: fileName, Body: content });
24
+ yield s3.send(command);
25
+ const getObjectCommand = new client_s3_1.GetObjectCommand({ Bucket: AWS_TMP_BUCKET_NAME, Key: fileName });
26
+ return (0, s3_request_presigner_1.getSignedUrl)(s3, getObjectCommand, { expiresIn: 3600 });
27
+ });
28
+ }
29
+ }
30
+ exports.applyFileProcessorsModuleDefaults = applyFileProcessorsModuleDefaults;
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ import { ProcessFileString } from '../types';
3
+ export declare const MAX_BODY_SIZE: number;
4
+ export declare function storeFile(fileContent: Buffer, folder: string): Promise<string>;
5
+ export declare function getFileContent(url: string): Promise<Buffer>;
6
+ export declare function getFileStrings(url: string): Promise<ProcessFileString[]>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.getFileStrings = exports.getFileContent = exports.storeFile = exports.MAX_BODY_SIZE = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const fs_1 = __importDefault(require("fs"));
18
+ const path_1 = __importDefault(require("path"));
19
+ exports.MAX_BODY_SIZE = 4.9 * 1024 * 1024; //4.9mb
20
+ function storeFile(fileContent, folder) {
21
+ const fileName = `file${Date.now()}`;
22
+ return new Promise((res, rej) => fs_1.default.writeFile(path_1.default.join(folder, fileName), fileContent, (err) => {
23
+ if (err) {
24
+ rej(err);
25
+ }
26
+ else {
27
+ res(fileName);
28
+ }
29
+ }));
30
+ }
31
+ exports.storeFile = storeFile;
32
+ function getFileContent(url) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const response = (yield axios_1.default.get(url, { responseType: 'arraybuffer' })).data;
35
+ return response;
36
+ });
37
+ }
38
+ exports.getFileContent = getFileContent;
39
+ function getFileStrings(url) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const response = (yield axios_1.default.get(url)).data;
42
+ // the response is presented in the ndjson format
43
+ const jsonRows = response.split(/\n|\n\r/).filter(Boolean);
44
+ return jsonRows.map((jsonStringRow) => JSON.parse(jsonStringRow));
45
+ });
46
+ }
47
+ exports.getFileStrings = getFileStrings;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="qs" />
2
- import { CrowdinClientRequest } from '../models';
2
+ import { CrowdinClientRequest } from '../types';
3
3
  import { Response } from 'express';
4
4
  export default function handle(): (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;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="qs" />
2
- import { CrowdinClientRequest } from '../models';
2
+ import { CrowdinClientRequest } from '../types';
3
3
  import { Response } from 'express';
4
4
  export default function handle(): (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;
@@ -1,4 +1,4 @@
1
1
  /// <reference types="qs" />
2
2
  import { Request, Response } from 'express';
3
- import { Config } from '../models';
4
- export default function handle(config: Config): (req: import("../models").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;
3
+ import { Config } from '../types';
4
+ export default function handle(config: Config): (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;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
13
- const models_1 = require("../models");
13
+ const types_1 = require("../types");
14
14
  const storage_1 = require("../storage");
15
15
  const util_1 = require("../util");
16
16
  const logger_1 = require("../util/logger");
@@ -29,7 +29,7 @@ function handle(config) {
29
29
  accessToken: token.accessToken,
30
30
  refreshToken: token.refreshToken,
31
31
  expire: (Date.now() / 1000 + token.expiresIn).toString(),
32
- type: event.domain ? models_1.AccountType.ENTERPRISE : models_1.AccountType.NORMAL,
32
+ type: event.domain ? types_1.AccountType.ENTERPRISE : types_1.AccountType.NORMAL,
33
33
  };
34
34
  const existingCredentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(credentials.id);
35
35
  if (!!existingCredentials) {
@@ -47,7 +47,7 @@ exports.default = handle;
47
47
  function fetchToken(config, event) {
48
48
  var _a, _b;
49
49
  return __awaiter(this, void 0, void 0, function* () {
50
- if (config.authenticationType === models_1.AuthenticationType.CODE) {
50
+ if (config.authenticationType === types_1.AuthenticationType.CODE) {
51
51
  const token = yield (0, crowdin_apps_functions_1.generateOAuthToken)({
52
52
  clientId: config.clientId,
53
53
  clientSecret: config.clientSecret,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest } from '../../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
5
  export default function handle(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;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
- export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../models").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;
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;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const util_1 = require("../../../util");
13
- const defaults_1 = require("../../../util/defaults");
13
+ const defaults_1 = require("../util/defaults");
14
14
  const logger_1 = require("../../../util/logger");
15
15
  function handle(config, integration) {
16
16
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,4 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest } from '../../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
4
  export default function handle(): (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;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
- export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../models").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;
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,12 +13,12 @@ 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 job_1 = require("../../../models/job");
16
+ const types_1 = require("../util/types");
17
17
  const util_1 = require("../../../util");
18
- const defaults_1 = require("../../../util/defaults");
18
+ const defaults_1 = require("../util/defaults");
19
19
  const logger_1 = require("../../../util/logger");
20
- const job_2 = require("../../../util/job");
21
- const files_1 = require("../../../util/files");
20
+ const job_1 = require("../util/job");
21
+ const files_1 = require("../util/files");
22
22
  function handle(config, integration) {
23
23
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
24
24
  var _a, _b;
@@ -33,10 +33,10 @@ function handle(config, integration) {
33
33
  if (((_b = config.api) === null || _b === void 0 ? void 0 : _b.default) && req.body.files) {
34
34
  req.body = req.body.files;
35
35
  }
36
- yield (0, job_2.runAsJob)({
36
+ yield (0, job_1.runAsJob)({
37
37
  integrationId: req.crowdinContext.clientId,
38
38
  crowdinId: req.crowdinContext.crowdinId,
39
- type: job_1.JobType.UPDATE_TO_CROWDIN,
39
+ type: types_1.JobType.UPDATE_TO_CROWDIN,
40
40
  title: 'Sync files to Crowdin',
41
41
  payload: req.body,
42
42
  res,
@@ -57,7 +57,7 @@ function handle(config, integration) {
57
57
  job,
58
58
  });
59
59
  let message;
60
- if ((0, util_1.isExtendedResultType)(result)) {
60
+ if ((0, files_1.isExtendedResultType)(result)) {
61
61
  message = result.message;
62
62
  }
63
63
  return { message };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Request, Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
- export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../models").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;
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;
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const storage_1 = require("../../../storage");
13
- const logger_1 = require("../../../util/logger");
14
13
  const util_1 = require("../../../util");
15
- const cron_1 = require("../../../util/cron");
16
- const webhooks_1 = require("../../../util/webhooks");
14
+ const logger_1 = require("../../../util/logger");
15
+ const webhooks_1 = require("../util/webhooks");
17
16
  const types_1 = require("../types");
17
+ const cron_1 = require("../util/cron");
18
18
  function filterSyncFiles(args) {
19
19
  var _a, _b;
20
20
  return __awaiter(this, void 0, void 0, function* () {
@@ -71,7 +71,12 @@ function handle(config, integration) {
71
71
  const webhookUrlParam = req.query[urlParam];
72
72
  let filesToSync;
73
73
  if (webhookUrlParam) {
74
- const { projectId, crowdinClient, rootFolder, appSettings, syncSettings } = yield (0, webhooks_1.prepareWebhookData)(config, integration, webhookUrlParam, types_1.Provider.CROWDIN);
74
+ const { projectId, crowdinClient, rootFolder, appSettings, syncSettings } = yield (0, webhooks_1.prepareWebhookData)({
75
+ config,
76
+ integration,
77
+ webhookUrlParam,
78
+ provider: types_1.Provider.CROWDIN,
79
+ });
75
80
  if (!crowdinClient) {
76
81
  return res.status(403).send({ error: 'Access denied' });
77
82
  }
@@ -98,7 +103,13 @@ function handle(config, integration) {
98
103
  delete syncFileSettings[eventPayload.fileId];
99
104
  }
100
105
  }
101
- const crowdinFiles = yield (0, cron_1.skipFoldersFromIntegrationRequest)(config, integration, projectId, filesToSync, crowdinClient.client);
106
+ const crowdinFiles = yield (0, cron_1.skipFoldersFromIntegrationRequest)({
107
+ config,
108
+ integration,
109
+ projectId,
110
+ crowdinFiles: filesToSync,
111
+ crowdinClient: crowdinClient.client,
112
+ });
102
113
  for (const fileId in crowdinFiles) {
103
114
  const webhook = yield (0, storage_1.getStorage)().getWebhooks(fileId, syncSettings.integrationId, syncSettings.crowdinId, syncSettings.provider);
104
115
  if (!webhook) {
@@ -1,4 +1,4 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
3
  import { IntegrationLogic } from '../types';
4
- export default function handle(integration: IntegrationLogic): (req: import("../../../models").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;
4
+ export default function handle(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;
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const util_1 = require("../../../util");
13
13
  const logger_1 = require("../../../util/logger");
14
- const files_1 = require("../../../util/files");
14
+ const files_1 = require("../util/files");
15
15
  function handle(integration) {
16
16
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
17
17
  const { parent_id: parentId, search, page } = req.query;
@@ -21,7 +21,7 @@ function handle(integration) {
21
21
  let files;
22
22
  try {
23
23
  const result = yield integration.getIntegrationFiles(req.integrationCredentials, req.integrationSettings, parentId, search, page);
24
- if ((0, util_1.isExtendedResultType)(result)) {
24
+ if ((0, files_1.isExtendedResultType)(result)) {
25
25
  files = result.data;
26
26
  message = result.message;
27
27
  stopPagination = result.stopPagination;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config, CrowdinClientRequest } from '../../../models';
3
+ import { Config, CrowdinClientRequest } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
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;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
- export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../models").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;
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;
@@ -11,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const storage_1 = require("../../../storage");
13
13
  const util_1 = require("../../../util");
14
- const connection_1 = require("../../../util/connection");
15
- const webhooks_1 = require("../../../util/webhooks");
16
14
  const logger_1 = require("../../../util/logger");
15
+ const subscription_1 = require("../../../util/subscription");
16
+ const webhooks_1 = require("../util/webhooks");
17
17
  function handle(config, integration) {
18
18
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
19
19
  req.logInfo('Received integration logout request');
@@ -34,9 +34,16 @@ function handle(config, integration) {
34
34
  }
35
35
  req.logInfo(`Deleting integration credentials for ${req.crowdinContext.clientId} client`);
36
36
  yield (0, storage_1.getStorage)().deleteIntegrationCredentials(req.crowdinContext.clientId);
37
- (0, connection_1.clearCache)(req.crowdinContext.crowdinId);
37
+ (0, subscription_1.clearCache)(req.crowdinContext.crowdinId);
38
38
  if (integration.webhooks) {
39
- yield (0, webhooks_1.unregisterWebhooks)(config, integration, req.crowdinApiClient, req.crowdinContext, req.integrationCredentials, req.integrationSettings);
39
+ yield (0, webhooks_1.unregisterWebhooks)({
40
+ config,
41
+ integration,
42
+ client: req.crowdinApiClient,
43
+ crowdinContext: req.crowdinContext,
44
+ apiCredentials: req.integrationCredentials,
45
+ appSettings: req.integrationSettings,
46
+ });
40
47
  }
41
48
  res.status(204).end();
42
49
  }));
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
- export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../models").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;
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,11 +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 job_1 = require("../../../models/job");
12
+ const types_1 = require("../util/types");
13
13
  const util_1 = require("../../../util");
14
- const defaults_1 = require("../../../util/defaults");
15
- const job_2 = require("../../../util/job");
14
+ const defaults_1 = require("../util/defaults");
15
+ const job_1 = require("../util/job");
16
16
  const logger_1 = require("../../../util/logger");
17
+ const files_1 = require("../util/files");
17
18
  function handle(config, integration) {
18
19
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
19
20
  var _a;
@@ -26,10 +27,10 @@ function handle(config, integration) {
26
27
  if (((_a = config.api) === null || _a === void 0 ? void 0 : _a.default) && req.body.files) {
27
28
  req.body = req.body.files;
28
29
  }
29
- yield (0, job_2.runAsJob)({
30
+ yield (0, job_1.runAsJob)({
30
31
  integrationId: req.crowdinContext.clientId,
31
32
  crowdinId: req.crowdinContext.crowdinId,
32
- type: job_1.JobType.UPDATE_TO_INTEGRATION,
33
+ type: types_1.JobType.UPDATE_TO_INTEGRATION,
33
34
  title: 'Sync files to ' + config.name,
34
35
  payload: req.body,
35
36
  res,
@@ -44,7 +45,7 @@ function handle(config, integration) {
44
45
  job,
45
46
  });
46
47
  let message;
47
- if ((0, util_1.isExtendedResultType)(result)) {
48
+ if ((0, files_1.isExtendedResultType)(result)) {
48
49
  message = result.message;
49
50
  }
50
51
  return { message };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Request, Response } from 'express';
3
- import { Config } from '../../../models';
3
+ import { Config } from '../../../types';
4
4
  import { IntegrationLogic } from '../types';
5
- export default function handle(config: Config, integration: IntegrationLogic): (req: import("../../../models").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;
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;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const util_1 = require("../../../util");
13
- const webhooks_1 = require("../../../util/webhooks");
13
+ const webhooks_1 = require("../util/webhooks");
14
14
  const types_1 = require("../types");
15
15
  function handle(config, integration) {
16
16
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
@@ -18,7 +18,12 @@ function handle(config, integration) {
18
18
  const urlParam = (_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.urlParam;
19
19
  const webhookUrlParam = req.query[urlParam];
20
20
  if (((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.integrationWebhookInterceptor) && webhookUrlParam) {
21
- const webhookData = yield (0, webhooks_1.prepareWebhookData)(config, integration, webhookUrlParam, types_1.Provider.INTEGRATION);
21
+ const webhookData = yield (0, webhooks_1.prepareWebhookData)({
22
+ config,
23
+ integration,
24
+ webhookUrlParam,
25
+ provider: types_1.Provider.INTEGRATION,
26
+ });
22
27
  if (!webhookData.crowdinClient) {
23
28
  return res.status(403).send({ error: 'Access denied' });
24
29
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- export default function handle(): (req: import("../../../models").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;
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 job_1 = require("../../../models/job");
12
+ const types_1 = require("../util/types");
13
13
  const util_1 = require("../../../util");
14
14
  const storage_1 = require("../../../storage");
15
15
  function handle() {
@@ -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
  }
@@ -1,3 +1,3 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- export default function handle(): (req: import("../../../models").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;
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;