@crowdin/app-project-module 1.16.0 → 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 (99) 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/storage/drizzle/d1/index.d.ts +7 -0
  42. package/out/storage/drizzle/d1/index.js +48 -0
  43. package/out/storage/drizzle/d1/migrations/init.d.ts +2 -0
  44. package/out/storage/drizzle/d1/migrations/init.js +122 -0
  45. package/out/storage/drizzle/d1/types.d.ts +13 -0
  46. package/out/storage/drizzle/d1/types.js +38 -0
  47. package/out/storage/{sqlite.d.ts → drizzle/index.d.ts} +37 -58
  48. package/out/storage/drizzle/index.js +939 -0
  49. package/out/storage/drizzle/postgresql/config.d.ts +5 -0
  50. package/out/storage/drizzle/postgresql/config.js +11 -0
  51. package/out/storage/drizzle/postgresql/index.d.ts +14 -0
  52. package/out/storage/drizzle/postgresql/index.js +144 -0
  53. package/out/storage/drizzle/postgresql/migrations/0000_init.sql +113 -0
  54. package/out/storage/drizzle/postgresql/migrations/0001_init_indexes.sql +28 -0
  55. package/out/storage/drizzle/postgresql/migrations/meta/0000_snapshot.json +646 -0
  56. package/out/storage/drizzle/postgresql/migrations/meta/0001_snapshot.json +646 -0
  57. package/out/storage/drizzle/postgresql/migrations/meta/_journal.json +20 -0
  58. package/out/storage/drizzle/postgresql/schema.d.ts +1410 -0
  59. package/out/storage/drizzle/postgresql/schema.js +106 -0
  60. package/out/storage/drizzle/sqlite/config.d.ts +5 -0
  61. package/out/storage/drizzle/sqlite/config.js +11 -0
  62. package/out/storage/drizzle/sqlite/index.d.ts +8 -0
  63. package/out/storage/drizzle/sqlite/index.js +63 -0
  64. package/out/storage/drizzle/sqlite/migrations/0000_init.sql +113 -0
  65. package/out/storage/drizzle/sqlite/migrations/meta/0000_snapshot.json +687 -0
  66. package/out/storage/drizzle/sqlite/migrations/meta/_journal.json +13 -0
  67. package/out/storage/drizzle/sqlite/schema.d.ts +1544 -0
  68. package/out/storage/drizzle/sqlite/schema.js +106 -0
  69. package/out/storage/index.d.ts +2 -88
  70. package/out/storage/index.js +12 -128
  71. package/out/storage/internal/backup.d.ts +3 -0
  72. package/out/storage/internal/backup.js +94 -0
  73. package/out/storage/types.d.ts +66 -0
  74. package/out/types.d.ts +43 -47
  75. package/out/util/credentials-masker.js +2 -2
  76. package/out/util/export.d.ts +1 -0
  77. package/out/util/export.js +2 -1
  78. package/out/util/index.d.ts +2 -1
  79. package/out/util/index.js +12 -9
  80. package/out/util/normalize-module.d.ts +0 -1
  81. package/out/util/normalize-module.js +0 -4
  82. package/package.json +18 -22
  83. package/out/modules/ai-tools/handlers/tool-calls.d.ts +0 -4
  84. package/out/modules/ai-tools/handlers/tool-calls.js +0 -52
  85. package/out/modules/ai-tools/index.d.ts +0 -10
  86. package/out/modules/ai-tools/index.js +0 -46
  87. package/out/modules/ai-tools/types.d.ts +0 -63
  88. package/out/modules/ai-tools/types.js +0 -2
  89. package/out/modules/ai-tools/util/index.d.ts +0 -5
  90. package/out/modules/ai-tools/util/index.js +0 -24
  91. package/out/storage/d1.d.ts +0 -107
  92. package/out/storage/d1.js +0 -837
  93. package/out/storage/export.d.ts +0 -1
  94. package/out/storage/export.js +0 -2
  95. package/out/storage/mysql.d.ts +0 -109
  96. package/out/storage/mysql.js +0 -984
  97. package/out/storage/postgre.d.ts +0 -124
  98. package/out/storage/postgre.js +0 -1027
  99. package/out/storage/sqlite.js +0 -786
