@crowdin/app-project-module 0.43.1 → 0.44.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.
- package/out/index.d.ts +1 -1
- package/out/index.js +57 -166
- package/out/middlewares/integration-credentials.d.ts +2 -1
- package/out/middlewares/ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.js +4 -0
- package/out/models/index.d.ts +52 -698
- package/out/models/index.js +2 -26
- package/out/modules/context-menu/index.d.ts +6 -0
- package/out/modules/context-menu/index.js +17 -0
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
- package/out/modules/custom-mt/index.d.ts +6 -0
- package/out/modules/custom-mt/index.js +17 -0
- package/out/modules/custom-mt/types.d.ts +22 -0
- package/out/modules/custom-mt/types.js +2 -0
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
- package/out/modules/custom-spell-check/index.d.ts +6 -0
- package/out/modules/custom-spell-check/index.js +32 -0
- package/out/modules/custom-spell-check/types.d.ts +56 -0
- package/out/modules/custom-spell-check/types.js +2 -0
- package/out/modules/editor-right-panel/index.d.ts +6 -0
- package/out/modules/editor-right-panel/index.js +17 -0
- package/out/modules/editor-right-panel/types.d.ts +7 -0
- package/out/modules/editor-right-panel/types.js +2 -0
- package/out/modules/editor-themes/index.d.ts +6 -0
- package/out/modules/editor-themes/index.js +11 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
- package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
- package/out/modules/file-processing/index.d.ts +22 -0
- package/out/modules/file-processing/index.js +57 -0
- package/out/modules/file-processing/types.d.ts +133 -0
- package/out/modules/file-processing/types.js +12 -0
- package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
- package/out/modules/form-data-save.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
- package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
- package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +6 -6
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +7 -7
- package/out/modules/integration/handlers/integration-data.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +4 -4
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
- package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +5 -5
- package/out/modules/integration/handlers/integration-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +5 -5
- package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +4 -4
- package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +3 -3
- package/out/modules/integration/handlers/job-info.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-info.js +3 -3
- package/out/modules/integration/handlers/main.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/main.js +4 -4
- package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
- package/out/modules/integration/handlers/settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +10 -10
- package/out/modules/integration/handlers/settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +5 -5
- package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
- package/out/modules/integration/handlers/user-errors.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
- package/out/modules/integration/index.d.ts +6 -0
- package/out/modules/integration/index.js +113 -0
- package/out/modules/integration/types.d.ts +446 -0
- package/out/modules/integration/types.js +19 -0
- package/out/modules/manifest.d.ts +3 -0
- package/out/{handlers → modules}/manifest.js +16 -10
- package/out/modules/modal/index.d.ts +6 -0
- package/out/modules/modal/index.js +17 -0
- package/out/modules/organization-menu/index.d.ts +6 -0
- package/out/modules/organization-menu/index.js +19 -0
- package/out/modules/profile-resources-menu/index.d.ts +6 -0
- package/out/modules/profile-resources-menu/index.js +19 -0
- package/out/modules/project-menu/index.d.ts +6 -0
- package/out/modules/project-menu/index.js +17 -0
- package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
- package/out/modules/project-menu-crowdsource/index.js +17 -0
- package/out/modules/project-reports/index.d.ts +6 -0
- package/out/modules/project-reports/index.js +19 -0
- package/out/modules/project-tools/index.d.ts +6 -0
- package/out/modules/project-tools/index.js +19 -0
- package/out/storage/index.d.ts +3 -2
- package/out/storage/mysql.d.ts +2 -1
- package/out/storage/postgre.d.ts +2 -1
- package/out/storage/sqlite.d.ts +2 -1
- package/out/util/api/api.d.ts +2 -2
- package/out/util/api/api.js +10 -10
- package/out/util/connection.d.ts +3 -2
- package/out/util/cron.d.ts +2 -1
- package/out/util/cron.js +6 -6
- package/out/util/defaults.d.ts +5 -2
- package/out/util/defaults.js +13 -3
- package/out/util/file-snapshot.d.ts +2 -1
- package/out/util/file-snapshot.js +5 -5
- package/out/util/files.d.ts +2 -1
- package/out/util/index.d.ts +2 -1
- package/out/util/logger.d.ts +2 -2
- package/out/util/webhooks.d.ts +2 -1
- package/out/util/webhooks.js +5 -5
- package/package.json +1 -1
- package/out/handlers/file-processing/file-download.d.ts +0 -4
- package/out/handlers/form-data-display.d.ts +0 -3
- package/out/handlers/form-data-save.d.ts +0 -3
- package/out/handlers/integration/crowdin-files.d.ts +0 -4
- package/out/handlers/integration/crowdin-update.d.ts +0 -4
- package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
- package/out/handlers/integration/integration-data.d.ts +0 -4
- package/out/handlers/integration/integration-logout.d.ts +0 -4
- package/out/handlers/integration/integration-update.d.ts +0 -4
- package/out/handlers/integration/integration-webhook.d.ts +0 -4
- package/out/handlers/integration/job-cancel.d.ts +0 -3
- package/out/handlers/integration/job-info.d.ts +0 -3
- package/out/handlers/integration/main.d.ts +0 -4
- package/out/handlers/integration/oauth-login.d.ts +0 -4
- package/out/handlers/integration/settings-save.d.ts +0 -4
- package/out/handlers/integration/settings.d.ts +0 -3
- package/out/handlers/integration/sync-settings-save.d.ts +0 -4
- package/out/handlers/integration/sync-settings.d.ts +0 -3
- package/out/handlers/integration/user-errors.d.ts +0 -3
- package/out/handlers/manifest.d.ts +0 -3
- /package/out/{handlers → modules}/form-data-display.js +0 -0
- /package/out/{handlers → modules}/form-data-save.js +0 -0
- /package/out/{handlers → modules}/install.d.ts +0 -0
- /package/out/{handlers → modules}/install.js +0 -0
- /package/out/{handlers → modules}/subscription-paid.d.ts +0 -0
- /package/out/{handlers → modules}/subscription-paid.js +0 -0
- /package/out/{handlers → modules}/uninstall.d.ts +0 -0
- /package/out/{handlers → modules}/uninstall.js +0 -0
package/out/models/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProjectPermissions = exports.UserPermissions = exports.
|
|
3
|
+
exports.ProjectPermissions = exports.UserPermissions = exports.RequestMethods = exports.ContextOptionsTypes = exports.ContextOptionsLocations = exports.EditorMode = exports.SubscriptionInfoType = exports.AccountType = exports.Scope = exports.AuthenticationType = void 0;
|
|
4
4
|
var AuthenticationType;
|
|
5
5
|
(function (AuthenticationType) {
|
|
6
6
|
AuthenticationType["CODE"] = "authorization_code";
|
|
7
7
|
AuthenticationType["APP"] = "crowdin_app";
|
|
8
|
+
AuthenticationType["NONE"] = "none";
|
|
8
9
|
})(AuthenticationType = exports.AuthenticationType || (exports.AuthenticationType = {}));
|
|
9
10
|
var Scope;
|
|
10
11
|
(function (Scope) {
|
|
@@ -37,15 +38,6 @@ var SubscriptionInfoType;
|
|
|
37
38
|
SubscriptionInfoType["TRIAL"] = "trial";
|
|
38
39
|
SubscriptionInfoType["SUBSCRIPTION"] = "subscription";
|
|
39
40
|
})(SubscriptionInfoType = exports.SubscriptionInfoType || (exports.SubscriptionInfoType = {}));
|
|
40
|
-
var ProcessFileJobType;
|
|
41
|
-
(function (ProcessFileJobType) {
|
|
42
|
-
ProcessFileJobType["PARSE_FILE"] = "parse-file";
|
|
43
|
-
ProcessFileJobType["BUILD_FILE"] = "build-file";
|
|
44
|
-
ProcessFileJobType["PRE_IMPORT"] = "pre-import-file";
|
|
45
|
-
ProcessFileJobType["POST_IMPORT"] = "post-import-file";
|
|
46
|
-
ProcessFileJobType["PRE_EXPORT"] = "pre-export-file";
|
|
47
|
-
ProcessFileJobType["POST_EXPORT"] = "post-export-file";
|
|
48
|
-
})(ProcessFileJobType = exports.ProcessFileJobType || (exports.ProcessFileJobType = {}));
|
|
49
41
|
var EditorMode;
|
|
50
42
|
(function (EditorMode) {
|
|
51
43
|
EditorMode["ASSETS"] = "assets";
|
|
@@ -68,11 +60,6 @@ var ContextOptionsTypes;
|
|
|
68
60
|
ContextOptionsTypes["NEW_TAB"] = "new_tab";
|
|
69
61
|
ContextOptionsTypes["REDIRECT"] = "redirect";
|
|
70
62
|
})(ContextOptionsTypes = exports.ContextOptionsTypes || (exports.ContextOptionsTypes = {}));
|
|
71
|
-
var Provider;
|
|
72
|
-
(function (Provider) {
|
|
73
|
-
Provider["CROWDIN"] = "crowdin";
|
|
74
|
-
Provider["INTEGRATION"] = "integration";
|
|
75
|
-
})(Provider = exports.Provider || (exports.Provider = {}));
|
|
76
63
|
var RequestMethods;
|
|
77
64
|
(function (RequestMethods) {
|
|
78
65
|
RequestMethods["GET"] = "GET";
|
|
@@ -81,17 +68,6 @@ var RequestMethods;
|
|
|
81
68
|
RequestMethods["PATCH"] = "PATCH";
|
|
82
69
|
RequestMethods["DELETE"] = "DELETE";
|
|
83
70
|
})(RequestMethods = exports.RequestMethods || (exports.RequestMethods = {}));
|
|
84
|
-
var SyncCondition;
|
|
85
|
-
(function (SyncCondition) {
|
|
86
|
-
SyncCondition[SyncCondition["ALL"] = 0] = "ALL";
|
|
87
|
-
SyncCondition[SyncCondition["TRANSLATED"] = 1] = "TRANSLATED";
|
|
88
|
-
SyncCondition[SyncCondition["APPROVED"] = 2] = "APPROVED";
|
|
89
|
-
})(SyncCondition = exports.SyncCondition || (exports.SyncCondition = {}));
|
|
90
|
-
var SyncSchedule;
|
|
91
|
-
(function (SyncSchedule) {
|
|
92
|
-
SyncSchedule[SyncSchedule["DISABLED"] = 0] = "DISABLED";
|
|
93
|
-
SyncSchedule[SyncSchedule["ACTIVE"] = 1 || 3 || 6 || 12 || 24] = "ACTIVE";
|
|
94
|
-
})(SyncSchedule = exports.SyncSchedule || (exports.SyncSchedule = {}));
|
|
95
71
|
var UserPermissions;
|
|
96
72
|
(function (UserPermissions) {
|
|
97
73
|
UserPermissions["OWNER"] = "owner";
|
|
@@ -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 defaults_1 = require("../../util/defaults");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const allowUnauthorized = !(0, defaults_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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { CrowdinClientRequest
|
|
3
|
+
import { CrowdinClientRequest } from '../../../models';
|
|
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("
|
|
13
|
-
const logger_1 = require("
|
|
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,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 '../../models';
|
|
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
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { CrowdinClientRequest
|
|
3
|
+
import { CrowdinClientRequest } from '../../../models';
|
|
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("
|
|
13
|
-
const logger_1 = require("
|
|
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 {
|
package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { CrowdinClientRequest
|
|
3
|
+
import { CrowdinClientRequest } from '../../../models';
|
|
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;
|
package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js
RENAMED
|
@@ -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("
|
|
13
|
-
const logger_1 = require("
|
|
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
|
|
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,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 defaults_1 = require("../../util/defaults");
|
|
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, defaults_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 '../../models';
|
|
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,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 defaults_1 = require("../../util/defaults");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.editorRightPanel) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, defaults_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,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;
|
package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { CrowdinClientRequest
|
|
3
|
+
import { CrowdinClientRequest } from '../../../models';
|
|
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;
|
package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js
RENAMED
|
@@ -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
|
|
18
|
-
const
|
|
19
|
-
const
|
|
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
|
|
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
|
|
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 '../../../models';
|
|
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;
|
|
@@ -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("
|
|
18
|
-
const logger_1 = require("
|
|
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* () {
|
package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config, CrowdinClientRequest
|
|
3
|
+
import { Config, CrowdinClientRequest } from '../../../models';
|
|
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;
|
package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js
RENAMED
|
@@ -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
|
|
18
|
-
const
|
|
19
|
-
const
|
|
17
|
+
const util_1 = require("../../../util");
|
|
18
|
+
const files_1 = require("../../../util/files");
|
|
19
|
+
const types_1 = require("../types");
|
|
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 ===
|
|
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
|
|
61
|
-
case
|
|
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
|
|
88
|
-
case
|
|
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 '../../models';
|
|
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 defaults_1 = require("../../util/defaults");
|
|
9
|
+
const custom_file_format_1 = __importDefault(require("./handlers/custom-file-format"));
|
|
10
|
+
const file_download_1 = __importDefault(require("./handlers/file-download"));
|
|
11
|
+
const pre_post_process_1 = __importDefault(require("./handlers/pre-post-process"));
|
|
12
|
+
const types_1 = require("./types");
|
|
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;
|