@crowdin/app-project-module 2.7.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/modules/ai-provider/handlers/chat-completions.js +9 -1
- package/out/modules/ai-provider/handlers/get-model-list.js +3 -0
- package/out/modules/ai-provider/types.d.ts +38 -1
- package/out/modules/integration/handlers/invite-users.js +30 -1
- package/out/modules/integration/handlers/users.js +3 -0
- package/out/modules/manifest.js +1 -2
- package/out/static/css/styles.css +1 -1
- package/out/static/ui/about.bundle.js +17225 -412
- package/out/static/ui/about.bundle.js.map +1 -1
- package/out/static/ui/error.bundle.js +17225 -412
- package/out/static/ui/error.bundle.js.map +1 -1
- package/out/static/ui/form.bundle.js +24365 -5884
- package/out/static/ui/form.bundle.js.map +1 -1
- package/out/static/ui/install.bundle.js +17225 -412
- package/out/static/ui/install.bundle.js.map +1 -1
- package/out/static/ui/login.bundle.js +17225 -412
- package/out/static/ui/login.bundle.js.map +1 -1
- package/out/static/ui/main.bundle.js +17390 -462
- package/out/static/ui/main.bundle.js.map +1 -1
- package/out/static/ui/oauth.bundle.js +17225 -412
- package/out/static/ui/oauth.bundle.js.map +1 -1
- package/out/static/ui/subscription.bundle.js +17225 -412
- package/out/static/ui/subscription.bundle.js.map +1 -1
- package/out/storage/drizzle/index.d.ts +3 -1
- package/out/storage/drizzle/index.js +104 -66
- package/package.json +14 -15
|
@@ -8,7 +8,7 @@ export declare class DrizzleStorage implements Storage {
|
|
|
8
8
|
protected readonly schema: typeof POSTGRESQL_SCHEMA;
|
|
9
9
|
protected readonly type: DB_TYPE;
|
|
10
10
|
protected readonly migrationPromise: Promise<void>;
|
|
11
|
-
|
|
11
|
+
private _delayedMigrationPromise;
|
|
12
12
|
protected readonly config: Config | UnauthorizedConfig;
|
|
13
13
|
constructor({ config, type, delayedMigration, }: {
|
|
14
14
|
config: Config | UnauthorizedConfig;
|
|
@@ -16,6 +16,8 @@ export declare class DrizzleStorage implements Storage {
|
|
|
16
16
|
delayedMigration?: boolean;
|
|
17
17
|
});
|
|
18
18
|
migrateDelayed(): Promise<void>;
|
|
19
|
+
private _cascadeDelete;
|
|
20
|
+
private _executeMigration;
|
|
19
21
|
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
20
22
|
updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
21
23
|
getCrowdinCredentials(id: string): Promise<CrowdinCredentials | undefined>;
|
|
@@ -31,7 +31,6 @@ class DrizzleStorage {
|
|
|
31
31
|
// schema: typeof D1_SCHEMA;
|
|
32
32
|
constructor({ config, type, delayedMigration, }) {
|
|
33
33
|
var _a, _b, _c, _d, _e;
|
|
34
|
-
this.migrated = false;
|
|
35
34
|
let db;
|
|
36
35
|
if (type === 'd1') {
|
|
37
36
|
db = (0, d1_1.initD1)(Object.assign(Object.assign({}, config.d1Config), { additionalSchema: (_a = config.customTables) === null || _a === void 0 ? void 0 : _a.schema }));
|
|
@@ -47,14 +46,14 @@ class DrizzleStorage {
|
|
|
47
46
|
directoryPath: config.migrateToPostgreFromSQLite ? config.dbFolder : undefined,
|
|
48
47
|
additionalMigrationFolder: (_c = config.customTables) === null || _c === void 0 ? void 0 : _c.migrationFolder,
|
|
49
48
|
});
|
|
50
|
-
this.
|
|
49
|
+
this._delayedMigrationPromise = Promise.resolve();
|
|
51
50
|
}
|
|
52
51
|
else {
|
|
53
52
|
db = (0, sqlite_1.initSqlite)(config.dbFolder, (_d = config.customTables) === null || _d === void 0 ? void 0 : _d.schema);
|
|
54
53
|
this.migrationPromise = delayedMigration
|
|
55
54
|
? Promise.resolve()
|
|
56
55
|
: (0, sqlite_1.migrateSqlite)(db, (_e = config.customTables) === null || _e === void 0 ? void 0 : _e.migrationFolder);
|
|
57
|
-
this.
|
|
56
|
+
this._delayedMigrationPromise = Promise.resolve();
|
|
58
57
|
}
|
|
59
58
|
// using cast here to avoid ts errors, since all drivers should have the same methods, just different clients
|
|
60
59
|
this.db = db;
|
|
@@ -64,26 +63,55 @@ class DrizzleStorage {
|
|
|
64
63
|
}
|
|
65
64
|
migrateDelayed() {
|
|
66
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
if (!this._delayedMigrationPromise) {
|
|
67
|
+
this._delayedMigrationPromise = this._executeMigration();
|
|
68
|
+
}
|
|
69
|
+
return this._delayedMigrationPromise;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Each backend needs a different atomic delete strategy:
|
|
73
|
+
// - better-sqlite3: synchronous transaction (async callbacks are not awaited by the driver)
|
|
74
|
+
// - D1: batch API (Workers runtime does not support BEGIN/COMMIT via the JS binding)
|
|
75
|
+
// - PostgreSQL: standard async transaction
|
|
76
|
+
_cascadeDelete(pairs) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
if (this.type === 'sqlite') {
|
|
79
|
+
this.db.transaction((tx) => {
|
|
80
|
+
for (const { table, condition } of pairs) {
|
|
81
|
+
tx.delete(table).where(condition).run();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else if (this.type === 'd1') {
|
|
86
|
+
const d1Db = this.db;
|
|
87
|
+
yield d1Db.batch(pairs.map(({ table, condition }) => d1Db.delete(table).where(condition)));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
yield this.db.transaction((tx) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
for (const { table, condition } of pairs) {
|
|
92
|
+
yield tx.delete(table).where(condition);
|
|
93
|
+
}
|
|
94
|
+
}));
|
|
84
95
|
}
|
|
85
96
|
});
|
|
86
97
|
}
|
|
98
|
+
_executeMigration() {
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
if (this.type === 'd1') {
|
|
101
|
+
return (0, d1_1.migrateD1)(this.db, (_a = this.config.customTables) === null || _a === void 0 ? void 0 : _a.d1Migrations);
|
|
102
|
+
}
|
|
103
|
+
else if (this.type === 'postgresql') {
|
|
104
|
+
return (0, postgresql_1.migratePostgreSQL)({
|
|
105
|
+
db: this.db,
|
|
106
|
+
name: this.config.name,
|
|
107
|
+
directoryPath: this.config.migrateToPostgreFromSQLite ? this.config.dbFolder : undefined,
|
|
108
|
+
additionalMigrationFolder: (_b = this.config.customTables) === null || _b === void 0 ? void 0 : _b.migrationFolder,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return (0, sqlite_1.migrateSqlite)(this.db, (_c = this.config.customTables) === null || _c === void 0 ? void 0 : _c.migrationFolder);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
87
115
|
saveCrowdinCredentials(credentials) {
|
|
88
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
117
|
yield this.migrationPromise;
|
|
@@ -168,22 +196,23 @@ class DrizzleStorage {
|
|
|
168
196
|
deleteCrowdinCredentials(id) {
|
|
169
197
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
198
|
yield this.migrationPromise;
|
|
171
|
-
yield this.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
.
|
|
184
|
-
.
|
|
185
|
-
|
|
186
|
-
|
|
199
|
+
yield this._cascadeDelete([
|
|
200
|
+
{ table: this.schema.crowdinCredentials, condition: (0, drizzle_orm_1.eq)(this.schema.crowdinCredentials.id, id) },
|
|
201
|
+
{
|
|
202
|
+
table: this.schema.integrationCredentials,
|
|
203
|
+
condition: (0, drizzle_orm_1.eq)(this.schema.integrationCredentials.crowdin_id, id),
|
|
204
|
+
},
|
|
205
|
+
{ table: this.schema.syncSettings, condition: (0, drizzle_orm_1.eq)(this.schema.syncSettings.crowdin_id, id) },
|
|
206
|
+
{ table: this.schema.appMetadata, condition: (0, drizzle_orm_1.eq)(this.schema.appMetadata.crowdin_id, id) },
|
|
207
|
+
{ table: this.schema.filesSnapshot, condition: (0, drizzle_orm_1.eq)(this.schema.filesSnapshot.crowdin_id, id) },
|
|
208
|
+
{ table: this.schema.webhooks, condition: (0, drizzle_orm_1.eq)(this.schema.webhooks.crowdin_id, id) },
|
|
209
|
+
{ table: this.schema.userErrors, condition: (0, drizzle_orm_1.eq)(this.schema.userErrors.crowdin_id, id) },
|
|
210
|
+
{ table: this.schema.integrationSettings, condition: (0, drizzle_orm_1.eq)(this.schema.integrationSettings.crowdin_id, id) },
|
|
211
|
+
{ table: this.schema.job, condition: (0, drizzle_orm_1.eq)(this.schema.job.crowdin_id, id) },
|
|
212
|
+
{ table: this.schema.translationFileCache, condition: (0, drizzle_orm_1.eq)(this.schema.translationFileCache.crowdin_id, id) },
|
|
213
|
+
{ table: this.schema.unsyncedFiles, condition: (0, drizzle_orm_1.eq)(this.schema.unsyncedFiles.crowdin_id, id) },
|
|
214
|
+
{ table: this.schema.syncedData, condition: (0, drizzle_orm_1.eq)(this.schema.syncedData.crowdin_id, id) },
|
|
215
|
+
]);
|
|
187
216
|
});
|
|
188
217
|
}
|
|
189
218
|
saveIntegrationCredentials(id, credentials, crowdinId) {
|
|
@@ -248,41 +277,50 @@ class DrizzleStorage {
|
|
|
248
277
|
deleteIntegrationCredentials(id) {
|
|
249
278
|
return __awaiter(this, void 0, void 0, function* () {
|
|
250
279
|
yield this.migrationPromise;
|
|
251
|
-
yield this.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
.
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
280
|
+
yield this._cascadeDelete([
|
|
281
|
+
{ table: this.schema.integrationCredentials, condition: (0, drizzle_orm_1.eq)(this.schema.integrationCredentials.id, id) },
|
|
282
|
+
{ table: this.schema.syncSettings, condition: (0, drizzle_orm_1.eq)(this.schema.syncSettings.integration_id, id) },
|
|
283
|
+
{ table: this.schema.filesSnapshot, condition: (0, drizzle_orm_1.eq)(this.schema.filesSnapshot.integration_id, id) },
|
|
284
|
+
{ table: this.schema.webhooks, condition: (0, drizzle_orm_1.eq)(this.schema.webhooks.integration_id, id) },
|
|
285
|
+
{ table: this.schema.userErrors, condition: (0, drizzle_orm_1.eq)(this.schema.userErrors.integration_id, id) },
|
|
286
|
+
{
|
|
287
|
+
table: this.schema.integrationSettings,
|
|
288
|
+
condition: (0, drizzle_orm_1.eq)(this.schema.integrationSettings.integration_id, id),
|
|
289
|
+
},
|
|
290
|
+
{ table: this.schema.job, condition: (0, drizzle_orm_1.eq)(this.schema.job.integration_id, id) },
|
|
291
|
+
{
|
|
292
|
+
table: this.schema.translationFileCache,
|
|
293
|
+
condition: (0, drizzle_orm_1.eq)(this.schema.translationFileCache.integration_id, id),
|
|
294
|
+
},
|
|
295
|
+
{ table: this.schema.unsyncedFiles, condition: (0, drizzle_orm_1.eq)(this.schema.unsyncedFiles.integration_id, id) },
|
|
296
|
+
{ table: this.schema.syncedData, condition: (0, drizzle_orm_1.eq)(this.schema.syncedData.integration_id, id) },
|
|
297
|
+
]);
|
|
265
298
|
});
|
|
266
299
|
}
|
|
267
300
|
deleteAllIntegrationCredentials(crowdinId) {
|
|
268
301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
269
302
|
yield this.migrationPromise;
|
|
270
|
-
yield this.
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
.
|
|
284
|
-
|
|
285
|
-
|
|
303
|
+
yield this._cascadeDelete([
|
|
304
|
+
{
|
|
305
|
+
table: this.schema.integrationCredentials,
|
|
306
|
+
condition: (0, drizzle_orm_1.eq)(this.schema.integrationCredentials.crowdin_id, crowdinId),
|
|
307
|
+
},
|
|
308
|
+
{ table: this.schema.syncSettings, condition: (0, drizzle_orm_1.eq)(this.schema.syncSettings.crowdin_id, crowdinId) },
|
|
309
|
+
{ table: this.schema.filesSnapshot, condition: (0, drizzle_orm_1.eq)(this.schema.filesSnapshot.crowdin_id, crowdinId) },
|
|
310
|
+
{ table: this.schema.webhooks, condition: (0, drizzle_orm_1.eq)(this.schema.webhooks.crowdin_id, crowdinId) },
|
|
311
|
+
{ table: this.schema.userErrors, condition: (0, drizzle_orm_1.eq)(this.schema.userErrors.crowdin_id, crowdinId) },
|
|
312
|
+
{
|
|
313
|
+
table: this.schema.integrationSettings,
|
|
314
|
+
condition: (0, drizzle_orm_1.eq)(this.schema.integrationSettings.crowdin_id, crowdinId),
|
|
315
|
+
},
|
|
316
|
+
{ table: this.schema.job, condition: (0, drizzle_orm_1.eq)(this.schema.job.crowdin_id, crowdinId) },
|
|
317
|
+
{
|
|
318
|
+
table: this.schema.translationFileCache,
|
|
319
|
+
condition: (0, drizzle_orm_1.eq)(this.schema.translationFileCache.crowdin_id, crowdinId),
|
|
320
|
+
},
|
|
321
|
+
{ table: this.schema.unsyncedFiles, condition: (0, drizzle_orm_1.eq)(this.schema.unsyncedFiles.crowdin_id, crowdinId) },
|
|
322
|
+
{ table: this.schema.syncedData, condition: (0, drizzle_orm_1.eq)(this.schema.syncedData.crowdin_id, crowdinId) },
|
|
323
|
+
]);
|
|
286
324
|
});
|
|
287
325
|
}
|
|
288
326
|
saveMetadata(id, metadata, crowdinId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crowdin/app-project-module",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.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",
|
|
@@ -57,24 +57,23 @@
|
|
|
57
57
|
"out/**/*"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@crowdin/crowdin-api-client": "^1.
|
|
60
|
+
"@crowdin/crowdin-api-client": "^1.56.1",
|
|
61
61
|
"@crowdin/logs-formatter": "^2.4.0",
|
|
62
62
|
"@godaddy/terminus": "^4.12.1",
|
|
63
|
-
"ajv": "^8.
|
|
63
|
+
"ajv": "^8.20.0",
|
|
64
64
|
"amqplib": "^2.0.1",
|
|
65
|
-
"better-sqlite3": "^
|
|
65
|
+
"better-sqlite3": "^13.0.2",
|
|
66
66
|
"cors": "^2.8.6",
|
|
67
67
|
"drizzle-orm": "^0.45.2",
|
|
68
68
|
"express": "^5.2.1",
|
|
69
|
-
"express-rate-limit": "^8.
|
|
70
|
-
"jsonwebtoken": "^9.0.
|
|
71
|
-
"minimatch": "^10.
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"react": "^
|
|
76
|
-
"
|
|
77
|
-
"swagger-jsdoc": "^6.2.8"
|
|
69
|
+
"express-rate-limit": "^8.6.1",
|
|
70
|
+
"jsonwebtoken": "^9.0.3",
|
|
71
|
+
"minimatch": "^10.2.6",
|
|
72
|
+
"node-cron": "^4.6.0",
|
|
73
|
+
"pg": "^8.22.0",
|
|
74
|
+
"react": "^19.2.8",
|
|
75
|
+
"react-dom": "^19.2.8",
|
|
76
|
+
"swagger-jsdoc": "^6.3.0"
|
|
78
77
|
},
|
|
79
78
|
"peerDependencies": {
|
|
80
79
|
"@aws-sdk/client-s3": "^3.995.0",
|
|
@@ -117,8 +116,8 @@
|
|
|
117
116
|
"@types/minimatch": "^5.1.2",
|
|
118
117
|
"@types/node": "^20",
|
|
119
118
|
"@types/pg": "^8.16.0",
|
|
120
|
-
"@types/react": "^
|
|
121
|
-
"@types/react-dom": "^
|
|
119
|
+
"@types/react": "^19.2.18",
|
|
120
|
+
"@types/react-dom": "^19.2.4",
|
|
122
121
|
"@types/swagger-jsdoc": "^6.0.4",
|
|
123
122
|
"@typescript-eslint/eslint-plugin": "^8.56.0",
|
|
124
123
|
"@typescript-eslint/parser": "^8.56.0",
|