metal-orm 1.0.90 → 1.0.92

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 (37) hide show
  1. package/dist/index.cjs +214 -118
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +71 -32
  4. package/dist/index.d.ts +71 -32
  5. package/dist/index.js +206 -118
  6. package/dist/index.js.map +1 -1
  7. package/package.json +4 -2
  8. package/scripts/generate-entities/render.mjs +16 -3
  9. package/src/core/ddl/introspect/utils.ts +45 -45
  10. package/src/decorators/bootstrap.ts +37 -37
  11. package/src/decorators/column-decorator.ts +3 -1
  12. package/src/dto/apply-filter.ts +279 -281
  13. package/src/dto/dto-types.ts +229 -229
  14. package/src/dto/filter-types.ts +193 -193
  15. package/src/dto/index.ts +97 -97
  16. package/src/dto/openapi/generators/base.ts +29 -29
  17. package/src/dto/openapi/generators/column.ts +37 -34
  18. package/src/dto/openapi/generators/dto.ts +94 -94
  19. package/src/dto/openapi/generators/filter.ts +75 -74
  20. package/src/dto/openapi/generators/nested-dto.ts +618 -532
  21. package/src/dto/openapi/generators/pagination.ts +111 -111
  22. package/src/dto/openapi/generators/relation-filter.ts +228 -210
  23. package/src/dto/openapi/index.ts +17 -17
  24. package/src/dto/openapi/type-mappings.ts +191 -191
  25. package/src/dto/openapi/types.ts +101 -83
  26. package/src/dto/openapi/utilities.ts +90 -45
  27. package/src/dto/pagination-utils.ts +150 -150
  28. package/src/dto/transform.ts +197 -193
  29. package/src/index.ts +69 -69
  30. package/src/orm/entity-context.ts +9 -9
  31. package/src/orm/entity-metadata.ts +14 -14
  32. package/src/orm/entity.ts +74 -74
  33. package/src/orm/orm-session.ts +159 -159
  34. package/src/orm/relation-change-processor.ts +3 -3
  35. package/src/orm/runtime-types.ts +5 -5
  36. package/src/schema/column-types.ts +4 -4
  37. 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 = unknown | RawDefaultValue;
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?: unknown[];
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?: unknown[]; tsType?: unknown } = {}): ColumnDef => ({
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: unknown): ColumnDef<T> =>
277
+ default: <T extends ColumnType>(def: ColumnDef<T>, value: DefaultValue): ColumnDef<T> =>
278
278
  ({
279
279
  ...def,
280
280
  default: value
@@ -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' ? unknown :
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