drizzle-orm 0.33.0-6386ea9 → 0.33.0-87d7704
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/aws-data-api/common/index.d.cts +1 -1
- package/aws-data-api/common/index.d.ts +1 -1
- package/index.cjs +2 -0
- package/index.cjs.map +1 -1
- package/index.d.cts +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/monodriver.cjs +83 -0
- package/monodriver.cjs.map +1 -0
- package/monodriver.d.cts +98 -0
- package/monodriver.d.ts +98 -0
- package/monodriver.js +49 -0
- package/monodriver.js.map +1 -0
- package/package.json +13 -1
- package/sqlite-core/columns/blob.d.cts +1 -1
- package/sqlite-core/columns/blob.d.ts +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Field } from '@aws-sdk/client-rds-data';
|
|
2
2
|
import { TypeHint } from '@aws-sdk/client-rds-data';
|
|
3
3
|
import type { QueryTypingsValue } from "../../sql/sql.cjs";
|
|
4
|
-
export declare function getValueFromDataApi(field: Field): string | number | boolean | string[] | number[] |
|
|
4
|
+
export declare function getValueFromDataApi(field: Field): string | number | boolean | string[] | Uint8Array | number[] | boolean[] | import("@aws-sdk/client-rds-data").ArrayValue[] | null;
|
|
5
5
|
export declare function typingsToAwsTypeHint(typings?: QueryTypingsValue): TypeHint | undefined;
|
|
6
6
|
export declare function toValueParam(value: any, typings?: QueryTypingsValue): {
|
|
7
7
|
value: Field;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Field } from '@aws-sdk/client-rds-data';
|
|
2
2
|
import { TypeHint } from '@aws-sdk/client-rds-data';
|
|
3
3
|
import type { QueryTypingsValue } from "../../sql/sql.js";
|
|
4
|
-
export declare function getValueFromDataApi(field: Field): string | number | boolean | string[] | number[] |
|
|
4
|
+
export declare function getValueFromDataApi(field: Field): string | number | boolean | string[] | Uint8Array | number[] | boolean[] | import("@aws-sdk/client-rds-data").ArrayValue[] | null;
|
|
5
5
|
export declare function typingsToAwsTypeHint(typings?: QueryTypingsValue): TypeHint | undefined;
|
|
6
6
|
export declare function toValueParam(value: any, typings?: QueryTypingsValue): {
|
|
7
7
|
value: Field;
|
package/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ __reExport(src_exports, require("./entity.cjs"), module.exports);
|
|
|
22
22
|
__reExport(src_exports, require("./errors.cjs"), module.exports);
|
|
23
23
|
__reExport(src_exports, require("./expressions.cjs"), module.exports);
|
|
24
24
|
__reExport(src_exports, require("./logger.cjs"), module.exports);
|
|
25
|
+
__reExport(src_exports, require("./monodriver.cjs"), module.exports);
|
|
25
26
|
__reExport(src_exports, require("./operations.cjs"), module.exports);
|
|
26
27
|
__reExport(src_exports, require("./query-promise.cjs"), module.exports);
|
|
27
28
|
__reExport(src_exports, require("./relations.cjs"), module.exports);
|
|
@@ -39,6 +40,7 @@ __reExport(src_exports, require("./view-common.cjs"), module.exports);
|
|
|
39
40
|
...require("./errors.cjs"),
|
|
40
41
|
...require("./expressions.cjs"),
|
|
41
42
|
...require("./logger.cjs"),
|
|
43
|
+
...require("./monodriver.cjs"),
|
|
42
44
|
...require("./operations.cjs"),
|
|
43
45
|
...require("./query-promise.cjs"),
|
|
44
46
|
...require("./relations.cjs"),
|
package/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './column-builder.ts';\nexport * from './column.ts';\nexport * from './entity.ts';\nexport * from './errors.ts';\nexport * from './expressions.ts';\nexport * from './logger.ts';\nexport * from './operations.ts';\nexport * from './query-promise.ts';\nexport * from './relations.ts';\nexport * from './sql/index.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './utils.ts';\nexport * from './view-common.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;AAGA,wBAAc,wBAHd;AAIA,wBAAc,wBAJd;AAKA,wBAAc,6BALd;AAMA,wBAAc,wBANd;AAOA,wBAAc,4BAPd;AAQA,wBAAc
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './column-builder.ts';\nexport * from './column.ts';\nexport * from './entity.ts';\nexport * from './errors.ts';\nexport * from './expressions.ts';\nexport * from './logger.ts';\nexport * from './monodriver.ts';\nexport * from './operations.ts';\nexport * from './query-promise.ts';\nexport * from './relations.ts';\nexport * from './sql/index.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './utils.ts';\nexport * from './view-common.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,uBAAd;AACA,wBAAc,gCADd;AAEA,wBAAc,wBAFd;AAGA,wBAAc,wBAHd;AAIA,wBAAc,wBAJd;AAKA,wBAAc,6BALd;AAMA,wBAAc,wBANd;AAOA,wBAAc,4BAPd;AAQA,wBAAc,4BARd;AASA,wBAAc,+BATd;AAUA,wBAAc,2BAVd;AAWA,wBAAc,2BAXd;AAYA,wBAAc,0BAZd;AAaA,wBAAc,uBAbd;AAcA,wBAAc,uBAdd;AAeA,wBAAc,6BAfd;","names":[]}
|
package/index.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./entity.cjs";
|
|
|
5
5
|
export * from "./errors.cjs";
|
|
6
6
|
export * from "./expressions.cjs";
|
|
7
7
|
export * from "./logger.cjs";
|
|
8
|
+
export * from "./monodriver.cjs";
|
|
8
9
|
export * from "./operations.cjs";
|
|
9
10
|
export * from "./query-promise.cjs";
|
|
10
11
|
export * from "./relations.cjs";
|
package/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./entity.js";
|
|
|
5
5
|
export * from "./errors.js";
|
|
6
6
|
export * from "./expressions.js";
|
|
7
7
|
export * from "./logger.js";
|
|
8
|
+
export * from "./monodriver.js";
|
|
8
9
|
export * from "./operations.js";
|
|
9
10
|
export * from "./query-promise.js";
|
|
10
11
|
export * from "./relations.js";
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from "./entity.js";
|
|
|
5
5
|
export * from "./errors.js";
|
|
6
6
|
export * from "./expressions.js";
|
|
7
7
|
export * from "./logger.js";
|
|
8
|
+
export * from "./monodriver.js";
|
|
8
9
|
export * from "./operations.js";
|
|
9
10
|
export * from "./query-promise.js";
|
|
10
11
|
export * from "./relations.js";
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './column-builder.ts';\nexport * from './column.ts';\nexport * from './entity.ts';\nexport * from './errors.ts';\nexport * from './expressions.ts';\nexport * from './logger.ts';\nexport * from './operations.ts';\nexport * from './query-promise.ts';\nexport * from './relations.ts';\nexport * from './sql/index.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './utils.ts';\nexport * from './view-common.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './column-builder.ts';\nexport * from './column.ts';\nexport * from './entity.ts';\nexport * from './errors.ts';\nexport * from './expressions.ts';\nexport * from './logger.ts';\nexport * from './monodriver.ts';\nexport * from './operations.ts';\nexport * from './query-promise.ts';\nexport * from './relations.ts';\nexport * from './sql/index.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './utils.ts';\nexport * from './view-common.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
|
package/monodriver.cjs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var monodriver_exports = {};
|
|
30
|
+
__export(monodriver_exports, {
|
|
31
|
+
drizzle: () => drizzle
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(monodriver_exports);
|
|
34
|
+
var import_pg = require("./aws-data-api/pg/index.cjs");
|
|
35
|
+
var import_better_sqlite3 = require("./better-sqlite3/index.cjs");
|
|
36
|
+
var import_bun_sqlite = require("./bun-sqlite/index.cjs");
|
|
37
|
+
var import_d1 = require("./d1/index.cjs");
|
|
38
|
+
var import_libsql = require("./libsql/index.cjs");
|
|
39
|
+
var import_node_postgres = require("./node-postgres/index.cjs");
|
|
40
|
+
const drizzle = async (params) => {
|
|
41
|
+
const { client, connection } = params;
|
|
42
|
+
const drizzleConfig = params;
|
|
43
|
+
delete drizzleConfig.client;
|
|
44
|
+
delete drizzleConfig.connection;
|
|
45
|
+
switch (client) {
|
|
46
|
+
case "node-postgres": {
|
|
47
|
+
const { Pool } = await import("pg");
|
|
48
|
+
const instance = new Pool(connection);
|
|
49
|
+
return (0, import_node_postgres.drizzle)(instance, drizzleConfig);
|
|
50
|
+
}
|
|
51
|
+
case "aws-data-api-pg": {
|
|
52
|
+
const { RDSDataClient } = await import("@aws-sdk/client-rds-data");
|
|
53
|
+
const instance = new RDSDataClient(connection);
|
|
54
|
+
return (0, import_pg.drizzle)(instance, drizzleConfig);
|
|
55
|
+
}
|
|
56
|
+
case "better-sqlite3": {
|
|
57
|
+
const { default: Client } = await import("better-sqlite3");
|
|
58
|
+
const { filename, options } = connection;
|
|
59
|
+
const instance = new Client(filename, options);
|
|
60
|
+
return (0, import_better_sqlite3.drizzle)(instance, drizzleConfig);
|
|
61
|
+
}
|
|
62
|
+
case "bun-sqlite": {
|
|
63
|
+
const { Database: Client } = await import("bun:sqlite");
|
|
64
|
+
const { filename, options } = connection;
|
|
65
|
+
const instance = new Client(filename, options);
|
|
66
|
+
return (0, import_bun_sqlite.drizzle)(instance, drizzleConfig);
|
|
67
|
+
}
|
|
68
|
+
case "d1": {
|
|
69
|
+
return (0, import_d1.drizzle)(connection, drizzleConfig);
|
|
70
|
+
}
|
|
71
|
+
case "libsql": {
|
|
72
|
+
const { createClient } = await import("@libsql/client");
|
|
73
|
+
const instance = createClient(connection);
|
|
74
|
+
return (0, import_libsql.drizzle)(instance, drizzleConfig);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return {};
|
|
78
|
+
};
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
drizzle
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=monodriver.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/monodriver.ts"],"sourcesContent":["/// <reference types=\"bun-types\" />\nimport type { RDSDataClientConfig as RDSConfig } from '@aws-sdk/client-rds-data';\nimport type { Config as LibsqlConfig } from '@libsql/client';\nimport type { ClientConfig as NeonHttpConfig, PoolConfig as NeonServerlessConfig } from '@neondatabase/serverless';\nimport type { Config as PlanetscaleConfig } from '@planetscale/database';\nimport type { Config as TiDBServerlessConfig } from '@tidbcloud/serverless';\nimport type { VercelPostgresPoolConfig as VercelPostgresConfig } from '@vercel/postgres';\nimport type { Options as BetterSQLite3Options } from 'better-sqlite3';\nimport type { ConnectionConfig as Mysql2Config } from 'mysql2';\nimport type { PoolConfig as NodePGPoolConfig } from 'pg';\nimport type { Options as PostgresJSOptions, PostgresType as PostgresJSPostgresType } from 'postgres';\nimport type { AwsDataApiPgDatabase, DrizzleAwsDataApiPgConfig } from './aws-data-api/pg/index.ts';\nimport type { BetterSQLite3Database } from './better-sqlite3/index.ts';\nimport type { BunSQLiteDatabase } from './bun-sqlite/index.ts';\nimport type { DrizzleD1Database } from './d1/index.ts';\nimport type { LibSQLDatabase } from './libsql/index.ts';\nimport type { MySql2Database } from './mysql2/index.ts';\nimport type { NeonHttpDatabase } from './neon-http/index.ts';\nimport type { NeonDatabase } from './neon-serverless/index.ts';\nimport type { NodePgDatabase } from './node-postgres/index.ts';\nimport type { PlanetScaleDatabase } from './planetscale-serverless/index.ts';\nimport type { PostgresJsDatabase } from './postgres-js/index.ts';\nimport type { TiDBServerlessDatabase } from './tidb-serverless/index.ts';\nimport type { DrizzleConfig } from './utils.ts';\nimport type { VercelPgDatabase } from './vercel-postgres/index.ts';\n\ntype BunSqliteDatabaseOptions =\n\t| number\n\t| {\n\t\t/**\n\t\t * Open the database as read-only (no write operations, no create).\n\t\t *\n\t\t * Equivalent to {@link constants.SQLITE_OPEN_READONLY}\n\t\t */\n\t\treadonly?: boolean;\n\t\t/**\n\t\t * Allow creating a new database\n\t\t *\n\t\t * Equivalent to {@link constants.SQLITE_OPEN_CREATE}\n\t\t */\n\t\tcreate?: boolean;\n\t\t/**\n\t\t * Open the database as read-write\n\t\t *\n\t\t * Equivalent to {@link constants.SQLITE_OPEN_READWRITE}\n\t\t */\n\t\treadwrite?: boolean;\n\t};\n\ntype BunSqliteDatabaseConfig = {\n\tfilename?: string;\n\toptions?: BunSqliteDatabaseOptions;\n};\n\ntype BetterSQLite3DatabaseConfig = {\n\tfilename?: string | Buffer;\n\toptions?: BetterSQLite3Options;\n};\n\ntype DatabaseClientType =\n\t| 'node-postgres'\n\t| 'postgres.js'\n\t| 'neon-serverless'\n\t| 'neon-http'\n\t| 'vercel-postgres'\n\t| 'aws-data-api-pg'\n\t| 'planetscale'\n\t| 'mysql2'\n\t| 'tidb-serverless'\n\t| 'libsql'\n\t| 'd1'\n\t| 'bun-sqlite'\n\t| 'better-sqlite3';\n\ntype ClientConnectionConfigMap = {\n\t'node-postgres': NodePGPoolConfig;\n\t'postgres.js': PostgresJSOptions<Record<string, PostgresJSPostgresType>>;\n\t'neon-serverless': NeonServerlessConfig;\n\t'neon-http': NeonHttpConfig;\n\t'vercel-postgres': VercelPostgresConfig;\n\t'aws-data-api-pg': RDSConfig;\n\tplanetscale: PlanetscaleConfig;\n\tmysql2: Mysql2Config;\n\t'tidb-serverless': TiDBServerlessConfig;\n\tlibsql: LibsqlConfig;\n\td1: D1Database;\n\t'bun-sqlite': BunSqliteDatabaseConfig;\n\t'better-sqlite3': BetterSQLite3DatabaseConfig;\n};\n\ntype ClientDrizzleInstanceMap<TSchema extends Record<string, any>> = {\n\t'node-postgres': NodePgDatabase<TSchema>;\n\t'postgres.js': PostgresJsDatabase<TSchema>;\n\t'neon-serverless': NeonDatabase<TSchema>;\n\t'neon-http': NeonHttpDatabase<TSchema>;\n\t'vercel-postgres': VercelPgDatabase<TSchema>;\n\t'aws-data-api-pg': AwsDataApiPgDatabase<TSchema>;\n\tplanetscale: PlanetScaleDatabase<TSchema>;\n\tmysql2: MySql2Database<TSchema>;\n\t'tidb-serverless': TiDBServerlessDatabase<TSchema>;\n\tlibsql: LibSQLDatabase<TSchema>;\n\td1: DrizzleD1Database<TSchema>;\n\t'bun-sqlite': BunSQLiteDatabase<TSchema>;\n\t'better-sqlite3': BetterSQLite3Database<TSchema>;\n};\n\ntype ClientParams<TClientType extends DatabaseClientType> = ClientConnectionConfigMap[TClientType];\n\ntype InitializerParams<\n\tTClientType extends DatabaseClientType,\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> = {\n\tclient: TClientType;\n\tconnection: ClientParams<TClientType>;\n} & DrizzleConfig<TSchema>;\n\ntype DetermineClient<\n\tTParams extends InitializerParams<any, any>,\n\tTSchema extends Record<string, unknown> = TParams extends { schema: Record<string, unknown> } ? TParams['schema']\n\t\t: Record<string, never>,\n> = TParams extends { client: DatabaseClientType } ? ClientDrizzleInstanceMap<TSchema>[TParams['client']]\n\t: never;\n\nimport { drizzle as rdsPgDrizzle } from './aws-data-api/pg/index.ts';\nimport { drizzle as betterSqliteDrizzle } from './better-sqlite3/index.ts';\nimport { drizzle as bunSqliteDrizzle } from './bun-sqlite/index.ts';\nimport { drizzle as d1Drizzle } from './d1/index.ts';\nimport { drizzle as libsqlDrizzle } from './libsql/index.ts';\n// import { drizzle as mysql2Drizzle } from './mysql2/index.ts';\n// import { drizzle as neonHttpDrizzle } from './neon-http/index.ts';\n// import { drizzle as neonDrizzle } from './neon-serverless/index.ts';\nimport { drizzle as pgDrizzle } from './node-postgres/index.ts';\n// import { drizzle as planetscaleDrizzle } from './planetscale-serverless/index.ts';\n// import { drizzle as postgresJSDrizzle } from './postgres-js/index.ts';\n// import { drizzle as tidbDrizzle } from './tidb-serverless/index.ts';\n// import { drizzle as vercelDrizzle } from './vercel-postgres/index.ts';\n\nexport const drizzle = async <\n\tTClientType extends DatabaseClientType,\n\tTSchema extends Record<string, any>,\n\tTParams extends InitializerParams<TClientType, TSchema>,\n>(params: TParams): Promise<DetermineClient<TParams>> => {\n\tconst { client, connection } = params;\n\tconst drizzleConfig = params as Omit<typeof params, 'client' | 'connection'>;\n\t// @ts-expect-error\n\tdelete drizzleConfig.client;\n\t// @ts-expect-error\n\tdelete drizzleConfig.connection;\n\n\tswitch (client) {\n\t\tcase 'node-postgres': {\n\t\t\tconst { Pool } = await import('pg');\n\t\t\tconst instance = new Pool(connection as NodePGPoolConfig);\n\n\t\t\treturn pgDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\tcase 'aws-data-api-pg': {\n\t\t\tconst { RDSDataClient } = await import('@aws-sdk/client-rds-data');\n\t\t\tconst instance = new RDSDataClient(connection);\n\n\t\t\treturn rdsPgDrizzle(instance, drizzleConfig as any as DrizzleAwsDataApiPgConfig) as any;\n\t\t}\n\t\tcase 'better-sqlite3': {\n\t\t\tconst { default: Client } = await import('better-sqlite3');\n\t\t\tconst { filename, options } = connection as BetterSQLite3DatabaseConfig;\n\t\t\tconst instance = new Client(filename, options);\n\n\t\t\treturn betterSqliteDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\tcase 'bun-sqlite': {\n\t\t\tconst { Database: Client } = await import('bun:sqlite');\n\t\t\tconst { filename, options } = connection as BunSqliteDatabaseConfig;\n\t\t\tconst instance = new Client(filename, options);\n\n\t\t\treturn bunSqliteDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\tcase 'd1': {\n\t\t\treturn d1Drizzle(connection as D1Database, drizzleConfig) as any;\n\t\t}\n\t\tcase 'libsql': {\n\t\t\tconst { createClient } = await import('@libsql/client');\n\t\t\tconst instance = createClient(connection as LibsqlConfig);\n\n\t\t\treturn libsqlDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\t\t// case 'mysql2': {\n\t\t\t// }\n\t\t\t// case 'neon-http': {\n\t\t\t// }\n\t\t\t// case 'neon-serverless': {\n\t\t\t// }\n\t\t\t// case 'planetscale': {\n\t\t\t// }\n\t\t\t// case 'postgres.js': {\n\t\t\t// }\n\t\t\t// case 'tidb-serverless': {\n\t\t\t// }\n\t\t\t// case 'vercel-postgres': {\n\t\t\t// }\n\t}\n\n\t// @ts-ignore\n\treturn {};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2HA,gBAAwC;AACxC,4BAA+C;AAC/C,wBAA4C;AAC5C,gBAAqC;AACrC,oBAAyC;AAIzC,2BAAqC;AAM9B,MAAM,UAAU,OAIrB,WAAuD;AACxD,QAAM,EAAE,QAAQ,WAAW,IAAI;AAC/B,QAAM,gBAAgB;AAEtB,SAAO,cAAc;AAErB,SAAO,cAAc;AAErB,UAAQ,QAAQ;AAAA,IACf,KAAK,iBAAiB;AACrB,YAAM,EAAE,KAAK,IAAI,MAAM,OAAO,IAAI;AAClC,YAAM,WAAW,IAAI,KAAK,UAA8B;AAExD,iBAAO,qBAAAA,SAAU,UAAU,aAAa;AAAA,IACzC;AAAA,IACA,KAAK,mBAAmB;AACvB,YAAM,EAAE,cAAc,IAAI,MAAM,OAAO,0BAA0B;AACjE,YAAM,WAAW,IAAI,cAAc,UAAU;AAE7C,iBAAO,UAAAC,SAAa,UAAU,aAAiD;AAAA,IAChF;AAAA,IACA,KAAK,kBAAkB;AACtB,YAAM,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,gBAAgB;AACzD,YAAM,EAAE,UAAU,QAAQ,IAAI;AAC9B,YAAM,WAAW,IAAI,OAAO,UAAU,OAAO;AAE7C,iBAAO,sBAAAC,SAAoB,UAAU,aAAa;AAAA,IACnD;AAAA,IACA,KAAK,cAAc;AAClB,YAAM,EAAE,UAAU,OAAO,IAAI,MAAM,OAAO,YAAY;AACtD,YAAM,EAAE,UAAU,QAAQ,IAAI;AAC9B,YAAM,WAAW,IAAI,OAAO,UAAU,OAAO;AAE7C,iBAAO,kBAAAC,SAAiB,UAAU,aAAa;AAAA,IAChD;AAAA,IACA,KAAK,MAAM;AACV,iBAAO,UAAAC,SAAU,YAA0B,aAAa;AAAA,IACzD;AAAA,IACA,KAAK,UAAU;AACd,YAAM,EAAE,aAAa,IAAI,MAAM,OAAO,gBAAgB;AACtD,YAAM,WAAW,aAAa,UAA0B;AAExD,iBAAO,cAAAC,SAAc,UAAU,aAAa;AAAA,IAC7C;AAAA,EAeD;AAGA,SAAO,CAAC;AACT;","names":["pgDrizzle","rdsPgDrizzle","betterSqliteDrizzle","bunSqliteDrizzle","d1Drizzle","libsqlDrizzle"]}
|
package/monodriver.d.cts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
/// <reference types="bun-types" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import type { RDSDataClientConfig as RDSConfig } from '@aws-sdk/client-rds-data';
|
|
5
|
+
import type { Config as LibsqlConfig } from '@libsql/client';
|
|
6
|
+
import type { ClientConfig as NeonHttpConfig, PoolConfig as NeonServerlessConfig } from '@neondatabase/serverless';
|
|
7
|
+
import type { Config as PlanetscaleConfig } from '@planetscale/database';
|
|
8
|
+
import type { Config as TiDBServerlessConfig } from '@tidbcloud/serverless';
|
|
9
|
+
import type { VercelPostgresPoolConfig as VercelPostgresConfig } from '@vercel/postgres';
|
|
10
|
+
import type { Options as BetterSQLite3Options } from 'better-sqlite3';
|
|
11
|
+
import type { ConnectionConfig as Mysql2Config } from 'mysql2';
|
|
12
|
+
import type { PoolConfig as NodePGPoolConfig } from 'pg';
|
|
13
|
+
import type { Options as PostgresJSOptions, PostgresType as PostgresJSPostgresType } from 'postgres';
|
|
14
|
+
import type { AwsDataApiPgDatabase } from "./aws-data-api/pg/index.cjs";
|
|
15
|
+
import type { BetterSQLite3Database } from "./better-sqlite3/index.cjs";
|
|
16
|
+
import type { BunSQLiteDatabase } from "./bun-sqlite/index.cjs";
|
|
17
|
+
import type { DrizzleD1Database } from "./d1/index.cjs";
|
|
18
|
+
import type { LibSQLDatabase } from "./libsql/index.cjs";
|
|
19
|
+
import type { MySql2Database } from "./mysql2/index.cjs";
|
|
20
|
+
import type { NeonHttpDatabase } from "./neon-http/index.cjs";
|
|
21
|
+
import type { NeonDatabase } from "./neon-serverless/index.cjs";
|
|
22
|
+
import type { NodePgDatabase } from "./node-postgres/index.cjs";
|
|
23
|
+
import type { PlanetScaleDatabase } from "./planetscale-serverless/index.cjs";
|
|
24
|
+
import type { PostgresJsDatabase } from "./postgres-js/index.cjs";
|
|
25
|
+
import type { TiDBServerlessDatabase } from "./tidb-serverless/index.cjs";
|
|
26
|
+
import type { DrizzleConfig } from "./utils.cjs";
|
|
27
|
+
import type { VercelPgDatabase } from "./vercel-postgres/index.cjs";
|
|
28
|
+
type BunSqliteDatabaseOptions = number | {
|
|
29
|
+
/**
|
|
30
|
+
* Open the database as read-only (no write operations, no create).
|
|
31
|
+
*
|
|
32
|
+
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
|
33
|
+
*/
|
|
34
|
+
readonly?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Allow creating a new database
|
|
37
|
+
*
|
|
38
|
+
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
|
39
|
+
*/
|
|
40
|
+
create?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Open the database as read-write
|
|
43
|
+
*
|
|
44
|
+
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
|
45
|
+
*/
|
|
46
|
+
readwrite?: boolean;
|
|
47
|
+
};
|
|
48
|
+
type BunSqliteDatabaseConfig = {
|
|
49
|
+
filename?: string;
|
|
50
|
+
options?: BunSqliteDatabaseOptions;
|
|
51
|
+
};
|
|
52
|
+
type BetterSQLite3DatabaseConfig = {
|
|
53
|
+
filename?: string | Buffer;
|
|
54
|
+
options?: BetterSQLite3Options;
|
|
55
|
+
};
|
|
56
|
+
type DatabaseClientType = 'node-postgres' | 'postgres.js' | 'neon-serverless' | 'neon-http' | 'vercel-postgres' | 'aws-data-api-pg' | 'planetscale' | 'mysql2' | 'tidb-serverless' | 'libsql' | 'd1' | 'bun-sqlite' | 'better-sqlite3';
|
|
57
|
+
type ClientConnectionConfigMap = {
|
|
58
|
+
'node-postgres': NodePGPoolConfig;
|
|
59
|
+
'postgres.js': PostgresJSOptions<Record<string, PostgresJSPostgresType>>;
|
|
60
|
+
'neon-serverless': NeonServerlessConfig;
|
|
61
|
+
'neon-http': NeonHttpConfig;
|
|
62
|
+
'vercel-postgres': VercelPostgresConfig;
|
|
63
|
+
'aws-data-api-pg': RDSConfig;
|
|
64
|
+
planetscale: PlanetscaleConfig;
|
|
65
|
+
mysql2: Mysql2Config;
|
|
66
|
+
'tidb-serverless': TiDBServerlessConfig;
|
|
67
|
+
libsql: LibsqlConfig;
|
|
68
|
+
d1: D1Database;
|
|
69
|
+
'bun-sqlite': BunSqliteDatabaseConfig;
|
|
70
|
+
'better-sqlite3': BetterSQLite3DatabaseConfig;
|
|
71
|
+
};
|
|
72
|
+
type ClientDrizzleInstanceMap<TSchema extends Record<string, any>> = {
|
|
73
|
+
'node-postgres': NodePgDatabase<TSchema>;
|
|
74
|
+
'postgres.js': PostgresJsDatabase<TSchema>;
|
|
75
|
+
'neon-serverless': NeonDatabase<TSchema>;
|
|
76
|
+
'neon-http': NeonHttpDatabase<TSchema>;
|
|
77
|
+
'vercel-postgres': VercelPgDatabase<TSchema>;
|
|
78
|
+
'aws-data-api-pg': AwsDataApiPgDatabase<TSchema>;
|
|
79
|
+
planetscale: PlanetScaleDatabase<TSchema>;
|
|
80
|
+
mysql2: MySql2Database<TSchema>;
|
|
81
|
+
'tidb-serverless': TiDBServerlessDatabase<TSchema>;
|
|
82
|
+
libsql: LibSQLDatabase<TSchema>;
|
|
83
|
+
d1: DrizzleD1Database<TSchema>;
|
|
84
|
+
'bun-sqlite': BunSQLiteDatabase<TSchema>;
|
|
85
|
+
'better-sqlite3': BetterSQLite3Database<TSchema>;
|
|
86
|
+
};
|
|
87
|
+
type ClientParams<TClientType extends DatabaseClientType> = ClientConnectionConfigMap[TClientType];
|
|
88
|
+
type InitializerParams<TClientType extends DatabaseClientType, TSchema extends Record<string, unknown> = Record<string, never>> = {
|
|
89
|
+
client: TClientType;
|
|
90
|
+
connection: ClientParams<TClientType>;
|
|
91
|
+
} & DrizzleConfig<TSchema>;
|
|
92
|
+
type DetermineClient<TParams extends InitializerParams<any, any>, TSchema extends Record<string, unknown> = TParams extends {
|
|
93
|
+
schema: Record<string, unknown>;
|
|
94
|
+
} ? TParams['schema'] : Record<string, never>> = TParams extends {
|
|
95
|
+
client: DatabaseClientType;
|
|
96
|
+
} ? ClientDrizzleInstanceMap<TSchema>[TParams['client']] : never;
|
|
97
|
+
export declare const drizzle: <TClientType extends DatabaseClientType, TSchema extends Record<string, any>, TParams extends InitializerParams<TClientType, TSchema>>(params: TParams) => Promise<DetermineClient<TParams>>;
|
|
98
|
+
export {};
|
package/monodriver.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
+
/// <reference types="bun-types" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import type { RDSDataClientConfig as RDSConfig } from '@aws-sdk/client-rds-data';
|
|
5
|
+
import type { Config as LibsqlConfig } from '@libsql/client';
|
|
6
|
+
import type { ClientConfig as NeonHttpConfig, PoolConfig as NeonServerlessConfig } from '@neondatabase/serverless';
|
|
7
|
+
import type { Config as PlanetscaleConfig } from '@planetscale/database';
|
|
8
|
+
import type { Config as TiDBServerlessConfig } from '@tidbcloud/serverless';
|
|
9
|
+
import type { VercelPostgresPoolConfig as VercelPostgresConfig } from '@vercel/postgres';
|
|
10
|
+
import type { Options as BetterSQLite3Options } from 'better-sqlite3';
|
|
11
|
+
import type { ConnectionConfig as Mysql2Config } from 'mysql2';
|
|
12
|
+
import type { PoolConfig as NodePGPoolConfig } from 'pg';
|
|
13
|
+
import type { Options as PostgresJSOptions, PostgresType as PostgresJSPostgresType } from 'postgres';
|
|
14
|
+
import type { AwsDataApiPgDatabase } from "./aws-data-api/pg/index.js";
|
|
15
|
+
import type { BetterSQLite3Database } from "./better-sqlite3/index.js";
|
|
16
|
+
import type { BunSQLiteDatabase } from "./bun-sqlite/index.js";
|
|
17
|
+
import type { DrizzleD1Database } from "./d1/index.js";
|
|
18
|
+
import type { LibSQLDatabase } from "./libsql/index.js";
|
|
19
|
+
import type { MySql2Database } from "./mysql2/index.js";
|
|
20
|
+
import type { NeonHttpDatabase } from "./neon-http/index.js";
|
|
21
|
+
import type { NeonDatabase } from "./neon-serverless/index.js";
|
|
22
|
+
import type { NodePgDatabase } from "./node-postgres/index.js";
|
|
23
|
+
import type { PlanetScaleDatabase } from "./planetscale-serverless/index.js";
|
|
24
|
+
import type { PostgresJsDatabase } from "./postgres-js/index.js";
|
|
25
|
+
import type { TiDBServerlessDatabase } from "./tidb-serverless/index.js";
|
|
26
|
+
import type { DrizzleConfig } from "./utils.js";
|
|
27
|
+
import type { VercelPgDatabase } from "./vercel-postgres/index.js";
|
|
28
|
+
type BunSqliteDatabaseOptions = number | {
|
|
29
|
+
/**
|
|
30
|
+
* Open the database as read-only (no write operations, no create).
|
|
31
|
+
*
|
|
32
|
+
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
|
33
|
+
*/
|
|
34
|
+
readonly?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Allow creating a new database
|
|
37
|
+
*
|
|
38
|
+
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
|
39
|
+
*/
|
|
40
|
+
create?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Open the database as read-write
|
|
43
|
+
*
|
|
44
|
+
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
|
45
|
+
*/
|
|
46
|
+
readwrite?: boolean;
|
|
47
|
+
};
|
|
48
|
+
type BunSqliteDatabaseConfig = {
|
|
49
|
+
filename?: string;
|
|
50
|
+
options?: BunSqliteDatabaseOptions;
|
|
51
|
+
};
|
|
52
|
+
type BetterSQLite3DatabaseConfig = {
|
|
53
|
+
filename?: string | Buffer;
|
|
54
|
+
options?: BetterSQLite3Options;
|
|
55
|
+
};
|
|
56
|
+
type DatabaseClientType = 'node-postgres' | 'postgres.js' | 'neon-serverless' | 'neon-http' | 'vercel-postgres' | 'aws-data-api-pg' | 'planetscale' | 'mysql2' | 'tidb-serverless' | 'libsql' | 'd1' | 'bun-sqlite' | 'better-sqlite3';
|
|
57
|
+
type ClientConnectionConfigMap = {
|
|
58
|
+
'node-postgres': NodePGPoolConfig;
|
|
59
|
+
'postgres.js': PostgresJSOptions<Record<string, PostgresJSPostgresType>>;
|
|
60
|
+
'neon-serverless': NeonServerlessConfig;
|
|
61
|
+
'neon-http': NeonHttpConfig;
|
|
62
|
+
'vercel-postgres': VercelPostgresConfig;
|
|
63
|
+
'aws-data-api-pg': RDSConfig;
|
|
64
|
+
planetscale: PlanetscaleConfig;
|
|
65
|
+
mysql2: Mysql2Config;
|
|
66
|
+
'tidb-serverless': TiDBServerlessConfig;
|
|
67
|
+
libsql: LibsqlConfig;
|
|
68
|
+
d1: D1Database;
|
|
69
|
+
'bun-sqlite': BunSqliteDatabaseConfig;
|
|
70
|
+
'better-sqlite3': BetterSQLite3DatabaseConfig;
|
|
71
|
+
};
|
|
72
|
+
type ClientDrizzleInstanceMap<TSchema extends Record<string, any>> = {
|
|
73
|
+
'node-postgres': NodePgDatabase<TSchema>;
|
|
74
|
+
'postgres.js': PostgresJsDatabase<TSchema>;
|
|
75
|
+
'neon-serverless': NeonDatabase<TSchema>;
|
|
76
|
+
'neon-http': NeonHttpDatabase<TSchema>;
|
|
77
|
+
'vercel-postgres': VercelPgDatabase<TSchema>;
|
|
78
|
+
'aws-data-api-pg': AwsDataApiPgDatabase<TSchema>;
|
|
79
|
+
planetscale: PlanetScaleDatabase<TSchema>;
|
|
80
|
+
mysql2: MySql2Database<TSchema>;
|
|
81
|
+
'tidb-serverless': TiDBServerlessDatabase<TSchema>;
|
|
82
|
+
libsql: LibSQLDatabase<TSchema>;
|
|
83
|
+
d1: DrizzleD1Database<TSchema>;
|
|
84
|
+
'bun-sqlite': BunSQLiteDatabase<TSchema>;
|
|
85
|
+
'better-sqlite3': BetterSQLite3Database<TSchema>;
|
|
86
|
+
};
|
|
87
|
+
type ClientParams<TClientType extends DatabaseClientType> = ClientConnectionConfigMap[TClientType];
|
|
88
|
+
type InitializerParams<TClientType extends DatabaseClientType, TSchema extends Record<string, unknown> = Record<string, never>> = {
|
|
89
|
+
client: TClientType;
|
|
90
|
+
connection: ClientParams<TClientType>;
|
|
91
|
+
} & DrizzleConfig<TSchema>;
|
|
92
|
+
type DetermineClient<TParams extends InitializerParams<any, any>, TSchema extends Record<string, unknown> = TParams extends {
|
|
93
|
+
schema: Record<string, unknown>;
|
|
94
|
+
} ? TParams['schema'] : Record<string, never>> = TParams extends {
|
|
95
|
+
client: DatabaseClientType;
|
|
96
|
+
} ? ClientDrizzleInstanceMap<TSchema>[TParams['client']] : never;
|
|
97
|
+
export declare const drizzle: <TClientType extends DatabaseClientType, TSchema extends Record<string, any>, TParams extends InitializerParams<TClientType, TSchema>>(params: TParams) => Promise<DetermineClient<TParams>>;
|
|
98
|
+
export {};
|
package/monodriver.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { drizzle as rdsPgDrizzle } from "./aws-data-api/pg/index.js";
|
|
2
|
+
import { drizzle as betterSqliteDrizzle } from "./better-sqlite3/index.js";
|
|
3
|
+
import { drizzle as bunSqliteDrizzle } from "./bun-sqlite/index.js";
|
|
4
|
+
import { drizzle as d1Drizzle } from "./d1/index.js";
|
|
5
|
+
import { drizzle as libsqlDrizzle } from "./libsql/index.js";
|
|
6
|
+
import { drizzle as pgDrizzle } from "./node-postgres/index.js";
|
|
7
|
+
const drizzle = async (params) => {
|
|
8
|
+
const { client, connection } = params;
|
|
9
|
+
const drizzleConfig = params;
|
|
10
|
+
delete drizzleConfig.client;
|
|
11
|
+
delete drizzleConfig.connection;
|
|
12
|
+
switch (client) {
|
|
13
|
+
case "node-postgres": {
|
|
14
|
+
const { Pool } = await import("pg");
|
|
15
|
+
const instance = new Pool(connection);
|
|
16
|
+
return pgDrizzle(instance, drizzleConfig);
|
|
17
|
+
}
|
|
18
|
+
case "aws-data-api-pg": {
|
|
19
|
+
const { RDSDataClient } = await import("@aws-sdk/client-rds-data");
|
|
20
|
+
const instance = new RDSDataClient(connection);
|
|
21
|
+
return rdsPgDrizzle(instance, drizzleConfig);
|
|
22
|
+
}
|
|
23
|
+
case "better-sqlite3": {
|
|
24
|
+
const { default: Client } = await import("better-sqlite3");
|
|
25
|
+
const { filename, options } = connection;
|
|
26
|
+
const instance = new Client(filename, options);
|
|
27
|
+
return betterSqliteDrizzle(instance, drizzleConfig);
|
|
28
|
+
}
|
|
29
|
+
case "bun-sqlite": {
|
|
30
|
+
const { Database: Client } = await import("bun:sqlite");
|
|
31
|
+
const { filename, options } = connection;
|
|
32
|
+
const instance = new Client(filename, options);
|
|
33
|
+
return bunSqliteDrizzle(instance, drizzleConfig);
|
|
34
|
+
}
|
|
35
|
+
case "d1": {
|
|
36
|
+
return d1Drizzle(connection, drizzleConfig);
|
|
37
|
+
}
|
|
38
|
+
case "libsql": {
|
|
39
|
+
const { createClient } = await import("@libsql/client");
|
|
40
|
+
const instance = createClient(connection);
|
|
41
|
+
return libsqlDrizzle(instance, drizzleConfig);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
drizzle
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=monodriver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/monodriver.ts"],"sourcesContent":["/// <reference types=\"bun-types\" />\nimport type { RDSDataClientConfig as RDSConfig } from '@aws-sdk/client-rds-data';\nimport type { Config as LibsqlConfig } from '@libsql/client';\nimport type { ClientConfig as NeonHttpConfig, PoolConfig as NeonServerlessConfig } from '@neondatabase/serverless';\nimport type { Config as PlanetscaleConfig } from '@planetscale/database';\nimport type { Config as TiDBServerlessConfig } from '@tidbcloud/serverless';\nimport type { VercelPostgresPoolConfig as VercelPostgresConfig } from '@vercel/postgres';\nimport type { Options as BetterSQLite3Options } from 'better-sqlite3';\nimport type { ConnectionConfig as Mysql2Config } from 'mysql2';\nimport type { PoolConfig as NodePGPoolConfig } from 'pg';\nimport type { Options as PostgresJSOptions, PostgresType as PostgresJSPostgresType } from 'postgres';\nimport type { AwsDataApiPgDatabase, DrizzleAwsDataApiPgConfig } from './aws-data-api/pg/index.ts';\nimport type { BetterSQLite3Database } from './better-sqlite3/index.ts';\nimport type { BunSQLiteDatabase } from './bun-sqlite/index.ts';\nimport type { DrizzleD1Database } from './d1/index.ts';\nimport type { LibSQLDatabase } from './libsql/index.ts';\nimport type { MySql2Database } from './mysql2/index.ts';\nimport type { NeonHttpDatabase } from './neon-http/index.ts';\nimport type { NeonDatabase } from './neon-serverless/index.ts';\nimport type { NodePgDatabase } from './node-postgres/index.ts';\nimport type { PlanetScaleDatabase } from './planetscale-serverless/index.ts';\nimport type { PostgresJsDatabase } from './postgres-js/index.ts';\nimport type { TiDBServerlessDatabase } from './tidb-serverless/index.ts';\nimport type { DrizzleConfig } from './utils.ts';\nimport type { VercelPgDatabase } from './vercel-postgres/index.ts';\n\ntype BunSqliteDatabaseOptions =\n\t| number\n\t| {\n\t\t/**\n\t\t * Open the database as read-only (no write operations, no create).\n\t\t *\n\t\t * Equivalent to {@link constants.SQLITE_OPEN_READONLY}\n\t\t */\n\t\treadonly?: boolean;\n\t\t/**\n\t\t * Allow creating a new database\n\t\t *\n\t\t * Equivalent to {@link constants.SQLITE_OPEN_CREATE}\n\t\t */\n\t\tcreate?: boolean;\n\t\t/**\n\t\t * Open the database as read-write\n\t\t *\n\t\t * Equivalent to {@link constants.SQLITE_OPEN_READWRITE}\n\t\t */\n\t\treadwrite?: boolean;\n\t};\n\ntype BunSqliteDatabaseConfig = {\n\tfilename?: string;\n\toptions?: BunSqliteDatabaseOptions;\n};\n\ntype BetterSQLite3DatabaseConfig = {\n\tfilename?: string | Buffer;\n\toptions?: BetterSQLite3Options;\n};\n\ntype DatabaseClientType =\n\t| 'node-postgres'\n\t| 'postgres.js'\n\t| 'neon-serverless'\n\t| 'neon-http'\n\t| 'vercel-postgres'\n\t| 'aws-data-api-pg'\n\t| 'planetscale'\n\t| 'mysql2'\n\t| 'tidb-serverless'\n\t| 'libsql'\n\t| 'd1'\n\t| 'bun-sqlite'\n\t| 'better-sqlite3';\n\ntype ClientConnectionConfigMap = {\n\t'node-postgres': NodePGPoolConfig;\n\t'postgres.js': PostgresJSOptions<Record<string, PostgresJSPostgresType>>;\n\t'neon-serverless': NeonServerlessConfig;\n\t'neon-http': NeonHttpConfig;\n\t'vercel-postgres': VercelPostgresConfig;\n\t'aws-data-api-pg': RDSConfig;\n\tplanetscale: PlanetscaleConfig;\n\tmysql2: Mysql2Config;\n\t'tidb-serverless': TiDBServerlessConfig;\n\tlibsql: LibsqlConfig;\n\td1: D1Database;\n\t'bun-sqlite': BunSqliteDatabaseConfig;\n\t'better-sqlite3': BetterSQLite3DatabaseConfig;\n};\n\ntype ClientDrizzleInstanceMap<TSchema extends Record<string, any>> = {\n\t'node-postgres': NodePgDatabase<TSchema>;\n\t'postgres.js': PostgresJsDatabase<TSchema>;\n\t'neon-serverless': NeonDatabase<TSchema>;\n\t'neon-http': NeonHttpDatabase<TSchema>;\n\t'vercel-postgres': VercelPgDatabase<TSchema>;\n\t'aws-data-api-pg': AwsDataApiPgDatabase<TSchema>;\n\tplanetscale: PlanetScaleDatabase<TSchema>;\n\tmysql2: MySql2Database<TSchema>;\n\t'tidb-serverless': TiDBServerlessDatabase<TSchema>;\n\tlibsql: LibSQLDatabase<TSchema>;\n\td1: DrizzleD1Database<TSchema>;\n\t'bun-sqlite': BunSQLiteDatabase<TSchema>;\n\t'better-sqlite3': BetterSQLite3Database<TSchema>;\n};\n\ntype ClientParams<TClientType extends DatabaseClientType> = ClientConnectionConfigMap[TClientType];\n\ntype InitializerParams<\n\tTClientType extends DatabaseClientType,\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> = {\n\tclient: TClientType;\n\tconnection: ClientParams<TClientType>;\n} & DrizzleConfig<TSchema>;\n\ntype DetermineClient<\n\tTParams extends InitializerParams<any, any>,\n\tTSchema extends Record<string, unknown> = TParams extends { schema: Record<string, unknown> } ? TParams['schema']\n\t\t: Record<string, never>,\n> = TParams extends { client: DatabaseClientType } ? ClientDrizzleInstanceMap<TSchema>[TParams['client']]\n\t: never;\n\nimport { drizzle as rdsPgDrizzle } from './aws-data-api/pg/index.ts';\nimport { drizzle as betterSqliteDrizzle } from './better-sqlite3/index.ts';\nimport { drizzle as bunSqliteDrizzle } from './bun-sqlite/index.ts';\nimport { drizzle as d1Drizzle } from './d1/index.ts';\nimport { drizzle as libsqlDrizzle } from './libsql/index.ts';\n// import { drizzle as mysql2Drizzle } from './mysql2/index.ts';\n// import { drizzle as neonHttpDrizzle } from './neon-http/index.ts';\n// import { drizzle as neonDrizzle } from './neon-serverless/index.ts';\nimport { drizzle as pgDrizzle } from './node-postgres/index.ts';\n// import { drizzle as planetscaleDrizzle } from './planetscale-serverless/index.ts';\n// import { drizzle as postgresJSDrizzle } from './postgres-js/index.ts';\n// import { drizzle as tidbDrizzle } from './tidb-serverless/index.ts';\n// import { drizzle as vercelDrizzle } from './vercel-postgres/index.ts';\n\nexport const drizzle = async <\n\tTClientType extends DatabaseClientType,\n\tTSchema extends Record<string, any>,\n\tTParams extends InitializerParams<TClientType, TSchema>,\n>(params: TParams): Promise<DetermineClient<TParams>> => {\n\tconst { client, connection } = params;\n\tconst drizzleConfig = params as Omit<typeof params, 'client' | 'connection'>;\n\t// @ts-expect-error\n\tdelete drizzleConfig.client;\n\t// @ts-expect-error\n\tdelete drizzleConfig.connection;\n\n\tswitch (client) {\n\t\tcase 'node-postgres': {\n\t\t\tconst { Pool } = await import('pg');\n\t\t\tconst instance = new Pool(connection as NodePGPoolConfig);\n\n\t\t\treturn pgDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\tcase 'aws-data-api-pg': {\n\t\t\tconst { RDSDataClient } = await import('@aws-sdk/client-rds-data');\n\t\t\tconst instance = new RDSDataClient(connection);\n\n\t\t\treturn rdsPgDrizzle(instance, drizzleConfig as any as DrizzleAwsDataApiPgConfig) as any;\n\t\t}\n\t\tcase 'better-sqlite3': {\n\t\t\tconst { default: Client } = await import('better-sqlite3');\n\t\t\tconst { filename, options } = connection as BetterSQLite3DatabaseConfig;\n\t\t\tconst instance = new Client(filename, options);\n\n\t\t\treturn betterSqliteDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\tcase 'bun-sqlite': {\n\t\t\tconst { Database: Client } = await import('bun:sqlite');\n\t\t\tconst { filename, options } = connection as BunSqliteDatabaseConfig;\n\t\t\tconst instance = new Client(filename, options);\n\n\t\t\treturn bunSqliteDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\tcase 'd1': {\n\t\t\treturn d1Drizzle(connection as D1Database, drizzleConfig) as any;\n\t\t}\n\t\tcase 'libsql': {\n\t\t\tconst { createClient } = await import('@libsql/client');\n\t\t\tconst instance = createClient(connection as LibsqlConfig);\n\n\t\t\treturn libsqlDrizzle(instance, drizzleConfig) as any;\n\t\t}\n\t\t\t// case 'mysql2': {\n\t\t\t// }\n\t\t\t// case 'neon-http': {\n\t\t\t// }\n\t\t\t// case 'neon-serverless': {\n\t\t\t// }\n\t\t\t// case 'planetscale': {\n\t\t\t// }\n\t\t\t// case 'postgres.js': {\n\t\t\t// }\n\t\t\t// case 'tidb-serverless': {\n\t\t\t// }\n\t\t\t// case 'vercel-postgres': {\n\t\t\t// }\n\t}\n\n\t// @ts-ignore\n\treturn {};\n};\n"],"mappings":"AA2HA,SAAS,WAAW,oBAAoB;AACxC,SAAS,WAAW,2BAA2B;AAC/C,SAAS,WAAW,wBAAwB;AAC5C,SAAS,WAAW,iBAAiB;AACrC,SAAS,WAAW,qBAAqB;AAIzC,SAAS,WAAW,iBAAiB;AAM9B,MAAM,UAAU,OAIrB,WAAuD;AACxD,QAAM,EAAE,QAAQ,WAAW,IAAI;AAC/B,QAAM,gBAAgB;AAEtB,SAAO,cAAc;AAErB,SAAO,cAAc;AAErB,UAAQ,QAAQ;AAAA,IACf,KAAK,iBAAiB;AACrB,YAAM,EAAE,KAAK,IAAI,MAAM,OAAO,IAAI;AAClC,YAAM,WAAW,IAAI,KAAK,UAA8B;AAExD,aAAO,UAAU,UAAU,aAAa;AAAA,IACzC;AAAA,IACA,KAAK,mBAAmB;AACvB,YAAM,EAAE,cAAc,IAAI,MAAM,OAAO,0BAA0B;AACjE,YAAM,WAAW,IAAI,cAAc,UAAU;AAE7C,aAAO,aAAa,UAAU,aAAiD;AAAA,IAChF;AAAA,IACA,KAAK,kBAAkB;AACtB,YAAM,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,gBAAgB;AACzD,YAAM,EAAE,UAAU,QAAQ,IAAI;AAC9B,YAAM,WAAW,IAAI,OAAO,UAAU,OAAO;AAE7C,aAAO,oBAAoB,UAAU,aAAa;AAAA,IACnD;AAAA,IACA,KAAK,cAAc;AAClB,YAAM,EAAE,UAAU,OAAO,IAAI,MAAM,OAAO,YAAY;AACtD,YAAM,EAAE,UAAU,QAAQ,IAAI;AAC9B,YAAM,WAAW,IAAI,OAAO,UAAU,OAAO;AAE7C,aAAO,iBAAiB,UAAU,aAAa;AAAA,IAChD;AAAA,IACA,KAAK,MAAM;AACV,aAAO,UAAU,YAA0B,aAAa;AAAA,IACzD;AAAA,IACA,KAAK,UAAU;AACd,YAAM,EAAE,aAAa,IAAI,MAAM,OAAO,gBAAgB;AACtD,YAAM,WAAW,aAAa,UAA0B;AAExD,aAAO,cAAc,UAAU,aAAa;AAAA,IAC7C;AAAA,EAeD;AAGA,SAAO,CAAC;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-orm",
|
|
3
|
-
"version": "0.33.0-
|
|
3
|
+
"version": "0.33.0-87d7704",
|
|
4
4
|
"description": "Drizzle ORM package for SQL databases",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -317,6 +317,18 @@
|
|
|
317
317
|
"types": "./migrator.d.ts",
|
|
318
318
|
"default": "./migrator.js"
|
|
319
319
|
},
|
|
320
|
+
"./monodriver": {
|
|
321
|
+
"import": {
|
|
322
|
+
"types": "./monodriver.d.ts",
|
|
323
|
+
"default": "./monodriver.js"
|
|
324
|
+
},
|
|
325
|
+
"require": {
|
|
326
|
+
"types": "./monodriver.d.cts",
|
|
327
|
+
"default": "./monodriver.cjs"
|
|
328
|
+
},
|
|
329
|
+
"types": "./monodriver.d.ts",
|
|
330
|
+
"default": "./monodriver.js"
|
|
331
|
+
},
|
|
320
332
|
"./operations": {
|
|
321
333
|
"import": {
|
|
322
334
|
"types": "./operations.d.ts",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/// <reference types="bun-types" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
3
|
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
|
|
4
4
|
import type { ColumnBaseConfig } from "../../column.cjs";
|
|
5
5
|
import { entityKind } from "../../entity.cjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
/// <reference types="bun-types" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
3
|
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
|
|
4
4
|
import type { ColumnBaseConfig } from "../../column.js";
|
|
5
5
|
import { entityKind } from "../../entity.js";
|
package/version.cjs
CHANGED
package/version.d.cts
CHANGED
package/version.d.ts
CHANGED
package/version.js
CHANGED