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

32
node_modules/drizzle-orm/sqlite-core/alias.cjs generated vendored Normal file
View File

@ -0,0 +1,32 @@
"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 alias_exports = {};
__export(alias_exports, {
alias: () => alias
});
module.exports = __toCommonJS(alias_exports);
var import_alias = require("../alias.cjs");
function alias(table, alias2) {
return new Proxy(table, new import_alias.TableAliasProxyHandler(alias2, false));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
alias
});
//# sourceMappingURL=alias.cjs.map

1
node_modules/drizzle-orm/sqlite-core/alias.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/alias.ts"],"sourcesContent":["import { TableAliasProxyHandler } from '~/alias.ts';\nimport type { BuildAliasTable } from './query-builders/select.types.ts';\n\nimport type { SQLiteTable } from './table.ts';\nimport type { SQLiteViewBase } from './view-base.ts';\n\nexport function alias<TTable extends SQLiteTable | SQLiteViewBase, TAlias extends string>(\n\ttable: TTable,\n\talias: TAlias,\n): BuildAliasTable<TTable, TAlias> {\n\treturn new Proxy(table, new TableAliasProxyHandler(alias, false)) as any;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAuC;AAMhC,SAAS,MACf,OACAA,QACkC;AAClC,SAAO,IAAI,MAAM,OAAO,IAAI,oCAAuBA,QAAO,KAAK,CAAC;AACjE;","names":["alias"]}

4
node_modules/drizzle-orm/sqlite-core/alias.d.cts generated vendored Normal file
View File

@ -0,0 +1,4 @@
import type { BuildAliasTable } from "./query-builders/select.types.cjs";
import type { SQLiteTable } from "./table.cjs";
import type { SQLiteViewBase } from "./view-base.cjs";
export declare function alias<TTable extends SQLiteTable | SQLiteViewBase, TAlias extends string>(table: TTable, alias: TAlias): BuildAliasTable<TTable, TAlias>;

4
node_modules/drizzle-orm/sqlite-core/alias.d.ts generated vendored Normal file
View File

@ -0,0 +1,4 @@
import type { BuildAliasTable } from "./query-builders/select.types.js";
import type { SQLiteTable } from "./table.js";
import type { SQLiteViewBase } from "./view-base.js";
export declare function alias<TTable extends SQLiteTable | SQLiteViewBase, TAlias extends string>(table: TTable, alias: TAlias): BuildAliasTable<TTable, TAlias>;

8
node_modules/drizzle-orm/sqlite-core/alias.js generated vendored Normal file
View File

@ -0,0 +1,8 @@
import { TableAliasProxyHandler } from "../alias.js";
function alias(table, alias2) {
return new Proxy(table, new TableAliasProxyHandler(alias2, false));
}
export {
alias
};
//# sourceMappingURL=alias.js.map

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

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/alias.ts"],"sourcesContent":["import { TableAliasProxyHandler } from '~/alias.ts';\nimport type { BuildAliasTable } from './query-builders/select.types.ts';\n\nimport type { SQLiteTable } from './table.ts';\nimport type { SQLiteViewBase } from './view-base.ts';\n\nexport function alias<TTable extends SQLiteTable | SQLiteViewBase, TAlias extends string>(\n\ttable: TTable,\n\talias: TAlias,\n): BuildAliasTable<TTable, TAlias> {\n\treturn new Proxy(table, new TableAliasProxyHandler(alias, false)) as any;\n}\n"],"mappings":"AAAA,SAAS,8BAA8B;AAMhC,SAAS,MACf,OACAA,QACkC;AAClC,SAAO,IAAI,MAAM,OAAO,IAAI,uBAAuBA,QAAO,KAAK,CAAC;AACjE;","names":["alias"]}

57
node_modules/drizzle-orm/sqlite-core/checks.cjs generated vendored Normal file
View File

@ -0,0 +1,57 @@
"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 checks_exports = {};
__export(checks_exports, {
Check: () => Check,
CheckBuilder: () => CheckBuilder,
check: () => check
});
module.exports = __toCommonJS(checks_exports);
var import_entity = require("../entity.cjs");
class CheckBuilder {
constructor(name, value) {
this.name = name;
this.value = value;
}
static [import_entity.entityKind] = "SQLiteCheckBuilder";
brand;
build(table) {
return new Check(table, this);
}
}
class Check {
constructor(table, builder) {
this.table = table;
this.name = builder.name;
this.value = builder.value;
}
static [import_entity.entityKind] = "SQLiteCheck";
name;
value;
}
function check(name, value) {
return new CheckBuilder(name, value);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Check,
CheckBuilder,
check
});
//# sourceMappingURL=checks.cjs.map

1
node_modules/drizzle-orm/sqlite-core/checks.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/checks.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/sql.ts';\nimport type { SQLiteTable } from './table.ts';\n\nexport class CheckBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteCheckBuilder';\n\n\tprotected brand!: 'SQLiteConstraintBuilder';\n\n\tconstructor(public name: string, public value: SQL) {}\n\n\tbuild(table: SQLiteTable): Check {\n\t\treturn new Check(table, this);\n\t}\n}\n\nexport class Check {\n\tstatic readonly [entityKind]: string = 'SQLiteCheck';\n\n\tdeclare _: {\n\t\tbrand: 'SQLiteCheck';\n\t};\n\n\treadonly name: string;\n\treadonly value: SQL;\n\n\tconstructor(public table: SQLiteTable, builder: CheckBuilder) {\n\t\tthis.name = builder.name;\n\t\tthis.value = builder.value;\n\t}\n}\n\nexport function check(name: string, value: SQL): CheckBuilder {\n\treturn new CheckBuilder(name, value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAIpB,MAAM,aAAa;AAAA,EAKzB,YAAmB,MAAqB,OAAY;AAAjC;AAAqB;AAAA,EAAa;AAAA,EAJrD,QAAiB,wBAAU,IAAY;AAAA,EAE7B;AAAA,EAIV,MAAM,OAA2B;AAChC,WAAO,IAAI,MAAM,OAAO,IAAI;AAAA,EAC7B;AACD;AAEO,MAAM,MAAM;AAAA,EAUlB,YAAmB,OAAoB,SAAuB;AAA3C;AAClB,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AAAA,EACtB;AAAA,EAZA,QAAiB,wBAAU,IAAY;AAAA,EAM9B;AAAA,EACA;AAMV;AAEO,SAAS,MAAM,MAAc,OAA0B;AAC7D,SAAO,IAAI,aAAa,MAAM,KAAK;AACpC;","names":[]}

22
node_modules/drizzle-orm/sqlite-core/checks.d.cts generated vendored Normal file
View File

@ -0,0 +1,22 @@
import { entityKind } from "../entity.cjs";
import type { SQL } from "../sql/sql.cjs";
import type { SQLiteTable } from "./table.cjs";
export declare class CheckBuilder {
name: string;
value: SQL;
static readonly [entityKind]: string;
protected brand: 'SQLiteConstraintBuilder';
constructor(name: string, value: SQL);
build(table: SQLiteTable): Check;
}
export declare class Check {
table: SQLiteTable;
static readonly [entityKind]: string;
_: {
brand: 'SQLiteCheck';
};
readonly name: string;
readonly value: SQL;
constructor(table: SQLiteTable, builder: CheckBuilder);
}
export declare function check(name: string, value: SQL): CheckBuilder;

22
node_modules/drizzle-orm/sqlite-core/checks.d.ts generated vendored Normal file
View File

@ -0,0 +1,22 @@
import { entityKind } from "../entity.js";
import type { SQL } from "../sql/sql.js";
import type { SQLiteTable } from "./table.js";
export declare class CheckBuilder {
name: string;
value: SQL;
static readonly [entityKind]: string;
protected brand: 'SQLiteConstraintBuilder';
constructor(name: string, value: SQL);
build(table: SQLiteTable): Check;
}
export declare class Check {
table: SQLiteTable;
static readonly [entityKind]: string;
_: {
brand: 'SQLiteCheck';
};
readonly name: string;
readonly value: SQL;
constructor(table: SQLiteTable, builder: CheckBuilder);
}
export declare function check(name: string, value: SQL): CheckBuilder;

31
node_modules/drizzle-orm/sqlite-core/checks.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
import { entityKind } from "../entity.js";
class CheckBuilder {
constructor(name, value) {
this.name = name;
this.value = value;
}
static [entityKind] = "SQLiteCheckBuilder";
brand;
build(table) {
return new Check(table, this);
}
}
class Check {
constructor(table, builder) {
this.table = table;
this.name = builder.name;
this.value = builder.value;
}
static [entityKind] = "SQLiteCheck";
name;
value;
}
function check(name, value) {
return new CheckBuilder(name, value);
}
export {
Check,
CheckBuilder,
check
};
//# sourceMappingURL=checks.js.map

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

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/checks.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/sql.ts';\nimport type { SQLiteTable } from './table.ts';\n\nexport class CheckBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteCheckBuilder';\n\n\tprotected brand!: 'SQLiteConstraintBuilder';\n\n\tconstructor(public name: string, public value: SQL) {}\n\n\tbuild(table: SQLiteTable): Check {\n\t\treturn new Check(table, this);\n\t}\n}\n\nexport class Check {\n\tstatic readonly [entityKind]: string = 'SQLiteCheck';\n\n\tdeclare _: {\n\t\tbrand: 'SQLiteCheck';\n\t};\n\n\treadonly name: string;\n\treadonly value: SQL;\n\n\tconstructor(public table: SQLiteTable, builder: CheckBuilder) {\n\t\tthis.name = builder.name;\n\t\tthis.value = builder.value;\n\t}\n}\n\nexport function check(name: string, value: SQL): CheckBuilder {\n\treturn new CheckBuilder(name, value);\n}\n"],"mappings":"AAAA,SAAS,kBAAkB;AAIpB,MAAM,aAAa;AAAA,EAKzB,YAAmB,MAAqB,OAAY;AAAjC;AAAqB;AAAA,EAAa;AAAA,EAJrD,QAAiB,UAAU,IAAY;AAAA,EAE7B;AAAA,EAIV,MAAM,OAA2B;AAChC,WAAO,IAAI,MAAM,OAAO,IAAI;AAAA,EAC7B;AACD;AAEO,MAAM,MAAM;AAAA,EAUlB,YAAmB,OAAoB,SAAuB;AAA3C;AAClB,SAAK,OAAO,QAAQ;AACpB,SAAK,QAAQ,QAAQ;AAAA,EACtB;AAAA,EAZA,QAAiB,UAAU,IAAY;AAAA,EAM9B;AAAA,EACA;AAMV;AAEO,SAAS,MAAM,MAAc,OAA0B;AAC7D,SAAO,IAAI,aAAa,MAAM,KAAK;AACpC;","names":[]}

44
node_modules/drizzle-orm/sqlite-core/columns/all.cjs generated vendored Normal file
View File

@ -0,0 +1,44 @@
"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 all_exports = {};
__export(all_exports, {
getSQLiteColumnBuilders: () => getSQLiteColumnBuilders
});
module.exports = __toCommonJS(all_exports);
var import_blob = require("./blob.cjs");
var import_custom = require("./custom.cjs");
var import_integer = require("./integer.cjs");
var import_numeric = require("./numeric.cjs");
var import_real = require("./real.cjs");
var import_text = require("./text.cjs");
function getSQLiteColumnBuilders() {
return {
blob: import_blob.blob,
customType: import_custom.customType,
integer: import_integer.integer,
numeric: import_numeric.numeric,
real: import_real.real,
text: import_text.text
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
getSQLiteColumnBuilders
});
//# sourceMappingURL=all.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/all.ts"],"sourcesContent":["import { blob } from './blob.ts';\nimport { customType } from './custom.ts';\nimport { integer } from './integer.ts';\nimport { numeric } from './numeric.ts';\nimport { real } from './real.ts';\nimport { text } from './text.ts';\n\nexport function getSQLiteColumnBuilders() {\n\treturn {\n\t\tblob,\n\t\tcustomType,\n\t\tinteger,\n\t\tnumeric,\n\t\treal,\n\t\ttext,\n\t};\n}\n\nexport type SQLiteColumnBuilders = ReturnType<typeof getSQLiteColumnBuilders>;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,oBAA2B;AAC3B,qBAAwB;AACxB,qBAAwB;AACxB,kBAAqB;AACrB,kBAAqB;AAEd,SAAS,0BAA0B;AACzC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}

15
node_modules/drizzle-orm/sqlite-core/columns/all.d.cts generated vendored Normal file
View File

@ -0,0 +1,15 @@
import { blob } from "./blob.cjs";
import { customType } from "./custom.cjs";
import { integer } from "./integer.cjs";
import { numeric } from "./numeric.cjs";
import { real } from "./real.cjs";
import { text } from "./text.cjs";
export declare function getSQLiteColumnBuilders(): {
blob: typeof blob;
customType: typeof customType;
integer: typeof integer;
numeric: typeof numeric;
real: typeof real;
text: typeof text;
};
export type SQLiteColumnBuilders = ReturnType<typeof getSQLiteColumnBuilders>;

15
node_modules/drizzle-orm/sqlite-core/columns/all.d.ts generated vendored Normal file
View File

@ -0,0 +1,15 @@
import { blob } from "./blob.js";
import { customType } from "./custom.js";
import { integer } from "./integer.js";
import { numeric } from "./numeric.js";
import { real } from "./real.js";
import { text } from "./text.js";
export declare function getSQLiteColumnBuilders(): {
blob: typeof blob;
customType: typeof customType;
integer: typeof integer;
numeric: typeof numeric;
real: typeof real;
text: typeof text;
};
export type SQLiteColumnBuilders = ReturnType<typeof getSQLiteColumnBuilders>;

20
node_modules/drizzle-orm/sqlite-core/columns/all.js generated vendored Normal file
View File

@ -0,0 +1,20 @@
import { blob } from "./blob.js";
import { customType } from "./custom.js";
import { integer } from "./integer.js";
import { numeric } from "./numeric.js";
import { real } from "./real.js";
import { text } from "./text.js";
function getSQLiteColumnBuilders() {
return {
blob,
customType,
integer,
numeric,
real,
text
};
}
export {
getSQLiteColumnBuilders
};
//# sourceMappingURL=all.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/all.ts"],"sourcesContent":["import { blob } from './blob.ts';\nimport { customType } from './custom.ts';\nimport { integer } from './integer.ts';\nimport { numeric } from './numeric.ts';\nimport { real } from './real.ts';\nimport { text } from './text.ts';\n\nexport function getSQLiteColumnBuilders() {\n\treturn {\n\t\tblob,\n\t\tcustomType,\n\t\tinteger,\n\t\tnumeric,\n\t\treal,\n\t\ttext,\n\t};\n}\n\nexport type SQLiteColumnBuilders = ReturnType<typeof getSQLiteColumnBuilders>;\n"],"mappings":"AAAA,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,eAAe;AACxB,SAAS,eAAe;AACxB,SAAS,YAAY;AACrB,SAAS,YAAY;AAEd,SAAS,0BAA0B;AACzC,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;","names":[]}

130
node_modules/drizzle-orm/sqlite-core/columns/blob.cjs generated vendored Normal file
View File

@ -0,0 +1,130 @@
"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 blob_exports = {};
__export(blob_exports, {
SQLiteBigInt: () => SQLiteBigInt,
SQLiteBigIntBuilder: () => SQLiteBigIntBuilder,
SQLiteBlobBuffer: () => SQLiteBlobBuffer,
SQLiteBlobBufferBuilder: () => SQLiteBlobBufferBuilder,
SQLiteBlobJson: () => SQLiteBlobJson,
SQLiteBlobJsonBuilder: () => SQLiteBlobJsonBuilder,
blob: () => blob
});
module.exports = __toCommonJS(blob_exports);
var import_entity = require("../../entity.cjs");
var import_utils = require("../../utils.cjs");
var import_common = require("./common.cjs");
class SQLiteBigIntBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteBigIntBuilder";
constructor(name) {
super(name, "bigint", "SQLiteBigInt");
}
/** @internal */
build(table) {
return new SQLiteBigInt(table, this.config);
}
}
class SQLiteBigInt extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteBigInt";
getSQLType() {
return "blob";
}
mapFromDriverValue(value) {
if (Buffer.isBuffer(value)) {
return BigInt(value.toString());
}
if (value instanceof ArrayBuffer) {
const decoder = new TextDecoder();
return BigInt(decoder.decode(value));
}
return BigInt(String.fromCodePoint(...value));
}
mapToDriverValue(value) {
return Buffer.from(value.toString());
}
}
class SQLiteBlobJsonBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteBlobJsonBuilder";
constructor(name) {
super(name, "json", "SQLiteBlobJson");
}
/** @internal */
build(table) {
return new SQLiteBlobJson(
table,
this.config
);
}
}
class SQLiteBlobJson extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteBlobJson";
getSQLType() {
return "blob";
}
mapFromDriverValue(value) {
if (Buffer.isBuffer(value)) {
return JSON.parse(value.toString());
}
if (value instanceof ArrayBuffer) {
const decoder = new TextDecoder();
return JSON.parse(decoder.decode(value));
}
return JSON.parse(String.fromCodePoint(...value));
}
mapToDriverValue(value) {
return Buffer.from(JSON.stringify(value));
}
}
class SQLiteBlobBufferBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteBlobBufferBuilder";
constructor(name) {
super(name, "buffer", "SQLiteBlobBuffer");
}
/** @internal */
build(table) {
return new SQLiteBlobBuffer(table, this.config);
}
}
class SQLiteBlobBuffer extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteBlobBuffer";
getSQLType() {
return "blob";
}
}
function blob(a, b) {
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
if (config?.mode === "json") {
return new SQLiteBlobJsonBuilder(name);
}
if (config?.mode === "bigint") {
return new SQLiteBigIntBuilder(name);
}
return new SQLiteBlobBufferBuilder(name);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteBigInt,
SQLiteBigIntBuilder,
SQLiteBlobBuffer,
SQLiteBlobBufferBuilder,
SQLiteBlobJson,
SQLiteBlobJsonBuilder,
blob
});
//# sourceMappingURL=blob.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,71 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import { type Equal } from "../../utils.cjs";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.cjs";
type BlobMode = 'buffer' | 'json' | 'bigint';
export type SQLiteBigIntBuilderInitial<TName extends string> = SQLiteBigIntBuilder<{
name: TName;
dataType: 'bigint';
columnType: 'SQLiteBigInt';
data: bigint;
driverParam: Buffer;
enumValues: undefined;
}>;
export declare class SQLiteBigIntBuilder<T extends ColumnBuilderBaseConfig<'bigint', 'SQLiteBigInt'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteBigInt<T extends ColumnBaseConfig<'bigint', 'SQLiteBigInt'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
mapFromDriverValue(value: Buffer | Uint8Array | ArrayBuffer): bigint;
mapToDriverValue(value: bigint): Buffer;
}
export type SQLiteBlobJsonBuilderInitial<TName extends string> = SQLiteBlobJsonBuilder<{
name: TName;
dataType: 'json';
columnType: 'SQLiteBlobJson';
data: unknown;
driverParam: Buffer;
enumValues: undefined;
}>;
export declare class SQLiteBlobJsonBuilder<T extends ColumnBuilderBaseConfig<'json', 'SQLiteBlobJson'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteBlobJson<T extends ColumnBaseConfig<'json', 'SQLiteBlobJson'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
mapFromDriverValue(value: Buffer | Uint8Array | ArrayBuffer): T['data'];
mapToDriverValue(value: T['data']): Buffer;
}
export type SQLiteBlobBufferBuilderInitial<TName extends string> = SQLiteBlobBufferBuilder<{
name: TName;
dataType: 'buffer';
columnType: 'SQLiteBlobBuffer';
data: Buffer;
driverParam: Buffer;
enumValues: undefined;
}>;
export declare class SQLiteBlobBufferBuilder<T extends ColumnBuilderBaseConfig<'buffer', 'SQLiteBlobBuffer'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteBlobBuffer<T extends ColumnBaseConfig<'buffer', 'SQLiteBlobBuffer'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
}
export interface BlobConfig<TMode extends BlobMode = BlobMode> {
mode: TMode;
}
/**
* It's recommended to use `text('...', { mode: 'json' })` instead of `blob` in JSON mode, because it supports JSON functions:
* >All JSON functions currently throw an error if any of their arguments are BLOBs because BLOBs are reserved for a future enhancement in which BLOBs will store the binary encoding for JSON.
*
* https://www.sqlite.org/json1.html
*/
export declare function blob(): SQLiteBlobJsonBuilderInitial<''>;
export declare function blob<TMode extends BlobMode = BlobMode>(config?: BlobConfig<TMode>): Equal<TMode, 'bigint'> extends true ? SQLiteBigIntBuilderInitial<''> : Equal<TMode, 'buffer'> extends true ? SQLiteBlobBufferBuilderInitial<''> : SQLiteBlobJsonBuilderInitial<''>;
export declare function blob<TName extends string, TMode extends BlobMode = BlobMode>(name: TName, config?: BlobConfig<TMode>): Equal<TMode, 'bigint'> extends true ? SQLiteBigIntBuilderInitial<TName> : Equal<TMode, 'buffer'> extends true ? SQLiteBlobBufferBuilderInitial<TName> : SQLiteBlobJsonBuilderInitial<TName>;
export {};

71
node_modules/drizzle-orm/sqlite-core/columns/blob.d.ts generated vendored Normal file
View File

@ -0,0 +1,71 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import { type Equal } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
type BlobMode = 'buffer' | 'json' | 'bigint';
export type SQLiteBigIntBuilderInitial<TName extends string> = SQLiteBigIntBuilder<{
name: TName;
dataType: 'bigint';
columnType: 'SQLiteBigInt';
data: bigint;
driverParam: Buffer;
enumValues: undefined;
}>;
export declare class SQLiteBigIntBuilder<T extends ColumnBuilderBaseConfig<'bigint', 'SQLiteBigInt'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteBigInt<T extends ColumnBaseConfig<'bigint', 'SQLiteBigInt'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
mapFromDriverValue(value: Buffer | Uint8Array | ArrayBuffer): bigint;
mapToDriverValue(value: bigint): Buffer;
}
export type SQLiteBlobJsonBuilderInitial<TName extends string> = SQLiteBlobJsonBuilder<{
name: TName;
dataType: 'json';
columnType: 'SQLiteBlobJson';
data: unknown;
driverParam: Buffer;
enumValues: undefined;
}>;
export declare class SQLiteBlobJsonBuilder<T extends ColumnBuilderBaseConfig<'json', 'SQLiteBlobJson'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteBlobJson<T extends ColumnBaseConfig<'json', 'SQLiteBlobJson'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
mapFromDriverValue(value: Buffer | Uint8Array | ArrayBuffer): T['data'];
mapToDriverValue(value: T['data']): Buffer;
}
export type SQLiteBlobBufferBuilderInitial<TName extends string> = SQLiteBlobBufferBuilder<{
name: TName;
dataType: 'buffer';
columnType: 'SQLiteBlobBuffer';
data: Buffer;
driverParam: Buffer;
enumValues: undefined;
}>;
export declare class SQLiteBlobBufferBuilder<T extends ColumnBuilderBaseConfig<'buffer', 'SQLiteBlobBuffer'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteBlobBuffer<T extends ColumnBaseConfig<'buffer', 'SQLiteBlobBuffer'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
}
export interface BlobConfig<TMode extends BlobMode = BlobMode> {
mode: TMode;
}
/**
* It's recommended to use `text('...', { mode: 'json' })` instead of `blob` in JSON mode, because it supports JSON functions:
* >All JSON functions currently throw an error if any of their arguments are BLOBs because BLOBs are reserved for a future enhancement in which BLOBs will store the binary encoding for JSON.
*
* https://www.sqlite.org/json1.html
*/
export declare function blob(): SQLiteBlobJsonBuilderInitial<''>;
export declare function blob<TMode extends BlobMode = BlobMode>(config?: BlobConfig<TMode>): Equal<TMode, 'bigint'> extends true ? SQLiteBigIntBuilderInitial<''> : Equal<TMode, 'buffer'> extends true ? SQLiteBlobBufferBuilderInitial<''> : SQLiteBlobJsonBuilderInitial<''>;
export declare function blob<TName extends string, TMode extends BlobMode = BlobMode>(name: TName, config?: BlobConfig<TMode>): Equal<TMode, 'bigint'> extends true ? SQLiteBigIntBuilderInitial<TName> : Equal<TMode, 'buffer'> extends true ? SQLiteBlobBufferBuilderInitial<TName> : SQLiteBlobJsonBuilderInitial<TName>;
export {};

100
node_modules/drizzle-orm/sqlite-core/columns/blob.js generated vendored Normal file
View File

