@crowdin/app-project-module 1.15.1 → 2.0.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.
Files changed (101) hide show
  1. package/out/index.js +8 -15
  2. package/out/middlewares/auto-credentials-masker.js +5 -2
  3. package/out/middlewares/crowdin-client.d.ts +1 -1
  4. package/out/middlewares/crowdin-client.js +1 -1
  5. package/out/middlewares/export.d.ts +2 -2
  6. package/out/middlewares/export.js +4 -35
  7. package/out/middlewares/json-response.d.ts +1 -1
  8. package/out/middlewares/json-response.js +1 -1
  9. package/out/modules/ai-prompt-provider/index.js +6 -6
  10. package/out/modules/ai-provider/index.js +7 -7
  11. package/out/modules/ai-provider/types.d.ts +10 -0
  12. package/out/modules/ai-provider/types.js +12 -0
  13. package/out/modules/ai-provider/util/index.d.ts +0 -10
  14. package/out/modules/ai-provider/util/index.js +2 -13
  15. package/out/modules/ai-request-processors/index.js +4 -4
  16. package/out/modules/api/api.js +18 -18
  17. package/out/modules/auth-guard/index.js +4 -5
  18. package/out/modules/automation-action/index.js +4 -6
  19. package/out/modules/context-menu/index.js +4 -13
  20. package/out/modules/custom-mt/index.js +4 -4
  21. package/out/modules/custom-spell-check/index.js +11 -11
  22. package/out/modules/editor-right-panel/index.js +1 -1
  23. package/out/modules/external-qa-check/index.js +7 -7
  24. package/out/modules/file-processing/index.js +14 -14
  25. package/out/modules/integration/index.js +26 -26
  26. package/out/modules/integration/types.d.ts +4 -4
  27. package/out/modules/integration/util/files.js +1 -1
  28. package/out/modules/integration/util/types.d.ts +1 -1
  29. package/out/modules/manifest.js +70 -281
  30. package/out/modules/modal/index.js +4 -13
  31. package/out/modules/organization-menu/index.js +1 -1
  32. package/out/modules/organization-settings-menu/index.js +1 -1
  33. package/out/modules/profile-resources-menu/index.js +1 -1
  34. package/out/modules/profile-settings-menu/index.js +1 -1
  35. package/out/modules/project-menu/index.js +1 -1
  36. package/out/modules/project-menu-crowdsource/index.js +1 -1
  37. package/out/modules/project-reports/index.js +1 -1
  38. package/out/modules/project-tools/index.js +1 -1
  39. package/out/modules/webhooks/index.js +3 -6
  40. package/out/modules/workflow-step-type/index.js +6 -6
  41. package/out/static/ui/form.bundle.js +7947 -6975
  42. package/out/static/ui/form.bundle.js.map +1 -1
  43. package/out/storage/drizzle/d1/index.d.ts +7 -0
  44. package/out/storage/drizzle/d1/index.js +48 -0
  45. package/out/storage/drizzle/d1/migrations/init.d.ts +2 -0
  46. package/out/storage/drizzle/d1/migrations/init.js +122 -0
  47. package/out/storage/drizzle/d1/types.d.ts +13 -0
  48. package/out/storage/drizzle/d1/types.js +38 -0
  49. package/out/storage/{sqlite.d.ts → drizzle/index.d.ts} +37 -58
  50. package/out/storage/drizzle/index.js +939 -0
  51. package/out/storage/drizzle/postgresql/config.d.ts +5 -0
  52. package/out/storage/drizzle/postgresql/config.js +11 -0
  53. package/out/storage/drizzle/postgresql/index.d.ts +14 -0
  54. package/out/storage/drizzle/postgresql/index.js +144 -0
  55. package/out/storage/drizzle/postgresql/migrations/0000_init.sql +113 -0
  56. package/out/storage/drizzle/postgresql/migrations/0001_init_indexes.sql +28 -0
  57. package/out/storage/drizzle/postgresql/migrations/meta/0000_snapshot.json +646 -0
  58. package/out/storage/drizzle/postgresql/migrations/meta/0001_snapshot.json +646 -0
  59. package/out/storage/drizzle/postgresql/migrations/meta/_journal.json +20 -0
  60. package/out/storage/drizzle/postgresql/schema.d.ts +1410 -0
  61. package/out/storage/drizzle/postgresql/schema.js +106 -0
  62. package/out/storage/drizzle/sqlite/config.d.ts +5 -0
  63. package/out/storage/drizzle/sqlite/config.js +11 -0
  64. package/out/storage/drizzle/sqlite/index.d.ts +8 -0
  65. package/out/storage/drizzle/sqlite/index.js +63 -0
  66. package/out/storage/drizzle/sqlite/migrations/0000_init.sql +113 -0
  67. package/out/storage/drizzle/sqlite/migrations/meta/0000_snapshot.json +687 -0
  68. package/out/storage/drizzle/sqlite/migrations/meta/_journal.json +13 -0
  69. package/out/storage/drizzle/sqlite/schema.d.ts +1544 -0
  70. package/out/storage/drizzle/sqlite/schema.js +106 -0
  71. package/out/storage/index.d.ts +2 -88
  72. package/out/storage/index.js +12 -128
  73. package/out/storage/internal/backup.d.ts +3 -0
  74. package/out/storage/internal/backup.js +94 -0
  75. package/out/storage/types.d.ts +66 -0
  76. package/out/types.d.ts +43 -47
  77. package/out/util/credentials-masker.js +2 -2
  78. package/out/util/export.d.ts +1 -0
  79. package/out/util/export.js +2 -1
  80. package/out/util/index.d.ts +2 -1
  81. package/out/util/index.js +12 -9
  82. package/out/util/normalize-module.d.ts +0 -1
  83. package/out/util/normalize-module.js +0 -4
  84. package/package.json +23 -23
  85. package/out/modules/ai-tools/handlers/tool-calls.d.ts +0 -4
  86. package/out/modules/ai-tools/handlers/tool-calls.js +0 -52
  87. package/out/modules/ai-tools/index.d.ts +0 -10
  88. package/out/modules/ai-tools/index.js +0 -46
  89. package/out/modules/ai-tools/types.d.ts +0 -63
  90. package/out/modules/ai-tools/types.js +0 -2
  91. package/out/modules/ai-tools/util/index.d.ts +0 -5
  92. package/out/modules/ai-tools/util/index.js +0 -24
  93. package/out/storage/d1.d.ts +0 -107
  94. package/out/storage/d1.js +0 -837
  95. package/out/storage/export.d.ts +0 -1
  96. package/out/storage/export.js +0 -2
  97. package/out/storage/mysql.d.ts +0 -109
  98. package/out/storage/mysql.js +0 -984
  99. package/out/storage/postgre.d.ts +0 -124
  100. package/out/storage/postgre.js +0 -1027
  101. package/out/storage/sqlite.js +0 -786
