Initial commit
This commit is contained in:
64
node_modules/drizzle-orm/op-sqlite/driver.cjs
generated
vendored
Normal file
64
node_modules/drizzle-orm/op-sqlite/driver.cjs
generated
vendored
Normal 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, {
|
||||
OPSQLiteDatabase: () => OPSQLiteDatabase,
|
||||
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 OPSQLiteDatabase extends import_db.BaseSQLiteDatabase {
|
||||
static [import_entity.entityKind] = "OPSQLiteDatabase";
|
||||
}
|
||||
function drizzle(client, config = {}) {
|
||||
const dialect = new import_dialect.SQLiteAsyncDialect({ 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.OPSQLiteSession(client, dialect, schema, { logger });
|
||||
const db = new OPSQLiteDatabase("async", dialect, session, schema);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
OPSQLiteDatabase,
|
||||
drizzle
|
||||
});
|
||||
//# sourceMappingURL=driver.cjs.map
|
||||
1
node_modules/drizzle-orm/op-sqlite/driver.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/driver.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/op-sqlite/driver.ts"],"sourcesContent":["import type { OPSQLiteConnection, QueryResult } from '@op-engineering/op-sqlite';\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteAsyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { OPSQLiteSession } from './session.ts';\n\nexport class OPSQLiteDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends BaseSQLiteDatabase<'async', QueryResult, TSchema> {\n\tstatic override readonly [entityKind]: string = 'OPSQLiteDatabase';\n}\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: OPSQLiteConnection,\n\tconfig: DrizzleConfig<TSchema> = {},\n): OPSQLiteDatabase<TSchema> & {\n\t$client: OPSQLiteConnection;\n} {\n\tconst dialect = new SQLiteAsyncDialect({ 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 OPSQLiteSession(client, dialect, schema, { logger });\n\tconst db = new OPSQLiteDatabase('async', dialect, session, schema) as OPSQLiteDatabase<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,uBAKO;AACP,gBAAmC;AACnC,qBAAmC;AAEnC,qBAAgC;AAEzB,MAAM,yBAEH,6BAAkD;AAAA,EAC3D,QAA0B,wBAAU,IAAY;AACjD;AAEO,SAAS,QACf,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,kCAAmB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAChE,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,QAAQ,SAAS,QAAQ,EAAE,OAAO,CAAC;AACvE,QAAM,KAAK,IAAI,iBAAiB,SAAS,SAAS,SAAS,MAAM;AACjE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;","names":[]}
|
||||
10
node_modules/drizzle-orm/op-sqlite/driver.d.cts
generated
vendored
Normal file
10
node_modules/drizzle-orm/op-sqlite/driver.d.cts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import type { OPSQLiteConnection, QueryResult } from '@op-engineering/op-sqlite';
|
||||
import { entityKind } from "../entity.cjs";
|
||||
import { BaseSQLiteDatabase } from "../sqlite-core/db.cjs";
|
||||
import type { DrizzleConfig } from "../utils.cjs";
|
||||
export declare class OPSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'async', QueryResult, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(client: OPSQLiteConnection, config?: DrizzleConfig<TSchema>): OPSQLiteDatabase<TSchema> & {
|
||||
$client: OPSQLiteConnection;
|
||||
};
|
||||
10
node_modules/drizzle-orm/op-sqlite/driver.d.ts
generated
vendored
Normal file
10
node_modules/drizzle-orm/op-sqlite/driver.d.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
import type { OPSQLiteConnection, QueryResult } from '@op-engineering/op-sqlite';
|
||||
import { entityKind } from "../entity.js";
|
||||
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
|
||||
import type { DrizzleConfig } from "../utils.js";
|
||||
export declare class OPSQLiteDatabase<TSchema extends Record<string, unknown> = Record<string, never>> extends BaseSQLiteDatabase<'async', QueryResult, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
}
|
||||
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(client: OPSQLiteConnection, config?: DrizzleConfig<TSchema>): OPSQLiteDatabase<TSchema> & {
|
||||
$client: OPSQLiteConnection;
|
||||
};
|
||||
42
node_modules/drizzle-orm/op-sqlite/driver.js
generated
vendored
Normal file
42
node_modules/drizzle-orm/op-sqlite/driver.js
generated
vendored
Normal 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 { SQLiteAsyncDialect } from "../sqlite-core/dialect.js";
|
||||
import { OPSQLiteSession } from "./session.js";
|
||||
class OPSQLiteDatabase extends BaseSQLiteDatabase {
|
||||
static [entityKind] = "OPSQLiteDatabase";
|
||||
}
|
||||
function drizzle(client, config = {}) {
|
||||
const dialect = new SQLiteAsyncDialect({ 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 OPSQLiteSession(client, dialect, schema, { logger });
|
||||
const db = new OPSQLiteDatabase("async", dialect, session, schema);
|
||||
db.$client = client;
|
||||
return db;
|
||||
}
|
||||
export {
|
||||
OPSQLiteDatabase,
|
||||
drizzle
|
||||
};
|
||||
//# sourceMappingURL=driver.js.map
|
||||
1
node_modules/drizzle-orm/op-sqlite/driver.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/driver.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/op-sqlite/driver.ts"],"sourcesContent":["import type { OPSQLiteConnection, QueryResult } from '@op-engineering/op-sqlite';\nimport { entityKind } from '~/entity.ts';\nimport { DefaultLogger } from '~/logger.ts';\nimport {\n\tcreateTableRelationsHelpers,\n\textractTablesRelationalConfig,\n\ttype RelationalSchemaConfig,\n\ttype TablesRelationalConfig,\n} from '~/relations.ts';\nimport { BaseSQLiteDatabase } from '~/sqlite-core/db.ts';\nimport { SQLiteAsyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { OPSQLiteSession } from './session.ts';\n\nexport class OPSQLiteDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> extends BaseSQLiteDatabase<'async', QueryResult, TSchema> {\n\tstatic override readonly [entityKind]: string = 'OPSQLiteDatabase';\n}\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: OPSQLiteConnection,\n\tconfig: DrizzleConfig<TSchema> = {},\n): OPSQLiteDatabase<TSchema> & {\n\t$client: OPSQLiteConnection;\n} {\n\tconst dialect = new SQLiteAsyncDialect({ 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 OPSQLiteSession(client, dialect, schema, { logger });\n\tconst db = new OPSQLiteDatabase('async', dialect, session, schema) as OPSQLiteDatabase<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,OAGM;AACP,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AAEnC,SAAS,uBAAuB;AAEzB,MAAM,yBAEH,mBAAkD;AAAA,EAC3D,QAA0B,UAAU,IAAY;AACjD;AAEO,SAAS,QACf,QACA,SAAiC,CAAC,GAGjC;AACD,QAAM,UAAU,IAAI,mBAAmB,EAAE,QAAQ,OAAO,OAAO,CAAC;AAChE,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,QAAQ,SAAS,QAAQ,EAAE,OAAO,CAAC;AACvE,QAAM,KAAK,IAAI,iBAAiB,SAAS,SAAS,SAAS,MAAM;AACjE,EAAO,GAAI,UAAU;AAErB,SAAO;AACR;","names":[]}
|
||||
25
node_modules/drizzle-orm/op-sqlite/index.cjs
generated
vendored
Normal file
25
node_modules/drizzle-orm/op-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 op_sqlite_exports = {};
|
||||
module.exports = __toCommonJS(op_sqlite_exports);
|
||||
__reExport(op_sqlite_exports, require("./driver.cjs"), module.exports);
|
||||
__reExport(op_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/op-sqlite/index.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/index.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/op-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,8BAAc,wBAAd;AACA,8BAAc,yBADd;","names":[]}
|
||||
2
node_modules/drizzle-orm/op-sqlite/index.d.cts
generated
vendored
Normal file
2
node_modules/drizzle-orm/op-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/op-sqlite/index.d.ts
generated
vendored
Normal file
2
node_modules/drizzle-orm/op-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/op-sqlite/index.js
generated
vendored
Normal file
3
node_modules/drizzle-orm/op-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/op-sqlite/index.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/op-sqlite/index.ts"],"sourcesContent":["export * from './driver.ts';\nexport * from './session.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
|
||||
90
node_modules/drizzle-orm/op-sqlite/migrator.cjs
generated
vendored
Normal file
90
node_modules/drizzle-orm/op-sqlite/migrator.cjs
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
"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,
|
||||
useMigrations: () => useMigrations
|
||||
});
|
||||
module.exports = __toCommonJS(migrator_exports);
|
||||
var import_react = require("react");
|
||||
async function readMigrationFiles({ journal, migrations }) {
|
||||
const migrationQueries = [];
|
||||
for await (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 = await readMigrationFiles(config);
|
||||
return db.dialect.migrate(migrations, db.session);
|
||||
}
|
||||
const useMigrations = (db, migrations) => {
|
||||
const initialState = {
|
||||
success: false,
|
||||
error: void 0
|
||||
};
|
||||
const fetchReducer = (state2, action) => {
|
||||
switch (action.type) {
|
||||
case "migrating": {
|
||||
return { ...initialState };
|
||||
}
|
||||
case "migrated": {
|
||||
return { ...initialState, success: action.payload };
|
||||
}
|
||||
case "error": {
|
||||
return { ...initialState, error: action.payload };
|
||||
}
|
||||
default: {
|
||||
return state2;
|
||||
}
|
||||
}
|
||||
};
|
||||
const [state, dispatch] = (0, import_react.useReducer)(fetchReducer, initialState);
|
||||
(0, import_react.useEffect)(() => {
|
||||
dispatch({ type: "migrating" });
|
||||
migrate(db, migrations).then(() => {
|
||||
dispatch({ type: "migrated", payload: true });
|
||||
}).catch((error) => {
|
||||
dispatch({ type: "error", payload: error });
|
||||
});
|
||||
}, []);
|
||||
return state;
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
migrate,
|
||||
useMigrations
|
||||
});
|
||||
//# sourceMappingURL=migrator.cjs.map
|
||||
1
node_modules/drizzle-orm/op-sqlite/migrator.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/migrator.cjs.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/op-sqlite/migrator.ts"],"sourcesContent":["import { useEffect, useReducer } from 'react';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { OPSQLiteDatabase } 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\nasync function readMigrationFiles({ journal, migrations }: MigrationConfig): Promise<MigrationMeta[]> {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor await (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<TSchema extends Record<string, unknown>>(\n\tdb: OPSQLiteDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = await readMigrationFiles(config);\n\treturn db.dialect.migrate(migrations, db.session);\n}\n\ninterface State {\n\tsuccess: boolean;\n\terror?: Error;\n}\n\ntype Action =\n\t| { type: 'migrating' }\n\t| { type: 'migrated'; payload: true }\n\t| { type: 'error'; payload: Error };\n\nexport const useMigrations = (db: OPSQLiteDatabase<any>, migrations: {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}): State => {\n\tconst initialState: State = {\n\t\tsuccess: false,\n\t\terror: undefined,\n\t};\n\n\tconst fetchReducer = (state: State, action: Action): State => {\n\t\tswitch (action.type) {\n\t\t\tcase 'migrating': {\n\t\t\t\treturn { ...initialState };\n\t\t\t}\n\t\t\tcase 'migrated': {\n\t\t\t\treturn { ...initialState, success: action.payload };\n\t\t\t}\n\t\t\tcase 'error': {\n\t\t\t\treturn { ...initialState, error: action.payload };\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t}\n\t};\n\n\tconst [state, dispatch] = useReducer(fetchReducer, initialState);\n\n\tuseEffect(() => {\n\t\tdispatch({ type: 'migrating' });\n\t\tmigrate(db, migrations).then(() => {\n\t\t\tdispatch({ type: 'migrated', payload: true });\n\t\t}).catch((error) => {\n\t\t\tdispatch({ type: 'error', payload: error as Error });\n\t\t});\n\t}, []);\n\n\treturn state;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAsC;AAWtC,eAAe,mBAAmB,EAAE,SAAS,WAAW,GAA8C;AACrG,QAAM,mBAAoC,CAAC;AAE3C,mBAAiB,gBAAgB,QAAQ,SAAS;AACjD,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,QACrB,IACA,QACC;AACD,QAAM,aAAa,MAAM,mBAAmB,MAAM;AAClD,SAAO,GAAG,QAAQ,QAAQ,YAAY,GAAG,OAAO;AACjD;AAYO,MAAM,gBAAgB,CAAC,IAA2B,eAK5C;AACZ,QAAM,eAAsB;AAAA,IAC3B,SAAS;AAAA,IACT,OAAO;AAAA,EACR;AAEA,QAAM,eAAe,CAACA,QAAc,WAA0B;AAC7D,YAAQ,OAAO,MAAM;AAAA,MACpB,KAAK,aAAa;AACjB,eAAO,EAAE,GAAG,aAAa;AAAA,MAC1B;AAAA,MACA,KAAK,YAAY;AAChB,eAAO,EAAE,GAAG,cAAc,SAAS,OAAO,QAAQ;AAAA,MACnD;AAAA,MACA,KAAK,SAAS;AACb,eAAO,EAAE,GAAG,cAAc,OAAO,OAAO,QAAQ;AAAA,MACjD;AAAA,MACA,SAAS;AACR,eAAOA;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAW,cAAc,YAAY;AAE/D,8BAAU,MAAM;AACf,aAAS,EAAE,MAAM,YAAY,CAAC;AAC9B,YAAQ,IAAI,UAAU,EAAE,KAAK,MAAM;AAClC,eAAS,EAAE,MAAM,YAAY,SAAS,KAAK,CAAC;AAAA,IAC7C,CAAC,EAAE,MAAM,CAAC,UAAU;AACnB,eAAS,EAAE,MAAM,SAAS,SAAS,MAAe,CAAC;AAAA,IACpD,CAAC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACR;","names":["state"]}
|
||||
29
node_modules/drizzle-orm/op-sqlite/migrator.d.cts
generated
vendored
Normal file
29
node_modules/drizzle-orm/op-sqlite/migrator.d.cts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { OPSQLiteDatabase } 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: OPSQLiteDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
||||
interface State {
|
||||
success: boolean;
|
||||
error?: Error;
|
||||
}
|
||||
export declare const useMigrations: (db: OPSQLiteDatabase<any>, migrations: {
|
||||
journal: {
|
||||
entries: {
|
||||
idx: number;
|
||||
when: number;
|
||||
tag: string;
|
||||
breakpoints: boolean;
|
||||
}[];
|
||||
};
|
||||
migrations: Record<string, string>;
|
||||
}) => State;
|
||||
export {};
|
||||
29
node_modules/drizzle-orm/op-sqlite/migrator.d.ts
generated
vendored
Normal file
29
node_modules/drizzle-orm/op-sqlite/migrator.d.ts
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
import type { OPSQLiteDatabase } 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: OPSQLiteDatabase<TSchema>, config: MigrationConfig): Promise<void>;
|
||||
interface State {
|
||||
success: boolean;
|
||||
error?: Error;
|
||||
}
|
||||
export declare const useMigrations: (db: OPSQLiteDatabase<any>, migrations: {
|
||||
journal: {
|
||||
entries: {
|
||||
idx: number;
|
||||
when: number;
|
||||
tag: string;
|
||||
breakpoints: boolean;
|
||||
}[];
|
||||
};
|
||||
migrations: Record<string, string>;
|
||||
}) => State;
|
||||
export {};
|
||||
65
node_modules/drizzle-orm/op-sqlite/migrator.js
generated
vendored
Normal file
65
node_modules/drizzle-orm/op-sqlite/migrator.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
import { useEffect, useReducer } from "react";
|
||||
async function readMigrationFiles({ journal, migrations }) {
|
||||
const migrationQueries = [];
|
||||
for await (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 = await readMigrationFiles(config);
|
||||
return db.dialect.migrate(migrations, db.session);
|
||||
}
|
||||
const useMigrations = (db, migrations) => {
|
||||
const initialState = {
|
||||
success: false,
|
||||
error: void 0
|
||||
};
|
||||
const fetchReducer = (state2, action) => {
|
||||
switch (action.type) {
|
||||
case "migrating": {
|
||||
return { ...initialState };
|
||||
}
|
||||
case "migrated": {
|
||||
return { ...initialState, success: action.payload };
|
||||
}
|
||||
case "error": {
|
||||
return { ...initialState, error: action.payload };
|
||||
}
|
||||
default: {
|
||||
return state2;
|
||||
}
|
||||
}
|
||||
};
|
||||
const [state, dispatch] = useReducer(fetchReducer, initialState);
|
||||
useEffect(() => {
|
||||
dispatch({ type: "migrating" });
|
||||
migrate(db, migrations).then(() => {
|
||||
dispatch({ type: "migrated", payload: true });
|
||||
}).catch((error) => {
|
||||
dispatch({ type: "error", payload: error });
|
||||
});
|
||||
}, []);
|
||||
return state;
|
||||
};
|
||||
export {
|
||||
migrate,
|
||||
useMigrations
|
||||
};
|
||||
//# sourceMappingURL=migrator.js.map
|
||||
1
node_modules/drizzle-orm/op-sqlite/migrator.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/migrator.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../src/op-sqlite/migrator.ts"],"sourcesContent":["import { useEffect, useReducer } from 'react';\nimport type { MigrationMeta } from '~/migrator.ts';\nimport type { OPSQLiteDatabase } 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\nasync function readMigrationFiles({ journal, migrations }: MigrationConfig): Promise<MigrationMeta[]> {\n\tconst migrationQueries: MigrationMeta[] = [];\n\n\tfor await (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<TSchema extends Record<string, unknown>>(\n\tdb: OPSQLiteDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = await readMigrationFiles(config);\n\treturn db.dialect.migrate(migrations, db.session);\n}\n\ninterface State {\n\tsuccess: boolean;\n\terror?: Error;\n}\n\ntype Action =\n\t| { type: 'migrating' }\n\t| { type: 'migrated'; payload: true }\n\t| { type: 'error'; payload: Error };\n\nexport const useMigrations = (db: OPSQLiteDatabase<any>, migrations: {\n\tjournal: {\n\t\tentries: { idx: number; when: number; tag: string; breakpoints: boolean }[];\n\t};\n\tmigrations: Record<string, string>;\n}): State => {\n\tconst initialState: State = {\n\t\tsuccess: false,\n\t\terror: undefined,\n\t};\n\n\tconst fetchReducer = (state: State, action: Action): State => {\n\t\tswitch (action.type) {\n\t\t\tcase 'migrating': {\n\t\t\t\treturn { ...initialState };\n\t\t\t}\n\t\t\tcase 'migrated': {\n\t\t\t\treturn { ...initialState, success: action.payload };\n\t\t\t}\n\t\t\tcase 'error': {\n\t\t\t\treturn { ...initialState, error: action.payload };\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t}\n\t};\n\n\tconst [state, dispatch] = useReducer(fetchReducer, initialState);\n\n\tuseEffect(() => {\n\t\tdispatch({ type: 'migrating' });\n\t\tmigrate(db, migrations).then(() => {\n\t\t\tdispatch({ type: 'migrated', payload: true });\n\t\t}).catch((error) => {\n\t\t\tdispatch({ type: 'error', payload: error as Error });\n\t\t});\n\t}, []);\n\n\treturn state;\n};\n"],"mappings":"AAAA,SAAS,WAAW,kBAAkB;AAWtC,eAAe,mBAAmB,EAAE,SAAS,WAAW,GAA8C;AACrG,QAAM,mBAAoC,CAAC;AAE3C,mBAAiB,gBAAgB,QAAQ,SAAS;AACjD,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,QACrB,IACA,QACC;AACD,QAAM,aAAa,MAAM,mBAAmB,MAAM;AAClD,SAAO,GAAG,QAAQ,QAAQ,YAAY,GAAG,OAAO;AACjD;AAYO,MAAM,gBAAgB,CAAC,IAA2B,eAK5C;AACZ,QAAM,eAAsB;AAAA,IAC3B,SAAS;AAAA,IACT,OAAO;AAAA,EACR;AAEA,QAAM,eAAe,CAACA,QAAc,WAA0B;AAC7D,YAAQ,OAAO,MAAM;AAAA,MACpB,KAAK,aAAa;AACjB,eAAO,EAAE,GAAG,aAAa;AAAA,MAC1B;AAAA,MACA,KAAK,YAAY;AAChB,eAAO,EAAE,GAAG,cAAc,SAAS,OAAO,QAAQ;AAAA,MACnD;AAAA,MACA,KAAK,SAAS;AACb,eAAO,EAAE,GAAG,cAAc,OAAO,OAAO,QAAQ;AAAA,MACjD;AAAA,MACA,SAAS;AACR,eAAOA;AAAA,MACR;AAAA,IACD;AAAA,EACD;AAEA,QAAM,CAAC,OAAO,QAAQ,IAAI,WAAW,cAAc,YAAY;AAE/D,YAAU,MAAM;AACf,aAAS,EAAE,MAAM,YAAY,CAAC;AAC9B,YAAQ,IAAI,UAAU,EAAE,KAAK,MAAM;AAClC,eAAS,EAAE,MAAM,YAAY,SAAS,KAAK,CAAC;AAAA,IAC7C,CAAC,EAAE,MAAM,CAAC,UAAU;AACnB,eAAS,EAAE,MAAM,SAAS,SAAS,MAAe,CAAC;AAAA,IACpD,CAAC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACR;","names":["state"]}
|
||||
143
node_modules/drizzle-orm/op-sqlite/session.cjs
generated
vendored
Normal file
143
node_modules/drizzle-orm/op-sqlite/session.cjs
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
"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, {
|
||||
OPSQLitePreparedQuery: () => OPSQLitePreparedQuery,
|
||||
OPSQLiteSession: () => OPSQLiteSession,
|
||||
OPSQLiteTransaction: () => OPSQLiteTransaction
|
||||
});
|
||||
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 OPSQLiteSession 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] = "OPSQLiteSession";
|
||||
logger;
|
||||
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
||||
return new OPSQLitePreparedQuery(
|
||||
this.client,
|
||||
query,
|
||||
this.logger,
|
||||
fields,
|
||||
executeMethod,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
transaction(transaction, config = {}) {
|
||||
const tx = new OPSQLiteTransaction("async", this.dialect, this, this.schema);
|
||||
this.run(import_sql.sql.raw(`begin${config?.behavior ? " " + config.behavior : ""}`));
|
||||
try {
|
||||
const result = transaction(tx);
|
||||
this.run(import_sql.sql`commit`);
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.run(import_sql.sql`rollback`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
class OPSQLiteTransaction extends import_sqlite_core.SQLiteTransaction {
|
||||
static [import_entity.entityKind] = "OPSQLiteTransaction";
|
||||
transaction(transaction) {
|
||||
const savepointName = `sp${this.nestedIndex}`;
|
||||
const tx = new OPSQLiteTransaction("async", 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 OPSQLitePreparedQuery extends import_session.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] = "OPSQLitePreparedQuery";
|
||||
run(placeholderValues) {
|
||||
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.client.executeAsync(this.query.sql, params);
|
||||
}
|
||||
async all(placeholderValues) {
|
||||
const { fields, joinsNotNullableMap, query, logger, customResultMapper, client } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
|
||||
logger.logQuery(query.sql, params);
|
||||
return client.execute(query.sql, params).rows?._array || [];
|
||||
}
|
||||
const rows = await this.values(placeholderValues);
|
||||
if (customResultMapper) {
|
||||
return customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row, joinsNotNullableMap));
|
||||
}
|
||||
async get(placeholderValues) {
|
||||
const { fields, joinsNotNullableMap, customResultMapper, query, logger, client } = this;
|
||||
const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
|
||||
logger.logQuery(query.sql, params);
|
||||
if (!fields && !customResultMapper) {
|
||||
const rows2 = client.execute(query.sql, params).rows?._array || [];
|
||||
return rows2[0];
|
||||
}
|
||||
const rows = await 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);
|
||||
return this.client.executeRawAsync(this.query.sql, params);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
OPSQLitePreparedQuery,
|
||||
OPSQLiteSession,
|
||||
OPSQLiteTransaction
|
||||
});
|
||||
//# sourceMappingURL=session.cjs.map
|
||||
1
node_modules/drizzle-orm/op-sqlite/session.cjs.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-sqlite/session.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
47
node_modules/drizzle-orm/op-sqlite/session.d.cts
generated
vendored
Normal file
47
node_modules/drizzle-orm/op-sqlite/session.d.cts
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import type { OPSQLiteConnection, QueryResult } from '@op-engineering/op-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 { SQLiteAsyncDialect } 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, type SQLiteExecuteMethod, SQLitePreparedQuery, SQLiteSession, type SQLiteTransactionConfig } from "../sqlite-core/session.cjs";
|
||||
export interface OPSQLiteSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
|
||||
export declare class OPSQLiteSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'async', QueryResult, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: OPSQLiteConnection, dialect: SQLiteAsyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: OPSQLiteSessionOptions);
|
||||
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): OPSQLitePreparedQuery<T>;
|
||||
transaction<T>(transaction: (tx: OPSQLiteTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
|
||||
}
|
||||
export declare class OPSQLiteTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'async', QueryResult, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(transaction: (tx: OPSQLiteTransaction<TFullSchema, TSchema>) => T): T;
|
||||
}
|
||||
export declare class OPSQLitePreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<{
|
||||
type: 'async';
|
||||
run: QueryResult;
|
||||
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: OPSQLiteConnection, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => unknown) | undefined);
|
||||
run(placeholderValues?: Record<string, unknown>): Promise<QueryResult>;
|
||||
all(placeholderValues?: Record<string, unknown>): Promise<T['all']>;
|
||||
get(placeholderValues?: Record<string, unknown>): Promise<T['get']>;
|
||||
values(placeholderValues?: Record<string, unknown>): Promise<T['values']>;
|
||||
}
|
||||
export {};
|
||||
47
node_modules/drizzle-orm/op-sqlite/session.d.ts
generated
vendored
Normal file
47
node_modules/drizzle-orm/op-sqlite/session.d.ts
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
import type { OPSQLiteConnection, QueryResult } from '@op-engineering/op-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 { SQLiteAsyncDialect } 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, type SQLiteExecuteMethod, SQLitePreparedQuery, SQLiteSession, type SQLiteTransactionConfig } from "../sqlite-core/session.js";
|
||||
export interface OPSQLiteSessionOptions {
|
||||
logger?: Logger;
|
||||
}
|
||||
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
|
||||
export declare class OPSQLiteSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'async', QueryResult, TFullSchema, TSchema> {
|
||||
private client;
|
||||
private schema;
|
||||
static readonly [entityKind]: string;
|
||||
private logger;
|
||||
constructor(client: OPSQLiteConnection, dialect: SQLiteAsyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: OPSQLiteSessionOptions);
|
||||
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): OPSQLitePreparedQuery<T>;
|
||||
transaction<T>(transaction: (tx: OPSQLiteTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
|
||||
}
|
||||
export declare class OPSQLiteTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'async', QueryResult, TFullSchema, TSchema> {
|
||||
static readonly [entityKind]: string;
|
||||
transaction<T>(transaction: (tx: OPSQLiteTransaction<TFullSchema, TSchema>) => T): T;
|
||||
}
|
||||
export declare class OPSQLitePreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends SQLitePreparedQuery<{
|
||||
type: 'async';
|
||||
run: QueryResult;
|
||||
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: OPSQLiteConnection, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => unknown) | undefined);
|
||||
run(placeholderValues?: Record<string, unknown>): Promise<QueryResult>;
|
||||
all(placeholderValues?: Record<string, unknown>): Promise<T['all']>;
|
||||
get(placeholderValues?: Record<string, unknown>): Promise<T['get']>;
|
||||
values(placeholderValues?: Record<string, unknown>): Promise<T['values']>;
|
||||
}
|
||||
export {};
|
||||
120
node_modules/drizzle-orm/op-sqlite/session.js
generated
vendored
Normal file
120
node_modules/drizzle-orm/op-sqlite/session.js
generated
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
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,
|
||||
SQLiteSession
|
||||
} from "../sqlite-core/session.js";
|
||||
import { mapResultRow } from "../utils.js";
|
||||
class OPSQLiteSession extends SQLiteSession {
|
||||
constructor(client, dialect, schema, options = {}) {
|
||||
super(dialect);
|
||||
this.client = client;
|
||||
this.schema = schema;
|
||||
this.logger = options.logger ?? new NoopLogger();
|
||||
}
|
||||
static [entityKind] = "OPSQLiteSession";
|
||||
logger;
|
||||
prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
|
||||
return new OPSQLitePreparedQuery(
|
||||
this.client,
|
||||
query,
|
||||
this.logger,
|
||||
fields,
|
||||
executeMethod,
|
||||
isResponseInArrayMode,
|
||||
customResultMapper
|
||||
);
|
||||
}
|
||||
transaction(transaction, config = {}) {
|
||||
const tx = new OPSQLiteTransaction("async", this.dialect, this, this.schema);
|
||||
this.run(sql.raw(`begin${config?.behavior ? " " + config.behavior : ""}`));
|
||||
try {
|
||||
const result = transaction(tx);
|
||||
this.run(sql`commit`);
|
||||
return result;
|
||||
} catch (err) {
|
||||
this.run(sql`rollback`);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
class OPSQLiteTransaction extends SQLiteTransaction {
|
||||
static [entityKind] = "OPSQLiteTransaction";
|
||||
transaction(transaction) {
|
||||
const savepointName = `sp${this.nestedIndex}`;
|
||||
const tx = new OPSQLiteTransaction("async", 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 OPSQLitePreparedQuery extends 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 [entityKind] = "OPSQLitePreparedQuery";
|
||||
run(placeholderValues) {
|
||||
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
|
||||
this.logger.logQuery(this.query.sql, params);
|
||||
return this.client.executeAsync(this.query.sql, params);
|
||||
}
|
||||
async all(placeholderValues) {
|
||||
const { fields, joinsNotNullableMap, query, logger, customResultMapper, client } = this;
|
||||
if (!fields && !customResultMapper) {
|
||||
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
||||
logger.logQuery(query.sql, params);
|
||||
return client.execute(query.sql, params).rows?._array || [];
|
||||
}
|
||||
const rows = await this.values(placeholderValues);
|
||||
if (customResultMapper) {
|
||||
return customResultMapper(rows);
|
||||
}
|
||||
return rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
||||
}
|
||||
async get(placeholderValues) {
|
||||
const { fields, joinsNotNullableMap, customResultMapper, query, logger, client } = this;
|
||||
const params = fillPlaceholders(query.params, placeholderValues ?? {});
|
||||
logger.logQuery(query.sql, params);
|
||||
if (!fields && !customResultMapper) {
|
||||
const rows2 = client.execute(query.sql, params).rows?._array || [];
|
||||
return rows2[0];
|
||||
}
|
||||
const rows = await 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);
|
||||
return this.client.executeRawAsync(this.query.sql, params);
|
||||
}
|
||||
/** @internal */
|
||||
isResponseInArrayMode() {
|
||||
return this._isResponseInArrayMode;
|
||||
}
|
||||
}
|
||||
export {
|
||||
OPSQLitePreparedQuery,
|
||||
OPSQLiteSession,
|
||||
OPSQLiteTransaction
|
||||
};
|
||||
//# sourceMappingURL=session.js.map
|
||||
1
node_modules/drizzle-orm/op-sqlite/session.js.map
generated
vendored
Normal file
1
node_modules/drizzle-orm/op-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