Initial commit

This commit is contained in:
Ammaar Reshi
2025-01-04 14:06:53 +00:00
parent 7082408604
commit d6025af146
23760 changed files with 3299690 additions and 0 deletions

64
node_modules/drizzle-orm/durable-sqlite/driver.cjs generated vendored Normal file
View File

@ -0,0 +1,64 @@
"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, {
DrizzleSqliteDODatabase: () => DrizzleSqliteDODatabase,
drizzle: () => drizzle
});
module.exports = __toCommonJS(driver_exports);
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_session = require("./session.cjs");
class DrizzleSqliteDODatabase extends import_db.BaseSQLiteDatabase {
static [import_entity.entityKind] = "DrizzleSqliteDODatabase";
}
function drizzle(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.SQLiteDOSession(client, dialect, schema, { logger });
const db = new DrizzleSqliteDODatabase("sync", dialect, session, schema);
db.$client = client;
return db;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DrizzleSqliteDODatabase,
drizzle
});
//# sourceMappingURL=driver.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/durable-sqlite/driver.ts"],"sourcesContent":["/// <reference types=\"@cloudflare/workers-types\" />\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype ExtractTablesWithRelations,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { SQLiteDOSession } from './session.ts';\n\nexport class DrizzleSqliteDODatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends BaseSQLiteDatabase<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TSchema> {\n\tstatic override readonly [entityKind]: string = 'DrizzleSqliteDODatabase';\n\n\t/** @internal */\n\tdeclare readonly session: SQLiteDOSession<TSchema, ExtractTablesWithRelations<TSchema>>;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends DurableObjectStorage = DurableObjectStorage,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): DrizzleSqliteDODatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tconst dialect = new SQLiteSyncDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new SQLiteDOSession(client as DurableObjectStorage, dialect, schema, { logger });\n\tconst db = new DrizzleSqliteDODatabase('sync', dialect, session, schema) as DrizzleSqliteDODatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA2B;AAC3B,oBAA8B;AAC9B,uBAMO;AACP,gBAAmC;AACnC,qBAAkC;AAElC,qBAAgC;AAEzB,MAAM,gCAEH,6BAAuF;AAAA,EAChG,QAA0B,wBAAU,IAAY;AAIjD;AAEO,SAAS,QAIf,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,iCAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC/D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,4BAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,mBAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,+BAAgB,QAAgC,SAAS,QAAQ,EAAE,OAAO,CAAC;AAC/F,QAAM,KAAK,IAAI,wBAAwB,QAAQ,SAAS,SAAS,MAAM;AACvE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;","names":[]}

9
node_modules/drizzle-orm/durable-sqlite/driver.d.cts generated vendored Normal file
View File

@ -0,0 +1,9 @@
import { entityKind } from "../entity.cjs";
import { BaseSQLiteDatabase } from "../sqlite-core/db.cjs";
import type { DrizzleConfig } from "../utils.cjs";
export declare class DrizzleSqliteDODatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends DurableObjectStorage = DurableObjectStorage>(client: TClient, config?: DrizzleConfig<TSchema>): DrizzleSqliteDODatabase<TSchema> & {
$client: TClient;
};

9
node_modules/drizzle-orm/durable-sqlite/driver.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
import { entityKind } from "../entity.js";
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
import type { DrizzleConfig } from "../utils.js";
export declare class DrizzleSqliteDODatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TSchema> {
static readonly [entityKind]: string;
}
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>, TClient extends DurableObjectStorage = DurableObjectStorage>(client: TClient, config?: DrizzleConfig<TSchema>): DrizzleSqliteDODatabase<TSchema> & {
$client: TClient;
};

42
node_modules/drizzle-orm/durable-sqlite/driver.js generated vendored Normal file
View File

