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

56
node_modules/drizzle-orm/sql-js/driver.cjs generated vendored Normal file
View File

@ -0,0 +1,56 @@
"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, {
drizzle: () => drizzle
});
module.exports = __toCommonJS(driver_exports);
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");
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.SQLJsSession(client, dialect, schema, { logger });
return new import_db.BaseSQLiteDatabase("sync", dialect, session, schema);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
drizzle
});
//# sourceMappingURL=driver.cjs.map

1
node_modules/drizzle-orm/sql-js/driver.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sql-js/driver.ts"],"sourcesContent":["import type { Database } from 'sql.js';\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 { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { SQLJsSession } from './session.ts';\n\nexport type SQLJsDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> = BaseSQLiteDatabase<'sync', void, TSchema>;\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: Database,\n\tconfig: DrizzleConfig<TSchema> = {},\n): SQLJsDatabase<TSchema> {\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 SQLJsSession(client, dialect, schema, { logger });\n\treturn new BaseSQLiteDatabase('sync', dialect, session, schema) as SQLJsDatabase<TSchema>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,uBAKO;AACP,gBAAmC;AACnC,qBAAkC;AAElC,qBAA6B;AAMtB,SAAS,QACf,QACA,SAAiC,CAAC,GACT;AACzB,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,4BAAa,QAAQ,SAAS,QAAQ,EAAE,OAAO,CAAC;AACpE,SAAO,IAAI,6BAAmB,QAAQ,SAAS,SAAS,MAAM;AAC/D;","names":[]}

5
node_modules/drizzle-orm/sql-js/driver.d.cts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import type { Database } from 'sql.js';
import { BaseSQLiteDatabase } from "../sqlite-core/db.cjs";
import type { DrizzleConfig } from "../utils.cjs";
export type SQLJsDatabase<TSchema extends Record<string, unknown> = Record<string, never>> = BaseSQLiteDatabase<'sync', void, TSchema>;
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(client: Database, config?: DrizzleConfig<TSchema>): SQLJsDatabase<TSchema>;

5
node_modules/drizzle-orm/sql-js/driver.d.ts generated vendored Normal file
View File

@ -0,0 +1,5 @@
import type { Database } from 'sql.js';
import { BaseSQLiteDatabase } from "../sqlite-core/db.js";
import type { DrizzleConfig } from "../utils.js";
export type SQLJsDatabase<TSchema extends Record<string, unknown> = Record<string, never>> = BaseSQLiteDatabase<'sync', void, TSchema>;
export declare function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(client: Database, config?: DrizzleConfig<TSchema>): SQLJsDatabase<TSchema>;

35
node_modules/drizzle-orm/sql-js/driver.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
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 { SQLJsSession } from "./session.js";
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 SQLJsSession(client, dialect, schema, { logger });
return new BaseSQLiteDatabase("sync", dialect, session, schema);
}
export {
drizzle
};
//# sourceMappingURL=driver.js.map

1
node_modules/drizzle-orm/sql-js/driver.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sql-js/driver.ts"],"sourcesContent":["import type { Database } from 'sql.js';\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 { SQLiteSyncDialect } from '~/sqlite-core/dialect.ts';\nimport type { DrizzleConfig } from '~/utils.ts';\nimport { SQLJsSession } from './session.ts';\n\nexport type SQLJsDatabase<\n\tTSchema extends Record<string, unknown> = Record<string, never>,\n> = BaseSQLiteDatabase<'sync', void, TSchema>;\n\nexport function drizzle<TSchema extends Record<string, unknown> = Record<string, never>>(\n\tclient: Database,\n\tconfig: DrizzleConfig<TSchema> = {},\n): SQLJsDatabase<TSchema> {\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 SQLJsSession(client, dialect, schema, { logger });\n\treturn new BaseSQLiteDatabase('sync', dialect, session, schema) as SQLJsDatabase<TSchema>;\n}\n"],"mappings":"AACA,SAAS,qBAAqB;AAC9B;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AACP,SAAS,0BAA0B;AACnC,SAAS,yBAAyB;AAElC,SAAS,oBAAoB;AAMtB,SAAS,QACf,QACA,SAAiC,CAAC,GACT;AACzB,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,aAAa,QAAQ,SAAS,QAAQ,EAAE,OAAO,CAAC;AACpE,SAAO,IAAI,mBAAmB,QAAQ,SAAS,SAAS,MAAM;AAC/D;","names":[]}

