metal-orm 1.0.90 → 1.0.91
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 +24 -10
- package/dist/index.d.ts +24 -10
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
- package/src/core/ddl/introspect/utils.ts +45 -45
- package/src/decorators/bootstrap.ts +37 -37
- package/src/dto/apply-filter.ts +279 -281
- package/src/dto/dto-types.ts +229 -229
- package/src/dto/filter-types.ts +193 -193
- package/src/dto/index.ts +97 -97
- package/src/dto/openapi/generators/base.ts +29 -29
- package/src/dto/openapi/generators/column.ts +34 -34
- package/src/dto/openapi/generators/dto.ts +94 -94
- package/src/dto/openapi/generators/filter.ts +74 -74
- package/src/dto/openapi/generators/nested-dto.ts +532 -532
- package/src/dto/openapi/generators/pagination.ts +111 -111
- package/src/dto/openapi/generators/relation-filter.ts +210 -210
- package/src/dto/openapi/index.ts +17 -17
- package/src/dto/openapi/type-mappings.ts +191 -191
- package/src/dto/openapi/types.ts +90 -83
- package/src/dto/openapi/utilities.ts +45 -45
- package/src/dto/pagination-utils.ts +150 -150
- package/src/dto/transform.ts +197 -193
- package/src/index.ts +69 -69
- package/src/orm/entity-context.ts +9 -9
- package/src/orm/entity.ts +74 -74
- package/src/orm/orm-session.ts +159 -159
- package/src/orm/relation-change-processor.ts +3 -3
- package/src/orm/runtime-types.ts +5 -5
- package/src/schema/column-types.ts +4 -4
- package/src/schema/types.ts +5 -1
|
@@ -64,7 +64,7 @@ export interface RawDefaultValue {
|
|
|
64
64
|
raw: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export type DefaultValue =
|
|
67
|
+
export type DefaultValue = string | number | boolean | Date | null | RawDefaultValue;
|
|
68
68
|
|
|
69
69
|
export interface ForeignKeyReference {
|
|
70
70
|
/** Target table name */
|
|
@@ -112,7 +112,7 @@ export interface ColumnDef<T extends ColumnType = ColumnType, TRuntime = unknown
|
|
|
112
112
|
/** Column comment/description */
|
|
113
113
|
comment?: string;
|
|
114
114
|
/** Additional arguments for the column type (e.g., VARCHAR length) */
|
|
115
|
-
args?:
|
|
115
|
+
args?: (string | number)[];
|
|
116
116
|
/** Table name this column belongs to (filled at runtime by defineTable) */
|
|
117
117
|
table?: string;
|
|
118
118
|
}
|
|
@@ -240,7 +240,7 @@ export const col = {
|
|
|
240
240
|
* Creates a column definition with a custom SQL type.
|
|
241
241
|
* Useful for dialect-specific types without polluting the standard set.
|
|
242
242
|
*/
|
|
243
|
-
custom: (type: string, opts: { dialect?: string; args?:
|
|
243
|
+
custom: (type: string, opts: { dialect?: string; args?: (string | number)[]; tsType?: unknown } = {}): ColumnDef => ({
|
|
244
244
|
name: '',
|
|
245
245
|
type,
|
|
246
246
|
args: opts.args,
|
|
@@ -274,7 +274,7 @@ export const col = {
|
|
|
274
274
|
/**
|
|
275
275
|
* Sets a default value for the column
|
|
276
276
|
*/
|
|
277
|
-
default: <T extends ColumnType>(def: ColumnDef<T>, value:
|
|
277
|
+
default: <T extends ColumnType>(def: ColumnDef<T>, value: DefaultValue): ColumnDef<T> =>
|
|
278
278
|
({
|
|
279
279
|
...def,
|
|
280
280
|
default: value
|
package/src/schema/types.ts
CHANGED
|
@@ -19,6 +19,10 @@ export type RelationTargetTable<TRel extends RelationDef> =
|
|
|
19
19
|
TRel extends BelongsToManyRelation<infer TTarget, TableDef> ? TTarget :
|
|
20
20
|
never;
|
|
21
21
|
|
|
22
|
+
export type JsonValue = string | number | boolean | null | JsonArray | JsonObject;
|
|
23
|
+
export type JsonArray = Array<JsonValue>;
|
|
24
|
+
export interface JsonObject { [key: string]: JsonValue }
|
|
25
|
+
|
|
22
26
|
type NormalizedColumnType<T extends ColumnDef> = Lowercase<T['type'] & string>;
|
|
23
27
|
|
|
24
28
|
/**
|
|
@@ -30,7 +34,7 @@ export type ColumnToTs<T extends ColumnDef> =
|
|
|
30
34
|
NormalizedColumnType<T> extends 'bigint' ? number | bigint :
|
|
31
35
|
NormalizedColumnType<T> extends 'decimal' | 'float' | 'double' ? number :
|
|
32
36
|
NormalizedColumnType<T> extends 'boolean' ? boolean :
|
|
33
|
-
NormalizedColumnType<T> extends 'json' ?
|
|
37
|
+
NormalizedColumnType<T> extends 'json' ? JsonValue :
|
|
34
38
|
NormalizedColumnType<T> extends 'blob' | 'binary' | 'varbinary' | 'bytea' ? Buffer :
|
|
35
39
|
NormalizedColumnType<T> extends 'date' | 'datetime' | 'timestamp' | 'timestamptz' ? string :
|
|
36
40
|
string
|