@crowdin/app-project-module 1.2.1 → 1.3.1
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/app-test/integration/get-integration-files.js +1 -1
- package/out/app-test/integration/index.js +6 -6
- package/out/app-test/integration/mocks/crowdin-storage.d.ts +16 -16
- package/out/app-test/integration/mocks/mock-crowdin-api-client.js +17 -7
- package/out/app-test/integration/update-crowdin.js +1 -1
- package/out/app-test/integration/update-integration.js +1 -1
- package/out/app-test/util/index.js +1 -2
- package/out/index.js +23 -13
- package/out/middlewares/api-call.js +1 -1
- package/out/middlewares/auto-credentials-masker.js +2 -3
- package/out/middlewares/crowdin-client.d.ts +1 -2
- package/out/middlewares/crowdin-client.js +5 -6
- package/out/middlewares/integration-credentials.d.ts +1 -2
- package/out/middlewares/integration-credentials.js +18 -8
- package/out/middlewares/json-response.js +1 -1
- package/out/middlewares/render-ui-module.d.ts +1 -2
- package/out/middlewares/render-ui-module.js +1 -1
- package/out/middlewares/ui-module.d.ts +1 -2
- package/out/middlewares/ui-module.js +1 -1
- package/out/modules/about.js +2 -3
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -2
- package/out/modules/ai-prompt-provider/handlers/compile.js +1 -1
- package/out/modules/ai-prompt-provider/index.js +1 -2
- package/out/modules/ai-prompt-provider/types.js +1 -1
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -2
- package/out/modules/ai-provider/handlers/chat-completions.js +2 -2
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -2
- package/out/modules/ai-provider/handlers/get-model-list.js +1 -1
- package/out/modules/ai-provider/index.js +1 -2
- package/out/modules/ai-provider/util/index.js +6 -6
- package/out/modules/ai-request-processors/handler.d.ts +1 -2
- package/out/modules/ai-request-processors/handler.js +1 -1
- package/out/modules/ai-request-processors/index.js +5 -5
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -2
- package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
- package/out/modules/ai-tools/index.js +2 -3
- package/out/modules/ai-tools/util/index.js +4 -5
- package/out/modules/api/api.js +4 -5
- package/out/modules/api/index.js +1 -2
- package/out/modules/api/types.js +1 -1
- package/out/modules/auth-guard/handlers/verify.d.ts +1 -2
- package/out/modules/auth-guard/handlers/verify.js +1 -1
- package/out/modules/auth-guard/index.js +1 -2
- package/out/modules/automation-action/handlers/execute.d.ts +1 -2
- package/out/modules/automation-action/handlers/execute.js +1 -1
- package/out/modules/automation-action/handlers/input-schema.d.ts +1 -2
- package/out/modules/automation-action/handlers/input-schema.js +1 -1
- package/out/modules/automation-action/handlers/output-schema.d.ts +1 -2
- package/out/modules/automation-action/handlers/output-schema.js +1 -1
- package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -2
- package/out/modules/automation-action/handlers/validate-settings.js +1 -1
- package/out/modules/automation-action/index.js +1 -2
- package/out/modules/automation-action/util/index.js +2 -3
- package/out/modules/automation-action/util/validate-input.js +1 -2
- package/out/modules/context-menu/index.js +1 -2
- package/out/modules/context-menu/types.js +2 -2
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -2
- package/out/modules/custom-mt/handlers/translate.js +1 -1
- package/out/modules/custom-mt/index.js +1 -2
- package/out/modules/custom-mt/types.d.ts +0 -2
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -2
- package/out/modules/custom-spell-check/handlers/get-languages-list.js +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -2
- package/out/modules/custom-spell-check/handlers/spell-check.js +1 -1
- package/out/modules/custom-spell-check/index.js +1 -2
- package/out/modules/editor-right-panel/index.js +1 -2
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -2
- package/out/modules/external-qa-check/handlers/validate.js +1 -1
- package/out/modules/external-qa-check/index.js +1 -2
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +1 -2
- package/out/modules/file-processing/handlers/custom-file-format.js +9 -9
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -2
- package/out/modules/file-processing/handlers/file-download.js +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -2
- package/out/modules/file-processing/handlers/pre-post-process.js +1 -1
- package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -2
- package/out/modules/file-processing/handlers/translations-alignment.js +1 -1
- package/out/modules/file-processing/index.js +6 -7
- package/out/modules/file-processing/types.d.ts +0 -2
- package/out/modules/file-processing/types.js +1 -1
- package/out/modules/file-processing/util/defaults.js +18 -9
- package/out/modules/file-processing/util/files.d.ts +0 -2
- package/out/modules/file-processing/util/files.js +4 -4
- package/out/modules/form-data-display.d.ts +1 -2
- package/out/modules/form-data-display.js +18 -8
- package/out/modules/form-data-save.d.ts +1 -2
- package/out/modules/form-data-save.js +18 -8
- package/out/modules/install.d.ts +1 -2
- package/out/modules/install.js +2 -2
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -2
- package/out/modules/integration/handlers/crowdin-file-progress.js +1 -1
- package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +1 -2
- package/out/modules/integration/handlers/crowdin-files-target-languages.js +1 -1
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -2
- package/out/modules/integration/handlers/crowdin-files.js +1 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -2
- package/out/modules/integration/handlers/crowdin-project.js +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -2
- package/out/modules/integration/handlers/crowdin-update.js +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -2
- package/out/modules/integration/handlers/crowdin-webhook.js +2 -2
- package/out/modules/integration/handlers/integration-data.d.ts +1 -2
- package/out/modules/integration/handlers/integration-data.js +1 -1
- package/out/modules/integration/handlers/integration-login.d.ts +1 -2
- package/out/modules/integration/handlers/integration-login.js +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -2
- package/out/modules/integration/handlers/integration-logout.js +18 -8
- package/out/modules/integration/handlers/integration-update.d.ts +1 -2
- package/out/modules/integration/handlers/integration-update.js +1 -1
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -2
- package/out/modules/integration/handlers/integration-webhook.js +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -2
- package/out/modules/integration/handlers/invite-users.js +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -2
- package/out/modules/integration/handlers/job-cancel.js +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -2
- package/out/modules/integration/handlers/job-info-deprecated.js +1 -1
- package/out/modules/integration/handlers/job-info.d.ts +1 -2
- package/out/modules/integration/handlers/job-info.js +1 -1
- package/out/modules/integration/handlers/job-list.d.ts +1 -2
- package/out/modules/integration/handlers/job-list.js +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -2
- package/out/modules/integration/handlers/main.js +1 -1
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -2
- package/out/modules/integration/handlers/oauth-login.js +1 -1
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -2
- package/out/modules/integration/handlers/oauth-polling.js +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -2
- package/out/modules/integration/handlers/oauth-url.js +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -2
- package/out/modules/integration/handlers/settings-save.js +1 -1
- package/out/modules/integration/handlers/settings.d.ts +1 -2
- package/out/modules/integration/handlers/settings.js +1 -1
- package/out/modules/integration/handlers/subscription-info.js +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -2
- package/out/modules/integration/handlers/sync-settings-save.js +1 -1
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -2
- package/out/modules/integration/handlers/sync-settings.js +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -2
- package/out/modules/integration/handlers/user-errors.js +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -2
- package/out/modules/integration/handlers/users.js +4 -5
- package/out/modules/integration/index.js +1 -2
- package/out/modules/integration/types.js +4 -4
- package/out/modules/integration/util/cron.js +46 -37
- package/out/modules/integration/util/defaults.js +33 -24
- package/out/modules/integration/util/files.js +29 -30
- package/out/modules/integration/util/job.js +29 -20
- package/out/modules/integration/util/snapshot.js +7 -8
- package/out/modules/integration/util/types.js +3 -3
- package/out/modules/integration/util/webhooks.js +54 -44
- package/out/modules/manifest.js +1 -1
- package/out/modules/modal/index.js +1 -2
- package/out/modules/organization-menu/index.js +1 -2
- package/out/modules/organization-settings-menu/index.js +1 -2
- package/out/modules/profile-resources-menu/index.js +1 -2
- package/out/modules/profile-settings-menu/index.js +1 -2
- package/out/modules/project-menu/index.js +1 -2
- package/out/modules/project-menu-crowdsource/index.js +1 -2
- package/out/modules/project-reports/index.js +1 -2
- package/out/modules/project-tools/index.js +1 -2
- package/out/modules/status.d.ts +1 -2
- package/out/modules/status.js +1 -1
- package/out/modules/subscription-paid.d.ts +1 -2
- package/out/modules/subscription-paid.js +1 -1
- package/out/modules/uninstall.d.ts +1 -2
- package/out/modules/uninstall.js +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +1 -2
- package/out/modules/webhooks/handlers/webhook-handler.js +18 -9
- package/out/modules/webhooks/index.js +1 -2
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -2
- package/out/modules/workflow-step-type/handlers/delete-step.js +18 -8
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -2
- package/out/modules/workflow-step-type/handlers/step-settings-save.js +18 -8
- package/out/modules/workflow-step-type/index.js +1 -2
- package/out/modules/workflow-step-type/types.js +1 -1
- package/out/modules/workflow-step-type/util/index.js +2 -3
- package/out/static/ui/error.bundle.js +446 -379
- package/out/static/ui/error.bundle.js.map +1 -1
- package/out/static/ui/form.bundle.js +29793 -29989
- package/out/static/ui/form.bundle.js.map +1 -1
- package/out/static/ui/install.bundle.js +446 -379
- package/out/static/ui/install.bundle.js.map +1 -1
- package/out/static/ui/login.bundle.js +448 -379
- package/out/static/ui/login.bundle.js.map +1 -1
- package/out/static/ui/main.bundle.js +448 -379
- package/out/static/ui/main.bundle.js.map +1 -1
- package/out/static/ui/oauth.bundle.js +448 -379
- package/out/static/ui/oauth.bundle.js.map +1 -1
- package/out/storage/d1.d.ts +1 -1
- package/out/storage/d1.js +29 -27
- package/out/storage/index.d.ts +1 -1
- package/out/storage/index.js +25 -11
- package/out/storage/mysql.d.ts +1 -1
- package/out/storage/mysql.js +35 -33
- package/out/storage/postgre.d.ts +1 -1
- package/out/storage/postgre.js +46 -44
- package/out/storage/sqlite.d.ts +1 -1
- package/out/storage/sqlite.js +18 -16
- package/out/types.d.ts +0 -2
- package/out/types.js +8 -8
- package/out/util/connection.js +34 -25
- package/out/util/credentials-masker.d.ts +1 -2
- package/out/util/credentials-masker.js +3 -4
- package/out/util/cron.js +20 -10
- package/out/util/form-schema.js +2 -3
- package/out/util/index.js +38 -28
- package/out/util/jsx-renderer.js +2 -3
- package/out/util/logger.js +41 -31
- package/out/util/static-files.d.ts +0 -1
- package/out/util/static-files.js +2 -3
- package/out/util/subscription.js +11 -12
- package/out/views/FormPage.js +3 -3
- package/package.json +28 -33
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.getIntegrationFilesTest = void 0;
|
|
13
13
|
const globals_1 = require("@jest/globals");
|
|
14
14
|
const util_1 = require("../util");
|
|
15
|
-
const getIntegrationFilesTest = (
|
|
15
|
+
const getIntegrationFilesTest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ appConfig, integrationTestConfig, }) {
|
|
16
16
|
if (!appConfig.projectIntegration) {
|
|
17
17
|
throw new Error('The app configuration is missing the projectIntegration module.');
|
|
18
18
|
}
|
|
@@ -35,8 +35,8 @@ const runProjectIntegrationTests = ({ getAppConfig, integrationTestConfig, }) =>
|
|
|
35
35
|
}
|
|
36
36
|
}));
|
|
37
37
|
(0, globals_1.test)('getIntegrationFiles()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
-
var
|
|
39
|
-
if ((
|
|
38
|
+
var _a;
|
|
39
|
+
if ((_a = integrationTestConfig.getIntegrationFiles) === null || _a === void 0 ? void 0 : _a.setup) {
|
|
40
40
|
yield integrationTestConfig.getIntegrationFiles.setup();
|
|
41
41
|
}
|
|
42
42
|
const appConfig = yield getAppConfig();
|
|
@@ -44,8 +44,8 @@ const runProjectIntegrationTests = ({ getAppConfig, integrationTestConfig, }) =>
|
|
|
44
44
|
}));
|
|
45
45
|
if (!((_b = integrationTestConfig.updateCrowdin) === null || _b === void 0 ? void 0 : _b.disabled)) {
|
|
46
46
|
(0, globals_1.test)('updateCrowdin()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
var
|
|
48
|
-
if ((
|
|
47
|
+
var _a;
|
|
48
|
+
if ((_a = integrationTestConfig.updateCrowdin) === null || _a === void 0 ? void 0 : _a.setup) {
|
|
49
49
|
yield integrationTestConfig.updateCrowdin.setup();
|
|
50
50
|
}
|
|
51
51
|
const appConfig = yield getAppConfig();
|
|
@@ -57,8 +57,8 @@ const runProjectIntegrationTests = ({ getAppConfig, integrationTestConfig, }) =>
|
|
|
57
57
|
}
|
|
58
58
|
if (!((_c = integrationTestConfig.updateIntegration) === null || _c === void 0 ? void 0 : _c.disabled)) {
|
|
59
59
|
(0, globals_1.test)('updateIntegration()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
-
var
|
|
61
|
-
if ((
|
|
60
|
+
var _a;
|
|
61
|
+
if ((_a = integrationTestConfig.updateIntegration) === null || _a === void 0 ? void 0 : _a.setup) {
|
|
62
62
|
yield integrationTestConfig.updateIntegration.setup();
|
|
63
63
|
}
|
|
64
64
|
const appConfig = yield getAppConfig();
|
|
@@ -6,11 +6,11 @@ export declare const crowdinFolders: {
|
|
|
6
6
|
id: number;
|
|
7
7
|
path: string;
|
|
8
8
|
name: string;
|
|
9
|
-
branchId?: number
|
|
10
|
-
directoryId?: number
|
|
11
|
-
title?: string
|
|
12
|
-
exportPattern?: string
|
|
13
|
-
priority?: SourceFilesModel.Priority
|
|
9
|
+
branchId?: number;
|
|
10
|
+
directoryId?: number;
|
|
11
|
+
title?: string;
|
|
12
|
+
exportPattern?: string;
|
|
13
|
+
priority?: SourceFilesModel.Priority;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
};
|
|
@@ -21,17 +21,17 @@ export declare const crowdinFiles: {
|
|
|
21
21
|
path: string;
|
|
22
22
|
storageId: number;
|
|
23
23
|
name: string;
|
|
24
|
-
branchId?: number
|
|
25
|
-
directoryId?: number
|
|
26
|
-
title?: string
|
|
27
|
-
context?: string
|
|
28
|
-
type?: SourceFilesModel.FileType
|
|
29
|
-
parserVersion?: number
|
|
30
|
-
importOptions?: SourceFilesModel.ImportOptions
|
|
31
|
-
exportOptions?: SourceFilesModel.ExportOptions
|
|
32
|
-
excludedTargetLanguages?: string[]
|
|
33
|
-
attachLabelIds?: number[]
|
|
34
|
-
fields?: Record<string, any
|
|
24
|
+
branchId?: number;
|
|
25
|
+
directoryId?: number;
|
|
26
|
+
title?: string;
|
|
27
|
+
context?: string;
|
|
28
|
+
type?: SourceFilesModel.FileType;
|
|
29
|
+
parserVersion?: number;
|
|
30
|
+
importOptions?: SourceFilesModel.ImportOptions;
|
|
31
|
+
exportOptions?: SourceFilesModel.ExportOptions;
|
|
32
|
+
excludedTargetLanguages?: string[];
|
|
33
|
+
attachLabelIds?: number[];
|
|
34
|
+
fields?: Record<string, any>;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
};
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -64,7 +64,7 @@ const getFilesFromTree = (tree) => {
|
|
|
64
64
|
.filter(({ type }) => type)
|
|
65
65
|
.map((file) => file);
|
|
66
66
|
};
|
|
67
|
-
const updateCrowdinTest = (
|
|
67
|
+
const updateCrowdinTest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ appConfig, integrationTestConfig, }) {
|
|
68
68
|
const { updateCrowdin, settings, integrationCredentials: credentials } = integrationTestConfig;
|
|
69
69
|
const expectedTree = integrationTestConfig.getIntegrationFiles.expected;
|
|
70
70
|
if (!appConfig.projectIntegration) {
|
|
@@ -27,7 +27,7 @@ const getUpdateIntegrationRequest = () => {
|
|
|
27
27
|
return request;
|
|
28
28
|
};
|
|
29
29
|
exports.getUpdateIntegrationRequest = getUpdateIntegrationRequest;
|
|
30
|
-
const updateIntegrationTest = (
|
|
30
|
+
const updateIntegrationTest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ appConfig, integrationTestConfig, }) {
|
|
31
31
|
if (!appConfig.projectIntegration) {
|
|
32
32
|
throw new Error('The app configuration is missing the projectIntegration module.');
|
|
33
33
|
}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.assert =
|
|
12
|
+
exports.assert = assert;
|
|
13
13
|
function assert(matcher, error) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
try {
|
|
@@ -21,4 +21,3 @@ function assert(matcher, error) {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
exports.assert = assert;
|
package/out/index.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -35,7 +45,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
46
|
};
|
|
37
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
48
|
+
exports.metadataStore = exports.express = exports.UserPermissions = exports.Scope = exports.ProjectPermissions = exports.maskKey = exports.postRequestCredentialsMasker = exports.getRequestCredentialsMasker = void 0;
|
|
49
|
+
exports.createApp = createApp;
|
|
50
|
+
exports.addCrowdinEndpoints = addCrowdinEndpoints;
|
|
39
51
|
const logsFormatter = __importStar(require("@crowdin/logs-formatter"));
|
|
40
52
|
const express_rate_limit_1 = require("express-rate-limit");
|
|
41
53
|
const path_1 = require("path");
|
|
@@ -102,7 +114,7 @@ exports.metadataStore = {
|
|
|
102
114
|
getMetadata: (id) => {
|
|
103
115
|
return storage.getStorage().getMetadata(id);
|
|
104
116
|
},
|
|
105
|
-
saveMetadata: (
|
|
117
|
+
saveMetadata: (_a) => __awaiter(void 0, [_a], void 0, function* ({ id, metadata, crowdinId }) {
|
|
106
118
|
if (!crowdinId) {
|
|
107
119
|
throw new Error('The crowdinId parameter is required.');
|
|
108
120
|
}
|
|
@@ -135,7 +147,6 @@ function createApp(clientConfig) {
|
|
|
135
147
|
/* eslint no-console: "off" */
|
|
136
148
|
app.listen(config, () => console.log(`App started on port ${config.port}`));
|
|
137
149
|
}
|
|
138
|
-
exports.createApp = createApp;
|
|
139
150
|
function addCrowdinEndpoints(app, clientConfig) {
|
|
140
151
|
var _a, _b, _c;
|
|
141
152
|
const config = convertClientConfig(clientConfig);
|
|
@@ -185,7 +196,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
185
196
|
if (((_a = config === null || config === void 0 ? void 0 : config.enableStatusPage) === null || _a === void 0 ? void 0 : _a.database) || ((_b = config === null || config === void 0 ? void 0 : config.enableStatusPage) === null || _b === void 0 ? void 0 : _b.filesystem)) {
|
|
186
197
|
app.set('trust proxy', 1);
|
|
187
198
|
const limiter = (0, express_rate_limit_1.rateLimit)({
|
|
188
|
-
windowMs: 60 * 1000,
|
|
199
|
+
windowMs: 60 * 1000, // 1 minute
|
|
189
200
|
limit: ((_c = config.enableStatusPage) === null || _c === void 0 ? void 0 : _c.rateLimit) || 10,
|
|
190
201
|
standardHeaders: true,
|
|
191
202
|
legacyHeaders: false,
|
|
@@ -274,7 +285,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
274
285
|
checkSubscriptionExpiration: false,
|
|
275
286
|
moduleKey,
|
|
276
287
|
});
|
|
277
|
-
}, encryptCrowdinConnection: (data) => (0, util_1.encryptData)(config, JSON.stringify(data)), decryptCrowdinConnection: (
|
|
288
|
+
}, encryptCrowdinConnection: (data) => (0, util_1.encryptData)(config, JSON.stringify(data)), decryptCrowdinConnection: (_a) => __awaiter(this, [_a], void 0, function* ({ hash, autoRenew }) {
|
|
278
289
|
const { crowdinId, extra } = JSON.parse((0, util_1.decryptData)(config, hash));
|
|
279
290
|
const credentials = yield storage.getStorage().getCrowdinCredentials(crowdinId);
|
|
280
291
|
if (!credentials) {
|
|
@@ -292,7 +303,6 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
292
303
|
});
|
|
293
304
|
} });
|
|
294
305
|
}
|
|
295
|
-
exports.addCrowdinEndpoints = addCrowdinEndpoints;
|
|
296
306
|
function addFormSchema({ app, config }) {
|
|
297
307
|
for (const moduleKey of Object.keys(config)) {
|
|
298
308
|
const moduleConfig = config[moduleKey];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.autoCredentialsMaskerMiddleware = autoCredentialsMaskerMiddleware;
|
|
4
|
+
exports.registerAutoCredentialsMasker = registerAutoCredentialsMasker;
|
|
4
5
|
const credentials_masker_1 = require("../util/credentials-masker");
|
|
5
6
|
const form_schema_1 = require("../util/form-schema");
|
|
6
7
|
const logger_1 = require("../util/logger");
|
|
@@ -41,8 +42,6 @@ function autoCredentialsMaskerMiddleware(config) {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
}
|
|
44
|
-
exports.autoCredentialsMaskerMiddleware = autoCredentialsMaskerMiddleware;
|
|
45
45
|
function registerAutoCredentialsMasker(app, config) {
|
|
46
46
|
app.use(autoCredentialsMaskerMiddleware(config));
|
|
47
47
|
}
|
|
48
|
-
exports.registerAutoCredentialsMasker = registerAutoCredentialsMasker;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
2
|
import { Response } from 'express';
|
|
4
3
|
import { Config, CrowdinClientRequest, CrowdinContextInfo, SubscriptionInfo } from '../types';
|
|
@@ -21,5 +20,5 @@ export default function handle({ config, optional, checkSubscriptionExpiration,
|
|
|
21
20
|
optional: boolean;
|
|
22
21
|
checkSubscriptionExpiration: boolean;
|
|
23
22
|
moduleKey?: string[] | string | undefined;
|
|
24
|
-
}): (req: import("express").Request
|
|
23
|
+
}): (req: import("express").Request | CrowdinClientRequest, res: Response, next: Function) => void;
|
|
25
24
|
export declare function getToken(req: CrowdinClientRequest): string | undefined;
|
|
@@ -9,7 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.prepareCrowdinRequest = prepareCrowdinRequest;
|
|
13
|
+
exports.default = handle;
|
|
14
|
+
exports.getToken = getToken;
|
|
13
15
|
const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
|
|
14
16
|
const storage_1 = require("../storage");
|
|
15
17
|
const util_1 = require("../util");
|
|
@@ -17,8 +19,8 @@ const api_1 = require("../modules/api/api");
|
|
|
17
19
|
const connection_1 = require("../util/connection");
|
|
18
20
|
const logger_1 = require("../util/logger");
|
|
19
21
|
const subscription_1 = require("../util/subscription");
|
|
20
|
-
function prepareCrowdinRequest(
|
|
21
|
-
return __awaiter(this,
|
|
22
|
+
function prepareCrowdinRequest(_a) {
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* ({ jwtToken, config, optional = false, checkSubscriptionExpiration = true, moduleKey, }) {
|
|
22
24
|
(0, logger_1.log)('Validating jwt token from incoming request');
|
|
23
25
|
const jwtPayload = yield (0, crowdin_apps_functions_1.validateJwtToken)(jwtToken, config.clientSecret, config.jwtValidationOptions);
|
|
24
26
|
const context = {
|
|
@@ -62,7 +64,6 @@ function prepareCrowdinRequest({ jwtToken, config, optional = false, checkSubscr
|
|
|
62
64
|
return { context, client, subscriptionInfo, logInfo, logError };
|
|
63
65
|
});
|
|
64
66
|
}
|
|
65
|
-
exports.prepareCrowdinRequest = prepareCrowdinRequest;
|
|
66
67
|
function handle({ config, optional = false, checkSubscriptionExpiration = true, moduleKey, }) {
|
|
67
68
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
68
69
|
var _a, _b;
|
|
@@ -108,7 +109,6 @@ function handle({ config, optional = false, checkSubscriptionExpiration = true,
|
|
|
108
109
|
}
|
|
109
110
|
}));
|
|
110
111
|
}
|
|
111
|
-
exports.default = handle;
|
|
112
112
|
function getToken(req) {
|
|
113
113
|
const jwtToken = req.query.jwtToken;
|
|
114
114
|
if (jwtToken) {
|
|
@@ -120,4 +120,3 @@ function getToken(req) {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
exports.getToken = getToken;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Response } from 'express';
|
|
3
2
|
import { IntegrationLogic } from '../modules/integration/types';
|
|
4
3
|
import { Config } from '../types';
|
|
5
|
-
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: import("express").Request
|
|
4
|
+
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: import("express").Request | import("../types").CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,6 +42,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
42
|
});
|
|
33
43
|
};
|
|
34
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.default = handle;
|
|
35
46
|
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
36
47
|
const storage_1 = require("../storage");
|
|
37
48
|
const util_1 = require("../util");
|
|
@@ -126,7 +137,6 @@ function handle(config, integration, optional = false) {
|
|
|
126
137
|
next();
|
|
127
138
|
}));
|
|
128
139
|
}
|
|
129
|
-
exports.default = handle;
|
|
130
140
|
function checkUserAccessToIntegration(integrationCredentials, userId) {
|
|
131
141
|
if (integrationCredentials === null || integrationCredentials === void 0 ? void 0 : integrationCredentials.managers) {
|
|
132
142
|
const managers = JSON.parse(integrationCredentials.managers);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Request, Response } from 'express';
|
|
3
2
|
import { UiModule, Config, UnauthorizedConfig } from '../types';
|
|
4
|
-
export default function handle(moduleConfig: UiModule, config: Config | UnauthorizedConfig): (req: Request
|
|
3
|
+
export default function handle(moduleConfig: UiModule, config: Config | UnauthorizedConfig): (req: Request | import("../types").CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = handle;
|
|
12
13
|
const util_1 = require("../util");
|
|
13
14
|
const static_files_1 = require("../util/static-files");
|
|
14
15
|
const views_1 = require("../views");
|
|
@@ -32,4 +33,3 @@ function handle(moduleConfig, config) {
|
|
|
32
33
|
throw new Error('uiPath or formSchema should be provided for module');
|
|
33
34
|
}));
|
|
34
35
|
}
|
|
35
|
-
exports.default = handle;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Request, Response } from 'express';
|
|
3
2
|
import { Config, UnauthorizedConfig } from '../types';
|
|
4
3
|
export default function handle({ config, allowUnauthorized, moduleType, }: {
|
|
5
4
|
config: Config | UnauthorizedConfig;
|
|
6
5
|
allowUnauthorized?: boolean;
|
|
7
6
|
moduleType?: string | undefined;
|
|
8
|
-
}): (req: Request
|
|
7
|
+
}): (req: Request | import("../types").CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = handle;
|
|
12
13
|
const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
|
|
13
14
|
const storage_1 = require("../storage");
|
|
14
15
|
const types_1 = require("../types");
|
|
@@ -76,4 +77,3 @@ function handle({ config, allowUnauthorized = false, moduleType, }) {
|
|
|
76
77
|
next();
|
|
77
78
|
}));
|
|
78
79
|
}
|
|
79
|
-
exports.default = handle;
|
package/out/modules/about.js
CHANGED
|
@@ -12,7 +12,8 @@ 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
|
-
exports.getAboutPageOptions =
|
|
15
|
+
exports.getAboutPageOptions = getAboutPageOptions;
|
|
16
|
+
exports.default = handle;
|
|
16
17
|
const axios_1 = __importDefault(require("axios"));
|
|
17
18
|
const util_1 = require("../util");
|
|
18
19
|
const crowdin_client_1 = require("../middlewares/crowdin-client");
|
|
@@ -39,7 +40,6 @@ function getAboutPageOptions(config) {
|
|
|
39
40
|
};
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
exports.getAboutPageOptions = getAboutPageOptions;
|
|
43
43
|
function handle(config) {
|
|
44
44
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
if (config.projectIntegration) {
|
|
@@ -61,4 +61,3 @@ function handle(config) {
|
|
|
61
61
|
return res.send(html);
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
exports.default = handle;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Response } from 'express';
|
|
3
2
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
3
|
import { AiPromptProviderModule } from '../types';
|
|
5
|
-
export default function handle(aiPromptProvider: AiPromptProviderModule): (req: import("express").Request
|
|
4
|
+
export default function handle(aiPromptProvider: AiPromptProviderModule): (req: import("express").Request | CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -20,6 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.default = handle;
|
|
23
24
|
const util_1 = require("../../../util");
|
|
24
25
|
const logger_1 = require("../../../util/logger");
|
|
25
26
|
function handle(aiPromptProvider) {
|
|
@@ -43,4 +44,3 @@ function handle(aiPromptProvider) {
|
|
|
43
44
|
}
|
|
44
45
|
}));
|
|
45
46
|
}
|
|
46
|
-
exports.default = handle;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.register =
|
|
6
|
+
exports.register = register;
|
|
7
7
|
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
8
8
|
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
9
|
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
@@ -25,4 +25,3 @@ function register({ config, app }) {
|
|
|
25
25
|
}
|
|
26
26
|
app.use('/logo/ai-prompt-provider', (0, util_1.serveLogo)(config, config.aiPromptProvider));
|
|
27
27
|
}
|
|
28
|
-
exports.register = register;
|
|
@@ -6,4 +6,4 @@ var PromptActions;
|
|
|
6
6
|
PromptActions["PRE_TRANSLATE"] = "pre_translate";
|
|
7
7
|
PromptActions["ASSIST"] = "assist";
|
|
8
8
|
PromptActions["QA_CHECK"] = "qa_check";
|
|
9
|
-
})(PromptActions
|
|
9
|
+
})(PromptActions || (exports.PromptActions = PromptActions = {}));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Response } from 'express';
|
|
3
2
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
3
|
import { AiProviderModule } from '../types';
|
|
5
|
-
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request
|
|
4
|
+
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request | CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.default = handle;
|
|
12
13
|
const util_1 = require("../../../util");
|
|
13
14
|
const logger_1 = require("../../../util/logger");
|
|
14
15
|
const files_1 = require("../../integration/util/files");
|
|
@@ -57,7 +58,7 @@ function handle(aiProvider) {
|
|
|
57
58
|
isStream,
|
|
58
59
|
tools,
|
|
59
60
|
toolChoice,
|
|
60
|
-
sendEvent: (
|
|
61
|
+
sendEvent: (_a) => __awaiter(this, [_a], void 0, function* ({ content, role, tool_calls }) {
|
|
61
62
|
if (!isStream) {
|
|
62
63
|
chunks.push({ content, role, tool_calls });
|
|
63
64
|
return;
|
|
@@ -125,4 +126,3 @@ function handle(aiProvider) {
|
|
|
125
126
|
}
|
|
126
127
|
}));
|
|
127
128
|
}
|
|
128
|
-
exports.default = handle;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Response } from 'express';
|
|
3
2
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
3
|
import { AiProviderModule } from '../types';
|
|
5
4
|
export declare const CONTEXT_WINDOW_LIMIT = 4096;
|
|
6
|
-
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request
|
|
5
|
+
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request | CrowdinClientRequest, res: Response, next: Function) => void;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CONTEXT_WINDOW_LIMIT = void 0;
|
|
13
|
+
exports.default = handle;
|
|
13
14
|
const util_1 = require("../../../util");
|
|
14
15
|
const logger_1 = require("../../../util/logger");
|
|
15
16
|
const util_2 = require("../util");
|
|
@@ -46,4 +47,3 @@ function handle(aiProvider) {
|
|
|
46
47
|
}
|
|
47
48
|
}));
|
|
48
49
|
}
|
|
49
|
-
exports.default = handle;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.register =
|
|
6
|
+
exports.register = register;
|
|
7
7
|
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
8
8
|
const get_model_list_1 = __importDefault(require("./handlers/get-model-list"));
|
|
9
9
|
const chat_completions_1 = __importDefault(require("./handlers/chat-completions"));
|
|
@@ -44,4 +44,3 @@ function register({ config, app }) {
|
|
|
44
44
|
}), (0, chat_completions_1.default)(config.aiProvider));
|
|
45
45
|
// END TEMPORARY CODE
|
|
46
46
|
}
|
|
47
|
-
exports.register = register;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RateLimitError = void 0;
|
|
4
|
+
exports.isRateLimitError = isRateLimitError;
|
|
5
|
+
exports.normalizeContentParts = normalizeContentParts;
|
|
6
|
+
exports.inputMessageToChatCompletionMessage = inputMessageToChatCompletionMessage;
|
|
7
|
+
exports.mergeToolCalls = mergeToolCalls;
|
|
8
|
+
exports.mergeChatCompletionChunks = mergeChatCompletionChunks;
|
|
4
9
|
const logger_1 = require("../../../util/logger");
|
|
5
10
|
const HTTP_RATE_LIMIT = 429;
|
|
6
11
|
function isRateLimitError(e) {
|
|
@@ -9,7 +14,6 @@ function isRateLimitError(e) {
|
|
|
9
14
|
}
|
|
10
15
|
return ('status' in e && e.status === HTTP_RATE_LIMIT) || ('code' in e && e.code === HTTP_RATE_LIMIT);
|
|
11
16
|
}
|
|
12
|
-
exports.isRateLimitError = isRateLimitError;
|
|
13
17
|
class RateLimitError extends logger_1.AppModuleAggregateError {
|
|
14
18
|
constructor({ error, message } = {}) {
|
|
15
19
|
const newMessage = message || 'Rate limit reached';
|
|
@@ -31,7 +35,6 @@ function normalizeContentParts(content) {
|
|
|
31
35
|
: part)
|
|
32
36
|
: content;
|
|
33
37
|
}
|
|
34
|
-
exports.normalizeContentParts = normalizeContentParts;
|
|
35
38
|
function inputMessageToChatCompletionMessage(message) {
|
|
36
39
|
switch (message.role) {
|
|
37
40
|
case undefined:
|
|
@@ -44,7 +47,6 @@ function inputMessageToChatCompletionMessage(message) {
|
|
|
44
47
|
return message;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
exports.inputMessageToChatCompletionMessage = inputMessageToChatCompletionMessage;
|
|
48
50
|
function mergeToolCalls(chunks) {
|
|
49
51
|
const toolCalls = [];
|
|
50
52
|
chunks.forEach((chunk) => {
|
|
@@ -76,7 +78,6 @@ function mergeToolCalls(chunks) {
|
|
|
76
78
|
});
|
|
77
79
|
return !toolCalls.length ? null : toolCalls;
|
|
78
80
|
}
|
|
79
|
-
exports.mergeToolCalls = mergeToolCalls;
|
|
80
81
|
function mergeChatCompletionChunks(chunks) {
|
|
81
82
|
const tool_calls = mergeToolCalls(chunks);
|
|
82
83
|
return [
|
|
@@ -87,4 +88,3 @@ function mergeChatCompletionChunks(chunks) {
|
|
|
87
88
|
},
|
|
88
89
|
];
|
|
89
90
|
}
|
|
90
|
-
exports.mergeChatCompletionChunks = mergeChatCompletionChunks;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
1
|
import { Response } from 'express';
|
|
3
2
|
import { CrowdinClientRequest } from '../../types';
|
|
4
3
|
import { AiRequestProcessorModule, AiStreamProcessorModule } from './types';
|
|
5
|
-
export default function handle(module: AiRequestProcessorModule | AiStreamProcessorModule, canHandleStream?: boolean): (req: import("express").Request
|
|
4
|
+
export default function handle(module: AiRequestProcessorModule | AiStreamProcessorModule, canHandleStream?: boolean): (req: import("express").Request | CrowdinClientRequest, res: Response, next: Function) => void;
|