uql-orm 0.101.1 → 0.101.2

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 (88) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/uql-browser.min.js +2 -2
  3. package/dist/browser/uql-browser.min.js.map +6 -6
  4. package/dist/d1/d1SqliteDialect.d.ts +1 -1
  5. package/dist/d1/d1SqliteDialect.js +1 -1
  6. package/dist/dialect/abstractDialect.js +2 -2
  7. package/dist/dialect/abstractSqlDialect.d.ts +10 -10
  8. package/dist/dialect/abstractSqlDialect.js +24 -24
  9. package/dist/dialect/operators.js +2 -2
  10. package/dist/dialect/pgLikeSqlDialect.d.ts +1 -1
  11. package/dist/dialect/pgLikeSqlDialect.js +5 -5
  12. package/dist/dialect/queryContext.d.ts +1 -1
  13. package/dist/dialect/queryContext.js +1 -1
  14. package/dist/dialect/vectorSqlDialect.js +1 -1
  15. package/dist/entity/decorator/entity.d.ts +2 -2
  16. package/dist/entity/decorator/entity.js +2 -2
  17. package/dist/http/query.d.ts +1 -1
  18. package/dist/http/query.js +4 -4
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.js +1 -1
  21. package/dist/migrate/builder/tableBuilder.js +1 -1
  22. package/dist/migrate/builder/types.d.ts +2 -2
  23. package/dist/migrate/codegen/entityCodeGenerator.js +1 -1
  24. package/dist/migrate/codegen/fieldOptionsSource.js +5 -5
  25. package/dist/migrate/codegen/indexDecoratorSource.d.ts +2 -2
  26. package/dist/migrate/codegen/indexDecoratorSource.js +5 -5
  27. package/dist/migrate/codegen/sourceLiteral.d.ts +2 -2
  28. package/dist/migrate/codegen/sourceLiteral.js +3 -3
  29. package/dist/migrate/ddl/defaultSql.js +1 -1
  30. package/dist/migrate/generator/definitionToNode.d.ts +3 -3
  31. package/dist/migrate/indexPredicate.d.ts +1 -1
  32. package/dist/migrate/indexPredicate.js +5 -5
  33. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +8 -8
  34. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +3 -3
  35. package/dist/migrate/introspection/mssqlIntrospector.d.ts +5 -5
  36. package/dist/migrate/introspection/mssqlIntrospector.js +10 -10
  37. package/dist/migrate/introspection/mysqlIntrospector.d.ts +5 -5
  38. package/dist/migrate/introspection/mysqlIntrospector.js +13 -13
  39. package/dist/migrate/introspection/postgresIntrospector.d.ts +13 -13
  40. package/dist/migrate/introspection/postgresIntrospector.js +21 -21
  41. package/dist/migrate/introspection/sqliteIntrospector.d.ts +4 -4
  42. package/dist/migrate/introspection/sqliteIntrospector.js +6 -6
  43. package/dist/migrate/migrationLock.d.ts +3 -3
  44. package/dist/migrate/migrationLock.js +7 -7
  45. package/dist/migrate/migrationTarget.js +2 -2
  46. package/dist/migrate/migrator.js +2 -2
  47. package/dist/migrate/schemaGenerator.d.ts +1 -1
  48. package/dist/migrate/schemaGenerator.js +1 -1
  49. package/dist/migrate/storage/databaseStorage.d.ts +3 -3
  50. package/dist/migrate/storage/databaseStorage.js +4 -4
  51. package/dist/migrate/triggerSql.js +7 -7
  52. package/dist/mongodb/mongoDialect.js +4 -4
  53. package/dist/mongodb/mongoSchemaGenerator.js +3 -3
  54. package/dist/mssql/mssqlDialect.js +3 -3
  55. package/dist/querier/abstractSqlQuerier.js +1 -1
  56. package/dist/schema/canonicalType.d.ts +1 -1
  57. package/dist/schema/canonicalType.js +6 -6
  58. package/dist/schema/sqlExpression.d.ts +4 -4
  59. package/dist/schema/sqlExpression.js +5 -5
  60. package/dist/sqlite/sqliteDialect.js +2 -2
  61. package/dist/type/dialect.d.ts +3 -3
  62. package/dist/type/entity.d.ts +39 -39
  63. package/dist/type/index.d.ts +1 -1
  64. package/dist/type/index.js +1 -1
  65. package/dist/type/migration.d.ts +1 -1
  66. package/dist/type/querier.d.ts +5 -5
  67. package/dist/type/query.d.ts +32 -32
  68. package/dist/type/queryAggregate.d.ts +2 -2
  69. package/dist/type/{queryRaw.d.ts → querySql.d.ts} +33 -33
  70. package/dist/type/{queryRaw.js → querySql.js} +17 -17
  71. package/dist/type/queryWhere.d.ts +22 -22
  72. package/dist/type/universalQuerier.d.ts +12 -12
  73. package/dist/type/wire.d.ts +4 -4
  74. package/dist/util/ddlExpression.util.d.ts +4 -4
  75. package/dist/util/ddlExpression.util.js +7 -7
  76. package/dist/util/dialect.util.d.ts +7 -7
  77. package/dist/util/dialect.util.js +4 -4
  78. package/dist/util/fieldOption.util.d.ts +3 -3
  79. package/dist/util/fieldOption.util.js +5 -5
  80. package/dist/util/index.d.ts +1 -1
  81. package/dist/util/index.js +1 -1
  82. package/dist/util/query.util.js +1 -1
  83. package/dist/util/{raw.d.ts → sql.d.ts} +22 -20
  84. package/dist/util/{raw.js → sql.js} +28 -26
  85. package/dist/util/triggerWrite.d.ts +7 -7
  86. package/dist/util/triggerWrite.js +2 -2
  87. package/package.json +1 -1
  88. package/skills/uql-orm/SKILL.md +7 -7