@ -0,0 +1,100 @@
import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteBigIntBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteBigIntBuilder";
constructor(name) {
super(name, "bigint", "SQLiteBigInt");
}
/** @internal */
build(table) {
return new SQLiteBigInt(table, this.config);
}
}
class SQLiteBigInt extends SQLiteColumn {
static [entityKind] = "SQLiteBigInt";
getSQLType() {
return "blob";
}
mapFromDriverValue(value) {
if (Buffer.isBuffer(value)) {
return BigInt(value.toString());
}
if (value instanceof ArrayBuffer) {
const decoder = new TextDecoder();
return BigInt(decoder.decode(value));
}
return BigInt(String.fromCodePoint(...value));
}
mapToDriverValue(value) {
return Buffer.from(value.toString());
}
}
class SQLiteBlobJsonBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteBlobJsonBuilder";
constructor(name) {
super(name, "json", "SQLiteBlobJson");
}
/** @internal */
build(table) {
return new SQLiteBlobJson(
table,
this.config
);
}
}
class SQLiteBlobJson extends SQLiteColumn {
static [entityKind] = "SQLiteBlobJson";
getSQLType() {
return "blob";
}
mapFromDriverValue(value) {
if (Buffer.isBuffer(value)) {
return JSON.parse(value.toString());
}
if (value instanceof ArrayBuffer) {
const decoder = new TextDecoder();
return JSON.parse(decoder.decode(value));
}
return JSON.parse(String.fromCodePoint(...value));
}
mapToDriverValue(value) {
return Buffer.from(JSON.stringify(value));
}
}
class SQLiteBlobBufferBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteBlobBufferBuilder";
constructor(name) {
super(name, "buffer", "SQLiteBlobBuffer");
}
/** @internal */
build(table) {
return new SQLiteBlobBuffer(table, this.config);
}
}
class SQLiteBlobBuffer extends SQLiteColumn {
static [entityKind] = "SQLiteBlobBuffer";
getSQLType() {
return "blob";
}
}
function blob(a, b) {
const { name, config } = getColumnNameAndConfig(a, b);
if (config?.mode === "json") {
return new SQLiteBlobJsonBuilder(name);
}
if (config?.mode === "bigint") {
return new SQLiteBigIntBuilder(name);
}
return new SQLiteBlobBufferBuilder(name);
}
export {
SQLiteBigInt,
SQLiteBigIntBuilder,
SQLiteBlobBuffer,
SQLiteBlobBufferBuilder,
SQLiteBlobJson,
SQLiteBlobJsonBuilder,
blob
};
//# sourceMappingURL=blob.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,84 @@
"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 common_exports = {};
__export(common_exports, {
SQLiteColumn: () => SQLiteColumn,
SQLiteColumnBuilder: () => SQLiteColumnBuilder
});
module.exports = __toCommonJS(common_exports);
var import_column_builder = require("../../column-builder.cjs");
var import_column = require("../../column.cjs");
var import_entity = require("../../entity.cjs");
var import_foreign_keys = require("../foreign-keys.cjs");
var import_unique_constraint = require("../unique-constraint.cjs");
class SQLiteColumnBuilder extends import_column_builder.ColumnBuilder {
static [import_entity.entityKind] = "SQLiteColumnBuilder";
foreignKeyConfigs = [];
references(ref, actions = {}) {
this.foreignKeyConfigs.push({ ref, actions });
return this;
}
unique(name) {
this.config.isUnique = true;
this.config.uniqueName = name;
return this;
}
generatedAlwaysAs(as, config) {
this.config.generated = {
as,
type: "always",
mode: config?.mode ?? "virtual"
};
return this;
}
/** @internal */
buildForeignKeys(column, table) {
return this.foreignKeyConfigs.map(({ ref, actions }) => {
return ((ref2, actions2) => {
const builder = new import_foreign_keys.ForeignKeyBuilder(() => {
const foreignColumn = ref2();
return { columns: [column], foreignColumns: [foreignColumn] };
});
if (actions2.onUpdate) {
builder.onUpdate(actions2.onUpdate);
}
if (actions2.onDelete) {
builder.onDelete(actions2.onDelete);
}
return builder.build(table);
})(ref, actions);
});
}
}
class SQLiteColumn extends import_column.Column {
constructor(table, config) {
if (!config.uniqueName) {
config.uniqueName = (0, import_unique_constraint.uniqueKeyName)(table, [config.name]);
}
super(table, config);
this.table = table;
}
static [import_entity.entityKind] = "SQLiteColumn";
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteColumn,
SQLiteColumnBuilder
});
//# sourceMappingURL=common.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
import type { ColumnBuilderBase, ColumnBuilderBaseConfig, ColumnBuilderExtraConfig, ColumnBuilderRuntimeConfig, ColumnDataType, HasGenerated } from "../../column-builder.cjs";
import { ColumnBuilder } from "../../column-builder.cjs";
import { Column } from "../../column.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import type { SQL } from "../../sql/sql.cjs";
import type { UpdateDeleteAction } from "../foreign-keys.cjs";
import type { SQLiteTable } from "../table.cjs";
import type { Update } from "../../utils.cjs";
export interface ReferenceConfig {
ref: () => SQLiteColumn;
actions: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
};
}
export interface SQLiteColumnBuilderBase<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TTypeConfig extends object = object> extends ColumnBuilderBase<T, TTypeConfig & {
dialect: 'sqlite';
}> {
}
export interface SQLiteGeneratedColumnConfig {
mode?: 'virtual' | 'stored';
}
export declare abstract class SQLiteColumnBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object, TTypeConfig extends object = object, TExtraConfig extends ColumnBuilderExtraConfig = object> extends ColumnBuilder<T, TRuntimeConfig, TTypeConfig & {
dialect: 'sqlite';
}, TExtraConfig> implements SQLiteColumnBuilderBase<T, TTypeConfig> {
static readonly [entityKind]: string;
private foreignKeyConfigs;
references(ref: ReferenceConfig['ref'], actions?: ReferenceConfig['actions']): this;
unique(name?: string): this;
generatedAlwaysAs(as: SQL | T['data'] | (() => SQL), config?: SQLiteGeneratedColumnConfig): HasGenerated<this, {
type: 'always';
}>;
}
export declare abstract class SQLiteColumn<T extends ColumnBaseConfig<ColumnDataType, string> = ColumnBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = {}, TTypeConfig extends object = {}> extends Column<T, TRuntimeConfig, TTypeConfig & {
dialect: 'sqlite';
}> {
readonly table: SQLiteTable;
static readonly [entityKind]: string;
constructor(table: SQLiteTable, config: ColumnBuilderRuntimeConfig<T['data'], TRuntimeConfig>);
}
export type AnySQLiteColumn<TPartial extends Partial<ColumnBaseConfig<ColumnDataType, string>> = {}> = SQLiteColumn<Required<Update<ColumnBaseConfig<ColumnDataType, string>, TPartial>>>;

View File

@ -0,0 +1,42 @@
import type { ColumnBuilderBase, ColumnBuilderBaseConfig, ColumnBuilderExtraConfig, ColumnBuilderRuntimeConfig, ColumnDataType, HasGenerated } from "../../column-builder.js";
import { ColumnBuilder } from "../../column-builder.js";
import { Column } from "../../column.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import type { SQL } from "../../sql/sql.js";
import type { UpdateDeleteAction } from "../foreign-keys.js";
import type { SQLiteTable } from "../table.js";
import type { Update } from "../../utils.js";
export interface ReferenceConfig {
ref: () => SQLiteColumn;
actions: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
};
}
export interface SQLiteColumnBuilderBase<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TTypeConfig extends object = object> extends ColumnBuilderBase<T, TTypeConfig & {
dialect: 'sqlite';
}> {
}
export interface SQLiteGeneratedColumnConfig {
mode?: 'virtual' | 'stored';
}
export declare abstract class SQLiteColumnBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object, TTypeConfig extends object = object, TExtraConfig extends ColumnBuilderExtraConfig = object> extends ColumnBuilder<T, TRuntimeConfig, TTypeConfig & {
dialect: 'sqlite';
}, TExtraConfig> implements SQLiteColumnBuilderBase<T, TTypeConfig> {
static readonly [entityKind]: string;
private foreignKeyConfigs;
references(ref: ReferenceConfig['ref'], actions?: ReferenceConfig['actions']): this;
unique(name?: string): this;
generatedAlwaysAs(as: SQL | T['data'] | (() => SQL), config?: SQLiteGeneratedColumnConfig): HasGenerated<this, {
type: 'always';
}>;
}
export declare abstract class SQLiteColumn<T extends ColumnBaseConfig<ColumnDataType, string> = ColumnBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = {}, TTypeConfig extends object = {}> extends Column<T, TRuntimeConfig, TTypeConfig & {
dialect: 'sqlite';
}> {
readonly table: SQLiteTable;
static readonly [entityKind]: string;
constructor(table: SQLiteTable, config: ColumnBuilderRuntimeConfig<T['data'], TRuntimeConfig>);
}
export type AnySQLiteColumn<TPartial extends Partial<ColumnBaseConfig<ColumnDataType, string>> = {}> = SQLiteColumn<Required<Update<ColumnBaseConfig<ColumnDataType, string>, TPartial>>>;

59
node_modules/drizzle-orm/sqlite-core/columns/common.js generated vendored Normal file
View File

@ -0,0 +1,59 @@
import { ColumnBuilder } from "../../column-builder.js";
import { Column } from "../../column.js";
import { entityKind } from "../../entity.js";
import { ForeignKeyBuilder } from "../foreign-keys.js";
import { uniqueKeyName } from "../unique-constraint.js";
class SQLiteColumnBuilder extends ColumnBuilder {
static [entityKind] = "SQLiteColumnBuilder";
foreignKeyConfigs = [];
references(ref, actions = {}) {
this.foreignKeyConfigs.push({ ref, actions });
return this;
}
unique(name) {
this.config.isUnique = true;
this.config.uniqueName = name;
return this;
}
generatedAlwaysAs(as, config) {
this.config.generated = {
as,
type: "always",
mode: config?.mode ?? "virtual"
};
return this;
}
/** @internal */
buildForeignKeys(column, table) {
return this.foreignKeyConfigs.map(({ ref, actions }) => {
return ((ref2, actions2) => {
const builder = new ForeignKeyBuilder(() => {
const foreignColumn = ref2();
return { columns: [column], foreignColumns: [foreignColumn] };
});
if (actions2.onUpdate) {
builder.onUpdate(actions2.onUpdate);
}
if (actions2.onDelete) {
builder.onDelete(actions2.onDelete);
}
return builder.build(table);
})(ref, actions);
});
}
}
class SQLiteColumn extends Column {
constructor(table, config) {
if (!config.uniqueName) {
config.uniqueName = uniqueKeyName(table, [config.name]);
}
super(table, config);
this.table = table;
}
static [entityKind] = "SQLiteColumn";
}
export {
SQLiteColumn,
SQLiteColumnBuilder
};
//# sourceMappingURL=common.js.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,81 @@
"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 custom_exports = {};
__export(custom_exports, {
SQLiteCustomColumn: () => SQLiteCustomColumn,
SQLiteCustomColumnBuilder: () => SQLiteCustomColumnBuilder,
customType: () => customType
});
module.exports = __toCommonJS(custom_exports);
var import_entity = require("../../entity.cjs");
var import_utils = require("../../utils.cjs");
var import_common = require("./common.cjs");
class SQLiteCustomColumnBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteCustomColumnBuilder";
constructor(name, fieldConfig, customTypeParams) {
super(name, "custom", "SQLiteCustomColumn");
this.config.fieldConfig = fieldConfig;
this.config.customTypeParams = customTypeParams;
}
/** @internal */
build(table) {
return new SQLiteCustomColumn(
table,
this.config
);
}
}
class SQLiteCustomColumn extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteCustomColumn";
sqlName;
mapTo;
mapFrom;
constructor(table, config) {
super(table, config);
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
this.mapTo = config.customTypeParams.toDriver;
this.mapFrom = config.customTypeParams.fromDriver;
}
getSQLType() {
return this.sqlName;
}
mapFromDriverValue(value) {
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
}
mapToDriverValue(value) {
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
}
}
function customType(customTypeParams) {
return (a, b) => {
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
return new SQLiteCustomColumnBuilder(
name,
config,
customTypeParams
);
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteCustomColumn,
SQLiteCustomColumnBuilder,
customType
});
//# sourceMappingURL=custom.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,155 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import type { SQL } from "../../sql/sql.cjs";
import type { AnySQLiteTable } from "../table.cjs";
import { type Equal } from "../../utils.cjs";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.cjs";
export type ConvertCustomConfig<TName extends string, T extends Partial<CustomTypeValues>> = {
name: TName;
dataType: 'custom';
columnType: 'SQLiteCustomColumn';
data: T['data'];
driverParam: T['driverData'];
enumValues: undefined;
} & (T['notNull'] extends true ? {
notNull: true;
} : {}) & (T['default'] extends true ? {
hasDefault: true;
} : {});
export interface SQLiteCustomColumnInnerConfig {
customTypeValues: CustomTypeValues;
}
export declare class SQLiteCustomColumnBuilder<T extends ColumnBuilderBaseConfig<'custom', 'SQLiteCustomColumn'>> extends SQLiteColumnBuilder<T, {
fieldConfig: CustomTypeValues['config'];
customTypeParams: CustomTypeParams<any>;
}, {
sqliteColumnBuilderBrand: 'SQLiteCustomColumnBuilderBrand';
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], fieldConfig: CustomTypeValues['config'], customTypeParams: CustomTypeParams<any>);
}
export declare class SQLiteCustomColumn<T extends ColumnBaseConfig<'custom', 'SQLiteCustomColumn'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
private sqlName;
private mapTo?;
private mapFrom?;
constructor(table: AnySQLiteTable<{
name: T['tableName'];
}>, config: SQLiteCustomColumnBuilder<T>['config']);
getSQLType(): string;
mapFromDriverValue(value: T['driverParam']): T['data'];
mapToDriverValue(value: T['data']): T['driverParam'];
}
export type CustomTypeValues = {
/**
* Required type for custom column, that will infer proper type model
*
* Examples:
*
* If you want your column to be `string` type after selecting/or on inserting - use `data: string`. Like `text`, `varchar`
*
* If you want your column to be `number` type after selecting/or on inserting - use `data: number`. Like `integer`
*/
data: unknown;
/**
* Type helper, that represents what type database driver is accepting for specific database data type
*/
driverData?: unknown;
/**
* What config type should be used for {@link CustomTypeParams} `dataType` generation
*/
config?: Record<string, any>;
/**
* Whether the config argument should be required or not
* @default false
*/
configRequired?: boolean;
/**
* If your custom data type should be notNull by default you can use `notNull: true`
*
* @example
* const customSerial = customType<{ data: number, notNull: true, default: true }>({
* dataType() {
* return 'serial';
* },
* });
*/
notNull?: boolean;
/**
* If your custom data type has default you can use `default: true`
*
* @example
* const customSerial = customType<{ data: number, notNull: true, default: true }>({
* dataType() {
* return 'serial';
* },
* });
*/
default?: boolean;
};
export interface CustomTypeParams<T extends CustomTypeValues> {
/**
* Database data type string representation, that is used for migrations
* @example
* ```
* `jsonb`, `text`
* ```
*
* If database data type needs additional params you can use them from `config` param
* @example
* ```
* `varchar(256)`, `numeric(2,3)`
* ```
*
* To make `config` be of specific type please use config generic in {@link CustomTypeValues}
*
* @example
* Usage example
* ```
* dataType() {
* return 'boolean';
* },
* ```
* Or
* ```
* dataType(config) {
* return typeof config.length !== 'undefined' ? `varchar(${config.length})` : `varchar`;
* }
* ```
*/
dataType: (config: T['config'] | (Equal<T['configRequired'], true> extends true ? never : undefined)) => string;
/**
* Optional mapping function, between user input and driver
* @example
* For example, when using jsonb we need to map JS/TS object to string before writing to database
* ```
* toDriver(value: TData): string {
* return JSON.stringify(value);
* }
* ```
*/
toDriver?: (value: T['data']) => T['driverData'] | SQL;
/**
* Optional mapping function, that is responsible for data mapping from database to JS/TS code
* @example
* For example, when using timestamp we need to map string Date representation to JS Date
* ```
* fromDriver(value: string): Date {
* return new Date(value);
* },
* ```
*/
fromDriver?: (value: T['driverData']) => T['data'];
}
/**
* Custom sqlite database data type generator
*/
export declare function customType<T extends CustomTypeValues = CustomTypeValues>(customTypeParams: CustomTypeParams<T>): Equal<T['configRequired'], true> extends true ? {
<TConfig extends Record<string, any> & T['config']>(fieldConfig: TConfig): SQLiteCustomColumnBuilder<ConvertCustomConfig<'', T>>;
<TName extends string>(dbName: TName, fieldConfig: T['config']): SQLiteCustomColumnBuilder<ConvertCustomConfig<TName, T>>;
} : {
(): SQLiteCustomColumnBuilder<ConvertCustomConfig<'', T>>;
<TConfig extends Record<string, any> & T['config']>(fieldConfig?: TConfig): SQLiteCustomColumnBuilder<ConvertCustomConfig<'', T>>;
<TName extends string>(dbName: TName, fieldConfig?: T['config']): SQLiteCustomColumnBuilder<ConvertCustomConfig<TName, T>>;
};

View File

@ -0,0 +1,155 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import type { SQL } from "../../sql/sql.js";
import type { AnySQLiteTable } from "../table.js";
import { type Equal } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
export type ConvertCustomConfig<TName extends string, T extends Partial<CustomTypeValues>> = {
name: TName;
dataType: 'custom';
columnType: 'SQLiteCustomColumn';
data: T['data'];
driverParam: T['driverData'];
enumValues: undefined;
} & (T['notNull'] extends true ? {
notNull: true;
} : {}) & (T['default'] extends true ? {
hasDefault: true;
} : {});
export interface SQLiteCustomColumnInnerConfig {
customTypeValues: CustomTypeValues;
}
export declare class SQLiteCustomColumnBuilder<T extends ColumnBuilderBaseConfig<'custom', 'SQLiteCustomColumn'>> extends SQLiteColumnBuilder<T, {
fieldConfig: CustomTypeValues['config'];
customTypeParams: CustomTypeParams<any>;
}, {
sqliteColumnBuilderBrand: 'SQLiteCustomColumnBuilderBrand';
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], fieldConfig: CustomTypeValues['config'], customTypeParams: CustomTypeParams<any>);
}
export declare class SQLiteCustomColumn<T extends ColumnBaseConfig<'custom', 'SQLiteCustomColumn'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
private sqlName;
private mapTo?;
private mapFrom?;
constructor(table: AnySQLiteTable<{
name: T['tableName'];
}>, config: SQLiteCustomColumnBuilder<T>['config']);
getSQLType(): string;
mapFromDriverValue(value: T['driverParam']): T['data'];
mapToDriverValue(value: T['data']): T['driverParam'];
}
export type CustomTypeValues = {
/**
* Required type for custom column, that will infer proper type model
*
* Examples:
*
* If you want your column to be `string` type after selecting/or on inserting - use `data: string`. Like `text`, `varchar`
*
* If you want your column to be `number` type after selecting/or on inserting - use `data: number`. Like `integer`
*/
data: unknown;
/**
* Type helper, that represents what type database driver is accepting for specific database data type
*/
driverData?: unknown;
/**
* What config type should be used for {@link CustomTypeParams} `dataType` generation
*/
config?: Record<string, any>;
/**
* Whether the config argument should be required or not
* @default false
*/
configRequired?: boolean;
/**
* If your custom data type should be notNull by default you can use `notNull: true`
*
* @example
* const customSerial = customType<{ data: number, notNull: true, default: true }>({
* dataType() {
* return 'serial';
* },
* });
*/
notNull?: boolean;
/**
* If your custom data type has default you can use `default: true`
*
* @example
* const customSerial = customType<{ data: number, notNull: true, default: true }>({
* dataType() {
* return 'serial';
* },
* });
*/
default?: boolean;
};
export interface CustomTypeParams<T extends CustomTypeValues> {
/**
* Database data type string representation, that is used for migrations
* @example
* ```
* `jsonb`, `text`
* ```
*
* If database data type needs additional params you can use them from `config` param
* @example
* ```
* `varchar(256)`, `numeric(2,3)`
* ```
*
* To make `config` be of specific type please use config generic in {@link CustomTypeValues}
*
* @example
* Usage example
* ```
* dataType() {
* return 'boolean';
* },
* ```
* Or
* ```
* dataType(config) {
* return typeof config.length !== 'undefined' ? `varchar(${config.length})` : `varchar`;
* }
* ```
*/
dataType: (config: T['config'] | (Equal<T['configRequired'], true> extends true ? never : undefined)) => string;
/**
* Optional mapping function, between user input and driver
* @example
* For example, when using jsonb we need to map JS/TS object to string before writing to database
* ```
* toDriver(value: TData): string {
* return JSON.stringify(value);
* }
* ```
*/
toDriver?: (value: T['data']) => T['driverData'] | SQL;
/**
* Optional mapping function, that is responsible for data mapping from database to JS/TS code
* @example
* For example, when using timestamp we need to map string Date representation to JS Date
* ```
* fromDriver(value: string): Date {
* return new Date(value);
* },
* ```
*/
fromDriver?: (value: T['driverData']) => T['data'];
}
/**
* Custom sqlite database data type generator
*/
export declare function customType<T extends CustomTypeValues = CustomTypeValues>(customTypeParams: CustomTypeParams<T>): Equal<T['configRequired'], true> extends true ? {
<TConfig extends Record<string, any> & T['config']>(fieldConfig: TConfig): SQLiteCustomColumnBuilder<ConvertCustomConfig<'', T>>;
<TName extends string>(dbName: TName, fieldConfig: T['config']): SQLiteCustomColumnBuilder<ConvertCustomConfig<TName, T>>;
} : {
(): SQLiteCustomColumnBuilder<ConvertCustomConfig<'', T>>;
<TConfig extends Record<string, any> & T['config']>(fieldConfig?: TConfig): SQLiteCustomColumnBuilder<ConvertCustomConfig<'', T>>;
<TName extends string>(dbName: TName, fieldConfig?: T['config']): SQLiteCustomColumnBuilder<ConvertCustomConfig<TName, T>>;
};

55
node_modules/drizzle-orm/sqlite-core/columns/custom.js generated vendored Normal file
View File

@ -0,0 +1,55 @@
import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteCustomColumnBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteCustomColumnBuilder";
constructor(name, fieldConfig, customTypeParams) {
super(name, "custom", "SQLiteCustomColumn");
this.config.fieldConfig = fieldConfig;
this.config.customTypeParams = customTypeParams;
}
/** @internal */
build(table) {
return new SQLiteCustomColumn(
table,
this.config
);
}
}
class SQLiteCustomColumn extends SQLiteColumn {
static [entityKind] = "SQLiteCustomColumn";
sqlName;
mapTo;
mapFrom;
constructor(table, config) {
super(table, config);
this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
this.mapTo = config.customTypeParams.toDriver;
this.mapFrom = config.customTypeParams.fromDriver;
}
getSQLType() {
return this.sqlName;
}
mapFromDriverValue(value) {
return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
}
mapToDriverValue(value) {
return typeof this.mapTo === "function" ? this.mapTo(value) : value;
}
}
function customType(customTypeParams) {
return (a, b) => {
const { name, config } = getColumnNameAndConfig(a, b);
return new SQLiteCustomColumnBuilder(
name,
config,
customTypeParams
);
};
}
export {
SQLiteCustomColumn,
SQLiteCustomColumnBuilder,
customType
};
//# sourceMappingURL=custom.js.map

File diff suppressed because one or more lines are too long

35
node_modules/drizzle-orm/sqlite-core/columns/index.cjs generated vendored Normal file
View File

@ -0,0 +1,35 @@
"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 columns_exports = {};
module.exports = __toCommonJS(columns_exports);
__reExport(columns_exports, require("./blob.cjs"), module.exports);
__reExport(columns_exports, require("./common.cjs"), module.exports);
__reExport(columns_exports, require("./custom.cjs"), module.exports);
__reExport(columns_exports, require("./integer.cjs"), module.exports);
__reExport(columns_exports, require("./numeric.cjs"), module.exports);
__reExport(columns_exports, require("./real.cjs"), module.exports);
__reExport(columns_exports, require("./text.cjs"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
...require("./blob.cjs"),
...require("./common.cjs"),
...require("./custom.cjs"),
...require("./integer.cjs"),
...require("./numeric.cjs"),
...require("./real.cjs"),
...require("./text.cjs")
});
//# sourceMappingURL=index.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/index.ts"],"sourcesContent":["export * from './blob.ts';\nexport * from './common.ts';\nexport * from './custom.ts';\nexport * from './integer.ts';\nexport * from './numeric.ts';\nexport * from './real.ts';\nexport * from './text.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,sBAAd;AACA,4BAAc,wBADd;AAEA,4BAAc,wBAFd;AAGA,4BAAc,yBAHd;AAIA,4BAAc,yBAJd;AAKA,4BAAc,sBALd;AAMA,4BAAc,sBANd;","names":[]}

View File

@ -0,0 +1,7 @@
export * from "./blob.cjs";
export * from "./common.cjs";
export * from "./custom.cjs";
export * from "./integer.cjs";
export * from "./numeric.cjs";
export * from "./real.cjs";
export * from "./text.cjs";

View File

@ -0,0 +1,7 @@
export * from "./blob.js";
export * from "./common.js";
export * from "./custom.js";
export * from "./integer.js";
export * from "./numeric.js";
export * from "./real.js";
export * from "./text.js";

View File

@ -0,0 +1,8 @@
export * from "./blob.js";
export * from "./common.js";
export * from "./custom.js";
export * from "./integer.js";
export * from "./numeric.js";
export * from "./real.js";
export * from "./text.js";
//# sourceMappingURL=index.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/index.ts"],"sourcesContent":["export * from './blob.ts';\nexport * from './common.ts';\nexport * from './custom.ts';\nexport * from './integer.ts';\nexport * from './numeric.ts';\nexport * from './real.ts';\nexport * from './text.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}

View File

