@crowdin/app-project-module 0.17.8 → 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 +30 -3
- package/out/handlers/custom-file-format/process.js +7 -3
- 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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Storage } from '.';
|
|
2
|
+
import { CrowdinCredentials, IntegrationCredentials, IntegrationSyncSettings } from '../models';
|
|
3
|
+
export interface SQLiteStorageConfig {
|
|
4
|
+
dbFolder: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class SQLiteStorage implements Storage<SQLiteStorageConfig> {
|
|
7
|
+
private db?;
|
|
8
|
+
private _res?;
|
|
9
|
+
private _rej?;
|
|
10
|
+
private dbPromise;
|
|
11
|
+
private _run;
|
|
12
|
+
private run;
|
|
13
|
+
private get;
|
|
14
|
+
private each;
|
|
15
|
+
private migrate;
|
|
16
|
+
connect(config: SQLiteStorageConfig): Promise<void>;
|
|
17
|
+
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
18
|
+
updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
19
|
+
getCrowdinCredentials(id: string): Promise<CrowdinCredentials | undefined>;
|
|
20
|
+
getAllCrowdinCredentials(): Promise<CrowdinCredentials[]>;
|
|
21
|
+
deleteCrowdinCredentials(id: string): Promise<void>;
|
|
22
|
+
saveIntegrationCredentials(id: string, credentials: any, crowdinId: string): Promise<void>;
|
|
23
|
+
updateIntegrationCredentials(id: string, credentials: any): Promise<void>;
|
|
24
|
+
updateIntegrationConfig(id: string, config: any): Promise<void>;
|
|
25
|
+
getIntegrationCredentials(id: string): Promise<IntegrationCredentials | undefined>;
|
|
26
|
+
getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
|
|
27
|
+
deleteIntegrationCredentials(id: string): Promise<void>;
|
|
28
|
+
saveMetadata(id: string, metadata: any): Promise<void>;
|
|
29
|
+
updateMetadata(id: string, metadata: any): Promise<void>;
|
|
30
|
+
getMetadata(id: string): Promise<any>;
|
|
31
|
+
deleteMetadata(id: string): Promise<void>;
|
|
32
|
+
getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
|
|
33
|
+
getAllSyncSettingsByType(type: string): Promise<IntegrationSyncSettings[]>;
|
|
34
|
+
saveSyncSettings(files: any, integrationId: string, crowdinId: string, type: string, provider: string): Promise<void>;
|
|
35
|
+
updateSyncSettings(files: any, integrationId: string, crowdinId: string, type: string, provider: string): Promise<void>;
|
|
36
|
+
getSyncSettings(integrationId: string, crowdinId: string, type: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/camelcase */
|
|
3
|
+
/* eslint-disable @typescript-eslint/ban-ts-ignore */
|
|
4
|
+
/* eslint-disable no-unused-expressions */
|
|
5
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.SQLiteStorage = void 0;
|
|
19
|
+
const path_1 = require("path");
|
|
20
|
+
const sqlite3_1 = __importDefault(require("sqlite3"));
|
|
21
|
+
class SQLiteStorage {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.dbPromise = new Promise((res, rej) => {
|
|
24
|
+
this._res = res;
|
|
25
|
+
this._rej = rej;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
_run(query, params) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
yield new Promise((res, rej) => {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = this.db) === null || _a === void 0 ? void 0 : _a.run(query, params, err => {
|
|
33
|
+
if (err) {
|
|
34
|
+
rej(err);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
res();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
run(query, params) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
yield this.dbPromise;
|
|
46
|
+
yield new Promise((res, rej) => {
|
|
47
|
+
var _a;
|
|
48
|
+
(_a = this.db) === null || _a === void 0 ? void 0 : _a.run(query, params, err => {
|
|
49
|
+
if (err) {
|
|
50
|
+
rej(err);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
res();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
get(query, params) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
yield this.dbPromise;
|
|
62
|
+
return new Promise((res, rej) => {
|
|
63
|
+
var _a;
|
|
64
|
+
(_a = this.db) === null || _a === void 0 ? void 0 : _a.get(query, params, (err, row) => {
|
|
65
|
+
if (err) {
|
|
66
|
+
rej(err);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
res(row);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
each(query, params) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
yield this.dbPromise;
|
|
78
|
+
return new Promise((res, rej) => {
|
|
79
|
+
var _a;
|
|
80
|
+
const result = [];
|
|
81
|
+
(_a = this.db) === null || _a === void 0 ? void 0 : _a.each(query, params, (err, row) => {
|
|
82
|
+
if (err) {
|
|
83
|
+
rej(err);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
result.push(row);
|
|
87
|
+
}
|
|
88
|
+
}, () => res(result));
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
migrate() {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
const newColumns = ['app_secret', 'domain', 'user_id', 'organization_id', 'base_url'];
|
|
95
|
+
const crowdinCredentialsInfo = yield this.each('PRAGMA table_info(crowdin_credentials);', []);
|
|
96
|
+
//@ts-ignore
|
|
97
|
+
crowdinCredentialsInfo.map((columnInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const index = newColumns.indexOf(columnInfo.name);
|
|
99
|
+
if (~index) {
|
|
100
|
+
newColumns.splice(index, 1);
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
for (const column of newColumns) {
|
|
104
|
+
yield this.run(`ALTER TABLE crowdin_credentials ADD COLUMN ${column} varchar null;`, []);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
connect(config) {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
let _connection_res;
|
|
111
|
+
let _connection_rej;
|
|
112
|
+
const connectionPromise = new Promise((res, rej) => {
|
|
113
|
+
_connection_res = res;
|
|
114
|
+
_connection_rej = rej;
|
|
115
|
+
});
|
|
116
|
+
this.db = new sqlite3_1.default.Database((0, path_1.join)(config.dbFolder, 'app.sqlite'), error => {
|
|
117
|
+
if (error) {
|
|
118
|
+
_connection_rej(error);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
_connection_res();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
yield connectionPromise;
|
|
126
|
+
yield this._run(`
|
|
127
|
+
create table if not exists crowdin_credentials
|
|
128
|
+
(
|
|
129
|
+
id varchar not null primary key,
|
|
130
|
+
app_secret varchar null,
|
|
131
|
+
domain varchar null,
|
|
132
|
+
user_id varchar null,
|
|
133
|
+
organization_id varchar null,
|
|
134
|
+
base_url varchar null,
|
|
135
|
+
access_token varchar not null,
|
|
136
|
+
refresh_token varchar not null,
|
|
137
|
+
expire varchar not null,
|
|
138
|
+
type varchar not null
|
|
139
|
+
);
|
|
140
|
+
`, []);
|
|
141
|
+
yield this._run(`
|
|
142
|
+
create table if not exists integration_credentials
|
|
143
|
+
(
|
|
144
|
+
id varchar not null primary key,
|
|
145
|
+
credentials varchar not null,
|
|
146
|
+
config varchar null,
|
|
147
|
+
crowdin_id varchar not null
|
|
148
|
+
);
|
|
149
|
+
`, []);
|
|
150
|
+
yield this._run(`
|
|
151
|
+
create table if not exists sync_settings
|
|
152
|
+
(
|
|
153
|
+
id integer not null primary key autoincrement,
|
|
154
|
+
files varchar null,
|
|
155
|
+
integration_id varchar not null,
|
|
156
|
+
crowdin_id varchar not null,
|
|
157
|
+
type varchar not null,
|
|
158
|
+
provider varchar not null
|
|
159
|
+
);
|
|
160
|
+
`, []);
|
|
161
|
+
yield this._run(`
|
|
162
|
+
create table if not exists app_metadata
|
|
163
|
+
(
|
|
164
|
+
id varchar not null primary key,
|
|
165
|
+
data varchar null
|
|
166
|
+
);
|
|
167
|
+
`, []);
|
|
168
|
+
this._res && this._res();
|
|
169
|
+
// TODO: temporary code
|
|
170
|
+
yield this.migrate();
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
this._rej && this._rej(e);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
saveCrowdinCredentials(credentials) {
|
|
178
|
+
return this.run('INSERT INTO crowdin_credentials(id, app_secret, domain, user_id, organization_id, base_url, access_token, refresh_token, expire, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [
|
|
179
|
+
credentials.id,
|
|
180
|
+
credentials.appSecret,
|
|
181
|
+
credentials.domain,
|
|
182
|
+
credentials.userId,
|
|
183
|
+
credentials.organizationId,
|
|
184
|
+
credentials.baseUrl,
|
|
185
|
+
credentials.accessToken,
|
|
186
|
+
credentials.refreshToken,
|
|
187
|
+
credentials.expire,
|
|
188
|
+
credentials.type,
|
|
189
|
+
]);
|
|
190
|
+
}
|
|
191
|
+
updateCrowdinCredentials(credentials) {
|
|
192
|
+
return this.run('UPDATE crowdin_credentials SET app_secret = ?, domain = ?, user_id = ?, organization_id = ?, base_url = ?, access_token = ?, refresh_token = ?, expire = ? WHERE id = ?', [
|
|
193
|
+
credentials.appSecret,
|
|
194
|
+
credentials.domain,
|
|
195
|
+
credentials.userId,
|
|
196
|
+
credentials.organizationId,
|
|
197
|
+
credentials.baseUrl,
|
|
198
|
+
credentials.accessToken,
|
|
199
|
+
credentials.refreshToken,
|
|
200
|
+
credentials.expire,
|
|
201
|
+
credentials.id,
|
|
202
|
+
]);
|
|
203
|
+
}
|
|
204
|
+
getCrowdinCredentials(id) {
|
|
205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
const row = yield this.get('SELECT id, app_secret as appSecret, domain, user_id as userId, organization_id as organizationId, base_url as baseUrl, access_token as accessToken, refresh_token as refreshToken, expire, type FROM crowdin_credentials WHERE id = ?', [id]);
|
|
207
|
+
if (row) {
|
|
208
|
+
return row;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
getAllCrowdinCredentials() {
|
|
213
|
+
return this.each('SELECT id, app_secret as appSecret, domain, user_id as userId, organization_id as organizationId, base_url as baseUrl, access_token as accessToken, refresh_token as refreshToken, expire, type FROM crowdin_credentials', []);
|
|
214
|
+
}
|
|
215
|
+
deleteCrowdinCredentials(id) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
yield this.run('DELETE FROM crowdin_credentials where id = ?', [id]);
|
|
218
|
+
yield this.run('DELETE FROM integration_credentials where crowdin_id = ?', [id]);
|
|
219
|
+
yield this.run('DELETE FROM sync_settings WHERE crowdin_id = ?', [id]);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
saveIntegrationCredentials(id, credentials, crowdinId) {
|
|
223
|
+
return this.run('INSERT INTO integration_credentials(id, credentials, crowdin_id) VALUES (?, ?, ?)', [
|
|
224
|
+
id,
|
|
225
|
+
credentials,
|
|
226
|
+
crowdinId,
|
|
227
|
+
]);
|
|
228
|
+
}
|
|
229
|
+
updateIntegrationCredentials(id, credentials) {
|
|
230
|
+
return this.run('UPDATE integration_credentials SET credentials = ? WHERE id = ?', [credentials, id]);
|
|
231
|
+
}
|
|
232
|
+
updateIntegrationConfig(id, config) {
|
|
233
|
+
return this.run('UPDATE integration_credentials SET config = ? WHERE id = ?', [config, id]);
|
|
234
|
+
}
|
|
235
|
+
getIntegrationCredentials(id) {
|
|
236
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
237
|
+
const row = yield this.get('SELECT id, credentials, config, crowdin_id as crowdinId FROM integration_credentials WHERE id = ?', [id]);
|
|
238
|
+
if (row) {
|
|
239
|
+
return row;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
getAllIntegrationCredentials(crowdinId) {
|
|
244
|
+
return this.each('SELECT id, credentials, config, crowdin_id as crowdinId FROM integration_credentials WHERE crowdin_id = ?', [crowdinId]);
|
|
245
|
+
}
|
|
246
|
+
deleteIntegrationCredentials(id) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
248
|
+
yield this.run('DELETE FROM integration_credentials where id = ?', [id]);
|
|
249
|
+
yield this.run('DELETE FROM sync_settings where integration_id = ?', [id]);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
saveMetadata(id, metadata) {
|
|
253
|
+
return this.run('INSERT INTO app_metadata(id, data) VALUES (?, ?)', [id, JSON.stringify(metadata)]);
|
|
254
|
+
}
|
|
255
|
+
updateMetadata(id, metadata) {
|
|
256
|
+
return this.run('UPDATE app_metadata SET data = ? WHERE id = ?', [JSON.stringify(metadata), id]);
|
|
257
|
+
}
|
|
258
|
+
getMetadata(id) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
260
|
+
const row = yield this.get('SELECT data FROM app_metadata WHERE id = ?', [id]);
|
|
261
|
+
if (row) {
|
|
262
|
+
return JSON.parse(row.data);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
deleteMetadata(id) {
|
|
267
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
268
|
+
yield this.run('DELETE FROM app_metadata where id = ?', [id]);
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
getSyncSettingsByProvider(integrationId, provider) {
|
|
272
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
273
|
+
const row = yield this.get('SELECT id, files, integration_id as integrationId, crowdin_id as crowdinId, type, provider FROM sync_settings WHERE integration_id = ? AND provider = ?', [integrationId, provider]);
|
|
274
|
+
if (row) {
|
|
275
|
+
return row;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
getAllSyncSettingsByType(type) {
|
|
280
|
+
return this.each('SELECT id, files, integration_id as integrationId, crowdin_id as crowdinId, type, provider FROM sync_settings WHERE type = ?', [type]);
|
|
281
|
+
}
|
|
282
|
+
saveSyncSettings(files, integrationId, crowdinId, type, provider) {
|
|
283
|
+
return this.run('INSERT INTO sync_settings(files, integration_id, crowdin_id, type, provider) VALUES (?, ?, ?, ?, ?)', [files, integrationId, crowdinId, type, provider]);
|
|
284
|
+
}
|
|
285
|
+
updateSyncSettings(files, integrationId, crowdinId, type, provider) {
|
|
286
|
+
return this.run('UPDATE sync_settings SET files = ? WHERE integration_id = ? AND crowdin_id = ? AND type = ? AND provider = ?', [files, integrationId, crowdinId, type, provider]);
|
|
287
|
+
}
|
|
288
|
+
getSyncSettings(integrationId, crowdinId, type, provider) {
|
|
289
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
+
const row = yield this.get('SELECT id, files, integration_id as integrationId, crowdin_id as crowdinId, type FROM sync_settings WHERE integration_id = ? AND crowdin_id = ? AND type = ? AND provider = ?', [integrationId, crowdinId, type, provider]);
|
|
291
|
+
if (row) {
|
|
292
|
+
return row;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
exports.SQLiteStorage = SQLiteStorage;
|
package/out/util/connection.js
CHANGED
|
@@ -53,7 +53,7 @@ function prepareCrowdinClient(config, credentials) {
|
|
|
53
53
|
(0, _1.log)('Crowdin credentials have expired. Requesting a new credentials', config.logger);
|
|
54
54
|
const newCredentials = yield crowdinAppFunctions.refreshOAuthToken(config.clientId, config.clientSecret, (0, _1.decryptData)(config, credentials.refreshToken), (_b = config.crowdinUrls) === null || _b === void 0 ? void 0 : _b.accountUrl);
|
|
55
55
|
(0, _1.log)('Saving updated crowdin credentials in the database', config.logger);
|
|
56
|
-
yield (0, storage_1.
|
|
56
|
+
yield (0, storage_1.getStorage)().updateCrowdinCredentials({
|
|
57
57
|
id: credentials.id,
|
|
58
58
|
appSecret: credentials.appSecret,
|
|
59
59
|
domain: credentials.domain,
|
|
@@ -112,7 +112,7 @@ function prepareIntegrationCredentials(config, integration, integrationCredentia
|
|
|
112
112
|
credentials.refreshToken = newCredentials[((_h = oauthLogin === null || oauthLogin === void 0 ? void 0 : oauthLogin.fieldsMapping) === null || _h === void 0 ? void 0 : _h.refreshToken) || 'refresh_token'];
|
|
113
113
|
}
|
|
114
114
|
(0, _1.log)('Saving updated integration credentials in the database', config.logger);
|
|
115
|
-
yield (0, storage_1.
|
|
115
|
+
yield (0, storage_1.getStorage)().updateIntegrationCredentials(integrationCredentials.id, (0, _1.encryptData)(config, JSON.stringify(credentials)));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
return credentials;
|
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
|
},
|