@crowdin/app-project-module 0.108.0 → 1.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.
- package/out/app-test/integration/get-integration-files.js +16 -4
- package/out/app-test/integration/types.d.ts +1 -1
- package/out/app-test/integration/update-crowdin.js +2 -2
- package/out/app-test/integration/update-integration.js +2 -2
- package/out/index.d.ts +2 -1
- package/out/index.js +73 -30
- package/out/middlewares/auto-credentials-masker.d.ts +4 -0
- package/out/middlewares/auto-credentials-masker.js +45 -0
- package/out/middlewares/crowdin-client.d.ts +1 -1
- package/out/middlewares/integration-credentials.d.ts +2 -2
- package/out/middlewares/integration-credentials.js +7 -4
- package/out/middlewares/render-ui-module.d.ts +3 -3
- package/out/middlewares/render-ui-module.js +10 -13
- package/out/middlewares/ui-module.d.ts +1 -1
- package/out/middlewares/ui-module.js +11 -1
- package/out/modules/about.d.ts +2 -1
- package/out/modules/about.js +10 -3
- package/out/modules/ai-prompt-provider/handlers/compile.d.ts +1 -1
- package/out/modules/ai-prompt-provider/handlers/compile.js +7 -1
- package/out/modules/ai-prompt-provider/index.js +2 -2
- package/out/modules/ai-prompt-provider/types.d.ts +7 -1
- package/out/modules/ai-provider/handlers/chat-completions.d.ts +1 -1
- package/out/modules/ai-provider/handlers/chat-completions.js +1 -1
- package/out/modules/ai-provider/handlers/get-model-list.d.ts +1 -1
- package/out/modules/ai-provider/index.js +2 -2
- package/out/modules/ai-provider/types.d.ts +4 -4
- package/out/modules/ai-request-processors/handler.d.ts +1 -1
- package/out/modules/ai-request-processors/handler.js +12 -2
- package/out/modules/ai-request-processors/types.d.ts +12 -2
- package/out/modules/ai-tools/handlers/tool-calls.d.ts +1 -1
- package/out/modules/ai-tools/handlers/tool-calls.js +1 -1
- package/out/modules/ai-tools/index.js +1 -1
- package/out/modules/ai-tools/types.d.ts +1 -1
- package/out/modules/auth-guard/handlers/verify.d.ts +1 -1
- package/out/modules/auth-guard/index.js +1 -1
- package/out/modules/automation-action/handlers/execute.d.ts +1 -1
- package/out/modules/automation-action/handlers/execute.js +1 -1
- package/out/modules/automation-action/handlers/input-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/output-schema.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.d.ts +1 -1
- package/out/modules/automation-action/handlers/validate-settings.js +1 -1
- package/out/modules/automation-action/index.js +1 -1
- package/out/modules/automation-action/types.d.ts +4 -4
- package/out/modules/automation-action/util/index.js +2 -5
- package/out/modules/context-menu/index.js +2 -2
- package/out/modules/custom-mt/handlers/translate.d.ts +1 -1
- package/out/modules/custom-mt/handlers/translate.js +25 -9
- package/out/modules/custom-mt/index.js +3 -3
- package/out/modules/custom-mt/types.d.ts +10 -2
- package/out/modules/custom-spell-check/handlers/get-languages-list.d.ts +1 -1
- package/out/modules/custom-spell-check/handlers/spell-check.d.ts +1 -1
- package/out/modules/custom-spell-check/index.js +4 -4
- package/out/modules/editor-right-panel/index.js +1 -1
- package/out/modules/external-qa-check/handlers/validate.d.ts +1 -1
- package/out/modules/external-qa-check/index.js +2 -2
- package/out/modules/file-processing/handlers/custom-file-format.d.ts +7 -2
- package/out/modules/file-processing/handlers/custom-file-format.js +62 -22
- package/out/modules/file-processing/handlers/file-download.d.ts +1 -1
- package/out/modules/file-processing/handlers/file-download.js +5 -0
- package/out/modules/file-processing/handlers/pre-post-process.d.ts +1 -1
- package/out/modules/file-processing/handlers/pre-post-process.js +41 -15
- package/out/modules/file-processing/handlers/translations-alignment.d.ts +1 -1
- package/out/modules/file-processing/handlers/translations-alignment.js +10 -4
- package/out/modules/file-processing/index.js +12 -2
- package/out/modules/file-processing/types.d.ts +36 -5
- package/out/modules/file-processing/util/defaults.js +50 -6
- package/out/modules/file-processing/util/files.js +2 -1
- package/out/modules/form-data-display.d.ts +1 -1
- package/out/modules/form-data-save.d.ts +1 -1
- package/out/modules/install.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-file-progress.js +5 -1
- package/out/modules/integration/handlers/crowdin-files-target-languages.d.ts +5 -0
- package/out/modules/integration/handlers/crowdin-files-target-languages.js +103 -0
- package/out/modules/integration/handlers/crowdin-files.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-files.js +7 -1
- package/out/modules/integration/handlers/crowdin-project.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-update.js +59 -18
- package/out/modules/integration/handlers/crowdin-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/crowdin-webhook.js +15 -8
- package/out/modules/integration/handlers/integration-data.d.ts +1 -1
- package/out/modules/integration/handlers/integration-data.js +13 -6
- package/out/modules/integration/handlers/integration-login.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.d.ts +1 -1
- package/out/modules/integration/handlers/integration-logout.js +8 -3
- package/out/modules/integration/handlers/integration-update.d.ts +1 -1
- package/out/modules/integration/handlers/integration-update.js +44 -6
- package/out/modules/integration/handlers/integration-webhook.d.ts +1 -1
- package/out/modules/integration/handlers/invite-users.d.ts +1 -1
- package/out/modules/integration/handlers/job-cancel.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.d.ts +1 -1
- package/out/modules/integration/handlers/job-info-deprecated.js +3 -2
- package/out/modules/integration/handlers/job-info.d.ts +1 -1
- package/out/modules/integration/handlers/job-list.d.ts +1 -1
- package/out/modules/integration/handlers/main.d.ts +1 -1
- package/out/modules/integration/handlers/main.js +32 -2
- package/out/modules/integration/handlers/oauth-login.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-login.js +28 -6
- package/out/modules/integration/handlers/oauth-polling.d.ts +1 -1
- package/out/modules/integration/handlers/oauth-url.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/settings-save.js +9 -9
- package/out/modules/integration/handlers/settings.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.d.ts +1 -1
- package/out/modules/integration/handlers/sync-settings-save.js +5 -9
- package/out/modules/integration/handlers/sync-settings.d.ts +1 -1
- package/out/modules/integration/handlers/user-errors.d.ts +1 -1
- package/out/modules/integration/handlers/users.d.ts +1 -1
- package/out/modules/integration/index.js +19 -33
- package/out/modules/integration/types.d.ts +133 -29
- package/out/modules/integration/types.js +1 -0
- package/out/modules/integration/util/cron.d.ts +2 -2
- package/out/modules/integration/util/cron.js +40 -24
- package/out/modules/integration/util/defaults.d.ts +4 -0
- package/out/modules/integration/util/defaults.js +175 -15
- package/out/modules/integration/util/files.d.ts +2 -1
- package/out/modules/integration/util/files.js +19 -8
- package/out/modules/integration/util/job.js +4 -3
- package/out/modules/integration/util/snapshot.js +19 -3
- package/out/modules/integration/util/types.d.ts +1 -0
- package/out/modules/integration/util/types.js +1 -0
- package/out/modules/integration/util/webhooks.d.ts +8 -8
- package/out/modules/integration/util/webhooks.js +34 -17
- package/out/modules/manifest.js +12 -12
- package/out/modules/modal/index.js +2 -2
- package/out/modules/organization-menu/index.js +5 -4
- package/out/modules/organization-settings-menu/index.js +5 -4
- package/out/modules/profile-resources-menu/index.js +5 -4
- package/out/modules/profile-settings-menu/index.js +5 -4
- package/out/modules/project-menu/index.js +1 -1
- package/out/modules/project-menu-crowdsource/index.js +1 -1
- package/out/modules/project-reports/index.js +3 -2
- package/out/modules/project-tools/index.js +3 -2
- package/out/modules/status.d.ts +1 -1
- package/out/modules/status.js +12 -3
- package/out/modules/subscription-paid.d.ts +1 -1
- package/out/modules/uninstall.d.ts +1 -1
- package/out/modules/uninstall.js +1 -1
- package/out/modules/webhooks/handlers/webhook-handler.d.ts +2 -2
- package/out/modules/webhooks/handlers/webhook-handler.js +33 -22
- package/out/modules/webhooks/types.d.ts +7 -0
- package/out/modules/workflow-step-type/handlers/delete-step.d.ts +1 -1
- package/out/modules/workflow-step-type/handlers/step-settings-save.d.ts +1 -1
- package/out/modules/workflow-step-type/index.js +2 -2
- package/out/modules/workflow-step-type/util/index.js +3 -6
- package/out/static/js/dependent.js +16 -7
- package/out/static/ui/error.bundle.js +474 -0
- package/out/static/ui/error.bundle.js.map +1 -0
- package/out/static/ui/install.bundle.js +459 -0
- package/out/static/ui/install.bundle.js.map +1 -0
- package/out/static/ui/login.bundle.js +630 -0
- package/out/static/ui/login.bundle.js.map +1 -0
- package/out/static/ui/main.bundle.js +2109 -0
- package/out/static/ui/main.bundle.js.map +1 -0
- package/out/static/ui/oauth.bundle.js +467 -0
- package/out/static/ui/oauth.bundle.js.map +1 -0
- package/out/storage/d1.d.ts +107 -0
- package/out/storage/d1.js +831 -0
- package/out/storage/index.js +8 -1
- package/out/storage/mysql.js +22 -19
- package/out/storage/postgre.d.ts +0 -1
- package/out/storage/postgre.js +20 -30
- package/out/storage/sqlite.d.ts +2 -5
- package/out/storage/sqlite.js +29 -69
- package/out/types.d.ts +78 -18
- package/out/util/connection.js +1 -1
- package/out/util/credentials-masker.d.ts +3 -3
- package/out/util/credentials-masker.js +14 -20
- package/out/util/cron.d.ts +29 -0
- package/out/util/cron.js +87 -0
- package/out/util/index.d.ts +14 -1
- package/out/util/index.js +121 -10
- package/out/util/jsx-renderer.d.ts +14 -0
- package/out/util/jsx-renderer.js +35 -0
- package/out/util/logger.d.ts +1 -0
- package/out/util/logger.js +2 -2
- package/out/util/static-files.d.ts +19 -0
- package/out/util/static-files.js +87 -0
- package/out/util/subscription.js +1 -1
- package/out/views/AboutPage.d.ts +10 -0
- package/out/views/AboutPage.js +76 -0
- package/out/views/FormPage.d.ts +14 -0
- package/out/views/FormPage.js +28 -0
- package/out/views/SubscriptionPage.d.ts +7 -0
- package/out/views/SubscriptionPage.js +26 -0
- package/out/views/index.d.ts +8 -0
- package/out/views/index.js +15 -0
- package/out/views/layout/Head.d.ts +9 -0
- package/out/views/layout/Head.js +54 -0
- package/package.json +43 -41
- package/out/util/handlebars.d.ts +0 -1
- package/out/util/handlebars.js +0 -46
- package/out/views/about.handlebars +0 -102
- package/out/views/error.handlebars +0 -54
- package/out/views/form.handlebars +0 -31
- package/out/views/install.handlebars +0 -16
- package/out/views/login.handlebars +0 -332
- package/out/views/main.handlebars +0 -2042
- package/out/views/oauth.handlebars +0 -11
- package/out/views/partials/head.handlebars +0 -53
- package/out/views/subscription.handlebars +0 -26
package/out/storage/index.js
CHANGED
|
@@ -41,6 +41,7 @@ const logger_1 = require("../util/logger");
|
|
|
41
41
|
const mysql_1 = require("./mysql");
|
|
42
42
|
const postgre_1 = require("./postgre");
|
|
43
43
|
const sqlite_1 = require("./sqlite");
|
|
44
|
+
const d1_1 = require("./d1");
|
|
44
45
|
const path_1 = __importStar(require("path"));
|
|
45
46
|
const fs_1 = __importDefault(require("fs"));
|
|
46
47
|
const child_process_1 = require("child_process");
|
|
@@ -62,7 +63,13 @@ exports.TABLES = {
|
|
|
62
63
|
let storage;
|
|
63
64
|
function initialize(config) {
|
|
64
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
if (config.
|
|
66
|
+
if (config.d1Config) {
|
|
67
|
+
(0, logger_1.log)('Using Cloudflare D1 database');
|
|
68
|
+
storage = new d1_1.D1Storage(config.d1Config);
|
|
69
|
+
// Skip migration for D1 - it will be done lazily on first request
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
else if (config.postgreConfig) {
|
|
66
73
|
(0, logger_1.log)('Using PostgreSQL database');
|
|
67
74
|
let dumpDirectory = null;
|
|
68
75
|
if (config.migrateToPostgreFromSQLite) {
|
package/out/storage/mysql.js
CHANGED
|
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.MySQLStorage = void 0;
|
|
14
|
-
const
|
|
14
|
+
const crypto_1 = require("crypto");
|
|
15
15
|
const types_1 = require("../modules/integration/util/types");
|
|
16
16
|
const util_1 = require("../util");
|
|
17
17
|
class MySQLStorage {
|
|
@@ -124,23 +124,23 @@ class MySQLStorage {
|
|
|
124
124
|
config text
|
|
125
125
|
)`,
|
|
126
126
|
job: `(
|
|
127
|
-
id
|
|
128
|
-
integration_id
|
|
129
|
-
crowdin_id
|
|
130
|
-
type
|
|
131
|
-
payload
|
|
132
|
-
title
|
|
133
|
-
progress
|
|
134
|
-
status
|
|
135
|
-
payload
|
|
136
|
-
info
|
|
137
|
-
data
|
|
138
|
-
attempt
|
|
139
|
-
errors
|
|
140
|
-
processed_entities
|
|
141
|
-
created_at
|
|
142
|
-
updated_at
|
|
143
|
-
finished_at
|
|
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
|
+
created_at varchar(255) not null,
|
|
142
|
+
updated_at varchar(255),
|
|
143
|
+
finished_at varchar(255)
|
|
144
144
|
)`,
|
|
145
145
|
translation_file_cache: `(
|
|
146
146
|
id int auto_increment primary key,
|
|
@@ -338,7 +338,10 @@ class MySQLStorage {
|
|
|
338
338
|
yield connection.execute('DELETE FROM sync_settings where integration_id = ?', [id]);
|
|
339
339
|
yield connection.execute('DELETE FROM files_snapshot where integration_id = ?', [id]);
|
|
340
340
|
yield connection.execute('DELETE FROM webhooks where integration_id = ?', [id]);
|
|
341
|
+
yield connection.execute('DELETE FROM user_errors where integration_id = ?', [id]);
|
|
342
|
+
yield connection.execute('DELETE FROM integration_settings where integration_id = ?', [id]);
|
|
341
343
|
yield connection.execute('DELETE FROM job where integration_id = ?', [id]);
|
|
344
|
+
yield connection.execute('DELETE FROM translation_file_cache where integration_id = ?', [id]);
|
|
342
345
|
yield connection.execute('DELETE FROM unsynced_files where integration_id = ?', [id]);
|
|
343
346
|
yield connection.execute('DELETE FROM synced_data where integration_id = ?', [id]);
|
|
344
347
|
}));
|
|
@@ -598,7 +601,7 @@ class MySQLStorage {
|
|
|
598
601
|
}
|
|
599
602
|
createJob({ integrationId, crowdinId, type, title, payload }) {
|
|
600
603
|
return __awaiter(this, void 0, void 0, function* () {
|
|
601
|
-
const id = (0,
|
|
604
|
+
const id = (0, crypto_1.randomUUID)();
|
|
602
605
|
yield this.dbPromise;
|
|
603
606
|
yield this.executeQuery((connection) => connection.execute(`
|
|
604
607
|
INSERT INTO job(id, integration_id, crowdin_id, type, payload, title, created_at)
|
package/out/storage/postgre.d.ts
CHANGED
|
@@ -48,7 +48,6 @@ export declare class PostgreStorage implements Storage {
|
|
|
48
48
|
executeQuery<T>(command: (client: Client) => Promise<T>): Promise<T>;
|
|
49
49
|
private hasDumpFiles;
|
|
50
50
|
migrate(): Promise<void>;
|
|
51
|
-
alterTables(client: Client): Promise<void>;
|
|
52
51
|
addColumns(client: Client, newColumns: string[], tableName: string): Promise<void>;
|
|
53
52
|
addColumn(client: Client, columnName: string, tableName: string, columnType: string): Promise<void>;
|
|
54
53
|
addTables(client: Client): Promise<void>;
|
package/out/storage/postgre.js
CHANGED
|
@@ -15,7 +15,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.PostgreStorage = void 0;
|
|
17
17
|
const pg_1 = require("pg");
|
|
18
|
-
const uuid_1 = require("uuid");
|
|
19
18
|
const crypto_1 = require("crypto");
|
|
20
19
|
const types_1 = require("../types");
|
|
21
20
|
const types_2 = require("../modules/integration/util/types");
|
|
@@ -91,22 +90,22 @@ class PostgreStorage {
|
|
|
91
90
|
config varchar
|
|
92
91
|
)`,
|
|
93
92
|
job: `(
|
|
94
|
-
id
|
|
95
|
-
integration_id
|
|
96
|
-
crowdin_id
|
|
97
|
-
type
|
|
98
|
-
title
|
|
99
|
-
progress
|
|
100
|
-
status
|
|
101
|
-
payload
|
|
102
|
-
info
|
|
103
|
-
data
|
|
104
|
-
attempt
|
|
105
|
-
errors
|
|
106
|
-
processed_entities
|
|
107
|
-
created_at
|
|
108
|
-
updated_at
|
|
109
|
-
finished_at
|
|
93
|
+
id varchar not null primary key,
|
|
94
|
+
integration_id varchar not null,
|
|
95
|
+
crowdin_id varchar not null,
|
|
96
|
+
type varchar not null,
|
|
97
|
+
title varchar null,
|
|
98
|
+
progress int default 0,
|
|
99
|
+
status varchar default '${types_2.JobStatus.CREATED}',
|
|
100
|
+
payload varchar null,
|
|
101
|
+
info varchar null,
|
|
102
|
+
data varchar null,
|
|
103
|
+
attempt int default 0,
|
|
104
|
+
errors varchar null,
|
|
105
|
+
processed_entities varchar null,
|
|
106
|
+
created_at varchar not null,
|
|
107
|
+
updated_at varchar null,
|
|
108
|
+
finished_at varchar null
|
|
110
109
|
)`,
|
|
111
110
|
translation_file_cache: `(
|
|
112
111
|
id serial primary key,
|
|
@@ -222,8 +221,6 @@ class PostgreStorage {
|
|
|
222
221
|
yield client.query('SELECT pg_advisory_lock($1)', [this.migrationLockId]);
|
|
223
222
|
try {
|
|
224
223
|
yield this.addTables(client);
|
|
225
|
-
// TODO: temporary code
|
|
226
|
-
yield this.alterTables(client);
|
|
227
224
|
}
|
|
228
225
|
finally {
|
|
229
226
|
yield client.query('SELECT pg_advisory_unlock($1)', [this.migrationLockId]);
|
|
@@ -237,16 +234,6 @@ class PostgreStorage {
|
|
|
237
234
|
}
|
|
238
235
|
});
|
|
239
236
|
}
|
|
240
|
-
alterTables(client) {
|
|
241
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
242
|
-
yield this.addColumns(client, ['crowdin_id'], 'app_metadata');
|
|
243
|
-
yield this.addColumns(client, ['agent_id'], 'crowdin_credentials');
|
|
244
|
-
yield this.addColumn(client, 'attempt', 'job', 'int default 0');
|
|
245
|
-
yield this.addColumn(client, 'errors', 'job', 'varchar NULL');
|
|
246
|
-
yield this.addColumn(client, 'processed_entities', 'job', 'varchar NULL');
|
|
247
|
-
yield this.addColumn(client, 'managers', 'integration_credentials', 'varchar NULL');
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
237
|
addColumns(client, newColumns, tableName) {
|
|
251
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
252
239
|
const tableInfo = yield client.query('SELECT column_name FROM information_schema.columns WHERE table_name = $1', [tableName]);
|
|
@@ -402,7 +389,10 @@ class PostgreStorage {
|
|
|
402
389
|
yield client.query('DELETE FROM sync_settings where integration_id = $1', [id]);
|
|
403
390
|
yield client.query('DELETE FROM files_snapshot where integration_id = $1', [id]);
|
|
404
391
|
yield client.query('DELETE FROM webhooks where integration_id = $1', [id]);
|
|
392
|
+
yield client.query('DELETE FROM user_errors where integration_id = $1', [id]);
|
|
393
|
+
yield client.query('DELETE FROM integration_settings where integration_id = $1', [id]);
|
|
405
394
|
yield client.query('DELETE FROM job where integration_id = $1', [id]);
|
|
395
|
+
yield client.query('DELETE FROM translation_file_cache where integration_id = $1', [id]);
|
|
406
396
|
yield client.query('DELETE FROM unsynced_files where integration_id = $1', [id]);
|
|
407
397
|
yield client.query('DELETE FROM synced_data where integration_id = $1', [id]);
|
|
408
398
|
}));
|
|
@@ -655,7 +645,7 @@ class PostgreStorage {
|
|
|
655
645
|
}
|
|
656
646
|
createJob({ integrationId, crowdinId, type, payload, title }) {
|
|
657
647
|
return __awaiter(this, void 0, void 0, function* () {
|
|
658
|
-
const id = (0,
|
|
648
|
+
const id = (0, crypto_1.randomUUID)();
|
|
659
649
|
yield this.dbPromise;
|
|
660
650
|
yield this.executeQuery((client) => client.query(`
|
|
661
651
|
INSERT
|
package/out/storage/sqlite.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Storage } from '.';
|
|
2
|
-
import { CrowdinCredentials } from '../types';
|
|
3
2
|
import { IntegrationConfig, IntegrationCredentials, IntegrationFilesSnapshot, IntegrationSyncSettings, IntegrationWebhooks } from '../modules/integration/types';
|
|
4
|
-
import { CreateJobParams, GetActiveJobsParams,
|
|
3
|
+
import { CreateJobParams, GetActiveJobsParams, GetAllJobsParams, GetFileTranslationCache, GetFileTranslationCacheByLanguageParams, GetJobParams, GetUnsyncedFiles, IntegrationSyncedData, Job, TranslationCache, UnsyncedFiles, UpdateJobParams, UpdateTranslationCacheParams } from '../modules/integration/util/types';
|
|
4
|
+
import { CrowdinCredentials } from '../types';
|
|
5
5
|
import { UserErrors } from './types';
|
|
6
6
|
export interface SQLiteStorageConfig {
|
|
7
7
|
dbFolder: string;
|
|
@@ -34,9 +34,6 @@ export declare class SQLiteStorage implements Storage {
|
|
|
34
34
|
private removeColumns;
|
|
35
35
|
private addColumns;
|
|
36
36
|
private addColumn;
|
|
37
|
-
private updateTables;
|
|
38
|
-
private moveIntegrationSettings;
|
|
39
|
-
private migrateManagers;
|
|
40
37
|
migrate(): Promise<void>;
|
|
41
38
|
saveCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
|
42
39
|
updateCrowdinCredentials(credentials: CrowdinCredentials): Promise<void>;
|
package/out/storage/sqlite.js
CHANGED
|
@@ -12,9 +12,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.SQLiteStorage = void 0;
|
|
14
14
|
const path_1 = require("path");
|
|
15
|
-
const
|
|
16
|
-
const types_1 = require("../types");
|
|
17
|
-
const types_2 = require("../
|
|
15
|
+
const crypto_1 = require("crypto");
|
|
16
|
+
const types_1 = require("../modules/integration/util/types");
|
|
17
|
+
const types_2 = require("../types");
|
|
18
18
|
class SQLiteStorage {
|
|
19
19
|
constructor(config) {
|
|
20
20
|
this.dbPromise = new Promise((res, rej) => {
|
|
@@ -84,22 +84,22 @@ class SQLiteStorage {
|
|
|
84
84
|
config varchar null
|
|
85
85
|
)`,
|
|
86
86
|
job: `(
|
|
87
|
-
id
|
|
88
|
-
integration_id
|
|
89
|
-
crowdin_id
|
|
90
|
-
type
|
|
91
|
-
title
|
|
92
|
-
progress
|
|
93
|
-
status
|
|
94
|
-
payload
|
|
95
|
-
info
|
|
96
|
-
data
|
|
97
|
-
attempt
|
|
98
|
-
errors
|
|
99
|
-
processed_entities
|
|
100
|
-
created_at
|
|
101
|
-
updated_at
|
|
102
|
-
finished_at
|
|
87
|
+
id varchar not null primary key,
|
|
88
|
+
integration_id varchar not null,
|
|
89
|
+
crowdin_id varchar not null,
|
|
90
|
+
type varchar not null,
|
|
91
|
+
title varchar null,
|
|
92
|
+
progress integer DEFAULT 0,
|
|
93
|
+
status varchar DEFAULT '${types_1.JobStatus.CREATED}',
|
|
94
|
+
payload varchar null,
|
|
95
|
+
info varchar null,
|
|
96
|
+
data varchar null,
|
|
97
|
+
attempt varchar DEFAULT 0,
|
|
98
|
+
errors varchar null,
|
|
99
|
+
processed_entities varchar null,
|
|
100
|
+
created_at varchar not null,
|
|
101
|
+
updated_at varchar null,
|
|
102
|
+
finished_at varchar null
|
|
103
103
|
)`,
|
|
104
104
|
translation_file_cache: `(
|
|
105
105
|
id integer not null primary key autoincrement,
|
|
@@ -228,47 +228,6 @@ class SQLiteStorage {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
|
-
updateTables() {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
-
yield this.addColumns(['app_secret', 'domain', 'user_id', 'agent_id', 'organization_id', 'base_url'], 'crowdin_credentials');
|
|
234
|
-
yield this.addColumns(['crowdin_id'], 'app_metadata');
|
|
235
|
-
yield this.addColumn('job', 'attempt', 'DEFAULT 0');
|
|
236
|
-
yield this.addColumn('job', 'errors', 'null');
|
|
237
|
-
yield this.addColumn('job', 'processed_entities', 'null');
|
|
238
|
-
yield this.addColumn('integration_credentials', 'managers', 'null');
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
moveIntegrationSettings() {
|
|
242
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
const integrationCredentials = yield this.each('SELECT * FROM integration_credentials', []);
|
|
244
|
-
for (const credentials of integrationCredentials) {
|
|
245
|
-
if (credentials.config) {
|
|
246
|
-
yield this.saveIntegrationConfig(credentials.id, credentials.crowdin_id, credentials.config);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
yield this.removeColumns('config', 'integration_credentials');
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
migrateManagers() {
|
|
253
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
-
const tableInfo = yield this.each('PRAGMA table_info(integration_credentials);', []);
|
|
255
|
-
const exists = tableInfo.some((columnInfo) => columnInfo.name === 'managers');
|
|
256
|
-
if (exists) {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
yield this.addColumn('integration_credentials', 'managers', 'null');
|
|
260
|
-
const integrationSettings = yield this.each('SELECT integration_id, config FROM integration_settings', []);
|
|
261
|
-
for (const settings of integrationSettings) {
|
|
262
|
-
const config = JSON.parse(settings.config);
|
|
263
|
-
if (config.managers) {
|
|
264
|
-
yield this.run('UPDATE integration_credentials SET managers = ? WHERE id = ?', [
|
|
265
|
-
JSON.stringify(config.managers),
|
|
266
|
-
settings.integration_id,
|
|
267
|
-
]);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
231
|
migrate() {
|
|
273
232
|
return __awaiter(this, void 0, void 0, function* () {
|
|
274
233
|
let _connection_res;
|
|
@@ -279,7 +238,7 @@ class SQLiteStorage {
|
|
|
279
238
|
});
|
|
280
239
|
const sqlite = require('sqlite3');
|
|
281
240
|
//@ts-ignore
|
|
282
|
-
this.db = new sqlite.Database((0, path_1.join)(this.config.dbFolder,
|
|
241
|
+
this.db = new sqlite.Database((0, path_1.join)(this.config.dbFolder, types_2.storageFiles.SQLITE), (error) => {
|
|
283
242
|
if (error) {
|
|
284
243
|
_connection_rej(error);
|
|
285
244
|
}
|
|
@@ -292,11 +251,9 @@ class SQLiteStorage {
|
|
|
292
251
|
for (const [tableName, tableSchema] of Object.entries(this.tables)) {
|
|
293
252
|
yield this._run(`create table if not exists ${tableName} ${tableSchema};`, []);
|
|
294
253
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
yield this.moveIntegrationSettings();
|
|
299
|
-
yield this.migrateManagers();
|
|
254
|
+
if (this._res) {
|
|
255
|
+
this._res();
|
|
256
|
+
}
|
|
300
257
|
}
|
|
301
258
|
catch (e) {
|
|
302
259
|
this._rej && this._rej(e);
|
|
@@ -389,7 +346,10 @@ class SQLiteStorage {
|
|
|
389
346
|
yield this.run('DELETE FROM sync_settings where integration_id = ?', [id]);
|
|
390
347
|
yield this.run('DELETE FROM files_snapshot where integration_id = ?', [id]);
|
|
391
348
|
yield this.run('DELETE FROM webhooks where integration_id = ?', [id]);
|
|
349
|
+
yield this.run('DELETE FROM user_errors where integration_id = ?', [id]);
|
|
350
|
+
yield this.run('DELETE FROM integration_settings where integration_id = ?', [id]);
|
|
392
351
|
yield this.run('DELETE FROM job where integration_id = ?', [id]);
|
|
352
|
+
yield this.run('DELETE FROM translation_file_cache where integration_id = ?', [id]);
|
|
393
353
|
yield this.run('DELETE FROM unsynced_files where integration_id = ?', [id]);
|
|
394
354
|
yield this.run('DELETE FROM synced_data where integration_id = ?', [id]);
|
|
395
355
|
});
|
|
@@ -570,7 +530,7 @@ class SQLiteStorage {
|
|
|
570
530
|
}
|
|
571
531
|
createJob({ integrationId, crowdinId, type, title, payload }) {
|
|
572
532
|
return __awaiter(this, void 0, void 0, function* () {
|
|
573
|
-
const id = (0,
|
|
533
|
+
const id = (0, crypto_1.randomUUID)();
|
|
574
534
|
yield this.run(`
|
|
575
535
|
INSERT
|
|
576
536
|
INTO job(id, integration_id, crowdin_id, type, payload, title, created_at)
|
|
@@ -593,7 +553,7 @@ class SQLiteStorage {
|
|
|
593
553
|
if (status) {
|
|
594
554
|
updateFields.push('status = ?');
|
|
595
555
|
updateParams.push(status);
|
|
596
|
-
if (!updateFields.includes('finished_at = ?') && [
|
|
556
|
+
if (!updateFields.includes('finished_at = ?') && [types_1.JobStatus.FAILED, types_1.JobStatus.CANCELED].includes(status)) {
|
|
597
557
|
updateFields.push('finished_at = ?');
|
|
598
558
|
updateParams.push(Date.now().toString());
|
|
599
559
|
}
|
|
@@ -659,7 +619,7 @@ class SQLiteStorage {
|
|
|
659
619
|
SELECT id, integration_id as integrationId, crowdin_id as crowdinId, type, payload, progress, status, title, info, data, attempt, errors, processed_entities as processedEntities, created_at as createdAt, updated_at as updatedAt, finished_at as finishedAt
|
|
660
620
|
FROM job
|
|
661
621
|
WHERE status IN (?,?) AND finished_at is NULL
|
|
662
|
-
`, [
|
|
622
|
+
`, [types_1.JobStatus.IN_PROGRESS, types_1.JobStatus.CREATED]);
|
|
663
623
|
});
|
|
664
624
|
}
|
|
665
625
|
getAllJobs({ integrationId, crowdinId, limit, offset }) {
|
package/out/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import Crowdin from '@crowdin/crowdin-api-client';
|
|
2
4
|
import { JwtPayload, VerifyOptions } from '@crowdin/crowdin-apps-functions';
|
|
3
5
|
import { Request } from 'express';
|
|
@@ -10,6 +12,8 @@ import { IntegrationLogic } from './modules/integration/types';
|
|
|
10
12
|
import { Storage } from './storage';
|
|
11
13
|
import { MySQLStorageConfig } from './storage/mysql';
|
|
12
14
|
import { PostgreStorageConfig } from './storage/postgre';
|
|
15
|
+
import { D1StorageConfig } from './storage/d1';
|
|
16
|
+
import type { Fetcher } from '@cloudflare/workers-types';
|
|
13
17
|
import { ApiModule } from './modules/api/types';
|
|
14
18
|
import { LogErrorFunction, LogFunction } from './util/logger';
|
|
15
19
|
import { AiProviderModule } from './modules/ai-provider/types';
|
|
@@ -21,6 +25,8 @@ import { WorkflowStepTypeModule } from './modules/workflow-step-type/types';
|
|
|
21
25
|
import { AiRequestProcessorModule, AiStreamProcessorModule } from './modules/ai-request-processors/types';
|
|
22
26
|
import { AutomationActionModule } from './modules/automation-action/types';
|
|
23
27
|
import { AuthGuardModule } from './modules/auth-guard/types';
|
|
28
|
+
import { Cron } from './util/cron';
|
|
29
|
+
export { Cron };
|
|
24
30
|
export interface ClientConfig extends ImagePath {
|
|
25
31
|
/**
|
|
26
32
|
* Authentication Crowdin App type: "authorization_code", "crowdin_app", "crowdin_agent". Default: "crowdin_app"
|
|
@@ -102,6 +108,20 @@ export interface ClientConfig extends ImagePath {
|
|
|
102
108
|
* config to configure MySQL as a storage
|
|
103
109
|
*/
|
|
104
110
|
mysqlConfig?: MySQLStorageConfig;
|
|
111
|
+
/**
|
|
112
|
+
* config to configure Cloudflare D1 as a storage
|
|
113
|
+
*/
|
|
114
|
+
d1Config?: D1StorageConfig;
|
|
115
|
+
/**
|
|
116
|
+
* Custom cron for scheduling background jobs.
|
|
117
|
+
* If not provided, the default node-cron will be used.
|
|
118
|
+
* Useful for external cron systems like Cloudflare Workers Scheduled Events.
|
|
119
|
+
*/
|
|
120
|
+
cron?: Cron;
|
|
121
|
+
/**
|
|
122
|
+
* Cloudflare Workers Assets configuration
|
|
123
|
+
*/
|
|
124
|
+
assetsConfig?: AssetsConfig;
|
|
105
125
|
/**
|
|
106
126
|
* integration module logic
|
|
107
127
|
*/
|
|
@@ -165,7 +185,7 @@ export interface ClientConfig extends ImagePath {
|
|
|
165
185
|
/**
|
|
166
186
|
* Install hook
|
|
167
187
|
*/
|
|
168
|
-
onInstall?: (
|
|
188
|
+
onInstall?: (options: {
|
|
169
189
|
organization: string;
|
|
170
190
|
userId: number;
|
|
171
191
|
client: Crowdin;
|
|
@@ -173,14 +193,20 @@ export interface ClientConfig extends ImagePath {
|
|
|
173
193
|
/**
|
|
174
194
|
* Uninstall hook for cleanup logic
|
|
175
195
|
*/
|
|
176
|
-
onUninstall?: (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
196
|
+
onUninstall?: (options: {
|
|
197
|
+
organization: string;
|
|
198
|
+
allCredentials: {
|
|
199
|
+
settings?: any;
|
|
200
|
+
credentials: any;
|
|
201
|
+
}[];
|
|
202
|
+
}) => Promise<void>;
|
|
180
203
|
/**
|
|
181
204
|
* Error interceptor (can be used to log error in centralized place)
|
|
182
205
|
*/
|
|
183
|
-
onError?: (
|
|
206
|
+
onError?: (options: {
|
|
207
|
+
error: any;
|
|
208
|
+
context?: CrowdinContextInfo;
|
|
209
|
+
}) => void;
|
|
184
210
|
/**
|
|
185
211
|
* Disable global error handling of unhandledRejection and uncaughtException events
|
|
186
212
|
*/
|
|
@@ -277,13 +303,27 @@ export interface ClientConfig extends ImagePath {
|
|
|
277
303
|
* Auth guard module for custom authentication/authorization checks
|
|
278
304
|
*/
|
|
279
305
|
authGuard?: AuthGuardModule | AuthGuardModule[];
|
|
306
|
+
/**
|
|
307
|
+
* custom file storage
|
|
308
|
+
*/
|
|
309
|
+
fileStore?: FileStore;
|
|
310
|
+
/**
|
|
311
|
+
* path to assets files directory (default: 'static')
|
|
312
|
+
*/
|
|
313
|
+
assetsPath?: string;
|
|
314
|
+
}
|
|
315
|
+
export interface AssetsConfig {
|
|
316
|
+
/**
|
|
317
|
+
* Cloudflare Workers Assets Fetcher
|
|
318
|
+
*/
|
|
319
|
+
fetcher: Fetcher;
|
|
280
320
|
}
|
|
281
321
|
export interface Environments {
|
|
282
322
|
environments?: Environment | Environment[];
|
|
283
323
|
}
|
|
284
324
|
type Environment = 'crowdin' | 'crowdin-enterprise';
|
|
285
325
|
export type Config = ClientConfig & {
|
|
286
|
-
baseUrl
|
|
326
|
+
baseUrl?: string;
|
|
287
327
|
clientId: string;
|
|
288
328
|
clientSecret: string;
|
|
289
329
|
port: number;
|
|
@@ -397,22 +437,39 @@ interface ModuleContent {
|
|
|
397
437
|
url?: string;
|
|
398
438
|
}
|
|
399
439
|
export interface CrowdinAppUtilities extends CrowdinMetadataStore {
|
|
400
|
-
establishCrowdinConnection: (
|
|
440
|
+
establishCrowdinConnection: (options: {
|
|
441
|
+
authRequest?: CrowdinClientRequest;
|
|
442
|
+
jwtToken?: string;
|
|
443
|
+
moduleKey: string[] | string | undefined;
|
|
444
|
+
}) => Promise<{
|
|
401
445
|
context: CrowdinContextInfo;
|
|
402
446
|
client?: Crowdin;
|
|
403
447
|
}>;
|
|
404
|
-
encryptCrowdinConnection: (
|
|
448
|
+
encryptCrowdinConnection: (options: {
|
|
405
449
|
crowdinId: string;
|
|
406
450
|
extra: Record<string, any>;
|
|
407
451
|
}) => string;
|
|
408
|
-
|
|
452
|
+
decryptCrowdinConnection: (options: {
|
|
453
|
+
hash: string;
|
|
454
|
+
autoRenew?: boolean;
|
|
455
|
+
}) => Promise<{
|
|
409
456
|
client: Crowdin;
|
|
410
457
|
extra: Record<string, any>;
|
|
411
458
|
}>;
|
|
459
|
+
jwtMiddleware: (options: {
|
|
460
|
+
moduleKey: string[] | string;
|
|
461
|
+
optional?: boolean;
|
|
462
|
+
checkSubscriptionExpiration?: boolean;
|
|
463
|
+
}) => (req: any, res: any, next: any) => void;
|
|
412
464
|
storage: Storage;
|
|
465
|
+
cron: Cron;
|
|
413
466
|
}
|
|
414
467
|
export interface CrowdinMetadataStore {
|
|
415
|
-
saveMetadata: (
|
|
468
|
+
saveMetadata: (options: {
|
|
469
|
+
id: string;
|
|
470
|
+
metadata: any;
|
|
471
|
+
crowdinId: string;
|
|
472
|
+
}) => Promise<void>;
|
|
416
473
|
getMetadata: (id: string) => Promise<any | undefined>;
|
|
417
474
|
deleteMetadata: (id: string) => Promise<void>;
|
|
418
475
|
/**
|
|
@@ -444,7 +501,7 @@ export interface UiModule extends ModuleKey {
|
|
|
444
501
|
/**
|
|
445
502
|
* Additional attributes for react-jsonschema-doc
|
|
446
503
|
*/
|
|
447
|
-
formUiSchema?:
|
|
504
|
+
formUiSchema?: any;
|
|
448
505
|
/**
|
|
449
506
|
* path to ui folder (e.g. {@example join(__dirname, 'public')})
|
|
450
507
|
*/
|
|
@@ -457,10 +514,6 @@ export interface UiModule extends ModuleKey {
|
|
|
457
514
|
* Module name
|
|
458
515
|
*/
|
|
459
516
|
name?: string;
|
|
460
|
-
/**
|
|
461
|
-
* Temporary property. Indicates if passwords should be masked. Will be dropped when all existing apps will migrate.
|
|
462
|
-
*/
|
|
463
|
-
maskPasswords?: boolean;
|
|
464
517
|
}
|
|
465
518
|
export interface ModuleKey {
|
|
466
519
|
/**
|
|
@@ -476,7 +529,10 @@ export interface ImagePath {
|
|
|
476
529
|
}
|
|
477
530
|
export interface Logger {
|
|
478
531
|
enabled: boolean;
|
|
479
|
-
log?: (
|
|
532
|
+
log?: (options: {
|
|
533
|
+
message: string;
|
|
534
|
+
context?: CrowdinContextInfo;
|
|
535
|
+
}) => void;
|
|
480
536
|
}
|
|
481
537
|
export interface Pricing {
|
|
482
538
|
planType: 'free' | 'recurring';
|
|
@@ -524,4 +580,8 @@ export interface ModalModule extends ModuleContent, UiModule, Environments {
|
|
|
524
580
|
}
|
|
525
581
|
export interface ContextModule extends ContextContent, UiModule, Environments {
|
|
526
582
|
}
|
|
527
|
-
export {
|
|
583
|
+
export interface FileStore {
|
|
584
|
+
getFile: (fileRef: string) => Promise<Buffer>;
|
|
585
|
+
storeFile: (content: Buffer) => Promise<string>;
|
|
586
|
+
deleteFile: (fileRef: string) => Promise<void>;
|
|
587
|
+
}
|
package/out/util/connection.js
CHANGED
|
@@ -273,7 +273,7 @@ function prepareIntegrationCredentials(config, integration, integrationCredentia
|
|
|
273
273
|
let newCredentials;
|
|
274
274
|
if (performRefreshTokenRequest) {
|
|
275
275
|
const loginForm = yield (0, storage_1.getStorage)().getMetadata((0, defaults_1.getOAuthLoginFormId)(integrationCredentials.id));
|
|
276
|
-
newCredentials = yield performRefreshTokenRequest(credentials, loginForm);
|
|
276
|
+
newCredentials = yield performRefreshTokenRequest({ credentials, loginForm });
|
|
277
277
|
}
|
|
278
278
|
else if (oauthLogin) {
|
|
279
279
|
const url = oauthLogin.refreshTokenUrl || oauthLogin.accessTokenUrl;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="qs" />
|
|
2
|
-
import { CrowdinClientRequest, UiModule } from '../types';
|
|
3
2
|
import { Request, Response } from 'express';
|
|
3
|
+
import { CrowdinClientRequest, UiModule } from '../types';
|
|
4
4
|
declare function maskKey(key: string): string;
|
|
5
5
|
declare function getRequestCredentialsMasker({ moduleConfig, dataPath, }: {
|
|
6
6
|
moduleConfig?: UiModule;
|
|
7
7
|
dataPath?: string;
|
|
8
8
|
}): (req: Request | CrowdinClientRequest, res: Response, next: Function) => any;
|
|
9
|
-
declare function postRequestCredentialsMasker(moduleConfig?: UiModule, credentialsExtractor?: Function): (req:
|
|
10
|
-
export { getRequestCredentialsMasker,
|
|
9
|
+
declare function postRequestCredentialsMasker(moduleConfig?: UiModule, credentialsExtractor?: Function): (req: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>> | CrowdinClientRequest, res: Response<any, Record<string, any>>, next: Function) => void;
|
|
10
|
+
export { getRequestCredentialsMasker, maskKey, postRequestCredentialsMasker };
|