25
node_modules/drizzle-orm/sql-js/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 sql_js_exports = {};
module.exports = __toCommonJS(sql_js_exports);
__reExport(sql_js_exports, require("./driver.cjs"), module.exports);
__reExport(sql_js_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/sql-js/index.cjs.map generated vendored Normal file
View File

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

2
node_modules/drizzle-orm/sql-js/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/sql-js/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/sql-js/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/sql-js/index.js.map generated vendored Normal file
View File

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

33
node_modules/drizzle-orm/sql-js/migrator.cjs generated vendored Normal file
View File

@ -0,0 +1,33 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var migrator_exports = {};
__export(migrator_exports, {
migrate: () => migrate
});
module.exports = __toCommonJS(migrator_exports);
var import_migrator = require("../migrator.cjs");
function migrate(db, config) {
const migrations = (0, import_migrator.readMigrationFiles)(config);
db.dialect.migrate(migrations, db.session, config);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
migrate
});
//# sourceMappingURL=migrator.cjs.map

1
node_modules/drizzle-orm/sql-js/migrator.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sql-js/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { SQLJsDatabase } from './driver.ts';\n\nexport function migrate<TSchema extends Record<string, unknown>>(\n\tdb: SQLJsDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tdb.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sBAAmC;AAG5B,SAAS,QACf,IACA,QACC;AACD,QAAM,iBAAa,oCAAmB,MAAM;AAC5C,KAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AAClD;","names":[]}

3
node_modules/drizzle-orm/sql-js/migrator.d.cts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import type { MigrationConfig } from "../migrator.cjs";
import type { SQLJsDatabase } from "./driver.cjs";
export declare function migrate<TSchema extends Record<string, unknown>>(db: SQLJsDatabase<TSchema>, config: MigrationConfig): void;

3
node_modules/drizzle-orm/sql-js/migrator.d.ts generated vendored Normal file
View File

@ -0,0 +1,3 @@
import type { MigrationConfig } from "../migrator.js";
import type { SQLJsDatabase } from "./driver.js";
export declare function migrate<TSchema extends Record<string, unknown>>(db: SQLJsDatabase<TSchema>, config: MigrationConfig): void;

9
node_modules/drizzle-orm/sql-js/migrator.js generated vendored Normal file
View File

@ -0,0 +1,9 @@
import { readMigrationFiles } from "../migrator.js";
function migrate(db, config) {
const migrations = readMigrationFiles(config);
db.dialect.migrate(migrations, db.session, config);
}
export {
migrate
};
//# sourceMappingURL=migrator.js.map

1
node_modules/drizzle-orm/sql-js/migrator.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sql-js/migrator.ts"],"sourcesContent":["import type { MigrationConfig } from '~/migrator.ts';\nimport { readMigrationFiles } from '~/migrator.ts';\nimport type { SQLJsDatabase } from './driver.ts';\n\nexport function migrate<TSchema extends Record<string, unknown>>(\n\tdb: SQLJsDatabase<TSchema>,\n\tconfig: MigrationConfig,\n) {\n\tconst migrations = readMigrationFiles(config);\n\tdb.dialect.migrate(migrations, db.session, config);\n}\n"],"mappings":"AACA,SAAS,0BAA0B;AAG5B,SAAS,QACf,IACA,QACC;AACD,QAAM,aAAa,mBAAmB,MAAM;AAC5C,KAAG,QAAQ,QAAQ,YAAY,GAAG,SAAS,MAAM;AAClD;","names":[]}

193
node_modules/drizzle-orm/sql-js/session.cjs generated vendored Normal file
View File

@ -0,0 +1,193 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var session_exports = {};
__export(session_exports, {
PreparedQuery: () => PreparedQuery,
SQLJsSession: () => SQLJsSession,
SQLJsTransaction: () => SQLJsTransaction
});
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 SQLJsSession 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] = "SQLJsSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode) {
const stmt = this.client.prepare(query.sql);
return new PreparedQuery(stmt, query, this.logger, fields, executeMethod, isResponseInArrayMode);
}
prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
const stmt = this.client.prepare(query.sql);
return new PreparedQuery(
stmt,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper,
true
);
}
transaction(transaction, config = {}) {
const tx = new SQLJsTransaction("sync", 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 SQLJsTransaction extends import_sqlite_core.SQLiteTransaction {
static [import_entity.entityKind] = "SQLJsTransaction";
transaction(transaction) {
const savepointName = `sp${this.nestedIndex + 1}`;
const tx = new SQLJsTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
tx.run(import_sql.sql.raw(`savepoint ${savepointName}`));
try {
const result = transaction(tx);
tx.run(import_sql.sql.raw(`release savepoint ${savepointName}`));
return result;
} catch (err) {
tx.run(import_sql.sql.raw(`rollback to savepoint ${savepointName}`));
throw err;
}
}
}
class PreparedQuery extends import_session.SQLitePreparedQuery {
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper, isOneTimeQuery = false) {
super("sync", executeMethod, query);
this.stmt = stmt;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
this.isOneTimeQuery = isOneTimeQuery;
}
static [import_entity.entityKind] = "SQLJsPreparedQuery";
run(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const result = this.stmt.run(params);
if (this.isOneTimeQuery) {
this.free();
}
return result;
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, logger, query, stmt, isOneTimeQuery, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = (0, import_sql.fillPlaceholders)(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
stmt.bind(params);
const rows2 = [];
while (stmt.step()) {
rows2.push(stmt.getAsObject());
}
if (isOneTimeQuery) {
this.free();
}
return rows2;
}
const rows = this.values(placeholderValues);
if (customResultMapper) {
return customResultMapper(rows, normalizeFieldValue);
}
return rows.map((row) => (0, import_utils.mapResultRow)(fields, row.map((v) => normalizeFieldValue(v)), joinsNotNullableMap));
}
get(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { fields, stmt, isOneTimeQuery, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
const result = stmt.getAsObject(params);
if (isOneTimeQuery) {
this.free();
}
return result;
}
const row = stmt.get(params);
if (isOneTimeQuery) {
this.free();
}
if (!row || row.length === 0 && fields.length > 0) {
return void 0;
}
if (customResultMapper) {
return customResultMapper([row], normalizeFieldValue);
}
return (0, import_utils.mapResultRow)(fields, row.map((v) => normalizeFieldValue(v)), joinsNotNullableMap);
}
values(placeholderValues) {
const params = (0, import_sql.fillPlaceholders)(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
this.stmt.bind(params);
const rows = [];
while (this.stmt.step()) {
rows.push(this.stmt.get());
}
if (this.isOneTimeQuery) {
this.free();
}
return rows;
}
free() {
return this.stmt.free();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
function normalizeFieldValue(value) {
if (value instanceof Uint8Array) {
if (typeof Buffer !== "undefined") {
if (!(value instanceof Buffer)) {
return Buffer.from(value);
}
return value;
}
if (typeof TextDecoder !== "undefined") {
return new TextDecoder().decode(value);
}
throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.");
}
return value;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PreparedQuery,
SQLJsSession,
SQLJsTransaction
});
//# sourceMappingURL=session.cjs.map

1
node_modules/drizzle-orm/sql-js/session.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

51
node_modules/drizzle-orm/sql-js/session.d.cts generated vendored Normal file
View File

@ -0,0 +1,51 @@
import type { Database, Statement } from 'sql.js';
import { entityKind } from "../entity.cjs";
import type { Logger } from "../logger.cjs";
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
import { type Query } from "../sql/sql.cjs";
import type { SQLiteSyncDialect } from "../sqlite-core/dialect.cjs";
import { SQLiteTransaction } from "../sqlite-core/index.cjs";
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.cjs";
import type { PreparedQueryConfig as PreparedQueryConfigBase, SQLiteExecuteMethod, SQLiteTransactionConfig } from "../sqlite-core/session.cjs";
import { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from "../sqlite-core/session.cjs";
export interface SQLJsSessionOptions {
logger?: Logger;
}
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
export declare class SQLJsSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', void, TFullSchema, TSchema> {
private client;
private schema;
static readonly [entityKind]: string;
private logger;
constructor(client: Database, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLJsSessionOptions);
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean): PreparedQuery<T>;
prepareOneTimeQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): PreparedQuery<T>;
transaction<T>(transaction: (tx: SQLJsTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
}
export declare class SQLJsTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', void, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: SQLJsTransaction<TFullSchema, TSchema>) => T): T;
}
export declare class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
type: 'sync';
run: void;
all: T['all'];
get: T['get'];
values: T['values'];
execute: T['execute'];
}> {
private stmt;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
private isOneTimeQuery;
static readonly [entityKind]: string;
constructor(stmt: Statement, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown) | undefined, isOneTimeQuery?: boolean);
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'];
free(): boolean;
}
export {};

