uql-orm 0.105.0 → 0.106.0

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.
Files changed (58) hide show
  1. package/dist/browser/querier/httpQuerier.d.ts +3 -3
  2. package/dist/browser/type/clientQuerier.d.ts +1 -1
  3. package/dist/browser/uql-browser.min.js +2 -2
  4. package/dist/browser/uql-browser.min.js.map +6 -6
  5. package/dist/cockroachdb/cockroachDialect.d.ts +2 -2
  6. package/dist/dialect/abstractDialect.d.ts +3 -3
  7. package/dist/dialect/abstractSqlDialect.d.ts +35 -35
  8. package/dist/dialect/mergeSqlDialect.d.ts +2 -2
  9. package/dist/dialect/mysqlLikeSqlDialect.d.ts +6 -6
  10. package/dist/dialect/queryJoins.d.ts +2 -2
  11. package/dist/entity/columnOptionsBuilder.d.ts +3 -3
  12. package/dist/entity/columnOptionsBuilder.js +3 -5
  13. package/dist/entity/decorator/bag.d.ts +2 -2
  14. package/dist/entity/decorator/entity.d.ts +2 -2
  15. package/dist/entity/decorator/members.d.ts +1 -1
  16. package/dist/entity/metadata/definition.d.ts +12 -7
  17. package/dist/entity/metadata/definition.js +84 -87
  18. package/dist/entity/metadata/schemaFixture/animal.d.ts +17 -5
  19. package/dist/entity/metadata/schemaFixture/author.d.ts +12 -12
  20. package/dist/entity/metadata/schemaFixture/author.js +3 -3
  21. package/dist/entity/metadata/schemaFixture/book.d.ts +20 -20
  22. package/dist/entity/metadata/schemaFixture/book.js +2 -1
  23. package/dist/http/contract.d.ts +2 -2
  24. package/dist/http/handler.d.ts +2 -2
  25. package/dist/mariadb/mariaDialect.d.ts +2 -2
  26. package/dist/migrate/cli.js +13 -13
  27. package/dist/migrate/codegen/entityTypes.d.ts +2 -2
  28. package/dist/migrate/migrator.d.ts +2 -2
  29. package/dist/migrate/schemaGenerator.d.ts +5 -5
  30. package/dist/mongodb/mongoDialect.d.ts +12 -12
  31. package/dist/mongodb/mongoSchemaGenerator.d.ts +4 -4
  32. package/dist/mssql/mssqlDialect.d.ts +4 -4
  33. package/dist/pglite/pgliteQuerierPool.d.ts +2 -2
  34. package/dist/postgres/postgresDialect.d.ts +2 -2
  35. package/dist/querier/abstractSqlQuerier.d.ts +1 -1
  36. package/dist/schema/schemaASTBuilder.d.ts +4 -4
  37. package/dist/sqlite/localSqliteQuerierPool.d.ts +3 -2
  38. package/dist/type/column.d.ts +23 -22
  39. package/dist/type/config.d.ts +2 -2
  40. package/dist/type/dialect.d.ts +13 -13
  41. package/dist/type/entity.d.ts +22 -39
  42. package/dist/type/index.d.ts +1 -0
  43. package/dist/type/index.js +1 -0
  44. package/dist/type/migration.d.ts +7 -7
  45. package/dist/type/querier.d.ts +2 -2
  46. package/dist/type/query.d.ts +1 -1
  47. package/dist/type/querySql.d.ts +2 -2
  48. package/dist/type/schemaEntity.d.ts +59 -58
  49. package/dist/type/standardSchema.d.ts +28 -0
  50. package/dist/type/standardSchema.js +1 -0
  51. package/dist/type/utility.d.ts +25 -33
  52. package/dist/util/fieldOption.util.js +1 -1
  53. package/dist/util/hook.util.d.ts +2 -2
  54. package/dist/util/sql.d.ts +4 -6
  55. package/dist/util/sql.js +0 -4
  56. package/dist/util/triggerWrite.d.ts +5 -5
  57. package/package.json +1 -1
  58. package/skills/uql-orm/SKILL.md +26 -11
@@ -1,4 +1,4 @@
1
- import { type ColumnFamily, type SavepointCommand, type DdlRenderOptions, type EntityData, type EntityMeta, type EntityWhereMeta, type FieldKey, type FieldOptions, type IsolationLevel, type TransactionOptions, type JsonColumnType, type JsonArrayUpdateOp, type JsonUpdateOp, type Query, type QueryAggregate, type QueryBuildFn, type QueryComparisonOptions, type QueryConflictPaths, type QueryContext, type QueryContextOptions, type QueryGroupOp, type QueryHavingMap, type QueryRenderOptions, type QueryPage, type QueryPager, QuerySql, type QuerySqlFnOptions, type QuerySearch, type QuerySelectValue, type QuerySizeComparisonOps, type QueryTextSearchOptions, type QueryWhere, type QueryWhereArray, type QueryWhereFieldOp, type QueryWhereOptions, type RelationAggregateSpec, type RelationMeta, type SqlDialectName, type SqlQueryDialect, type SqlValues, type TriggerRows, type TriggerWrite, type Type, type UpdatePayload } from '../type/index.js';
1
+ import { type ColumnFamily, type SavepointCommand, type DdlRenderOptions, type EntityData, type EntityMeta, type EntityWhereMeta, type FieldKey, type FieldOptions, type IsolationLevel, type TransactionOptions, type JsonColumnType, type JsonArrayUpdateOp, type JsonUpdateOp, type Query, type QueryAggregate, type QueryBuildFn, type QueryComparisonOptions, type QueryConflictPaths, type QueryContext, type QueryContextOptions, type QueryGroupOp, type QueryHavingMap, type QueryRenderOptions, type QueryPage, type QueryPager, QuerySql, type QuerySqlFnOptions, type QuerySearch, type QuerySelectValue, type QuerySizeComparisonOps, type QueryTextSearchOptions, type QueryWhere, type QueryWhereArray, type QueryWhereFieldOp, type QueryWhereOptions, type RelationAggregateSpec, type RelationMeta, type SqlDialectName, type SqlQueryDialect, type SqlValues, type TriggerRows, type TriggerWrite, type AbstractType, type UpdatePayload } from '../type/index.js';
2
2
  import { type SortDirection } from '../util/index.js';
