@ignisia/sql 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +113 -0
  2. package/dist/chunk-4DQRB5XS.js +94 -0
  3. package/dist/chunk-CIWX3UCZ.js +51 -0
  4. package/dist/chunk-D2ASIT4Q.js +44 -0
  5. package/dist/chunk-FYSNJAGD.js +19 -0
  6. package/dist/chunk-G3LSCLIQ.js +104 -0
  7. package/dist/chunk-GLOHF5CP.js +9 -0
  8. package/dist/chunk-GY7R637S.js +113 -0
  9. package/dist/chunk-HKTHKQLK.js +98 -0
  10. package/dist/chunk-JF7OSNH4.js +40 -0
  11. package/dist/chunk-MG2S4V4N.js +60 -0
  12. package/dist/chunk-TQ2GXAE7.js +663 -0
  13. package/dist/chunk-V4OMHVJN.js +96 -0
  14. package/dist/chunk-W2DR3ZVK.js +59 -0
  15. package/dist/chunk-WVJGTZFI.js +60 -0
  16. package/dist/chunk-Y7FSRHH3.js +22 -0
  17. package/dist/column/constants.d.ts +97 -0
  18. package/dist/column/constants.js +9 -0
  19. package/dist/column/index.d.ts +42 -0
  20. package/dist/column/index.js +8 -0
  21. package/dist/column/types.d.ts +43 -0
  22. package/dist/column/types.js +2 -0
  23. package/dist/database/alter.d.ts +52 -0
  24. package/dist/database/alter.js +15 -0
  25. package/dist/database/column.d.ts +24 -0
  26. package/dist/database/column.js +11 -0
  27. package/dist/database/contract.d.ts +8 -0
  28. package/dist/database/contract.js +0 -0
  29. package/dist/database/index.d.ts +8 -0
  30. package/dist/database/index.js +19 -0
  31. package/dist/database/table.d.ts +21 -0
  32. package/dist/database/table.js +19 -0
  33. package/dist/database/types.d.ts +7 -0
  34. package/dist/database/types.js +0 -0
  35. package/dist/database/wrapper.d.ts +36 -0
  36. package/dist/database/wrapper.js +9 -0
  37. package/dist/index-DJhQVUY3.d.ts +344 -0
  38. package/dist/index-Dcm5xIpR.d.ts +99 -0
  39. package/dist/index.d.ts +10 -0
  40. package/dist/index.js +32 -0
  41. package/dist/migration/index.d.ts +30 -0
  42. package/dist/migration/index.js +6 -0
  43. package/dist/migration/runner.d.ts +3 -0
  44. package/dist/migration/runner.js +69 -0
  45. package/dist/migration/type.d.ts +19 -0
  46. package/dist/migration/type.js +0 -0
  47. package/dist/query/builder.d.ts +14 -0
  48. package/dist/query/builder.js +16 -0
  49. package/dist/query/condition.d.ts +7 -0
  50. package/dist/query/condition.js +24 -0
  51. package/dist/query/constants.d.ts +58 -0
  52. package/dist/query/constants.js +18 -0
  53. package/dist/query/contract.d.ts +7 -0
  54. package/dist/query/contract.js +0 -0
  55. package/dist/query/helper.d.ts +7 -0
  56. package/dist/query/helper.js +18 -0
  57. package/dist/query/index.d.ts +7 -0
  58. package/dist/query/index.js +10 -0
  59. package/dist/query/join.d.ts +16 -0
  60. package/dist/query/join.js +6 -0
  61. package/dist/query/sql.d.ts +17 -0
  62. package/dist/query/sql.js +16 -0
  63. package/dist/query/types.d.ts +7 -0
  64. package/dist/query/types.js +0 -0
  65. package/dist/query/utilities.d.ts +34 -0
  66. package/dist/query/utilities.js +24 -0
  67. package/dist/table/constants.d.ts +7 -0
  68. package/dist/table/constants.js +6 -0
  69. package/dist/table/index.d.ts +7 -0
  70. package/dist/table/index.js +14 -0
  71. package/dist/table/types.d.ts +7 -0
  72. package/dist/table/types.js +0 -0
  73. package/dist/table/utilities.d.ts +7 -0
  74. package/dist/table/utilities.js +15 -0
  75. package/dist/types.d.ts +3 -0
  76. package/dist/types.js +0 -0
  77. package/dist/utilities.d.ts +4 -0
  78. package/dist/utilities.js +8 -0
  79. package/package.json +20 -0