@@ -0,0 +1,5 @@
1
+ /**
2
+ * npm run drizzle:postgresql:generate -- --name "<migration_name>"
3
+ */
4
+ declare const _default: import("drizzle-kit").Config;
5
+ export default _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const drizzle_kit_1 = require("drizzle-kit");
4
+ /**
5
+ * npm run drizzle:postgresql:generate -- --name "<migration_name>"
6
+ */
7
+ exports.default = (0, drizzle_kit_1.defineConfig)({
8
+ schema: 'src/storage/drizzle/postgresql/schema.ts',
9
+ out: 'src/storage/drizzle/postgresql/migrations',
10
+ dialect: 'postgresql',
11
+ });
@@ -0,0 +1,14 @@
1
+ import { Pool, PoolConfig } from 'pg';
2
+ import * as schema from './schema';
3
+ export type PostgreStorageConfig = PoolConfig;
4
+ export type POSTGRESQL_DB = import('drizzle-orm/node-postgres').NodePgDatabase<typeof schema> & {
5
+ $client: Pool;
6
+ };
7
+ export declare function initPostgreSQL(config: PostgreStorageConfig, additionalSchema?: Record<string, unknown>): POSTGRESQL_DB;
8
+ export declare const POSTGRESQL_SCHEMA: typeof schema;
9
+ export declare const migratePostgreSQL: ({ db, name, directoryPath, additionalMigrationFolder, }: {
10
+ db: POSTGRESQL_DB;
11
+ name: string;
12
+ directoryPath?: string;
13
+ additionalMigrationFolder?: string;
14
+ }) => Promise<void>;
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.migratePostgreSQL = exports.POSTGRESQL_SCHEMA = void 0;
49
+ exports.initPostgreSQL = initPostgreSQL;
50
+ const node_postgres_1 = require("drizzle-orm/node-postgres");
51
+ const migrator_1 = require("drizzle-orm/node-postgres/migrator");
52
+ const pg_1 = require("pg");
53
+ const crypto_1 = require("crypto");
54
+ const fs_1 = __importDefault(require("fs"));
55
+ const path_1 = require("path");
56
+ const types_1 = require("../../../types");
57
+ const schema = __importStar(require("./schema"));
58
+ function initPostgreSQL(config, additionalSchema = {}) {
59
+ const client = new pg_1.Pool(config);
60
+ return (0, node_postgres_1.drizzle)(client, { schema: Object.assign(Object.assign({}, schema), additionalSchema) });
61
+ }
62
+ exports.POSTGRESQL_SCHEMA = schema;
63
+ const migratePostgreSQL = (_a) => __awaiter(void 0, [_a], void 0, function* ({ db, name, directoryPath, additionalMigrationFolder, }) {
64
+ if (directoryPath && hasDumpFiles(directoryPath)) {
65
+ yield migrateFromSqlite(db, directoryPath);
66
+ }
67
+ // Use advisory lock to prevent concurrent migrations
68
+ const lockId = generateLockId(name);
69
+ yield db.$client.query('SELECT pg_advisory_lock($1)', [lockId]);
70
+ try {
71
+ yield (0, migrator_1.migrate)(db, { migrationsFolder: (0, path_1.join)(__dirname, 'migrations') });
72
+ if (additionalMigrationFolder) {
73
+ yield (0, migrator_1.migrate)(db, { migrationsFolder: additionalMigrationFolder });
74
+ }
75
+ }
76
+ finally {
77
+ yield db.$client.query('SELECT pg_advisory_unlock($1)', [lockId]);
78
+ }
79
+ });
80
+ exports.migratePostgreSQL = migratePostgreSQL;
81
+ function hasDumpFiles(directoryPath) {
82
+ if (!fs_1.default.existsSync(directoryPath)) {
83
+ return false;
84
+ }
85
+ const [name, extension] = types_1.storageFiles.DUMP.split('%s');
86
+ const files = fs_1.default.readdirSync(directoryPath).filter((file) => file.startsWith(name) && file.endsWith(extension));
87
+ return files.length > 0;
88
+ }
89
+ function migrateFromSqlite(db, directoryPath) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const [name, extension] = types_1.storageFiles.DUMP.split('%s');
92
+ const files = fs_1.default
93
+ .readdirSync(directoryPath)
94
+ .filter((file) => file.startsWith(name) && file.endsWith(extension))
95
+ .sort((a, b) => a.localeCompare(b, undefined, { numeric: true }));
96
+ for (const file of files) {
97
+ const filePath = (0, path_1.join)(directoryPath, file);
98
+ const sql = fs_1.default.readFileSync(filePath, 'utf8');
99
+ try {
100
+ yield db.$client.query(sql);
101
+ fs_1.default.unlinkSync(filePath);
102
+ }
103
+ catch (e) {
104
+ console.error('Error while executing', file);
105
+ console.error(e);
106
+ fs_1.default.renameSync(filePath, filePath.replace('dump_table_', 'error_dump_table_'));
107
+ }
108
+ }
109
+ // Reset sequences for tables with serial primary keys
110
+ yield resetSequences(db);
111
+ });
112
+ }
113
+ function resetSequences(db) {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ for (const table of Object.keys(schema)) {
116
+ const tableName = schema[table]._.name;
117
+ const query = `
118
+ SELECT a.attname
119
+ FROM pg_index i
120
+ JOIN pg_attribute a ON a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey)
121
+ WHERE i.indrelid = '${tableName}'::regclass
122
+ AND i.indisprimary;
123
+ `;
124
+ const primaryKeyResult = yield db.$client.query(query);
125
+ if (primaryKeyResult.rows.length === 0) {
126
+ continue;
127
+ }
128
+ const primaryKey = primaryKeyResult.rows[0].attname;
129
+ const maxIdResult = yield db.$client.query(`SELECT MAX(${primaryKey}) FROM ${tableName}`);
130
+ const maxId = maxIdResult.rows[0].max;
131
+ // Skip if maxId is not a valid integer
132
+ if (maxId === null || isNaN(Number(maxId))) {
133
+ continue;
134
+ }
135
+ yield db.$client.query(`SELECT setval('${tableName}_${primaryKey}_seq', ${Number(maxId)}, true)`);
136
+ }
137
+ });
138
+ }
139
+ function generateLockId(str) {
140
+ // Create MD5 hash of the string
141
+ const hash = (0, crypto_1.createHash)('md5').update(str).digest('hex');
142
+ // Take first 8 hex characters and convert to integer
143
+ return parseInt(hash.substring(0, 8), 16);
144
+ }
@@ -0,0 +1,113 @@
1
+ CREATE TABLE IF NOT EXISTS "app_metadata" (
2
+ "id" text PRIMARY KEY NOT NULL,
3
+ "data" text,
4
+ "crowdin_id" text
5
+ );
6
+ --> statement-breakpoint
7
+ CREATE TABLE IF NOT EXISTS "crowdin_credentials" (
8
+ "id" text PRIMARY KEY NOT NULL,
9
+ "app_secret" text,
10
+ "domain" text,
11
+ "user_id" text,
12
+ "agent_id" text,
13
+ "organization_id" text,
14
+ "base_url" text,
15
+ "access_token" text NOT NULL,
16
+ "refresh_token" text NOT NULL,
17
+ "expire" text NOT NULL,
18
+ "type" text NOT NULL
19
+ );
20
+ --> statement-breakpoint
21
+ CREATE TABLE IF NOT EXISTS "files_snapshot" (
22
+ "id" serial PRIMARY KEY NOT NULL,
23
+ "integration_id" text NOT NULL,
24
+ "crowdin_id" text NOT NULL,
25
+ "files" text,
26
+ "provider" text NOT NULL
27
+ );
28
+ --> statement-breakpoint
29
+ CREATE TABLE IF NOT EXISTS "integration_credentials" (
30
+ "id" text PRIMARY KEY NOT NULL,
31
+ "credentials" text NOT NULL,
32
+ "crowdin_id" text NOT NULL,
33
+ "managers" text
34
+ );
35
+ --> statement-breakpoint
36
+ CREATE TABLE IF NOT EXISTS "integration_settings" (
37
+ "id" serial PRIMARY KEY NOT NULL,
38
+ "integration_id" text NOT NULL,
39
+ "crowdin_id" text NOT NULL,
40
+ "config" text
41
+ );
42
+ --> statement-breakpoint
43
+ CREATE TABLE IF NOT EXISTS "job" (
44
+ "id" text PRIMARY KEY NOT NULL,
45
+ "integration_id" text NOT NULL,
46
+ "crowdin_id" text NOT NULL,
47
+ "type" text NOT NULL,
48
+ "title" text,
49
+ "progress" integer DEFAULT 0 NOT NULL,
50
+ "status" text DEFAULT 'CREATED' NOT NULL,
51
+ "payload" text,
52
+ "info" text,
53
+ "data" text,
54
+ "attempt" integer DEFAULT 0 NOT NULL,
55
+ "errors" text,
56
+ "processed_entities" text,
57
+ "initiated_by" text,
58
+ "created_at" text NOT NULL,
59
+ "updated_at" text,
60
+ "finished_at" text
61
+ );
62
+ --> statement-breakpoint
63
+ CREATE TABLE IF NOT EXISTS "sync_settings" (
64
+ "id" serial PRIMARY KEY NOT NULL,
65
+ "files" text,
66
+ "integration_id" text NOT NULL,
67
+ "crowdin_id" text NOT NULL,
68
+ "type" text NOT NULL,
69
+ "provider" text NOT NULL
70
+ );
71
+ --> statement-breakpoint
72
+ CREATE TABLE IF NOT EXISTS "synced_data" (
73
+ "id" serial PRIMARY KEY NOT NULL,
74
+ "files" text,
75
+ "integration_id" text NOT NULL,
76
+ "crowdin_id" text NOT NULL,
77
+ "type" text NOT NULL,
78
+ "updated_at" text
79
+ );
80
+ --> statement-breakpoint
81
+ CREATE TABLE IF NOT EXISTS "translation_file_cache" (
82
+ "id" serial PRIMARY KEY NOT NULL,
83
+ "integration_id" text NOT NULL,
84
+ "crowdin_id" text NOT NULL,
85
+ "file_id" integer NOT NULL,
86
+ "language_id" text NOT NULL,
87
+ "etag" text
88
+ );
89
+ --> statement-breakpoint
90
+ CREATE TABLE IF NOT EXISTS "unsynced_files" (
91
+ "id" serial PRIMARY KEY NOT NULL,
92
+ "integration_id" text NOT NULL,
93
+ "crowdin_id" text NOT NULL,
94
+ "files" text
95
+ );
96
+ --> statement-breakpoint
97
+ CREATE TABLE IF NOT EXISTS "user_errors" (
98
+ "id" serial PRIMARY KEY NOT NULL,
99
+ "action" text NOT NULL,
100
+ "message" text NOT NULL,
101
+ "data" text,
102
+ "created_at" text NOT NULL,
103
+ "crowdin_id" text NOT NULL,
104
+ "integration_id" text
105
+ );
106
+ --> statement-breakpoint
107
+ CREATE TABLE IF NOT EXISTS "webhooks" (
108
+ "id" serial PRIMARY KEY NOT NULL,
109
+ "file_id" text NOT NULL,
110
+ "integration_id" text NOT NULL,
111
+ "crowdin_id" text NOT NULL,
112
+ "provider" text NOT NULL
113
+ );
@@ -0,0 +1,28 @@
1
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "integration_credentials" ("crowdin_id");
2
+
3
+ CREATE INDEX IF NOT EXISTS idx_integration_provider ON "sync_settings" ("integration_id","provider");
4
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "sync_settings" ("crowdin_id");
5
+ CREATE INDEX IF NOT EXISTS idx_type ON "sync_settings" ("type");
6
+
7
+ CREATE INDEX IF NOT EXISTS idx_integration ON "files_snapshot" ("integration_id");
8
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "files_snapshot" ("crowdin_id");
9
+
10
+ CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "webhooks" ("integration_id","crowdin_id");
11
+ CREATE INDEX IF NOT EXISTS idx_file_provider ON "webhooks" ("file_id","provider");
12
+
13
+ CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "user_errors" ("integration_id","crowdin_id");
14
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "user_errors" ("crowdin_id");
15
+ CREATE INDEX IF NOT EXISTS idx_created_at ON "user_errors" ("created_at");
16
+
17
+ CREATE INDEX IF NOT EXISTS idx_integration ON "integration_settings" ("integration_id");
18
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "integration_settings" ("crowdin_id");
19
+
20
+ CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "job" ("integration_id","crowdin_id") WHERE "finished_at" IS NULL;
21
+ CREATE INDEX IF NOT EXISTS idx_finished_at ON "job" ("finished_at") WHERE "finished_at" IS NOT NULL;
22
+ CREATE INDEX IF NOT EXISTS idx_status ON "job" ("status") WHERE "finished_at" IS NULL;
23
+
24
+ CREATE INDEX IF NOT EXISTS idx_integration_crowdin_file_language ON "translation_file_cache" ("integration_id","crowdin_id","file_id","language_id");
25
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "translation_file_cache" ("crowdin_id");
26
+
27
+ CREATE INDEX IF NOT EXISTS idx_integration_crowdin ON "unsynced_files" ("integration_id","crowdin_id");
28
+ CREATE INDEX IF NOT EXISTS idx_crowdin ON "unsynced_files" ("crowdin_id");