3
3
  import type { HydrateKind } from './hydrateColumn.js';
4
4
  import { type JsonAccessMode, type JsonContainer, type JsonKeyWrite, type JsonSlot } from './jsonSql.js';
@@ -67,7 +67,7 @@ type SelectOptions = {
67
67
  };
68
68
  /** A to-many's rows as the parent's statement reads them: an ordinary read of the related entity. */
69
69
  export type RelationRows = {
70
- readonly entity: Type<object>;
70
+ readonly entity: AbstractType<object>;
71
71
  readonly query: Query<object>;
72
72
  readonly alias: string;
73
73
  readonly joins: QueryJoins;
@@ -144,7 +144,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
144
144
  */
145
145
  protected buildFragment(ctx: QueryContext, build: QueryBuildFn): string;
146
146
  /** A `sql()` rendered in place, an operand or a projected term: bound, the driver would get the object. */
147
- protected rawFragment(ctx: QueryContext, value: QuerySql, prefix?: string, entity?: Type<unknown>): string;
147
+ protected rawFragment(ctx: QueryContext, value: QuerySql, prefix?: string, entity?: AbstractType<unknown>): string;
148
148
  /**
149
149
  * Each operand rendered on its own, keeping those that emitted SQL: an empty one leaves no dangling
150
150
  * separator, and the count of what emitted decides the parentheses.
@@ -166,12 +166,12 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
166
166
  * ` RETURNING` the fields `keys` names, after an `UPDATE` or `DELETE` this context holds, projected and read as
167
167
  * a read's are: the terms its rows answer under. Only where `features.writeReturning`.
168
168
  */
169
- returning<E>(ctx: QueryContext, entity: Type<E>, keys: readonly FieldKey<E>[]): readonly SelectTerm[];
169
+ returning<E>(ctx: QueryContext, entity: AbstractType<E>, keys: readonly FieldKey<E>[]): readonly SelectTerm[];
170
170
  /** What the returned row is read off, for an engine that names it: SQL Server's `INSERTED.`. */
171
171
  protected readonly returnedRowPrefix: string;
172
172
  /** `<id column> AS` {@link RETURNED_ID} on its own, for a statement composing a `RETURNING` list of several items. */
173
173
  protected returningIdExpression<E>(meta: EntityMeta<E>): string;
174
- search<E>(ctx: QueryContext, entity: Type<E>, q?: Query<E>, opts?: ReadOptions, joins?: QueryJoins, order?: readonly SortRef[]): void;
174
+ search<E>(ctx: QueryContext, entity: AbstractType<E>, q?: Query<E>, opts?: ReadOptions, joins?: QueryJoins, order?: readonly SortRef[]): void;
175
175
  /**
176
176
  * A relation's rows ordered by the columns their sort terms were carried out in, where they are
177
177
  * paged: otherwise the aggregate reading them orders them, and sorting them first is wasted work.
@@ -183,7 +183,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
183
183
  * joined row keeps its key, every column of a composite past any subtraction: it is what tells a
184
184
  * matched row from no match.
185
185
  */
186
- selectTerms<E>(ctx: QueryContext, entity: Type<E>, select: QuerySelectValue<E> | undefined, opts?: SelectOptions): SelectTerm[];
186
+ selectTerms<E>(ctx: QueryContext, entity: AbstractType<E>, select: QuerySelectValue<E> | undefined, opts?: SelectOptions): SelectTerm[];
187
187
  /** One field's column, or the expression an inlined one stands for, as the projection reads it. */
188
188
  private fieldTerm;
189
189
  /**
@@ -219,13 +219,13 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
219
219
  protected textColumns<E>(meta: EntityMeta<E>, keys: readonly string[], prefix: string | undefined): string[];
220
220
  /** Ranks by the root `$text` of `where`, which is looked up only once a `$sort` asks for it. */
221
221
  private textRanker;
222
- select<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, opts?: ReadOptions, joins?: QueryJoins, totalAlias?: string): ReadProjection;
222
+ select<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts?: ReadOptions, joins?: QueryJoins, totalAlias?: string): ReadProjection;
223
223
  /**
224
224
  * Everything a read's rows answer under, in order: its own fields, each joined row's fields and to-many
225
225
  * relations under its path, its own to-many relations and `$count`, and each vector distance a `$sort`
226
226
  * projects.
227
227
  */
228
- protected projection<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, opts: SelectOptions, joins: QueryJoins): SelectTerm[];
228
+ protected projection<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts: SelectOptions, joins: QueryJoins): SelectTerm[];
229
229
  /** A projection's list of terms. */
230
230
  private termsSql;
231
231
  /** A term as a projection writes it, aliased unless its SQL already answers under its key. */
@@ -260,11 +260,11 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
260
260
  /** Each joined row's columns and to-many relations under its path, which is what unflattens it. */
