@mikro-orm/core 6.4.17-dev.95 → 6.4.17-dev.97
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/entity/defineEntity.d.ts +19 -10
- package/entity/defineEntity.js +19 -0
- package/index.mjs +9 -0
- package/package.json +2 -2
package/entity/defineEntity.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ import type { Collection } from './Collection';
|
|
|
14
14
|
import type { IType, Type } from '../types/Type';
|
|
15
15
|
import { types } from '../types';
|
|
16
16
|
import { EntitySchema } from '../metadata/EntitySchema';
|
|
17
|
-
|
|
17
|
+
/** @internal */
|
|
18
|
+
export declare class PropertyOptionsBuilder<Value> {
|
|
18
19
|
'~options': PropertyOptions<any>;
|
|
19
20
|
'~type'?: {
|
|
20
21
|
value: Value;
|
|
@@ -262,7 +263,8 @@ declare class PropertyOptionsBuilder<Value> {
|
|
|
262
263
|
*/
|
|
263
264
|
$type<Runtime, Raw, Serialized = Raw>(): PropertyOptionsBuilder<IType<Runtime, Raw, Serialized>>;
|
|
264
265
|
}
|
|
265
|
-
|
|
266
|
+
/** @internal */
|
|
267
|
+
export declare class EnumOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
|
|
266
268
|
'~options': {
|
|
267
269
|
enum: true;
|
|
268
270
|
} & EnumOptions<any>;
|
|
@@ -271,7 +273,8 @@ declare class EnumOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
|
|
|
271
273
|
/** for postgres, by default it uses text column with check constraint */
|
|
272
274
|
nativeEnumName(nativeEnumName: string): EnumOptionsBuilder<Value>;
|
|
273
275
|
}
|
|
274
|
-
|
|
276
|
+
/** @internal */
|
|
277
|
+
export declare class EmbeddedOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
|
|
275
278
|
'~options': ({
|
|
276
279
|
kind: 'embedded';
|
|
277
280
|
entity: () => EntitySchema<any, any> | EntitySchema<any, any>[];
|
|
@@ -282,7 +285,8 @@ declare class EmbeddedOptionsBuilder<Value> extends PropertyOptionsBuilder<Value
|
|
|
282
285
|
object(object?: boolean): EmbeddedOptionsBuilder<Value>;
|
|
283
286
|
array<T extends boolean = true>(array?: T): EmbeddedOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
|
|
284
287
|
}
|
|
285
|
-
|
|
288
|
+
/** @internal */
|
|
289
|
+
export declare class ReferenceOptionsBuilder<Value extends object> extends PropertyOptionsBuilder<Value> {
|
|
286
290
|
'~options': ReferenceOptions<any, any>;
|
|
287
291
|
constructor(options: ReferenceOptionsBuilder<Value>['~options']);
|
|
288
292
|
/** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
|
|
@@ -302,7 +306,8 @@ declare class ReferenceOptionsBuilder<Value extends object> extends PropertyOpti
|
|
|
302
306
|
*/
|
|
303
307
|
primary(primary?: boolean): ReferenceOptionsBuilder<any>;
|
|
304
308
|
}
|
|
305
|
-
|
|
309
|
+
/** @internal */
|
|
310
|
+
export declare class ManyToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
|
|
306
311
|
'~options': ({
|
|
307
312
|
kind: 'm:n';
|
|
308
313
|
entity: () => EntitySchema<any, any>;
|
|
@@ -343,7 +348,8 @@ declare class ManyToManyOptionsBuilder<TargetValue extends object> extends Refer
|
|
|
343
348
|
/** What to do when the reference to the target entity gets updated. */
|
|
344
349
|
updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToManyOptionsBuilder<TargetValue>;
|
|
345
350
|
}
|
|
346
|
-
|
|
351
|
+
/** @internal */
|
|
352
|
+
export declare class ManyToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
|
|
347
353
|
'~options': ({
|
|
348
354
|
kind: 'm:1';
|
|
349
355
|
entity: () => EntitySchema<any, any>;
|
|
@@ -374,7 +380,8 @@ declare class ManyToOneOptionsBuilder<TargetValue extends object> extends Refere
|
|
|
374
380
|
/** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
|
|
375
381
|
deferMode(deferMode: DeferMode | `${DeferMode}`): ManyToOneOptionsBuilder<TargetValue>;
|
|
376
382
|
}
|
|
377
|
-
|
|
383
|
+
/** @internal */
|
|
384
|
+
export declare class OneToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
|
|
378
385
|
'~options': ({
|
|
379
386
|
kind: '1:m';
|
|
380
387
|
entity: () => EntitySchema<TargetValue>;
|
|
@@ -399,7 +406,8 @@ declare class OneToManyOptionsBuilder<TargetValue extends object> extends Refere
|
|
|
399
406
|
/** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
|
|
400
407
|
referencedColumnNames(...referencedColumnNames: string[]): OneToManyOptionsBuilder<TargetValue>;
|
|
401
408
|
}
|
|
402
|
-
|
|
409
|
+
/** @internal */
|
|
410
|
+
export declare class OneToManyOptionsBuilderOnlyMappedBy<TargetValue extends object> {
|
|
403
411
|
'~options': ({
|
|
404
412
|
kind: '1:m';
|
|
405
413
|
entity: () => EntitySchema<TargetValue>;
|
|
@@ -408,7 +416,8 @@ declare class OneToManyOptionsBuilderOnlyMappedBy<TargetValue extends object> {
|
|
|
408
416
|
/** Point to the owning side property name. */
|
|
409
417
|
mappedBy(mappedBy: (AnyString & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): OneToManyOptionsBuilder<TargetValue>;
|
|
410
418
|
}
|
|
411
|
-
|
|
419
|
+
/** @internal */
|
|
420
|
+
export declare class OneToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
|
|
412
421
|
'~options': ({
|
|
413
422
|
kind: '1:1';
|
|
414
423
|
entity: () => EntitySchema<any, any>;
|
|
@@ -510,7 +519,7 @@ type InferPropertyValueType<T extends PropertyValueType> = T extends string ? In
|
|
|
510
519
|
type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<typeof types[T]> : InferColumnType<T>;
|
|
511
520
|
type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
|
|
512
521
|
type InferColumnType<T extends string> = T extends 'int' | 'int4' | 'integer' | 'bigint' | 'int8' | 'int2' | 'tinyint' | 'smallint' | 'mediumint' ? number : T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4' ? number : T extends 'datetime' | 'time' | 'time with time zone' | 'timestamp' | 'timestamp with time zone' | 'timetz' | 'timestamptz' | 'date' | 'interval' ? Date : T extends 'ObjectId' | 'objectId' | 'character varying' | 'varchar' | 'char' | 'character' | 'uuid' | 'text' | 'tinytext' | 'mediumtext' | 'longtext' | 'enum' ? string : T extends 'boolean' | 'bool' | 'bit' ? boolean : T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea' ? Buffer : T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry' ? number[] : T extends 'tsvector' | 'tsquery' ? string[] : T extends 'json' | 'jsonb' ? any : any;
|
|
513
|
-
type InferEntityFromProperties<Properties extends Record<string, any>> = {
|
|
522
|
+
export type InferEntityFromProperties<Properties extends Record<string, any>> = {
|
|
514
523
|
-readonly [K in keyof Properties]: Properties[K] extends (() => any) ? InferBuilderValue<ReturnType<Properties[K]>> : InferBuilderValue<Properties[K]>;
|
|
515
524
|
};
|
|
516
525
|
type InferBuilderValue<Builder> = Builder extends {
|
package/entity/defineEntity.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OneToOneOptionsBuilder = exports.OneToManyOptionsBuilderOnlyMappedBy = exports.OneToManyOptionsBuilder = exports.ManyToOneOptionsBuilder = exports.ManyToManyOptionsBuilder = exports.ReferenceOptionsBuilder = exports.EmbeddedOptionsBuilder = exports.EnumOptionsBuilder = exports.PropertyOptionsBuilder = void 0;
|
|
3
4
|
exports.defineEntity = defineEntity;
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
const EntitySchema_1 = require("../metadata/EntitySchema");
|
|
7
|
+
/** @internal */
|
|
6
8
|
class PropertyOptionsBuilder {
|
|
7
9
|
'~options';
|
|
8
10
|
'~type';
|
|
@@ -325,6 +327,8 @@ class PropertyOptionsBuilder {
|
|
|
325
327
|
return new PropertyOptionsBuilder({ ...this['~options'] });
|
|
326
328
|
}
|
|
327
329
|
}
|
|
330
|
+
exports.PropertyOptionsBuilder = PropertyOptionsBuilder;
|
|
331
|
+
/** @internal */
|
|
328
332
|
class EnumOptionsBuilder extends PropertyOptionsBuilder {
|
|
329
333
|
constructor(options) {
|
|
330
334
|
super(options);
|
|
@@ -338,6 +342,8 @@ class EnumOptionsBuilder extends PropertyOptionsBuilder {
|
|
|
338
342
|
return new EnumOptionsBuilder({ ...this['~options'], nativeEnumName });
|
|
339
343
|
}
|
|
340
344
|
}
|
|
345
|
+
exports.EnumOptionsBuilder = EnumOptionsBuilder;
|
|
346
|
+
/** @internal */
|
|
341
347
|
class EmbeddedOptionsBuilder extends PropertyOptionsBuilder {
|
|
342
348
|
constructor(options) {
|
|
343
349
|
super(options);
|
|
@@ -356,6 +362,8 @@ class EmbeddedOptionsBuilder extends PropertyOptionsBuilder {
|
|
|
356
362
|
return new EmbeddedOptionsBuilder({ ...this['~options'], array });
|
|
357
363
|
}
|
|
358
364
|
}
|
|
365
|
+
exports.EmbeddedOptionsBuilder = EmbeddedOptionsBuilder;
|
|
366
|
+
/** @internal */
|
|
359
367
|
class ReferenceOptionsBuilder extends PropertyOptionsBuilder {
|
|
360
368
|
constructor(options) {
|
|
361
369
|
super(options);
|
|
@@ -390,6 +398,8 @@ class ReferenceOptionsBuilder extends PropertyOptionsBuilder {
|
|
|
390
398
|
return new ReferenceOptionsBuilder({ ...this['~options'], primary });
|
|
391
399
|
}
|
|
392
400
|
}
|
|
401
|
+
exports.ReferenceOptionsBuilder = ReferenceOptionsBuilder;
|
|
402
|
+
/** @internal */
|
|
393
403
|
class ManyToManyOptionsBuilder extends ReferenceOptionsBuilder {
|
|
394
404
|
constructor(options) {
|
|
395
405
|
super(options);
|
|
@@ -464,6 +474,8 @@ class ManyToManyOptionsBuilder extends ReferenceOptionsBuilder {
|
|
|
464
474
|
return new ManyToManyOptionsBuilder({ ...this['~options'], updateRule });
|
|
465
475
|
}
|
|
466
476
|
}
|
|
477
|
+
exports.ManyToManyOptionsBuilder = ManyToManyOptionsBuilder;
|
|
478
|
+
/** @internal */
|
|
467
479
|
class ManyToOneOptionsBuilder extends ReferenceOptionsBuilder {
|
|
468
480
|
constructor(options) {
|
|
469
481
|
super(options);
|
|
@@ -518,6 +530,8 @@ class ManyToOneOptionsBuilder extends ReferenceOptionsBuilder {
|
|
|
518
530
|
return new ManyToOneOptionsBuilder({ ...this['~options'], deferMode });
|
|
519
531
|
}
|
|
520
532
|
}
|
|
533
|
+
exports.ManyToOneOptionsBuilder = ManyToOneOptionsBuilder;
|
|
534
|
+
/** @internal */
|
|
521
535
|
class OneToManyOptionsBuilder extends ReferenceOptionsBuilder {
|
|
522
536
|
constructor(options) {
|
|
523
537
|
super(options);
|
|
@@ -560,6 +574,8 @@ class OneToManyOptionsBuilder extends ReferenceOptionsBuilder {
|
|
|
560
574
|
return new OneToManyOptionsBuilder({ ...this['~options'], referencedColumnNames });
|
|
561
575
|
}
|
|
562
576
|
}
|
|
577
|
+
exports.OneToManyOptionsBuilder = OneToManyOptionsBuilder;
|
|
578
|
+
/** @internal */
|
|
563
579
|
class OneToManyOptionsBuilderOnlyMappedBy {
|
|
564
580
|
constructor(options) {
|
|
565
581
|
this['~options'] = options;
|
|
@@ -569,6 +585,8 @@ class OneToManyOptionsBuilderOnlyMappedBy {
|
|
|
569
585
|
return new OneToManyOptionsBuilder({ ...this['~options'], mappedBy });
|
|
570
586
|
}
|
|
571
587
|
}
|
|
588
|
+
exports.OneToManyOptionsBuilderOnlyMappedBy = OneToManyOptionsBuilderOnlyMappedBy;
|
|
589
|
+
/** @internal */
|
|
572
590
|
class OneToOneOptionsBuilder extends ReferenceOptionsBuilder {
|
|
573
591
|
constructor(options) {
|
|
574
592
|
super(options);
|
|
@@ -611,6 +629,7 @@ class OneToOneOptionsBuilder extends ReferenceOptionsBuilder {
|
|
|
611
629
|
return new OneToOneOptionsBuilder({ ...this['~options'], deferMode });
|
|
612
630
|
}
|
|
613
631
|
}
|
|
632
|
+
exports.OneToOneOptionsBuilder = OneToOneOptionsBuilder;
|
|
614
633
|
function createPropertyBuilders(options) {
|
|
615
634
|
return Object.fromEntries(Object.entries(options).map(([key, value]) => [key, () => new PropertyOptionsBuilder({ type: value })]));
|
|
616
635
|
}
|
package/index.mjs
CHANGED
|
@@ -55,6 +55,7 @@ export const DriverException = mod.DriverException;
|
|
|
55
55
|
export const EagerProps = mod.EagerProps;
|
|
56
56
|
export const Embeddable = mod.Embeddable;
|
|
57
57
|
export const Embedded = mod.Embedded;
|
|
58
|
+
export const EmbeddedOptionsBuilder = mod.EmbeddedOptionsBuilder;
|
|
58
59
|
export const EnsureRequestContext = mod.EnsureRequestContext;
|
|
59
60
|
export const Entity = mod.Entity;
|
|
60
61
|
export const EntityAssigner = mod.EntityAssigner;
|
|
@@ -75,6 +76,7 @@ export const EntityTransformer = mod.EntityTransformer;
|
|
|
75
76
|
export const EntityValidator = mod.EntityValidator;
|
|
76
77
|
export const Enum = mod.Enum;
|
|
77
78
|
export const EnumArrayType = mod.EnumArrayType;
|
|
79
|
+
export const EnumOptionsBuilder = mod.EnumOptionsBuilder;
|
|
78
80
|
export const EnumType = mod.EnumType;
|
|
79
81
|
export const EventManager = mod.EventManager;
|
|
80
82
|
export const EventType = mod.EventType;
|
|
@@ -103,7 +105,9 @@ export const LoadStrategy = mod.LoadStrategy;
|
|
|
103
105
|
export const LockMode = mod.LockMode;
|
|
104
106
|
export const LockWaitTimeoutException = mod.LockWaitTimeoutException;
|
|
105
107
|
export const ManyToMany = mod.ManyToMany;
|
|
108
|
+
export const ManyToManyOptionsBuilder = mod.ManyToManyOptionsBuilder;
|
|
106
109
|
export const ManyToOne = mod.ManyToOne;
|
|
110
|
+
export const ManyToOneOptionsBuilder = mod.ManyToOneOptionsBuilder;
|
|
107
111
|
export const MediumIntType = mod.MediumIntType;
|
|
108
112
|
export const MemoryCacheAdapter = mod.MemoryCacheAdapter;
|
|
109
113
|
export const MetadataDiscovery = mod.MetadataDiscovery;
|
|
@@ -124,7 +128,10 @@ export const ObjectHydrator = mod.ObjectHydrator;
|
|
|
124
128
|
export const OnInit = mod.OnInit;
|
|
125
129
|
export const OnLoad = mod.OnLoad;
|
|
126
130
|
export const OneToMany = mod.OneToMany;
|
|
131
|
+
export const OneToManyOptionsBuilder = mod.OneToManyOptionsBuilder;
|
|
132
|
+
export const OneToManyOptionsBuilderOnlyMappedBy = mod.OneToManyOptionsBuilderOnlyMappedBy;
|
|
127
133
|
export const OneToOne = mod.OneToOne;
|
|
134
|
+
export const OneToOneOptionsBuilder = mod.OneToOneOptionsBuilder;
|
|
128
135
|
export const OptimisticLockError = mod.OptimisticLockError;
|
|
129
136
|
export const OptionalProps = mod.OptionalProps;
|
|
130
137
|
export const PlainObject = mod.PlainObject;
|
|
@@ -134,6 +141,7 @@ export const PopulatePath = mod.PopulatePath;
|
|
|
134
141
|
export const PrimaryKey = mod.PrimaryKey;
|
|
135
142
|
export const PrimaryKeyProp = mod.PrimaryKeyProp;
|
|
136
143
|
export const Property = mod.Property;
|
|
144
|
+
export const PropertyOptionsBuilder = mod.PropertyOptionsBuilder;
|
|
137
145
|
export const QueryFlag = mod.QueryFlag;
|
|
138
146
|
export const QueryHelper = mod.QueryHelper;
|
|
139
147
|
export const QueryOperator = mod.QueryOperator;
|
|
@@ -144,6 +152,7 @@ export const ReadOnlyException = mod.ReadOnlyException;
|
|
|
144
152
|
export const Ref = mod.Ref;
|
|
145
153
|
export const Reference = mod.Reference;
|
|
146
154
|
export const ReferenceKind = mod.ReferenceKind;
|
|
155
|
+
export const ReferenceOptionsBuilder = mod.ReferenceOptionsBuilder;
|
|
147
156
|
export const ReflectMetadataProvider = mod.ReflectMetadataProvider;
|
|
148
157
|
export const RequestContext = mod.RequestContext;
|
|
149
158
|
export const SCALAR_TYPES = mod.SCALAR_TYPES;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.4.17-dev.
|
|
3
|
+
"version": "6.4.17-dev.97",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.3.1",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.4.17-dev.
|
|
67
|
+
"mikro-orm": "6.4.17-dev.97",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|