@ -0,0 +1,42 @@
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 { SQLiteDOSession } from "./session.js";
class DrizzleSqliteDODatabase extends BaseSQLiteDatabase {
static [entityKind] = "DrizzleSqliteDODatabase";
}
function drizzle(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 SQLiteDOSession(client, dialect, schema, { logger });
const db = new DrizzleSqliteDODatabase("sync", dialect, session, schema);
db.$client = client;
return db;
}
export {
DrizzleSqliteDODatabase,
drizzle
};
//# sourceMappingURL=driver.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/durable-sqlite/driver.ts"],"sourcesContent":["/// <reference types=\"@cloudflare/workers-types\" />\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype ExtractTablesWithRelations,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { SQLiteDOSession } from './session.ts';\n\nexport class DrizzleSqliteDODatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends BaseSQLiteDatabase<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TSchema> {\n\tstatic override readonly [entityKind]: string = 'DrizzleSqliteDODatabase';\n\n\t/** @internal */\n\tdeclare readonly session: SQLiteDOSession<TSchema, ExtractTablesWithRelations<TSchema>>;\n}\n\nexport function drizzle<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n\tTClient extends DurableObjectStorage = DurableObjectStorage,\n>(\n\tclient: TClient,\n\tconfig: DrizzleConfig<TSchema> = {},\n): DrizzleSqliteDODatabase<TSchema> & {\n\t$client: TClient;\n} {\n\tconst dialect = new SQLiteSyncDialect({ casing: config.casing });\n\tlet logger;\n\tif (config.logger === true) {\n\t\tlogger = new DefaultLogger();\n\t} else if (config.logger !== false) {\n\t\tlogger = config.logger;\n\t}\n\n\tlet schema: RelationalSchemaConfig<TablesRelationalConfig> | undefined;\n\tif (config.schema) {\n\t\tconst tablesConfig = extractTablesRelationalConfig(\n\t\t\tconfig.schema,\n\t\t\tcreateTableRelationsHelpers,\n\t\t);\n\t\tschema = {\n\t\t\tfullSchema: config.schema,\n\t\t\tschema: tablesConfig.tables,\n\t\t\ttableNamesMap: tablesConfig.tableNamesMap,\n\t\t};\n\t}\n\n\tconst session = new SQLiteDOSession(client as DurableObjectStorage, dialect, schema, { logger });\n\tconst db = new DrizzleSqliteDODatabase('sync', dialect, session, schema) as DrizzleSqliteDODatabase<TSchema>;\n\t(<any> db).$client = client;\n\n\treturn db as any;\n}\n"],"mappings":"AACA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,OAIM;AACP,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAElC,SAAS,uBAAuB;AAEzB,MAAM,gCAEH,mBAAuF;AAAA,EAChG,QAA0B,UAAU,IAAY;AAIjD;AAEO,SAAS,QAIf,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,kBAAkB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAC/D,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM;AAC3B,aAAS,IAAI,cAAc;AAAA,EAC5B,WAAW,OAAO,WAAW,OAAO;AACnC,aAAS,OAAO;AAAA,EACjB;AAEA,MAAI;AACJ,MAAI,OAAO,QAAQ;AAClB,UAAM,eAAe;AAAA,MACpB,OAAO;AAAA,MACP;AAAA,IACD;AACA,aAAS;AAAA,MACR,YAAY,OAAO;AAAA,MACnB,QAAQ,aAAa;AAAA,MACrB,eAAe,aAAa;AAAA,IAC7B;AAAA,EACD;AAEA,QAAM,UAAU,IAAI,gBAAgB,QAAgC,SAAS,QAAQ,EAAE,OAAO,CAAC;AAC/F,QAAM,KAAK,IAAI,wBAAwB,QAAQ,SAAS,SAAS,MAAM;AACvE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;","names":[]}

25
node_modules/drizzle-orm/durable-sqlite/index.cjs generated vendored Normal file
View 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 durable_sqlite_exports = {};
module.exports = __toCommonJS(durable_sqlite_exports);
__reExport(durable_sqlite_exports, require("./driver.cjs"), module.exports);
__reExport(durable_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

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/durable-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,mCAAc,wBAAd;AACA,mCAAc,yBADd;","names":[]}

2
node_modules/drizzle-orm/durable-sqlite/index.d.cts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export * from "./driver.cjs";
export * from "./session.cjs";

2
node_modules/drizzle-orm/durable-sqlite/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
export * from "./driver.js";
export * from "./session.js";

3
node_modules/drizzle-orm/durable-sqlite/index.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
export * from "./driver.js";
export * from "./session.js";
//# sourceMappingURL=index.js.map

1
node_modules/drizzle-orm/durable-sqlite/index.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/durable-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}

