Initial commit
This commit is contained in:
92
node_modules/drizzle-orm/bun-sqlite/driver.cjs
generated
vendored
Normal file
92
node_modules/drizzle-orm/bun-sqlite/driver.cjs
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var driver_exports = {};
|
||||
__export(driver_exports, {
|
||||
BunSQLiteDatabase: () => BunSQLiteDatabase,
|
||||
drizzle: () => drizzle
|
||||
});
|
||||
module.exports = __toCommonJS(driver_exports);
|
||||
var import_bun_sqlite = require("bun:sqlite");
|
||||
var import_entity = require("../entity.cjs");
|
||||
var import_logger = require("../logger.cjs");
|
||||
var import_relations = require("../relations.cjs");
|
||||
var import_db = require("../sqlite-core/db.cjs");
|
||||
var import_dialect = require("../sqlite-core/dialect.cjs");
|
||||
var import_utils = require("../utils.cjs");
|
||||
var import_session = require("./session.cjs");
|
||||
class BunSQLiteDatabase extends import_db.BaseSQLiteDatabase {
|
||||
static [import_entity.entityKind] = "BunSQLiteDatabase";
|
||||
}
|
||||
function construct(client, config = {}) {
|
||||
const dialect = new import_dialect.SQLiteSyncDialect({ casing: config.casing });
|
||||
let logger;
|
||||
if (config.logger === true) {
|
||||
logger = new import_logger.DefaultLogger();
|
||||
} else if (config.logger !== false) {
|
||||
logger = config.logger;
|
||||
}
|
||||
let schema;
|
||||
if (config.schema) {
|
||||
const tablesConfig = (0, import_relations.extractTablesRelationalConfig)(
|
||||
config.schema,
|
||||
import_relations.createTableRelationsHelpers
|
||||
);
|
||||
schema = {
|
||||
fullSchema: config.schema,
|
||||
schema: tablesConfig.tables,
|
||||
tableNamesMap: tablesConfig.tableNamesMap
|
||||
};
|
||||
}
|
||||
const session = new import_session.SQLiteBunSession(client, dialect, schema, { logger });
|
||||
const db = new BunSQLiteDatabase("sync", dialect, session, schema);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
function drizzle(...params) {
|
||||
if (params[0] === void 0 || typeof params[0] === "string") {
|
||||
const instance = params[0] === void 0 ? new import_bun_sqlite.Database() : new import_bun_sqlite.Database(params[0]);
|
||||
return construct(instance, params[1]);
|
||||
}
|
||||
if ((0, import_utils.isConfig)(params[0])) {
|
||||
const { connection, client, ...drizzleConfig } = params[0];
|
||||
if (client)
|
||||
return construct(client, drizzleConfig);
|
||||
if (typeof connection === "object") {
|
||||
const { source, ...opts } = connection;
|
||||
const options = Object.values(opts).filter((v) => v !== void 0).length ? opts : void 0;
|
||||
const instance2 = new import_bun_sqlite.Database(source, options);
|
||||
return construct(instance2, drizzleConfig);
|
||||
}
|
||||
const instance = new import_bun_sqlite.Database(connection);
|
||||
return construct(instance, drizzleConfig);
|
||||
}
|
||||
return construct(params[0], params[1]);
|
||||
}
|
||||
((drizzle2) => {
|
||||
function mock(config) {
|
||||
return construct({}, config);
|
||||
}
|
||||
drizzle2.mock = mock;
|
||||
})(drizzle || (drizzle = {}));
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
BunSQLiteDatabase,
|
||||
drizzle
|
||||
});
|
||||
//# sourceMappingURL=driver.cjs.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/driver.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/driver.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
50
node_modules/drizzle-orm/bun-sqlite/driver.d.cts
generated
vendored
Normal file
50
node_modules/drizzle-orm/bun-sqlite/driver.d.cts
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import { Database } from 'bun:sqlite';
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import { BaseSQLiteDatabase } from "../sqlite-core/db.cjs";
|
||||
import { type DrizzleConfig } from "../utils.cjs";
|
||||
export declare class BunSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', void, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
type DrizzleBunSqliteDatabaseOptions = {
|
||||
/**
|
||||
* Open the database as read-only (no write operations, no create).
|
||||
*
|
||||
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
||||
*/
|
||||
readonly?: boolean;
|
||||
/**
|
||||
* Allow creating a new database
|
||||
*
|
||||
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
||||
*/
|
||||
create?: boolean;
|
||||
/**
|
||||
* Open the database as read-write
|
||||
*
|
||||
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
||||
*/
|
||||
readwrite?: boolean;
|
||||
};
|
||||
export type DrizzleBunSqliteDatabaseConfig = ({
|
||||
source?: string;
|
||||
} & DrizzleBunSqliteDatabaseOptions) | string | undefined;
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Database = Database>(...params: [] | [
|
||||
TClient | string
|
||||
] | [
|
||||
TClient | string,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
connection?: DrizzleBunSqliteDatabaseConfig;
|
||||
} | {
|
||||
client: TClient;
|
||||
}))
|
||||
]): BunSQLiteDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): BunSQLiteDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
export {};
|
||||
50
node_modules/drizzle-orm/bun-sqlite/driver.d.ts
generated
vendored
Normal file
50
node_modules/drizzle-orm/bun-sqlite/driver.d.ts
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import { Database } from 'bun:sqlite';
|
||||
import { entityKind } from "../entity.js";
|
||||
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
|
||||
import { type DrizzleConfig } from "../utils.js";
|
||||
export declare class BunSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', void, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
type DrizzleBunSqliteDatabaseOptions = {
|
||||
/**
|
||||
* Open the database as read-only (no write operations, no create).
|
||||
*
|
||||
* Equivalent to {@link constants.SQLITE_OPEN_READONLY}
|
||||
*/
|
||||
readonly?: boolean;
|
||||
/**
|
||||
* Allow creating a new database
|
||||
*
|
||||
* Equivalent to {@link constants.SQLITE_OPEN_CREATE}
|
||||
*/
|
||||
create?: boolean;
|
||||
/**
|
||||
* Open the database as read-write
|
||||
*
|
||||
* Equivalent to {@link constants.SQLITE_OPEN_READWRITE}
|
||||
*/
|
||||
readwrite?: boolean;
|
||||
};
|
||||
export type DrizzleBunSqliteDatabaseConfig = ({
|
||||
source?: string;
|
||||
} & DrizzleBunSqliteDatabaseOptions) | string | undefined;
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends Database = Database>(...params: [] | [
|
||||
TClient | string
|
||||
] | [
|
||||
TClient | string,
|
||||
DrizzleConfig<TSchema>
|
||||
] | [
|
||||
(DrizzleConfig<TSchema> & ({
|
||||
connection?: DrizzleBunSqliteDatabaseConfig;
|
||||
} | {
|
||||
client: TClient;
|
||||
}))
|
||||
]): BunSQLiteDatabase<TSchema> & {
|
||||
$client: TClient;
|
||||
};
|
||||
export declare namespace drizzle {
|
||||
function mock<TSchema extends Record<string, unknown> = Record<string, never>>(config?: DrizzleConfig<TSchema>): BunSQLiteDatabase<TSchema> & {
|
||||
$client: '$client is not available on drizzle.mock()';
|
||||
};
|
||||
}
|
||||
export {};
|
||||
70
node_modules/drizzle-orm/bun-sqlite/driver.js
generated
vendored
Normal file
70
node_modules/drizzle-orm/bun-sqlite/driver.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
import { Database } from "bun:sqlite";
|
||||
import { entityKind } from "../entity.js";
|
||||
import { DefaultLogger } from "../logger.js";
|
||||
import {
|
||||
createTableRelationsHelpers,
|
||||
extractTablesRelationalConfig
|
||||
} from "../relations.js";
|
||||
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
|
||||
import { SQLiteSyncDialect } from "../sqlite-core/dialect.js";
|
||||
import { isConfig } from "../utils.js";
|
||||
import { SQLiteBunSession } from "./session.js";
|
||||
class BunSQLiteDatabase extends BaseSQLiteDatabase {
|
||||
static [entityKind] = "BunSQLiteDatabase";
|
||||
}
|
||||
function construct(client, config = {}) {
|
||||
const dialect = new SQLiteSyncDialect({ casing: config.casing });
|
||||
let logger;
|
||||
if (config.logger === true) {
|
||||
logger = new DefaultLogger();
|
||||
} else if (config.logger !== false) {
|
||||
logger = config.logger;
|
||||
}
|
||||
let schema;
|
||||
if (config.schema) {
|
||||
const tablesConfig = extractTablesRelationalConfig(
|
||||
config.schema,
|
||||
createTableRelationsHelpers
|
||||
);
|
||||
schema = {
|
||||
fullSchema: config.schema,
|
||||
schema: tablesConfig.tables,
|
||||
tableNamesMap: tablesConfig.tableNamesMap
|
||||
};
|
||||
}
|
||||
const session = new SQLiteBunSession(client, dialect, schema, { logger });
|
||||
const db = new BunSQLiteDatabase("sync", dialect, session, schema);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
function drizzle(...params) {
|
||||
if (params[0] === void 0 || typeof params[0] === "string") {
|
||||
const instance = params[0] === void 0 ? new Database() : new Database(params[0]);
|
||||
return construct(instance, params[1]);
|
||||
}
|
||||
if (isConfig(params[0])) {
|
||||
const { connection, client, ...drizzleConfig } = params[0];
|
||||
if (client)
|
||||
return construct(client, drizzleConfig);
|
||||
if (typeof connection === "object") {
|
||||
const { source, ...opts } = connection;
|
||||
const options = Object.values(opts).filter((v) => v !== void 0).length ? opts : void 0;
|
||||
const instance2 = new Database(source, options);
|
||||
return construct(instance2, drizzleConfig);
|
||||
}
|
||||
const instance = new Database(connection);
|
||||
return construct(instance, drizzleConfig);
|
||||
}
|
||||
return construct(params[0], params[1]);
|
||||
}
|
||||
((drizzle2) => {
|
||||
function mock(config) {
|
||||
return construct({}, config);
|
||||
}
|
||||
drizzle2.mock = mock;
|
||||
})(drizzle || (drizzle = {}));
|
||||
export {
|
||||
BunSQLiteDatabase,
|
||||
drizzle
|
||||
};
|
||||
//# sourceMappingURL=driver.js.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/driver.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/driver.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
25
node_modules/drizzle-orm/bun-sqlite/index.cjs
generated
vendored
Normal file
25
node_modules/drizzle-orm/bun-sqlite/index.cjs
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var bun_sqlite_exports = {};
|
||||
module.exports = __toCommonJS(bun_sqlite_exports);
|
||||
__reExport(bun_sqlite_exports, require("./driver.cjs"), module.exports);
|
||||
__reExport(bun_sqlite_exports, require("./session.cjs"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("./driver.cjs"),
|
||||
...require("./session.cjs")
|
||||
});
|
||||
//# sourceMappingURL=index.cjs.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/index.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/index.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/bun-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAc,wBAAd;AACA,+BAAc,yBADd;","names":[]}
|
||||
2
node_modules/drizzle-orm/bun-sqlite/index.d.cts
generated
vendored
Normal file
2
node_modules/drizzle-orm/bun-sqlite/index.d.cts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./driver.cjs";
|
||||
export * from "./session.cjs";
|
||||
2
node_modules/drizzle-orm/bun-sqlite/index.d.ts
generated
vendored
Normal file
2
node_modules/drizzle-orm/bun-sqlite/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
export * from "./driver.js";
|
||||
export * from "./session.js";
|
||||
3
node_modules/drizzle-orm/bun-sqlite/index.js
generated
vendored
Normal file
3
node_modules/drizzle-orm/bun-sqlite/index.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export * from "./driver.js";
|
||||
export * from "./session.js";
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/index.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/bun-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
||||
33
node_modules/drizzle-orm/bun-sqlite/migrator.cjs
generated
vendored
Normal file
33
node_modules/drizzle-orm/bun-sqlite/migrator.cjs
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var migrator_exports = {};
|
||||
__export(migrator_exports, {
|
||||
migrate: () => migrate
|
||||
});
|
||||
module.exports = __toCommonJS(migrator_exports);
|
||||
var import_migrator = require("../migrator.cjs");
|
||||
function migrate(db, config) {
|
||||
const migrations = (0, import_migrator.readMigrationFiles)(config);
|
||||
db.dialect.migrate(migrations, db.session, config);
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
migrate
|
||||
});
|
||||
//# sourceMappingURL=migrator.cjs.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/migrator.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/migrator.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/bun-sqlite/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { BunSQLiteDatabase } from './driver.ts';\n\nexport function migrate<TSchema extends Record<string, unknown>>(\n\tdb: BunSQLiteDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tdb.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAG5B,SAAS,QACf,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAC5C,KAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AAClD;","names":[]}
|
||||
3
node_modules/drizzle-orm/bun-sqlite/migrator.d.cts
generated
vendored
Normal file
3
node_modules/drizzle-orm/bun-sqlite/migrator.d.cts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import type { MigrationConfig } from "../migrator.cjs";
|
||||
import type { BunSQLiteDatabase } from "./driver.cjs";
|
||||
export declare function migrate<TSchema extends Record<string, unknown>>(db: BunSQLiteDatabase<TSchema>, config: MigrationConfig): void;
|
||||
3
node_modules/drizzle-orm/bun-sqlite/migrator.d.ts
generated
vendored
Normal file
3
node_modules/drizzle-orm/bun-sqlite/migrator.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import type { MigrationConfig } from "../migrator.js";
|
||||
import type { BunSQLiteDatabase } from "./driver.js";
|
||||
export declare function migrate<TSchema extends Record<string, unknown>>(db: BunSQLiteDatabase<TSchema>, config: MigrationConfig): void;
|
||||
9
node_modules/drizzle-orm/bun-sqlite/migrator.js
generated
vendored
Normal file
9
node_modules/drizzle-orm/bun-sqlite/migrator.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
import { readMigrationFiles } from "../migrator.js";
|
||||
function migrate(db, config) {
|
||||
const migrations = readMigrationFiles(config);
|
||||
db.dialect.migrate(migrations, db.session, config);
|
||||
}
|
||||
export {
|
||||
migrate
|
||||
};
|
||||
//# sourceMappingURL=migrator.js.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/migrator.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/migrator.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/bun-sqlite/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { BunSQLiteDatabase } from './driver.ts';\n\nexport function migrate<TSchema extends Record<string, unknown>>(\n\tdb: BunSQLiteDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tdb.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AAG5B,SAAS,QACf,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAC5C,KAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AAClD;","names":[]}
|
||||
142
node_modules/drizzle-orm/bun-sqlite/session.cjs
generated
vendored
Normal file
142
node_modules/drizzle-orm/bun-sqlite/session.cjs
generated
vendored
Normal file
@ -0,0 +1,142 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var session_exports = {};
|
||||
__export(session_exports, {
|
||||
PreparedQuery: () => PreparedQuery,
|
||||
SQLiteBunSession: () => SQLiteBunSession,
|
||||
SQLiteBunTransaction: () => SQLiteBunTransaction
|
||||
});
|
||||
module.exports = __toCommonJS(session_exports);
|
||||
var import_entity = require("../entity.cjs");
|
||||
var import_logger = require("../logger.cjs");
|
||||
var import_sql = require("../sql/sql.cjs");
|
||||
var import_sqlite_core = require("../sqlite-core/index.cjs");
|
||||
var import_session = require("../sqlite-core/session.cjs");
|
||||
var import_utils = require("../utils.cjs");
|
||||
class SQLiteBunSession extends import_session.SQLiteSession {
|
||||
constructor(client, dialect, schema, options = {}) {
|
||||
super(dialect);
|
||||
this.client = client;
|
||||
this.schema = schema;
|
||||
this.logger = options.logger ?? new import_logger.NoopLogger();
|
||||
}
|
||||
static [import_entity.entityKind] = "SQLiteBunSession";
|
||||
logger;
|
||||
exec(query) {
|
||||
this.client.exec(query);
|
||||
}
|
||||
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
||||
const stmt = this.client.prepare(query.sql);
|
||||
return new PreparedQuery(
|
||||
stmt,
|
||||
query,
|
||||
this.logger,
|
||||
fields,
|
||||
executeMethod,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
transaction(transaction, config = {}) {
|
||||
const tx = new SQLiteBunTransaction("sync", this.dialect, this, this.schema);
|
||||
let result;
|
||||
const nativeTx = this.client.transaction(() => {
|
||||
result = transaction(tx);
|
||||
});
|
||||
nativeTx[config.behavior ?? "deferred"]();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
class SQLiteBunTransaction extends import_sqlite_core.SQLiteTransaction {
|
||||
static [import_entity.entityKind] = "SQLiteBunTransaction";
|
||||
transaction(transaction) {
|
||||
const savepointName = `sp${this.nestedIndex}`;
|
||||
const tx = new SQLiteBunTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
||||
this.session.run(import_sql.sql.raw(`savepoint ${savepointName}`));
|
||||
try {
|
||||
const result = transaction(tx);
|
||||
this.session.run(import_sql.sql.raw(`release savepoint ${savepointName}`));
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.session.run(import_sql.sql.raw(`rollback to savepoint ${savepointName}`));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
class PreparedQuery extends import_session.SQLitePreparedQuery {
|
||||
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
||||
super("sync", executeMethod, query);
|
||||
this.stmt = stmt;
|
||||
this.logger = logger;
|
||||
this.fields = fields;
|
||||
this._isResponseInArrayMode = _isResponseInArrayMode;
|
||||
this.customResultMapper = customResultMapper;
|
||||
}
|
||||
static [import_entity.entityKind] = "SQLiteBunPreparedQuery";
|
||||
run(placeholderValues) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.stmt.run(...params);
|
||||
}
|
||||
all(placeholderValues) {
|
||||
const { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
|
||||
logger.logQuery(query.sql, params);
|
||||
return stmt.all(...params);
|
||||
}
|
||||
const rows = this.values(placeholderValues);
|
||||
if (customResultMapper) {
|
||||
return customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
||||
}
|
||||
get(placeholderValues) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
const row = this.stmt.values(...params)[0];
|
||||
if (!row) {
|
||||
return void 0;
|
||||
}
|
||||
const { fields, joinsNotNullableMap, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
return row;
|
||||
}
|
||||
if (customResultMapper) {
|
||||
return customResultMapper([row]);
|
||||
}
|
||||
return (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap);
|
||||
}
|
||||
values(placeholderValues) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.stmt.values(...params);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
PreparedQuery,
|
||||
SQLiteBunSession,
|
||||
SQLiteBunTransaction
|
||||
});
|
||||
//# sourceMappingURL=session.cjs.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/session.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/session.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
50
node_modules/drizzle-orm/bun-sqlite/session.d.cts
generated
vendored
Normal file
50
node_modules/drizzle-orm/bun-sqlite/session.d.cts
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import type { Database, Statement as BunStatement } from 'bun:sqlite';
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import type { Logger } from "../logger.cjs";
|
||||
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
||||
import { type Query } from "../sql/sql.cjs";
|
||||
import type { SQLiteSyncDialect } from "../sqlite-core/dialect.cjs";
|
||||
import { SQLiteTransaction } from "../sqlite-core/index.cjs";
|
||||
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.cjs";
|
||||
import type { PreparedQueryConfig as PreparedQueryConfigBase, SQLiteExecuteMethod, SQLiteTransactionConfig } from "../sqlite-core/session.cjs";
|
||||
import { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from "../sqlite-core/session.cjs";
|
||||
export interface SQLiteBunSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
|
||||
type Statement = BunStatement<any>;
|
||||
export declare class SQLiteBunSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', void, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: Database, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLiteBunSessionOptions);
|
||||
exec(query: string): void;
|
||||
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): PreparedQuery<T>;
|
||||
transaction<T>(transaction: (tx: SQLiteBunTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
|
||||
}
|
||||
export declare class SQLiteBunTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', void, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(transaction: (tx: SQLiteBunTransaction<TFullSchema, TSchema>) => T): T;
|
||||
}
|
||||
export declare class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
|
||||
type: 'sync';
|
||||
run: void;
|
||||
all: T['all'];
|
||||
get: T['get'];
|
||||
values: T['values'];
|
||||
execute: T['execute'];
|
||||
}> {
|
||||
private stmt;
|
||||
private logger;
|
||||
private fields;
|
||||
private _isResponseInArrayMode;
|
||||
private customResultMapper?;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(stmt: Statement, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => unknown) | undefined);
|
||||
run(placeholderValues?: Record<string, unknown>): void;
|
||||
all(placeholderValues?: Record<string, unknown>): T['all'];
|
||||
get(placeholderValues?: Record<string, unknown>): T['get'];
|
||||
values(placeholderValues?: Record<string, unknown>): T['values'];
|
||||
}
|
||||
export {};
|
||||
50
node_modules/drizzle-orm/bun-sqlite/session.d.ts
generated
vendored
Normal file
50
node_modules/drizzle-orm/bun-sqlite/session.d.ts
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
import type { Database, Statement as BunStatement } from 'bun:sqlite';
|
||||
import { entityKind } from "../entity.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
||||
import { type Query } from "../sql/sql.js";
|
||||
import type { SQLiteSyncDialect } from "../sqlite-core/dialect.js";
|
||||
import { SQLiteTransaction } from "../sqlite-core/index.js";
|
||||
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.js";
|
||||
import type { PreparedQueryConfig as PreparedQueryConfigBase, SQLiteExecuteMethod, SQLiteTransactionConfig } from "../sqlite-core/session.js";
|
||||
import { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from "../sqlite-core/session.js";
|
||||
export interface SQLiteBunSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
|
||||
type Statement = BunStatement<any>;
|
||||
export declare class SQLiteBunSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', void, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: Database, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLiteBunSessionOptions);
|
||||
exec(query: string): void;
|
||||
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): PreparedQuery<T>;
|
||||
transaction<T>(transaction: (tx: SQLiteBunTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
|
||||
}
|
||||
export declare class SQLiteBunTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', void, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(transaction: (tx: SQLiteBunTransaction<TFullSchema, TSchema>) => T): T;
|
||||
}
|
||||
export declare class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
|
||||
type: 'sync';
|
||||
run: void;
|
||||
all: T['all'];
|
||||
get: T['get'];
|
||||
values: T['values'];
|
||||
execute: T['execute'];
|
||||
}> {
|
||||
private stmt;
|
||||
private logger;
|
||||
private fields;
|
||||
private _isResponseInArrayMode;
|
||||
private customResultMapper?;
|
||||
static readonly [entityKind]: string;
|
||||
constructor(stmt: Statement, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => unknown) | undefined);
|
||||
run(placeholderValues?: Record<string, unknown>): void;
|
||||
all(placeholderValues?: Record<string, unknown>): T['all'];
|
||||
get(placeholderValues?: Record<string, unknown>): T['get'];
|
||||
values(placeholderValues?: Record<string, unknown>): T['values'];
|
||||
}
|
||||
export {};
|
||||
116
node_modules/drizzle-orm/bun-sqlite/session.js
generated
vendored
Normal file
116
node_modules/drizzle-orm/bun-sqlite/session.js
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
import { entityKind } from "../entity.js";
|
||||
import { NoopLogger } from "../logger.js";
|
||||
import { fillPlaceholders, sql } from "../sql/sql.js";
|
||||
import { SQLiteTransaction } from "../sqlite-core/index.js";
|
||||
import { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from "../sqlite-core/session.js";
|
||||
import { mapResultRow } from "../utils.js";
|
||||
class SQLiteBunSession extends SQLiteSession {
|
||||
constructor(client, dialect, schema, options = {}) {
|
||||
super(dialect);
|
||||
this.client = client;
|
||||
this.schema = schema;
|
||||
this.logger = options.logger ?? new NoopLogger();
|
||||
}
|
||||
static [entityKind] = "SQLiteBunSession";
|
||||
logger;
|
||||
exec(query) {
|
||||
this.client.exec(query);
|
||||
}
|
||||
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
||||
const stmt = this.client.prepare(query.sql);
|
||||
return new PreparedQuery(
|
||||
stmt,
|
||||
query,
|
||||
this.logger,
|
||||
fields,
|
||||
executeMethod,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
transaction(transaction, config = {}) {
|
||||
const tx = new SQLiteBunTransaction("sync", this.dialect, this, this.schema);
|
||||
let result;
|
||||
const nativeTx = this.client.transaction(() => {
|
||||
result = transaction(tx);
|
||||
});
|
||||
nativeTx[config.behavior ?? "deferred"]();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
class SQLiteBunTransaction extends SQLiteTransaction {
|
||||
static [entityKind] = "SQLiteBunTransaction";
|
||||
transaction(transaction) {
|
||||
const savepointName = `sp${this.nestedIndex}`;
|
||||
const tx = new SQLiteBunTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
|
||||
this.session.run(sql.raw(`savepoint ${savepointName}`));
|
||||
try {
|
||||
const result = transaction(tx);
|
||||
this.session.run(sql.raw(`release savepoint ${savepointName}`));
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.session.run(sql.raw(`rollback to savepoint ${savepointName}`));
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
class PreparedQuery extends PreparedQueryBase {
|
||||
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
|
||||
super("sync", executeMethod, query);
|
||||
this.stmt = stmt;
|
||||
this.logger = logger;
|
||||
this.fields = fields;
|
||||
this._isResponseInArrayMode = _isResponseInArrayMode;
|
||||
this.customResultMapper = customResultMapper;
|
||||
}
|
||||
static [entityKind] = "SQLiteBunPreparedQuery";
|
||||
run(placeholderValues) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.stmt.run(...params);
|
||||
}
|
||||
all(placeholderValues) {
|
||||
const { fields, query, logger, joinsNotNullableMap, stmt, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
||||
logger.logQuery(query.sql, params);
|
||||
return stmt.all(...params);
|
||||
}
|
||||
const rows = this.values(placeholderValues);
|
||||
if (customResultMapper) {
|
||||
return customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
||||
}
|
||||
get(placeholderValues) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
const row = this.stmt.values(...params)[0];
|
||||
if (!row) {
|
||||
return void 0;
|
||||
}
|
||||
const { fields, joinsNotNullableMap, customResultMapper } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
return row;
|
||||
}
|
||||
if (customResultMapper) {
|
||||
return customResultMapper([row]);
|
||||
}
|
||||
return mapResultRow(fields, row, joinsNotNullableMap);
|
||||
}
|
||||
values(placeholderValues) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.stmt.values(...params);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
export {
|
||||
PreparedQuery,
|
||||
SQLiteBunSession,
|
||||
SQLiteBunTransaction
|
||||
};
|
||||
//# sourceMappingURL=session.js.map
|
||||
1
node_modules/drizzle-orm/bun-sqlite/session.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/bun-sqlite/session.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user