uql-orm 0.104.0 → 0.105.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 (143) hide show
  1. package/README.md +24 -10
  2. package/dist/browser/uql-browser.min.js +2 -2
  3. package/dist/browser/uql-browser.min.js.map +7 -7
  4. package/dist/dialect/abstractSqlDialect.d.ts +6 -4
  5. package/dist/dialect/abstractSqlDialect.js +35 -32
  6. package/dist/dialect/aliases.d.ts +2 -0
  7. package/dist/dialect/aliases.js +2 -0
  8. package/dist/dialect/jsonSql.js +2 -2
  9. package/dist/dialect/mysqlLikeSqlDialect.d.ts +1 -1
  10. package/dist/dialect/mysqlLikeSqlDialect.js +1 -1
  11. package/dist/dialect/operators.js +2 -4
  12. package/dist/dialect/queryJoins.d.ts +2 -0
  13. package/dist/dialect/vectorSqlDialect.d.ts +1 -1
  14. package/dist/dialect/vectorSqlDialect.js +1 -1
  15. package/dist/entity/column.d.ts +3 -0
  16. package/dist/entity/column.js +3 -0
  17. package/dist/entity/columnOptionsBuilder.d.ts +54 -0
  18. package/dist/entity/columnOptionsBuilder.js +108 -0
  19. package/dist/entity/decorator/bag.d.ts +4 -4
  20. package/dist/entity/decorator/entity.d.ts +2 -19
  21. package/dist/entity/decorator/entity.js +3 -37
  22. package/dist/entity/decorator/members.d.ts +46 -76
  23. package/dist/entity/decorator/members.js +18 -7
  24. package/dist/entity/index.d.ts +2 -1
  25. package/dist/entity/index.js +2 -1
  26. package/dist/entity/metadata/definition.d.ts +10 -24
  27. package/dist/entity/metadata/definition.js +329 -147
  28. package/dist/entity/metadata/schemaFixture/animal.d.ts +54 -0
  29. package/dist/entity/metadata/schemaFixture/animal.js +7 -0
  30. package/dist/entity/metadata/schemaFixture/author.d.ts +140 -0
  31. package/dist/entity/metadata/schemaFixture/author.js +25 -0
  32. package/dist/entity/metadata/schemaFixture/book.d.ts +192 -0
  33. package/dist/entity/metadata/schemaFixture/book.js +22 -0
  34. package/dist/http/query.js +12 -13
  35. package/dist/index.d.ts +2 -2
  36. package/dist/index.js +2 -1
  37. package/dist/mariadb/mariaDialect.js +1 -1
  38. package/dist/mariadb/mariadbQuerier.js +1 -3
  39. package/dist/migrate/builder/columnBuilder.d.ts +20 -68
  40. package/dist/migrate/builder/columnBuilder.js +104 -110
  41. package/dist/migrate/builder/migrationBuilder.d.ts +3 -3
  42. package/dist/migrate/builder/migrationBuilder.js +7 -6
  43. package/dist/migrate/builder/tableBuilder.d.ts +3 -55
  44. package/dist/migrate/builder/tableBuilder.js +88 -204
  45. package/dist/migrate/builder/types.d.ts +52 -151
  46. package/dist/migrate/builder/types.js +0 -6
  47. package/dist/migrate/codegen/entityCodeGenerator.d.ts +2 -2
  48. package/dist/migrate/codegen/entityCodeGenerator.js +24 -24
  49. package/dist/migrate/codegen/fieldOptionsSource.d.ts +3 -1
  50. package/dist/migrate/codegen/fieldOptionsSource.js +35 -34
  51. package/dist/migrate/codegen/indexEntrySource.d.ts +16 -0
  52. package/dist/migrate/codegen/{indexDecoratorSource.js → indexEntrySource.js} +54 -27
  53. package/dist/migrate/ddl/defaultSql.js +7 -6
  54. package/dist/migrate/ddl/indexCapabilities.d.ts +8 -7
  55. package/dist/migrate/ddl/indexCapabilities.js +26 -13
  56. package/dist/migrate/ddl/indexDdl.d.ts +13 -13
  57. package/dist/migrate/ddl/indexDdl.js +33 -30
  58. package/dist/migrate/ddl/mysqlIndexDdl.d.ts +6 -11
  59. package/dist/migrate/ddl/mysqlIndexDdl.js +17 -28
  60. package/dist/migrate/ddl/pgIndexDdl.d.ts +2 -2
  61. package/dist/migrate/ddl/sqliteIndexDdl.d.ts +2 -2
  62. package/dist/migrate/drift/driftDetector.js +2 -2
  63. package/dist/migrate/generator/definitionToNode.d.ts +8 -2
  64. package/dist/migrate/generator/definitionToNode.js +4 -5
  65. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +11 -2
  66. package/dist/migrate/introspection/jsonIndexEntry.d.ts +6 -0
  67. package/dist/migrate/introspection/jsonIndexEntry.js +120 -0
  68. package/dist/migrate/introspection/mysqlIntrospector.d.ts +4 -4
  69. package/dist/migrate/introspection/mysqlIntrospector.js +25 -21
  70. package/dist/migrate/introspection/postgresIntrospector.d.ts +1 -1
  71. package/dist/migrate/introspection/postgresIntrospector.js +3 -4
  72. package/dist/migrate/introspection/sqliteIntrospector.js +24 -9
  73. package/dist/migrate/introspection/tableSchemaAST.js +5 -1
  74. package/dist/migrate/schemaChange.d.ts +3 -3
  75. package/dist/migrate/schemaChange.js +3 -2
  76. package/dist/migrate/schemaGenerator.js +1 -1
  77. package/dist/migrate/storage/databaseStorage.js +4 -4
  78. package/dist/mongodb/mongoDialect.d.ts +33 -36
  79. package/dist/mongodb/mongoDialect.js +118 -32
  80. package/dist/mongodb/mongoIntrospector.d.ts +3 -1
  81. package/dist/mongodb/mongoIntrospector.js +11 -5
  82. package/dist/mongodb/mongoSchemaGenerator.js +35 -27
  83. package/dist/mongodb/mongodbQuerier.d.ts +1 -11
  84. package/dist/mongodb/mongodbQuerier.js +9 -43
  85. package/dist/querier/abstractQuerier.d.ts +0 -1
  86. package/dist/querier/abstractQuerier.js +1 -20
  87. package/dist/querier/keyset.js +3 -3
  88. package/dist/schema/declaredColumn.d.ts +11 -0
  89. package/dist/schema/declaredColumn.js +21 -0
  90. package/dist/schema/indexColumns.d.ts +0 -3
  91. package/dist/schema/indexColumns.js +11 -7
  92. package/dist/schema/indexDifferences.d.ts +10 -5
  93. package/dist/schema/indexDifferences.js +42 -28
  94. package/dist/schema/schemaASTBuilder.js +28 -36
  95. package/dist/schema/schemaASTDiffer.js +8 -4
  96. package/dist/schema/sqlExpression.d.ts +21 -17
  97. package/dist/schema/sqlExpression.js +11 -23
  98. package/dist/type/column.d.ts +328 -0
  99. package/dist/type/column.js +2 -0
  100. package/dist/type/config.d.ts +1 -1
  101. package/dist/type/dialect.d.ts +2 -1
  102. package/dist/type/dialect.js +1 -0
  103. package/dist/type/entity.d.ts +290 -279
  104. package/dist/type/entity.js +6 -1
  105. package/dist/type/index.d.ts +2 -0
  106. package/dist/type/index.js +2 -0
  107. package/dist/type/migration.d.ts +5 -5
  108. package/dist/type/query.d.ts +45 -41
  109. package/dist/type/query.js +2 -3
  110. package/dist/type/queryAggregate.d.ts +22 -12
  111. package/dist/type/querySql.d.ts +20 -4
  112. package/dist/type/querySql.js +27 -9
  113. package/dist/type/schemaEntity.d.ts +190 -0
  114. package/dist/type/schemaEntity.js +1 -0
  115. package/dist/type/utility.d.ts +0 -6
  116. package/dist/type/vector.d.ts +1 -1
  117. package/dist/util/ddlExpression.util.d.ts +12 -13
  118. package/dist/util/ddlExpression.util.js +12 -21
  119. package/dist/util/dialect.util.d.ts +11 -5
  120. package/dist/util/dialect.util.js +31 -37
  121. package/dist/util/field.util.d.ts +10 -9
  122. package/dist/util/field.util.js +14 -10
  123. package/dist/util/fieldOption.util.d.ts +11 -95
  124. package/dist/util/fieldOption.util.js +49 -16
  125. package/dist/util/hook.util.d.ts +2 -14
  126. package/dist/util/hook.util.js +3 -16
  127. package/dist/util/index.d.ts +1 -0
  128. package/dist/util/index.js +1 -0
  129. package/dist/util/indexEntry.util.d.ts +45 -0
  130. package/dist/util/indexEntry.util.js +138 -0
  131. package/dist/util/relationQuery.util.d.ts +0 -1
  132. package/dist/util/relationQuery.util.js +0 -5
  133. package/dist/util/sql.d.ts +10 -7
  134. package/dist/util/sql.js +34 -16
  135. package/dist/util/sql.util.d.ts +4 -5
  136. package/dist/util/sql.util.js +7 -16
  137. package/dist/util/string.util.d.ts +2 -0
  138. package/dist/util/string.util.js +4 -0
  139. package/dist/util/uqlError.d.ts +1 -1
  140. package/dist/util/uqlError.js +1 -1
  141. package/package.json +1 -1
  142. package/skills/uql-orm/SKILL.md +76 -25
  143. package/dist/migrate/codegen/indexDecoratorSource.d.ts +0 -16
