nitro-drizzle 0.3.0-beta.6 → 0.3.1
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/README.md +3 -3
- package/dist/config/defineConfig.d.mts +2 -6
- package/dist/config/defineConfig.mjs +1 -2
- package/dist/config.mjs +1 -2
- package/dist/context/internal/async.mjs +1 -2
- package/dist/context/internal/codegen.mjs +1 -2
- package/dist/context/internal/config.mjs +2 -3
- package/dist/context/internal/format.mjs +1 -2
- package/dist/context/internal/fs.mjs +1 -2
- package/dist/context/internal/logger.mjs +1 -2
- package/dist/context/internal/templates.mjs +3 -4
- package/dist/context/internal/templates.mjs.map +1 -1
- package/dist/context/internal/virtual.mjs +4 -3
- package/dist/context/internal/virtual.mjs.map +1 -1
- package/dist/context.d.mts +13 -16
- package/dist/context.mjs +34 -13
- package/dist/context.mjs.map +1 -1
- package/dist/dialects/index.d.mts +9 -12
- package/dist/dialects/mysql.d.mts +4 -8
- package/dist/dialects/mysql.mjs +1 -2
- package/dist/dialects/postgresql.d.mts +4 -8
- package/dist/dialects/postgresql.mjs +1 -2
- package/dist/dialects/sqlite.d.mts +4 -8
- package/dist/dialects/sqlite.mjs +1 -2
- package/dist/drivers/d1/dialect.mjs +1 -2
- package/dist/drivers/d1-http.d.mts +7 -10
- package/dist/drivers/d1-http.mjs +3 -4
- package/dist/drivers/d1-http.mjs.map +1 -1
- package/dist/drivers/d1.d.mts +3 -7
- package/dist/drivers/d1.mjs +4 -5
- package/dist/drivers/d1.mjs.map +1 -1
- package/dist/drivers/index.d.mts +6 -10
- package/dist/drivers/index.mjs +1 -2
- package/dist/drivers/internal/sql.mjs +1 -2
- package/dist/drivers/mysql.d.mts +2 -5
- package/dist/drivers/mysql.mjs +3 -4
- package/dist/drivers/pglite.d.mts +2 -5
- package/dist/drivers/pglite.mjs +2 -3
- package/dist/drivers/postgresql.d.mts +3 -6
- package/dist/drivers/postgresql.mjs +3 -4
- package/dist/drivers/sqlite.d.mts +3 -6
- package/dist/drivers/sqlite.mjs +3 -4
- package/dist/index.mjs +1 -2
- package/dist/meta.d.mts +2 -5
- package/dist/meta.mjs +1 -2
- package/dist/middleware/context.d.mts +7 -21
- package/dist/middleware/context.mjs +5 -25
- package/dist/middleware/context.mjs.map +1 -1
- package/dist/migrations/internal/migrate.d.mts +3 -7
- package/dist/migrations/internal/migrate.mjs +1 -2
- package/dist/migrations/internal/migrate.mjs.map +1 -1
- package/dist/migrations/migrate.d.mts +4 -7
- package/dist/migrations/migrate.mjs +3 -4
- package/dist/migrations/task.d.mts +1 -4
- package/dist/migrations/task.mjs +1 -2
- package/dist/migrations/useMigrations.d.mts +8 -12
- package/dist/migrations/useMigrations.mjs +3 -4
- package/dist/module/internal/fs.mjs +5 -6
- package/dist/module/internal/fs.mjs.map +1 -1
- package/dist/module/internal/path.mjs +1 -2
- package/dist/module/internal/reload.mjs +1 -2
- package/dist/module/internal/reload.mjs.map +1 -1
- package/dist/module/internal/resolver.mjs +1 -2
- package/dist/module/internal/resolver.mjs.map +1 -1
- package/dist/module/internal/rollup.mjs +1 -2
- package/dist/module/internal/types.mjs +21 -19
- package/dist/module/internal/types.mjs.map +1 -1
- package/dist/module/utils/assets.d.mts +1 -5
- package/dist/module/utils/assets.mjs +1 -2
- package/dist/module/utils/externals.d.mts +1 -5
- package/dist/module/utils/externals.mjs +1 -2
- package/dist/module/utils/nitro.d.mts +1 -5
- package/dist/module/utils/nitro.mjs +1 -2
- package/dist/module.d.mts +11 -21
- package/dist/module.mjs +27 -19
- package/dist/module.mjs.map +1 -1
- package/dist/plugins/init/index.d.mts +6 -0
- package/dist/plugins/init/index.mjs +20 -0
- package/dist/plugins/init/index.mjs.map +1 -0
- package/dist/plugins/init/legacy.d.mts +15 -0
- package/dist/plugins/init/legacy.mjs +26 -0
- package/dist/plugins/init/legacy.mjs.map +1 -0
- package/dist/plugins/{migrate.d.mts → migrate/hooks.d.mts} +3 -16
- package/dist/plugins/migrate/hooks.mjs +10 -0
- package/dist/plugins/migrate/hooks.mjs.map +1 -0
- package/dist/plugins/migrate/index.d.mts +11 -0
- package/dist/plugins/{migrate.mjs → migrate/index.mjs} +10 -10
- package/dist/plugins/migrate/index.mjs.map +1 -0
- package/dist/plugins/migrate/legacy.d.mts +11 -0
- package/dist/plugins/migrate/legacy.mjs +25 -0
- package/dist/plugins/migrate/legacy.mjs.map +1 -0
- package/dist/runtime/callInitHook.d.mts +8 -0
- package/dist/runtime/callInitHook.mjs +27 -0
- package/dist/runtime/callInitHook.mjs.map +1 -0
- package/dist/runtime/internal/config.mjs +1 -2
- package/dist/runtime/internal/createDatasource.mjs +4 -5
- package/dist/runtime/internal/hooks.d.mts +14 -0
- package/dist/runtime/internal/hooks.mjs +5 -0
- package/dist/runtime/internal/hooks.mjs.map +1 -0
- package/dist/runtime/internal/state.d.mts +10 -0
- package/dist/runtime/internal/state.mjs +28 -0
- package/dist/runtime/internal/state.mjs.map +1 -0
- package/dist/runtime/useConfig.d.mts +2 -6
- package/dist/runtime/useConfig.mjs +1 -2
- package/dist/runtime/useDatasource.d.mts +3 -7
- package/dist/runtime/useDatasource.mjs +2 -3
- package/dist/runtime/useDialect.d.mts +5 -8
- package/dist/runtime/useDialect.mjs +2 -3
- package/dist/runtime.d.mts +22 -22
- package/dist/runtime.mjs +4 -1
- package/dist/shared/variants.d.mts +7 -10
- package/dist/shared/variants.mjs +1 -2
- package/dist/shared.d.mts +7 -10
- package/dist/shared.mjs +1 -2
- package/dist/utils/usePrimaryKey.d.mts +1 -5
- package/dist/utils/usePrimaryKey.mjs +1 -2
- package/dist/utils.mjs +1 -2
- package/package.json +35 -31
- package/dist/drivers/db0.d.mts +0 -21
- package/dist/drivers/db0.mjs +0 -28
- package/dist/drivers/db0.mjs.map +0 -1
- package/dist/plugins/init.d.mts +0 -15
- package/dist/plugins/init.mjs +0 -13
- package/dist/plugins/init.mjs.map +0 -1
- package/dist/plugins/legacy/init.d.mts +0 -24
- package/dist/plugins/legacy/init.mjs +0 -50
- package/dist/plugins/legacy/init.mjs.map +0 -1
- package/dist/plugins/legacy/migrate.d.mts +0 -21
- package/dist/plugins/legacy/migrate.mjs +0 -25
- package/dist/plugins/legacy/migrate.mjs.map +0 -1
- package/dist/plugins/migrate.mjs.map +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { InferMysqlTable } from "./mysql.mjs";
|
|
2
|
-
import { InferPgTable } from "./postgresql.mjs";
|
|
3
|
-
import { InferSqliteTable } from "./sqlite.mjs";
|
|
4
1
|
import { Column, SQL, Table } from "drizzle-orm";
|
|
5
|
-
import { SQLiteInsertBase } from "drizzle-orm/sqlite-core";
|
|
6
2
|
import { MySqlInsertBase } from "drizzle-orm/mysql-core";
|
|
3
|
+
import { InferMysqlTable } from "./mysql.mjs";
|
|
7
4
|
import { PgInsertBase } from "drizzle-orm/pg-core";
|
|
8
|
-
|
|
5
|
+
import { InferPgTable } from "./postgresql.mjs";
|
|
6
|
+
import { SQLiteInsertBase } from "drizzle-orm/sqlite-core";
|
|
7
|
+
import { InferSqliteTable } from "./sqlite.mjs";
|
|
9
8
|
interface OnConflictOptions<TSet extends Record<string, SQL | undefined>> {
|
|
10
9
|
set: TSet;
|
|
11
10
|
}
|
|
@@ -13,26 +12,24 @@ interface OnConflictOptions<TSet extends Record<string, SQL | undefined>> {
|
|
|
13
12
|
* Options for ON CONFLICT DO UPDATE clause.
|
|
14
13
|
* @template T - The insert type
|
|
15
14
|
*/
|
|
16
|
-
type OnConflictDoUpdateOptions<T extends AnyInsert> = OnConflictOptions<{ [K in keyof InferColumns<InferTable<T>>]?: SQL; }>;
|
|
15
|
+
export type OnConflictDoUpdateOptions<T extends AnyInsert> = OnConflictOptions<{ [K in keyof InferColumns<InferTable<T>>]?: SQL; }>;
|
|
17
16
|
/**
|
|
18
17
|
* Infers column types from a Drizzle table.
|
|
19
18
|
* @template TTable - The table type
|
|
20
19
|
*/
|
|
21
|
-
type InferColumns<TTable extends Table> = TTable extends Table<infer TTableConfig> ? TTableConfig["columns"] : never;
|
|
20
|
+
export type InferColumns<TTable extends Table> = TTable extends Table<infer TTableConfig> ? TTableConfig["columns"] : never;
|
|
22
21
|
type AnyInsert = MySqlInsertBase<any, any, any, any, any, any> | PgInsertBase<any, any, any, any, any, any> | SQLiteInsertBase<any, any, any, any, any, any>;
|
|
23
22
|
/**
|
|
24
23
|
* Infers the table type from an insert statement.
|
|
25
24
|
* @template T - The insert type
|
|
26
25
|
*/
|
|
27
|
-
type InferTable<T extends AnyInsert> = T extends MySqlInsertBase<any, any, any, any, any, any> ? InferMysqlTable<T> : T extends PgInsertBase<any, any, any, any, any, any> ? InferPgTable<T> : T extends SQLiteInsertBase<any, any, any, any, any, any> ? InferSqliteTable<T> : never;
|
|
26
|
+
export type InferTable<T extends AnyInsert> = T extends MySqlInsertBase<any, any, any, any, any, any> ? InferMysqlTable<T> : T extends PgInsertBase<any, any, any, any, any, any> ? InferPgTable<T> : T extends SQLiteInsertBase<any, any, any, any, any, any> ? InferSqliteTable<T> : never;
|
|
28
27
|
type RemoveNeverProps<T extends Record<string, any>> = { [K in keyof T as T[K] extends never ? never : K]: T[K]; };
|
|
29
28
|
/**
|
|
30
29
|
* Infers primary key columns from a Drizzle table.
|
|
31
30
|
* @template T - The table type
|
|
32
31
|
*/
|
|
33
|
-
type InferPrimaryColumns<T extends Table> = RemoveNeverProps<{ [K in keyof InferColumns<T>]: InferColumns<T>[K] extends Column<infer TColumnConfig> ? Extract<TColumnConfig, {
|
|
32
|
+
export type InferPrimaryColumns<T extends Table> = RemoveNeverProps<{ [K in keyof InferColumns<T>]: InferColumns<T>[K] extends Column<infer TColumnConfig> ? Extract<TColumnConfig, {
|
|
34
33
|
isPrimaryKey: true;
|
|
35
34
|
}> extends never ? never : InferColumns<T>[K] : never; }>;
|
|
36
|
-
|
|
37
|
-
export { InferColumns, InferPrimaryColumns, InferTable, OnConflictDoUpdateOptions };
|
|
38
|
-
//# sourceMappingURL=index.d.mts.map
|
|
35
|
+
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { InferPrimaryColumns, InferTable, OnConflictDoUpdateOptions } from "./index.mjs";
|
|
2
1
|
import { MySqlInsertBase } from "drizzle-orm/mysql-core";
|
|
3
|
-
|
|
2
|
+
import { InferPrimaryColumns, InferTable, OnConflictDoUpdateOptions } from "./index.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Adds an ON CONFLICT DO UPDATE clause to a MySQL insert statement.
|
|
6
5
|
* @template TInsert - The insert type
|
|
@@ -9,7 +8,7 @@ import { MySqlInsertBase } from "drizzle-orm/mysql-core";
|
|
|
9
8
|
* @param options - Options containing the SET values
|
|
10
9
|
* @returns The modified insert statement
|
|
11
10
|
*/
|
|
12
|
-
declare function onConflictDoUpdate<TInsert extends MySqlInsertBase<any, any, any, any, any, any>>(_: InferPrimaryColumns<InferTable<TInsert>>, insert: TInsert, options: OnConflictDoUpdateOptions<TInsert>): TInsert | Omit<MySqlInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["preparedQueryHKT"], TInsert["_"]["returning"], any, "$returning" | TInsert["_"]["excludedMethods"]>, "onDuplicateKeyUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
11
|
+
export declare function onConflictDoUpdate<TInsert extends MySqlInsertBase<any, any, any, any, any, any>>(_: InferPrimaryColumns<InferTable<TInsert>>, insert: TInsert, options: OnConflictDoUpdateOptions<TInsert>): TInsert | Omit<MySqlInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["preparedQueryHKT"], TInsert["_"]["returning"], any, "$returning" | TInsert["_"]["excludedMethods"]>, "onDuplicateKeyUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
13
12
|
/**
|
|
14
13
|
* Adds an ON CONFLICT DO NOTHING clause to a MySQL insert statement.
|
|
15
14
|
* Uses ON DUPLICATE KEY UPDATE with the primary key values for equivalent behavior.
|
|
@@ -18,12 +17,9 @@ declare function onConflictDoUpdate<TInsert extends MySqlInsertBase<any, any, an
|
|
|
18
17
|
* @param insert - The insert statement
|
|
19
18
|
* @returns The modified insert statement
|
|
20
19
|
*/
|
|
21
|
-
declare function onConflictDoNothing<TInsert extends MySqlInsertBase<any, any, any, any, any, any>>(target: InferPrimaryColumns<InferTable<TInsert>>, insert: TInsert): TInsert | Omit<MySqlInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["preparedQueryHKT"], TInsert["_"]["returning"], any, "$returning" | TInsert["_"]["excludedMethods"]>, "onDuplicateKeyUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
20
|
+
export declare function onConflictDoNothing<TInsert extends MySqlInsertBase<any, any, any, any, any, any>>(target: InferPrimaryColumns<InferTable<TInsert>>, insert: TInsert): TInsert | Omit<MySqlInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["preparedQueryHKT"], TInsert["_"]["returning"], any, "$returning" | TInsert["_"]["excludedMethods"]>, "onDuplicateKeyUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
22
21
|
/**
|
|
23
22
|
* Infers the table type from a MySQL insert statement.
|
|
24
23
|
* @template T - The insert type
|
|
25
24
|
*/
|
|
26
|
-
type InferMysqlTable<T extends MySqlInsertBase<any, any, any, any, any, any>> = T extends MySqlInsertBase<infer TTable, any, any, any, any, any> ? TTable : never;
|
|
27
|
-
//#endregion
|
|
28
|
-
export { InferMysqlTable, onConflictDoNothing, onConflictDoUpdate };
|
|
29
|
-
//# sourceMappingURL=mysql.d.mts.map
|
|
25
|
+
export type InferMysqlTable<T extends MySqlInsertBase<any, any, any, any, any, any>> = T extends MySqlInsertBase<infer TTable, any, any, any, any, any> ? TTable : never;
|
package/dist/dialects/mysql.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sql } from "drizzle-orm/sql";
|
|
2
|
-
|
|
2
|
+
// src/dialects/mysql.ts
|
|
3
3
|
/**
|
|
4
4
|
* Adds an ON CONFLICT DO UPDATE clause to a MySQL insert statement.
|
|
5
5
|
* @template TInsert - The insert type
|
|
@@ -24,7 +24,6 @@ function onConflictDoNothing(target, insert) {
|
|
|
24
24
|
return [name, sql`${column}`];
|
|
25
25
|
})) });
|
|
26
26
|
}
|
|
27
|
-
//#endregion
|
|
28
27
|
export { onConflictDoNothing, onConflictDoUpdate };
|
|
29
28
|
|
|
30
29
|
//# sourceMappingURL=mysql.mjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { InferColumns, InferTable, OnConflictDoUpdateOptions } from "./index.mjs";
|
|
2
1
|
import { PgInsertBase } from "drizzle-orm/pg-core";
|
|
3
|
-
|
|
2
|
+
import { InferColumns, InferTable, OnConflictDoUpdateOptions } from "./index.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Adds an ON CONFLICT DO UPDATE clause to a PostgreSQL insert statement.
|
|
6
5
|
* @template TInsert - The insert type
|
|
@@ -9,7 +8,7 @@ import { PgInsertBase } from "drizzle-orm/pg-core";
|
|
|
9
8
|
* @param options - Options containing the SET values
|
|
10
9
|
* @returns The modified insert statement
|
|
11
10
|
*/
|
|
12
|
-
declare function onConflictDoUpdate<TInsert extends PgInsertBase<any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert, options: OnConflictDoUpdateOptions<TInsert>): TInsert | Omit<PgInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["selectedFields"], TInsert["_"]["returning"], any, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
11
|
+
export declare function onConflictDoUpdate<TInsert extends PgInsertBase<any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert, options: OnConflictDoUpdateOptions<TInsert>): TInsert | Omit<PgInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["selectedFields"], TInsert["_"]["returning"], any, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
13
12
|
/**
|
|
14
13
|
* Adds an ON CONFLICT DO NOTHING clause to a PostgreSQL insert statement.
|
|
15
14
|
* @template TInsert - The insert type
|
|
@@ -17,12 +16,9 @@ declare function onConflictDoUpdate<TInsert extends PgInsertBase<any, any, any>>
|
|
|
17
16
|
* @param insert - The insert statement
|
|
18
17
|
* @returns The modified insert statement with DO NOTHING
|
|
19
18
|
*/
|
|
20
|
-
declare function onConflictDoNothing<TInsert extends PgInsertBase<any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert): TInsert | Omit<PgInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["selectedFields"], TInsert["_"]["returning"], any, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
19
|
+
export declare function onConflictDoNothing<TInsert extends PgInsertBase<any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert): TInsert | Omit<PgInsertBase<TInsert["_"]["table"], TInsert["_"]["queryResult"], TInsert["_"]["selectedFields"], TInsert["_"]["returning"], any, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>, "onConflictDoNothing" | "onConflictDoUpdate" | TInsert["_"]["excludedMethods"]>;
|
|
21
20
|
/**
|
|
22
21
|
* Infers the table type from a PostgreSQL insert statement.
|
|
23
22
|
* @template T - The insert type
|
|
24
23
|
*/
|
|
25
|
-
type InferPgTable<T extends PgInsertBase<any, any, any, any, any, any>> = T extends PgInsertBase<infer TTable, any, any, any, any, any> ? TTable : never;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { InferPgTable, onConflictDoNothing, onConflictDoUpdate };
|
|
28
|
-
//# sourceMappingURL=postgresql.d.mts.map
|
|
24
|
+
export type InferPgTable<T extends PgInsertBase<any, any, any, any, any, any>> = T extends PgInsertBase<infer TTable, any, any, any, any, any> ? TTable : never;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dialects/postgresql.ts
|
|
2
2
|
/**
|
|
3
3
|
* Adds an ON CONFLICT DO UPDATE clause to a PostgreSQL insert statement.
|
|
4
4
|
* @template TInsert - The insert type
|
|
@@ -23,7 +23,6 @@ function onConflictDoUpdate(target, insert, options) {
|
|
|
23
23
|
function onConflictDoNothing(target, insert) {
|
|
24
24
|
return insert.onConflictDoNothing({ target: Object.values(target) });
|
|
25
25
|
}
|
|
26
|
-
//#endregion
|
|
27
26
|
export { onConflictDoNothing, onConflictDoUpdate };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=postgresql.mjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { InferColumns, InferTable, OnConflictDoUpdateOptions } from "./index.mjs";
|
|
2
1
|
import { SQLiteInsertBase } from "drizzle-orm/sqlite-core";
|
|
3
|
-
|
|
2
|
+
import { InferColumns, InferTable, OnConflictDoUpdateOptions } from "./index.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* Adds an ON CONFLICT DO UPDATE clause to a SQLite insert statement.
|
|
6
5
|
* @template TInsert - The insert type
|
|
@@ -9,7 +8,7 @@ import { SQLiteInsertBase } from "drizzle-orm/sqlite-core";
|
|
|
9
8
|
* @param options - Options containing the SET values
|
|
10
9
|
* @returns The modified insert statement
|
|
11
10
|
*/
|
|
12
|
-
declare function onConflictDoUpdate<TInsert extends SQLiteInsertBase<any, any, any, any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert, options: OnConflictDoUpdateOptions<TInsert>): TInsert;
|
|
11
|
+
export declare function onConflictDoUpdate<TInsert extends SQLiteInsertBase<any, any, any, any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert, options: OnConflictDoUpdateOptions<TInsert>): TInsert;
|
|
13
12
|
/**
|
|
14
13
|
* Adds an ON CONFLICT DO NOTHING clause to a SQLite insert statement.
|
|
15
14
|
* @template TInsert - The insert type
|
|
@@ -17,12 +16,9 @@ declare function onConflictDoUpdate<TInsert extends SQLiteInsertBase<any, any, a
|
|
|
17
16
|
* @param insert - The insert statement
|
|
18
17
|
* @returns The modified insert statement with DO NOTHING
|
|
19
18
|
*/
|
|
20
|
-
declare function onConflictDoNothing<TInsert extends SQLiteInsertBase<any, any, any, any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert): TInsert;
|
|
19
|
+
export declare function onConflictDoNothing<TInsert extends SQLiteInsertBase<any, any, any, any, any, any>>(target: Partial<InferColumns<InferTable<TInsert>>>, insert: TInsert): TInsert;
|
|
21
20
|
/**
|
|
22
21
|
* Infers the table type from a SQLite insert statement.
|
|
23
22
|
* @template T - The insert type
|
|
24
23
|
*/
|
|
25
|
-
type InferSqliteTable<T extends SQLiteInsertBase<any, any, any, any, any, any>> = T extends SQLiteInsertBase<infer TTable, any, any, any, any, any> ? TTable : never;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { InferSqliteTable, onConflictDoNothing, onConflictDoUpdate };
|
|
28
|
-
//# sourceMappingURL=sqlite.d.mts.map
|
|
24
|
+
export type InferSqliteTable<T extends SQLiteInsertBase<any, any, any, any, any, any>> = T extends SQLiteInsertBase<infer TTable, any, any, any, any, any> ? TTable : never;
|
package/dist/dialects/sqlite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/dialects/sqlite.ts
|
|
2
2
|
/**
|
|
3
3
|
* Adds an ON CONFLICT DO UPDATE clause to a SQLite insert statement.
|
|
4
4
|
* @template TInsert - The insert type
|
|
@@ -23,7 +23,6 @@ function onConflictDoUpdate(target, insert, options) {
|
|
|
23
23
|
function onConflictDoNothing(target, insert) {
|
|
24
24
|
return insert.onConflictDoNothing({ target: Object.values(target) });
|
|
25
25
|
}
|
|
26
|
-
//#endregion
|
|
27
26
|
export { onConflictDoNothing, onConflictDoUpdate };
|
|
28
27
|
|
|
29
28
|
//# sourceMappingURL=sqlite.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sql } from "drizzle-orm";
|
|
2
2
|
import { SQLiteAsyncDialect } from "drizzle-orm/sqlite-core";
|
|
3
3
|
import { SQLiteRaw } from "drizzle-orm/sqlite-core/query-builders/raw";
|
|
4
|
-
|
|
4
|
+
// src/drivers/d1/dialect.ts
|
|
5
5
|
/**
|
|
6
6
|
* SQLite dialect for Cloudflare D1 that uses batching instead of transactions for migrations.
|
|
7
7
|
* D1 does not support transactions, so migrations are executed as a batch.
|
|
@@ -36,7 +36,6 @@ var SQLiteD1Dialect = class extends SQLiteAsyncDialect {
|
|
|
36
36
|
function createBatchItem({ session, dialect, sql }) {
|
|
37
37
|
return new SQLiteRaw(async () => await session.run(sql), () => sql, "run", dialect, (result) => result);
|
|
38
38
|
}
|
|
39
|
-
//#endregion
|
|
40
39
|
export { SQLiteD1Dialect };
|
|
41
40
|
|
|
42
41
|
//# sourceMappingURL=dialect.mjs.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
import { AsyncBatchRemoteCallback, AsyncRemoteCallback, RemoteCallback, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
|
1
2
|
import { Schema } from "./index.mjs";
|
|
2
3
|
import { DrizzleConfig } from "drizzle-orm";
|
|
3
|
-
import { AsyncBatchRemoteCallback, AsyncRemoteCallback, RemoteCallback, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
|
4
|
-
//#region src/drivers/d1-http.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Cloudflare D1 HTTP datasource driver for remote connections.
|
|
7
6
|
* @template TSchema - The schema type
|
|
@@ -16,7 +15,7 @@ declare const driver: <TSchema extends Schema>(options: D1HttpOptions, schema: T
|
|
|
16
15
|
close(): Promise<void>;
|
|
17
16
|
};
|
|
18
17
|
/** Configuration options for the Cloudflare D1 HTTP driver. */
|
|
19
|
-
type D1HttpOptions = {
|
|
18
|
+
export type D1HttpOptions = {
|
|
20
19
|
/** Cloudflare account ID. */
|
|
21
20
|
accountId: string;
|
|
22
21
|
/** D1 database ID. */
|
|
@@ -25,7 +24,7 @@ type D1HttpOptions = {
|
|
|
25
24
|
token: string;
|
|
26
25
|
};
|
|
27
26
|
/** Internal type for the HTTP driver callback functions. */
|
|
28
|
-
type D1HttpDriver = {
|
|
27
|
+
export type D1HttpDriver = {
|
|
29
28
|
callback: AsyncRemoteCallback;
|
|
30
29
|
batchCallback: AsyncBatchRemoteCallback;
|
|
31
30
|
};
|
|
@@ -35,9 +34,7 @@ type D1HttpDriver = {
|
|
|
35
34
|
* @returns Object containing callback and batchCallback functions
|
|
36
35
|
* @see [Cloudflare API docs](https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/raw/)
|
|
37
36
|
*/
|
|
38
|
-
declare function d1HttpDriver(options: D1HttpOptions): D1HttpDriver;
|
|
39
|
-
declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(callback: RemoteCallback, config?: DrizzleConfig<TSchema>): SqliteRemoteDatabase<TSchema>;
|
|
40
|
-
declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(callback: RemoteCallback, batchCallback?: AsyncBatchRemoteCallback, config?: DrizzleConfig<TSchema>): SqliteRemoteDatabase<TSchema>;
|
|
41
|
-
|
|
42
|
-
export { D1HttpDriver, D1HttpOptions, d1HttpDriver, driver as default, drizzle };
|
|
43
|
-
//# sourceMappingURL=d1-http.d.mts.map
|
|
37
|
+
export declare function d1HttpDriver(options: D1HttpOptions): D1HttpDriver;
|
|
38
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(callback: RemoteCallback, config?: DrizzleConfig<TSchema>): SqliteRemoteDatabase<TSchema>;
|
|
39
|
+
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(callback: RemoteCallback, batchCallback?: AsyncBatchRemoteCallback, config?: DrizzleConfig<TSchema>): SqliteRemoteDatabase<TSchema>;
|
|
40
|
+
export { driver as default };
|
package/dist/drivers/d1-http.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { SQLiteRemoteSession, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
|
1
2
|
import { defineConnector } from "./index.mjs";
|
|
3
|
+
import { DefaultLogger, createTableRelationsHelpers, extractTablesRelationalConfig } from "drizzle-orm";
|
|
2
4
|
import { SQLiteD1Dialect } from "./d1/dialect.mjs";
|
|
3
5
|
import { SELECT_1 } from "./internal/sql.mjs";
|
|
4
|
-
|
|
5
|
-
import { SQLiteRemoteSession, SqliteRemoteDatabase } from "drizzle-orm/sqlite-proxy";
|
|
6
|
-
//#region src/drivers/d1-http.ts
|
|
6
|
+
// src/drivers/d1-http.ts
|
|
7
7
|
/**
|
|
8
8
|
* Cloudflare D1 HTTP datasource driver for remote connections.
|
|
9
9
|
* @template TSchema - The schema type
|
|
@@ -100,7 +100,6 @@ function drizzle(callback, batchCallback, config) {
|
|
|
100
100
|
if (db.$cache) db.$cache["invalidate"] = cache?.onMutate;
|
|
101
101
|
return db;
|
|
102
102
|
}
|
|
103
|
-
//#endregion
|
|
104
103
|
export { d1HttpDriver, driver as default, drizzle };
|
|
105
104
|
|
|
106
105
|
//# sourceMappingURL=d1-http.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d1-http.mjs","names":[],"sources":["../../src/drivers/d1-http.ts"],"sourcesContent":["import {\n type AsyncRemoteCallback,\n type AsyncBatchRemoteCallback,\n SqliteRemoteDatabase,\n SQLiteRemoteSession,\n type RemoteCallback,\n} from \"drizzle-orm/sqlite-proxy\";\nimport { defineConnector, type Schema } from \".\";\nimport {\n type DrizzleConfig,\n DefaultLogger,\n type RelationalSchemaConfig,\n type TablesRelationalConfig,\n extractTablesRelationalConfig,\n createTableRelationsHelpers,\n} from \"drizzle-orm\";\nimport { SQLiteD1Dialect } from \"./d1/dialect\";\nimport { SELECT_1 } from \"./internal/sql\";\n\n/**\n * Cloudflare D1 HTTP datasource driver for remote connections.\n * @template TSchema - The schema type\n * @param options - Driver configuration options\n * @param schema - The Drizzle schema\n * @returns A Datasource instance\n */\nconst driver = defineConnector(\n <TSchema extends Schema>(options: D1HttpOptions, schema: TSchema) => {\n const { callback, batchCallback } = d1HttpDriver(options);\n const database = drizzle(callback, batchCallback, { schema });\n return {\n database,\n schema,\n async waitReady() {\n await database.run(SELECT_1);\n },\n async close() {},\n };\n },\n);\n\nexport default driver;\n\n/** Configuration options for the Cloudflare D1 HTTP driver. */\nexport type D1HttpOptions = {\n /** Cloudflare account ID. */\n accountId: string;\n /** D1 database ID. */\n databaseId: string;\n /** API token for authentication. */\n token: string;\n};\n\n/** Internal type for the HTTP driver callback functions. */\nexport type D1HttpDriver = {\n callback: AsyncRemoteCallback;\n batchCallback: AsyncBatchRemoteCallback;\n};\n\ntype D1Response =\n | {\n success: true;\n result: [Result, ...Result[]];\n }\n | {\n success: false;\n errors: { code: number; message: string }[];\n };\n\ntype Result = {\n results:\n | any[]\n | {\n columns: string[];\n rows: any[][];\n };\n};\n\ntype D1HttpQuery = {\n sql: string;\n params: any[];\n};\n\ntype FetchD1Body =\n | {\n batch: D1HttpQuery[];\n }\n | D1HttpQuery;\n\nasync function fetchD1(url: string | URL, body: FetchD1Body, options: D1HttpOptions) {\n const res = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${options.token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(body),\n });\n\n const data = (await res.json()) as D1Response;\n\n if (!data.success) {\n throw new Error(data.errors.map((it) => `${it.code}: ${it.message}`).join(\"\\n\"));\n }\n\n const result = data.result[0].results;\n const rows = Array.isArray(result) ? result : result.rows;\n\n return { rows };\n}\n\n/**\n * Creates an HTTP driver for Cloudflare D1 API.\n * @param options - D1 HTTP configuration options\n * @returns Object containing callback and batchCallback functions\n * @see [Cloudflare API docs](https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/raw/)\n */\nexport function d1HttpDriver(options: D1HttpOptions): D1HttpDriver {\n const url = new URL(\n `accounts/${options.accountId}/d1/database/${options.databaseId}/raw`,\n \"https://api.cloudflare.com/client/v4/\",\n );\n return {\n async callback(sql, params, _) {\n const body = { sql, params };\n const res = await fetchD1(url, body, options);\n return res;\n },\n async batchCallback(batch) {\n const body = {\n batch: batch.map(({ sql, params }) => {\n return {\n sql,\n params,\n };\n }),\n };\n const res = await fetchD1(url, body, options);\n return [res];\n },\n };\n}\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n callback: RemoteCallback,\n config?: DrizzleConfig<TSchema>,\n): SqliteRemoteDatabase<TSchema>;\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n callback: RemoteCallback,\n batchCallback?: AsyncBatchRemoteCallback,\n config?: DrizzleConfig<TSchema>,\n): SqliteRemoteDatabase<TSchema>;\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n callback: RemoteCallback,\n batchCallback?: AsyncBatchRemoteCallback | DrizzleConfig<TSchema>,\n config?: DrizzleConfig<TSchema>,\n): SqliteRemoteDatabase<TSchema> {\n const dialect = new SQLiteD1Dialect({ casing: config?.casing });\n let logger;\n let cache;\n let _batchCallback: AsyncBatchRemoteCallback | undefined;\n let _config: DrizzleConfig<TSchema> = {};\n\n if (batchCallback) {\n if (typeof batchCallback === \"function\") {\n _batchCallback = batchCallback as AsyncBatchRemoteCallback;\n _config = config ?? {};\n } else {\n _batchCallback = undefined;\n _config = batchCallback as DrizzleConfig<TSchema>;\n }\n\n if (_config.logger === true) {\n logger = new DefaultLogger();\n } else if (_config.logger !== false) {\n logger = _config.logger;\n cache = _config.cache;\n }\n }\n\n let schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n if (_config.schema) {\n const tablesConfig = extractTablesRelationalConfig(_config.schema, createTableRelationsHelpers);\n schema = {\n fullSchema: _config.schema,\n schema: tablesConfig.tables,\n tableNamesMap: tablesConfig.tableNamesMap,\n };\n }\n\n const session = new SQLiteRemoteSession(callback, dialect, schema, _batchCallback, {\n logger,\n cache,\n });\n const db = new SqliteRemoteDatabase(\n \"async\",\n dialect,\n session,\n schema,\n ) as SqliteRemoteDatabase<TSchema>;\n (<any>db).$cache = cache;\n if ((<any>db).$cache) {\n (<any>db).$cache[\"invalidate\"] = cache?.onMutate;\n }\n return db;\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAM,SAAS,iBACY,SAAwB,WAAoB;CACnE,MAAM,EAAE,UAAU,kBAAkB,aAAa,OAAO;CACxD,MAAM,WAAW,QAAQ,UAAU,eAAe,EAAE,OAAO,CAAC;CAC5D,OAAO;EACL;EACA;EACA,MAAM,YAAY;GAChB,MAAM,SAAS,IAAI,QAAQ;EAC7B;EACA,MAAM,QAAQ,CAAC;CACjB;AACF,CACF;AAkDA,eAAe,QAAQ,KAAmB,MAAmB,SAAwB;CAUnF,MAAM,OAAQ,OAAM,MATF,MAAM,KAAK;EAC3B,QAAQ;EACR,SAAS;GACP,eAAe,UAAU,QAAQ;GACjC,gBAAgB;EAClB;EACA,MAAM,KAAK,UAAU,IAAI;CAC3B,CAAC,EAAA,CAEuB,KAAK;CAE7B,IAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,KAAK,OAAO,KAAK,OAAO,GAAG,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC,CAAC,KAAK,IAAI,CAAC;CAGjF,MAAM,SAAS,KAAK,OAAO,EAAE,CAAC;CAG9B,OAAO,EAAE,MAFI,MAAM,QAAQ,MAAM,IAAI,SAAS,OAAO,KAEvC;AAChB;;;;;;;AAQA,SAAgB,aAAa,SAAsC;CACjE,MAAM,MAAM,IAAI,IACd,YAAY,QAAQ,UAAU,eAAe,QAAQ,WAAW,OAChE,uCACF;CACA,OAAO;EACL,MAAM,SAAS,KAAK,QAAQ,GAAG;GAG7B,OAAO,MADW,QAAQ,KAAK;IADhB;IAAK;GACc,GAAG,OAAO;EAE9C;EACA,MAAM,cAAc,OAAO;GACzB,MAAM,OAAO,EACX,OAAO,MAAM,KAAK,EAAE,KAAK,aAAa;IACpC,OAAO;KACL;KACA;IACF;GACF,CAAC,EACH;GAEA,OAAO,CAAC,MADU,QAAQ,KAAK,MAAM,OAAO,CACjC;EACb;CACF;AACF;AAWA,SAAgB,QACd,UACA,eACA,QAC+B;CAC/B,MAAM,UAAU,IAAI,gBAAgB,EAAE,QAAQ,QAAQ,OAAO,CAAC;CAC9D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,UAAkC,CAAC;CAEvC,IAAI,eAAe;EACjB,IAAI,OAAO,kBAAkB,YAAY;GACvC,iBAAiB;GACjB,UAAU,UAAU,CAAC;EACvB,OAAO;GACL,iBAAiB,KAAA;GACjB,UAAU;EACZ;EAEA,IAAI,QAAQ,WAAW,MACrB,SAAS,IAAI,cAAc;OACtB,IAAI,QAAQ,WAAW,OAAO;GACnC,SAAS,QAAQ;GACjB,QAAQ,QAAQ;EAClB;CACF;CAEA,IAAI;CACJ,IAAI,QAAQ,QAAQ;EAClB,MAAM,eAAe,8BAA8B,QAAQ,QAAQ,2BAA2B;EAC9F,SAAS;GACP,YAAY,QAAQ;GACpB,QAAQ,aAAa;GACrB,eAAe,aAAa;EAC9B;CACF;CAEA,MAAM,UAAU,IAAI,oBAAoB,UAAU,SAAS,QAAQ,gBAAgB;EACjF;EACA;CACF,CAAC;CACD,MAAM,KAAK,IAAI,qBACb,SACA,SACA,SACA,MACF;
|
|
1
|
+
{"version":3,"file":"d1-http.mjs","names":[],"sources":["../../src/drivers/d1-http.ts"],"sourcesContent":["import {\n type AsyncRemoteCallback,\n type AsyncBatchRemoteCallback,\n SqliteRemoteDatabase,\n SQLiteRemoteSession,\n type RemoteCallback,\n} from \"drizzle-orm/sqlite-proxy\";\nimport { defineConnector, type Schema } from \".\";\nimport {\n type DrizzleConfig,\n DefaultLogger,\n type RelationalSchemaConfig,\n type TablesRelationalConfig,\n extractTablesRelationalConfig,\n createTableRelationsHelpers,\n} from \"drizzle-orm\";\nimport { SQLiteD1Dialect } from \"./d1/dialect\";\nimport { SELECT_1 } from \"./internal/sql\";\n\n/**\n * Cloudflare D1 HTTP datasource driver for remote connections.\n * @template TSchema - The schema type\n * @param options - Driver configuration options\n * @param schema - The Drizzle schema\n * @returns A Datasource instance\n */\nconst driver = defineConnector(\n <TSchema extends Schema>(options: D1HttpOptions, schema: TSchema) => {\n const { callback, batchCallback } = d1HttpDriver(options);\n const database = drizzle(callback, batchCallback, { schema });\n return {\n database,\n schema,\n async waitReady() {\n await database.run(SELECT_1);\n },\n async close() {},\n };\n },\n);\n\nexport default driver;\n\n/** Configuration options for the Cloudflare D1 HTTP driver. */\nexport type D1HttpOptions = {\n /** Cloudflare account ID. */\n accountId: string;\n /** D1 database ID. */\n databaseId: string;\n /** API token for authentication. */\n token: string;\n};\n\n/** Internal type for the HTTP driver callback functions. */\nexport type D1HttpDriver = {\n callback: AsyncRemoteCallback;\n batchCallback: AsyncBatchRemoteCallback;\n};\n\ntype D1Response =\n | {\n success: true;\n result: [Result, ...Result[]];\n }\n | {\n success: false;\n errors: { code: number; message: string }[];\n };\n\ntype Result = {\n results:\n | any[]\n | {\n columns: string[];\n rows: any[][];\n };\n};\n\ntype D1HttpQuery = {\n sql: string;\n params: any[];\n};\n\ntype FetchD1Body =\n | {\n batch: D1HttpQuery[];\n }\n | D1HttpQuery;\n\nasync function fetchD1(url: string | URL, body: FetchD1Body, options: D1HttpOptions) {\n const res = await fetch(url, {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${options.token}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(body),\n });\n\n const data = (await res.json()) as D1Response;\n\n if (!data.success) {\n throw new Error(data.errors.map((it) => `${it.code}: ${it.message}`).join(\"\\n\"));\n }\n\n const result = data.result[0].results;\n const rows = Array.isArray(result) ? result : result.rows;\n\n return { rows };\n}\n\n/**\n * Creates an HTTP driver for Cloudflare D1 API.\n * @param options - D1 HTTP configuration options\n * @returns Object containing callback and batchCallback functions\n * @see [Cloudflare API docs](https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/raw/)\n */\nexport function d1HttpDriver(options: D1HttpOptions): D1HttpDriver {\n const url = new URL(\n `accounts/${options.accountId}/d1/database/${options.databaseId}/raw`,\n \"https://api.cloudflare.com/client/v4/\",\n );\n return {\n async callback(sql, params, _) {\n const body = { sql, params };\n const res = await fetchD1(url, body, options);\n return res;\n },\n async batchCallback(batch) {\n const body = {\n batch: batch.map(({ sql, params }) => {\n return {\n sql,\n params,\n };\n }),\n };\n const res = await fetchD1(url, body, options);\n return [res];\n },\n };\n}\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n callback: RemoteCallback,\n config?: DrizzleConfig<TSchema>,\n): SqliteRemoteDatabase<TSchema>;\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n callback: RemoteCallback,\n batchCallback?: AsyncBatchRemoteCallback,\n config?: DrizzleConfig<TSchema>,\n): SqliteRemoteDatabase<TSchema>;\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n callback: RemoteCallback,\n batchCallback?: AsyncBatchRemoteCallback | DrizzleConfig<TSchema>,\n config?: DrizzleConfig<TSchema>,\n): SqliteRemoteDatabase<TSchema> {\n const dialect = new SQLiteD1Dialect({ casing: config?.casing });\n let logger;\n let cache;\n let _batchCallback: AsyncBatchRemoteCallback | undefined;\n let _config: DrizzleConfig<TSchema> = {};\n\n if (batchCallback) {\n if (typeof batchCallback === \"function\") {\n _batchCallback = batchCallback as AsyncBatchRemoteCallback;\n _config = config ?? {};\n } else {\n _batchCallback = undefined;\n _config = batchCallback as DrizzleConfig<TSchema>;\n }\n\n if (_config.logger === true) {\n logger = new DefaultLogger();\n } else if (_config.logger !== false) {\n logger = _config.logger;\n cache = _config.cache;\n }\n }\n\n let schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n if (_config.schema) {\n const tablesConfig = extractTablesRelationalConfig(_config.schema, createTableRelationsHelpers);\n schema = {\n fullSchema: _config.schema,\n schema: tablesConfig.tables,\n tableNamesMap: tablesConfig.tableNamesMap,\n };\n }\n\n const session = new SQLiteRemoteSession(callback, dialect, schema, _batchCallback, {\n logger,\n cache,\n });\n const db = new SqliteRemoteDatabase(\n \"async\",\n dialect,\n session,\n schema,\n ) as SqliteRemoteDatabase<TSchema>;\n (<any>db).$cache = cache;\n if ((<any>db).$cache) {\n (<any>db).$cache[\"invalidate\"] = cache?.onMutate;\n }\n return db;\n}\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAM,SAAS,iBACY,SAAwB,WAAoB;CACnE,MAAM,EAAE,UAAU,kBAAkB,aAAa,OAAO;CACxD,MAAM,WAAW,QAAQ,UAAU,eAAe,EAAE,OAAO,CAAC;CAC5D,OAAO;EACL;EACA;EACA,MAAM,YAAY;GAChB,MAAM,SAAS,IAAI,QAAQ;EAC7B;EACA,MAAM,QAAQ,CAAC;CACjB;AACF,CACF;AAkDA,eAAe,QAAQ,KAAmB,MAAmB,SAAwB;CAUnF,MAAM,OAAQ,OAAM,MATF,MAAM,KAAK;EAC3B,QAAQ;EACR,SAAS;GACP,eAAe,UAAU,QAAQ;GACjC,gBAAgB;EAClB;EACA,MAAM,KAAK,UAAU,IAAI;CAC3B,CAAC,EAAA,CAEuB,KAAK;CAE7B,IAAI,CAAC,KAAK,SACR,MAAM,IAAI,MAAM,KAAK,OAAO,KAAK,OAAO,GAAG,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC,CAAC,KAAK,IAAI,CAAC;CAGjF,MAAM,SAAS,KAAK,OAAO,EAAE,CAAC;CAG9B,OAAO,EAAE,MAFI,MAAM,QAAQ,MAAM,IAAI,SAAS,OAAO,KAEvC;AAChB;;;;;;;AAQA,SAAgB,aAAa,SAAsC;CACjE,MAAM,MAAM,IAAI,IACd,YAAY,QAAQ,UAAU,eAAe,QAAQ,WAAW,OAChE,uCACF;CACA,OAAO;EACL,MAAM,SAAS,KAAK,QAAQ,GAAG;GAG7B,OAAO,MADW,QAAQ,KAAK;IADhB;IAAK;GACc,GAAG,OAAO;EAE9C;EACA,MAAM,cAAc,OAAO;GACzB,MAAM,OAAO,EACX,OAAO,MAAM,KAAK,EAAE,KAAK,aAAa;IACpC,OAAO;KACL;KACA;IACF;GACF,CAAC,EACH;GAEA,OAAO,CAAC,MADU,QAAQ,KAAK,MAAM,OAAO,CACjC;EACb;CACF;AACF;AAWA,SAAgB,QACd,UACA,eACA,QAC+B;CAC/B,MAAM,UAAU,IAAI,gBAAgB,EAAE,QAAQ,QAAQ,OAAO,CAAC;CAC9D,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,UAAkC,CAAC;CAEvC,IAAI,eAAe;EACjB,IAAI,OAAO,kBAAkB,YAAY;GACvC,iBAAiB;GACjB,UAAU,UAAU,CAAC;EACvB,OAAO;GACL,iBAAiB,KAAA;GACjB,UAAU;EACZ;EAEA,IAAI,QAAQ,WAAW,MACrB,SAAS,IAAI,cAAc;OACtB,IAAI,QAAQ,WAAW,OAAO;GACnC,SAAS,QAAQ;GACjB,QAAQ,QAAQ;EAClB;CACF;CAEA,IAAI;CACJ,IAAI,QAAQ,QAAQ;EAClB,MAAM,eAAe,8BAA8B,QAAQ,QAAQ,2BAA2B;EAC9F,SAAS;GACP,YAAY,QAAQ;GACpB,QAAQ,aAAa;GACrB,eAAe,aAAa;EAC9B;CACF;CAEA,MAAM,UAAU,IAAI,oBAAoB,UAAU,SAAS,QAAQ,gBAAgB;EACjF;EACA;CACF,CAAC;CACD,MAAM,KAAK,IAAI,qBACb,SACA,SACA,SACA,MACF;CACM,GAAI,SAAS;CACnB,IAAU,GAAI,QACN,GAAI,OAAO,gBAAgB,OAAO;CAE1C,OAAO;AACT"}
|
package/dist/drivers/d1.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Schema } from "./index.mjs";
|
|
2
2
|
import { DrizzleD1Database } from "drizzle-orm/d1";
|
|
3
|
-
import { D1Database } from "@cloudflare/workers-types";
|
|
4
|
-
//#region src/drivers/d1.d.ts
|
|
5
3
|
/**
|
|
6
4
|
* Cloudflare D1 datasource driver.
|
|
7
5
|
* @template TSchema - The schema type
|
|
@@ -11,17 +9,15 @@ import { D1Database } from "@cloudflare/workers-types";
|
|
|
11
9
|
*/
|
|
12
10
|
declare const _default: <TSchema extends Schema>(options: D1Options, schema: TSchema) => Promise<{
|
|
13
11
|
database: DrizzleD1Database<TSchema> & {
|
|
14
|
-
$client:
|
|
12
|
+
$client: TClient;
|
|
15
13
|
};
|
|
16
14
|
schema: TSchema;
|
|
17
15
|
waitReady(): Promise<void>;
|
|
18
16
|
close(): Promise<void>;
|
|
19
17
|
}>;
|
|
20
18
|
/** Configuration options for the Cloudflare D1 driver. */
|
|
21
|
-
type D1Options = {
|
|
19
|
+
export type D1Options = {
|
|
22
20
|
/** The binding name for the D1 database in Cloudflare Workers. */
|
|
23
21
|
binding: string;
|
|
24
22
|
};
|
|
25
|
-
|
|
26
|
-
export { D1Options, _default as default };
|
|
27
|
-
//# sourceMappingURL=d1.d.mts.map
|
|
23
|
+
export { _default as default };
|
package/dist/drivers/d1.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import cloudflareD1Connector from "db0/connectors/cloudflare-d1";
|
|
1
2
|
import { defineConnector } from "./index.mjs";
|
|
2
|
-
import { SQLiteD1Dialect } from "./d1/dialect.mjs";
|
|
3
|
-
import { SELECT_1 } from "./internal/sql.mjs";
|
|
4
3
|
import { DefaultLogger, createTableRelationsHelpers, extractTablesRelationalConfig } from "drizzle-orm";
|
|
5
|
-
import cloudflareD1Connector from "db0/connectors/cloudflare-d1";
|
|
6
4
|
import { DrizzleD1Database, SQLiteD1Session } from "drizzle-orm/d1";
|
|
7
|
-
|
|
5
|
+
import { SQLiteD1Dialect } from "./d1/dialect.mjs";
|
|
6
|
+
import { SELECT_1 } from "./internal/sql.mjs";
|
|
7
|
+
// src/drivers/d1.ts
|
|
8
8
|
/**
|
|
9
9
|
* Cloudflare D1 datasource driver.
|
|
10
10
|
* @template TSchema - The schema type
|
|
@@ -47,7 +47,6 @@ function drizzle(client, config = {}) {
|
|
|
47
47
|
if (db.$cache) db.$cache["invalidate"] = config.cache?.onMutate;
|
|
48
48
|
return db;
|
|
49
49
|
}
|
|
50
|
-
//#endregion
|
|
51
50
|
export { d1_default as default };
|
|
52
51
|
|
|
53
52
|
//# sourceMappingURL=d1.mjs.map
|
package/dist/drivers/d1.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"d1.mjs","names":[],"sources":["../../src/drivers/d1.ts"],"sourcesContent":["import cloudflareD1Connector from \"db0/connectors/cloudflare-d1\";\nimport { defineConnector, type Schema } from \".\";\nimport type { D1Database } from \"@cloudflare/workers-types\";\nimport type { DrizzleConfig, RelationalSchemaConfig, TablesRelationalConfig } from \"drizzle-orm\";\nimport {\n DefaultLogger,\n extractTablesRelationalConfig,\n createTableRelationsHelpers,\n} from \"drizzle-orm\";\nimport { DrizzleD1Database, SQLiteD1Session, type AnyD1Database } from \"drizzle-orm/d1\";\nimport { SQLiteD1Dialect } from \"./d1/dialect\";\nimport { SELECT_1 } from \"./internal/sql\";\n\n/**\n * Cloudflare D1 datasource driver.\n * @template TSchema - The schema type\n * @param options - Driver configuration options\n * @param schema - The Drizzle schema\n * @returns A Datasource instance\n */\nexport default defineConnector(\n async <TSchema extends Schema>(options: D1Options, schema: TSchema) => {\n const connector = cloudflareD1Connector({\n bindingName: options.binding,\n });\n const client = await connector.getInstance();\n const database = drizzle(client, { schema });\n return {\n database,\n schema,\n async waitReady() {\n await database.run(SELECT_1);\n },\n async close() {},\n };\n },\n);\n\n/** Configuration options for the Cloudflare D1 driver. */\nexport type D1Options = {\n /** The binding name for the D1 database in Cloudflare Workers. */\n binding: string;\n};\n\nfunction drizzle<\n TSchema extends Record<string, unknown> = Record<string, never>,\n TClient extends AnyD1Database = AnyD1Database,\n>(\n client: TClient,\n config: DrizzleConfig<TSchema> = {},\n): DrizzleD1Database<TSchema> & {\n $client: TClient;\n} {\n const dialect = new SQLiteD1Dialect({ casing: config.casing });\n let logger;\n if (config.logger === true) {\n logger = new DefaultLogger();\n } else if (config.logger !== false) {\n logger = config.logger;\n }\n\n let schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n if (config.schema) {\n const tablesConfig = extractTablesRelationalConfig(config.schema, createTableRelationsHelpers);\n schema = {\n fullSchema: config.schema,\n schema: tablesConfig.tables,\n tableNamesMap: tablesConfig.tableNamesMap,\n };\n }\n\n const session = new SQLiteD1Session(client as D1Database, dialect, schema, {\n logger,\n cache: config.cache,\n });\n const db = new DrizzleD1Database(\"async\", dialect, session, schema) as DrizzleD1Database<TSchema>;\n (<any>db).$client = client;\n (<any>db).$cache = config.cache;\n if ((<any>db).$cache) {\n (<any>db).$cache[\"invalidate\"] = config.cache?.onMutate;\n }\n\n return db as any;\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAA,aAAe,gBACb,OAA+B,SAAoB,WAAoB;CAKrE,MAAM,WAAW,QAAQ,MAJP,sBAAsB,EACtC,aAAa,QAAQ,QACvB,CAC6B,CAAC,CAAC,YAAY,GACV,EAAE,OAAO,CAAC;CAC3C,OAAO;EACL;EACA;EACA,MAAM,YAAY;GAChB,MAAM,SAAS,IAAI,QAAQ;EAC7B;EACA,MAAM,QAAQ,CAAC;CACjB;AACF,CACF;AAQA,SAAS,QAIP,QACA,SAAiC,CAAC,GAGlC;CACA,MAAM,UAAU,IAAI,gBAAgB,EAAE,QAAQ,OAAO,OAAO,CAAC;CAC7D,IAAI;CACJ,IAAI,OAAO,WAAW,MACpB,SAAS,IAAI,cAAc;MACtB,IAAI,OAAO,WAAW,OAC3B,SAAS,OAAO;CAGlB,IAAI;CACJ,IAAI,OAAO,QAAQ;EACjB,MAAM,eAAe,8BAA8B,OAAO,QAAQ,2BAA2B;EAC7F,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,aAAa;GACrB,eAAe,aAAa;EAC9B;CACF;CAEA,MAAM,UAAU,IAAI,gBAAgB,QAAsB,SAAS,QAAQ;EACzE;EACA,OAAO,OAAO;CAChB,CAAC;CACD,MAAM,KAAK,IAAI,kBAAkB,SAAS,SAAS,SAAS,MAAM;
|
|
1
|
+
{"version":3,"file":"d1.mjs","names":[],"sources":["../../src/drivers/d1.ts"],"sourcesContent":["import cloudflareD1Connector from \"db0/connectors/cloudflare-d1\";\nimport { defineConnector, type Schema } from \".\";\nimport type { D1Database } from \"@cloudflare/workers-types\";\nimport type { DrizzleConfig, RelationalSchemaConfig, TablesRelationalConfig } from \"drizzle-orm\";\nimport {\n DefaultLogger,\n extractTablesRelationalConfig,\n createTableRelationsHelpers,\n} from \"drizzle-orm\";\nimport { DrizzleD1Database, SQLiteD1Session, type AnyD1Database } from \"drizzle-orm/d1\";\nimport { SQLiteD1Dialect } from \"./d1/dialect\";\nimport { SELECT_1 } from \"./internal/sql\";\n\n/**\n * Cloudflare D1 datasource driver.\n * @template TSchema - The schema type\n * @param options - Driver configuration options\n * @param schema - The Drizzle schema\n * @returns A Datasource instance\n */\nexport default defineConnector(\n async <TSchema extends Schema>(options: D1Options, schema: TSchema) => {\n const connector = cloudflareD1Connector({\n bindingName: options.binding,\n });\n const client = await connector.getInstance();\n const database = drizzle(client, { schema });\n return {\n database,\n schema,\n async waitReady() {\n await database.run(SELECT_1);\n },\n async close() {},\n };\n },\n);\n\n/** Configuration options for the Cloudflare D1 driver. */\nexport type D1Options = {\n /** The binding name for the D1 database in Cloudflare Workers. */\n binding: string;\n};\n\nfunction drizzle<\n TSchema extends Record<string, unknown> = Record<string, never>,\n TClient extends AnyD1Database = AnyD1Database,\n>(\n client: TClient,\n config: DrizzleConfig<TSchema> = {},\n): DrizzleD1Database<TSchema> & {\n $client: TClient;\n} {\n const dialect = new SQLiteD1Dialect({ casing: config.casing });\n let logger;\n if (config.logger === true) {\n logger = new DefaultLogger();\n } else if (config.logger !== false) {\n logger = config.logger;\n }\n\n let schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n if (config.schema) {\n const tablesConfig = extractTablesRelationalConfig(config.schema, createTableRelationsHelpers);\n schema = {\n fullSchema: config.schema,\n schema: tablesConfig.tables,\n tableNamesMap: tablesConfig.tableNamesMap,\n };\n }\n\n const session = new SQLiteD1Session(client as D1Database, dialect, schema, {\n logger,\n cache: config.cache,\n });\n const db = new DrizzleD1Database(\"async\", dialect, session, schema) as DrizzleD1Database<TSchema>;\n (<any>db).$client = client;\n (<any>db).$cache = config.cache;\n if ((<any>db).$cache) {\n (<any>db).$cache[\"invalidate\"] = config.cache?.onMutate;\n }\n\n return db as any;\n}\n"],"mappings":";;;;;;;;;;;;;;AAoBA,IAAA,aAAe,gBACb,OAA+B,SAAoB,WAAoB;CAKrE,MAAM,WAAW,QAAQ,MAJP,sBAAsB,EACtC,aAAa,QAAQ,QACvB,CAC6B,CAAC,CAAC,YAAY,GACV,EAAE,OAAO,CAAC;CAC3C,OAAO;EACL;EACA;EACA,MAAM,YAAY;GAChB,MAAM,SAAS,IAAI,QAAQ;EAC7B;EACA,MAAM,QAAQ,CAAC;CACjB;AACF,CACF;AAQA,SAAS,QAIP,QACA,SAAiC,CAAC,GAGlC;CACA,MAAM,UAAU,IAAI,gBAAgB,EAAE,QAAQ,OAAO,OAAO,CAAC;CAC7D,IAAI;CACJ,IAAI,OAAO,WAAW,MACpB,SAAS,IAAI,cAAc;MACtB,IAAI,OAAO,WAAW,OAC3B,SAAS,OAAO;CAGlB,IAAI;CACJ,IAAI,OAAO,QAAQ;EACjB,MAAM,eAAe,8BAA8B,OAAO,QAAQ,2BAA2B;EAC7F,SAAS;GACP,YAAY,OAAO;GACnB,QAAQ,aAAa;GACrB,eAAe,aAAa;EAC9B;CACF;CAEA,MAAM,UAAU,IAAI,gBAAgB,QAAsB,SAAS,QAAQ;EACzE;EACA,OAAO,OAAO;CAChB,CAAC;CACD,MAAM,KAAK,IAAI,kBAAkB,SAAS,SAAS,SAAS,MAAM;CAC5D,GAAI,UAAU;CACd,GAAI,SAAS,OAAO;CAC1B,IAAU,GAAI,QACN,GAAI,OAAO,gBAAgB,OAAO,OAAO;CAGjD,OAAO;AACT"}
|
package/dist/drivers/index.d.mts
CHANGED
|
@@ -1,33 +1,32 @@
|
|
|
1
1
|
import { MaybePromise, UnionToIntersection } from "nitro-drizzle/shared";
|
|
2
|
-
//#region src/drivers/index.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Schema type representing database tables.
|
|
5
4
|
*/
|
|
6
|
-
type Schema = Record<string, any>;
|
|
5
|
+
export type Schema = Record<string, any>;
|
|
7
6
|
/**
|
|
8
7
|
* Factory function type for creating Drizzle datasource instances.
|
|
9
8
|
* @template TDatabase - The database type
|
|
10
9
|
*/
|
|
11
|
-
type Connector<TDialect extends string, TDatabase, TSchema extends Schema, TConfig> = (config: TConfig, schema: TSchema) => MaybePromise<Datasource<TDialect, TDatabase, TSchema>>;
|
|
10
|
+
export type Connector<TDialect extends string, TDatabase, TSchema extends Schema, TConfig> = (config: TConfig, schema: TSchema) => MaybePromise<Datasource<TDialect, TDatabase, TSchema>>;
|
|
12
11
|
/**
|
|
13
12
|
* Combines multiple schema types into an intersection type.
|
|
14
13
|
* @template T - The array of schema types
|
|
15
14
|
* @template Indices - The indices to include
|
|
16
15
|
*/
|
|
17
|
-
type MergeSchema<T extends readonly Schema[], Indices extends keyof T & number> = [Indices] extends [never] ? {} : UnionToIntersection<{ [K in Indices]: K extends keyof T ? T[K] : never; }[Indices]>;
|
|
16
|
+
export type MergeSchema<T extends readonly Schema[], Indices extends keyof T & number> = [Indices] extends [never] ? {} : UnionToIntersection<{ [K in Indices]: K extends keyof T ? T[K] : never; }[Indices]>;
|
|
18
17
|
/**
|
|
19
18
|
* Defines a driver factory function.
|
|
20
19
|
* @template TConnector - The driver factory type
|
|
21
20
|
* @param create - The driver factory function
|
|
22
21
|
* @returns The same driver factory function
|
|
23
22
|
*/
|
|
24
|
-
declare function defineConnector<TDialect extends string, TSchema extends Schema, TConnector extends Connector<TDialect, any, TSchema, any>>(create: TConnector): TConnector;
|
|
23
|
+
export declare function defineConnector<TDialect extends string, TSchema extends Schema, TConnector extends Connector<TDialect, any, TSchema, any>>(create: TConnector): TConnector;
|
|
25
24
|
/**
|
|
26
25
|
* Datasource interface representing a connected database with schema.
|
|
27
26
|
* @template TDatabase - The database client type
|
|
28
27
|
* @template TSchema - The schema type
|
|
29
28
|
*/
|
|
30
|
-
interface Datasource<_TDialect, TDatabase, TSchema extends Schema> {
|
|
29
|
+
export interface Datasource<_TDialect, TDatabase, TSchema extends Schema> {
|
|
31
30
|
/** The database client instance. */
|
|
32
31
|
database: TDatabase;
|
|
33
32
|
/** The schema definition. */
|
|
@@ -36,7 +35,4 @@ interface Datasource<_TDialect, TDatabase, TSchema extends Schema> {
|
|
|
36
35
|
waitReady: () => MaybePromise<void>;
|
|
37
36
|
/** Closes the database connection. */
|
|
38
37
|
close: () => MaybePromise<void>;
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
export { Connector, Datasource, MergeSchema, Schema, defineConnector };
|
|
42
|
-
//# sourceMappingURL=index.d.mts.map
|
|
38
|
+
}
|
package/dist/drivers/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/drivers/index.ts
|
|
2
2
|
/**
|
|
3
3
|
* Defines a driver factory function.
|
|
4
4
|
* @template TConnector - The driver factory type
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
function defineConnector(create) {
|
|
9
9
|
return create;
|
|
10
10
|
}
|
|
11
|
-
//#endregion
|
|
12
11
|
export { defineConnector };
|
|
13
12
|
|
|
14
13
|
//# sourceMappingURL=index.mjs.map
|
package/dist/drivers/mysql.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Schema } from "./index.mjs";
|
|
2
|
-
//#region src/drivers/mysql.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* MySQL datasource driver using mysql2.
|
|
5
4
|
* @template TSchema - The schema type
|
|
@@ -18,10 +17,8 @@ declare const _default: <TSchema extends Schema>(config: Options, schema: TSchem
|
|
|
18
17
|
/**
|
|
19
18
|
* Configuration options for the MySQL driver.
|
|
20
19
|
*/
|
|
21
|
-
type Options = {
|
|
20
|
+
export type Options = {
|
|
22
21
|
/** Database connection URL. */
|
|
23
22
|
url: string;
|
|
24
23
|
};
|
|
25
|
-
|
|
26
|
-
export { Options, _default as default };
|
|
27
|
-
//# sourceMappingURL=mysql.d.mts.map
|
|
24
|
+
export { _default as default };
|
package/dist/drivers/mysql.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineConnector } from "./index.mjs";
|
|
2
|
-
import { SELECT_1 } from "./internal/sql.mjs";
|
|
3
1
|
import { drizzle } from "drizzle-orm/mysql2";
|
|
4
2
|
import { createConnection } from "mysql2/promise";
|
|
5
|
-
|
|
3
|
+
import { defineConnector } from "./index.mjs";
|
|
4
|
+
import { SELECT_1 } from "./internal/sql.mjs";
|
|
5
|
+
// src/drivers/mysql.ts
|
|
6
6
|
/**
|
|
7
7
|
* MySQL datasource driver using mysql2.
|
|
8
8
|
* @template TSchema - The schema type
|
|
@@ -27,7 +27,6 @@ var mysql_default = defineConnector(async (config, schema) => {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
|
-
//#endregion
|
|
31
30
|
export { mysql_default as default };
|
|
32
31
|
|
|
33
32
|
//# sourceMappingURL=mysql.mjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Schema } from "./index.mjs";
|
|
2
1
|
import { PGlite, PGliteOptions } from "@electric-sql/pglite";
|
|
3
|
-
|
|
2
|
+
import { Schema } from "./index.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* PGlite datasource driver for PostgreSQL in the browser.
|
|
6
5
|
* @template TSchema - The schema type
|
|
@@ -17,6 +16,4 @@ declare const _default: <TSchema extends Schema>(options: PGliteOptions, schema:
|
|
|
17
16
|
waitReady(): Promise<void>;
|
|
18
17
|
close(): Promise<void>;
|
|
19
18
|
};
|
|
20
|
-
|
|
21
|
-
export { _default as default };
|
|
22
|
-
//# sourceMappingURL=pglite.d.mts.map
|
|
19
|
+
export { _default as default };
|
package/dist/drivers/pglite.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineConnector } from "./index.mjs";
|
|
2
1
|
import { drizzle } from "drizzle-orm/pglite";
|
|
3
2
|
import { PGlite } from "@electric-sql/pglite";
|
|
4
|
-
|
|
3
|
+
import { defineConnector } from "./index.mjs";
|
|
4
|
+
// src/drivers/pglite.ts
|
|
5
5
|
/**
|
|
6
6
|
* PGlite datasource driver for PostgreSQL in the browser.
|
|
7
7
|
* @template TSchema - The schema type
|
|
@@ -24,7 +24,6 @@ var pglite_default = defineConnector((options, schema) => {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
});
|
|
27
|
-
//#endregion
|
|
28
27
|
export { pglite_default as default };
|
|
29
28
|
|
|
30
29
|
//# sourceMappingURL=pglite.mjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Schema } from "./index.mjs";
|
|
2
1
|
import createPostgres, { Options as Options$1 } from "postgres";
|
|
3
|
-
|
|
2
|
+
import { Schema } from "./index.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* PostgreSQL datasource driver using postgres.js.
|
|
6
5
|
* @template TSchema - The schema type
|
|
@@ -19,10 +18,8 @@ declare const _default: <TSchema extends Schema>(options: Options, schema: TSche
|
|
|
19
18
|
/**
|
|
20
19
|
* Configuration options for the PostgreSQL driver.
|
|
21
20
|
*/
|
|
22
|
-
type Options = Options$1<Record<string, createPostgres.PostgresType>> & {
|
|
21
|
+
export type Options = Options$1<Record<string, createPostgres.PostgresType>> & {
|
|
23
22
|
/** Connection URL string (optional if connection config is provided). */
|
|
24
23
|
url?: string;
|
|
25
24
|
};
|
|
26
|
-
|
|
27
|
-
export { Options, _default as default };
|
|
28
|
-
//# sourceMappingURL=postgresql.d.mts.map
|
|
25
|
+
export { _default as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineConnector } from "./index.mjs";
|
|
2
|
-
import { SELECT_1 } from "./internal/sql.mjs";
|
|
3
1
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
4
2
|
import createPostgres from "postgres";
|
|
5
|
-
|
|
3
|
+
import { defineConnector } from "./index.mjs";
|
|
4
|
+
import { SELECT_1 } from "./internal/sql.mjs";
|
|
5
|
+
// src/drivers/postgresql.ts
|
|
6
6
|
/**
|
|
7
7
|
* PostgreSQL datasource driver using postgres.js.
|
|
8
8
|
* @template TSchema - The schema type
|
|
@@ -25,7 +25,6 @@ var postgresql_default = defineConnector((options, schema) => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
//#endregion
|
|
29
28
|
export { postgresql_default as default };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=postgresql.mjs.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Schema } from "./index.mjs";
|
|
2
1
|
import sqlite3, { Options as Options$1 } from "better-sqlite3";
|
|
3
|
-
|
|
2
|
+
import { Schema } from "./index.mjs";
|
|
4
3
|
/**
|
|
5
4
|
* SQLite datasource driver using better-sqlite3.
|
|
6
5
|
* @template TSchema - The schema type
|
|
@@ -19,10 +18,8 @@ declare const _default: <TSchema extends Schema>(config: Options, schema: TSchem
|
|
|
19
18
|
/**
|
|
20
19
|
* Configuration options for the SQLite driver.
|
|
21
20
|
*/
|
|
22
|
-
type Options = {
|
|
21
|
+
export type Options = {
|
|
23
22
|
/** Database file path or URL. */
|
|
24
23
|
url: string;
|
|
25
24
|
} & Options$1;
|
|
26
|
-
|
|
27
|
-
export { Options, _default as default };
|
|
28
|
-
//# sourceMappingURL=sqlite.d.mts.map
|
|
25
|
+
export { _default as default };
|
package/dist/drivers/sqlite.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineConnector } from "./index.mjs";
|
|
2
|
-
import { SELECT_1 } from "./internal/sql.mjs";
|
|
3
1
|
import sqlite3 from "better-sqlite3";
|
|
4
2
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
5
|
-
|
|
3
|
+
import { defineConnector } from "./index.mjs";
|
|
4
|
+
import { SELECT_1 } from "./internal/sql.mjs";
|
|
5
|
+
// src/drivers/sqlite.ts
|
|
6
6
|
/**
|
|
7
7
|
* SQLite datasource driver using better-sqlite3.
|
|
8
8
|
* @template TSchema - The schema type
|
|
@@ -25,7 +25,6 @@ var sqlite_default = defineConnector((config, schema) => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
//#endregion
|
|
29
28
|
export { sqlite_default as default };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=sqlite.mjs.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { module_default as default };
|
|
1
|
+
export { default } from "nitro-drizzle/module";
|