@@ -1,7 +1,7 @@
1
1
  import type { EnumValues, ForeignKeyAction, IndexType } from '../schema/types.js';
2
2
  import type { SqlDialectName } from './dialect.js';
3
3
  import type { FilterOptions, RelationQuery } from './query.js';
4
- import type { ColumnRef, QueryRaw, RawFor, RelationAggregate } from './queryRaw.js';
4
+ import type { ColumnRef, QuerySql, SqlFor, RelationAggregate } from './querySql.js';
5
5
  import type { QueryWhere } from './queryWhere.js';
6
6
  import type { AtLeastOne, Except, ExactlyOne, IsEqual, IsJson, JsonBrand, IsMany, Json, Scalar, Type, Unpacked, Writable } from './utility.js';
7
7
  import type { VectorDistance, VectorIndexOptions, VectorIndexType } from './vector.js';
@@ -51,7 +51,7 @@ export type EntityWrite<E> = EntityData<E, Exclude<WritableKey<E>, FilledKey<E>>
51
51
  });
52
52
  /** A row a trigger's body writes: each writable field its value, or SQL - a row's ref most often. */
53
53
  export type WriteRow<E, F extends keyof E = WritableKey<E>> = {
54
- readonly [K in F]?: E[K] | RawFor<QueryRaw, E[K]>;
54
+ readonly [K in F]?: E[K] | SqlFor<QuerySql, E[K]>;
55
55
  };
56
56
  /**
57
57
  * The property an entity brands with {@link versionKey} as its optimistic lock, `never` where it
@@ -66,7 +66,7 @@ export type VersionKey<E> = E extends {
66
66
  * and with the version where the entity keeps one - a write that cannot say which row state it read
67
67
  * is refused here rather than silently overwriting whatever is there now.
68
68
  */
69
- export type UpdateWrite<E, Raw = QueryRaw> = UpdatePayload<E, Raw, WritableKey<E>> & Required<Pick<E, VersionKey<E>>>;
69
+ export type UpdateWrite<E, Sql = QuerySql> = UpdatePayload<E, Sql, WritableKey<E>> & Required<Pick<E, VersionKey<E>>>;
70
70
  /** The relation names of an entity: every key but its fields and its methods, so the two sets cannot drift. */
71
71
  export type RelationKey<E> = Exclude<Key<E>, FieldKey<E> | MethodKey<E>>;
72
72
  /**
@@ -143,11 +143,11 @@ type JsonUpdateOpFor<V, T = UnwrapJson<NonNullable<V>>> = [T] extends [never] ?
143
143
  * would change the result. A `bigint` steps by a `bigint`, exactly, and the step may be SQL of the field's type.
144
144
  * @example `{ stock: { $inc: -1 } }`, `{ total: { $inc: newRow.amount } }`
145
145
  */
146
- export type FieldUpdateOp<T = number | bigint | QueryRaw> = ExactlyOne<Record<'$inc' | '$mul', T>>;
146
+ export type FieldUpdateOp<T = number | bigint | QuerySql> = ExactlyOne<Record<'$inc' | '$mul', T>>;
147
147
  /** The {@link FieldUpdateOp} a field takes: `never` on one it has no operator for, which is any but a number. */
148
- type FieldUpdateOpFor<V, Raw> = [NonNullable<V>] extends [number] ? FieldUpdateOp<number | RawFor<Raw, number>> : [NonNullable<V>] extends [bigint] ? FieldUpdateOp<bigint | RawFor<Raw, bigint>> : never;
149
- /** What an update takes beyond the value: `null` to clear an optional member, `raw` SQL, and update operators. */
150
- type UpdateExtra<V, Raw> = (undefined extends V ? null : never) | RawFor<Raw, V> | JsonUpdateOpFor<V> | FieldUpdateOpFor<V, Raw>;
148
+ type FieldUpdateOpFor<V, Sql> = [NonNullable<V>] extends [number] ? FieldUpdateOp<number | SqlFor<Sql, number>> : [NonNullable<V>] extends [bigint] ? FieldUpdateOp<bigint | SqlFor<Sql, bigint>> : never;
149
+ /** What an update takes beyond the value: `null` to clear an optional member, `sql` SQL, and update operators. */
150
+ type UpdateExtra<V, Sql> = (undefined extends V ? null : never) | SqlFor<Sql, V> | JsonUpdateOpFor<V> | FieldUpdateOpFor<V, Sql>;
151
151
  /**
152
152
  * What a whole-record write persists: the fields and relations with their declared optionality, a
153
153
  * related row as a caller writes one, and no methods. Two mapped types, since asking each key costs a
@@ -161,10 +161,10 @@ export type EntityData<E, F extends keyof E = FieldKey<E>, R extends keyof E = R
161
161
  /** A relation's value as its rows' {@link EntityWrite}. */
162
162
  type RelationData<V> = V extends readonly (infer T)[] ? EntityWrite<T>[] : V extends object ? EntityWrite<V> : never;
163
163
  /** {@link EntityData} made partial, each member also taking its {@link UpdateExtra}. */
