metal-orm 1.0.34 → 1.0.35
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.
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/schema/column.ts +216 -214
- package/src/schema/types.ts +10 -8
package/dist/index.d.cts
CHANGED
|
@@ -24,11 +24,13 @@ interface ForeignKeyReference {
|
|
|
24
24
|
/**
|
|
25
25
|
* Definition of a database column
|
|
26
26
|
*/
|
|
27
|
-
interface ColumnDef<T extends ColumnType = ColumnType> {
|
|
27
|
+
interface ColumnDef<T extends ColumnType = ColumnType, TRuntime = unknown> {
|
|
28
28
|
/** Column name (filled at runtime by defineTable) */
|
|
29
29
|
name: string;
|
|
30
30
|
/** Data type of the column */
|
|
31
31
|
type: T;
|
|
32
|
+
/** Optional override for the inferred TypeScript type */
|
|
33
|
+
tsType?: TRuntime;
|
|
32
34
|
/** Whether this column is a primary key */
|
|
33
35
|
primary?: boolean;
|
|
34
36
|
/** Whether this column cannot be null */
|
|
@@ -102,19 +104,19 @@ declare const col: {
|
|
|
102
104
|
/**
|
|
103
105
|
* Creates a timestamp column definition
|
|
104
106
|
*/
|
|
105
|
-
timestamp: () => ColumnDef<"TIMESTAMP">;
|
|
107
|
+
timestamp: <TRuntime = string>() => ColumnDef<"TIMESTAMP", TRuntime>;
|
|
106
108
|
/**
|
|
107
109
|
* Creates a timestamptz column definition
|
|
108
110
|
*/
|
|
109
|
-
timestamptz: () => ColumnDef<"TIMESTAMPTZ">;
|
|
111
|
+
timestamptz: <TRuntime = string>() => ColumnDef<"TIMESTAMPTZ", TRuntime>;
|
|
110
112
|
/**
|
|
111
113
|
* Creates a date column definition
|
|
112
114
|
*/
|
|
113
|
-
date: () => ColumnDef<"DATE">;
|
|
115
|
+
date: <TRuntime = string>() => ColumnDef<"DATE", TRuntime>;
|
|
114
116
|
/**
|
|
115
117
|
* Creates a datetime column definition
|
|
116
118
|
*/
|
|
117
|
-
datetime: () => ColumnDef<"DATETIME">;
|
|
119
|
+
datetime: <TRuntime = string>() => ColumnDef<"DATETIME", TRuntime>;
|
|
118
120
|
/**
|
|
119
121
|
* Creates a JSON column definition
|
|
120
122
|
* @returns ColumnDef with JSON type
|
|
@@ -371,7 +373,7 @@ type RelationTargetTable<TRel extends RelationDef> = TRel extends HasManyRelatio
|
|
|
371
373
|
/**
|
|
372
374
|
* Maps a ColumnDef to its TypeScript type representation
|
|
373
375
|
*/
|
|
374
|
-
type ColumnToTs<T extends ColumnDef> = T['type'] extends 'INT' | 'INTEGER' | 'int' | 'integer' ? number : T['type'] extends 'BIGINT' | 'bigint' ? number | bigint : T['type'] extends 'DECIMAL' | 'decimal' | 'FLOAT' | 'float' | 'DOUBLE' | 'double' ? number : T['type'] extends 'BOOLEAN' | 'boolean' ? boolean : T['type'] extends 'JSON' | 'json' ? unknown : T['type'] extends 'BLOB' | 'blob' | 'BINARY' | 'binary' | 'VARBINARY' | 'varbinary' | 'BYTEA' | 'bytea' ? Buffer : T['type'] extends 'DATE' | 'date' | 'DATETIME' | 'datetime' | 'TIMESTAMP' | 'timestamp' | 'TIMESTAMPTZ' | 'timestamptz' ? string : string
|
|
376
|
+
type ColumnToTs<T extends ColumnDef> = T['tsType'] extends undefined ? T['type'] extends 'INT' | 'INTEGER' | 'int' | 'integer' ? number : T['type'] extends 'BIGINT' | 'bigint' ? number | bigint : T['type'] extends 'DECIMAL' | 'decimal' | 'FLOAT' | 'float' | 'DOUBLE' | 'double' ? number : T['type'] extends 'BOOLEAN' | 'boolean' ? boolean : T['type'] extends 'JSON' | 'json' ? unknown : T['type'] extends 'BLOB' | 'blob' | 'BINARY' | 'binary' | 'VARBINARY' | 'varbinary' | 'BYTEA' | 'bytea' ? Buffer : T['type'] extends 'DATE' | 'date' | 'DATETIME' | 'datetime' | 'TIMESTAMP' | 'timestamp' | 'TIMESTAMPTZ' | 'timestamptz' ? string : string : Exclude<T['tsType'], undefined>;
|
|
375
377
|
/**
|
|
376
378
|
* Infers a row shape from a table definition
|
|
377
379
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -24,11 +24,13 @@ interface ForeignKeyReference {
|
|
|
24
24
|
/**
|
|
25
25
|
* Definition of a database column
|
|
26
26
|
*/
|
|
27
|
-
interface ColumnDef<T extends ColumnType = ColumnType> {
|
|
27
|
+
interface ColumnDef<T extends ColumnType = ColumnType, TRuntime = unknown> {
|
|
28
28
|
/** Column name (filled at runtime by defineTable) */
|
|
29
29
|
name: string;
|
|
30
30
|
/** Data type of the column */
|
|
31
31
|
type: T;
|
|
32
|
+
/** Optional override for the inferred TypeScript type */
|
|
33
|
+
tsType?: TRuntime;
|
|
32
34
|
/** Whether this column is a primary key */
|
|
33
35
|
primary?: boolean;
|
|
34
36
|
/** Whether this column cannot be null */
|
|
@@ -102,19 +104,19 @@ declare const col: {
|
|
|
102
104
|
/**
|
|
103
105
|
* Creates a timestamp column definition
|
|
104
106
|
*/
|
|
105
|
-
timestamp: () => ColumnDef<"TIMESTAMP">;
|
|
107
|
+
timestamp: <TRuntime = string>() => ColumnDef<"TIMESTAMP", TRuntime>;
|
|
106
108
|
/**
|
|
107
109
|
* Creates a timestamptz column definition
|
|
108
110
|
*/
|
|
109
|
-
timestamptz: () => ColumnDef<"TIMESTAMPTZ">;
|
|
111
|
+
timestamptz: <TRuntime = string>() => ColumnDef<"TIMESTAMPTZ", TRuntime>;
|
|
110
112
|
/**
|
|
111
113
|
* Creates a date column definition
|
|
112
114
|
*/
|
|
113
|
-
date: () => ColumnDef<"DATE">;
|
|
115
|
+
date: <TRuntime = string>() => ColumnDef<"DATE", TRuntime>;
|
|
114
116
|
/**
|
|
115
117
|
* Creates a datetime column definition
|
|
116
118
|
*/
|
|
117
|
-
datetime: () => ColumnDef<"DATETIME">;
|
|
119
|
+
datetime: <TRuntime = string>() => ColumnDef<"DATETIME", TRuntime>;
|
|
118
120
|
/**
|
|
119
121
|
* Creates a JSON column definition
|
|
120
122
|
* @returns ColumnDef with JSON type
|
|
@@ -371,7 +373,7 @@ type RelationTargetTable<TRel extends RelationDef> = TRel extends HasManyRelatio
|
|
|
371
373
|
/**
|
|
372
374
|
* Maps a ColumnDef to its TypeScript type representation
|
|
373
375
|
*/
|
|
374
|
-
type ColumnToTs<T extends ColumnDef> = T['type'] extends 'INT' | 'INTEGER' | 'int' | 'integer' ? number : T['type'] extends 'BIGINT' | 'bigint' ? number | bigint : T['type'] extends 'DECIMAL' | 'decimal' | 'FLOAT' | 'float' | 'DOUBLE' | 'double' ? number : T['type'] extends 'BOOLEAN' | 'boolean' ? boolean : T['type'] extends 'JSON' | 'json' ? unknown : T['type'] extends 'BLOB' | 'blob' | 'BINARY' | 'binary' | 'VARBINARY' | 'varbinary' | 'BYTEA' | 'bytea' ? Buffer : T['type'] extends 'DATE' | 'date' | 'DATETIME' | 'datetime' | 'TIMESTAMP' | 'timestamp' | 'TIMESTAMPTZ' | 'timestamptz' ? string : string
|
|
376
|
+
type ColumnToTs<T extends ColumnDef> = T['tsType'] extends undefined ? T['type'] extends 'INT' | 'INTEGER' | 'int' | 'integer' ? number : T['type'] extends 'BIGINT' | 'bigint' ? number | bigint : T['type'] extends 'DECIMAL' | 'decimal' | 'FLOAT' | 'float' | 'DOUBLE' | 'double' ? number : T['type'] extends 'BOOLEAN' | 'boolean' ? boolean : T['type'] extends 'JSON' | 'json' ? unknown : T['type'] extends 'BLOB' | 'blob' | 'BINARY' | 'binary' | 'VARBINARY' | 'varbinary' | 'BYTEA' | 'bytea' ? Buffer : T['type'] extends 'DATE' | 'date' | 'DATETIME' | 'datetime' | 'TIMESTAMP' | 'timestamp' | 'TIMESTAMPTZ' | 'timestamptz' ? string : string : Exclude<T['tsType'], undefined>;
|
|
375
377
|
/**
|
|
376
378
|
* Infers a row shape from a table definition
|
|
377
379
|
*/
|