@crowdin/app-project-module 1.11.0 → 1.12.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/ai-prompt-provider/handlers/status.d.ts +4 -0
- package/out/modules/ai-prompt-provider/handlers/status.js +43 -0
- package/out/modules/ai-prompt-provider/index.js +9 -0
- package/out/modules/ai-prompt-provider/types.d.ts +21 -0
- package/out/modules/manifest.js +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { CrowdinClientRequest } from '../../../types';
|
|
3
|
+
import { AiPromptProviderModule } from '../types';
|
|
4
|
+
export default function handle(aiPromptProvider: AiPromptProviderModule): (req: import("express").Request | CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = handle;
|
|
13
|
+
const util_1 = require("../../../util");
|
|
14
|
+
const logger_1 = require("../../../util/logger");
|
|
15
|
+
function handle(aiPromptProvider) {
|
|
16
|
+
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
if (!aiPromptProvider.status) {
|
|
18
|
+
res.status(204).send();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
const { options, aiPromptId } = req.body;
|
|
23
|
+
const result = yield aiPromptProvider.status({
|
|
24
|
+
options,
|
|
25
|
+
aiPromptId,
|
|
26
|
+
client: req.crowdinApiClient,
|
|
27
|
+
context: req.crowdinContext,
|
|
28
|
+
});
|
|
29
|
+
res.send({
|
|
30
|
+
usedAiProviderIds: result.usedAiProviderIds,
|
|
31
|
+
isConfigured: result.isConfigured,
|
|
32
|
+
errors: result.errors,
|
|
33
|
+
warnings: result.warnings,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
if (req.logError) {
|
|
38
|
+
req.logError(e);
|
|
39
|
+
}
|
|
40
|
+
res.status(500).send({ error: { message: (0, logger_1.getErrorMessage)(e) } });
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
@@ -10,6 +10,7 @@ const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-
|
|
|
10
10
|
const util_1 = require("../../util");
|
|
11
11
|
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
12
12
|
const compile_1 = __importDefault(require("./handlers/compile"));
|
|
13
|
+
const status_1 = __importDefault(require("./handlers/status"));
|
|
13
14
|
const normalize_module_1 = require("../../util/normalize-module");
|
|
14
15
|
function register({ config, app }) {
|
|
15
16
|
var _a;
|
|
@@ -34,6 +35,14 @@ function register({ config, app }) {
|
|
|
34
35
|
checkSubscriptionExpiration: true,
|
|
35
36
|
moduleKey: key,
|
|
36
37
|
}), (0, compile_1.default)(provider));
|
|
38
|
+
if (provider.status) {
|
|
39
|
+
app.post(`${base}/status`, json_response_1.default, (0, crowdin_client_1.default)({
|
|
40
|
+
config,
|
|
41
|
+
optional: false,
|
|
42
|
+
checkSubscriptionExpiration: true,
|
|
43
|
+
moduleKey: key,
|
|
44
|
+
}), (0, status_1.default)(provider));
|
|
45
|
+
}
|
|
37
46
|
if (provider.formSchema || provider.uiPath) {
|
|
38
47
|
app.use(`${base}/settings`, (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: key }), (0, render_ui_module_1.default)(provider, config));
|
|
39
48
|
}
|
|
@@ -25,4 +25,25 @@ export interface AiPromptProviderModule extends UiModule {
|
|
|
25
25
|
* Default: true
|
|
26
26
|
*/
|
|
27
27
|
allowRetryOnQaIssues?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Optional handler that returns prompt status info (used providers, configuration state, errors).
|
|
30
|
+
* When provided, Crowdin will call this to display real-time status for external prompts.
|
|
31
|
+
*/
|
|
32
|
+
status?: (options: {
|
|
33
|
+
options: any;
|
|
34
|
+
aiPromptId: number;
|
|
35
|
+
client: Crowdin;
|
|
36
|
+
context: CrowdinContextInfo;
|
|
37
|
+
}) => Promise<{
|
|
38
|
+
usedAiProviderIds: number[];
|
|
39
|
+
isConfigured: boolean;
|
|
40
|
+
errors: Array<{
|
|
41
|
+
code: string;
|
|
42
|
+
message: string;
|
|
43
|
+
}>;
|
|
44
|
+
warnings: Array<{
|
|
45
|
+
code: string;
|
|
46
|
+
message: string;
|
|
47
|
+
}>;
|
|
48
|
+
}>;
|
|
28
49
|
}
|
package/out/modules/manifest.js
CHANGED
|
@@ -575,9 +575,9 @@ function handle(config) {
|
|
|
575
575
|
item.key = key;
|
|
576
576
|
const base = isSingle ? '/prompt-provider' : `/prompt-provider/${key}`;
|
|
577
577
|
const logoPath = isSingle ? '/ai-prompt-provider' : `/ai-prompt-provider-${key}`;
|
|
578
|
-
return Object.assign(Object.assign(Object.assign({ key, name: item.name || config.name, logo: (0, util_1.getLogoUrl)(config, item, logoPath), compileUrl: `${base}/compile` }, ((0, util_1.isDefined)(item.allowRetryOnQaIssues) && {
|
|
578
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({ key, name: item.name || config.name, logo: (0, util_1.getLogoUrl)(config, item, logoPath), compileUrl: `${base}/compile` }, ((0, util_1.isDefined)(item.allowRetryOnQaIssues) && {
|
|
579
579
|
allowRetryOnQaIssues: item.allowRetryOnQaIssues,
|
|
580
|
-
})), (item.actions ? { actions: item.actions } : {})), (item.formSchema || item.uiPath
|
|
580
|
+
})), (item.actions ? { actions: item.actions } : {})), (item.status ? { statusUrl: `${base}/status` } : {})), (item.formSchema || item.uiPath
|
|
581
581
|
? { configuratorUrl: `${base}/settings/` + (item.fileName || 'index.html') }
|
|
582
582
|
: {}));
|
|
583
583
|
});
|
package/package.json
CHANGED