@crowdin/app-project-module 0.68.1 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.js +21 -3
- package/out/modules/ai-provider/handlers/chat-completions.js +20 -21
- package/out/modules/ai-provider/handlers/get-model-list.js +3 -2
- package/out/modules/ai-provider/types.d.ts +112 -7
- package/out/modules/ai-provider/util/index.d.ts +5 -0
- package/out/modules/ai-provider/util/index.js +72 -1
- package/out/modules/api/api.js +4 -4
- package/out/modules/file-processing/handlers/pre-post-process.js +6 -0
- package/out/modules/file-processing/types.d.ts +16 -8
- package/out/modules/integration/util/cron.js +8 -5
- package/out/modules/integration/util/webhooks.js +5 -4
- package/out/modules/manifest.js +46 -0
- package/out/modules/organization-settings-menu/index.d.ts +6 -0
- package/out/modules/organization-settings-menu/index.js +18 -0
- package/out/modules/profile-settings-menu/index.d.ts +6 -0
- package/out/modules/profile-settings-menu/index.js +18 -0
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +5 -0
- package/out/modules/webhooks/handlers/webhook-handler.js +78 -0
- package/out/modules/webhooks/index.d.ts +6 -0
- package/out/modules/webhooks/index.js +18 -0
- package/out/modules/webhooks/types.d.ts +294 -0
- package/out/modules/webhooks/types.js +2 -0
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +5 -0
- package/out/modules/workflow-step-type/handlers/delete-step.js +70 -0
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +5 -0
- package/out/modules/workflow-step-type/handlers/step-settings-save.js +80 -0
- package/out/modules/workflow-step-type/index.d.ts +6 -0
- package/out/modules/workflow-step-type/index.js +36 -0
- package/out/modules/workflow-step-type/types.d.ts +57 -0
- package/out/modules/workflow-step-type/types.js +2 -0
- package/out/modules/workflow-step-type/util/index.d.ts +3 -0
- package/out/modules/workflow-step-type/util/index.js +16 -0
- package/out/static/js/form.js +32 -32
- package/out/static/js/main.js +2 -2
- package/out/storage/index.d.ts +1 -0
- package/out/storage/mysql.d.ts +1 -0
- package/out/storage/mysql.js +9 -0
- package/out/storage/postgre.d.ts +1 -0
- package/out/storage/postgre.js +9 -0
- package/out/storage/sqlite.d.ts +1 -0
- package/out/storage/sqlite.js +3 -0
- package/out/types.d.ts +19 -1
- package/out/util/logger.d.ts +5 -2
- package/out/util/logger.js +26 -10
- package/out/views/main.handlebars +48 -24
- package/package.json +16 -8
package/out/modules/manifest.js
CHANGED
|
@@ -5,6 +5,7 @@ const util_1 = require("../util");
|
|
|
5
5
|
const subscription_1 = require("../util/subscription");
|
|
6
6
|
const api_1 = require("./api/api");
|
|
7
7
|
const util_2 = require("./ai-tools/util");
|
|
8
|
+
const util_3 = require("./workflow-step-type/util");
|
|
8
9
|
function normalizeEnvironments(environments) {
|
|
9
10
|
if (Array.isArray(environments)) {
|
|
10
11
|
return environments;
|
|
@@ -12,6 +13,7 @@ function normalizeEnvironments(environments) {
|
|
|
12
13
|
return [environments];
|
|
13
14
|
}
|
|
14
15
|
function handle(config) {
|
|
16
|
+
var _a, _b;
|
|
15
17
|
const modules = {};
|
|
16
18
|
if (config.projectIntegration) {
|
|
17
19
|
config.projectIntegration.key = config.identifier + '-int';
|
|
@@ -100,6 +102,17 @@ function handle(config) {
|
|
|
100
102
|
},
|
|
101
103
|
];
|
|
102
104
|
}
|
|
105
|
+
if (config.organizationSettingsMenu) {
|
|
106
|
+
config.organizationSettingsMenu.key = config.identifier + '-organization-settings-menu';
|
|
107
|
+
modules['organization-settings-menu'] = [
|
|
108
|
+
{
|
|
109
|
+
key: config.organizationSettingsMenu.key,
|
|
110
|
+
name: config.organizationSettingsMenu.name || config.name,
|
|
111
|
+
url: '/settings/' + (config.organizationSettingsMenu.fileName || 'index.html'),
|
|
112
|
+
icon: (0, util_1.getLogoUrl)(config.organizationSettingsMenu, '/settings'),
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
}
|
|
103
116
|
if (config.profileResourcesMenu) {
|
|
104
117
|
config.profileResourcesMenu.key = config.identifier + '-profile-resources-menu';
|
|
105
118
|
modules['profile-resources-menu'] = [
|
|
@@ -108,6 +121,14 @@ function handle(config) {
|
|
|
108
121
|
})),
|
|
109
122
|
];
|
|
110
123
|
}
|
|
124
|
+
if (config.profileSettingsMenu) {
|
|
125
|
+
config.profileSettingsMenu.key = config.identifier + '-profile-settings-menu';
|
|
126
|
+
modules['profile-settings-menu'] = [
|
|
127
|
+
Object.assign({ key: config.profileSettingsMenu.key, name: config.profileSettingsMenu.name || config.name, url: '/settings/' + (config.profileSettingsMenu.fileName || 'index.html'), icon: (0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings') }, (!!config.profileSettingsMenu.environments && {
|
|
128
|
+
environments: normalizeEnvironments(config.profileSettingsMenu.environments),
|
|
129
|
+
})),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
111
132
|
if (config.editorRightPanel) {
|
|
112
133
|
config.editorRightPanel.key = config.identifier + '-editor-panels';
|
|
113
134
|
modules['editor-right-panel'] = [
|
|
@@ -225,6 +246,18 @@ function handle(config) {
|
|
|
225
246
|
})));
|
|
226
247
|
}
|
|
227
248
|
}
|
|
249
|
+
if (config.webhooks) {
|
|
250
|
+
const webhooks = Array.isArray(config.webhooks) ? config.webhooks : [config.webhooks];
|
|
251
|
+
modules['webhook'] = [];
|
|
252
|
+
for (let i = 0; i < webhooks.length; i++) {
|
|
253
|
+
webhooks[i].key = config.identifier + '-' + 'webhook-' + i;
|
|
254
|
+
modules['webhook'].push({
|
|
255
|
+
key: webhooks[i].key,
|
|
256
|
+
url: '/webhooks',
|
|
257
|
+
events: webhooks[i].events,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
228
261
|
if (config.externalQaCheck) {
|
|
229
262
|
config.externalQaCheck.key = config.identifier + '-qa-check';
|
|
230
263
|
const uiModule = config.externalQaCheck.settingsUiModule;
|
|
@@ -232,6 +265,19 @@ function handle(config) {
|
|
|
232
265
|
Object.assign(Object.assign({ key: config.externalQaCheck.key, name: config.externalQaCheck.name || config.name, description: config.externalQaCheck.description || config.description, runQaCheckUrl: '/validate' }, (config.externalQaCheck.batchSize ? { getBatchSizeUrl: '/batch-size' } : {})), (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
|
|
233
266
|
];
|
|
234
267
|
}
|
|
268
|
+
if (config.workflowStepType) {
|
|
269
|
+
const workflowSteps = Array.isArray(config.workflowStepType)
|
|
270
|
+
? config.workflowStepType
|
|
271
|
+
: [config.workflowStepType];
|
|
272
|
+
modules['workflow-step-type'] = [];
|
|
273
|
+
for (const workflowStep of workflowSteps) {
|
|
274
|
+
if (!workflowStep.key) {
|
|
275
|
+
workflowStep.key = config.identifier + '-' + (0, util_3.getWorkflowStepKey)(workflowStep);
|
|
276
|
+
}
|
|
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({ key: workflowStep.key, name: workflowStep.name || config.name, description: workflowStep.description || config.description, boundaries: workflowStep.boundaries, updateSettingsUrl: (0, util_3.getWorkflowStepUrl)('/settings', workflowStep), deleteSettingsUrl: (0, util_3.getWorkflowStepUrl)('/delete', workflowStep) }, (uiModule ? { url: (0, util_3.getWorkflowStepUrl)('/workflow-step', workflowStep) } : {})));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
235
281
|
const events = {
|
|
236
282
|
installed: '/installed',
|
|
237
283
|
uninstall: '/uninstall',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.organizationSettingsMenu) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
15
|
+
app.get((0, util_1.getLogoUrl)(config.organizationSettingsMenu, '/settings'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
16
|
+
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.organizationSettingsMenu.key }), (0, render_ui_module_1.default)(config.organizationSettingsMenu));
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.profileSettingsMenu) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
app.get((0, util_1.getLogoUrl)(config.profileSettingsMenu, '/settings'), (req, res) => { var _a; return res.sendFile(((_a = config.profileSettingsMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
15
|
+
const allowUnauthorized = !(0, util_1.isAuthorizedConfig)(config);
|
|
16
|
+
app.use('/settings', (0, ui_module_1.default)({ config, allowUnauthorized, moduleType: config.profileSettingsMenu.key }), (0, render_ui_module_1.default)(config.profileSettingsMenu));
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Config, CrowdinClientRequest } from '../../../types';
|
|
3
|
+
import { Response } from 'express';
|
|
4
|
+
import { Webhook } from '../types';
|
|
5
|
+
export declare function webhookHandler(config: Config, webhooks: Webhook[]): (req: CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.webhookHandler = void 0;
|
|
39
|
+
const util_1 = require("../../../util");
|
|
40
|
+
const lodash_isstring_1 = __importDefault(require("lodash.isstring"));
|
|
41
|
+
const crypto = __importStar(require("node:crypto"));
|
|
42
|
+
const storage = __importStar(require("../../../storage"));
|
|
43
|
+
const connection_1 = require("../../../util/connection");
|
|
44
|
+
function webhookHandler(config, webhooks) {
|
|
45
|
+
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const domain = req.headers['x-crowdin-domain'];
|
|
47
|
+
const organizationId = req.headers['x-crowdin-id'];
|
|
48
|
+
const signature = req.headers['x-crowdin-signature'];
|
|
49
|
+
const moduleKey = req.headers['x-module-key'];
|
|
50
|
+
if (!(0, lodash_isstring_1.default)(domain) || !(0, lodash_isstring_1.default)(organizationId) || !(0, lodash_isstring_1.default)(signature) || !(0, lodash_isstring_1.default)(moduleKey)) {
|
|
51
|
+
res.status(400).send({ error: 'Invalid request' });
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const crowdinId = domain || organizationId;
|
|
55
|
+
const credentials = yield storage.getStorage().getCrowdinCredentials(crowdinId);
|
|
56
|
+
if (!credentials) {
|
|
57
|
+
throw new Error('Failed to find Crowdin credentials');
|
|
58
|
+
}
|
|
59
|
+
const hmac = crypto.createHmac('sha256', credentials.appSecret);
|
|
60
|
+
hmac.update(req.body.toString());
|
|
61
|
+
const generatedSignature = hmac.digest('hex');
|
|
62
|
+
if (generatedSignature !== signature.replace('sha256=', '')) {
|
|
63
|
+
res.status(403).send({ error: 'Invalid signature' });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
res.status(200).send();
|
|
67
|
+
const { client } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, autoRenew: true });
|
|
68
|
+
const json = JSON.parse(req.body.toString());
|
|
69
|
+
for (const webhook of webhooks) {
|
|
70
|
+
if (webhook.key === moduleKey) {
|
|
71
|
+
for (const event of json.events) {
|
|
72
|
+
yield webhook.callback({ credentials, event, client });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
exports.webhookHandler = webhookHandler;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
8
|
+
const webhook_handler_1 = require("./handlers/webhook-handler");
|
|
9
|
+
function register({ config, app }) {
|
|
10
|
+
if (!config.webhooks) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const webhooks = Array.isArray(config.webhooks) ? config.webhooks : [config.webhooks];
|
|
14
|
+
if (webhooks.length) {
|
|
15
|
+
app.post('/webhooks', json_response_1.default, (0, webhook_handler_1.webhookHandler)(config, webhooks));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { CrowdinCredentials, ModuleKey } from '../../types';
|
|
2
|
+
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
|
+
export interface Webhook extends ModuleKey {
|
|
4
|
+
/**
|
|
5
|
+
* Events that the webhook should listen to
|
|
6
|
+
*/
|
|
7
|
+
events: string[];
|
|
8
|
+
/**
|
|
9
|
+
* handle function
|
|
10
|
+
*/
|
|
11
|
+
callback: (data: {
|
|
12
|
+
credentials: CrowdinCredentials;
|
|
13
|
+
event: Event;
|
|
14
|
+
client: Crowdin;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
interface EventPayload {
|
|
18
|
+
event: string;
|
|
19
|
+
}
|
|
20
|
+
interface BranchPayload {
|
|
21
|
+
id: number;
|
|
22
|
+
}
|
|
23
|
+
interface FilePayload {
|
|
24
|
+
id: number;
|
|
25
|
+
name: string;
|
|
26
|
+
title: string | null;
|
|
27
|
+
type: string;
|
|
28
|
+
path: string;
|
|
29
|
+
status: string;
|
|
30
|
+
revision: number;
|
|
31
|
+
branchId: number | null;
|
|
32
|
+
directoryId: number | null;
|
|
33
|
+
project?: ProjectPayload;
|
|
34
|
+
}
|
|
35
|
+
interface GroupPayload {
|
|
36
|
+
id: number;
|
|
37
|
+
name: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
updatedAt: string;
|
|
40
|
+
description: string | null;
|
|
41
|
+
parentId: number;
|
|
42
|
+
userId: number;
|
|
43
|
+
organizationId: number;
|
|
44
|
+
}
|
|
45
|
+
interface LanguagePayload {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
editorCode: string;
|
|
49
|
+
twoLettersCode: string;
|
|
50
|
+
threeLettersCode: string;
|
|
51
|
+
locale: string;
|
|
52
|
+
androidCode: string;
|
|
53
|
+
osxCode: string;
|
|
54
|
+
osxLocale: string;
|
|
55
|
+
textDirection: string;
|
|
56
|
+
dialectOf: string;
|
|
57
|
+
}
|
|
58
|
+
interface ProjectBuildPayload {
|
|
59
|
+
id: number;
|
|
60
|
+
downloadUrl: string;
|
|
61
|
+
project: ProjectPayload;
|
|
62
|
+
}
|
|
63
|
+
interface ProjectPayload {
|
|
64
|
+
id: number;
|
|
65
|
+
userId: number;
|
|
66
|
+
sourceLanguageId: string;
|
|
67
|
+
targetLanguageIds: string[];
|
|
68
|
+
identifier: string;
|
|
69
|
+
name: string;
|
|
70
|
+
createdAt: string;
|
|
71
|
+
updatedAt: string;
|
|
72
|
+
lastActivity: string;
|
|
73
|
+
description: string;
|
|
74
|
+
url: string;
|
|
75
|
+
cname: string | null;
|
|
76
|
+
languageAccessPolicy?: string;
|
|
77
|
+
visibility?: string;
|
|
78
|
+
publicDownloads?: boolean;
|
|
79
|
+
logo?: string;
|
|
80
|
+
isExternal?: boolean;
|
|
81
|
+
externalType?: string | null;
|
|
82
|
+
hasCrowdsourcing?: boolean;
|
|
83
|
+
}
|
|
84
|
+
interface StepPayload {
|
|
85
|
+
name: string;
|
|
86
|
+
}
|
|
87
|
+
interface SuggestionPayload {
|
|
88
|
+
id: number;
|
|
89
|
+
text: string;
|
|
90
|
+
pluralCategoryName: string | null;
|
|
91
|
+
rating: number;
|
|
92
|
+
provider: string | null;
|
|
93
|
+
isPreTranslated: boolean;
|
|
94
|
+
createdAt: string;
|
|
95
|
+
step?: StepPayload | null;
|
|
96
|
+
}
|
|
97
|
+
interface NewSuggestionPayload {
|
|
98
|
+
user: UserPayload | null;
|
|
99
|
+
targetLanguage: LanguagePayload | null;
|
|
100
|
+
string: TranslationPayload | null;
|
|
101
|
+
}
|
|
102
|
+
interface TaskPayload {
|
|
103
|
+
id: number;
|
|
104
|
+
type: number;
|
|
105
|
+
vendor?: string | null;
|
|
106
|
+
status?: string | null;
|
|
107
|
+
title: string;
|
|
108
|
+
assignees: TaskAssigneeUserPayload[];
|
|
109
|
+
assignedTeams: TaskAssigneeTeamPayload[];
|
|
110
|
+
fileIds?: number[];
|
|
111
|
+
branchIds?: number[];
|
|
112
|
+
progress: {
|
|
113
|
+
total: number;
|
|
114
|
+
done: number;
|
|
115
|
+
percent: number;
|
|
116
|
+
};
|
|
117
|
+
description: string;
|
|
118
|
+
translationUrl: string | null;
|
|
119
|
+
wordsCount: number;
|
|
120
|
+
filesCount?: number;
|
|
121
|
+
commentsCount: number;
|
|
122
|
+
deadline: string;
|
|
123
|
+
timeRange: string | null;
|
|
124
|
+
workflowStepId: number;
|
|
125
|
+
buyUrl: string;
|
|
126
|
+
createdAt: string;
|
|
127
|
+
updatedAt: string;
|
|
128
|
+
oldStatus: string | null;
|
|
129
|
+
newStatus: string | null;
|
|
130
|
+
sourceLanguage: LanguagePayload;
|
|
131
|
+
targetLanguage: LanguagePayload | null;
|
|
132
|
+
project: ProjectPayload;
|
|
133
|
+
taskCreator: UserPayload;
|
|
134
|
+
}
|
|
135
|
+
interface TranslationDiscussionsPayload {
|
|
136
|
+
id: number;
|
|
137
|
+
text: string;
|
|
138
|
+
type: string;
|
|
139
|
+
issueType: string;
|
|
140
|
+
issueStatus: string;
|
|
141
|
+
resolvedAt: string;
|
|
142
|
+
createdAt: string;
|
|
143
|
+
string: TranslationPayload;
|
|
144
|
+
targetLanguage: LanguagePayload;
|
|
145
|
+
user: UserPayload;
|
|
146
|
+
commentResolver: UserPayload;
|
|
147
|
+
}
|
|
148
|
+
interface TranslationPayload {
|
|
149
|
+
id: number;
|
|
150
|
+
identifier: string;
|
|
151
|
+
key: string;
|
|
152
|
+
text: string;
|
|
153
|
+
type: string;
|
|
154
|
+
context: string;
|
|
155
|
+
maxLength: number;
|
|
156
|
+
isHidden: boolean;
|
|
157
|
+
isDuplicate: boolean;
|
|
158
|
+
masterStringId: number;
|
|
159
|
+
revision?: number;
|
|
160
|
+
hasPlurals: boolean;
|
|
161
|
+
labelIds: number[];
|
|
162
|
+
url: string;
|
|
163
|
+
createdAt: string;
|
|
164
|
+
updatedAt: string;
|
|
165
|
+
file?: FilePayload;
|
|
166
|
+
branch?: BranchPayload;
|
|
167
|
+
project: ProjectPayload;
|
|
168
|
+
}
|
|
169
|
+
interface UserPayload {
|
|
170
|
+
id: number;
|
|
171
|
+
username: string;
|
|
172
|
+
fullName: string;
|
|
173
|
+
avatarUrl: string;
|
|
174
|
+
}
|
|
175
|
+
interface TaskAssigneeUserPayload extends UserPayload {
|
|
176
|
+
worksCount: number;
|
|
177
|
+
wordsLeft: number;
|
|
178
|
+
}
|
|
179
|
+
interface TaskAssigneeTeamPayload {
|
|
180
|
+
id: number;
|
|
181
|
+
wordsCount: number;
|
|
182
|
+
}
|
|
183
|
+
export interface FileTranslatedEvent extends EventPayload {
|
|
184
|
+
file: FilePayload;
|
|
185
|
+
targetLanguage: LanguagePayload;
|
|
186
|
+
step?: StepPayload;
|
|
187
|
+
}
|
|
188
|
+
export interface FileApprovedEvent extends EventPayload {
|
|
189
|
+
file: FilePayload;
|
|
190
|
+
targetLanguage: LanguagePayload;
|
|
191
|
+
step?: StepPayload;
|
|
192
|
+
}
|
|
193
|
+
export interface FileAddedEvent extends EventPayload {
|
|
194
|
+
file: FilePayload;
|
|
195
|
+
user: UserPayload;
|
|
196
|
+
}
|
|
197
|
+
export interface FileUpdatedEvent extends EventPayload {
|
|
198
|
+
file: FilePayload;
|
|
199
|
+
user: UserPayload;
|
|
200
|
+
}
|
|
201
|
+
export interface FileRevertedEvent extends EventPayload {
|
|
202
|
+
file: FilePayload;
|
|
203
|
+
user: UserPayload;
|
|
204
|
+
}
|
|
205
|
+
export interface FileDeletedEvent extends EventPayload {
|
|
206
|
+
file: FilePayload;
|
|
207
|
+
user: UserPayload;
|
|
208
|
+
}
|
|
209
|
+
export interface ProjectTranslatedEvent extends EventPayload {
|
|
210
|
+
project: ProjectPayload;
|
|
211
|
+
targetLanguage: LanguagePayload;
|
|
212
|
+
workflowStep: StepPayload;
|
|
213
|
+
}
|
|
214
|
+
export interface ProjectApprovedEvent extends EventPayload {
|
|
215
|
+
project: ProjectPayload;
|
|
216
|
+
targetLanguage: LanguagePayload;
|
|
217
|
+
workflowStep: StepPayload;
|
|
218
|
+
}
|
|
219
|
+
export interface ProjectBuiltEvent extends EventPayload {
|
|
220
|
+
build: ProjectBuildPayload;
|
|
221
|
+
}
|
|
222
|
+
export interface TopSuggestionUpdatedEvent extends EventPayload {
|
|
223
|
+
oldTranslation: SuggestionPayload;
|
|
224
|
+
newTranslation: NewSuggestionPayload;
|
|
225
|
+
}
|
|
226
|
+
export interface SuggestionAddedEvent extends EventPayload {
|
|
227
|
+
translation: TranslationPayload;
|
|
228
|
+
}
|
|
229
|
+
export interface SuggestionUpdatedEvent extends EventPayload {
|
|
230
|
+
translation: TranslationPayload;
|
|
231
|
+
}
|
|
232
|
+
export interface SuggestionDeletedEvent extends EventPayload {
|
|
233
|
+
translation: TranslationPayload;
|
|
234
|
+
}
|
|
235
|
+
export interface SuggestionApprovedEvent extends EventPayload {
|
|
236
|
+
translation: TranslationPayload;
|
|
237
|
+
}
|
|
238
|
+
export interface SuggestionDisapprovedEvent extends EventPayload {
|
|
239
|
+
translation: TranslationPayload;
|
|
240
|
+
}
|
|
241
|
+
export interface StringAddedEvent extends EventPayload {
|
|
242
|
+
string: TranslationPayload;
|
|
243
|
+
user: UserPayload;
|
|
244
|
+
}
|
|
245
|
+
export interface StringUpdatedEvent extends EventPayload {
|
|
246
|
+
string: TranslationPayload;
|
|
247
|
+
user: UserPayload;
|
|
248
|
+
}
|
|
249
|
+
export interface StringDeletedEvent extends EventPayload {
|
|
250
|
+
string: TranslationPayload;
|
|
251
|
+
user: UserPayload;
|
|
252
|
+
}
|
|
253
|
+
export interface TranslationDiscussionsCreatedEvent extends EventPayload {
|
|
254
|
+
comment: TranslationDiscussionsPayload;
|
|
255
|
+
}
|
|
256
|
+
export interface TranslationDiscussionsUpdatedEvent extends EventPayload {
|
|
257
|
+
comment: TranslationDiscussionsPayload;
|
|
258
|
+
}
|
|
259
|
+
export interface TranslationDiscussionsDeletedEvent extends EventPayload {
|
|
260
|
+
comment: TranslationDiscussionsPayload;
|
|
261
|
+
}
|
|
262
|
+
export interface TranslationDiscussionsRestoredEvent extends EventPayload {
|
|
263
|
+
comment: TranslationDiscussionsPayload;
|
|
264
|
+
}
|
|
265
|
+
export interface TaskAddedEvent extends EventPayload {
|
|
266
|
+
task: TaskPayload;
|
|
267
|
+
}
|
|
268
|
+
export interface TaskStatusChangedEvent extends EventPayload {
|
|
269
|
+
task: TaskPayload;
|
|
270
|
+
}
|
|
271
|
+
export interface TaskDeletedEvent extends EventPayload {
|
|
272
|
+
task: TaskPayload;
|
|
273
|
+
}
|
|
274
|
+
export interface TaskUpdatedEvent extends EventPayload {
|
|
275
|
+
task: TaskPayload;
|
|
276
|
+
}
|
|
277
|
+
export interface ProjectCreatedEvent extends EventPayload {
|
|
278
|
+
project: ProjectPayload;
|
|
279
|
+
user: UserPayload;
|
|
280
|
+
}
|
|
281
|
+
export interface ProjectDeletedEvent extends EventPayload {
|
|
282
|
+
project: ProjectPayload;
|
|
283
|
+
user: UserPayload;
|
|
284
|
+
}
|
|
285
|
+
export interface GroupCreatedEvent extends EventPayload {
|
|
286
|
+
group: GroupPayload;
|
|
287
|
+
user: UserPayload;
|
|
288
|
+
}
|
|
289
|
+
export interface GroupDeletedEvent extends EventPayload {
|
|
290
|
+
group: GroupPayload;
|
|
291
|
+
user: UserPayload;
|
|
292
|
+
}
|
|
293
|
+
export type Event = FileTranslatedEvent | FileApprovedEvent | FileAddedEvent | FileUpdatedEvent | FileRevertedEvent | FileDeletedEvent | ProjectTranslatedEvent | ProjectApprovedEvent | ProjectBuiltEvent | TopSuggestionUpdatedEvent | SuggestionAddedEvent | SuggestionUpdatedEvent | SuggestionDeletedEvent | SuggestionApprovedEvent | SuggestionDisapprovedEvent | StringAddedEvent | StringUpdatedEvent | StringDeletedEvent | TranslationDiscussionsCreatedEvent | TranslationDiscussionsUpdatedEvent | TranslationDiscussionsDeletedEvent | TranslationDiscussionsRestoredEvent | TaskAddedEvent | TaskStatusChangedEvent | TaskDeletedEvent | TaskUpdatedEvent | ProjectCreatedEvent | ProjectDeletedEvent | GroupCreatedEvent | GroupDeletedEvent;
|
|
294
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { CrowdinClientRequest } from '../../../types';
|
|
4
|
+
import { WorkflowStepTypeModule } from '../types';
|
|
5
|
+
export default function handle(workflowStep: WorkflowStepTypeModule): (req: CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const util_1 = require("../../../util");
|
|
36
|
+
const storage = __importStar(require("../../../storage"));
|
|
37
|
+
const logger_1 = require("../../../util/logger");
|
|
38
|
+
function handle(workflowStep) {
|
|
39
|
+
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
try {
|
|
41
|
+
const { organizationId, projectId, stepId, workflowId } = req.body;
|
|
42
|
+
const context = req.crowdinContext;
|
|
43
|
+
if (workflowStep.onDeleteStep) {
|
|
44
|
+
yield workflowStep.onDeleteStep({
|
|
45
|
+
projectId,
|
|
46
|
+
organizationId,
|
|
47
|
+
stepId,
|
|
48
|
+
workflowId,
|
|
49
|
+
context: req.crowdinContext,
|
|
50
|
+
client: req.crowdinApiClient,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const workflowStepDataId = `form-data-${context.crowdinId}-${projectId}-${stepId}`;
|
|
55
|
+
const existing = yield storage.getStorage().getMetadata(workflowStepDataId);
|
|
56
|
+
if (existing) {
|
|
57
|
+
yield storage.getStorage().deleteMetadata(workflowStepDataId);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
res.status(204).end();
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
if (req.logError) {
|
|
64
|
+
req.logError(e);
|
|
65
|
+
}
|
|
66
|
+
res.send({ error: { message: (0, logger_1.getErrorMessage)(e) } });
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
exports.default = handle;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { CrowdinClientRequest } from '../../../types';
|
|
4
|
+
import { WorkflowStepTypeModule } from '../types';
|
|
5
|
+
export default function handle(workflowStep: WorkflowStepTypeModule): (req: CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|