51
node_modules/drizzle-orm/sql-js/session.d.ts generated vendored Normal file
View File

@ -0,0 +1,51 @@
import type { Database, Statement } from 'sql.js';
import { entityKind } from "../entity.js";
import type { Logger } from "../logger.js";
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
import { type Query } from "../sql/sql.js";
import type { SQLiteSyncDialect } from "../sqlite-core/dialect.js";
import { SQLiteTransaction } from "../sqlite-core/index.js";
import type { SelectedFieldsOrdered } from "../sqlite-core/query-builders/select.types.js";
import type { PreparedQueryConfig as PreparedQueryConfigBase, SQLiteExecuteMethod, SQLiteTransactionConfig } from "../sqlite-core/session.js";
import { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from "../sqlite-core/session.js";
export interface SQLJsSessionOptions {
logger?: Logger;
}
type PreparedQueryConfig = Omit<PreparedQueryConfigBase, 'statement' | 'run'>;
export declare class SQLJsSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteSession<'sync', void, TFullSchema, TSchema> {
private client;
private schema;
static readonly [entityKind]: string;
private logger;
constructor(client: Database, dialect: SQLiteSyncDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: SQLJsSessionOptions);
prepareQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean): PreparedQuery<T>;
prepareOneTimeQuery<T extends Omit<PreparedQueryConfig, 'run'>>(query: Query, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => unknown): PreparedQuery<T>;
transaction<T>(transaction: (tx: SQLJsTransaction<TFullSchema, TSchema>) => T, config?: SQLiteTransactionConfig): T;
}
export declare class SQLJsTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends SQLiteTransaction<'sync', void, TFullSchema, TSchema> {
static readonly [entityKind]: string;
transaction<T>(transaction: (tx: SQLJsTransaction<TFullSchema, TSchema>) => T): T;
}
export declare class PreparedQuery<T extends PreparedQueryConfig = PreparedQueryConfig> extends PreparedQueryBase<{
type: 'sync';
run: void;
all: T['all'];
get: T['get'];
values: T['values'];
execute: T['execute'];
}> {
private stmt;
private logger;
private fields;
private _isResponseInArrayMode;
private customResultMapper?;
private isOneTimeQuery;
static readonly [entityKind]: string;
constructor(stmt: Statement, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, executeMethod: SQLiteExecuteMethod, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][], mapColumnValue?: (value: unknown) => unknown) => unknown) | undefined, isOneTimeQuery?: boolean);
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'];
free(): boolean;
}
export {};

