@mikro-orm/decorators 7.0.2-dev.13 → 7.0.2-dev.15
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/es/Check.d.ts +1 -0
- package/es/Check.js +1 -0
- package/es/CreateRequestContext.d.ts +2 -0
- package/es/CreateRequestContext.js +2 -0
- package/es/Embeddable.d.ts +1 -0
- package/es/Embeddable.js +1 -0
- package/es/Embedded.d.ts +1 -0
- package/es/Embedded.js +1 -0
- package/es/Entity.d.ts +1 -0
- package/es/Entity.js +1 -0
- package/es/Enum.d.ts +1 -0
- package/es/Enum.js +1 -0
- package/es/Filter.d.ts +1 -0
- package/es/Filter.js +1 -0
- package/es/Formula.d.ts +1 -0
- package/es/Formula.js +1 -0
- package/es/Indexed.d.ts +2 -0
- package/es/Indexed.js +2 -0
- package/es/ManyToMany.d.ts +1 -0
- package/es/ManyToMany.js +1 -0
- package/es/ManyToOne.d.ts +1 -0
- package/es/ManyToOne.js +1 -0
- package/es/OneToMany.d.ts +1 -0
- package/es/OneToOne.d.ts +1 -0
- package/es/OneToOne.js +1 -0
- package/es/PrimaryKey.d.ts +2 -0
- package/es/PrimaryKey.js +2 -0
- package/es/Property.d.ts +1 -0
- package/es/Property.js +1 -0
- package/es/hooks.d.ts +8 -0
- package/es/hooks.js +8 -0
- package/legacy/Check.d.ts +1 -0
- package/legacy/Check.js +1 -0
- package/legacy/CreateRequestContext.d.ts +2 -0
- package/legacy/CreateRequestContext.js +2 -0
- package/legacy/Embeddable.d.ts +1 -0
- package/legacy/Embeddable.js +1 -0
- package/legacy/Embedded.d.ts +1 -0
- package/legacy/Embedded.js +1 -0
- package/legacy/Entity.d.ts +1 -0
- package/legacy/Entity.js +1 -0
- package/legacy/Enum.d.ts +1 -0
- package/legacy/Enum.js +1 -0
- package/legacy/Filter.d.ts +1 -0
- package/legacy/Filter.js +1 -0
- package/legacy/Formula.d.ts +1 -0
- package/legacy/Formula.js +1 -0
- package/legacy/Indexed.d.ts +2 -0
- package/legacy/Indexed.js +2 -0
- package/legacy/ManyToMany.d.ts +1 -0
- package/legacy/ManyToOne.d.ts +1 -0
- package/legacy/OneToMany.d.ts +1 -0
- package/legacy/OneToOne.d.ts +1 -0
- package/legacy/PrimaryKey.d.ts +2 -0
- package/legacy/PrimaryKey.js +2 -0
- package/legacy/Property.d.ts +1 -0
- package/legacy/Property.js +1 -0
- package/legacy/ReflectMetadataProvider.d.ts +1 -0
- package/legacy/ReflectMetadataProvider.js +1 -0
- package/legacy/hooks.d.ts +8 -0
- package/legacy/hooks.js +8 -0
- package/package.json +2 -2
- package/utils.d.ts +1 -0
- package/utils.js +1 -0
package/es/Check.d.ts
CHANGED
package/es/Check.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type ContextProvider } from '../utils.js';
|
|
2
|
+
/** Wraps an async method in a new RequestContext, forking the EntityManager (TC39 decorator). */
|
|
2
3
|
export declare function CreateRequestContext<T extends object>(contextProvider?: ContextProvider<T>, respectExistingContext?: boolean): (value: (this: T, ...args: any) => any, context: ClassMethodDecoratorContext<T>) => (this: T, ...args: any[]) => Promise<any>;
|
|
4
|
+
/** Like `@CreateRequestContext`, but reuses an existing RequestContext if one is available (TC39 decorator). */
|
|
3
5
|
export declare function EnsureRequestContext<T extends object>(context?: ContextProvider<T>): (value: (this: T, ...args: any) => any, context: ClassMethodDecoratorContext<T>) => (this: T, ...args: any[]) => Promise<any>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RequestContext, TransactionContext } from '@mikro-orm/core';
|
|
2
2
|
import { resolveContextProvider } from '../utils.js';
|
|
3
|
+
/** Wraps an async method in a new RequestContext, forking the EntityManager (TC39 decorator). */
|
|
3
4
|
export function CreateRequestContext(contextProvider, respectExistingContext = false) {
|
|
4
5
|
return function (value, context) {
|
|
5
6
|
const name = respectExistingContext ? 'EnsureRequestContext' : 'CreateRequestContext';
|
|
@@ -24,6 +25,7 @@ export function CreateRequestContext(contextProvider, respectExistingContext = f
|
|
|
24
25
|
};
|
|
25
26
|
};
|
|
26
27
|
}
|
|
28
|
+
/** Like `@CreateRequestContext`, but reuses an existing RequestContext if one is available (TC39 decorator). */
|
|
27
29
|
export function EnsureRequestContext(context) {
|
|
28
30
|
return CreateRequestContext(context, true);
|
|
29
31
|
}
|
package/es/Embeddable.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type Constructor, type EmbeddableOptions, type EntityClass } from '@mikro-orm/core';
|
|
2
|
+
/** Marks a class as an embeddable type (TC39 decorator). */
|
|
2
3
|
export declare function Embeddable<Owner extends EntityClass<unknown> & Constructor>(options?: EmbeddableOptions<Owner>): (target: Owner, context: ClassDecoratorContext<Owner>) => Owner;
|
package/es/Embeddable.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Utils } from '@mikro-orm/core';
|
|
2
2
|
import { getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Marks a class as an embeddable type (TC39 decorator). */
|
|
3
4
|
export function Embeddable(options = {}) {
|
|
4
5
|
return function (target, context) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target);
|
package/es/Embedded.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type EntityName, type EmbeddedOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines an embedded property on an entity (TC39 decorator). */
|
|
2
3
|
export declare function Embedded<Owner extends object, Target>(type?: EmbeddedOptions<Owner, Target> | (() => EntityName<Target> | EntityName[]), options?: EmbeddedOptions<Owner, Target>): (value: unknown, context: ClassFieldDecoratorContext<Owner>) => void;
|
package/es/Embedded.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext } from '../utils.js';
|
|
3
|
+
/** Defines an embedded property on an entity (TC39 decorator). */
|
|
3
4
|
export function Embedded(type = {}, options = {}) {
|
|
4
5
|
return function (value, context) {
|
|
5
6
|
const meta = prepareMetadataContext(context, ReferenceKind.EMBEDDED);
|
package/es/Entity.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type Constructor, type EntityOptions, type EntityClass } from '@mikro-orm/core';
|
|
2
|
+
/** Marks a class as a MikroORM entity (TC39 decorator). */
|
|
2
3
|
export declare function Entity<Owner extends EntityClass<unknown> & Constructor>(options?: EntityOptions<Owner>): (target: Owner, context: ClassDecoratorContext<Owner>) => void;
|
package/es/Entity.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Utils } from '@mikro-orm/core';
|
|
2
2
|
import { getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Marks a class as a MikroORM entity (TC39 decorator). */
|
|
3
4
|
export function Entity(options = {}) {
|
|
4
5
|
return function (target, context) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target);
|
package/es/Enum.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type EnumOptions, type AnyEntity, type Dictionary } from '@mikro-orm/core';
|
|
2
|
+
/** Defines an enum property on an entity (TC39 decorator). */
|
|
2
3
|
export declare function Enum<Owner extends object>(options?: EnumOptions<AnyEntity> | (() => Dictionary)): (target: unknown, context: ClassFieldDecoratorContext<Owner>) => void;
|
package/es/Enum.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext } from '../utils.js';
|
|
3
|
+
/** Defines an enum property on an entity (TC39 decorator). */
|
|
3
4
|
export function Enum(options = {}) {
|
|
4
5
|
return function (target, context) {
|
|
5
6
|
const meta = prepareMetadataContext(context);
|
package/es/Filter.d.ts
CHANGED
package/es/Filter.js
CHANGED
package/es/Formula.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type FormulaCallback, type PropertyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a computed SQL formula property on an entity (TC39 decorator). */
|
|
2
3
|
export declare function Formula<Owner extends object>(formula: string | FormulaCallback<Owner>, options?: PropertyOptions<Owner>): (value: unknown, context: ClassFieldDecoratorContext<Owner>) => void;
|
package/es/Formula.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext } from '../utils.js';
|
|
3
|
+
/** Defines a computed SQL formula property on an entity (TC39 decorator). */
|
|
3
4
|
export function Formula(formula, options = {}) {
|
|
4
5
|
return function (value, context) {
|
|
5
6
|
const meta = prepareMetadataContext(context);
|
package/es/Indexed.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type IndexOptions, type UniqueOptions, type Constructor } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a database index on a property or entity class (TC39 decorator). */
|
|
2
3
|
export declare function Index<T extends object, H extends string>(options?: IndexOptions<T, H>): (value: unknown, context: ClassDecoratorContext<T & Constructor> | ClassFieldDecoratorContext<T>) => any;
|
|
4
|
+
/** Defines a unique constraint on a property or entity class (TC39 decorator). */
|
|
3
5
|
export declare function Unique<T extends object, H extends string>(options?: UniqueOptions<T, H>): (value: unknown, context: ClassDecoratorContext<T & Constructor> | ClassFieldDecoratorContext<T>) => any;
|
package/es/Indexed.js
CHANGED
|
@@ -9,9 +9,11 @@ function createDecorator(options, unique) {
|
|
|
9
9
|
meta[key].push(options);
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
+
/** Defines a database index on a property or entity class (TC39 decorator). */
|
|
12
13
|
export function Index(options = {}) {
|
|
13
14
|
return createDecorator(options, false);
|
|
14
15
|
}
|
|
16
|
+
/** Defines a unique constraint on a property or entity class (TC39 decorator). */
|
|
15
17
|
export function Unique(options = {}) {
|
|
16
18
|
return createDecorator(options, true);
|
|
17
19
|
}
|
package/es/ManyToMany.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type EntityName, type ManyToManyOptions, type Collection } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a many-to-many relationship (TC39 decorator). */
|
|
2
3
|
export declare function ManyToMany<Target extends object, Owner extends object>(entity?: ManyToManyOptions<Owner, Target> | string | (() => EntityName<Target>), mappedBy?: (string & keyof Target) | ((e: Target) => any), options?: Partial<ManyToManyOptions<Owner, Target>>): (_: unknown, context: ClassFieldDecoratorContext<Owner, Collection<Target> | undefined>) => void;
|
package/es/ManyToMany.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext, processDecoratorParameters } from '../utils.js';
|
|
3
|
+
/** Defines a many-to-many relationship (TC39 decorator). */
|
|
3
4
|
export function ManyToMany(entity, mappedBy, options = {}) {
|
|
4
5
|
return function (_, context) {
|
|
5
6
|
const meta = prepareMetadataContext(context, ReferenceKind.MANY_TO_MANY);
|
package/es/ManyToOne.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type ManyToOneOptions, type EntityName, type Ref } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a many-to-one relationship (TC39 decorator). */
|
|
2
3
|
export declare function ManyToOne<Target extends object, Owner extends object>(entity?: ManyToOneOptions<Owner, Target> | ((e?: Owner) => EntityName<Target> | EntityName[]), options?: Partial<ManyToOneOptions<Owner, Target>>): (_: unknown, context: ClassFieldDecoratorContext<Owner, Target | undefined | null | Ref<Target>>) => void;
|
package/es/ManyToOne.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext, processDecoratorParameters } from '../utils.js';
|
|
3
|
+
/** Defines a many-to-one relationship (TC39 decorator). */
|
|
3
4
|
export function ManyToOne(entity = {}, options = {}) {
|
|
4
5
|
return function (_, context) {
|
|
5
6
|
const meta = prepareMetadataContext(context, ReferenceKind.MANY_TO_ONE);
|
package/es/OneToMany.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type Collection, type EntityName, type OneToManyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a one-to-many relationship (TC39 decorator). */
|
|
2
3
|
export declare function OneToMany<Target extends object, Owner extends object>(entity: string | ((e?: Owner) => EntityName<Target>), mappedBy: (string & keyof Target) | ((e: Target) => any), options?: Partial<OneToManyOptions<Owner, Target>>): (value: unknown, context: ClassFieldDecoratorContext<Owner, Collection<Target> | undefined>) => void;
|
|
3
4
|
export declare function OneToMany<Target extends object, Owner extends object>(options: OneToManyOptions<Owner, Target>): (value: unknown, context: ClassFieldDecoratorContext<Owner, Collection<Target> | undefined>) => void;
|
package/es/OneToOne.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type EntityName, type OneToOneOptions, type Ref } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a one-to-one relationship (TC39 decorator). */
|
|
2
3
|
export declare function OneToOne<Target extends object, Owner extends object>(entity?: OneToOneOptions<Owner, Target> | string | ((e: Owner) => EntityName<Target> | EntityName[]), mappedByOrOptions?: (string & keyof Target) | ((e: Target) => any) | Partial<OneToOneOptions<Owner, Target>>, options?: Partial<OneToOneOptions<Owner, Target>>): (_: unknown, context: ClassFieldDecoratorContext<Owner, Target | Ref<Target> | null | undefined>) => void;
|
package/es/OneToOne.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext, processDecoratorParameters } from '../utils.js';
|
|
3
|
+
/** Defines a one-to-one relationship (TC39 decorator). */
|
|
3
4
|
export function OneToOne(entity, mappedByOrOptions, options = {}) {
|
|
4
5
|
const mappedBy = typeof mappedByOrOptions === 'object' ? mappedByOrOptions.mappedBy : mappedByOrOptions;
|
|
5
6
|
options = typeof mappedByOrOptions === 'object' ? { ...mappedByOrOptions, ...options } : options;
|
package/es/PrimaryKey.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type PrimaryKeyOptions, type SerializedPrimaryKeyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Marks a property as the primary key of an entity (TC39 decorator). */
|
|
2
3
|
export declare function PrimaryKey<T extends object>(options?: PrimaryKeyOptions<T>): (value: unknown, context: ClassFieldDecoratorContext<T>) => void;
|
|
4
|
+
/** Marks a property as the serialized form of the primary key, e.g. for MongoDB ObjectId (TC39 decorator). */
|
|
3
5
|
export declare function SerializedPrimaryKey<T extends object>(options?: SerializedPrimaryKeyOptions<T>): (value: unknown, context: ClassFieldDecoratorContext<T>) => void;
|
package/es/PrimaryKey.js
CHANGED
|
@@ -12,9 +12,11 @@ function createDecorator(options, serialized) {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
+
/** Marks a property as the primary key of an entity (TC39 decorator). */
|
|
15
16
|
export function PrimaryKey(options = {}) {
|
|
16
17
|
return createDecorator(options, false);
|
|
17
18
|
}
|
|
19
|
+
/** Marks a property as the serialized form of the primary key, e.g. for MongoDB ObjectId (TC39 decorator). */
|
|
18
20
|
export function SerializedPrimaryKey(options = {}) {
|
|
19
21
|
return createDecorator(options, true);
|
|
20
22
|
}
|
package/es/Property.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type PropertyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a scalar property on an entity (TC39 decorator). */
|
|
2
3
|
export declare function Property<T extends object>(options?: PropertyOptions<T>): (value: unknown, context: ClassFieldDecoratorContext<T> | ClassGetterDecoratorContext<T> | ClassSetterDecoratorContext<T> | ClassAccessorDecoratorContext<T> | ClassMethodDecoratorContext<T>) => void;
|
package/es/Property.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, Utils } from '@mikro-orm/core';
|
|
2
2
|
import { prepareMetadataContext } from '../utils.js';
|
|
3
|
+
/** Defines a scalar property on an entity (TC39 decorator). */
|
|
3
4
|
export function Property(options = {}) {
|
|
4
5
|
return function (value, context) {
|
|
5
6
|
const meta = prepareMetadataContext(context, ReferenceKind.SCALAR);
|
package/es/hooks.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
/** Called before a new entity is persisted to the database (TC39 decorator). */
|
|
1
2
|
export declare function BeforeCreate(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
3
|
+
/** Called after a new entity has been persisted to the database (TC39 decorator). */
|
|
2
4
|
export declare function AfterCreate(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
5
|
+
/** Called before an existing entity is updated in the database (TC39 decorator). */
|
|
3
6
|
export declare function BeforeUpdate(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
7
|
+
/** Called after an existing entity has been updated in the database (TC39 decorator). */
|
|
4
8
|
export declare function AfterUpdate(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
9
|
+
/** Called before an entity is upserted (TC39 decorator). */
|
|
5
10
|
export declare function BeforeUpsert(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
11
|
+
/** Called after an entity has been upserted (TC39 decorator). */
|
|
6
12
|
export declare function AfterUpsert(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
13
|
+
/** Called when an entity is instantiated by the EntityManager (TC39 decorator). */
|
|
7
14
|
export declare function OnInit(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
15
|
+
/** Called after an entity is loaded from the database (TC39 decorator). */
|
|
8
16
|
export declare function OnLoad(): (value: (...args: any[]) => unknown, context: ClassMethodDecoratorContext) => void;
|
|
9
17
|
/**
|
|
10
18
|
* Called before deleting entity, but only when providing initialized entity to EM#remove()
|
package/es/hooks.js
CHANGED
|
@@ -7,27 +7,35 @@ function hook(type) {
|
|
|
7
7
|
meta.hooks[type].push(value);
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
/** Called before a new entity is persisted to the database (TC39 decorator). */
|
|
10
11
|
export function BeforeCreate() {
|
|
11
12
|
return hook(EventType.beforeCreate);
|
|
12
13
|
}
|
|
14
|
+
/** Called after a new entity has been persisted to the database (TC39 decorator). */
|
|
13
15
|
export function AfterCreate() {
|
|
14
16
|
return hook(EventType.afterCreate);
|
|
15
17
|
}
|
|
18
|
+
/** Called before an existing entity is updated in the database (TC39 decorator). */
|
|
16
19
|
export function BeforeUpdate() {
|
|
17
20
|
return hook(EventType.beforeUpdate);
|
|
18
21
|
}
|
|
22
|
+
/** Called after an existing entity has been updated in the database (TC39 decorator). */
|
|
19
23
|
export function AfterUpdate() {
|
|
20
24
|
return hook(EventType.afterUpdate);
|
|
21
25
|
}
|
|
26
|
+
/** Called before an entity is upserted (TC39 decorator). */
|
|
22
27
|
export function BeforeUpsert() {
|
|
23
28
|
return hook(EventType.beforeUpsert);
|
|
24
29
|
}
|
|
30
|
+
/** Called after an entity has been upserted (TC39 decorator). */
|
|
25
31
|
export function AfterUpsert() {
|
|
26
32
|
return hook(EventType.afterUpsert);
|
|
27
33
|
}
|
|
34
|
+
/** Called when an entity is instantiated by the EntityManager (TC39 decorator). */
|
|
28
35
|
export function OnInit() {
|
|
29
36
|
return hook(EventType.onInit);
|
|
30
37
|
}
|
|
38
|
+
/** Called after an entity is loaded from the database (TC39 decorator). */
|
|
31
39
|
export function OnLoad() {
|
|
32
40
|
return hook(EventType.onLoad);
|
|
33
41
|
}
|
package/legacy/Check.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type CheckConstraint, type EntityClass } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a database check constraint on a property or entity class (legacy TypeScript decorator). */
|
|
2
3
|
export declare function Check<T>(options: CheckConstraint<T>): (target: T, propertyName?: T extends EntityClass<unknown> ? undefined : keyof T) => any;
|
package/legacy/Check.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getMetadataFromDecorator } from '../utils.js';
|
|
2
|
+
/** Defines a database check constraint on a property or entity class (legacy TypeScript decorator). */
|
|
2
3
|
export function Check(options) {
|
|
3
4
|
return function (target, propertyName) {
|
|
4
5
|
const meta = getMetadataFromDecorator((propertyName ? target.constructor : target));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type ContextProvider } from '../utils.js';
|
|
2
|
+
/** Wraps an async method in a new RequestContext, forking the EntityManager (legacy TypeScript decorator). */
|
|
2
3
|
export declare function CreateRequestContext<T extends object>(context?: ContextProvider<T>, respectExistingContext?: boolean): MethodDecorator;
|
|
4
|
+
/** Like `@CreateRequestContext`, but reuses an existing RequestContext if one is available (legacy TypeScript decorator). */
|
|
3
5
|
export declare function EnsureRequestContext<T extends object>(context?: ContextProvider<T>): MethodDecorator;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RequestContext, TransactionContext } from '@mikro-orm/core';
|
|
2
2
|
import { resolveContextProvider } from '../utils.js';
|
|
3
|
+
/** Wraps an async method in a new RequestContext, forking the EntityManager (legacy TypeScript decorator). */
|
|
3
4
|
export function CreateRequestContext(context, respectExistingContext = false) {
|
|
4
5
|
return function (target, propertyKey, descriptor) {
|
|
5
6
|
const originalMethod = descriptor.value;
|
|
@@ -26,6 +27,7 @@ export function CreateRequestContext(context, respectExistingContext = false) {
|
|
|
26
27
|
return descriptor;
|
|
27
28
|
};
|
|
28
29
|
}
|
|
30
|
+
/** Like `@CreateRequestContext`, but reuses an existing RequestContext if one is available (legacy TypeScript decorator). */
|
|
29
31
|
export function EnsureRequestContext(context) {
|
|
30
32
|
return CreateRequestContext(context, true);
|
|
31
33
|
}
|
package/legacy/Embeddable.d.ts
CHANGED
package/legacy/Embeddable.js
CHANGED
package/legacy/Embedded.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type AnyEntity, type EntityName, type EmbeddedOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines an embedded property on an entity (legacy TypeScript decorator). */
|
|
2
3
|
export declare function Embedded<Owner extends object, Target>(type?: EmbeddedOptions<Owner, Target> | (() => EntityName<Target> | EntityName[]), options?: EmbeddedOptions<Owner, Target>): (target: AnyEntity, propertyName: string) => void;
|
package/legacy/Embedded.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { validateSingleDecorator, getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Defines an embedded property on an entity (legacy TypeScript decorator). */
|
|
3
4
|
export function Embedded(type = {}, options = {}) {
|
|
4
5
|
return function (target, propertyName) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target.constructor);
|
package/legacy/Entity.d.ts
CHANGED
package/legacy/Entity.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Utils } from '@mikro-orm/core';
|
|
2
2
|
import { getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Marks a class as a MikroORM entity (legacy TypeScript decorator). */
|
|
3
4
|
export function Entity(options = {}) {
|
|
4
5
|
return function (target) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target);
|
package/legacy/Enum.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type EnumOptions, type AnyEntity, type Dictionary } from '@mikro-orm/core';
|
|
2
|
+
/** Defines an enum property on an entity (legacy TypeScript decorator). */
|
|
2
3
|
export declare function Enum<T extends object>(options?: EnumOptions<AnyEntity> | (() => Dictionary)): (target: T, propertyName: string) => void;
|
package/legacy/Enum.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, } from '@mikro-orm/core';
|
|
2
2
|
import { getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Defines an enum property on an entity (legacy TypeScript decorator). */
|
|
3
4
|
export function Enum(options = {}) {
|
|
4
5
|
return function (target, propertyName) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target.constructor);
|
package/legacy/Filter.d.ts
CHANGED
package/legacy/Filter.js
CHANGED
package/legacy/Formula.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { type FormulaCallback, type PropertyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a computed SQL formula property on an entity (legacy TypeScript decorator). */
|
|
2
3
|
export declare function Formula<T extends object>(formula: string | FormulaCallback<T>, options?: PropertyOptions<T>): (target: T, propertyName: string) => void;
|
package/legacy/Formula.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ReferenceKind, } from '@mikro-orm/core';
|
|
2
2
|
import { getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Defines a computed SQL formula property on an entity (legacy TypeScript decorator). */
|
|
3
4
|
export function Formula(formula, options = {}) {
|
|
4
5
|
return function (target, propertyName) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target.constructor);
|
package/legacy/Indexed.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type EntityClass, type IndexOptions, type UniqueOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a database index on a property or entity class (legacy TypeScript decorator). */
|
|
2
3
|
export declare function Index<T extends object, H extends string>(options?: IndexOptions<T, H>): (target: T, propertyName?: T extends EntityClass<unknown> ? undefined : keyof T) => any;
|
|
4
|
+
/** Defines a unique constraint on a property or entity class (legacy TypeScript decorator). */
|
|
3
5
|
export declare function Unique<T extends object, H extends string>(options?: UniqueOptions<T, H>): (target: T, propertyName?: T extends EntityClass<unknown> ? undefined : keyof T) => any;
|
package/legacy/Indexed.js
CHANGED
|
@@ -11,9 +11,11 @@ function createDecorator(options, unique) {
|
|
|
11
11
|
return undefined;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
/** Defines a database index on a property or entity class (legacy TypeScript decorator). */
|
|
14
15
|
export function Index(options = {}) {
|
|
15
16
|
return createDecorator(options, false);
|
|
16
17
|
}
|
|
18
|
+
/** Defines a unique constraint on a property or entity class (legacy TypeScript decorator). */
|
|
17
19
|
export function Unique(options = {}) {
|
|
18
20
|
return createDecorator(options, true);
|
|
19
21
|
}
|
package/legacy/ManyToMany.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type EntityName, type ManyToManyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a many-to-many relationship (legacy TypeScript decorator). */
|
|
2
3
|
export declare function ManyToMany<Target extends object, Owner extends object>(entity: () => EntityName<Target>, mappedBy?: (string & keyof Target) | ((e: Target) => any), options?: Partial<ManyToManyOptions<Owner, Target>>): (target: Owner, propertyName: keyof Owner) => void;
|
|
3
4
|
export declare function ManyToMany<Target extends object, Owner extends object>(entity: string, options?: any): never;
|
|
4
5
|
export declare function ManyToMany<Target extends object, Owner extends object>(options?: ManyToManyOptions<Owner, Target>): (target: Owner, propertyName: keyof Owner) => void;
|
package/legacy/ManyToOne.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ManyToOneOptions, type EntityName } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a many-to-one relationship (legacy TypeScript decorator). */
|
|
2
3
|
export declare function ManyToOne<Target extends object, Owner extends object>(entity: (e?: any) => EntityName<Target> | EntityName[], options?: Partial<ManyToOneOptions<Owner, Target>>): (target: Owner, propertyName: string) => void;
|
|
3
4
|
export declare function ManyToOne<Target extends object, Owner extends object>(entity: string, options?: any): never;
|
|
4
5
|
export declare function ManyToOne<Target extends object, Owner extends object>(options?: ManyToOneOptions<Owner, Target>): (target: Owner, propertyName: string) => void;
|
package/legacy/OneToMany.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type EntityName, type OneToManyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a one-to-many relationship (legacy TypeScript decorator). */
|
|
2
3
|
export declare function OneToMany<Target extends object, Owner extends object>(entity: (e?: any) => EntityName<Target>, mappedBy: (string & keyof Target) | ((e: Target) => any), options?: Partial<OneToManyOptions<Owner, Target>>): (target: Owner, propertyName: string) => void;
|
|
3
4
|
export declare function OneToMany<Target extends object, Owner extends object>(options: OneToManyOptions<Owner, Target>): (target: Owner, propertyName: string) => void;
|
package/legacy/OneToOne.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { type EntityName, type OneToOneOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Defines a one-to-one relationship (legacy TypeScript decorator). */
|
|
2
3
|
export declare function OneToOne<Target, Owner>(entity: (e: Owner) => EntityName<Target> | EntityName[], mappedByOrOptions?: (string & keyof Target) | ((e: Target) => any) | Partial<OneToOneOptions<Owner, Target>>, options?: Partial<OneToOneOptions<Owner, Target>>): (target: Owner, propertyName: string) => void;
|
|
3
4
|
export declare function OneToOne<Target, Owner>(entity?: OneToOneOptions<Owner, Target>): (target: Owner, propertyName: string) => void;
|
package/legacy/PrimaryKey.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type PrimaryKeyOptions, type SerializedPrimaryKeyOptions } from '@mikro-orm/core';
|
|
2
|
+
/** Marks a property as the primary key of an entity (legacy TypeScript decorator). */
|
|
2
3
|
export declare function PrimaryKey<T extends object>(options?: PrimaryKeyOptions<T>): (target: T, propertyName: string) => void;
|
|
4
|
+
/** Marks a property as the serialized form of the primary key, e.g. for MongoDB ObjectId (legacy TypeScript decorator). */
|
|
3
5
|
export declare function SerializedPrimaryKey<T extends object>(options?: SerializedPrimaryKeyOptions<T>): (target: T, propertyName: string) => void;
|
package/legacy/PrimaryKey.js
CHANGED
|
@@ -13,9 +13,11 @@ function createDecorator(options, serialized) {
|
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
+
/** Marks a property as the primary key of an entity (legacy TypeScript decorator). */
|
|
16
17
|
export function PrimaryKey(options = {}) {
|
|
17
18
|
return createDecorator(options, false);
|
|
18
19
|
}
|
|
20
|
+
/** Marks a property as the serialized form of the primary key, e.g. for MongoDB ObjectId (legacy TypeScript decorator). */
|
|
19
21
|
export function SerializedPrimaryKey(options = {}) {
|
|
20
22
|
return createDecorator(options, true);
|
|
21
23
|
}
|
package/legacy/Property.d.ts
CHANGED
package/legacy/Property.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Utils, ReferenceKind } from '@mikro-orm/core';
|
|
2
2
|
import { validateSingleDecorator, getMetadataFromDecorator } from '../utils.js';
|
|
3
|
+
/** Defines a scalar property on an entity (legacy TypeScript decorator). */
|
|
3
4
|
export function Property(options = {}) {
|
|
4
5
|
return function (target, propertyName) {
|
|
5
6
|
const meta = getMetadataFromDecorator(target.constructor);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { type EntityMetadata, type EntityProperty, MetadataProvider } from '@mikro-orm/core';
|
|
3
|
+
/** Metadata provider that uses `reflect-metadata` to infer property types from TypeScript's emitted design:type metadata. */
|
|
3
4
|
export declare class ReflectMetadataProvider extends MetadataProvider {
|
|
4
5
|
loadEntityMetadata(meta: EntityMetadata): void;
|
|
5
6
|
protected initPropertyType(meta: EntityMetadata, prop: EntityProperty): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { EntitySchema, MetadataProvider, ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
3
|
+
/** Metadata provider that uses `reflect-metadata` to infer property types from TypeScript's emitted design:type metadata. */
|
|
3
4
|
export class ReflectMetadataProvider extends MetadataProvider {
|
|
4
5
|
loadEntityMetadata(meta) {
|
|
5
6
|
// load types and column names
|
package/legacy/hooks.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
/** Called before a new entity is persisted to the database (legacy TypeScript decorator). */
|
|
1
2
|
export declare function BeforeCreate(): (target: any, method: string) => void;
|
|
3
|
+
/** Called after a new entity has been persisted to the database (legacy TypeScript decorator). */
|
|
2
4
|
export declare function AfterCreate(): (target: any, method: string) => void;
|
|
5
|
+
/** Called before an existing entity is updated in the database (legacy TypeScript decorator). */
|
|
3
6
|
export declare function BeforeUpdate(): (target: any, method: string) => void;
|
|
7
|
+
/** Called after an existing entity has been updated in the database (legacy TypeScript decorator). */
|
|
4
8
|
export declare function AfterUpdate(): (target: any, method: string) => void;
|
|
9
|
+
/** Called before an entity is upserted (legacy TypeScript decorator). */
|
|
5
10
|
export declare function BeforeUpsert(): (target: any, method: string) => void;
|
|
11
|
+
/** Called after an entity has been upserted (legacy TypeScript decorator). */
|
|
6
12
|
export declare function AfterUpsert(): (target: any, method: string) => void;
|
|
13
|
+
/** Called when an entity is instantiated by the EntityManager (legacy TypeScript decorator). */
|
|
7
14
|
export declare function OnInit(): (target: any, method: string) => void;
|
|
15
|
+
/** Called after an entity is loaded from the database (legacy TypeScript decorator). */
|
|
8
16
|
export declare function OnLoad(): (target: any, method: string) => void;
|
|
9
17
|
/**
|
|
10
18
|
* Called before deleting entity, but only when providing initialized entity to EM#remove()
|
package/legacy/hooks.js
CHANGED
|
@@ -7,27 +7,35 @@ function hook(type) {
|
|
|
7
7
|
meta.hooks[type].push(method);
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
+
/** Called before a new entity is persisted to the database (legacy TypeScript decorator). */
|
|
10
11
|
export function BeforeCreate() {
|
|
11
12
|
return hook(EventType.beforeCreate);
|
|
12
13
|
}
|
|
14
|
+
/** Called after a new entity has been persisted to the database (legacy TypeScript decorator). */
|
|
13
15
|
export function AfterCreate() {
|
|
14
16
|
return hook(EventType.afterCreate);
|
|
15
17
|
}
|
|
18
|
+
/** Called before an existing entity is updated in the database (legacy TypeScript decorator). */
|
|
16
19
|
export function BeforeUpdate() {
|
|
17
20
|
return hook(EventType.beforeUpdate);
|
|
18
21
|
}
|
|
22
|
+
/** Called after an existing entity has been updated in the database (legacy TypeScript decorator). */
|
|
19
23
|
export function AfterUpdate() {
|
|
20
24
|
return hook(EventType.afterUpdate);
|
|
21
25
|
}
|
|
26
|
+
/** Called before an entity is upserted (legacy TypeScript decorator). */
|
|
22
27
|
export function BeforeUpsert() {
|
|
23
28
|
return hook(EventType.beforeUpsert);
|
|
24
29
|
}
|
|
30
|
+
/** Called after an entity has been upserted (legacy TypeScript decorator). */
|
|
25
31
|
export function AfterUpsert() {
|
|
26
32
|
return hook(EventType.afterUpsert);
|
|
27
33
|
}
|
|
34
|
+
/** Called when an entity is instantiated by the EntityManager (legacy TypeScript decorator). */
|
|
28
35
|
export function OnInit() {
|
|
29
36
|
return hook(EventType.onInit);
|
|
30
37
|
}
|
|
38
|
+
/** Called after an entity is loaded from the database (legacy TypeScript decorator). */
|
|
31
39
|
export function OnLoad() {
|
|
32
40
|
return hook(EventType.onLoad);
|
|
33
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/decorators",
|
|
3
|
-
"version": "7.0.2-dev.
|
|
3
|
+
"version": "7.0.2-dev.15",
|
|
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
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@mikro-orm/core": "^7.0.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@mikro-orm/core": "7.0.2-dev.
|
|
55
|
+
"@mikro-orm/core": "7.0.2-dev.15",
|
|
56
56
|
"reflect-metadata": "^0.1.0 || ^0.2.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependenciesMeta": {
|
package/utils.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare function prepareMetadataContext<T>(context: ClassFieldDecoratorCo
|
|
|
39
39
|
* Analyzes stack trace of error created inside the function call.
|
|
40
40
|
*/
|
|
41
41
|
export declare function lookupPathFromDecorator(name: string, stack?: string[]): string;
|
|
42
|
+
/** Retrieves or creates the metadata object for a decorated entity class. */
|
|
42
43
|
export declare function getMetadataFromDecorator<T = any>(target: T & Dictionary & {
|
|
43
44
|
[MetadataStorage.PATH_SYMBOL]?: string;
|
|
44
45
|
}): EntityMetadata<T>;
|
package/utils.js
CHANGED
|
@@ -114,6 +114,7 @@ export function lookupPathFromDecorator(name, stack) {
|
|
|
114
114
|
return name;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
+
/** Retrieves or creates the metadata object for a decorated entity class. */
|
|
117
118
|
export function getMetadataFromDecorator(target) {
|
|
118
119
|
if (!Object.hasOwn(target, MetadataStorage.PATH_SYMBOL)) {
|
|
119
120
|
Object.defineProperty(target, MetadataStorage.PATH_SYMBOL, {
|