@crowdin/app-project-module 0.107.0 → 1.0.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/app-test/integration/get-integration-files.js +16 -4
- package/out/app-test/integration/types.d.ts +1 -1
- package/out/app-test/integration/update-crowdin.js +2 -2
- package/out/app-test/integration/update-integration.js +2 -2
- package/out/index.d.ts +2 -1
- package/out/index.js +73 -30
- package/out/middlewares/auto-credentials-masker.d.ts +4 -0
- package/out/middlewares/auto-credentials-masker.js +45 -0
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/integration-credentials.d.ts +2 -2
- package/out/middlewares/integration-credentials.js +7 -4
- package/out/middlewares/render-ui-module.d.ts +3 -3
- package/out/middlewares/render-ui-module.js +10 -13
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.js +11 -1
- package/out/modules/about.d.ts +2 -1
- package/out/modules/about.js +10 -3
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
- package/out/modules/ai-prompt-provider/handlers/compile.js +7 -1
- package/out/modules/ai-prompt-provider/index.js +2 -2
- package/out/modules/ai-prompt-provider/types.d.ts +7 -1
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
- package/out/modules/ai-provider/handlers/chat-completions.js +1 -1
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
- package/out/modules/ai-provider/index.js +2 -2
- package/out/modules/ai-provider/types.d.ts +4 -4
- package/out/modules/ai-request-processors/handler.d.ts +1 -1
- package/out/modules/ai-request-processors/handler.js +12 -2
- package/out/modules/ai-request-processors/types.d.ts +12 -2
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
- package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
- package/out/modules/ai-tools/index.js +1 -1
- package/out/modules/ai-tools/types.d.ts +1 -1
- package/out/modules/api/api.js +58 -7
- package/out/modules/api/base.d.ts +1 -0
- package/out/modules/api/base.js +1 -0
- package/out/modules/api/components.d.ts +251 -27
- package/out/modules/api/components.js +251 -27
- package/out/modules/auth-guard/handlers/verify.d.ts +1 -1
- package/out/modules/auth-guard/index.js +1 -1
- package/out/modules/automation-action/handlers/execute.d.ts +1 -1
- package/out/modules/automation-action/handlers/execute.js +1 -1
- package/out/modules/automation-action/handlers/input-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/output-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.js +1 -1
- package/out/modules/automation-action/index.js +1 -1
- package/out/modules/automation-action/types.d.ts +4 -4
- package/out/modules/automation-action/util/index.js +2 -5
- package/out/modules/context-menu/index.js +2 -2
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-mt/handlers/translate.js +25 -9
- package/out/modules/custom-mt/index.js +3 -3
- package/out/modules/custom-mt/types.d.ts +10 -2
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/custom-spell-check/index.js +4 -4
- package/out/modules/editor-right-panel/index.js +1 -1
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
- package/out/modules/external-qa-check/index.js +2 -2
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +7 -2
- package/out/modules/file-processing/handlers/custom-file-format.js +62 -22
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
- package/out/modules/file-processing/handlers/file-download.js +5 -0
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.js +41 -15
- package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -1
- package/out/modules/file-processing/handlers/translations-alignment.js +10 -4
- package/out/modules/file-processing/index.js +12 -2
- package/out/modules/file-processing/types.d.ts +36 -5
- package/out/modules/file-processing/util/defaults.js +50 -6
- package/out/modules/file-processing/util/files.js +2 -1
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.js +5 -1
- package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +5 -0
- package/out/modules/integration/handlers/crowdin-files-target-languages.js +103 -0
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.js +7 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.js +59 -18
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.js +15 -8
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.js +13 -6
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.js +8 -3
- package/out/modules/integration/handlers/integration-update.d.ts +1 -1
- package/out/modules/integration/handlers/integration-update.js +44 -6
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.js +3 -2
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/job-list.d.ts +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -1
- package/out/modules/integration/handlers/main.js +32 -2
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-login.js +28 -6
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.js +9 -9
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.js +5 -9
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -1
- package/out/modules/integration/index.js +19 -33
- package/out/modules/integration/types.d.ts +133 -29
- package/out/modules/integration/types.js +1 -0
- package/out/modules/integration/util/cron.d.ts +2 -2
- package/out/modules/integration/util/cron.js +40 -24
- package/out/modules/integration/util/defaults.d.ts +4 -0
- package/out/modules/integration/util/defaults.js +175 -15
- package/out/modules/integration/util/files.d.ts +2 -1
- package/out/modules/integration/util/files.js +19 -8
- package/out/modules/integration/util/job.js +4 -3
- package/out/modules/integration/util/snapshot.js +19 -3
- package/out/modules/integration/util/types.d.ts +1 -0
- package/out/modules/integration/util/types.js +1 -0
- package/out/modules/integration/util/webhooks.d.ts +8 -8
- package/out/modules/integration/util/webhooks.js +34 -17
- package/out/modules/manifest.js +12 -12
- package/out/modules/modal/index.js +2 -2
- package/out/modules/organization-menu/index.js +5 -4
- package/out/modules/organization-settings-menu/index.js +5 -4
- package/out/modules/profile-resources-menu/index.js +5 -4
- package/out/modules/profile-settings-menu/index.js +5 -4
- package/out/modules/project-menu/index.js +1 -1
- package/out/modules/project-menu-crowdsource/index.js +1 -1
- package/out/modules/project-reports/index.js +3 -2
- package/out/modules/project-tools/index.js +3 -2
- package/out/modules/status.d.ts +1 -1
- package/out/modules/status.js +12 -3
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/uninstall.d.ts +1 -1
- package/out/modules/uninstall.js +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +2 -2
- package/out/modules/webhooks/handlers/webhook-handler.js +33 -22
- package/out/modules/webhooks/types.d.ts +7 -0
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
- package/out/modules/workflow-step-type/index.js +2 -2
- package/out/modules/workflow-step-type/types.d.ts +1 -1
- package/out/modules/workflow-step-type/util/index.js +3 -6
- package/out/static/js/dependent.js +16 -7
- package/out/static/ui/error.bundle.js +474 -0
- package/out/static/ui/error.bundle.js.map +1 -0
- package/out/static/ui/install.bundle.js +459 -0
- package/out/static/ui/install.bundle.js.map +1 -0
- package/out/static/ui/login.bundle.js +630 -0
- package/out/static/ui/login.bundle.js.map +1 -0
- package/out/static/ui/main.bundle.js +2109 -0
- package/out/static/ui/main.bundle.js.map +1 -0
- package/out/static/ui/oauth.bundle.js +467 -0
- package/out/static/ui/oauth.bundle.js.map +1 -0
- package/out/storage/d1.d.ts +107 -0
- package/out/storage/d1.js +831 -0
- package/out/storage/index.js +8 -1
- package/out/storage/mysql.js +22 -19
- package/out/storage/postgre.d.ts +0 -1
- package/out/storage/postgre.js +20 -30
- package/out/storage/sqlite.d.ts +2 -5
- package/out/storage/sqlite.js +29 -69
- package/out/types.d.ts +80 -18
- package/out/util/connection.js +16 -5
- package/out/util/credentials-masker.d.ts +3 -3
- package/out/util/credentials-masker.js +14 -20
- package/out/util/cron.d.ts +29 -0
- package/out/util/cron.js +87 -0
- package/out/util/index.d.ts +14 -1
- package/out/util/index.js +121 -10
- package/out/util/jsx-renderer.d.ts +14 -0
- package/out/util/jsx-renderer.js +35 -0
- package/out/util/logger.d.ts +1 -0
- package/out/util/logger.js +2 -2
- package/out/util/static-files.d.ts +19 -0
- package/out/util/static-files.js +87 -0
- package/out/util/subscription.js +1 -1
- package/out/views/AboutPage.d.ts +10 -0
- package/out/views/AboutPage.js +76 -0
- package/out/views/FormPage.d.ts +14 -0
- package/out/views/FormPage.js +28 -0
- package/out/views/SubscriptionPage.d.ts +7 -0
- package/out/views/SubscriptionPage.js +26 -0
- package/out/views/index.d.ts +8 -0
- package/out/views/index.js +15 -0
- package/out/views/layout/Head.d.ts +9 -0
- package/out/views/layout/Head.js +54 -0
- package/package.json +43 -41
- package/out/util/handlebars.d.ts +0 -1
- package/out/util/handlebars.js +0 -46
- package/out/views/about.handlebars +0 -102
- package/out/views/error.handlebars +0 -54
- package/out/views/form.handlebars +0 -31
- package/out/views/install.handlebars +0 -16
- package/out/views/login.handlebars +0 -332
- package/out/views/main.handlebars +0 -2042
- package/out/views/oauth.handlebars +0 -11
- package/out/views/partials/head.handlebars +0 -53
- package/out/views/subscription.handlebars +0 -26
|
@@ -17,9 +17,9 @@ function register({ config, app }) {
|
|
|
17
17
|
}
|
|
18
18
|
if ((0, util_1.isAuthorizedConfig)(config)) {
|
|
19
19
|
if (config.customSpellchecker.settingsUiModule) {
|
|
20
|
-
app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
|
|
20
|
+
app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
|
|
21
21
|
// TEMPORARY CODE: it needs to support old path
|
|
22
|
-
app.use('/settings', (0, ui_module_1.default)({ config }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
|
|
22
|
+
app.use('/settings', (0, ui_module_1.default)({ config }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
|
|
23
23
|
// END TEMPORARY CODE
|
|
24
24
|
}
|
|
25
25
|
app.get('/spellchecker/languages', json_response_1.default, (0, crowdin_client_1.default)({
|
|
@@ -49,9 +49,9 @@ function register({ config, app }) {
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
if (config.customSpellchecker.settingsUiModule) {
|
|
52
|
-
app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
|
|
52
|
+
app.use('/spellchecker/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.customSpellchecker.key }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
|
|
53
53
|
// TEMPORARY CODE: it needs to support old path
|
|
54
|
-
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
|
|
54
|
+
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule, config));
|
|
55
55
|
// END TEMPORARY CODE
|
|
56
56
|
}
|
|
57
57
|
app.get('/spellchecker/languages', json_response_1.default, (0, get_languages_list_1.default)(config.customSpellchecker));
|
|
@@ -12,6 +12,6 @@ function register({ config, app }) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
|
-
app.use('/editor-panels', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.editorRightPanel.key }), (0, render_ui_module_1.default)(config.editorRightPanel));
|
|
15
|
+
app.use('/editor-panels', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.editorRightPanel.key }), (0, render_ui_module_1.default)(config.editorRightPanel, config));
|
|
16
16
|
}
|
|
17
17
|
exports.register = register;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { ExternalQaCheckModule } from '../types';
|
|
5
|
-
export default function handle(externalQaCheck: ExternalQaCheckModule): (req:
|
|
5
|
+
export default function handle(externalQaCheck: ExternalQaCheckModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -38,9 +38,9 @@ function register({ config, app }) {
|
|
|
38
38
|
}), (0, validate_1.default)(qaCheck));
|
|
39
39
|
// END TEMPORARY CODE
|
|
40
40
|
if (qaCheck.settingsUiModule) {
|
|
41
|
-
app.use('/qa-check/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
|
|
41
|
+
app.use('/qa-check/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: qaCheck.key }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule, config));
|
|
42
42
|
// TEMPORARY CODE: it needs to support old path
|
|
43
|
-
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule));
|
|
43
|
+
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true }), (0, render_ui_module_1.default)(qaCheck.settingsUiModule, config));
|
|
44
44
|
// END TEMPORARY CODE
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { CrowdinClientRequest } from '../../../types';
|
|
3
|
+
import { CrowdinClientRequest, FileStore } from '../../../types';
|
|
4
4
|
import { CustomFileFormatLogic } from '../types';
|
|
5
|
-
export default function handle(baseUrl
|
|
5
|
+
export default function handle({ baseUrl, folder, config, fileStore, }: {
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
folder: string;
|
|
8
|
+
config: CustomFileFormatLogic;
|
|
9
|
+
fileStore?: FileStore;
|
|
10
|
+
}): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -17,9 +17,11 @@ const path_1 = __importDefault(require("path"));
|
|
|
17
17
|
const util_1 = require("../../../util");
|
|
18
18
|
const files_1 = require("../util/files");
|
|
19
19
|
const types_1 = require("../types");
|
|
20
|
-
function handle(baseUrl, folder, config) {
|
|
21
|
-
if (!
|
|
22
|
-
fs_1.default.
|
|
20
|
+
function handle({ baseUrl, folder, config, fileStore, }) {
|
|
21
|
+
if (!fileStore) {
|
|
22
|
+
if (!fs_1.default.existsSync(path_1.default.join(folder, 'custom-file-format'))) {
|
|
23
|
+
fs_1.default.mkdirSync(path_1.default.join(folder, 'custom-file-format'), { recursive: true });
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
25
27
|
const baseFilesUrl = `${baseUrl}/file/download`;
|
|
@@ -43,12 +45,32 @@ function handle(baseUrl, folder, config) {
|
|
|
43
45
|
let error;
|
|
44
46
|
switch (body.jobType) {
|
|
45
47
|
case types_1.ProcessFileJobType.BUILD_FILE:
|
|
46
|
-
const buildFileResult = yield handleBuildFile(
|
|
48
|
+
const buildFileResult = yield handleBuildFile({
|
|
49
|
+
baseUrl: baseFilesUrl,
|
|
50
|
+
dataFolder: folder,
|
|
51
|
+
config,
|
|
52
|
+
req: body,
|
|
53
|
+
client: req.crowdinApiClient,
|
|
54
|
+
context: req.crowdinContext,
|
|
55
|
+
projectId: req.crowdinContext.jwtPayload.context.project_id,
|
|
56
|
+
file,
|
|
57
|
+
fileStore,
|
|
58
|
+
});
|
|
47
59
|
response = buildFileResult.response;
|
|
48
60
|
error = buildFileResult.error;
|
|
49
61
|
break;
|
|
50
62
|
case types_1.ProcessFileJobType.PARSE_FILE:
|
|
51
|
-
const parseFileResult = yield handleParseFile(
|
|
63
|
+
const parseFileResult = yield handleParseFile({
|
|
64
|
+
baseUrl: baseFilesUrl,
|
|
65
|
+
dataFolder: folder,
|
|
66
|
+
config,
|
|
67
|
+
req: body,
|
|
68
|
+
client: req.crowdinApiClient,
|
|
69
|
+
context: req.crowdinContext,
|
|
70
|
+
projectId: req.crowdinContext.jwtPayload.context.project_id,
|
|
71
|
+
file,
|
|
72
|
+
fileStore,
|
|
73
|
+
});
|
|
52
74
|
response = parseFileResult.response;
|
|
53
75
|
error = parseFileResult.error;
|
|
54
76
|
break;
|
|
@@ -59,7 +81,7 @@ function handle(baseUrl, folder, config) {
|
|
|
59
81
|
}));
|
|
60
82
|
}
|
|
61
83
|
exports.default = handle;
|
|
62
|
-
function handleBuildFile(baseUrl, dataFolder, config, req, client, context, projectId, file) {
|
|
84
|
+
function handleBuildFile({ baseUrl, dataFolder, config, req, client, context, projectId, file, fileStore, }) {
|
|
63
85
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
86
|
const response = {};
|
|
65
87
|
if (!req.strings && !req.stringsUrl) {
|
|
@@ -74,10 +96,10 @@ function handleBuildFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
74
96
|
}
|
|
75
97
|
let res;
|
|
76
98
|
if ((req.file.id || !file) && config.exportStrings) {
|
|
77
|
-
res = yield config.exportStrings(req, strings, client, context, projectId);
|
|
99
|
+
res = yield config.exportStrings({ request: req, strings, client, context, projectId });
|
|
78
100
|
}
|
|
79
101
|
else if (file && config.buildFile) {
|
|
80
|
-
res = yield config.buildFile(file, req, strings, client, context, projectId);
|
|
102
|
+
res = yield config.buildFile({ fileContent: file, request: req, strings, client, context, projectId });
|
|
81
103
|
}
|
|
82
104
|
else {
|
|
83
105
|
return { response };
|
|
@@ -88,25 +110,31 @@ function handleBuildFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
88
110
|
}
|
|
89
111
|
else {
|
|
90
112
|
let url;
|
|
91
|
-
if (
|
|
92
|
-
|
|
113
|
+
if (fileStore) {
|
|
114
|
+
const fileRef = yield fileStore.storeFile(res.contentFile);
|
|
115
|
+
url = `${baseUrl}?file=${fileRef}`;
|
|
93
116
|
}
|
|
94
117
|
else {
|
|
95
|
-
|
|
96
|
-
|
|
118
|
+
if (config.storeFile) {
|
|
119
|
+
url = yield config.storeFile(res.contentFile);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
const storedFile = yield (0, files_1.storeFile)(res.contentFile, path_1.default.join(dataFolder, 'custom-file-format'));
|
|
123
|
+
url = `${baseUrl}?file=${storedFile}`;
|
|
124
|
+
}
|
|
97
125
|
}
|
|
98
126
|
response.contentUrl = url;
|
|
99
127
|
}
|
|
100
128
|
return { response, error: res.error };
|
|
101
129
|
});
|
|
102
130
|
}
|
|
103
|
-
function handleParseFile(baseUrl, dataFolder, config, req, client, context, projectId, file) {
|
|
131
|
+
function handleParseFile({ baseUrl, dataFolder, config, req, client, context, projectId, file, fileStore, }) {
|
|
104
132
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
133
|
const response = {};
|
|
106
134
|
if (!config.parseFile || !file) {
|
|
107
135
|
return { response };
|
|
108
136
|
}
|
|
109
|
-
const res = yield config.parseFile(file, req, client, context, projectId);
|
|
137
|
+
const res = yield config.parseFile({ fileContent: file, request: req, client, context, projectId });
|
|
110
138
|
let maxSize = files_1.MAX_BODY_SIZE;
|
|
111
139
|
if (res.strings && res.previewFile) {
|
|
112
140
|
maxSize = maxSize / 2;
|
|
@@ -117,12 +145,18 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
117
145
|
}
|
|
118
146
|
else {
|
|
119
147
|
let url;
|
|
120
|
-
if (
|
|
121
|
-
|
|
148
|
+
if (fileStore) {
|
|
149
|
+
const fileRef = yield fileStore.storeFile(res.previewFile);
|
|
150
|
+
url = `${baseUrl}?file=${fileRef}`;
|
|
122
151
|
}
|
|
123
152
|
else {
|
|
124
|
-
|
|
125
|
-
|
|
153
|
+
if (config.storeFile) {
|
|
154
|
+
url = yield config.storeFile(res.previewFile);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const storedFile = yield (0, files_1.storeFile)(res.previewFile, path_1.default.join(dataFolder, 'custom-file-format'));
|
|
158
|
+
url = `${baseUrl}?file=${storedFile}`;
|
|
159
|
+
}
|
|
126
160
|
}
|
|
127
161
|
response.previewUrl = url;
|
|
128
162
|
}
|
|
@@ -145,12 +179,18 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
145
179
|
}
|
|
146
180
|
else {
|
|
147
181
|
let url;
|
|
148
|
-
if (
|
|
149
|
-
|
|
182
|
+
if (fileStore) {
|
|
183
|
+
const fileRef = yield fileStore.storeFile(bufferData);
|
|
184
|
+
url = `${baseUrl}?file=${fileRef}`;
|
|
150
185
|
}
|
|
151
186
|
else {
|
|
152
|
-
|
|
153
|
-
|
|
187
|
+
if (config.storeFile) {
|
|
188
|
+
url = yield config.storeFile(bufferData);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const storedFile = yield (0, files_1.storeFile)(bufferData, path_1.default.join(dataFolder, 'custom-file-format'));
|
|
192
|
+
url = `${baseUrl}?file=${storedFile}`;
|
|
193
|
+
}
|
|
154
194
|
}
|
|
155
195
|
response.stringsUrl = url;
|
|
156
196
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../../../types';
|
|
4
4
|
import { FileProcessLogic } from '../types';
|
|
5
|
-
export default function handle(config: Config, processingConfig: FileProcessLogic, folderName: string): (req:
|
|
5
|
+
export default function handle(config: Config, processingConfig: FileProcessLogic, folderName: string): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -19,6 +19,11 @@ 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* () {
|
|
22
|
+
if (config.fileStore) {
|
|
23
|
+
const fileContent = yield config.fileStore.getFile(req.query.file);
|
|
24
|
+
res.send(fileContent);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
22
27
|
const filePath = path_1.default.join(folder, folderName, req.query.file);
|
|
23
28
|
(0, logger_1.log)(`Downloading file ${filePath}`);
|
|
24
29
|
res.download(filePath, function (err) {
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { FileImportExportLogic } from '../types';
|
|
5
|
-
export default function handle(baseConfig: Config, config: FileImportExportLogic, folderName: string): (req:
|
|
5
|
+
export default function handle(baseConfig: Config, config: FileImportExportLogic, folderName: string): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -19,8 +19,10 @@ const types_1 = require("../types");
|
|
|
19
19
|
const files_1 = require("../util/files");
|
|
20
20
|
function handle(baseConfig, config, folderName) {
|
|
21
21
|
const folderPath = config.filesFolder || baseConfig.dbFolder;
|
|
22
|
-
if (!
|
|
23
|
-
fs_1.default.
|
|
22
|
+
if (!baseConfig.fileStore) {
|
|
23
|
+
if (!fs_1.default.existsSync(path_1.default.join(folderPath, folderName))) {
|
|
24
|
+
fs_1.default.mkdirSync(path_1.default.join(folderPath, folderName), { recursive: true });
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
26
28
|
var _a;
|
|
@@ -57,7 +59,13 @@ function handle(baseConfig, config, folderName) {
|
|
|
57
59
|
return rawContent;
|
|
58
60
|
});
|
|
59
61
|
}
|
|
60
|
-
const fileProcessResult = yield config.fileProcess(
|
|
62
|
+
const fileProcessResult = yield config.fileProcess({
|
|
63
|
+
request: body,
|
|
64
|
+
content: fileContent,
|
|
65
|
+
client: req.crowdinApiClient,
|
|
66
|
+
context: req.crowdinContext,
|
|
67
|
+
projectId: req.crowdinContext.jwtPayload.context.project_id,
|
|
68
|
+
});
|
|
61
69
|
if (fileProcessResult.notModified) {
|
|
62
70
|
res.sendStatus(304);
|
|
63
71
|
return;
|
|
@@ -72,12 +80,18 @@ function handle(baseConfig, config, folderName) {
|
|
|
72
80
|
}
|
|
73
81
|
else {
|
|
74
82
|
let url;
|
|
75
|
-
if (
|
|
76
|
-
|
|
83
|
+
if (baseConfig.fileStore) {
|
|
84
|
+
const fileRef = yield baseConfig.fileStore.storeFile(contentFile);
|
|
85
|
+
url = `${baseFilesUrl}?file=${fileRef}`;
|
|
77
86
|
}
|
|
78
87
|
else {
|
|
79
|
-
|
|
80
|
-
|
|
88
|
+
if (config.storeFile) {
|
|
89
|
+
url = yield config.storeFile(contentFile);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const storedFile = yield (0, files_1.storeFile)(contentFile, path_1.default.join(folderPath, folderName));
|
|
93
|
+
url = `${baseFilesUrl}?file=${storedFile}`;
|
|
94
|
+
}
|
|
81
95
|
}
|
|
82
96
|
response.contentUrl = url;
|
|
83
97
|
}
|
|
@@ -103,12 +117,18 @@ function handle(baseConfig, config, folderName) {
|
|
|
103
117
|
}
|
|
104
118
|
else {
|
|
105
119
|
let url;
|
|
106
|
-
if (
|
|
107
|
-
|
|
120
|
+
if (baseConfig.fileStore) {
|
|
121
|
+
const fileRef = yield baseConfig.fileStore.storeFile(previewFile);
|
|
122
|
+
url = `${baseFilesUrl}?file=${fileRef}`;
|
|
108
123
|
}
|
|
109
124
|
else {
|
|
110
|
-
|
|
111
|
-
|
|
125
|
+
if (config.storeFile) {
|
|
126
|
+
url = yield config.storeFile(previewFile);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const storedFile = yield (0, files_1.storeFile)(previewFile, path_1.default.join(folderPath, folderName));
|
|
130
|
+
url = `${baseFilesUrl}?file=${storedFile}`;
|
|
131
|
+
}
|
|
112
132
|
}
|
|
113
133
|
response.previewUrl = url;
|
|
114
134
|
}
|
|
@@ -121,12 +141,18 @@ function handle(baseConfig, config, folderName) {
|
|
|
121
141
|
}
|
|
122
142
|
else {
|
|
123
143
|
let url;
|
|
124
|
-
if (
|
|
125
|
-
|
|
144
|
+
if (baseConfig.fileStore) {
|
|
145
|
+
const fileRef = yield baseConfig.fileStore.storeFile(bufferData);
|
|
146
|
+
url = `${baseFilesUrl}?file=${fileRef}`;
|
|
126
147
|
}
|
|
127
148
|
else {
|
|
128
|
-
|
|
129
|
-
|
|
149
|
+
if (config.storeFile) {
|
|
150
|
+
url = yield config.storeFile(bufferData);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const storedFile = yield (0, files_1.storeFile)(bufferData, path_1.default.join(folderPath, folderName));
|
|
154
|
+
url = `${baseFilesUrl}?file=${storedFile}`;
|
|
155
|
+
}
|
|
130
156
|
}
|
|
131
157
|
response.stringsUrl = url;
|
|
132
158
|
}
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { Config, CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { TranslationsAlignmentLogic } from '../types';
|
|
5
|
-
export default function handle(baseConfig: Config, config: TranslationsAlignmentLogic, folderName: string): (req:
|
|
5
|
+
export default function handle(baseConfig: Config, config: TranslationsAlignmentLogic, folderName: string): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -37,10 +37,16 @@ function handle(baseConfig, config, folderName) {
|
|
|
37
37
|
const fileTranslationsContent = body.translationStringsUrl
|
|
38
38
|
? (yield (0, files_1.getFileStrings)(body.translationStringsUrl))
|
|
39
39
|
: body.translationStrings;
|
|
40
|
-
const fileProcessResult = yield config.fileProcess(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const fileProcessResult = yield config.fileProcess({
|
|
41
|
+
request: body,
|
|
42
|
+
content: {
|
|
43
|
+
sourceStrings: fileSourceStringsContent,
|
|
44
|
+
translations: fileTranslationsContent,
|
|
45
|
+
},
|
|
46
|
+
client: req.crowdinApiClient,
|
|
47
|
+
context: req.crowdinContext,
|
|
48
|
+
projectId: req.crowdinContext.jwtPayload.context.project_id,
|
|
49
|
+
});
|
|
44
50
|
const { strings, error: processingErrorMessage } = fileProcessResult;
|
|
45
51
|
if (!strings) {
|
|
46
52
|
response.translations = [];
|
|
@@ -21,13 +21,23 @@ function registerCustomFileFormat({ config, app }) {
|
|
|
21
21
|
optional: false,
|
|
22
22
|
checkSubscriptionExpiration: true,
|
|
23
23
|
moduleKey: config.customFileFormat.key,
|
|
24
|
-
}), (0, custom_file_format_1.default)(
|
|
24
|
+
}), (0, custom_file_format_1.default)({
|
|
25
|
+
baseUrl: config.baseUrl,
|
|
26
|
+
folder: config.customFileFormat.filesFolder || config.dbFolder,
|
|
27
|
+
config: config.customFileFormat,
|
|
28
|
+
fileStore: config.fileStore,
|
|
29
|
+
}));
|
|
25
30
|
// TEMPORARY CODE: it needs to support old path
|
|
26
31
|
app.post('/process', (0, crowdin_client_1.default)({
|
|
27
32
|
config,
|
|
28
33
|
optional: false,
|
|
29
34
|
checkSubscriptionExpiration: true,
|
|
30
|
-
}), (0, custom_file_format_1.default)(
|
|
35
|
+
}), (0, custom_file_format_1.default)({
|
|
36
|
+
baseUrl: config.baseUrl,
|
|
37
|
+
folder: config.customFileFormat.filesFolder || config.dbFolder,
|
|
38
|
+
config: config.customFileFormat,
|
|
39
|
+
fileStore: config.fileStore,
|
|
40
|
+
}));
|
|
31
41
|
// END TEMPORARY CODE
|
|
32
42
|
app.get('/file/download', (0, file_download_1.default)(config, config.customFileFormat, 'custom-file-format'));
|
|
33
43
|
}
|
|
@@ -48,15 +48,34 @@ export interface CustomFileFormatLogic extends FileProcessLogic {
|
|
|
48
48
|
/**
|
|
49
49
|
* Used for initial source file upload, source file update, and translation upload
|
|
50
50
|
*/
|
|
51
|
-
parseFile?: (
|
|
51
|
+
parseFile?: (options: {
|
|
52
|
+
fileContent: Buffer;
|
|
53
|
+
request: Omit<ProcessFileRequest, 'jobType' | 'file'>;
|
|
54
|
+
client: Crowdin;
|
|
55
|
+
context: CrowdinContextInfo;
|
|
56
|
+
projectId: number;
|
|
57
|
+
}) => Promise<ParseFileResponse>;
|
|
52
58
|
/**
|
|
53
59
|
* Used for translation download
|
|
54
60
|
*/
|
|
55
|
-
buildFile?: (
|
|
61
|
+
buildFile?: (options: {
|
|
62
|
+
fileContent: Buffer;
|
|
63
|
+
request: Omit<ProcessFileRequest, 'jobType' | 'file'>;
|
|
64
|
+
strings: ProcessFileString[];
|
|
65
|
+
client: Crowdin;
|
|
66
|
+
context: CrowdinContextInfo;
|
|
67
|
+
projectId: number;
|
|
68
|
+
}) => Promise<BuildFileResponse>;
|
|
56
69
|
/**
|
|
57
70
|
* Used for strings export
|
|
58
71
|
*/
|
|
59
|
-
exportStrings?: (
|
|
72
|
+
exportStrings?: (options: {
|
|
73
|
+
request: Omit<ProcessFileRequest, 'jobType'>;
|
|
74
|
+
strings: ProcessFileString[];
|
|
75
|
+
client: Crowdin;
|
|
76
|
+
context: CrowdinContextInfo;
|
|
77
|
+
projectId: number;
|
|
78
|
+
}) => Promise<BuildFileResponse>;
|
|
60
79
|
}
|
|
61
80
|
export type FileImportExportLogic = FilePreImportLogic | FilePostImportLogic | FilePreExportLogic | FilePostExportLogic;
|
|
62
81
|
export type FileImportExportContent = ProcessFileString[] | Buffer | undefined;
|
|
@@ -66,10 +85,22 @@ export interface FileTranslationAlignmentContent {
|
|
|
66
85
|
translations: TranslationAlignmentContent;
|
|
67
86
|
}
|
|
68
87
|
export interface BaseFileProcessLogic<T> {
|
|
69
|
-
fileProcess: (
|
|
88
|
+
fileProcess: (options: {
|
|
89
|
+
request: ProcessFileRequest;
|
|
90
|
+
content: FileImportExportContent;
|
|
91
|
+
client: Crowdin;
|
|
92
|
+
context: CrowdinContextInfo;
|
|
93
|
+
projectId: number;
|
|
94
|
+
}) => Promise<T>;
|
|
70
95
|
}
|
|
71
96
|
export interface TranslationAlignmentProcessLogin<T> {
|
|
72
|
-
fileProcess: (
|
|
97
|
+
fileProcess: (options: {
|
|
98
|
+
request: ProcessTranslationAlignmentRequest;
|
|
99
|
+
content: FileTranslationAlignmentContent;
|
|
100
|
+
client: Crowdin;
|
|
101
|
+
context: CrowdinContextInfo;
|
|
102
|
+
projectId: number;
|
|
103
|
+
}) => Promise<T>;
|
|
73
104
|
}
|
|
74
105
|
export interface FilePreImportLogic extends FileProcessLogic, BaseFileProcessLogic<ContentFileResponse> {
|
|
75
106
|
/**
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,20 +33,41 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
33
|
};
|
|
11
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
35
|
exports.applyFileProcessorsModuleDefaults = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
36
|
+
function loadAwsSdk() {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
try {
|
|
39
|
+
const [s3Client, s3Presigner] = yield Promise.all([
|
|
40
|
+
Promise.resolve().then(() => __importStar(require('@aws-sdk/client-s3'))),
|
|
41
|
+
Promise.resolve().then(() => __importStar(require('@aws-sdk/s3-request-presigner'))),
|
|
42
|
+
]);
|
|
43
|
+
return {
|
|
44
|
+
S3Client: s3Client.S3Client,
|
|
45
|
+
GetObjectCommand: s3Client.GetObjectCommand,
|
|
46
|
+
PutObjectCommand: s3Client.PutObjectCommand,
|
|
47
|
+
getSignedUrl: s3Presigner.getSignedUrl,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (_a) {
|
|
51
|
+
throw new Error('AWS SDK is not installed. To use S3 file storage, install required packages:\n' +
|
|
52
|
+
'npm install @aws-sdk/client-s3 @aws-sdk/s3-request-presigner');
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
15
56
|
function applyFileProcessorsModuleDefaults(config, fileModule) {
|
|
16
57
|
var _a, _b;
|
|
17
58
|
const AWS_TMP_BUCKET_NAME = (_a = config.awsConfig) === null || _a === void 0 ? void 0 : _a.tmpBucketName;
|
|
18
59
|
const AWS_REGION = (_b = config.awsConfig) === null || _b === void 0 ? void 0 : _b.region;
|
|
19
60
|
if (AWS_TMP_BUCKET_NAME && AWS_REGION && !fileModule.storeFile) {
|
|
20
|
-
|
|
61
|
+
let initPromise = null;
|
|
62
|
+
const getS3 = () => (initPromise !== null && initPromise !== void 0 ? initPromise : (initPromise = loadAwsSdk().then((sdk) => ({ sdk, s3: new sdk.S3Client({ region: AWS_REGION }) }))));
|
|
21
63
|
fileModule.storeFile = (content) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
const { sdk, s3 } = yield getS3();
|
|
65
|
+
const { GetObjectCommand, PutObjectCommand, getSignedUrl } = sdk;
|
|
22
66
|
const fileName = `file-${config.identifier}-${Date.now()}`;
|
|
23
|
-
const command = new
|
|
67
|
+
const command = new PutObjectCommand({ Bucket: AWS_TMP_BUCKET_NAME, Key: fileName, Body: content });
|
|
24
68
|
yield s3.send(command);
|
|
25
|
-
const getObjectCommand = new
|
|
26
|
-
return
|
|
69
|
+
const getObjectCommand = new GetObjectCommand({ Bucket: AWS_TMP_BUCKET_NAME, Key: fileName });
|
|
70
|
+
return getSignedUrl(s3, getObjectCommand, { expiresIn: 3600 });
|
|
27
71
|
});
|
|
28
72
|
}
|
|
29
73
|
}
|
|
@@ -32,7 +32,8 @@ exports.storeFile = storeFile;
|
|
|
32
32
|
function getFileContent(url) {
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const response = (yield axios_1.default.get(url, { responseType: 'arraybuffer' })).data;
|
|
35
|
-
|
|
35
|
+
// Support for both Node.js (returns Buffer) and Cloudflare Workers (returns ArrayBuffer)
|
|
36
|
+
return Buffer.isBuffer(response) ? response : Buffer.from(response);
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
exports.getFileContent = getFileContent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Config, CrowdinClientRequest } from '../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Config, CrowdinClientRequest } from '../types';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
package/out/modules/install.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
3
|
import { Config } from '../types';
|
|
4
|
-
export default function handle(config: Config): (req:
|
|
4
|
+
export default function handle(config: Config): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { IntegrationLogic } from '../types';
|
|
5
|
-
export default function handle(integration: IntegrationLogic): (req:
|
|
5
|
+
export default function handle(integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -24,7 +24,11 @@ function handle(integration) {
|
|
|
24
24
|
req.logInfo(`Loading translation progress for file ${fileId}`);
|
|
25
25
|
if (integration.getFileProgress) {
|
|
26
26
|
try {
|
|
27
|
-
const progress = yield integration.getFileProgress(
|
|
27
|
+
const progress = yield integration.getFileProgress({
|
|
28
|
+
projectId: req.crowdinContext.jwtPayload.context.project_id,
|
|
29
|
+
client: req.crowdinApiClient,
|
|
30
|
+
fileId,
|
|
31
|
+
});
|
|
28
32
|
req.logInfo(`Translation progress for file ${fileId} ${JSON.stringify(progress, null, 2)}`);
|
|
29
33
|
res.send(progress);
|
|
30
34
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { Config } from '../../../types';
|
|
4
|
+
import { IntegrationLogic } from '../types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../../../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|