261
261
  protected selectJoinedRows(ctx: QueryContext, joins: QueryJoins, json: boolean | undefined, distinct: boolean): SelectTerm[];
262
262
  protected selectRelationJoins<E>(ctx: QueryContext, meta: EntityMeta<E>, rootAlias: string, joins: QueryJoins): void;
263
- where<E>(ctx: QueryContext, entity: Type<E>, where?: QueryWhere<E>, opts?: QueryWhereOptions): void;
263
+ where<E>(ctx: QueryContext, entity: AbstractType<E>, where?: QueryWhere<E>, opts?: QueryWhereOptions): void;
264
264
  /** Renders a `$where` tree without applying entity filters (used for same-scope group-operator recursion). */
265
- protected renderWhere<E>(ctx: QueryContext, entity: Type<E>, where?: QueryWhere<E>, opts?: QueryWhereOptions): void;
266
- compare<E>(ctx: QueryContext, entity: Type<E>, key: string, val: unknown, opts?: QueryComparisonOptions): void;
267
- protected compareLogicalOperator<E>(ctx: QueryContext, entity: Type<E>, key: QueryGroupOp, val: QueryWhereArray<E>, opts: QueryComparisonOptions): void;
265
+ protected renderWhere<E>(ctx: QueryContext, entity: AbstractType<E>, where?: QueryWhere<E>, opts?: QueryWhereOptions): void;
266
+ compare<E>(ctx: QueryContext, entity: AbstractType<E>, key: string, val: unknown, opts?: QueryComparisonOptions): void;
267
+ protected compareLogicalOperator<E>(ctx: QueryContext, entity: AbstractType<E>, key: QueryGroupOp, val: QueryWhereArray<E>, opts: QueryComparisonOptions): void;
268
268
  /** Memoizes {@link escapedColumnName}; see there for why it is per dialect instance. */
269
269
  private readonly escapedColumns;
270
270
  /**
@@ -285,7 +285,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
285
285
  * as text rather than appending it, so every operator gets a real operand to wrap - `LOWER(...)`,
286
286
  * `NOT (... <=> ...)` - instead of having to fall back to a form that takes none.
287
287
  */
288
- protected resolveOperandField<E>(ctx: QueryContext, entity: Type<E>, key: string, opts: QueryRenderOptions): string;
288
+ protected resolveOperandField<E>(ctx: QueryContext, entity: AbstractType<E>, key: string, opts: QueryRenderOptions): string;
289
289
  /**
290
290
  * The expression an inlined computed field stands for, or nothing when the field is a real column. Every
291
291
  * clause names it by the expression, never the output alias, which exists only when it was selected; and
@@ -293,7 +293,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
293
293
  */
294
294
  private inlinedOperand;
295
295
  /** {@link fieldCondition}, appended. */
296
- compareFieldOperator<E>(ctx: QueryContext, entity: Type<E>, key: FieldKey<E>, op: QueryWhereFieldOp, val: unknown, opts?: QueryComparisonOptions): void;
296
+ compareFieldOperator<E>(ctx: QueryContext, entity: AbstractType<E>, key: FieldKey<E>, op: QueryWhereFieldOp, val: unknown, opts?: QueryComparisonOptions): void;
297
297
  /** One operator of a field's condition. Both come from the query as data, so neither is trusted. */
298
298
  private fieldCondition;
299
299
  /**
@@ -364,10 +364,10 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
364
364
  */
365
365
  protected jsonScalarParam(ctx: QueryContext, value: unknown): string;
366
366
  /** {@link resolveOperandField}, appended. */
367
- getComparisonKey<E>(ctx: QueryContext, entity: Type<E>, key: FieldKey<E>, opts?: QueryRenderOptions): void;
367
+ getComparisonKey<E>(ctx: QueryContext, entity: AbstractType<E>, key: FieldKey<E>, opts?: QueryRenderOptions): void;
368
368
  /** Appends the `ORDER BY`, reporting whether there was one - which {@link pager} needs on the
369
369
  * engines that refuse to page an unordered statement. */
370
- sort<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, opts?: QuerySortOptions): boolean;
370
+ sort<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts?: QuerySortOptions): boolean;
371
371
  /**
372
372
  * The terms of an `ORDER BY`, collected before anything is appended so an unorderable key is reported
373
373
  * instead of half a clause, and because a vector distance is the primary ordering wherever it appears.
@@ -401,7 +401,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
401
401
  */
402
402
  pager(ctx: QueryContext, opts: QueryPager, _sorted?: boolean): void;
403
403
  /** The engine's own refusal first, then what a lock over a join needs, which is SQL's alone. */
404
- assertLockSupported<E>(entity: Type<E>, q: Query<E>, joins?: QueryJoins): void;
404
+ assertLockSupported<E>(entity: AbstractType<E>, q: Query<E>, joins?: QueryJoins): void;
405
405
  /**
406
406
  * The lock as a hint on the table itself, which a `'tableHint'` dialect states instead of the
407
407
  * trailing clause {@link appendLock} emits. Empty everywhere else: `rowLocks.placement` is what
@@ -413,17 +413,17 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
413
413
  * joined: Postgres refuses a bare `FOR UPDATE` over the nullable side of an outer join outright,
414
414
  * and the other engines quietly widen the lock to the joined rows.
415
415
  */
416
- protected appendLock<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, joins?: QueryJoins, alias?: string): void;
416
+ protected appendLock<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, joins?: QueryJoins, alias?: string): void;
417
417
  /**
418
418
  * `COUNT(*)` over the filter, or over the rows a page settles. The clauses are read off `q` one by one:
419
419
  * `/http` hands it over untyped, and a smuggled `$sort` changes no count.
420
420
  */
