@fragno-dev/db 0.1.3 → 0.1.6
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/.turbo/turbo-build.log +43 -30
- package/CHANGELOG.md +19 -0
- package/dist/adapters/adapters.js +1 -0
- package/dist/adapters/drizzle/drizzle-adapter.d.ts +1 -1
- package/dist/adapters/drizzle/drizzle-adapter.d.ts.map +1 -1
- package/dist/adapters/drizzle/drizzle-adapter.js +9 -2
- package/dist/adapters/drizzle/drizzle-adapter.js.map +1 -1
- package/dist/adapters/drizzle/generate.js +1 -1
- package/dist/adapters/drizzle/generate.js.map +1 -1
- package/dist/adapters/kysely/kysely-adapter.d.ts +1 -1
- package/dist/adapters/kysely/kysely-adapter.d.ts.map +1 -1
- package/dist/adapters/kysely/kysely-adapter.js +47 -27
- package/dist/adapters/kysely/kysely-adapter.js.map +1 -1
- package/dist/adapters/kysely/kysely-query-compiler.js +2 -2
- package/dist/adapters/kysely/kysely-query-compiler.js.map +1 -1
- package/dist/adapters/kysely/kysely-query.js +2 -1
- package/dist/adapters/kysely/kysely-query.js.map +1 -1
- package/dist/adapters/kysely/kysely-uow-compiler.js +2 -2
- package/dist/adapters/kysely/kysely-uow-compiler.js.map +1 -1
- package/dist/adapters/kysely/migration/execute-base.js +128 -0
- package/dist/adapters/kysely/migration/execute-base.js.map +1 -0
- package/dist/adapters/kysely/migration/execute-factory.js +28 -0
- package/dist/adapters/kysely/migration/execute-factory.js.map +1 -0
- package/dist/adapters/kysely/migration/execute-mssql.js +112 -0
- package/dist/adapters/kysely/migration/execute-mssql.js.map +1 -0
- package/dist/adapters/kysely/migration/execute-mysql.js +93 -0
- package/dist/adapters/kysely/migration/execute-mysql.js.map +1 -0
- package/dist/adapters/kysely/migration/execute-postgres.js +104 -0
- package/dist/adapters/kysely/migration/execute-postgres.js.map +1 -0
- package/dist/adapters/kysely/migration/execute-sqlite.js +123 -0
- package/dist/adapters/kysely/migration/execute-sqlite.js.map +1 -0
- package/dist/adapters/kysely/migration/execute.js +23 -168
- package/dist/adapters/kysely/migration/execute.js.map +1 -1
- package/dist/migration-engine/shared.d.ts +24 -5
- package/dist/migration-engine/shared.d.ts.map +1 -1
- package/dist/migration-engine/shared.js.map +1 -1
- package/dist/query/query.d.ts +4 -4
- package/dist/query/query.d.ts.map +1 -1
- package/dist/query/unit-of-work.d.ts +22 -22
- package/dist/query/unit-of-work.d.ts.map +1 -1
- package/dist/schema/create.d.ts +41 -41
- package/dist/schema/create.d.ts.map +1 -1
- package/package.json +7 -2
- package/src/adapters/drizzle/drizzle-adapter-pglite.test.ts +1 -1
- package/src/adapters/drizzle/drizzle-adapter.ts +13 -3
- package/src/adapters/drizzle/generate.test.ts +97 -0
- package/src/adapters/drizzle/generate.ts +3 -2
- package/src/adapters/kysely/kysely-adapter.ts +64 -35
- package/src/adapters/kysely/kysely-query-compiler.ts +3 -1
- package/src/adapters/kysely/kysely-query.ts +3 -1
- package/src/adapters/kysely/kysely-uow-compiler.ts +4 -2
- package/src/adapters/kysely/migration/execute-base.ts +256 -0
- package/src/adapters/kysely/migration/execute-factory.ts +32 -0
- package/src/adapters/kysely/migration/execute-mssql.ts +250 -0
- package/src/adapters/kysely/migration/execute-mysql.ts +211 -0
- package/src/adapters/kysely/migration/execute-postgres.ts +234 -0
- package/src/adapters/kysely/migration/execute-sqlite.test.ts +1363 -0
- package/src/adapters/kysely/migration/execute-sqlite.ts +247 -0
- package/src/adapters/kysely/migration/execute.ts +33 -396
- package/src/adapters/kysely/migration/kysely-migrator.test.ts +84 -2
- package/src/migration-engine/shared.ts +29 -11
- package/tsdown.config.ts +1 -0
|
@@ -1,179 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { schemaToDBType } from "../../../schema/serialize.js";
|
|
3
|
-
import { isUpdated } from "../../../migration-engine/shared.js";
|
|
4
|
-
import { sql } from "kysely";
|
|
1
|
+
import { createMigrationExecutor } from "./execute-factory.js";
|
|
5
2
|
|
|
6
3
|
//#region src/adapters/kysely/migration/execute.ts
|
|
7
|
-
const errors = {
|
|
8
|
-
IdColumnUpdate: "ID columns cannot be updated. Not every database supports updating primary keys and often requires workarounds.",
|
|
9
|
-
SQLiteUpdateColumn: "SQLite doesn't support updating columns. Recreate the table instead.",
|
|
10
|
-
SQLiteUpdateForeignKeys: "SQLite doesn't support modifying foreign keys directly. Use `recreate-table` instead."
|
|
11
|
-
};
|
|
12
4
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
5
|
+
* Execute a single migration operation using the appropriate provider-specific executor.
|
|
6
|
+
*
|
|
7
|
+
* @param operation - The migration operation to execute
|
|
8
|
+
* @param config - Kysely configuration with database instance and provider
|
|
9
|
+
* @param onCustomNode - Handler for custom operations
|
|
10
|
+
* @param mapper - Optional table name mapper for namespacing
|
|
11
|
+
* @returns ExecuteNode(s) that can be compiled to SQL or executed
|
|
15
12
|
*/
|
|
16
|
-
function
|
|
17
|
-
|
|
13
|
+
function execute(operation, config, onCustomNode, mapper) {
|
|
14
|
+
if (operation.type === "custom") return onCustomNode(operation);
|
|
15
|
+
return createMigrationExecutor(config).executeOperation(operation, mapper);
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
18
|
+
* Preprocess a batch of migration operations.
|
|
19
|
+
* This allows provider-specific transformations before execution.
|
|
20
|
+
*
|
|
21
|
+
* For example, SQLite merges add-foreign-key operations into create-table operations
|
|
22
|
+
* since foreign keys must be defined at table creation time.
|
|
23
|
+
*
|
|
24
|
+
* @param operations - The migration operations to preprocess
|
|
25
|
+
* @param config - Kysely configuration with database instance and provider
|
|
26
|
+
* @returns Preprocessed migration operations
|
|
21
27
|
*/
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
function createUniqueIndex(db, name, tableName, cols, provider) {
|
|
26
|
-
const query = db.schema.createIndex(name).on(tableName).columns(cols).unique();
|
|
27
|
-
if (provider === "mssql") return query.where((b) => {
|
|
28
|
-
return b.and(cols.map((col) => b(col, "is not", null)));
|
|
29
|
-
});
|
|
30
|
-
return query;
|
|
31
|
-
}
|
|
32
|
-
function dropUniqueIndex(db, name, tableName, provider) {
|
|
33
|
-
let query = db.schema.dropIndex(name).ifExists();
|
|
34
|
-
if (provider === "cockroachdb") query = query.cascade();
|
|
35
|
-
if (provider === "mssql") query = query.on(tableName);
|
|
36
|
-
return query;
|
|
37
|
-
}
|
|
38
|
-
function executeColumn(tableName, operation, config) {
|
|
39
|
-
const { db, provider } = config;
|
|
40
|
-
const next = () => db.schema.alterTable(tableName);
|
|
41
|
-
const results = [];
|
|
42
|
-
switch (operation.type) {
|
|
43
|
-
case "rename-column":
|
|
44
|
-
results.push(next().renameColumn(operation.from, operation.to));
|
|
45
|
-
return results;
|
|
46
|
-
case "drop-column":
|
|
47
|
-
results.push(next().dropColumn(operation.name));
|
|
48
|
-
return results;
|
|
49
|
-
case "create-column": {
|
|
50
|
-
const col = operation.value;
|
|
51
|
-
results.push(next().addColumn(col.name, sql.raw(schemaToDBType(col, provider)), getColumnBuilderCallback(col, provider)));
|
|
52
|
-
return results;
|
|
53
|
-
}
|
|
54
|
-
case "update-column": {
|
|
55
|
-
const col = operation.value;
|
|
56
|
-
if (col.role === "external-id" || col.role === "internal-id") throw new Error(errors.IdColumnUpdate);
|
|
57
|
-
if (provider === "sqlite") throw new Error(errors.SQLiteUpdateColumn);
|
|
58
|
-
if (!isUpdated(operation)) return results;
|
|
59
|
-
if (provider === "mysql") {
|
|
60
|
-
results.push(next().modifyColumn(operation.name, sql.raw(schemaToDBType(col, provider)), getColumnBuilderCallback(col, provider)));
|
|
61
|
-
return results;
|
|
62
|
-
}
|
|
63
|
-
const mssqlRecreateDefaultConstraint = operation.updateDataType || operation.updateDefault;
|
|
64
|
-
if (provider === "mssql" && mssqlRecreateDefaultConstraint) results.push(rawToNode(db, mssqlDropDefaultConstraint(tableName, col.name)));
|
|
65
|
-
if (operation.updateDataType) {
|
|
66
|
-
const dbType = sql.raw(schemaToDBType(col, provider));
|
|
67
|
-
if (provider === "postgresql" || provider === "cockroachdb") results.push(rawToNode(db, sql`ALTER TABLE ${sql.ref(tableName)} ALTER COLUMN ${sql.ref(operation.name)} TYPE ${dbType} USING (${sql.ref(operation.name)}::${dbType})`));
|
|
68
|
-
else results.push(next().alterColumn(operation.name, (b) => b.setDataType(dbType)));
|
|
69
|
-
}
|
|
70
|
-
if (operation.updateNullable) results.push(next().alterColumn(operation.name, (build) => col.isNullable ? build.dropNotNull() : build.setNotNull()));
|
|
71
|
-
if (provider === "mssql" && mssqlRecreateDefaultConstraint) {
|
|
72
|
-
const defaultValue = defaultValueToDB(col, provider);
|
|
73
|
-
if (defaultValue) {
|
|
74
|
-
const constraintName = getMssqlDefaultConstraintName(tableName, col.name);
|
|
75
|
-
results.push(rawToNode(db, sql`ALTER TABLE ${sql.ref(tableName)} ADD CONSTRAINT ${sql.ref(constraintName)} DEFAULT ${defaultValue} FOR ${sql.ref(col.name)}`));
|
|
76
|
-
}
|
|
77
|
-
} else if (operation.updateDefault) {
|
|
78
|
-
const defaultValue = defaultValueToDB(col, provider);
|
|
79
|
-
results.push(next().alterColumn(operation.name, (build) => {
|
|
80
|
-
if (!defaultValue) return build.dropDefault();
|
|
81
|
-
return build.setDefault(defaultValue);
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
return results;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function execute(operation, config, onCustomNode, mapper) {
|
|
89
|
-
const { db, provider } = config;
|
|
90
|
-
const getTableName = (tableName) => tableName === SETTINGS_TABLE_NAME ? tableName : mapper ? mapper.toPhysical(tableName) : tableName;
|
|
91
|
-
function createTable(tableName, columns) {
|
|
92
|
-
let builder = db.schema.createTable(getTableName(tableName));
|
|
93
|
-
for (const columnInfo of columns) builder = builder.addColumn(columnInfo.name, sql.raw(schemaToDBType(columnInfo, provider)), getColumnBuilderCallback(columnInfo, provider));
|
|
94
|
-
return builder;
|
|
95
|
-
}
|
|
96
|
-
switch (operation.type) {
|
|
97
|
-
case "create-table": return createTable(operation.name, operation.columns);
|
|
98
|
-
case "rename-table":
|
|
99
|
-
if (provider === "mssql") return rawToNode(db, sql`EXEC sp_rename ${sql.lit(getTableName(operation.from))}, ${sql.lit(getTableName(operation.to))}`);
|
|
100
|
-
return db.schema.alterTable(getTableName(operation.from)).renameTo(getTableName(operation.to));
|
|
101
|
-
case "alter-table": {
|
|
102
|
-
const results = [];
|
|
103
|
-
for (const op of operation.value) results.push(...executeColumn(getTableName(operation.name), op, config));
|
|
104
|
-
return results;
|
|
105
|
-
}
|
|
106
|
-
case "drop-table": return db.schema.dropTable(getTableName(operation.name));
|
|
107
|
-
case "custom": return onCustomNode(operation);
|
|
108
|
-
case "add-foreign-key": {
|
|
109
|
-
if (provider === "sqlite") throw new Error(errors.SQLiteUpdateForeignKeys);
|
|
110
|
-
const { table, value } = operation;
|
|
111
|
-
const action = getForeignKeyAction(provider);
|
|
112
|
-
return db.schema.alterTable(getTableName(table)).addForeignKeyConstraint(value.name, value.columns, getTableName(value.referencedTable), value.referencedColumns, (b) => b.onUpdate(action).onDelete(action));
|
|
113
|
-
}
|
|
114
|
-
case "drop-foreign-key": {
|
|
115
|
-
if (provider === "sqlite") throw new Error(errors.SQLiteUpdateForeignKeys);
|
|
116
|
-
const { table, name } = operation;
|
|
117
|
-
let query = db.schema.alterTable(getTableName(table)).dropConstraint(name);
|
|
118
|
-
if (provider !== "mysql") query = query.ifExists();
|
|
119
|
-
return query;
|
|
120
|
-
}
|
|
121
|
-
case "add-index":
|
|
122
|
-
if (operation.unique) return createUniqueIndex(db, operation.name, getTableName(operation.table), operation.columns, provider);
|
|
123
|
-
return db.schema.createIndex(operation.name).on(getTableName(operation.table)).columns(operation.columns);
|
|
124
|
-
case "drop-index": return dropUniqueIndex(db, operation.name, getTableName(operation.table), provider);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function getColumnBuilderCallback(col, provider) {
|
|
128
|
-
return (build) => {
|
|
129
|
-
if (!col.isNullable) build = build.notNull();
|
|
130
|
-
if (col.role === "internal-id") {
|
|
131
|
-
build = build.primaryKey();
|
|
132
|
-
if (provider === "postgresql" || provider === "cockroachdb") {} else if (provider === "mysql") build = build.autoIncrement();
|
|
133
|
-
else if (provider === "sqlite") build = build.autoIncrement();
|
|
134
|
-
else if (provider === "mssql") build = build.identity();
|
|
135
|
-
}
|
|
136
|
-
if (col.role === "external-id") build = build.unique();
|
|
137
|
-
const defaultValue = defaultValueToDB(col, provider);
|
|
138
|
-
if (defaultValue) build = build.defaultTo(defaultValue);
|
|
139
|
-
return build;
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function rawToNode(db, raw) {
|
|
143
|
-
return {
|
|
144
|
-
compile() {
|
|
145
|
-
return raw.compile(db);
|
|
146
|
-
},
|
|
147
|
-
execute() {
|
|
148
|
-
return raw.execute(db);
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
function mssqlDropDefaultConstraint(tableName, columnName) {
|
|
153
|
-
return sql`
|
|
154
|
-
DECLARE @ConstraintName NVARCHAR(200);
|
|
155
|
-
|
|
156
|
-
SELECT @ConstraintName = dc.name
|
|
157
|
-
FROM sys.default_constraints dc
|
|
158
|
-
JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
|
|
159
|
-
JOIN sys.tables t ON t.object_id = c.object_id
|
|
160
|
-
JOIN sys.schemas s ON t.schema_id = s.schema_id
|
|
161
|
-
WHERE s.name = 'dbo' AND t.name = ${sql.lit(tableName)} AND c.name = ${sql.lit(columnName)};
|
|
162
|
-
|
|
163
|
-
IF @ConstraintName IS NOT NULL
|
|
164
|
-
BEGIN
|
|
165
|
-
EXEC('ALTER TABLE [dbo].[' + ${sql.lit(tableName)} + '] DROP CONSTRAINT [' + @ConstraintName + ']');
|
|
166
|
-
END`;
|
|
167
|
-
}
|
|
168
|
-
function defaultValueToDB(column, provider) {
|
|
169
|
-
const value = column.default;
|
|
170
|
-
if (!value) return;
|
|
171
|
-
if (provider === "mysql" && column.type === "string") return;
|
|
172
|
-
if ("value" in value && value.value !== void 0) return sql.lit(value.value);
|
|
173
|
-
if ("dbSpecial" in value && value.dbSpecial === "now") return sql`CURRENT_TIMESTAMP`;
|
|
174
|
-
if ("runtime" in value) return;
|
|
28
|
+
function preprocessOperations(operations, config) {
|
|
29
|
+
return createMigrationExecutor(config).preprocessOperations(operations);
|
|
175
30
|
}
|
|
176
31
|
|
|
177
32
|
//#endregion
|
|
178
|
-
export { execute };
|
|
33
|
+
export { execute, preprocessOperations };
|
|
179
34
|
//# sourceMappingURL=execute.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.js","names":["results: ExecuteNode[]"],"sources":["../../../../src/adapters/kysely/migration/execute.ts"],"sourcesContent":["import {\n type ColumnBuilderCallback,\n type Compilable,\n type CreateTableBuilder,\n type Kysely,\n type RawBuilder,\n sql,\n} from \"kysely\";\nimport {\n type CustomOperation,\n isUpdated,\n type ColumnOperation,\n type MigrationOperation,\n type ColumnInfo,\n} from \"../../../migration-engine/shared\";\nimport type { SQLProvider } from \"../../../shared/providers\";\nimport { schemaToDBType } from \"../../../schema/serialize\";\nimport type { KyselyConfig } from \"../kysely-adapter\";\nimport type { TableNameMapper } from \"../kysely-shared\";\nimport { SETTINGS_TABLE_NAME } from \"../../../shared/settings-schema\";\n\nexport type ExecuteNode = Compilable & {\n execute(): Promise<unknown>;\n};\n\ntype KyselyAny = Kysely<any>; // eslint-disable-line @typescript-eslint/no-explicit-any\n\nconst errors = {\n IdColumnUpdate:\n \"ID columns cannot be updated. Not every database supports updating primary keys and often requires workarounds.\",\n SQLiteUpdateColumn: \"SQLite doesn't support updating columns. Recreate the table instead.\",\n SQLiteUpdateForeignKeys:\n \"SQLite doesn't support modifying foreign keys directly. Use `recreate-table` instead.\",\n} as const;\n\n/**\n * Returns the appropriate foreign key action based on the provider.\n * MSSQL doesn't support RESTRICT, so we use NO ACTION (functionally equivalent).\n */\nfunction getForeignKeyAction(provider: SQLProvider): \"restrict\" | \"no action\" {\n return provider === \"mssql\" ? \"no action\" : \"restrict\";\n}\n\n/**\n * Generates MSSQL default constraint name following the DF_tableName_columnName pattern.\n */\nfunction getMssqlDefaultConstraintName(tableName: string, columnName: string): string {\n const MSSQL_DEFAULT_CONSTRAINT_PREFIX = \"DF\" as const;\n return `${MSSQL_DEFAULT_CONSTRAINT_PREFIX}_${tableName}_${columnName}`;\n}\n\nfunction createUniqueIndex(\n db: KyselyAny,\n name: string,\n tableName: string,\n cols: string[],\n provider: SQLProvider,\n) {\n const query = db.schema.createIndex(name).on(tableName).columns(cols).unique();\n\n if (provider === \"mssql\") {\n // MSSQL: ignore null values in unique indexes by default\n return query.where((b) => {\n return b.and(cols.map((col) => b(col, \"is not\", null)));\n });\n }\n\n return query;\n}\n\nfunction dropUniqueIndex(db: KyselyAny, name: string, tableName: string, provider: SQLProvider) {\n let query = db.schema.dropIndex(name).ifExists();\n\n if (provider === \"cockroachdb\") {\n query = query.cascade();\n }\n\n if (provider === \"mssql\") {\n query = query.on(tableName);\n }\n\n return query;\n}\n\nfunction executeColumn(\n tableName: string,\n operation: ColumnOperation,\n config: KyselyConfig,\n): ExecuteNode[] {\n const { db, provider } = config;\n const next = () => db.schema.alterTable(tableName);\n const results: ExecuteNode[] = [];\n\n switch (operation.type) {\n case \"rename-column\":\n results.push(next().renameColumn(operation.from, operation.to));\n return results;\n\n case \"drop-column\":\n results.push(next().dropColumn(operation.name));\n\n return results;\n case \"create-column\": {\n const col = operation.value;\n\n results.push(\n next().addColumn(\n col.name,\n sql.raw(schemaToDBType(col, provider)),\n getColumnBuilderCallback(col, provider),\n ),\n );\n\n return results;\n }\n case \"update-column\": {\n const col = operation.value;\n\n if (col.role === \"external-id\" || col.role === \"internal-id\") {\n throw new Error(errors.IdColumnUpdate);\n }\n if (provider === \"sqlite\") {\n throw new Error(errors.SQLiteUpdateColumn);\n }\n\n if (!isUpdated(operation)) {\n return results;\n }\n if (provider === \"mysql\") {\n results.push(\n next().modifyColumn(\n operation.name,\n sql.raw(schemaToDBType(col, provider)),\n getColumnBuilderCallback(col, provider),\n ),\n );\n return results;\n }\n\n // MSSQL requires dropping and recreating default constraints when changing data type or default value\n const mssqlRecreateDefaultConstraint = operation.updateDataType || operation.updateDefault;\n\n if (provider === \"mssql\" && mssqlRecreateDefaultConstraint) {\n results.push(rawToNode(db, mssqlDropDefaultConstraint(tableName, col.name)));\n }\n\n // TODO: We should maybe do some of these operations in a single query\n\n if (operation.updateDataType) {\n const dbType = sql.raw(schemaToDBType(col, provider));\n\n if (provider === \"postgresql\" || provider === \"cockroachdb\") {\n // PostgreSQL/CockroachDB: Use explicit USING clause for type conversion\n results.push(\n rawToNode(\n db,\n sql`ALTER TABLE ${sql.ref(tableName)} ALTER COLUMN ${sql.ref(operation.name)} TYPE ${dbType} USING (${sql.ref(operation.name)}::${dbType})`,\n ),\n );\n } else {\n results.push(next().alterColumn(operation.name, (b) => b.setDataType(dbType)));\n }\n }\n\n if (operation.updateNullable) {\n results.push(\n next().alterColumn(operation.name, (build) =>\n col.isNullable ? build.dropNotNull() : build.setNotNull(),\n ),\n );\n }\n\n if (provider === \"mssql\" && mssqlRecreateDefaultConstraint) {\n const defaultValue = defaultValueToDB(col, provider);\n\n if (defaultValue) {\n const constraintName = getMssqlDefaultConstraintName(tableName, col.name);\n\n results.push(\n rawToNode(\n db,\n sql`ALTER TABLE ${sql.ref(tableName)} ADD CONSTRAINT ${sql.ref(constraintName)} DEFAULT ${defaultValue} FOR ${sql.ref(col.name)}`,\n ),\n );\n }\n } else if (operation.updateDefault) {\n const defaultValue = defaultValueToDB(col, provider);\n\n results.push(\n next().alterColumn(operation.name, (build) => {\n if (!defaultValue) {\n return build.dropDefault();\n }\n return build.setDefault(defaultValue);\n }),\n );\n }\n\n return results;\n }\n }\n}\n\nexport function execute(\n operation: MigrationOperation,\n config: KyselyConfig,\n onCustomNode: (op: CustomOperation) => ExecuteNode | ExecuteNode[],\n mapper?: TableNameMapper,\n): ExecuteNode | ExecuteNode[] {\n const { db, provider } = config;\n\n // Settings table is never namespaced\n const getTableName = (tableName: string) =>\n tableName === SETTINGS_TABLE_NAME\n ? tableName\n : mapper\n ? mapper.toPhysical(tableName)\n : tableName;\n\n function createTable(tableName: string, columns: ColumnInfo[]) {\n let builder = db.schema.createTable(getTableName(tableName)) as CreateTableBuilder<\n string,\n string\n >;\n\n // Add columns from the column info array\n for (const columnInfo of columns) {\n builder = builder.addColumn(\n columnInfo.name,\n sql.raw(schemaToDBType(columnInfo, provider)),\n getColumnBuilderCallback(columnInfo, provider),\n );\n }\n\n return builder;\n }\n\n switch (operation.type) {\n case \"create-table\":\n return createTable(operation.name, operation.columns);\n case \"rename-table\":\n if (provider === \"mssql\") {\n return rawToNode(\n db,\n sql`EXEC sp_rename ${sql.lit(getTableName(operation.from))}, ${sql.lit(getTableName(operation.to))}`,\n );\n }\n\n return db.schema\n .alterTable(getTableName(operation.from))\n .renameTo(getTableName(operation.to));\n case \"alter-table\": {\n const results: ExecuteNode[] = [];\n\n for (const op of operation.value) {\n results.push(...executeColumn(getTableName(operation.name), op, config));\n }\n\n return results;\n }\n case \"drop-table\":\n return db.schema.dropTable(getTableName(operation.name));\n case \"custom\":\n return onCustomNode(operation);\n case \"add-foreign-key\": {\n if (provider === \"sqlite\") {\n throw new Error(errors.SQLiteUpdateForeignKeys);\n }\n\n const { table, value } = operation;\n const action = getForeignKeyAction(provider);\n\n return db.schema\n .alterTable(getTableName(table))\n .addForeignKeyConstraint(\n value.name,\n value.columns,\n getTableName(value.referencedTable),\n value.referencedColumns,\n (b) => b.onUpdate(action).onDelete(action),\n );\n }\n case \"drop-foreign-key\": {\n if (provider === \"sqlite\") {\n throw new Error(errors.SQLiteUpdateForeignKeys);\n }\n\n const { table, name } = operation;\n let query = db.schema.alterTable(getTableName(table)).dropConstraint(name);\n\n // MySQL doesn't support IF EXISTS for dropping constraints\n if (provider !== \"mysql\") {\n query = query.ifExists();\n }\n\n return query;\n }\n case \"add-index\": {\n if (operation.unique) {\n return createUniqueIndex(\n db,\n operation.name,\n getTableName(operation.table),\n operation.columns,\n provider,\n );\n }\n return db.schema\n .createIndex(operation.name)\n .on(getTableName(operation.table))\n .columns(operation.columns);\n }\n case \"drop-index\": {\n return dropUniqueIndex(db, operation.name, getTableName(operation.table), provider);\n }\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nfunction getColumnBuilderCallback(col: ColumnInfo, provider: SQLProvider): ColumnBuilderCallback {\n return (build) => {\n if (!col.isNullable) {\n build = build.notNull();\n }\n\n // Internal ID is the primary key with auto-increment\n if (col.role === \"internal-id\") {\n build = build.primaryKey();\n // Auto-increment for internal ID\n if (provider === \"postgresql\" || provider === \"cockroachdb\") {\n // SERIAL/BIGSERIAL handles auto-increment\n // Already handled in schemaToDBType\n } else if (provider === \"mysql\") {\n build = build.autoIncrement();\n } else if (provider === \"sqlite\") {\n build = build.autoIncrement();\n } else if (provider === \"mssql\") {\n build = build.identity();\n }\n }\n\n // External ID must be unique\n if (col.role === \"external-id\") {\n build = build.unique();\n }\n\n const defaultValue = defaultValueToDB(col, provider);\n if (defaultValue) {\n build = build.defaultTo(defaultValue);\n }\n return build;\n };\n}\n\nfunction rawToNode(db: KyselyAny, raw: RawBuilder<unknown>): ExecuteNode {\n return {\n compile() {\n return raw.compile(db);\n },\n execute() {\n return raw.execute(db);\n },\n };\n}\n\nfunction mssqlDropDefaultConstraint(tableName: string, columnName: string) {\n return sql`\nDECLARE @ConstraintName NVARCHAR(200);\n\nSELECT @ConstraintName = dc.name\nFROM sys.default_constraints dc\nJOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id\nJOIN sys.tables t ON t.object_id = c.object_id\nJOIN sys.schemas s ON t.schema_id = s.schema_id\nWHERE s.name = 'dbo' AND t.name = ${sql.lit(tableName)} AND c.name = ${sql.lit(columnName)};\n\nIF @ConstraintName IS NOT NULL\nBEGIN\n EXEC('ALTER TABLE [dbo].[' + ${sql.lit(tableName)} + '] DROP CONSTRAINT [' + @ConstraintName + ']');\nEND`;\n}\n\nfunction defaultValueToDB(column: ColumnInfo, provider: SQLProvider) {\n const value = column.default;\n if (!value) {\n return undefined;\n }\n\n // MySQL doesn't support default values for TEXT columns\n if (provider === \"mysql\" && column.type === \"string\") {\n return undefined;\n }\n\n // Static default values: defaultTo(value)\n if (\"value\" in value && value.value !== undefined) {\n return sql.lit(value.value);\n }\n\n // Database-level special functions: defaultTo(b => b.now())\n if (\"dbSpecial\" in value && value.dbSpecial === \"now\") {\n return sql`CURRENT_TIMESTAMP`;\n }\n\n // Runtime defaults (defaultTo$) are NOT generated in SQL - they're handled in application code\n if (\"runtime\" in value) {\n return undefined;\n }\n\n return undefined;\n}\n"],"mappings":";;;;;;AA2BA,MAAM,SAAS;CACb,gBACE;CACF,oBAAoB;CACpB,yBACE;CACH;;;;;AAMD,SAAS,oBAAoB,UAAiD;AAC5E,QAAO,aAAa,UAAU,cAAc;;;;;AAM9C,SAAS,8BAA8B,WAAmB,YAA4B;AAEpF,QAAO,MAAsC,UAAU,GAAG;;AAG5D,SAAS,kBACP,IACA,MACA,WACA,MACA,UACA;CACA,MAAM,QAAQ,GAAG,OAAO,YAAY,KAAK,CAAC,GAAG,UAAU,CAAC,QAAQ,KAAK,CAAC,QAAQ;AAE9E,KAAI,aAAa,QAEf,QAAO,MAAM,OAAO,MAAM;AACxB,SAAO,EAAE,IAAI,KAAK,KAAK,QAAQ,EAAE,KAAK,UAAU,KAAK,CAAC,CAAC;GACvD;AAGJ,QAAO;;AAGT,SAAS,gBAAgB,IAAe,MAAc,WAAmB,UAAuB;CAC9F,IAAI,QAAQ,GAAG,OAAO,UAAU,KAAK,CAAC,UAAU;AAEhD,KAAI,aAAa,cACf,SAAQ,MAAM,SAAS;AAGzB,KAAI,aAAa,QACf,SAAQ,MAAM,GAAG,UAAU;AAG7B,QAAO;;AAGT,SAA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/execute.ts"],"sourcesContent":["import type { CustomOperation, MigrationOperation } from \"../../../migration-engine/shared\";\nimport type { KyselyConfig } from \"../kysely-adapter\";\nimport type { TableNameMapper } from \"../kysely-shared\";\nimport type { ExecuteNode } from \"./execute-base\";\nimport { createMigrationExecutor } from \"./execute-factory\";\n\nexport type { ExecuteNode };\n\n/**\n * Execute a single migration operation using the appropriate provider-specific executor.\n *\n * @param operation - The migration operation to execute\n * @param config - Kysely configuration with database instance and provider\n * @param onCustomNode - Handler for custom operations\n * @param mapper - Optional table name mapper for namespacing\n * @returns ExecuteNode(s) that can be compiled to SQL or executed\n */\nexport function execute(\n operation: MigrationOperation,\n config: KyselyConfig,\n onCustomNode: (op: CustomOperation) => ExecuteNode | ExecuteNode[],\n mapper?: TableNameMapper,\n): ExecuteNode | ExecuteNode[] {\n // For custom operations, use the provided handler\n if (operation.type === \"custom\") {\n return onCustomNode(operation);\n }\n\n const executor = createMigrationExecutor(config);\n return executor.executeOperation(operation, mapper);\n}\n\n/**\n * Preprocess a batch of migration operations.\n * This allows provider-specific transformations before execution.\n *\n * For example, SQLite merges add-foreign-key operations into create-table operations\n * since foreign keys must be defined at table creation time.\n *\n * @param operations - The migration operations to preprocess\n * @param config - Kysely configuration with database instance and provider\n * @returns Preprocessed migration operations\n */\nexport function preprocessOperations(\n operations: MigrationOperation[],\n config: KyselyConfig,\n): MigrationOperation[] {\n const executor = createMigrationExecutor(config);\n return executor.preprocessOperations(operations);\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,QACd,WACA,QACA,cACA,QAC6B;AAE7B,KAAI,UAAU,SAAS,SACrB,QAAO,aAAa,UAAU;AAIhC,QADiB,wBAAwB,OAAO,CAChC,iBAAiB,WAAW,OAAO;;;;;;;;;;;;;AAcrD,SAAgB,qBACd,YACA,QACsB;AAEtB,QADiB,wBAAwB,OAAO,CAChC,qBAAqB,WAAW"}
|
|
@@ -5,6 +5,13 @@ interface ForeignKeyInfo {
|
|
|
5
5
|
referencedTable: string;
|
|
6
6
|
referencedColumns: string[];
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Provider-specific metadata that can be attached to operations during preprocessing.
|
|
10
|
+
* This allows providers to add additional context without polluting the core operation types.
|
|
11
|
+
*/
|
|
12
|
+
interface MigrationOperationMetadata {
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
8
15
|
interface ColumnInfo {
|
|
9
16
|
name: string;
|
|
10
17
|
type: "string" | "integer" | "bigint" | "decimal" | "bool" | "date" | "timestamp" | "json" | "binary" | `varchar(${number})`;
|
|
@@ -18,25 +25,37 @@ interface ColumnInfo {
|
|
|
18
25
|
runtime: "cuid" | "now";
|
|
19
26
|
};
|
|
20
27
|
}
|
|
21
|
-
type MigrationOperation = TableOperation
|
|
28
|
+
type MigrationOperation<TMeta extends MigrationOperationMetadata = MigrationOperationMetadata> = (TableOperation & {
|
|
29
|
+
metadata?: TMeta;
|
|
30
|
+
}) | ({
|
|
22
31
|
type: "add-foreign-key";
|
|
23
32
|
table: string;
|
|
24
33
|
value: ForeignKeyInfo;
|
|
25
|
-
}
|
|
34
|
+
} & {
|
|
35
|
+
metadata?: TMeta;
|
|
36
|
+
}) | ({
|
|
26
37
|
type: "drop-foreign-key";
|
|
27
38
|
table: string;
|
|
28
39
|
name: string;
|
|
29
|
-
}
|
|
40
|
+
} & {
|
|
41
|
+
metadata?: TMeta;
|
|
42
|
+
}) | ({
|
|
30
43
|
type: "drop-index";
|
|
31
44
|
table: string;
|
|
32
45
|
name: string;
|
|
33
|
-
}
|
|
46
|
+
} & {
|
|
47
|
+
metadata?: TMeta;
|
|
48
|
+
}) | ({
|
|
34
49
|
type: "add-index";
|
|
35
50
|
table: string;
|
|
36
51
|
columns: string[];
|
|
37
52
|
name: string;
|
|
38
53
|
unique: boolean;
|
|
39
|
-
}
|
|
54
|
+
} & {
|
|
55
|
+
metadata?: TMeta;
|
|
56
|
+
}) | (CustomOperation & {
|
|
57
|
+
metadata?: TMeta;
|
|
58
|
+
});
|
|
40
59
|
type CustomOperation = {
|
|
41
60
|
type: "custom";
|
|
42
61
|
} & Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,IAAA,EAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"shared.d.ts","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":[],"mappings":";UAAiB,cAAA;EAAA,IAAA,EAAA,MAAA;EAWA,OAAA,EAAA,MAAA,EAAA;EAYA,eAAU,EAAA,MAAA;EAkBf,iBAAA,EAAA,MAAkB,EAAA;;;;;;AAST,UAvCJ,0BAAA,CAuCI;EAMA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;UAjCJ,UAAA;;;;;;;;;;;;;KAkBL,iCACI,6BAA6B,+BAExC;aAA8B;;;;SAKtB;;aACQ;;;;;;aAMA;;;;;;aAKA;;;;;;;;aAOA;MAChB;aAA+B;;KAExB,eAAA;;IAER;KAEQ,cAAA;;;WAIG;;;;;;;SASF;;;;;;KAQD,eAAA;;;;;;;;;;;;SAeC;;;;;;;;;;;;;;;SAgBA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":["export interface ForeignKeyInfo {\n name: string;\n columns: string[];\n referencedTable: string;\n referencedColumns: string[];\n}\n\nexport interface ColumnInfo {\n name: string;\n type:\n | \"string\"\n | \"integer\"\n | \"bigint\"\n | \"decimal\"\n | \"bool\"\n | \"date\"\n | \"timestamp\"\n | \"json\"\n | \"binary\"\n | `varchar(${number})`;\n isNullable: boolean;\n role: \"external-id\" | \"internal-id\" | \"version\" | \"reference\" | \"regular\";\n default?: { value: unknown } | { dbSpecial: \"now\" } | { runtime: \"cuid\" | \"now\" };\n}\n\nexport type MigrationOperation =\n | TableOperation\n | {\n // warning: not supported by SQLite\n type: \"add-foreign-key\";\n table: string;\n value: ForeignKeyInfo;\n }\n | {\n // warning: not supported by SQLite\n type: \"drop-foreign-key\";\n table: string;\n name: string;\n }\n | {\n type: \"drop-index\";\n table: string;\n name: string;\n }\n | {\n type: \"add-index\";\n table: string;\n columns: string[];\n name: string;\n unique: boolean;\n }\n | CustomOperation;\n\nexport type CustomOperation = {\n type: \"custom\";\n} & Record<string, unknown>;\n\nexport type TableOperation =\n | {\n type: \"create-table\";\n name: string;\n columns: ColumnInfo[];\n }\n | {\n type: \"drop-table\";\n name: string;\n }\n | {\n type: \"alter-table\";\n name: string;\n value: ColumnOperation[];\n }\n | {\n type: \"rename-table\";\n from: string;\n to: string;\n };\n\nexport type ColumnOperation =\n | {\n type: \"rename-column\";\n from: string;\n to: string;\n }\n | {\n type: \"drop-column\";\n name: string;\n }\n | {\n /**\n * Note: unique constraints are not created, please use dedicated operations like `add-index` instead\n */\n type: \"create-column\";\n value: ColumnInfo;\n }\n | {\n /**\n * warning: Not supported by SQLite\n */\n type: \"update-column\";\n name: string;\n /**\n * For databases like MySQL, it requires the full definition for any modify column statement.\n * Hence, you need to specify the full information of your column here.\n *\n * Then, opt-in for in-detail modification for other databases that supports changing data type/nullable/default separately, such as PostgreSQL.\n *\n * Note: unique constraints are not updated, please use dedicated operations like `add-index` instead\n */\n value: ColumnInfo;\n\n updateNullable: boolean;\n updateDefault: boolean;\n updateDataType: boolean;\n };\n\nexport function isUpdated(op: Extract<ColumnOperation, { type: \"update-column\" }>): boolean {\n return op.updateDataType || op.updateDefault || op.updateNullable;\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../src/migration-engine/shared.ts"],"sourcesContent":["export interface ForeignKeyInfo {\n name: string;\n columns: string[];\n referencedTable: string;\n referencedColumns: string[];\n}\n\n/**\n * Provider-specific metadata that can be attached to operations during preprocessing.\n * This allows providers to add additional context without polluting the core operation types.\n */\nexport interface MigrationOperationMetadata {\n [key: string]: unknown;\n}\n\n/**\n * SQLite-specific metadata for create-table operations.\n * Includes foreign keys that should be created inline with the table.\n */\nexport interface SqliteCreateTableMetadata extends MigrationOperationMetadata {\n inlineForeignKeys?: ForeignKeyInfo[];\n}\n\nexport interface ColumnInfo {\n name: string;\n type:\n | \"string\"\n | \"integer\"\n | \"bigint\"\n | \"decimal\"\n | \"bool\"\n | \"date\"\n | \"timestamp\"\n | \"json\"\n | \"binary\"\n | `varchar(${number})`;\n isNullable: boolean;\n role: \"external-id\" | \"internal-id\" | \"version\" | \"reference\" | \"regular\";\n default?: { value: unknown } | { dbSpecial: \"now\" } | { runtime: \"cuid\" | \"now\" };\n}\n\nexport type MigrationOperation<\n TMeta extends MigrationOperationMetadata = MigrationOperationMetadata,\n> =\n | (TableOperation & { metadata?: TMeta })\n | ({\n // warning: not supported by SQLite\n type: \"add-foreign-key\";\n table: string;\n value: ForeignKeyInfo;\n } & { metadata?: TMeta })\n | ({\n // warning: not supported by SQLite\n type: \"drop-foreign-key\";\n table: string;\n name: string;\n } & { metadata?: TMeta })\n | ({\n type: \"drop-index\";\n table: string;\n name: string;\n } & { metadata?: TMeta })\n | ({\n type: \"add-index\";\n table: string;\n columns: string[];\n name: string;\n unique: boolean;\n } & { metadata?: TMeta })\n | (CustomOperation & { metadata?: TMeta });\n\nexport type CustomOperation = {\n type: \"custom\";\n} & Record<string, unknown>;\n\nexport type TableOperation =\n | {\n type: \"create-table\";\n name: string;\n columns: ColumnInfo[];\n }\n | {\n type: \"drop-table\";\n name: string;\n }\n | {\n type: \"alter-table\";\n name: string;\n value: ColumnOperation[];\n }\n | {\n type: \"rename-table\";\n from: string;\n to: string;\n };\n\nexport type ColumnOperation =\n | {\n type: \"rename-column\";\n from: string;\n to: string;\n }\n | {\n type: \"drop-column\";\n name: string;\n }\n | {\n /**\n * Note: unique constraints are not created, please use dedicated operations like `add-index` instead\n */\n type: \"create-column\";\n value: ColumnInfo;\n }\n | {\n /**\n * warning: Not supported by SQLite\n */\n type: \"update-column\";\n name: string;\n /**\n * For databases like MySQL, it requires the full definition for any modify column statement.\n * Hence, you need to specify the full information of your column here.\n *\n * Then, opt-in for in-detail modification for other databases that supports changing data type/nullable/default separately, such as PostgreSQL.\n *\n * Note: unique constraints are not updated, please use dedicated operations like `add-index` instead\n */\n value: ColumnInfo;\n\n updateNullable: boolean;\n updateDefault: boolean;\n updateDataType: boolean;\n };\n\nexport function isUpdated(op: Extract<ColumnOperation, { type: \"update-column\" }>): boolean {\n return op.updateDataType || op.updateDefault || op.updateNullable;\n}\n"],"mappings":";AAsIA,SAAgB,UAAU,IAAkE;AAC1F,QAAO,GAAG,kBAAkB,GAAG,iBAAiB,GAAG"}
|
package/dist/query/query.d.ts
CHANGED
|
@@ -14,16 +14,16 @@ type RawInsertValues<T extends AnyTable> = { [K in keyof T["columns"] as string
|
|
|
14
14
|
type TableToInsertValues<T extends AnyTable> = Prettify<Partial<PickNullable<RawInsertValues<T>>> & PickNotNullable<RawInsertValues<T>>>;
|
|
15
15
|
type TableToUpdateValues<T extends AnyTable> = { [K in keyof T["columns"] as string extends K ? never : K]?: T["columns"][K] extends IdColumn ? never : T["columns"][K]["$in"] };
|
|
16
16
|
type MainSelectResult<S extends SelectClause<T>, T extends AnyTable> = S extends true ? TableToColumnValues<T> : S extends (keyof T["columns"])[] ? { [K in S[number] as string extends K ? never : K]: K extends keyof T["columns"] ? T["columns"][K]["$out"] : never } : never;
|
|
17
|
-
type SelectResult<T extends AnyTable, JoinOut
|
|
17
|
+
type SelectResult<T extends AnyTable, JoinOut, Select extends SelectClause<T>> = MainSelectResult<Select, T> & JoinOut;
|
|
18
18
|
interface MapRelationType<Type$1> {
|
|
19
19
|
one: Type$1 | null;
|
|
20
20
|
many: Type$1[];
|
|
21
21
|
}
|
|
22
22
|
type JoinBuilder<T extends AnyTable, Out = {}> = { [K in keyof T["relations"]]: T["relations"][K] extends Relation<infer Type, infer Target> ? <Select extends SelectClause<Target> = true, JoinOut = {}>(options?: FindManyOptions<Target, Select, JoinOut, false>) => JoinBuilder<T, Out & { [$K in K]: MapRelationType<SelectResult<Target, JoinOut, Select>>[Type] }> : never };
|
|
23
23
|
type OrderBy<Column = string> = [columnName: Column, "asc" | "desc"];
|
|
24
|
-
type FindFirstOptions<T extends AnyTable = AnyTable, Select
|
|
25
|
-
type FindManyOptions<T extends AnyTable = AnyTable, Select
|
|
26
|
-
select?: Select
|
|
24
|
+
type FindFirstOptions<T extends AnyTable = AnyTable, Select extends SelectClause<T> = SelectClause<T>, JoinOut = {}, IsRoot extends boolean = true> = Omit<FindManyOptions<T, Select, JoinOut, IsRoot>, IsRoot extends true ? "limit" : "limit" | "offset" | "orderBy">;
|
|
25
|
+
type FindManyOptions<T extends AnyTable = AnyTable, Select extends SelectClause<T> = SelectClause<T>, _JoinOut = {}, IsRoot extends boolean = true> = {
|
|
26
|
+
select?: Select;
|
|
27
27
|
where?: (eb: ConditionBuilder<T["columns"]>) => Condition | boolean;
|
|
28
28
|
limit?: number;
|
|
29
29
|
orderBy?: OrderBy<keyof T["columns"]> | OrderBy<keyof T["columns"]>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","names":[],"sources":["../../src/query/query.ts"],"sourcesContent":[],"mappings":";;;;;;KAWY,eAAA,GAAkB,aAAa;KAE/B,uBAAuB,0BAA0B;AAFjD,KAIA,eAJe,CAAA,UAIW,QAJR,CAAA,GAAA,QAElB,MAGE,CAHF,CAAA,SAAY,CAAA,IAAW,MAAA,SAGU,CAHiB,GAAA,KAAA,GAGL,CAHK,GAGD,CAHC,CAAA,SAAA,CAAA,CAGY,CAHZ,CAAA,CAAA,MAAA,CAAA,EAE9D;AAAsC,KAI1B,mBAJ0B,CAAA,UAII,QAJJ,CAAA,GAIgB,eAJhB,CAIgC,CAJhC,CAAA;KAMjC,YALS,CAAA,CAAA,CAAA,GAAA,QAA+B,MAM/B,CAN+B,IAAA,IAAA,SAMb,CANa,CAMX,CANW,CAAA,GAMN,CANM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,GAyIjE,IAzIiE,CAyI5D,aAzI4D,EAAA,OAAA,GAAA,OAAA,CAAA,EAAA,GA0InE,OA1ImE,CAAA,IAAA,CAAA;EAC9D;;;EAKA,UAAA,EAAA,CAAA,kBAAY,MAyIe,OAzIf,CAAA,QAAA,CAAA,GAAA,MAAA,CAAA,CAAA,KAAA,EA0Ib,SA1Ia,EAAA,SAAA,EAAA,CAAA,OAAA,EA4IT,IA5IS,CA4IJ,WA5II,CA4IQ,OA5IR,CAAA,QAAA,CAAA,CA4I0B,SA5I1B,CAAA,CAAA,EAAA,OAAA,GAAA,OAAA,CAAA,EAAA,GAAA,IAAA,EAAA,GA8IjB,OA9IiB,CAAA,IAAA,CAAA;EACZ;;;EAGS,gBAAA,EAAA,CAAA,IAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EA+IwB,UA/IxB,EAAA,GA+IuC,UA/IvC,CA+IkD,OA/IlD,EAAA,EAAA,CAAA"}
|
|
@@ -32,7 +32,7 @@ type InferIdColumnName<TTable extends AnyTable> = keyof OmitNever<{ [K in keyof
|
|
|
32
32
|
* For "primary", returns only the ID column.
|
|
33
33
|
* For named indexes, returns the columns defined in that index.
|
|
34
34
|
*/
|
|
35
|
-
type ColumnsForIndex<TTable extends AnyTable, TIndexName
|
|
35
|
+
type ColumnsForIndex<TTable extends AnyTable, TIndexName extends ValidIndexName<TTable>> = TIndexName extends "primary" ? Pick<TTable["columns"], InferIdColumnName<TTable>> : TIndexName extends keyof TTable["indexes"] ? Pick<TTable["columns"], IndexColumns<TTable["indexes"][TIndexName]>> : never;
|
|
36
36
|
/**
|
|
37
37
|
* ConditionBuilder restricted to indexed columns only.
|
|
38
38
|
* Used throughout Unit of Work to ensure all queries can leverage indexes for optimal performance.
|
|
@@ -41,7 +41,7 @@ type IndexedConditionBuilder<TTable extends AnyTable> = ConditionBuilder<Pick<TT
|
|
|
41
41
|
/**
|
|
42
42
|
* ConditionBuilder restricted to columns in a specific index.
|
|
43
43
|
*/
|
|
44
|
-
type IndexSpecificConditionBuilder<TTable extends AnyTable, TIndexName
|
|
44
|
+
type IndexSpecificConditionBuilder<TTable extends AnyTable, TIndexName extends ValidIndexName<TTable>> = ConditionBuilder<ColumnsForIndex<TTable, TIndexName>>;
|
|
45
45
|
/**
|
|
46
46
|
* Valid index names for a table, including the static "primary" index
|
|
47
47
|
*/
|
|
@@ -49,7 +49,7 @@ type ValidIndexName<TTable extends AnyTable> = "primary" | (string & keyof TTabl
|
|
|
49
49
|
/**
|
|
50
50
|
* Find options for Unit of Work (internal, used after builder finalization)
|
|
51
51
|
*/
|
|
52
|
-
type FindOptions<TTable extends AnyTable = AnyTable, TSelect
|
|
52
|
+
type FindOptions<TTable extends AnyTable = AnyTable, TSelect extends SelectClause<TTable> = SelectClause<TTable>> = {
|
|
53
53
|
/**
|
|
54
54
|
* Which index to use for this query (required)
|
|
55
55
|
*/
|
|
@@ -57,7 +57,7 @@ type FindOptions<TTable extends AnyTable = AnyTable, TSelect$1 extends SelectCla
|
|
|
57
57
|
/**
|
|
58
58
|
* Select clause - which columns to return
|
|
59
59
|
*/
|
|
60
|
-
select?: TSelect
|
|
60
|
+
select?: TSelect;
|
|
61
61
|
/**
|
|
62
62
|
* Where clause - filtering restricted to indexed columns only
|
|
63
63
|
*/
|
|
@@ -127,8 +127,8 @@ type MutationOperation<TSchema extends AnySchema, TTable extends AnyTable = TSch
|
|
|
127
127
|
/**
|
|
128
128
|
* Compiled mutation with metadata for execution
|
|
129
129
|
*/
|
|
130
|
-
interface CompiledMutation<TOutput
|
|
131
|
-
query: TOutput
|
|
130
|
+
interface CompiledMutation<TOutput> {
|
|
131
|
+
query: TOutput;
|
|
132
132
|
/**
|
|
133
133
|
* Number of rows this operation must affect for the transaction to succeed.
|
|
134
134
|
* If actual affected rows doesn't match, it indicates a version conflict.
|
|
@@ -139,15 +139,15 @@ interface CompiledMutation<TOutput$1> {
|
|
|
139
139
|
/**
|
|
140
140
|
* Compiler interface for Unit of Work operations
|
|
141
141
|
*/
|
|
142
|
-
interface UOWCompiler<TSchema extends AnySchema, TOutput
|
|
142
|
+
interface UOWCompiler<TSchema extends AnySchema, TOutput> {
|
|
143
143
|
/**
|
|
144
144
|
* Compile a retrieval operation to the adapter's query format
|
|
145
145
|
*/
|
|
146
|
-
compileRetrievalOperation(op: RetrievalOperation<TSchema>): TOutput
|
|
146
|
+
compileRetrievalOperation(op: RetrievalOperation<TSchema>): TOutput | null;
|
|
147
147
|
/**
|
|
148
148
|
* Compile a mutation operation to the adapter's query format
|
|
149
149
|
*/
|
|
150
|
-
compileMutationOperation(op: MutationOperation<TSchema>): CompiledMutation<TOutput
|
|
150
|
+
compileMutationOperation(op: MutationOperation<TSchema>): CompiledMutation<TOutput> | null;
|
|
151
151
|
}
|
|
152
152
|
type MutationResult = {
|
|
153
153
|
success: true;
|
|
@@ -158,17 +158,17 @@ type MutationResult = {
|
|
|
158
158
|
/**
|
|
159
159
|
* Executor interface for Unit of Work operations
|
|
160
160
|
*/
|
|
161
|
-
interface UOWExecutor<TOutput
|
|
161
|
+
interface UOWExecutor<TOutput, TRawResult = unknown> {
|
|
162
162
|
/**
|
|
163
163
|
* Execute the retrieval phase - all queries run in a single transaction for snapshot isolation
|
|
164
164
|
*/
|
|
165
|
-
executeRetrievalPhase(retrievalBatch: TOutput
|
|
165
|
+
executeRetrievalPhase(retrievalBatch: TOutput[]): Promise<TRawResult[]>;
|
|
166
166
|
/**
|
|
167
167
|
* Execute the mutation phase - all queries run in a transaction with version checks
|
|
168
168
|
* Returns success status indicating if mutations completed without conflicts,
|
|
169
169
|
* and internal IDs for create operations (null if database doesn't support RETURNING)
|
|
170
170
|
*/
|
|
171
|
-
executeMutationPhase(mutationBatch: CompiledMutation<TOutput
|
|
171
|
+
executeMutationPhase(mutationBatch: CompiledMutation<TOutput>[]): Promise<MutationResult>;
|
|
172
172
|
}
|
|
173
173
|
/**
|
|
174
174
|
* Decoder interface for Unit of Work retrieval results
|
|
@@ -189,7 +189,7 @@ interface UOWDecoder<TSchema extends AnySchema, TRawInput = unknown> {
|
|
|
189
189
|
/**
|
|
190
190
|
* Builder for find operations in Unit of Work
|
|
191
191
|
*/
|
|
192
|
-
declare class FindBuilder<TTable extends AnyTable, TSelect
|
|
192
|
+
declare class FindBuilder<TTable extends AnyTable, TSelect extends SelectClause<TTable> = true, TJoinOut = {}> {
|
|
193
193
|
#private;
|
|
194
194
|
constructor(tableName: string, table: TTable);
|
|
195
195
|
/**
|
|
@@ -200,7 +200,7 @@ declare class FindBuilder<TTable extends AnyTable, TSelect$1 extends SelectClaus
|
|
|
200
200
|
* Specify columns to select
|
|
201
201
|
* @throws Error if selectCount() has already been called
|
|
202
202
|
*/
|
|
203
|
-
select<const TNewSelect extends SelectClause<TTable>>(columns: TNewSelect): FindBuilder<TTable, TNewSelect, TJoinOut
|
|
203
|
+
select<const TNewSelect extends SelectClause<TTable>>(columns: TNewSelect): FindBuilder<TTable, TNewSelect, TJoinOut>;
|
|
204
204
|
/**
|
|
205
205
|
* Select count instead of records
|
|
206
206
|
* @throws Error if select() has already been called
|
|
@@ -226,14 +226,14 @@ declare class FindBuilder<TTable extends AnyTable, TSelect$1 extends SelectClaus
|
|
|
226
226
|
* Add joins to include related data
|
|
227
227
|
* Join where clauses are restricted to indexed columns only
|
|
228
228
|
*/
|
|
229
|
-
join<TNewJoinOut>(joinFn: (jb: IndexedJoinBuilder<TTable, {}>) => IndexedJoinBuilder<TTable, TNewJoinOut>): FindBuilder<TTable, TSelect
|
|
229
|
+
join<TNewJoinOut>(joinFn: (jb: IndexedJoinBuilder<TTable, {}>) => IndexedJoinBuilder<TTable, TNewJoinOut>): FindBuilder<TTable, TSelect, TNewJoinOut>;
|
|
230
230
|
/**
|
|
231
231
|
* @internal
|
|
232
232
|
*/
|
|
233
233
|
build(): {
|
|
234
234
|
type: "find";
|
|
235
235
|
indexName: string;
|
|
236
|
-
options: FindOptions<TTable, TSelect
|
|
236
|
+
options: FindOptions<TTable, TSelect>;
|
|
237
237
|
} | {
|
|
238
238
|
type: "count";
|
|
239
239
|
indexName: string;
|
|
@@ -287,7 +287,7 @@ declare class DeleteBuilder {
|
|
|
287
287
|
* Builder for join operations in Unit of Work
|
|
288
288
|
* Similar to FindBuilder but tailored for joins (no cursor pagination, no count mode)
|
|
289
289
|
*/
|
|
290
|
-
declare class JoinFindBuilder<TTable extends AnyTable, TSelect
|
|
290
|
+
declare class JoinFindBuilder<TTable extends AnyTable, TSelect extends SelectClause<TTable> = true, TJoinOut = {}> {
|
|
291
291
|
#private;
|
|
292
292
|
constructor(tableName: string, table: TTable);
|
|
293
293
|
/**
|
|
@@ -297,7 +297,7 @@ declare class JoinFindBuilder<TTable extends AnyTable, TSelect$1 extends SelectC
|
|
|
297
297
|
/**
|
|
298
298
|
* Specify columns to select
|
|
299
299
|
*/
|
|
300
|
-
select<const TNewSelect extends SelectClause<TTable>>(columns: TNewSelect): JoinFindBuilder<TTable, TNewSelect, TJoinOut
|
|
300
|
+
select<const TNewSelect extends SelectClause<TTable>>(columns: TNewSelect): JoinFindBuilder<TTable, TNewSelect, TJoinOut>;
|
|
301
301
|
/**
|
|
302
302
|
* Order results by index in ascending or descending order
|
|
303
303
|
*/
|
|
@@ -310,13 +310,13 @@ declare class JoinFindBuilder<TTable extends AnyTable, TSelect$1 extends SelectC
|
|
|
310
310
|
* Add joins to include related data
|
|
311
311
|
* Join where clauses are restricted to indexed columns only
|
|
312
312
|
*/
|
|
313
|
-
join<TNewJoinOut>(joinFn: (jb: IndexedJoinBuilder<TTable, {}>) => IndexedJoinBuilder<TTable, TNewJoinOut>): JoinFindBuilder<TTable, TSelect
|
|
313
|
+
join<TNewJoinOut>(joinFn: (jb: IndexedJoinBuilder<TTable, {}>) => IndexedJoinBuilder<TTable, TNewJoinOut>): JoinFindBuilder<TTable, TSelect, TJoinOut & TNewJoinOut>;
|
|
314
314
|
/**
|
|
315
315
|
* @internal
|
|
316
316
|
*/
|
|
317
317
|
build(): {
|
|
318
318
|
indexName: string | undefined;
|
|
319
|
-
select: TSelect
|
|
319
|
+
select: TSelect | undefined;
|
|
320
320
|
where: ((eb: IndexedConditionBuilder<TTable>) => Condition | boolean) | undefined;
|
|
321
321
|
orderByIndex: {
|
|
322
322
|
indexName: string;
|
|
@@ -334,12 +334,12 @@ interface MapRelationType<T> {
|
|
|
334
334
|
* Join builder with indexed-only where clauses for Unit of Work
|
|
335
335
|
* TJoinOut accumulates the types of all joined relations
|
|
336
336
|
*/
|
|
337
|
-
type IndexedJoinBuilder<TTable extends AnyTable, TJoinOut
|
|
337
|
+
type IndexedJoinBuilder<TTable extends AnyTable, TJoinOut> = { [K in keyof TTable["relations"]]: TTable["relations"][K] extends Relation<infer TRelationType, infer TTargetTable> ? <TSelect extends SelectClause<TTable["relations"][K]["table"]> = true, TNestedJoinOut = {}>(builderFn?: (builder: JoinFindBuilder<TTable["relations"][K]["table"]>) => JoinFindBuilder<TTable["relations"][K]["table"], TSelect, TNestedJoinOut>) => IndexedJoinBuilder<TTable, TJoinOut & { [P in K]: MapRelationType<SelectResult<TTargetTable, TNestedJoinOut, TSelect>>[TRelationType] }> : never };
|
|
338
338
|
/**
|
|
339
339
|
* Build join operations with indexed-only where clauses for Unit of Work
|
|
340
340
|
* This ensures all join conditions can leverage indexes for optimal performance
|
|
341
341
|
*/
|
|
342
|
-
declare function buildJoinIndexed<TTable extends AnyTable, TJoinOut
|
|
342
|
+
declare function buildJoinIndexed<TTable extends AnyTable, TJoinOut>(table: TTable, fn: (builder: IndexedJoinBuilder<TTable, {}>) => IndexedJoinBuilder<TTable, TJoinOut>): CompiledJoin[];
|
|
343
343
|
declare function createUnitOfWork<const TSchema extends AnySchema, const TRetrievalResults extends unknown[] = [], const TRawInput = unknown>(schema: TSchema, compiler: UOWCompiler<TSchema, unknown>, executor: UOWExecutor<unknown, TRawInput>, decoder: UOWDecoder<TSchema, TRawInput>, name?: string): UnitOfWork<TSchema, TRetrievalResults, TRawInput>;
|
|
344
344
|
/**
|
|
345
345
|
* Unit of Work implementation with optimistic concurrency control
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unit-of-work.d.ts","names":[],"sources":["../../src/query/unit-of-work.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAUA;;AAC+C,UAD9B,iBAC8B,CAAA,eADG,QACH,CAAA,CAAA;EAAf,UAAA,CAAA,mBAAA,cAAA,CAAe,MAAf,CAAA,CAAA,CAAA,SAAA,EACjB,UADiB,EAAA,SAAA,CAAA,EAAA,CAAA,EAAA,EAEX,6BAFW,CAEmB,MAFnB,EAE2B,UAF3B,CAAA,EAAA,GAE2C,SAF3C,GAAA,OAAA,CAAA,EAAA,IAAA;EACjB,GAAA,CAAA,MAAA,EAGD,mBAHC,CAGmB,MAHnB,CAAA,CAAA,EAAA,IAAA;;;;;AAGmB,KAMtB,YANsB,CAAA,eAMM,KANN,CAAA,GAMe,MANf,CAAA,aAAA,CAAA,CAAA,MAAA,CAAA;KAQ7B,iBARS,CAAA,CAAA,CAAA,GAQc,CARd,SAAA,MAAA,GAAA,CAAA,MAQwC,CARxC,SAAA,KAAA,GAAA,KAAA,GAQkE,CARlE,CAAA,GAAA,KAAA;;AAMd;AAA+E;KAO1E,cALuB,CAAA,iBAKS,MALT,CAAA,MAAA,EAKwB,KALxB,CAAA,CAAA,GAKkC,QALlC,CAAA,MAKiD,QALjD,CAAA,SAKmE,KALnE,GAMxB,YANwB,CAMX,QANW,CAAA,MAMI,QANJ,CAAA,CAAA,GAAA,KAAA;KASvB,SATiD,CAAA,CAAA,CAAA,GAAA,QAA0B,MAS9C,CAT8C,IASzC,CATyC,CASvC,CATuC,CAAA,SAAA,KAAA,GAAA,KAAA,GASZ,CATY,GASR,CATQ,CASN,CATM,CAAA,EAAC;AAAA;;;;AAKJ,KAUjE,iBAViE,CAAA,eAUhC,QAVgC,CAAA,GAAA,MAUd,SAVc,CAAA,QAAkB,MAWjF,MAXiF,CAAA,SAAA,CAAA,GAW7D,MAX6D,CAAA,SAAA,CAAA,CAW3C,CAX2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