@ -0,0 +1,158 @@
"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 integer_exports = {};
__export(integer_exports, {
SQLiteBaseInteger: () => SQLiteBaseInteger,
SQLiteBaseIntegerBuilder: () => SQLiteBaseIntegerBuilder,
SQLiteBoolean: () => SQLiteBoolean,
SQLiteBooleanBuilder: () => SQLiteBooleanBuilder,
SQLiteInteger: () => SQLiteInteger,
SQLiteIntegerBuilder: () => SQLiteIntegerBuilder,
SQLiteTimestamp: () => SQLiteTimestamp,
SQLiteTimestampBuilder: () => SQLiteTimestampBuilder,
int: () => int,
integer: () => integer
});
module.exports = __toCommonJS(integer_exports);
var import_entity = require("../../entity.cjs");
var import_sql = require("../../sql/sql.cjs");
var import_utils = require("../../utils.cjs");
var import_common = require("./common.cjs");
class SQLiteBaseIntegerBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteBaseIntegerBuilder";
constructor(name, dataType, columnType) {
super(name, dataType, columnType);
this.config.autoIncrement = false;
}
primaryKey(config) {
if (config?.autoIncrement) {
this.config.autoIncrement = true;
}
this.config.hasDefault = true;
return super.primaryKey();
}
}
class SQLiteBaseInteger extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteBaseInteger";
autoIncrement = this.config.autoIncrement;
getSQLType() {
return "integer";
}
}
class SQLiteIntegerBuilder extends SQLiteBaseIntegerBuilder {
static [import_entity.entityKind] = "SQLiteIntegerBuilder";
constructor(name) {
super(name, "number", "SQLiteInteger");
}
build(table) {
return new SQLiteInteger(
table,
this.config
);
}
}
class SQLiteInteger extends SQLiteBaseInteger {
static [import_entity.entityKind] = "SQLiteInteger";
}
class SQLiteTimestampBuilder extends SQLiteBaseIntegerBuilder {
static [import_entity.entityKind] = "SQLiteTimestampBuilder";
constructor(name, mode) {
super(name, "date", "SQLiteTimestamp");
this.config.mode = mode;
}
/**
* @deprecated Use `default()` with your own expression instead.
*
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
*/
defaultNow() {
return this.default(import_sql.sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
}
build(table) {
return new SQLiteTimestamp(
table,
this.config
);
}
}
class SQLiteTimestamp extends SQLiteBaseInteger {
static [import_entity.entityKind] = "SQLiteTimestamp";
mode = this.config.mode;
mapFromDriverValue(value) {
if (this.config.mode === "timestamp") {
return new Date(value * 1e3);
}
return new Date(value);
}
mapToDriverValue(value) {
const unix = value.getTime();
if (this.config.mode === "timestamp") {
return Math.floor(unix / 1e3);
}
return unix;
}
}
class SQLiteBooleanBuilder extends SQLiteBaseIntegerBuilder {
static [import_entity.entityKind] = "SQLiteBooleanBuilder";
constructor(name, mode) {
super(name, "boolean", "SQLiteBoolean");
this.config.mode = mode;
}
build(table) {
return new SQLiteBoolean(
table,
this.config
);
}
}
class SQLiteBoolean extends SQLiteBaseInteger {
static [import_entity.entityKind] = "SQLiteBoolean";
mode = this.config.mode;
mapFromDriverValue(value) {
return Number(value) === 1;
}
mapToDriverValue(value) {
return value ? 1 : 0;
}
}
function integer(a, b) {
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") {
return new SQLiteTimestampBuilder(name, config.mode);
}
if (config?.mode === "boolean") {
return new SQLiteBooleanBuilder(name, config.mode);
}
return new SQLiteIntegerBuilder(name);
}
const int = integer;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteBaseInteger,
SQLiteBaseIntegerBuilder,
SQLiteBoolean,
SQLiteBooleanBuilder,
SQLiteInteger,
SQLiteIntegerBuilder,
SQLiteTimestamp,
SQLiteTimestampBuilder,
int,
integer
});
//# sourceMappingURL=integer.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,108 @@
import type { ColumnBuilderBaseConfig, ColumnDataType, HasDefault, IsPrimaryKey, MakeColumnConfig, NotNull } from "../../column-builder.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import type { OnConflict } from "../utils.cjs";
import { type Equal, type Or } from "../../utils.cjs";
import type { AnySQLiteTable } from "../table.cjs";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.cjs";
export interface PrimaryKeyConfig {
autoIncrement?: boolean;
onConflict?: OnConflict;
}
export declare abstract class SQLiteBaseIntegerBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends SQLiteColumnBuilder<T, TRuntimeConfig & {
autoIncrement: boolean;
}, {}, {
primaryKeyHasDefault: true;
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], dataType: T['dataType'], columnType: T['columnType']);
primaryKey(config?: PrimaryKeyConfig): IsPrimaryKey<HasDefault<NotNull<this>>>;
}
export declare abstract class SQLiteBaseInteger<T extends ColumnBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends SQLiteColumn<T, TRuntimeConfig & {
autoIncrement: boolean;
}> {
static readonly [entityKind]: string;
readonly autoIncrement: boolean;
getSQLType(): string;
}
export type SQLiteIntegerBuilderInitial<TName extends string> = SQLiteIntegerBuilder<{
name: TName;
dataType: 'number';
columnType: 'SQLiteInteger';
data: number;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteIntegerBuilder<T extends ColumnBuilderBaseConfig<'number', 'SQLiteInteger'>> extends SQLiteBaseIntegerBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
build<TTableName extends string>(table: AnySQLiteTable<{
name: TTableName;
}>): SQLiteInteger<MakeColumnConfig<T, TTableName>>;
}
export declare class SQLiteInteger<T extends ColumnBaseConfig<'number', 'SQLiteInteger'>> extends SQLiteBaseInteger<T> {
static readonly [entityKind]: string;
}
export type SQLiteTimestampBuilderInitial<TName extends string> = SQLiteTimestampBuilder<{
name: TName;
dataType: 'date';
columnType: 'SQLiteTimestamp';
data: Date;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteTimestampBuilder<T extends ColumnBuilderBaseConfig<'date', 'SQLiteTimestamp'>> extends SQLiteBaseIntegerBuilder<T, {
mode: 'timestamp' | 'timestamp_ms';
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], mode: 'timestamp' | 'timestamp_ms');
/**
* @deprecated Use `default()` with your own expression instead.
*
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
*/
defaultNow(): HasDefault<this>;
build<TTableName extends string>(table: AnySQLiteTable<{
name: TTableName;
}>): SQLiteTimestamp<MakeColumnConfig<T, TTableName>>;
}
export declare class SQLiteTimestamp<T extends ColumnBaseConfig<'date', 'SQLiteTimestamp'>> extends SQLiteBaseInteger<T, {
mode: 'timestamp' | 'timestamp_ms';
}> {
static readonly [entityKind]: string;
readonly mode: 'timestamp' | 'timestamp_ms';
mapFromDriverValue(value: number): Date;
mapToDriverValue(value: Date): number;
}
export type SQLiteBooleanBuilderInitial<TName extends string> = SQLiteBooleanBuilder<{
name: TName;
dataType: 'boolean';
columnType: 'SQLiteBoolean';
data: boolean;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteBooleanBuilder<T extends ColumnBuilderBaseConfig<'boolean', 'SQLiteBoolean'>> extends SQLiteBaseIntegerBuilder<T, {
mode: 'boolean';
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], mode: 'boolean');
build<TTableName extends string>(table: AnySQLiteTable<{
name: TTableName;
}>): SQLiteBoolean<MakeColumnConfig<T, TTableName>>;
}
export declare class SQLiteBoolean<T extends ColumnBaseConfig<'boolean', 'SQLiteBoolean'>> extends SQLiteBaseInteger<T, {
mode: 'boolean';
}> {
static readonly [entityKind]: string;
readonly mode: 'boolean';
mapFromDriverValue(value: number): boolean;
mapToDriverValue(value: boolean): number;
}
export interface IntegerConfig<TMode extends 'number' | 'timestamp' | 'timestamp_ms' | 'boolean' = 'number' | 'timestamp' | 'timestamp_ms' | 'boolean'> {
mode: TMode;
}
export declare function integer(): SQLiteIntegerBuilderInitial<''>;
export declare function integer<TMode extends IntegerConfig['mode']>(config?: IntegerConfig<TMode>): Or<Equal<TMode, 'timestamp'>, Equal<TMode, 'timestamp_ms'>> extends true ? SQLiteTimestampBuilderInitial<''> : Equal<TMode, 'boolean'> extends true ? SQLiteBooleanBuilderInitial<''> : SQLiteIntegerBuilderInitial<''>;
export declare function integer<TName extends string, TMode extends IntegerConfig['mode']>(name: TName, config?: IntegerConfig<TMode>): Or<Equal<TMode, 'timestamp'>, Equal<TMode, 'timestamp_ms'>> extends true ? SQLiteTimestampBuilderInitial<TName> : Equal<TMode, 'boolean'> extends true ? SQLiteBooleanBuilderInitial<TName> : SQLiteIntegerBuilderInitial<TName>;
export declare const int: typeof integer;

View File

@ -0,0 +1,108 @@
import type { ColumnBuilderBaseConfig, ColumnDataType, HasDefault, IsPrimaryKey, MakeColumnConfig, NotNull } from "../../column-builder.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import type { OnConflict } from "../utils.js";
import { type Equal, type Or } from "../../utils.js";
import type { AnySQLiteTable } from "../table.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
export interface PrimaryKeyConfig {
autoIncrement?: boolean;
onConflict?: OnConflict;
}
export declare abstract class SQLiteBaseIntegerBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends SQLiteColumnBuilder<T, TRuntimeConfig & {
autoIncrement: boolean;
}, {}, {
primaryKeyHasDefault: true;
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], dataType: T['dataType'], columnType: T['columnType']);
primaryKey(config?: PrimaryKeyConfig): IsPrimaryKey<HasDefault<NotNull<this>>>;
}
export declare abstract class SQLiteBaseInteger<T extends ColumnBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends SQLiteColumn<T, TRuntimeConfig & {
autoIncrement: boolean;
}> {
static readonly [entityKind]: string;
readonly autoIncrement: boolean;
getSQLType(): string;
}
export type SQLiteIntegerBuilderInitial<TName extends string> = SQLiteIntegerBuilder<{
name: TName;
dataType: 'number';
columnType: 'SQLiteInteger';
data: number;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteIntegerBuilder<T extends ColumnBuilderBaseConfig<'number', 'SQLiteInteger'>> extends SQLiteBaseIntegerBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
build<TTableName extends string>(table: AnySQLiteTable<{
name: TTableName;
}>): SQLiteInteger<MakeColumnConfig<T, TTableName>>;
}
export declare class SQLiteInteger<T extends ColumnBaseConfig<'number', 'SQLiteInteger'>> extends SQLiteBaseInteger<T> {
static readonly [entityKind]: string;
}
export type SQLiteTimestampBuilderInitial<TName extends string> = SQLiteTimestampBuilder<{
name: TName;
dataType: 'date';
columnType: 'SQLiteTimestamp';
data: Date;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteTimestampBuilder<T extends ColumnBuilderBaseConfig<'date', 'SQLiteTimestamp'>> extends SQLiteBaseIntegerBuilder<T, {
mode: 'timestamp' | 'timestamp_ms';
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], mode: 'timestamp' | 'timestamp_ms');
/**
* @deprecated Use `default()` with your own expression instead.
*
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
*/
defaultNow(): HasDefault<this>;
build<TTableName extends string>(table: AnySQLiteTable<{
name: TTableName;
}>): SQLiteTimestamp<MakeColumnConfig<T, TTableName>>;
}
export declare class SQLiteTimestamp<T extends ColumnBaseConfig<'date', 'SQLiteTimestamp'>> extends SQLiteBaseInteger<T, {
mode: 'timestamp' | 'timestamp_ms';
}> {
static readonly [entityKind]: string;
readonly mode: 'timestamp' | 'timestamp_ms';
mapFromDriverValue(value: number): Date;
mapToDriverValue(value: Date): number;
}
export type SQLiteBooleanBuilderInitial<TName extends string> = SQLiteBooleanBuilder<{
name: TName;
dataType: 'boolean';
columnType: 'SQLiteBoolean';
data: boolean;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteBooleanBuilder<T extends ColumnBuilderBaseConfig<'boolean', 'SQLiteBoolean'>> extends SQLiteBaseIntegerBuilder<T, {
mode: 'boolean';
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], mode: 'boolean');
build<TTableName extends string>(table: AnySQLiteTable<{
name: TTableName;
}>): SQLiteBoolean<MakeColumnConfig<T, TTableName>>;
}
export declare class SQLiteBoolean<T extends ColumnBaseConfig<'boolean', 'SQLiteBoolean'>> extends SQLiteBaseInteger<T, {
mode: 'boolean';
}> {
static readonly [entityKind]: string;
readonly mode: 'boolean';
mapFromDriverValue(value: number): boolean;
mapToDriverValue(value: boolean): number;
}
export interface IntegerConfig<TMode extends 'number' | 'timestamp' | 'timestamp_ms' | 'boolean' = 'number' | 'timestamp' | 'timestamp_ms' | 'boolean'> {
mode: TMode;
}
export declare function integer(): SQLiteIntegerBuilderInitial<''>;
export declare function integer<TMode extends IntegerConfig['mode']>(config?: IntegerConfig<TMode>): Or<Equal<TMode, 'timestamp'>, Equal<TMode, 'timestamp_ms'>> extends true ? SQLiteTimestampBuilderInitial<''> : Equal<TMode, 'boolean'> extends true ? SQLiteBooleanBuilderInitial<''> : SQLiteIntegerBuilderInitial<''>;
export declare function integer<TName extends string, TMode extends IntegerConfig['mode']>(name: TName, config?: IntegerConfig<TMode>): Or<Equal<TMode, 'timestamp'>, Equal<TMode, 'timestamp_ms'>> extends true ? SQLiteTimestampBuilderInitial<TName> : Equal<TMode, 'boolean'> extends true ? SQLiteBooleanBuilderInitial<TName> : SQLiteIntegerBuilderInitial<TName>;
export declare const int: typeof integer;

125
node_modules/drizzle-orm/sqlite-core/columns/integer.js generated vendored Normal file
View File

@ -0,0 +1,125 @@
import { entityKind } from "../../entity.js";
import { sql } from "../../sql/sql.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteBaseIntegerBuilder";
constructor(name, dataType, columnType) {
super(name, dataType, columnType);
this.config.autoIncrement = false;
}
primaryKey(config) {
if (config?.autoIncrement) {
this.config.autoIncrement = true;
}
this.config.hasDefault = true;
return super.primaryKey();
}
}
class SQLiteBaseInteger extends SQLiteColumn {
static [entityKind] = "SQLiteBaseInteger";
autoIncrement = this.config.autoIncrement;
getSQLType() {
return "integer";
}
}
class SQLiteIntegerBuilder extends SQLiteBaseIntegerBuilder {
static [entityKind] = "SQLiteIntegerBuilder";
constructor(name) {
super(name, "number", "SQLiteInteger");
}
build(table) {
return new SQLiteInteger(
table,
this.config
);
}
}
class SQLiteInteger extends SQLiteBaseInteger {
static [entityKind] = "SQLiteInteger";
}
class SQLiteTimestampBuilder extends SQLiteBaseIntegerBuilder {
static [entityKind] = "SQLiteTimestampBuilder";
constructor(name, mode) {
super(name, "date", "SQLiteTimestamp");
this.config.mode = mode;
}
/**
* @deprecated Use `default()` with your own expression instead.
*
* Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
*/
defaultNow() {
return this.default(sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
}
build(table) {
return new SQLiteTimestamp(
table,
this.config
);
}
}
class SQLiteTimestamp extends SQLiteBaseInteger {
static [entityKind] = "SQLiteTimestamp";
mode = this.config.mode;
mapFromDriverValue(value) {
if (this.config.mode === "timestamp") {
return new Date(value * 1e3);
}
return new Date(value);
}
mapToDriverValue(value) {
const unix = value.getTime();
if (this.config.mode === "timestamp") {
return Math.floor(unix / 1e3);
}
return unix;
}
}
class SQLiteBooleanBuilder extends SQLiteBaseIntegerBuilder {
static [entityKind] = "SQLiteBooleanBuilder";
constructor(name, mode) {
super(name, "boolean", "SQLiteBoolean");
this.config.mode = mode;
}
build(table) {
return new SQLiteBoolean(
table,
this.config
);
}
}
class SQLiteBoolean extends SQLiteBaseInteger {
static [entityKind] = "SQLiteBoolean";
mode = this.config.mode;
mapFromDriverValue(value) {
return Number(value) === 1;
}
mapToDriverValue(value) {
return value ? 1 : 0;
}
}
function integer(a, b) {
const { name, config } = getColumnNameAndConfig(a, b);
if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") {
return new SQLiteTimestampBuilder(name, config.mode);
}
if (config?.mode === "boolean") {
return new SQLiteBooleanBuilder(name, config.mode);
}
return new SQLiteIntegerBuilder(name);
}
const int = integer;
export {
SQLiteBaseInteger,
SQLiteBaseIntegerBuilder,
SQLiteBoolean,
SQLiteBooleanBuilder,
SQLiteInteger,
SQLiteIntegerBuilder,
SQLiteTimestamp,
SQLiteTimestampBuilder,
int,
integer
};
//# sourceMappingURL=integer.js.map

File diff suppressed because one or more lines are too long

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 numeric_exports = {};
__export(numeric_exports, {
SQLiteNumeric: () => SQLiteNumeric,
SQLiteNumericBuilder: () => SQLiteNumericBuilder,
numeric: () => numeric
});
module.exports = __toCommonJS(numeric_exports);
var import_entity = require("../../entity.cjs");
var import_common = require("./common.cjs");
class SQLiteNumericBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteNumericBuilder";
constructor(name) {
super(name, "string", "SQLiteNumeric");
}
/** @internal */
build(table) {
return new SQLiteNumeric(
table,
this.config
);
}
}
class SQLiteNumeric extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteNumeric";
getSQLType() {
return "numeric";
}
}
function numeric(name) {
return new SQLiteNumericBuilder(name ?? "");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteNumeric,
SQLiteNumericBuilder,
numeric
});
//# sourceMappingURL=numeric.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/numeric.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnySQLiteTable } from '~/sqlite-core/table.ts';\nimport { SQLiteColumn, SQLiteColumnBuilder } from './common.ts';\n\nexport type SQLiteNumericBuilderInitial<TName extends string> = SQLiteNumericBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'SQLiteNumeric';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class SQLiteNumericBuilder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteNumeric'>>\n\textends SQLiteColumnBuilder<T>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteNumericBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'string', 'SQLiteNumeric');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnySQLiteTable<{ name: TTableName }>,\n\t): SQLiteNumeric<MakeColumnConfig<T, TTableName>> {\n\t\treturn new SQLiteNumeric<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class SQLiteNumeric<T extends ColumnBaseConfig<'string', 'SQLiteNumeric'>> extends SQLiteColumn<T> {\n\tstatic override readonly [entityKind]: string = 'SQLiteNumeric';\n\n\tgetSQLType(): string {\n\t\treturn 'numeric';\n\t}\n}\n\nexport function numeric(): SQLiteNumericBuilderInitial<''>;\nexport function numeric<TName extends string>(name: TName): SQLiteNumericBuilderInitial<TName>;\nexport function numeric(name?: string) {\n\treturn new SQLiteNumericBuilder(name ?? '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,oBAAkD;AAW3C,MAAM,6BACJ,kCACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,UAAU,eAAe;AAAA,EACtC;AAAA;AAAA,EAGS,MACR,OACiD;AACjD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,sBAA6E,2BAAgB;AAAA,EACzG,QAA0B,wBAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AACD;AAIO,SAAS,QAAQ,MAAe;AACtC,SAAO,IAAI,qBAAqB,QAAQ,EAAE;AAC3C;","names":[]}

View File

@ -0,0 +1,22 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.cjs";
export type SQLiteNumericBuilderInitial<TName extends string> = SQLiteNumericBuilder<{
name: TName;
dataType: 'string';
columnType: 'SQLiteNumeric';
data: string;
driverParam: string;
enumValues: undefined;
}>;
export declare class SQLiteNumericBuilder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteNumeric'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteNumeric<T extends ColumnBaseConfig<'string', 'SQLiteNumeric'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
}
export declare function numeric(): SQLiteNumericBuilderInitial<''>;
export declare function numeric<TName extends string>(name: TName): SQLiteNumericBuilderInitial<TName>;

View File

@ -0,0 +1,22 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
export type SQLiteNumericBuilderInitial<TName extends string> = SQLiteNumericBuilder<{
name: TName;
dataType: 'string';
columnType: 'SQLiteNumeric';
data: string;
driverParam: string;
enumValues: undefined;
}>;
export declare class SQLiteNumericBuilder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteNumeric'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteNumeric<T extends ColumnBaseConfig<'string', 'SQLiteNumeric'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
}
export declare function numeric(): SQLiteNumericBuilderInitial<''>;
export declare function numeric<TName extends string>(name: TName): SQLiteNumericBuilderInitial<TName>;

View File

@ -0,0 +1,30 @@
import { entityKind } from "../../entity.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteNumericBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteNumericBuilder";
constructor(name) {
super(name, "string", "SQLiteNumeric");
}
/** @internal */
build(table) {
return new SQLiteNumeric(
table,
this.config
);
}
}
class SQLiteNumeric extends SQLiteColumn {
static [entityKind] = "SQLiteNumeric";
getSQLType() {
return "numeric";
}
}
function numeric(name) {
return new SQLiteNumericBuilder(name ?? "");
}
export {
SQLiteNumeric,
SQLiteNumericBuilder,
numeric
};
//# sourceMappingURL=numeric.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/numeric.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnySQLiteTable } from '~/sqlite-core/table.ts';\nimport { SQLiteColumn, SQLiteColumnBuilder } from './common.ts';\n\nexport type SQLiteNumericBuilderInitial<TName extends string> = SQLiteNumericBuilder<{\n\tname: TName;\n\tdataType: 'string';\n\tcolumnType: 'SQLiteNumeric';\n\tdata: string;\n\tdriverParam: string;\n\tenumValues: undefined;\n}>;\n\nexport class SQLiteNumericBuilder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteNumeric'>>\n\textends SQLiteColumnBuilder<T>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteNumericBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'string', 'SQLiteNumeric');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnySQLiteTable<{ name: TTableName }>,\n\t): SQLiteNumeric<MakeColumnConfig<T, TTableName>> {\n\t\treturn new SQLiteNumeric<MakeColumnConfig<T, TTableName>>(\n\t\t\ttable,\n\t\t\tthis.config as ColumnBuilderRuntimeConfig<any, any>,\n\t\t);\n\t}\n}\n\nexport class SQLiteNumeric<T extends ColumnBaseConfig<'string', 'SQLiteNumeric'>> extends SQLiteColumn<T> {\n\tstatic override readonly [entityKind]: string = 'SQLiteNumeric';\n\n\tgetSQLType(): string {\n\t\treturn 'numeric';\n\t}\n}\n\nexport function numeric(): SQLiteNumericBuilderInitial<''>;\nexport function numeric<TName extends string>(name: TName): SQLiteNumericBuilderInitial<TName>;\nexport function numeric(name?: string) {\n\treturn new SQLiteNumericBuilder(name ?? '');\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,cAAc,2BAA2B;AAW3C,MAAM,6BACJ,oBACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,UAAU,eAAe;AAAA,EACtC;AAAA;AAAA,EAGS,MACR,OACiD;AACjD,WAAO,IAAI;AAAA,MACV;AAAA,MACA,KAAK;AAAA,IACN;AAAA,EACD;AACD;AAEO,MAAM,sBAA6E,aAAgB;AAAA,EACzG,QAA0B,UAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AACD;AAIO,SAAS,QAAQ,MAAe;AACtC,SAAO,IAAI,qBAAqB,QAAQ,EAAE;AAC3C;","names":[]}

53
node_modules/drizzle-orm/sqlite-core/columns/real.cjs generated vendored Normal file
View File

@ -0,0 +1,53 @@
"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 real_exports = {};
__export(real_exports, {
SQLiteReal: () => SQLiteReal,
SQLiteRealBuilder: () => SQLiteRealBuilder,
real: () => real
});
module.exports = __toCommonJS(real_exports);
var import_entity = require("../../entity.cjs");
var import_common = require("./common.cjs");
class SQLiteRealBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteRealBuilder";
constructor(name) {
super(name, "number", "SQLiteReal");
}
/** @internal */
build(table) {
return new SQLiteReal(table, this.config);
}
}
class SQLiteReal extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteReal";
getSQLType() {
return "real";
}
}
function real(name) {
return new SQLiteRealBuilder(name ?? "");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteReal,
SQLiteRealBuilder,
real
});
//# sourceMappingURL=real.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/real.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnySQLiteTable } from '../table.ts';\nimport { SQLiteColumn, SQLiteColumnBuilder } from './common.ts';\n\nexport type SQLiteRealBuilderInitial<TName extends string> = SQLiteRealBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'SQLiteReal';\n\tdata: number;\n\tdriverParam: number;\n\tenumValues: undefined;\n}>;\n\nexport class SQLiteRealBuilder<T extends ColumnBuilderBaseConfig<'number', 'SQLiteReal'>>\n\textends SQLiteColumnBuilder<T>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteRealBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'number', 'SQLiteReal');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnySQLiteTable<{ name: TTableName }>,\n\t): SQLiteReal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new SQLiteReal<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class SQLiteReal<T extends ColumnBaseConfig<'number', 'SQLiteReal'>> extends SQLiteColumn<T> {\n\tstatic override readonly [entityKind]: string = 'SQLiteReal';\n\n\tgetSQLType(): string {\n\t\treturn 'real';\n\t}\n}\n\nexport function real(): SQLiteRealBuilderInitial<''>;\nexport function real<TName extends string>(name: TName): SQLiteRealBuilderInitial<TName>;\nexport function real(name?: string) {\n\treturn new SQLiteRealBuilder(name ?? '');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAA2B;AAE3B,oBAAkD;AAW3C,MAAM,0BACJ,kCACT;AAAA,EACC,QAA0B,wBAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,UAAU,YAAY;AAAA,EACnC;AAAA;AAAA,EAGS,MACR,OAC8C;AAC9C,WAAO,IAAI,WAA4C,OAAO,KAAK,MAA8C;AAAA,EAClH;AACD;AAEO,MAAM,mBAAuE,2BAAgB;AAAA,EACnG,QAA0B,wBAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AACD;AAIO,SAAS,KAAK,MAAe;AACnC,SAAO,IAAI,kBAAkB,QAAQ,EAAE;AACxC;","names":[]}

View File

@ -0,0 +1,22 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.cjs";
export type SQLiteRealBuilderInitial<TName extends string> = SQLiteRealBuilder<{
name: TName;
dataType: 'number';
columnType: 'SQLiteReal';
data: number;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteRealBuilder<T extends ColumnBuilderBaseConfig<'number', 'SQLiteReal'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteReal<T extends ColumnBaseConfig<'number', 'SQLiteReal'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
}
export declare function real(): SQLiteRealBuilderInitial<''>;
export declare function real<TName extends string>(name: TName): SQLiteRealBuilderInitial<TName>;

