metal-orm 1.0.35 → 1.0.36
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/README.md +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/decorators/bootstrap.ts +3 -3
- package/src/decorators/column.ts +3 -1
- package/src/orm/entity-metadata.ts +16 -9
- package/src/orm/entity.ts +7 -4
- package/src/schema/types.ts +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -373,7 +373,9 @@ type RelationTargetTable<TRel extends RelationDef> = TRel extends HasManyRelatio
|
|
|
373
373
|
/**
|
|
374
374
|
* Maps a ColumnDef to its TypeScript type representation
|
|
375
375
|
*/
|
|
376
|
-
type ColumnToTs<T extends ColumnDef> =
|
|
376
|
+
type ColumnToTs<T extends ColumnDef> = [
|
|
377
|
+
unknown
|
|
378
|
+
] extends [T['tsType']] ? 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>;
|
|
377
379
|
/**
|
|
378
380
|
* Infers a row shape from a table definition
|
|
379
381
|
*/
|
|
@@ -3621,7 +3623,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
3621
3623
|
}
|
|
3622
3624
|
|
|
3623
3625
|
declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof RelationMap<TTable> = keyof RelationMap<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: TLazy[]) => EntityInstance<TTable>;
|
|
3624
|
-
declare const createEntityFromRow: <TTable extends TableDef>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: (keyof RelationMap<TTable>)[]) =>
|
|
3626
|
+
declare const createEntityFromRow: <TTable extends TableDef, TResult extends EntityInstance<TTable> = EntityInstance<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: (keyof RelationMap<TTable>)[]) => TResult;
|
|
3625
3627
|
|
|
3626
3628
|
type Rows$3 = Record<string, any>[];
|
|
3627
3629
|
declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasManyRelation) => Promise<Map<string, Rows$3>>;
|
|
@@ -3755,8 +3757,9 @@ interface ColumnOptions {
|
|
|
3755
3757
|
args?: ColumnDef['args'];
|
|
3756
3758
|
notNull?: boolean;
|
|
3757
3759
|
primary?: boolean;
|
|
3760
|
+
tsType?: ColumnDef['tsType'];
|
|
3758
3761
|
}
|
|
3759
|
-
type ColumnInput = ColumnOptions | ColumnDef
|
|
3762
|
+
type ColumnInput = ColumnOptions | ColumnDef<any, any>;
|
|
3760
3763
|
declare function Column(definition: ColumnInput): DualModePropertyDecorator;
|
|
3761
3764
|
declare function PrimaryKey(definition: ColumnInput): DualModePropertyDecorator;
|
|
3762
3765
|
|
|
@@ -3791,8 +3794,8 @@ declare function BelongsTo(options: BelongsToOptions): DualModePropertyDecorator
|
|
|
3791
3794
|
declare function BelongsToMany(options: BelongsToManyOptions): DualModePropertyDecorator;
|
|
3792
3795
|
|
|
3793
3796
|
declare const bootstrapEntities: () => TableDef[];
|
|
3794
|
-
declare const getTableDefFromEntity: (ctor: EntityConstructor) =>
|
|
3795
|
-
declare const selectFromEntity: <TTable extends TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<any, TTable>;
|
|
3797
|
+
declare const getTableDefFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => TTable | undefined;
|
|
3798
|
+
declare const selectFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<any, TTable>;
|
|
3796
3799
|
|
|
3797
3800
|
interface PostgresClientLike {
|
|
3798
3801
|
query(text: string, params?: unknown[]): Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -373,7 +373,9 @@ type RelationTargetTable<TRel extends RelationDef> = TRel extends HasManyRelatio
|
|
|
373
373
|
/**
|
|
374
374
|
* Maps a ColumnDef to its TypeScript type representation
|
|
375
375
|
*/
|
|
376
|
-
type ColumnToTs<T extends ColumnDef> =
|
|
376
|
+
type ColumnToTs<T extends ColumnDef> = [
|
|
377
|
+
unknown
|
|
378
|
+
] extends [T['tsType']] ? 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>;
|
|
377
379
|
/**
|
|
378
380
|
* Infers a row shape from a table definition
|
|
379
381
|
*/
|
|
@@ -3621,7 +3623,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
3621
3623
|
}
|
|
3622
3624
|
|
|
3623
3625
|
declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof RelationMap<TTable> = keyof RelationMap<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: TLazy[]) => EntityInstance<TTable>;
|
|
3624
|
-
declare const createEntityFromRow: <TTable extends TableDef>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: (keyof RelationMap<TTable>)[]) =>
|
|
3626
|
+
declare const createEntityFromRow: <TTable extends TableDef, TResult extends EntityInstance<TTable> = EntityInstance<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: (keyof RelationMap<TTable>)[]) => TResult;
|
|
3625
3627
|
|
|
3626
3628
|
type Rows$3 = Record<string, any>[];
|
|
3627
3629
|
declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasManyRelation) => Promise<Map<string, Rows$3>>;
|
|
@@ -3755,8 +3757,9 @@ interface ColumnOptions {
|
|
|
3755
3757
|
args?: ColumnDef['args'];
|
|
3756
3758
|
notNull?: boolean;
|
|
3757
3759
|
primary?: boolean;
|
|
3760
|
+
tsType?: ColumnDef['tsType'];
|
|
3758
3761
|
}
|
|
3759
|
-
type ColumnInput = ColumnOptions | ColumnDef
|
|
3762
|
+
type ColumnInput = ColumnOptions | ColumnDef<any, any>;
|
|
3760
3763
|
declare function Column(definition: ColumnInput): DualModePropertyDecorator;
|
|
3761
3764
|
declare function PrimaryKey(definition: ColumnInput): DualModePropertyDecorator;
|
|
3762
3765
|
|
|
@@ -3791,8 +3794,8 @@ declare function BelongsTo(options: BelongsToOptions): DualModePropertyDecorator
|
|
|
3791
3794
|
declare function BelongsToMany(options: BelongsToManyOptions): DualModePropertyDecorator;
|
|
3792
3795
|
|
|
3793
3796
|
declare const bootstrapEntities: () => TableDef[];
|
|
3794
|
-
declare const getTableDefFromEntity: (ctor: EntityConstructor) =>
|
|
3795
|
-
declare const selectFromEntity: <TTable extends TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<any, TTable>;
|
|
3797
|
+
declare const getTableDefFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => TTable | undefined;
|
|
3798
|
+
declare const selectFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<any, TTable>;
|
|
3796
3799
|
|
|
3797
3800
|
interface PostgresClientLike {
|
|
3798
3801
|
query(text: string, params?: unknown[]): Promise<{
|
package/dist/index.js
CHANGED
|
@@ -7576,6 +7576,7 @@ var normalizeColumnInput = (input) => {
|
|
|
7576
7576
|
args: asOptions.args ?? asDefinition.args,
|
|
7577
7577
|
notNull: asOptions.notNull ?? asDefinition.notNull,
|
|
7578
7578
|
primary: asOptions.primary ?? asDefinition.primary,
|
|
7579
|
+
tsType: asDefinition.tsType ?? asOptions.tsType,
|
|
7579
7580
|
unique: asDefinition.unique,
|
|
7580
7581
|
default: asDefinition.default,
|
|
7581
7582
|
autoIncrement: asDefinition.autoIncrement,
|