@crowdin/app-project-module 0.43.1 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.d.ts +3 -3
- package/out/index.js +103 -219
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/crowdin-client.js +3 -2
- package/out/middlewares/integration-credentials.d.ts +3 -2
- package/out/middlewares/render-ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.js +5 -1
- package/out/{util → modules}/api/api.d.ts +3 -2
- package/out/{util → modules}/api/api.js +22 -22
- package/out/modules/api/index.d.ts +6 -0
- package/out/modules/api/index.js +14 -0
- package/out/modules/api/types.d.ts +20 -0
- package/out/modules/api/types.js +11 -0
- package/out/modules/context-menu/index.d.ts +6 -0
- package/out/modules/context-menu/index.js +17 -0
- package/out/modules/context-menu/types.d.ts +27 -0
- package/out/modules/context-menu/types.js +18 -0
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.d.ts +2 -1
- package/out/{handlers/custom-mt → modules/custom-mt/handlers}/translate.js +2 -2
- package/out/modules/custom-mt/index.d.ts +6 -0
- package/out/modules/custom-mt/index.js +17 -0
- package/out/modules/custom-mt/types.d.ts +22 -0
- package/out/modules/custom-mt/types.js +2 -0
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/get-languages-list.js +2 -2
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.d.ts +2 -1
- package/out/{handlers/custom-spell-check → modules/custom-spell-check/handlers}/spell-check.js +5 -3
- package/out/modules/custom-spell-check/index.d.ts +6 -0
- package/out/modules/custom-spell-check/index.js +32 -0
- package/out/modules/custom-spell-check/types.d.ts +56 -0
- package/out/modules/custom-spell-check/types.js +2 -0
- package/out/modules/editor-right-panel/index.d.ts +6 -0
- package/out/modules/editor-right-panel/index.js +17 -0
- package/out/modules/editor-right-panel/types.d.ts +7 -0
- package/out/modules/editor-right-panel/types.js +2 -0
- package/out/modules/editor-themes/index.d.ts +6 -0
- package/out/modules/editor-themes/index.js +11 -0
- package/out/modules/editor-themes/types.d.ts +17 -0
- package/out/modules/editor-themes/types.js +2 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/custom-file-format.js +5 -5
- package/out/modules/file-processing/handlers/file-download.d.ts +5 -0
- package/out/{handlers/file-processing → modules/file-processing/handlers}/file-download.js +2 -2
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.d.ts +2 -1
- package/out/{handlers/file-processing → modules/file-processing/handlers}/pre-post-process.js +8 -8
- package/out/modules/file-processing/index.d.ts +22 -0
- package/out/modules/file-processing/index.js +57 -0
- package/out/modules/file-processing/types.d.ts +133 -0
- package/out/modules/file-processing/types.js +12 -0
- package/out/modules/file-processing/util/defaults.d.ts +3 -0
- package/out/modules/file-processing/util/defaults.js +30 -0
- package/out/modules/file-processing/util/files.d.ts +6 -0
- package/out/modules/file-processing/util/files.js +47 -0
- package/out/{handlers/integration/crowdin-project.d.ts → modules/form-data-display.d.ts} +1 -1
- package/out/modules/form-data-save.d.ts +4 -0
- package/out/modules/install.d.ts +4 -0
- package/out/{handlers → modules}/install.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-file-progress.js +2 -2
- package/out/modules/integration/handlers/crowdin-files.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-files.js +3 -3
- package/out/modules/integration/handlers/crowdin-project.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-project.js +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-update.js +9 -9
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +19 -8
- package/out/modules/integration/handlers/integration-data.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +5 -5
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/integration-login.js +3 -3
- package/out/modules/integration/handlers/integration-logout.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-logout.js +14 -7
- package/out/modules/integration/handlers/integration-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +9 -8
- package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +9 -4
- package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +4 -4
- package/out/modules/integration/handlers/job-info.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-info.js +4 -4
- package/out/modules/integration/handlers/main.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/main.js +5 -5
- package/out/modules/integration/handlers/oauth-login.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/oauth-login.js +3 -3
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.d.ts +2 -1
- package/out/{handlers/integration → modules/integration/handlers}/oauth-url.js +2 -2
- package/out/modules/integration/handlers/settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings-save.js +28 -11
- package/out/modules/integration/handlers/settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/settings.js +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.d.ts +1 -1
- package/out/{handlers/integration → modules/integration/handlers}/subscription-info.js +2 -2
- package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +16 -8
- package/out/modules/integration/handlers/sync-settings.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings.js +2 -2
- package/out/modules/integration/handlers/user-errors.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/user-errors.js +2 -2
- package/out/modules/integration/index.d.ts +6 -0
- package/out/modules/integration/index.js +118 -0
- package/out/modules/integration/types.d.ts +435 -0
- package/out/modules/integration/types.js +19 -0
- package/out/modules/integration/util/cron.d.ts +27 -0
- package/out/{util → modules/integration/util}/cron.js +97 -28
- package/out/{util → modules/integration/util}/defaults.d.ts +2 -3
- package/out/{util → modules/integration/util}/defaults.js +1 -36
- package/out/modules/integration/util/files.d.ts +5 -0
- package/out/{util → modules/integration/util}/files.js +9 -40
- package/out/{util → modules/integration/util}/job.d.ts +1 -1
- package/out/{util → modules/integration/util}/job.js +11 -11
- package/out/{util/file-snapshot.d.ts → modules/integration/util/snapshot.d.ts} +2 -3
- package/out/{util/file-snapshot.js → modules/integration/util/snapshot.js} +6 -65
- package/out/{models/job.d.ts → modules/integration/util/types.d.ts} +14 -0
- package/out/modules/integration/util/webhooks.d.ts +48 -0
- package/out/{util → modules/integration/util}/webhooks.js +95 -49
- package/out/modules/manifest.d.ts +3 -0
- package/out/{handlers → modules}/manifest.js +22 -16
- package/out/modules/modal/index.d.ts +6 -0
- package/out/modules/modal/index.js +17 -0
- package/out/modules/organization-menu/index.d.ts +6 -0
- package/out/modules/organization-menu/index.js +18 -0
- package/out/modules/profile-resources-menu/index.d.ts +6 -0
- package/out/modules/profile-resources-menu/index.js +18 -0
- package/out/modules/project-menu/index.d.ts +6 -0
- package/out/modules/project-menu/index.js +17 -0
- package/out/modules/project-menu-crowdsource/index.d.ts +6 -0
- package/out/modules/project-menu-crowdsource/index.js +17 -0
- package/out/modules/project-reports/index.d.ts +6 -0
- package/out/modules/project-reports/index.js +18 -0
- package/out/modules/project-tools/index.d.ts +6 -0
- package/out/modules/project-tools/index.js +18 -0
- package/out/modules/subscription-paid.d.ts +3 -0
- package/out/{handlers → modules}/subscription-paid.js +2 -2
- package/out/modules/uninstall.d.ts +4 -0
- package/out/{handlers → modules}/uninstall.js +6 -2
- package/out/storage/index.d.ts +5 -3
- package/out/storage/mysql.d.ts +4 -2
- package/out/storage/mysql.js +3 -3
- package/out/storage/postgre.d.ts +4 -2
- package/out/storage/postgre.js +3 -3
- package/out/storage/sqlite.d.ts +4 -2
- package/out/storage/sqlite.js +3 -3
- package/out/storage/types.d.ts +9 -0
- package/out/storage/types.js +2 -0
- package/out/types.d.ts +374 -0
- package/out/types.js +59 -0
- package/out/util/connection.d.ts +2 -9
- package/out/util/connection.js +54 -150
- package/out/util/handlebars.d.ts +1 -0
- package/out/util/handlebars.js +34 -0
- package/out/util/index.d.ts +2 -2
- package/out/util/index.js +6 -6
- package/out/util/logger.d.ts +2 -2
- package/out/util/subscription.d.ts +9 -0
- package/out/util/subscription.js +111 -0
- package/package.json +1 -1
- package/out/handlers/file-processing/file-download.d.ts +0 -4
- package/out/handlers/form-data-display.d.ts +0 -3
- package/out/handlers/form-data-save.d.ts +0 -3
- package/out/handlers/install.d.ts +0 -4
- package/out/handlers/integration/crowdin-files.d.ts +0 -4
- package/out/handlers/integration/crowdin-update.d.ts +0 -4
- package/out/handlers/integration/crowdin-webhook.d.ts +0 -4
- package/out/handlers/integration/integration-data.d.ts +0 -4
- package/out/handlers/integration/integration-logout.d.ts +0 -4
- package/out/handlers/integration/integration-update.d.ts +0 -4
- package/out/handlers/integration/integration-webhook.d.ts +0 -4
- package/out/handlers/integration/job-cancel.d.ts +0 -3
- package/out/handlers/integration/job-info.d.ts +0 -3
- package/out/handlers/integration/main.d.ts +0 -4
- package/out/handlers/integration/oauth-login.d.ts +0 -4
- package/out/handlers/integration/settings-save.d.ts +0 -4
- package/out/handlers/integration/settings.d.ts +0 -3
- package/out/handlers/integration/sync-settings-save.d.ts +0 -4
- package/out/handlers/integration/sync-settings.d.ts +0 -3
- package/out/handlers/integration/user-errors.d.ts +0 -3
- package/out/handlers/manifest.d.ts +0 -3
- package/out/handlers/subscription-paid.d.ts +0 -3
- package/out/handlers/uninstall.d.ts +0 -4
- package/out/models/index.d.ts +0 -1088
- package/out/models/index.js +0 -106
- package/out/util/cron.d.ts +0 -7
- package/out/util/files.d.ts +0 -9
- package/out/util/webhooks.d.ts +0 -28
- /package/out/{util → modules}/api/base.d.ts +0 -0
- /package/out/{util → modules}/api/base.js +0 -0
- /package/out/{util → modules}/api/components.d.ts +0 -0
- /package/out/{util → modules}/api/components.js +0 -0
- /package/out/{handlers → modules}/form-data-display.js +0 -0
- /package/out/{handlers → modules}/form-data-save.js +0 -0
- /package/out/{models/job.js → modules/integration/util/types.js} +0 -0
package/out/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
import { ClientConfig, Config, CrowdinAppUtilities, CrowdinMetadataStore } from './
|
|
2
|
+
import { ClientConfig, Config, CrowdinAppUtilities, CrowdinMetadataStore } from './types';
|
|
3
3
|
import express from './util/terminus-express';
|
|
4
|
-
export { ProjectPermissions, Scope, UserPermissions } from './
|
|
4
|
+
export { ProjectPermissions, Scope, UserPermissions } from './types';
|
|
5
5
|
export { express };
|
|
6
6
|
export declare const metadataStore: CrowdinMetadataStore;
|
|
7
|
-
export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): CrowdinAppUtilities;
|
|
8
7
|
export declare function createApp(clientConfig: ClientConfig): void;
|
|
8
|
+
export declare function addCrowdinEndpoints(app: Express, clientConfig: Config | ClientConfig): Partial<CrowdinAppUtilities>;
|
package/out/index.js
CHANGED
|
@@ -35,64 +35,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.
|
|
38
|
+
exports.addCrowdinEndpoints = exports.createApp = exports.metadataStore = exports.express = exports.UserPermissions = exports.Scope = exports.ProjectPermissions = void 0;
|
|
39
39
|
const logsFormatter = __importStar(require("@crowdin/logs-formatter"));
|
|
40
|
-
const express_handlebars_1 = __importDefault(require("express-handlebars"));
|
|
41
|
-
const cron = __importStar(require("node-cron"));
|
|
42
40
|
const path_1 = require("path");
|
|
43
|
-
const translate_1 = __importDefault(require("./handlers/custom-mt/translate"));
|
|
44
|
-
const custom_file_format_1 = __importDefault(require("./handlers/file-processing/custom-file-format"));
|
|
45
|
-
const file_download_1 = __importDefault(require("./handlers/file-processing/file-download"));
|
|
46
|
-
const pre_post_process_1 = __importDefault(require("./handlers/file-processing/pre-post-process"));
|
|
47
|
-
const form_data_display_1 = __importDefault(require("./handlers/form-data-display"));
|
|
48
|
-
const form_data_save_1 = __importDefault(require("./handlers/form-data-save"));
|
|
49
|
-
const install_1 = __importDefault(require("./handlers/install"));
|
|
50
|
-
const crowdin_file_progress_1 = __importDefault(require("./handlers/integration/crowdin-file-progress"));
|
|
51
|
-
const crowdin_files_1 = __importDefault(require("./handlers/integration/crowdin-files"));
|
|
52
|
-
const crowdin_project_1 = __importDefault(require("./handlers/integration/crowdin-project"));
|
|
53
|
-
const crowdin_update_1 = __importDefault(require("./handlers/integration/crowdin-update"));
|
|
54
|
-
const crowdin_webhook_1 = __importDefault(require("./handlers/integration/crowdin-webhook"));
|
|
55
|
-
const integration_data_1 = __importDefault(require("./handlers/integration/integration-data"));
|
|
56
|
-
const integration_login_1 = __importDefault(require("./handlers/integration/integration-login"));
|
|
57
|
-
const integration_logout_1 = __importDefault(require("./handlers/integration/integration-logout"));
|
|
58
|
-
const integration_update_1 = __importDefault(require("./handlers/integration/integration-update"));
|
|
59
|
-
const integration_webhook_1 = __importDefault(require("./handlers/integration/integration-webhook"));
|
|
60
|
-
const main_1 = __importDefault(require("./handlers/integration/main"));
|
|
61
|
-
const oauth_login_1 = __importDefault(require("./handlers/integration/oauth-login"));
|
|
62
|
-
const oauth_url_1 = __importDefault(require("./handlers/integration/oauth-url"));
|
|
63
|
-
const settings_save_1 = __importDefault(require("./handlers/integration/settings-save"));
|
|
64
|
-
const subscription_info_1 = __importDefault(require("./handlers/integration/subscription-info"));
|
|
65
|
-
const job_info_1 = __importDefault(require("./handlers/integration/job-info"));
|
|
66
|
-
const job_cancel_1 = __importDefault(require("./handlers/integration/job-cancel"));
|
|
67
|
-
const sync_settings_1 = __importDefault(require("./handlers/integration/sync-settings"));
|
|
68
|
-
const sync_settings_save_1 = __importDefault(require("./handlers/integration/sync-settings-save"));
|
|
69
|
-
const user_errors_1 = __importDefault(require("./handlers/integration/user-errors"));
|
|
70
|
-
const manifest_1 = __importDefault(require("./handlers/manifest"));
|
|
71
|
-
const subscription_paid_1 = __importDefault(require("./handlers/subscription-paid"));
|
|
72
|
-
const uninstall_1 = __importDefault(require("./handlers/uninstall"));
|
|
73
|
-
const get_languages_list_1 = __importDefault(require("./handlers/custom-spell-check/get-languages-list"));
|
|
74
|
-
const spell_check_1 = __importDefault(require("./handlers/custom-spell-check/spell-check"));
|
|
75
41
|
const crowdin_client_1 = __importStar(require("./middlewares/crowdin-client"));
|
|
76
|
-
const integration_credentials_1 = __importDefault(require("./middlewares/integration-credentials"));
|
|
77
42
|
const json_response_1 = __importDefault(require("./middlewares/json-response"));
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
const
|
|
43
|
+
const form_data_display_1 = __importDefault(require("./modules/form-data-display"));
|
|
44
|
+
const form_data_save_1 = __importDefault(require("./modules/form-data-save"));
|
|
45
|
+
const install_1 = __importDefault(require("./modules/install"));
|
|
46
|
+
const manifest_1 = __importDefault(require("./modules/manifest"));
|
|
47
|
+
const subscription_paid_1 = __importDefault(require("./modules/subscription-paid"));
|
|
48
|
+
const uninstall_1 = __importDefault(require("./modules/uninstall"));
|
|
81
49
|
const storage = __importStar(require("./storage"));
|
|
50
|
+
const types_1 = require("./types");
|
|
82
51
|
const util_1 = require("./util");
|
|
83
|
-
const api_1 = require("./util/api/api");
|
|
84
52
|
const connection_1 = require("./util/connection");
|
|
85
|
-
const
|
|
86
|
-
const defaults_1 = require("./util/defaults");
|
|
53
|
+
const handlebars_1 = require("./util/handlebars");
|
|
87
54
|
const logger = __importStar(require("./util/logger"));
|
|
88
55
|
const logger_1 = require("./util/logger");
|
|
89
56
|
const terminus_express_1 = __importDefault(require("./util/terminus-express"));
|
|
90
57
|
exports.express = terminus_express_1.default;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
58
|
+
//apps
|
|
59
|
+
const apiApp = __importStar(require("./modules/api"));
|
|
60
|
+
const contextMenuApp = __importStar(require("./modules/context-menu"));
|
|
61
|
+
const customMTApp = __importStar(require("./modules/custom-mt"));
|
|
62
|
+
const spellCheckApp = __importStar(require("./modules/custom-spell-check"));
|
|
63
|
+
const editorRightPanelApp = __importStar(require("./modules/editor-right-panel"));
|
|
64
|
+
const editorThemesApp = __importStar(require("./modules/editor-themes"));
|
|
65
|
+
const fileProcessingApps = __importStar(require("./modules/file-processing"));
|
|
66
|
+
const integrationApp = __importStar(require("./modules/integration"));
|
|
67
|
+
const modalApp = __importStar(require("./modules/modal"));
|
|
68
|
+
const organizationMenuApp = __importStar(require("./modules/organization-menu"));
|
|
69
|
+
const profileResourcesMenuApp = __importStar(require("./modules/profile-resources-menu"));
|
|
70
|
+
const projectMenuApp = __importStar(require("./modules/project-menu"));
|
|
71
|
+
const projectMenuCrowdsourceApp = __importStar(require("./modules/project-menu-crowdsource"));
|
|
72
|
+
const projectReportsApp = __importStar(require("./modules/project-reports"));
|
|
73
|
+
const projectToolsApp = __importStar(require("./modules/project-tools"));
|
|
74
|
+
const subscription_1 = require("./util/subscription");
|
|
75
|
+
var types_2 = require("./types");
|
|
76
|
+
Object.defineProperty(exports, "ProjectPermissions", { enumerable: true, get: function () { return types_2.ProjectPermissions; } });
|
|
77
|
+
Object.defineProperty(exports, "Scope", { enumerable: true, get: function () { return types_2.Scope; } });
|
|
78
|
+
Object.defineProperty(exports, "UserPermissions", { enumerable: true, get: function () { return types_2.UserPermissions; } });
|
|
96
79
|
exports.metadataStore = {
|
|
97
80
|
getMetadata: (id) => {
|
|
98
81
|
return storage.getStorage().getMetadata(id);
|
|
@@ -116,9 +99,16 @@ exports.metadataStore = {
|
|
|
116
99
|
}
|
|
117
100
|
}),
|
|
118
101
|
};
|
|
102
|
+
function createApp(clientConfig) {
|
|
103
|
+
const app = (0, terminus_express_1.default)();
|
|
104
|
+
const config = convertClientConfig(clientConfig);
|
|
105
|
+
addCrowdinEndpoints(app, config);
|
|
106
|
+
/* eslint no-console: "off" */
|
|
107
|
+
app.listen(config.port, () => console.log(`App started on port ${config.port}`));
|
|
108
|
+
}
|
|
109
|
+
exports.createApp = createApp;
|
|
119
110
|
function addCrowdinEndpoints(app, clientConfig) {
|
|
120
|
-
|
|
121
|
-
const config = (0, defaults_1.convertClientConfig)(clientConfig);
|
|
111
|
+
const config = convertClientConfig(clientConfig);
|
|
122
112
|
if (!config.disableGlobalErrorHandling) {
|
|
123
113
|
handleUncaughtErrors();
|
|
124
114
|
}
|
|
@@ -132,175 +122,48 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
132
122
|
}
|
|
133
123
|
app.use('/assets', terminus_express_1.default.static((0, path_1.join)(__dirname, 'static')));
|
|
134
124
|
app.set('views', (0, path_1.join)(__dirname, 'views'));
|
|
135
|
-
app.engine('handlebars',
|
|
136
|
-
layoutsDir: '',
|
|
137
|
-
defaultLayout: '',
|
|
138
|
-
helpers: {
|
|
139
|
-
ifeq: function (a, b, options) {
|
|
140
|
-
if (a === b) {
|
|
141
|
-
return options.fn(this);
|
|
142
|
-
}
|
|
143
|
-
return options.inverse(this);
|
|
144
|
-
},
|
|
145
|
-
checkLength: function (a, b, options) {
|
|
146
|
-
if (a.length > b) {
|
|
147
|
-
return options.fn(this);
|
|
148
|
-
}
|
|
149
|
-
return options.inverse(this);
|
|
150
|
-
},
|
|
151
|
-
in: function (a, b, options) {
|
|
152
|
-
if (a.toString().includes(b.toString())) {
|
|
153
|
-
return options.fn(this);
|
|
154
|
-
}
|
|
155
|
-
return options.inverse(this);
|
|
156
|
-
},
|
|
157
|
-
or: function (a, b, options) {
|
|
158
|
-
return a || b ? options.fn(this) : options.inverse(this);
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
}));
|
|
125
|
+
app.engine('handlebars', handlebars_1.engine);
|
|
162
126
|
app.set('view engine', 'handlebars');
|
|
163
127
|
app.get((0, util_1.getLogoUrl)(), (req, res) => res.sendFile(config.imagePath));
|
|
164
|
-
app.post('/installed', (0, install_1.default)(config));
|
|
165
|
-
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
166
128
|
app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
|
|
167
|
-
if (!(0,
|
|
129
|
+
if (!(0, subscription_1.isAppFree)(config)) {
|
|
168
130
|
app.post('/subscription-paid', (0, subscription_paid_1.default)());
|
|
169
131
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
app.get('/api/crowdin/file-progress/:fileId', (0, crowdin_client_1.default)(config), (0, crowdin_file_progress_1.default)(integrationLogic));
|
|
184
|
-
app.get('/api/integration/data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_data_1.default)(integrationLogic));
|
|
185
|
-
app.post('/api/crowdin/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, crowdin_update_1.default)(config, integrationLogic));
|
|
186
|
-
app.post('/api/integration/update', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, integration_update_1.default)(config, integrationLogic));
|
|
187
|
-
app.get('/api/sync-settings/:provider', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_1.default)());
|
|
188
|
-
app.post('/api/sync-settings', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, sync_settings_save_1.default)(config, integrationLogic));
|
|
189
|
-
if (integrationLogic.oauthLogin) {
|
|
190
|
-
app.get((0, defaults_1.getOauthRoute)(integrationLogic), (0, oauth_login_1.default)(config, integrationLogic));
|
|
191
|
-
app.post('/api/oauth-url', json_response_1.default, (0, crowdin_client_1.default)(config, false, false), (0, oauth_url_1.default)(config, integrationLogic));
|
|
192
|
-
}
|
|
193
|
-
if (integrationLogic.cronJobs) {
|
|
194
|
-
integrationLogic.cronJobs.forEach((job) => {
|
|
195
|
-
cron.schedule(job.expression, () => (0, cron_1.runJob)(config, integrationLogic, job).catch(console.error));
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
if (integrationLogic.withCronSync) {
|
|
199
|
-
cron.schedule('0 * * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '1').catch(console.error));
|
|
200
|
-
cron.schedule('0 */3 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '3').catch(console.error));
|
|
201
|
-
cron.schedule('0 */6 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '6').catch(console.error));
|
|
202
|
-
cron.schedule('0 */12 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '12').catch(console.error));
|
|
203
|
-
cron.schedule('0 0 * * *', () => (0, cron_1.filesCron)(config, integrationLogic, '24').catch(console.error));
|
|
204
|
-
}
|
|
205
|
-
if (integrationLogic.webhooks) {
|
|
206
|
-
app.post(`${integrationLogic.webhooks.crowdinWebhookUrl
|
|
207
|
-
? integrationLogic.webhooks.crowdinWebhookUrl
|
|
208
|
-
: '/api/crowdin/webhook'}`, json_response_1.default, (0, crowdin_webhook_1.default)(config, integrationLogic));
|
|
209
|
-
if (((_a = integrationLogic.webhooks) === null || _a === void 0 ? void 0 : _a.integrationWebhookInterceptor) && !((_b = integrationLogic.webhooks) === null || _b === void 0 ? void 0 : _b.queueUrl)) {
|
|
210
|
-
app.post(`${integrationLogic.webhooks.integrationWebhookUrl
|
|
211
|
-
? integrationLogic.webhooks.integrationWebhookUrl
|
|
212
|
-
: '/api/integration/webhook'}`, (0, integration_webhook_1.default)(config, integrationLogic));
|
|
213
|
-
}
|
|
214
|
-
if ((_c = integrationLogic.webhooks) === null || _c === void 0 ? void 0 : _c.queueUrl) {
|
|
215
|
-
(0, webhooks_1.listenQueueMessage)(config, integrationLogic, integrationLogic.webhooks.queueUrl, config.identifier);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
app.get('/api/user-errors', json_response_1.default, (0, crowdin_client_1.default)(config), (0, integration_credentials_1.default)(config, integrationLogic), (0, user_errors_1.default)());
|
|
219
|
-
cron.schedule('0 0 1 * *', () => (0, cron_1.removeFinishedJobs)());
|
|
220
|
-
}
|
|
221
|
-
if (config.customFileFormat) {
|
|
222
|
-
(0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.customFileFormat);
|
|
223
|
-
app.post('/process', (0, crowdin_client_1.default)(config), (0, custom_file_format_1.default)(config.baseUrl, config.customFileFormat.filesFolder || config.dbFolder, config.customFileFormat));
|
|
224
|
-
app.get('/file/download', (0, file_download_1.default)(config, config.customFileFormat, 'custom-file-format'));
|
|
225
|
-
}
|
|
226
|
-
if (config.filePreImport) {
|
|
227
|
-
(0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePreImport);
|
|
228
|
-
app.post('/pre-import', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePreImport, models_1.ProcessFileJobType.PRE_IMPORT));
|
|
229
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.PRE_IMPORT}`, (0, file_download_1.default)(config, config.filePreImport, models_1.ProcessFileJobType.PRE_IMPORT));
|
|
230
|
-
}
|
|
231
|
-
if (config.filePostImport) {
|
|
232
|
-
(0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePostImport);
|
|
233
|
-
app.post('/post-import', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePostImport, models_1.ProcessFileJobType.POST_IMPORT));
|
|
234
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.POST_IMPORT}`, (0, file_download_1.default)(config, config.filePostImport, models_1.ProcessFileJobType.POST_IMPORT));
|
|
235
|
-
}
|
|
236
|
-
if (config.filePreExport) {
|
|
237
|
-
(0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePreExport);
|
|
238
|
-
app.post('/pre-export', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePreExport, models_1.ProcessFileJobType.PRE_EXPORT));
|
|
239
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.PRE_EXPORT}`, (0, file_download_1.default)(config, config.filePreExport, models_1.ProcessFileJobType.PRE_EXPORT));
|
|
240
|
-
}
|
|
241
|
-
if (config.filePostExport) {
|
|
242
|
-
(0, defaults_1.applyFileProcessorsModuleDefaults)(config, config.filePostExport);
|
|
243
|
-
app.post('/post-export', (0, crowdin_client_1.default)(config), (0, pre_post_process_1.default)(config, config.filePostExport, models_1.ProcessFileJobType.POST_EXPORT));
|
|
244
|
-
app.get(`/file/download/${models_1.ProcessFileJobType.POST_EXPORT}`, (0, file_download_1.default)(config, config.filePostExport, models_1.ProcessFileJobType.POST_EXPORT));
|
|
245
|
-
}
|
|
246
|
-
if (config.customMT) {
|
|
247
|
-
app.get((0, util_1.getLogoUrl)(config.customMT, '/mt'), (req, res) => { var _a; return res.sendFile(((_a = config.customMT) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
248
|
-
app.post('/translate', (0, crowdin_client_1.default)(config), (0, translate_1.default)(config.customMT));
|
|
249
|
-
}
|
|
250
|
-
if (config.profileResourcesMenu) {
|
|
251
|
-
app.get((0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.profileResourcesMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
252
|
-
app.use('/resources', (0, ui_module_1.default)(config, config.profileResourcesMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.profileResourcesMenu));
|
|
253
|
-
}
|
|
254
|
-
if (config.organizationMenu) {
|
|
255
|
-
app.get((0, util_1.getLogoUrl)(config.organizationMenu, '/resources'), (req, res) => { var _a; return res.sendFile(((_a = config.organizationMenu) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
256
|
-
app.use('/resources', (0, ui_module_1.default)(config, config.organizationMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.organizationMenu));
|
|
257
|
-
}
|
|
258
|
-
if (config.editorRightPanel) {
|
|
259
|
-
app.use('/editor-panels', (0, ui_module_1.default)(config, config.editorRightPanel.allowUnauthorized), (0, render_ui_module_1.default)(config.editorRightPanel));
|
|
260
|
-
}
|
|
261
|
-
if (config.editorThemes) {
|
|
262
|
-
app.get((0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'), (req, res) => { var _a; return res.sendFile(((_a = config.editorThemes) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
263
|
-
}
|
|
264
|
-
if (config.projectMenu) {
|
|
265
|
-
app.use('/project-menu', (0, ui_module_1.default)(config, config.projectMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenu));
|
|
266
|
-
}
|
|
267
|
-
if (config.projectMenuCrowdsource) {
|
|
268
|
-
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, config.projectMenuCrowdsource.allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenuCrowdsource));
|
|
269
|
-
}
|
|
270
|
-
if (config.projectTools) {
|
|
271
|
-
app.get((0, util_1.getLogoUrl)(config.projectTools, '/tools'), (req, res) => { var _a; return res.sendFile(((_a = config.projectTools) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
272
|
-
app.use('/tools', (0, ui_module_1.default)(config, config.projectTools.allowUnauthorized), (0, render_ui_module_1.default)(config.projectTools));
|
|
273
|
-
}
|
|
274
|
-
if (config.projectReports) {
|
|
275
|
-
app.get((0, util_1.getLogoUrl)(config.projectReports, '/reports'), (req, res) => { var _a; return res.sendFile(((_a = config.projectReports) === null || _a === void 0 ? void 0 : _a.imagePath) || config.imagePath); });
|
|
276
|
-
app.use('/reports', (0, ui_module_1.default)(config, config.projectReports.allowUnauthorized), (0, render_ui_module_1.default)(config.projectReports));
|
|
277
|
-
}
|
|
278
|
-
if (((_d = config.modal) === null || _d === void 0 ? void 0 : _d.uiPath) || ((_e = config.modal) === null || _e === void 0 ? void 0 : _e.formSchema)) {
|
|
279
|
-
app.use('/modal', (0, ui_module_1.default)(config, config.modal.allowUnauthorized), (0, render_ui_module_1.default)(config.modal));
|
|
280
|
-
}
|
|
281
|
-
if (((_f = config.contextMenu) === null || _f === void 0 ? void 0 : _f.uiPath) || ((_g = config.contextMenu) === null || _g === void 0 ? void 0 : _g.formSchema)) {
|
|
282
|
-
app.use('/context', (0, ui_module_1.default)(config, config.contextMenu.allowUnauthorized), (0, render_ui_module_1.default)(config.contextMenu));
|
|
283
|
-
}
|
|
284
|
-
if (config.api) {
|
|
285
|
-
if (config.api.default) {
|
|
286
|
-
(0, api_1.addDefaultApiEndpoints)(app, config);
|
|
287
|
-
}
|
|
288
|
-
(0, api_1.addSwagerApiDocumentation)(app, config);
|
|
289
|
-
}
|
|
290
|
-
if (config.customSpellchecker) {
|
|
291
|
-
if (config.customSpellchecker.settingsUiModule) {
|
|
292
|
-
app.use('/settings', (0, ui_module_1.default)(config, config.customSpellchecker.settingsUiModule.allowUnauthorized), (0, render_ui_module_1.default)(config.customSpellchecker.settingsUiModule));
|
|
293
|
-
}
|
|
294
|
-
app.get('/languages', json_response_1.default, (0, crowdin_client_1.default)(config), (0, get_languages_list_1.default)(config.customSpellchecker));
|
|
295
|
-
app.post('/spellcheck', json_response_1.default, (0, crowdin_client_1.default)(config), (0, spell_check_1.default)(config.customSpellchecker));
|
|
296
|
-
}
|
|
297
|
-
if (Object.keys(config).some((moduleKey) => {
|
|
298
|
-
const moduleConfig = config[moduleKey];
|
|
299
|
-
return typeof moduleConfig === 'object' && moduleConfig.hasOwnProperty('formSchema');
|
|
300
|
-
})) {
|
|
301
|
-
app.get('/api/form-data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, form_data_display_1.default)());
|
|
302
|
-
app.post('/api/form-data', (0, crowdin_client_1.default)(config), (0, form_data_save_1.default)());
|
|
132
|
+
spellCheckApp.register({ config, app });
|
|
133
|
+
editorRightPanelApp.register({ config, app });
|
|
134
|
+
projectMenuApp.register({ config, app });
|
|
135
|
+
profileResourcesMenuApp.register({ config, app });
|
|
136
|
+
organizationMenuApp.register({ config, app });
|
|
137
|
+
projectMenuCrowdsourceApp.register({ config, app });
|
|
138
|
+
projectToolsApp.register({ config, app });
|
|
139
|
+
projectReportsApp.register({ config, app });
|
|
140
|
+
modalApp.register({ config, app });
|
|
141
|
+
contextMenuApp.register({ config, app });
|
|
142
|
+
//other apps only work in authorized context
|
|
143
|
+
if (!(0, util_1.isAuthorizedConfig)(config)) {
|
|
144
|
+
return {};
|
|
303
145
|
}
|
|
146
|
+
app.post('/installed', (0, install_1.default)(config));
|
|
147
|
+
app.post('/uninstall', (0, uninstall_1.default)(config));
|
|
148
|
+
/**
|
|
149
|
+
* Module structure
|
|
150
|
+
* /modules
|
|
151
|
+
* /<module-name>
|
|
152
|
+
* index.ts -> registration
|
|
153
|
+
* types.ts -> types, interfaces, etc
|
|
154
|
+
* /util -> folder for utilities
|
|
155
|
+
* /handlers -> for http handlers
|
|
156
|
+
*/
|
|
157
|
+
integrationApp.register({ config, app });
|
|
158
|
+
editorThemesApp.register({ config, app });
|
|
159
|
+
customMTApp.register({ config, app });
|
|
160
|
+
fileProcessingApps.registerCustomFileFormat({ config, app });
|
|
161
|
+
fileProcessingApps.registerFilePreImport({ config, app });
|
|
162
|
+
fileProcessingApps.registerFilePostImport({ config, app });
|
|
163
|
+
fileProcessingApps.registerFilePreExport({ config, app });
|
|
164
|
+
fileProcessingApps.registerFilePostExport({ config, app });
|
|
165
|
+
apiApp.register({ config, app });
|
|
166
|
+
addFormSchema({ config, app });
|
|
304
167
|
return Object.assign(Object.assign({}, exports.metadataStore), { establishCrowdinConnection: (authRequest) => {
|
|
305
168
|
let jwtToken = '';
|
|
306
169
|
if (typeof authRequest === 'string') {
|
|
@@ -321,14 +184,35 @@ function addCrowdinEndpoints(app, clientConfig) {
|
|
|
321
184
|
}) });
|
|
322
185
|
}
|
|
323
186
|
exports.addCrowdinEndpoints = addCrowdinEndpoints;
|
|
324
|
-
function
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
187
|
+
function addFormSchema({ app, config }) {
|
|
188
|
+
if (Object.keys(config).some((moduleKey) => {
|
|
189
|
+
const moduleConfig = config[moduleKey];
|
|
190
|
+
return typeof moduleConfig === 'object' && moduleConfig.hasOwnProperty('formSchema');
|
|
191
|
+
})) {
|
|
192
|
+
app.get('/api/form-data', json_response_1.default, (0, crowdin_client_1.default)(config), (0, form_data_display_1.default)());
|
|
193
|
+
app.post('/api/form-data', (0, crowdin_client_1.default)(config), (0, form_data_save_1.default)());
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function convertClientConfig(clientConfig) {
|
|
197
|
+
const baseUrl = clientConfig.baseUrl || process.env.URL;
|
|
198
|
+
const clientId = clientConfig.clientId || process.env.CROWDIN_CLIENT_ID;
|
|
199
|
+
const clientSecret = clientConfig.clientSecret || process.env.CROWDIN_CLIENT_SECRET;
|
|
200
|
+
const port = clientConfig.port || process.env.PORT || 3000;
|
|
201
|
+
const { region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION, tmpBucketName = process.env.AWS_TMP_BUCKET_NAME, } = clientConfig.awsConfig || {};
|
|
202
|
+
if (!baseUrl) {
|
|
203
|
+
throw new Error('Missing baseUrl parameter');
|
|
204
|
+
}
|
|
205
|
+
if (clientConfig.authenticationType !== types_1.AuthenticationType.NONE) {
|
|
206
|
+
if (!clientId && !clientSecret) {
|
|
207
|
+
throw new Error('Missing [clientId, clientSecret] parameters');
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl, clientId,
|
|
211
|
+
clientSecret, awsConfig: {
|
|
212
|
+
tmpBucketName,
|
|
213
|
+
region,
|
|
214
|
+
}, port: Number(port), dbFolder: clientConfig.dbFolder || (0, path_1.join)(process.cwd(), 'db'), imagePath: clientConfig.imagePath || (0, path_1.join)(process.cwd(), 'logo.png') });
|
|
330
215
|
}
|
|
331
|
-
exports.createApp = createApp;
|
|
332
216
|
function handleUncaughtErrors() {
|
|
333
217
|
process
|
|
334
218
|
.on('unhandledRejection', (reason) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
3
3
|
import { Response } from 'express';
|
|
4
|
-
import { Config, CrowdinClientRequest, CrowdinContextInfo, SubscriptionInfo } from '../
|
|
4
|
+
import { Config, CrowdinClientRequest, CrowdinContextInfo, SubscriptionInfo } from '../types';
|
|
5
5
|
import { LogErrorFunction, LogFunction } from '../util/logger';
|
|
6
6
|
export declare function prepareCrowdinRequest(jwtToken: string, config: Config, optional?: boolean, checkSubscriptionExpiration?: boolean): Promise<{
|
|
7
7
|
context: CrowdinContextInfo;
|
|
@@ -13,9 +13,10 @@ exports.getToken = exports.prepareCrowdinRequest = void 0;
|
|
|
13
13
|
const crowdin_apps_functions_1 = require("@crowdin/crowdin-apps-functions");
|
|
14
14
|
const storage_1 = require("../storage");
|
|
15
15
|
const util_1 = require("../util");
|
|
16
|
-
const api_1 = require("../
|
|
16
|
+
const api_1 = require("../modules/api/api");
|
|
17
17
|
const connection_1 = require("../util/connection");
|
|
18
18
|
const logger_1 = require("../util/logger");
|
|
19
|
+
const subscription_1 = require("../util/subscription");
|
|
19
20
|
function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscriptionExpiration = true) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
22
|
(0, logger_1.log)('Validating jwt token from incoming request');
|
|
@@ -40,7 +41,7 @@ function prepareCrowdinRequest(jwtToken, config, optional = false, checkSubscrip
|
|
|
40
41
|
const { client, token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, autoRenew: true, context });
|
|
41
42
|
let subscriptionInfo;
|
|
42
43
|
if (checkSubscriptionExpiration) {
|
|
43
|
-
subscriptionInfo = yield (0,
|
|
44
|
+
subscriptionInfo = yield (0, subscription_1.checkSubscription)({
|
|
44
45
|
config,
|
|
45
46
|
token,
|
|
46
47
|
organization: credentials.id,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Response } from 'express';
|
|
3
|
-
import { Config
|
|
4
|
-
|
|
3
|
+
import { Config } from '../types';
|
|
4
|
+
import { IntegrationLogic } from '../modules/integration/types';
|
|
5
|
+
export default function handle(config: Config, integration: IntegrationLogic, optional?: boolean): (req: import("../types").CrowdinClientRequest | import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import { UiModule } from '../
|
|
4
|
-
export default function handle(moduleConfig: UiModule): (req: import("../
|
|
3
|
+
import { UiModule } from '../types';
|
|
4
|
+
export default function handle(moduleConfig: UiModule): (req: import("../types").CrowdinClientRequest | express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
2
|
import { Request, Response } from 'express';
|
|
3
|
-
import { Config } from '../
|
|
4
|
-
export default function handle(config: Config, allowUnauthorized?: boolean): (req: import("../
|
|
3
|
+
import { Config, UnauthorizedConfig } from '../types';
|
|
4
|
+
export default function handle(config: Config | UnauthorizedConfig, allowUnauthorized?: boolean): (req: import("../types").CrowdinClientRequest | Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
@@ -14,12 +14,16 @@ const storage_1 = require("../storage");
|
|
|
14
14
|
const util_1 = require("../util");
|
|
15
15
|
const connection_1 = require("../util/connection");
|
|
16
16
|
const logger_1 = require("../util/logger");
|
|
17
|
+
const subscription_1 = require("../util/subscription");
|
|
17
18
|
function handle(config, allowUnauthorized = false) {
|
|
18
19
|
return (0, util_1.runAsyncWrapper)((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
19
20
|
if (allowUnauthorized) {
|
|
20
21
|
next();
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
24
|
+
if (!(0, util_1.isAuthorizedConfig)(config)) {
|
|
25
|
+
throw new Error('Invalid configuration. UI module was configured as authorized but client id and client secret are missing');
|
|
26
|
+
}
|
|
23
27
|
const jwtToken = req.query.jwtToken;
|
|
24
28
|
if (!jwtToken) {
|
|
25
29
|
return res.status(403).send({ error: 'Access denied' });
|
|
@@ -41,7 +45,7 @@ function handle(config, allowUnauthorized = false) {
|
|
|
41
45
|
}
|
|
42
46
|
logInfo('Building crowdin client instance');
|
|
43
47
|
const { token } = yield (0, connection_1.prepareCrowdinClient)({ config, credentials, context });
|
|
44
|
-
const { expired, subscribeLink } = yield (0,
|
|
48
|
+
const { expired, subscribeLink } = yield (0, subscription_1.checkSubscription)({
|
|
45
49
|
config,
|
|
46
50
|
token,
|
|
47
51
|
organization: credentials.id,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { Config, CrowdinClientRequest, CrowdinContextInfo, UnauthorizedConfig } from '../../types';
|
|
3
|
+
import { ApiEndpoints, ApiModule } from './types';
|
|
4
|
+
export declare function getApiManifest(config: Config | UnauthorizedConfig, apiModule: ApiModule): ApiEndpoints[];
|
|
4
5
|
export declare function updateCrowdinContext(req: CrowdinClientRequest, context: CrowdinContextInfo): CrowdinContextInfo;
|
|
5
6
|
export declare function addDefaultApiEndpoints(app: Express, config: Config): void;
|
|
6
7
|
export declare function addSwagerApiDocumentation(app: Express, config: Config): void;
|
|
@@ -7,20 +7,20 @@ exports.addSwagerApiDocumentation = exports.addDefaultApiEndpoints = exports.upd
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const redoc_express_1 = __importDefault(require("redoc-express"));
|
|
9
9
|
const swagger_jsdoc_1 = __importDefault(require("swagger-jsdoc"));
|
|
10
|
-
const crowdin_file_progress_1 = __importDefault(require("../../handlers/integration/crowdin-file-progress"));
|
|
11
|
-
const crowdin_files_1 = __importDefault(require("../../handlers/integration/crowdin-files"));
|
|
12
|
-
const crowdin_update_1 = __importDefault(require("../../handlers/integration/crowdin-update"));
|
|
13
|
-
const integration_data_1 = __importDefault(require("../../handlers/integration/integration-data"));
|
|
14
|
-
const integration_login_1 = __importDefault(require("../../handlers/integration/integration-login"));
|
|
15
|
-
const integration_update_1 = __importDefault(require("../../handlers/integration/integration-update"));
|
|
16
|
-
const settings_1 = __importDefault(require("../../handlers/integration/settings"));
|
|
17
|
-
const settings_save_1 = __importDefault(require("../../handlers/integration/settings-save"));
|
|
18
|
-
const sync_settings_1 = __importDefault(require("../../handlers/integration/sync-settings"));
|
|
19
|
-
const sync_settings_save_1 = __importDefault(require("../../handlers/integration/sync-settings-save"));
|
|
20
10
|
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
21
11
|
const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
|
|
22
12
|
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
|
23
|
-
const
|
|
13
|
+
const crowdin_file_progress_1 = __importDefault(require("../integration/handlers/crowdin-file-progress"));
|
|
14
|
+
const crowdin_files_1 = __importDefault(require("../integration/handlers/crowdin-files"));
|
|
15
|
+
const crowdin_update_1 = __importDefault(require("../integration/handlers/crowdin-update"));
|
|
16
|
+
const integration_data_1 = __importDefault(require("../integration/handlers/integration-data"));
|
|
17
|
+
const integration_login_1 = __importDefault(require("../integration/handlers/integration-login"));
|
|
18
|
+
const integration_update_1 = __importDefault(require("../integration/handlers/integration-update"));
|
|
19
|
+
const settings_1 = __importDefault(require("../integration/handlers/settings"));
|
|
20
|
+
const settings_save_1 = __importDefault(require("../integration/handlers/settings-save"));
|
|
21
|
+
const sync_settings_1 = __importDefault(require("../integration/handlers/sync-settings"));
|
|
22
|
+
const sync_settings_save_1 = __importDefault(require("../integration/handlers/sync-settings-save"));
|
|
23
|
+
const types_1 = require("./types");
|
|
24
24
|
function getApiManifest(config, apiModule) {
|
|
25
25
|
const apiModuleManifest = [];
|
|
26
26
|
if (apiModule.endpoints) {
|
|
@@ -51,60 +51,60 @@ function getDefaultApiEndpointsManifest(config) {
|
|
|
51
51
|
key: 'crowdin-files-api',
|
|
52
52
|
name: 'Get Crowdin Files',
|
|
53
53
|
url: '/crowdin-files',
|
|
54
|
-
method:
|
|
54
|
+
method: types_1.RequestMethods.GET,
|
|
55
55
|
description: 'Get a list of synced files',
|
|
56
56
|
documentationUrl: '/api-docs#tag/Files/operation/crowdin.files',
|
|
57
57
|
}, {
|
|
58
58
|
key: 'crowdin-files-api',
|
|
59
59
|
name: 'File Translation Progress',
|
|
60
60
|
url: '/file-progress',
|
|
61
|
-
method:
|
|
61
|
+
method: types_1.RequestMethods.GET,
|
|
62
62
|
description: 'Get file translation progress',
|
|
63
63
|
documentationUrl: '/api-docs#tag/Files/operation/file.progress',
|
|
64
64
|
}, {
|
|
65
65
|
key: 'integration-files-api',
|
|
66
66
|
name: 'Get Integration Files',
|
|
67
67
|
url: '/integration-files',
|
|
68
|
-
method:
|
|
68
|
+
method: types_1.RequestMethods.GET,
|
|
69
69
|
description: 'Get integration data',
|
|
70
70
|
documentationUrl: '/api-docs#tag/Files/operation/integration.files',
|
|
71
71
|
}, {
|
|
72
72
|
key: 'crowdin-update-api',
|
|
73
73
|
name: 'Update Crowdin',
|
|
74
74
|
url: '/crowdin-update',
|
|
75
|
-
method:
|
|
75
|
+
method: types_1.RequestMethods.POST,
|
|
76
76
|
description: 'Update crowdin data',
|
|
77
77
|
documentationUrl: '/api-docs#tag/Files/operation/crowdin.update',
|
|
78
78
|
}, {
|
|
79
79
|
key: 'integration-update-api',
|
|
80
80
|
name: 'Update Integration',
|
|
81
81
|
url: '/integration-update',
|
|
82
|
-
method:
|
|
82
|
+
method: types_1.RequestMethods.POST,
|
|
83
83
|
description: 'Update integration data',
|
|
84
84
|
documentationUrl: '/api-docs#tag/Files/operation/integration.update',
|
|
85
85
|
}, {
|
|
86
86
|
key: 'settings-api',
|
|
87
87
|
name: 'Get App Settings',
|
|
88
88
|
url: '/settings',
|
|
89
|
-
method:
|
|
89
|
+
method: types_1.RequestMethods.GET,
|
|
90
90
|
documentationUrl: '/api-docs#tag/Settings/operation/settings.get',
|
|
91
91
|
}, {
|
|
92
92
|
key: 'settings-update-api',
|
|
93
93
|
name: 'Update App Settings',
|
|
94
94
|
url: '/settings',
|
|
95
|
-
method:
|
|
95
|
+
method: types_1.RequestMethods.POST,
|
|
96
96
|
documentationUrl: '/api-docs#tag/Settings/operation/settings.update',
|
|
97
97
|
}, {
|
|
98
98
|
key: 'sync-settings-api',
|
|
99
99
|
name: 'Get Sync Settings',
|
|
100
100
|
url: '/sync-settings',
|
|
101
|
-
method:
|
|
101
|
+
method: types_1.RequestMethods.GET,
|
|
102
102
|
documentationUrl: '/api-docs#tag/Settings/operation/sync.settings.get',
|
|
103
103
|
}, {
|
|
104
104
|
key: 'sync-settings-update-api',
|
|
105
105
|
name: 'Update Sync Settings',
|
|
106
106
|
url: '/sync-settings',
|
|
107
|
-
method:
|
|
107
|
+
method: types_1.RequestMethods.POST,
|
|
108
108
|
documentationUrl: '/api-docs#tag/Settings/operation/sync.settings.update',
|
|
109
109
|
});
|
|
110
110
|
if (config.projectIntegration.loginForm) {
|
|
@@ -112,13 +112,13 @@ function getDefaultApiEndpointsManifest(config) {
|
|
|
112
112
|
key: 'login-data',
|
|
113
113
|
name: 'Get Login Fields',
|
|
114
114
|
url: '/login-fields',
|
|
115
|
-
method:
|
|
115
|
+
method: types_1.RequestMethods.GET,
|
|
116
116
|
documentationUrl: '/api-docs#tag/Login/operation/integration.fields',
|
|
117
117
|
}, {
|
|
118
118
|
key: 'login',
|
|
119
119
|
name: 'Login',
|
|
120
120
|
url: '/login',
|
|
121
|
-
method:
|
|
121
|
+
method: types_1.RequestMethods.POST,
|
|
122
122
|
documentationUrl: '/api-docs#tag/Login/operation/integration.login',
|
|
123
123
|
});
|
|
124
124
|
}
|