@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
|
@@ -0,0 +1,80 @@
|
|
|
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, settings } = req.body;
|
|
42
|
+
const context = req.crowdinContext;
|
|
43
|
+
if (workflowStep.onStepSettingsSave) {
|
|
44
|
+
yield workflowStep.onStepSettingsSave({
|
|
45
|
+
projectId,
|
|
46
|
+
organizationId,
|
|
47
|
+
stepId,
|
|
48
|
+
workflowId,
|
|
49
|
+
settings,
|
|
50
|
+
context: req.crowdinContext,
|
|
51
|
+
client: req.crowdinApiClient,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const workflowStepDataId = `form-data-${context.crowdinId}-${projectId}-${stepId}`;
|
|
56
|
+
const workflowStepSettings = Object.assign(Object.assign({}, settings), { context,
|
|
57
|
+
stepId });
|
|
58
|
+
const existing = yield storage.getStorage().getMetadata(workflowStepDataId);
|
|
59
|
+
if (existing) {
|
|
60
|
+
yield storage
|
|
61
|
+
.getStorage()
|
|
62
|
+
.updateMetadata(workflowStepDataId, workflowStepSettings, context.crowdinId);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
yield storage
|
|
66
|
+
.getStorage()
|
|
67
|
+
.saveMetadata(workflowStepDataId, workflowStepSettings, context.crowdinId);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
res.status(204).end();
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
if (req.logError) {
|
|
74
|
+
req.logError(e);
|
|
75
|
+
}
|
|
76
|
+
res.send({ error: { message: (0, logger_1.getErrorMessage)(e) } });
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
exports.default = handle;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
8
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
9
|
+
const util_1 = require("./util");
|
|
10
|
+
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
11
|
+
const step_settings_save_1 = __importDefault(require("./handlers/step-settings-save"));
|
|
12
|
+
const delete_step_1 = __importDefault(require("./handlers/delete-step"));
|
|
13
|
+
function register({ config, app }) {
|
|
14
|
+
if (!config.workflowStepType) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const workflowSteps = Array.isArray(config.workflowStepType) ? config.workflowStepType : [config.workflowStepType];
|
|
18
|
+
for (const workflowStep of workflowSteps) {
|
|
19
|
+
app.post((0, util_1.getWorkflowStepUrl)('/settings', workflowStep), (0, crowdin_client_1.default)({
|
|
20
|
+
config,
|
|
21
|
+
optional: true,
|
|
22
|
+
checkSubscriptionExpiration: false,
|
|
23
|
+
moduleKey: workflowStep.key,
|
|
24
|
+
}), (0, step_settings_save_1.default)(workflowStep));
|
|
25
|
+
app.delete((0, util_1.getWorkflowStepUrl)('/delete', workflowStep), (0, crowdin_client_1.default)({
|
|
26
|
+
config,
|
|
27
|
+
optional: true,
|
|
28
|
+
checkSubscriptionExpiration: false,
|
|
29
|
+
moduleKey: workflowStep.key,
|
|
30
|
+
}), (0, delete_step_1.default)(workflowStep));
|
|
31
|
+
if (workflowStep.settingsUiModule) {
|
|
32
|
+
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
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.register = register;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CrowdinContextInfo, ModuleKey, UiModule } from '../../types';
|
|
2
|
+
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
|
+
interface Boundaries {
|
|
4
|
+
input: Input;
|
|
5
|
+
outputs: Output[];
|
|
6
|
+
}
|
|
7
|
+
interface Input {
|
|
8
|
+
title: string;
|
|
9
|
+
ports: Port[];
|
|
10
|
+
}
|
|
11
|
+
interface Output {
|
|
12
|
+
title: string;
|
|
13
|
+
port: Port;
|
|
14
|
+
}
|
|
15
|
+
type Port = 'customCodeFalse' | 'customCodeTrue' | 'untranslated' | 'translated' | 'approved' | 'skipped' | 'all';
|
|
16
|
+
export interface WorkflowStepTypeModule extends ModuleKey {
|
|
17
|
+
/**
|
|
18
|
+
* module name
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
/**
|
|
22
|
+
* module description
|
|
23
|
+
*/
|
|
24
|
+
description?: string;
|
|
25
|
+
/**
|
|
26
|
+
* settings UI module
|
|
27
|
+
*/
|
|
28
|
+
settingsUiModule?: UiModule;
|
|
29
|
+
/**
|
|
30
|
+
* input and output boundaries for the module
|
|
31
|
+
*/
|
|
32
|
+
boundaries: Boundaries;
|
|
33
|
+
/**
|
|
34
|
+
* function to save workflow step settings
|
|
35
|
+
*/
|
|
36
|
+
onStepSettingsSave: ({ organizationId, projectId, stepId, workflowId, settings, context, client, }: {
|
|
37
|
+
organizationId: number;
|
|
38
|
+
projectId?: number;
|
|
39
|
+
stepId: number;
|
|
40
|
+
workflowId: number;
|
|
41
|
+
settings: any;
|
|
42
|
+
context: CrowdinContextInfo;
|
|
43
|
+
client: Crowdin;
|
|
44
|
+
}) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* function for handling actions after a step has been deleted from the workflow
|
|
47
|
+
*/
|
|
48
|
+
onDeleteStep: ({ organizationId, projectId, stepId, workflowId, context, client, }: {
|
|
49
|
+
organizationId: number;
|
|
50
|
+
projectId?: number;
|
|
51
|
+
stepId: number;
|
|
52
|
+
workflowId: number;
|
|
53
|
+
context: CrowdinContextInfo;
|
|
54
|
+
client: Crowdin;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
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.getWorkflowStepUrl = exports.getWorkflowStepKey = void 0;
|
|
7
|
+
const lodash_snakecase_1 = __importDefault(require("lodash.snakecase"));
|
|
8
|
+
function getWorkflowStepKey(workflowStep) {
|
|
9
|
+
return (0, lodash_snakecase_1.default)(workflowStep.name);
|
|
10
|
+
}
|
|
11
|
+
exports.getWorkflowStepKey = getWorkflowStepKey;
|
|
12
|
+
function getWorkflowStepUrl(url, workflowStep) {
|
|
13
|
+
const key = (0, lodash_snakecase_1.default)(workflowStep.key) || getWorkflowStepKey(workflowStep);
|
|
14
|
+
return `${url}/${key}`;
|
|
15
|
+
}
|
|
16
|
+
exports.getWorkflowStepUrl = getWorkflowStepUrl;
|