22
node_modules/drizzle-orm/sqlite-core/columns/real.d.ts generated vendored Normal file
View File

@ -0,0 +1,22 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
export type SQLiteRealBuilderInitial<TName extends string> = SQLiteRealBuilder<{
name: TName;
dataType: 'number';
columnType: 'SQLiteReal';
data: number;
driverParam: number;
enumValues: undefined;
}>;
export declare class SQLiteRealBuilder<T extends ColumnBuilderBaseConfig<'number', 'SQLiteReal'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteReal<T extends ColumnBaseConfig<'number', 'SQLiteReal'>> extends SQLiteColumn<T> {
static readonly [entityKind]: string;
getSQLType(): string;
}
export declare function real(): SQLiteRealBuilderInitial<''>;
export declare function real<TName extends string>(name: TName): SQLiteRealBuilderInitial<TName>;

27
node_modules/drizzle-orm/sqlite-core/columns/real.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
import { entityKind } from "../../entity.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteRealBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteRealBuilder";
constructor(name) {
super(name, "number", "SQLiteReal");
}
/** @internal */
build(table) {
return new SQLiteReal(table, this.config);
}
}
class SQLiteReal extends SQLiteColumn {
static [entityKind] = "SQLiteReal";
getSQLType() {
return "real";
}
}
function real(name) {
return new SQLiteRealBuilder(name ?? "");
}
export {
SQLiteReal,
SQLiteRealBuilder,
real
};
//# sourceMappingURL=real.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../src/sqlite-core/columns/real.ts"],"sourcesContent":["import type { ColumnBuilderBaseConfig, ColumnBuilderRuntimeConfig, MakeColumnConfig } from '~/column-builder.ts';\nimport type { ColumnBaseConfig } from '~/column.ts';\nimport { entityKind } from '~/entity.ts';\nimport type { AnySQLiteTable } from '../table.ts';\nimport { SQLiteColumn, SQLiteColumnBuilder } from './common.ts';\n\nexport type SQLiteRealBuilderInitial<TName extends string> = SQLiteRealBuilder<{\n\tname: TName;\n\tdataType: 'number';\n\tcolumnType: 'SQLiteReal';\n\tdata: number;\n\tdriverParam: number;\n\tenumValues: undefined;\n}>;\n\nexport class SQLiteRealBuilder<T extends ColumnBuilderBaseConfig<'number', 'SQLiteReal'>>\n\textends SQLiteColumnBuilder<T>\n{\n\tstatic override readonly [entityKind]: string = 'SQLiteRealBuilder';\n\n\tconstructor(name: T['name']) {\n\t\tsuper(name, 'number', 'SQLiteReal');\n\t}\n\n\t/** @internal */\n\toverride build<TTableName extends string>(\n\t\ttable: AnySQLiteTable<{ name: TTableName }>,\n\t): SQLiteReal<MakeColumnConfig<T, TTableName>> {\n\t\treturn new SQLiteReal<MakeColumnConfig<T, TTableName>>(table, this.config as ColumnBuilderRuntimeConfig<any, any>);\n\t}\n}\n\nexport class SQLiteReal<T extends ColumnBaseConfig<'number', 'SQLiteReal'>> extends SQLiteColumn<T> {\n\tstatic override readonly [entityKind]: string = 'SQLiteReal';\n\n\tgetSQLType(): string {\n\t\treturn 'real';\n\t}\n}\n\nexport function real(): SQLiteRealBuilderInitial<''>;\nexport function real<TName extends string>(name: TName): SQLiteRealBuilderInitial<TName>;\nexport function real(name?: string) {\n\treturn new SQLiteRealBuilder(name ?? '');\n}\n"],"mappings":"AAEA,SAAS,kBAAkB;AAE3B,SAAS,cAAc,2BAA2B;AAW3C,MAAM,0BACJ,oBACT;AAAA,EACC,QAA0B,UAAU,IAAY;AAAA,EAEhD,YAAY,MAAiB;AAC5B,UAAM,MAAM,UAAU,YAAY;AAAA,EACnC;AAAA;AAAA,EAGS,MACR,OAC8C;AAC9C,WAAO,IAAI,WAA4C,OAAO,KAAK,MAA8C;AAAA,EAClH;AACD;AAEO,MAAM,mBAAuE,aAAgB;AAAA,EACnG,QAA0B,UAAU,IAAY;AAAA,EAEhD,aAAqB;AACpB,WAAO;AAAA,EACR;AACD;AAIO,SAAS,KAAK,MAAe;AACnC,SAAO,IAAI,kBAAkB,QAAQ,EAAE;AACxC;","names":[]}

97
node_modules/drizzle-orm/sqlite-core/columns/text.cjs generated vendored Normal file
View File

@ -0,0 +1,97 @@
"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 text_exports = {};
__export(text_exports, {
SQLiteText: () => SQLiteText,
SQLiteTextBuilder: () => SQLiteTextBuilder,
SQLiteTextJson: () => SQLiteTextJson,
SQLiteTextJsonBuilder: () => SQLiteTextJsonBuilder,
text: () => text
});
module.exports = __toCommonJS(text_exports);
var import_entity = require("../../entity.cjs");
var import_utils = require("../../utils.cjs");
var import_common = require("./common.cjs");
class SQLiteTextBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteTextBuilder";
constructor(name, config) {
super(name, "string", "SQLiteText");
this.config.enumValues = config.enum;
this.config.length = config.length;
}
/** @internal */
build(table) {
return new SQLiteText(
table,
this.config
);
}
}
class SQLiteText extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteText";
enumValues = this.config.enumValues;
length = this.config.length;
constructor(table, config) {
super(table, config);
}
getSQLType() {
return `text${this.config.length ? `(${this.config.length})` : ""}`;
}
}
class SQLiteTextJsonBuilder extends import_common.SQLiteColumnBuilder {
static [import_entity.entityKind] = "SQLiteTextJsonBuilder";
constructor(name) {
super(name, "json", "SQLiteTextJson");
}
/** @internal */
build(table) {
return new SQLiteTextJson(
table,
this.config
);
}
}
class SQLiteTextJson extends import_common.SQLiteColumn {
static [import_entity.entityKind] = "SQLiteTextJson";
getSQLType() {
return "text";
}
mapFromDriverValue(value) {
return JSON.parse(value);
}
mapToDriverValue(value) {
return JSON.stringify(value);
}
}
function text(a, b = {}) {
const { name, config } = (0, import_utils.getColumnNameAndConfig)(a, b);
if (config.mode === "json") {
return new SQLiteTextJsonBuilder(name);
}
return new SQLiteTextBuilder(name, config);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteText,
SQLiteTextBuilder,
SQLiteTextJson,
SQLiteTextJsonBuilder,
text
});
//# sourceMappingURL=text.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,72 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.cjs";
import type { ColumnBaseConfig } from "../../column.cjs";
import { entityKind } from "../../entity.cjs";
import type { AnySQLiteTable } from "../table.cjs";
import { type Equal, type Writable } from "../../utils.cjs";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.cjs";
export type SQLiteTextBuilderInitial<TName extends string, TEnum extends [string, ...string[]], TLength extends number | undefined> = SQLiteTextBuilder<{
name: TName;
dataType: 'string';
columnType: 'SQLiteText';
data: TEnum[number];
driverParam: string;
enumValues: TEnum;
length: TLength;
}>;
export declare class SQLiteTextBuilder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteText'> & {
length?: number | undefined;
}> extends SQLiteColumnBuilder<T, {
length: T['length'];
enumValues: T['enumValues'];
}, {
length: T['length'];
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], config: SQLiteTextConfig<'text', T['enumValues'], T['length']>);
}
export declare class SQLiteText<T extends ColumnBaseConfig<'string', 'SQLiteText'> & {
length?: number | undefined;
}> extends SQLiteColumn<T, {
length: T['length'];
enumValues: T['enumValues'];
}> {
static readonly [entityKind]: string;
readonly enumValues: T["enumValues"];
readonly length: T['length'];
constructor(table: AnySQLiteTable<{
name: T['tableName'];
}>, config: SQLiteTextBuilder<T>['config']);
getSQLType(): string;
}
export type SQLiteTextJsonBuilderInitial<TName extends string> = SQLiteTextJsonBuilder<{
name: TName;
dataType: 'json';
columnType: 'SQLiteTextJson';
data: unknown;
driverParam: string;
enumValues: undefined;
generated: undefined;
}>;
export declare class SQLiteTextJsonBuilder<T extends ColumnBuilderBaseConfig<'json', 'SQLiteTextJson'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteTextJson<T extends ColumnBaseConfig<'json', 'SQLiteTextJson'>> extends SQLiteColumn<T, {
length: number | undefined;
enumValues: T['enumValues'];
}> {
static readonly [entityKind]: string;
getSQLType(): string;
mapFromDriverValue(value: string): T['data'];
mapToDriverValue(value: T['data']): string;
}
export type SQLiteTextConfig<TMode extends 'text' | 'json' = 'text' | 'json', TEnum extends readonly string[] | string[] | undefined = readonly string[] | string[] | undefined, TLength extends number | undefined = number | undefined> = TMode extends 'text' ? {
mode?: TMode;
length?: TLength;
enum?: TEnum;
} : {
mode?: TMode;
};
export declare function text(): SQLiteTextBuilderInitial<'', [string, ...string[]], undefined>;
export declare function text<U extends string, T extends Readonly<[U, ...U[]]>, L extends number | undefined, TMode extends 'text' | 'json' = 'text' | 'json'>(config?: SQLiteTextConfig<TMode, T | Writable<T>, L>): Equal<TMode, 'json'> extends true ? SQLiteTextJsonBuilderInitial<''> : SQLiteTextBuilderInitial<'', Writable<T>, L>;
export declare function text<TName extends string, U extends string, T extends Readonly<[U, ...U[]]>, L extends number | undefined, TMode extends 'text' | 'json' = 'text' | 'json'>(name: TName, config?: SQLiteTextConfig<TMode, T | Writable<T>, L>): Equal<TMode, 'json'> extends true ? SQLiteTextJsonBuilderInitial<TName> : SQLiteTextBuilderInitial<TName, Writable<T>, L>;

72
node_modules/drizzle-orm/sqlite-core/columns/text.d.ts generated vendored Normal file
View File

@ -0,0 +1,72 @@
import type { ColumnBuilderBaseConfig } from "../../column-builder.js";
import type { ColumnBaseConfig } from "../../column.js";
import { entityKind } from "../../entity.js";
import type { AnySQLiteTable } from "../table.js";
import { type Equal, type Writable } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
export type SQLiteTextBuilderInitial<TName extends string, TEnum extends [string, ...string[]], TLength extends number | undefined> = SQLiteTextBuilder<{
name: TName;
dataType: 'string';
columnType: 'SQLiteText';
data: TEnum[number];
driverParam: string;
enumValues: TEnum;
length: TLength;
}>;
export declare class SQLiteTextBuilder<T extends ColumnBuilderBaseConfig<'string', 'SQLiteText'> & {
length?: number | undefined;
}> extends SQLiteColumnBuilder<T, {
length: T['length'];
enumValues: T['enumValues'];
}, {
length: T['length'];
}> {
static readonly [entityKind]: string;
constructor(name: T['name'], config: SQLiteTextConfig<'text', T['enumValues'], T['length']>);
}
export declare class SQLiteText<T extends ColumnBaseConfig<'string', 'SQLiteText'> & {
length?: number | undefined;
}> extends SQLiteColumn<T, {
length: T['length'];
enumValues: T['enumValues'];
}> {
static readonly [entityKind]: string;
readonly enumValues: T["enumValues"];
readonly length: T['length'];
constructor(table: AnySQLiteTable<{
name: T['tableName'];
}>, config: SQLiteTextBuilder<T>['config']);
getSQLType(): string;
}
export type SQLiteTextJsonBuilderInitial<TName extends string> = SQLiteTextJsonBuilder<{
name: TName;
dataType: 'json';
columnType: 'SQLiteTextJson';
data: unknown;
driverParam: string;
enumValues: undefined;
generated: undefined;
}>;
export declare class SQLiteTextJsonBuilder<T extends ColumnBuilderBaseConfig<'json', 'SQLiteTextJson'>> extends SQLiteColumnBuilder<T> {
static readonly [entityKind]: string;
constructor(name: T['name']);
}
export declare class SQLiteTextJson<T extends ColumnBaseConfig<'json', 'SQLiteTextJson'>> extends SQLiteColumn<T, {
length: number | undefined;
enumValues: T['enumValues'];
}> {
static readonly [entityKind]: string;
getSQLType(): string;
mapFromDriverValue(value: string): T['data'];
mapToDriverValue(value: T['data']): string;
}
export type SQLiteTextConfig<TMode extends 'text' | 'json' = 'text' | 'json', TEnum extends readonly string[] | string[] | undefined = readonly string[] | string[] | undefined, TLength extends number | undefined = number | undefined> = TMode extends 'text' ? {
mode?: TMode;
length?: TLength;
enum?: TEnum;
} : {
mode?: TMode;
};
export declare function text(): SQLiteTextBuilderInitial<'', [string, ...string[]], undefined>;
export declare function text<U extends string, T extends Readonly<[U, ...U[]]>, L extends number | undefined, TMode extends 'text' | 'json' = 'text' | 'json'>(config?: SQLiteTextConfig<TMode, T | Writable<T>, L>): Equal<TMode, 'json'> extends true ? SQLiteTextJsonBuilderInitial<''> : SQLiteTextBuilderInitial<'', Writable<T>, L>;
export declare function text<TName extends string, U extends string, T extends Readonly<[U, ...U[]]>, L extends number | undefined, TMode extends 'text' | 'json' = 'text' | 'json'>(name: TName, config?: SQLiteTextConfig<TMode, T | Writable<T>, L>): Equal<TMode, 'json'> extends true ? SQLiteTextJsonBuilderInitial<TName> : SQLiteTextBuilderInitial<TName, Writable<T>, L>;

69
node_modules/drizzle-orm/sqlite-core/columns/text.js generated vendored Normal file
View File

@ -0,0 +1,69 @@
import { entityKind } from "../../entity.js";
import { getColumnNameAndConfig } from "../../utils.js";
import { SQLiteColumn, SQLiteColumnBuilder } from "./common.js";
class SQLiteTextBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteTextBuilder";
constructor(name, config) {
super(name, "string", "SQLiteText");
this.config.enumValues = config.enum;
this.config.length = config.length;
}
/** @internal */
build(table) {
return new SQLiteText(
table,
this.config
);
}
}
class SQLiteText extends SQLiteColumn {
static [entityKind] = "SQLiteText";
enumValues = this.config.enumValues;
length = this.config.length;
constructor(table, config) {
super(table, config);
}
getSQLType() {
return `text${this.config.length ? `(${this.config.length})` : ""}`;
}
}
class SQLiteTextJsonBuilder extends SQLiteColumnBuilder {
static [entityKind] = "SQLiteTextJsonBuilder";
constructor(name) {
super(name, "json", "SQLiteTextJson");
}
/** @internal */
build(table) {
return new SQLiteTextJson(
table,
this.config
);
}
}
class SQLiteTextJson extends SQLiteColumn {
static [entityKind] = "SQLiteTextJson";
getSQLType() {
return "text";
}
mapFromDriverValue(value) {
return JSON.parse(value);
}
mapToDriverValue(value) {
return JSON.stringify(value);
}
}
function text(a, b = {}) {
const { name, config } = getColumnNameAndConfig(a, b);
if (config.mode === "json") {
return new SQLiteTextJsonBuilder(name);
}
return new SQLiteTextBuilder(name, config);
}
export {
SQLiteText,
SQLiteTextBuilder,
SQLiteTextJson,
SQLiteTextJsonBuilder,
text
};
//# sourceMappingURL=text.js.map

File diff suppressed because one or more lines are too long

351
node_modules/drizzle-orm/sqlite-core/db.cjs generated vendored Normal file
View File

