@crowdin/app-project-module 0.29.1 → 0.29.3
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/handlers/crowdin-webhook.js +11 -2
- package/out/handlers/form-data-save.js +2 -2
- package/out/handlers/integration-webhook.js +1 -1
- package/out/index.js +3 -3
- package/out/models/index.d.ts +8 -3
- package/out/static/js/form.js +32 -32
- package/out/storage/index.d.ts +2 -2
- package/out/storage/mysql.d.ts +2 -2
- package/out/storage/mysql.js +15 -5
- package/out/storage/postgre.d.ts +2 -2
- package/out/storage/postgre.js +15 -5
- package/out/storage/sqlite.d.ts +3 -2
- package/out/storage/sqlite.js +26 -11
- package/out/util/api/api.js +17 -2
- package/out/util/cron.d.ts +3 -1
- package/out/util/cron.js +2 -1
- package/out/util/webhooks.d.ts +2 -3
- package/out/util/webhooks.js +18 -4
- package/out/views/form.handlebars +1 -0
- package/package.json +1 -1
package/out/storage/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export interface Storage {
|
|
|
13
13
|
getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
|
|
14
14
|
deleteIntegrationCredentials(id: string): Promise<void>;
|
|
15
15
|
deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
|
|
16
|
-
saveMetadata(id: string, metadata: any): Promise<void>;
|
|
17
|
-
updateMetadata(id: string, metadata: any): Promise<void>;
|
|
16
|
+
saveMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
|
|
17
|
+
updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
|
|
18
18
|
getMetadata(id: string): Promise<any | undefined>;
|
|
19
19
|
deleteMetadata(id: string): Promise<void>;
|
|
20
20
|
getSyncSettingsByProvider(integrationId: string, provider: Provider): Promise<IntegrationSyncSettings | undefined>;
|
package/out/storage/mysql.d.ts
CHANGED
|
@@ -30,8 +30,8 @@ export declare class MySQLStorage implements Storage {
|
|
|
30
30
|
getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
|
|
31
31
|
deleteIntegrationCredentials(id: string): Promise<void>;
|
|
32
32
|
deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
|
|
33
|
-
saveMetadata(id: string, metadata: any): Promise<void>;
|
|
34
|
-
updateMetadata(id: string, metadata: any): Promise<void>;
|
|
33
|
+
saveMetadata(id: string, metadata: any, crowdinId: string): Promise<void>;
|
|
34
|
+
updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
|
|
35
35
|
getMetadata(id: string): Promise<any>;
|
|
36
36
|
deleteMetadata(id: string): Promise<void>;
|
|
37
37
|
getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
|
package/out/storage/mysql.js
CHANGED
|
@@ -100,7 +100,8 @@ class MySQLStorage {
|
|
|
100
100
|
create table if not exists app_metadata
|
|
101
101
|
(
|
|
102
102
|
id varchar(255) primary key,
|
|
103
|
-
data text
|
|
103
|
+
data text,
|
|
104
|
+
crowdin_id text
|
|
104
105
|
)
|
|
105
106
|
`);
|
|
106
107
|
yield connection.execute(`
|
|
@@ -173,6 +174,7 @@ class MySQLStorage {
|
|
|
173
174
|
yield connection.execute('DELETE FROM crowdin_credentials where id = ?', [id]);
|
|
174
175
|
yield connection.execute('DELETE FROM integration_credentials where crowdin_id = ?', [id]);
|
|
175
176
|
yield connection.execute('DELETE FROM sync_settings WHERE crowdin_id = ?', [id]);
|
|
177
|
+
yield connection.execute('DELETE FROM app_metadata WHERE crowdin_id = ?', [id]);
|
|
176
178
|
yield connection.execute('DELETE FROM files_snapshot WHERE crowdin_id = ?', [id]);
|
|
177
179
|
}));
|
|
178
180
|
});
|
|
@@ -237,16 +239,24 @@ class MySQLStorage {
|
|
|
237
239
|
}));
|
|
238
240
|
});
|
|
239
241
|
}
|
|
240
|
-
saveMetadata(id, metadata) {
|
|
242
|
+
saveMetadata(id, metadata, crowdinId) {
|
|
241
243
|
return __awaiter(this, void 0, void 0, function* () {
|
|
242
244
|
yield this.dbPromise;
|
|
243
|
-
yield this.executeQuery((connection) => connection.execute('INSERT INTO app_metadata(id, data) VALUES (?, ?)', [
|
|
245
|
+
yield this.executeQuery((connection) => connection.execute('INSERT INTO app_metadata(id, data, crowdin_id) VALUES (?, ?, ?)', [
|
|
246
|
+
id,
|
|
247
|
+
JSON.stringify(metadata),
|
|
248
|
+
crowdinId,
|
|
249
|
+
]));
|
|
244
250
|
});
|
|
245
251
|
}
|
|
246
|
-
updateMetadata(id, metadata) {
|
|
252
|
+
updateMetadata(id, metadata, crowdinId) {
|
|
247
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
254
|
yield this.dbPromise;
|
|
249
|
-
yield this.executeQuery((connection) => connection.execute('UPDATE app_metadata SET data = ? WHERE id = ?', [
|
|
255
|
+
yield this.executeQuery((connection) => connection.execute('UPDATE app_metadata SET data = ?, crowdin_id = ? WHERE id = ?', [
|
|
256
|
+
JSON.stringify(metadata),
|
|
257
|
+
crowdinId,
|
|
258
|
+
id,
|
|
259
|
+
]));
|
|
250
260
|
});
|
|
251
261
|
}
|
|
252
262
|
getMetadata(id) {
|
package/out/storage/postgre.d.ts
CHANGED
|
@@ -34,8 +34,8 @@ export declare class PostgreStorage implements Storage {
|
|
|
34
34
|
getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
|
|
35
35
|
deleteIntegrationCredentials(id: string): Promise<void>;
|
|
36
36
|
deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
|
|
37
|
-
saveMetadata(id: string, metadata: any): Promise<void>;
|
|
38
|
-
updateMetadata(id: string, metadata: any): Promise<void>;
|
|
37
|
+
saveMetadata(id: string, metadata: any, crowdinId: string): Promise<void>;
|
|
38
|
+
updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
|
|
39
39
|
getMetadata(id: string): Promise<any>;
|
|
40
40
|
deleteMetadata(id: string): Promise<void>;
|
|
41
41
|
getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
|
package/out/storage/postgre.js
CHANGED
|
@@ -96,7 +96,8 @@ class PostgreStorage {
|
|
|
96
96
|
create table if not exists app_metadata
|
|
97
97
|
(
|
|
98
98
|
id varchar primary key,
|
|
99
|
-
data varchar
|
|
99
|
+
data varchar,
|
|
100
|
+
crowdin_id varchar,
|
|
100
101
|
)
|
|
101
102
|
`);
|
|
102
103
|
yield client.query(`
|
|
@@ -170,6 +171,7 @@ class PostgreStorage {
|
|
|
170
171
|
yield client.query('DELETE FROM integration_credentials where crowdin_id = $1', [id]);
|
|
171
172
|
yield client.query('DELETE FROM sync_settings WHERE crowdin_id = $1', [id]);
|
|
172
173
|
yield client.query('DELETE FROM files_snapshot WHERE crowdin_id = $1', [id]);
|
|
174
|
+
yield client.query('DELETE FROM app_metadata WHERE crowdin_id = $1', [id]);
|
|
173
175
|
}));
|
|
174
176
|
});
|
|
175
177
|
}
|
|
@@ -233,16 +235,24 @@ class PostgreStorage {
|
|
|
233
235
|
}));
|
|
234
236
|
});
|
|
235
237
|
}
|
|
236
|
-
saveMetadata(id, metadata) {
|
|
238
|
+
saveMetadata(id, metadata, crowdinId) {
|
|
237
239
|
return __awaiter(this, void 0, void 0, function* () {
|
|
238
240
|
yield this.dbPromise;
|
|
239
|
-
yield this.executeQuery((client) => client.query('INSERT INTO app_metadata(id, data) VALUES ($1, $2)', [
|
|
241
|
+
yield this.executeQuery((client) => client.query('INSERT INTO app_metadata(id, data, crowdin_id) VALUES ($1, $2, $3)', [
|
|
242
|
+
id,
|
|
243
|
+
JSON.stringify(metadata),
|
|
244
|
+
crowdinId,
|
|
245
|
+
]));
|
|
240
246
|
});
|
|
241
247
|
}
|
|
242
|
-
updateMetadata(id, metadata) {
|
|
248
|
+
updateMetadata(id, metadata, crowdinId) {
|
|
243
249
|
return __awaiter(this, void 0, void 0, function* () {
|
|
244
250
|
yield this.dbPromise;
|
|
245
|
-
yield this.executeQuery((client) => client.query('UPDATE app_metadata SET data = $1 WHERE id = $
|
|
251
|
+
yield this.executeQuery((client) => client.query('UPDATE app_metadata SET data = $1, crowdin_id = $2 WHERE id = $3', [
|
|
252
|
+
JSON.stringify(metadata),
|
|
253
|
+
crowdinId,
|
|
254
|
+
id,
|
|
255
|
+
]));
|
|
246
256
|
});
|
|
247
257
|
}
|
|
248
258
|
getMetadata(id) {
|
package/out/storage/sqlite.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare class SQLiteStorage implements Storage {
|
|
|
14
14
|
private run;
|
|
15
15
|
private get;
|
|
16
16
|
private each;
|
|
17
|
+
private updateTable;
|
|
17
18
|
private addColumns;
|
|
18
19
|
migrate(): Promise<void>;
|
|
19
20
|
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
@@ -28,8 +29,8 @@ export declare class SQLiteStorage implements Storage {
|
|
|
28
29
|
getAllIntegrationCredentials(crowdinId: string): Promise<IntegrationCredentials[]>;
|
|
29
30
|
deleteIntegrationCredentials(id: string): Promise<void>;
|
|
30
31
|
deleteAllIntegrationCredentials(crowdinId: string): Promise<void>;
|
|
31
|
-
saveMetadata(id: string, metadata: any): Promise<void>;
|
|
32
|
-
updateMetadata(id: string, metadata: any): Promise<void>;
|
|
32
|
+
saveMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
|
|
33
|
+
updateMetadata(id: string, metadata: any, crowdinId?: string): Promise<void>;
|
|
33
34
|
getMetadata(id: string): Promise<any>;
|
|
34
35
|
deleteMetadata(id: string): Promise<void>;
|
|
35
36
|
getSyncSettingsByProvider(integrationId: string, provider: string): Promise<IntegrationSyncSettings | undefined>;
|
package/out/storage/sqlite.js
CHANGED
|
@@ -92,22 +92,27 @@ class SQLiteStorage {
|
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
updateTable(newColumns, tableName) {
|
|
96
96
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const
|
|
98
|
-
const crowdinCredentialsInfo = yield this.each('PRAGMA table_info(crowdin_credentials);', []);
|
|
97
|
+
const tableInfo = yield this.each(`PRAGMA table_info(${tableName});`, []);
|
|
99
98
|
//@ts-ignore
|
|
100
|
-
|
|
99
|
+
tableInfo.map((columnInfo) => __awaiter(this, void 0, void 0, function* () {
|
|
101
100
|
const index = newColumns.indexOf(columnInfo.name);
|
|
102
101
|
if (~index) {
|
|
103
102
|
newColumns.splice(index, 1);
|
|
104
103
|
}
|
|
105
104
|
}));
|
|
106
105
|
for (const column of newColumns) {
|
|
107
|
-
yield this.run(`ALTER TABLE
|
|
106
|
+
yield this.run(`ALTER TABLE ${tableName} ADD COLUMN ${column} varchar null;`, []);
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
}
|
|
110
|
+
addColumns() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
yield this.updateTable(['app_secret', 'domain', 'user_id', 'organization_id', 'base_url'], 'crowdin_credentials');
|
|
113
|
+
yield this.updateTable(['crowdin_id'], 'app_metadata');
|
|
114
|
+
});
|
|
115
|
+
}
|
|
111
116
|
migrate() {
|
|
112
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
118
|
let _connection_res;
|
|
@@ -166,8 +171,9 @@ class SQLiteStorage {
|
|
|
166
171
|
yield this._run(`
|
|
167
172
|
create table if not exists app_metadata
|
|
168
173
|
(
|
|
169
|
-
id
|
|
170
|
-
data
|
|
174
|
+
id varchar not null primary key,
|
|
175
|
+
data varchar null,
|
|
176
|
+
crowdin_id varchar null
|
|
171
177
|
);
|
|
172
178
|
`, []);
|
|
173
179
|
yield this._run(`
|
|
@@ -232,6 +238,7 @@ class SQLiteStorage {
|
|
|
232
238
|
yield this.run('DELETE FROM crowdin_credentials where id = ?', [id]);
|
|
233
239
|
yield this.run('DELETE FROM integration_credentials where crowdin_id = ?', [id]);
|
|
234
240
|
yield this.run('DELETE FROM sync_settings WHERE crowdin_id = ?', [id]);
|
|
241
|
+
yield this.run('DELETE FROM app_metadata WHERE crowdin_id = ?', [id]);
|
|
235
242
|
yield this.run('DELETE FROM files_snapshot WHERE crowdin_id = ?', [id]);
|
|
236
243
|
});
|
|
237
244
|
}
|
|
@@ -273,11 +280,19 @@ class SQLiteStorage {
|
|
|
273
280
|
yield this.run('DELETE FROM files_snapshot where crowdin_id = ?', [crowdinId]);
|
|
274
281
|
});
|
|
275
282
|
}
|
|
276
|
-
saveMetadata(id, metadata) {
|
|
277
|
-
return this.run('INSERT INTO app_metadata(id, data) VALUES (?, ?)', [
|
|
283
|
+
saveMetadata(id, metadata, crowdinId) {
|
|
284
|
+
return this.run('INSERT INTO app_metadata(id, data, crowdin_id) VALUES (?, ?, ?)', [
|
|
285
|
+
id,
|
|
286
|
+
JSON.stringify(metadata),
|
|
287
|
+
crowdinId,
|
|
288
|
+
]);
|
|
278
289
|
}
|
|
279
|
-
updateMetadata(id, metadata) {
|
|
280
|
-
return this.run('UPDATE app_metadata SET data = ? WHERE id = ?', [
|
|
290
|
+
updateMetadata(id, metadata, crowdinId) {
|
|
291
|
+
return this.run('UPDATE app_metadata SET data = ?, crowdin_id = ? WHERE id = ?', [
|
|
292
|
+
JSON.stringify(metadata),
|
|
293
|
+
crowdinId,
|
|
294
|
+
id,
|
|
295
|
+
]);
|
|
281
296
|
}
|
|
282
297
|
getMetadata(id) {
|
|
283
298
|
return __awaiter(this, void 0, void 0, function* () {
|
package/out/util/api/api.js
CHANGED
|
@@ -413,6 +413,19 @@ function addSwagerApiDocumentation(app, config) {
|
|
|
413
413
|
openapi: '3.0.0',
|
|
414
414
|
info: {
|
|
415
415
|
title: `${config.name} Application API`,
|
|
416
|
+
description: "API methods of this application cannot be called directly. Instead, you should trigger Crowdin's platform API endpoint, Crowdin will authorize your request and route it to this app.\n\n" +
|
|
417
|
+
'Example call for crowdin.com \n\n' +
|
|
418
|
+
' curl --request GET \n' +
|
|
419
|
+
' --url "https://crowdin.com/api/v2/applications/' +
|
|
420
|
+
config.identifier +
|
|
421
|
+
'/api/data?report=raw&projects=479" \n' +
|
|
422
|
+
' --header "Authorization: Bearer 70cf05deasdas78c84c73c4cf986ee0a3ee911w1dsad384e3c4asd1qdbbcf6b6db5732e" \n' +
|
|
423
|
+
'Example call for Crowdin Enterprise \n\n' +
|
|
424
|
+
' curl --request GET \n' +
|
|
425
|
+
' --url "https://acme.crowdin.com/api/v2/applications/' +
|
|
426
|
+
config.identifier +
|
|
427
|
+
'/api/data?report=raw&projects=479&startDate=2023-06-01T06%3A32%3A01.048Z&endDate=2023-06-23T06%3A32%3A01.048Z" \n' +
|
|
428
|
+
' --header "Authorization: Bearer 70cf05dee35sad12rfes0a3ee911462e7b0723rfdfrg1e45bbcf6b6db5732e" \n',
|
|
416
429
|
version: '1.0.0',
|
|
417
430
|
'x-logo': {
|
|
418
431
|
url: 'https://support.crowdin.com/assets/crowdin-logo.svg',
|
|
@@ -424,14 +437,16 @@ function addSwagerApiDocumentation(app, config) {
|
|
|
424
437
|
},
|
|
425
438
|
],
|
|
426
439
|
},
|
|
427
|
-
apis:
|
|
440
|
+
apis: config.projectIntegration
|
|
441
|
+
? [path_1.default.resolve(__dirname, './base.js'), path_1.default.resolve(__dirname, './components.js'), __filename]
|
|
442
|
+
: [],
|
|
428
443
|
};
|
|
429
444
|
if ((_a = config.api) === null || _a === void 0 ? void 0 : _a.docFile) {
|
|
430
445
|
options.apis.push(config.api.docFile);
|
|
431
446
|
}
|
|
432
447
|
const swaggerSpec = (0, swagger_jsdoc_1.default)(options);
|
|
433
448
|
// remove Login info from doc
|
|
434
|
-
if (!((_b = config.projectIntegration) === null || _b === void 0 ? void 0 : _b.loginForm)) {
|
|
449
|
+
if (config.projectIntegration && !((_b = config.projectIntegration) === null || _b === void 0 ? void 0 : _b.loginForm)) {
|
|
435
450
|
delete swaggerSpec.paths['/login'];
|
|
436
451
|
delete swaggerSpec.paths['/login-fields'];
|
|
437
452
|
delete swaggerSpec.components.schemas['Login'];
|
package/out/util/cron.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
+
import { Config, CronJob, IntegrationLogic, UpdateIntegrationRequest, Provider, IntegrationRequest } from '../models';
|
|
2
3
|
export declare function runJob(config: Config, integration: IntegrationLogic, job: CronJob): Promise<void>;
|
|
3
4
|
export declare function filesCron(config: Config, integration: IntegrationLogic, period: string): Promise<void>;
|
|
5
|
+
export declare function skipFoldersFromIntegrationRequest(config: Config, integration: IntegrationLogic, projectId: number, crowdinFiles: UpdateIntegrationRequest, crowdinClient: Crowdin): Promise<UpdateIntegrationRequest>;
|
|
4
6
|
export declare function createOrUpdateSyncSettings(config: Config, req: IntegrationRequest, files: any, provider: Provider, onlyCreate?: boolean): Promise<void>;
|
package/out/util/cron.js
CHANGED
|
@@ -32,7 +32,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.createOrUpdateSyncSettings = exports.filesCron = exports.runJob = void 0;
|
|
35
|
+
exports.createOrUpdateSyncSettings = exports.skipFoldersFromIntegrationRequest = exports.filesCron = exports.runJob = void 0;
|
|
36
36
|
const crowdinAppFunctions = __importStar(require("@crowdin/crowdin-apps-functions"));
|
|
37
37
|
const _1 = require(".");
|
|
38
38
|
const models_1 = require("../models");
|
|
@@ -247,6 +247,7 @@ function skipFoldersFromIntegrationRequest(config, integration, projectId, crowd
|
|
|
247
247
|
return crowdinFiles;
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
|
+
exports.skipFoldersFromIntegrationRequest = skipFoldersFromIntegrationRequest;
|
|
250
251
|
function createOrUpdateSyncSettings(config, req, files, provider, onlyCreate = false) {
|
|
251
252
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
253
|
const existingSettings = yield (0, storage_1.getStorage)().getSyncSettings(req.crowdinContext.clientId, req.crowdinContext.crowdinId, 'schedule', provider);
|
package/out/util/webhooks.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
|
-
import { Config, CrowdinContextInfo, IntegrationLogic, IntegrationSyncSettings, Payload, Provider, TreeItem, UpdateIntegrationRequest, WebhookUrlParams } from '../models';
|
|
2
|
+
import { Config, CrowdinContextInfo, IntegrationLogic, IntegrationSyncSettings, Payload, Provider, TreeItem, UpdateCrowdinWebhookPayloadsArgs, UpdateIntegrationRequest, WebhookUrlParams } from '../models';
|
|
3
3
|
import { WebhooksModel } from '@crowdin/crowdin-api-client/out/webhooks';
|
|
4
|
-
import { Request } from 'express';
|
|
5
4
|
export declare function encodedUrlParam(config: Config, integration: IntegrationLogic, crowdinContext: CrowdinContextInfo): string;
|
|
6
5
|
export declare function decodedUrlParam(config: Config, data: string): WebhookUrlParams;
|
|
7
6
|
export declare function makeCrowdinWebhookUrl(config: Config, integration: IntegrationLogic, crowdinContext: CrowdinContextInfo): string;
|
|
@@ -26,5 +25,5 @@ export declare function prepareWebhookData(config: Config, integration: Integrat
|
|
|
26
25
|
syncSettings: IntegrationSyncSettings | null;
|
|
27
26
|
newFiles: TreeItem[] | UpdateIntegrationRequest;
|
|
28
27
|
}>;
|
|
29
|
-
export declare function updateCrowdinFromWebhookRequest(
|
|
28
|
+
export declare function updateCrowdinFromWebhookRequest(args: UpdateCrowdinWebhookPayloadsArgs): Promise<void | import("../models").ExtendedResult<void>>;
|
|
30
29
|
export declare function listenQueueMessage(config: Config, integration: IntegrationLogic, queueUrl: string, queueName: string): Promise<void>;
|
package/out/util/webhooks.js
CHANGED
|
@@ -272,15 +272,29 @@ function prepareWebhookData(config, integration, webhookUrlParam, provider) {
|
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
exports.prepareWebhookData = prepareWebhookData;
|
|
275
|
-
function updateCrowdinFromWebhookRequest(
|
|
275
|
+
function updateCrowdinFromWebhookRequest(args) {
|
|
276
276
|
var _a, _b;
|
|
277
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
+
const { integration, webhookData, req } = args;
|
|
278
279
|
let filesToSync = [];
|
|
279
280
|
const { projectId, crowdinClient, preparedIntegrationCredentials, rootFolder, appSettings, syncSettings, newFiles, } = webhookData;
|
|
281
|
+
const syncFiles = (syncSettings === null || syncSettings === void 0 ? void 0 : syncSettings.files) ? JSON.parse(syncSettings.files) : [];
|
|
280
282
|
if ((_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.integrationWebhookInterceptor) {
|
|
281
|
-
filesToSync = yield ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.integrationWebhookInterceptor(projectId, crowdinClient.client, preparedIntegrationCredentials, rootFolder, appSettings, syncSettings, req
|
|
283
|
+
filesToSync = yield ((_b = integration.webhooks) === null || _b === void 0 ? void 0 : _b.integrationWebhookInterceptor(projectId, crowdinClient.client, preparedIntegrationCredentials, rootFolder, appSettings, syncSettings, req));
|
|
282
284
|
}
|
|
283
|
-
|
|
285
|
+
const allIntFiles = [...filesToSync, ...newFiles].map((file) => (Object.assign({ id: file.id, name: file.name, parentId: file.parent_id || file.parentId,
|
|
286
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
287
|
+
parent_id: file.parent_id || file.parentId, nodeType: file.nodeType || file.node_type || '1',
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/camelcase
|
|
289
|
+
node_type: file.nodeType || file.node_type || '1' }, (file.type ? { type: file.type } : {}))));
|
|
290
|
+
const intFiles = allIntFiles.filter((file) => file.nodeType === '1');
|
|
291
|
+
const newSyncSettingsFiels = [...syncFiles, ...newFiles].map((file) => (Object.assign(Object.assign({}, file), { schedule: true, sync: false })));
|
|
292
|
+
if (newFiles) {
|
|
293
|
+
yield (0, storage_1.getStorage)().updateSyncSettings(JSON.stringify(newSyncSettingsFiels), syncSettings.integrationId, syncSettings.crowdinId, 'schedule', syncSettings.provider);
|
|
294
|
+
const currentFileSnapshot = yield (0, file_snapshot_1.getIntegrationSnapshot)(integration, preparedIntegrationCredentials, appSettings);
|
|
295
|
+
yield (0, storage_1.getStorage)().updateFilesSnapshot(JSON.stringify(currentFileSnapshot), syncSettings.integrationId, syncSettings.crowdinId, syncSettings.provider);
|
|
296
|
+
}
|
|
297
|
+
return yield integration.updateCrowdin(projectId, crowdinClient.client, preparedIntegrationCredentials, intFiles, rootFolder, appSettings);
|
|
284
298
|
});
|
|
285
299
|
}
|
|
286
300
|
exports.updateCrowdinFromWebhookRequest = updateCrowdinFromWebhookRequest;
|
|
@@ -321,7 +335,7 @@ function consumer(channel, config, integration) {
|
|
|
321
335
|
const urlParam = (_a = integration.webhooks) === null || _a === void 0 ? void 0 : _a.urlParam;
|
|
322
336
|
const webhookUrlParam = data.query[urlParam];
|
|
323
337
|
const webhookData = yield prepareWebhookData(config, integration, webhookUrlParam, models_1.Provider.INTEGRATION);
|
|
324
|
-
yield updateCrowdinFromWebhookRequest(integration, webhookData, data);
|
|
338
|
+
yield updateCrowdinFromWebhookRequest({ integration, webhookData, req: data });
|
|
325
339
|
}
|
|
326
340
|
catch (e) {
|
|
327
341
|
(0, util_1.logError)(e, config.onError);
|
package/package.json
CHANGED