421
- count<E>(ctx: QueryContext, entity: Type<E>, q: QueryPage<E>, opts?: QueryRenderOptions): void;
421
+ count<E>(ctx: QueryContext, entity: AbstractType<E>, q: QueryPage<E>, opts?: QueryRenderOptions): void;
422
422
  /**
423
423
  * How many rows a `$distinct` read returns: the deduplication runs after `COUNT(*)` and a window
424
424
  * alike, so the deduplicated set is counted as a derived table, never paged.
425
425
  */
426
- countDistinct<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, opts?: QueryRenderOptions): void;
426
+ countDistinct<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts?: QueryRenderOptions): void;
427
427
  /** `SELECT COUNT(*)` over the rows `rows` appends, as a derived table. */
428
428
  private countRows;
429
429
  /**
@@ -431,8 +431,8 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
431
431
  * keep one; the rest throw, because falling back to `COUNT(*)` would run exactly the scan the
432
432
  * caller reached for this to avoid, and only say so by taking a long time.
433
433
  */
434
- estimatedCount<E>(_ctx: QueryContext, _entity: Type<E>): void;
435
- aggregate<E>(ctx: QueryContext, entity: Type<E>, q: QueryAggregate<E>, opts?: QueryRenderOptions): readonly SelectTerm[];
434
+ estimatedCount<E>(_ctx: QueryContext, _entity: AbstractType<E>): void;
435
+ aggregate<E>(ctx: QueryContext, entity: AbstractType<E>, q: QueryAggregate<E>, opts?: QueryRenderOptions): readonly SelectTerm[];
436
436
  /**
437
437
  * What one entry reads: a grouped field, through the join its path passes, or an aggregate's argument,
438
438
  * narrowed by its own `$where` to `CASE WHEN … THEN … END`. Bare where it is a column or `'*'`.
@@ -463,12 +463,12 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
463
463
  */
464
464
  protected readonly totalOverExpr = "COUNT(*) OVER ()";
465
465
  /** A read, answering with the terms its rows answer under, which say how each reads back. */
466
- find<E>(ctx: QueryContext, entity: Type<E>, q?: Query<E>, opts?: QueryRenderOptions, totalAlias?: string): readonly SelectTerm[];
466
+ find<E>(ctx: QueryContext, entity: AbstractType<E>, q?: Query<E>, opts?: QueryRenderOptions, totalAlias?: string): readonly SelectTerm[];
467
467
  /**
468
468
  * A read's whole statement. The lock is appended here rather than in `search`, which `count`,
469
469
  * `update` and `delete` share: it belongs to a SELECT alone, and every engine spells it last.
470
470
  */
471
- protected read<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, opts: ReadOptions, joins: QueryJoins, totalAlias?: string): ReadProjection;
471
+ protected read<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts: ReadOptions, joins: QueryJoins, totalAlias?: string): ReadProjection;
472
472
  /**
473
473
  * `opts` with the alias the read's table claims: its own name, which needs no alias written, unless
474
474
  * another table of the statement took it first.
@@ -479,7 +479,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
479
479
  * statement cannot return them, and on a composite key, which has no id to ask for.
480
480
  */
481
481
  protected insertedIdReturning<E>(meta: EntityMeta<E>): string;
482
- insert<E>(ctx: QueryContext, entity: Type<E>, payload: E | E[], opts?: QueryRenderOptions): void;
482
+ insert<E>(ctx: QueryContext, entity: AbstractType<E>, payload: E | E[], opts?: QueryRenderOptions): void;
483
483
  /**
484
484
  * What a text search matches and a fulltext index covers, which have to agree for the index to serve the
485
485
  * search: the columns themselves, where the engine indexes them as they are (MySQL's `MATCH (a, b)`).
@@ -493,11 +493,11 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
493
493
  * `INSERT INTO ... VALUES (...)`, or the engine's spelling of a row naming no column, and nothing more. The upsert
494
494
  * builders extend this rather than {@link insert}: their own clause has to come before the `RETURNING`.
495
495
  */