85
node_modules/drizzle-orm/durable-sqlite/migrator.cjs generated vendored Normal file
View File

@ -0,0 +1,85 @@
"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_sql = require("../sql/index.cjs");
function readMigrationFiles({ journal, migrations }) {
const migrationQueries = [];
for (const journalEntry of journal.entries) {
const query = migrations[`m${journalEntry.idx.toString().padStart(4, "0")}`];
if (!query) {
throw new Error(`Missing migration: ${journalEntry.tag}`);
}
try {
const result = query.split("--> statement-breakpoint").map((it) => {
return it;
});
migrationQueries.push({
sql: result,
bps: journalEntry.breakpoints,
folderMillis: journalEntry.when,
hash: ""
});
} catch {
throw new Error(`Failed to parse migration: ${journalEntry.tag}`);
}
}
return migrationQueries;
}
async function migrate(db, config) {
const migrations = readMigrationFiles(config);
db.transaction((tx) => {
try {
const migrationsTable = "__drizzle_migrations";
const migrationTableCreate = import_sql.sql`
CREATE TABLE IF NOT EXISTS ${import_sql.sql.identifier(migrationsTable)} (
id SERIAL PRIMARY KEY,
hash text NOT NULL,
created_at numeric
)
`;
db.run(migrationTableCreate);
const dbMigrations = db.values(
import_sql.sql`SELECT id, hash, created_at FROM ${import_sql.sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
for (const stmt of migration.sql) {
db.run(import_sql.sql.raw(stmt));
}
db.run(
import_sql.sql`INSERT INTO ${import_sql.sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
);
}
}
} catch (error) {
tx.rollback();
throw error;
}
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
migrate
});
//# sourceMappingURL=migrator.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/durable-sqlite/migrator.ts"],"sourcesContent":["import type { MigrationMeta } from '~/migrator.ts';\nimport { sql } from '~/sql/index.ts';\nimport type { DrizzleSqliteDODatabase } from './driver.ts';\n\ninterface MigrationConfig {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}\n\nfunction readMigrationFiles({ journal, migrations }: MigrationConfig): MigrationMeta[] {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor (const journalEntry of journal.entries) {\n\t\tconst query = migrations[`m${journalEntry.idx.toString().padStart(4, '0')}`];\n\n\t\tif (!query) {\n\t\t\tthrow new Error(`Missing migration: ${journalEntry.tag}`);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = query.split('--> statement-breakpoint').map((it) => {\n\t\t\t\treturn it;\n\t\t\t});\n\n\t\t\tmigrationQueries.push({\n\t\t\t\tsql: result,\n\t\t\t\tbps: journalEntry.breakpoints,\n\t\t\t\tfolderMillis: journalEntry.when,\n\t\t\t\thash: '',\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new Error(`Failed to parse migration: ${journalEntry.tag}`);\n\t\t}\n\t}\n\n\treturn migrationQueries;\n}\n\nexport async function migrate<\n\tTSchema extends Record<string, unknown>,\n>(\n\tdb: DrizzleSqliteDODatabase<TSchema>,\n\tconfig: MigrationConfig,\n): Promise<void> {\n\tconst migrations = readMigrationFiles(config);\n\n\tdb.transaction((tx) => {\n\t\ttry {\n\t\t\tconst migrationsTable = '__drizzle_migrations';\n\n\t\t\tconst migrationTableCreate = sql`\n\t\t\t\tCREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsTable)} (\n\t\t\t\t\tid SERIAL PRIMARY KEY,\n\t\t\t\t\thash text NOT NULL,\n\t\t\t\t\tcreated_at numeric\n\t\t\t\t)\n\t\t\t`;\n\t\t\tdb.run(migrationTableCreate);\n\n\t\t\tconst dbMigrations = db.values<[number, string, string]>(\n\t\t\t\tsql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`,\n\t\t\t);\n\n\t\t\tconst lastDbMigration = dbMigrations[0] ?? undefined;\n\n\t\t\tfor (const migration of migrations) {\n\t\t\t\tif (!lastDbMigration || Number(lastDbMigration[2])! < migration.folderMillis) {\n\t\t\t\t\tfor (const stmt of migration.sql) {\n\t\t\t\t\t\tdb.run(sql.raw(stmt));\n\t\t\t\t\t}\n\t\t\t\t\tdb.run(\n\t\t\t\t\t\tsql`INSERT INTO ${\n\t\t\t\t\t\t\tsql.identifier(migrationsTable)\n\t\t\t\t\t\t} (\"hash\", \"created_at\") VALUES(${migration.hash}, ${migration.folderMillis})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error: any) {\n\t\t\ttx.rollback();\n\t\t\tthrow error;\n\t\t}\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,iBAAoB;AAUpB,SAAS,mBAAmB,EAAE,SAAS,WAAW,GAAqC;AACtF,QAAM,mBAAoC,CAAC;AAE3C,aAAW,gBAAgB,QAAQ,SAAS;AAC3C,UAAM,QAAQ,WAAW,IAAI,aAAa,IAAI,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE;AAE3E,QAAI,CAAC,OAAO;AACX,YAAM,IAAI,MAAM,sBAAsB,aAAa,GAAG,EAAE;AAAA,IACzD;AAEA,QAAI;AACH,YAAM,SAAS,MAAM,MAAM,0BAA0B,EAAE,IAAI,CAAC,OAAO;AAClE,eAAO;AAAA,MACR,CAAC;AAED,uBAAiB,KAAK;AAAA,QACrB,KAAK;AAAA,QACL,KAAK,aAAa;AAAA,QAClB,cAAc,aAAa;AAAA,QAC3B,MAAM;AAAA,MACP,CAAC;AAAA,IACF,QAAQ;AACP,YAAM,IAAI,MAAM,8BAA8B,aAAa,GAAG,EAAE;AAAA,IACjE;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,QAGrB,IACA,QACgB;AAChB,QAAM,aAAa,mBAAmB,MAAM;AAE5C,KAAG,YAAY,CAAC,OAAO;AACtB,QAAI;AACH,YAAM,kBAAkB;AAExB,YAAM,uBAAuB;AAAA,iCACC,eAAI,WAAW,eAAe,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAM7D,SAAG,IAAI,oBAAoB;AAE3B,YAAM,eAAe,GAAG;AAAA,QACvB,kDAAuC,eAAI,WAAW,eAAe,CAAC;AAAA,MACvE;AAEA,YAAM,kBAAkB,aAAa,CAAC,KAAK;AAE3C,iBAAW,aAAa,YAAY;AACnC,YAAI,CAAC,mBAAmB,OAAO,gBAAgB,CAAC,CAAC,IAAK,UAAU,cAAc;AAC7E,qBAAW,QAAQ,UAAU,KAAK;AACjC,eAAG,IAAI,eAAI,IAAI,IAAI,CAAC;AAAA,UACrB;AACA,aAAG;AAAA,YACF,6BACC,eAAI,WAAW,eAAe,CAC/B,kCAAkC,UAAU,IAAI,KAAK,UAAU,YAAY;AAAA,UAC5E;AAAA,QACD;AAAA,MACD;AAAA,IACD,SAAS,OAAY;AACpB,SAAG,SAAS;AACZ,YAAM;AAAA,IACP;AAAA,EACD,CAAC;AACF;","names":[]}

