@crowdin/app-project-module 0.17.9 → 0.18.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/README.md +27 -0
- package/out/handlers/install.js +3 -3
- package/out/handlers/integration-login.js +3 -3
- package/out/handlers/integration-logout.js +1 -1
- package/out/handlers/settings-save.js +1 -1
- package/out/handlers/sync-settings-save.js +3 -3
- package/out/handlers/sync-settings.js +1 -1
- package/out/handlers/uninstall.js +1 -1
- package/out/index.js +9 -9
- package/out/middlewares/crowdin-client.js +1 -1
- package/out/middlewares/integration-credentials.js +1 -1
- package/out/middlewares/ui-module.js +1 -1
- package/out/models/index.d.ts +6 -1
- package/out/storage/index.d.ts +26 -22
- package/out/storage/index.js +29 -308
- package/out/storage/postgre.d.ts +42 -0
- package/out/storage/postgre.js +261 -0
- package/out/storage/sqlite.d.ts +37 -0
- package/out/storage/sqlite.js +297 -0
- package/out/util/connection.js +2 -2
- package/out/util/cron.js +5 -5
- package/out/util/index.js +1 -1
- package/package.json +3 -1
package/out/util/cron.js
CHANGED
|
@@ -37,7 +37,7 @@ const defaults_1 = require("./defaults");
|
|
|
37
37
|
function runJob(config, integration, job) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
39
|
(0, _1.log)(`Starting cron job with expression [${job.expression}]`, config.logger);
|
|
40
|
-
const crowdinCredentialsList = yield (0, storage_1.
|
|
40
|
+
const crowdinCredentialsList = yield (0, storage_1.getStorage)().getAllCrowdinCredentials();
|
|
41
41
|
yield Promise.all(crowdinCredentialsList.map((crowdinCredentials) => __awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
const { client: crowdinClient, token } = yield (0, connection_1.prepareCrowdinClient)(config, crowdinCredentials);
|
|
43
43
|
const { expired } = yield (0, connection_1.checkSubscription)(config, token, crowdinCredentials.id, crowdinCredentials.type);
|
|
@@ -45,7 +45,7 @@ function runJob(config, integration, job) {
|
|
|
45
45
|
(0, _1.log)(`Subscription expired. Skipping job [${job.expression}] for organization ${crowdinCredentials.id}`);
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
const integrationCredentialsList = yield (0, storage_1.
|
|
48
|
+
const integrationCredentialsList = yield (0, storage_1.getStorage)().getAllIntegrationCredentials(crowdinCredentials.id);
|
|
49
49
|
yield Promise.all(integrationCredentialsList.map((integrationCredentials) => __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
const projectId = crowdinAppFunctions.getProjectId(integrationCredentials.id);
|
|
51
51
|
const apiCredentials = yield (0, connection_1.prepareIntegrationCredentials)(config, integration, integrationCredentials);
|
|
@@ -65,11 +65,11 @@ exports.runJob = runJob;
|
|
|
65
65
|
function filesCron(config, integration, period) {
|
|
66
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
(0, _1.log)(`Starting files cron job with period [${period}]`, config.logger);
|
|
68
|
-
const syncSettingsList = yield (0, storage_1.
|
|
68
|
+
const syncSettingsList = yield (0, storage_1.getStorage)().getAllSyncSettingsByType('schedule');
|
|
69
69
|
yield Promise.all(syncSettingsList.map((syncSettings) => __awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
const files = JSON.parse(syncSettings.files);
|
|
71
|
-
const crowdinCredentials = yield (0, storage_1.
|
|
72
|
-
const integrationCredentials = yield (0, storage_1.
|
|
71
|
+
const crowdinCredentials = yield (0, storage_1.getStorage)().getCrowdinCredentials(syncSettings.crowdinId);
|
|
72
|
+
const integrationCredentials = yield (0, storage_1.getStorage)().getIntegrationCredentials(syncSettings.integrationId);
|
|
73
73
|
if (crowdinCredentials && integrationCredentials) {
|
|
74
74
|
const intConfig = integrationCredentials.config
|
|
75
75
|
? JSON.parse(integrationCredentials.config)
|
package/out/util/index.js
CHANGED
|
@@ -72,7 +72,7 @@ function handleError(err, req, res) {
|
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
const code = err.code ? err.code : 500;
|
|
74
74
|
if (code === 401 && isCrowdinClientRequest(req)) {
|
|
75
|
-
yield (0, storage_1.
|
|
75
|
+
yield (0, storage_1.getStorage)().deleteIntegrationCredentials(req.crowdinContext.clientId);
|
|
76
76
|
}
|
|
77
77
|
if (code === 401 && req.path === '/') {
|
|
78
78
|
res.redirect('/');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdin/app-project-module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
|
|
5
5
|
"main": "out/index.js",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -13,10 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"@crowdin/crowdin-apps-functions": "0.1.4",
|
|
16
|
+
"@types/pg": "^8.6.5",
|
|
16
17
|
"crypto-js": "^4.0.0",
|
|
17
18
|
"express": "4.17.1",
|
|
18
19
|
"express-handlebars": "^5.3.4",
|
|
19
20
|
"node-cron": "^3.0.0",
|
|
21
|
+
"pg": "^8.8.0",
|
|
20
22
|
"sqlite3": "^5.0.2",
|
|
21
23
|
"uuid": "^8.3.2"
|
|
22
24
|
},
|