@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,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = void 0;
4
+ const api_1 = require("./api");
5
+ function register({ config, app }) {
6
+ if (!config.api) {
7
+ return;
8
+ }
9
+ if (config.api.default) {
10
+ (0, api_1.addDefaultApiEndpoints)(app, config);
11
+ }
12
+ (0, api_1.addSwagerApiDocumentation)(app, config);
13
+ }
14
+ exports.register = register;
@@ -0,0 +1,20 @@
1
+ export declare enum RequestMethods {
2
+ GET = "GET",
3
+ POST = "POST",
4
+ PUT = "PUT",
5
+ PATCH = "PATCH",
6
+ DELETE = "DELETE"
7
+ }
8
+ export interface ApiEndpoints {
9
+ key: string;
10
+ name: string;
11
+ url: string;
12
+ method: RequestMethods;
13
+ description?: string;
14
+ documentationUrl?: string;
15
+ }
16
+ export interface ApiModule {
17
+ default?: boolean;
18
+ endpoints?: ApiEndpoints[];
19
+ docFile?: string;
20
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestMethods = void 0;
4
+ var RequestMethods;
5
+ (function (RequestMethods) {
6
+ RequestMethods["GET"] = "GET";
7
+ RequestMethods["POST"] = "POST";
8
+ RequestMethods["PUT"] = "PUT";
9
+ RequestMethods["PATCH"] = "PATCH";
10
+ RequestMethods["DELETE"] = "DELETE";
11
+ })(RequestMethods = exports.RequestMethods || (exports.RequestMethods = {}));
@@ -0,0 +1,6 @@
1
+ import { Express } from 'express';
2
+ import { Config, UnauthorizedConfig } from '../../types';
3
+ export declare function register({ config, app }: {
4
+ config: Config | UnauthorizedConfig;
5
+ app: Express;
6
+ }): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.register = void 0;
7
+ const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
8
+ const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
+ const util_1 = require("../../util");
10
+ function register({ config, app }) {
11
+ var _a, _b;
12
+ const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
13
+ if (((_a = config.contextMenu) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.contextMenu) === null || _b === void 0 ? void 0 : _b.formSchema)) {
14
+ app.use('/context', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.contextMenu));
15
+ }
16
+ }
17
+ exports.register = register;
@@ -0,0 +1,27 @@
1
+ import { SignaturePatterns } from '../../types';
2
+ export interface ContextModule {
3
+ location: ContextOptionsLocations;
4
+ type: ContextOptionsTypes;
5
+ module: string;
6
+ /**
7
+ * Context menu name
8
+ */
9
+ name?: string;
10
+ /**
11
+ * Support fileName pattern only. Contains fileName field regular expressions used to detect the file type. If the file name matches any of the regular expressions, the context menu will be displayed.
12
+ */
13
+ signaturePatterns?: SignaturePatterns;
14
+ }
15
+ export declare enum ContextOptionsLocations {
16
+ TM = "tm",
17
+ GLOSSARY = "glossary",
18
+ LANGUAGE = "language",
19
+ SCREENSHOT = "screenshot",
20
+ SOURCE_FILE = "source_file",
21
+ TRANSLATED_FILE = "translated_file"
22
+ }
23
+ export declare enum ContextOptionsTypes {
24
+ MODAL = "modal",
25
+ NEW_TAB = "new_tab",
26
+ REDIRECT = "redirect"
27
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContextOptionsTypes = exports.ContextOptionsLocations = void 0;
4
+ var ContextOptionsLocations;
5
+ (function (ContextOptionsLocations) {
6
+ ContextOptionsLocations["TM"] = "tm";
7
+ ContextOptionsLocations["GLOSSARY"] = "glossary";
8
+ ContextOptionsLocations["LANGUAGE"] = "language";
9
+ ContextOptionsLocations["SCREENSHOT"] = "screenshot";
10
+ ContextOptionsLocations["SOURCE_FILE"] = "source_file";
11
+ ContextOptionsLocations["TRANSLATED_FILE"] = "translated_file";
12
+ })(ContextOptionsLocations = exports.ContextOptionsLocations || (exports.ContextOptionsLocations = {}));
13
+ var ContextOptionsTypes;
14
+ (function (ContextOptionsTypes) {
15
+ ContextOptionsTypes["MODAL"] = "modal";
16
+ ContextOptionsTypes["NEW_TAB"] = "new_tab";
17
+ ContextOptionsTypes["REDIRECT"] = "redirect";
18
+ })(ContextOptionsTypes = exports.ContextOptionsTypes || (exports.ContextOptionsTypes = {}));
@@ -1,4 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest, CustomMTLogic } from '../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
+ import { CustomMTLogic } from '../types';
4
5
  export default function handle(config: CustomMTLogic): (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 logger_1 = require("../../util/logger");
12
+ const util_1 = require("../../../util");
13
+ const logger_1 = require("../../../util/logger");
14
14
  function handle(config) {
15
15
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
16
  const source = req.query.source;
@@ -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,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.register = void 0;
7
+ const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
8
+ const util_1 = require("../../util");
9
+ const translate_1 = __importDefault(require("./handlers/translate"));
10
+ function register({ config, app }) {
11
+ if (!config.customMT) {
12
+ return;
13
+ }
14
+ app.get((0, util_1.getLogoUrl)(config.customMT, '/mt'), (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
15
+ app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config.customMT));
16
+ }
17
+ exports.register = register;
@@ -0,0 +1,22 @@
1
+ import Crowdin, { SourceStringsModel } from '@crowdin/crowdin-api-client';
2
+ import { CrowdinContextInfo } from '../../types';
3
+ export interface CustomMTLogic {
4
+ withContext?: boolean;
5
+ translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number, source: string, target: string, strings: CustomMtString[]) => Promise<string[]>;
6
+ validate?: (client: Crowdin) => Promise<void>;
7
+ }
8
+ export interface CustomMTRequest {
9
+ strings: CustomMtString[];
10
+ }
11
+ export type CustomMtString = string | {
12
+ id: number;
13
+ projectId: number;
14
+ fileId: number;
15
+ identifier: string;
16
+ context: string;
17
+ maxLength: number;
18
+ isHidden: boolean;
19
+ text: string | SourceStringsModel.PluralText;
20
+ isPlural: boolean;
21
+ pluralForm: any;
22
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest, CustomSpellcheckerModule } from '../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
+ import { CustomSpellcheckerModule } from '../types';
4
5
  export default function handle(customSpellchecker: CustomSpellcheckerModule): (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 logger_1 = require("../../util/logger");
12
+ const util_1 = require("../../../util");
13
+ const logger_1 = require("../../../util/logger");
14
14
  function handle(customSpellchecker) {
15
15
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
16
  try {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest, CustomSpellcheckerModule } from '../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
+ import { CustomSpellcheckerModule } from '../types';
4
5
  export default function handle(customSpellchecker: CustomSpellcheckerModule): (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 logger_1 = require("../../util/logger");
12
+ const util_1 = require("../../../util");
13
+ const logger_1 = require("../../../util/logger");
14
14
  function handle(customSpellchecker) {
15
15
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
16
16
  const body = req.body;
@@ -26,7 +26,9 @@ function handle(customSpellchecker) {
26
26
  res.send({ data: response.texts, error: response.error ? { message: response.error } : undefined });
27
27
  }
28
28
  catch (e) {
29
- req.logError(e);
29
+ if (req.logError) {
30
+ req.logError(e);
31
+ }
30
32
  res.send({ error: { message: (0, logger_1.getErrorMessage)(e) } });
31
33
  }
32
34
  }));
@@ -0,0 +1,6 @@
1
+ import { Express } from 'express';
2
+ import { Config, UnauthorizedConfig } from '../../types';
3
+ export declare function register({ config, app }: {
4
+ config: Config | UnauthorizedConfig;
5
+ app: Express;
6
+ }): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.register = void 0;
7
+ const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
8
+ const json_response_1 = __importDefault(require("../../middlewares/json-response"));
9
+ const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
10
+ const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
11
+ const util_1 = require("../../util");
12
+ const get_languages_list_1 = __importDefault(require("./handlers/get-languages-list"));
13
+ const spell_check_1 = __importDefault(require("./handlers/spell-check"));
14
+ function register({ config, app }) {
15
+ if (!config.customSpellchecker) {
16
+ return;
17
+ }
18
+ if ((0, util_1.isAuthorizedConfig)(config)) {
19
+ if (config.customSpellchecker.settingsUiModule) {
20
+ app.use('/settings', (0, ui_module_1.default)(config), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
21
+ }
22
+ app.get('/languages', json_response_1.default, (0, crowdin_client_1.default)(config), (0, get_languages_list_1.default)(config.customSpellchecker));
23
+ app.post('/spellcheck', json_response_1.default, (0, crowdin_client_1.default)(config), (0, spell_check_1.default)(config.customSpellchecker));
24
+ return;
25
+ }
26
+ if (config.customSpellchecker.settingsUiModule) {
27
+ app.use('/settings', (0, ui_module_1.default)(config, true), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
28
+ }
29
+ app.get('/languages', json_response_1.default, (0, get_languages_list_1.default)(config.customSpellchecker));
30
+ app.post('/spellcheck', json_response_1.default, (0, spell_check_1.default)(config.customSpellchecker));
31
+ }
32
+ exports.register = register;
@@ -0,0 +1,56 @@
1
+ import Crowdin from '@crowdin/crowdin-api-client';
2
+ import { CrowdinContextInfo, Environments, UiModule } from '../../types';
3
+ export interface CustomSpellCheckRequest {
4
+ language: string;
5
+ texts: string[];
6
+ }
7
+ export type SpellCheckCategory = 'typography' | 'casing' | 'grammar' | 'typos' | 'punctuation' | 'confused_words' | 'redundancy' | 'style' | 'gender_neutrality' | 'semantics' | 'colloquialisms' | 'wikipedia' | 'barbarism' | 'misc';
8
+ export interface SupportedLanguage {
9
+ code: string;
10
+ name: string;
11
+ }
12
+ export interface SpellCheckMatch {
13
+ category: SpellCheckCategory;
14
+ message: string;
15
+ shortMessage: string;
16
+ offset: number;
17
+ length: number;
18
+ replacements: string[];
19
+ }
20
+ export interface CustomSpellCheckResponse {
21
+ texts: {
22
+ text: string;
23
+ matches: SpellCheckMatch[];
24
+ }[];
25
+ error?: string;
26
+ }
27
+ export interface CustomSpellcheckerModule extends Environments {
28
+ /**
29
+ * module description
30
+ */
31
+ description?: string;
32
+ /**
33
+ * module name
34
+ */
35
+ name?: string;
36
+ /**
37
+ * Settings UI module
38
+ */
39
+ settingsUiModule?: UiModule;
40
+ /**
41
+ * function to get list of supported languages that are supports by current spellchecker
42
+ */
43
+ getSupportedLanguage: ({ client, context, }: {
44
+ client: Crowdin;
45
+ context: CrowdinContextInfo;
46
+ }) => Promise<SupportedLanguage[]>;
47
+ /**
48
+ * function to check spelling
49
+ */
50
+ runSpellCheck: ({ client, context, language, texts, }: {
51
+ client?: Crowdin;
52
+ context?: CrowdinContextInfo;
53
+ language: string;
54
+ texts: string[];
55
+ }) => Promise<CustomSpellCheckResponse>;
56
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { Express } from 'express';
2
+ import { Config, UnauthorizedConfig } from '../../types';
3
+ export declare function register({ config, app }: {
4
+ config: Config | UnauthorizedConfig;
5
+ app: Express;
6
+ }): void;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.register = void 0;
7
+ const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
8
+ const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
9
+ const util_1 = require("../../util");
10
+ function register({ config, app }) {
11
+ if (!config.editorRightPanel) {
12
+ return;
13
+ }
14
+ const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
15
+ app.use('/editor-panels', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.editorRightPanel));
16
+ }
17
+ exports.register = register;
@@ -0,0 +1,7 @@
1
+ import { EditorMode, UiModule } from '../../types';
2
+ export interface EditorPanels extends UiModule {
3
+ /**
4
+ * The Editor's mode list where the module will be available.
5
+ */
6
+ modes: EditorMode[];
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { Express } from 'express';
2
+ import { Config, UnauthorizedConfig } from '../../types';
3
+ export declare function register({ config, app }: {
4
+ config: Config | UnauthorizedConfig;
5
+ app: Express;
6
+ }): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = void 0;
4
+ const util_1 = require("../../util");
5
+ function register({ config, app }) {
6
+ if (!config.editorThemes) {
7
+ return;
8
+ }
9
+ app.get((0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'), (req, res) => { var _a; return res.sendFile(((_a = config.editorThemes) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
10
+ }
11
+ exports.register = register;
@@ -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,4 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { CrowdinClientRequest, CustomFileFormatLogic } from '../../models';
3
+ import { CrowdinClientRequest } from '../../../types';
4
+ import { CustomFileFormatLogic } from '../types';
4
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;
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
- const models_1 = require("../../models");
18
- const util_1 = require("../../util");
19
- const files_1 = require("../../util/files");
17
+ const util_1 = require("../../../util");
18
+ const files_1 = require("../util/files");
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'))) {
22
22
  fs_1.default.mkdirSync(path_1.default.join(folder, 'custom-file-format'), { recursive: true });
@@ -42,12 +42,12 @@ function handle(baseUrl, folder, config) {
42
42
  let response = {};
43
43
  let error;
44
44
  switch (body.jobType) {
45
- case models_1.ProcessFileJobType.BUILD_FILE:
45
+ case types_1.ProcessFileJobType.BUILD_FILE:
46
46
  const buildFileResult = yield handleBuildFile(baseFilesUrl, folder, config, body, req.crowdinApiClient, req.crowdinContext, req.crowdinContext.jwtPayload.context.project_id, file);
47
47
  response = buildFileResult.response;
48
48
  error = buildFileResult.error;
49
49
  break;
50
- case models_1.ProcessFileJobType.PARSE_FILE:
50
+ case types_1.ProcessFileJobType.PARSE_FILE:
51
51
  const parseFileResult = yield handleParseFile(baseFilesUrl, folder, config, body, req.crowdinApiClient, req.crowdinContext, req.crowdinContext.jwtPayload.context.project_id, file);
52
52
  response = parseFileResult.response;
53
53
  error = parseFileResult.error;
@@ -0,0 +1,5 @@
1
+ /// <reference types="qs" />
2
+ import { Request, Response } from 'express';
3
+ import { Config } from '../../../types';
4
+ import { FileProcessLogic } from '../types';
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;
@@ -14,8 +14,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
- const util_1 = require("../../util");
18
- const logger_1 = require("../../util/logger");
17
+ const util_1 = require("../../../util");
18
+ const logger_1 = require("../../../util/logger");
19
19
  function handle(config, processingConfig, folderName) {
20
20
  const folder = processingConfig.filesFolder || config.dbFolder;
21
21
  return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,5 @@
1
1
  /// <reference types="qs" />
2
2
  import { Response } from 'express';
3
- import { Config, CrowdinClientRequest, FileImportExportLogic } from '../../models';
3
+ import { Config, CrowdinClientRequest } from '../../../types';
4
+ import { FileImportExportLogic } from '../types';
4
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;
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const fs_1 = __importDefault(require("fs"));
16
16
  const path_1 = __importDefault(require("path"));
17
- const models_1 = require("../../models");
18
- const util_1 = require("../../util");
19
- const files_1 = require("../../util/files");
17
+ const util_1 = require("../../../util");
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))) {
@@ -43,7 +43,7 @@ function handle(baseConfig, config, folderName) {
43
43
  rawContent = body.file.content;
44
44
  fileContent = Buffer.from(rawContent, 'base64');
45
45
  }
46
- if (body.jobType === models_1.ProcessFileJobType.PRE_IMPORT || body.jobType === models_1.ProcessFileJobType.POST_EXPORT) {
46
+ if (body.jobType === types_1.ProcessFileJobType.PRE_IMPORT || body.jobType === types_1.ProcessFileJobType.POST_EXPORT) {
47
47
  body.getRawContent = (encoding) => __awaiter(this, void 0, void 0, function* () {
48
48
  if (typeof rawContent === 'string') {
49
49
  return Buffer.from(rawContent, 'base64').toString(encoding);
@@ -57,8 +57,8 @@ function handle(baseConfig, config, folderName) {
57
57
  return;
58
58
  }
59
59
  switch (body.jobType) {
60
- case models_1.ProcessFileJobType.PRE_IMPORT:
61
- case models_1.ProcessFileJobType.POST_EXPORT:
60
+ case types_1.ProcessFileJobType.PRE_IMPORT:
61
+ case types_1.ProcessFileJobType.POST_EXPORT:
62
62
  const { contentFile, fileName, fileType, error: contentFileError, } = fileProcessResult;
63
63
  if (contentFile) {
64
64
  if (Buffer.byteLength(contentFile) < files_1.MAX_BODY_SIZE) {
@@ -84,8 +84,8 @@ function handle(baseConfig, config, folderName) {
84
84
  }
85
85
  processingError = contentFileError;
86
86
  break;
87
- case models_1.ProcessFileJobType.POST_IMPORT:
88
- case models_1.ProcessFileJobType.PRE_EXPORT:
87
+ case types_1.ProcessFileJobType.POST_IMPORT:
88
+ case types_1.ProcessFileJobType.PRE_EXPORT:
89
89
  const { strings, error: stringsFileError } = fileProcessResult;
90
90
  if (strings) {
91
91
  const stringsNDJson = strings.map((s) => JSON.stringify(s)).join('\n\r');
@@ -0,0 +1,22 @@
1
+ import { Express } from 'express';
2
+ import { Config } from '../../types';
3
+ export declare function registerCustomFileFormat({ config, app }: {
4
+ config: Config;
5
+ app: Express;
6
+ }): void;
7
+ export declare function registerFilePreImport({ config, app }: {
8
+ config: Config;
9
+ app: Express;
10
+ }): void;
11
+ export declare function registerFilePostImport({ config, app }: {
12
+ config: Config;
13
+ app: Express;
14
+ }): void;
15
+ export declare function registerFilePreExport({ config, app }: {
16
+ config: Config;
17
+ app: Express;
18
+ }): void;
19
+ export declare function registerFilePostExport({ config, app }: {
20
+ config: Config;
21
+ app: Express;
22
+ }): void;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.registerFilePostExport = exports.registerFilePreExport = exports.registerFilePostImport = exports.registerFilePreImport = exports.registerCustomFileFormat = void 0;
7
+ const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
8
+ const custom_file_format_1 = __importDefault(require("./handlers/custom-file-format"));
9
+ const file_download_1 = __importDefault(require("./handlers/file-download"));
10
+ const pre_post_process_1 = __importDefault(require("./handlers/pre-post-process"));
11
+ const types_1 = require("./types");
12
+ const defaults_1 = require("./util/defaults");
13
+ function registerCustomFileFormat({ config, app }) {
14
+ if (!config.customFileFormat) {
15
+ return;
16
+ }
17
+ (0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.customFileFormat);
18
+ app.post('/process', (0, crowdin_client_1.default)(config), (0, custom_file_format_1.default)(config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder, config.customFileFormat));
19
+ app.get('/file/download', (0, file_download_1.default)(config, config.customFileFormat, 'custom-file-format'));
20
+ }
21
+ exports.registerCustomFileFormat = registerCustomFileFormat;
22
+ function registerFilePreImport({ config, app }) {
23
+ if (!config.filePreImport) {
24
+ return;
25
+ }
26
+ (0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePreImport);
27
+ app.post('/pre-import', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePreImport, types_1.ProcessFileJobType.PRE_IMPORT));
28
+ app.get(`/file/download/${types_1.ProcessFileJobType.PRE_IMPORT}`, (0, file_download_1.default)(config, config.filePreImport, types_1.ProcessFileJobType.PRE_IMPORT));
29
+ }
30
+ exports.registerFilePreImport = registerFilePreImport;
31
+ function registerFilePostImport({ config, app }) {
32
+ if (!config.filePostImport) {
33
+ return;
34
+ }
35
+ (0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePostImport);
36
+ app.post('/post-import', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePostImport, types_1.ProcessFileJobType.POST_IMPORT));
37
+ app.get(`/file/download/${types_1.ProcessFileJobType.POST_IMPORT}`, (0, file_download_1.default)(config, config.filePostImport, types_1.ProcessFileJobType.POST_IMPORT));
38
+ }
39
+ exports.registerFilePostImport = registerFilePostImport;
40
+ function registerFilePreExport({ config, app }) {
41
+ if (!config.filePreExport) {
42
+ return;
43
+ }
44
+ (0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePreExport);
45
+ app.post('/pre-export', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePreExport, types_1.ProcessFileJobType.PRE_EXPORT));
46
+ app.get(`/file/download/${types_1.ProcessFileJobType.PRE_EXPORT}`, (0, file_download_1.default)(config, config.filePreExport, types_1.ProcessFileJobType.PRE_EXPORT));
47
+ }
48
+ exports.registerFilePreExport = registerFilePreExport;
49
+ function registerFilePostExport({ config, app }) {
50
+ if (!config.filePostExport) {
51
+ return;
52
+ }
53
+ (0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePostExport);
54
+ app.post('/post-export', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePostExport, types_1.ProcessFileJobType.POST_EXPORT));
55
+ app.get(`/file/download/${types_1.ProcessFileJobType.POST_EXPORT}`, (0, file_download_1.default)(config, config.filePostExport, types_1.ProcessFileJobType.POST_EXPORT));
56
+ }
57
+ exports.registerFilePostExport = registerFilePostExport;