14
node_modules/drizzle-orm/durable-sqlite/migrator.d.cts generated vendored Normal file
View File

@ -0,0 +1,14 @@
import type { DrizzleSqliteDODatabase } from "./driver.cjs";
interface MigrationConfig {
journal: {
entries: {
idx: number;
when: number;
tag: string;
breakpoints: boolean;
}[];
};
migrations: Record<string, string>;
}
export declare function migrate<TSchema extends Record<string, unknown>>(db: DrizzleSqliteDODatabase<TSchema>, config: MigrationConfig): Promise<void>;
export {};

14
node_modules/drizzle-orm/durable-sqlite/migrator.d.ts generated vendored Normal file
View File

@ -0,0 +1,14 @@
import type { DrizzleSqliteDODatabase } from "./driver.js";
interface MigrationConfig {
journal: {
entries: {
idx: number;
when: number;
tag: string;
breakpoints: boolean;
}[];
};
migrations: Record<string, string>;
}
export declare function migrate<TSchema extends Record<string, unknown>>(db: DrizzleSqliteDODatabase<TSchema>, config: MigrationConfig): Promise<void>;
export {};

61
node_modules/drizzle-orm/durable-sqlite/migrator.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
import { sql } from "../sql/index.js";
function readMigrationFiles({ journal, migrations }) {
const migrationQueries = [];
for (const journalEntry of journal.entries) {
const query = migrations[`m${journalEntry.idx.toString().padStart(4, "0")}`];
if (!query) {
throw new Error(`Missing migration: ${journalEntry.tag}`);
}
try {
const result = query.split("--> statement-breakpoint").map((it) => {
return it;
});
migrationQueries.push({
sql: result,
bps: journalEntry.breakpoints,
folderMillis: journalEntry.when,
hash: ""
});
} catch {
throw new Error(`Failed to parse migration: ${journalEntry.tag}`);
}
}
return migrationQueries;
}
async function migrate(db, config) {
const migrations = readMigrationFiles(config);
db.transaction((tx) => {
try {
const migrationsTable = "__drizzle_migrations";
const migrationTableCreate = sql`
CREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsTable)} (
id SERIAL PRIMARY KEY,
hash text NOT NULL,
created_at numeric
)
`;
db.run(migrationTableCreate);
const dbMigrations = db.values(
sql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
for (const stmt of migration.sql) {
db.run(sql.raw(stmt));
}
db.run(
sql`INSERT INTO ${sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
);
}
}
} catch (error) {
tx.rollback();
throw error;
}
});
}
export {
migrate
};
//# sourceMappingURL=migrator.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/durable-sqlite/migrator.ts"],"sourcesContent":["import type { MigrationMeta } from '~/migrator.ts';\nimport { sql } from '~/sql/index.ts';\nimport type { DrizzleSqliteDODatabase } from './driver.ts';\n\ninterface MigrationConfig {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}\n\nfunction readMigrationFiles({ journal, migrations }: MigrationConfig): MigrationMeta[] {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor (const journalEntry of journal.entries) {\n\t\tconst query = migrations[`m${journalEntry.idx.toString().padStart(4, '0')}`];\n\n\t\tif (!query) {\n\t\t\tthrow new Error(`Missing migration: ${journalEntry.tag}`);\n\t\t}\n\n\t\ttry {\n\t\t\tconst result = query.split('--> statement-breakpoint').map((it) => {\n\t\t\t\treturn it;\n\t\t\t});\n\n\t\t\tmigrationQueries.push({\n\t\t\t\tsql: result,\n\t\t\t\tbps: journalEntry.breakpoints,\n\t\t\t\tfolderMillis: journalEntry.when,\n\t\t\t\thash: '',\n\t\t\t});\n\t\t} catch {\n\t\t\tthrow new Error(`Failed to parse migration: ${journalEntry.tag}`);\n\t\t}\n\t}\n\n\treturn migrationQueries;\n}\n\nexport async function migrate<\n\tTSchema extends Record<string, unknown>,\n>(\n\tdb: DrizzleSqliteDODatabase<TSchema>,\n\tconfig: MigrationConfig,\n): Promise<void> {\n\tconst migrations = readMigrationFiles(config);\n\n\tdb.transaction((tx) => {\n\t\ttry {\n\t\t\tconst migrationsTable = '__drizzle_migrations';\n\n\t\t\tconst migrationTableCreate = sql`\n\t\t\t\tCREATE TABLE IF NOT EXISTS ${sql.identifier(migrationsTable)} (\n\t\t\t\t\tid SERIAL PRIMARY KEY,\n\t\t\t\t\thash text NOT NULL,\n\t\t\t\t\tcreated_at numeric\n\t\t\t\t)\n\t\t\t`;\n\t\t\tdb.run(migrationTableCreate);\n\n\t\t\tconst dbMigrations = db.values<[number, string, string]>(\n\t\t\t\tsql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`,\n\t\t\t);\n\n\t\t\tconst lastDbMigration = dbMigrations[0] ?? undefined;\n\n\t\t\tfor (const migration of migrations) {\n\t\t\t\tif (!lastDbMigration || Number(lastDbMigration[2])! < migration.folderMillis) {\n\t\t\t\t\tfor (const stmt of migration.sql) {\n\t\t\t\t\t\tdb.run(sql.raw(stmt));\n\t\t\t\t\t}\n\t\t\t\t\tdb.run(\n\t\t\t\t\t\tsql`INSERT INTO ${\n\t\t\t\t\t\t\tsql.identifier(migrationsTable)\n\t\t\t\t\t\t} (\"hash\", \"created_at\") VALUES(${migration.hash}, ${migration.folderMillis})`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch (error: any) {\n\t\t\ttx.rollback();\n\t\t\tthrow error;\n\t\t}\n\t});\n}\n"],"mappings":"AACA,SAAS,WAAW;AAUpB,SAAS,mBAAmB,EAAE,SAAS,WAAW,GAAqC;AACtF,QAAM,mBAAoC,CAAC;AAE3C,aAAW,gBAAgB,QAAQ,SAAS;AAC3C,UAAM,QAAQ,WAAW,IAAI,aAAa,IAAI,SAAS,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE;AAE3E,QAAI,CAAC,OAAO;AACX,YAAM,IAAI,MAAM,sBAAsB,aAAa,GAAG,EAAE;AAAA,IACzD;AAEA,QAAI;AACH,YAAM,SAAS,MAAM,MAAM,0BAA0B,EAAE,IAAI,CAAC,OAAO;AAClE,eAAO;AAAA,MACR,CAAC;AAED,uBAAiB,KAAK;AAAA,QACrB,KAAK;AAAA,QACL,KAAK,aAAa;AAAA,QAClB,cAAc,aAAa;AAAA,QAC3B,MAAM;AAAA,MACP,CAAC;AAAA,IACF,QAAQ;AACP,YAAM,IAAI,MAAM,8BAA8B,aAAa,GAAG,EAAE;AAAA,IACjE;AAAA,EACD;AAEA,SAAO;AACR;AAEA,eAAsB,QAGrB,IACA,QACgB;AAChB,QAAM,aAAa,mBAAmB,MAAM;AAE5C,KAAG,YAAY,CAAC,OAAO;AACtB,QAAI;AACH,YAAM,kBAAkB;AAExB,YAAM,uBAAuB;AAAA,iCACC,IAAI,WAAW,eAAe,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA;AAM7D,SAAG,IAAI,oBAAoB;AAE3B,YAAM,eAAe,GAAG;AAAA,QACvB,uCAAuC,IAAI,WAAW,eAAe,CAAC;AAAA,MACvE;AAEA,YAAM,kBAAkB,aAAa,CAAC,KAAK;AAE3C,iBAAW,aAAa,YAAY;AACnC,YAAI,CAAC,mBAAmB,OAAO,gBAAgB,CAAC,CAAC,IAAK,UAAU,cAAc;AAC7E,qBAAW,QAAQ,UAAU,KAAK;AACjC,eAAG,IAAI,IAAI,IAAI,IAAI,CAAC;AAAA,UACrB;AACA,aAAG;AAAA,YACF,kBACC,IAAI,WAAW,eAAe,CAC/B,kCAAkC,UAAU,IAAI,KAAK,UAAU,YAAY;AAAA,UAC5E;AAAA,QACD;AAAA,MACD;AAAA,IACD,SAAS,OAAY;AACpB,SAAG,SAAS;AACZ,YAAM;AAAA,IACP;AAAA,EACD,CAAC;AACF;","names":[]}

131
node_modules/drizzle-orm/durable-sqlite/session.cjs generated vendored Normal file
View File

@ -0,0 +1,131 @@
"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, {
SQLiteDOPreparedQuery: () => SQLiteDOPreparedQuery,
SQLiteDOSession: () => SQLiteDOSession,
SQLiteDOTransaction: () => SQLiteDOTransaction
});
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_session2 = require("../sqlite-core/session.cjs");
var import_utils = require("../utils.cjs");
class SQLiteDOSession 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] = "SQLiteDOSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
return new SQLiteDOPreparedQuery(
this.client,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper
);
}
transaction(transaction, _config) {
const tx = new SQLiteDOTransaction("sync", this.dialect, this, this.schema);
this.client.transactionSync(() => {
transaction(tx);
});
return {};
}
}
class SQLiteDOTransaction extends import_sqlite_core.SQLiteTransaction {
static [import_entity.entityKind] = "SQLiteDOTransaction";
transaction(transaction) {
const tx = new SQLiteDOTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
this.session.transaction(() => transaction(tx));
return {};
}
}
class SQLiteDOPreparedQuery extends import_session2.SQLitePreparedQuery {
constructor(client, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
super("sync", executeMethod, query);
this.client = client;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [import_entity.entityKind] = "SQLiteDOPreparedQuery";
run(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
params.length > 0 ? this.client.sql.exec(this.query.sql, ...params) : this.client.sql.exec(this.query.sql);
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, query, logger, client, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
return params.length > 0 ? client.sql.exec(query.sql, ...params).toArray() : client.sql.exec(query.sql).toArray();
}
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 { fields, client, joinsNotNullableMap, customResultMapper, query } = this;
if (!fields && !customResultMapper) {
return params.length > 0 ? client.sql.exec(query.sql, ...params).one() : client.sql.exec(query.sql).one();
}
const rows = this.values(placeholderValues);
const row = rows[0];
if (!row) {
return void 0;
}
if (customResultMapper) {
return customResultMapper(rows);
}
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);
const res = params.length > 0 ? this.client.sql.exec(this.query.sql, ...params) : this.client.sql.exec(this.query.sql);
return res.raw().toArray();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteDOPreparedQuery,
SQLiteDOSession,
SQLiteDOTransaction
});
//# sourceMappingURL=session.cjs.map