@@ -1,29 +1,17 @@
1
1
  import { QuerySql, SQL_VALUE_NAMES } from '../type/index.js';
2
2
  import { isRecord } from '../util/object.util.js';
3
3
  import { SQL_VALUES } from '../util/sql.js';
4
- /**
5
- * A column default that is SQL rather than a literal, whether an entity or a migration declares it or
6
- * introspection reads it back. It is a class, not a plain object, so a JSON default cannot pass for one.
7
- */
8
- export class SqlExpression {
9
- kind;
10
- sql;
11
- /** `sql` is set only for the `sql` kind, which carries its own text verbatim. */
12
- constructor(kind, sql) {
13
- this.kind = kind;
14
- this.sql = sql;
15
- }
16
- static isExpression(value) {
17
- return value instanceof SqlExpression;
18
- }
4
+ const EXPRESSION = Symbol('sqlExpression');
5
+ export const SqlExpression = {
6
+ named: (kind) => ({ [EXPRESSION]: true, kind }),
7
+ raw: (sql) => ({ [EXPRESSION]: true, kind: 'sql', sql }),
19
8
  /** Wraps `sql` in parentheses, which every engine accepts for a default expression and SQLite and MySQL require. */
20
- static parenthesized(sql) {
21
- return new SqlExpression('sql', `(${sql})`);
22
- }
23
- /** Its SQL, or its kind, as diffs and drift reports show it. */
24
- toString() {
25
- return this.sql ?? this.kind;
26
- }
9
+ parenthesized: (sql) => SqlExpression.raw(`(${sql})`),
10
+ isExpression: (value) => typeof value === 'object' && value !== null && EXPRESSION in value,
11
+ };
12
+ /** Its SQL, or its kind, as diffs and drift reports show it. */
13
+ export function sqlExpressionText(expression) {
14
+ return expression.sql ?? expression.kind;
27
15
  }
28
16
  const NAME_OF = new Map(SQL_VALUE_NAMES.map((name) => [SQL_VALUES[name], name]));
29
17
  /**
@@ -33,7 +21,7 @@ const NAME_OF = new Map(SQL_VALUE_NAMES.map((name) => [SQL_VALUES[name], name]))
33
21
  export function schemaDefault(value, compile) {
34
22
  const name = NAME_OF.get(value);
35
23
  if (name) {
36
- return new SqlExpression(name);
24
+ return SqlExpression.named(name);
37
25
  }
38
26
  return value instanceof QuerySql ? SqlExpression.parenthesized(compile(value)) : value;
39
27
  }
@@ -0,0 +1,328 @@
1
+ import type { ForeignKeyAction } from '../schema/types.js';
2
+ import type { TYPE_BOUNDS, VALUE_DECIDERS } from '../util/fieldOption.util.js';
3
+ import type { BlobColumnType, BooleanColumnType, ColumnType, DateColumnType, DdlDefault, JsonColumnType, NumericColumnType, StringColumnType, VectorColumnType, FieldOptions, HasCompositeKey, IdValue, JsonShape, OnFieldCallback, ShapeValue, StampEvent } from './entity.js';
4
+ import type { QuerySql } from './querySql.js';
5
+ import type { ReferencedKey } from './schemaEntity.js';
6
+ import type { Json, Type } from './utility.js';
7
+ import type { VectorDistance } from './vector.js';
8
+ /** Where a column builder holds its options, so every string key of a builder is a method. */
9
+ export declare const COLUMN_OPTIONS: unique symbol;
10
+ /** What a builder has written and the value a row holds, carried for the type level alone: nothing sets it. */
11
+ export declare const COLUMN_TYPE: unique symbol;
12
+ /**
13
+ * A column as `f` declares it: the options the registry reads, and for the type level the options written so
14
+ * far, `O`, and the value a row holds, `V`, never `null`, which `nullable()` adds where the row is read.
15
+ */
16
+ export type Column<O = unknown, V = unknown> = {
17
+ readonly [COLUMN_OPTIONS]: FieldOptions;
18
+ readonly [COLUMN_TYPE]?: {
19
+ readonly options: O;
20
+ readonly value: V;
21
+ };
22
+ };
23
+ /** The options a builder has written. */
24
+ export type ColumnOptionsOf<C> = C extends Column<infer O> ? O : never;
25
+ /** The value a column holds, `null` aside. */
26
+ export type ColumnValueOf<C> = C extends Column<unknown, infer V> ? V : never;
27
+ /** What a builder writes that lets an insert leave the column out: something fills it. */
28
+ export type FilledOptions = {
29
+ readonly defaultValue: unknown;
30
+ } | {
31
+ readonly onInsert: unknown;
32
+ } | {
33
+ readonly autoIncrement: true;
34
+ };
35
+ /** The `null` a column's row holds: none unless `nullable()` said so. */
36
+ export type NullOf<O> = O extends {
37
+ readonly nullable: true;
38
+ } ? null : never;
39
+ /** A builder that has written none of `K`; the index signature keeps it from being a weak type every builder fails. */
40
+ type Lacking<K extends keyof FieldOptions> = Column<{
41
+ readonly [P in K]?: undefined;
42
+ } & {
43
+ readonly [key: string]: unknown;
44
+ }>;
45
+ /** The options that decide what a column holds: a column the database writes takes none. */
46
+ type ValueDecider = (typeof VALUE_DECIDERS)[number];
47
+ /** What bounds a type: a column type written out as SQL carries its own. */
48
+ type TypeBound = (typeof TYPE_BOUNDS)[number];
49
+ /** A builder whose SQL type is not written out as `sql`, which is what leaves a bound a bound on the column. */
50
+ type TypeNotSql = Column<{
51
+ readonly columnType?: ColumnType;
52
+ } & {
53
+ readonly [key: string]: unknown;
54
+ }>;
55
+ /** The builder of each column family, which is what keeps an option off a column it means nothing on. */
56
+ interface Builders<O, V> {
57
+ readonly numeric: NumericColumn<O, V>;
58
+ readonly string: StringColumn<O, V>;
59
+ readonly date: DateColumn<O, V>;
60
+ readonly boolean: ColumnBuilder<O, V, 'boolean'>;
61
+ readonly json: ColumnBuilder<O, V, 'json'>;
62
+ readonly blob: ColumnBuilder<O, V, 'blob'>;
63
+ readonly vector: VectorColumn<O, V>;
64
+ /** A column whose family is known only at run time: a foreign key's is its target key's, a runtime schema's its data's. */
65
+ readonly any: ColumnBuilder<O, V, 'any'>;
66
+ }
67
+ type Family = keyof Builders<unknown, unknown>;
68
+ /** The same builder, having written `X` too. */
69
+ type With<O, V, X, F extends Family> = Builders<O & X, V>[F];
70
+ /** What every column takes. */
71
+ export interface ColumnBuilder<in out O, in out V, F extends Family> extends Column<O, V> {
72
+ /** Lets the column hold `null`, which a read then answers with: a column is `NOT NULL` otherwise. */
73
+ nullable(this: Lacking<'isId'>): With<O, V, {
74
+ readonly nullable: true;
75
+ }, F>;
76
+ /** Makes it the primary key, or a column of a composite one. */
77
+ id(this: Lacking<'nullable'>): With<O, V, {
78
+ readonly isId: true;
79
+ }, F>;
80
+ /** The column's DDL default: a value, or SQL the database evaluates per row (`currentTimestamp`, `sql`). */
81
+ default(value: DdlDefault<V> | QuerySql): With<O, V, {
82
+ readonly defaultValue: unknown;
83
+ }, F>;
84
+ /** The value uql writes on insert, where the row has none: a value, SQL or a function returning either. */
85
+ onInsert(value: OnFieldCallback<V>): With<O, V, {
86
+ readonly onInsert: unknown;
87
+ }, F>;
88
+ /** The value uql writes on each update. */
89
+ onUpdate(this: Lacking<'updatable'>, value: OnFieldCallback<V>): With<O, V, {
90
+ readonly onUpdate: unknown;
91
+ }, F>;
92
+ /** Leaves the column out of every update. */
93
+ updatable(this: Lacking<'onUpdate'>, updatable: false): With<O, V, {
94
+ readonly updatable: false;
95
+ }, F>;
96
+ /** Makes a delete stamp the column instead, and reads skip stamped rows: `new Date()` unless given a value. */
97
+ softDelete(value?: OnFieldCallback<V>): With<O, V, {
98
+ readonly softDelete: unknown;
99
+ }, F>;
100
+ unique(): With<O, V, {
101
+ readonly unique: true;
102
+ }, F>;
103
+ /** An index over the column, named or not; `false` keeps a foreign key column unindexed. */
104
+ index(name?: string | false): With<O, V, {
105
+ readonly index: unknown;
106
+ }, F>;
107
+ /** The column's name, where it is not the field's. */
108
+ name(column: string): With<O, V, {
109
+ readonly name: string;
110
+ }, F>;
111
+ comment(text: string): With<O, V, {
112
+ readonly comment: string;
113
+ }, F>;
114
+ /** Leaves the column out of a read naming no fields. */
115
+ eager(eager: false): With<O, V, {
116
+ readonly eager: false;
117
+ }, F>;
118
+ /** The SQL type where it differs from the one the builder implies; an engine's own, `sql`citext``, verbatim. */
119
+ columnType(type: ColumnType): With<O, V, {
120
+ readonly columnType: ColumnType;
121
+ }, F>;
122
+ columnType(this: Lacking<TypeBound>, type: QuerySql): With<O, V, {
123
+ readonly columnType: QuerySql;
124
+ }, F>;
125
+ /** A foreign key to `entity`'s key, which the column has to hold the kind of: `f.number().references(() => User)`. */
126
+ references<C extends Type<object>>(entity: () => C & HoldsKey<C, V>): With<O, V, {
127
+ readonly references: () => C;
128
+ }, F>;
129
+ /** The foreign key's delete action. */
130
+ onDelete(this: Column<{
131
+ readonly references: unknown;
132
+ }>, action: ForeignKeyAction): With<O, V, {
133
+ readonly onDelete: ForeignKeyAction;
134
+ }, F>;
135
+ /** Narrows the value a row holds, a branded id or a literal union: `f.uuid().narrow<UserId>()`. */
136
+ narrow<T extends V>(): Builders<O, T>[F];
137
+ /**
138
+ * A column the database computes from `expression`, read in each query naming it; `stored()` keeps it. A relation
139
+ * aggregate is no column's SQL: it is read on each query, so `@Computed` or `aggregates` declares one.
140
+ */
141
+ as(this: Lacking<ValueDecider | 'isId'>, expression: QuerySql & {
142
+ readonly spec?: never;
143
+ }): ComputedColumn<O & {
144
+ readonly computed: QuerySql;
145
+ }, V>;
146
+ }
147
+ export interface NumericColumn<in out O, in out V> extends ColumnBuilder<O, V, 'numeric'> {
148
+ /** Digits in all: a `DECIMAL`, read as a number where the builder is `f.number()`, rounding where it must. */
149
+ precision(this: TypeNotSql, digits: number): NumericColumn<O & {
150
+ readonly precision: number;
151
+ }, V>;
152
+ scale(this: TypeNotSql, digits: number): NumericColumn<O & {
153
+ readonly scale: number;
154
+ }, V>;
155
+ /** Has the database generate the value, which a numeric sole key does unless `autoIncrement(false)` says otherwise. */
156
+ autoIncrement(): NumericColumn<O & {
157
+ readonly autoIncrement: true;
158
+ }, V>;
159
+ autoIncrement(generated: false): NumericColumn<O & {
160
+ readonly autoIncrement: false;
161
+ }, V>;
162
+ }
163
+ export interface StringColumn<in out O, in out V> extends ColumnBuilder<O, V, 'string'> {
164
+ length(this: TypeNotSql, length: number): StringColumn<O & {
165
+ readonly length: number;
166
+ }, V>;
167
+ }
168
+ export interface DateColumn<in out O, in out V> extends ColumnBuilder<O, V, 'date'> {
169
+ /** Fractional-second digits. */
170
+ precision(this: TypeNotSql, digits: number): DateColumn<O & {
171
+ readonly precision: number;
172
+ }, V>;
173
+ }
174
+ export interface VectorColumn<in out O, in out V> extends ColumnBuilder<O, V, 'vector'> {
175
+ dimensions(this: TypeNotSql, dimensions: number): VectorColumn<O & {
176
+ readonly dimensions: number;
177
+ }, V>;
178
+ /** The metric a search on it uses unless it names its own `$distance`; by default its vector index's, else cosine. */
179
+ distance(distance: VectorDistance): VectorColumn<O & {
180
+ readonly distance: VectorDistance;
181
+ }, V>;
182
+ }
183
+ /** A column the database computes, which nothing writes. */
184
+ export interface ComputedColumn<in out O, in out V> extends Column<O, V> {
185
+ /**
186
+ * Keeps it: a generated column, or with events a stamp a trigger writes on each, whoever writes the row,
187
+ * which keeps a `currentTimestamp` current where `onUpdate` sees only uql's writes.
188
+ */
189
+ stored(events?: readonly StampEvent[]): ComputedColumn<O & {
190
+ readonly stored: unknown;
191
+ }, V>;
192
+ }
193
+ /** The version column, an optimistic lock: an update matches the version it read and writes the next. */
194
+ export interface VersionColumn<in out O, in out V> extends Column<O, V> {
195
+ name(column: string): VersionColumn<O & {
196
+ readonly name: string;
197
+ }, V>;
198
+ comment(text: string): VersionColumn<O & {
199
+ readonly comment: string;
200
+ }, V>;
201
+ }
202
+ /** A key's kind as a join compares it: a number and a bigint both integers, so a BIGINT column holds either key. */
203
+ type ValueKind<T> = T extends number | bigint ? number | bigint : T;
204
+ /** Refuses a target whose key is another kind of value than the column holds, which no join matches. */
205
+ type HoldsKey<C, V> = [ValueKind<NonNullable<ReferencedKey<C>>>] extends [ValueKind<V>] ? unknown : {
206
+ readonly __columnMustHoldReferencedKey: ReferencedKey<C>;
207
+ };
208
+ /** The column types holding an exact decimal, read as its text: a JS number would round it. */
209
+ type DecimalType = 'decimal' | 'numeric';
210
+ /** What a JSON column holds: its shape's payload, or any document. */
211
+ type JsonValue<S> = [S] extends [never] ? Json : ShapeValue<S> extends infer P extends object | string | number | boolean ? Json<P> : Json;
212
+ /** The key a column referencing `C` holds, or a named complaint for a composite one, which no one column holds. */
213
+ type ReferenceValue<C> = C extends Type<infer E> ? HasCompositeKey<E> extends true ? {
214
+ readonly __compositeKeyNeedsAColumnPerKey: true;
215
+ } : NonNullable<IdValue<E>> : never;
216
+ /** The builders, one per value a column holds; `column` takes any SQL type, its family deciding what it offers. */
217
+ export type ColumnFactory = {
218
+ string(): StringColumn<{
219
+ readonly type: StringConstructor;
220
+ }, string>;
221
+ text(): StringColumn<{
222
+ readonly type: 'text';
223
+ }, string>;
224
+ uuid(): StringColumn<{
225
+ readonly type: 'uuid';
226
+ }, string>;
227
+ number(): NumericColumn<{
228
+ readonly type: NumberConstructor;
229
+ }, number>;
230
+ bigint(): NumericColumn<{
231
+ readonly type: BigIntConstructor;
232
+ }, bigint>;
233
+ /** An exact decimal, read as its text: a JS number would round it. `f.number().precision()` opts in to that. */
234
+ decimal(): NumericColumn<{
235
+ readonly type: 'decimal';
236
+ }, string>;
237
+ decimal(precision: number): NumericColumn<{
238
+ readonly type: 'decimal';
239
+ readonly precision: number;
240
+ }, string>;
241
+ decimal(precision: number, scale: number): NumericColumn<{
242
+ readonly type: 'decimal';
243
+ readonly precision: number;
244
+ readonly scale: number;
245
+ }, string>;
246
+ boolean(): ColumnBuilder<{
247
+ readonly type: BooleanConstructor;
248
+ }, boolean, 'boolean'>;
249
+ date(): DateColumn<{
250
+ readonly type: DateConstructor;
251
+ }, Date>;
252
+ json(): ColumnBuilder<{
253
+ readonly type: 'json';
254
+ }, Json, 'json'>;
255
+ json<const S extends JsonShape>(shape: S): ColumnBuilder<{
256
+ readonly type: 'json';
257
+ readonly shape: S;
258
+ }, JsonValue<S>, 'json'>;
259
+ jsonb(): ColumnBuilder<{
260
+ readonly type: 'jsonb';
261
+ }, Json, 'json'>;
262
+ jsonb<const S extends JsonShape>(shape: S): ColumnBuilder<{
263
+ readonly type: 'jsonb';
264
+ readonly shape: S;
265
+ }, JsonValue<S>, 'json'>;
266
+ vector(dimensions: number): VectorColumn<{
267
+ readonly type: 'vector';
268
+ readonly dimensions: number;
269
+ }, readonly number[]>;
270
+ /** The values the column accepts, a `CHECK (col IN (...))` on every SQL engine, and the row's literal union. */
271
+ enum<const M extends readonly string[]>(members: M): StringColumn<{
272
+ readonly type: StringConstructor;
273
+ readonly enum: M;
274
+ }, M[number]>;
275
+ enum<const M extends readonly number[]>(members: M): NumericColumn<{
276
+ readonly type: NumberConstructor;
277
+ readonly enum: M;
278
+ }, M[number]>;
279
+ /**
280
+ * The optimistic lock: `NOT NULL DEFAULT 0`, and the class's `[versionKey]` brand makes each update carry it. A
281
+ * `BigInt` one counts past 2^53.
282
+ */
283
+ version(): VersionColumn<{
284
+ readonly type: NumberConstructor;
285
+ readonly version: true;
286
+ }, number>;
287
+ version(type: BigIntConstructor): VersionColumn<{
288
+ readonly type: BigIntConstructor;
289
+ readonly version: true;
290
+ }, bigint>;
291
+ /** A column of SQL type `type`, offering what its family takes. */
292
+ column(type: DecimalType): NumericColumn<{
293
+ readonly type: DecimalType;
294
+ }, string>;
295
+ column(type: Exclude<NumericColumnType, DecimalType>): NumericColumn<{
296
+ readonly type: NumericColumnType;
297
+ }, number | bigint>;
298
+ column(type: StringColumnType): StringColumn<{
299
+ readonly type: StringColumnType;
300
+ }, string>;
301
+ column(type: 'time'): DateColumn<{
302
+ readonly type: 'time';
303
+ }, string>;
304
+ column(type: Exclude<DateColumnType, 'time'>): DateColumn<{
305
+ readonly type: DateColumnType;
306
+ }, Date>;
307
+ column(type: VectorColumnType): VectorColumn<{
308
+ readonly type: VectorColumnType;
309
+ }, readonly number[]>;
310
+ column(type: BooleanColumnType): ColumnBuilder<{
311
+ readonly type: BooleanColumnType;
312
+ }, boolean, 'boolean'>;
313
+ column(type: JsonColumnType): ColumnBuilder<{
314
+ readonly type: JsonColumnType;
315
+ }, Json, 'json'>;
316
+ column(type: BlobColumnType): ColumnBuilder<{
317
+ readonly type: BlobColumnType;
318
+ }, Uint8Array, 'blob'>;
319
+ /** A column whose type is data, as a schema built at run time declares one. */
320
+ column(type: ColumnType): ColumnBuilder<{
321
+ readonly type: ColumnType;
322
+ }, unknown, 'any'>;
323
+ /** A foreign key to `entity`'s key, its column typed as that key is. */
324
+ references<C extends Type<object>>(entity: () => C): ColumnBuilder<{
325
+ readonly references: () => C;
326
+ }, ReferenceValue<C>, 'any'>;
327
+ };
328
+ export {};
@@ -0,0 +1,2 @@
1
+ /** Where a column builder holds its options, so every string key of a builder is a method. */
2
+ export const COLUMN_OPTIONS = Symbol('columnOptions');
@@ -15,7 +15,7 @@ export interface Config {
15
15
  pool: QuerierPool<Querier, MigratorDialect>;
16
16
  /**
17
17
  * List of entity classes to be managed by the ORM.
18
- * If omitted, classes that completed `defineEntity` (including via `@Entity()`) are discovered via `getEntities()`.
18
+ * If omitted, every registered entity (`@Entity()` or `defineEntity`) is discovered via `getEntities()`.
19
19
  */
20
20
  entities?: Type<object>[];
21
21
  /**
@@ -121,7 +121,7 @@ export interface DialectFeatures {
121
121
  * (`boundedText`, the Postgres family), or always bounded, 255 by default (`varchar`).
122
122
  */
123
123
  readonly stringSizing: 'text' | 'boundedText' | 'varchar';
124
- /** Whether the engine has unsigned integers, so `@Field({ unsigned: true })` reaches the column. */
124
+ /** Whether the engine has unsigned integers, so an unsigned column type reaches the database. */
125
125
  readonly supportsUnsigned: boolean;
126
126
  /**
127
127
  * Whether the engine has `DECLARE`/`FETCH FORWARD`/`CLOSE` cursors, which a querier with no stream of
@@ -443,6 +443,7 @@ export declare const INDEX_FEATURE_LABELS: {
443
443
  readonly include: 'covering indexes (INCLUDE)';
444
444
  readonly jsonPath: 'indexes over a path inside a JSON column';
445
445
  readonly jsonArray: 'multi-valued indexes over a JSON array';
446
+ readonly fulltextPath: 'fulltext indexes over a path inside a JSON column, which a search of whole columns never reads';
446
447
  };
447
448
  /** Derived from the labels, so a feature cannot be added without the words an error reports it in. */
448
449
  export type IndexFeature = keyof typeof INDEX_FEATURE_LABELS;
@@ -14,4 +14,5 @@ export const INDEX_FEATURE_LABELS = {
14
14
  include: 'covering indexes (INCLUDE)',
15
15
  jsonPath: 'indexes over a path inside a JSON column',
16
16
  jsonArray: 'multi-valued indexes over a JSON array',
17
+ fulltextPath: 'fulltext indexes over a path inside a JSON column, which a search of whole columns never reads',
17
18
  };