164
- export type UpdatePayload<E, Raw = QueryRaw, F extends keyof E = FieldKey<E>, R extends keyof E = RelationKey<E>> = {
165
- [P in F]?: E[P] | UpdateExtra<E[P], Raw>;
164
+ export type UpdatePayload<E, Sql = QuerySql, F extends keyof E = FieldKey<E>, R extends keyof E = RelationKey<E>> = {
165
+ [P in F]?: E[P] | UpdateExtra<E[P], Sql>;
166
166
  } & {
167
- [P in R]?: E[P] | RelationData<E[P]> | UpdateExtra<E[P], Raw>;
167
+ [P in R]?: E[P] | RelationData<E[P]> | UpdateExtra<E[P], Sql>;
168
168
  };
169
169
  /** The key's name where the entity states it, by the `idKey` brand or a conventional name; `never` otherwise. */
170
170
  export type NamedIdKey<E> = E extends {
@@ -243,7 +243,7 @@ export type TypeFor<V, T = NonNullable<V>> = IsJsonColumn<T> extends true ? Json
243
243
  /** A field as the registry holds it: what was authored, plus what registration worked out, which no decorator can write. */
244
244
  export type FieldMeta<V = TsTypeOf<FieldType>> = Except<FieldOptions<V>, 'computed'> & {
245
245
  /** {@link FieldOptions.computed}, a callback resolved to the SQL it returns. */
246
- readonly computed?: QueryRaw;
246
+ readonly computed?: QuerySql;
247
247
  /** Whether the column type comes from the referenced key, where the field gave `references` but no `type`. */
248
248
  readonly typeFromReference?: boolean;
249
249
  };
@@ -273,7 +273,7 @@ export type FieldOptions<V = TsTypeOf<FieldType>, E = unknown> = {
273
273
  readonly enum?: EnumValues;
274
274
  /**
275
275
  * An expression the database computes, never written: spliced into each read, or with `stored` a
276
- * generated column, `computed: (user) => raw`${user.first} || ' ' || ${user.last}``.
276
+ * generated column, `computed: (user) => sql`${user.first} || ' ' || ${user.last}``.
277
277
  *
278
278
  * A relation aggregate is the other form, `computed: (user) => user.resources.count()`, read as the
279
279
  * subquery a `$count` reads. Both resolve to SQL at registration, so everything downstream sees one.
@@ -302,10 +302,10 @@ export type FieldOptions<V = TsTypeOf<FieldType>, E = unknown> = {
302
302
  readonly version?: true;
303
303
  /**
304
304
  * The SQL type, where it differs from the one `type` implies: `type: String, columnType: 'decimal'`.
305
- * An engine's own type is a `raw` constant, `columnType: raw`tsvector``, rendered verbatim and
305
+ * An engine's own type is a `sql` constant, `columnType: sql`tsvector``, rendered verbatim and
306
306
  * never translated, so a column declaring one is yours to keep portable.
307
307
  */
308
- readonly columnType?: ColumnType | QueryRaw;
308
+ readonly columnType?: ColumnType | QuerySql;
309
309
  /** A string column's length. */
310
310
  readonly length?: number;
311
311
  /** A decimal column's digits, or a timestamp's fractional-second digits. */
@@ -314,8 +314,8 @@ export type FieldOptions<V = TsTypeOf<FieldType>, E = unknown> = {
314
314
  readonly scale?: number;
315
315
  readonly nullable?: boolean;
316
316
  readonly unique?: boolean;
317
- /** The column's DDL default: a literal, or SQL the database evaluates per inserted row (`currentTimestamp`, `raw`). */
318
- readonly defaultValue?: DdlDefault<V> | QueryRaw;
317
+ /** The column's DDL default: a literal, or SQL the database evaluates per inserted row (`currentTimestamp`, `sql`). */
318
+ readonly defaultValue?: DdlDefault<V> | QuerySql;
319
319
  /** Whether the database generates the value; a numeric sole key does unless something else fills it. */
320
320
  readonly autoIncrement?: boolean;
321
321
  /**
@@ -326,7 +326,7 @@ export type FieldOptions<V = TsTypeOf<FieldType>, E = unknown> = {
326
326
  /** The column's comment in the database. */
327
327
  readonly comment?: string;
328
328
  };
329
- export type OnFieldCallback<V = TsTypeOf<FieldType>> = V | QueryRaw | (() => V | QueryRaw);
329
+ export type OnFieldCallback<V = TsTypeOf<FieldType>> = V | QuerySql | (() => V | QuerySql);
330
330
  /**
331
331
  * What a column may default to: its value, or on a JSON column the document it stores, `[]`, or its SQL text,
332
332
  * `'{}'`. The erased `FieldOptions` takes them all, so every field's options stay assignable to it.
@@ -478,9 +478,9 @@ export type KeyMap<E> = {
478
478
  export type RefMap<E, F extends keyof E = FieldKey<E>> = {
479
479
  readonly [K in F]-?: ColumnRef<K & string, E[K]>;
480
480
  };
481
- /** SQL a definition writes: `raw`, or a callback reading the fields off its refs, bivariant so the registry can hold it. */
482
- export type EntitySql<E> = QueryRaw | {
483
- sql(refs: RefMap<E>): QueryRaw;
481
+ /** SQL a definition writes: `sql`, or a callback reading the fields off its refs, bivariant so the registry can hold it. */
482
+ export type EntitySql<E> = QuerySql | {
483
+ sql(refs: RefMap<E>): QuerySql;
484
484
  }['sql'];
485
485
  /** One field of `C`, read off its refs: `(item) => item.amount`. */
486
486
  type PickRef<C, K extends keyof C> = (refs: RefMap<C>) => ColumnRef<K & string>;
@@ -527,8 +527,8 @@ export type EntityAggregate<E> = {
527
527
  * SQL a `computed` field writes. One callback shape for every arm, aggregate or not: overload
528
528
  * resolution picks a contextual parameter type per arm only while they agree on one.
529
529
  */
530
- export type ComputedSql<E> = QueryRaw | {
531
- sql(refs: ComputedRefs<E>): QueryRaw;
530
+ export type ComputedSql<E> = QuerySql | {
531
+ sql(refs: ComputedRefs<E>): QuerySql;
532
532
  }['sql'];
533
533
  /** The value a field's options declare it holds, where an aggregate is what declares it. */
534
534
  export type AggregateValue<O> = O extends {
@@ -545,7 +545,7 @@ export type EntityPredicate<E> = QueryWhere<E> & {
545
545
  /** A definition's predicate: an {@link EntityPredicate}, or {@link EntitySql} for what one cannot say. */
546
546
  export type EntityWhere<E> = EntityPredicate<E> | EntitySql<E>;
547
547
  /** A definition's predicate as metadata keeps it, a callback resolved to its SQL, for the schema build to compile. */
548
- export type EntityWhereMeta<E> = EntityPredicate<E> | QueryRaw;
548
+ export type EntityWhereMeta<E> = EntityPredicate<E> | QuerySql;
549
549
  export type RelationReferences = {
550
550
  readonly local: string;
551
551
  readonly foreign: string;
@@ -583,13 +583,13 @@ export type IndexTypeOptions = {
583
583
  distance?: never;
584
584
  config?: never;
585
585
  };
586
- /** One index entry as the migration builder takes it: a column name, `raw`, or an object when it needs more. */
587
- export type IndexColumnInput = string | QueryRaw | EntityIndexColumn;
586
+ /** One index entry as the migration builder takes it: a column name, `sql`, or an object when it needs more. */
587
+ export type IndexColumnInput = string | QuerySql | EntityIndexColumn;
588
588
  /**
589
- * One entry of an entity's index, read off its refs: a column, `raw`, or an object when it needs more.
590
- * @example `@Index((post) => [post.tenantId, { column: post.createdAt, order: 'desc' }, raw`lower(${post.email})`])`
589
+ * One entry of an entity's index, read off its refs: a column, `sql`, or an object when it needs more.
590
+ * @example `@Index((post) => [post.tenantId, { column: post.createdAt, order: 'desc' }, sql`lower(${post.email})`])`
591
591
  */
592
- export type EntityIndexColumnInput<E> = QueryRaw | IndexColumnOptions | IndexJsonColumnOptions<E>;
592
+ export type EntityIndexColumnInput<E> = QuerySql | IndexColumnOptions | IndexJsonColumnOptions<E>;
593
593
  /** A JSON entry, its `path` checked against its own column's payload: a misspelled one builds an index nothing uses. */
594
594
  type IndexJsonColumnOptions<E> = {
595
595
  [K in JsonColumnKey<E>]: IndexColumnPlainModifiers & {
@@ -658,8 +658,8 @@ export type IndexJsonArray = {
658
658
  type IndexColumnPlainModifiers = Except<IndexColumnModifiers, 'jsonPath' | 'jsonArray'>;
659
659
  /** An entity's entry with plain modifiers, never a JSON one, whose path would then go unchecked. */
660
660
  type IndexColumnOptions = IndexColumnPlainModifiers & {
661
- /** A column read off the refs, or `raw` for an expression. */
662
- readonly column: QueryRaw;
661
+ /** A column read off the refs, or `sql` for an expression. */
662
+ readonly column: QuerySql;
663
663
  readonly jsonPath?: never;
664
664
  readonly jsonArray?: never;
665
665
  };
@@ -672,7 +672,7 @@ export type IndexColumnSchema = IndexColumnModifiers & {
672
672
  };
673
673
  /** One index entry as metadata keeps it: a member, or an expression rendered when the schema is built. */
674
674
  export type EntityIndexColumn = IndexColumnModifiers & {
675
- readonly column: string | QueryRaw;
675
+ readonly column: string | QuerySql;
676
676
  };
677
677
  /** An index as metadata keeps it. */
678
678
  export type EntityIndexMeta<E = object> = {
@@ -749,7 +749,7 @@ type TriggerRowRefs<E, Ev extends TriggerEvent, R extends '$new' | '$old'> = R e
749
749
  * The one an event lacks is `never`, so reading it does not compile, and a body reading only the outgoing
750
750
  * row - `(_newRow, oldRow)` - serves an update and a delete alike.
751
751
  */
752
- type TriggerBody<E, Ev extends TriggerEvent> = (newRow: TriggerRowRefs<E, Ev, '$new'>, oldRow: TriggerRowRefs<E, Ev, '$old'>) => QueryRaw;
752
+ type TriggerBody<E, Ev extends TriggerEvent> = (newRow: TriggerRowRefs<E, Ev, '$new'>, oldRow: TriggerRowRefs<E, Ev, '$old'>) => QuerySql;
753
753
  /**
754
754
  * A condition as data: a predicate on each row it names, of the rows the event has, all of which hold.
755
755
  * The row is `$`-marked, as the operators inside it are, so it never reads as a field of the entity.
@@ -764,7 +764,7 @@ type TriggerPredicate<E, Ev extends TriggerEvent> = {
764
764
  */
765
765
  type TriggerRun<E, Ev extends TriggerEvent> = TriggerBody<E, Ev> | Readonly<AtLeastOne<Record<SqlDialectName, TriggerBody<E, Ev>>>>;
766
766
  /**
767
- * A trigger, `{ on: 'beforeUpdate', of: (post) => [post.body], run: (newRow) => raw`...` }`.
767
+ * A trigger, `{ on: 'beforeUpdate', of: (post) => [post.body], run: (newRow) => sql`...` }`.
768
768
  *
769
769
  * A list rather than a map keyed by the event, as `checks` and `indexes` are lists: several triggers may
770
770
  * share an event, they fire in the order written, and each is named, diffed and dropped by that name.
@@ -801,7 +801,7 @@ export type TriggerOptions<E = unknown> = {
801
801
  */
802
802
  readonly deferred?: Ev extends `after${string}` ? boolean : never;
803
803
  /**
804
- * The body, as SQL off the rows, `(newRow, oldRow) => raw`...``: the incoming row first and the
804
+ * The body, as SQL off the rows, `(newRow, oldRow) => sql`...``: the incoming row first and the
805
805
  * outgoing one second, the one `on` lacks typed `never`. One for every engine, or a map naming one
806
806
  * per engine where their SQL differs.
807
807
  */
@@ -822,11 +822,11 @@ export type EntityTriggerMeta<E = object> = Except<TriggerOptions<E>, 'of' | 'wh
822
822
  * so a body typing the row its event lacks as `never` is still held here.
823
823
  */
824
824
  export type TriggerMetaBody<E> = {
825
- run(newRow: RefMap<E>, oldRow: RefMap<E>): QueryRaw;
825
+ run(newRow: RefMap<E>, oldRow: RefMap<E>): QuerySql;
826
826
  }['run'];
827
827
  /**
828
828
  * A table's `CHECK`, `{ where: { balance: { $gte: 0 } } }`, or SQL off the refs,
829
- * `{ where: (wallet) => raw`${wallet.spent} <= ${wallet.balance}` }`.
829
+ * `{ where: (wallet) => sql`${wallet.spent} <= ${wallet.balance}` }`.
830
830
  */
831
831
  export type CheckOptions<E = unknown> = {
832
832
  /** Derived from the table and the constraint's position when absent. */
@@ -880,8 +880,8 @@ export type EntityOptions<E = unknown> = {
880
880
  * `type`/`distance` a discriminated pair: omitting `distance` on a vector index type is a compile error.
881
881
  */
882
882
  export type IndexOptions = Except<EntityIndexMeta, 'columns' | 'where'> & {
883
- /** Partial-index predicate, as `raw` with no interpolation: the migration builder has no entity to compile one against. */
884
- readonly where?: QueryRaw;
883
+ /** Partial-index predicate, as `sql` with no interpolation: the migration builder has no entity to compile one against. */
884
+ readonly where?: QuerySql;
885
885
  };
886
886
  /**
887
887
  * {@link IndexOptions} on an entity, whose stored columns are read off its refs, `(post) => [post.slug]`,
@@ -891,7 +891,7 @@ export type EntityIndexOptions<E> = Except<IndexOptions, 'include' | 'where'> &
891
891
  readonly include?: (refs: RefMap<E>) => readonly ColumnRef<FieldKey<E>>[];
892
892
  /**
893
893
  * Partial-index predicate, written as the predicate the query passes: a planner matches the two by
894
- * shape, so a hand-written `raw` that means the same thing leaves the index unused. See {@link EntityWhere}.
894
+ * shape, so a hand-written `sql` that means the same thing leaves the index unused. See {@link EntityWhere}.
895
895
  */
896
896
  readonly where?: EntityWhere<E>;
897
897
  };
@@ -10,7 +10,7 @@ export * from './querierPool.js';
10
10
  export * from './query.js';
11
11
  export * from './queryAggregate.js';
12
12
  export * from './queryLock.js';
13
- export * from './queryRaw.js';
13
+ export * from './querySql.js';
14
14
  export * from './queryWhere.js';
15
15
  export * from './universalQuerier.js';
16
16
  export * from './utility.js';
@@ -10,7 +10,7 @@ export * from './querierPool.js';
10
10
  export * from './query.js';
11
11
  export * from './queryAggregate.js';
12
12
  export * from './queryLock.js';
13
- export * from './queryRaw.js';
13
+ export * from './querySql.js';
14
14
  export * from './queryWhere.js';
15
15
  export * from './universalQuerier.js';
16
16
  export * from './utility.js';
@@ -127,7 +127,7 @@ export interface IndexSchema extends VectorIndexOptions, IndexedVectorField {
127
127
  readonly name: string;
128
128
  /**
129
129
  * What the index is over, in order. Named `entries` and not `columns` because an entry need not be
130
- * a column at all: ``raw`lower(email)` `` is one, and so is a column carrying a prefix length or a
130
+ * a column at all: ``sql`lower(email)` `` is one, and so is a column carrying a prefix length or a
131
131
  * stored order. The authored form, `@Index`, still spells this `columns`, since that is what
132
132
  * it reads like at the call site.
133
133
  */
@@ -4,10 +4,10 @@ import type { FieldKey, HookEvent, RelationKey } from './entity.js';
4
4
  import type { LoggingOptions } from './logger.js';
5
5
  import type { NamingStrategy } from './namingStrategy.js';
6
6
  import type { QueryFilter, QueryFindResult, QueryOptions, QueryPage, QuerySearch, QueryUpdateResult, ReturningResult, WriteOptions } from './query.js';
7
- import type { SqlStatement } from './queryRaw.js';
7
+ import type { SqlStatement } from './querySql.js';
8
8
  import type { ProjectedQuery, ProjectedRead, ProjectedResult, UniversalQuerier } from './universalQuerier.js';
9
9
  import type { BooleanLike, RawRow, Type } from './utility.js';
10
- import type { QuerierRaw } from './wire.js';
10
+ import type { QuerierSql } from './wire.js';
11
11
  /**
12
12
  * Isolation levels for transactions.
13
13
  */
@@ -28,7 +28,7 @@ export type DialectName = SqlDialectName | 'mongodb';
28
28
  * **first** on purpose: when no signature matches, TypeScript reports the error of the *last* one, so a
29
29
  * typo'd query key is reported as itself rather than as a missing `$entity`.
30
30
  */
31
- type DualRead<Q extends keyof ProjectedQuery<object, never, never, never, never, never, never>, R extends keyof ProjectedResult<'server', unknown>> = (<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(q: ProjectedQuery<E, S, V, X, P, C, QuerierRaw<'server'>>[Q] & {
31
+ type DualRead<Q extends keyof ProjectedQuery<object, never, never, never, never, never, never>, R extends keyof ProjectedResult<'server', unknown>> = (<E extends object, const S extends FieldKey<E> = never, const V = true, const X extends FieldKey<E> = never, const P extends RelationKey<E> = never, const C extends RelationKey<E> = never>(q: ProjectedQuery<E, S, V, X, P, C, QuerierSql<'server'>>[Q] & {
32
32
  $entity: Type<E>;
33
33
  }, opts?: QueryOptions) => ProjectedResult<'server', QueryFindResult<E, S, V, X, P, C>>[R]) & ProjectedRead<Q, R, 'server', QueryOptions>;
34
34
  /** The reads, counts and deletes below take the entity first or as the query's `$entity`, as {@link DualRead} does. */
@@ -103,10 +103,10 @@ export interface SqlQuerier extends Querier {
103
103
  readonly dialect: AbstractSqlDialect;
104
104
  /**
105
105
  * The rows a statement answers, written as a tag, `all<Row>`SELECT ... WHERE id = ${id}``, each interpolated
106
- * value bound, never spliced; or a `raw` built apart.
106
+ * value bound, never spliced; or a `sql` built apart.
107
107
  */
108
108
  all<T extends object = RawRow>(...statement: SqlStatement): Promise<T[]>;
109
- /** Runs a statement (INSERT, UPDATE, DELETE, DDL), written as a tag or a `raw`, each interpolated value bound. */
109
+ /** Runs a statement (INSERT, UPDATE, DELETE, DDL), written as a tag or a `sql`, each interpolated value bound. */
110
110
  run(...statement: SqlStatement): Promise<QueryUpdateResult>;
111
111
  }
112
112
  /**
@@ -1,6 +1,6 @@
1
1
  import type { FieldKey, FieldKeyOf, JsonFieldPaths, RelationKey, RelationTarget, ToManyRelationKey } from './entity.js';
2
2
  import type { QueryLock } from './queryLock.js';
3
- import type { QueryRaw } from './queryRaw.js';
3
+ import type { QuerySql } from './querySql.js';
4
4
  import type { QueryWhere } from './queryWhere.js';
5
5
  import type { BooleanLike, Except, IsMany, PrimaryKey } from './utility.js';
6
6
  import type { QueryVectorQuery, QueryVectorSearch } from './vector.js';
@@ -49,10 +49,10 @@ export type QuerySelect<E, F extends keyof E = FieldKey<E>, V = BooleanLike> = {
49
49
  [K in F]?: V;
50
50
  };
51
51
  /**
52
- * Accepted `$select` value: a field map, or raw SQL projections built with `raw()`
53
- * (e.g. ``[raw`*`, raw`LOG10(points)`.as('score')]``). The raw form is SQL-only.
52
+ * Accepted `$select` value: a field map, or raw SQL projections built with `sql()`
53
+ * (e.g. ``[sql`*`, sql`LOG10(points)`.as('score')]``). The raw form is SQL-only.
54
54
  */
55
- export type QuerySelectValue<E, Raw = QueryRaw> = QuerySelect<E> | readonly Raw[];
55
+ export type QuerySelectValue<E, Sql = QuerySql> = QuerySelect<E> | readonly Sql[];
56
56
  /**
57
57
  * Fields to exclude from the query result - `{ name: true }` blacklists fields.
58
58
  * Mutually exclusive with positive field selections in `$select`.
@@ -61,8 +61,8 @@ export type QueryExclude<E> = QuerySelect<E>;
61
61
  /**
62
62
  * relation population map.
63
63
  */
64
- export type QueryPopulate<E, Raw = QueryRaw, R extends keyof E = RelationKey<E>> = {
65
- [K in R]?: BooleanLike | QueryPopulateRelationOptions<E[K], Raw>;
64
+ export type QueryPopulate<E, Sql = QuerySql, R extends keyof E = RelationKey<E>> = {
65
+ [K in R]?: BooleanLike | QueryPopulateRelationOptions<E[K], Sql>;
66
66
  };
67
67
  /**
68
68
  * The key a read carries its relation tallies under. One spelling for the type and the runtime that
@@ -74,8 +74,8 @@ export declare const COUNT_RESULT_KEY = "_count";
74
74
  * which ones count: a correlated count in the read's own statement, so no related row is loaded. Comes
75
75
  * back under `_count`, which keeps it clear of a relation of the same name `$populate` filled.
76
76
  */
77
- export type QueryCount<E, Raw = QueryRaw, R extends keyof E = ToManyRelationKey<E>> = {
78
- [K in R]?: BooleanLike | QueryFilter<RelationTarget<E[K]>, Raw>;
77
+ export type QueryCount<E, Sql = QuerySql, R extends keyof E = ToManyRelationKey<E>> = {
78
+ [K in R]?: BooleanLike | QueryFilter<RelationTarget<E[K]>, Sql>;
79
79
  };
80
80
  /**
81
81
  * query conflict paths - subset of field keys used to detect upsert conflicts.
@@ -84,7 +84,7 @@ export type QueryConflictPaths<E> = QuerySelect<E, FieldKey<E>, true>;
84
84
  /**
85
85
  * Options to populate a relation declared as `V`, by its cardinality.
86
86
  */
87
- export type QueryPopulateRelationOptions<V, Raw = QueryRaw> = IsMany<V> extends true ? RelationQuery<RelationTarget<V>, Raw> : QueryUnique<RelationTarget<V>, Raw> & {
87
+ export type QueryPopulateRelationOptions<V, Sql = QuerySql> = IsMany<V> extends true ? RelationQuery<RelationTarget<V>, Sql> : QueryUnique<RelationTarget<V>, Sql> & {
88
88
  $required?: boolean;
89
89
  };
90
90
  /**
@@ -195,24 +195,24 @@ export type QueryPager = {
195
195
  /**
196
196
  * Which rows a statement addresses.
197
197
  */
198
- export type QueryFilter<E, Raw = QueryRaw> = {
198
+ export type QueryFilter<E, Sql = QuerySql> = {
199
199
  /**
200
200
  * filtering options.
201
201
  */
202
- $where?: QueryWhere<E, Raw>;
202
+ $where?: QueryWhere<E, Sql>;
203
203
  };
204
204
  /**
205
205
  * A filter plus the page `count` takes. No `$sort`: ordering picks *which* rows a page holds, never
206
206
  * how many, so a count that accepted one would promise an influence it cannot have.
207
207
  */
208
- export type QueryPage<E, Raw = QueryRaw> = QueryFilter<E, Raw> & QueryPager;
208
+ export type QueryPage<E, Sql = QuerySql> = QueryFilter<E, Sql> & QueryPager;
209
209
  /**
210
210
  * A filter plus the ordering and page `updateMany`/`deleteMany` take. Both settle the
211
211
  * rows they address with a SELECT first, so the page is portable rather than MySQL-only, and a
212
212
  * vector `$sort` is as valid here as on a read: it ranks the settle query's rows, which has the
213
213
  * projection list to hold the distance. `$lock` stays off these, declared on {@link Query} instead.
214
214
  */
215
- export type QuerySearch<E, Raw = QueryRaw> = QueryPage<E, Raw> & {
215
+ export type QuerySearch<E, Sql = QuerySql> = QueryPage<E, Sql> & {
216
216
  /**
217
217
  * sorting options.
218
218
  */
@@ -221,21 +221,21 @@ export type QuerySearch<E, Raw = QueryRaw> = QueryPage<E, Raw> & {
221
221
  /**
222
222
  * query options.
223
223
  */
224
- export type Query<E, Raw = QueryRaw> = {
224
+ export type Query<E, Sql = QuerySql> = {
225
225
  /**
226
226
  * field selection - `{ name: true }` whitelists fields, or raw SQL projections
227
- * (``[raw`LOG10(points)`.as('score')]``, SQL dialects only - MongoDB rejects the raw-array form).
227
+ * (``[sql`LOG10(points)`.as('score')]``, SQL dialects only - MongoDB rejects the raw-array form).
228
228
  * Mutually exclusive with `$exclude`.
229
229
  */
230
- $select?: QuerySelectValue<E, Raw>;
230
+ $select?: QuerySelectValue<E, Sql>;
231
231
  /**
232
232
  * relation population options.
233
233
  */
234
- $populate?: QueryPopulate<E, Raw>;
234
+ $populate?: QueryPopulate<E, Sql>;
235
235
  /**
236
236
  * how many rows each named relation holds, under `_count` on every row. See {@link QueryCount}.
237
237
  */
238
- $count?: QueryCount<E, Raw>;
238
+ $count?: QueryCount<E, Sql>;
239
239
  /**
240
240
  * field exclusion - `{ name: true }` blacklists fields. Mutually exclusive with positive `$select`.
241
241
  * Keys a relation is assembled from (a joined row's primary key, a to-many's foreign key) are kept
@@ -264,7 +264,7 @@ export type Query<E, Raw = QueryRaw> = {
264
264
  /**
265
265
  * filtering options.
266
266
  */
267
- $where?: QueryWhere<E, Raw>;
267
+ $where?: QueryWhere<E, Sql>;
268
268
  /**
269
269
  * Index from where start the search
270
270
  */
@@ -275,13 +275,13 @@ export type Query<E, Raw = QueryRaw> = {
275
275
  $limit?: number;
276
276
  };
277
277
  /**
278
- * A {@link Query} as it travels as JSON, which a `raw` SQL fragment cannot: what the browser client takes,
278
+ * A {@link Query} as it travels as JSON, which a `sql` SQL fragment cannot: what the browser client takes,
279
279
  * and what an RPC contract (tRPC, oRPC, TanStack Start) declares as its input.
280
280
  */
281
281
  export type WireQuery<E> = Query<E, never>;
282
282
  /**
283
283
  * The type of a clause's value, and where the clause may appear: a `relation` clause is also allowed in a
284
- * populated relation's own query, a `statement` clause only in the statement itself.
284
+ * populated relation's own query, a `sql` clause only in the statement itself.
285
285
  */
286
286
  export type QueryClause = {
287
287
  readonly value: 'object' | 'number' | 'boolean' | 'string';
@@ -354,7 +354,7 @@ export type QueryClauseOf<Shape extends Partial<QueryClause>> = {
354
354
  * A populated relation's own query: the clauses {@link QUERY_CLAUSES} gives the `relation` scope. Its runtime
355
355
  * check reads the same table, so the two cannot drift.
356
356
  */
357
- export type RelationQuery<E = object, Raw = QueryRaw> = Pick<Query<E, Raw>, QueryClauseOf<{
357
+ export type RelationQuery<E = object, Sql = QuerySql> = Pick<Query<E, Sql>, QueryClauseOf<{
358
358
  scope: 'relation';
359
359
  }>> & {
360
360
  $required?: boolean;
@@ -362,35 +362,35 @@ export type RelationQuery<E = object, Raw = QueryRaw> = Pick<Query<E, Raw>, Quer
362
362
  /**
363
363
  * options to get a single record.
364
364
  */
365
- export type QueryOne<E, Raw = QueryRaw> = Except<Query<E, Raw>, '$limit'>;
365
+ export type QueryOne<E, Sql = QuerySql> = Except<Query<E, Sql>, '$limit'>;
366
366
  /**
367
367
  * options to get an unique record.
368
368
  */
369
- export type QueryUnique<E, Raw = QueryRaw> = Pick<QueryOne<E, Raw>, '$select' | '$exclude' | '$populate' | '$where'>;
369
+ export type QueryUnique<E, Sql = QuerySql> = Pick<QueryOne<E, Sql>, '$select' | '$exclude' | '$populate' | '$where'>;
370
370
  /**
371
371
  * The clauses that shape a row, captured as key sets rather than maps: a naked type parameter skips
372
372
  * excess-property checks, while a key set fails its own constraint on a typo.
373
373
  * @internal
374
374
  */
375
- type QueryProjection<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E>, Raw = QueryRaw> = {
376
- $select?: QuerySelect<E, S, V> | readonly Raw[];
375
+ type QueryProjection<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E>, Sql = QuerySql> = {
376
+ $select?: QuerySelect<E, S, V> | readonly Sql[];
377
377
  $exclude?: QuerySelect<E, X, V>;
378
- $populate?: QueryPopulate<E, Raw, P>;
379
- $count?: QueryCount<E, Raw, C & ToManyRelationKey<E>>;
378
+ $populate?: QueryPopulate<E, Sql, P>;
379
+ $count?: QueryCount<E, Sql, C & ToManyRelationKey<E>>;
380
380
  };
381
381
  /**
382
382
  * A {@link Query} whose projection is captured, so {@link QueryFindResult} can shape the row.
383
383
  */
384
- export type QueryProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Raw = QueryRaw> = Query<E, Raw> & QueryProjection<E, S, V, X, P, C, Raw>;
384
+ export type QueryProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Sql = QuerySql> = Query<E, Sql> & QueryProjection<E, S, V, X, P, C, Sql>;
385
385
  /**
386
386
  * A {@link QueryOne} whose projection is captured, so {@link QueryFindResult} can shape the row.
387
387
  */
388
- export type QueryOneProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Raw = QueryRaw> = QueryOne<E, Raw> & QueryProjection<E, S, V, X, P, C, Raw>;
388
+ export type QueryOneProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Sql = QuerySql> = QueryOne<E, Sql> & QueryProjection<E, S, V, X, P, C, Sql>;
389
389
  /**
390
390
  * The query `findManyPage` takes: a {@link Query} paged by cursor instead of offset, so it has no `$skip` and
391
391
  * `$limit` is the page size. `$after` reads the page after a cursor, `$before` the page before it.
392
392
  */
393
- export type QueryKeyset<E, Raw = QueryRaw> = Except<Query<E, Raw>, '$skip'> & {
393
+ export type QueryKeyset<E, Sql = QuerySql> = Except<Query<E, Sql>, '$skip'> & {
394
394
  /** The page size, required here although `Query` leaves it optional. */
395
395
  $limit: number;
396
396
  /** A page's `endCursor`, to read the rows after it. */
@@ -399,7 +399,7 @@ export type QueryKeyset<E, Raw = QueryRaw> = Except<Query<E, Raw>, '$skip'> & {
399
399
  $before?: string;
400
400
  };
401
401
  /** A {@link QueryKeyset} with its projection captured, so {@link QueryFindResult} can narrow the row. */
402
- export type QueryKeysetProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Raw = QueryRaw> = QueryKeyset<E, Raw> & QueryProjection<E, S, V, X, P, C, Raw>;
402
+ export type QueryKeysetProjected<E, S extends FieldKey<E>, V, X extends FieldKey<E>, P extends RelationKey<E>, C extends RelationKey<E> = never, Sql = QuerySql> = QueryKeyset<E, Sql> & QueryProjection<E, S, V, X, P, C, Sql>;
403
403
  /**
404
404
  * One page of `findManyPage`. Each cursor is opaque, and absent on an empty page. The flag in the reading
405
405
  * direction is exact. The other one only says whether the page was read from a cursor (`hasPrevPage` forward,
@@ -1,6 +1,6 @@
1
1
  import type { FieldKey, FieldKeyOf, RelationKey, RelationTarget } from './entity.js';
2
2
  import type { QueryPager, QuerySelect, QuerySortDirection } from './query.js';
3
- import type { QueryRaw } from './queryRaw.js';
3
+ import type { QuerySql } from './querySql.js';
4
4
  import type { QueryWhere, QueryWhereFieldValue } from './queryWhere.js';
5
5
  import type { ExactlyOne, IsMany, RejectKeys } from './utility.js';
6
6
  /** The columns `$group` names by a literal `true`, so an uninferred `$group`, its own constraint, names none. */
@@ -73,7 +73,7 @@ export type QueryAggregateFn<E> = ExactlyOne<QueryAggregateArgMap<E>> & {
73
73
  readonly $where?: QueryAggregateWhere<E>;
74
74
  };
75
75
  /** What an aggregate's own `$where` reads: the entity's fields, since a relation there is a subquery inside it. */
76
- type QueryAggregateWhere<E> = QueryWhere<E, QueryRaw, FieldKey<E>>;
76
+ type QueryAggregateWhere<E> = QueryWhere<E, QuerySql, FieldKey<E>>;
77
77
  /** An aggregate's `$where` naming a key it does not have, refused: a captured `$select` skips the excess-property check. */
78
78
  type AggregateWhereKeys<E, Fn> = Fn extends {
79
79
  readonly $where: infer W;