496
- protected appendInsertValues<E>(ctx: QueryContext, entity: Type<E>, payload: E | E[],
496
+ protected appendInsertValues<E>(ctx: QueryContext, entity: AbstractType<E>, payload: E | E[],
497
497
  /** Spliced between the target and its rows; see {@link returningPosition}. */
498
498
  afterTarget?: string): void;
499
499
  /** The columns an insert writes and the rows it writes, resolved once, and shared with a `MERGE`'s row source. */
500
- protected insertShape<E>(entity: Type<E>, payload: E | E[]): InsertShape<E>;
500
+ protected insertShape<E>(entity: AbstractType<E>, payload: E | E[]): InsertShape<E>;
501
501
  /** `(a, b), (c, d)` - the row constructor an INSERT and a MERGE source both write. */
502
502
  protected appendValueRows<E>(ctx: QueryContext, { payloads, keys, fields, kinds }: InsertShape<E>): void;
503
503
  /**
@@ -506,7 +506,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
506
506
  * it does not support the `DEFAULT` keyword inside `VALUES`.
507
507
  */
508
508
  protected appendDefaultInsertValue(ctx: QueryContext, _field: FieldOptions | undefined): void;
509
- update<E>(ctx: QueryContext, entity: Type<E>, q: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryRenderOptions): void;
509
+ update<E>(ctx: QueryContext, entity: AbstractType<E>, q: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryRenderOptions): void;
510
510
  /** What an update assigns: the payload's fields, `onUpdate` fills included. */
511
511
  private updateEntries;
512
512
  /**
@@ -546,12 +546,12 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
546
546
  * `INSERT ... ON CONFLICT ... DO UPDATE/NOTHING RETURNING`. The assignments are built before the insert
547
547
  * fills `onInsert` columns, which must stay out of them, and their values bound after it, where a `?` reads them.
548
548
  */
549
- upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
549
+ upsert<E>(ctx: QueryContext, entity: AbstractType<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
550
550
  /**
551
551
  * What an upsert of rows shaped as `row` assigns a row it finds: the values its assignments bind once per
552
552
  * statement beside its rows, and whether there are any, where none is `DO NOTHING`, which skips that row.
553
553
  */
554
- upsertAssignments<E>(entity: Type<E>, conflictPaths: QueryConflictPaths<E>, row: E, update?: UpdatePayload<E>): {
554
+ upsertAssignments<E>(entity: AbstractType<E>, conflictPaths: QueryConflictPaths<E>, row: E, update?: UpdatePayload<E>): {
555
555
  readonly binds: number;
556
556
  readonly assigns: boolean;
557
557
  };
@@ -575,7 +575,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
575
575
  /** What a found row takes by default: each payload column as the incoming row has it, and the `onUpdate` fills. */
576
576
  private conflictEntries;
577
577
  protected getUpsertConflictPathsStr<E>(meta: EntityMeta<E>, conflictPaths: QueryConflictPaths<E>): string;
578
- delete<E>(ctx: QueryContext, entity: Type<E>, q: QuerySearch<E>, opts?: QueryRenderOptions): void;
578
+ delete<E>(ctx: QueryContext, entity: AbstractType<E>, q: QuerySearch<E>, opts?: QueryRenderOptions): void;
579
579
  escapeId(val: string | undefined, forbidQualified?: boolean, addDot?: boolean): string;
580
580
  /**
581
581
  * A name behind its schema, each part escaped on its own rather than as one dotted string taken
@@ -674,7 +674,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
674
674
  * predicate with no entity filter applied; a migration's is `sql` reading none.
675
675
  */
676
676
  compileDdl(sql: QuerySql): string;
677
- compileDdl<E>(sql: EntityWhereMeta<E>, entity: Type<E>, opts?: DdlRenderOptions): string;
677
+ compileDdl<E>(sql: EntityWhereMeta<E>, entity: AbstractType<E>, opts?: DdlRenderOptions): string;
678
678
  getRawValue(ctx: QueryContext, opts: QuerySqlFnOptions & {
679
679
  value: QuerySql;
680
680
  }): void;
@@ -714,7 +714,7 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
714
714
  * A relation aggregate as the correlated subquery a `computed` field reads, the same one `$count`
715
715
  * emits: `(user) => user.resources.count()` renders here, wherever the field is named.
716
716
  */
717
- appendRelationAggregate<E>(ctx: QueryContext, entity: Type<E>, aggregate: RelationAggregateSpec, prefix: string): void;
717
+ appendRelationAggregate<E>(ctx: QueryContext, entity: AbstractType<E>, aggregate: RelationAggregateSpec, prefix: string): void;
718
718
  /**
719
719
  * The page a capped aggregate reads: an ordinary read of the related entity under its own alias,
720
720
  * narrowed to the parent's rows, carrying out the one column the aggregate runs over. Its `$sort`,
@@ -788,9 +788,9 @@ export declare abstract class AbstractSqlDialect extends VectorSqlDialect implem
788
788
  /** `'key', column, ...`: the arguments of a JSON object call over `pairs`. */
789
789
  protected jsonObjectArgs(pairs: DerivedRelation['pairs']): string;
790
790
  /** Filter by relation: a parent matches when {@link appendRelationSubquery} finds one target row. */
791
- protected compareRelation<E>(ctx: QueryContext, entity: Type<E>, relKey: string, val: QueryWhere<object>, rel: RelationMeta, opts: QueryComparisonOptions): void;
791
+ protected compareRelation<E>(ctx: QueryContext, entity: AbstractType<E>, relKey: string, val: QueryWhere<object>, rel: RelationMeta, opts: QueryComparisonOptions): void;
792
792
  /** Filter by relation size: the same subquery, counting instead of testing for existence. */
793
- protected compareRelationSize<E>(ctx: QueryContext, entity: Type<E>, relKey: string, sizeVal: number | QuerySizeComparisonOps, rel: RelationMeta, opts: QueryComparisonOptions): void;
793
+ protected compareRelationSize<E>(ctx: QueryContext, entity: AbstractType<E>, relKey: string, sizeVal: number | QuerySizeComparisonOps, rel: RelationMeta, opts: QueryComparisonOptions): void;
794
794
  /**
795
795
  * `<expr> <op> <value>` for each bound, `AND`-joined. `expr` is spelled once per bound because it is an
796
796
  * expression, not a column: a `WHERE` has no output alias to refer back to. A count for `$size`, a
@@ -1,4 +1,4 @@
1
- import type { EntityMeta, QueryConflictPaths, QueryContext, QueryPager, TriggerRows, Type, UpdatePayload } from '../type/index.js';
1
+ import type { EntityMeta, QueryConflictPaths, QueryContext, QueryPager, TriggerRows, AbstractType, UpdatePayload } from '../type/index.js';
2
2
  import { AbstractSqlDialect } from './abstractSqlDialect.js';
3
3
  /** What SQL Server and Oracle share: paging and upsert spelled as the standard does. */
4
4
  export declare abstract class MergeSqlDialect extends AbstractSqlDialect {
@@ -12,7 +12,7 @@ export declare abstract class MergeSqlDialect extends AbstractSqlDialect {
12
12
  * assignments bind their values before the rows, though they follow them in the SQL; this works only because
13
13
  * SQL Server numbers each placeholder (`@p1`).
14
14
  */
15
- upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
15
+ upsert<E>(ctx: QueryContext, entity: AbstractType<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
16
16
  /** A trigger's upsert as a `MERGE` of the rows it was handed, `SELECT`ed off them as its source. */
17
17
  protected appendTriggerUpsert<E>(ctx: QueryContext, meta: EntityMeta<E>, conflictPaths: QueryConflictPaths<E>, entries: readonly [string, unknown][], assignments: string, rows?: TriggerRows): void;
18
18
  /**
@@ -1,4 +1,4 @@
1
- import type { EntityMeta, InsertIdSource, Query, QueryConflictPaths, QueryContext, QueryOptions, QueryTextSearchOptions, RowLockFeatures, SqlDialectFeatures, SqlDialectName, SqlValues, Type, UpdatePayload, TransactionOptions } from '../type/index.js';
1
+ import type { EntityMeta, InsertIdSource, Query, QueryConflictPaths, QueryContext, QueryOptions, QueryTextSearchOptions, RowLockFeatures, SqlDialectFeatures, SqlDialectName, SqlValues, AbstractType, UpdatePayload, TransactionOptions } from '../type/index.js';
2
2
  import { AbstractSqlDialect, type DerivedRelation, type RelationRows, type SelectTerm } from './abstractSqlDialect.js';
3
3
  import { type JsonContainer, type JsonSlot } from './jsonSql.js';
4
4
  /** Declared apart so MariaDB, which has no `FOR UPDATE OF`, can restate that one part of it. */
@@ -17,7 +17,7 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
17
17
  * anything has been analyzed. `DATABASE()` where the entity names no schema, so the estimate comes
18
18
  * from the connection's own database rather than a same-named table in another one.
19
19
  */
20
- estimatedCount<E>(ctx: QueryContext, entity: Type<E>): void;
20
+ estimatedCount<E>(ctx: QueryContext, entity: AbstractType<E>): void;
21
21
  protected readonly unboundedLimit: string;
22
22
  /** Case-sensitive, as on every other engine, where the column's collation would fold it. */
23
23
  protected regexCondition(operand: string, placeholder: string): string;
@@ -30,7 +30,7 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
30
30
  readonly sqlValues: SqlValues;
31
31
  readonly insertIdSource: InsertIdSource;
32
32
  /** `INSERT ... ON DUPLICATE KEY UPDATE`, the assignments bound after the insert, where a `?` reads them. */
33
- upsert<E>(ctx: QueryContext, entity: Type<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
33
+ upsert<E>(ctx: QueryContext, entity: AbstractType<E>, conflictPaths: QueryConflictPaths<E>, payload: E | E[], update?: UpdatePayload<E>): void;
34
34
  protected appendTriggerUpsert<E>(ctx: QueryContext, meta: EntityMeta<E>, _conflictPaths: QueryConflictPaths<E>, entries: readonly [string, unknown][], assignments: string): void;
35
35
  /**
36
36
  * `insert` on a duplicate key: `ON DUPLICATE KEY UPDATE` with the new row named, or `INSERT IGNORE` where there
@@ -54,15 +54,15 @@ export declare abstract class MysqlLikeSqlDialect extends AbstractSqlDialect {
54
54
  */
55
55
  protected appendRelationArray(ctx: QueryContext, rows: RelationRows): readonly SelectTerm[];
56
56
  /** A read's statement, with the settings it needs applied to it alone. */
57
- find<E>(ctx: QueryContext, entity: Type<E>, q?: Query<E>, opts?: QueryOptions, totalAlias?: string): readonly SelectTerm[];
57
+ find<E>(ctx: QueryContext, entity: AbstractType<E>, q?: Query<E>, opts?: QueryOptions, totalAlias?: string): readonly SelectTerm[];
58
58
  /** A `$distinct` read's count, which reads the relations the read does. */
59
- countDistinct<E>(ctx: QueryContext, entity: Type<E>, q: Query<E>, opts?: QueryOptions): void;
59
+ countDistinct<E>(ctx: QueryContext, entity: AbstractType<E>, q: Query<E>, opts?: QueryOptions): void;
60
60
  private settled;
61
61
  /**
62
62
  * `name=value` for each variable a read's statement sets for itself alone. `GROUP_CONCAT`, and
63
63
  * MariaDB's `JSON_ARRAYAGG` built on it, cut a relation's array at `group_concat_max_len`.
64
64
  */
65
- protected statementSettings<E>(entity: Type<E>, q: Query<E>): string[];
65
+ protected statementSettings<E>(entity: AbstractType<E>, q: Query<E>): string[];
66
66
  /** `sql` with `settings` scoped to it, in this engine's spelling. */
67
67
  protected abstract applySettings(sql: string, settings: readonly string[]): string;
68
68
  /** `JSON_OBJECT` of each key and its value. */
@@ -1,4 +1,4 @@
1
- import type { EntityMeta, FieldMeta, Query, QueryGroupMap, QuerySortMap, QueryWhere, RelationAggregateSpec, RelationMeta, RelationQuery, Type } from '../type/index.js';
1
+ import type { EntityMeta, FieldMeta, Query, QueryGroupMap, QuerySortMap, QueryWhere, RelationAggregateSpec, RelationMeta, RelationQuery, AbstractType } from '../type/index.js';
2
2
  import { type ParsedGroupEntry } from '../util/index.js';
3
3
  /**
4
4
  * One relation a statement joins, keyed by the alias its columns are addressed by (`tax`,
@@ -12,7 +12,7 @@ export type QueryJoin = {
12
12
  readonly path: string;
13
13
  /** The alias the statement reads it through: its path, unless another table of the statement took it. */
14
14
  readonly alias: string;
15
- readonly entity: Type<object>;
15
+ readonly entity: AbstractType<object>;
16
16
  readonly meta: EntityMeta<object>;
17
17
  readonly relation: RelationMeta;
18
18
  readonly query: RelationQuery;
@@ -1,5 +1,5 @@
1
1
  import type { ForeignKeyAction } from '../schema/types.js';
2
- import { COLUMN_OPTIONS, type ColumnType, type FieldOptions, type JsonShape, type OnFieldCallback, type QuerySql, type StampEvent, type Type, type VectorDistance } from '../type/index.js';
2
+ import { COLUMN_OPTIONS, type ColumnType, type FieldOptions, type OnFieldCallback, type QuerySql, type StampEvent, type StandardSchemaV1, type Type, type VectorDistance } from '../type/index.js';
3
3
  /**
4
4
  * Every family's builder at run time: the types offer each family only its own methods. Immutable, so a shared
5
5
  * `const money = f.decimal(12, 2)` is reused safely, and its options are the plain ones the registry reads.
@@ -44,8 +44,8 @@ export declare const columns: {
44
44
  decimal: (precision?: number, scale?: number) => ColumnOptionsBuilder;
45
45
  boolean: () => ColumnOptionsBuilder;
46
46
  date: () => ColumnOptionsBuilder;
47
- json: (shape?: JsonShape) => ColumnOptionsBuilder;
48
- jsonb: (shape?: JsonShape) => ColumnOptionsBuilder;
47
+ json: (schema?: StandardSchemaV1) => ColumnOptionsBuilder;
48
+ jsonb: (schema?: StandardSchemaV1) => ColumnOptionsBuilder;
49
49
  vector: (dimensions: number) => ColumnOptionsBuilder;
50
50
  enum: (members: readonly string[] | readonly number[]) => ColumnOptionsBuilder;
51
51
  version: (type?: NumberConstructor | BigIntConstructor) => ColumnOptionsBuilder;
@@ -85,9 +85,7 @@ export class ColumnOptionsBuilder {
85
85
  }
86
86
  }
87
87
  const column = (options) => new ColumnOptionsBuilder(options);
88
- function json(type, shape) {
89
- return column({ type, ...(shape && { shape }) });
90
- }
88
+ const jsonColumn = (type) => (schema) => column({ type, ...(schema && { schema }) });
91
89
  /** The column constructors at run time, which `f` types and the migration builder names. */
92
90
  export const columns = {
93
91
  string: () => column({ type: String }),
@@ -98,8 +96,8 @@ export const columns = {
98
96
  decimal: (precision, scale) => column({ type: 'decimal', ...(precision !== undefined && { precision }), ...(scale !== undefined && { scale }) }),
99
97
  boolean: () => column({ type: Boolean }),
100
98
  date: () => column({ type: Date }),
101
- json: (shape) => json('json', shape),
102
- jsonb: (shape) => json('jsonb', shape),
99
+ json: jsonColumn('json'),
100
+ jsonb: jsonColumn('jsonb'),
103
101
  vector: (dimensions) => column({ type: 'vector', dimensions }),
104
102
  enum: (members) => column({ type: typeof members[0] === 'number' ? Number : String, enum: members }),
105
103
  version: (type = Number) => column({ type, version: true }),
@@ -1,4 +1,4 @@
1
- import type { FieldOptions, HookDeclaration, HookEvent, RelationRegistration, Type } from '../../type/index.js';
1
+ import type { FieldOptions, HookDeclaration, HookEvent, RelationRegistration, AbstractType } from '../../type/index.js';
2
2
  /**
3
3
  * What the member decorators record for one class, until `@Entity()` or a subclass's registration drains it: the
4
4
  * only channel from a member decorator to its class, and what a schema's members are registered as too.
@@ -22,4 +22,4 @@ export declare function drainRegistrations(metadata: DecoratorMetadata | undefin
22
22
  * The registrations a class made for itself, readable once it is fully defined: `@Entity()` reads
23
23
  * `context.metadata` instead, since the class gets `Symbol.metadata` after its decorators return.
24
24
  */
25
- export declare function ownRegistrations(entity: Type<unknown>): MemberRegistrations | undefined;
25
+ export declare function ownRegistrations(entity: AbstractType<unknown>): MemberRegistrations | undefined;
@@ -1,6 +1,6 @@
1
- import type { BrandsNameFields, EntityOptions, Type } from '../../type/index.js';
1
+ import type { BrandsNameFields, EntityOptions, AbstractType } from '../../type/index.js';
2
2
  /**
3
3
  * Marks a class as an entity and finalizes its metadata, draining `context.metadata`: the class gets
4
4
  * `Symbol.metadata` only after its decorators return. `abstract: true` marks a base that is never a table.
5
5
  */
6
- export declare function Entity<E>(opts?: NoInfer<EntityOptions<E>>): (entity: Type<E> & BrandsNameFields<E>, context?: ClassDecoratorContext) => void;
6
+ export declare function Entity<E>(opts?: NoInfer<EntityOptions<E>>): (entity: AbstractType<E> & BrandsNameFields<E>, context?: ClassDecoratorContext) => void;
@@ -41,7 +41,7 @@ type ComputedColumn = Column<{
41
41
  type ComputedValue<C> = C extends RelationAggregate<infer V> ? V : C extends Column<infer O, infer V> ? V | NullOf<O> : never;
42
42
  /** What the property has to admit: all of an aggregate's value, which is exact, and a column's `null`. */
43
43
  type ComputedAdmits<C> = C extends RelationAggregate<infer V> ? V : C extends Column<infer O> ? NullOf<O> : never;
44
- /** A JSON column with no shape holds any document, which the property narrows: `Json<Settings>`. */
44
+ /** A JSON column with no schema holds any document, which the property narrows: `Json<Settings>`. */
45
45
  type Narrowable<V> = IsEqual<V, Json> extends true ? JsonBrand | readonly JsonBrand[] : V;
46
46
  /** Whether the column is a key, which the class has to name. */
47
47
  type IsKey<O> = O extends {
@@ -1,4 +1,4 @@
1
- import { type EntityGetter, type EntityMeta, type EntityOptions, type FieldMeta, type IdKey, type KeyMap, type RelationKey, type RelationMeta, type RelationOptions, type RelationRegistration, type SchemaEntityOptions, type Brands, type ColumnRow, type SchemaFields, type SchemaKey, type Type, type WrittenId, type SchemaEntity } from '../../type/index.js';
1
+ import { type EntityGetter, type EntityMeta, type EntityOptions, type Except, type FieldMeta, type IdKey, type KeyMap, type RelationKey, type RelationMeta, type RelationOptions, type RelationRegistration, type SchemaEntityOptions, type Brands, type EntityBrand, type ColumnRow, type SchemaFields, type SchemaKey, type Type, type AbstractType, type WrittenId, type SchemaEntity } from '../../type/index.js';
2
2
  import { type MemberRegistrations } from '../decorator/bag.js';
3
3
  /**
4
4
  * `opts` as the registry takes them: `mappedBy` and `references` read off their key maps down to the
@@ -11,17 +11,21 @@ export declare function relationRegistration<T extends object, O>({ mappedBy, re
11
11
  * entity names one, since a selector follows a rename and a string does not.
12
12
  */
13
13
  export declare function keyOf<E, K extends keyof E>(pick: (keys: KeyMap<E>) => K): K;
14
+ type DeclaredRow<F extends SchemaFields, B> = Except<B, EntityBrand & keyof B> & ColumnRow<F> & Brands<F, B>;
14
15
  /**
15
16
  * Declares an entity by its schema and returns its class, whose row type the schema derives, so nothing is
16
- * written twice: its columns now, then each section, `.indexes()` and so on, `.relations()` last. It registers on
17
- * first read, with every section in, and its relations once each target exists.
17
+ * written twice: its columns now, then each section, `.indexes()` and so on, `.relations()` last but for
18
+ * `.filters()`. It registers on first read, with every section in, and its relations once each target exists.
18
19
  */
19
- export declare function defineEntity<const F extends SchemaFields, B = object, BK = unknown, BC = unknown>(schema: SchemaEntityOptions<F, B, BK, BC>): SchemaEntity<B & ColumnRow<F> & Brands<F>, SchemaKey<F, BK>, BC & ColumnRow<F>, B>;
20
+ export declare function defineEntity<const F extends SchemaFields, B = object, BK = unknown, BC = unknown>(schema: SchemaEntityOptions<F, B, BK, BC> & {
21
+ readonly abstract: true;
22
+ }): SchemaEntity<DeclaredRow<F, B>, SchemaKey<F, BK>, BC & ColumnRow<F>, B, true>;
23
+ export declare function defineEntity<const F extends SchemaFields, B = object, BK = unknown, BC = unknown>(schema: SchemaEntityOptions<F, B, BK, BC>): SchemaEntity<DeclaredRow<F, B>, SchemaKey<F, BK>, BC & ColumnRow<F>, B>;
20
24
  /**
21
25
  * The registration both forms share, a schema's `members` given as the decorators would register them. Built
22
26
  * apart and stored once it passes, so a rejected definition leaves the registry as it was.
23
27
  */
24
- export declare function registerEntity<E>(entity: Type<E>, opts?: EntityOptions<E>, members?: Partial<MemberRegistrations>): EntityMeta<E>;
28
+ export declare function registerEntity<E>(entity: AbstractType<E>, opts?: EntityOptions<E>, members?: Partial<MemberRegistrations>): EntityMeta<E>;
25
29
  /**
26
30
  * Refuses an entity whose primary key is not one column, naming the path that cannot express it.
27
31
  *
@@ -59,12 +63,13 @@ export declare function idOf<E>(meta: EntityMeta<E>, row: KeyedRow<E>): WrittenI
59
63
  * what pointed at it, and a decorated class does not come back (its decorators drained at first
60
64
  * registration). See the Runtime Schemas guide.
61
65
  */
62
- export declare function removeEntity<E>(entity: Type<E>): boolean;
66
+ export declare function removeEntity<E>(entity: AbstractType<E>): boolean;
63
67
  export declare function getEntities(): Type<object>[];
64
- export declare function getMeta<E>(entity: Type<E>): EntityMeta<E>;
68
+ export declare function getMeta<E>(entity: AbstractType<E>): EntityMeta<E>;
65
69
  /**
66
70
  * The foreign keys an entity holds: each owning to-one's columns, and each `f.references()` no
67
71
  * relation joins on, as the many-to-one it describes, once its target has registered a key. What the
68
72
  * schema build constrains and a junction joins by, settling the relations holding them first.
69
73
  */
70
74
  export declare function foreignKeysOf<E>(meta: EntityMeta<E>): RelationMeta[];
75
+ export {};