uql-orm 0.24.3 → 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.
@@ -279,9 +279,11 @@ export type FieldOptions<V = TsTypeOf<FieldType>> = {
279
279
  */
280
280
  readonly unique?: boolean;
281
281
  /**
282
- * Default value for the column
282
+ * The column's DDL default, rendered into `CREATE TABLE` by `formatDefaultValue` - not `V`, unlike
283
+ * the generators above. A JSONB column defaults with the SQL literal it stores, `defaultValue: '{}'`,
284
+ * which is a string whatever the field's TypeScript type is.
283
285
  */
284
- readonly defaultValue?: V | Record<string, unknown>;
286
+ readonly defaultValue?: Scalar | Record<string, unknown>;
285
287
  /**
286
288
  * Whether the column is auto-incrementing (for integer IDs).
287
289
  */
@@ -345,10 +347,19 @@ export type RelationOptionsFor<V> = Omit<RelationOptions<RelationTarget<V>>, 'en
345
347
  export type MethodKey<E> = {
346
348
  readonly [K in keyof E]-?: NonNullable<E[K]> extends (...args: never[]) => unknown ? K : never;
347
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
+ */
348
359
  export type EntityGetter<E = any> = () => Type<E>;
349
360
  export type CascadeType = 'persist' | 'delete';
350
361
  export type RelationOptions<E = any> = {
351
- entity?: EntityGetter<E>;
362
+ entity: EntityGetter<E>;
352
363
  cardinality: RelationCardinality;
353
364
  readonly cascade?: boolean | CascadeType;
354
365
  mappedBy?: RelationMappedBy<E>;
@@ -360,12 +371,17 @@ export type RelationOptions<E = any> = {
360
371
  references?: RelationReferences;
361
372
  };
362
373
  /**
363
- * A relation once `getMeta` has resolved it: `entity` and `references` are settled and `mappedBy` is
364
- * the key its callback named. Consumers read this shape rather than {@link RelationOptions}, so they
365
- * need no assertions - `fillRelations` establishes the invariant once, and throws where it cannot.
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.
366
383
  */
367
- export type RelationMeta<E = any> = Omit<RelationOptions<E>, 'entity' | 'mappedBy' | 'references'> & {
368
- entity: EntityGetter<E>;
384
+ export type RelationMeta<E = any> = Omit<RelationOptions<E>, 'mappedBy' | 'references'> & {
369
385
  mappedBy?: Key<E>;
370
386
  references: RelationReferences;
371
387
  };
@@ -377,8 +393,8 @@ type RelationOwnerJoin<E> = Required<Pick<RelationOptions<E>, 'through'>> | Requ
377
393
  */
378
394
  type RelationJoin<E> = RelationOwnerJoin<E> | Required<Pick<RelationOptions<E>, 'mappedBy'>>;
379
395
  type RelationOptionsOwner<E> = Pick<RelationOptions<E>, 'entity' | 'references' | 'cascade'>;
380
- type RelationOptionsInverseSide<E> = Required<Pick<RelationOptions<E>, 'entity' | 'mappedBy'>> & Pick<RelationOptions<E>, 'cascade'>;
381
- type RelationOptionsThroughOwner<E> = Required<Pick<RelationOptions<E>, 'entity'>> & Pick<RelationOptions<E>, 'cascade'> & RelationOwnerJoin<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>;
382
398
  /**
383
399
  * The key names of `E` as values, so `mappedBy` can be written as `(user) => user.company` instead of
384
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.3",
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": "4301613bcab77a626513197f1e815f972aa21bba"
201
+ "gitHead": "1c763ccfdb4431afa49716b99512d9df4e0ad4b7"
202
202
  }