@crowdin/app-project-module 0.28.0-13 → 0.28.0-2
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/CONTRIBUTING.md +1 -19
- package/README.md +984 -1
- package/out/handlers/crowdin-webhook.js +1 -1
- package/out/handlers/custom-file-format/download.d.ts +4 -0
- package/out/handlers/{file-processing/file-download.js → custom-file-format/download.js} +2 -3
- package/out/handlers/{file-processing/custom-file-format.js → custom-file-format/process.js} +23 -8
- package/out/handlers/form-data-display.js +2 -6
- package/out/handlers/form-data-save.js +1 -5
- package/out/handlers/manifest.js +0 -36
- package/out/index.d.ts +3 -3
- package/out/index.js +26 -49
- package/out/middlewares/render-ui-module.js +1 -3
- package/out/models/index.d.ts +28 -71
- package/out/models/index.js +0 -4
- package/out/static/js/form.js +9 -9
- package/out/storage/index.js +7 -4
- package/out/util/cron.js +1 -5
- package/out/util/defaults.d.ts +2 -3
- package/out/util/defaults.js +4 -21
- package/out/util/index.js +1 -5
- package/out/util/webhooks.js +4 -15
- package/out/views/form.handlebars +2 -6
- package/package.json +15 -15
- package/rollup.config.mjs +31 -0
- package/out/handlers/file-processing/file-download.d.ts +0 -4
- package/out/handlers/file-processing/pre-post-process.d.ts +0 -4
- package/out/handlers/file-processing/pre-post-process.js +0 -99
- package/out/util/files.d.ts +0 -3
- package/out/util/files.js +0 -43
- /package/out/handlers/{file-processing/custom-file-format.d.ts → custom-file-format/process.d.ts} +0 -0
|
@@ -26,7 +26,7 @@ function handle(config, integration) {
|
|
|
26
26
|
return res.status(200).send({ message: 'Sync is not configured' });
|
|
27
27
|
}
|
|
28
28
|
if ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.crowdinWebhookInterceptor) {
|
|
29
|
-
filesToSync = yield integration.webhooks.crowdinWebhookInterceptor(projectId, crowdinClient.client, rootFolder, appSettings, syncSettings
|
|
29
|
+
filesToSync = yield integration.webhooks.crowdinWebhookInterceptor(projectId, crowdinClient.client, rootFolder, appSettings, syncSettings);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
filesToSync = (0, webhooks_1.filterSyncFiles)(req.body.events, JSON.parse(syncSettings.files));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { Config } from '../../models';
|
|
4
|
+
export default function handle(config: Config, folder: string): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -15,10 +15,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const fs_1 = __importDefault(require("fs"));
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const util_1 = require("../../util");
|
|
18
|
-
function handle(config,
|
|
19
|
-
const folder = processingConfig.filesFolder || config.dbFolder;
|
|
18
|
+
function handle(config, folder) {
|
|
20
19
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const filePath = path_1.default.join(folder,
|
|
20
|
+
const filePath = path_1.default.join(folder, 'custom-file-format', req.query.file);
|
|
22
21
|
(0, util_1.log)(`Downloading file ${filePath}`, config.logger);
|
|
23
22
|
res.download(filePath, function (err) {
|
|
24
23
|
if (err) {
|
package/out/handlers/{file-processing/custom-file-format.js → custom-file-format/process.js}
RENAMED
|
@@ -12,11 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
15
16
|
const fs_1 = __importDefault(require("fs"));
|
|
16
17
|
const path_1 = __importDefault(require("path"));
|
|
17
18
|
const models_1 = require("../../models");
|
|
18
19
|
const util_1 = require("../../util");
|
|
19
|
-
const
|
|
20
|
+
const MAX_BODY_SIZE = 4.9 * 1024 * 1024; //4.9mb
|
|
20
21
|
function handle(baseConfig, baseUrl, folder, config) {
|
|
21
22
|
if (!fs_1.default.existsSync(path_1.default.join(folder, 'custom-file-format'))) {
|
|
22
23
|
fs_1.default.mkdirSync(path_1.default.join(folder, 'custom-file-format'), { recursive: true });
|
|
@@ -37,7 +38,7 @@ function handle(baseConfig, baseUrl, folder, config) {
|
|
|
37
38
|
file = Buffer.from(body.file.content, 'base64').toString();
|
|
38
39
|
}
|
|
39
40
|
else if (body.file.contentUrl) {
|
|
40
|
-
file = yield
|
|
41
|
+
file = (yield axios_1.default.get(body.file.contentUrl)).data;
|
|
41
42
|
}
|
|
42
43
|
let response = {};
|
|
43
44
|
let error;
|
|
@@ -70,7 +71,10 @@ function handleBuildFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
70
71
|
strings = req.strings;
|
|
71
72
|
}
|
|
72
73
|
else {
|
|
73
|
-
|
|
74
|
+
// the response is presented in the ndjson format
|
|
75
|
+
const response = (yield axios_1.default.get(req.stringsUrl)).data;
|
|
76
|
+
const jsonRows = response.split(/\n|\n\r/).filter(Boolean);
|
|
77
|
+
strings = jsonRows.map((jsonStringRow) => JSON.parse(jsonStringRow));
|
|
74
78
|
}
|
|
75
79
|
let res;
|
|
76
80
|
if ((req.file.id || !file) && config.exportStrings) {
|
|
@@ -83,7 +87,7 @@ function handleBuildFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
83
87
|
return { response };
|
|
84
88
|
}
|
|
85
89
|
const contentFileEncoded = Buffer.from(res.contentFile).toString('base64');
|
|
86
|
-
if (Buffer.byteLength(contentFileEncoded, 'utf8') <
|
|
90
|
+
if (Buffer.byteLength(contentFileEncoded, 'utf8') < MAX_BODY_SIZE) {
|
|
87
91
|
response.content = contentFileEncoded;
|
|
88
92
|
}
|
|
89
93
|
else {
|
|
@@ -92,7 +96,7 @@ function handleBuildFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
92
96
|
url = yield config.storeFile(res.contentFile);
|
|
93
97
|
}
|
|
94
98
|
else {
|
|
95
|
-
const storedFile = yield
|
|
99
|
+
const storedFile = yield storeFile(res.contentFile, dataFolder);
|
|
96
100
|
url = `${baseUrl}?file=${storedFile}`;
|
|
97
101
|
}
|
|
98
102
|
response.contentUrl = url;
|
|
@@ -107,7 +111,7 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
107
111
|
return { response };
|
|
108
112
|
}
|
|
109
113
|
const res = yield config.parseFile(file, req, client, context, projectId);
|
|
110
|
-
let maxSize =
|
|
114
|
+
let maxSize = MAX_BODY_SIZE;
|
|
111
115
|
if (res.strings && res.previewFile) {
|
|
112
116
|
maxSize = maxSize / 2;
|
|
113
117
|
}
|
|
@@ -122,7 +126,7 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
122
126
|
url = yield config.storeFile(res.previewFile);
|
|
123
127
|
}
|
|
124
128
|
else {
|
|
125
|
-
const storedFile = yield
|
|
129
|
+
const storedFile = yield storeFile(res.previewFile, dataFolder);
|
|
126
130
|
url = `${baseUrl}?file=${storedFile}`;
|
|
127
131
|
}
|
|
128
132
|
response.previewUrl = url;
|
|
@@ -149,7 +153,7 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
149
153
|
url = yield config.storeFile(stringsNDJson);
|
|
150
154
|
}
|
|
151
155
|
else {
|
|
152
|
-
const storedFile = yield
|
|
156
|
+
const storedFile = yield storeFile(stringsNDJson, dataFolder);
|
|
153
157
|
url = `${baseUrl}?file=${storedFile}`;
|
|
154
158
|
}
|
|
155
159
|
response.stringsUrl = url;
|
|
@@ -158,3 +162,14 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
|
|
|
158
162
|
return { response, error: res.error };
|
|
159
163
|
});
|
|
160
164
|
}
|
|
165
|
+
function storeFile(fileContent, folder) {
|
|
166
|
+
const fileName = `file${Date.now()}`;
|
|
167
|
+
return new Promise((res, rej) => fs_1.default.writeFile(path_1.default.join(folder, 'custom-file-format', fileName), fileContent, (err) => {
|
|
168
|
+
if (err) {
|
|
169
|
+
rej(err);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
res(fileName);
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -39,7 +35,7 @@ function handle() {
|
|
|
39
35
|
const id = req.query.id;
|
|
40
36
|
const data = (yield storage.getStorage().getMetadata(id)) || {};
|
|
41
37
|
return res.send({
|
|
42
|
-
|
|
38
|
+
data,
|
|
43
39
|
});
|
|
44
40
|
}));
|
|
45
41
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
package/out/handlers/manifest.js
CHANGED
|
@@ -31,42 +31,6 @@ function handle(config) {
|
|
|
31
31
|
},
|
|
32
32
|
];
|
|
33
33
|
}
|
|
34
|
-
if (config.filePreImport) {
|
|
35
|
-
modules['file-pre-import'] = [
|
|
36
|
-
{
|
|
37
|
-
key: config.identifier + '-pri',
|
|
38
|
-
signaturePatterns: config.filePreImport.signaturePatterns,
|
|
39
|
-
url: '/pre-import',
|
|
40
|
-
},
|
|
41
|
-
];
|
|
42
|
-
}
|
|
43
|
-
if (config.filePostImport) {
|
|
44
|
-
modules['file-post-import'] = [
|
|
45
|
-
{
|
|
46
|
-
key: config.identifier + '-poi',
|
|
47
|
-
signaturePatterns: config.filePostImport.signaturePatterns,
|
|
48
|
-
url: '/post-import',
|
|
49
|
-
},
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
if (config.filePreExport) {
|
|
53
|
-
modules['file-pre-export'] = [
|
|
54
|
-
{
|
|
55
|
-
key: config.identifier + '-pre',
|
|
56
|
-
signaturePatterns: config.filePreExport.signaturePatterns,
|
|
57
|
-
url: '/pre-export',
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
-
if (config.filePostExport) {
|
|
62
|
-
modules['file-post-export'] = [
|
|
63
|
-
{
|
|
64
|
-
key: config.identifier + '-poe',
|
|
65
|
-
signaturePatterns: config.filePostExport.signaturePatterns,
|
|
66
|
-
url: '/post-export',
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
}
|
|
70
34
|
if (config.customMT) {
|
|
71
35
|
modules['custom-mt'] = [
|
|
72
36
|
{
|
package/out/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
import {
|
|
2
|
+
import { Config, CrowdinAppUtilities } from './models';
|
|
3
3
|
export { Scope } from './models';
|
|
4
|
-
export declare function addCrowdinEndpoints(app: Express,
|
|
5
|
-
export declare function createApp(
|
|
4
|
+
export declare function addCrowdinEndpoints(app: Express, plainConfig: Config): CrowdinAppUtilities;
|
|
5
|
+
export declare function createApp(config: Config): void;
|
package/out/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
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);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -45,23 +41,22 @@ const crowdin_files_1 = __importDefault(require("./handlers/crowdin-files"));
|
|
|
45
41
|
const crowdin_project_1 = __importDefault(require("./handlers/crowdin-project"));
|
|
46
42
|
const crowdin_update_1 = __importDefault(require("./handlers/crowdin-update"));
|
|
47
43
|
const crowdin_webhook_1 = __importDefault(require("./handlers/crowdin-webhook"));
|
|
44
|
+
const integration_webhook_1 = __importDefault(require("./handlers/integration-webhook"));
|
|
45
|
+
const download_1 = __importDefault(require("./handlers/custom-file-format/download"));
|
|
46
|
+
const process_1 = __importDefault(require("./handlers/custom-file-format/process"));
|
|
48
47
|
const translate_1 = __importDefault(require("./handlers/custom-mt/translate"));
|
|
49
|
-
const custom_file_format_1 = __importDefault(require("./handlers/file-processing/custom-file-format"));
|
|
50
|
-
const file_download_1 = __importDefault(require("./handlers/file-processing/file-download"));
|
|
51
|
-
const pre_post_process_1 = __importDefault(require("./handlers/file-processing/pre-post-process"));
|
|
52
|
-
const form_data_display_1 = __importDefault(require("./handlers/form-data-display"));
|
|
53
|
-
const form_data_save_1 = __importDefault(require("./handlers/form-data-save"));
|
|
54
48
|
const install_1 = __importDefault(require("./handlers/install"));
|
|
55
49
|
const integration_data_1 = __importDefault(require("./handlers/integration-data"));
|
|
56
50
|
const integration_login_1 = __importDefault(require("./handlers/integration-login"));
|
|
57
51
|
const integration_logout_1 = __importDefault(require("./handlers/integration-logout"));
|
|
58
52
|
const integration_update_1 = __importDefault(require("./handlers/integration-update"));
|
|
59
|
-
const integration_webhook_1 = __importDefault(require("./handlers/integration-webhook"));
|
|
60
53
|
const main_1 = __importDefault(require("./handlers/main"));
|
|
61
54
|
const manifest_1 = __importDefault(require("./handlers/manifest"));
|
|
62
55
|
const oauth_login_1 = __importDefault(require("./handlers/oauth-login"));
|
|
63
56
|
const oauth_url_1 = __importDefault(require("./handlers/oauth-url"));
|
|
64
57
|
const settings_save_1 = __importDefault(require("./handlers/settings-save"));
|
|
58
|
+
const form_data_display_1 = __importDefault(require("./handlers/form-data-display"));
|
|
59
|
+
const form_data_save_1 = __importDefault(require("./handlers/form-data-save"));
|
|
65
60
|
const subscription_info_1 = __importDefault(require("./handlers/subscription-info"));
|
|
66
61
|
const subscription_paid_1 = __importDefault(require("./handlers/subscription-paid"));
|
|
67
62
|
const sync_settings_1 = __importDefault(require("./handlers/sync-settings"));
|
|
@@ -70,23 +65,22 @@ const uninstall_1 = __importDefault(require("./handlers/uninstall"));
|
|
|
70
65
|
const crowdin_client_1 = __importStar(require("./middlewares/crowdin-client"));
|
|
71
66
|
const integration_credentials_1 = __importDefault(require("./middlewares/integration-credentials"));
|
|
72
67
|
const json_response_1 = __importDefault(require("./middlewares/json-response"));
|
|
73
|
-
const render_ui_module_1 = __importDefault(require("./middlewares/render-ui-module"));
|
|
74
68
|
const ui_module_1 = __importDefault(require("./middlewares/ui-module"));
|
|
75
|
-
const
|
|
69
|
+
const render_ui_module_1 = __importDefault(require("./middlewares/render-ui-module"));
|
|
76
70
|
const storage = __importStar(require("./storage"));
|
|
77
71
|
const util_1 = require("./util");
|
|
78
72
|
const connection_1 = require("./util/connection");
|
|
79
73
|
const cron_1 = require("./util/cron");
|
|
80
74
|
const defaults_1 = require("./util/defaults");
|
|
81
75
|
const webhooks_1 = require("./util/webhooks");
|
|
82
|
-
var
|
|
83
|
-
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return
|
|
84
|
-
function addCrowdinEndpoints(app,
|
|
76
|
+
var models_1 = require("./models");
|
|
77
|
+
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return models_1.Scope; } });
|
|
78
|
+
function addCrowdinEndpoints(app, plainConfig) {
|
|
85
79
|
var _a, _b, _c;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
handleUncaughtErrors(config);
|
|
80
|
+
if (!plainConfig.disableGlobalErrorHandling) {
|
|
81
|
+
handleUncaughtErrors(plainConfig);
|
|
89
82
|
}
|
|
83
|
+
const config = Object.assign(Object.assign({}, plainConfig), { baseUrl: plainConfig.baseUrl.endsWith('/') ? plainConfig.baseUrl.slice(0, -1) : plainConfig.baseUrl });
|
|
90
84
|
storage.initialize(config);
|
|
91
85
|
app.use(express_1.default.json({ limit: '50mb' }));
|
|
92
86
|
app.use('/assets', express_1.default.static((0, path_1.join)(__dirname, 'static')));
|
|
@@ -119,7 +113,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
119
113
|
},
|
|
120
114
|
}));
|
|
121
115
|
app.set('view engine', 'handlebars');
|
|
122
|
-
app.get('/logo.png', (req, res) => res.sendFile(config.imagePath));
|
|
116
|
+
app.get('/logo.png', (req, res) => res.sendFile(config.imagePath || (0, path_1.join)(__dirname, 'logo.png')));
|
|
123
117
|
app.post('/installed', (0, install_1.default)(config));
|
|
124
118
|
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
125
119
|
app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
|
|
@@ -128,8 +122,8 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
128
122
|
}
|
|
129
123
|
const integrationLogic = config.projectIntegration;
|
|
130
124
|
if (integrationLogic) {
|
|
131
|
-
(0, defaults_1.
|
|
132
|
-
app.get('/logo/integration/logo.png', (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath));
|
|
125
|
+
(0, defaults_1.applyDefaults)(config, integrationLogic);
|
|
126
|
+
app.get('/logo/integration/logo.png', (req, res) => res.sendFile(integrationLogic.imagePath || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')));
|
|
133
127
|
app.get('/', (0, crowdin_client_1.default)(config, true, false), (0, integration_credentials_1.default)(config, integrationLogic, true), (0, main_1.default)(config, integrationLogic));
|
|
134
128
|
app.get('/api/subscription-info', json_response_1.default, (0, crowdin_client_1.default)(config), (0, subscription_info_1.default)(config));
|
|
135
129
|
app.post('/api/settings', (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, settings_save_1.default)(config, integrationLogic));
|
|
@@ -169,40 +163,24 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
169
163
|
: '/api/integration/webhook'}`, (0, integration_webhook_1.default)(config, integrationLogic));
|
|
170
164
|
}
|
|
171
165
|
if ((_c = integrationLogic.webhooks) === null || _c === void 0 ? void 0 : _c.queueUrl) {
|
|
172
|
-
(0, webhooks_1.listenQueueMessage)(config, integrationLogic, integrationLogic.webhooks.queueUrl, config.
|
|
166
|
+
(0, webhooks_1.listenQueueMessage)(config, integrationLogic, integrationLogic.webhooks.queueUrl, config.name);
|
|
173
167
|
}
|
|
174
168
|
}
|
|
175
169
|
}
|
|
176
170
|
if (config.customFileFormat) {
|
|
177
|
-
app.post('/process', (0, crowdin_client_1.default)(config), (0,
|
|
178
|
-
app.get('/file/download', (0,
|
|
179
|
-
}
|
|
180
|
-
if (config.filePreImport) {
|
|
181
|
-
app.post('/pre-import', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePreImport, models_1.ProcessFileJobType.PRE_IMPORT));
|
|
182
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.PRE_IMPORT}`, (0, file_download_1.default)(config, config.filePreImport, models_1.ProcessFileJobType.PRE_IMPORT));
|
|
183
|
-
}
|
|
184
|
-
if (config.filePostImport) {
|
|
185
|
-
app.post('/post-import', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePostImport, models_1.ProcessFileJobType.POST_IMPORT));
|
|
186
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.POST_IMPORT}`, (0, file_download_1.default)(config, config.filePostImport, models_1.ProcessFileJobType.POST_IMPORT));
|
|
187
|
-
}
|
|
188
|
-
if (config.filePreExport) {
|
|
189
|
-
app.post('/pre-export', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePreExport, models_1.ProcessFileJobType.PRE_EXPORT));
|
|
190
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.PRE_EXPORT}`, (0, file_download_1.default)(config, config.filePreExport, models_1.ProcessFileJobType.PRE_EXPORT));
|
|
191
|
-
}
|
|
192
|
-
if (config.filePostExport) {
|
|
193
|
-
app.post('/post-export', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePostExport, models_1.ProcessFileJobType.POST_EXPORT));
|
|
194
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.POST_EXPORT}`, (0, file_download_1.default)(config, config.filePostExport, models_1.ProcessFileJobType.POST_EXPORT));
|
|
171
|
+
app.post('/process', (0, crowdin_client_1.default)(config), (0, process_1.default)(config, config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder || '/', config.customFileFormat));
|
|
172
|
+
app.get('/file/download', (0, download_1.default)(config, config.customFileFormat.filesFolder || config.dbFolder || '/'));
|
|
195
173
|
}
|
|
196
174
|
if (config.customMT) {
|
|
197
|
-
app.get('/logo/mt/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
175
|
+
app.get('/logo/mt/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
198
176
|
app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config, config.customMT));
|
|
199
177
|
}
|
|
200
178
|
if (config.profileResourcesMenu) {
|
|
201
|
-
app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
179
|
+
app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
202
180
|
app.use('/resources', (0, ui_module_1.default)(config, config.profileResourcesMenu.allowUnauthorized), (0, render_ui_module_1.default)(config, config.profileResourcesMenu));
|
|
203
181
|
}
|
|
204
182
|
if (config.organizationMenu) {
|
|
205
|
-
app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
183
|
+
app.get('/logo/resources/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
206
184
|
app.use('/resources', (0, ui_module_1.default)(config, config.organizationMenu.allowUnauthorized), (0, render_ui_module_1.default)(config, config.organizationMenu));
|
|
207
185
|
}
|
|
208
186
|
if (config.editorRightPanel) {
|
|
@@ -215,11 +193,11 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
215
193
|
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, config.projectMenuCrowdsource.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectMenuCrowdsource));
|
|
216
194
|
}
|
|
217
195
|
if (config.projectTools) {
|
|
218
|
-
app.get('/logo/tools/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
196
|
+
app.get('/logo/tools/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
219
197
|
app.use('/tools', (0, ui_module_1.default)(config, config.projectTools.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectTools));
|
|
220
198
|
}
|
|
221
199
|
if (config.projectReports) {
|
|
222
|
-
app.get('/logo/reports/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
200
|
+
app.get('/logo/reports/logo.png', (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath || (0, path_1.join)(__dirname, 'logo.png')); });
|
|
223
201
|
app.use('/reports', (0, ui_module_1.default)(config, config.projectReports.allowUnauthorized), (0, render_ui_module_1.default)(config, config.projectReports));
|
|
224
202
|
}
|
|
225
203
|
if (Object.keys(config).some((moduleKey) => {
|
|
@@ -251,12 +229,11 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
251
229
|
};
|
|
252
230
|
}
|
|
253
231
|
exports.addCrowdinEndpoints = addCrowdinEndpoints;
|
|
254
|
-
function createApp(
|
|
232
|
+
function createApp(config) {
|
|
255
233
|
const app = (0, express_1.default)();
|
|
256
|
-
const config = (0, defaults_1.convertClientConfig)(clientConfig);
|
|
257
234
|
addCrowdinEndpoints(app, config);
|
|
258
235
|
/* eslint no-console: "off" */
|
|
259
|
-
app.listen(config.port, () => console.log(`App started on port ${config.port}`));
|
|
236
|
+
app.listen(config.port || 3000, () => console.log(`App started on port ${config.port || 3000}`));
|
|
260
237
|
}
|
|
261
238
|
exports.createApp = createApp;
|
|
262
239
|
function handleUncaughtErrors(config) {
|
|
@@ -18,10 +18,8 @@ function handle(config, moduleConfig) {
|
|
|
18
18
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
if (moduleConfig.formSchema) {
|
|
20
20
|
return res.render('form', {
|
|
21
|
-
|
|
22
|
-
formPostDataUrl: moduleConfig.formPostDataUrl ? moduleConfig.formPostDataUrl : '/api/form-data',
|
|
21
|
+
formDataUrl: moduleConfig.formDataUrl ? moduleConfig.formDataUrl : '/api/form-data',
|
|
23
22
|
formSchema: JSON.stringify(moduleConfig.formSchema),
|
|
24
|
-
formUiSchema: moduleConfig.formUiSchema ? JSON.stringify(moduleConfig.formUiSchema) : '{}',
|
|
25
23
|
});
|
|
26
24
|
}
|
|
27
25
|
if (moduleConfig.uiPath) {
|
package/out/models/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
|
|
|
3
3
|
import { Request } from 'express';
|
|
4
4
|
import { MySQLStorageConfig } from '../storage/mysql';
|
|
5
5
|
import { PostgreStorageConfig } from '../storage/postgre';
|
|
6
|
-
export interface
|
|
6
|
+
export interface Config extends ImagePath {
|
|
7
7
|
/**
|
|
8
8
|
* Authentication Crowdin App type: "authorization_code", "crowdin_app". Default: "crowdin_app"
|
|
9
9
|
*/
|
|
@@ -11,11 +11,11 @@ export interface ClientConfig extends ImagePath {
|
|
|
11
11
|
/**
|
|
12
12
|
* client id that we received when registering the app
|
|
13
13
|
*/
|
|
14
|
-
clientId
|
|
14
|
+
clientId: string;
|
|
15
15
|
/**
|
|
16
16
|
* client secret that we received when registering the app
|
|
17
17
|
*/
|
|
18
|
-
clientSecret
|
|
18
|
+
clientSecret: string;
|
|
19
19
|
/**
|
|
20
20
|
* Secret to encrypt/decrypt credentials (by default @clientSecret will be used)
|
|
21
21
|
*/
|
|
@@ -27,7 +27,7 @@ export interface ClientConfig extends ImagePath {
|
|
|
27
27
|
/**
|
|
28
28
|
* https url where an app is reachable from the internet (e.g. the one that ngrok generates for us)
|
|
29
29
|
*/
|
|
30
|
-
baseUrl
|
|
30
|
+
baseUrl: string;
|
|
31
31
|
/**
|
|
32
32
|
* define custom Crowdin urls (e.g. to work against local Crowdin server)
|
|
33
33
|
*/
|
|
@@ -127,19 +127,7 @@ export interface ClientConfig extends ImagePath {
|
|
|
127
127
|
* Configuration of app pricing
|
|
128
128
|
*/
|
|
129
129
|
pricing?: Pricing;
|
|
130
|
-
filePreImport?: FilePreImportLogic;
|
|
131
|
-
filePostImport?: FilePostImportLogic;
|
|
132
|
-
filePreExport?: FilePreExportLogic;
|
|
133
|
-
filePostExport?: FilePostExportLogic;
|
|
134
130
|
}
|
|
135
|
-
export type Config = ClientConfig & {
|
|
136
|
-
baseUrl: string;
|
|
137
|
-
clientId: string;
|
|
138
|
-
clientSecret: string;
|
|
139
|
-
port: number;
|
|
140
|
-
dbFolder: string;
|
|
141
|
-
imagePath: string;
|
|
142
|
-
};
|
|
143
131
|
export declare enum AuthenticationType {
|
|
144
132
|
CODE = "authorization_code",
|
|
145
133
|
APP = "crowdin_app"
|
|
@@ -262,7 +250,7 @@ export interface IntegrationLogic {
|
|
|
262
250
|
*/
|
|
263
251
|
webhooks?: Webhooks;
|
|
264
252
|
}
|
|
265
|
-
export type FormEntity = FormField | FormDelimeter;
|
|
253
|
+
export declare type FormEntity = FormField | FormDelimeter;
|
|
266
254
|
export interface FormDelimeter {
|
|
267
255
|
label: string;
|
|
268
256
|
}
|
|
@@ -415,13 +403,13 @@ export interface ExtendedResult<T> {
|
|
|
415
403
|
message?: string;
|
|
416
404
|
stopPagination?: boolean;
|
|
417
405
|
}
|
|
418
|
-
export type TreeItem = File | Folder;
|
|
406
|
+
export declare type TreeItem = File | Folder;
|
|
419
407
|
/**
|
|
420
408
|
* 0 - folder
|
|
421
409
|
* 1 - file
|
|
422
410
|
* 2 - branch
|
|
423
411
|
*/
|
|
424
|
-
type IntegrationTreeElementType = '0' | '1' | '2';
|
|
412
|
+
declare type IntegrationTreeElementType = '0' | '1' | '2';
|
|
425
413
|
export interface File {
|
|
426
414
|
id: string;
|
|
427
415
|
name: string;
|
|
@@ -496,29 +484,23 @@ export interface CronJob {
|
|
|
496
484
|
task: (projectId: number, client: Crowdin, apiCredentials: any, appRootFolder?: SourceFilesModel.Directory, config?: any) => Promise<void>;
|
|
497
485
|
expression: string;
|
|
498
486
|
}
|
|
499
|
-
export interface
|
|
500
|
-
/**
|
|
501
|
-
* Folder where larger file will be temporary stored (default "{@link dbFolder}/custom-file-format")
|
|
502
|
-
*/
|
|
503
|
-
filesFolder?: string;
|
|
504
|
-
/**
|
|
505
|
-
* Contains fileName and/or fileContent regular expressions used to detect file type when uploading a new source file via UI (or via API without specified type parameter). If the file matches regular expressions, it's labeled as a custom format file.
|
|
506
|
-
*/
|
|
507
|
-
signaturePatterns?: SignaturePatterns;
|
|
508
|
-
/**
|
|
509
|
-
* Override to store huge responses (by default they will be stored in fs)
|
|
510
|
-
*/
|
|
511
|
-
storeFile?: (content: string) => Promise<string>;
|
|
512
|
-
}
|
|
513
|
-
export interface CustomFileFormatLogic extends FileProcessLogic {
|
|
487
|
+
export interface CustomFileFormatLogic {
|
|
514
488
|
/**
|
|
515
489
|
* The type parameter value for a custom file format. Used for a custom format file upload via API.
|
|
516
490
|
*/
|
|
517
491
|
type: string;
|
|
492
|
+
/**
|
|
493
|
+
* Folder where larger file will be temporary stored (default "{@link dbFolder}/custom-file-format")
|
|
494
|
+
*/
|
|
495
|
+
filesFolder?: string;
|
|
518
496
|
/**
|
|
519
497
|
* This parameter is used to combine the content of multiple languages into one request when uploading and downloading translations in your Crowdin project.
|
|
520
498
|
*/
|
|
521
499
|
multilingual?: boolean;
|
|
500
|
+
/**
|
|
501
|
+
* Contains fileName and/or fileContent regular expressions used to detect file type when uploading a new source file via UI (or via API without specified type parameter). If the file matches regular expressions, it's labeled as a custom format file.
|
|
502
|
+
*/
|
|
503
|
+
signaturePatterns?: SignaturePatterns;
|
|
522
504
|
/**
|
|
523
505
|
* Flag to automatically upload translations
|
|
524
506
|
*/
|
|
@@ -551,19 +533,10 @@ export interface CustomFileFormatLogic extends FileProcessLogic {
|
|
|
551
533
|
* Used for strings export
|
|
552
534
|
*/
|
|
553
535
|
exportStrings?: (req: Omit<ProcessFileRequest, 'jobType'>, strings: ProcessFileString[], client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
559
|
-
export interface FilePostImportLogic extends FileProcessLogic {
|
|
560
|
-
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ParseFileResponse>;
|
|
561
|
-
}
|
|
562
|
-
export interface FilePreExportLogic extends FileProcessLogic {
|
|
563
|
-
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<ParseFileResponse>;
|
|
564
|
-
}
|
|
565
|
-
export interface FilePostExportLogic extends FileProcessLogic {
|
|
566
|
-
fileProcess: (req: ProcessFileRequest, content: string, client: Crowdin, context: CrowdinContextInfo, projectId: number) => Promise<BuildFileResponse>;
|
|
536
|
+
/**
|
|
537
|
+
* Override to store huge responses (by default they will be stored in fs)
|
|
538
|
+
*/
|
|
539
|
+
storeFile?: (content: string) => Promise<string>;
|
|
567
540
|
}
|
|
568
541
|
export interface SignaturePatterns {
|
|
569
542
|
fileName?: string;
|
|
@@ -586,11 +559,7 @@ export interface ProcessFileRecord {
|
|
|
586
559
|
}
|
|
587
560
|
export declare enum ProcessFileJobType {
|
|
588
561
|
PARSE_FILE = "parse-file",
|
|
589
|
-
BUILD_FILE = "build-file"
|
|
590
|
-
PRE_IMPORT = "pre-import-file",
|
|
591
|
-
POST_IMPORT = "post-import-file",
|
|
592
|
-
PRE_EXPORT = "pre-export-file",
|
|
593
|
-
POST_EXPORT = "post-export-file"
|
|
562
|
+
BUILD_FILE = "build-file"
|
|
594
563
|
}
|
|
595
564
|
export interface ParseFileResponse {
|
|
596
565
|
previewFile?: string;
|
|
@@ -600,8 +569,6 @@ export interface ParseFileResponse {
|
|
|
600
569
|
export interface BuildFileResponse {
|
|
601
570
|
contentFile: string;
|
|
602
571
|
error?: string;
|
|
603
|
-
fileName?: string;
|
|
604
|
-
fileType?: string;
|
|
605
572
|
}
|
|
606
573
|
export interface ProcessFileString {
|
|
607
574
|
previewId?: number;
|
|
@@ -615,7 +582,6 @@ export interface ProcessFileString {
|
|
|
615
582
|
labels?: string[];
|
|
616
583
|
text: string | SourceStringsModel.PluralText;
|
|
617
584
|
translations?: StringTranslations;
|
|
618
|
-
uniqId?: string;
|
|
619
585
|
}
|
|
620
586
|
export interface StringTranslations {
|
|
621
587
|
[language: string]: {
|
|
@@ -636,19 +602,10 @@ export interface UiModule {
|
|
|
636
602
|
*/
|
|
637
603
|
formSchema?: object;
|
|
638
604
|
/**
|
|
639
|
-
* URL to custom endpoint that can be used instead of default one to save form data.
|
|
640
|
-
* Endpoint should accept POST requests.
|
|
641
|
-
*/
|
|
642
|
-
formPostDataUrl?: string;
|
|
643
|
-
/**
|
|
644
|
-
* URL to custom endpoint that can be used instead of default one to retrieve form data.
|
|
645
|
-
* Endpoint should accept GET requests.
|
|
646
|
-
*/
|
|
647
|
-
formGetDataUrl?: string;
|
|
648
|
-
/**
|
|
649
|
-
* Additional attributes for react-jsonschema-doc
|
|
605
|
+
* URL to custom endpoint that can be used instead of default one to save and retrieve form data.
|
|
606
|
+
* Endpoint should accept both POST requests for data saving and GET requests for data retrieving.
|
|
650
607
|
*/
|
|
651
|
-
|
|
608
|
+
formDataUrl?: string;
|
|
652
609
|
/**
|
|
653
610
|
* path to ui folder (e.g. {@example join(__dirname, 'public')})
|
|
654
611
|
*/
|
|
@@ -718,8 +675,8 @@ export interface Webhooks {
|
|
|
718
675
|
urlParam?: string;
|
|
719
676
|
crowdinWebhooks?: (client: Crowdin, projectId: number, available: boolean, config?: any) => Promise<void>;
|
|
720
677
|
integrationWebhooks?: (apiCredentials: any, urlParam: string, available: boolean, config?: any, syncSettings?: any) => Promise<void>;
|
|
721
|
-
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any
|
|
722
|
-
integrationWebhookInterceptor?: (projectId: number, client: Crowdin,
|
|
678
|
+
crowdinWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any) => Promise<UpdateIntegrationRequest>;
|
|
679
|
+
integrationWebhookInterceptor?: (projectId: number, client: Crowdin, appRootFolder?: SourceFilesModel.Directory, config?: any, syncSettings?: any, webhookRequest?: any) => Promise<IntegrationFile[]>;
|
|
723
680
|
queueUrl: string;
|
|
724
681
|
}
|
|
725
682
|
export declare enum SyncCondition {
|
|
@@ -732,13 +689,13 @@ export declare enum SyncType {
|
|
|
732
689
|
SCHEDULE = 1,
|
|
733
690
|
WEBHOOKS = 2
|
|
734
691
|
}
|
|
735
|
-
export type Payload = {
|
|
692
|
+
export declare type Payload = {
|
|
736
693
|
event: string;
|
|
737
694
|
projectId: string;
|
|
738
695
|
language: string;
|
|
739
696
|
fileId: string;
|
|
740
697
|
};
|
|
741
|
-
export type WebhookUrlParams = {
|
|
698
|
+
export declare type WebhookUrlParams = {
|
|
742
699
|
projectId: number;
|
|
743
700
|
crowdinId: string;
|
|
744
701
|
clientId: string;
|
package/out/models/index.js
CHANGED
|
@@ -39,10 +39,6 @@ var ProcessFileJobType;
|
|
|
39
39
|
(function (ProcessFileJobType) {
|
|
40
40
|
ProcessFileJobType["PARSE_FILE"] = "parse-file";
|
|
41
41
|
ProcessFileJobType["BUILD_FILE"] = "build-file";
|
|
42
|
-
ProcessFileJobType["PRE_IMPORT"] = "pre-import-file";
|
|
43
|
-
ProcessFileJobType["POST_IMPORT"] = "post-import-file";
|
|
44
|
-
ProcessFileJobType["PRE_EXPORT"] = "pre-export-file";
|
|
45
|
-
ProcessFileJobType["POST_EXPORT"] = "post-export-file";
|
|
46
42
|
})(ProcessFileJobType = exports.ProcessFileJobType || (exports.ProcessFileJobType = {}));
|
|
47
43
|
var EditorPanelsMode;
|
|
48
44
|
(function (EditorPanelsMode) {
|