@ -0,0 +1,351 @@
"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 db_exports = {};
__export(db_exports, {
BaseSQLiteDatabase: () => BaseSQLiteDatabase,
withReplicas: () => withReplicas
});
module.exports = __toCommonJS(db_exports);
var import_entity = require("../entity.cjs");
var import_selection_proxy = require("../selection-proxy.cjs");
var import_sql = require("../sql/sql.cjs");
var import_query_builders = require("./query-builders/index.cjs");
var import_subquery = require("../subquery.cjs");
var import_count = require("./query-builders/count.cjs");
var import_query = require("./query-builders/query.cjs");
var import_raw = require("./query-builders/raw.cjs");
class BaseSQLiteDatabase {
constructor(resultKind, dialect, session, schema) {
this.resultKind = resultKind;
this.dialect = dialect;
this.session = session;
this._ = schema ? {
schema: schema.schema,
fullSchema: schema.fullSchema,
tableNamesMap: schema.tableNamesMap
} : {
schema: void 0,
fullSchema: {},
tableNamesMap: {}
};
this.query = {};
const query = this.query;
if (this._.schema) {
for (const [tableName, columns] of Object.entries(this._.schema)) {
query[tableName] = new import_query.RelationalQueryBuilder(
resultKind,
schema.fullSchema,
this._.schema,
this._.tableNamesMap,
schema.fullSchema[tableName],
columns,
dialect,
session
);
}
}
}
static [import_entity.entityKind] = "BaseSQLiteDatabase";
query;
/**
* Creates a subquery that defines a temporary named result set as a CTE.
*
* It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param alias The alias for the subquery.
*
* Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
*
* @example
*
* ```ts
* // Create a subquery with alias 'sq' and use it in the select query
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* const result = await db.with(sq).select().from(sq);
* ```
*
* To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
*
* ```ts
* // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
* const sq = db.$with('sq').as(db.select({
* name: sql<string>`upper(${users.name})`.as('name'),
* })
* .from(users));
*
* const result = await db.with(sq).select({ name: sq.name }).from(sq);
* ```
*/
$with(alias) {
const self = this;
return {
as(qb) {
if (typeof qb === "function") {
qb = qb(new import_query_builders.QueryBuilder(self.dialect));
}
return new Proxy(
new import_subquery.WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true),
new import_selection_proxy.SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
);
}
};
}
$count(source, filters) {
return new import_count.SQLiteCountBuilder({ source, filters, session: this.session });
}
/**
* Incorporates a previously defined CTE (using `$with`) into the main query.
*
* This method allows the main query to reference a temporary named result set.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param queries The CTEs to incorporate into the main query.
*
* @example
*
* ```ts
* // Define a subquery 'sq' as a CTE using $with
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* // Incorporate the CTE 'sq' into the main query and select from it
* const result = await db.with(sq).select().from(sq);
* ```
*/
with(...queries) {
const self = this;
function select(fields) {
return new import_query_builders.SQLiteSelectBuilder({
fields: fields ?? void 0,
session: self.session,
dialect: self.dialect,
withList: queries
});
}
function selectDistinct(fields) {
return new import_query_builders.SQLiteSelectBuilder({
fields: fields ?? void 0,
session: self.session,
dialect: self.dialect,
withList: queries,
distinct: true
});
}
function update(table) {
return new import_query_builders.SQLiteUpdateBuilder(table, self.session, self.dialect, queries);
}
function insert(into) {
return new import_query_builders.SQLiteInsertBuilder(into, self.session, self.dialect, queries);
}
function delete_(from) {
return new import_query_builders.SQLiteDeleteBase(from, self.session, self.dialect, queries);
}
return { select, selectDistinct, update, insert, delete: delete_ };
}
select(fields) {
return new import_query_builders.SQLiteSelectBuilder({ fields: fields ?? void 0, session: this.session, dialect: this.dialect });
}
selectDistinct(fields) {
return new import_query_builders.SQLiteSelectBuilder({
fields: fields ?? void 0,
session: this.session,
dialect: this.dialect,
distinct: true
});
}
/**
* Creates an update query.
*
* Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
*
* Use `.set()` method to specify which values to update.
*
* See docs: {@link https://orm.drizzle.team/docs/update}
*
* @param table The table to update.
*
* @example
*
* ```ts
* // Update all rows in the 'cars' table
* await db.update(cars).set({ color: 'red' });
*
* // Update rows with filters and conditions
* await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
*
* // Update with returning clause
* const updatedCar: Car[] = await db.update(cars)
* .set({ color: 'red' })
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
update(table) {
return new import_query_builders.SQLiteUpdateBuilder(table, this.session, this.dialect);
}
/**
* Creates an insert query.
*
* Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
*
* See docs: {@link https://orm.drizzle.team/docs/insert}
*
* @param table The table to insert into.
*
* @example
*
* ```ts
* // Insert one row
* await db.insert(cars).values({ brand: 'BMW' });
*
* // Insert multiple rows
* await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
*
* // Insert with returning clause
* const insertedCar: Car[] = await db.insert(cars)
* .values({ brand: 'BMW' })
* .returning();
* ```
*/
insert(into) {
return new import_query_builders.SQLiteInsertBuilder(into, this.session, this.dialect);
}
/**
* Creates a delete query.
*
* Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
*
* See docs: {@link https://orm.drizzle.team/docs/delete}
*
* @param table The table to delete from.
*
* @example
*
* ```ts
* // Delete all rows in the 'cars' table
* await db.delete(cars);
*
* // Delete rows with filters and conditions
* await db.delete(cars).where(eq(cars.color, 'green'));
*
* // Delete with returning clause
* const deletedCar: Car[] = await db.delete(cars)
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
delete(from) {
return new import_query_builders.SQLiteDeleteBase(from, this.session, this.dialect);
}
run(query) {
const sequel = typeof query === "string" ? import_sql.sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new import_raw.SQLiteRaw(
async () => this.session.run(sequel),
() => sequel,
"run",
this.dialect,
this.session.extractRawRunValueFromBatchResult.bind(this.session)
);
}
return this.session.run(sequel);
}
all(query) {
const sequel = typeof query === "string" ? import_sql.sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new import_raw.SQLiteRaw(
async () => this.session.all(sequel),
() => sequel,
"all",
this.dialect,
this.session.extractRawAllValueFromBatchResult.bind(this.session)
);
}
return this.session.all(sequel);
}
get(query) {
const sequel = typeof query === "string" ? import_sql.sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new import_raw.SQLiteRaw(
async () => this.session.get(sequel),
() => sequel,
"get",
this.dialect,
this.session.extractRawGetValueFromBatchResult.bind(this.session)
);
}
return this.session.get(sequel);
}
values(query) {
const sequel = typeof query === "string" ? import_sql.sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new import_raw.SQLiteRaw(
async () => this.session.values(sequel),
() => sequel,
"values",
this.dialect,
this.session.extractRawValuesValueFromBatchResult.bind(this.session)
);
}
return this.session.values(sequel);
}
transaction(transaction, config) {
return this.session.transaction(transaction, config);
}
}
const withReplicas = (primary, replicas, getReplica = () => replicas[Math.floor(Math.random() * replicas.length)]) => {
const select = (...args) => getReplica(replicas).select(...args);
const selectDistinct = (...args) => getReplica(replicas).selectDistinct(...args);
const $with = (...args) => getReplica(replicas).with(...args);
const update = (...args) => primary.update(...args);
const insert = (...args) => primary.insert(...args);
const $delete = (...args) => primary.delete(...args);
const run = (...args) => primary.run(...args);
const all = (...args) => primary.all(...args);
const get = (...args) => primary.get(...args);
const values = (...args) => primary.values(...args);
const transaction = (...args) => primary.transaction(...args);
return {
...primary,
update,
insert,
delete: $delete,
run,
all,
get,
values,
transaction,
$primary: primary,
select,
selectDistinct,
with: $with,
get query() {
return getReplica(replicas).query;
}
};
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
BaseSQLiteDatabase,
withReplicas
});
//# sourceMappingURL=db.cjs.map

1
node_modules/drizzle-orm/sqlite-core/db.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

255
node_modules/drizzle-orm/sqlite-core/db.d.cts generated vendored Normal file
View File

@ -0,0 +1,255 @@
import { entityKind } from "../entity.cjs";
import type { TypedQueryBuilder } from "../query-builders/query-builder.cjs";
import type { ExtractTablesWithRelations, RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
import { type ColumnsSelection, type SQL, type SQLWrapper } from "../sql/sql.cjs";
import type { SQLiteAsyncDialect, SQLiteSyncDialect } from "./dialect.cjs";
import { QueryBuilder, SQLiteDeleteBase, SQLiteInsertBuilder, SQLiteSelectBuilder, SQLiteUpdateBuilder } from "./query-builders/index.cjs";
import type { DBResult, Result, SQLiteSession, SQLiteTransaction, SQLiteTransactionConfig } from "./session.cjs";
import type { SQLiteTable } from "./table.cjs";
import { WithSubquery } from "../subquery.cjs";
import type { DrizzleTypeError } from "../utils.cjs";
import { SQLiteCountBuilder } from "./query-builders/count.cjs";
import { RelationalQueryBuilder } from "./query-builders/query.cjs";
import type { SelectedFields } from "./query-builders/select.types.cjs";
import type { WithSubqueryWithSelection } from "./subquery.cjs";
import type { SQLiteViewBase } from "./view-base.cjs";
export declare class BaseSQLiteDatabase<TResultKind extends 'sync' | 'async', TRunResult, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = ExtractTablesWithRelations<TFullSchema>> {
private resultKind;
static readonly [entityKind]: string;
readonly _: {
readonly schema: TSchema | undefined;
readonly fullSchema: TFullSchema;
readonly tableNamesMap: Record<string, string>;
};
query: TFullSchema extends Record<string, never> ? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'> : {
[K in keyof TSchema]: RelationalQueryBuilder<TResultKind, TFullSchema, TSchema, TSchema[K]>;
};
constructor(resultKind: TResultKind,
/** @internal */
dialect: {
sync: SQLiteSyncDialect;
async: SQLiteAsyncDialect;
}[TResultKind],
/** @internal */
session: SQLiteSession<TResultKind, TRunResult, TFullSchema, TSchema>, schema: RelationalSchemaConfig<TSchema> | undefined);
/**
* Creates a subquery that defines a temporary named result set as a CTE.
*
* It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param alias The alias for the subquery.
*
* Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
*
* @example
*
* ```ts
* // Create a subquery with alias 'sq' and use it in the select query
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* const result = await db.with(sq).select().from(sq);
* ```
*
* To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
*
* ```ts
* // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
* const sq = db.$with('sq').as(db.select({
* name: sql<string>`upper(${users.name})`.as('name'),
* })
* .from(users));
*
* const result = await db.with(sq).select({ name: sq.name }).from(sq);
* ```
*/
$with<TAlias extends string>(alias: TAlias): {
as<TSelection extends ColumnsSelection>(qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>)): WithSubqueryWithSelection<TSelection, TAlias>;
};
$count(source: SQLiteTable | SQLiteViewBase | SQL | SQLWrapper, filters?: SQL<unknown>): SQLiteCountBuilder<SQLiteSession<TResultKind, TRunResult, TFullSchema, TSchema>>;
/**
* Incorporates a previously defined CTE (using `$with`) into the main query.
*
* This method allows the main query to reference a temporary named result set.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param queries The CTEs to incorporate into the main query.
*
* @example
*
* ```ts
* // Define a subquery 'sq' as a CTE using $with
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* // Incorporate the CTE 'sq' into the main query and select from it
* const result = await db.with(sq).select().from(sq);
* ```
*/
with(...queries: WithSubquery[]): {
select: {
(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
};
selectDistinct: {
(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
};
update: <TTable extends SQLiteTable>(table: TTable) => SQLiteUpdateBuilder<TTable, TResultKind, TRunResult>;
insert: <TTable extends SQLiteTable>(into: TTable) => SQLiteInsertBuilder<TTable, TResultKind, TRunResult>;
delete: <TTable extends SQLiteTable>(from: TTable) => SQLiteDeleteBase<TTable, TResultKind, TRunResult>;
};
/**
* Creates a select query.
*
* Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.
*
* Use `.from()` method to specify which table to select from.
*
* See docs: {@link https://orm.drizzle.team/docs/select}
*
* @param fields The selection object.
*
* @example
*
* ```ts
* // Select all columns and all rows from the 'cars' table
* const allCars: Car[] = await db.select().from(cars);
*
* // Select specific columns and all rows from the 'cars' table
* const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({
* id: cars.id,
* brand: cars.brand
* })
* .from(cars);
* ```
*
* Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
*
* ```ts
* // Select specific columns along with expression and all rows from the 'cars' table
* const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({
* id: cars.id,
* lowerBrand: sql<string>`lower(${cars.brand})`,
* })
* .from(cars);
* ```
*/
select(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
select<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
/**
* Adds `distinct` expression to the select query.
*
* Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.
*
* Use `.from()` method to specify which table to select from.
*
* See docs: {@link https://orm.drizzle.team/docs/select#distinct}
*
* @param fields The selection object.
*
* @example
*
* ```ts
* // Select all unique rows from the 'cars' table
* await db.selectDistinct()
* .from(cars)
* .orderBy(cars.id, cars.brand, cars.color);
*
* // Select all unique brands from the 'cars' table
* await db.selectDistinct({ brand: cars.brand })
* .from(cars)
* .orderBy(cars.brand);
* ```
*/
selectDistinct(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
selectDistinct<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
/**
* Creates an update query.
*
* Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
*
* Use `.set()` method to specify which values to update.
*
* See docs: {@link https://orm.drizzle.team/docs/update}
*
* @param table The table to update.
*
* @example
*
* ```ts
* // Update all rows in the 'cars' table
* await db.update(cars).set({ color: 'red' });
*
* // Update rows with filters and conditions
* await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
*
* // Update with returning clause
* const updatedCar: Car[] = await db.update(cars)
* .set({ color: 'red' })
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
update<TTable extends SQLiteTable>(table: TTable): SQLiteUpdateBuilder<TTable, TResultKind, TRunResult>;
/**
* Creates an insert query.
*
* Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
*
* See docs: {@link https://orm.drizzle.team/docs/insert}
*
* @param table The table to insert into.
*
* @example
*
* ```ts
* // Insert one row
* await db.insert(cars).values({ brand: 'BMW' });
*
* // Insert multiple rows
* await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
*
* // Insert with returning clause
* const insertedCar: Car[] = await db.insert(cars)
* .values({ brand: 'BMW' })
* .returning();
* ```
*/
insert<TTable extends SQLiteTable>(into: TTable): SQLiteInsertBuilder<TTable, TResultKind, TRunResult>;
/**
* Creates a delete query.
*
* Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
*
* See docs: {@link https://orm.drizzle.team/docs/delete}
*
* @param table The table to delete from.
*
* @example
*
* ```ts
* // Delete all rows in the 'cars' table
* await db.delete(cars);
*
* // Delete rows with filters and conditions
* await db.delete(cars).where(eq(cars.color, 'green'));
*
* // Delete with returning clause
* const deletedCar: Car[] = await db.delete(cars)
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
delete<TTable extends SQLiteTable>(from: TTable): SQLiteDeleteBase<TTable, TResultKind, TRunResult>;
run(query: SQLWrapper | string): DBResult<TResultKind, TRunResult>;
all<T = unknown>(query: SQLWrapper | string): DBResult<TResultKind, T[]>;
get<T = unknown>(query: SQLWrapper | string): DBResult<TResultKind, T>;
values<T extends unknown[] = unknown[]>(query: SQLWrapper | string): DBResult<TResultKind, T[]>;
transaction<T>(transaction: (tx: SQLiteTransaction<TResultKind, TRunResult, TFullSchema, TSchema>) => Result<TResultKind, T>, config?: SQLiteTransactionConfig): Result<TResultKind, T>;
}
export type SQLiteWithReplicas<Q> = Q & {
$primary: Q;
};
export declare const withReplicas: <TResultKind extends "sync" | "async", TRunResult, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig, Q extends BaseSQLiteDatabase<TResultKind, TRunResult, TFullSchema, TSchema extends Record<string, unknown> ? ExtractTablesWithRelations<TFullSchema> : TSchema>>(primary: Q, replicas: [Q, ...Q[]], getReplica?: (replicas: Q[]) => Q) => SQLiteWithReplicas<Q>;

255
node_modules/drizzle-orm/sqlite-core/db.d.ts generated vendored Normal file
View File

@ -0,0 +1,255 @@
import { entityKind } from "../entity.js";
import type { TypedQueryBuilder } from "../query-builders/query-builder.js";
import type { ExtractTablesWithRelations, RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
import { type ColumnsSelection, type SQL, type SQLWrapper } from "../sql/sql.js";
import type { SQLiteAsyncDialect, SQLiteSyncDialect } from "./dialect.js";
import { QueryBuilder, SQLiteDeleteBase, SQLiteInsertBuilder, SQLiteSelectBuilder, SQLiteUpdateBuilder } from "./query-builders/index.js";
import type { DBResult, Result, SQLiteSession, SQLiteTransaction, SQLiteTransactionConfig } from "./session.js";
import type { SQLiteTable } from "./table.js";
import { WithSubquery } from "../subquery.js";
import type { DrizzleTypeError } from "../utils.js";
import { SQLiteCountBuilder } from "./query-builders/count.js";
import { RelationalQueryBuilder } from "./query-builders/query.js";
import type { SelectedFields } from "./query-builders/select.types.js";
import type { WithSubqueryWithSelection } from "./subquery.js";
import type { SQLiteViewBase } from "./view-base.js";
export declare class BaseSQLiteDatabase<TResultKind extends 'sync' | 'async', TRunResult, TFullSchema extends Record<string, unknown> = Record<string, never>, TSchema extends TablesRelationalConfig = ExtractTablesWithRelations<TFullSchema>> {
private resultKind;
static readonly [entityKind]: string;
readonly _: {
readonly schema: TSchema | undefined;
readonly fullSchema: TFullSchema;
readonly tableNamesMap: Record<string, string>;
};
query: TFullSchema extends Record<string, never> ? DrizzleTypeError<'Seems like the schema generic is missing - did you forget to add it to your DB type?'> : {
[K in keyof TSchema]: RelationalQueryBuilder<TResultKind, TFullSchema, TSchema, TSchema[K]>;
};
constructor(resultKind: TResultKind,
/** @internal */
dialect: {
sync: SQLiteSyncDialect;
async: SQLiteAsyncDialect;
}[TResultKind],
/** @internal */
session: SQLiteSession<TResultKind, TRunResult, TFullSchema, TSchema>, schema: RelationalSchemaConfig<TSchema> | undefined);
/**
* Creates a subquery that defines a temporary named result set as a CTE.
*
* It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param alias The alias for the subquery.
*
* Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
*
* @example
*
* ```ts
* // Create a subquery with alias 'sq' and use it in the select query
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* const result = await db.with(sq).select().from(sq);
* ```
*
* To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
*
* ```ts
* // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
* const sq = db.$with('sq').as(db.select({
* name: sql<string>`upper(${users.name})`.as('name'),
* })
* .from(users));
*
* const result = await db.with(sq).select({ name: sq.name }).from(sq);
* ```
*/
$with<TAlias extends string>(alias: TAlias): {
as<TSelection extends ColumnsSelection>(qb: TypedQueryBuilder<TSelection> | ((qb: QueryBuilder) => TypedQueryBuilder<TSelection>)): WithSubqueryWithSelection<TSelection, TAlias>;
};
$count(source: SQLiteTable | SQLiteViewBase | SQL | SQLWrapper, filters?: SQL<unknown>): SQLiteCountBuilder<SQLiteSession<TResultKind, TRunResult, TFullSchema, TSchema>>;
/**
* Incorporates a previously defined CTE (using `$with`) into the main query.
*
* This method allows the main query to reference a temporary named result set.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param queries The CTEs to incorporate into the main query.
*
* @example
*
* ```ts
* // Define a subquery 'sq' as a CTE using $with
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* // Incorporate the CTE 'sq' into the main query and select from it
* const result = await db.with(sq).select().from(sq);
* ```
*/
with(...queries: WithSubquery[]): {
select: {
(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
};
selectDistinct: {
(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
};
update: <TTable extends SQLiteTable>(table: TTable) => SQLiteUpdateBuilder<TTable, TResultKind, TRunResult>;
insert: <TTable extends SQLiteTable>(into: TTable) => SQLiteInsertBuilder<TTable, TResultKind, TRunResult>;
delete: <TTable extends SQLiteTable>(from: TTable) => SQLiteDeleteBase<TTable, TResultKind, TRunResult>;
};
/**
* Creates a select query.
*
* Calling this method with no arguments will select all columns from the table. Pass a selection object to specify the columns you want to select.
*
* Use `.from()` method to specify which table to select from.
*
* See docs: {@link https://orm.drizzle.team/docs/select}
*
* @param fields The selection object.
*
* @example
*
* ```ts
* // Select all columns and all rows from the 'cars' table
* const allCars: Car[] = await db.select().from(cars);
*
* // Select specific columns and all rows from the 'cars' table
* const carsIdsAndBrands: { id: number; brand: string }[] = await db.select({
* id: cars.id,
* brand: cars.brand
* })
* .from(cars);
* ```
*
* Like in SQL, you can use arbitrary expressions as selection fields, not just table columns:
*
* ```ts
* // Select specific columns along with expression and all rows from the 'cars' table
* const carsIdsAndLowerNames: { id: number; lowerBrand: string }[] = await db.select({
* id: cars.id,
* lowerBrand: sql<string>`lower(${cars.brand})`,
* })
* .from(cars);
* ```
*/
select(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
select<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
/**
* Adds `distinct` expression to the select query.
*
* Calling this method will return only unique values. When multiple columns are selected, it returns rows with unique combinations of values in these columns.
*
* Use `.from()` method to specify which table to select from.
*
* See docs: {@link https://orm.drizzle.team/docs/select#distinct}
*
* @param fields The selection object.
*
* @example
*
* ```ts
* // Select all unique rows from the 'cars' table
* await db.selectDistinct()
* .from(cars)
* .orderBy(cars.id, cars.brand, cars.color);
*
* // Select all unique brands from the 'cars' table
* await db.selectDistinct({ brand: cars.brand })
* .from(cars)
* .orderBy(cars.brand);
* ```
*/
selectDistinct(): SQLiteSelectBuilder<undefined, TResultKind, TRunResult>;
selectDistinct<TSelection extends SelectedFields>(fields: TSelection): SQLiteSelectBuilder<TSelection, TResultKind, TRunResult>;
/**
* Creates an update query.
*
* Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
*
* Use `.set()` method to specify which values to update.
*
* See docs: {@link https://orm.drizzle.team/docs/update}
*
* @param table The table to update.
*
* @example
*
* ```ts
* // Update all rows in the 'cars' table
* await db.update(cars).set({ color: 'red' });
*
* // Update rows with filters and conditions
* await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
*
* // Update with returning clause
* const updatedCar: Car[] = await db.update(cars)
* .set({ color: 'red' })
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
update<TTable extends SQLiteTable>(table: TTable): SQLiteUpdateBuilder<TTable, TResultKind, TRunResult>;
/**
* Creates an insert query.
*
* Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
*
* See docs: {@link https://orm.drizzle.team/docs/insert}
*
* @param table The table to insert into.
*
* @example
*
* ```ts
* // Insert one row
* await db.insert(cars).values({ brand: 'BMW' });
*
* // Insert multiple rows
* await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
*
* // Insert with returning clause
* const insertedCar: Car[] = await db.insert(cars)
* .values({ brand: 'BMW' })
* .returning();
* ```
*/
insert<TTable extends SQLiteTable>(into: TTable): SQLiteInsertBuilder<TTable, TResultKind, TRunResult>;
/**
* Creates a delete query.
*
* Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
*
* See docs: {@link https://orm.drizzle.team/docs/delete}
*
* @param table The table to delete from.
*
* @example
*
* ```ts
* // Delete all rows in the 'cars' table
* await db.delete(cars);
*
* // Delete rows with filters and conditions
* await db.delete(cars).where(eq(cars.color, 'green'));
*
* // Delete with returning clause
* const deletedCar: Car[] = await db.delete(cars)
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
delete<TTable extends SQLiteTable>(from: TTable): SQLiteDeleteBase<TTable, TResultKind, TRunResult>;
run(query: SQLWrapper | string): DBResult<TResultKind, TRunResult>;
all<T = unknown>(query: SQLWrapper | string): DBResult<TResultKind, T[]>;
get<T = unknown>(query: SQLWrapper | string): DBResult<TResultKind, T>;
values<T extends unknown[] = unknown[]>(query: SQLWrapper | string): DBResult<TResultKind, T[]>;
transaction<T>(transaction: (tx: SQLiteTransaction<TResultKind, TRunResult, TFullSchema, TSchema>) => Result<TResultKind, T>, config?: SQLiteTransactionConfig): Result<TResultKind, T>;
}
export type SQLiteWithReplicas<Q> = Q & {
$primary: Q;
};
export declare const withReplicas: <TResultKind extends "sync" | "async", TRunResult, TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig, Q extends BaseSQLiteDatabase<TResultKind, TRunResult, TFullSchema, TSchema extends Record<string, unknown> ? ExtractTablesWithRelations<TFullSchema> : TSchema>>(primary: Q, replicas: [Q, ...Q[]], getReplica?: (replicas: Q[]) => Q) => SQLiteWithReplicas<Q>;

332
node_modules/drizzle-orm/sqlite-core/db.js generated vendored Normal file
View File

@ -0,0 +1,332 @@
import { entityKind } from "../entity.js";
import { SelectionProxyHandler } from "../selection-proxy.js";
import { sql } from "../sql/sql.js";
import {
QueryBuilder,
SQLiteDeleteBase,
SQLiteInsertBuilder,
SQLiteSelectBuilder,
SQLiteUpdateBuilder
} from "./query-builders/index.js";
import { WithSubquery } from "../subquery.js";
import { SQLiteCountBuilder } from "./query-builders/count.js";
import { RelationalQueryBuilder } from "./query-builders/query.js";
import { SQLiteRaw } from "./query-builders/raw.js";
class BaseSQLiteDatabase {
constructor(resultKind, dialect, session, schema) {
this.resultKind = resultKind;
this.dialect = dialect;
this.session = session;
this._ = schema ? {
schema: schema.schema,
fullSchema: schema.fullSchema,
tableNamesMap: schema.tableNamesMap
} : {
schema: void 0,
fullSchema: {},
tableNamesMap: {}
};
this.query = {};
const query = this.query;
if (this._.schema) {
for (const [tableName, columns] of Object.entries(this._.schema)) {
query[tableName] = new RelationalQueryBuilder(
resultKind,
schema.fullSchema,
this._.schema,
this._.tableNamesMap,
schema.fullSchema[tableName],
columns,
dialect,
session
);
}
}
}
static [entityKind] = "BaseSQLiteDatabase";
query;
/**
* Creates a subquery that defines a temporary named result set as a CTE.
*
* It is useful for breaking down complex queries into simpler parts and for reusing the result set in subsequent parts of the query.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param alias The alias for the subquery.
*
* Failure to provide an alias will result in a DrizzleTypeError, preventing the subquery from being referenced in other queries.
*
* @example
*
* ```ts
* // Create a subquery with alias 'sq' and use it in the select query
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* const result = await db.with(sq).select().from(sq);
* ```
*
* To select arbitrary SQL values as fields in a CTE and reference them in other CTEs or in the main query, you need to add aliases to them:
*
* ```ts
* // Select an arbitrary SQL value as a field in a CTE and reference it in the main query
* const sq = db.$with('sq').as(db.select({
* name: sql<string>`upper(${users.name})`.as('name'),
* })
* .from(users));
*
* const result = await db.with(sq).select({ name: sq.name }).from(sq);
* ```
*/
$with(alias) {
const self = this;
return {
as(qb) {
if (typeof qb === "function") {
qb = qb(new QueryBuilder(self.dialect));
}
return new Proxy(
new WithSubquery(qb.getSQL(), qb.getSelectedFields(), alias, true),
new SelectionProxyHandler({ alias, sqlAliasedBehavior: "alias", sqlBehavior: "error" })
);
}
};
}
$count(source, filters) {
return new SQLiteCountBuilder({ source, filters, session: this.session });
}
/**
* Incorporates a previously defined CTE (using `$with`) into the main query.
*
* This method allows the main query to reference a temporary named result set.
*
* See docs: {@link https://orm.drizzle.team/docs/select#with-clause}
*
* @param queries The CTEs to incorporate into the main query.
*
* @example
*
* ```ts
* // Define a subquery 'sq' as a CTE using $with
* const sq = db.$with('sq').as(db.select().from(users).where(eq(users.id, 42)));
*
* // Incorporate the CTE 'sq' into the main query and select from it
* const result = await db.with(sq).select().from(sq);
* ```
*/
with(...queries) {
const self = this;
function select(fields) {
return new SQLiteSelectBuilder({
fields: fields ?? void 0,
session: self.session,
dialect: self.dialect,
withList: queries
});
}
function selectDistinct(fields) {
return new SQLiteSelectBuilder({
fields: fields ?? void 0,
session: self.session,
dialect: self.dialect,
withList: queries,
distinct: true
});
}
function update(table) {
return new SQLiteUpdateBuilder(table, self.session, self.dialect, queries);
}
function insert(into) {
return new SQLiteInsertBuilder(into, self.session, self.dialect, queries);
}
function delete_(from) {
return new SQLiteDeleteBase(from, self.session, self.dialect, queries);
}
return { select, selectDistinct, update, insert, delete: delete_ };
}
select(fields) {
return new SQLiteSelectBuilder({ fields: fields ?? void 0, session: this.session, dialect: this.dialect });
}
selectDistinct(fields) {
return new SQLiteSelectBuilder({
fields: fields ?? void 0,
session: this.session,
dialect: this.dialect,
distinct: true
});
}
/**
* Creates an update query.
*
* Calling this method without `.where()` clause will update all rows in a table. The `.where()` clause specifies which rows should be updated.
*
* Use `.set()` method to specify which values to update.
*
* See docs: {@link https://orm.drizzle.team/docs/update}
*
* @param table The table to update.
*
* @example
*
* ```ts
* // Update all rows in the 'cars' table
* await db.update(cars).set({ color: 'red' });
*
* // Update rows with filters and conditions
* await db.update(cars).set({ color: 'red' }).where(eq(cars.brand, 'BMW'));
*
* // Update with returning clause
* const updatedCar: Car[] = await db.update(cars)
* .set({ color: 'red' })
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
update(table) {
return new SQLiteUpdateBuilder(table, this.session, this.dialect);
}
/**
* Creates an insert query.
*
* Calling this method will create new rows in a table. Use `.values()` method to specify which values to insert.
*
* See docs: {@link https://orm.drizzle.team/docs/insert}
*
* @param table The table to insert into.
*
* @example
*
* ```ts
* // Insert one row
* await db.insert(cars).values({ brand: 'BMW' });
*
* // Insert multiple rows
* await db.insert(cars).values([{ brand: 'BMW' }, { brand: 'Porsche' }]);
*
* // Insert with returning clause
* const insertedCar: Car[] = await db.insert(cars)
* .values({ brand: 'BMW' })
* .returning();
* ```
*/
insert(into) {
return new SQLiteInsertBuilder(into, this.session, this.dialect);
}
/**
* Creates a delete query.
*
* Calling this method without `.where()` clause will delete all rows in a table. The `.where()` clause specifies which rows should be deleted.
*
* See docs: {@link https://orm.drizzle.team/docs/delete}
*
* @param table The table to delete from.
*
* @example
*
* ```ts
* // Delete all rows in the 'cars' table
* await db.delete(cars);
*
* // Delete rows with filters and conditions
* await db.delete(cars).where(eq(cars.color, 'green'));
*
* // Delete with returning clause
* const deletedCar: Car[] = await db.delete(cars)
* .where(eq(cars.id, 1))
* .returning();
* ```
*/
delete(from) {
return new SQLiteDeleteBase(from, this.session, this.dialect);
}
run(query) {
const sequel = typeof query === "string" ? sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new SQLiteRaw(
async () => this.session.run(sequel),
() => sequel,
"run",
this.dialect,
this.session.extractRawRunValueFromBatchResult.bind(this.session)
);
}
return this.session.run(sequel);
}
all(query) {
const sequel = typeof query === "string" ? sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new SQLiteRaw(
async () => this.session.all(sequel),
() => sequel,
"all",
this.dialect,
this.session.extractRawAllValueFromBatchResult.bind(this.session)
);
}
return this.session.all(sequel);
}
get(query) {
const sequel = typeof query === "string" ? sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new SQLiteRaw(
async () => this.session.get(sequel),
() => sequel,
"get",
this.dialect,
this.session.extractRawGetValueFromBatchResult.bind(this.session)
);
}
return this.session.get(sequel);
}
values(query) {
const sequel = typeof query === "string" ? sql.raw(query) : query.getSQL();
if (this.resultKind === "async") {
return new SQLiteRaw(
async () => this.session.values(sequel),
() => sequel,
"values",
this.dialect,
this.session.extractRawValuesValueFromBatchResult.bind(this.session)
);
}
return this.session.values(sequel);
}
transaction(transaction, config) {
return this.session.transaction(transaction, config);
}
}
const withReplicas = (primary, replicas, getReplica = () => replicas[Math.floor(Math.random() * replicas.length)]) => {
const select = (...args) => getReplica(replicas).select(...args);
const selectDistinct = (...args) => getReplica(replicas).selectDistinct(...args);
const $with = (...args) => getReplica(replicas).with(...args);
const update = (...args) => primary.update(...args);
const insert = (...args) => primary.insert(...args);
const $delete = (...args) => primary.delete(...args);
const run = (...args) => primary.run(...args);
const all = (...args) => primary.all(...args);
const get = (...args) => primary.get(...args);
const values = (...args) => primary.values(...args);
const transaction = (...args) => primary.transaction(...args);
return {
...primary,
update,
insert,
delete: $delete,
run,
all,
get,
values,
transaction,
$primary: primary,
select,
selectDistinct,
with: $with,
get query() {
return getReplica(replicas).query;
}
};
};
export {
BaseSQLiteDatabase,
withReplicas
};
//# sourceMappingURL=db.js.map

1
node_modules/drizzle-orm/sqlite-core/db.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

654
node_modules/drizzle-orm/sqlite-core/dialect.cjs generated vendored Normal file
View File

@ -0,0 +1,654 @@
"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 dialect_exports = {};
__export(dialect_exports, {
SQLiteAsyncDialect: () => SQLiteAsyncDialect,
SQLiteDialect: () => SQLiteDialect,
SQLiteSyncDialect: () => SQLiteSyncDialect
});
module.exports = __toCommonJS(dialect_exports);
var import_alias = require("../alias.cjs");
var import_casing = require("../casing.cjs");
var import_column = require("../column.cjs");
var import_entity = require("../entity.cjs");
var import_errors = require("../errors.cjs");
var import_relations = require("../relations.cjs");
var import_sql = require("../sql/index.cjs");
var import_sql2 = require("../sql/sql.cjs");
var import_columns = require("./columns/index.cjs");
var import_table = require("./table.cjs");
var import_subquery = require("../subquery.cjs");
var import_table2 = require("../table.cjs");
var import_utils = require("../utils.cjs");
var import_view_common = require("../view-common.cjs");
var import_view_base = require("./view-base.cjs");
class SQLiteDialect {
static [import_entity.entityKind] = "SQLiteDialect";
/** @internal */
casing;
constructor(config) {
this.casing = new import_casing.CasingCache(config?.casing);
}
escapeName(name) {
return `"${name}"`;
}
escapeParam(_num) {
return "?";
}
escapeString(str) {
return `'${str.replace(/'/g, "''")}'`;
}
buildWithCTE(queries) {
if (!queries?.length)
return void 0;
const withSqlChunks = [import_sql2.sql`with `];
for (const [i, w] of queries.entries()) {
withSqlChunks.push(import_sql2.sql`${import_sql2.sql.identifier(w._.alias)} as (${w._.sql})`);
if (i < queries.length - 1) {
withSqlChunks.push(import_sql2.sql`, `);
}
}
withSqlChunks.push(import_sql2.sql` `);
return import_sql2.sql.join(withSqlChunks);
}
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }) {
const withSql = this.buildWithCTE(withList);
const returningSql = returning ? import_sql2.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
const whereSql = where ? import_sql2.sql` where ${where}` : void 0;
const orderBySql = this.buildOrderBy(orderBy);
const limitSql = this.buildLimit(limit);
return import_sql2.sql`${withSql}delete from ${table}${whereSql}${returningSql}${orderBySql}${limitSql}`;
}
buildUpdateSet(table, set) {
const tableColumns = table[import_table2.Table.Symbol.Columns];
const columnNames = Object.keys(tableColumns).filter(
(colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0
);
const setSize = columnNames.length;
return import_sql2.sql.join(columnNames.flatMap((colName, i) => {
const col = tableColumns[colName];
const value = set[colName] ?? import_sql2.sql.param(col.onUpdateFn(), col);
const res = import_sql2.sql`${import_sql2.sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
if (i < setSize - 1) {
return [res, import_sql2.sql.raw(", ")];
}
return [res];
}));
}
buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy }) {
const withSql = this.buildWithCTE(withList);
const setSql = this.buildUpdateSet(table, set);
const fromSql = from && import_sql2.sql.join([import_sql2.sql.raw(" from "), this.buildFromTable(from)]);
const joinsSql = this.buildJoins(joins);
const returningSql = returning ? import_sql2.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
const whereSql = where ? import_sql2.sql` where ${where}` : void 0;
const orderBySql = this.buildOrderBy(orderBy);
const limitSql = this.buildLimit(limit);
return import_sql2.sql`${withSql}update ${table} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}${orderBySql}${limitSql}`;
}
/**
* Builds selection SQL with provided fields/expressions
*
* Examples:
*
* `select <selection> from`
*
* `insert ... returning <selection>`
*
* If `isSingleTable` is true, then columns won't be prefixed with table name
*/
buildSelection(fields, { isSingleTable = false } = {}) {
const columnsLen = fields.length;
const chunks = fields.flatMap(({ field }, i) => {
const chunk = [];
if ((0, import_entity.is)(field, import_sql2.SQL.Aliased) && field.isSelectionField) {
chunk.push(import_sql2.sql.identifier(field.fieldAlias));
} else if ((0, import_entity.is)(field, import_sql2.SQL.Aliased) || (0, import_entity.is)(field, import_sql2.SQL)) {
const query = (0, import_entity.is)(field, import_sql2.SQL.Aliased) ? field.sql : field;
if (isSingleTable) {
chunk.push(
new import_sql2.SQL(
query.queryChunks.map((c) => {
if ((0, import_entity.is)(c, import_column.Column)) {
return import_sql2.sql.identifier(this.casing.getColumnCasing(c));
}
return c;
})
)
);
} else {
chunk.push(query);
}
if ((0, import_entity.is)(field, import_sql2.SQL.Aliased)) {
chunk.push(import_sql2.sql` as ${import_sql2.sql.identifier(field.fieldAlias)}`);
}
} else if ((0, import_entity.is)(field, import_column.Column)) {
const tableName = field.table[import_table2.Table.Symbol.Name];
if (isSingleTable) {
chunk.push(import_sql2.sql.identifier(this.casing.getColumnCasing(field)));
} else {
chunk.push(import_sql2.sql`${import_sql2.sql.identifier(tableName)}.${import_sql2.sql.identifier(this.casing.getColumnCasing(field))}`);
}
}
if (i < columnsLen - 1) {
chunk.push(import_sql2.sql`, `);
}
return chunk;
});
return import_sql2.sql.join(chunks);
}
buildJoins(joins) {
if (!joins || joins.length === 0) {
return void 0;
}
const joinsArray = [];
if (joins) {
for (const [index, joinMeta] of joins.entries()) {
if (index === 0) {
joinsArray.push(import_sql2.sql` `);
}
const table = joinMeta.table;
if ((0, import_entity.is)(table, import_table.SQLiteTable)) {
const tableName = table[import_table.SQLiteTable.Symbol.Name];
const tableSchema = table[import_table.SQLiteTable.Symbol.Schema];
const origTableName = table[import_table.SQLiteTable.Symbol.OriginalName];
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
joinsArray.push(
import_sql2.sql`${import_sql2.sql.raw(joinMeta.joinType)} join ${tableSchema ? import_sql2.sql`${import_sql2.sql.identifier(tableSchema)}.` : void 0}${import_sql2.sql.identifier(origTableName)}${alias && import_sql2.sql` ${import_sql2.sql.identifier(alias)}`} on ${joinMeta.on}`
);
} else {
joinsArray.push(
import_sql2.sql`${import_sql2.sql.raw(joinMeta.joinType)} join ${table} on ${joinMeta.on}`
);
}
if (index < joins.length - 1) {
joinsArray.push(import_sql2.sql` `);
}
}
}
return import_sql2.sql.join(joinsArray);
}
buildLimit(limit) {
return typeof limit === "object" || typeof limit === "number" && limit >= 0 ? import_sql2.sql` limit ${limit}` : void 0;
}
buildOrderBy(orderBy) {
const orderByList = [];
if (orderBy) {
for (const [index, orderByValue] of orderBy.entries()) {
orderByList.push(orderByValue);
if (index < orderBy.length - 1) {
orderByList.push(import_sql2.sql`, `);
}
}
}
return orderByList.length > 0 ? import_sql2.sql` order by ${import_sql2.sql.join(orderByList)}` : void 0;
}
buildFromTable(table) {
if ((0, import_entity.is)(table, import_table2.Table) && table[import_table2.Table.Symbol.OriginalName] !== table[import_table2.Table.Symbol.Name]) {
return import_sql2.sql`${import_sql2.sql.identifier(table[import_table2.Table.Symbol.OriginalName])} ${import_sql2.sql.identifier(table[import_table2.Table.Symbol.Name])}`;
}
return table;
}
buildSelectQuery({
withList,
fields,
fieldsFlat,
where,
having,
table,
joins,
orderBy,
groupBy,
limit,
offset,
distinct,
setOperators
}) {
const fieldsList = fieldsFlat ?? (0, import_utils.orderSelectedFields)(fields);
for (const f of fieldsList) {
if ((0, import_entity.is)(f.field, import_column.Column) && (0, import_table2.getTableName)(f.field.table) !== ((0, import_entity.is)(table, import_subquery.Subquery) ? table._.alias : (0, import_entity.is)(table, import_view_base.SQLiteViewBase) ? table[import_view_common.ViewBaseConfig].name : (0, import_entity.is)(table, import_sql2.SQL) ? void 0 : (0, import_table2.getTableName)(table)) && !((table2) => joins?.some(
({ alias }) => alias === (table2[import_table2.Table.Symbol.IsAlias] ? (0, import_table2.getTableName)(table2) : table2[import_table2.Table.Symbol.BaseName])
))(f.field.table)) {
const tableName = (0, import_table2.getTableName)(f.field.table);
throw new Error(
`Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`
);
}
}
const isSingleTable = !joins || joins.length === 0;
const withSql = this.buildWithCTE(withList);
const distinctSql = distinct ? import_sql2.sql` distinct` : void 0;
const selection = this.buildSelection(fieldsList, { isSingleTable });
const tableSql = this.buildFromTable(table);
const joinsSql = this.buildJoins(joins);
const whereSql = where ? import_sql2.sql` where ${where}` : void 0;
const havingSql = having ? import_sql2.sql` having ${having}` : void 0;
const groupByList = [];
if (groupBy) {
for (const [index, groupByValue] of groupBy.entries()) {
groupByList.push(groupByValue);
if (index < groupBy.length - 1) {
groupByList.push(import_sql2.sql`, `);
}
}
}
const groupBySql = groupByList.length > 0 ? import_sql2.sql` group by ${import_sql2.sql.join(groupByList)}` : void 0;
const orderBySql = this.buildOrderBy(orderBy);
const limitSql = this.buildLimit(limit);
const offsetSql = offset ? import_sql2.sql` offset ${offset}` : void 0;
const finalQuery = import_sql2.sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}`;
if (setOperators.length > 0) {
return this.buildSetOperations(finalQuery, setOperators);
}
return finalQuery;
}
buildSetOperations(leftSelect, setOperators) {
const [setOperator, ...rest] = setOperators;
if (!setOperator) {
throw new Error("Cannot pass undefined values to any set operator");
}
if (rest.length === 0) {
return this.buildSetOperationQuery({ leftSelect, setOperator });
}
return this.buildSetOperations(
this.buildSetOperationQuery({ leftSelect, setOperator }),
rest
);
}
buildSetOperationQuery({
leftSelect,
setOperator: { type, isAll, rightSelect, limit, orderBy, offset }
}) {
const leftChunk = import_sql2.sql`${leftSelect.getSQL()} `;
const rightChunk = import_sql2.sql`${rightSelect.getSQL()}`;
let orderBySql;
if (orderBy && orderBy.length > 0) {
const orderByValues = [];
for (const singleOrderBy of orderBy) {
if ((0, import_entity.is)(singleOrderBy, import_columns.SQLiteColumn)) {
orderByValues.push(import_sql2.sql.identifier(singleOrderBy.name));
} else if ((0, import_entity.is)(singleOrderBy, import_sql2.SQL)) {
for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
const chunk = singleOrderBy.queryChunks[i];
if ((0, import_entity.is)(chunk, import_columns.SQLiteColumn)) {
singleOrderBy.queryChunks[i] = import_sql2.sql.identifier(this.casing.getColumnCasing(chunk));
}
}
orderByValues.push(import_sql2.sql`${singleOrderBy}`);
} else {
orderByValues.push(import_sql2.sql`${singleOrderBy}`);
}
}
orderBySql = import_sql2.sql` order by ${import_sql2.sql.join(orderByValues, import_sql2.sql`, `)}`;
}
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? import_sql2.sql` limit ${limit}` : void 0;
const operatorChunk = import_sql2.sql.raw(`${type} ${isAll ? "all " : ""}`);
const offsetSql = offset ? import_sql2.sql` offset ${offset}` : void 0;
return import_sql2.sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
}
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select }) {
const valuesSqlList = [];
const columns = table[import_table2.Table.Symbol.Columns];
const colEntries = Object.entries(columns).filter(
([_, col]) => !col.shouldDisableInsert()
);
const insertOrder = colEntries.map(([, column]) => import_sql2.sql.identifier(this.casing.getColumnCasing(column)));
if (select) {
const select2 = valuesOrSelect;
if ((0, import_entity.is)(select2, import_sql2.SQL)) {
valuesSqlList.push(select2);
} else {
valuesSqlList.push(select2.getSQL());
}
} else {
const values = valuesOrSelect;
valuesSqlList.push(import_sql2.sql.raw("values "));
for (const [valueIndex, value] of values.entries()) {
const valueList = [];
for (const [fieldName, col] of colEntries) {
const colValue = value[fieldName];
if (colValue === void 0 || (0, import_entity.is)(colValue, import_sql2.Param) && colValue.value === void 0) {
let defaultValue;
if (col.default !== null && col.default !== void 0) {
defaultValue = (0, import_entity.is)(col.default, import_sql2.SQL) ? col.default : import_sql2.sql.param(col.default, col);
} else if (col.defaultFn !== void 0) {
const defaultFnResult = col.defaultFn();
defaultValue = (0, import_entity.is)(defaultFnResult, import_sql2.SQL) ? defaultFnResult : import_sql2.sql.param(defaultFnResult, col);
} else if (!col.default && col.onUpdateFn !== void 0) {
const onUpdateFnResult = col.onUpdateFn();
defaultValue = (0, import_entity.is)(onUpdateFnResult, import_sql2.SQL) ? onUpdateFnResult : import_sql2.sql.param(onUpdateFnResult, col);
} else {
defaultValue = import_sql2.sql`null`;
}
valueList.push(defaultValue);
} else {
valueList.push(colValue);
}
}
valuesSqlList.push(valueList);
if (valueIndex < values.length - 1) {
valuesSqlList.push(import_sql2.sql`, `);
}
}
}
const withSql = this.buildWithCTE(withList);
const valuesSql = import_sql2.sql.join(valuesSqlList);
const returningSql = returning ? import_sql2.sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
const onConflictSql = onConflict ? import_sql2.sql` on conflict ${onConflict}` : void 0;
return import_sql2.sql`${withSql}insert into ${table} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
}
sqlToQuery(sql2, invokeSource) {
return sql2.toQuery({
casing: this.casing,
escapeName: this.escapeName,
escapeParam: this.escapeParam,
escapeString: this.escapeString,
invokeSource
});
}
buildRelationalQuery({
fullSchema,
schema,
tableNamesMap,
table,
tableConfig,
queryConfig: config,
tableAlias,
nestedQueryRelation,
joinOn
}) {
let selection = [];
let limit, offset, orderBy = [], where;
const joins = [];
if (config === true) {
const selectionEntries = Object.entries(tableConfig.columns);
selection = selectionEntries.map(([key, value]) => ({
dbKey: value.name,
tsKey: key,
field: (0, import_alias.aliasedTableColumn)(value, tableAlias),
relationTableTsKey: void 0,
isJson: false,
selection: []
}));
} else {
const aliasedColumns = Object.fromEntries(
Object.entries(tableConfig.columns).map(([key, value]) => [key, (0, import_alias.aliasedTableColumn)(value, tableAlias)])
);
if (config.where) {
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, (0, import_relations.getOperators)()) : config.where;
where = whereSql && (0, import_alias.mapColumnsInSQLToAlias)(whereSql, tableAlias);
}
const fieldsSelection = [];
let selectedColumns = [];
if (config.columns) {
let isIncludeMode = false;
for (const [field, value] of Object.entries(config.columns)) {
if (value === void 0) {
continue;
}
if (field in tableConfig.columns) {
if (!isIncludeMode && value === true) {
isIncludeMode = true;
}
selectedColumns.push(field);
}
}
if (selectedColumns.length > 0) {
selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
}
} else {
selectedColumns = Object.keys(tableConfig.columns);
}
for (const field of selectedColumns) {
const column = tableConfig.columns[field];
fieldsSelection.push({ tsKey: field, value: column });
}
let selectedRelations = [];
if (config.with) {
selectedRelations = Object.entries(config.with).filter((entry) => !!entry[1]).map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey] }));
}
let extras;
if (config.extras) {
extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql: import_sql2.sql }) : config.extras;
for (const [tsKey, value] of Object.entries(extras)) {
fieldsSelection.push({
tsKey,
value: (0, import_alias.mapColumnsInAliasedSQLToAlias)(value, tableAlias)
});
}
}
for (const { tsKey, value } of fieldsSelection) {
selection.push({
dbKey: (0, import_entity.is)(value, import_sql2.SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey].name,
tsKey,
field: (0, import_entity.is)(value, import_column.Column) ? (0, import_alias.aliasedTableColumn)(value, tableAlias) : value,
relationTableTsKey: void 0,
isJson: false,
selection: []
});
}
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, (0, import_relations.getOrderByOperators)()) : config.orderBy ?? [];
if (!Array.isArray(orderByOrig)) {
orderByOrig = [orderByOrig];
}
orderBy = orderByOrig.map((orderByValue) => {
if ((0, import_entity.is)(orderByValue, import_column.Column)) {
return (0, import_alias.aliasedTableColumn)(orderByValue, tableAlias);
}
return (0, import_alias.mapColumnsInSQLToAlias)(orderByValue, tableAlias);
});
limit = config.limit;
offset = config.offset;
for (const {
tsKey: selectedRelationTsKey,
queryConfig: selectedRelationConfigValue,
relation
} of selectedRelations) {
const normalizedRelation = (0, import_relations.normalizeRelation)(schema, tableNamesMap, relation);
const relationTableName = (0, import_table2.getTableUniqueName)(relation.referencedTable);
const relationTableTsName = tableNamesMap[relationTableName];
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
const joinOn2 = (0, import_sql.and)(
...normalizedRelation.fields.map(
(field2, i) => (0, import_sql.eq)(
(0, import_alias.aliasedTableColumn)(normalizedRelation.references[i], relationTableAlias),
(0, import_alias.aliasedTableColumn)(field2, tableAlias)
)
)
);
const builtRelation = this.buildRelationalQuery({
fullSchema,
schema,
tableNamesMap,
table: fullSchema[relationTableTsName],
tableConfig: schema[relationTableTsName],
queryConfig: (0, import_entity.is)(relation, import_relations.One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
tableAlias: relationTableAlias,
joinOn: joinOn2,
nestedQueryRelation: relation
});
const field = import_sql2.sql`(${builtRelation.sql})`.as(selectedRelationTsKey);
selection.push({
dbKey: selectedRelationTsKey,
tsKey: selectedRelationTsKey,
field,
relationTableTsKey: relationTableTsName,
isJson: true,
selection: builtRelation.selection
});
}
}
if (selection.length === 0) {
throw new import_errors.DrizzleError({
message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`
});
}
let result;
where = (0, import_sql.and)(joinOn, where);
if (nestedQueryRelation) {
let field = import_sql2.sql`json_array(${import_sql2.sql.join(
selection.map(
({ field: field2 }) => (0, import_entity.is)(field2, import_columns.SQLiteColumn) ? import_sql2.sql.identifier(this.casing.getColumnCasing(field2)) : (0, import_entity.is)(field2, import_sql2.SQL.Aliased) ? field2.sql : field2
),
import_sql2.sql`, `
)})`;
if ((0, import_entity.is)(nestedQueryRelation, import_relations.Many)) {
field = import_sql2.sql`coalesce(json_group_array(${field}), json_array())`;
}
const nestedSelection = [{
dbKey: "data",
tsKey: "data",
field: field.as("data"),
isJson: true,
relationTableTsKey: tableConfig.tsName,
selection
}];
const needsSubquery = limit !== void 0 || offset !== void 0 || orderBy.length > 0;
if (needsSubquery) {
result = this.buildSelectQuery({
table: (0, import_alias.aliasedTable)(table, tableAlias),
fields: {},
fieldsFlat: [
{
path: [],
field: import_sql2.sql.raw("*")
}
],
where,
limit,
offset,
orderBy,
setOperators: []
});
where = void 0;
limit = void 0;
offset = void 0;
orderBy = void 0;
} else {
result = (0, import_alias.aliasedTable)(table, tableAlias);
}
result = this.buildSelectQuery({
table: (0, import_entity.is)(result, import_table.SQLiteTable) ? result : new import_subquery.Subquery(result, {}, tableAlias),
fields: {},
fieldsFlat: nestedSelection.map(({ field: field2 }) => ({
path: [],
field: (0, import_entity.is)(field2, import_column.Column) ? (0, import_alias.aliasedTableColumn)(field2, tableAlias) : field2
})),
joins,
where,
limit,
offset,
orderBy,
setOperators: []
});
} else {
result = this.buildSelectQuery({
table: (0, import_alias.aliasedTable)(table, tableAlias),
fields: {},
fieldsFlat: selection.map(({ field }) => ({
path: [],
field: (0, import_entity.is)(field, import_column.Column) ? (0, import_alias.aliasedTableColumn)(field, tableAlias) : field
})),
joins,
where,
limit,
offset,
orderBy,
setOperators: []
});
}
return {
tableTsKey: tableConfig.tsName,
sql: result,
selection
};
}
}
class SQLiteSyncDialect extends SQLiteDialect {
static [import_entity.entityKind] = "SQLiteSyncDialect";
migrate(migrations, session, config) {
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.migrationsTable ?? "__drizzle_migrations";
const migrationTableCreate = import_sql2.sql`
CREATE TABLE IF NOT EXISTS ${import_sql2.sql.identifier(migrationsTable)} (
id SERIAL PRIMARY KEY,
hash text NOT NULL,
created_at numeric
)
`;
session.run(migrationTableCreate);
const dbMigrations = session.values(
import_sql2.sql`SELECT id, hash, created_at FROM ${import_sql2.sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
session.run(import_sql2.sql`BEGIN`);
try {
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
for (const stmt of migration.sql) {
session.run(import_sql2.sql.raw(stmt));
}
session.run(
import_sql2.sql`INSERT INTO ${import_sql2.sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
);
}
}
session.run(import_sql2.sql`COMMIT`);
} catch (e) {
session.run(import_sql2.sql`ROLLBACK`);
throw e;
}
}
}
class SQLiteAsyncDialect extends SQLiteDialect {
static [import_entity.entityKind] = "SQLiteAsyncDialect";
async migrate(migrations, session, config) {
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.migrationsTable ?? "__drizzle_migrations";
const migrationTableCreate = import_sql2.sql`
CREATE TABLE IF NOT EXISTS ${import_sql2.sql.identifier(migrationsTable)} (
id SERIAL PRIMARY KEY,
hash text NOT NULL,
created_at numeric
)
`;
await session.run(migrationTableCreate);
const dbMigrations = await session.values(
import_sql2.sql`SELECT id, hash, created_at FROM ${import_sql2.sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
await session.transaction(async (tx) => {
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
for (const stmt of migration.sql) {
await tx.run(import_sql2.sql.raw(stmt));
}
await tx.run(
import_sql2.sql`INSERT INTO ${import_sql2.sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
);
}
}
});
}
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SQLiteAsyncDialect,
SQLiteDialect,
SQLiteSyncDialect
});
//# sourceMappingURL=dialect.cjs.map