@@ -0,0 +1,96 @@
1
+ import {
2
+ Dialect
3
+ } from "./chunk-GLOHF5CP.js";
4
+
5
+ // src/database/alter.ts
6
+ async function alterColumnType(tableName, columnName, newType) {
7
+ if (this.dialect === Dialect.SQLITE) {
8
+ throw new Error("SQLite does not support ALTER COLUMN TYPE directly.");
9
+ }
10
+ await this.client.exec(
11
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} TYPE ${newType}`
12
+ );
13
+ if (!this.tables[tableName]) return this;
14
+ this.tables[tableName].columns[columnName].type = newType;
15
+ return this;
16
+ }
17
+ async function setColumnDefault(tableName, columnName, value) {
18
+ if (this.dialect === Dialect.SQLITE) {
19
+ throw new Error("SQLite does not support ALTER COLUMN DEFAULT directly.");
20
+ }
21
+ await this.client.exec(
22
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} SET DEFAULT ${value}`
23
+ );
24
+ if (!this.tables[tableName]) return this;
25
+ if (
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ !this.tables[tableName].columns[columnName].definition
28
+ ) {
29
+ this.tables[tableName].columns[columnName].definition = {};
30
+ }
31
+ this.tables[tableName].columns[columnName].definition.default = value;
32
+ return this;
33
+ }
34
+ async function dropColumnDefault(tableName, columnName) {
35
+ if (this.dialect === Dialect.SQLITE) {
36
+ throw new Error("SQLite does not support DROP DEFAULT directly.");
37
+ }
38
+ await this.client.exec(
39
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} DROP DEFAULT`
40
+ );
41
+ if (!this.tables[tableName]) return this;
42
+ if (
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ !this.tables[tableName].columns[columnName].definition
45
+ ) {
46
+ this.tables[tableName].columns[columnName].definition = {};
47
+ }
48
+ delete this.tables[tableName].columns[columnName].definition.default;
49
+ return this;
50
+ }
51
+ async function setColumnNotNull(tableName, columnName) {
52
+ if (this.dialect === Dialect.SQLITE) {
53
+ throw new Error(
54
+ "SQLite does not support SET NOT NULL (requires table rebuild)"
55
+ );
56
+ }
57
+ await this.client.exec(
58
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} SET NOT NULL`
59
+ );
60
+ if (!this.tables[tableName]) return this;
61
+ if (
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
63
+ !this.tables[tableName].columns[columnName].definition
64
+ ) {
65
+ this.tables[tableName].columns[columnName].definition = {};
66
+ }
67
+ this.tables[tableName].columns[columnName].definition.notNull = true;
68
+ return this;
69
+ }
70
+ async function dropColumnNotNull(tableName, columnName) {
71
+ if (this.dialect === Dialect.SQLITE) {
72
+ throw new Error(
73
+ "SQLite does not support DROP NOT NULL (requires table rebuild)"
74
+ );
75
+ }
76
+ await this.client.exec(
77
+ `ALTER TABLE ${tableName} ALTER COLUMN ${columnName} DROP NOT NULL`
78
+ );
79
+ if (!this.tables[tableName]) return this;
80
+ if (
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ !this.tables[tableName].columns[columnName].definition
83
+ ) {
84
+ this.tables[tableName].columns[columnName].definition = {};
85
+ }
86
+ this.tables[tableName].columns[columnName].definition.notNull = null;
87
+ return this;
88
+ }
89
+
90
+ export {
91
+ alterColumnType,
92
+ setColumnDefault,
93
+ dropColumnDefault,
94
+ setColumnNotNull,
95
+ dropColumnNotNull
96
+ };
@@ -0,0 +1,59 @@
1
+ import {
2
+ QueryBuilder
3
+ } from "./chunk-TQ2GXAE7.js";
4
+ import {
5
+ defineColumns
6
+ } from "./chunk-WVJGTZFI.js";
7
+
8
+ // src/table/index.ts
9
+ var Table = class _Table {
10
+ database;
11
+ dialect;
12
+ name;
13
+ columns;
14
+ timestamp;
15
+ paranoid;
16
+ _output;
17
+ constructor(options) {
18
+ this.dialect = options.dialect;
19
+ this.name = options.name;
20
+ this.columns = options.columns;
21
+ this.paranoid = options.paranoid || null;
22
+ this.timestamp = options.timestamp || null;
23
+ this.database = null;
24
+ for (const column of Object.values(this.columns)) {
25
+ column.dialect(options.dialect);
26
+ }
27
+ }
28
+ infer() {
29
+ return null;
30
+ }
31
+ static define(options) {
32
+ const columns = defineColumns(options);
33
+ return new _Table({
34
+ ...options,
35
+ columns
36
+ });
37
+ }
38
+ async create(db = this.database) {
39
+ if (!db) throw new Error("Database client not defined");
40
+ const sql = `CREATE TABLE IF NOT EXISTS ${this.name} (${Object.entries(
41
+ this.columns
42
+ ).map(([name, column]) => `${name} ${column.toQuery().query}`).join(", ")});`;
43
+ await db.exec(sql);
44
+ return this;
45
+ }
46
+ async drop(db = this.database) {
47
+ if (!db) throw new Error("Database client not defined");
48
+ const sql = `DROP TABLE IF EXISTS ${this.name};`;
49
+ await db.exec(sql);
50
+ return this;
51
+ }
52
+ query() {
53
+ return new QueryBuilder(this);
54
+ }
55
+ };
56
+
57
+ export {
58
+ Table
59
+ };
@@ -0,0 +1,60 @@
1
+ import {
2
+ Column
3
+ } from "./chunk-GY7R637S.js";
4
+
5
+ // src/table/utilities.ts
6
+ var createdAt = Column.define({
7
+ type: "DATETIME"
8
+ }).default("CURRENT_TIMESTAMP");
9
+ var updatedAt = Column.define({
10
+ type: "DATETIME"
11
+ });
12
+ var deletedAt = Column.define({
13
+ type: "DATETIME"
14
+ });
15
+ function defineColumns(options) {
16
+ const columns = {
17
+ ...options.columns
18
+ };
19
+ const tracker = {
20
+ createdAt: "createdAt",
21
+ updatedAt: "updatedAt",
22
+ deletedAt: "deletedAt"
23
+ };
24
+ if (options.timestamp) {
25
+ const timestamp = {
26
+ createdAt: "createdAt",
27
+ updatedAt: "updatedAt"
28
+ };
29
+ if (typeof options.timestamp === "object") {
30
+ if (typeof options.timestamp.createdAt === "string") {
31
+ timestamp.createdAt = options.timestamp.createdAt;
32
+ }
33
+ if (typeof options.timestamp.updatedAt === "string") {
34
+ timestamp.updatedAt = options.timestamp.updatedAt;
35
+ }
36
+ }
37
+ if (!columns[timestamp.createdAt]) {
38
+ columns[timestamp.createdAt] = createdAt;
39
+ }
40
+ if (!columns[timestamp.updatedAt]) {
41
+ columns[timestamp.updatedAt] = updatedAt;
42
+ }
43
+ }
44
+ if (options.paranoid) {
45
+ if (typeof options.paranoid !== "boolean") {
46
+ tracker.deletedAt = options.paranoid;
47
+ }
48
+ if (!columns[tracker.deletedAt]) {
49
+ columns[tracker.deletedAt] = deletedAt;
50
+ }
51
+ }
52
+ return columns;
53
+ }
54
+
55
+ export {
56
+ createdAt,
57
+ updatedAt,
58
+ deletedAt,
59
+ defineColumns
60
+ };
@@ -0,0 +1,22 @@
1
+ // src/utilities.ts
2
+ function deepClone(obj) {
3
+ if (Array.isArray(obj)) {
4
+ return obj.map((item) => deepClone(item));
5
+ }
6
+ if (obj && typeof obj === "object") {
7
+ const clonedObj = {};
8
+ for (const key in obj) {
9
+ clonedObj[key] = deepClone(obj[key]);
10
+ }
11
+ return clonedObj;
12
+ }
13
+ return obj;
14
+ }
15
+ function quoteIdentifier(identifier) {
16
+ return `"${identifier.replace(/"/g, '""')}"`;
17
+ }
18
+
19
+ export {
20
+ deepClone,
21
+ quoteIdentifier
22
+ };
@@ -0,0 +1,97 @@
1
+ declare const AcceptedColumnTypes: {
2
+ readonly INTEGER: "INTEGER";
3
+ readonly STRING: "STRING";
4
+ readonly BOOLEAN: "BOOLEAN";
5
+ readonly DATE: "DATE";
6
+ readonly FLOAT: "FLOAT";
7
+ readonly DECIMAL: "DECIMAL";
8
+ readonly BIGINT: "BIGINT";
9
+ readonly TEXT: "TEXT";
10
+ readonly BLOB: "BLOB";
11
+ readonly JSON: "JSON";
12
+ readonly VARCHAR: "VARCHAR";
13
+ readonly TIME: "TIME";
14
+ readonly TIMESTAMP: "TIMESTAMP";
15
+ readonly DOUBLE: "DOUBLE";
16
+ readonly DATETIME: "DATETIME";
17
+ readonly DATEONLY: "DATEONLY";
18
+ readonly ENUM: "ENUM";
19
+ readonly SERIAL: "SERIAL";
20
+ };
21
+ type AcceptedColumnTypes = (typeof AcceptedColumnTypes)[keyof typeof AcceptedColumnTypes];
22
+ declare const ColumnTypeMapping: {
23
+ readonly INTEGER: {
24
+ readonly sqlite: "INTEGER";
25
+ readonly postgres: "INTEGER";
26
+ };
27
+ readonly STRING: {
28
+ readonly sqlite: "TEXT";
29
+ readonly postgres: "VARCHAR";
30
+ };
31
+ readonly BOOLEAN: {
32
+ readonly sqlite: "INTEGER";
33
+ readonly postgres: "BOOLEAN";
34
+ };
35
+ readonly DATE: {
36
+ readonly sqlite: "TEXT";
37
+ readonly postgres: "DATE";
38
+ };
39
+ readonly FLOAT: {
40
+ readonly sqlite: "REAL";
41
+ readonly postgres: "FLOAT";
42
+ };
43
+ readonly DECIMAL: {
44
+ readonly sqlite: "TEXT";
45
+ readonly postgres: "DECIMAL";
46
+ };
47
+ readonly BIGINT: {
48
+ readonly sqlite: "TEXT";
49
+ readonly postgres: "BIGINT";
50
+ };
51
+ readonly TEXT: {
52
+ readonly sqlite: "TEXT";
53
+ readonly postgres: "TEXT";
54
+ };
55
+ readonly BLOB: {
56
+ readonly sqlite: "BLOB";
57
+ readonly postgres: "BYTEA";
58
+ };
59
+ readonly JSON: {
60
+ readonly sqlite: "TEXT";
61
+ readonly postgres: "JSONB";
62
+ };
63
+ readonly VARCHAR: {
64
+ readonly sqlite: "TEXT";
65
+ readonly postgres: "VARCHAR";
66
+ };
67
+ readonly TIME: {
68
+ readonly sqlite: "TEXT";
69
+ readonly postgres: "TIME";
70
+ };
71
+ readonly TIMESTAMP: {
72
+ readonly sqlite: "TEXT";
73
+ readonly postgres: "TIMESTAMP";
74
+ };
75
+ readonly DOUBLE: {
76
+ readonly sqlite: "REAL";
77
+ readonly postgres: "DOUBLE PRECISION";
78
+ };
79
+ readonly DATETIME: {
80
+ readonly sqlite: "TEXT";
81
+ readonly postgres: "TIMESTAMP";
82
+ };
83
+ readonly DATEONLY: {
84
+ readonly sqlite: "TEXT";
85
+ readonly postgres: "DATE";
86
+ };
87
+ readonly ENUM: {
88
+ readonly sqlite: "TEXT";
89
+ readonly postgres: "TEXT";
90
+ };
91
+ readonly SERIAL: {
92
+ readonly sqlite: "INTEGER AUTOINCREMENT";
93
+ readonly postgres: "SERIAL";
94
+ };
95
+ };
96
+
97
+ export { AcceptedColumnTypes, ColumnTypeMapping };
@@ -0,0 +1,9 @@
1
+ import {
2
+ AcceptedColumnTypes,
3
+ ColumnTypeMapping
4
+ } from "../chunk-G3LSCLIQ.js";
5
+ import "../chunk-GLOHF5CP.js";
6
+ export {
7
+ AcceptedColumnTypes,
8
+ ColumnTypeMapping
9
+ };
@@ -0,0 +1,42 @@
1
+ import { Dialect } from '../table/constants.js';
2
+ import { AcceptedColumnTypes } from './constants.js';
3
+ import { ColumnOptions, AcceptedColumnTypeMap, EnumOptions, ColumnDefinition, ValueSelector } from './types.js';
4
+
5
+ declare class Column<Type extends AcceptedColumnTypes = AcceptedColumnTypes, Values extends number | readonly string[] = Type extends typeof AcceptedColumnTypes.ENUM ? readonly string[] : number, Options extends ColumnOptions<Type, Values> = ColumnOptions<Type, Values>, ColumnValue extends AcceptedColumnTypeMap[Options['type']] = AcceptedColumnTypeMap[Options['type']], Value extends Options extends EnumOptions<infer Value> ? Value[number] : ColumnValue = ColumnValue, Definition extends Partial<ColumnDefinition<Value, Dialect>> = NonNullable<unknown>> {
6
+ readonly definition: Definition;
7
+ readonly type: Options['type'];
8
+ readonly length: number | null;
9
+ readonly enums: readonly Value[];
10
+ readonly _output: ValueSelector<Definition, Value>;
11
+ protected constructor(options: Options);
12
+ static define<Type extends AcceptedColumnTypes = AcceptedColumnTypes, Values extends number | readonly string[] = number | readonly string[], Options extends ColumnOptions<Type, Values> = ColumnOptions<Type, Values>>(options: Options): Column<AcceptedColumnTypes, number | readonly string[], Options, AcceptedColumnTypeMap[Options["type"]], Options extends EnumOptions<infer Value extends readonly string[]> ? Value[number] : AcceptedColumnTypeMap[Options["type"]], {}>;
13
+ autoIncrement(): Column<Type, Values, Options, ColumnValue, Value, Definition & {
14
+ autoIncrement: true;
15
+ }>;
16
+ primaryKey(): Column<Type, Values, Options, ColumnValue, Value, Definition & {
17
+ primaryKey: true;
18
+ }>;
19
+ notNull(): Column<Type, Values, Options, ColumnValue, Value, Definition & {
20
+ notNull: true;
21
+ }>;
22
+ unique(): Column<Type, Values, Options, ColumnValue, Value, Definition & {
23
+ unique: true;
24
+ }>;
25
+ comment<Comment extends string | null>(value: Comment): Column<Type, Values, Options, ColumnValue, Value, Definition & {
26
+ comment: Comment;
27
+ }>;
28
+ default<FinalValue extends ValueSelector<Definition, Value>>(value: FinalValue): Column<Type, Values, Options, ColumnValue, Value, Definition & {
29
+ default: FinalValue;
30
+ }>;
31
+ dialect<DbDialect extends Dialect>(dialect: DbDialect): Column<Type, Values, Options, ColumnValue, Value, Definition & {
32
+ dialect: DbDialect;
33
+ }>;
34
+ toQuery(): {
35
+ query: string;
36
+ params: never[];
37
+ };
38
+ toString(): string;
39
+ infer(): this['_output'];
40
+ }
41
+
42
+ export { Column };
@@ -0,0 +1,8 @@
1
+ import {
2
+ Column
3
+ } from "../chunk-GY7R637S.js";
4
+ import "../chunk-G3LSCLIQ.js";
5
+ import "../chunk-GLOHF5CP.js";
6
+ export {
7
+ Column
8
+ };
@@ -0,0 +1,43 @@
1
+ import { Dialect } from '../table/constants.js';
2
+ import { AcceptedColumnTypes } from './constants.js';
3
+
4
+ interface ColumnDefinition<T, U extends Dialect | null = null> {
5
+ primaryKey: boolean;
6
+ autoIncrement: boolean;
7
+ notNull: boolean;
8
+ unique: boolean;
9
+ comment: string | null;
10
+ default: T | undefined;
11
+ dialect: U | null;
12
+ }
13
+ type ValueSelector<Definition extends Partial<ColumnDefinition<Value, Dialect>> | ColumnDefinition<Value, Dialect>, Value> = Definition['notNull'] extends true ? Value | (string & {}) : Value | (string & {}) | null;
14
+ type AcceptedColumnTypeMap<T = any> = {
15
+ [K in AcceptedColumnTypes]: K extends typeof AcceptedColumnTypes.INTEGER | typeof AcceptedColumnTypes.BIGINT | typeof AcceptedColumnTypes.FLOAT | typeof AcceptedColumnTypes.DOUBLE | typeof AcceptedColumnTypes.DECIMAL | typeof AcceptedColumnTypes.SERIAL ? number : K extends typeof AcceptedColumnTypes.STRING | typeof AcceptedColumnTypes.TEXT | typeof AcceptedColumnTypes.VARCHAR ? string : K extends typeof AcceptedColumnTypes.BOOLEAN ? boolean : K extends typeof AcceptedColumnTypes.DATE | typeof AcceptedColumnTypes.TIME | typeof AcceptedColumnTypes.TIMESTAMP | typeof AcceptedColumnTypes.DATETIME | typeof AcceptedColumnTypes.DATEONLY ? Date : K extends typeof AcceptedColumnTypes.JSON ? object : K extends typeof AcceptedColumnTypes.BLOB ? Buffer : K extends typeof AcceptedColumnTypes.ENUM ? T[number][] : never;
16
+ };
17
+ type DateOptions = {
18
+ type: typeof AcceptedColumnTypes.DATE | typeof AcceptedColumnTypes.TIME | typeof AcceptedColumnTypes.TIMESTAMP | typeof AcceptedColumnTypes.DATETIME | typeof AcceptedColumnTypes.DATEONLY;
19
+ };
20
+ type NumberOptions<Length extends number = number> = {
21
+ type: typeof AcceptedColumnTypes.INTEGER | typeof AcceptedColumnTypes.BIGINT | typeof AcceptedColumnTypes.FLOAT | typeof AcceptedColumnTypes.DECIMAL | typeof AcceptedColumnTypes.DOUBLE | typeof AcceptedColumnTypes.SERIAL;
22
+ length?: Length;
23
+ };
24
+ type StringOptions<Length extends number = number> = {
25
+ type: typeof AcceptedColumnTypes.STRING | typeof AcceptedColumnTypes.VARCHAR | typeof AcceptedColumnTypes.TEXT;
26
+ length?: Length;
27
+ };
28
+ type EnumOptions<Values extends readonly string[]> = {
29
+ type: typeof AcceptedColumnTypes.ENUM;
30
+ values: Values;
31
+ };
32
+ type BooleanOptions = {
33
+ type: typeof AcceptedColumnTypes.BOOLEAN;
34
+ };
35
+ type JsonOptions = {
36
+ type: typeof AcceptedColumnTypes.JSON;
37
+ };
38
+ type BlobOptions = {
39
+ type: typeof AcceptedColumnTypes.BLOB;
40
+ };
41
+ type ColumnOptions<Type extends AcceptedColumnTypes, U extends number | readonly string[]> = Type extends typeof AcceptedColumnTypes.BLOB ? BlobOptions : Type extends typeof AcceptedColumnTypes.JSON ? JsonOptions : Type extends typeof AcceptedColumnTypes.BOOLEAN ? BooleanOptions : Type extends typeof AcceptedColumnTypes.DATE | typeof AcceptedColumnTypes.TIME | typeof AcceptedColumnTypes.TIMESTAMP | typeof AcceptedColumnTypes.DATETIME | typeof AcceptedColumnTypes.DATEONLY ? DateOptions : Type extends typeof AcceptedColumnTypes.STRING | typeof AcceptedColumnTypes.VARCHAR | typeof AcceptedColumnTypes.TEXT ? U extends number ? StringOptions<U> : StringOptions : Type extends typeof AcceptedColumnTypes.INTEGER | typeof AcceptedColumnTypes.BIGINT | typeof AcceptedColumnTypes.FLOAT | typeof AcceptedColumnTypes.DECIMAL | typeof AcceptedColumnTypes.DOUBLE | typeof AcceptedColumnTypes.SERIAL ? U extends number ? NumberOptions<U> : NumberOptions : Type extends typeof AcceptedColumnTypes.ENUM ? U extends readonly string[] ? EnumOptions<U> : never : never;
42
+
43
+ export type { AcceptedColumnTypeMap, BlobOptions, BooleanOptions, ColumnDefinition, ColumnOptions, DateOptions, EnumOptions, JsonOptions, NumberOptions, StringOptions, ValueSelector };
@@ -0,0 +1,2 @@
1
+ import "../chunk-G3LSCLIQ.js";
2
+ import "../chunk-GLOHF5CP.js";
@@ -0,0 +1,52 @@
1
+ import { D as Database } from '../index-Dcm5xIpR.js';
2
+ import { Column } from '../column/index.js';
3
+ import { AcceptedColumnTypes } from '../column/constants.js';
4
+ import { T as Table, D as DatabaseDefinition } from '../index-DJhQVUY3.js';
5
+ import { Dialect } from '../table/constants.js';
6
+ import '../column/types.js';
7
+ import '../types.js';
8
+ import '../query/constants.js';
9
+
10
+ declare function alterColumnType<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), Type extends Omit<AcceptedColumnTypes, typeof AcceptedColumnTypes.ENUM>, NewTables extends Omit<Tables, TableName> & {
11
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], ColName> & {
12
+ [K in ColName]: Tables[TableName]['columns'][ColName] & {
13
+ type: Type;
14
+ };
15
+ }>;
16
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName, newType: Type): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
17
+ declare function setColumnDefault<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), DefaultValue extends string | number | boolean | null, NewTables extends Omit<Tables, TableName> & {
18
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], ColName> & {
19
+ [K in ColName]: Omit<Tables[TableName]['columns'][ColName], 'definition'> & {
20
+ definition: Omit<Tables[TableName]['columns'][ColName]['definition'], 'default'> & {
21
+ default: DefaultValue;
22
+ };
23
+ };
24
+ }>;
25
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName, value: DefaultValue): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
26
+ declare function dropColumnDefault<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewTables extends Omit<Tables, TableName> & {
27
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], ColName> & {
28
+ [K in ColName]: Omit<Tables[TableName]['columns'][ColName], 'definition'> & {
29
+ definition: Omit<Tables[TableName]['columns'][ColName]['definition'], 'default'> & {
30
+ default: undefined;
31
+ };
32
+ };
33
+ }>;
34
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
35
+ declare function setColumnNotNull<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewTables extends Omit<Tables, TableName> & {
36
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], ColName> & {
37
+ [K in ColName]: Omit<Tables[TableName]['columns'][ColName], 'definition'> & {
38
+ definition: Omit<Tables[TableName]['columns'][ColName]['definition'], 'notNull'> & {
39
+ notNull: true;
40
+ };
41
+ };
42
+ }>;
43
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
44
+ declare function dropColumnNotNull<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewTables extends Omit<Tables, TableName> & {
45
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], ColName> & {
46
+ [K in ColName]: Omit<Tables[TableName]['columns'][ColName], 'definition'> & {
47
+ definition: Omit<Tables[TableName]['columns'][ColName]['definition'], 'notNull'>;
48
+ };
49
+ }>;
50
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
51
+
52
+ export { alterColumnType, dropColumnDefault, dropColumnNotNull, setColumnDefault, setColumnNotNull };
@@ -0,0 +1,15 @@
1
+ import {
2
+ alterColumnType,
3
+ dropColumnDefault,
4
+ dropColumnNotNull,
5
+ setColumnDefault,
6
+ setColumnNotNull
7
+ } from "../chunk-V4OMHVJN.js";
8
+ import "../chunk-GLOHF5CP.js";
9
+ export {
10
+ alterColumnType,
11
+ dropColumnDefault,
12
+ dropColumnNotNull,
13
+ setColumnDefault,
14
+ setColumnNotNull
15
+ };
@@ -0,0 +1,24 @@
1
+ import { D as Database } from '../index-Dcm5xIpR.js';
2
+ import { Column } from '../column/index.js';
3
+ import { T as Table, D as DatabaseDefinition } from '../index-DJhQVUY3.js';
4
+ import { Dialect } from '../table/constants.js';
5
+ import '../column/constants.js';
6
+ import '../column/types.js';
7
+ import '../types.js';
8
+ import '../query/constants.js';
9
+
10
+ declare function addColumn<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewTables extends Omit<Tables, TableName> & {
11
+ [K in TableName]: Table<TableName, Tables[TableName]['columns'] & {
12
+ [K in ColName]: Column;
13
+ }>;
14
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName, column: Column): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
15
+ declare function renameColumn<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), OldName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewTables extends Omit<Tables, TableName> & {
16
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], OldName> & {
17
+ [K in NewName]: Tables[TableName]['columns'][OldName];
18
+ }>;
19
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, oldName: OldName, newName: NewName): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
20
+ declare function dropColumn<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {}), ColName extends (keyof Tables[TableName]['columns'] & string) | (string & {}), NewTables extends Omit<Tables, TableName> & {
21
+ [K in TableName]: Table<TableName, Omit<Tables[TableName]['columns'], ColName>>;
22
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columnName: ColName): Promise<Database<DbDialect, Tables, Definition> | Database<DbDialect, NewTables, Definition>>;
23
+
24
+ export { addColumn, dropColumn, renameColumn };
@@ -0,0 +1,11 @@
1
+ import {
2
+ addColumn,
3
+ dropColumn,
4
+ renameColumn
5
+ } from "../chunk-JF7OSNH4.js";
6
+ import "../chunk-GLOHF5CP.js";
7
+ export {
8
+ addColumn,
9
+ dropColumn,
10
+ renameColumn
11
+ };
@@ -0,0 +1,8 @@
1
+ export { C as ColumnAlterationContract, T as TableAlterationContract } from '../index-Dcm5xIpR.js';
2
+ import '../column/index.js';
3
+ import '../column/constants.js';
4
+ import '../index-DJhQVUY3.js';
5
+ import '../table/constants.js';
6
+ import '../column/types.js';
7
+ import '../types.js';
8
+ import '../query/constants.js';
File without changes
@@ -0,0 +1,8 @@
1
+ import '../column/index.js';
2
+ import '../index-DJhQVUY3.js';
3
+ import '../table/constants.js';
4
+ export { D as Database } from '../index-Dcm5xIpR.js';
5
+ import '../column/constants.js';
6
+ import '../column/types.js';
7
+ import '../types.js';
8
+ import '../query/constants.js';
@@ -0,0 +1,19 @@
1
+ import {
2
+ Database
3
+ } from "../chunk-4DQRB5XS.js";
4
+ import "../chunk-HKTHKQLK.js";
5
+ import "../chunk-JF7OSNH4.js";
6
+ import "../chunk-D2ASIT4Q.js";
7
+ import "../chunk-W2DR3ZVK.js";
8
+ import "../chunk-TQ2GXAE7.js";
9
+ import "../chunk-MG2S4V4N.js";
10
+ import "../chunk-FYSNJAGD.js";
11
+ import "../chunk-WVJGTZFI.js";
12
+ import "../chunk-GY7R637S.js";
13
+ import "../chunk-G3LSCLIQ.js";
14
+ import "../chunk-Y7FSRHH3.js";
15
+ import "../chunk-V4OMHVJN.js";
16
+ import "../chunk-GLOHF5CP.js";
17
+ export {
18
+ Database
19
+ };
@@ -0,0 +1,21 @@
1
+ import { D as Database } from '../index-Dcm5xIpR.js';
2
+ import { Column } from '../column/index.js';
3
+ import { T as Table, D as DatabaseDefinition, a as TimestampOptions, M as MergeTimestampParanoid } from '../index-DJhQVUY3.js';
4
+ import { Dialect } from '../table/constants.js';
5
+ import '../column/constants.js';
6
+ import '../column/types.js';
7
+ import '../types.js';
8
+ import '../query/constants.js';
9
+
10
+ declare function createTable<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends string, Columns extends Record<string, Column>, CreatedAt extends string, UpdatedAt extends string, Timestamp extends TimestampOptions<CreatedAt, UpdatedAt> | boolean, Paranoid extends string | boolean, FinalColumns extends MergeTimestampParanoid<Columns, CreatedAt, UpdatedAt, Timestamp, Paranoid>, NewTables extends Tables & {
11
+ [K in TableName]: Table<TableName, FinalColumns, DbDialect, CreatedAt, UpdatedAt, Timestamp, Paranoid>;
12
+ }>(this: Database<DbDialect, Tables, Definition>, tableName: TableName, columns: Columns, options?: {
13
+ paranoid?: Paranoid;
14
+ timestamp?: Timestamp;
15
+ }): Promise<Database<DbDialect, NewTables, Definition>>;
16
+ declare function renameTable<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, OldName extends (keyof Tables & string) | (string & {}), NewName extends string, NewTables extends Omit<Tables, OldName> & {
17
+ [K in NewName]: Tables[OldName];
18
+ }>(this: Database<DbDialect, Tables, Definition>, oldName: OldName, newName: NewName): Promise<Database<DbDialect, NewTables, Definition>>;
19
+ declare function dropTable<DbDialect extends Dialect, Tables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<DatabaseDefinition<DbDialect>>, TableName extends (keyof Tables & string) | (string & {})>(this: Database<DbDialect, Tables, Definition>, tableName: TableName): Promise<Database<DbDialect, Omit<Tables, TableName>, Definition>>;
20
+
21
+ export { createTable, dropTable, renameTable };
@@ -0,0 +1,19 @@
1
+ import {
2
+ createTable,
3
+ dropTable,
4
+ renameTable
5
+ } from "../chunk-D2ASIT4Q.js";
6
+ import "../chunk-W2DR3ZVK.js";
7
+ import "../chunk-TQ2GXAE7.js";
8
+ import "../chunk-MG2S4V4N.js";
9
+ import "../chunk-FYSNJAGD.js";
10
+ import "../chunk-WVJGTZFI.js";
11
+ import "../chunk-GY7R637S.js";
12
+ import "../chunk-G3LSCLIQ.js";
13
+ import "../chunk-Y7FSRHH3.js";
14
+ import "../chunk-GLOHF5CP.js";
15
+ export {
16
+ createTable,
17
+ dropTable,
18
+ renameTable
19
+ };
@@ -0,0 +1,7 @@
1
+ import '../column/index.js';
2
+ export { D as DatabaseDefinition, b as DatabaseDialect, f as DatabaseOptions, P as PostgresConfig, S as SqliteConfig } from '../index-DJhQVUY3.js';
3
+ import '../table/constants.js';
4
+ import '../column/constants.js';
5
+ import '../column/types.js';
6
+ import '../types.js';
7
+ import '../query/constants.js';
File without changes