uql-orm 0.24.4 → 0.24.5
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/type/entity.d.ts +22 -8
- package/package.json +2 -2
package/dist/type/entity.d.ts
CHANGED
|
@@ -347,10 +347,19 @@ export type RelationOptionsFor<V> = Omit<RelationOptions<RelationTarget<V>>, 'en
|
|
|
347
347
|
export type MethodKey<E> = {
|
|
348
348
|
readonly [K in keyof E]-?: NonNullable<E[K]> extends (...args: never[]) => unknown ? K : never;
|
|
349
349
|
}[Key<E>];
|
|
350
|
+
/**
|
|
351
|
+
* A deferred reference to an entity class, e.g. `() => Company`.
|
|
352
|
+
*
|
|
353
|
+
* A getter rather than the class itself because decorator expressions are evaluated while the class is
|
|
354
|
+
* being defined, before its binding is initialized, so naming the class directly is a `ReferenceError`
|
|
355
|
+
* for a self-reference and for whichever side of a circular import is evaluated first - the two shapes an
|
|
356
|
+
* entity graph almost always has. Nothing about the standard decorator spec changes that; it only removed
|
|
357
|
+
* the reflected `design:type` that used to make `entity` optional.
|
|
358
|
+
*/
|
|
350
359
|
export type EntityGetter<E = any> = () => Type<E>;
|
|
351
360
|
export type CascadeType = 'persist' | 'delete';
|
|
352
361
|
export type RelationOptions<E = any> = {
|
|
353
|
-
entity
|
|
362
|
+
entity: EntityGetter<E>;
|
|
354
363
|
cardinality: RelationCardinality;
|
|
355
364
|
readonly cascade?: boolean | CascadeType;
|
|
356
365
|
mappedBy?: RelationMappedBy<E>;
|
|
@@ -362,12 +371,17 @@ export type RelationOptions<E = any> = {
|
|
|
362
371
|
references?: RelationReferences;
|
|
363
372
|
};
|
|
364
373
|
/**
|
|
365
|
-
* A relation once `getMeta` has resolved it: `
|
|
366
|
-
*
|
|
367
|
-
*
|
|
374
|
+
* A relation once `getMeta` has resolved it: `references` is filled in and `mappedBy` is the key its
|
|
375
|
+
* callback named. Consumers read this shape rather than {@link RelationOptions}, so they need no
|
|
376
|
+
* assertions - `fillRelations` establishes the invariant once, and throws where it cannot.
|
|
377
|
+
*
|
|
378
|
+
* `entity` and `through` stay {@link EntityGetter}s. Resolution could call them once and store the class,
|
|
379
|
+
* but only by keeping the authored relations in a second map: it reads them *across* entities, and a
|
|
380
|
+
* circular import can leave the entity being read mid-resolution, where telling "no such relation" apart
|
|
381
|
+
* from "declared, but an inverse side too, so neither owns the foreign key" needs the unresolved shape
|
|
382
|
+
* still there to find. A phase-split metadata map costs more than the call parentheses it saves.
|
|
368
383
|
*/
|
|
369
|
-
export type RelationMeta<E = any> = Omit<RelationOptions<E>, '
|
|
370
|
-
entity: EntityGetter<E>;
|
|
384
|
+
export type RelationMeta<E = any> = Omit<RelationOptions<E>, 'mappedBy' | 'references'> & {
|
|
371
385
|
mappedBy?: Key<E>;
|
|
372
386
|
references: RelationReferences;
|
|
373
387
|
};
|
|
@@ -379,8 +393,8 @@ type RelationOwnerJoin<E> = Required<Pick<RelationOptions<E>, 'through'>> | Requ
|
|
|
379
393
|
*/
|
|
380
394
|
type RelationJoin<E> = RelationOwnerJoin<E> | Required<Pick<RelationOptions<E>, 'mappedBy'>>;
|
|
381
395
|
type RelationOptionsOwner<E> = Pick<RelationOptions<E>, 'entity' | 'references' | 'cascade'>;
|
|
382
|
-
type RelationOptionsInverseSide<E> =
|
|
383
|
-
type RelationOptionsThroughOwner<E> =
|
|
396
|
+
type RelationOptionsInverseSide<E> = Pick<RelationOptions<E>, 'entity' | 'cascade'> & Required<Pick<RelationOptions<E>, 'mappedBy'>>;
|
|
397
|
+
type RelationOptionsThroughOwner<E> = Pick<RelationOptions<E>, 'entity' | 'cascade'> & RelationOwnerJoin<E>;
|
|
384
398
|
/**
|
|
385
399
|
* The key names of `E` as values, so `mappedBy` can be written as `(user) => user.company` instead of
|
|
386
400
|
* a string literal and survive a rename.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"homepage": "https://uql-orm.dev",
|
|
4
4
|
"description": "Extremely fast, type-safe TypeScript ORM - one API for every database",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.24.
|
|
6
|
+
"version": "0.24.5",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=24"
|
|
@@ -198,5 +198,5 @@
|
|
|
198
198
|
"publishConfig": {
|
|
199
199
|
"access": "public"
|
|
200
200
|
},
|
|
201
|
-
"gitHead": "
|
|
201
|
+
"gitHead": "1c763ccfdb4431afa49716b99512d9df4e0ad4b7"
|
|
202
202
|
}
|