1
node_modules/drizzle-orm/sqlite-core/dialect.cjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

67
node_modules/drizzle-orm/sqlite-core/dialect.d.cts generated vendored Normal file
View File

@ -0,0 +1,67 @@
import { entityKind } from "../entity.cjs";
import type { MigrationConfig, MigrationMeta } from "../migrator.cjs";
import { type BuildRelationalQueryResult, type DBQueryConfig, type Relation, type TableRelationalConfig, type TablesRelationalConfig } from "../relations.cjs";
import { type QueryWithTypings, SQL } from "../sql/sql.cjs";
import { SQLiteColumn } from "./columns/index.cjs";
import type { SQLiteDeleteConfig, SQLiteInsertConfig, SQLiteUpdateConfig } from "./query-builders/index.cjs";
import { SQLiteTable } from "./table.cjs";
import { type Casing, type UpdateSet } from "../utils.cjs";
import type { SQLiteSelectConfig } from "./query-builders/select.types.cjs";
import type { SQLiteSession } from "./session.cjs";
export interface SQLiteDialectConfig {
casing?: Casing;
}
export declare abstract class SQLiteDialect {
static readonly [entityKind]: string;
constructor(config?: SQLiteDialectConfig);
escapeName(name: string): string;
escapeParam(_num: number): string;
escapeString(str: string): string;
private buildWithCTE;
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }: SQLiteDeleteConfig): SQL;
buildUpdateSet(table: SQLiteTable, set: UpdateSet): SQL;
buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy }: SQLiteUpdateConfig): SQL;
/**
* Builds selection SQL with provided fields/expressions
*
* Examples:
*
* `select <selection> from`
*
* `insert ... returning <selection>`
*
* If `isSingleTable` is true, then columns won't be prefixed with table name
*/
private buildSelection;
private buildJoins;
private buildLimit;
private buildOrderBy;
private buildFromTable;
buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, distinct, setOperators, }: SQLiteSelectConfig): SQL;
buildSetOperations(leftSelect: SQL, setOperators: SQLiteSelectConfig['setOperators']): SQL;
buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset }, }: {
leftSelect: SQL;
setOperator: SQLiteSelectConfig['setOperators'][number];
}): SQL;
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select }: SQLiteInsertConfig): SQL;
sqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings;
buildRelationalQuery({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
fullSchema: Record<string, unknown>;
schema: TablesRelationalConfig;
tableNamesMap: Record<string, string>;
table: SQLiteTable;
tableConfig: TableRelationalConfig;
queryConfig: true | DBQueryConfig<'many', true>;
tableAlias: string;
nestedQueryRelation?: Relation;
joinOn?: SQL;
}): BuildRelationalQueryResult<SQLiteTable, SQLiteColumn>;
}
export declare class SQLiteSyncDialect extends SQLiteDialect {
static readonly [entityKind]: string;
migrate(migrations: MigrationMeta[], session: SQLiteSession<'sync', unknown, Record<string, unknown>, TablesRelationalConfig>, config?: string | MigrationConfig): void;
}
export declare class SQLiteAsyncDialect extends SQLiteDialect {
static readonly [entityKind]: string;
migrate(migrations: MigrationMeta[], session: SQLiteSession<'async', any, any, any>, config?: string | MigrationConfig): Promise<void>;
}

67
node_modules/drizzle-orm/sqlite-core/dialect.d.ts generated vendored Normal file
View File