167
node_modules/drizzle-orm/sql-js/session.js generated vendored Normal file
View File

@ -0,0 +1,167 @@
import { entityKind } from "../entity.js";
import { NoopLogger } from "../logger.js";
import { fillPlaceholders, sql } from "../sql/sql.js";
import { SQLiteTransaction } from "../sqlite-core/index.js";
import { SQLitePreparedQuery as PreparedQueryBase, SQLiteSession } from "../sqlite-core/session.js";
import { mapResultRow } from "../utils.js";
class SQLJsSession extends SQLiteSession {
constructor(client, dialect, schema, options = {}) {
super(dialect);
this.client = client;
this.schema = schema;
this.logger = options.logger ?? new NoopLogger();
}
static [entityKind] = "SQLJsSession";
logger;
prepareQuery(query, fields, executeMethod, isResponseInArrayMode) {
const stmt = this.client.prepare(query.sql);
return new PreparedQuery(stmt, query, this.logger, fields, executeMethod, isResponseInArrayMode);
}
prepareOneTimeQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
const stmt = this.client.prepare(query.sql);
return new PreparedQuery(
stmt,
query,
this.logger,
fields,
executeMethod,
isResponseInArrayMode,
customResultMapper,
true
);
}
transaction(transaction, config = {}) {
const tx = new SQLJsTransaction("sync", 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 SQLJsTransaction extends SQLiteTransaction {
static [entityKind] = "SQLJsTransaction";
transaction(transaction) {
const savepointName = `sp${this.nestedIndex + 1}`;
const tx = new SQLJsTransaction("sync", this.dialect, this.session, this.schema, this.nestedIndex + 1);
tx.run(sql.raw(`savepoint ${savepointName}`));
try {
const result = transaction(tx);
tx.run(sql.raw(`release savepoint ${savepointName}`));
return result;
} catch (err) {
tx.run(sql.raw(`rollback to savepoint ${savepointName}`));
throw err;
}
}
}
class PreparedQuery extends PreparedQueryBase {
constructor(stmt, query, logger, fields, executeMethod, _isResponseInArrayMode, customResultMapper, isOneTimeQuery = false) {
super("sync", executeMethod, query);
this.stmt = stmt;
this.logger = logger;
this.fields = fields;
this._isResponseInArrayMode = _isResponseInArrayMode;
this.customResultMapper = customResultMapper;
this.isOneTimeQuery = isOneTimeQuery;
}
static [entityKind] = "SQLJsPreparedQuery";
run(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const result = this.stmt.run(params);
if (this.isOneTimeQuery) {
this.free();
}
return result;
}
all(placeholderValues) {
const { fields, joinsNotNullableMap, logger, query, stmt, isOneTimeQuery, customResultMapper } = this;
if (!fields && !customResultMapper) {
const params = fillPlaceholders(query.params, placeholderValues ?? {});
logger.logQuery(query.sql, params);
stmt.bind(params);
const rows2 = [];
while (stmt.step()) {
rows2.push(stmt.getAsObject());
}
if (isOneTimeQuery) {
this.free();
}
return rows2;
}
const rows = this.values(placeholderValues);
if (customResultMapper) {
return customResultMapper(rows, normalizeFieldValue);
}
return rows.map((row) => mapResultRow(fields, row.map((v) => normalizeFieldValue(v)), joinsNotNullableMap));
}
get(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
const { fields, stmt, isOneTimeQuery, joinsNotNullableMap, customResultMapper } = this;
if (!fields && !customResultMapper) {
const result = stmt.getAsObject(params);
if (isOneTimeQuery) {
this.free();
}
return result;
}
const row = stmt.get(params);
if (isOneTimeQuery) {
this.free();
}
if (!row || row.length === 0 && fields.length > 0) {
return void 0;
}
if (customResultMapper) {
return customResultMapper([row], normalizeFieldValue);
}
return mapResultRow(fields, row.map((v) => normalizeFieldValue(v)), joinsNotNullableMap);
}
values(placeholderValues) {
const params = fillPlaceholders(this.query.params, placeholderValues ?? {});
this.logger.logQuery(this.query.sql, params);
this.stmt.bind(params);
const rows = [];
while (this.stmt.step()) {
rows.push(this.stmt.get());
}
if (this.isOneTimeQuery) {
this.free();
}
return rows;
}
free() {
return this.stmt.free();
}
/** @internal */
isResponseInArrayMode() {
return this._isResponseInArrayMode;
}
}
function normalizeFieldValue(value) {
if (value instanceof Uint8Array) {
if (typeof Buffer !== "undefined") {
if (!(value instanceof Buffer)) {
return Buffer.from(value);
}
return value;
}
if (typeof TextDecoder !== "undefined") {
return new TextDecoder().decode(value);
}
throw new Error("TextDecoder is not available. Please provide either Buffer or TextDecoder polyfill.");
}
return value;
}
export {
PreparedQuery,
SQLJsSession,
SQLJsTransaction
};
//# sourceMappingURL=session.js.map

1
node_modules/drizzle-orm/sql-js/session.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long