@crowdin/app-project-module 0.108.0 → 1.0.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 +16 -4
- package/out/app-test/integration/types.d.ts +1 -1
- package/out/app-test/integration/update-crowdin.js +2 -2
- package/out/app-test/integration/update-integration.js +2 -2
- package/out/index.d.ts +2 -1
- package/out/index.js +73 -30
- package/out/middlewares/auto-credentials-masker.d.ts +4 -0
- package/out/middlewares/auto-credentials-masker.js +45 -0
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/integration-credentials.d.ts +2 -2
- package/out/middlewares/integration-credentials.js +7 -4
- package/out/middlewares/render-ui-module.d.ts +3 -3
- package/out/middlewares/render-ui-module.js +10 -13
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.js +11 -1
- package/out/modules/about.d.ts +2 -1
- package/out/modules/about.js +10 -3
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
- package/out/modules/ai-prompt-provider/handlers/compile.js +7 -1
- package/out/modules/ai-prompt-provider/index.js +2 -2
- package/out/modules/ai-prompt-provider/types.d.ts +7 -1
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
- package/out/modules/ai-provider/handlers/chat-completions.js +1 -1
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
- package/out/modules/ai-provider/index.js +2 -2
- package/out/modules/ai-provider/types.d.ts +4 -4
- package/out/modules/ai-request-processors/handler.d.ts +1 -1
- package/out/modules/ai-request-processors/handler.js +12 -2
- package/out/modules/ai-request-processors/types.d.ts +12 -2
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
- package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
- package/out/modules/ai-tools/index.js +1 -1
- package/out/modules/ai-tools/types.d.ts +1 -1
- package/out/modules/auth-guard/handlers/verify.d.ts +1 -1
- package/out/modules/auth-guard/index.js +1 -1
- package/out/modules/automation-action/handlers/execute.d.ts +1 -1
- package/out/modules/automation-action/handlers/execute.js +1 -1
- package/out/modules/automation-action/handlers/input-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/output-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.js +1 -1
- package/out/modules/automation-action/index.js +1 -1
- package/out/modules/automation-action/types.d.ts +4 -4
- package/out/modules/automation-action/util/index.js +2 -5
- package/out/modules/context-menu/index.js +2 -2
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-mt/handlers/translate.js +25 -9
- package/out/modules/custom-mt/index.js +3 -3
- package/out/modules/custom-mt/types.d.ts +10 -2
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/custom-spell-check/index.js +4 -4
- package/out/modules/editor-right-panel/index.js +1 -1
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
- package/out/modules/external-qa-check/index.js +2 -2
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +7 -2
- package/out/modules/file-processing/handlers/custom-file-format.js +62 -22
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
- package/out/modules/file-processing/handlers/file-download.js +5 -0
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.js +41 -15
- package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -1
- package/out/modules/file-processing/handlers/translations-alignment.js +10 -4
- package/out/modules/file-processing/index.js +12 -2
- package/out/modules/file-processing/types.d.ts +36 -5
- package/out/modules/file-processing/util/defaults.js +50 -6
- package/out/modules/file-processing/util/files.js +2 -1
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.js +5 -1
- package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +5 -0
- package/out/modules/integration/handlers/crowdin-files-target-languages.js +103 -0
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.js +7 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.js +59 -18
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.js +15 -8
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.js +13 -6
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.js +8 -3
- package/out/modules/integration/handlers/integration-update.d.ts +1 -1
- package/out/modules/integration/handlers/integration-update.js +44 -6
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.js +3 -2
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/job-list.d.ts +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -1
- package/out/modules/integration/handlers/main.js +32 -2
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-login.js +28 -6
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.js +9 -9
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.js +8 -11
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -1
- package/out/modules/integration/index.js +19 -33
- package/out/modules/integration/types.d.ts +133 -29
- package/out/modules/integration/types.js +1 -0
- package/out/modules/integration/util/cron.d.ts +2 -2
- package/out/modules/integration/util/cron.js +41 -25
- package/out/modules/integration/util/defaults.d.ts +4 -0
- package/out/modules/integration/util/defaults.js +175 -15
- package/out/modules/integration/util/files.d.ts +4 -1
- package/out/modules/integration/util/files.js +27 -8
- package/out/modules/integration/util/job.js +4 -3
- package/out/modules/integration/util/snapshot.js +19 -3
- package/out/modules/integration/util/types.d.ts +1 -0
- package/out/modules/integration/util/types.js +1 -0
- package/out/modules/integration/util/webhooks.d.ts +8 -8
- package/out/modules/integration/util/webhooks.js +34 -17
- package/out/modules/manifest.js +12 -12
- package/out/modules/modal/index.js +2 -2
- package/out/modules/organization-menu/index.js +5 -4
- package/out/modules/organization-settings-menu/index.js +5 -4
- package/out/modules/profile-resources-menu/index.js +5 -4
- package/out/modules/profile-settings-menu/index.js +5 -4
- package/out/modules/project-menu/index.js +1 -1
- package/out/modules/project-menu-crowdsource/index.js +1 -1
- package/out/modules/project-reports/index.js +3 -2
- package/out/modules/project-tools/index.js +3 -2
- package/out/modules/status.d.ts +1 -1
- package/out/modules/status.js +12 -3
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/uninstall.d.ts +1 -1
- package/out/modules/uninstall.js +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +2 -2
- package/out/modules/webhooks/handlers/webhook-handler.js +33 -22
- package/out/modules/webhooks/types.d.ts +7 -0
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
- package/out/modules/workflow-step-type/index.js +2 -2
- package/out/modules/workflow-step-type/util/index.js +3 -6
- package/out/static/js/dependent.js +16 -7
- package/out/static/ui/error.bundle.js +474 -0
- package/out/static/ui/error.bundle.js.map +1 -0
- package/out/static/ui/install.bundle.js +459 -0
- package/out/static/ui/install.bundle.js.map +1 -0
- package/out/static/ui/login.bundle.js +630 -0
- package/out/static/ui/login.bundle.js.map +1 -0
- package/out/static/ui/main.bundle.js +2109 -0
- package/out/static/ui/main.bundle.js.map +1 -0
- package/out/static/ui/oauth.bundle.js +467 -0
- package/out/static/ui/oauth.bundle.js.map +1 -0
- package/out/storage/d1.d.ts +107 -0
- package/out/storage/d1.js +831 -0
- package/out/storage/index.js +8 -1
- package/out/storage/mysql.js +22 -19
- package/out/storage/postgre.d.ts +0 -1
- package/out/storage/postgre.js +20 -30
- package/out/storage/sqlite.d.ts +2 -5
- package/out/storage/sqlite.js +29 -69
- package/out/types.d.ts +78 -18
- package/out/util/connection.js +1 -1
- package/out/util/credentials-masker.d.ts +3 -3
- package/out/util/credentials-masker.js +14 -20
- package/out/util/cron.d.ts +29 -0
- package/out/util/cron.js +87 -0
- package/out/util/index.d.ts +14 -1
- package/out/util/index.js +121 -10
- package/out/util/jsx-renderer.d.ts +14 -0
- package/out/util/jsx-renderer.js +35 -0
- package/out/util/logger.d.ts +1 -0
- package/out/util/logger.js +2 -2
- package/out/util/static-files.d.ts +19 -0
- package/out/util/static-files.js +87 -0
- package/out/util/subscription.js +1 -1
- package/out/views/AboutPage.d.ts +10 -0
- package/out/views/AboutPage.js +76 -0
- package/out/views/FormPage.d.ts +14 -0
- package/out/views/FormPage.js +28 -0
- package/out/views/SubscriptionPage.d.ts +7 -0
- package/out/views/SubscriptionPage.js +26 -0
- package/out/views/index.d.ts +8 -0
- package/out/views/index.js +15 -0
- package/out/views/layout/Head.d.ts +9 -0
- package/out/views/layout/Head.js +54 -0
- package/package.json +43 -41
- package/out/util/handlebars.d.ts +0 -1
- package/out/util/handlebars.js +0 -46
- package/out/views/about.handlebars +0 -102
- package/out/views/error.handlebars +0 -54
- package/out/views/form.handlebars +0 -31
- package/out/views/install.handlebars +0 -16
- package/out/views/login.handlebars +0 -332
- package/out/views/main.handlebars +0 -2042
- package/out/views/oauth.handlebars +0 -11
- package/out/views/partials/head.handlebars +0 -53
- package/out/views/subscription.handlebars +0 -26
|
@@ -21,13 +21,19 @@ const getIntegrationFilesTest = ({ appConfig, integrationTestConfig, }) => __awa
|
|
|
21
21
|
const expectedTree = getIntegrationFiles.expected;
|
|
22
22
|
const allFiles = [];
|
|
23
23
|
const params = {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
credentials: {},
|
|
25
|
+
settings: {},
|
|
26
26
|
parentId: '',
|
|
27
27
|
search: '',
|
|
28
28
|
page: '0',
|
|
29
29
|
};
|
|
30
|
-
const result = yield (0, util_1.assert)(() => integration.getIntegrationFiles(
|
|
30
|
+
const result = yield (0, util_1.assert)(() => integration.getIntegrationFiles({
|
|
31
|
+
credentials: params.credentials,
|
|
32
|
+
settings: params.settings,
|
|
33
|
+
parentId: params.parentId,
|
|
34
|
+
search: params.search,
|
|
35
|
+
page: params.page,
|
|
36
|
+
}), `Fail to run method getIntegrationFiles(), with params ${JSON.stringify(params)}`);
|
|
31
37
|
if (integration.integrationOneLevelFetching) {
|
|
32
38
|
const rootLevel = result;
|
|
33
39
|
const rootLevelExpected = expectedTree.filter((node) => !node.parentId || node.parentId === '0');
|
|
@@ -38,7 +44,13 @@ const getIntegrationFilesTest = ({ appConfig, integrationTestConfig, }) => __awa
|
|
|
38
44
|
};
|
|
39
45
|
const getAll = (node) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
46
|
params.parentId = node.id;
|
|
41
|
-
const data = (yield (0, util_1.assert)(() => integration.getIntegrationFiles(
|
|
47
|
+
const data = (yield (0, util_1.assert)(() => integration.getIntegrationFiles({
|
|
48
|
+
credentials: params.credentials,
|
|
49
|
+
settings: params.settings,
|
|
50
|
+
parentId: params.parentId,
|
|
51
|
+
search: params.search,
|
|
52
|
+
page: params.page,
|
|
53
|
+
}), `Fail to run method getIntegrationFiles(), with params ${JSON.stringify(params)}`));
|
|
42
54
|
for (const node of data) {
|
|
43
55
|
if (isFolder(node)) {
|
|
44
56
|
yield getAll(node);
|
|
@@ -35,7 +35,7 @@ export interface IntegrationTestConfig {
|
|
|
35
35
|
getIntegrationFiles: GetIntegrationFilesConfig;
|
|
36
36
|
updateCrowdin?: UpdateCrowdinConfig;
|
|
37
37
|
updateIntegration?: UpdateIntegrationConfig;
|
|
38
|
-
|
|
38
|
+
settings?: object;
|
|
39
39
|
integrationCredentials?: object;
|
|
40
40
|
beforeAll?: () => Promise<void>;
|
|
41
41
|
}
|
|
@@ -65,7 +65,7 @@ const getFilesFromTree = (tree) => {
|
|
|
65
65
|
.map((file) => file);
|
|
66
66
|
};
|
|
67
67
|
const updateCrowdinTest = ({ appConfig, integrationTestConfig, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
-
const { updateCrowdin,
|
|
68
|
+
const { updateCrowdin, settings, integrationCredentials: credentials } = integrationTestConfig;
|
|
69
69
|
const expectedTree = integrationTestConfig.getIntegrationFiles.expected;
|
|
70
70
|
if (!appConfig.projectIntegration) {
|
|
71
71
|
throw new Error('The app configuration is missing the projectIntegration module.');
|
|
@@ -87,7 +87,7 @@ const updateCrowdinTest = ({ appConfig, integrationTestConfig, }) => __awaiter(v
|
|
|
87
87
|
credentials,
|
|
88
88
|
request,
|
|
89
89
|
rootFolder,
|
|
90
|
-
|
|
90
|
+
settings,
|
|
91
91
|
uploadTranslations: false,
|
|
92
92
|
job: {
|
|
93
93
|
get: function getJob() {
|
|
@@ -31,7 +31,7 @@ const updateIntegrationTest = ({ appConfig, integrationTestConfig, }) => __await
|
|
|
31
31
|
if (!appConfig.projectIntegration) {
|
|
32
32
|
throw new Error('The app configuration is missing the projectIntegration module.');
|
|
33
33
|
}
|
|
34
|
-
const { updateIntegration,
|
|
34
|
+
const { updateIntegration, settings, integrationCredentials } = integrationTestConfig;
|
|
35
35
|
const client = new crowdin_api_client_1.default({ token: 'fakeToken' });
|
|
36
36
|
const updateProgressMock = jest.fn(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
37
|
return { isCanceled: false };
|
|
@@ -45,7 +45,7 @@ const updateIntegrationTest = ({ appConfig, integrationTestConfig, }) => __await
|
|
|
45
45
|
credentials: integrationCredentials,
|
|
46
46
|
request,
|
|
47
47
|
rootFolder: (0, crowdin_storage_1.getRootFolder)(appConfig),
|
|
48
|
-
|
|
48
|
+
settings,
|
|
49
49
|
job: {
|
|
50
50
|
get: function getJob() {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
package/out/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import express from './util/terminus-express';
|
|
|
4
4
|
import { getRequestCredentialsMasker, postRequestCredentialsMasker, maskKey } from './util/credentials-masker';
|
|
5
5
|
export { getRequestCredentialsMasker, postRequestCredentialsMasker, maskKey };
|
|
6
6
|
export { ProjectPermissions, Scope, UserPermissions } from './types';
|
|
7
|
+
export { Cron } from './util/cron';
|
|
7
8
|
export { express };
|
|
8
9
|
export declare const metadataStore: CrowdinMetadataStore;
|
|
9
10
|
export declare function createApp(clientConfig: ClientConfig): void;
|
|
10
|
-
export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig):
|
|
11
|
+
export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): CrowdinAppUtilities;
|
package/out/index.js
CHANGED
|
@@ -50,11 +50,12 @@ const subscription_paid_1 = __importDefault(require("./modules/subscription-paid
|
|
|
50
50
|
const uninstall_1 = __importDefault(require("./modules/uninstall"));
|
|
51
51
|
const status_1 = __importDefault(require("./modules/status"));
|
|
52
52
|
const storage = __importStar(require("./storage"));
|
|
53
|
+
const d1_1 = require("./storage/d1");
|
|
54
|
+
const cron = __importStar(require("./util/cron"));
|
|
53
55
|
const types_1 = require("./types");
|
|
54
56
|
const util_1 = require("./util");
|
|
55
57
|
const form_schema_1 = require("./util/form-schema");
|
|
56
58
|
const connection_1 = require("./util/connection");
|
|
57
|
-
const handlebars_1 = require("./util/handlebars");
|
|
58
59
|
const logger = __importStar(require("./util/logger"));
|
|
59
60
|
const logger_1 = require("./util/logger");
|
|
60
61
|
const terminus_express_1 = __importDefault(require("./util/terminus-express"));
|
|
@@ -63,6 +64,9 @@ const credentials_masker_1 = require("./util/credentials-masker");
|
|
|
63
64
|
Object.defineProperty(exports, "getRequestCredentialsMasker", { enumerable: true, get: function () { return credentials_masker_1.getRequestCredentialsMasker; } });
|
|
64
65
|
Object.defineProperty(exports, "postRequestCredentialsMasker", { enumerable: true, get: function () { return credentials_masker_1.postRequestCredentialsMasker; } });
|
|
65
66
|
Object.defineProperty(exports, "maskKey", { enumerable: true, get: function () { return credentials_masker_1.maskKey; } });
|
|
67
|
+
const auto_credentials_masker_1 = require("./middlewares/auto-credentials-masker");
|
|
68
|
+
const static_files_1 = require("./util/static-files");
|
|
69
|
+
const util_2 = require("./util");
|
|
66
70
|
//apps
|
|
67
71
|
const apiApp = __importStar(require("./modules/api"));
|
|
68
72
|
const contextMenuApp = __importStar(require("./modules/context-menu"));
|
|
@@ -98,7 +102,7 @@ exports.metadataStore = {
|
|
|
98
102
|
getMetadata: (id) => {
|
|
99
103
|
return storage.getStorage().getMetadata(id);
|
|
100
104
|
},
|
|
101
|
-
saveMetadata: (id, metadata, crowdinId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
saveMetadata: ({ id, metadata, crowdinId }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
106
|
if (!crowdinId) {
|
|
103
107
|
throw new Error('The crowdinId parameter is required.');
|
|
104
108
|
}
|
|
@@ -140,6 +144,27 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
140
144
|
}
|
|
141
145
|
storage.initialize(config);
|
|
142
146
|
logger.initialize(config);
|
|
147
|
+
cron.initialize(config);
|
|
148
|
+
// Middleware to ensure D1 migration before handling requests
|
|
149
|
+
app.use((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
try {
|
|
151
|
+
const storageInstance = storage.getStorage();
|
|
152
|
+
if (storageInstance instanceof d1_1.D1Storage) {
|
|
153
|
+
yield storageInstance.ensureMigrated();
|
|
154
|
+
}
|
|
155
|
+
next();
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
next(error);
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
161
|
+
// Middleware to detect and cache baseUrl from request if not provided
|
|
162
|
+
app.use((req, res, next) => {
|
|
163
|
+
if (!config.baseUrl) {
|
|
164
|
+
config.baseUrl = (0, util_1.extractBaseUrlFromRequest)(req);
|
|
165
|
+
}
|
|
166
|
+
next();
|
|
167
|
+
});
|
|
143
168
|
app.use((req, res, next) => {
|
|
144
169
|
if (config.webhooks && req.path === '/webhooks') {
|
|
145
170
|
return terminus_express_1.default.raw({ type: '*/*', limit: '50mb' })(req, res, next);
|
|
@@ -153,11 +178,8 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
153
178
|
app.use(logsFormatter.contextResolverMiddleware());
|
|
154
179
|
app.use(logsFormatter.expressMiddleware());
|
|
155
180
|
}
|
|
156
|
-
app.use('/assets',
|
|
157
|
-
app.
|
|
158
|
-
app.engine('handlebars', handlebars_1.engine);
|
|
159
|
-
app.set('view engine', 'handlebars');
|
|
160
|
-
app.get((0, util_1.getLogoUrl)(), (req, res) => res.sendFile(config.imagePath));
|
|
181
|
+
app.use('/assets', (0, static_files_1.serveStatic)(config, config.assetsPath || 'static'));
|
|
182
|
+
app.use('/', (0, util_2.serveLogo)(config));
|
|
161
183
|
app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
|
|
162
184
|
app.get('/', (0, about_1.default)(config));
|
|
163
185
|
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)) {
|
|
@@ -192,7 +214,15 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
192
214
|
contextMenuApp.register({ config, app });
|
|
193
215
|
//other apps only work in authorized context
|
|
194
216
|
if (!(0, util_1.isAuthorizedConfig)(config)) {
|
|
195
|
-
return Object.assign({}, exports.metadataStore)
|
|
217
|
+
return Object.assign(Object.assign({}, exports.metadataStore), { cron: cron.getCron(), storage: storage.getStorage(), establishCrowdinConnection: () => {
|
|
218
|
+
throw new Error('Establishing Crowdin connection is not available in unauthorized config');
|
|
219
|
+
}, encryptCrowdinConnection: () => {
|
|
220
|
+
throw new Error('Encrypting Crowdin connection is not available in unauthorized config');
|
|
221
|
+
}, decryptCrowdinConnection: () => {
|
|
222
|
+
throw new Error('Decrypting Crowdin connection is not available in unauthorized config');
|
|
223
|
+
}, jwtMiddleware: () => {
|
|
224
|
+
throw new Error('JWT Middleware is not available in unauthorized config');
|
|
225
|
+
} });
|
|
196
226
|
}
|
|
197
227
|
app.post('/installed', (0, install_1.default)(config));
|
|
198
228
|
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
@@ -224,15 +254,19 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
224
254
|
aiRequestProcessors.register({ config, app });
|
|
225
255
|
automationAction.register({ config, app });
|
|
226
256
|
authGuard.register({ config, app });
|
|
257
|
+
(0, auto_credentials_masker_1.registerAutoCredentialsMasker)(app, config);
|
|
227
258
|
addFormSchema({ config, app });
|
|
228
|
-
return Object.assign(Object.assign({}, exports.metadataStore), { storage: storage.getStorage(), establishCrowdinConnection: (authRequest, moduleKey) => {
|
|
259
|
+
return Object.assign(Object.assign({}, exports.metadataStore), { storage: storage.getStorage(), cron: cron.getCron(), establishCrowdinConnection: ({ authRequest, jwtToken: token, moduleKey }) => {
|
|
229
260
|
let jwtToken = '';
|
|
230
|
-
if (
|
|
231
|
-
jwtToken =
|
|
261
|
+
if (token) {
|
|
262
|
+
jwtToken = token;
|
|
232
263
|
}
|
|
233
|
-
else {
|
|
264
|
+
else if (authRequest) {
|
|
234
265
|
jwtToken = (0, crowdin_client_1.getToken)(authRequest);
|
|
235
266
|
}
|
|
267
|
+
else {
|
|
268
|
+
throw new Error('Either authRequest or jwtToken must be provided');
|
|
269
|
+
}
|
|
236
270
|
return (0, crowdin_client_1.prepareCrowdinRequest)({
|
|
237
271
|
jwtToken,
|
|
238
272
|
config,
|
|
@@ -240,7 +274,7 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
240
274
|
checkSubscriptionExpiration: false,
|
|
241
275
|
moduleKey,
|
|
242
276
|
});
|
|
243
|
-
}, encryptCrowdinConnection: (data) => (0, util_1.encryptData)(config, JSON.stringify(data)),
|
|
277
|
+
}, encryptCrowdinConnection: (data) => (0, util_1.encryptData)(config, JSON.stringify(data)), decryptCrowdinConnection: ({ hash, autoRenew }) => __awaiter(this, void 0, void 0, function* () {
|
|
244
278
|
const { crowdinId, extra } = JSON.parse((0, util_1.decryptData)(config, hash));
|
|
245
279
|
const credentials = yield storage.getStorage().getCrowdinCredentials(crowdinId);
|
|
246
280
|
if (!credentials) {
|
|
@@ -248,7 +282,15 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
248
282
|
}
|
|
249
283
|
const { client } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, autoRenew });
|
|
250
284
|
return { client, extra };
|
|
251
|
-
})
|
|
285
|
+
}), jwtMiddleware: (options) => {
|
|
286
|
+
var _a, _b;
|
|
287
|
+
return (0, crowdin_client_1.default)({
|
|
288
|
+
config,
|
|
289
|
+
optional: (_a = options.optional) !== null && _a !== void 0 ? _a : false,
|
|
290
|
+
checkSubscriptionExpiration: (_b = options.checkSubscriptionExpiration) !== null && _b !== void 0 ? _b : false,
|
|
291
|
+
moduleKey: options.moduleKey,
|
|
292
|
+
});
|
|
293
|
+
} });
|
|
252
294
|
}
|
|
253
295
|
exports.addCrowdinEndpoints = addCrowdinEndpoints;
|
|
254
296
|
function addFormSchema({ app, config }) {
|
|
@@ -257,18 +299,22 @@ function addFormSchema({ app, config }) {
|
|
|
257
299
|
if ((0, form_schema_1.hasFormSchema)(moduleConfig)) {
|
|
258
300
|
const moduleConfigWithForm = (0, form_schema_1.getLowCodeUiConfigFromModuleConfig)(moduleConfig);
|
|
259
301
|
if (moduleConfigWithForm) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
302
|
+
if (!moduleConfigWithForm.formGetDataUrl) {
|
|
303
|
+
app.get(`/api/${moduleConfigWithForm.key}/form-data`, json_response_1.default, (0, crowdin_client_1.default)({
|
|
304
|
+
config,
|
|
305
|
+
optional: false,
|
|
306
|
+
checkSubscriptionExpiration: true,
|
|
307
|
+
moduleKey: moduleConfigWithForm.key,
|
|
308
|
+
}), (0, credentials_masker_1.getRequestCredentialsMasker)({ moduleConfig: moduleConfigWithForm }), (0, form_data_display_1.default)(config));
|
|
309
|
+
}
|
|
310
|
+
if (!moduleConfigWithForm.formPostDataUrl) {
|
|
311
|
+
app.post(`/api/${moduleConfigWithForm.key}/form-data`, (0, crowdin_client_1.default)({
|
|
312
|
+
config,
|
|
313
|
+
optional: false,
|
|
314
|
+
checkSubscriptionExpiration: true,
|
|
315
|
+
moduleKey: moduleConfigWithForm.key,
|
|
316
|
+
}), (0, credentials_masker_1.postRequestCredentialsMasker)(moduleConfigWithForm), (0, form_data_save_1.default)(config));
|
|
317
|
+
}
|
|
272
318
|
}
|
|
273
319
|
}
|
|
274
320
|
}
|
|
@@ -279,9 +325,6 @@ function convertClientConfig(clientConfig) {
|
|
|
279
325
|
const clientSecret = clientConfig.clientSecret || process.env.CROWDIN_CLIENT_SECRET;
|
|
280
326
|
const port = clientConfig.port || process.env.PORT || 3000;
|
|
281
327
|
const { region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION, tmpBucketName = process.env.AWS_TMP_BUCKET_NAME, } = clientConfig.awsConfig || {};
|
|
282
|
-
if (!baseUrl) {
|
|
283
|
-
throw new Error('Missing baseUrl parameter');
|
|
284
|
-
}
|
|
285
328
|
if (clientConfig.authenticationType !== types_1.AuthenticationType.NONE) {
|
|
286
329
|
if (!clientId && !clientSecret) {
|
|
287
330
|
throw new Error('Missing [clientId, clientSecret] parameters');
|
|
@@ -291,7 +334,7 @@ function convertClientConfig(clientConfig) {
|
|
|
291
334
|
clientConfig.api = Object.assign({ default: true }, clientConfig.api);
|
|
292
335
|
}
|
|
293
336
|
clientConfig.enableStatusPage = Object.assign({ database: true, filesystem: true }, (clientConfig.enableStatusPage || {}));
|
|
294
|
-
return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl, clientId,
|
|
337
|
+
return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl ? (baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl) : undefined, clientId,
|
|
295
338
|
clientSecret, awsConfig: {
|
|
296
339
|
tmpBucketName,
|
|
297
340
|
region,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Express, Request, Response, NextFunction } from 'express';
|
|
2
|
+
import { Config, UnauthorizedConfig } from '../types';
|
|
3
|
+
export declare function autoCredentialsMaskerMiddleware(config: Config | UnauthorizedConfig): (req: Request, res: Response, next: NextFunction) => any;
|
|
4
|
+
export declare function registerAutoCredentialsMasker(app: Express, config: Config | UnauthorizedConfig): void;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAutoCredentialsMasker = exports.autoCredentialsMaskerMiddleware = void 0;
|
|
4
|
+
const credentials_masker_1 = require("../util/credentials-masker");
|
|
5
|
+
const form_schema_1 = require("../util/form-schema");
|
|
6
|
+
const logger_1 = require("../util/logger");
|
|
7
|
+
function autoCredentialsMaskerMiddleware(config) {
|
|
8
|
+
return function (req, res, next) {
|
|
9
|
+
try {
|
|
10
|
+
if (req.__credentialsMaskerApplied) {
|
|
11
|
+
return next();
|
|
12
|
+
}
|
|
13
|
+
const requestPath = req.path;
|
|
14
|
+
const requestMethod = req.method.toLowerCase();
|
|
15
|
+
for (const moduleKey of Object.keys(config)) {
|
|
16
|
+
const moduleConfig = config[moduleKey];
|
|
17
|
+
if ((0, form_schema_1.hasFormSchema)(moduleConfig)) {
|
|
18
|
+
const moduleConfigWithForm = (0, form_schema_1.getLowCodeUiConfigFromModuleConfig)(moduleConfig);
|
|
19
|
+
if (moduleConfigWithForm) {
|
|
20
|
+
if (requestMethod === 'get' && moduleConfigWithForm.formGetDataUrl) {
|
|
21
|
+
if (requestPath === moduleConfigWithForm.formGetDataUrl) {
|
|
22
|
+
return (0, credentials_masker_1.getRequestCredentialsMasker)({ moduleConfig: moduleConfigWithForm })(req, res, next);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (requestMethod === 'post' && moduleConfigWithForm.formPostDataUrl) {
|
|
26
|
+
if (requestPath === moduleConfigWithForm.formPostDataUrl) {
|
|
27
|
+
return (0, credentials_masker_1.postRequestCredentialsMasker)(moduleConfigWithForm)(req, res, next);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
next();
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
(0, logger_1.logError)(`Error in autoCredentialsMaskerMiddleware: ${error}`);
|
|
37
|
+
next();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.autoCredentialsMaskerMiddleware = autoCredentialsMaskerMiddleware;
|
|
42
|
+
function registerAutoCredentialsMasker(app, config) {
|
|
43
|
+
app.use(autoCredentialsMaskerMiddleware(config));
|
|
44
|
+
}
|
|
45
|
+
exports.registerAutoCredentialsMasker = registerAutoCredentialsMasker;
|
|
@@ -21,5 +21,5 @@ export default function handle({ config, optional, checkSubscriptionExpiration,
|
|
|
21
21
|
optional: boolean;
|
|
22
22
|
checkSubscriptionExpiration: boolean;
|
|
23
23
|
moduleKey?: string[] | string | undefined;
|
|
24
|
-
}): (req:
|
|
24
|
+
}): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
25
25
|
export declare function getToken(req: CrowdinClientRequest): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config } from '../types';
|
|
4
3
|
import { IntegrationLogic } from '../modules/integration/types';
|
|
5
|
-
|
|
4
|
+
import { Config } from '../types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -32,11 +32,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
35
36
|
const storage_1 = require("../storage");
|
|
36
37
|
const util_1 = require("../util");
|
|
37
38
|
const connection_1 = require("../util/connection");
|
|
39
|
+
const jsx_renderer_1 = require("../util/jsx-renderer");
|
|
38
40
|
const logger_1 = require("../util/logger");
|
|
39
|
-
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
40
41
|
function handle(config, integration, optional = false) {
|
|
41
42
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
42
43
|
let clientId = req.crowdinContext.clientId;
|
|
@@ -89,7 +90,9 @@ function handle(config, integration, optional = false) {
|
|
|
89
90
|
else {
|
|
90
91
|
(0, logger_1.temporaryErrorDebug)('Access denied: integration-credentials', req);
|
|
91
92
|
}
|
|
92
|
-
|
|
93
|
+
const html = (0, jsx_renderer_1.renderJSXOnClient)({ name: 'error', props: errorOptions });
|
|
94
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
95
|
+
return res.send(html);
|
|
93
96
|
}
|
|
94
97
|
try {
|
|
95
98
|
req.integrationCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
@@ -113,8 +116,8 @@ function handle(config, integration, optional = false) {
|
|
|
113
116
|
let integrationSettings = JSON.parse(integrationConfig.config) || {};
|
|
114
117
|
if (integration.normalizeSettings) {
|
|
115
118
|
integrationSettings = yield integration.normalizeSettings({
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
settings: integrationSettings,
|
|
120
|
+
credentials: req.integrationCredentials,
|
|
118
121
|
client: req.crowdinApiClient,
|
|
119
122
|
});
|
|
120
123
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
|
-
import
|
|
3
|
-
import { UiModule } from '../types';
|
|
4
|
-
export default function handle(moduleConfig: UiModule): (req:
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import { UiModule, Config, UnauthorizedConfig } from '../types';
|
|
4
|
+
export default function handle(moduleConfig: UiModule, config: Config | UnauthorizedConfig): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -8,29 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const express_1 = __importDefault(require("express"));
|
|
16
12
|
const util_1 = require("../util");
|
|
17
|
-
|
|
13
|
+
const static_files_1 = require("../util/static-files");
|
|
14
|
+
const views_1 = require("../views");
|
|
15
|
+
const jsx_renderer_1 = require("../util/jsx-renderer");
|
|
16
|
+
function handle(moduleConfig, config) {
|
|
18
17
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
19
18
|
if (moduleConfig.formSchema) {
|
|
20
|
-
|
|
21
|
-
formGetDataUrl: moduleConfig.formGetDataUrl
|
|
22
|
-
|
|
23
|
-
: `/api/${moduleConfig.key}/form-data`,
|
|
24
|
-
formPostDataUrl: moduleConfig.formPostDataUrl
|
|
25
|
-
? moduleConfig.formPostDataUrl
|
|
26
|
-
: `/api/${moduleConfig.key}/form-data`,
|
|
19
|
+
const html = (0, jsx_renderer_1.renderJSXOnServer)(views_1.FormPage, {
|
|
20
|
+
formGetDataUrl: moduleConfig.formGetDataUrl || `/api/${moduleConfig.key}/form-data`,
|
|
21
|
+
formPostDataUrl: moduleConfig.formPostDataUrl || `/api/${moduleConfig.key}/form-data`,
|
|
27
22
|
formSchema: JSON.stringify(moduleConfig.formSchema),
|
|
28
23
|
formUiSchema: moduleConfig.formUiSchema ? JSON.stringify(moduleConfig.formUiSchema) : '{}',
|
|
29
24
|
formPatchDataUrl: moduleConfig.formPatchDataUrl,
|
|
30
25
|
});
|
|
26
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
27
|
+
return res.send(html);
|
|
31
28
|
}
|
|
32
29
|
if (moduleConfig.uiPath) {
|
|
33
|
-
return
|
|
30
|
+
return (0, static_files_1.serveStatic)(config, moduleConfig.uiPath)(req, res, next);
|
|
34
31
|
}
|
|
35
32
|
throw new Error('uiPath or formSchema should be provided for module');
|
|
36
33
|
}));
|
|
@@ -5,4 +5,4 @@ export default function handle({ config, allowUnauthorized, moduleType, }: {
|
|
|
5
5
|
config: Config | UnauthorizedConfig;
|
|
6
6
|
allowUnauthorized?: boolean;
|
|
7
7
|
moduleType?: string | undefined;
|
|
8
|
-
}): (req:
|
|
8
|
+
}): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | import("../types").CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -14,10 +14,18 @@ const storage_1 = require("../storage");
|
|
|
14
14
|
const types_1 = require("../types");
|
|
15
15
|
const util_1 = require("../util");
|
|
16
16
|
const connection_1 = require("../util/connection");
|
|
17
|
+
const jsx_renderer_1 = require("../util/jsx-renderer");
|
|
17
18
|
const logger_1 = require("../util/logger");
|
|
18
19
|
const subscription_1 = require("../util/subscription");
|
|
20
|
+
const views_1 = require("../views");
|
|
19
21
|
function handle({ config, allowUnauthorized = false, moduleType, }) {
|
|
20
22
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
// Allow access to non-HTML files
|
|
24
|
+
const isHtmlFile = /\.html?$/i.test(req.path);
|
|
25
|
+
if (!isHtmlFile) {
|
|
26
|
+
next();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
21
29
|
if (allowUnauthorized) {
|
|
22
30
|
next();
|
|
23
31
|
return;
|
|
@@ -60,7 +68,9 @@ function handle({ config, allowUnauthorized = false, moduleType, }) {
|
|
|
60
68
|
accountType: credentials.type,
|
|
61
69
|
});
|
|
62
70
|
if (expired) {
|
|
63
|
-
|
|
71
|
+
const html = (0, jsx_renderer_1.renderJSXOnServer)(views_1.SubscriptionPage, { subscribeLink });
|
|
72
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
73
|
+
return res.send(html);
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
next();
|
package/out/modules/about.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export declare function getAboutPageOptions(config: Config | UnauthorizedConfig)
|
|
|
5
5
|
logo: string;
|
|
6
6
|
manifest: string;
|
|
7
7
|
storeLink: string;
|
|
8
|
+
showDebugLink: boolean;
|
|
8
9
|
}>;
|
|
9
|
-
export default function handle(config: Config | UnauthorizedConfig): (req: Request, res: Response, next: NextFunction) => Promise<
|
|
10
|
+
export default function handle(config: Config | UnauthorizedConfig): (req: Request, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>> | undefined>;
|
package/out/modules/about.js
CHANGED
|
@@ -16,6 +16,8 @@ exports.getAboutPageOptions = void 0;
|
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const util_1 = require("../util");
|
|
18
18
|
const crowdin_client_1 = require("../middlewares/crowdin-client");
|
|
19
|
+
const jsx_renderer_1 = require("../util/jsx-renderer");
|
|
20
|
+
const views_1 = require("../views");
|
|
19
21
|
function getAboutPageOptions(config) {
|
|
20
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
23
|
let detailPage = '';
|
|
@@ -30,9 +32,10 @@ function getAboutPageOptions(config) {
|
|
|
30
32
|
}
|
|
31
33
|
return {
|
|
32
34
|
name: config.name,
|
|
33
|
-
logo: (0, util_1.getLogoUrl)(),
|
|
35
|
+
logo: (0, util_1.getLogoUrl)(config),
|
|
34
36
|
manifest: config.baseUrl + '/manifest.json',
|
|
35
37
|
storeLink: (config === null || config === void 0 ? void 0 : config.detailPage) || detailPage,
|
|
38
|
+
showDebugLink: process.env.SHOW_DEBUG_LINK === 'true',
|
|
36
39
|
};
|
|
37
40
|
});
|
|
38
41
|
}
|
|
@@ -43,7 +46,9 @@ function handle(config) {
|
|
|
43
46
|
const jwtToken = (0, crowdin_client_1.getToken)(req);
|
|
44
47
|
if (!jwtToken) {
|
|
45
48
|
const options = yield getAboutPageOptions(config);
|
|
46
|
-
|
|
49
|
+
const html = (0, jsx_renderer_1.renderJSXOnServer)(views_1.AboutPage, options);
|
|
50
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
51
|
+
return res.send(html);
|
|
47
52
|
}
|
|
48
53
|
else {
|
|
49
54
|
next();
|
|
@@ -51,7 +56,9 @@ function handle(config) {
|
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
const options = yield getAboutPageOptions(config);
|
|
54
|
-
|
|
59
|
+
const html = (0, jsx_renderer_1.renderJSXOnServer)(views_1.AboutPage, options);
|
|
60
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
61
|
+
return res.send(html);
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
64
|
exports.default = handle;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiPromptProviderModule } from '../types';
|
|
5
|
-
export default function handle(aiPromptProvider: AiPromptProviderModule): (req:
|
|
5
|
+
export default function handle(aiPromptProvider: AiPromptProviderModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -26,7 +26,13 @@ function handle(aiPromptProvider) {
|
|
|
26
26
|
return (0, util_1.runAsyncWrapper)((req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
try {
|
|
28
28
|
const _a = req.body, { options, payload } = _a, body = __rest(_a, ["options", "payload"]);
|
|
29
|
-
const compiledPrompt = yield aiPromptProvider.compile(
|
|
29
|
+
const compiledPrompt = yield aiPromptProvider.compile({
|
|
30
|
+
options,
|
|
31
|
+
payload,
|
|
32
|
+
client: req.crowdinApiClient,
|
|
33
|
+
context: req.crowdinContext,
|
|
34
|
+
requestData: body,
|
|
35
|
+
});
|
|
30
36
|
res.send({ data: { content: compiledPrompt } });
|
|
31
37
|
}
|
|
32
38
|
catch (e) {
|
|
@@ -21,8 +21,8 @@ function register({ config, app }) {
|
|
|
21
21
|
moduleKey: config.aiPromptProvider.key,
|
|
22
22
|
}), (0, compile_1.default)(config.aiPromptProvider));
|
|
23
23
|
if (config.aiPromptProvider.formSchema || config.aiPromptProvider.uiPath) {
|
|
24
|
-
app.use('/prompt-provider/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.aiPromptProvider.key }), (0, render_ui_module_1.default)(config.aiPromptProvider));
|
|
24
|
+
app.use('/prompt-provider/settings', (0, ui_module_1.default)({ config, allowUnauthorized: true, moduleType: config.aiPromptProvider.key }), (0, render_ui_module_1.default)(config.aiPromptProvider, config));
|
|
25
25
|
}
|
|
26
|
-
app.
|
|
26
|
+
app.use('/logo/ai-prompt-provider', (0, util_1.serveLogo)(config, config.aiPromptProvider));
|
|
27
27
|
}
|
|
28
28
|
exports.register = register;
|
|
@@ -9,7 +9,13 @@ export interface AiPromptProviderModule extends UiModule {
|
|
|
9
9
|
/**
|
|
10
10
|
* generates prompt text based on provided options
|
|
11
11
|
*/
|
|
12
|
-
compile: (options:
|
|
12
|
+
compile: (options: {
|
|
13
|
+
options: any;
|
|
14
|
+
payload: any;
|
|
15
|
+
client: Crowdin;
|
|
16
|
+
context: CrowdinContextInfo;
|
|
17
|
+
requestData: any;
|
|
18
|
+
}) => Promise<string>;
|
|
13
19
|
/**
|
|
14
20
|
* Represents a collection of supported actions. If not provided, all actions are supported.
|
|
15
21
|
*/
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
import { Response } from 'express';
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiProviderModule } from '../types';
|
|
5
|
-
export default function handle(aiProvider: AiProviderModule): (req:
|
|
5
|
+
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -3,4 +3,4 @@ import { Response } from 'express';
|
|
|
3
3
|
import { CrowdinClientRequest } from '../../../types';
|
|
4
4
|
import { AiProviderModule } from '../types';
|
|
5
5
|
export declare const CONTEXT_WINDOW_LIMIT = 4096;
|
|
6
|
-
export default function handle(aiProvider: AiProviderModule): (req:
|
|
6
|
+
export default function handle(aiProvider: AiProviderModule): (req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|