@ -0,0 +1,67 @@
import { entityKind } from "../entity.js";
import type { MigrationConfig, MigrationMeta } from "../migrator.js";
import { type BuildRelationalQueryResult, type DBQueryConfig, type Relation, type TableRelationalConfig, type TablesRelationalConfig } from "../relations.js";
import { type QueryWithTypings, SQL } from "../sql/sql.js";
import { SQLiteColumn } from "./columns/index.js";
import type { SQLiteDeleteConfig, SQLiteInsertConfig, SQLiteUpdateConfig } from "./query-builders/index.js";
import { SQLiteTable } from "./table.js";
import { type Casing, type UpdateSet } from "../utils.js";
import type { SQLiteSelectConfig } from "./query-builders/select.types.js";
import type { SQLiteSession } from "./session.js";
export interface SQLiteDialectConfig {
casing?: Casing;
}
export declare abstract class SQLiteDialect {
static readonly [entityKind]: string;
constructor(config?: SQLiteDialectConfig);
escapeName(name: string): string;
escapeParam(_num: number): string;
escapeString(str: string): string;
private buildWithCTE;
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }: SQLiteDeleteConfig): SQL;
buildUpdateSet(table: SQLiteTable, set: UpdateSet): SQL;
buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy }: SQLiteUpdateConfig): SQL;
/**
* Builds selection SQL with provided fields/expressions
*
* Examples:
*
* `select <selection> from`
*
* `insert ... returning <selection>`
*
* If `isSingleTable` is true, then columns won't be prefixed with table name
*/
private buildSelection;
private buildJoins;
private buildLimit;
private buildOrderBy;
private buildFromTable;
buildSelectQuery({ withList, fields, fieldsFlat, where, having, table, joins, orderBy, groupBy, limit, offset, distinct, setOperators, }: SQLiteSelectConfig): SQL;
buildSetOperations(leftSelect: SQL, setOperators: SQLiteSelectConfig['setOperators']): SQL;
buildSetOperationQuery({ leftSelect, setOperator: { type, isAll, rightSelect, limit, orderBy, offset }, }: {
leftSelect: SQL;
setOperator: SQLiteSelectConfig['setOperators'][number];
}): SQL;
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select }: SQLiteInsertConfig): SQL;
sqlToQuery(sql: SQL, invokeSource?: 'indexes' | undefined): QueryWithTypings;
buildRelationalQuery({ fullSchema, schema, tableNamesMap, table, tableConfig, queryConfig: config, tableAlias, nestedQueryRelation, joinOn, }: {
fullSchema: Record<string, unknown>;
schema: TablesRelationalConfig;
tableNamesMap: Record<string, string>;
table: SQLiteTable;
tableConfig: TableRelationalConfig;
queryConfig: true | DBQueryConfig<'many', true>;
tableAlias: string;
nestedQueryRelation?: Relation;
joinOn?: SQL;
}): BuildRelationalQueryResult<SQLiteTable, SQLiteColumn>;
}
export declare class SQLiteSyncDialect extends SQLiteDialect {
static readonly [entityKind]: string;
migrate(migrations: MigrationMeta[], session: SQLiteSession<'sync', unknown, Record<string, unknown>, TablesRelationalConfig>, config?: string | MigrationConfig): void;
}
export declare class SQLiteAsyncDialect extends SQLiteDialect {
static readonly [entityKind]: string;
migrate(migrations: MigrationMeta[], session: SQLiteSession<'async', any, any, any>, config?: string | MigrationConfig): Promise<void>;
}

634
node_modules/drizzle-orm/sqlite-core/dialect.js generated vendored Normal file
View File

