@crowdin/app-project-module 0.43.0 → 0.44.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 +1 -1
- package/out/index.js +57 -166
- package/out/middlewares/integration-credentials.d.ts +2 -1
- package/out/middlewares/ui-module.d.ts +2 -2
- package/out/middlewares/ui-module.js +4 -0
- package/out/models/index.d.ts +52 -698
- package/out/models/index.js +2 -26
- package/out/modules/context-menu/index.d.ts +6 -0
- package/out/modules/context-menu/index.js +17 -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/{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/{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/{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 +6 -6
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/crowdin-webhook.js +7 -7
- package/out/modules/integration/handlers/integration-data.d.ts +4 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-data.js +4 -4
- 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 +5 -5
- package/out/modules/integration/handlers/integration-update.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-update.js +5 -5
- package/out/modules/integration/handlers/integration-webhook.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/integration-webhook.js +4 -4
- package/out/modules/integration/handlers/job-cancel.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-cancel.js +3 -3
- package/out/modules/integration/handlers/job-info.d.ts +3 -0
- package/out/{handlers/integration → modules/integration/handlers}/job-info.js +3 -3
- package/out/modules/integration/handlers/main.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/main.js +4 -4
- 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 +10 -10
- 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 +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +5 -0
- package/out/{handlers/integration → modules/integration/handlers}/sync-settings-save.js +5 -5
- 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 +113 -0
- package/out/modules/integration/types.d.ts +446 -0
- package/out/modules/integration/types.js +19 -0
- package/out/modules/manifest.d.ts +3 -0
- package/out/{handlers → modules}/manifest.js +16 -10
- 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 +19 -0
- package/out/modules/profile-resources-menu/index.d.ts +6 -0
- package/out/modules/profile-resources-menu/index.js +19 -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 +19 -0
- package/out/modules/project-tools/index.d.ts +6 -0
- package/out/modules/project-tools/index.js +19 -0
- package/out/storage/index.d.ts +3 -2
- package/out/storage/mysql.d.ts +2 -1
- package/out/storage/mysql.js +1 -1
- package/out/storage/postgre.d.ts +2 -1
- package/out/storage/postgre.js +9 -7
- package/out/storage/sqlite.d.ts +2 -1
- package/out/util/api/api.d.ts +2 -2
- package/out/util/api/api.js +10 -10
- package/out/util/connection.d.ts +3 -2
- package/out/util/cron.d.ts +2 -1
- package/out/util/cron.js +6 -6
- package/out/util/defaults.d.ts +5 -2
- package/out/util/defaults.js +13 -3
- package/out/util/file-snapshot.d.ts +2 -1
- package/out/util/file-snapshot.js +5 -5
- package/out/util/files.d.ts +2 -1
- package/out/util/index.d.ts +2 -1
- package/out/util/logger.d.ts +2 -2
- package/out/util/webhooks.d.ts +2 -1
- package/out/util/webhooks.js +5 -5
- 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/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 → modules}/form-data-display.js +0 -0
- /package/out/{handlers → modules}/form-data-save.js +0 -0
- /package/out/{handlers → modules}/install.d.ts +0 -0
- /package/out/{handlers → modules}/install.js +0 -0
- /package/out/{handlers → modules}/subscription-paid.d.ts +0 -0
- /package/out/{handlers → modules}/subscription-paid.js +0 -0
- /package/out/{handlers → modules}/uninstall.d.ts +0 -0
- /package/out/{handlers → modules}/uninstall.js +0 -0
|
@@ -4,6 +4,12 @@ const models_1 = require("../models");
|
|
|
4
4
|
const util_1 = require("../util");
|
|
5
5
|
const api_1 = require("../util/api/api");
|
|
6
6
|
const connection_1 = require("../util/connection");
|
|
7
|
+
function normalizeEnvironments(environments) {
|
|
8
|
+
if (Array.isArray(environments)) {
|
|
9
|
+
return environments;
|
|
10
|
+
}
|
|
11
|
+
return [environments];
|
|
12
|
+
}
|
|
7
13
|
function handle(config) {
|
|
8
14
|
const modules = {};
|
|
9
15
|
if (config.projectIntegration) {
|
|
@@ -14,7 +20,7 @@ function handle(config) {
|
|
|
14
20
|
description: config.description,
|
|
15
21
|
logo: (0, util_1.getLogoUrl)(config.projectIntegration, '/integration'),
|
|
16
22
|
url: '/',
|
|
17
|
-
environments: config.projectIntegration.environments,
|
|
23
|
+
environments: normalizeEnvironments(config.projectIntegration.environments),
|
|
18
24
|
},
|
|
19
25
|
];
|
|
20
26
|
}
|
|
@@ -76,7 +82,7 @@ function handle(config) {
|
|
|
76
82
|
name: config.name,
|
|
77
83
|
logo: (0, util_1.getLogoUrl)(config.customMT, '/mt'),
|
|
78
84
|
url: '/translate',
|
|
79
|
-
environments: config.customMT.environments,
|
|
85
|
+
environments: normalizeEnvironments(config.customMT.environments),
|
|
80
86
|
withContext: !!config.customMT.withContext,
|
|
81
87
|
},
|
|
82
88
|
];
|
|
@@ -98,7 +104,7 @@ function handle(config) {
|
|
|
98
104
|
name: config.profileResourcesMenu.name || config.name,
|
|
99
105
|
url: '/resources/' + (config.profileResourcesMenu.fileName || 'index.html'),
|
|
100
106
|
icon: (0, util_1.getLogoUrl)(config.profileResourcesMenu, '/resources'),
|
|
101
|
-
environments: config.profileResourcesMenu.environments,
|
|
107
|
+
environments: normalizeEnvironments(config.profileResourcesMenu.environments),
|
|
102
108
|
},
|
|
103
109
|
];
|
|
104
110
|
}
|
|
@@ -109,7 +115,7 @@ function handle(config) {
|
|
|
109
115
|
name: config.editorRightPanel.name || config.name,
|
|
110
116
|
url: '/editor-panels/' + (config.editorRightPanel.fileName || 'index.html'),
|
|
111
117
|
modes: config.editorRightPanel.modes,
|
|
112
|
-
environments: config.editorRightPanel.environments,
|
|
118
|
+
environments: normalizeEnvironments(config.editorRightPanel.environments),
|
|
113
119
|
},
|
|
114
120
|
];
|
|
115
121
|
}
|
|
@@ -121,7 +127,7 @@ function handle(config) {
|
|
|
121
127
|
logo: (0, util_1.getLogoUrl)(config.editorThemes, '/editor-themes'),
|
|
122
128
|
styles: config.editorThemes.styles,
|
|
123
129
|
modes: config.editorThemes.modes,
|
|
124
|
-
environments: config.editorThemes.environments,
|
|
130
|
+
environments: normalizeEnvironments(config.editorThemes.environments),
|
|
125
131
|
},
|
|
126
132
|
];
|
|
127
133
|
}
|
|
@@ -131,7 +137,7 @@ function handle(config) {
|
|
|
131
137
|
key: config.identifier + '-project-menu',
|
|
132
138
|
name: config.projectMenu.name || config.name,
|
|
133
139
|
url: '/project-menu/' + (config.projectMenu.fileName || 'index.html'),
|
|
134
|
-
environments: config.projectMenu.environments,
|
|
140
|
+
environments: normalizeEnvironments(config.projectMenu.environments),
|
|
135
141
|
},
|
|
136
142
|
];
|
|
137
143
|
}
|
|
@@ -152,7 +158,7 @@ function handle(config) {
|
|
|
152
158
|
description: config.description,
|
|
153
159
|
logo: (0, util_1.getLogoUrl)(config.projectTools, '/tools'),
|
|
154
160
|
url: '/tools/' + (config.projectTools.fileName || 'index.html'),
|
|
155
|
-
environments: config.projectTools.environments,
|
|
161
|
+
environments: normalizeEnvironments(config.projectTools.environments),
|
|
156
162
|
},
|
|
157
163
|
];
|
|
158
164
|
}
|
|
@@ -173,7 +179,7 @@ function handle(config) {
|
|
|
173
179
|
key: config.identifier + '-modal',
|
|
174
180
|
name: config.modal.name || config.name,
|
|
175
181
|
url: config.modal.url || '/modal/' + (config.modal.fileName || 'index.html'),
|
|
176
|
-
environments: config.modal.environments,
|
|
182
|
+
environments: normalizeEnvironments(config.modal.environments),
|
|
177
183
|
},
|
|
178
184
|
];
|
|
179
185
|
}
|
|
@@ -191,7 +197,7 @@ function handle(config) {
|
|
|
191
197
|
}
|
|
192
198
|
: {})), { url: '/context/' + (config.contextMenu.fileName || 'index.html') }),
|
|
193
199
|
signaturePatterns: config.contextMenu.signaturePatterns,
|
|
194
|
-
environments: config.contextMenu.environments,
|
|
200
|
+
environments: normalizeEnvironments(config.contextMenu.environments),
|
|
195
201
|
},
|
|
196
202
|
];
|
|
197
203
|
}
|
|
@@ -201,7 +207,7 @@ function handle(config) {
|
|
|
201
207
|
if (config.customSpellchecker) {
|
|
202
208
|
const uiModule = config.customSpellchecker.settingsUiModule;
|
|
203
209
|
modules['custom-spellchecker'] = [
|
|
204
|
-
Object.assign({ key: config.identifier + '-spellchecker', name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck', environments: config.customSpellchecker.environments }, (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
|
|
210
|
+
Object.assign({ key: config.identifier + '-spellchecker', name: config.customSpellchecker.name || config.name, description: config.customSpellchecker.description || config.description, listSupportedLanguagesUrl: '/languages', checkSpellingUrl: '/spellcheck', environments: normalizeEnvironments(config.customSpellchecker.environments) }, (uiModule ? { url: '/settings/' + (uiModule.fileName || 'index.html') } : {})),
|
|
205
211
|
];
|
|
206
212
|
}
|
|
207
213
|
const events = {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const defaults_1 = require("../../util/defaults");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
13
|
+
if (((_a = config.modal) === null || _a === void 0 ? void 0 : _a.uiPath) || ((_b = config.modal) === null || _b === void 0 ? void 0 : _b.formSchema)) {
|
|
14
|
+
app.use('/modal', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.modal));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.register = register;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
const defaults_1 = require("../../util/defaults");
|
|
11
|
+
function register({ config, app }) {
|
|
12
|
+
if (!config.organizationMenu) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
16
|
+
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); });
|
|
17
|
+
app.use('/resources', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.organizationMenu));
|
|
18
|
+
}
|
|
19
|
+
exports.register = register;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
const defaults_1 = require("../../util/defaults");
|
|
11
|
+
function register({ config, app }) {
|
|
12
|
+
if (!config.profileResourcesMenu) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
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); });
|
|
16
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
17
|
+
app.use('/resources', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.profileResourcesMenu));
|
|
18
|
+
}
|
|
19
|
+
exports.register = register;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const defaults_1 = require("../../util/defaults");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.projectMenu) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
15
|
+
app.use('/project-menu', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenu));
|
|
16
|
+
}
|
|
17
|
+
exports.register = register;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const defaults_1 = require("../../util/defaults");
|
|
10
|
+
function register({ config, app }) {
|
|
11
|
+
if (!config.projectMenuCrowdsource) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
15
|
+
app.use('/project-menu-crowdsource', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectMenuCrowdsource));
|
|
16
|
+
}
|
|
17
|
+
exports.register = register;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
const defaults_1 = require("../../util/defaults");
|
|
11
|
+
function register({ config, app }) {
|
|
12
|
+
if (!config.projectReports) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
16
|
+
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); });
|
|
17
|
+
app.use('/reports', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectReports));
|
|
18
|
+
}
|
|
19
|
+
exports.register = register;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.register = void 0;
|
|
7
|
+
const render_ui_module_1 = __importDefault(require("../../middlewares/render-ui-module"));
|
|
8
|
+
const ui_module_1 = __importDefault(require("../../middlewares/ui-module"));
|
|
9
|
+
const util_1 = require("../../util");
|
|
10
|
+
const defaults_1 = require("../../util/defaults");
|
|
11
|
+
function register({ config, app }) {
|
|
12
|
+
if (!config.projectTools) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const allowUnauthorized = !(0, defaults_1.isAuthorizedConfig)(config);
|
|
16
|
+
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); });
|
|
17
|
+
app.use('/tools', (0, ui_module_1.default)(config, allowUnauthorized), (0, render_ui_module_1.default)(config.projectTools));
|
|
18
|
+
}
|
|
19
|
+
exports.register = register;
|
package/out/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks, Provider } from '../modules/integration/types';
|
|
2
|
+
import { Config, CrowdinCredentials, UserErrors, UnauthorizedConfig } from '../models';
|
|
2
3
|
import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
|
|
3
4
|
export interface Storage {
|
|
4
5
|
migrate(): Promise<void>;
|
|
@@ -42,5 +43,5 @@ export interface Storage {
|
|
|
42
43
|
getActiveJobs(params: GetActiveJobsParams): Promise<Job[] | undefined>;
|
|
43
44
|
deleteFinishedJobs(): Promise<void>;
|
|
44
45
|
}
|
|
45
|
-
export declare function initialize(config: Config): Promise<void>;
|
|
46
|
+
export declare function initialize(config: Config | UnauthorizedConfig): Promise<void>;
|
|
46
47
|
export declare function getStorage(): Storage;
|
package/out/storage/mysql.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
|
-
import { CrowdinCredentials,
|
|
2
|
+
import { CrowdinCredentials, UserErrors } from '../models';
|
|
3
3
|
import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
|
|
4
|
+
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
4
5
|
export interface MySQLStorageConfig {
|
|
5
6
|
uri?: string;
|
|
6
7
|
host?: string;
|
package/out/storage/mysql.js
CHANGED
|
@@ -497,7 +497,7 @@ class MySQLStorage {
|
|
|
497
497
|
const id = (0, uuid_1.v4)();
|
|
498
498
|
yield this.dbPromise;
|
|
499
499
|
yield this.executeQuery((connection) => connection.execute(`
|
|
500
|
-
INSERT INTO
|
|
500
|
+
INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, created_at)
|
|
501
501
|
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
502
502
|
`, [id, integrationId, crowdinId, type, payload, title, Date.now().toString()]));
|
|
503
503
|
return id;
|
package/out/storage/postgre.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Client } from 'pg';
|
|
2
2
|
import { Storage } from '.';
|
|
3
|
-
import { CrowdinCredentials,
|
|
3
|
+
import { CrowdinCredentials, UserErrors } from '../models';
|
|
4
4
|
import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
|
|
5
|
+
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
5
6
|
export interface PostgreStorageConfig {
|
|
6
7
|
host?: string;
|
|
7
8
|
connectionString?: string;
|
package/out/storage/postgre.js
CHANGED
|
@@ -167,10 +167,9 @@ class PostgreStorage {
|
|
|
167
167
|
integration_id varchar not null,
|
|
168
168
|
crowdin_id varchar not null,
|
|
169
169
|
type varchar not null,
|
|
170
|
-
payload varchar null,
|
|
171
170
|
title varchar null,
|
|
172
|
-
progress int
|
|
173
|
-
status varchar
|
|
171
|
+
progress int default 0,
|
|
172
|
+
status varchar default '${job_1.JobStatus.CREATED}',
|
|
174
173
|
payload varchar null,
|
|
175
174
|
info varchar null,
|
|
176
175
|
data varchar null,
|
|
@@ -502,7 +501,10 @@ class PostgreStorage {
|
|
|
502
501
|
updateIntegrationConfig(integrationId, config) {
|
|
503
502
|
return __awaiter(this, void 0, void 0, function* () {
|
|
504
503
|
yield this.dbPromise;
|
|
505
|
-
yield this.executeQuery((client) => client.query('UPDATE integration_settings SET config = $1 WHERE
|
|
504
|
+
yield this.executeQuery((client) => client.query('UPDATE integration_settings SET config = $1 WHERE integration_id = $2', [
|
|
505
|
+
config,
|
|
506
|
+
integrationId,
|
|
507
|
+
]));
|
|
506
508
|
});
|
|
507
509
|
}
|
|
508
510
|
createJob({ integrationId, crowdinId, type, payload, title }) {
|
|
@@ -543,7 +545,7 @@ class PostgreStorage {
|
|
|
543
545
|
}
|
|
544
546
|
if (info) {
|
|
545
547
|
updateFields.push('info = $' + updateParams.length.toString());
|
|
546
|
-
updateParams.push(
|
|
548
|
+
updateParams.push(info);
|
|
547
549
|
}
|
|
548
550
|
updateParams.push(id);
|
|
549
551
|
yield this.dbPromise;
|
|
@@ -561,7 +563,7 @@ class PostgreStorage {
|
|
|
561
563
|
const res = yield client.query(`
|
|
562
564
|
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status,
|
|
563
565
|
title, info, payload, data, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
564
|
-
FROM
|
|
566
|
+
FROM job
|
|
565
567
|
WHERE id = $1
|
|
566
568
|
`, [id]);
|
|
567
569
|
return res === null || res === void 0 ? void 0 : res.rows[0];
|
|
@@ -575,7 +577,7 @@ class PostgreStorage {
|
|
|
575
577
|
const res = yield client.query(`
|
|
576
578
|
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status,
|
|
577
579
|
title, info, payload, data, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
578
|
-
FROM
|
|
580
|
+
FROM job
|
|
579
581
|
WHERE integration_id = $1 AND crowdin_id = $2 AND finished_at is NULL
|
|
580
582
|
`, [integrationId, crowdinId]);
|
|
581
583
|
return (res === null || res === void 0 ? void 0 : res.rows) || [];
|
package/out/storage/sqlite.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
|
-
import { CrowdinCredentials,
|
|
2
|
+
import { CrowdinCredentials, UserErrors } from '../models';
|
|
3
3
|
import { CreateJobParams, GetActiveJobsParams, GetJobParams, Job, UpdateJobParams } from '../models/job';
|
|
4
|
+
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
4
5
|
export interface SQLiteStorageConfig {
|
|
5
6
|
dbFolder: string;
|
|
6
7
|
}
|
package/out/util/api/api.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Express } from 'express';
|
|
2
|
-
import { ApiEndpoints, ApiModule, Config, CrowdinClientRequest, CrowdinContextInfo } from '../../models';
|
|
3
|
-
export declare function getApiManifest(config: Config, apiModule: ApiModule): ApiEndpoints[];
|
|
2
|
+
import { ApiEndpoints, ApiModule, Config, CrowdinClientRequest, CrowdinContextInfo, UnauthorizedConfig } from '../../models';
|
|
3
|
+
export declare function getApiManifest(config: Config | UnauthorizedConfig, apiModule: ApiModule): ApiEndpoints[];
|
|
4
4
|
export declare function updateCrowdinContext(req: CrowdinClientRequest, context: CrowdinContextInfo): CrowdinContextInfo;
|
|
5
5
|
export declare function addDefaultApiEndpoints(app: Express, config: Config): void;
|
|
6
6
|
export declare function addSwagerApiDocumentation(app: Express, config: Config): void;
|
package/out/util/api/api.js
CHANGED
|
@@ -7,16 +7,16 @@ 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("../../
|
|
11
|
-
const crowdin_files_1 = __importDefault(require("../../
|
|
12
|
-
const crowdin_update_1 = __importDefault(require("../../
|
|
13
|
-
const integration_data_1 = __importDefault(require("../../
|
|
14
|
-
const integration_login_1 = __importDefault(require("../../
|
|
15
|
-
const integration_update_1 = __importDefault(require("../../
|
|
16
|
-
const settings_1 = __importDefault(require("../../
|
|
17
|
-
const settings_save_1 = __importDefault(require("../../
|
|
18
|
-
const sync_settings_1 = __importDefault(require("../../
|
|
19
|
-
const sync_settings_save_1 = __importDefault(require("../../
|
|
10
|
+
const crowdin_file_progress_1 = __importDefault(require("../../modules/integration/handlers/crowdin-file-progress"));
|
|
11
|
+
const crowdin_files_1 = __importDefault(require("../../modules/integration/handlers/crowdin-files"));
|
|
12
|
+
const crowdin_update_1 = __importDefault(require("../../modules/integration/handlers/crowdin-update"));
|
|
13
|
+
const integration_data_1 = __importDefault(require("../../modules/integration/handlers/integration-data"));
|
|
14
|
+
const integration_login_1 = __importDefault(require("../../modules/integration/handlers/integration-login"));
|
|
15
|
+
const integration_update_1 = __importDefault(require("../../modules/integration/handlers/integration-update"));
|
|
16
|
+
const settings_1 = __importDefault(require("../../modules/integration/handlers/settings"));
|
|
17
|
+
const settings_save_1 = __importDefault(require("../../modules/integration/handlers/settings-save"));
|
|
18
|
+
const sync_settings_1 = __importDefault(require("../../modules/integration/handlers/sync-settings"));
|
|
19
|
+
const sync_settings_save_1 = __importDefault(require("../../modules/integration/handlers/sync-settings-save"));
|
|
20
20
|
const crowdin_client_1 = __importDefault(require("../../middlewares/crowdin-client"));
|
|
21
21
|
const integration_credentials_1 = __importDefault(require("../../middlewares/integration-credentials"));
|
|
22
22
|
const json_response_1 = __importDefault(require("../../middlewares/json-response"));
|
package/out/util/connection.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
-
import { AccountType, Config, CrowdinContextInfo, CrowdinCredentials,
|
|
2
|
+
import { AccountType, Config, CrowdinContextInfo, CrowdinCredentials, SubscriptionInfo, UnauthorizedConfig } from '../models';
|
|
3
|
+
import { IntegrationCredentials, IntegrationLogic } from '../modules/integration/types';
|
|
3
4
|
export declare function prepareCrowdinClient({ config, credentials, autoRenew, context, }: {
|
|
4
5
|
config: Config;
|
|
5
6
|
credentials: CrowdinCredentials;
|
|
@@ -11,7 +12,7 @@ export declare function prepareCrowdinClient({ config, credentials, autoRenew, c
|
|
|
11
12
|
}>;
|
|
12
13
|
export declare function prepareIntegrationCredentials(config: Config, integration: IntegrationLogic, integrationCredentials: IntegrationCredentials): Promise<any>;
|
|
13
14
|
export declare function clearCache(organization: string): void;
|
|
14
|
-
export declare function isAppFree(config: Config): boolean;
|
|
15
|
+
export declare function isAppFree(config: Config | UnauthorizedConfig): boolean;
|
|
15
16
|
export declare function checkSubscription({ config, token, organization, accountType, }: {
|
|
16
17
|
config: Config;
|
|
17
18
|
token: string;
|
package/out/util/cron.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
-
import { Config
|
|
2
|
+
import { Config } from '../models';
|
|
3
|
+
import { CronJob, IntegrationLogic, IntegrationRequest, Provider, UpdateIntegrationRequest } from '../modules/integration/types';
|
|
3
4
|
export declare function runJob(config: Config, integration: IntegrationLogic, job: CronJob): Promise<void>;
|
|
4
5
|
export declare function filesCron(config: Config, integration: IntegrationLogic, period: string): Promise<void>;
|
|
5
6
|
export declare function skipFoldersFromIntegrationRequest(config: Config, integration: IntegrationLogic, projectId: number, crowdinFiles: UpdateIntegrationRequest, crowdinClient: Crowdin): Promise<UpdateIntegrationRequest>;
|
package/out/util/cron.js
CHANGED
|
@@ -34,7 +34,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.removeFinishedJobs = exports.createOrUpdateSyncSettings = exports.skipFoldersFromIntegrationRequest = exports.filesCron = exports.runJob = void 0;
|
|
36
36
|
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
37
|
-
const models_1 = require("../models");
|
|
38
37
|
const job_1 = require("../models/job");
|
|
39
38
|
const storage_1 = require("../storage");
|
|
40
39
|
const connection_1 = require("./connection");
|
|
@@ -42,6 +41,7 @@ const defaults_1 = require("./defaults");
|
|
|
42
41
|
const file_snapshot_1 = require("./file-snapshot");
|
|
43
42
|
const logger_1 = require("./logger");
|
|
44
43
|
const job_2 = require("./job");
|
|
44
|
+
const types_1 = require("../modules/integration/types");
|
|
45
45
|
function runJob(config, integration, job) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
47
|
(0, logger_1.log)(`Starting cron job with expression [${job.expression}]`);
|
|
@@ -150,7 +150,7 @@ function filesCron(config, integration, period) {
|
|
|
150
150
|
if (integration.webhooks) {
|
|
151
151
|
const webhooks = yield (0, storage_1.getStorage)().getAllWebhooks(syncSettings.integrationId, syncSettings.crowdinId, syncSettings.provider);
|
|
152
152
|
const webhooksFileIds = (webhooks || []).map((webhook) => webhook.fileId);
|
|
153
|
-
if (syncSettings.provider ===
|
|
153
|
+
if (syncSettings.provider === types_1.Provider.CROWDIN) {
|
|
154
154
|
files = webhooksFileIds.reduce((acc, fileId) => {
|
|
155
155
|
if (files[fileId]) {
|
|
156
156
|
acc[fileId] = files[fileId];
|
|
@@ -163,11 +163,11 @@ function filesCron(config, integration, period) {
|
|
|
163
163
|
}
|
|
164
164
|
yield (0, storage_1.getStorage)().deleteWebhooks(webhooksFileIds, syncSettings.integrationId, syncSettings.crowdinId, syncSettings.provider);
|
|
165
165
|
}
|
|
166
|
-
if (syncSettings.provider ===
|
|
166
|
+
if (syncSettings.provider === types_1.Provider.CROWDIN) {
|
|
167
167
|
const crowdinFiles = yield skipFoldersFromIntegrationRequest(config, integration, projectId, Object.assign(Object.assign({}, files), newFiles), crowdinClient);
|
|
168
|
-
const onlyTranslated = +intConfig.condition ===
|
|
169
|
-
const onlyApproved = +intConfig.condition ===
|
|
170
|
-
const all = +intConfig.condition ===
|
|
168
|
+
const onlyTranslated = +intConfig.condition === types_1.SyncCondition.TRANSLATED;
|
|
169
|
+
const onlyApproved = +intConfig.condition === types_1.SyncCondition.APPROVED;
|
|
170
|
+
const all = +intConfig.condition === types_1.SyncCondition.ALL || intConfig.condition === undefined;
|
|
171
171
|
const filesToProcess = all
|
|
172
172
|
? crowdinFiles
|
|
173
173
|
: yield getOnlyTranslatedOrApprovedFiles(config, projectId, crowdinFiles, crowdinClient, onlyApproved, onlyTranslated);
|
package/out/util/defaults.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import Crowdin, { SourceFilesModel } from '@crowdin/crowdin-api-client';
|
|
2
|
-
import { ClientConfig, Config,
|
|
2
|
+
import { ClientConfig, Config, UnauthorizedConfig } from '../models';
|
|
3
|
+
import { IntegrationLogic } from '../modules/integration/types';
|
|
4
|
+
import { FileProcessLogic } from '../modules/file-processing/types';
|
|
3
5
|
export declare function getRootFolder(config: Config, integration: IntegrationLogic, client: Crowdin, projectId: number): Promise<SourceFilesModel.Directory | undefined>;
|
|
4
6
|
export declare function getOauthRoute(integration: IntegrationLogic): string;
|
|
5
7
|
export declare function applyIntegrationModuleDefaults(config: Config, integration: IntegrationLogic): void;
|
|
6
8
|
export declare function applyFileProcessorsModuleDefaults(config: Config, fileModule: FileProcessLogic): void;
|
|
7
9
|
export declare function constructOauthUrl(config: Config, integration: IntegrationLogic): string;
|
|
8
|
-
export declare function
|
|
10
|
+
export declare function isAuthorizedConfig(config: Config | UnauthorizedConfig): config is Config;
|
|
11
|
+
export declare function convertClientConfig(clientConfig: ClientConfig): Config | UnauthorizedConfig;
|
package/out/util/defaults.js
CHANGED
|
@@ -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
|
-
exports.convertClientConfig = exports.constructOauthUrl = exports.applyFileProcessorsModuleDefaults = exports.applyIntegrationModuleDefaults = exports.getOauthRoute = exports.getRootFolder = void 0;
|
|
35
|
+
exports.convertClientConfig = exports.isAuthorizedConfig = exports.constructOauthUrl = exports.applyFileProcessorsModuleDefaults = exports.applyIntegrationModuleDefaults = exports.getOauthRoute = exports.getRootFolder = void 0;
|
|
36
36
|
const client_s3_1 = require("@aws-sdk/client-s3");
|
|
37
37
|
const s3_request_presigner_1 = require("@aws-sdk/s3-request-presigner");
|
|
38
38
|
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
39
39
|
const path_1 = require("path");
|
|
40
|
+
const models_1 = require("../models");
|
|
40
41
|
function getRootFolder(config, integration, client, projectId) {
|
|
41
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
43
|
if (!integration.withRootFolder) {
|
|
@@ -270,14 +271,23 @@ function constructOauthUrl(config, integration) {
|
|
|
270
271
|
return url;
|
|
271
272
|
}
|
|
272
273
|
exports.constructOauthUrl = constructOauthUrl;
|
|
274
|
+
function isAuthorizedConfig(config) {
|
|
275
|
+
return !!config.clientId && !!config.clientSecret && config.authenticationType !== models_1.AuthenticationType.NONE;
|
|
276
|
+
}
|
|
277
|
+
exports.isAuthorizedConfig = isAuthorizedConfig;
|
|
273
278
|
function convertClientConfig(clientConfig) {
|
|
274
279
|
const baseUrl = clientConfig.baseUrl || process.env.URL;
|
|
275
280
|
const clientId = clientConfig.clientId || process.env.CROWDIN_CLIENT_ID;
|
|
276
281
|
const clientSecret = clientConfig.clientSecret || process.env.CROWDIN_CLIENT_SECRET;
|
|
277
282
|
const port = clientConfig.port || process.env.PORT || 3000;
|
|
278
283
|
const { region = process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION, tmpBucketName = process.env.AWS_TMP_BUCKET_NAME, } = clientConfig.awsConfig || {};
|
|
279
|
-
if (!baseUrl
|
|
280
|
-
throw new Error('
|
|
284
|
+
if (!baseUrl) {
|
|
285
|
+
throw new Error('Missing baseUrl parameter');
|
|
286
|
+
}
|
|
287
|
+
if (clientConfig.authenticationType !== models_1.AuthenticationType.NONE) {
|
|
288
|
+
if (!clientId && !clientSecret) {
|
|
289
|
+
throw new Error('Missing [clientId, clientSecret] parameters');
|
|
290
|
+
}
|
|
281
291
|
}
|
|
282
292
|
return Object.assign(Object.assign({}, clientConfig), { baseUrl: baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl, clientId,
|
|
283
293
|
clientSecret, awsConfig: {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
-
import { Config
|
|
2
|
+
import { Config } from '../models';
|
|
3
|
+
import { GetAllNewFilesArgs, IntegrationLogic, IntegrationRequest, Provider, TreeItem, UpdateIntegrationRequest } from '../modules/integration/types';
|
|
3
4
|
export declare function getFileDiff(currentFiles: TreeItem[], savedFiles: TreeItem[]): TreeItem[];
|
|
4
5
|
export declare function getAllNewFiles(args: GetAllNewFilesArgs): Promise<TreeItem[] | UpdateIntegrationRequest>;
|
|
5
6
|
export declare function getCrowdinSnapshot(config: Config, integration: IntegrationLogic, crowdinApiClient: Crowdin, projectId: number, integrationSettings: any): Promise<TreeItem[]>;
|
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createOrUpdateFileSnapshot = exports.getIntegrationSnapshot = exports.getCrowdinSnapshot = exports.getAllNewFiles = exports.getFileDiff = void 0;
|
|
13
|
-
const models_1 = require("../models");
|
|
14
13
|
const storage_1 = require("../storage");
|
|
15
14
|
const defaults_1 = require("./defaults");
|
|
16
15
|
const index_1 = require("./index");
|
|
17
16
|
const files_1 = require("./files");
|
|
17
|
+
const types_1 = require("../modules/integration/types");
|
|
18
18
|
function getFileDiff(currentFiles, savedFiles) {
|
|
19
19
|
return currentFiles.filter((x) => !savedFiles.some((x2) => x2.id === x.id));
|
|
20
20
|
}
|
|
@@ -25,7 +25,7 @@ function getAllNewFiles(args) {
|
|
|
25
25
|
let currentFileSnapshot = [];
|
|
26
26
|
const fileSnapshotData = yield (0, storage_1.getStorage)().getFilesSnapshot(integrationId, crowdinId, syncSettings.provider);
|
|
27
27
|
const snapshotFiles = (fileSnapshotData === null || fileSnapshotData === void 0 ? void 0 : fileSnapshotData.files) ? JSON.parse(fileSnapshotData.files) : [];
|
|
28
|
-
if (syncSettings.provider ===
|
|
28
|
+
if (syncSettings.provider === types_1.Provider.CROWDIN) {
|
|
29
29
|
currentFileSnapshot = yield getCrowdinSnapshot(config, integration, crowdinApiClient, projectId, integrationSettings);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
@@ -34,7 +34,7 @@ function getAllNewFiles(args) {
|
|
|
34
34
|
const difference = getFileDiff(currentFileSnapshot, snapshotFiles);
|
|
35
35
|
const onlyFiles = difference.filter((file) => 'type' in file);
|
|
36
36
|
const synFiles = JSON.parse(syncSettings.files);
|
|
37
|
-
if (syncSettings.provider ===
|
|
37
|
+
if (syncSettings.provider === types_1.Provider.INTEGRATION) {
|
|
38
38
|
if (integrationSettings[`new-${syncSettings.provider}-files`]) {
|
|
39
39
|
return onlyFiles;
|
|
40
40
|
}
|
|
@@ -133,10 +133,10 @@ function createOrUpdateFileSnapshot(config, integration, req, provider) {
|
|
|
133
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
134
|
let files = [];
|
|
135
135
|
const existingSnapshot = yield (0, storage_1.getStorage)().getFilesSnapshot(req.crowdinContext.clientId, req.crowdinContext.crowdinId, provider);
|
|
136
|
-
if (provider ===
|
|
136
|
+
if (provider === types_1.Provider.CROWDIN) {
|
|
137
137
|
files = yield getCrowdinSnapshot(config, integration, req.crowdinApiClient, req.crowdinContext.jwtPayload.context.project_id, req.integrationSettings);
|
|
138
138
|
}
|
|
139
|
-
if (provider ===
|
|
139
|
+
if (provider === types_1.Provider.INTEGRATION) {
|
|
140
140
|
files = yield getIntegrationSnapshot(integration, req.integrationCredentials, req.integrationSettings);
|
|
141
141
|
}
|
|
142
142
|
if (existingSnapshot) {
|