@@ -1,984 +0,0 @@
1
- "use strict";
2
- /* eslint-disable no-unused-expressions */
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.MySQLStorage = void 0;
14
- const crypto_1 = require("crypto");
15
- const types_1 = require("../modules/integration/util/types");
16
- const util_1 = require("../util");
17
- class MySQLStorage {
18
- constructor(config) {
19
- this.mysql = require('mysql2/promise');
20
- this.dbPromise = new Promise((res, rej) => {
21
- this._res = res;
22
- this._rej = rej;
23
- });
24
- this.tableIndexes = {
25
- integration_credentials: {
26
- idx_crowdin: '(crowdin_id)',
27
- },
28
- sync_settings: {
29
- idx_integration_provider: '(integration_id, provider)',
30
- idx_crowdin: '(crowdin_id)',
31
- idx_type: '(type)',
32
- },
33
- files_snapshot: {
34
- idx_integration: '(integration_id)',
35
- idx_crowdin: '(crowdin_id)',
36
- },
37
- webhooks: {
38
- idx_integration_crowdin: '(integration_id, crowdin_id)',
39
- idx_file_provider: '(file_id, provider)',
40
- },
41
- user_errors: {
42
- idx_integration_crowdin: '(integration_id, crowdin_id)',
43
- idx_crowdin: '(crowdin_id)',
44
- idx_created_at: '(created_at)',
45
- },
46
- integration_settings: {
47
- idx_integration: '(integration_id)',
48
- idx_crowdin: '(crowdin_id)',
49
- },
50
- job: {
51
- idx_integration_crowdin: '(integration_id, crowdin_id)',
52
- idx_finished_at: '(finished_at)',
53
- idx_status: '(status)',
54
- },
55
- translation_file_cache: {
56
- idx_integration_crowdin_file_language: '(integration_id, crowdin_id, file_id, language_id)',
57
- idx_crowdin: '(crowdin_id)',
58
- },
59
- unsynced_files: {
60
- idx_integration_crowdin: '(integration_id, crowdin_id)',
61
- idx_crowdin: '(crowdin_id)',
62
- },
63
- };
64
- this.tables = {
65
- crowdin_credentials: `(
66
- id varchar(255) primary key,
67
- app_secret text,
68
- domain varchar(255),
69
- user_id varchar(255),
70
- agent_id varchar(255),
71
- organization_id varchar(255),
72
- base_url varchar(255),
73
- access_token text not null,
74
- refresh_token text not null,
75
- expire varchar(255) not null,
76
- type varchar(255) not null
77
- )`,
78
- integration_credentials: `(
79
- id varchar(255) primary key,
80
- credentials text,
81
- crowdin_id varchar(255) not null,
82
- managers text
83
- )`,
84
- sync_settings: `(
85
- id int auto_increment primary key,
86
- files text,
87
- integration_id varchar(255) not null,
88
- crowdin_id varchar(255) not null,
89
- type varchar(255) not null,
90
- provider varchar(255) not null
91
- )`,
92
- app_metadata: `(
93
- id varchar(255) primary key,
94
- data text,
95
- crowdin_id text
96
- )`,
97
- files_snapshot: `(
98
- id int auto_increment primary key,
99
- files text,
100
- integration_id varchar(255) not null,
101
- crowdin_id varchar(255) not null,
102
- provider varchar(255) not null
103
- )`,
104
- webhooks: `(
105
- id int auto_increment primary key,
106
- file_id varchar(255) not null,
107
- integration_id varchar(255) not null,
108
- crowdin_id varchar(255) not null,
109
- provider varchar(255) not null
110
- )`,
111
- user_errors: `(
112
- id int auto_increment primary key,
113
- action varchar(255) not null,
114
- message varchar(255) not null,
115
- data text,
116
- created_at varchar(255) not null,
117
- crowdin_id varchar(255) not null,
118
- integration_id varchar(255)
119
- )`,
120
- integration_settings: `(
121
- id int auto_increment primary key,
122
- integration_id varchar(255) not null,
123
- crowdin_id varchar(255) not null,
124
- config text
125
- )`,
126
- job: `(
127
- id varchar(255) not null primary key,
128
- integration_id varchar(255) not null,
129
- crowdin_id varchar(255) not null,
130
- type varchar(255) not null,
131
- payload text,
132
- title text,
133
- progress int 0,
134
- status varchar(255) '${types_1.JobStatus.CREATED}',
135
- payload text,
136
- info text,
137
- data text,
138
- attempt int 0,
139
- errors text,
140
- processed_entities text,
141
- initiated_by varchar(255),
142
- created_at varchar(255) not null,
143
- updated_at varchar(255),
144
- finished_at varchar(255)
145
- )`,
146
- translation_file_cache: `(
147
- id int auto_increment primary key,
148
- integration_id varchar(255) not null,
149
- crowdin_id varchar(255) not null,
150
- file_id int not null,
151
- language_id varchar(255) not null,
152
- etag varchar(255)
153
- )`,
154
- unsynced_files: `(
155
- id int auto_increment primary key,
156
- integration_id varchar(255) not null,
157
- crowdin_id varchar(255) not null,
158
- files text
159
- )`,
160
- synced_data: `(
161
- id int auto_increment primary key,
162
- files text,
163
- integration_id varchar(255) not null,
164
- crowdin_id varchar(255) not null,
165
- type varchar(255) not null,
166
- updated_at varchar(255) null,
167
- )`,
168
- };
169
- this.config = config;
170
- }
171
- executeQuery(command) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- return (0, util_1.executeWithRetry)(() => __awaiter(this, void 0, void 0, function* () {
174
- let connection;
175
- try {
176
- connection = yield this.mysql.createConnection(this.config);
177
- const res = yield command(connection);
178
- yield connection.end();
179
- return res;
180
- }
181
- catch (error) {
182
- if (connection) {
183
- try {
184
- yield connection.end();
185
- }
186
- catch (nestedError) {
187
- throw nestedError;
188
- }
189
- }
190
- throw error;
191
- }
192
- }));
193
- });
194
- }
195
- migrate(skipOnboarding) {
196
- return __awaiter(this, void 0, void 0, function* () {
197
- try {
198
- if (!skipOnboarding) {
199
- yield this.executeQuery((connection) => this.addTables(connection));
200
- }
201
- this._res && this._res();
202
- }
203
- catch (e) {
204
- console.error(e);
205
- this._rej && this._rej();
206
- }
207
- });
208
- }
209
- addTables(connection) {
210
- return __awaiter(this, void 0, void 0, function* () {
211
- for (const [tableName, tableSchema] of Object.entries(this.tables)) {
212
- yield connection.execute(`create table if not exists ${tableName} ${tableSchema}`);
213
- if (this.tableIndexes[tableName]) {
214
- for (const [indexName, indexSchema] of Object.entries(this.tableIndexes[tableName])) {
215
- // For MySQL, we need to handle partial indexes differently since MySQL doesn't support WHERE clauses in indexes
216
- // We'll create the basic index without the WHERE clause
217
- const indexColumns = indexSchema.replace(/WHERE.*$/, '').trim();
218
- yield connection.execute(`create index if not exists ${indexName} on ${tableName}${indexColumns}`);
219
- }
220
- }
221
- }
222
- });
223
- }
224
- saveCrowdinCredentials(credentials) {
225
- return __awaiter(this, void 0, void 0, function* () {
226
- yield this.dbPromise;
227
- yield this.executeQuery((connection) => connection.execute('INSERT INTO crowdin_credentials(id, app_secret, domain, user_id, agent_id, organization_id, base_url, access_token, refresh_token, expire, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [
228
- credentials.id,
229
- credentials.appSecret,
230
- credentials.domain,
231
- credentials.userId,
232
- credentials.agentId,
233
- credentials.organizationId,
234
- credentials.baseUrl,
235
- credentials.accessToken,
236
- credentials.refreshToken,
237
- credentials.expire,
238
- credentials.type,
239
- ]));
240
- });
241
- }
242
- updateCrowdinCredentials(credentials) {
243
- return __awaiter(this, void 0, void 0, function* () {
244
- yield this.dbPromise;
245
- yield this.executeQuery((connection) => connection.execute('UPDATE crowdin_credentials SET app_secret = ?, domain = ?, user_id = ?, agent_id = ?, organization_id = ?, base_url = ?, access_token = ?, refresh_token = ?, expire = ? WHERE id = ?', [
246
- credentials.appSecret,
247
- credentials.domain,
248
- credentials.userId,
249
- credentials.agentId,
250
- credentials.organizationId,
251
- credentials.baseUrl,
252
- credentials.accessToken,
253
- credentials.refreshToken,
254
- credentials.expire,
255
- credentials.id,
256
- ]));
257
- });
258
- }
259
- getCrowdinCredentials(id) {
260
- return __awaiter(this, void 0, void 0, function* () {
261
- yield this.dbPromise;
262
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
263
- const [rows] = yield connection.execute('SELECT id, app_secret as "appSecret", domain, user_id as "userId", agent_id as "agentId", organization_id as "organizationId", base_url as "baseUrl", access_token as "accessToken", refresh_token as "refreshToken", expire, type FROM crowdin_credentials WHERE id = ?', [id]);
264
- return (rows || [])[0];
265
- }));
266
- });
267
- }
268
- getAllCrowdinCredentials() {
269
- return __awaiter(this, void 0, void 0, function* () {
270
- yield this.dbPromise;
271
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
272
- const [rows] = yield connection.execute('SELECT id, app_secret as "appSecret", domain, user_id as "userId", agent_id as "agentId", organization_id as "organizationId", base_url as "baseUrl", access_token as "accessToken", refresh_token as "refreshToken", expire, type FROM crowdin_credentials', []);
273
- return rows || [];
274
- }));
275
- });
276
- }
277
- deleteCrowdinCredentials(id) {
278
- return __awaiter(this, void 0, void 0, function* () {
279
- yield this.dbPromise;
280
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
281
- yield connection.execute('DELETE FROM crowdin_credentials where id = ?', [id]);
282
- yield connection.execute('DELETE FROM integration_credentials where crowdin_id = ?', [id]);
283
- yield connection.execute('DELETE FROM sync_settings WHERE crowdin_id = ?', [id]);
284
- yield connection.execute('DELETE FROM app_metadata WHERE crowdin_id = ?', [id]);
285
- yield connection.execute('DELETE FROM files_snapshot WHERE crowdin_id = ?', [id]);
286
- yield connection.execute('DELETE FROM webhooks WHERE crowdin_id = ?', [id]);
287
- yield connection.execute('DELETE FROM user_errors WHERE crowdin_id = ?', [id]);
288
- yield connection.execute('DELETE FROM integration_settings WHERE crowdin_id = ?', [id]);
289
- yield connection.execute('DELETE FROM job WHERE crowdin_id = ?', [id]);
290
- yield connection.execute('DELETE FROM translation_file_cache WHERE crowdin_id = ?', [id]);
291
- yield connection.execute('DELETE FROM unsynced_files WHERE crowdin_id = ?', [id]);
292
- yield connection.execute('DELETE FROM synced_data WHERE crowdin_id = ?', [id]);
293
- }));
294
- });
295
- }
296
- saveIntegrationCredentials(id, credentials, crowdinId) {
297
- return __awaiter(this, void 0, void 0, function* () {
298
- yield this.dbPromise;
299
- yield this.executeQuery((connection) => connection.execute('INSERT INTO integration_credentials(id, credentials, crowdin_id) VALUES (?, ?, ?)', [
300
- id,
301
- credentials,
302
- crowdinId,
303
- ]));
304
- });
305
- }
306
- updateIntegrationCredentials(id, credentials) {
307
- return __awaiter(this, void 0, void 0, function* () {
308
- yield this.dbPromise;
309
- yield this.executeQuery((connection) => connection.execute('UPDATE integration_credentials SET credentials = ? WHERE id = ?', [credentials, id]));
310
- });
311
- }
312
- updateIntegrationManagers(id, managers) {
313
- return __awaiter(this, void 0, void 0, function* () {
314
- yield this.dbPromise;
315
- yield this.executeQuery((connection) => connection.execute('UPDATE integration_credentials SET managers = ? WHERE id = ?', [managers, id]));
316
- });
317
- }
318
- getIntegrationCredentials(id) {
319
- return __awaiter(this, void 0, void 0, function* () {
320
- yield this.dbPromise;
321
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
322
- const [rows] = yield connection.execute('SELECT id, credentials, crowdin_id as "crowdinId", managers FROM integration_credentials WHERE id = ?', [id]);
323
- return (rows || [])[0];
324
- }));
325
- });
326
- }
327
- getAllIntegrationCredentials(crowdinId) {
328
- return __awaiter(this, void 0, void 0, function* () {
329
- yield this.dbPromise;
330
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
331
- const [rows] = yield connection.execute('SELECT id, credentials, crowdin_id as "crowdinId", managers FROM integration_credentials WHERE crowdin_id = ?', [crowdinId]);
332
- return rows || [];
333
- }));
334
- });
335
- }
336
- deleteIntegrationCredentials(id) {
337
- return __awaiter(this, void 0, void 0, function* () {
338
- yield this.dbPromise;
339
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
340
- yield connection.execute('DELETE FROM integration_credentials where id = ?', [id]);
341
- yield connection.execute('DELETE FROM sync_settings where integration_id = ?', [id]);
342
- yield connection.execute('DELETE FROM files_snapshot where integration_id = ?', [id]);
343
- yield connection.execute('DELETE FROM webhooks where integration_id = ?', [id]);
344
- yield connection.execute('DELETE FROM user_errors where integration_id = ?', [id]);
345
- yield connection.execute('DELETE FROM integration_settings where integration_id = ?', [id]);
346
- yield connection.execute('DELETE FROM job where integration_id = ?', [id]);
347
- yield connection.execute('DELETE FROM translation_file_cache where integration_id = ?', [id]);
348
- yield connection.execute('DELETE FROM unsynced_files where integration_id = ?', [id]);
349
- yield connection.execute('DELETE FROM synced_data where integration_id = ?', [id]);
350
- }));
351
- });
352
- }
353
- deleteAllIntegrationCredentials(crowdinId) {
354
- return __awaiter(this, void 0, void 0, function* () {
355
- yield this.dbPromise;
356
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
357
- yield connection.execute('DELETE FROM integration_credentials where crowdin_id = ?', [crowdinId]);
358
- yield connection.execute('DELETE FROM sync_settings where crowdin_id = ?', [crowdinId]);
359
- yield connection.execute('DELETE FROM files_snapshot where crowdin_id = ?', [crowdinId]);
360
- yield connection.execute('DELETE FROM webhooks where crowdin_id = ?', [crowdinId]);
361
- yield connection.execute('DELETE FROM user_errors where crowdin_id = ?', [crowdinId]);
362
- yield connection.execute('DELETE FROM job where crowdin_id = ?', [crowdinId]);
363
- yield connection.execute('DELETE FROM unsynced_files where crowdin_id = ?', [crowdinId]);
364
- yield connection.execute('DELETE FROM synced_data where crowdin_id = ?', [crowdinId]);
365
- }));
366
- });
367
- }
368
- saveMetadata(id, metadata, crowdinId) {
369
- return __awaiter(this, void 0, void 0, function* () {
370
- yield this.dbPromise;
371
- yield this.executeQuery((connection) => connection.execute('INSERT INTO app_metadata(id, data, crowdin_id) VALUES (?, ?, ?)', [
372
- id,
373
- JSON.stringify(metadata),
374
- crowdinId,
375
- ]));
376
- });
377
- }
378
- updateMetadata(id, metadata, crowdinId) {
379
- return __awaiter(this, void 0, void 0, function* () {
380
- yield this.dbPromise;
381
- yield this.executeQuery((connection) => connection.execute('UPDATE app_metadata SET data = ?, crowdin_id = ? WHERE id = ?', [
382
- JSON.stringify(metadata),
383
- crowdinId,
384
- id,
385
- ]));
386
- });
387
- }
388
- getMetadata(id) {
389
- return __awaiter(this, void 0, void 0, function* () {
390
- yield this.dbPromise;
391
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
392
- const [rows] = yield connection.execute('SELECT data FROM app_metadata WHERE id = ?', [id]);
393
- if (rows && rows[0]) {
394
- return JSON.parse(rows[0].data);
395
- }
396
- }));
397
- });
398
- }
399
- getAllMetadata() {
400
- return __awaiter(this, void 0, void 0, function* () {
401
- yield this.dbPromise;
402
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
403
- const [rows] = yield connection.execute('SELECT * FROM app_metadata');
404
- return rows || [];
405
- }));
406
- });
407
- }
408
- deleteMetadata(id) {
409
- return __awaiter(this, void 0, void 0, function* () {
410
- yield this.dbPromise;
411
- yield this.executeQuery((connection) => connection.execute('DELETE FROM app_metadata where id = ?', [id]));
412
- });
413
- }
414
- getSyncSettingsByProvider(integrationId, provider) {
415
- return __awaiter(this, void 0, void 0, function* () {
416
- yield this.dbPromise;
417
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
418
- const [rows] = yield connection.execute('SELECT id, files, integration_id as "integrationId", crowdin_id as "crowdinId", type, provider FROM sync_settings WHERE integration_id = ? AND provider = ?', [integrationId, provider]);
419
- return (rows || [])[0];
420
- }));
421
- });
422
- }
423
- getSyncSettingsBySchedule(type, schedule) {
424
- return __awaiter(this, void 0, void 0, function* () {
425
- yield this.dbPromise;
426
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
427
- const [rows] = yield connection.execute(`
428
- SELECT s.id, s.files, s.integration_id as "integrationId", s.crowdin_id as "crowdinId", s.type, s.provider
429
- FROM sync_settings s
430
- INNER JOIN integration_settings i ON s.integration_id = i.integration_id
431
- WHERE s.type = ?
432
- AND CASE
433
- WHEN i.config IS NULL THEN false
434
- ELSE JSON_EXTRACT(i.config, '$.schedule') = ?
435
- END
436
- `, [type, schedule]);
437
- return rows || [];
438
- }));
439
- });
440
- }
441
- saveSyncSettings(files, integrationId, crowdinId, type, provider) {
442
- return __awaiter(this, void 0, void 0, function* () {
443
- yield this.dbPromise;
444
- yield this.executeQuery((connection) => connection.execute('INSERT INTO sync_settings(files, integration_id, crowdin_id, type, provider) VALUES (?, ?, ?, ?, ?)', [files, integrationId, crowdinId, type, provider]));
445
- });
446
- }
447
- updateSyncSettings(files, integrationId, crowdinId, type, provider) {
448
- return __awaiter(this, void 0, void 0, function* () {
449
- yield this.dbPromise;
450
- yield this.executeQuery((connection) => connection.execute('UPDATE sync_settings SET files = ? WHERE integration_id = ? AND crowdin_id = ? AND type = ? AND provider = ?', [files, integrationId, crowdinId, type, provider]));
451
- });
452
- }
453
- getSyncSettings(integrationId, crowdinId, type, provider) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- yield this.dbPromise;
456
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
457
- const [rows] = yield connection.execute('SELECT id, files, integration_id as "integrationId", crowdin_id as "crowdinId", type, provider FROM sync_settings WHERE integration_id = ? AND crowdin_id = ? AND type = ? AND provider = ?', [integrationId, crowdinId, type, provider]);
458
- return (rows || [])[0];
459
- }));
460
- });
461
- }
462
- saveFilesSnapshot(files, integrationId, crowdinId, provider) {
463
- return __awaiter(this, void 0, void 0, function* () {
464
- yield this.dbPromise;
465
- yield this.executeQuery((connection) => connection.execute('INSERT INTO files_snapshot(files, integration_id, crowdin_id, provider) VALUES (?, ?, ?, ?)', [files, integrationId, crowdinId, provider]));
466
- });
467
- }
468
- updateFilesSnapshot(files, integrationId, crowdinId, provider) {
469
- return __awaiter(this, void 0, void 0, function* () {
470
- yield this.dbPromise;
471
- yield this.executeQuery((connection) => connection.execute('UPDATE files_snapshot SET files = ? WHERE integration_id = ? AND crowdin_id = ? AND provider = ?', [files, integrationId, crowdinId, provider]));
472
- });
473
- }
474
- getFilesSnapshot(integrationId, crowdinId, provider) {
475
- return __awaiter(this, void 0, void 0, function* () {
476
- yield this.dbPromise;
477
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
478
- const [rows] = yield connection.execute('SELECT id, files, integration_id as "integrationId", crowdin_id as "crowdinId" FROM files_snapshot WHERE integration_id = ? AND crowdin_id = ? AND provider = ?', [integrationId, crowdinId, provider]);
479
- return (rows || [])[0];
480
- }));
481
- });
482
- }
483
- getAllWebhooks(integrationId, crowdinId, provider) {
484
- return __awaiter(this, void 0, void 0, function* () {
485
- yield this.dbPromise;
486
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
487
- const [rows] = yield connection.execute('SELECT id, file_id as "fileId", integration_id as "integrationId", crowdin_id as "crowdinId" FROM webhooks WHERE integration_id = ? AND crowdin_id = ? AND provider = ?', [integrationId, crowdinId, provider]);
488
- return rows || [];
489
- }));
490
- });
491
- }
492
- getWebhooks(fileId, integrationId, crowdinId, provider) {
493
- return __awaiter(this, void 0, void 0, function* () {
494
- yield this.dbPromise;
495
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
496
- const [rows] = yield connection.execute('SELECT id, file_id as "fileId", integration_id as "integrationId", crowdin_id as "crowdinId" FROM webhooks WHERE file_id = ? AND integration_id = ? AND crowdin_id = ? AND provider = ?', [fileId, integrationId, crowdinId, provider]);
497
- return (rows || [])[0];
498
- }));
499
- });
500
- }
501
- saveWebhooks(fileId, integrationId, crowdinId, provider) {
502
- return __awaiter(this, void 0, void 0, function* () {
503
- yield this.dbPromise;
504
- yield this.executeQuery((connection) => connection.execute('INSERT INTO webhooks(file_id, integration_id, crowdin_id, provider) VALUES (?, ?, ?, ?)', [fileId, integrationId, crowdinId, provider]));
505
- });
506
- }
507
- deleteWebhooks(fileIds, integrationId, crowdinId, provider) {
508
- return __awaiter(this, void 0, void 0, function* () {
509
- if (!fileIds.length) {
510
- return;
511
- }
512
- yield this.dbPromise;
513
- const placeholders = fileIds.map(() => '?').join(',');
514
- yield this.executeQuery((connection) => connection.execute(`DELETE
515
- FROM webhooks
516
- WHERE file_id IN (${placeholders})
517
- AND integration_id = ?
518
- AND crowdin_id = ?
519
- AND provider = ?`, [...fileIds, integrationId, crowdinId, provider]));
520
- });
521
- }
522
- getAllUserErrors(crowdinId, integrationId) {
523
- return __awaiter(this, void 0, void 0, function* () {
524
- yield this.dbPromise;
525
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
526
- let whereIntegrationCondition = 'integration_id is NULL';
527
- const params = [crowdinId];
528
- if (integrationId) {
529
- whereIntegrationCondition = 'integration_id = ?';
530
- params.push(integrationId);
531
- }
532
- const [rows] = yield connection.execute(`SELECT id, action, message, data, created_at as "createdAt"
533
- FROM user_errors
534
- WHERE crowdin_id = ? AND ${whereIntegrationCondition}`, params);
535
- return rows || [];
536
- }));
537
- });
538
- }
539
- saveUserError(action, message, data, createdAt, crowdinId, integrationId) {
540
- return __awaiter(this, void 0, void 0, function* () {
541
- yield this.dbPromise;
542
- yield this.executeQuery((connection) => connection.execute('INSERT INTO user_errors(action, message, data, created_at, integration_id, crowdin_id) VALUES (?, ?, ?, ?, ?, ?)', [action, message, data, createdAt, integrationId, crowdinId]));
543
- });
544
- }
545
- deleteUserErrors(createdAt, crowdinId, integrationId) {
546
- return __awaiter(this, void 0, void 0, function* () {
547
- yield this.dbPromise;
548
- yield this.executeQuery((connection) => {
549
- let whereIntegrationCondition = 'integration_id is NULL';
550
- const params = [createdAt, crowdinId];
551
- if (integrationId) {
552
- whereIntegrationCondition = 'integration_id = ?';
553
- params.push(integrationId);
554
- }
555
- return connection.execute(`DELETE
556
- FROM user_errors
557
- WHERE created_at < ?
558
- AND crowdin_id = ?
559
- AND ${whereIntegrationCondition}`, params);
560
- });
561
- });
562
- }
563
- deleteAllUsersErrorsOlderThan(createdAt) {
564
- return __awaiter(this, void 0, void 0, function* () {
565
- yield this.dbPromise;
566
- yield this.executeQuery((connection) => connection.execute('DELETE FROM user_errors WHERE created_at < ?', [createdAt]));
567
- });
568
- }
569
- saveIntegrationConfig(integrationId, crowdinId, config) {
570
- return __awaiter(this, void 0, void 0, function* () {
571
- yield this.dbPromise;
572
- yield this.executeQuery((connection) => connection.execute('INSERT INTO integration_settings(integrationId, crowdin_id, config) VALUES (?, ?, ?)', [
573
- integrationId,
574
- crowdinId,
575
- config,
576
- ]));
577
- });
578
- }
579
- getAllIntegrationConfigs(crowdinId) {
580
- return __awaiter(this, void 0, void 0, function* () {
581
- yield this.dbPromise;
582
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
583
- const [rows] = yield connection.execute('SELECT config FROM integration_settings WHERE crowdin_id = ?', [
584
- crowdinId,
585
- ]);
586
- return rows || [];
587
- }));
588
- });
589
- }
590
- getIntegrationConfig(integrationId) {
591
- return __awaiter(this, void 0, void 0, function* () {
592
- yield this.dbPromise;
593
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
594
- const [rows] = yield connection.execute('SELECT config FROM integration_settings WHERE integration_id = ?', [integrationId]);
595
- return (rows || [])[0];
596
- }));
597
- });
598
- }
599
- updateIntegrationConfig(integrationId, config) {
600
- return __awaiter(this, void 0, void 0, function* () {
601
- yield this.dbPromise;
602
- yield this.executeQuery((connection) => connection.execute('UPDATE integration_settings SET config = ? WHERE id = ?', [config, integrationId]));
603
- });
604
- }
605
- createJob(_a) {
606
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, type, title, payload, initiatedBy }) {
607
- const id = (0, crypto_1.randomUUID)();
608
- yield this.dbPromise;
609
- yield this.executeQuery((connection) => connection.execute(`
610
- INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, initiated_by, created_at)
611
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
612
- `, [id, integrationId, crowdinId, type, payload, title, initiatedBy !== null && initiatedBy !== void 0 ? initiatedBy : null, Date.now().toString()]));
613
- return id;
614
- });
615
- }
616
- updateJob(_a) {
617
- return __awaiter(this, arguments, void 0, function* ({ id, progress, status, info, data, attempt, errors, processedEntities, }) {
618
- const updateFields = ['updated_at'];
619
- const updateParams = [Date.now().toString()];
620
- if (progress) {
621
- updateFields.push('progress = ?');
622
- updateParams.push(Math.round(progress));
623
- if (progress >= 100) {
624
- updateFields.push('finished_at = ?');
625
- updateParams.push(Date.now().toString());
626
- }
627
- }
628
- if (status) {
629
- updateFields.push('status = ?');
630
- updateParams.push(status);
631
- if (!updateFields.includes('finished_at = ?') && [types_1.JobStatus.FAILED, types_1.JobStatus.CANCELED].includes(status)) {
632
- updateFields.push('finished_at = ?');
633
- updateParams.push(Date.now().toString());
634
- }
635
- }
636
- if (data) {
637
- updateFields.push('data = ?');
638
- updateParams.push(data);
639
- }
640
- if (info) {
641
- updateFields.push('info = ?');
642
- updateParams.push(info);
643
- }
644
- if (attempt) {
645
- updateFields.push('attempt = ?');
646
- updateParams.push(attempt);
647
- }
648
- if (errors) {
649
- updateFields.push('errors = ?');
650
- updateParams.push(JSON.stringify(errors));
651
- }
652
- if (processedEntities) {
653
- updateFields.push('processed_entities = ?');
654
- updateParams.push(processedEntities);
655
- }
656
- updateParams.push(id);
657
- yield this.dbPromise;
658
- yield this.executeQuery((connection) => connection.execute(`
659
- UPDATE job
660
- SET ${updateFields.join(', ')}
661
- WHERE id = ?
662
- `, updateParams));
663
- });
664
- }
665
- getJob(_a) {
666
- return __awaiter(this, arguments, void 0, function* ({ id }) {
667
- yield this.dbPromise;
668
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
669
- const [rows] = yield connection.execute(`
670
- SELECT id,
671
- integration_id as "integrationId",
672
- crowdin_id as "crowdinId",
673
- type,
674
- payload,
675
- progress,
676
- status,
677
- title,
678
- info,
679
- data,
680
- attempt,
681
- errors,
682
- processed_entities as "processedEntities",
683
- initiated_by as "initiatedBy",
684
- created_at as "createdAt",
685
- updated_at as "updatedAt",
686
- finished_at as "finishedAt"
687
- FROM job
688
- WHERE id = ?
689
- `, [id]);
690
- return (rows || [])[0];
691
- }));
692
- });
693
- }
694
- getActiveJobs(_a) {
695
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId }) {
696
- yield this.dbPromise;
697
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
698
- const [rows] = yield connection.execute(`
699
- SELECT id,
700
- integration_id as "integrationId",
701
- crowdin_id as "crowdinId",
702
- type,
703
- payload,
704
- progress,
705
- status,
706
- title,
707
- info,
708
- data,
709
- attempt,
710
- errors,
711
- processed_entities as "processedEntities",
712
- initiated_by as "initiatedBy",
713
- created_at as "createdAt",
714
- updated_at as "updatedAt",
715
- finished_at as "finishedAt"
716
- FROM job
717
- WHERE integration_id = ?
718
- AND crowdin_id = ?
719
- AND finished_at is NULL
720
- `, [integrationId, crowdinId]);
721
- return rows || [];
722
- }));
723
- });
724
- }
725
- deleteFinishedJobs() {
726
- return __awaiter(this, void 0, void 0, function* () {
727
- yield this.dbPromise;
728
- yield this.executeQuery((connection) => connection.execute('DELETE FROM job WHERE finished_at is not NULL', []));
729
- });
730
- }
731
- getAllInProgressJobs() {
732
- return __awaiter(this, void 0, void 0, function* () {
733
- yield this.dbPromise;
734
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
735
- const [rows] = yield connection.execute(`
736
- SELECT id,
737
- integration_id as "integrationId",
738
- crowdin_id as "crowdinId",
739
- type,
740
- payload,
741
- progress,
742
- status,
743
- title,
744
- info,
745
- data,
746
- attempt,
747
- errors,
748
- processed_entities as "processedEntities",
749
- initiated_by as "initiatedBy",
750
- created_at as "createdAt",
751
- updated_at as "updatedAt",
752
- finished_at as "finishedAt"
753
- FROM job
754
- WHERE status IN (?, ?)
755
- AND finished_at is NULL
756
- `, [types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED]);
757
- return rows || [];
758
- }));
759
- });
760
- }
761
- getAllJobs(_a) {
762
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, limit, offset }) {
763
- yield this.dbPromise;
764
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
765
- const [rows] = yield connection.execute(`
766
- SELECT
767
- id,
768
- integration_id as "integrationId",
769
- crowdin_id as "crowdinId",
770
- type,
771
- payload,
772
- progress,
773
- status,
774
- title,
775
- info,
776
- data,
777
- attempt,
778
- initiated_by as "initiatedBy",
779
- created_at as "createdAt",
780
- updated_at as "updatedAt",
781
- finished_at as "finishedAt"
782
- FROM job
783
- WHERE integration_id = ?
784
- AND crowdin_id = ?
785
- ORDER BY created_at DESC
786
- LIMIT ? OFFSET ?
787
- `, [integrationId, crowdinId, limit, offset]);
788
- return rows || [];
789
- }));
790
- });
791
- }
792
- saveTranslationCache(_a) {
793
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, fileId, languageId, etag, }) {
794
- yield this.dbPromise;
795
- yield this.executeQuery((connection) => connection.execute(`
796
- INSERT INTO translation_file_cache(integration_id, crowdin_id, file_id, language_id, etag)
797
- VALUES (?, ?, ?, ?, ?)
798
- `, [integrationId, crowdinId, fileId, languageId, etag]));
799
- });
800
- }
801
- getFileTranslationCache(_a) {
802
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, fileId, }) {
803
- yield this.dbPromise;
804
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
805
- const [rows] = yield connection.execute(`
806
- SELECT integration_id as "integrationId",
807
- crowdin_id as "crowdinId",
808
- file_id as "fileId",
809
- language_id as "languageId",
810
- etag
811
- FROM translation_file_cache
812
- WHERE integration_id = ?
813
- AND crowdin_id = ?
814
- AND file_id = ?
815
- `, [integrationId, crowdinId, fileId]);
816
- return rows || [];
817
- }));
818
- });
819
- }
820
- getFileTranslationCacheByLanguage(_a) {
821
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, fileId, languageId, }) {
822
- yield this.dbPromise;
823
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
824
- const [rows] = yield connection.execute(`
825
- SELECT integration_id as "integrationId",
826
- crowdin_id as "crowdinId",
827
- file_id as "fileId",
828
- language_id as "languageId",
829
- etag
830
- FROM translation_file_cache
831
- WHERE integration_id = ?
832
- AND crowdin_id = ?
833
- AND file_id = ?
834
- AND language_id = ?
835
- `, [integrationId, crowdinId, fileId, languageId]);
836
- return (rows || [])[0];
837
- }));
838
- });
839
- }
840
- updateTranslationCache(_a) {
841
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, fileId, languageId, etag, }) {
842
- yield this.dbPromise;
843
- yield this.executeQuery((connection) => connection.execute(`
844
- UPDATE translation_file_cache
845
- SET etag = ?
846
- WHERE integration_id = ?
847
- AND crowdin_id = ?
848
- AND file_id = ?
849
- AND language_id = ?
850
- `, [etag, integrationId, crowdinId, fileId, languageId]));
851
- });
852
- }
853
- saveUnsyncedFiles(_a) {
854
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, files }) {
855
- yield this.dbPromise;
856
- yield this.executeQuery((connection) => connection.execute(`
857
- INSERT INTO unsynced_files(integration_id, crowdin_id, files)
858
- VALUES (?, ?, ?,)
859
- `, [integrationId, crowdinId, files]));
860
- });
861
- }
862
- updateUnsyncedFiles(_a) {
863
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId, files }) {
864
- yield this.dbPromise;
865
- yield this.executeQuery((connection) => connection.execute(`
866
- UPDATE unsynced_files
867
- SET files = ?
868
- WHERE integration_id = ?
869
- AND crowdin_id = ?
870
- `, [files, integrationId, crowdinId]));
871
- });
872
- }
873
- getUnsyncedFiles(_a) {
874
- return __awaiter(this, arguments, void 0, function* ({ integrationId, crowdinId }) {
875
- yield this.dbPromise;
876
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
877
- const [rows] = yield connection.execute(`
878
- SELECT fileIds
879
- FROM unsynced_files
880
- WHERE integration_id = ?
881
- AND crowdin_id = ?
882
- `, [integrationId, crowdinId]);
883
- return (rows || [])[0];
884
- }));
885
- });
886
- }
887
- registerCustomTable(tableName, schema) {
888
- return __awaiter(this, void 0, void 0, function* () {
889
- const columns = Object.entries(schema)
890
- .map(([col, def]) => `${col} ${def}`)
891
- .join(', ');
892
- const query = `CREATE TABLE IF NOT EXISTS ${tableName}
893
- (
894
- ${columns}
895
- );`;
896
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
897
- yield connection.execute(query);
898
- return;
899
- }));
900
- });
901
- }
902
- insertRecord(tableName, data) {
903
- return __awaiter(this, void 0, void 0, function* () {
904
- const columns = Object.keys(data).join(', ');
905
- const placeholders = Object.keys(data)
906
- .map(() => '?')
907
- .join(', ');
908
- const values = Object.values(data);
909
- const query = `INSERT INTO ${tableName} (${columns})
910
- VALUES (${placeholders});`;
911
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
912
- yield connection.execute(query, values);
913
- return;
914
- }));
915
- });
916
- }
917
- selectRecords(tableName_1) {
918
- return __awaiter(this, arguments, void 0, function* (tableName, options = {}, params = []) {
919
- var _a;
920
- const columns = ((_a = options.columns) === null || _a === void 0 ? void 0 : _a.length) ? options.columns.join(', ') : '*';
921
- const distinctKeyword = options.distinct ? 'DISTINCT ' : '';
922
- const whereClause = options.whereClause ? ` ${options.whereClause}` : '';
923
- const orderByClause = options.orderBy ? ` ORDER BY ${options.orderBy}` : '';
924
- let limitClause = options.limit ? ` LIMIT ${options.limit}` : '';
925
- if (!options.limit && options.offset) {
926
- throw new Error('[selectRecords] Limit is required for pagination with MySQL');
927
- }
928
- else if (options.limit && options.offset) {
929
- limitClause += ` OFFSET ${options.offset}`;
930
- }
931
- const query = `SELECT ${distinctKeyword}${columns} FROM ${tableName}${whereClause}${orderByClause}${limitClause};`;
932
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
933
- const [rows] = yield connection.execute(query, params);
934
- return rows;
935
- }));
936
- });
937
- }
938
- updateRecord(tableName_1, data_1, whereClause_1) {
939
- return __awaiter(this, arguments, void 0, function* (tableName, data, whereClause, params = []) {
940
- const setClause = Object.keys(data)
941
- .map((key) => `${key} = ?`)
942
- .join(', ');
943
- const values = Object.values(data);
944
- const query = `UPDATE ${tableName}
945
- SET ${setClause} ${whereClause};`;
946
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
947
- yield connection.execute(query, [...values, ...params]);
948
- return;
949
- }));
950
- });
951
- }
952
- deleteRecord(tableName_1, whereClause_1) {
953
- return __awaiter(this, arguments, void 0, function* (tableName, whereClause, params = []) {
954
- const query = `DELETE
955
- FROM ${tableName} ${whereClause};`;
956
- yield this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
957
- yield connection.execute(query, params);
958
- return;
959
- }));
960
- });
961
- }
962
- saveSyncedData(files, integrationId, crowdinId, type) {
963
- return __awaiter(this, void 0, void 0, function* () {
964
- yield this.dbPromise;
965
- yield this.executeQuery((connection) => connection.execute('INSERT INTO synced_data(files, integration_id, crowdin_id, type, updated_at) VALUES (?, ?, ?, ?, ?)', [files, integrationId, crowdinId, type, Date.now().toString()]));
966
- });
967
- }
968
- updateSyncedData(files, integrationId, crowdinId, type) {
969
- return __awaiter(this, void 0, void 0, function* () {
970
- yield this.dbPromise;
971
- yield this.executeQuery((connection) => connection.execute('UPDATE synced_data SET files = ?, updated_at = ? WHERE integration_id = ? AND crowdin_id = ? AND type = ?', [files, Date.now().toString(), integrationId, crowdinId, type]));
972
- });
973
- }
974
- getSyncedData(integrationId, crowdinId, type) {
975
- return __awaiter(this, void 0, void 0, function* () {
976
- yield this.dbPromise;
977
- return this.executeQuery((connection) => __awaiter(this, void 0, void 0, function* () {
978
- const [rows] = yield connection.execute('SELECT id, files, integration_id as "integrationId", crowdin_id as "crowdinId", type, updated_at as "updatedAt" FROM synced_data WHERE integration_id = ? AND crowdin_id = ? AND type = ?', [integrationId, crowdinId, type]);
979
- return (rows || [])[0];
980
- }));
981
- });
982
- }
983
- }
984
- exports.MySQLStorage = MySQLStorage;