@ -0,0 +1,634 @@
import { aliasedTable, aliasedTableColumn, mapColumnsInAliasedSQLToAlias, mapColumnsInSQLToAlias } from "../alias.js";
import { CasingCache } from "../casing.js";
import { Column } from "../column.js";
import { entityKind, is } from "../entity.js";
import { DrizzleError } from "../errors.js";
import {
getOperators,
getOrderByOperators,
Many,
normalizeRelation,
One
} from "../relations.js";
import { and, eq } from "../sql/index.js";
import { Param, SQL, sql } from "../sql/sql.js";
import { SQLiteColumn } from "./columns/index.js";
import { SQLiteTable } from "./table.js";
import { Subquery } from "../subquery.js";
import { getTableName, getTableUniqueName, Table } from "../table.js";
import { orderSelectedFields } from "../utils.js";
import { ViewBaseConfig } from "../view-common.js";
import { SQLiteViewBase } from "./view-base.js";
class SQLiteDialect {
static [entityKind] = "SQLiteDialect";
/** @internal */
casing;
constructor(config) {
this.casing = new CasingCache(config?.casing);
}
escapeName(name) {
return `"${name}"`;
}
escapeParam(_num) {
return "?";
}
escapeString(str) {
return `'${str.replace(/'/g, "''")}'`;
}
buildWithCTE(queries) {
if (!queries?.length)
return void 0;
const withSqlChunks = [sql`with `];
for (const [i, w] of queries.entries()) {
withSqlChunks.push(sql`${sql.identifier(w._.alias)} as (${w._.sql})`);
if (i < queries.length - 1) {
withSqlChunks.push(sql`, `);
}
}
withSqlChunks.push(sql` `);
return sql.join(withSqlChunks);
}
buildDeleteQuery({ table, where, returning, withList, limit, orderBy }) {
const withSql = this.buildWithCTE(withList);
const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
const whereSql = where ? sql` where ${where}` : void 0;
const orderBySql = this.buildOrderBy(orderBy);
const limitSql = this.buildLimit(limit);
return sql`${withSql}delete from ${table}${whereSql}${returningSql}${orderBySql}${limitSql}`;
}
buildUpdateSet(table, set) {
const tableColumns = table[Table.Symbol.Columns];
const columnNames = Object.keys(tableColumns).filter(
(colName) => set[colName] !== void 0 || tableColumns[colName]?.onUpdateFn !== void 0
);
const setSize = columnNames.length;
return sql.join(columnNames.flatMap((colName, i) => {
const col = tableColumns[colName];
const value = set[colName] ?? sql.param(col.onUpdateFn(), col);
const res = sql`${sql.identifier(this.casing.getColumnCasing(col))} = ${value}`;
if (i < setSize - 1) {
return [res, sql.raw(", ")];
}
return [res];
}));
}
buildUpdateQuery({ table, set, where, returning, withList, joins, from, limit, orderBy }) {
const withSql = this.buildWithCTE(withList);
const setSql = this.buildUpdateSet(table, set);
const fromSql = from && sql.join([sql.raw(" from "), this.buildFromTable(from)]);
const joinsSql = this.buildJoins(joins);
const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
const whereSql = where ? sql` where ${where}` : void 0;
const orderBySql = this.buildOrderBy(orderBy);
const limitSql = this.buildLimit(limit);
return sql`${withSql}update ${table} set ${setSql}${fromSql}${joinsSql}${whereSql}${returningSql}${orderBySql}${limitSql}`;
}
/**
* Builds selection SQL with provided fields/expressions
*
* Examples:
*
* `select <selection> from`
*
* `insert ... returning <selection>`
*
* If `isSingleTable` is true, then columns won't be prefixed with table name
*/
buildSelection(fields, { isSingleTable = false } = {}) {
const columnsLen = fields.length;
const chunks = fields.flatMap(({ field }, i) => {
const chunk = [];
if (is(field, SQL.Aliased) && field.isSelectionField) {
chunk.push(sql.identifier(field.fieldAlias));
} else if (is(field, SQL.Aliased) || is(field, SQL)) {
const query = is(field, SQL.Aliased) ? field.sql : field;
if (isSingleTable) {
chunk.push(
new SQL(
query.queryChunks.map((c) => {
if (is(c, Column)) {
return sql.identifier(this.casing.getColumnCasing(c));
}
return c;
})
)
);
} else {
chunk.push(query);
}
if (is(field, SQL.Aliased)) {
chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
}
} else if (is(field, Column)) {
const tableName = field.table[Table.Symbol.Name];
if (isSingleTable) {
chunk.push(sql.identifier(this.casing.getColumnCasing(field)));
} else {
chunk.push(sql`${sql.identifier(tableName)}.${sql.identifier(this.casing.getColumnCasing(field))}`);
}
}
if (i < columnsLen - 1) {
chunk.push(sql`, `);
}
return chunk;
});
return sql.join(chunks);
}
buildJoins(joins) {
if (!joins || joins.length === 0) {
return void 0;
}
const joinsArray = [];
if (joins) {
for (const [index, joinMeta] of joins.entries()) {
if (index === 0) {
joinsArray.push(sql` `);
}
const table = joinMeta.table;
if (is(table, SQLiteTable)) {
const tableName = table[SQLiteTable.Symbol.Name];
const tableSchema = table[SQLiteTable.Symbol.Schema];
const origTableName = table[SQLiteTable.Symbol.OriginalName];
const alias = tableName === origTableName ? void 0 : joinMeta.alias;
joinsArray.push(
sql`${sql.raw(joinMeta.joinType)} join ${tableSchema ? sql`${sql.identifier(tableSchema)}.` : void 0}${sql.identifier(origTableName)}${alias && sql` ${sql.identifier(alias)}`} on ${joinMeta.on}`
);
} else {
joinsArray.push(
sql`${sql.raw(joinMeta.joinType)} join ${table} on ${joinMeta.on}`
);
}
if (index < joins.length - 1) {
joinsArray.push(sql` `);
}
}
}
return sql.join(joinsArray);
}
buildLimit(limit) {
return typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : void 0;
}
buildOrderBy(orderBy) {
const orderByList = [];
if (orderBy) {
for (const [index, orderByValue] of orderBy.entries()) {
orderByList.push(orderByValue);
if (index < orderBy.length - 1) {
orderByList.push(sql`, `);
}
}
}
return orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : void 0;
}
buildFromTable(table) {
if (is(table, Table) && table[Table.Symbol.OriginalName] !== table[Table.Symbol.Name]) {
return sql`${sql.identifier(table[Table.Symbol.OriginalName])} ${sql.identifier(table[Table.Symbol.Name])}`;
}
return table;
}
buildSelectQuery({
withList,
fields,
fieldsFlat,
where,
having,
table,
joins,
orderBy,
groupBy,
limit,
offset,
distinct,
setOperators
}) {
const fieldsList = fieldsFlat ?? orderSelectedFields(fields);
for (const f of fieldsList) {
if (is(f.field, Column) && getTableName(f.field.table) !== (is(table, Subquery) ? table._.alias : is(table, SQLiteViewBase) ? table[ViewBaseConfig].name : is(table, SQL) ? void 0 : getTableName(table)) && !((table2) => joins?.some(
({ alias }) => alias === (table2[Table.Symbol.IsAlias] ? getTableName(table2) : table2[Table.Symbol.BaseName])
))(f.field.table)) {
const tableName = getTableName(f.field.table);
throw new Error(
`Your "${f.path.join("->")}" field references a column "${tableName}"."${f.field.name}", but the table "${tableName}" is not part of the query! Did you forget to join it?`
);
}
}
const isSingleTable = !joins || joins.length === 0;
const withSql = this.buildWithCTE(withList);
const distinctSql = distinct ? sql` distinct` : void 0;
const selection = this.buildSelection(fieldsList, { isSingleTable });
const tableSql = this.buildFromTable(table);
const joinsSql = this.buildJoins(joins);
const whereSql = where ? sql` where ${where}` : void 0;
const havingSql = having ? sql` having ${having}` : void 0;
const groupByList = [];
if (groupBy) {
for (const [index, groupByValue] of groupBy.entries()) {
groupByList.push(groupByValue);
if (index < groupBy.length - 1) {
groupByList.push(sql`, `);
}
}
}
const groupBySql = groupByList.length > 0 ? sql` group by ${sql.join(groupByList)}` : void 0;
const orderBySql = this.buildOrderBy(orderBy);
const limitSql = this.buildLimit(limit);
const offsetSql = offset ? sql` offset ${offset}` : void 0;
const finalQuery = sql`${withSql}select${distinctSql} ${selection} from ${tableSql}${joinsSql}${whereSql}${groupBySql}${havingSql}${orderBySql}${limitSql}${offsetSql}`;
if (setOperators.length > 0) {
return this.buildSetOperations(finalQuery, setOperators);
}
return finalQuery;
}
buildSetOperations(leftSelect, setOperators) {
const [setOperator, ...rest] = setOperators;
if (!setOperator) {
throw new Error("Cannot pass undefined values to any set operator");
}
if (rest.length === 0) {
return this.buildSetOperationQuery({ leftSelect, setOperator });
}
return this.buildSetOperations(
this.buildSetOperationQuery({ leftSelect, setOperator }),
rest
);
}
buildSetOperationQuery({
leftSelect,
setOperator: { type, isAll, rightSelect, limit, orderBy, offset }
}) {
const leftChunk = sql`${leftSelect.getSQL()} `;
const rightChunk = sql`${rightSelect.getSQL()}`;
let orderBySql;
if (orderBy && orderBy.length > 0) {
const orderByValues = [];
for (const singleOrderBy of orderBy) {
if (is(singleOrderBy, SQLiteColumn)) {
orderByValues.push(sql.identifier(singleOrderBy.name));
} else if (is(singleOrderBy, SQL)) {
for (let i = 0; i < singleOrderBy.queryChunks.length; i++) {
const chunk = singleOrderBy.queryChunks[i];
if (is(chunk, SQLiteColumn)) {
singleOrderBy.queryChunks[i] = sql.identifier(this.casing.getColumnCasing(chunk));
}
}
orderByValues.push(sql`${singleOrderBy}`);
} else {
orderByValues.push(sql`${singleOrderBy}`);
}
}
orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)}`;
}
const limitSql = typeof limit === "object" || typeof limit === "number" && limit >= 0 ? sql` limit ${limit}` : void 0;
const operatorChunk = sql.raw(`${type} ${isAll ? "all " : ""}`);
const offsetSql = offset ? sql` offset ${offset}` : void 0;
return sql`${leftChunk}${operatorChunk}${rightChunk}${orderBySql}${limitSql}${offsetSql}`;
}
buildInsertQuery({ table, values: valuesOrSelect, onConflict, returning, withList, select }) {
const valuesSqlList = [];
const columns = table[Table.Symbol.Columns];
const colEntries = Object.entries(columns).filter(
([_, col]) => !col.shouldDisableInsert()
);
const insertOrder = colEntries.map(([, column]) => sql.identifier(this.casing.getColumnCasing(column)));
if (select) {
const select2 = valuesOrSelect;
if (is(select2, SQL)) {
valuesSqlList.push(select2);
} else {
valuesSqlList.push(select2.getSQL());
}
} else {
const values = valuesOrSelect;
valuesSqlList.push(sql.raw("values "));
for (const [valueIndex, value] of values.entries()) {
const valueList = [];
for (const [fieldName, col] of colEntries) {
const colValue = value[fieldName];
if (colValue === void 0 || is(colValue, Param) && colValue.value === void 0) {
let defaultValue;
if (col.default !== null && col.default !== void 0) {
defaultValue = is(col.default, SQL) ? col.default : sql.param(col.default, col);
} else if (col.defaultFn !== void 0) {
const defaultFnResult = col.defaultFn();
defaultValue = is(defaultFnResult, SQL) ? defaultFnResult : sql.param(defaultFnResult, col);
} else if (!col.default && col.onUpdateFn !== void 0) {
const onUpdateFnResult = col.onUpdateFn();
defaultValue = is(onUpdateFnResult, SQL) ? onUpdateFnResult : sql.param(onUpdateFnResult, col);
} else {
defaultValue = sql`null`;
}
valueList.push(defaultValue);
} else {
valueList.push(colValue);
}
}
valuesSqlList.push(valueList);
if (valueIndex < values.length - 1) {
valuesSqlList.push(sql`, `);
}
}
}
const withSql = this.buildWithCTE(withList);
const valuesSql = sql.join(valuesSqlList);
const returningSql = returning ? sql` returning ${this.buildSelection(returning, { isSingleTable: true })}` : void 0;
const onConflictSql = onConflict ? sql` on conflict ${onConflict}` : void 0;
return sql`${withSql}insert into ${table} ${insertOrder} ${valuesSql}${onConflictSql}${returningSql}`;
}
sqlToQuery(sql2, invokeSource) {
return sql2.toQuery({
casing: this.casing,
escapeName: this.escapeName,
escapeParam: this.escapeParam,
escapeString: this.escapeString,
invokeSource
});
}
buildRelationalQuery({
fullSchema,
schema,
tableNamesMap,
table,
tableConfig,
queryConfig: config,
tableAlias,
nestedQueryRelation,
joinOn
}) {
let selection = [];
let limit, offset, orderBy = [], where;
const joins = [];
if (config === true) {
const selectionEntries = Object.entries(tableConfig.columns);
selection = selectionEntries.map(([key, value]) => ({
dbKey: value.name,
tsKey: key,
field: aliasedTableColumn(value, tableAlias),
relationTableTsKey: void 0,
isJson: false,
selection: []
}));
} else {
const aliasedColumns = Object.fromEntries(
Object.entries(tableConfig.columns).map(([key, value]) => [key, aliasedTableColumn(value, tableAlias)])
);
if (config.where) {
const whereSql = typeof config.where === "function" ? config.where(aliasedColumns, getOperators()) : config.where;
where = whereSql && mapColumnsInSQLToAlias(whereSql, tableAlias);
}
const fieldsSelection = [];
let selectedColumns = [];
if (config.columns) {
let isIncludeMode = false;
for (const [field, value] of Object.entries(config.columns)) {
if (value === void 0) {
continue;
}
if (field in tableConfig.columns) {
if (!isIncludeMode && value === true) {
isIncludeMode = true;
}
selectedColumns.push(field);
}
}
if (selectedColumns.length > 0) {
selectedColumns = isIncludeMode ? selectedColumns.filter((c) => config.columns?.[c] === true) : Object.keys(tableConfig.columns).filter((key) => !selectedColumns.includes(key));
}
} else {
selectedColumns = Object.keys(tableConfig.columns);
}
for (const field of selectedColumns) {
const column = tableConfig.columns[field];
fieldsSelection.push({ tsKey: field, value: column });
}
let selectedRelations = [];
if (config.with) {
selectedRelations = Object.entries(config.with).filter((entry) => !!entry[1]).map(([tsKey, queryConfig]) => ({ tsKey, queryConfig, relation: tableConfig.relations[tsKey] }));
}
let extras;
if (config.extras) {
extras = typeof config.extras === "function" ? config.extras(aliasedColumns, { sql }) : config.extras;
for (const [tsKey, value] of Object.entries(extras)) {
fieldsSelection.push({
tsKey,
value: mapColumnsInAliasedSQLToAlias(value, tableAlias)
});
}
}
for (const { tsKey, value } of fieldsSelection) {
selection.push({
dbKey: is(value, SQL.Aliased) ? value.fieldAlias : tableConfig.columns[tsKey].name,
tsKey,
field: is(value, Column) ? aliasedTableColumn(value, tableAlias) : value,
relationTableTsKey: void 0,
isJson: false,
selection: []
});
}
let orderByOrig = typeof config.orderBy === "function" ? config.orderBy(aliasedColumns, getOrderByOperators()) : config.orderBy ?? [];
if (!Array.isArray(orderByOrig)) {
orderByOrig = [orderByOrig];
}
orderBy = orderByOrig.map((orderByValue) => {
if (is(orderByValue, Column)) {
return aliasedTableColumn(orderByValue, tableAlias);
}
return mapColumnsInSQLToAlias(orderByValue, tableAlias);
});
limit = config.limit;
offset = config.offset;
for (const {
tsKey: selectedRelationTsKey,
queryConfig: selectedRelationConfigValue,
relation
} of selectedRelations) {
const normalizedRelation = normalizeRelation(schema, tableNamesMap, relation);
const relationTableName = getTableUniqueName(relation.referencedTable);
const relationTableTsName = tableNamesMap[relationTableName];
const relationTableAlias = `${tableAlias}_${selectedRelationTsKey}`;
const joinOn2 = and(
...normalizedRelation.fields.map(
(field2, i) => eq(
aliasedTableColumn(normalizedRelation.references[i], relationTableAlias),
aliasedTableColumn(field2, tableAlias)
)
)
);
const builtRelation = this.buildRelationalQuery({
fullSchema,
schema,
tableNamesMap,
table: fullSchema[relationTableTsName],
tableConfig: schema[relationTableTsName],
queryConfig: is(relation, One) ? selectedRelationConfigValue === true ? { limit: 1 } : { ...selectedRelationConfigValue, limit: 1 } : selectedRelationConfigValue,
tableAlias: relationTableAlias,
joinOn: joinOn2,
nestedQueryRelation: relation
});
const field = sql`(${builtRelation.sql})`.as(selectedRelationTsKey);
selection.push({
dbKey: selectedRelationTsKey,
tsKey: selectedRelationTsKey,
field,
relationTableTsKey: relationTableTsName,
isJson: true,
selection: builtRelation.selection
});
}
}
if (selection.length === 0) {
throw new DrizzleError({
message: `No fields selected for table "${tableConfig.tsName}" ("${tableAlias}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`
});
}
let result;
where = and(joinOn, where);
if (nestedQueryRelation) {
let field = sql`json_array(${sql.join(
selection.map(
({ field: field2 }) => is(field2, SQLiteColumn) ? sql.identifier(this.casing.getColumnCasing(field2)) : is(field2, SQL.Aliased) ? field2.sql : field2
),
sql`, `
)})`;
if (is(nestedQueryRelation, Many)) {
field = sql`coalesce(json_group_array(${field}), json_array())`;
}
const nestedSelection = [{
dbKey: "data",
tsKey: "data",
field: field.as("data"),
isJson: true,
relationTableTsKey: tableConfig.tsName,
selection
}];
const needsSubquery = limit !== void 0 || offset !== void 0 || orderBy.length > 0;
if (needsSubquery) {
result = this.buildSelectQuery({
table: aliasedTable(table, tableAlias),
fields: {},
fieldsFlat: [
{
path: [],
field: sql.raw("*")
}
],
where,
limit,
offset,
orderBy,
setOperators: []
});
where = void 0;
limit = void 0;
offset = void 0;
orderBy = void 0;
} else {
result = aliasedTable(table, tableAlias);
}
result = this.buildSelectQuery({
table: is(result, SQLiteTable) ? result : new Subquery(result, {}, tableAlias),
fields: {},
fieldsFlat: nestedSelection.map(({ field: field2 }) => ({
path: [],
field: is(field2, Column) ? aliasedTableColumn(field2, tableAlias) : field2
})),
joins,
where,
limit,
offset,
orderBy,
setOperators: []
});
} else {
result = this.buildSelectQuery({
table: aliasedTable(table, tableAlias),
fields: {},
fieldsFlat: selection.map(({ field }) => ({
path: [],
field: is(field, Column) ? aliasedTableColumn(field, tableAlias) : field
})),
joins,
where,
limit,
offset,
orderBy,
setOperators: []
});
}
return {
tableTsKey: tableConfig.tsName,
sql: result,
selection
};
}
}
class SQLiteSyncDialect extends SQLiteDialect {
static [entityKind] = "SQLiteSyncDialect";
migrate(migrations, session, config) {
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.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
)
`;
session.run(migrationTableCreate);
const dbMigrations = session.values(
sql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
session.run(sql`BEGIN`);
try {
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
for (const stmt of migration.sql) {
session.run(sql.raw(stmt));
}
session.run(
sql`INSERT INTO ${sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
);
}
}
session.run(sql`COMMIT`);
} catch (e) {
session.run(sql`ROLLBACK`);
throw e;
}
}
}
class SQLiteAsyncDialect extends SQLiteDialect {
static [entityKind] = "SQLiteAsyncDialect";
async migrate(migrations, session, config) {
const migrationsTable = config === void 0 ? "__drizzle_migrations" : typeof config === "string" ? "__drizzle_migrations" : config.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
)
`;
await session.run(migrationTableCreate);
const dbMigrations = await session.values(
sql`SELECT id, hash, created_at FROM ${sql.identifier(migrationsTable)} ORDER BY created_at DESC LIMIT 1`
);
const lastDbMigration = dbMigrations[0] ?? void 0;
await session.transaction(async (tx) => {
for (const migration of migrations) {
if (!lastDbMigration || Number(lastDbMigration[2]) < migration.folderMillis) {
for (const stmt of migration.sql) {
await tx.run(sql.raw(stmt));
}
await tx.run(
sql`INSERT INTO ${sql.identifier(migrationsTable)} ("hash", "created_at") VALUES(${migration.hash}, ${migration.folderMillis})`
);
}
}
});
}
}
export {
SQLiteAsyncDialect,
SQLiteDialect,
SQLiteSyncDialect
};
//# sourceMappingURL=dialect.js.map

1
node_modules/drizzle-orm/sqlite-core/dialect.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

54
node_modules/drizzle-orm/sqlite-core/expressions.cjs generated vendored Normal file
View File

@ -0,0 +1,54 @@
"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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var expressions_exports = {};
__export(expressions_exports, {
concat: () => concat,
rowId: () => rowId,
substring: () => substring
});
module.exports = __toCommonJS(expressions_exports);
var import_expressions = require("../expressions.cjs");
var import_sql = require("../sql/sql.cjs");
__reExport(expressions_exports, require("../expressions.cjs"), module.exports);
function concat(column, value) {
return import_sql.sql`${column} || ${(0, import_expressions.bindIfParam)(value, column)}`;
}
function substring(column, { from, for: _for }) {
const chunks = [import_sql.sql`substring(`, column];
if (from !== void 0) {
chunks.push(import_sql.sql` from `, (0, import_expressions.bindIfParam)(from, column));
}
if (_for !== void 0) {
chunks.push(import_sql.sql` for `, (0, import_expressions.bindIfParam)(_for, column));
}
chunks.push(import_sql.sql`)`);
return import_sql.sql.join(chunks);
}
function rowId() {
return import_sql.sql`rowid`;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
concat,
rowId,
substring,
...require("../expressions.cjs")
});
//# sourceMappingURL=expressions.cjs.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/expressions.ts"],"sourcesContent":["import { bindIfParam } from '~/expressions.ts';\nimport type { SQL, SQLChunk, SQLWrapper } from '~/sql/sql.ts';\nimport { sql } from '~/sql/sql.ts';\nimport type { SQLiteColumn } from '~/sqlite-core/columns/index.ts';\n\nexport * from '~/expressions.ts';\n\nexport function concat(column: SQLiteColumn | SQL.Aliased, value: string | SQLWrapper): SQL {\n\treturn sql`${column} || ${bindIfParam(value, column)}`;\n}\n\nexport function substring(\n\tcolumn: SQLiteColumn | SQL.Aliased,\n\t{ from, for: _for }: { from?: number | SQLWrapper; for?: number | SQLWrapper },\n): SQL {\n\tconst chunks: SQLChunk[] = [sql`substring(`, column];\n\tif (from !== undefined) {\n\t\tchunks.push(sql` from `, bindIfParam(from, column));\n\t}\n\tif (_for !== undefined) {\n\t\tchunks.push(sql` for `, bindIfParam(_for, column));\n\t}\n\tchunks.push(sql`)`);\n\treturn sql.join(chunks);\n}\n\nexport function rowId(): SQL<number> {\n\treturn sql<number>`rowid`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAA4B;AAE5B,iBAAoB;AAGpB,gCAAc,6BALd;AAOO,SAAS,OAAO,QAAoC,OAAiC;AAC3F,SAAO,iBAAM,MAAM,WAAO,gCAAY,OAAO,MAAM,CAAC;AACrD;AAEO,SAAS,UACf,QACA,EAAE,MAAM,KAAK,KAAK,GACZ;AACN,QAAM,SAAqB,CAAC,4BAAiB,MAAM;AACnD,MAAI,SAAS,QAAW;AACvB,WAAO,KAAK,4BAAa,gCAAY,MAAM,MAAM,CAAC;AAAA,EACnD;AACA,MAAI,SAAS,QAAW;AACvB,WAAO,KAAK,2BAAY,gCAAY,MAAM,MAAM,CAAC;AAAA,EAClD;AACA,SAAO,KAAK,iBAAM;AAClB,SAAO,eAAI,KAAK,MAAM;AACvB;AAEO,SAAS,QAAqB;AACpC,SAAO;AACR;","names":[]}

View File

@ -0,0 +1,9 @@
import type { SQL, SQLWrapper } from "../sql/sql.cjs";
import type { SQLiteColumn } from "./columns/index.cjs";
export * from "../expressions.cjs";
export declare function concat(column: SQLiteColumn | SQL.Aliased, value: string | SQLWrapper): SQL;
export declare function substring(column: SQLiteColumn | SQL.Aliased, { from, for: _for }: {
from?: number | SQLWrapper;
for?: number | SQLWrapper;
}): SQL;
export declare function rowId(): SQL<number>;

View File

@ -0,0 +1,9 @@
import type { SQL, SQLWrapper } from "../sql/sql.js";
import type { SQLiteColumn } from "./columns/index.js";
export * from "../expressions.js";
export declare function concat(column: SQLiteColumn | SQL.Aliased, value: string | SQLWrapper): SQL;
export declare function substring(column: SQLiteColumn | SQL.Aliased, { from, for: _for }: {
from?: number | SQLWrapper;
for?: number | SQLWrapper;
}): SQL;
export declare function rowId(): SQL<number>;

26
node_modules/drizzle-orm/sqlite-core/expressions.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
import { bindIfParam } from "../expressions.js";
import { sql } from "../sql/sql.js";
export * from "../expressions.js";
function concat(column, value) {
return sql`${column} || ${bindIfParam(value, column)}`;
}
function substring(column, { from, for: _for }) {
const chunks = [sql`substring(`, column];
if (from !== void 0) {
chunks.push(sql` from `, bindIfParam(from, column));
}
if (_for !== void 0) {
chunks.push(sql` for `, bindIfParam(_for, column));
}
chunks.push(sql`)`);
return sql.join(chunks);
}
function rowId() {
return sql`rowid`;
}
export {
concat,
rowId,
substring
};
//# sourceMappingURL=expressions.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/expressions.ts"],"sourcesContent":["import { bindIfParam } from '~/expressions.ts';\nimport type { SQL, SQLChunk, SQLWrapper } from '~/sql/sql.ts';\nimport { sql } from '~/sql/sql.ts';\nimport type { SQLiteColumn } from '~/sqlite-core/columns/index.ts';\n\nexport * from '~/expressions.ts';\n\nexport function concat(column: SQLiteColumn | SQL.Aliased, value: string | SQLWrapper): SQL {\n\treturn sql`${column} || ${bindIfParam(value, column)}`;\n}\n\nexport function substring(\n\tcolumn: SQLiteColumn | SQL.Aliased,\n\t{ from, for: _for }: { from?: number | SQLWrapper; for?: number | SQLWrapper },\n): SQL {\n\tconst chunks: SQLChunk[] = [sql`substring(`, column];\n\tif (from !== undefined) {\n\t\tchunks.push(sql` from `, bindIfParam(from, column));\n\t}\n\tif (_for !== undefined) {\n\t\tchunks.push(sql` for `, bindIfParam(_for, column));\n\t}\n\tchunks.push(sql`)`);\n\treturn sql.join(chunks);\n}\n\nexport function rowId(): SQL<number> {\n\treturn sql<number>`rowid`;\n}\n"],"mappings":"AAAA,SAAS,mBAAmB;AAE5B,SAAS,WAAW;AAGpB,cAAc;AAEP,SAAS,OAAO,QAAoC,OAAiC;AAC3F,SAAO,MAAM,MAAM,OAAO,YAAY,OAAO,MAAM,CAAC;AACrD;AAEO,SAAS,UACf,QACA,EAAE,MAAM,KAAK,KAAK,GACZ;AACN,QAAM,SAAqB,CAAC,iBAAiB,MAAM;AACnD,MAAI,SAAS,QAAW;AACvB,WAAO,KAAK,aAAa,YAAY,MAAM,MAAM,CAAC;AAAA,EACnD;AACA,MAAI,SAAS,QAAW;AACvB,WAAO,KAAK,YAAY,YAAY,MAAM,MAAM,CAAC;AAAA,EAClD;AACA,SAAO,KAAK,MAAM;AAClB,SAAO,IAAI,KAAK,MAAM;AACvB;AAEO,SAAS,QAAqB;AACpC,SAAO;AACR;","names":[]}

103
node_modules/drizzle-orm/sqlite-core/foreign-keys.cjs generated vendored Normal file
View File

@ -0,0 +1,103 @@
"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 foreign_keys_exports = {};
__export(foreign_keys_exports, {
ForeignKey: () => ForeignKey,
ForeignKeyBuilder: () => ForeignKeyBuilder,
foreignKey: () => foreignKey
});
module.exports = __toCommonJS(foreign_keys_exports);
var import_entity = require("../entity.cjs");
var import_table_utils = require("../table.utils.cjs");
class ForeignKeyBuilder {
static [import_entity.entityKind] = "SQLiteForeignKeyBuilder";
/** @internal */
reference;
/** @internal */
_onUpdate;
/** @internal */
_onDelete;
constructor(config, actions) {
this.reference = () => {
const { name, columns, foreignColumns } = config();
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
};
if (actions) {
this._onUpdate = actions.onUpdate;
this._onDelete = actions.onDelete;
}
}
onUpdate(action) {
this._onUpdate = action;
return this;
}
onDelete(action) {
this._onDelete = action;
return this;
}
/** @internal */
build(table) {
return new ForeignKey(table, this);
}
}
class ForeignKey {
constructor(table, builder) {
this.table = table;
this.reference = builder.reference;
this.onUpdate = builder._onUpdate;
this.onDelete = builder._onDelete;
}
static [import_entity.entityKind] = "SQLiteForeignKey";
reference;
onUpdate;
onDelete;
getName() {
const { name, columns, foreignColumns } = this.reference();
const columnNames = columns.map((column) => column.name);
const foreignColumnNames = foreignColumns.map((column) => column.name);
const chunks = [
this.table[import_table_utils.TableName],
...columnNames,
foreignColumns[0].table[import_table_utils.TableName],
...foreignColumnNames
];
return name ?? `${chunks.join("_")}_fk`;
}
}
function foreignKey(config) {
function mappedConfig() {
if (typeof config === "function") {
const { name, columns, foreignColumns } = config();
return {
name,
columns,
foreignColumns
};
}
return config;
}
return new ForeignKeyBuilder(mappedConfig);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ForeignKey,
ForeignKeyBuilder,
foreignKey
});
//# sourceMappingURL=foreign-keys.cjs.map

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,65 @@
import { entityKind } from "../entity.cjs";
import type { AnySQLiteColumn, SQLiteColumn } from "./columns/index.cjs";
import type { SQLiteTable } from "./table.cjs";
export type UpdateDeleteAction = 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
export type Reference = () => {
readonly name?: string;
readonly columns: SQLiteColumn[];
readonly foreignTable: SQLiteTable;
readonly foreignColumns: SQLiteColumn[];
};
export declare class ForeignKeyBuilder {
static readonly [entityKind]: string;
_: {
brand: 'SQLiteForeignKeyBuilder';
foreignTableName: 'TForeignTableName';
};
constructor(config: () => {
name?: string;
columns: SQLiteColumn[];
foreignColumns: SQLiteColumn[];
}, actions?: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
} | undefined);
onUpdate(action: UpdateDeleteAction): this;
onDelete(action: UpdateDeleteAction): this;
}
export declare class ForeignKey {
readonly table: SQLiteTable;
static readonly [entityKind]: string;
readonly reference: Reference;
readonly onUpdate: UpdateDeleteAction | undefined;
readonly onDelete: UpdateDeleteAction | undefined;
constructor(table: SQLiteTable, builder: ForeignKeyBuilder);
getName(): string;
}
type ColumnsWithTable<TTableName extends string, TColumns extends SQLiteColumn[]> = {
[Key in keyof TColumns]: AnySQLiteColumn<{
tableName: TTableName;
}>;
};
/**
* @deprecated please use `foreignKey({ columns: [], foreignColumns: [] })` syntax without callback
* @param config
* @returns
*/
export declare function foreignKey<TTableName extends string, TForeignTableName extends string, TColumns extends [AnySQLiteColumn<{
tableName: TTableName;
}>, ...AnySQLiteColumn<{
tableName: TTableName;
}>[]]>(config: () => {
name?: string;
columns: TColumns;
foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
}): ForeignKeyBuilder;
export declare function foreignKey<TTableName extends string, TForeignTableName extends string, TColumns extends [AnySQLiteColumn<{
tableName: TTableName;
}>, ...AnySQLiteColumn<{
tableName: TTableName;
}>[]]>(config: {
name?: string;
columns: TColumns;
foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
}): ForeignKeyBuilder;
export {};

65
node_modules/drizzle-orm/sqlite-core/foreign-keys.d.ts generated vendored Normal file
View File

@ -0,0 +1,65 @@
import { entityKind } from "../entity.js";
import type { AnySQLiteColumn, SQLiteColumn } from "./columns/index.js";
import type { SQLiteTable } from "./table.js";
export type UpdateDeleteAction = 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
export type Reference = () => {
readonly name?: string;
readonly columns: SQLiteColumn[];
readonly foreignTable: SQLiteTable;
readonly foreignColumns: SQLiteColumn[];
};
export declare class ForeignKeyBuilder {
static readonly [entityKind]: string;
_: {
brand: 'SQLiteForeignKeyBuilder';
foreignTableName: 'TForeignTableName';
};
constructor(config: () => {
name?: string;
columns: SQLiteColumn[];
foreignColumns: SQLiteColumn[];
}, actions?: {
onUpdate?: UpdateDeleteAction;
onDelete?: UpdateDeleteAction;
} | undefined);
onUpdate(action: UpdateDeleteAction): this;
onDelete(action: UpdateDeleteAction): this;
}
export declare class ForeignKey {
readonly table: SQLiteTable;
static readonly [entityKind]: string;
readonly reference: Reference;
readonly onUpdate: UpdateDeleteAction | undefined;
readonly onDelete: UpdateDeleteAction | undefined;
constructor(table: SQLiteTable, builder: ForeignKeyBuilder);
getName(): string;
}
type ColumnsWithTable<TTableName extends string, TColumns extends SQLiteColumn[]> = {
[Key in keyof TColumns]: AnySQLiteColumn<{
tableName: TTableName;
}>;
};
/**
* @deprecated please use `foreignKey({ columns: [], foreignColumns: [] })` syntax without callback
* @param config
* @returns
*/
export declare function foreignKey<TTableName extends string, TForeignTableName extends string, TColumns extends [AnySQLiteColumn<{
tableName: TTableName;
}>, ...AnySQLiteColumn<{
tableName: TTableName;
}>[]]>(config: () => {
name?: string;
columns: TColumns;
foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
}): ForeignKeyBuilder;
export declare function foreignKey<TTableName extends string, TForeignTableName extends string, TColumns extends [AnySQLiteColumn<{
tableName: TTableName;
}>, ...AnySQLiteColumn<{
tableName: TTableName;
}>[]]>(config: {
name?: string;
columns: TColumns;
foreignColumns: ColumnsWithTable<TForeignTableName, TColumns>;
}): ForeignKeyBuilder;
export {};

77
node_modules/drizzle-orm/sqlite-core/foreign-keys.js generated vendored Normal file
View File

@ -0,0 +1,77 @@
import { entityKind } from "../entity.js";
import { TableName } from "../table.utils.js";
class ForeignKeyBuilder {
static [entityKind] = "SQLiteForeignKeyBuilder";
/** @internal */
reference;
/** @internal */
_onUpdate;
/** @internal */
_onDelete;
constructor(config, actions) {
this.reference = () => {
const { name, columns, foreignColumns } = config();
return { name, columns, foreignTable: foreignColumns[0].table, foreignColumns };
};
if (actions) {
this._onUpdate = actions.onUpdate;
this._onDelete = actions.onDelete;
}
}
onUpdate(action) {
this._onUpdate = action;
return this;
}
onDelete(action) {
this._onDelete = action;
return this;
}
/** @internal */
build(table) {
return new ForeignKey(table, this);
}
}
class ForeignKey {
constructor(table, builder) {
this.table = table;
this.reference = builder.reference;
this.onUpdate = builder._onUpdate;
this.onDelete = builder._onDelete;
}
static [entityKind] = "SQLiteForeignKey";
reference;
onUpdate;
onDelete;
getName() {
const { name, columns, foreignColumns } = this.reference();
const columnNames = columns.map((column) => column.name);
const foreignColumnNames = foreignColumns.map((column) => column.name);
const chunks = [
this.table[TableName],
...columnNames,
foreignColumns[0].table[TableName],
...foreignColumnNames
];
return name ?? `${chunks.join("_")}_fk`;
}
}
function foreignKey(config) {
function mappedConfig() {
if (typeof config === "function") {
const { name, columns, foreignColumns } = config();
return {
name,
columns,
foreignColumns
};
}
return config;
}
return new ForeignKeyBuilder(mappedConfig);
}
export {
ForeignKey,
ForeignKeyBuilder,
foreignKey
};
//# sourceMappingURL=foreign-keys.js.map

File diff suppressed because one or more lines are too long

51
node_modules/drizzle-orm/sqlite-core/index.cjs generated vendored Normal file
View File

@ -0,0 +1,51 @@
"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 sqlite_core_exports = {};
module.exports = __toCommonJS(sqlite_core_exports);
__reExport(sqlite_core_exports, require("./alias.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./checks.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./columns/index.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./db.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./dialect.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./foreign-keys.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./indexes.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./primary-keys.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./query-builders/index.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./session.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./subquery.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./table.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./unique-constraint.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./utils.cjs"), module.exports);
__reExport(sqlite_core_exports, require("./view.cjs"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
...require("./alias.cjs"),
...require("./checks.cjs"),
...require("./columns/index.cjs"),
...require("./db.cjs"),
...require("./dialect.cjs"),
...require("./foreign-keys.cjs"),
...require("./indexes.cjs"),
...require("./primary-keys.cjs"),
...require("./query-builders/index.cjs"),
...require("./session.cjs"),
...require("./subquery.cjs"),
...require("./table.cjs"),
...require("./unique-constraint.cjs"),
...require("./utils.cjs"),
...require("./view.cjs")
});
//# sourceMappingURL=index.cjs.map

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

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './checks.ts';\nexport * from './columns/index.ts';\nexport * from './db.ts';\nexport * from './dialect.ts';\nexport * from './foreign-keys.ts';\nexport * from './indexes.ts';\nexport * from './primary-keys.ts';\nexport * from './query-builders/index.ts';\nexport * from './session.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './unique-constraint.ts';\nexport * from './utils.ts';\nexport * from './view.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,gCAAc,uBAAd;AACA,gCAAc,wBADd;AAEA,gCAAc,+BAFd;AAGA,gCAAc,oBAHd;AAIA,gCAAc,yBAJd;AAKA,gCAAc,8BALd;AAMA,gCAAc,yBANd;AAOA,gCAAc,8BAPd;AAQA,gCAAc,sCARd;AASA,gCAAc,yBATd;AAUA,gCAAc,0BAVd;AAWA,gCAAc,uBAXd;AAYA,gCAAc,mCAZd;AAaA,gCAAc,uBAbd;AAcA,gCAAc,sBAdd;","names":[]}

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

@ -0,0 +1,15 @@
export * from "./alias.cjs";
export * from "./checks.cjs";
export * from "./columns/index.cjs";
export * from "./db.cjs";
export * from "./dialect.cjs";
export * from "./foreign-keys.cjs";
export * from "./indexes.cjs";
export * from "./primary-keys.cjs";
export * from "./query-builders/index.cjs";
export * from "./session.cjs";
export * from "./subquery.cjs";
export * from "./table.cjs";
export * from "./unique-constraint.cjs";
export * from "./utils.cjs";
export * from "./view.cjs";

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

@ -0,0 +1,15 @@
export * from "./alias.js";
export * from "./checks.js";
export * from "./columns/index.js";
export * from "./db.js";
export * from "./dialect.js";
export * from "./foreign-keys.js";
export * from "./indexes.js";
export * from "./primary-keys.js";
export * from "./query-builders/index.js";
export * from "./session.js";
export * from "./subquery.js";
export * from "./table.js";
export * from "./unique-constraint.js";
export * from "./utils.js";
export * from "./view.js";

16
node_modules/drizzle-orm/sqlite-core/index.js generated vendored Normal file
View File

@ -0,0 +1,16 @@
export * from "./alias.js";
export * from "./checks.js";
export * from "./columns/index.js";
export * from "./db.js";
export * from "./dialect.js";
export * from "./foreign-keys.js";
export * from "./indexes.js";
export * from "./primary-keys.js";
export * from "./query-builders/index.js";
export * from "./session.js";
export * from "./subquery.js";
export * from "./table.js";
export * from "./unique-constraint.js";
export * from "./utils.js";
export * from "./view.js";
//# sourceMappingURL=index.js.map

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

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/index.ts"],"sourcesContent":["export * from './alias.ts';\nexport * from './checks.ts';\nexport * from './columns/index.ts';\nexport * from './db.ts';\nexport * from './dialect.ts';\nexport * from './foreign-keys.ts';\nexport * from './indexes.ts';\nexport * from './primary-keys.ts';\nexport * from './query-builders/index.ts';\nexport * from './session.ts';\nexport * from './subquery.ts';\nexport * from './table.ts';\nexport * from './unique-constraint.ts';\nexport * from './utils.ts';\nexport * from './view.ts';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}

84
node_modules/drizzle-orm/sqlite-core/indexes.cjs generated vendored Normal file
View File

@ -0,0 +1,84 @@
"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 indexes_exports = {};
__export(indexes_exports, {
Index: () => Index,
IndexBuilder: () => IndexBuilder,
IndexBuilderOn: () => IndexBuilderOn,
index: () => index,
uniqueIndex: () => uniqueIndex
});
module.exports = __toCommonJS(indexes_exports);
var import_entity = require("../entity.cjs");
class IndexBuilderOn {
constructor(name, unique) {
this.name = name;
this.unique = unique;
}
static [import_entity.entityKind] = "SQLiteIndexBuilderOn";
on(...columns) {
return new IndexBuilder(this.name, columns, this.unique);
}
}
class IndexBuilder {
static [import_entity.entityKind] = "SQLiteIndexBuilder";
/** @internal */
config;
constructor(name, columns, unique) {
this.config = {
name,
columns,
unique,
where: void 0
};
}
/**
* Condition for partial index.
*/
where(condition) {
this.config.where = condition;
return this;
}
/** @internal */
build(table) {
return new Index(this.config, table);
}
}
class Index {
static [import_entity.entityKind] = "SQLiteIndex";
config;
constructor(config, table) {
this.config = { ...config, table };
}
}
function index(name) {
return new IndexBuilderOn(name, false);
}
function uniqueIndex(name) {
return new IndexBuilderOn(name, true);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
Index,
IndexBuilder,
IndexBuilderOn,
index,
uniqueIndex
});
//# sourceMappingURL=indexes.cjs.map

1
node_modules/drizzle-orm/sqlite-core/indexes.cjs.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"sources":["../../src/sqlite-core/indexes.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { SQL } from '~/sql/sql.ts';\nimport type { SQLiteColumn } from './columns/index.ts';\nimport type { SQLiteTable } from './table.ts';\n\nexport interface IndexConfig {\n\tname: string;\n\tcolumns: IndexColumn[];\n\tunique: boolean;\n\twhere: SQL | undefined;\n}\n\nexport type IndexColumn = SQLiteColumn | SQL;\n\nexport class IndexBuilderOn {\n\tstatic readonly [entityKind]: string = 'SQLiteIndexBuilderOn';\n\n\tconstructor(private name: string, private unique: boolean) {}\n\n\ton(...columns: [IndexColumn, ...IndexColumn[]]): IndexBuilder {\n\t\treturn new IndexBuilder(this.name, columns, this.unique);\n\t}\n}\n\nexport class IndexBuilder {\n\tstatic readonly [entityKind]: string = 'SQLiteIndexBuilder';\n\n\tdeclare _: {\n\t\tbrand: 'SQLiteIndexBuilder';\n\t};\n\n\t/** @internal */\n\tconfig: IndexConfig;\n\n\tconstructor(name: string, columns: IndexColumn[], unique: boolean) {\n\t\tthis.config = {\n\t\t\tname,\n\t\t\tcolumns,\n\t\t\tunique,\n\t\t\twhere: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Condition for partial index.\n\t */\n\twhere(condition: SQL): this {\n\t\tthis.config.where = condition;\n\t\treturn this;\n\t}\n\n\t/** @internal */\n\tbuild(table: SQLiteTable): Index {\n\t\treturn new Index(this.config, table);\n\t}\n}\n\nexport class Index {\n\tstatic readonly [entityKind]: string = 'SQLiteIndex';\n\n\tdeclare _: {\n\t\tbrand: 'SQLiteIndex';\n\t};\n\n\treadonly config: IndexConfig & { table: SQLiteTable };\n\n\tconstructor(config: IndexConfig, table: SQLiteTable) {\n\t\tthis.config = { ...config, table };\n\t}\n}\n\nexport function index(name: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(name, false);\n}\n\nexport function uniqueIndex(name: string): IndexBuilderOn {\n\treturn new IndexBuilderOn(name, true);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAcpB,MAAM,eAAe;AAAA,EAG3B,YAAoB,MAAsB,QAAiB;AAAvC;AAAsB;AAAA,EAAkB;AAAA,EAF5D,QAAiB,wBAAU,IAAY;AAAA,EAIvC,MAAM,SAAwD;AAC7D,WAAO,IAAI,aAAa,KAAK,MAAM,SAAS,KAAK,MAAM;AAAA,EACxD;AACD;AAEO,MAAM,aAAa;AAAA,EACzB,QAAiB,wBAAU,IAAY;AAAA;AAAA,EAOvC;AAAA,EAEA,YAAY,MAAc,SAAwB,QAAiB;AAClE,SAAK,SAAS;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACR;AAAA,EACD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,WAAsB;AAC3B,SAAK,OAAO,QAAQ;AACpB,WAAO;AAAA,EACR;AAAA;AAAA,EAGA,MAAM,OAA2B;AAChC,WAAO,IAAI,MAAM,KAAK,QAAQ,KAAK;AAAA,EACpC;AACD;AAEO,MAAM,MAAM;AAAA,EAClB,QAAiB,wBAAU,IAAY;AAAA,EAM9B;AAAA,EAET,YAAY,QAAqB,OAAoB;AACpD,SAAK,SAAS,EAAE,GAAG,QAAQ,MAAM;AAAA,EAClC;AACD;AAEO,SAAS,MAAM,MAA8B;AACnD,SAAO,IAAI,eAAe,MAAM,KAAK;AACtC;AAEO,SAAS,YAAY,MAA8B;AACzD,SAAO,IAAI,eAAe,MAAM,IAAI;AACrC;","names":[]}

41
node_modules/drizzle-orm/sqlite-core/indexes.d.cts generated vendored Normal file
View File

@ -0,0 +1,41 @@
import { entityKind } from "../entity.cjs";
import type { SQL } from "../sql/sql.cjs";
import type { SQLiteColumn } from "./columns/index.cjs";
import type { SQLiteTable } from "./table.cjs";
export interface IndexConfig {
name: string;
columns: IndexColumn[];
unique: boolean;
where: SQL | undefined;
}
export type IndexColumn = SQLiteColumn | SQL;
export declare class IndexBuilderOn {
private name;
private unique;
static readonly [entityKind]: string;
constructor(name: string, unique: boolean);
on(...columns: [IndexColumn, ...IndexColumn[]]): IndexBuilder;
}
export declare class IndexBuilder {
static readonly [entityKind]: string;
_: {
brand: 'SQLiteIndexBuilder';
};
constructor(name: string, columns: IndexColumn[], unique: boolean);
/**
* Condition for partial index.
*/
where(condition: SQL): this;
}
export declare class Index {
static readonly [entityKind]: string;
_: {
brand: 'SQLiteIndex';
};
readonly config: IndexConfig & {
table: SQLiteTable;
};
constructor(config: IndexConfig, table: SQLiteTable);
}
export declare function index(name: string): IndexBuilderOn;
export declare function uniqueIndex(name: string): IndexBuilderOn;

41
node_modules/drizzle-orm/sqlite-core/indexes.d.ts generated vendored Normal file
View File

@ -0,0 +1,41 @@
import { entityKind } from "../entity.js";
import type { SQL } from "../sql/sql.js";
import type { SQLiteColumn } from "./columns/index.js";
import type { SQLiteTable } from "./table.js";
export interface IndexConfig {
name: string;
columns: IndexColumn[];
unique: boolean;
where: SQL | undefined;
}
export type IndexColumn = SQLiteColumn | SQL;
export declare class IndexBuilderOn {
private name;
private unique;
static readonly [entityKind]: string;
constructor(name: string, unique: boolean);
on(...columns: [IndexColumn, ...IndexColumn[]]): IndexBuilder;
}
export declare class IndexBuilder {
static readonly [entityKind]: string;
_: {
brand: 'SQLiteIndexBuilder';
};
constructor(name: string, columns: IndexColumn[], unique: boolean);
/**
* Condition for partial index.
*/
where(condition: SQL): this;
}
export declare class Index {
static readonly [entityKind]: string;
_: {
brand: 'SQLiteIndex';
};
readonly config: IndexConfig & {
table: SQLiteTable;
};
constructor(config: IndexConfig, table: SQLiteTable);
}
export declare function index(name: string): IndexBuilderOn;
export declare function uniqueIndex(name: string): IndexBuilderOn;

Some files were not shown because too many files have changed in this diff Show More