@crowdin/app-project-module 0.73.2 → 0.75.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/modules/api/api.js +75 -3
- package/out/modules/api/components.d.ts +58 -17
- package/out/modules/api/components.js +58 -17
- package/out/modules/context-menu/types.d.ts +5 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +2 -1
- package/out/modules/integration/handlers/job-cancel.js +10 -2
- package/out/modules/integration/handlers/job-info.js +32 -1
- package/out/modules/integration/index.js +1 -1
- package/out/modules/integration/util/webhooks.js +18 -12
- package/out/modules/manifest.js +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.js +2 -2
- package/out/modules/workflow-step-type/index.js +4 -0
- package/out/modules/workflow-step-type/types.d.ts +2 -2
- package/out/static/js/form.js +11 -11
- package/out/storage/index.js +93 -1
- package/out/storage/postgre.d.ts +3 -1
- package/out/storage/postgre.js +38 -5
- package/out/storage/sqlite.js +7 -5
- package/out/types.d.ts +9 -0
- package/out/types.js +7 -1
- package/out/util/index.d.ts +1 -0
- package/out/util/index.js +6 -1
- package/out/views/main.handlebars +10 -12
- package/package.json +10 -10
package/out/modules/api/api.js
CHANGED
|
@@ -14,6 +14,8 @@ const crowdin_file_progress_1 = __importDefault(require("../integration/handlers
|
|
|
14
14
|
const crowdin_files_1 = __importDefault(require("../integration/handlers/crowdin-files"));
|
|
15
15
|
const crowdin_update_1 = __importDefault(require("../integration/handlers/crowdin-update"));
|
|
16
16
|
const integration_data_1 = __importDefault(require("../integration/handlers/integration-data"));
|
|
17
|
+
const job_info_1 = __importDefault(require("../integration/handlers/job-info"));
|
|
18
|
+
const job_cancel_1 = __importDefault(require("../integration/handlers/job-cancel"));
|
|
17
19
|
const integration_login_1 = __importDefault(require("../integration/handlers/integration-login"));
|
|
18
20
|
const integration_update_1 = __importDefault(require("../integration/handlers/integration-update"));
|
|
19
21
|
const settings_1 = __importDefault(require("../integration/handlers/settings"));
|
|
@@ -55,7 +57,7 @@ function getDefaultApiEndpointsManifest(config) {
|
|
|
55
57
|
description: 'Get a list of synced files',
|
|
56
58
|
documentationUrl: '/api-docs#tag/Files/operation/crowdin.files',
|
|
57
59
|
}, {
|
|
58
|
-
key: '
|
|
60
|
+
key: 'file-translation-progress-api',
|
|
59
61
|
name: 'File Translation Progress',
|
|
60
62
|
url: '/file-progress',
|
|
61
63
|
method: types_1.RequestMethods.GET,
|
|
@@ -82,6 +84,20 @@ function getDefaultApiEndpointsManifest(config) {
|
|
|
82
84
|
method: types_1.RequestMethods.POST,
|
|
83
85
|
description: 'Update integration data',
|
|
84
86
|
documentationUrl: '/api-docs#tag/Files/operation/integration.update',
|
|
87
|
+
}, {
|
|
88
|
+
key: 'job-get-api',
|
|
89
|
+
name: 'Job Status',
|
|
90
|
+
url: '/jobs',
|
|
91
|
+
method: types_1.RequestMethods.GET,
|
|
92
|
+
description: 'Get Job Info',
|
|
93
|
+
documentationUrl: '/api-docs#tag/Jobs/operation/job.get',
|
|
94
|
+
}, {
|
|
95
|
+
key: 'job-cancel-api',
|
|
96
|
+
name: 'Job Status',
|
|
97
|
+
url: '/jobs',
|
|
98
|
+
method: types_1.RequestMethods.DELETE,
|
|
99
|
+
description: 'Cancel Job',
|
|
100
|
+
documentationUrl: '/api-docs#tag/Jobs/operation/job.cancel',
|
|
85
101
|
}, {
|
|
86
102
|
key: 'settings-api',
|
|
87
103
|
name: 'Get App Settings',
|
|
@@ -191,7 +207,7 @@ function addDefaultApiEndpoints(app, config) {
|
|
|
191
207
|
* name: fileId
|
|
192
208
|
* in: query
|
|
193
209
|
* required: true
|
|
194
|
-
* description: '
|
|
210
|
+
* description: 'Get via [List Crowdin Files](#operation/crowdin.files)'
|
|
195
211
|
* schema:
|
|
196
212
|
* type: integer
|
|
197
213
|
* example: 102
|
|
@@ -294,6 +310,62 @@ function addDefaultApiEndpoints(app, config) {
|
|
|
294
310
|
checkSubscriptionExpiration: true,
|
|
295
311
|
moduleKey: config.projectIntegration.key,
|
|
296
312
|
}), (0, integration_credentials_1.default)(config, config.projectIntegration), (0, integration_update_1.default)(config, config.projectIntegration));
|
|
313
|
+
/**
|
|
314
|
+
* @openapi
|
|
315
|
+
* /jobs:
|
|
316
|
+
* get:
|
|
317
|
+
* tags:
|
|
318
|
+
* - 'Jobs'
|
|
319
|
+
* summary: 'Get Job Info'
|
|
320
|
+
* operationId: job.get
|
|
321
|
+
* parameters:
|
|
322
|
+
* - $ref: '#/components/parameters/ProjectId'
|
|
323
|
+
* - name: jobId
|
|
324
|
+
* in: query
|
|
325
|
+
* required: false
|
|
326
|
+
* schema:
|
|
327
|
+
* type: string
|
|
328
|
+
* example: 067da473-fc0b-43e3-b0a2-09d26af130c1
|
|
329
|
+
* responses:
|
|
330
|
+
* 200:
|
|
331
|
+
* description: 'Job information retrieved successfully'
|
|
332
|
+
* content:
|
|
333
|
+
* application/json:
|
|
334
|
+
* schema:
|
|
335
|
+
* $ref: '#/components/schemas/JobResponse'
|
|
336
|
+
*/
|
|
337
|
+
app.get('/jobs', json_response_1.default, (0, crowdin_client_1.default)({
|
|
338
|
+
config,
|
|
339
|
+
optional: false,
|
|
340
|
+
checkSubscriptionExpiration: true,
|
|
341
|
+
moduleKey: config.projectIntegration.key,
|
|
342
|
+
}), (0, job_info_1.default)(config));
|
|
343
|
+
/**
|
|
344
|
+
* @openapi
|
|
345
|
+
* /jobs:
|
|
346
|
+
* delete:
|
|
347
|
+
* tags:
|
|
348
|
+
* - 'Jobs'
|
|
349
|
+
* summary: 'Cancel Job'
|
|
350
|
+
* operationId: job.cancel
|
|
351
|
+
* parameters:
|
|
352
|
+
* - $ref: '#/components/parameters/ProjectId'
|
|
353
|
+
* - name: jobId
|
|
354
|
+
* in: query
|
|
355
|
+
* required: false
|
|
356
|
+
* schema:
|
|
357
|
+
* type: string
|
|
358
|
+
* example: 067da473-fc0b-43e3-b0a2-09d26af130c1
|
|
359
|
+
* responses:
|
|
360
|
+
* 204:
|
|
361
|
+
* description: 'Job canceled successfully'
|
|
362
|
+
*/
|
|
363
|
+
app.delete('/jobs', json_response_1.default, (0, crowdin_client_1.default)({
|
|
364
|
+
config,
|
|
365
|
+
optional: false,
|
|
366
|
+
checkSubscriptionExpiration: true,
|
|
367
|
+
moduleKey: config.projectIntegration.key,
|
|
368
|
+
}), (0, job_cancel_1.default)(config));
|
|
297
369
|
/**
|
|
298
370
|
* @openapi
|
|
299
371
|
* /settings:
|
|
@@ -413,7 +485,7 @@ function addDefaultApiEndpoints(app, config) {
|
|
|
413
485
|
* operationId: integration.fields
|
|
414
486
|
* responses:
|
|
415
487
|
* 200:
|
|
416
|
-
* description: '
|
|
488
|
+
* description: 'Login Form Fields'
|
|
417
489
|
* content:
|
|
418
490
|
* application/json:
|
|
419
491
|
* schema:
|
|
@@ -70,25 +70,32 @@
|
|
|
70
70
|
* - files
|
|
71
71
|
* properties:
|
|
72
72
|
* projectId:
|
|
73
|
-
* description: 'Project
|
|
73
|
+
* description: 'Project Id. Get via [List Projects](https://developer.crowdin.com/api/v2/#operation/api.projects.getMany)'
|
|
74
74
|
* type: integer
|
|
75
75
|
* example: 12
|
|
76
76
|
* files:
|
|
77
|
+
* example: { 102: ['de', 'fr'], 999: ['uk'] }
|
|
77
78
|
* type: object
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
79
|
+
* description: |
|
|
80
|
+
* - **{fileId}** _(integer)_: Crowdin File Id. Get via [List Crowdin Files](#operation/crowdin.files)
|
|
81
|
+
* - **[{languageCode}]** _(array of strings)_: List Of Language Id. Get via [List Supported Languages](https://support.crowdin.com/developer/api/v2/#tag/Languages/operation/api.languages.getMany)
|
|
82
|
+
*
|
|
83
|
+
* **Example:**
|
|
84
|
+
* ```json
|
|
85
|
+
* {
|
|
86
|
+
* 102: ["de", "fr"],
|
|
87
|
+
* 999: ["uk"]
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
84
90
|
* UpdateResponse:
|
|
85
91
|
* type: object
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
+
* properties:
|
|
93
|
+
* jobId:
|
|
94
|
+
* type: string
|
|
95
|
+
* example: '067da473-fc0b-43e3-b0a2-09d26af130c1'
|
|
96
|
+
* message:
|
|
97
|
+
* type: string
|
|
98
|
+
* example: 'Another sync is running'
|
|
92
99
|
* SettingsData:
|
|
93
100
|
* type: object
|
|
94
101
|
* example: {schedule: 0, condition: 0}
|
|
@@ -195,8 +202,17 @@
|
|
|
195
202
|
* type: integer
|
|
196
203
|
* example: 86
|
|
197
204
|
* LoginFieldsResponse:
|
|
198
|
-
*
|
|
199
|
-
*
|
|
205
|
+
* type: array
|
|
206
|
+
* items:
|
|
207
|
+
* type: object
|
|
208
|
+
* properties:
|
|
209
|
+
* key:
|
|
210
|
+
* type: string
|
|
211
|
+
* example: 'apiKey'
|
|
212
|
+
* name:
|
|
213
|
+
* type: string
|
|
214
|
+
* example: 'Service API key'
|
|
215
|
+
* example: [{ key: 'email', name: 'User email' }, { key: 'password', name: 'User password' }]
|
|
200
216
|
* Login:
|
|
201
217
|
* title: 'Login'
|
|
202
218
|
* required:
|
|
@@ -211,9 +227,34 @@
|
|
|
211
227
|
* $ref: '#/components/schemas/LoginData'
|
|
212
228
|
* LoginData:
|
|
213
229
|
* type: object
|
|
230
|
+
* description: 'Login Form Fields. Get via [Integration Login Form Fields](#operation/integration.fields)'
|
|
214
231
|
* example: { email: 'user@crowdin.com', password: 'password' }
|
|
215
|
-
*
|
|
216
|
-
*
|
|
232
|
+
* Job:
|
|
233
|
+
* type: object
|
|
234
|
+
* properties:
|
|
235
|
+
* id:
|
|
236
|
+
* type: string
|
|
237
|
+
* description: 'The Unique Identifier For The Job.'
|
|
238
|
+
* example: '067da473-fc0b-43e3-b0a2-09d26af130c1'
|
|
239
|
+
* progress:
|
|
240
|
+
* type: integer
|
|
241
|
+
* description: 'The Progress Of The Job.'
|
|
242
|
+
* example: 94
|
|
243
|
+
* status:
|
|
244
|
+
* type: string
|
|
245
|
+
* description: 'The Current Status Of The Job.'
|
|
246
|
+
* example: 'inProgress'
|
|
247
|
+
* title:
|
|
248
|
+
* type: string
|
|
249
|
+
* description: 'The Title Of The Job.'
|
|
250
|
+
* example: 'Sync files to Crowdin'
|
|
251
|
+
* JobResponse:
|
|
252
|
+
* type: object
|
|
253
|
+
* properties:
|
|
254
|
+
* data:
|
|
255
|
+
* type: array
|
|
256
|
+
* items:
|
|
257
|
+
* $ref: '#/components/schemas/Job'
|
|
217
258
|
*
|
|
218
259
|
* parameters:
|
|
219
260
|
* ProjectId:
|
|
@@ -71,25 +71,32 @@
|
|
|
71
71
|
* - files
|
|
72
72
|
* properties:
|
|
73
73
|
* projectId:
|
|
74
|
-
* description: 'Project
|
|
74
|
+
* description: 'Project Id. Get via [List Projects](https://developer.crowdin.com/api/v2/#operation/api.projects.getMany)'
|
|
75
75
|
* type: integer
|
|
76
76
|
* example: 12
|
|
77
77
|
* files:
|
|
78
|
+
* example: { 102: ['de', 'fr'], 999: ['uk'] }
|
|
78
79
|
* type: object
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
80
|
+
* description: |
|
|
81
|
+
* - **{fileId}** _(integer)_: Crowdin File Id. Get via [List Crowdin Files](#operation/crowdin.files)
|
|
82
|
+
* - **[{languageCode}]** _(array of strings)_: List Of Language Id. Get via [List Supported Languages](https://support.crowdin.com/developer/api/v2/#tag/Languages/operation/api.languages.getMany)
|
|
83
|
+
*
|
|
84
|
+
* **Example:**
|
|
85
|
+
* ```json
|
|
86
|
+
* {
|
|
87
|
+
* 102: ["de", "fr"],
|
|
88
|
+
* 999: ["uk"]
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
85
91
|
* UpdateResponse:
|
|
86
92
|
* type: object
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
+
* properties:
|
|
94
|
+
* jobId:
|
|
95
|
+
* type: string
|
|
96
|
+
* example: '067da473-fc0b-43e3-b0a2-09d26af130c1'
|
|
97
|
+
* message:
|
|
98
|
+
* type: string
|
|
99
|
+
* example: 'Another sync is running'
|
|
93
100
|
* SettingsData:
|
|
94
101
|
* type: object
|
|
95
102
|
* example: {schedule: 0, condition: 0}
|
|
@@ -196,8 +203,17 @@
|
|
|
196
203
|
* type: integer
|
|
197
204
|
* example: 86
|
|
198
205
|
* LoginFieldsResponse:
|
|
199
|
-
*
|
|
200
|
-
*
|
|
206
|
+
* type: array
|
|
207
|
+
* items:
|
|
208
|
+
* type: object
|
|
209
|
+
* properties:
|
|
210
|
+
* key:
|
|
211
|
+
* type: string
|
|
212
|
+
* example: 'apiKey'
|
|
213
|
+
* name:
|
|
214
|
+
* type: string
|
|
215
|
+
* example: 'Service API key'
|
|
216
|
+
* example: [{ key: 'email', name: 'User email' }, { key: 'password', name: 'User password' }]
|
|
201
217
|
* Login:
|
|
202
218
|
* title: 'Login'
|
|
203
219
|
* required:
|
|
@@ -212,9 +228,34 @@
|
|
|
212
228
|
* $ref: '#/components/schemas/LoginData'
|
|
213
229
|
* LoginData:
|
|
214
230
|
* type: object
|
|
231
|
+
* description: 'Login Form Fields. Get via [Integration Login Form Fields](#operation/integration.fields)'
|
|
215
232
|
* example: { email: 'user@crowdin.com', password: 'password' }
|
|
216
|
-
*
|
|
217
|
-
*
|
|
233
|
+
* Job:
|
|
234
|
+
* type: object
|
|
235
|
+
* properties:
|
|
236
|
+
* id:
|
|
237
|
+
* type: string
|
|
238
|
+
* description: 'The Unique Identifier For The Job.'
|
|
239
|
+
* example: '067da473-fc0b-43e3-b0a2-09d26af130c1'
|
|
240
|
+
* progress:
|
|
241
|
+
* type: integer
|
|
242
|
+
* description: 'The Progress Of The Job.'
|
|
243
|
+
* example: 94
|
|
244
|
+
* status:
|
|
245
|
+
* type: string
|
|
246
|
+
* description: 'The Current Status Of The Job.'
|
|
247
|
+
* example: 'inProgress'
|
|
248
|
+
* title:
|
|
249
|
+
* type: string
|
|
250
|
+
* description: 'The Title Of The Job.'
|
|
251
|
+
* example: 'Sync files to Crowdin'
|
|
252
|
+
* JobResponse:
|
|
253
|
+
* type: object
|
|
254
|
+
* properties:
|
|
255
|
+
* data:
|
|
256
|
+
* type: array
|
|
257
|
+
* items:
|
|
258
|
+
* $ref: '#/components/schemas/Job'
|
|
218
259
|
*
|
|
219
260
|
* parameters:
|
|
220
261
|
* ProjectId:
|
|
@@ -10,7 +10,7 @@ export interface ContextModule {
|
|
|
10
10
|
/**
|
|
11
11
|
* Support fileName pattern only. Contains fileName field regular expressions used to detect the file type. If the file name matches any of the regular expressions, the context menu will be displayed.
|
|
12
12
|
*/
|
|
13
|
-
signaturePatterns?:
|
|
13
|
+
signaturePatterns?: ContextSignaturePatterns;
|
|
14
14
|
}
|
|
15
15
|
export declare enum ContextOptionsLocations {
|
|
16
16
|
TM = "tm",
|
|
@@ -25,3 +25,7 @@ export declare enum ContextOptionsTypes {
|
|
|
25
25
|
NEW_TAB = "new_tab",
|
|
26
26
|
REDIRECT = "redirect"
|
|
27
27
|
}
|
|
28
|
+
export type ElementNodeType = 0 | 1 | 2;
|
|
29
|
+
export type ContextSignaturePatterns = SignaturePatterns & {
|
|
30
|
+
nodeType?: ElementNodeType[];
|
|
31
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
|
|
3
|
+
import { Config } from '../../../types';
|
|
4
|
+
export default function handle(config: Config): (req: import("../../../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -12,9 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const types_1 = require("../util/types");
|
|
13
13
|
const util_1 = require("../../../util");
|
|
14
14
|
const storage_1 = require("../../../storage");
|
|
15
|
-
function handle() {
|
|
15
|
+
function handle(config) {
|
|
16
16
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
|
|
17
|
+
var _a;
|
|
18
|
+
const id = req.query.jobId || req.body.jobId;
|
|
19
|
+
const isApi = (0, util_1.isApiRequest)(req, config);
|
|
20
|
+
if (isApi && !((_a = req.body) === null || _a === void 0 ? void 0 : _a.projectId)) {
|
|
21
|
+
res.send({
|
|
22
|
+
error: 'Project id is require',
|
|
23
|
+
});
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
18
26
|
if (!id) {
|
|
19
27
|
req.logInfo('Job id is absent');
|
|
20
28
|
res.status(400).send('Job id is required');
|
|
@@ -35,13 +35,33 @@ function getHumanETA(ms) {
|
|
|
35
35
|
}
|
|
36
36
|
function handle(config) {
|
|
37
37
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
|
|
38
|
+
var _a;
|
|
39
|
+
const id = req.query.jobId || req.body.jobId;
|
|
40
|
+
const isApi = (0, util_1.isApiRequest)(req, config);
|
|
41
|
+
if (isApi && !((_a = req.body) === null || _a === void 0 ? void 0 : _a.projectId)) {
|
|
42
|
+
res.send({
|
|
43
|
+
error: 'Project id is require',
|
|
44
|
+
});
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
39
47
|
if (!id) {
|
|
40
48
|
req.logInfo('Get active jobs');
|
|
41
49
|
const jobs = yield (0, storage_1.getStorage)().getActiveJobs({
|
|
42
50
|
integrationId: req.crowdinContext.clientId,
|
|
43
51
|
crowdinId: req.crowdinContext.crowdinId,
|
|
44
52
|
});
|
|
53
|
+
if (isApi && jobs) {
|
|
54
|
+
const filteredJobs = jobs.map((job) => ({
|
|
55
|
+
id: job.id,
|
|
56
|
+
progress: job.progress,
|
|
57
|
+
status: job.status,
|
|
58
|
+
title: job.title,
|
|
59
|
+
}));
|
|
60
|
+
req.logInfo(`Returning active filtered jobs info ${JSON.stringify(filteredJobs, null, 2)}`);
|
|
61
|
+
res.send(filteredJobs);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
req.logInfo(`Returning active jobs info ${JSON.stringify(jobs, null, 2)}`);
|
|
45
65
|
res.send(jobs);
|
|
46
66
|
return;
|
|
47
67
|
}
|
|
@@ -51,6 +71,17 @@ function handle(config) {
|
|
|
51
71
|
job.eta = ((Date.now() - job.createdAt) / job.progress) * (100 - job.progress);
|
|
52
72
|
job.info = getHumanETA(job.eta) + (job.info ? `\n${job.info}` : '');
|
|
53
73
|
}
|
|
74
|
+
if (isApi && job) {
|
|
75
|
+
const filteredJob = {
|
|
76
|
+
id: job.id,
|
|
77
|
+
progress: job.progress,
|
|
78
|
+
status: job.status,
|
|
79
|
+
title: job.title,
|
|
80
|
+
};
|
|
81
|
+
req.logInfo(`Returning filtered job info ${JSON.stringify(filteredJob, null, 2)}`);
|
|
82
|
+
res.send([filteredJob]);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
54
85
|
if (job && (job === null || job === void 0 ? void 0 : job.updatedAt) && Date.now() - job.updatedAt >= MINUTES * 60 * 1000) {
|
|
55
86
|
const context = req.crowdinContext;
|
|
56
87
|
const projectId = context.jwtPayload.context.project_id;
|
|
@@ -99,7 +99,7 @@ function register({ config, app }) {
|
|
|
99
99
|
optional: false,
|
|
100
100
|
checkSubscriptionExpiration: true,
|
|
101
101
|
moduleKey: integrationLogic.key,
|
|
102
|
-
}), (0, job_cancel_1.default)());
|
|
102
|
+
}), (0, job_cancel_1.default)(config));
|
|
103
103
|
app.post('/api/settings', (0, crowdin_client_1.default)({
|
|
104
104
|
config,
|
|
105
105
|
optional: false,
|
|
@@ -45,8 +45,8 @@ const connection_1 = require("../../../util/connection");
|
|
|
45
45
|
const defaults_1 = require("./defaults");
|
|
46
46
|
const index_1 = require("../../../util/index");
|
|
47
47
|
const logger_1 = require("../../../util/logger");
|
|
48
|
-
const prefetchCount =
|
|
49
|
-
const forceProcessDelay =
|
|
48
|
+
const prefetchCount = 10;
|
|
49
|
+
const forceProcessDelay = 10000;
|
|
50
50
|
exports.HookEvents = {
|
|
51
51
|
fileAdded: 'file.added',
|
|
52
52
|
fileDeleted: 'file.deleted',
|
|
@@ -407,7 +407,7 @@ function consumer({ channel, config, integration, }) {
|
|
|
407
407
|
webhooksInfo[clientId].data.push(data);
|
|
408
408
|
}
|
|
409
409
|
if (messagesCounter < prefetchCount) {
|
|
410
|
-
// if all messages are not received, wait
|
|
410
|
+
// if all messages are not received, wait 10 seconds to force process messages
|
|
411
411
|
timeoutId = setTimeout(() => __awaiter(this, void 0, void 0, function* () {
|
|
412
412
|
yield processMessages({
|
|
413
413
|
webhooksData,
|
|
@@ -436,16 +436,22 @@ function consumer({ channel, config, integration, }) {
|
|
|
436
436
|
}
|
|
437
437
|
function processMessages({ channel, msg, webhooksData, webhooksInfo, }) {
|
|
438
438
|
return __awaiter(this, void 0, void 0, function* () {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
439
|
+
try {
|
|
440
|
+
yield Promise.all(webhooksData);
|
|
441
|
+
for (const { data, integration, webhookData } of Object.values(webhooksInfo)) {
|
|
442
|
+
if (webhookData && webhookData.crowdinClient) {
|
|
443
|
+
yield updateCrowdinFromWebhookRequest({
|
|
444
|
+
integration: integration,
|
|
445
|
+
webhookData: webhookData,
|
|
446
|
+
req: data,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
447
449
|
}
|
|
450
|
+
channel.ack(msg, true);
|
|
451
|
+
}
|
|
452
|
+
catch (e) {
|
|
453
|
+
(0, logger_1.logError)(e);
|
|
454
|
+
channel.nack(msg, false, false);
|
|
448
455
|
}
|
|
449
|
-
channel.ack(msg, true);
|
|
450
456
|
});
|
|
451
457
|
}
|
package/out/modules/manifest.js
CHANGED
|
@@ -275,7 +275,7 @@ function handle(config) {
|
|
|
275
275
|
workflowStep.key = config.identifier + '-' + (0, util_3.getWorkflowStepKey)(workflowStep);
|
|
276
276
|
}
|
|
277
277
|
const uiModule = ((_a = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _a === void 0 ? void 0 : _a.formSchema) || ((_b = workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.settingsUiModule) === null || _b === void 0 ? void 0 : _b.fileName);
|
|
278
|
-
modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name, description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }, (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/delete', workflowStep) }), (uiModule ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));
|
|
278
|
+
modules['workflow-step-type'].push(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ key: workflowStep.key, name: workflowStep.name || config.name }, ((workflowStep === null || workflowStep === void 0 ? void 0 : workflowStep.imagePath) ? { logo: (0, util_1.getLogoUrl)(workflowStep, `-${workflowStep.key}`) } : {})), { description: workflowStep.description || config.description, boundaries: workflowStep.boundaries }), (workflowStep.editorMode ? { editorMode: workflowStep.editorMode } : {})), { updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/delete', workflowStep) }), (uiModule ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
281
|
const events = {
|
|
@@ -47,11 +47,11 @@ function webhookHandler(config, webhooks) {
|
|
|
47
47
|
const organizationId = req.headers['x-crowdin-id'];
|
|
48
48
|
const signature = req.headers['x-crowdin-signature'];
|
|
49
49
|
const moduleKey = req.headers['x-module-key'];
|
|
50
|
-
if (!(0, lodash_isstring_1.default)(
|
|
50
|
+
if (!(0, lodash_isstring_1.default)(organizationId) || !(0, lodash_isstring_1.default)(signature) || !(0, lodash_isstring_1.default)(moduleKey)) {
|
|
51
51
|
res.status(400).send({ error: 'Invalid request' });
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
const crowdinId = domain
|
|
54
|
+
const crowdinId = domain && (0, lodash_isstring_1.default)(domain) ? domain : organizationId;
|
|
55
55
|
const credentials = yield storage.getStorage().getCrowdinCredentials(crowdinId);
|
|
56
56
|
if (!credentials) {
|
|
57
57
|
throw new Error('Failed to find Crowdin credentials');
|
|
@@ -10,6 +10,7 @@ const util_1 = require("./util");
|
|
|
10
10
|
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
11
11
|
const step_settings_save_1 = __importDefault(require("./handlers/step-settings-save"));
|
|
12
12
|
const delete_step_1 = __importDefault(require("./handlers/delete-step"));
|
|
13
|
+
const util_2 = require("../../util");
|
|
13
14
|
function register({ config, app }) {
|
|
14
15
|
if (!config.workflowStepType) {
|
|
15
16
|
return;
|
|
@@ -28,6 +29,9 @@ function register({ config, app }) {
|
|
|
28
29
|
checkSubscriptionExpiration: false,
|
|
29
30
|
moduleKey: workflowStep.key,
|
|
30
31
|
}), (0, delete_step_1.default)(workflowStep));
|
|
32
|
+
if (workflowStep.imagePath) {
|
|
33
|
+
app.get((0, util_2.getLogoUrl)(workflowStep, `-${workflowStep.key}`), (req, res) => res.sendFile(workflowStep.imagePath || config.imagePath));
|
|
34
|
+
}
|
|
31
35
|
if (workflowStep.settingsUiModule) {
|
|
32
36
|
app.use((0, util_1.getWorkflowStepUrl)('/workflow-step', workflowStep), (0, ui_module_1.default)({ config, moduleType: workflowStep.key }), (0, render_ui_module_1.default)(workflowStep.settingsUiModule));
|
|
33
37
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CrowdinContextInfo, ModuleKey, UiModule } from '../../types';
|
|
1
|
+
import { CrowdinContextInfo, ImagePath, ModuleKey, UiModule } from '../../types';
|
|
2
2
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
3
|
interface Boundaries {
|
|
4
4
|
input: Input;
|
|
@@ -13,7 +13,7 @@ interface Output {
|
|
|
13
13
|
port: Port;
|
|
14
14
|
}
|
|
15
15
|
type Port = 'customCodeFalse' | 'customCodeTrue' | 'untranslated' | 'translated' | 'approved' | 'skipped' | 'all';
|
|
16
|
-
export interface WorkflowStepTypeModule extends ModuleKey {
|
|
16
|
+
export interface WorkflowStepTypeModule extends ModuleKey, ImagePath {
|
|
17
17
|
/**
|
|
18
18
|
* module name
|
|
19
19
|
*/
|