File diff suppressed because one or more lines are too long

46
node_modules/drizzle-orm/durable-sqlite/session.d.cts generated vendored Normal file
View File

@ -0,0 +1,46 @@
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, SQLiteTransaction } from "../sqlite-core/index.cjs";
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.cjs";
import { type PreparedQueryConfig as PreparedQueryConfigBase, type SQLiteExecuteMethod, SQLiteSession, type SQLiteTransactionConfig } from "../sqlite-core/session.cjs";
import { SQLitePreparedQuery as PreparedQueryBase } from "../sqlite-core/session.cjs";
export interface SQLiteDOSessionOptions {
logger?: Logger;
}
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
export declare class SQLiteDOSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TFullSchema, TSchema> {
private client;
private schema;
static readonly [entityKind]: string;
private logger;
constructor(client: DurableObjectStorage, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLiteDOSessionOptions);
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): SQLiteDOPreparedQuery<T>;
transaction<T>(transaction: (tx: SQLiteTransaction<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TFullSchema, TSchema>) => T, _config?: SQLiteTransactionConfig): T;
}
export declare class SQLiteDOTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: SQLiteDOTransaction<TFullSchema, TSchema>) => T): T;
}
export declare class SQLiteDOPreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
type: 'sync';
run: void;
all: T['all'];
get: T['get'];
values: T['values'];
execute: T['execute'];
}> {
private client;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
constructor(client: DurableObjectStorage, 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 {};

46
node_modules/drizzle-orm/durable-sqlite/session.d.ts generated vendored Normal file
View File

@ -0,0 +1,46 @@
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, SQLiteTransaction } from "../sqlite-core/index.js";
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.js";
import { type PreparedQueryConfig as PreparedQueryConfigBase, type SQLiteExecuteMethod, SQLiteSession, type SQLiteTransactionConfig } from "../sqlite-core/session.js";
import { SQLitePreparedQuery as PreparedQueryBase } from "../sqlite-core/session.js";
export interface SQLiteDOSessionOptions {
logger?: Logger;
}
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
export declare class SQLiteDOSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TFullSchema, TSchema> {
private client;
private schema;
static readonly [entityKind]: string;
private logger;
constructor(client: DurableObjectStorage, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLiteDOSessionOptions);
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): SQLiteDOPreparedQuery<T>;
transaction<T>(transaction: (tx: SQLiteTransaction<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TFullSchema, TSchema>) => T, _config?: SQLiteTransactionConfig): T;
}
export declare class SQLiteDOTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', SqlStorageCursor<Record<string, SqlStorageValue>>, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: SQLiteDOTransaction<TFullSchema, TSchema>) => T): T;
}
export declare class SQLiteDOPreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
type: 'sync';
run: void;
all: T['all'];
get: T['get'];
values: T['values'];
execute: T['execute'];
}> {
private client;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
static readonly [entityKind]: string;
constructor(client: DurableObjectStorage, 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 {};

107
node_modules/drizzle-orm/durable-sqlite/session.js generated vendored Normal file
View File

@ -0,0 +1,107 @@
import { entityKind } from "../entity.js";
import { NoopLogger } from "../logger.js";
import { fillPlaceholders } from "../sql/sql.js";
import { SQLiteTransaction } from "../sqlite-core/index.js";
import {
SQLiteSession
} from "../sqlite-core/session.js";
import { SQLitePreparedQuery as PreparedQueryBase } from "../sqlite-core/session.js";
import { mapResultRow } from "../utils.js";
class SQLiteDOSession extends SQLiteSession {
constructor(client, dialect, schema, options = {}) {
super(dialect);
this.client = client;
this.schema = schema;
this.logger = options.logger ?? new NoopLogger();
}
static [entityKind] = "SQLiteDOSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
return new SQLiteDOPreparedQuery(
this.client,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper
);
}
transaction(transaction, _config) {
const tx = new SQLiteDOTransaction("sync", this.dialect, this, this.schema);
this.client.transactionSync(() => {
transaction(tx);
});
return {};
}
}
class SQLiteDOTransaction extends SQLiteTransaction {
static [entityKind] = "SQLiteDOTransaction";
transaction(transaction) {
const tx = new SQLiteDOTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
this.session.transaction(() => transaction(tx));
return {};
}
}
class SQLiteDOPreparedQuery extends PreparedQueryBase {
constructor(client, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper) {
super("sync", executeMethod, query);
this.client = client;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
}
static [entityKind] = "SQLiteDOPreparedQuery";
run(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
params.length > 0 ? this.client.sql.exec(this.query.sql, ...params) : this.client.sql.exec(this.query.sql);
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, query, logger, client, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = fillPlaceholders(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
return params.length > 0 ? client.sql.exec(query.sql, ...params).toArray() : client.sql.exec(query.sql).toArray();
}
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 { fields, client, joinsNotNullableMap, customResultMapper, query } = this;
if (!fields && !customResultMapper) {
return params.length > 0 ? client.sql.exec(query.sql, ...params).one() : client.sql.exec(query.sql).one();
}
const rows = this.values(placeholderValues);
const row = rows[0];
if (!row) {
return void 0;
}
if (customResultMapper) {
return customResultMapper(rows);
}
return mapResultRow(fields, row, joinsNotNullableMap);
}
values(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const res = params.length > 0 ? this.client.sql.exec(this.query.sql, ...params) : this.client.sql.exec(this.query.sql);
return res.raw().toArray();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
export {
SQLiteDOPreparedQuery,
SQLiteDOSession,
SQLiteDOTransaction
};
//# sourceMappingURL=session.js.map

File diff suppressed because one or more lines are too long