qubu 0.0.0 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canonical-BbnqavJm.mjs +972 -0
- package/dist/codegen.d.mts +107 -0
- package/dist/codegen.mjs +1199 -0
- package/dist/column-CXMxx8Hq.mjs +118 -0
- package/dist/complete-D5Djh-zo.mjs +1788 -0
- package/dist/complete-types-BdFqUfbb.d.mts +371 -0
- package/dist/core.d.mts +33 -0
- package/dist/core.mjs +36 -0
- package/dist/ddl.d.mts +118 -0
- package/dist/ddl.mjs +1120 -0
- package/dist/dialect-b2-Z6uBF.mjs +13 -0
- package/dist/diff.d.mts +2 -0
- package/dist/diff.mjs +883 -0
- package/dist/drizzle-mysql.d.mts +24 -0
- package/dist/drizzle-mysql.mjs +72 -0
- package/dist/drizzle-postgres.d.mts +24 -0
- package/dist/drizzle-postgres.mjs +73 -0
- package/dist/drizzle-sqlite.d.mts +24 -0
- package/dist/drizzle-sqlite.mjs +82 -0
- package/dist/drizzle.d.mts +13 -0
- package/dist/drizzle.mjs +2 -0
- package/dist/errors-BGCoLe_r.mjs +14 -0
- package/dist/errors-Dxv73YJu.mjs +26 -0
- package/dist/explain-CkIK13L_.mjs +98 -0
- package/dist/index-Ds7-mhJi.d.mts +146 -0
- package/dist/index-Dug5HnLB.d.mts +204 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1276 -0
- package/dist/introspection.d.mts +117 -0
- package/dist/introspection.mjs +4341 -0
- package/dist/json-CUZlv4HT.mjs +169 -0
- package/dist/migration.d.mts +215 -0
- package/dist/migration.mjs +1161 -0
- package/dist/mysql-DqkqXB6A.mjs +355 -0
- package/dist/mysql.d.mts +5 -0
- package/dist/mysql.mjs +50 -0
- package/dist/naming-QVCOnSj2.mjs +20 -0
- package/dist/omit-OxV58AwX.mjs +5 -0
- package/dist/on-conflict-BxnxubMb.mjs +143 -0
- package/dist/postgres-DEBBeh52.mjs +235 -0
- package/dist/postgres.d.mts +123 -0
- package/dist/postgres.mjs +52 -0
- package/dist/registry-BufIskVN.mjs +569 -0
- package/dist/relational-DCZrrNia.mjs +77 -0
- package/dist/runtime-BTr-MTlo.mjs +193 -0
- package/dist/schema.d.mts +2 -0
- package/dist/schema.mjs +5 -0
- package/dist/serialize-PF1cfH2P.mjs +556 -0
- package/dist/snapshot-CWPgzxNx.mjs +392 -0
- package/dist/snapshot.d.mts +4 -0
- package/dist/snapshot.mjs +8 -0
- package/dist/source-DUoJVXmL.mjs +68 -0
- package/dist/sqlite-BU6DBxef.mjs +320 -0
- package/dist/sqlite.d.mts +5 -0
- package/dist/sqlite.mjs +48 -0
- package/dist/standard-BTVYKh_F.mjs +12 -0
- package/dist/table-llv9tsZ8.mjs +384 -0
- package/dist/types-4Q076HKo.d.mts +3636 -0
- package/dist/types-BX0mckiU.d.mts +644 -0
- package/dist/types-CO1KaRNc.d.mts +46 -0
- package/dist/types-Cec0xzo4.mjs +116 -0
- package/dist/value-BvilP0oz.mjs +29 -0
- package/dist/vite/ambient.d.ts +449 -0
- package/dist/vite.d.mts +35 -0
- package/dist/vite.mjs +498 -0
- package/docs/config.json +21 -0
- package/docs/dialects-and-execution.md +427 -0
- package/docs/getting-started.md +96 -0
- package/docs/guides/compose-queries.md +225 -0
- package/docs/guides/drizzle.md +129 -0
- package/docs/guides/extensions/dialects.md +40 -0
- package/docs/guides/extensions/overview.md +36 -0
- package/docs/guides/extensions/sources-and-clauses.md +82 -0
- package/docs/guides/extensions/typed-expressions.md +94 -0
- package/docs/guides/extensions/unsafe-syntax.md +27 -0
- package/docs/guides/json.md +65 -0
- package/docs/guides/mutations.md +138 -0
- package/docs/guides/select/conditions.md +110 -0
- package/docs/guides/select/grouping-and-windows.md +82 -0
- package/docs/guides/select/ordering-and-pagination.md +78 -0
- package/docs/guides/select/overview.md +139 -0
- package/docs/guides/sql-templates.md +157 -0
- package/docs/guides/vite-plugin.md +92 -0
- package/docs/index.md +111 -0
- package/docs/query-model/fragments.md +109 -0
- package/docs/query-model/result-shapes.md +125 -0
- package/docs/query-model/source-scope.md +182 -0
- package/docs/reference/introspection-support.md +196 -0
- package/docs/reference/mysql-snapshot.md +55 -0
- package/docs/reference/postgres-snapshot.md +61 -0
- package/docs/reference/sqlite-snapshot.md +53 -0
- package/docs/reference/supported-surface.md +104 -0
- package/docs/schema/catalog-model.md +58 -0
- package/docs/schema/code-generation.md +139 -0
- package/docs/schema/columns-and-writes.md +130 -0
- package/docs/schema/constraints-and-indexes.md +180 -0
- package/docs/schema/ddl-emission.md +75 -0
- package/docs/schema/diff.md +75 -0
- package/docs/schema/introspection.md +214 -0
- package/docs/schema/migration-plans.md +76 -0
- package/docs/schema/snapshots.md +93 -0
- package/docs/schema/storage-and-schema-sql.md +104 -0
- package/docs/schema/tables-and-names.md +106 -0
- package/docs/sql-semantic-types.md +141 -0
- package/docs/troubleshooting.md +151 -0
- package/package.json +132 -10
- package/skills/qubu/SKILL.md +42 -0
- package/skills/qubu/agents/openai.yaml +6 -0
- package/readme.md +0 -1
|
@@ -0,0 +1,3636 @@
|
|
|
1
|
+
//#region src/core/sql-types.d.ts
|
|
2
|
+
/** A portable or dialect-specific SQL value domain. */
|
|
3
|
+
interface SqlSemanticType<TName extends string = string> {
|
|
4
|
+
readonly sqlType: TName;
|
|
5
|
+
}
|
|
6
|
+
/** Marker for extensions whose SQL domain has not been declared. */
|
|
7
|
+
type SqlUnknown = SqlSemanticType<'unknown'> & {
|
|
8
|
+
readonly sqlUnknown: true;
|
|
9
|
+
};
|
|
10
|
+
/** SQL domains accepted by text operations and the text equality group. */
|
|
11
|
+
interface SqlTextLike extends SqlEqualityComparable<'text'> {
|
|
12
|
+
readonly sqlTextLike: true;
|
|
13
|
+
}
|
|
14
|
+
/** SQL domains accepted by numeric operations. */
|
|
15
|
+
interface SqlNumericLike {
|
|
16
|
+
readonly sqlNumericLike: true;
|
|
17
|
+
}
|
|
18
|
+
/** SQL domains with a portable ordering relation. */
|
|
19
|
+
interface SqlOrderable<TGroup = unknown> {
|
|
20
|
+
readonly sqlOrderGroup: TGroup;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* SQL domains that can be compared for equality with the same compatibility
|
|
24
|
+
* group. Dialect extensions can share a group with a portable domain.
|
|
25
|
+
*/
|
|
26
|
+
interface SqlEqualityComparable<TGroup = unknown> {
|
|
27
|
+
readonly sqlEqualityGroup: TGroup;
|
|
28
|
+
}
|
|
29
|
+
/** Portable text domain with text, ordering, and equality capabilities. */
|
|
30
|
+
type SqlText = SqlSemanticType<'text'> & SqlTextLike & SqlOrderable<'text'> & SqlEqualityComparable<'text'>;
|
|
31
|
+
/** Portable UUID domain; equality-capable but deliberately not text-like. */
|
|
32
|
+
type SqlUuid = SqlSemanticType<'uuid'> & SqlEqualityComparable<'uuid'>;
|
|
33
|
+
/** Portable integer domain in the shared numeric compatibility groups. */
|
|
34
|
+
type SqlInteger = SqlSemanticType<'integer'> & SqlNumericLike & SqlOrderable<'numeric'> & SqlEqualityComparable<'numeric'>;
|
|
35
|
+
/** Portable decimal domain in the shared numeric compatibility groups. */
|
|
36
|
+
type SqlDecimal = SqlSemanticType<'decimal'> & SqlNumericLike & SqlOrderable<'numeric'> & SqlEqualityComparable<'numeric'>;
|
|
37
|
+
/** Portable boolean domain with equality comparison. */
|
|
38
|
+
type SqlBoolean = SqlSemanticType<'boolean'> & SqlEqualityComparable<'boolean'>;
|
|
39
|
+
/** Portable date domain with date-specific equality and ordering groups. */
|
|
40
|
+
type SqlDate = SqlSemanticType<'date'> & SqlOrderable<'date'> & SqlEqualityComparable<'date'>;
|
|
41
|
+
/** Portable timestamp domain with timestamp-specific comparison groups. */
|
|
42
|
+
type SqlTimestamp = SqlSemanticType<'timestamp'> & SqlOrderable<'timestamp'> & SqlEqualityComparable<'timestamp'>;
|
|
43
|
+
/** Portable JSON domain retaining its decoded application value type. */
|
|
44
|
+
type SqlJson<TValue = unknown> = SqlSemanticType<'json'> & {
|
|
45
|
+
readonly sqlJsonValue?: TValue;
|
|
46
|
+
};
|
|
47
|
+
/** Portable bigint domain in the shared numeric compatibility groups. */
|
|
48
|
+
type SqlBigInt = SqlSemanticType<'bigint'> & SqlNumericLike & SqlOrderable<'numeric'> & SqlEqualityComparable<'numeric'>;
|
|
49
|
+
/** Portable binary domain with equality comparison. */
|
|
50
|
+
type SqlBinary = SqlSemanticType<'binary'> & SqlEqualityComparable<'binary'>;
|
|
51
|
+
/** Any declared SQL semantic type, including user and dialect extensions. */
|
|
52
|
+
type AnySqlType = SqlSemanticType<string>;
|
|
53
|
+
type IsUnresolvedSqlType<T> = T extends SqlUnknown ? true : T extends AnySqlType ? string extends T['sqlType'] ? true : false : false;
|
|
54
|
+
/** Whether a declared SQL domain satisfies a semantic capability constraint. */
|
|
55
|
+
type SqlTypeSatisfies<TActual, TConstraint> = true extends IsUnresolvedSqlType<TActual> ? true : TActual extends TConstraint ? true : false;
|
|
56
|
+
type EqualityGroup<T> = T extends SqlEqualityComparable<infer TGroup> ? TGroup : never;
|
|
57
|
+
/** Portable equality compatibility, with unknown extension types left open. */
|
|
58
|
+
type SqlEqualityCompatible<TLeft, TRight> = true extends IsUnresolvedSqlType<TLeft> ? true : true extends IsUnresolvedSqlType<TRight> ? true : [EqualityGroup<TLeft>] extends [never] ? false : [EqualityGroup<TRight>] extends [never] ? false : [EqualityGroup<TLeft>] extends [EqualityGroup<TRight>] ? [EqualityGroup<TRight>] extends [EqualityGroup<TLeft>] ? true : false : false;
|
|
59
|
+
type OrderGroup<T> = T extends SqlOrderable<infer TGroup> ? TGroup : never;
|
|
60
|
+
/** Portable ordering compatibility, with unknown extension types left open. */
|
|
61
|
+
type SqlOrderCompatible<TLeft, TRight> = true extends IsUnresolvedSqlType<TLeft> ? true : true extends IsUnresolvedSqlType<TRight> ? true : [OrderGroup<TLeft>] extends [never] ? false : [OrderGroup<TRight>] extends [never] ? false : [OrderGroup<TLeft>] extends [OrderGroup<TRight>] ? [OrderGroup<TRight>] extends [OrderGroup<TLeft>] ? true : false : false;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/core/fragment.d.ts
|
|
64
|
+
declare const fragmentMetadata: unique symbol;
|
|
65
|
+
/** Result value metadata, including nullability provenance and its SQL domain. */
|
|
66
|
+
type ResultMeta<TOutput, TNullableFrom = never, TSqlType extends AnySqlType = SqlUnknown> = {
|
|
67
|
+
readonly kind: 'result';
|
|
68
|
+
readonly output: TOutput;
|
|
69
|
+
readonly nullableFrom: TNullableFrom;
|
|
70
|
+
readonly sqlType: TSqlType;
|
|
71
|
+
};
|
|
72
|
+
type RequiresSourceMeta<TSource> = {
|
|
73
|
+
readonly kind: 'requires-source';
|
|
74
|
+
readonly source: TSource;
|
|
75
|
+
};
|
|
76
|
+
/** A source that must be provided by the enclosing query scope. */
|
|
77
|
+
type RequiresOuterSourceMeta<TSource> = {
|
|
78
|
+
readonly kind: 'requires-outer-source';
|
|
79
|
+
readonly source: TSource;
|
|
80
|
+
};
|
|
81
|
+
/** A correlated query clause that provisions sources from its enclosing scope. */
|
|
82
|
+
type ProvidesOuterSourceMeta<TSource> = {
|
|
83
|
+
readonly kind: 'provides-outer-source';
|
|
84
|
+
readonly source: TSource;
|
|
85
|
+
};
|
|
86
|
+
type NullableSourceMeta<TSource> = {
|
|
87
|
+
readonly kind: 'nullable-source';
|
|
88
|
+
readonly source: TSource;
|
|
89
|
+
};
|
|
90
|
+
/** A fragment that introduces a typed relational source to FROM/JOIN. */
|
|
91
|
+
type ProvidesSourceMeta<TSource, TRow = unknown> = {
|
|
92
|
+
readonly kind: 'provides-source';
|
|
93
|
+
readonly source: TSource;
|
|
94
|
+
readonly row: TRow;
|
|
95
|
+
};
|
|
96
|
+
/** Dependencies read by an expression at the current query level. */
|
|
97
|
+
type ExpressionMeta<TDependencies = unknown> = {
|
|
98
|
+
readonly kind: 'expression';
|
|
99
|
+
readonly dependencies: TDependencies;
|
|
100
|
+
};
|
|
101
|
+
/** Dependencies consumed inside an aggregate expression. */
|
|
102
|
+
type AggregateMeta<TDependencies = unknown> = {
|
|
103
|
+
readonly kind: 'aggregate';
|
|
104
|
+
readonly dependencies: TDependencies;
|
|
105
|
+
};
|
|
106
|
+
/** Marks an expression that contains a window function. */
|
|
107
|
+
type WindowMeta = {
|
|
108
|
+
readonly kind: 'window';
|
|
109
|
+
};
|
|
110
|
+
/** Marks an expression that contains a scalar or predicate subquery. */
|
|
111
|
+
type SubqueryMeta = {
|
|
112
|
+
readonly kind: 'subquery';
|
|
113
|
+
};
|
|
114
|
+
/** Grouping keys and column dependencies made available by a GROUP BY clause. */
|
|
115
|
+
type GroupingMeta<TKeys = unknown, TDependencies = unknown> = {
|
|
116
|
+
readonly kind: 'grouping';
|
|
117
|
+
readonly keys: TKeys;
|
|
118
|
+
readonly dependencies: TDependencies;
|
|
119
|
+
};
|
|
120
|
+
type QueryCardinality = 'many' | 'zero-or-one' | 'exactly-one';
|
|
121
|
+
type CardinalityMeta<TCardinality extends QueryCardinality = QueryCardinality> = {
|
|
122
|
+
readonly kind: 'cardinality';
|
|
123
|
+
readonly cardinality: TCardinality;
|
|
124
|
+
};
|
|
125
|
+
/** A fragment whose syntax must be rendered by a dialect with this capability. */
|
|
126
|
+
type RequiresCapabilityMeta<TCapability extends DialectCapability = DialectCapability> = {
|
|
127
|
+
readonly kind: 'requires-capability';
|
|
128
|
+
readonly capability: TCapability;
|
|
129
|
+
};
|
|
130
|
+
type FragmentMeta = ResultMeta<unknown, unknown, AnySqlType> | RequiresSourceMeta<unknown> | RequiresOuterSourceMeta<unknown> | ProvidesOuterSourceMeta<unknown> | NullableSourceMeta<unknown> | ProvidesSourceMeta<unknown, unknown> | ExpressionMeta | AggregateMeta | WindowMeta | SubqueryMeta | GroupingMeta | CardinalityMeta | RequiresCapabilityMeta;
|
|
131
|
+
interface RenderContext {
|
|
132
|
+
readonly dialect: Dialect;
|
|
133
|
+
/** Whether selected fields name an application result or a SQL relation. */
|
|
134
|
+
readonly projectionMode: 'result' | 'relation';
|
|
135
|
+
append(text: string): void;
|
|
136
|
+
parameter(value: unknown): void;
|
|
137
|
+
render(part: Fragment<any>): void;
|
|
138
|
+
/** Render an embedded query with SQL-facing projection names. */
|
|
139
|
+
renderRelation(part: Fragment<any>): void;
|
|
140
|
+
/**
|
|
141
|
+
* Optional schema-rendering hook used to emit a bare physical column name.
|
|
142
|
+
* Ordinary query rendering leaves this undefined and retains qualification.
|
|
143
|
+
*/
|
|
144
|
+
readonly renderColumnReference?: (columnName: string) => void;
|
|
145
|
+
}
|
|
146
|
+
type RenderFunction = (context: RenderContext) => void;
|
|
147
|
+
/**
|
|
148
|
+
* The smallest composable unit in qubu. Runtime rendering is deliberately
|
|
149
|
+
* just a function; the metadata type carries semantic information for
|
|
150
|
+
* TypeScript consumers without imposing an AST on extensions.
|
|
151
|
+
*/
|
|
152
|
+
interface Fragment<TMetadata = any> {
|
|
153
|
+
readonly [fragmentMetadata]?: TMetadata;
|
|
154
|
+
readonly render: RenderFunction;
|
|
155
|
+
}
|
|
156
|
+
type AnyFragment = Fragment<any>;
|
|
157
|
+
type MetadataOf<T> = T extends Fragment<infer TMetadata> ? TMetadata : never;
|
|
158
|
+
type WithoutResult<TMetadata> = TMetadata extends {
|
|
159
|
+
readonly kind: 'result' | 'cardinality';
|
|
160
|
+
} ? never : TMetadata;
|
|
161
|
+
type ResultMetadata<TMetadata> = TMetadata extends {
|
|
162
|
+
readonly kind: 'result';
|
|
163
|
+
} ? TMetadata : never;
|
|
164
|
+
type ResultOutput<TMetadata> = TMetadata extends {
|
|
165
|
+
readonly output: infer TOutput;
|
|
166
|
+
} ? TOutput : never;
|
|
167
|
+
type ResultNullableFrom<TMetadata> = TMetadata extends {
|
|
168
|
+
readonly nullableFrom: infer TSource;
|
|
169
|
+
} ? TSource : never;
|
|
170
|
+
type ResultSqlType<TMetadata> = TMetadata extends {
|
|
171
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
172
|
+
} ? TSqlType : SqlUnknown;
|
|
173
|
+
type RequiredSource<TMetadata> = TMetadata extends {
|
|
174
|
+
readonly kind: 'requires-source';
|
|
175
|
+
readonly source: infer TSource;
|
|
176
|
+
} ? TSource : never;
|
|
177
|
+
type RequiredOuterSource<TMetadata> = TMetadata extends {
|
|
178
|
+
readonly kind: 'requires-outer-source';
|
|
179
|
+
readonly source: infer TSource;
|
|
180
|
+
} ? TSource : never;
|
|
181
|
+
type ProvidedOuterSource<TMetadata> = TMetadata extends {
|
|
182
|
+
readonly kind: 'provides-outer-source';
|
|
183
|
+
readonly source: infer TSource;
|
|
184
|
+
} ? TSource : never;
|
|
185
|
+
type NullableSource<TMetadata> = TMetadata extends {
|
|
186
|
+
readonly kind: 'nullable-source';
|
|
187
|
+
readonly source: infer TSource;
|
|
188
|
+
} ? TSource : never;
|
|
189
|
+
type ExpressionDependencies<TMetadata> = TMetadata extends {
|
|
190
|
+
readonly kind: 'expression';
|
|
191
|
+
readonly dependencies: infer TDependencies;
|
|
192
|
+
} ? TDependencies : never;
|
|
193
|
+
type AggregateDependencies<TMetadata> = TMetadata extends {
|
|
194
|
+
readonly kind: 'aggregate';
|
|
195
|
+
readonly dependencies: infer TDependencies;
|
|
196
|
+
} ? TDependencies : never;
|
|
197
|
+
type GroupingKeys<TMetadata> = TMetadata extends {
|
|
198
|
+
readonly kind: 'grouping';
|
|
199
|
+
readonly keys: infer TKeys;
|
|
200
|
+
} ? TKeys : never;
|
|
201
|
+
type GroupingDependencies<TMetadata> = TMetadata extends {
|
|
202
|
+
readonly kind: 'grouping';
|
|
203
|
+
readonly dependencies: infer TDependencies;
|
|
204
|
+
} ? TDependencies : never;
|
|
205
|
+
type Cardinality<TMetadata> = TMetadata extends {
|
|
206
|
+
readonly kind: 'cardinality';
|
|
207
|
+
readonly cardinality: infer TCardinality;
|
|
208
|
+
} ? TCardinality : never;
|
|
209
|
+
type RequiredCapabilities<TMetadata> = TMetadata extends {
|
|
210
|
+
readonly kind: 'requires-capability';
|
|
211
|
+
readonly capability: infer TCapability extends DialectCapability;
|
|
212
|
+
} ? TCapability : never;
|
|
213
|
+
type InheritedMetadataOf<TMetadata> = WithoutResult<TMetadata>;
|
|
214
|
+
type InheritedMetadata<T> = InheritedMetadataOf<MetadataOf<T>>;
|
|
215
|
+
type OutputOf<T> = ResultOutput<ResultMetadata<MetadataOf<T>>>;
|
|
216
|
+
/** The SQL semantic domain produced by a result-bearing fragment. */
|
|
217
|
+
type SqlTypeOf<T> = ResultSqlType<ResultMetadata<MetadataOf<T>>>;
|
|
218
|
+
type RequiresOf<T> = RequiredSource<MetadataOf<T>>;
|
|
219
|
+
type RequiresOuterOf<T> = RequiredOuterSource<MetadataOf<T>>;
|
|
220
|
+
type ProvidesOuterOf<T> = ProvidedOuterSource<MetadataOf<T>>;
|
|
221
|
+
type RequiresOuterMetadataOf<T> = Extract<MetadataOf<T>, {
|
|
222
|
+
readonly kind: 'requires-outer-source';
|
|
223
|
+
}>;
|
|
224
|
+
type NullabilityOf<T> = ResultNullableFrom<ResultMetadata<MetadataOf<T>>>;
|
|
225
|
+
type NullableSourcesOf<T> = NullableSource<MetadataOf<T>>;
|
|
226
|
+
type DependenciesOf<T> = ExpressionDependencies<MetadataOf<T>>;
|
|
227
|
+
type AggregateDependenciesOf<T> = AggregateDependencies<MetadataOf<T>>;
|
|
228
|
+
/** Dependencies still visible after aggregate arguments have been consumed. */
|
|
229
|
+
type VisibleDependenciesOf<T> = Exclude<DependenciesOf<T>, AggregateDependenciesOf<T>>;
|
|
230
|
+
type GroupingKeysOf<T> = GroupingKeys<MetadataOf<T>>;
|
|
231
|
+
type GroupingDependenciesOf<T> = GroupingDependencies<MetadataOf<T>>;
|
|
232
|
+
type HasAggregate<T> = [Extract<MetadataOf<T>, {
|
|
233
|
+
readonly kind: 'aggregate';
|
|
234
|
+
}>] extends [never] ? false : true;
|
|
235
|
+
type HasWindow<T> = [Extract<MetadataOf<T>, {
|
|
236
|
+
readonly kind: 'window';
|
|
237
|
+
}>] extends [never] ? false : true;
|
|
238
|
+
type HasSubquery<T> = [Extract<MetadataOf<T>, {
|
|
239
|
+
readonly kind: 'subquery';
|
|
240
|
+
}>] extends [never] ? false : true;
|
|
241
|
+
type CardinalityOf<T> = Cardinality<MetadataOf<T>>;
|
|
242
|
+
type CapabilitiesOf<T> = RequiredCapabilities<MetadataOf<T>>;
|
|
243
|
+
type CapabilityMetadataOf<T> = [CapabilitiesOf<T>] extends [never] ? never : RequiresCapabilityMeta<CapabilitiesOf<T>>;
|
|
244
|
+
declare function fragment<TMetadata = never>(render: RenderFunction): Fragment<TMetadata>;
|
|
245
|
+
declare function sequence<const TParts extends readonly AnyFragment[]>(parts: TParts, separator?: string): Fragment<InheritedMetadata<TParts[number]>>;
|
|
246
|
+
declare function parenthesize<TPart extends AnyFragment>(part: TPart): Fragment<InheritedMetadata<TPart>>;
|
|
247
|
+
declare function isFragment(value: unknown): value is AnyFragment;
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/expressions/types.d.ts
|
|
250
|
+
type ExpressionKind = 'value' | 'column' | 'function' | 'operator' | 'sql' | 'subquery' | 'unsafe';
|
|
251
|
+
/** Runtime/type-level proof that an expression is safe to use in schema SQL. */
|
|
252
|
+
declare const schemaExpressionBrand: unique symbol;
|
|
253
|
+
interface SchemaExpressionBrand {
|
|
254
|
+
readonly [schemaExpressionBrand]: true;
|
|
255
|
+
}
|
|
256
|
+
interface Expression<TMetadata = any, TKind extends ExpressionKind = ExpressionKind> extends Fragment<TMetadata> {
|
|
257
|
+
readonly expressionKind: TKind;
|
|
258
|
+
/** Internal runtime marker for query constructs rejected by schema SQL. */
|
|
259
|
+
readonly expressionCategory?: 'aggregate' | 'window' | 'subquery';
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* An expression whose renderer is deterministic and may be used by schema
|
|
263
|
+
* metadata. Query extensions remain ordinary {@link Expression} values until
|
|
264
|
+
* they explicitly opt into this contract.
|
|
265
|
+
*/
|
|
266
|
+
type SchemaExpression<TMetadata = any, TKind extends ExpressionKind = ExpressionKind> = Expression<TMetadata, TKind> & SchemaExpressionBrand;
|
|
267
|
+
type AnyExpression = Expression<any, any>;
|
|
268
|
+
type AnySchemaExpression = SchemaExpression<any, any>;
|
|
269
|
+
type ExpressionOutput<T> = OutputOf<T>;
|
|
270
|
+
type ExpressionRequires<T> = RequiresOf<T>;
|
|
271
|
+
type ExpressionNullability<T> = NullabilityOf<T>;
|
|
272
|
+
/** Extract the SQL semantic domain produced by an expression. */
|
|
273
|
+
type ExpressionSqlType<T> = SqlTypeOf<T>;
|
|
274
|
+
/** Add a concrete dialect requirement without dropping expression metadata. */
|
|
275
|
+
declare function withDialectCapability<const TCapability extends DialectCapability, TExpression extends AnyExpression>(expression: TExpression, capability: TCapability): TExpression extends SchemaExpression<any, any> ? SchemaExpression<MetadataOf<TExpression> | RequiresCapabilityMeta<TCapability>, TExpression['expressionKind']> : Expression<MetadataOf<TExpression> | RequiresCapabilityMeta<TCapability>, TExpression['expressionKind']>;
|
|
276
|
+
/** An expression whose result is known to be assignable to `TOutput`. */
|
|
277
|
+
type ExpressionWithOutput<TOutput, TKind extends ExpressionKind = ExpressionKind> = Expression<ResultMeta<TOutput, unknown, AnySqlType> | RequiresSourceMeta<unknown> | NullableSourceMeta<unknown> | ExpressionMeta<unknown> | AggregateMeta<unknown> | RequiresCapabilityMeta | WindowMeta | SubqueryMeta, TKind>;
|
|
278
|
+
/** Build an expression result while inheriting non-result metadata from children. */
|
|
279
|
+
type ResultExpression<TOutput, TChildren = never, TKind extends ExpressionKind = ExpressionKind, TNullableFrom = NullabilityOf<TChildren>, TSqlType extends AnySqlType = SqlUnknown> = SchemaExpression<ResultMeta<TOutput, TNullableFrom, TSqlType> | ExpressionMeta<DependenciesOf<TChildren>> | InheritedMetadata<TChildren>, TKind>;
|
|
280
|
+
/** Build an aggregate result while recording which dependencies it consumes. */
|
|
281
|
+
type AggregateResultExpression<TOutput, TChildren = never, TKind extends ExpressionKind = ExpressionKind, TNullableFrom = NullabilityOf<TChildren>, TSqlType extends AnySqlType = SqlUnknown> = Expression<ResultMeta<TOutput, TNullableFrom, TSqlType> | ExpressionMeta<DependenciesOf<TChildren>> | AggregateMeta<DependenciesOf<TChildren>> | InheritedMetadata<TChildren>, TKind>;
|
|
282
|
+
/** A result expression that contains a query boundary. */
|
|
283
|
+
type SubqueryResultExpression<TOutput, TChildren = never, TNullableFrom = NullabilityOf<TChildren>, TSqlType extends AnySqlType = SqlUnknown> = Expression<ResultMeta<TOutput, TNullableFrom, TSqlType> | ExpressionMeta<DependenciesOf<TChildren>> | InheritedMetadata<TChildren> | SubqueryMeta, 'subquery'>;
|
|
284
|
+
declare function makeExpression<TMetadata = never, TKind extends ExpressionKind = ExpressionKind>(expressionKind: TKind, render: (context: RenderContext) => void, expressionCategory?: 'aggregate' | 'window' | 'subquery'): Expression<TMetadata, TKind>;
|
|
285
|
+
/** Mark a query-only expression category without changing its SQL renderer. */
|
|
286
|
+
declare function markExpressionCategory<TMetadata, TKind extends ExpressionKind>(expression: Expression<TMetadata, TKind>, category: 'aggregate' | 'window' | 'subquery'): Expression<TMetadata, TKind>;
|
|
287
|
+
declare function isExpression(value: unknown): value is AnyExpression;
|
|
288
|
+
//#endregion
|
|
289
|
+
//#region src/expressions/column.d.ts
|
|
290
|
+
interface ColumnReference<TFieldName extends string = string, TMetadata = never> extends SchemaExpression<TMetadata, 'column'> {
|
|
291
|
+
/** Application-facing key used by typed rows and dependency metadata. */
|
|
292
|
+
readonly fieldName: TFieldName;
|
|
293
|
+
/** Physical SQL identifier rendered for this column. */
|
|
294
|
+
readonly columnName: string;
|
|
295
|
+
}
|
|
296
|
+
type ColumnDependency<TSource, TName extends string> = {
|
|
297
|
+
readonly kind: 'column';
|
|
298
|
+
readonly source: TSource;
|
|
299
|
+
readonly name: TName;
|
|
300
|
+
};
|
|
301
|
+
type ColumnGroupingDependencies<T> = T extends ColumnReference<any, any> ? DependenciesOf<T> : never;
|
|
302
|
+
/** Turn an expression into a fragment that renders it without changing it. */
|
|
303
|
+
declare function expressionFragment<TExpression extends Expression>(expression: TExpression): Fragment<MetadataOf<TExpression>>;
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/schema/metadata.d.ts
|
|
306
|
+
/** Dialect identities with first-party schema metadata adapters. */
|
|
307
|
+
type SchemaDialectName = 'postgresql' | 'sqlite' | 'mysql';
|
|
308
|
+
/** A dialect-owned extension attached to serializable schema metadata. */
|
|
309
|
+
interface SchemaDialectExtension<TDialect extends string = string> {
|
|
310
|
+
readonly dialect: TDialect;
|
|
311
|
+
}
|
|
312
|
+
/** An optional physical-name override for a relational schema object. */
|
|
313
|
+
interface SchemaObjectNameOptions {
|
|
314
|
+
/** Physical SQL name; the metadata record key remains the logical ID. */
|
|
315
|
+
readonly physicalName?: string;
|
|
316
|
+
}
|
|
317
|
+
/** Common identity fields materialized on constraints and indexes. */
|
|
318
|
+
interface SchemaObjectIdentity {
|
|
319
|
+
/** Stable logical ID, normally the metadata record key. */
|
|
320
|
+
readonly id?: string;
|
|
321
|
+
/** Resolved physical SQL object name. */
|
|
322
|
+
readonly physicalName?: string;
|
|
323
|
+
}
|
|
324
|
+
/** Structured diagnostics produced while resolving relational metadata. */
|
|
325
|
+
interface SchemaMetadataDiagnostic {
|
|
326
|
+
readonly code: 'invalid-physical-name' | 'duplicate-physical-name' | 'dialect-mismatch' | 'unsupported-dialect-option';
|
|
327
|
+
readonly message: string;
|
|
328
|
+
readonly path: readonly (string | number)[];
|
|
329
|
+
readonly relatedPaths?: readonly (readonly (string | number)[])[];
|
|
330
|
+
readonly dialect?: string;
|
|
331
|
+
}
|
|
332
|
+
/** Error raised when relational metadata cannot be represented safely. */
|
|
333
|
+
declare class SchemaMetadataValidationError extends TypeError {
|
|
334
|
+
readonly name = "SchemaMetadataValidationError";
|
|
335
|
+
readonly diagnostics: readonly SchemaMetadataDiagnostic[];
|
|
336
|
+
readonly issues: readonly SchemaMetadataDiagnostic[];
|
|
337
|
+
constructor(diagnostics: readonly SchemaMetadataDiagnostic[]);
|
|
338
|
+
}
|
|
339
|
+
/** Generate the version-one physical name for a relational object ID. */
|
|
340
|
+
declare function generatedSchemaObjectName(id: string): string;
|
|
341
|
+
/** Deep-freeze plain metadata values without introducing executable nodes. */
|
|
342
|
+
declare function freezeSchemaMetadata<T>(value: T): T;
|
|
343
|
+
/** Check the portable identifier subset used for generated metadata names. */
|
|
344
|
+
declare function isValidSchemaObjectName(name: string): boolean;
|
|
345
|
+
/**
|
|
346
|
+
* Attach a record key and resolved physical name without changing the
|
|
347
|
+
* enumerable shape of legacy constraint/index values. The properties are
|
|
348
|
+
* still ordinary read-only runtime metadata and are available to snapshot
|
|
349
|
+
* traversals.
|
|
350
|
+
*/
|
|
351
|
+
declare function materializeSchemaObjectIdentity<TValue extends object>(value: TValue, id: string, physicalName?: string): TValue & SchemaObjectIdentity;
|
|
352
|
+
type NamedMetadataValue = object & {
|
|
353
|
+
readonly physicalName?: string;
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* Resolve and validate names for one metadata record. The caller decides
|
|
357
|
+
* whether constraint and index names share a database namespace.
|
|
358
|
+
*/
|
|
359
|
+
declare function materializeSchemaObjectRecord<TValue extends NamedMetadataValue>(record: Readonly<Record<string, TValue>>, kind: 'constraint' | 'index'): Readonly<Record<string, TValue & SchemaObjectIdentity>>;
|
|
360
|
+
/** Return a diagnostic when a dialect extension is used by another adapter. */
|
|
361
|
+
declare function dialectMismatchDiagnostic(extension: SchemaDialectExtension, dialect: string, path: readonly (string | number)[]): SchemaMetadataDiagnostic | undefined;
|
|
362
|
+
/** Throw a structured error for one or more dialect capability findings. */
|
|
363
|
+
declare function assertSchemaDialectSupport(diagnostics: readonly SchemaMetadataDiagnostic[]): void;
|
|
364
|
+
//#endregion
|
|
365
|
+
//#region src/schema/column-behavior.d.ts
|
|
366
|
+
/** Values that can be represented without a dialect-specific SQL renderer. */
|
|
367
|
+
type SchemaLiteralValue = null | boolean | string | number | bigint;
|
|
368
|
+
/**
|
|
369
|
+
* Public input accepted by a column's `default` option.
|
|
370
|
+
*
|
|
371
|
+
* Primitive values are always literals. Branded schema expressions are
|
|
372
|
+
* rendered as SQL expressions, and an external descriptor records a default
|
|
373
|
+
* whose definition belongs to another schema authority.
|
|
374
|
+
*/
|
|
375
|
+
type ColumnDefaultInput = SchemaLiteralValue | AnySchemaExpression | ExternalDefaultDescriptor;
|
|
376
|
+
/** A canonical, dialect-neutral literal node retained by default metadata. */
|
|
377
|
+
type CanonicalLiteral = {
|
|
378
|
+
readonly kind: 'null';
|
|
379
|
+
} | {
|
|
380
|
+
readonly kind: 'boolean';
|
|
381
|
+
readonly value: boolean;
|
|
382
|
+
} | {
|
|
383
|
+
readonly kind: 'string';
|
|
384
|
+
readonly value: string;
|
|
385
|
+
} | {
|
|
386
|
+
readonly kind: 'number';
|
|
387
|
+
readonly value: string;
|
|
388
|
+
} | {
|
|
389
|
+
readonly kind: 'bigint';
|
|
390
|
+
readonly value: string;
|
|
391
|
+
};
|
|
392
|
+
/** A default represented by a canonical literal node. */
|
|
393
|
+
interface LiteralDefaultDescriptor<TLiteral extends CanonicalLiteral = CanonicalLiteral> {
|
|
394
|
+
readonly kind: 'literal';
|
|
395
|
+
readonly value: TLiteral;
|
|
396
|
+
}
|
|
397
|
+
/** A default whose SQL is retained as a deterministic schema expression. */
|
|
398
|
+
interface ExpressionDefaultDescriptor<TExpression extends AnySchemaExpression = AnySchemaExpression> {
|
|
399
|
+
readonly kind: 'expression';
|
|
400
|
+
readonly expression: TExpression;
|
|
401
|
+
}
|
|
402
|
+
/** A default supplied by the database or another external schema authority. */
|
|
403
|
+
interface ExternalDefaultDescriptor {
|
|
404
|
+
readonly kind: 'external';
|
|
405
|
+
}
|
|
406
|
+
/** Complete default metadata carried by a column definition. */
|
|
407
|
+
type ColumnDefault = LiteralDefaultDescriptor | ExpressionDefaultDescriptor | ExternalDefaultDescriptor;
|
|
408
|
+
/** Alias used by snapshot and schema tooling consumers. */
|
|
409
|
+
type DefaultDescriptor = ColumnDefault;
|
|
410
|
+
/** Storage mode for a generated-column expression. */
|
|
411
|
+
type GeneratedColumnMode = 'stored' | 'virtual';
|
|
412
|
+
/** A generated column with an expression that can be rendered later. */
|
|
413
|
+
interface ExpressionGeneratedColumnDescriptor<TExpression extends AnySchemaExpression = AnySchemaExpression> {
|
|
414
|
+
readonly kind: 'expression';
|
|
415
|
+
readonly expression: TExpression;
|
|
416
|
+
readonly mode: GeneratedColumnMode;
|
|
417
|
+
}
|
|
418
|
+
/** A generated-column behavior known to exist but owned externally. */
|
|
419
|
+
interface ExternalGeneratedColumnDescriptor {
|
|
420
|
+
readonly kind: 'external';
|
|
421
|
+
}
|
|
422
|
+
/** Complete generated-column metadata, separate from identity metadata. */
|
|
423
|
+
type GeneratedColumnDescriptor = ExpressionGeneratedColumnDescriptor | ExternalGeneratedColumnDescriptor;
|
|
424
|
+
/** Alias used by snapshot and schema tooling consumers. */
|
|
425
|
+
type GeneratedDescriptor = GeneratedColumnDescriptor;
|
|
426
|
+
/** Identity generation policy. Identity is not an ordinary SQL expression. */
|
|
427
|
+
type IdentityGeneration = 'always' | 'by-default';
|
|
428
|
+
/** SQLite's opt-in AUTOINCREMENT behavior for an INTEGER rowid alias. */
|
|
429
|
+
interface SqliteIdentityExtension extends SchemaDialectExtension<'sqlite'> {
|
|
430
|
+
/** Preserve deleted rowids instead of allowing SQLite to reuse them. */
|
|
431
|
+
readonly autoIncrement?: boolean;
|
|
432
|
+
}
|
|
433
|
+
/** MySQL's column-level AUTO_INCREMENT identity detail. */
|
|
434
|
+
interface MysqlIdentityExtension extends SchemaDialectExtension<'mysql'> {
|
|
435
|
+
/** Emit MySQL's AUTO_INCREMENT behavior for this identity column. */
|
|
436
|
+
readonly autoIncrement?: boolean;
|
|
437
|
+
}
|
|
438
|
+
/** Dialect-owned identity details retained independently from generation. */
|
|
439
|
+
type IdentityDialectExtension = SqliteIdentityExtension | MysqlIdentityExtension | (SchemaDialectExtension<string> & Readonly<Record<string, unknown>>);
|
|
440
|
+
/** Complete identity metadata for a database-generated column value. */
|
|
441
|
+
interface IdentityDescriptor {
|
|
442
|
+
readonly kind: 'identity';
|
|
443
|
+
readonly generation: IdentityGeneration;
|
|
444
|
+
/** Optional dialect-owned identity semantics such as SQLite AUTOINCREMENT. */
|
|
445
|
+
readonly dialect?: IdentityDialectExtension;
|
|
446
|
+
}
|
|
447
|
+
/** Structured failures raised while resolving column behavior metadata. */
|
|
448
|
+
type ColumnBehaviorErrorCode = 'invalid-default' | 'invalid-generated-column' | 'invalid-identity' | 'invalid-on-update' | 'default-flag-conflict' | 'generated-flag-conflict' | 'default-generated-conflict' | 'identity-generated-conflict';
|
|
449
|
+
/** A column behavior error with a stable code and optional property path. */
|
|
450
|
+
declare class ColumnBehaviorError extends TypeError {
|
|
451
|
+
readonly code: ColumnBehaviorErrorCode;
|
|
452
|
+
readonly path?: string;
|
|
453
|
+
constructor(code: ColumnBehaviorErrorCode, message: string, path?: string);
|
|
454
|
+
}
|
|
455
|
+
/** Build a canonical literal node from a supported JavaScript scalar. */
|
|
456
|
+
declare function canonicalLiteral(value: SchemaLiteralValue): CanonicalLiteral;
|
|
457
|
+
/** Mark a legacy or externally managed database default explicitly. */
|
|
458
|
+
declare function externalDefault(): ExternalDefaultDescriptor;
|
|
459
|
+
/** Create an immutable generated-column descriptor. */
|
|
460
|
+
declare function generatedColumn<const TExpression extends AnySchemaExpression>(expression: TExpression, mode?: GeneratedColumnMode | {
|
|
461
|
+
readonly mode: GeneratedColumnMode;
|
|
462
|
+
}): ExpressionGeneratedColumnDescriptor<TExpression>;
|
|
463
|
+
/** Mark a legacy or externally managed generated column explicitly. */
|
|
464
|
+
declare function externalGeneratedColumn(): ExternalGeneratedColumnDescriptor;
|
|
465
|
+
/** Describe a database identity column without inventing a generated SQL expression. */
|
|
466
|
+
declare function identityColumn(generation?: IdentityGeneration, options?: {
|
|
467
|
+
readonly dialect?: IdentityDialectExtension;
|
|
468
|
+
}): IdentityDescriptor;
|
|
469
|
+
/** The normalized behavior fields attached to a column definition. */
|
|
470
|
+
interface ResolvedColumnBehavior {
|
|
471
|
+
readonly hasDefault: boolean;
|
|
472
|
+
readonly generated: boolean;
|
|
473
|
+
readonly default?: ColumnDefault;
|
|
474
|
+
readonly generatedColumn?: GeneratedColumnDescriptor;
|
|
475
|
+
readonly identity?: IdentityDescriptor;
|
|
476
|
+
readonly onUpdate?: AnySchemaExpression;
|
|
477
|
+
}
|
|
478
|
+
/** Normalize complete and legacy column behavior into immutable metadata. */
|
|
479
|
+
declare function resolveColumnBehavior(options: {
|
|
480
|
+
readonly hasDefault?: boolean;
|
|
481
|
+
readonly generated?: boolean;
|
|
482
|
+
readonly default?: ColumnDefaultInput;
|
|
483
|
+
readonly generatedColumn?: GeneratedColumnDescriptor;
|
|
484
|
+
readonly identity?: IdentityDescriptor;
|
|
485
|
+
readonly onUpdate?: AnySchemaExpression;
|
|
486
|
+
}): ResolvedColumnBehavior;
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region src/schema/column.d.ts
|
|
489
|
+
/** Portable physical storage spellings understood by every schema dialect. */
|
|
490
|
+
type PortableStorageType = 'integer' | 'numeric' | 'text' | 'boolean' | 'date' | 'timestamp' | 'uuid' | 'json' | 'bigint' | 'binary';
|
|
491
|
+
/** A dialect-neutral physical storage descriptor. */
|
|
492
|
+
interface PortableColumnStorage<TType extends PortableStorageType = PortableStorageType> {
|
|
493
|
+
readonly kind: 'portable';
|
|
494
|
+
/** Stable physical storage category, independent of the SQL domain. */
|
|
495
|
+
readonly type: TType;
|
|
496
|
+
}
|
|
497
|
+
/** A physical storage declaration owned by one SQL dialect. */
|
|
498
|
+
interface NativeColumnStorage<TDialect extends string = string, TDeclaration extends string = string> {
|
|
499
|
+
readonly kind: 'native';
|
|
500
|
+
/** Adapter name that owns the declaration. */
|
|
501
|
+
readonly dialect: TDialect;
|
|
502
|
+
/** Exact dialect declaration, preserved without normalization. */
|
|
503
|
+
readonly type: TDeclaration;
|
|
504
|
+
}
|
|
505
|
+
/** Physical storage metadata carried by a column definition. */
|
|
506
|
+
type ColumnStorage = PortableColumnStorage | NativeColumnStorage;
|
|
507
|
+
/** Alias for callers that prefer the descriptor terminology. */
|
|
508
|
+
type StorageDescriptor = ColumnStorage;
|
|
509
|
+
/** Alias for the complete column storage union. */
|
|
510
|
+
type ColumnStorageDescriptor = ColumnStorage;
|
|
511
|
+
/** Alias for the dialect-owned branch of {@link ColumnStorage}. */
|
|
512
|
+
type DialectNativeStorage<TDialect extends string = string, TDeclaration extends string = string> = NativeColumnStorage<TDialect, TDeclaration>;
|
|
513
|
+
/** Alias for the dialect-owned descriptor terminology. */
|
|
514
|
+
type NativeStorageDescriptor<TDialect extends string = string, TDeclaration extends string = string> = NativeColumnStorage<TDialect, TDeclaration>;
|
|
515
|
+
/** Alias for the portable branch of {@link ColumnStorage}. */
|
|
516
|
+
type PortableStorage<TType extends PortableStorageType = PortableStorageType> = PortableColumnStorage<TType>;
|
|
517
|
+
/** Alias for the portable descriptor terminology. */
|
|
518
|
+
type PortableStorageDescriptor<TType extends PortableStorageType = PortableStorageType> = PortableColumnStorage<TType>;
|
|
519
|
+
/** Alias for the native branch of {@link ColumnStorage}. */
|
|
520
|
+
type NativeStorage<TDialect extends string = string, TDeclaration extends string = string> = NativeColumnStorage<TDialect, TDeclaration>;
|
|
521
|
+
/** Create an immutable portable physical storage descriptor. */
|
|
522
|
+
declare function portableStorage<const TType extends PortableStorageType>(type: TType): PortableColumnStorage<TType>;
|
|
523
|
+
/** Create an immutable dialect-native physical storage descriptor. */
|
|
524
|
+
declare function nativeStorage<const TDialect extends string, const TDeclaration extends string>(dialect: TDialect, type: TDeclaration): NativeColumnStorage<TDialect, TDeclaration>;
|
|
525
|
+
/** Create a native descriptor from a named object for adapter integrations. */
|
|
526
|
+
declare function nativeStorage<const TDialect extends string, const TDeclaration extends string>(options: {
|
|
527
|
+
readonly dialect: TDialect;
|
|
528
|
+
readonly type: TDeclaration;
|
|
529
|
+
}): NativeColumnStorage<TDialect, TDeclaration>;
|
|
530
|
+
/** Accept `declaration` when adapting an external type registry. */
|
|
531
|
+
declare function nativeStorage<const TDialect extends string, const TDeclaration extends string>(options: {
|
|
532
|
+
readonly dialect: TDialect;
|
|
533
|
+
readonly declaration: TDeclaration;
|
|
534
|
+
}): NativeColumnStorage<TDialect, TDeclaration>;
|
|
535
|
+
/** Describes the storage branch carried by a column definition. */
|
|
536
|
+
type ColumnStorageOf<T> = T extends {
|
|
537
|
+
readonly storage?: infer TStorage;
|
|
538
|
+
} ? TStorage : never;
|
|
539
|
+
/** Extract the portable storage category from a column definition. */
|
|
540
|
+
type ColumnStorageTypeOf<T> = Extract<ColumnStorageOf<T>, PortableColumnStorage> extends PortableColumnStorage<infer TType> ? TType : never;
|
|
541
|
+
/** Extract the owning dialect from a native column definition. */
|
|
542
|
+
type ColumnStorageDialectOf<T> = Extract<ColumnStorageOf<T>, NativeColumnStorage> extends NativeColumnStorage<infer TDialect, any> ? TDialect : never;
|
|
543
|
+
/** Extract the exact native declaration from a column definition. */
|
|
544
|
+
type ColumnStorageDeclarationOf<T> = Extract<ColumnStorageOf<T>, NativeColumnStorage> extends NativeColumnStorage<any, infer TDeclaration> ? TDeclaration : never;
|
|
545
|
+
/** Extract the descriptor discriminant from a column definition. */
|
|
546
|
+
type ColumnStorageKindOf<T> = Extract<ColumnStorageOf<T>, ColumnStorage>['kind'];
|
|
547
|
+
/** Short alias for {@link ColumnStorageOf}. */
|
|
548
|
+
type StorageOf<T> = ColumnStorageOf<T>;
|
|
549
|
+
/** Alias matching the existing `ColumnSqlType` extraction naming. */
|
|
550
|
+
type ColumnStorageType<T> = ColumnStorageOf<T>;
|
|
551
|
+
/** Alias for the portable category extraction. */
|
|
552
|
+
type StorageTypeOf<T> = ColumnStorageTypeOf<T>;
|
|
553
|
+
/** Alias for the dialect extraction. */
|
|
554
|
+
type StorageDialectOf<T> = ColumnStorageDialectOf<T>;
|
|
555
|
+
/** Alias for the native declaration extraction. */
|
|
556
|
+
type StorageDeclarationOf<T> = ColumnStorageDeclarationOf<T>;
|
|
557
|
+
interface ColumnOptions {
|
|
558
|
+
readonly nullable?: boolean;
|
|
559
|
+
readonly hasDefault?: boolean;
|
|
560
|
+
readonly generated?: boolean;
|
|
561
|
+
/** A literal, deterministic expression, or externally managed default. */
|
|
562
|
+
readonly default?: ColumnDefaultInput;
|
|
563
|
+
/** Complete generated-column metadata, independent of identity behavior. */
|
|
564
|
+
readonly generatedColumn?: GeneratedColumnDescriptor;
|
|
565
|
+
/** Database identity metadata; identity is not an ordinary expression. */
|
|
566
|
+
readonly identity?: IdentityDescriptor;
|
|
567
|
+
/** MySQL's optional parameter-free `ON UPDATE` expression. */
|
|
568
|
+
readonly onUpdate?: AnySchemaExpression;
|
|
569
|
+
/** Override the snake_case SQL identifier derived from the field name. */
|
|
570
|
+
readonly sqlName?: string;
|
|
571
|
+
/** Physical storage metadata for a custom column definition. */
|
|
572
|
+
readonly storage?: ColumnStorage;
|
|
573
|
+
/**
|
|
574
|
+
* Raw SQL target that makes a custom definition reusable with cast().
|
|
575
|
+
* The value is emitted verbatim and must come from trusted source code.
|
|
576
|
+
*/
|
|
577
|
+
readonly castType?: string;
|
|
578
|
+
}
|
|
579
|
+
type BuiltInColumnOptions = Omit<ColumnOptions, 'castType' | 'storage'> & {
|
|
580
|
+
readonly castType?: never;
|
|
581
|
+
readonly storage?: never;
|
|
582
|
+
};
|
|
583
|
+
interface ColumnDefinition<TOutput = unknown, TNullable extends boolean = false, TInsert = TOutput, TUpdate = TInsert, THasDefault extends boolean = false, TGenerated extends boolean = false, TSqlType extends AnySqlType = SqlUnknown, TStorage extends ColumnStorage | undefined = undefined, TDefault extends ColumnDefault | undefined = ColumnDefault | undefined, TGeneratedColumn extends GeneratedColumnDescriptor | undefined = GeneratedColumnDescriptor | undefined, TIdentity extends IdentityDescriptor | undefined = IdentityDescriptor | undefined, TOnUpdate extends AnySchemaExpression | undefined = AnySchemaExpression | undefined> {
|
|
584
|
+
readonly definitionKind: 'column';
|
|
585
|
+
readonly nullable: TNullable;
|
|
586
|
+
readonly hasDefault: THasDefault;
|
|
587
|
+
readonly generated: TGenerated;
|
|
588
|
+
/** Complete database default metadata, when known. */
|
|
589
|
+
readonly default?: TDefault;
|
|
590
|
+
/** Complete generated-column metadata, when known. */
|
|
591
|
+
readonly generatedColumn?: TGeneratedColumn;
|
|
592
|
+
/** Identity behavior is modeled separately from generated expressions. */
|
|
593
|
+
readonly identity?: TIdentity;
|
|
594
|
+
/** MySQL's optional parameter-free `ON UPDATE` expression. */
|
|
595
|
+
readonly onUpdate?: TOnUpdate;
|
|
596
|
+
readonly sqlName?: string;
|
|
597
|
+
/** Physical storage metadata, separate from the application and SQL types. */
|
|
598
|
+
readonly storage?: TStorage;
|
|
599
|
+
/** Runtime CAST target when this definition can describe a cast result. */
|
|
600
|
+
readonly castTarget?: CastTarget;
|
|
601
|
+
readonly __output?: TOutput;
|
|
602
|
+
readonly __insert?: TInsert;
|
|
603
|
+
readonly __update?: TUpdate;
|
|
604
|
+
/**
|
|
605
|
+
* Narrow the column's application type without changing its runtime
|
|
606
|
+
* definition.
|
|
607
|
+
*
|
|
608
|
+
* @remarks Distinct insert or update types are preserved. This method does
|
|
609
|
+
* not validate values or add a database constraint.
|
|
610
|
+
*/
|
|
611
|
+
readonly $type: <const TType extends TOutput>() => ColumnDefinition<TType, TNullable, SameType<TInsert, TOutput> extends true ? TType : TInsert, SameType<TUpdate, TOutput> extends true ? TType : TUpdate, THasDefault, TGenerated, TSqlType, TStorage, TDefault, TGeneratedColumn, TIdentity, TOnUpdate> & (this extends {
|
|
612
|
+
readonly castTarget: infer TCastTarget extends CastTarget;
|
|
613
|
+
} ? {
|
|
614
|
+
readonly castTarget: TCastTarget;
|
|
615
|
+
} : unknown);
|
|
616
|
+
readonly __sqlType?: TSqlType;
|
|
617
|
+
}
|
|
618
|
+
type Flag<T extends boolean | undefined> = T extends true ? true : false;
|
|
619
|
+
type HasExplicitOption<TOptions, TKey extends PropertyKey> = TKey extends keyof TOptions ? {} extends Pick<TOptions, TKey> ? false : true : false;
|
|
620
|
+
type ColumnHasDefaultOption<TOptions extends ColumnOptions> = HasExplicitOption<TOptions, 'default'> extends true ? true : Flag<TOptions['hasDefault']>;
|
|
621
|
+
type ColumnIsGeneratedOption<TOptions extends ColumnOptions> = TOptions extends {
|
|
622
|
+
readonly generatedColumn: GeneratedColumnDescriptor;
|
|
623
|
+
} ? true : TOptions extends {
|
|
624
|
+
readonly identity: IdentityDescriptor;
|
|
625
|
+
} ? true : Flag<TOptions['generated']>;
|
|
626
|
+
type ColumnDefaultOption<TOptions extends ColumnOptions> = HasExplicitOption<TOptions, 'default'> extends true ? TOptions extends {
|
|
627
|
+
readonly default: infer TDefault;
|
|
628
|
+
} ? TDefault extends AnySchemaExpression ? ExpressionDefaultDescriptor<TDefault> : TDefault extends ExternalDefaultDescriptor ? TDefault : TDefault extends SchemaLiteralValue ? LiteralDefaultDescriptor : never : never : TOptions['hasDefault'] extends true ? ExternalDefaultDescriptor : undefined;
|
|
629
|
+
type ColumnGeneratedOption<TOptions extends ColumnOptions> = TOptions extends {
|
|
630
|
+
readonly generatedColumn: infer TGenerated extends GeneratedColumnDescriptor;
|
|
631
|
+
} ? TGenerated : TOptions['generated'] extends true ? ExternalGeneratedColumnDescriptor : undefined;
|
|
632
|
+
type ColumnIdentityOption<TOptions extends ColumnOptions> = TOptions extends {
|
|
633
|
+
readonly identity: infer TIdentity extends IdentityDescriptor;
|
|
634
|
+
} ? TIdentity : undefined;
|
|
635
|
+
type ColumnOnUpdateOption<TOptions extends ColumnOptions> = TOptions extends {
|
|
636
|
+
readonly onUpdate: infer TOnUpdate extends AnySchemaExpression;
|
|
637
|
+
} ? TOnUpdate : undefined;
|
|
638
|
+
type IsAny$1<T> = 0 extends 1 & T ? true : false;
|
|
639
|
+
type SameType<TLeft, TRight> = IsAny$1<TLeft> extends true ? IsAny$1<TRight> : IsAny$1<TRight> extends true ? false : [TLeft] extends [TRight] ? [TRight] extends [TLeft] ? true : false : false;
|
|
640
|
+
type ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends ColumnOptions, TSqlType extends AnySqlType = SqlUnknown> = ColumnDefinition<TOutput, Flag<TOptions['nullable']>, TInsert, TUpdate, ColumnHasDefaultOption<TOptions>, ColumnIsGeneratedOption<TOptions>, TSqlType, TOptions extends {
|
|
641
|
+
readonly storage: infer TStorage;
|
|
642
|
+
} ? TStorage extends ColumnStorage ? TStorage : undefined : undefined, ColumnDefaultOption<TOptions>, ColumnGeneratedOption<TOptions>, ColumnIdentityOption<TOptions>, ColumnOnUpdateOption<TOptions>> & (TOptions extends {
|
|
643
|
+
readonly castType: string;
|
|
644
|
+
} ? {
|
|
645
|
+
readonly castTarget: NamedCastTarget;
|
|
646
|
+
} : unknown);
|
|
647
|
+
type ColumnOutput<T> = T extends ColumnDefinition<infer TOutput, infer TNullable, any, any, any, any, any, any, any, any> ? TNullable extends true ? TOutput | null : TOutput : never;
|
|
648
|
+
type ColumnInsertInput<T> = T extends ColumnDefinition<any, infer TNullable, infer TInsert, any, any, any, any, any, any, any, any> ? TNullable extends true ? TInsert | null : TInsert : never;
|
|
649
|
+
type ColumnUpdateInput<T> = T extends ColumnDefinition<any, infer TNullable, any, infer TUpdate, any, any, any, any, any, any, any> ? TNullable extends true ? TUpdate | null : TUpdate : never;
|
|
650
|
+
type ColumnHasDefault<T> = T extends ColumnDefinition<any, any, any, any, infer THasDefault, any, any, any, any, any, any> ? THasDefault : false;
|
|
651
|
+
type ColumnIsGenerated<T> = T extends ColumnDefinition<any, any, any, any, any, infer TGenerated, any, any, any, any, any> ? TGenerated : false;
|
|
652
|
+
/** Extract complete default metadata from a column definition. */
|
|
653
|
+
type ColumnDefaultOf<T> = T extends ColumnDefinition<any, any, any, any, any, any, any, any, infer TDefault, any, any> ? TDefault : undefined;
|
|
654
|
+
/** Extract complete generated-column metadata from a column definition. */
|
|
655
|
+
type ColumnGeneratedOf<T> = T extends ColumnDefinition<any, any, any, any, any, any, any, any, any, infer TGenerated, any> ? TGenerated : undefined;
|
|
656
|
+
/** Extract identity metadata from a column definition. */
|
|
657
|
+
type ColumnIdentityOf<T> = T extends ColumnDefinition<any, any, any, any, any, any, any, any, any, any, infer TIdentity> ? TIdentity : undefined;
|
|
658
|
+
/** Extract a column's optional deterministic `ON UPDATE` expression. */
|
|
659
|
+
type ColumnOnUpdateOf<T> = T extends ColumnDefinition<any, any, any, any, any, any, any, any, any, any, any, infer TOnUpdate> ? TOnUpdate : undefined;
|
|
660
|
+
/** Extract the SQL semantic domain declared by a column definition. */
|
|
661
|
+
type ColumnSqlType<T> = T extends ColumnDefinition<any, any, any, any, any, any, infer TSqlType, any, any, any, any> ? TSqlType : SqlUnknown;
|
|
662
|
+
/** Whether a column definition explicitly permits SQL NULL values. */
|
|
663
|
+
type ColumnIsNullable<T> = T extends ColumnDefinition<any, infer TNullable, any, any, any, any, any, any, any, any, any> ? TNullable : false;
|
|
664
|
+
type FalseColumnOptions = {
|
|
665
|
+
readonly nullable?: false;
|
|
666
|
+
readonly hasDefault?: false;
|
|
667
|
+
readonly generated?: false;
|
|
668
|
+
readonly sqlName?: string;
|
|
669
|
+
};
|
|
670
|
+
type AnyColumnDefinition = ColumnDefinition<any, any, any, any, any, any, AnySqlType, any, any, any, any>;
|
|
671
|
+
type NamedCastColumn<TDefinition extends AnyColumnDefinition> = TDefinition & {
|
|
672
|
+
readonly castTarget: NamedCastTarget;
|
|
673
|
+
};
|
|
674
|
+
type PortableCastColumn<TDefinition extends AnyColumnDefinition, TType extends PortableCastType> = TDefinition & {
|
|
675
|
+
readonly castTarget: PortableCastTarget<TType>;
|
|
676
|
+
};
|
|
677
|
+
type StoredColumnDefinition<TDefinition extends AnyColumnDefinition, TStorage extends ColumnStorage> = TDefinition extends ColumnDefinition<infer TOutput, infer TNullable, infer TInsert, infer TUpdate, infer THasDefault, infer TGenerated, infer TSqlType, any, infer TDefault, infer TGeneratedColumn, infer TIdentity, infer TOnUpdate> ? ColumnDefinition<TOutput, TNullable, TInsert, TUpdate, THasDefault, TGenerated, TSqlType, TStorage, TDefault, TGeneratedColumn, TIdentity, Extract<TOnUpdate, AnySchemaExpression> | undefined> & (TDefinition extends {
|
|
678
|
+
readonly castTarget: infer TCastTarget extends CastTarget;
|
|
679
|
+
} ? {
|
|
680
|
+
readonly castTarget: TCastTarget;
|
|
681
|
+
} : unknown) : never;
|
|
682
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown, const TStorage extends ColumnStorage = ColumnStorage, const TOptions extends Omit<ColumnOptions, 'storage'> = Omit<ColumnOptions, 'storage'>>(options: TOptions & {
|
|
683
|
+
readonly storage: TStorage;
|
|
684
|
+
}): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions & {
|
|
685
|
+
readonly storage: TStorage;
|
|
686
|
+
}, TSqlType>;
|
|
687
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: FalseColumnOptions & {
|
|
688
|
+
readonly castType: string;
|
|
689
|
+
}): NamedCastColumn<ColumnDefinition<TOutput, false, TInsert, TUpdate, false, false, TSqlType>>;
|
|
690
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
691
|
+
readonly nullable: true;
|
|
692
|
+
readonly hasDefault: true;
|
|
693
|
+
readonly generated: true;
|
|
694
|
+
readonly sqlName?: string;
|
|
695
|
+
}): ColumnDefinition<TOutput, true, TInsert, TUpdate, true, true, TSqlType, undefined, ExternalDefaultDescriptor, ExternalGeneratedColumnDescriptor>;
|
|
696
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
697
|
+
readonly nullable: true;
|
|
698
|
+
readonly hasDefault: true;
|
|
699
|
+
readonly generated?: false;
|
|
700
|
+
readonly sqlName?: string;
|
|
701
|
+
}): ColumnDefinition<TOutput, true, TInsert, TUpdate, true, false, TSqlType, undefined, ExternalDefaultDescriptor>;
|
|
702
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
703
|
+
readonly nullable: true;
|
|
704
|
+
readonly hasDefault?: false;
|
|
705
|
+
readonly generated: true;
|
|
706
|
+
readonly sqlName?: string;
|
|
707
|
+
}): ColumnDefinition<TOutput, true, TInsert, TUpdate, false, true, TSqlType, undefined, undefined, ExternalGeneratedColumnDescriptor>;
|
|
708
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
709
|
+
readonly nullable: true;
|
|
710
|
+
readonly hasDefault?: false;
|
|
711
|
+
readonly generated?: false;
|
|
712
|
+
readonly sqlName?: string;
|
|
713
|
+
}): ColumnDefinition<TOutput, true, TInsert, TUpdate, false, false, TSqlType>;
|
|
714
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
715
|
+
readonly nullable?: false;
|
|
716
|
+
readonly hasDefault: true;
|
|
717
|
+
readonly generated: true;
|
|
718
|
+
readonly sqlName?: string;
|
|
719
|
+
}): ColumnDefinition<TOutput, false, TInsert, TUpdate, true, true, TSqlType, undefined, ExternalDefaultDescriptor, ExternalGeneratedColumnDescriptor>;
|
|
720
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
721
|
+
readonly nullable?: false;
|
|
722
|
+
readonly hasDefault: true;
|
|
723
|
+
readonly generated?: false;
|
|
724
|
+
readonly sqlName?: string;
|
|
725
|
+
}): ColumnDefinition<TOutput, false, TInsert, TUpdate, true, false, TSqlType, undefined, ExternalDefaultDescriptor>;
|
|
726
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options: {
|
|
727
|
+
readonly nullable?: false;
|
|
728
|
+
readonly hasDefault?: false;
|
|
729
|
+
readonly generated: true;
|
|
730
|
+
readonly sqlName?: string;
|
|
731
|
+
}): ColumnDefinition<TOutput, false, TInsert, TUpdate, false, true, TSqlType, undefined, undefined, ExternalGeneratedColumnDescriptor>;
|
|
732
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown>(options?: FalseColumnOptions): ColumnDefinition<TOutput, false, TInsert, TUpdate, false, false, TSqlType>;
|
|
733
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, TSqlType extends AnySqlType = SqlUnknown, const TOptions extends ColumnOptions = {}>(options?: TOptions): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType>;
|
|
734
|
+
declare function column<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends ColumnOptions = {}, TSqlType extends AnySqlType = SqlUnknown>(options?: TOptions): ColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType>;
|
|
735
|
+
type NativeColumnOptions = Omit<ColumnOptions, 'storage'> & {
|
|
736
|
+
readonly storage?: never;
|
|
737
|
+
};
|
|
738
|
+
type NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions extends NativeColumnOptions, TSqlType extends AnySqlType, TDialect extends string, TDeclaration extends string> = ColumnDefinition<TOutput, Flag<TOptions['nullable']>, TInsert, TUpdate, ColumnHasDefaultOption<TOptions>, ColumnIsGeneratedOption<TOptions>, TSqlType, NativeColumnStorage<TDialect, TDeclaration>, ColumnDefaultOption<TOptions>, ColumnGeneratedOption<TOptions>, ColumnIdentityOption<TOptions>, ColumnOnUpdateOption<TOptions>> & (TOptions extends {
|
|
739
|
+
readonly castType: string;
|
|
740
|
+
} ? {
|
|
741
|
+
readonly castTarget: NamedCastTarget;
|
|
742
|
+
} : unknown);
|
|
743
|
+
/** Create a column whose physical declaration belongs to one SQL dialect. */
|
|
744
|
+
declare function nativeColumn<TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends NativeColumnOptions = {}, TSqlType extends AnySqlType = SqlUnknown, const TDialect extends string = string, const TDeclaration extends string = string>(storage: NativeColumnStorage<TDialect, TDeclaration>, options?: TOptions): NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType, TDialect, TDeclaration>;
|
|
745
|
+
/** Create a dialect-native column from an adapter name and exact declaration. */
|
|
746
|
+
declare function nativeColumn<const TDialect extends string, const TDeclaration extends string, TOutput = unknown, TInsert = TOutput, TUpdate = TInsert, const TOptions extends NativeColumnOptions = {}, TSqlType extends AnySqlType = SqlUnknown>(dialect: TDialect, type: TDeclaration, options?: TOptions): NativeColumnFromOptions<TOutput, TInsert, TUpdate, TOptions, TSqlType, TDialect, TDeclaration>;
|
|
747
|
+
declare function nullable<TOutput, TNullable extends boolean, TInsert, TUpdate, THasDefault extends boolean, TGenerated extends boolean, TSqlType extends AnySqlType, TStorage extends ColumnStorage | undefined, TDefault extends ColumnDefault | undefined, TGeneratedColumn extends GeneratedColumnDescriptor | undefined, TIdentity extends IdentityDescriptor | undefined, TOnUpdate extends AnySchemaExpression | undefined>(definition: ColumnDefinition<TOutput, TNullable, TInsert, TUpdate, THasDefault, TGenerated, TSqlType, TStorage, TDefault, TGeneratedColumn, TIdentity, TOnUpdate>): ColumnDefinition<TOutput, true, TInsert, TUpdate, THasDefault, TGenerated, TSqlType, TStorage, TDefault, TGeneratedColumn, TIdentity, TOnUpdate>;
|
|
748
|
+
declare function integer<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<number, number, number, TOptions, SqlInteger>, "integer">, PortableColumnStorage<"integer">>;
|
|
749
|
+
declare function numeric<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<number, number, number, TOptions, SqlDecimal>, "decimal">, PortableColumnStorage<"numeric">>;
|
|
750
|
+
declare function text<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<string, string, string, TOptions, SqlText>, "text">, PortableColumnStorage<"text">>;
|
|
751
|
+
declare function boolean<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<boolean, boolean, boolean, TOptions, SqlBoolean>, "boolean">, PortableColumnStorage<"boolean">>;
|
|
752
|
+
declare function date<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<Date, Date, Date, TOptions, SqlDate>, "date">, PortableColumnStorage<"date">>;
|
|
753
|
+
declare function timestamp<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<Date, Date, Date, TOptions, SqlTimestamp>, "timestamp">, PortableColumnStorage<"timestamp">>;
|
|
754
|
+
declare function uuid<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<string, string, string, TOptions, SqlUuid>, "uuid">, PortableColumnStorage<"uuid">>;
|
|
755
|
+
declare function json<TOutput = unknown, const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<TOutput, TOutput, TOutput, TOptions, SqlJson<TOutput>>, "json">, PortableColumnStorage<"json">>;
|
|
756
|
+
declare function bigint<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<bigint, bigint, bigint, TOptions, SqlBigInt>, "bigint">, PortableColumnStorage<"bigint">>;
|
|
757
|
+
declare function binary<const TOptions extends BuiltInColumnOptions = {}>(options?: TOptions): StoredColumnDefinition<PortableCastColumn<ColumnFromOptions<Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, Uint8Array<ArrayBufferLike>, TOptions, SqlBinary>, "binary">, PortableColumnStorage<"binary">>;
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/schema/column-nullability.d.ts
|
|
760
|
+
declare const declaredColumnNullability: unique symbol;
|
|
761
|
+
/** @internal */
|
|
762
|
+
type DeclaredColumnNullability<TNullable extends boolean> = {
|
|
763
|
+
readonly [declaredColumnNullability]: TNullable;
|
|
764
|
+
};
|
|
765
|
+
/** @internal */
|
|
766
|
+
type DeclaredColumnNullabilityOf<TColumn> = TColumn extends DeclaredColumnNullability<infer TNullable> ? TNullable : never;
|
|
767
|
+
//#endregion
|
|
768
|
+
//#region src/schema/constraints.d.ts
|
|
769
|
+
declare const fieldConstraint: unique symbol;
|
|
770
|
+
/** Application and SQL facts that a reusable source field may require. */
|
|
771
|
+
interface FieldLikeOptions {
|
|
772
|
+
readonly output?: unknown;
|
|
773
|
+
readonly sqlType?: object;
|
|
774
|
+
readonly nullable?: boolean;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* A reusable source-field requirement combining application and SQL facts.
|
|
778
|
+
* Omitted facts impose no constraint; `nullable: false` requires a non-null
|
|
779
|
+
* selected value.
|
|
780
|
+
*/
|
|
781
|
+
interface FieldLike<TOptions extends FieldLikeOptions = FieldLikeOptions> {
|
|
782
|
+
readonly [fieldConstraint]: TOptions;
|
|
783
|
+
}
|
|
784
|
+
type FieldOptions<T> = T extends FieldLike<infer TOptions> ? TOptions : never;
|
|
785
|
+
type RequiredOutput<T> = T extends FieldLike<any> ? FieldOptions<T> extends {
|
|
786
|
+
readonly output: infer TOutput;
|
|
787
|
+
} ? FieldOptions<T> extends {
|
|
788
|
+
readonly nullable: false;
|
|
789
|
+
} ? NonNullable<TOutput> : TOutput : FieldOptions<T> extends {
|
|
790
|
+
readonly nullable: false;
|
|
791
|
+
} ? {} : unknown : T;
|
|
792
|
+
type RequiredSqlType<T> = T extends FieldLike<any> ? FieldOptions<T> extends {
|
|
793
|
+
readonly sqlType: infer TSqlType;
|
|
794
|
+
} ? (AnySqlType & TSqlType) | SqlUnknown : AnySqlType : AnySqlType;
|
|
795
|
+
type RequiredColumn<TField extends string, TRequirement, TIdentity> = ColumnReference<TField, ResultMeta<RequiredOutput<TRequirement>, TIdentity, RequiredSqlType<TRequirement>> | RequiresSourceMeta<TIdentity> | ExpressionMeta<ColumnDependency<TIdentity, TField>>>;
|
|
796
|
+
type RequiredColumns<TShape extends object, TIdentity> = { readonly [K in keyof TShape]-?: K extends string ? RequiredColumn<K, TShape[K], TIdentity> : never; };
|
|
797
|
+
/**
|
|
798
|
+
* A source containing at least the requested application and SQL fields.
|
|
799
|
+
* Additional fields and the concrete source identity are preserved by generic
|
|
800
|
+
* functions that accept this lower-bound constraint.
|
|
801
|
+
*/
|
|
802
|
+
interface SourceLike<TShape extends object> extends Fragment<any> {
|
|
803
|
+
readonly sourceKind: SourceKind;
|
|
804
|
+
readonly [sourceIdentity]: unknown;
|
|
805
|
+
readonly reference: Fragment<never>;
|
|
806
|
+
readonly columns: RequiredColumns<TShape, this[typeof sourceIdentity]>;
|
|
807
|
+
}
|
|
808
|
+
/** The physical-table form of the lower-bound {@link SourceLike} constraint. */
|
|
809
|
+
interface TableLike<TShape extends object> extends SourceLike<TShape> {
|
|
810
|
+
readonly tableName: string;
|
|
811
|
+
readonly definitions: object;
|
|
812
|
+
readonly sqlNames: Readonly<Record<string, string>>;
|
|
813
|
+
}
|
|
814
|
+
/** Standard SQL referential action retained on a foreign-key constraint. */
|
|
815
|
+
type ReferentialAction = 'no-action' | 'restrict' | 'cascade' | 'set-null' | 'set-default';
|
|
816
|
+
/** Standard SQL match mode for a composite foreign key. */
|
|
817
|
+
type ForeignKeyMatch = 'simple' | 'full' | 'partial';
|
|
818
|
+
/** Deferrability timing for a foreign-key or key constraint. */
|
|
819
|
+
type ConstraintTiming = 'immediate' | 'deferred';
|
|
820
|
+
/** PostgreSQL-only constraint options retained for a schema adapter. */
|
|
821
|
+
interface PostgresConstraintExtension extends SchemaDialectExtension<'postgresql'> {
|
|
822
|
+
/** PostgreSQL `NOT VALID` validation state for a constraint. */
|
|
823
|
+
readonly notValid?: boolean;
|
|
824
|
+
}
|
|
825
|
+
/** SQLite-only table-constraint options. */
|
|
826
|
+
interface SqliteConstraintExtension extends SchemaDialectExtension<'sqlite'> {
|
|
827
|
+
/** SQLite conflict policy attached to a table constraint. */
|
|
828
|
+
readonly onConflict?: 'rollback' | 'abort' | 'fail' | 'ignore' | 'replace';
|
|
829
|
+
}
|
|
830
|
+
/** MySQL-only constraint options. */
|
|
831
|
+
interface MysqlConstraintExtension extends SchemaDialectExtension<'mysql'> {
|
|
832
|
+
/** MySQL 8 constraint enforcement state. */
|
|
833
|
+
readonly enforced?: boolean;
|
|
834
|
+
}
|
|
835
|
+
/** First-party and user-defined dialect extensions for constraints. */
|
|
836
|
+
type ConstraintDialectExtension = PostgresConstraintExtension | SqliteConstraintExtension | MysqlConstraintExtension | (SchemaDialectExtension<string> & Readonly<Record<string, unknown>>);
|
|
837
|
+
/** Shared physical-name and dialect-extension options for constraints. */
|
|
838
|
+
interface ConstraintOptions<TExtension extends ConstraintDialectExtension | undefined = ConstraintDialectExtension | undefined> extends SchemaObjectNameOptions {
|
|
839
|
+
/** Engine-specific metadata owned by a future schema adapter. */
|
|
840
|
+
readonly dialect?: TExtension;
|
|
841
|
+
}
|
|
842
|
+
/** Options for primary-key and candidate-key declarations. */
|
|
843
|
+
interface KeyConstraintOptions<TExtension extends ConstraintDialectExtension | undefined = ConstraintDialectExtension | undefined> extends ConstraintOptions<TExtension> {
|
|
844
|
+
/** Whether the key can be deferred by a supporting dialect. */
|
|
845
|
+
readonly deferrable?: boolean;
|
|
846
|
+
/** Initial enforcement timing for a deferrable key. */
|
|
847
|
+
readonly initially?: ConstraintTiming;
|
|
848
|
+
}
|
|
849
|
+
/** Options for a database unique constraint, including nullable columns. */
|
|
850
|
+
interface UniqueConstraintOptions<TExtension extends ConstraintDialectExtension | undefined = ConstraintDialectExtension | undefined> extends ConstraintOptions<TExtension> {
|
|
851
|
+
/**
|
|
852
|
+
* SQL NULL comparison semantics. `distinct` is the common default in which
|
|
853
|
+
* multiple NULL values do not conflict; `not-distinct` permits at most one.
|
|
854
|
+
*/
|
|
855
|
+
readonly nulls?: UniqueNullSemantics;
|
|
856
|
+
/** Whether the constraint can be deferred by a supporting dialect. */
|
|
857
|
+
readonly deferrable?: boolean;
|
|
858
|
+
/** Initial enforcement timing for a deferrable constraint. */
|
|
859
|
+
readonly initially?: ConstraintTiming;
|
|
860
|
+
}
|
|
861
|
+
/** Explicit NULL behavior for a database uniqueness rule. */
|
|
862
|
+
type UniqueNullSemantics = 'distinct' | 'not-distinct';
|
|
863
|
+
/** Options for a table check constraint. */
|
|
864
|
+
interface CheckConstraintOptions<TExtension extends ConstraintDialectExtension | undefined = ConstraintDialectExtension | undefined> extends ConstraintOptions<TExtension> {
|
|
865
|
+
/** Whether the check can be deferred by a supporting dialect. */
|
|
866
|
+
readonly deferrable?: boolean;
|
|
867
|
+
/** Initial enforcement timing for a deferrable check. */
|
|
868
|
+
readonly initially?: ConstraintTiming;
|
|
869
|
+
}
|
|
870
|
+
/** Dialect tag and parameter-free SQL needed to reconstruct a catalog check. */
|
|
871
|
+
interface CatalogCheckSql<TDialect extends SchemaDialectName = SchemaDialectName> {
|
|
872
|
+
/** Catalog dialect that supplied the check expression. */
|
|
873
|
+
readonly dialect: TDialect;
|
|
874
|
+
/** Opaque SQL text recovered from the catalog. */
|
|
875
|
+
readonly sql: string;
|
|
876
|
+
}
|
|
877
|
+
/** Options for a foreign-key declaration. */
|
|
878
|
+
interface ForeignKeyOptions<TExtension extends ConstraintDialectExtension | undefined = ConstraintDialectExtension | undefined> extends ConstraintOptions<TExtension> {
|
|
879
|
+
readonly onUpdate?: ReferentialAction;
|
|
880
|
+
readonly onDelete?: ReferentialAction;
|
|
881
|
+
readonly match?: ForeignKeyMatch;
|
|
882
|
+
readonly deferrable?: boolean;
|
|
883
|
+
readonly initially?: ConstraintTiming;
|
|
884
|
+
}
|
|
885
|
+
/** A schema constraint whose columns form a relational key. */
|
|
886
|
+
interface KeyConstraint<TKind extends 'primary-key' | 'unique' = 'primary-key' | 'unique', TColumns extends readonly ColumnReference<string, any>[] = readonly ColumnReference<string, any>[]> extends SchemaObjectIdentity {
|
|
887
|
+
readonly kind: TKind;
|
|
888
|
+
readonly columns: TColumns;
|
|
889
|
+
readonly physicalName?: string;
|
|
890
|
+
readonly dialect?: ConstraintDialectExtension;
|
|
891
|
+
readonly deferrable?: boolean;
|
|
892
|
+
readonly initially?: ConstraintTiming;
|
|
893
|
+
}
|
|
894
|
+
/** A referenced table and exact candidate-key column tuple. */
|
|
895
|
+
interface ForeignKeyTarget<TTable extends TableLike<any> = TableLike<any>, TColumns extends readonly AnyKeyColumn[] = readonly AnyKeyColumn[]> {
|
|
896
|
+
readonly table: TTable;
|
|
897
|
+
readonly columns: TColumns;
|
|
898
|
+
}
|
|
899
|
+
type ForeignKeyTargetInput<TTarget extends ForeignKeyTarget = ForeignKeyTarget> = TTarget | (() => TTarget);
|
|
900
|
+
/** A foreign key from local columns to a direct or lazily resolved target. */
|
|
901
|
+
interface ForeignKeyConstraint<TColumns extends readonly AnyKeyColumn[] = readonly AnyKeyColumn[], TTarget extends ForeignKeyTargetInput = ForeignKeyTargetInput> extends SchemaObjectIdentity {
|
|
902
|
+
readonly kind: 'foreign-key';
|
|
903
|
+
readonly columns: TColumns;
|
|
904
|
+
readonly target: TTarget;
|
|
905
|
+
readonly physicalName?: string;
|
|
906
|
+
readonly dialect?: ConstraintDialectExtension;
|
|
907
|
+
readonly onUpdate?: ReferentialAction;
|
|
908
|
+
readonly onDelete?: ReferentialAction;
|
|
909
|
+
readonly match?: ForeignKeyMatch;
|
|
910
|
+
readonly deferrable?: boolean;
|
|
911
|
+
readonly initially?: ConstraintTiming;
|
|
912
|
+
}
|
|
913
|
+
/** Database uniqueness that deliberately does not prove a candidate key. */
|
|
914
|
+
interface UniqueConstraint<TColumns extends readonly AnyKeyColumn[] = readonly AnyKeyColumn[], TNulls extends UniqueNullSemantics = UniqueNullSemantics> extends SchemaObjectIdentity {
|
|
915
|
+
readonly kind: 'unique-constraint';
|
|
916
|
+
readonly columns: TColumns;
|
|
917
|
+
readonly nulls: TNulls;
|
|
918
|
+
readonly physicalName?: string;
|
|
919
|
+
readonly dialect?: ConstraintDialectExtension;
|
|
920
|
+
readonly deferrable?: boolean;
|
|
921
|
+
readonly initially?: ConstraintTiming;
|
|
922
|
+
}
|
|
923
|
+
/** A table-scoped boolean invariant. */
|
|
924
|
+
interface CheckConstraint<TExpression extends AnyExpression = AnyExpression> extends SchemaObjectIdentity {
|
|
925
|
+
readonly kind: 'check';
|
|
926
|
+
readonly expression: TExpression;
|
|
927
|
+
readonly physicalName?: string;
|
|
928
|
+
readonly dialect?: ConstraintDialectExtension;
|
|
929
|
+
readonly deferrable?: boolean;
|
|
930
|
+
readonly initially?: ConstraintTiming;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Opaque catalog SQL whose check-constraint origin proves a boolean SQL
|
|
934
|
+
* semantic type. The expression remains dialect-tagged and parameter-free.
|
|
935
|
+
*/
|
|
936
|
+
interface CatalogCheckExpression<TDialect extends SchemaDialectName = SchemaDialectName> extends SchemaExpression<ResultMeta<boolean, never, SqlBoolean> | ExpressionMeta<never>, 'unsafe'> {
|
|
937
|
+
readonly schemaSqlDialect: TDialect;
|
|
938
|
+
readonly schemaSql: string;
|
|
939
|
+
}
|
|
940
|
+
/** Structured schema metadata carried by sources that declare constraints. */
|
|
941
|
+
type SourceConstraint = KeyConstraint | UniqueConstraint | ForeignKeyConstraint | CheckConstraint;
|
|
942
|
+
/** Named schema constraints attached to a source. */
|
|
943
|
+
type SourceConstraintsRecord = Readonly<Record<string, SourceConstraint>>;
|
|
944
|
+
/**
|
|
945
|
+
* Validate one constraint against a schema adapter dialect. This is kept
|
|
946
|
+
* separate from construction because the same declaration can be inspected
|
|
947
|
+
* for more than one target dialect before a serializer is selected.
|
|
948
|
+
*/
|
|
949
|
+
declare function validateConstraintDialect(constraint: SourceConstraint, dialect: string, path?: readonly (string | number)[]): readonly SchemaMetadataDiagnostic[];
|
|
950
|
+
type AnyKeyColumn = ColumnReference<string, any>;
|
|
951
|
+
type ColumnSource<TColumn> = DependenciesOf<TColumn> extends ColumnDependency<infer TSource, string> ? TSource : never;
|
|
952
|
+
type IsNullableKeyColumn<TColumn> = [DeclaredColumnNullabilityOf<TColumn>] extends [never] ? null extends OutputOf<TColumn> ? true : false : true extends DeclaredColumnNullabilityOf<TColumn> ? true : false;
|
|
953
|
+
type InvalidKeyColumn<TColumn, TSource> = TColumn extends AnyKeyColumn ? IsNullableKeyColumn<TColumn> extends true ? TColumn : DependenciesOf<TColumn> extends ColumnDependency<TSource, string> ? never : TColumn : TColumn;
|
|
954
|
+
type KeyColumnsValidation<TColumns extends readonly AnyKeyColumn[]> = [{ [K in keyof TColumns]: InvalidKeyColumn<TColumns[K], ColumnSource<TColumns[0]>>; }[number]] extends [never] ? unknown : never;
|
|
955
|
+
type SameSourceColumnsValidation<TColumns extends readonly AnyKeyColumn[]> = [{ [K in keyof TColumns]: TColumns[K] extends AnyKeyColumn ? DependenciesOf<TColumns[K]> extends ColumnDependency<ColumnSource<TColumns[0]>, string> ? never : TColumns[K] : TColumns[K]; }[number]] extends [never] ? unknown : never;
|
|
956
|
+
type SameSqlDomain<TLeft, TRight> = SqlTypeOf<TLeft> extends (infer TLeftSql) ? SqlTypeOf<TRight> extends (infer TRightSql) ? TLeftSql extends SqlUnknown ? false : TRightSql extends SqlUnknown ? false : TLeftSql extends AnySqlType ? TRightSql extends AnySqlType ? string extends TLeftSql['sqlType'] ? false : string extends TRightSql['sqlType'] ? false : [TLeftSql['sqlType']] extends [TRightSql['sqlType']] ? [TRightSql['sqlType']] extends [TLeftSql['sqlType']] ? true : false : false : false : false : false : false;
|
|
957
|
+
type ForeignKeyColumnsValidation<TLocal extends readonly AnyKeyColumn[], TTarget extends readonly AnyKeyColumn[]> = TLocal extends readonly [infer TLocalHead, ...infer TLocalTail] ? TTarget extends readonly [infer TTargetHead, ...infer TTargetTail] ? TLocalHead extends AnyKeyColumn ? TTargetHead extends AnyKeyColumn ? SameSqlDomain<TLocalHead, TTargetHead> extends true ? ForeignKeyColumnsValidation<Extract<TLocalTail, readonly AnyKeyColumn[]>, Extract<TTargetTail, readonly AnyKeyColumn[]>> : never : never : never : never : TTarget extends readonly [] ? unknown : never;
|
|
958
|
+
type IsUnresolvedSqlDomain<TSqlType> = TSqlType extends SqlUnknown ? true : TSqlType extends AnySqlType ? string extends TSqlType['sqlType'] ? true : false : true;
|
|
959
|
+
type CatalogSqlDomainCompatible<TLeft, TRight> = true extends IsUnresolvedSqlDomain<SqlTypeOf<TLeft>> | IsUnresolvedSqlDomain<SqlTypeOf<TRight>> ? true : SameSqlDomain<TLeft, TRight>;
|
|
960
|
+
type CatalogForeignKeyColumnsValidation<TLocal extends readonly AnyKeyColumn[], TTarget extends readonly AnyKeyColumn[]> = TLocal extends readonly [infer TLocalHead, ...infer TLocalTail] ? TTarget extends readonly [infer TTargetHead, ...infer TTargetTail] ? TLocalHead extends AnyKeyColumn ? TTargetHead extends AnyKeyColumn ? CatalogSqlDomainCompatible<TLocalHead, TTargetHead> extends true ? CatalogForeignKeyColumnsValidation<Extract<TLocalTail, readonly AnyKeyColumn[]>, Extract<TTargetTail, readonly AnyKeyColumn[]>> : never : never : never : never : TTarget extends readonly [] ? unknown : never;
|
|
961
|
+
type CheckExpressionValidation<TExpression> = [SqlTypeOf<TExpression>] extends [never] ? never : SqlTypeOf<TExpression> extends SqlBoolean ? unknown : never;
|
|
962
|
+
/** Declare a primary key, including a composite primary key. */
|
|
963
|
+
declare function primaryKey<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]]>(...columns: TColumns & KeyColumnsValidation<NoInfer<TColumns>>): KeyConstraint<'primary-key', TColumns>;
|
|
964
|
+
declare function primaryKey<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]], const TOptions extends KeyConstraintOptions>(...columnsAndOptions: [...TColumns, TOptions] & KeyColumnsValidation<NoInfer<TColumns>>): KeyConstraint<'primary-key', TColumns>;
|
|
965
|
+
/** Declare a non-null unique key, including a composite unique key. */
|
|
966
|
+
declare function unique<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]]>(...columns: TColumns & KeyColumnsValidation<NoInfer<TColumns>>): KeyConstraint<'unique', TColumns>;
|
|
967
|
+
declare function unique<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]], const TOptions extends KeyConstraintOptions>(...columnsAndOptions: [...TColumns, TOptions] & KeyColumnsValidation<NoInfer<TColumns>>): KeyConstraint<'unique', TColumns>;
|
|
968
|
+
/**
|
|
969
|
+
* Describe database uniqueness without claiming that the columns determine a
|
|
970
|
+
* row. Nullable columns are accepted, and the NULL behavior is explicit in
|
|
971
|
+
* the returned metadata. Use {@link unique} when a type-level key proof is
|
|
972
|
+
* intended.
|
|
973
|
+
*/
|
|
974
|
+
declare function uniqueConstraint<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]]>(...columns: TColumns & SameSourceColumnsValidation<NoInfer<TColumns>>): UniqueConstraint<TColumns, 'distinct'>;
|
|
975
|
+
declare function uniqueConstraint<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]], const TOptions extends UniqueConstraintOptions>(...columnsAndOptions: [...TColumns, TOptions] & SameSourceColumnsValidation<NoInfer<TColumns>>): UniqueConstraint<TColumns, TOptions extends {
|
|
976
|
+
readonly nulls: infer TNulls extends UniqueNullSemantics;
|
|
977
|
+
} ? TNulls : 'distinct'>;
|
|
978
|
+
/** Pair a table with the exact columns targeted by a foreign key. */
|
|
979
|
+
declare function references<TTable extends TableLike<any>, const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]]>(table: TTable, ...columns: TColumns): ForeignKeyTarget<TTable, TColumns>;
|
|
980
|
+
type ResolvedTarget$1<T> = T extends (() => infer TResolved) ? TResolved : T;
|
|
981
|
+
/** Declare a single-column or composite foreign key. */
|
|
982
|
+
declare function foreignKey<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]], const TTarget extends ForeignKeyTargetInput, const TOptions extends ForeignKeyOptions = {}>(columns: TColumns & SameSourceColumnsValidation<NoInfer<TColumns>>, target: TTarget & (ResolvedTarget$1<TTarget> extends ForeignKeyTarget<any, infer TTargetColumns> ? ForeignKeyColumnsValidation<TColumns, TTargetColumns> : never), options?: TOptions): ForeignKeyConstraint<TColumns, TTarget>;
|
|
983
|
+
/**
|
|
984
|
+
* Reconstruct a foreign key proved by database catalog metadata.
|
|
985
|
+
*
|
|
986
|
+
* @remarks
|
|
987
|
+
* Use this helper for generated or introspection-owned declarations when one
|
|
988
|
+
* or both native SQL domains are unresolved. It accepts unresolved domains,
|
|
989
|
+
* but still rejects known domain mismatches, unequal tuple arity, and local
|
|
990
|
+
* columns from different sources. The enclosing `table()` declaration
|
|
991
|
+
* continues to verify target-column ownership and candidate-key metadata.
|
|
992
|
+
* Resolved targets also receive runtime shape, ownership, and arity checks.
|
|
993
|
+
* The returned value serializes as an ordinary foreign-key constraint.
|
|
994
|
+
*/
|
|
995
|
+
declare function catalogForeignKey<const TColumns extends readonly [AnyKeyColumn, ...AnyKeyColumn[]], const TTarget extends ForeignKeyTargetInput, const TOptions extends ForeignKeyOptions = {}>(columns: TColumns & SameSourceColumnsValidation<NoInfer<TColumns>>, target: TTarget & (ResolvedTarget$1<TTarget> extends ForeignKeyTarget<any, infer TTargetColumns> ? CatalogForeignKeyColumnsValidation<TColumns, TTargetColumns> : never), options?: TOptions): ForeignKeyConstraint<TColumns, TTarget>;
|
|
996
|
+
/** Declare a boolean table invariant. */
|
|
997
|
+
declare function check<const TExpression extends Expression<any, any>, const TOptions extends CheckConstraintOptions = {}>(expression: TExpression & CheckExpressionValidation<TExpression>, options?: TOptions): CheckConstraint<TExpression>;
|
|
998
|
+
/**
|
|
999
|
+
* Reconstruct a boolean check from opaque SQL recovered from a database
|
|
1000
|
+
* catalog.
|
|
1001
|
+
*
|
|
1002
|
+
* @remarks
|
|
1003
|
+
* This helper records catalog origin as a narrow type-level proof. It
|
|
1004
|
+
* gives the opaque expression the {@link SqlBoolean} semantic type without
|
|
1005
|
+
* changing the ordinary {@link check} contract. Qubu does not parse or infer
|
|
1006
|
+
* dependencies from the SQL. It preserves the text apart from normalizing
|
|
1007
|
+
* line endings and retains the dialect tag in serialized schema metadata.
|
|
1008
|
+
*/
|
|
1009
|
+
declare function catalogCheck<const TDialect extends SchemaDialectName, const TOptions extends CheckConstraintOptions = {}>(input: CatalogCheckSql<TDialect>, options?: TOptions): CheckConstraint<CatalogCheckExpression<TDialect>>;
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/query/errors.d.ts
|
|
1012
|
+
/** Stable diagnostics shared by type-level and runtime query validation. */
|
|
1013
|
+
type QueryValidationErrorCode = 'invalid-selection' | 'duplicate-clause' | 'invalid-mutation' | 'unsafe-mutation' | 'invalid-update' | 'invalid-insert' | 'invalid-comparison' | 'invalid-boolean-expression' | 'invalid-pagination' | 'invalid-row-lock' | 'invalid-json-path' | 'missing-source' | 'invalid-grouping' | 'incompatible-sql-domain' | 'incompatible-sql-equality' | 'incompatible-sql-order' | 'incompatible-set-domain' | 'invalid-subquery' | 'invalid-omission' | 'invalid-stream-query' | 'invalid-explain-query' | 'invalid-explain-options' | 'unsupported-explain-option' | 'unsupported-explain-dialect' | 'missing-dialect-capability';
|
|
1014
|
+
interface QueryValidationIssue {
|
|
1015
|
+
readonly code: QueryValidationErrorCode;
|
|
1016
|
+
readonly context: string;
|
|
1017
|
+
readonly path: readonly (string | number)[];
|
|
1018
|
+
readonly message: string;
|
|
1019
|
+
readonly hint: string;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* A type-level query failure that names the failing rule and the repair path.
|
|
1023
|
+
* The legacy detail field is optional so each validator can retain the useful
|
|
1024
|
+
* source or clause type in the compiler diagnostic.
|
|
1025
|
+
*/
|
|
1026
|
+
type QueryTypeValidation<TCode extends QueryValidationErrorCode, TContext extends string, THint extends string, TDetail = never> = {
|
|
1027
|
+
readonly __qubu_error_code__: TCode;
|
|
1028
|
+
readonly __qubu_error_context__: TContext;
|
|
1029
|
+
readonly __qubu_error_hint__: THint;
|
|
1030
|
+
} & ([TDetail] extends [never] ? unknown : {
|
|
1031
|
+
readonly __qubu_error_detail__: TDetail;
|
|
1032
|
+
});
|
|
1033
|
+
/** Raised when a query cannot satisfy Qubu's runtime authoring rules. */
|
|
1034
|
+
declare class QueryValidationError extends TypeError {
|
|
1035
|
+
readonly name = "QueryValidationError";
|
|
1036
|
+
readonly code: QueryValidationErrorCode;
|
|
1037
|
+
readonly context: string;
|
|
1038
|
+
readonly path: readonly (string | number)[];
|
|
1039
|
+
readonly hint: string;
|
|
1040
|
+
readonly issue: QueryValidationIssue;
|
|
1041
|
+
constructor(issue: QueryValidationIssue);
|
|
1042
|
+
}
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/core/render.d.ts
|
|
1045
|
+
type DefaultDialectCapability = 'json';
|
|
1046
|
+
interface RenderedQuery {
|
|
1047
|
+
readonly text: string;
|
|
1048
|
+
readonly parameters: readonly unknown[];
|
|
1049
|
+
}
|
|
1050
|
+
interface RenderOptions<TCapabilities extends DialectCapability = DialectCapability> {
|
|
1051
|
+
readonly dialect?: Dialect<TCapabilities>;
|
|
1052
|
+
}
|
|
1053
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
1054
|
+
type MissingCapabilities<TQuery, TCapabilities extends DialectCapability> = IsAny<CapabilitiesOf<TQuery>> extends true ? never : Exclude<CapabilitiesOf<TQuery>, TCapabilities>;
|
|
1055
|
+
type RenderCapabilityValidation<TQuery, TCapabilities extends DialectCapability> = [MissingCapabilities<TQuery, TCapabilities>] extends [never] ? unknown : QueryTypeValidation<'missing-dialect-capability', 'render.dialect', 'Provide a dialect that supports every capability required by the query.', MissingCapabilities<TQuery, TCapabilities>>;
|
|
1056
|
+
declare function render<TQuery extends AnyFragment>(query: TQuery & RenderCapabilityValidation<TQuery, DefaultDialectCapability>): RenderedQuery;
|
|
1057
|
+
declare function render<TQuery extends AnyFragment, TCapabilities extends DialectCapability>(query: TQuery & RenderCapabilityValidation<TQuery, TCapabilities>, options: RenderOptions<TCapabilities> | Dialect<TCapabilities>): RenderedQuery;
|
|
1058
|
+
//#endregion
|
|
1059
|
+
//#region src/execution.d.ts
|
|
1060
|
+
type StreamableQuery<TRow extends object = Record<string, unknown>> = Query<TRow, any, any, any> & {
|
|
1061
|
+
readonly queryKind: 'select' | 'set';
|
|
1062
|
+
};
|
|
1063
|
+
/** Rendering policy and cancellation input accepted by query execution. */
|
|
1064
|
+
interface ExecutionOptions extends RenderOptions {
|
|
1065
|
+
/** Passed to the application adapter for drivers that support cancellation. */
|
|
1066
|
+
readonly signal?: AbortSignal;
|
|
1067
|
+
}
|
|
1068
|
+
/** Rendering, EXPLAIN, and cancellation options for plan requests. */
|
|
1069
|
+
interface ExplainOptions extends RenderOptions, ExplainRenderOptions {
|
|
1070
|
+
/** Passed to the application adapter for drivers that support cancellation. */
|
|
1071
|
+
readonly signal?: AbortSignal;
|
|
1072
|
+
}
|
|
1073
|
+
/** EXPLAIN options accepted for SELECT and set-operation queries. */
|
|
1074
|
+
type ExplainReadOptions = ExplainOptions;
|
|
1075
|
+
/** EXPLAIN options for mutations, which never run with analysis enabled. */
|
|
1076
|
+
type ExplainMutationOptions = Omit<ExplainOptions, 'analyze'> & {
|
|
1077
|
+
readonly analyze?: never;
|
|
1078
|
+
};
|
|
1079
|
+
/** Select read-only or plan-only EXPLAIN options from the query kind. */
|
|
1080
|
+
type ExplainOptionsFor<TQuery extends Query<any, any, any, any>> = TQuery['queryKind'] extends 'select' | 'set' ? ExplainReadOptions : ExplainMutationOptions;
|
|
1081
|
+
/** Controls the lifecycle of one adapter-owned transaction. */
|
|
1082
|
+
interface TransactionOptions {
|
|
1083
|
+
/** Passed to the adapter for transaction begin, commit, and rollback. */
|
|
1084
|
+
readonly signal?: AbortSignal;
|
|
1085
|
+
}
|
|
1086
|
+
/** One rendered statement and the controls passed to an application adapter. */
|
|
1087
|
+
interface ExecutionRequest {
|
|
1088
|
+
/** SQL text and raw application parameters produced by Qubu's renderer. */
|
|
1089
|
+
readonly statement: RenderedQuery;
|
|
1090
|
+
/** The source query kind, available without parsing rendered SQL. */
|
|
1091
|
+
readonly queryKind: QueryKind;
|
|
1092
|
+
/** Present when the caller supplied an abort signal to {@link execute} or {@link stream}. */
|
|
1093
|
+
readonly signal?: AbortSignal;
|
|
1094
|
+
}
|
|
1095
|
+
/** One rendered EXPLAIN statement and the controls passed to an adapter. */
|
|
1096
|
+
interface ExplainRequest extends ExecutionRequest {}
|
|
1097
|
+
/**
|
|
1098
|
+
* Driver-neutral rows and optional mutation facts returned by an adapter.
|
|
1099
|
+
*
|
|
1100
|
+
* Adapters normalize driver result fields into this shape. They should omit a
|
|
1101
|
+
* mutation fact when the driver cannot report it accurately.
|
|
1102
|
+
*/
|
|
1103
|
+
interface ExecutionResult<TRow extends object = Record<string, unknown>> {
|
|
1104
|
+
/** Decoded result rows. Mutations without `RETURNING` use an empty array. */
|
|
1105
|
+
readonly rows: readonly TRow[];
|
|
1106
|
+
/** Rows inserted, updated, or deleted when the driver reports that count. */
|
|
1107
|
+
readonly affectedRows?: number | bigint;
|
|
1108
|
+
/** Rows whose stored values changed when distinct from affected rows. */
|
|
1109
|
+
readonly changedRows?: number | bigint;
|
|
1110
|
+
/** An insert identifier reported by the driver, including generated IDs. */
|
|
1111
|
+
readonly insertId?: string | number | bigint;
|
|
1112
|
+
}
|
|
1113
|
+
/** Adapter-decoded vendor plan rows returned by an EXPLAIN request. */
|
|
1114
|
+
interface ExplainResult<TPlanRow extends object = Record<string, unknown>> {
|
|
1115
|
+
/** Opaque plan rows in the shape selected by the application adapter. */
|
|
1116
|
+
readonly rows: readonly TPlanRow[];
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* The driver-facing boundary. `request.statement.parameters` contains raw
|
|
1120
|
+
* application values in placeholder order; the adapter binds and encodes them
|
|
1121
|
+
* for its driver. Connection pooling, transactions, retries, and row decoding
|
|
1122
|
+
* remain adapter concerns.
|
|
1123
|
+
*/
|
|
1124
|
+
interface QueryAdapter {
|
|
1125
|
+
/** Default rendering policy for queries sent through this adapter. */
|
|
1126
|
+
readonly dialect: Dialect;
|
|
1127
|
+
/** Execute one request and normalize the driver's result fields. */
|
|
1128
|
+
execute<TRow extends object>(request: ExecutionRequest): Promise<ExecutionResult<TRow>>;
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* An opt-in adapter capability for typed, adapter-decoded EXPLAIN results.
|
|
1132
|
+
*
|
|
1133
|
+
* Qubu renders and validates the statement. The adapter binds parameters,
|
|
1134
|
+
* executes the plan request, owns cancellation and connection lifecycle, and
|
|
1135
|
+
* decodes vendor-specific plan rows without a cross-dialect Qubu plan tree.
|
|
1136
|
+
*/
|
|
1137
|
+
interface ExplainableQueryAdapter<TPlanRow extends object = Record<string, unknown>> extends QueryAdapter {
|
|
1138
|
+
explain(request: ExplainRequest): Promise<ExplainResult<TPlanRow>>;
|
|
1139
|
+
}
|
|
1140
|
+
/** Extract the plan-row type owned by an explainable adapter. */
|
|
1141
|
+
type ExplainPlanRow<TAdapter extends ExplainableQueryAdapter> = TAdapter extends ExplainableQueryAdapter<infer TPlanRow> ? TPlanRow : never;
|
|
1142
|
+
/**
|
|
1143
|
+
* An opt-in adapter capability for streaming rows from read queries.
|
|
1144
|
+
*
|
|
1145
|
+
* The adapter owns the returned iterator and every resource behind it. The
|
|
1146
|
+
* iterator must release those resources when it completes, is closed early,
|
|
1147
|
+
* fails, or observes an aborted request signal.
|
|
1148
|
+
*/
|
|
1149
|
+
interface StreamingQueryAdapter extends QueryAdapter {
|
|
1150
|
+
/** Return a typed, adapter-owned stream for one SELECT or set query. */
|
|
1151
|
+
stream<TRow extends object>(request: ExecutionRequest): AsyncIterable<TRow>;
|
|
1152
|
+
}
|
|
1153
|
+
type QueryExecutor = QueryAdapter;
|
|
1154
|
+
/**
|
|
1155
|
+
* An adapter that can pin one driver connection for a callback transaction.
|
|
1156
|
+
* The callback receives an adapter scoped to that transaction. Qubu does not
|
|
1157
|
+
* issue transaction SQL or manage the driver's connection lifecycle.
|
|
1158
|
+
*/
|
|
1159
|
+
interface TransactionalQueryAdapter<TTransactionAdapter extends QueryAdapter = QueryAdapter> extends QueryAdapter {
|
|
1160
|
+
transaction<T>(callback: (adapter: TTransactionAdapter) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
1161
|
+
}
|
|
1162
|
+
/** A transaction-capable streaming adapter whose scoped client can stream. */
|
|
1163
|
+
type StreamingTransactionalQueryAdapter = StreamingQueryAdapter & TransactionalQueryAdapter<StreamingQueryAdapter>;
|
|
1164
|
+
/** A query client with one application-owned adapter bound to every call. */
|
|
1165
|
+
interface QubuClient<TAdapter extends QueryAdapter = QueryAdapter> {
|
|
1166
|
+
/** The adapter supplied to {@link qubu}. */
|
|
1167
|
+
readonly adapter: TAdapter;
|
|
1168
|
+
/** Execute a query and keep the adapter's structured mutation facts. */
|
|
1169
|
+
execute<TRow extends object>(query: Query<TRow, any, any, any>, options?: ExecutionOptions): Promise<ExecutionResult<TRow>>;
|
|
1170
|
+
/** Execute a query and return only its decoded rows. */
|
|
1171
|
+
rows<TRow extends object>(query: Query<TRow, any, any, any>, options?: ExecutionOptions): Promise<readonly TRow[]>;
|
|
1172
|
+
}
|
|
1173
|
+
/** A bound client whose adapter also decodes vendor-specific EXPLAIN rows. */
|
|
1174
|
+
interface QubuExplainableClient<TAdapter extends ExplainableQueryAdapter = ExplainableQueryAdapter> extends QubuClient<TAdapter> {
|
|
1175
|
+
/** Explain a query without executing it and return adapter-owned plan rows. */
|
|
1176
|
+
explain<TQuery extends Query<any, any, any, any>>(query: TQuery, options?: ExplainOptionsFor<TQuery>): Promise<ExplainResult<ExplainPlanRow<TAdapter>>>;
|
|
1177
|
+
}
|
|
1178
|
+
/** A bound client whose adapter also supports typed read-query streams. */
|
|
1179
|
+
interface QubuStreamingClient<TAdapter extends StreamingQueryAdapter = StreamingQueryAdapter> extends QubuClient<TAdapter> {
|
|
1180
|
+
/** Stream decoded rows without materializing the complete result. */
|
|
1181
|
+
stream<TRow extends object>(query: StreamableQuery<TRow>, options?: ExecutionOptions): AsyncIterable<TRow>;
|
|
1182
|
+
}
|
|
1183
|
+
/** A bound client that supports both streaming and typed EXPLAIN plans. */
|
|
1184
|
+
interface QubuStreamingExplainableClient<TAdapter extends StreamingQueryAdapter & ExplainableQueryAdapter = StreamingQueryAdapter & ExplainableQueryAdapter> extends QubuStreamingClient<TAdapter>, QubuExplainableClient<TAdapter> {}
|
|
1185
|
+
type QubuClientFor<TAdapter extends QueryAdapter> = TAdapter extends StreamingQueryAdapter ? TAdapter extends ExplainableQueryAdapter ? QubuStreamingExplainableClient<TAdapter> : QubuStreamingClient<TAdapter> : TAdapter extends ExplainableQueryAdapter ? QubuExplainableClient<TAdapter> : QubuClient<TAdapter>;
|
|
1186
|
+
/** The client available inside a transaction callback. */
|
|
1187
|
+
type QubuTransaction = QubuClient<QueryAdapter>;
|
|
1188
|
+
/** The streaming client available inside a streaming transaction callback. */
|
|
1189
|
+
type QubuStreamingTransaction = QubuStreamingClient<StreamingQueryAdapter>;
|
|
1190
|
+
/** A bound client whose adapter supports transaction-scoped execution. */
|
|
1191
|
+
interface QubuTransactionalClient<TAdapter extends TransactionalQueryAdapter = TransactionalQueryAdapter, TTransactionAdapter extends QueryAdapter = QueryAdapter> extends QubuClient<TAdapter> {
|
|
1192
|
+
/** Run several queries on one adapter-owned transaction. */
|
|
1193
|
+
transaction<T>(callback: (transaction: QubuClientFor<TTransactionAdapter>) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
1194
|
+
}
|
|
1195
|
+
/** A bound EXPLAIN client with an adapter-owned transaction callback. */
|
|
1196
|
+
type QubuExplainableTransactionalClient<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter = ExplainableQueryAdapter & TransactionalQueryAdapter, TTransactionAdapter extends QueryAdapter = QueryAdapter> = QubuExplainableClient<TAdapter> & QubuTransactionalClient<TAdapter, TTransactionAdapter>;
|
|
1197
|
+
/** A bound streaming and EXPLAIN client with an adapter-owned transaction. */
|
|
1198
|
+
type QubuExplainableStreamingTransactionalClient<TAdapter extends ExplainableQueryAdapter & StreamingTransactionalQueryAdapter = ExplainableQueryAdapter & StreamingTransactionalQueryAdapter> = QubuStreamingExplainableClient<TAdapter> & QubuTransactionalClient<TAdapter, StreamingQueryAdapter>;
|
|
1199
|
+
/** A bound streaming client whose transaction callback can also stream. */
|
|
1200
|
+
interface QubuStreamingTransactionalClient<TAdapter extends StreamingTransactionalQueryAdapter = StreamingTransactionalQueryAdapter> extends QubuStreamingClient<TAdapter> {
|
|
1201
|
+
/** Run a callback whose streams must be consumed or closed before it resolves. */
|
|
1202
|
+
transaction<T>(callback: (transaction: QubuStreamingTransaction) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
1203
|
+
}
|
|
1204
|
+
/** Bind an application-owned adapter once for repeated query execution. */
|
|
1205
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & StreamingTransactionalQueryAdapter>(adapter: TAdapter): QubuExplainableStreamingTransactionalClient<TAdapter>;
|
|
1206
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter): QubuExplainableTransactionalClient<TAdapter> & QubuStreamingExplainableClient<TAdapter>;
|
|
1207
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & TransactionalQueryAdapter>(adapter: TAdapter): QubuExplainableTransactionalClient<TAdapter>;
|
|
1208
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter): QubuStreamingExplainableClient<TAdapter>;
|
|
1209
|
+
declare function qubu<TAdapter extends ExplainableQueryAdapter>(adapter: TAdapter): QubuExplainableClient<TAdapter>;
|
|
1210
|
+
declare function qubu<TAdapter extends StreamingTransactionalQueryAdapter>(adapter: TAdapter): QubuStreamingTransactionalClient<TAdapter>;
|
|
1211
|
+
declare function qubu<TAdapter extends TransactionalQueryAdapter & StreamingQueryAdapter>(adapter: TAdapter): QubuTransactionalClient<TAdapter> & QubuStreamingClient<TAdapter>;
|
|
1212
|
+
declare function qubu<TAdapter extends TransactionalQueryAdapter>(adapter: TAdapter): QubuTransactionalClient<TAdapter>;
|
|
1213
|
+
declare function qubu<TAdapter extends StreamingQueryAdapter>(adapter: TAdapter): QubuStreamingClient<TAdapter>;
|
|
1214
|
+
declare function qubu<TAdapter extends QueryAdapter>(adapter: TAdapter): QubuClient<TAdapter>;
|
|
1215
|
+
interface DriverValueEncoder<TDriverValue = unknown> {
|
|
1216
|
+
/** Convert one Qubu parameter into the driver's bindable representation. */
|
|
1217
|
+
encode(value: unknown): TDriverValue;
|
|
1218
|
+
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Render a typed query, pass it to an application adapter, and return the
|
|
1221
|
+
* adapter's structured result unchanged.
|
|
1222
|
+
*
|
|
1223
|
+
* Driver errors are not caught or translated.
|
|
1224
|
+
*/
|
|
1225
|
+
declare function execute<TRow extends object>(query: Query<TRow, any, any, any>, adapter: QueryAdapter, options?: ExecutionOptions): Promise<ExecutionResult<TRow>>;
|
|
1226
|
+
declare function execute<TRow extends object>(adapter: QueryAdapter, query: Query<TRow, any, any, any>, options?: ExecutionOptions): Promise<ExecutionResult<TRow>>;
|
|
1227
|
+
/** Execute a query and return its decoded rows without mutation facts. */
|
|
1228
|
+
declare function executeRows<TRow extends object>(query: Query<TRow, any, any, any>, adapter: QueryAdapter, options?: ExecutionOptions): Promise<readonly TRow[]>;
|
|
1229
|
+
declare function executeRows<TRow extends object>(adapter: QueryAdapter, query: Query<TRow, any, any, any>, options?: ExecutionOptions): Promise<readonly TRow[]>;
|
|
1230
|
+
/**
|
|
1231
|
+
* Render a query as a dialect-specific EXPLAIN request and return the
|
|
1232
|
+
* adapter-decoded vendor plan rows. EXPLAIN never calls QueryAdapter.execute.
|
|
1233
|
+
*/
|
|
1234
|
+
declare function explain<TQuery extends Query<any, any, any, any>, TAdapter extends ExplainableQueryAdapter>(query: TQuery, adapter: TAdapter, options?: ExplainOptionsFor<TQuery>): Promise<ExplainResult<ExplainPlanRow<TAdapter>>>;
|
|
1235
|
+
declare function explain<TQuery extends Query<any, any, any, any>, TAdapter extends ExplainableQueryAdapter>(adapter: TAdapter, query: TQuery, options?: ExplainOptionsFor<TQuery>): Promise<ExplainResult<ExplainPlanRow<TAdapter>>>;
|
|
1236
|
+
/**
|
|
1237
|
+
* Render a SELECT or set-operation query and return the adapter-owned row
|
|
1238
|
+
* stream. Mutations, including mutations with RETURNING, must use execute().
|
|
1239
|
+
*/
|
|
1240
|
+
declare function stream<TRow extends object>(query: StreamableQuery<TRow>, adapter: StreamingQueryAdapter, options?: ExecutionOptions): AsyncIterable<TRow>;
|
|
1241
|
+
declare function stream<TRow extends object>(adapter: StreamingQueryAdapter, query: StreamableQuery<TRow>, options?: ExecutionOptions): AsyncIterable<TRow>;
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region src/expressions/cast.d.ts
|
|
1244
|
+
type CastDefinition = ColumnDefinition<any, false, any, any, false, false, AnySqlType, any, any, any> & {
|
|
1245
|
+
readonly castTarget: CastTarget;
|
|
1246
|
+
};
|
|
1247
|
+
/**
|
|
1248
|
+
* Cast to a built-in or custom column definition while deriving both result
|
|
1249
|
+
* types from that definition. Operand nullability and source facts survive.
|
|
1250
|
+
*/
|
|
1251
|
+
declare function cast<TDefinition extends CastDefinition, TExpression extends AnyExpression>(expression: TExpression, definition: TDefinition): ResultExpression<ColumnOutput<TDefinition>, TExpression, 'operator', NullabilityOf<TExpression>, ColumnSqlType<TDefinition>>;
|
|
1252
|
+
/** Cast using a type name supplied by the caller or an adapter. */
|
|
1253
|
+
declare function cast<T, TSqlType extends AnySqlType = SqlUnknown, TExpression extends AnyExpression = AnyExpression, const TType extends string = string>(expression: TExpression, typeName: TType): ResultExpression<T, TExpression, 'operator', NullabilityOf<TExpression>, TSqlType>;
|
|
1254
|
+
/** Create a cast whose JS output and SQL result domain are declared up front. */
|
|
1255
|
+
declare function typedCast<T, TSqlType extends AnySqlType>(): <TExpression extends AnyExpression, const TType extends string>(expression: TExpression, typeName: TType) => ResultExpression<T, TExpression, "operator", (MetadataOf<TExpression> extends (infer T_1) ? T_1 extends MetadataOf<TExpression> ? T_1 extends {
|
|
1256
|
+
readonly kind: "result";
|
|
1257
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TExpression> extends (infer T_3) ? T_3 extends MetadataOf<TExpression> ? T_3 extends {
|
|
1258
|
+
readonly kind: "result";
|
|
1259
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1260
|
+
readonly nullableFrom: infer TSource;
|
|
1261
|
+
} ? TSource : never : never : never, TSqlType>;
|
|
1262
|
+
//#endregion
|
|
1263
|
+
//#region src/expressions/value.d.ts
|
|
1264
|
+
interface ValueExpression<T = unknown, TSqlType extends AnySqlType = SqlUnknown> extends SchemaExpression<ResultMeta<T, never, TSqlType> | ExpressionMeta<never>, 'value'> {
|
|
1265
|
+
readonly value: T;
|
|
1266
|
+
}
|
|
1267
|
+
declare function value<T>(input: T): ValueExpression<T>;
|
|
1268
|
+
/** Bind a value while declaring its SQL semantic domain. */
|
|
1269
|
+
declare function typedValue<TSqlType extends AnySqlType, T>(input: T): ValueExpression<T, TSqlType>;
|
|
1270
|
+
declare function asValue<TInput>(input: TInput): TInput extends AnyExpression ? TInput : ValueExpression<TInput>;
|
|
1271
|
+
//#endregion
|
|
1272
|
+
//#region src/expressions/operators/shared.d.ts
|
|
1273
|
+
type Operand<T> = T | ExpressionWithOutput<T>;
|
|
1274
|
+
/** Plain values are contextually typed by the expression beside them. */
|
|
1275
|
+
type OperandSqlType<T, TContext extends AnySqlType> = T extends Fragment<any> ? SqlTypeOf<T> : TContext;
|
|
1276
|
+
/** Type-level validation that a known SQL domain provides a capability. */
|
|
1277
|
+
type SqlCapabilityValidation<TActual, TCapability> = SqlTypeSatisfies<TActual, TCapability> extends true ? unknown : QueryTypeValidation<'incompatible-sql-domain', 'expression.sql-domain', 'Use an expression with the required SQL domain.', TActual>;
|
|
1278
|
+
/** Type-level validation that two known SQL domains can test equality. */
|
|
1279
|
+
type SqlEqualityValidation<TLeft, TRight> = SqlEqualityCompatible<TLeft, TRight> extends true ? unknown : QueryTypeValidation<'incompatible-sql-equality', 'comparison.operands', 'Use operands from the same SQL equality group.', readonly [TLeft, TRight]>;
|
|
1280
|
+
/** Type-level validation that two known SQL domains share an ordering group. */
|
|
1281
|
+
type SqlOrderValidation<TLeft, TRight> = SqlOrderCompatible<TLeft, TRight> extends true ? unknown : QueryTypeValidation<'incompatible-sql-order', 'comparison.operands', 'Use operands from the same SQL ordering group.', readonly [TLeft, TRight]>;
|
|
1282
|
+
type OperandNullability<T> = T extends Fragment<any> ? NullabilityOf<T> : never;
|
|
1283
|
+
type IsNullOperand<T> = T extends null ? true : T extends ValueExpression<infer TValue> ? [TValue] extends [null] ? true : false : false;
|
|
1284
|
+
//#endregion
|
|
1285
|
+
//#region src/expressions/operators/comparison/null.d.ts
|
|
1286
|
+
declare function isNull<TExpression extends AnyExpression>(expression: TExpression): ResultExpression<boolean, TExpression, 'operator', never, SqlBoolean>;
|
|
1287
|
+
declare function isNotNull<TExpression extends AnyExpression>(expression: TExpression): ResultExpression<boolean, TExpression, 'operator', never, SqlBoolean>;
|
|
1288
|
+
declare function isTrue<TExpression extends ExpressionWithOutput<boolean>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlBoolean>): ResultExpression<boolean, TExpression, "operator", never, SqlBoolean>;
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region src/expressions/operators/comparison/range.d.ts
|
|
1291
|
+
type BetweenValidation<TExpression, TLower, TUpper> = SqlOrderValidation<ExpressionSqlType<TExpression>, OperandSqlType<TLower, ExpressionSqlType<TExpression>>> & SqlOrderValidation<ExpressionSqlType<TExpression>, OperandSqlType<TUpper, ExpressionSqlType<TExpression>>>;
|
|
1292
|
+
type ListValidation<TExpression, TValues extends readonly unknown[]> = TValues extends readonly [infer THead, ...infer TTail] ? SqlEqualityValidation<ExpressionSqlType<TExpression>, OperandSqlType<THead, ExpressionSqlType<TExpression>>> & ListValidation<TExpression, TTail> : unknown;
|
|
1293
|
+
declare function between<T, TExpression extends ExpressionWithOutput<T>, L extends Operand<NoInfer<T>>, H extends Operand<NoInfer<T>>>(expression: TExpression & BetweenValidation<TExpression, L, H>, lower: L, upper: H): ResultExpression<boolean, TExpression | L | H, "operator", NullabilityOf<TExpression | L | H>, SqlBoolean>;
|
|
1294
|
+
declare function inList<T, TExpression extends ExpressionWithOutput<T>, const TValues extends readonly Operand<NoInfer<T>>[]>(expression: TExpression & ListValidation<TExpression, TValues>, values: TValues): ResultExpression<boolean, TExpression | TValues[number], "operator", NullabilityOf<TExpression | TValues[number]>, SqlBoolean>;
|
|
1295
|
+
declare function notIn<T, TExpression extends ExpressionWithOutput<T>, const TValues extends readonly Operand<NoInfer<T>>[]>(expression: TExpression & ListValidation<TExpression, TValues>, values: TValues): ResultExpression<boolean, TExpression | TValues[number], "operator", NullabilityOf<TExpression | TValues[number]>, SqlBoolean>;
|
|
1296
|
+
//#endregion
|
|
1297
|
+
//#region src/expressions/operators/comparison/relational.d.ts
|
|
1298
|
+
type ComparisonResult<TLeft, R, TOperator extends string> = ResultExpression<boolean, TLeft | R, 'operator', TOperator extends 'IS DISTINCT FROM' | 'IS NOT DISTINCT FROM' ? never : TOperator extends '=' | '<>' ? IsNullOperand<R> extends true ? never : NullabilityOf<TLeft> | OperandNullability<R> : NullabilityOf<TLeft> | OperandNullability<R>, SqlBoolean>;
|
|
1299
|
+
/** SQL-domain validation selected by a comparison operator family. */
|
|
1300
|
+
type ComparisonValidation<TLeft, TRight, TOperator extends string> = TOperator extends 'LIKE' | 'NOT LIKE' | 'ILIKE' ? SqlCapabilityValidation<ExpressionSqlType<TLeft>, SqlTextLike> & SqlCapabilityValidation<OperandSqlType<TRight, ExpressionSqlType<TLeft>>, SqlTextLike> : TOperator extends '<' | '<=' | '>' | '>=' ? SqlOrderValidation<ExpressionSqlType<TLeft>, OperandSqlType<TRight, ExpressionSqlType<TLeft>>> : SqlEqualityValidation<ExpressionSqlType<TLeft>, OperandSqlType<TRight, ExpressionSqlType<TLeft>>>;
|
|
1301
|
+
declare function eq<T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ComparisonValidation<TLeft, R, '='>, right: R): ComparisonResult<TLeft & SqlEqualityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1302
|
+
readonly kind: "result";
|
|
1303
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1304
|
+
readonly kind: "result";
|
|
1305
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1306
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1307
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1308
|
+
readonly kind: "result";
|
|
1309
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1310
|
+
readonly kind: "result";
|
|
1311
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1312
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1313
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, "=">;
|
|
1314
|
+
declare function ne<T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ComparisonValidation<TLeft, R, '<>'>, right: R): ComparisonResult<TLeft & SqlEqualityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1315
|
+
readonly kind: "result";
|
|
1316
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1317
|
+
readonly kind: "result";
|
|
1318
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1319
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1320
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1321
|
+
readonly kind: "result";
|
|
1322
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1323
|
+
readonly kind: "result";
|
|
1324
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1325
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1326
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, "<>">;
|
|
1327
|
+
declare function lt<TLeft extends AnyExpression, R extends Operand<Exclude<ExpressionOutput<TLeft>, null>>>(left: TLeft & ComparisonValidation<TLeft, R, '<'>, right: R): ComparisonResult<TLeft & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T) ? T extends MetadataOf<TLeft> ? T extends {
|
|
1328
|
+
readonly kind: "result";
|
|
1329
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TLeft> extends (infer T_2) ? T_2 extends MetadataOf<TLeft> ? T_2 extends {
|
|
1330
|
+
readonly kind: "result";
|
|
1331
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1332
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1333
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1334
|
+
readonly kind: "result";
|
|
1335
|
+
} ? T_3 : never : never : never) extends (infer T_4) ? T_4 extends (MetadataOf<TLeft> extends (infer T_5) ? T_5 extends MetadataOf<TLeft> ? T_5 extends {
|
|
1336
|
+
readonly kind: "result";
|
|
1337
|
+
} ? T_5 : never : never : never) ? T_4 extends {
|
|
1338
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1339
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, "<">;
|
|
1340
|
+
declare function lte<TLeft extends AnyExpression, R extends Operand<Exclude<ExpressionOutput<TLeft>, null>>>(left: TLeft & ComparisonValidation<TLeft, R, '<='>, right: R): ComparisonResult<TLeft & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T) ? T extends MetadataOf<TLeft> ? T extends {
|
|
1341
|
+
readonly kind: "result";
|
|
1342
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TLeft> extends (infer T_2) ? T_2 extends MetadataOf<TLeft> ? T_2 extends {
|
|
1343
|
+
readonly kind: "result";
|
|
1344
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1345
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1346
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1347
|
+
readonly kind: "result";
|
|
1348
|
+
} ? T_3 : never : never : never) extends (infer T_4) ? T_4 extends (MetadataOf<TLeft> extends (infer T_5) ? T_5 extends MetadataOf<TLeft> ? T_5 extends {
|
|
1349
|
+
readonly kind: "result";
|
|
1350
|
+
} ? T_5 : never : never : never) ? T_4 extends {
|
|
1351
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1352
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, "<=">;
|
|
1353
|
+
declare function gt<TLeft extends AnyExpression, R extends Operand<Exclude<ExpressionOutput<TLeft>, null>>>(left: TLeft & ComparisonValidation<TLeft, R, '>'>, right: R): ComparisonResult<TLeft & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T) ? T extends MetadataOf<TLeft> ? T extends {
|
|
1354
|
+
readonly kind: "result";
|
|
1355
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TLeft> extends (infer T_2) ? T_2 extends MetadataOf<TLeft> ? T_2 extends {
|
|
1356
|
+
readonly kind: "result";
|
|
1357
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1358
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1359
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1360
|
+
readonly kind: "result";
|
|
1361
|
+
} ? T_3 : never : never : never) extends (infer T_4) ? T_4 extends (MetadataOf<TLeft> extends (infer T_5) ? T_5 extends MetadataOf<TLeft> ? T_5 extends {
|
|
1362
|
+
readonly kind: "result";
|
|
1363
|
+
} ? T_5 : never : never : never) ? T_4 extends {
|
|
1364
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1365
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, ">">;
|
|
1366
|
+
declare function gte<TLeft extends AnyExpression, R extends Operand<Exclude<ExpressionOutput<TLeft>, null>>>(left: TLeft & ComparisonValidation<TLeft, R, '>='>, right: R): ComparisonResult<TLeft & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T) ? T extends MetadataOf<TLeft> ? T extends {
|
|
1367
|
+
readonly kind: "result";
|
|
1368
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TLeft> extends (infer T_2) ? T_2 extends MetadataOf<TLeft> ? T_2 extends {
|
|
1369
|
+
readonly kind: "result";
|
|
1370
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1371
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1372
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1373
|
+
readonly kind: "result";
|
|
1374
|
+
} ? T_3 : never : never : never) extends (infer T_4) ? T_4 extends (MetadataOf<TLeft> extends (infer T_5) ? T_5 extends MetadataOf<TLeft> ? T_5 extends {
|
|
1375
|
+
readonly kind: "result";
|
|
1376
|
+
} ? T_5 : never : never : never) ? T_4 extends {
|
|
1377
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1378
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, ">=">;
|
|
1379
|
+
declare function like<TLeft extends ExpressionWithOutput<string>, R extends Operand<string>>(left: TLeft & ComparisonValidation<TLeft, R, 'LIKE'>, pattern: R): ComparisonResult<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T) ? T extends MetadataOf<TLeft> ? T extends {
|
|
1380
|
+
readonly kind: "result";
|
|
1381
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TLeft> extends (infer T_2) ? T_2 extends MetadataOf<TLeft> ? T_2 extends {
|
|
1382
|
+
readonly kind: "result";
|
|
1383
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1384
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1385
|
+
} ? TSqlType : SqlUnknown : never : never, SqlTextLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1386
|
+
readonly kind: "result";
|
|
1387
|
+
} ? T_3 : never : never : never) extends (infer T_4) ? T_4 extends (MetadataOf<TLeft> extends (infer T_5) ? T_5 extends MetadataOf<TLeft> ? T_5 extends {
|
|
1388
|
+
readonly kind: "result";
|
|
1389
|
+
} ? T_5 : never : never : never) ? T_4 extends {
|
|
1390
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1391
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlTextLike>, R, "LIKE">;
|
|
1392
|
+
declare function notLike<TLeft extends ExpressionWithOutput<string>, R extends Operand<string>>(left: TLeft & ComparisonValidation<TLeft, R, 'NOT LIKE'>, pattern: R): ComparisonResult<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T) ? T extends MetadataOf<TLeft> ? T extends {
|
|
1393
|
+
readonly kind: "result";
|
|
1394
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TLeft> extends (infer T_2) ? T_2 extends MetadataOf<TLeft> ? T_2 extends {
|
|
1395
|
+
readonly kind: "result";
|
|
1396
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1397
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1398
|
+
} ? TSqlType : SqlUnknown : never : never, SqlTextLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1399
|
+
readonly kind: "result";
|
|
1400
|
+
} ? T_3 : never : never : never) extends (infer T_4) ? T_4 extends (MetadataOf<TLeft> extends (infer T_5) ? T_5 extends MetadataOf<TLeft> ? T_5 extends {
|
|
1401
|
+
readonly kind: "result";
|
|
1402
|
+
} ? T_5 : never : never : never) ? T_4 extends {
|
|
1403
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1404
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlTextLike>, R, "NOT LIKE">;
|
|
1405
|
+
declare function isDistinctFrom<T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ComparisonValidation<TLeft, R, 'IS DISTINCT FROM'>, right: R): ComparisonResult<TLeft & SqlEqualityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1406
|
+
readonly kind: "result";
|
|
1407
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1408
|
+
readonly kind: "result";
|
|
1409
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1410
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1411
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1412
|
+
readonly kind: "result";
|
|
1413
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1414
|
+
readonly kind: "result";
|
|
1415
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1416
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1417
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, "IS DISTINCT FROM">;
|
|
1418
|
+
declare function isNotDistinctFrom<T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ComparisonValidation<TLeft, R, 'IS NOT DISTINCT FROM'>, right: R): ComparisonResult<TLeft & SqlEqualityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1419
|
+
readonly kind: "result";
|
|
1420
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1421
|
+
readonly kind: "result";
|
|
1422
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1423
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1424
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1425
|
+
readonly kind: "result";
|
|
1426
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1427
|
+
readonly kind: "result";
|
|
1428
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1429
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1430
|
+
} ? TSqlType : SqlUnknown : never : never>>, R, "IS NOT DISTINCT FROM">;
|
|
1431
|
+
//#endregion
|
|
1432
|
+
//#region src/expressions/subquery.d.ts
|
|
1433
|
+
type SingleColumn<Row extends object> = keyof Row extends (infer TKey) ? TKey extends keyof Row ? [keyof Row] extends [TKey] ? Row[TKey] : never : never : never;
|
|
1434
|
+
type ScalarOutput<TQuery extends AnyQuery> = SingleColumn<QueryRow<TQuery>> | ([CardinalityOf<TQuery>] extends ['exactly-one'] ? never : null);
|
|
1435
|
+
type SingleColumnSqlType<TQuery extends AnyQuery> = SingleColumn<QuerySqlTypeMap<TQuery>>;
|
|
1436
|
+
declare function scalar<TQuery extends AnyQuery>(query: TQuery): Expression<ResultMeta<ScalarOutput<TQuery>, never, SingleColumnSqlType<TQuery>> | InheritedMetadata<TQuery> | SubqueryMeta, 'subquery'>;
|
|
1437
|
+
//#endregion
|
|
1438
|
+
//#region src/expressions/operators/comparison/subquery.d.ts
|
|
1439
|
+
type IsUnion<T, TWhole = T> = T extends unknown ? [TWhole] extends [T] ? false : true : never;
|
|
1440
|
+
type InQueryValidation<TExpression, TQuery> = [keyof QueryRow<TQuery>] extends [never] ? QueryTypeValidation<'invalid-subquery', 'in-query.projection', 'Select exactly one field in the IN subquery.'> : true extends IsUnion<keyof QueryRow<TQuery>> ? QueryTypeValidation<'invalid-subquery', 'in-query.projection', 'Select exactly one field in the IN subquery.'> : SingleColumn<QueryRow<TQuery>> extends ExpressionOutput<TExpression> ? SqlEqualityValidation<ExpressionSqlType<TExpression>, SingleColumn<QuerySqlTypeMap<TQuery>>> : QueryTypeValidation<'incompatible-sql-equality', 'in-query.operands', 'Select a subquery field from the same SQL equality group as the expression.', SingleColumn<QueryRow<TQuery>>>;
|
|
1441
|
+
declare function inQuery<TExpression extends AnyExpression, TQuery extends Query<any, any, any>>(expression: TExpression & InQueryValidation<TExpression, TQuery>, query: TQuery): SubqueryResultExpression<boolean, TExpression | TQuery, never, SqlBoolean>;
|
|
1442
|
+
declare function exists<TQuery extends Query<any, any, any>>(query: TQuery): SubqueryResultExpression<boolean, TQuery, never, SqlBoolean>;
|
|
1443
|
+
declare function notExists<TQuery extends Query<any, any, any>>(query: TQuery): SubqueryResultExpression<boolean, TQuery, never, SqlBoolean>;
|
|
1444
|
+
//#endregion
|
|
1445
|
+
//#region src/expressions/operators/comparison/types.d.ts
|
|
1446
|
+
type BooleanExpression<TMetadata = never, TKind extends ExpressionKind = ExpressionKind> = Expression<ResultMeta<boolean, unknown, AnySqlType> | TMetadata, TKind>;
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region src/expressions/case.d.ts
|
|
1449
|
+
type CaseSqlType<TThen, TElse> = TThen extends Fragment<any> ? SqlTypeOf<TThen> : TElse extends Fragment<any> ? SqlTypeOf<TElse> : SqlUnknown;
|
|
1450
|
+
declare function caseWhen<T, TCondition extends BooleanExpression<any>, TThen extends Operand<T>, TElse extends Operand<T>>(condition: TCondition & SqlCapabilityValidation<ExpressionSqlType<TCondition>, SqlBoolean>, thenValue: TThen & SqlEqualityValidation<OperandSqlType<TThen, CaseSqlType<TThen, TElse>>, OperandSqlType<TElse, CaseSqlType<TThen, TElse>>>, elseValue: TElse): ResultExpression<T, TCondition | TThen | TElse, "operator", OperandNullability<TThen> | OperandNullability<TElse>, CaseSqlType<TThen, TElse>>;
|
|
1451
|
+
//#endregion
|
|
1452
|
+
//#region src/expressions/sql.d.ts
|
|
1453
|
+
type SqlChild<TValues extends readonly unknown[]> = Extract<TValues[number], AnyFragment>;
|
|
1454
|
+
type EmbeddedQueryMetadata<TChild> = TChild extends AnyQuery ? SubqueryMeta : never;
|
|
1455
|
+
/**
|
|
1456
|
+
* A parameterized SQL template that composes with Qubu expressions and
|
|
1457
|
+
* queries through the normal renderer.
|
|
1458
|
+
*/
|
|
1459
|
+
type SqlFragment<TOutput = unknown, TSqlType extends AnySqlType = SqlUnknown, TChild extends AnyFragment = never> = Expression<ResultMeta<TOutput, NullabilityOf<TChild>, TSqlType> | ExpressionMeta<DependenciesOf<TChild>> | InheritedMetadata<TChild> | EmbeddedQueryMetadata<TChild>, 'sql'>;
|
|
1460
|
+
/** A SQL template tag with an explicitly declared output and SQL domain. */
|
|
1461
|
+
interface TypedSqlTag<TOutput, TSqlType extends AnySqlType = SqlUnknown> {
|
|
1462
|
+
<const TValues extends readonly unknown[]>(strings: TemplateStringsArray, ...values: TValues): SqlFragment<TOutput, TSqlType, SqlChild<TValues>>;
|
|
1463
|
+
}
|
|
1464
|
+
/** Public call contract for {@link sql}. */
|
|
1465
|
+
interface SqlTag extends TypedSqlTag<unknown, SqlUnknown> {
|
|
1466
|
+
/**
|
|
1467
|
+
* Declare the application output and SQL semantic domain without changing
|
|
1468
|
+
* how template substitutions render.
|
|
1469
|
+
*/
|
|
1470
|
+
type<TOutput, TSqlType extends AnySqlType = SqlUnknown>(): TypedSqlTag<TOutput, TSqlType>;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Build trusted SQL syntax while binding every ordinary substitution as a
|
|
1474
|
+
* parameter. Qubu fragments remain composable substitutions.
|
|
1475
|
+
*
|
|
1476
|
+
* @remarks Template text is trusted and is not parsed. Use `identifier()` from
|
|
1477
|
+
* `qubu/core` for runtime identifiers and `unsafeExpression()` for deliberately
|
|
1478
|
+
* dynamic syntax. Use `sql.type<Output, SqlType>()` when the fragment's result
|
|
1479
|
+
* is known.
|
|
1480
|
+
*/
|
|
1481
|
+
declare const sql: SqlTag;
|
|
1482
|
+
//#endregion
|
|
1483
|
+
//#region src/expressions/functions/aggregate.d.ts
|
|
1484
|
+
declare function count(): AggregateResultExpression<number, never, 'function', never, SqlInteger>;
|
|
1485
|
+
declare function count<TExpression extends AnyExpression>(expression: TExpression): AggregateResultExpression<number, TExpression, 'function', never, SqlInteger>;
|
|
1486
|
+
declare function countDistinct<TExpression extends AnyExpression>(expression: TExpression): AggregateResultExpression<number, TExpression, "function", never, SqlInteger>;
|
|
1487
|
+
declare function sum<T, TExpression extends ExpressionWithOutput<T>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlNumericLike>): AggregateResultExpression<ExpressionOutput<TExpression>, TExpression, "function", NullabilityOf<TExpression>, ExpressionSqlType<TExpression>>;
|
|
1488
|
+
declare function avg<T, TExpression extends ExpressionWithOutput<T>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlNumericLike>): AggregateResultExpression<number, TExpression, "function", NullabilityOf<TExpression>, SqlDecimal>;
|
|
1489
|
+
declare function min<T, TExpression extends ExpressionWithOutput<T>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>): AggregateResultExpression<ExpressionOutput<TExpression>, TExpression, "function", NullabilityOf<TExpression>, ExpressionSqlType<TExpression>>;
|
|
1490
|
+
declare function max<T, TExpression extends ExpressionWithOutput<T>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>): AggregateResultExpression<ExpressionOutput<TExpression>, TExpression, "function", NullabilityOf<TExpression>, ExpressionSqlType<TExpression>>;
|
|
1491
|
+
//#endregion
|
|
1492
|
+
//#region src/expressions/functions/call.d.ts
|
|
1493
|
+
declare function call<TOutput = unknown, const TName extends string = string, const TArguments extends readonly unknown[] = readonly unknown[], TNullableFrom = NullabilityOf<TArguments[number]>, TSqlType extends AnySqlType = SqlUnknown>(name: TName, ...args: TArguments): Expression<ResultMeta<TOutput, TNullableFrom, TSqlType> | ExpressionMeta<DependenciesOf<TArguments[number]>> | InheritedMetadata<TArguments[number]>, "function">;
|
|
1494
|
+
/**
|
|
1495
|
+
* Internal built-in function constructor for deterministic schema functions.
|
|
1496
|
+
* Arbitrary calls stay on {@link call} and require an explicit schema
|
|
1497
|
+
* extension contract before they can be used in schema metadata.
|
|
1498
|
+
*/
|
|
1499
|
+
declare function schemaCall<TOutput = unknown, const TName extends string = string, const TArguments extends readonly unknown[] = readonly unknown[], TNullableFrom = NullabilityOf<TArguments[number]>, TSqlType extends AnySqlType = SqlUnknown>(name: TName, ...args: TArguments): SchemaExpression<ResultMeta<TOutput, TNullableFrom, TSqlType> | ExpressionMeta<DependenciesOf<TArguments[number]>> | InheritedMetadata<TArguments[number]>, "function">;
|
|
1500
|
+
/** Declare the SQL result domain of a custom function call. */
|
|
1501
|
+
declare function typedCall<TSqlType extends AnySqlType, TOutput = unknown>(): <const TName extends string, const TArguments extends readonly unknown[]>(name: TName, ...args: TArguments) => Expression<ResultMeta<TOutput, NullabilityOf<TArguments[number]>, TSqlType> | ExpressionMeta<MetadataOf<TArguments[number]> extends (infer T) ? T extends MetadataOf<TArguments[number]> ? T extends {
|
|
1502
|
+
readonly kind: "expression";
|
|
1503
|
+
readonly dependencies: infer TDependencies;
|
|
1504
|
+
} ? TDependencies : never : never : never> | (MetadataOf<TArguments[number]> extends (infer T_1) ? T_1 extends MetadataOf<TArguments[number]> ? T_1 extends {
|
|
1505
|
+
readonly kind: "result" | "cardinality";
|
|
1506
|
+
} ? never : T_1 : never : never), "function">;
|
|
1507
|
+
//#endregion
|
|
1508
|
+
//#region src/expressions/functions/string.d.ts
|
|
1509
|
+
type TextArgumentsValidation<TArguments extends readonly unknown[]> = TArguments extends readonly [infer THead, ...infer TTail] ? SqlCapabilityValidation<OperandSqlType<THead, SqlText>, SqlTextLike> & TextArgumentsValidation<TTail> : unknown;
|
|
1510
|
+
type CoalesceValidation<TFirst, TRest extends readonly unknown[]> = TRest extends readonly [infer THead, ...infer TTail] ? SqlEqualityValidation<ExpressionSqlType<TFirst>, ExpressionSqlType<THead>> & CoalesceValidation<TFirst, TTail> : unknown;
|
|
1511
|
+
declare function lower<TExpression extends ExpressionWithOutput<string>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlTextLike>): SchemaExpression<ResultMeta<string, (MetadataOf<TExpression> extends (infer T) ? T extends MetadataOf<TExpression> ? T extends {
|
|
1512
|
+
readonly kind: "result";
|
|
1513
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TExpression> extends (infer T_2) ? T_2 extends MetadataOf<TExpression> ? T_2 extends {
|
|
1514
|
+
readonly kind: "result";
|
|
1515
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1516
|
+
readonly nullableFrom: infer TSource;
|
|
1517
|
+
} ? TSource : never : never : never, SqlText> | ExpressionMeta<MetadataOf<TExpression> extends (infer T_3) ? T_3 extends MetadataOf<TExpression> ? T_3 extends {
|
|
1518
|
+
readonly kind: "expression";
|
|
1519
|
+
readonly dependencies: infer TDependencies;
|
|
1520
|
+
} ? TDependencies : never : never : never> | (MetadataOf<TExpression> extends (infer T_4) ? T_4 extends MetadataOf<TExpression> ? T_4 extends {
|
|
1521
|
+
readonly kind: "result" | "cardinality";
|
|
1522
|
+
} ? never : T_4 : never : never), "function">;
|
|
1523
|
+
declare function upper<TExpression extends ExpressionWithOutput<string>>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlTextLike>): SchemaExpression<ResultMeta<string, (MetadataOf<TExpression> extends (infer T) ? T extends MetadataOf<TExpression> ? T extends {
|
|
1524
|
+
readonly kind: "result";
|
|
1525
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TExpression> extends (infer T_2) ? T_2 extends MetadataOf<TExpression> ? T_2 extends {
|
|
1526
|
+
readonly kind: "result";
|
|
1527
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1528
|
+
readonly nullableFrom: infer TSource;
|
|
1529
|
+
} ? TSource : never : never : never, SqlText> | ExpressionMeta<MetadataOf<TExpression> extends (infer T_3) ? T_3 extends MetadataOf<TExpression> ? T_3 extends {
|
|
1530
|
+
readonly kind: "expression";
|
|
1531
|
+
readonly dependencies: infer TDependencies;
|
|
1532
|
+
} ? TDependencies : never : never : never> | (MetadataOf<TExpression> extends (infer T_4) ? T_4 extends MetadataOf<TExpression> ? T_4 extends {
|
|
1533
|
+
readonly kind: "result" | "cardinality";
|
|
1534
|
+
} ? never : T_4 : never : never), "function">;
|
|
1535
|
+
declare function coalesce<T, const TExpressions extends readonly [ExpressionWithOutput<T>, ...ExpressionWithOutput<T>[]]>(...expressions: TExpressions & CoalesceValidation<TExpressions[0], TExpressions extends readonly [any, ...infer TRest] ? TRest : never>): SchemaExpression<ResultMeta<T, never, ExpressionSqlType<TExpressions[0]>> | ExpressionMeta<MetadataOf<TExpressions[number]> extends (infer T_1) ? T_1 extends MetadataOf<TExpressions[number]> ? T_1 extends {
|
|
1536
|
+
readonly kind: "expression";
|
|
1537
|
+
readonly dependencies: infer TDependencies;
|
|
1538
|
+
} ? TDependencies : never : never : never> | (MetadataOf<TExpressions[number]> extends (infer T_2) ? T_2 extends MetadataOf<TExpressions[number]> ? T_2 extends {
|
|
1539
|
+
readonly kind: "result" | "cardinality";
|
|
1540
|
+
} ? never : T_2 : never : never), "function">;
|
|
1541
|
+
declare function concat<const TArguments extends readonly Operand<string>[]>(...argumentsToConcat: TArguments & TextArgumentsValidation<TArguments>): SchemaExpression<ResultMeta<string, (MetadataOf<TArguments[number]> extends (infer T) ? T extends MetadataOf<TArguments[number]> ? T extends {
|
|
1542
|
+
readonly kind: "result";
|
|
1543
|
+
} ? T : never : never : never) extends (infer T_1) ? T_1 extends (MetadataOf<TArguments[number]> extends (infer T_2) ? T_2 extends MetadataOf<TArguments[number]> ? T_2 extends {
|
|
1544
|
+
readonly kind: "result";
|
|
1545
|
+
} ? T_2 : never : never : never) ? T_1 extends {
|
|
1546
|
+
readonly nullableFrom: infer TSource;
|
|
1547
|
+
} ? TSource : never : never : never, SqlText> | ExpressionMeta<MetadataOf<TArguments[number]> extends (infer T_3) ? T_3 extends MetadataOf<TArguments[number]> ? T_3 extends {
|
|
1548
|
+
readonly kind: "expression";
|
|
1549
|
+
readonly dependencies: infer TDependencies;
|
|
1550
|
+
} ? TDependencies : never : never : never> | (MetadataOf<TArguments[number]> extends (infer T_4) ? T_4 extends MetadataOf<TArguments[number]> ? T_4 extends {
|
|
1551
|
+
readonly kind: "result" | "cardinality";
|
|
1552
|
+
} ? never : T_4 : never : never), "function">;
|
|
1553
|
+
//#endregion
|
|
1554
|
+
//#region src/expressions/functions/window.d.ts
|
|
1555
|
+
type WindowOrder = AnyExpression | OrderTerm<any>;
|
|
1556
|
+
/**
|
|
1557
|
+
* The initial inline window scope. Named windows and frame clauses can be
|
|
1558
|
+
* added at a later dialect-aware boundary without changing expression types.
|
|
1559
|
+
*/
|
|
1560
|
+
interface WindowSpec {
|
|
1561
|
+
readonly partitionBy?: readonly AnyExpression[];
|
|
1562
|
+
readonly orderBy?: readonly WindowOrder[];
|
|
1563
|
+
}
|
|
1564
|
+
type FragmentItems<T> = T extends readonly unknown[] ? T[number] : never;
|
|
1565
|
+
type WindowSpecParts<TWindow> = TWindow extends WindowSpec ? FragmentItems<TWindow['partitionBy']> | FragmentItems<TWindow['orderBy']> : never;
|
|
1566
|
+
type WindowedExpression<TExpression extends AnyExpression, TWindow extends WindowSpec | undefined> = Expression<ResultMeta<OutputOf<TExpression>, NullabilityOf<TExpression>, SqlTypeOf<TExpression>> | ExpressionMeta<DependenciesOf<TExpression | WindowSpecParts<TWindow>>> | InheritedMetadata<TExpression | WindowSpecParts<TWindow>> | WindowMeta, 'function'>;
|
|
1567
|
+
declare function over<TExpression extends AnyExpression, const TWindow extends WindowSpec | undefined = undefined>(expression: TExpression, window?: TWindow): WindowedExpression<TExpression, TWindow>;
|
|
1568
|
+
declare function rowNumber(): Expression<ExpressionMeta<never> | ResultMeta<number, never, SqlInteger>, "function">;
|
|
1569
|
+
declare function rank(): Expression<ExpressionMeta<never> | ResultMeta<number, never, SqlInteger>, "function">;
|
|
1570
|
+
declare function denseRank(): Expression<ExpressionMeta<never> | ResultMeta<number, never, SqlInteger>, "function">;
|
|
1571
|
+
//#endregion
|
|
1572
|
+
//#region src/expressions/json.d.ts
|
|
1573
|
+
/** One safely encoded object key or zero-based array index in a JSON path. */
|
|
1574
|
+
type JsonPathSegment = string | number;
|
|
1575
|
+
declare const jsonPathBrand: unique symbol;
|
|
1576
|
+
/** An opaque root-relative JSON path whose literal segments remain available to TypeScript. */
|
|
1577
|
+
interface JsonPath<TSegments extends readonly JsonPathSegment[] = readonly JsonPathSegment[]> {
|
|
1578
|
+
readonly [jsonPathBrand]: true;
|
|
1579
|
+
readonly pathKind: 'json';
|
|
1580
|
+
readonly segments: TSegments;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Build a root-relative JSON path from object keys and array indexes.
|
|
1584
|
+
*
|
|
1585
|
+
* @throws {TypeError} When an index is negative, fractional, or unsafe.
|
|
1586
|
+
*/
|
|
1587
|
+
declare function jsonPath<const TSegments extends readonly JsonPathSegment[]>(...segments: TSegments): JsonPath<TSegments>;
|
|
1588
|
+
type JsonExpressionMetadata<TOutput, TDocument> = ResultMeta<TOutput> | ExpressionMeta<DependenciesOf<TDocument>> | InheritedMetadata<TDocument> | RequiresCapabilityMeta<'json'>;
|
|
1589
|
+
/** Extract a JSON string, returning SQL NULL for missing, null, or non-string values. */
|
|
1590
|
+
declare function jsonText<TDocument extends AnyExpression, TPath extends JsonPath>(document: TDocument, path: TPath): SchemaExpression<JsonExpressionMetadata<string | null, TDocument>, "function">;
|
|
1591
|
+
/** Extract a JSON number, returning SQL NULL for missing, null, or non-number values. */
|
|
1592
|
+
declare function jsonNumber<TDocument extends AnyExpression, TPath extends JsonPath>(document: TDocument, path: TPath): SchemaExpression<JsonExpressionMetadata<number | null, TDocument>, "function">;
|
|
1593
|
+
/** Extract a JSON boolean, returning SQL NULL for missing, null, or non-boolean values. */
|
|
1594
|
+
declare function jsonBoolean<TDocument extends AnyExpression, TPath extends JsonPath>(document: TDocument, path: TPath): SchemaExpression<JsonExpressionMetadata<boolean | null, TDocument>, "function">;
|
|
1595
|
+
/** Test whether a path exists, including when its value is JSON null. */
|
|
1596
|
+
declare function jsonExists<TDocument extends AnyExpression, TPath extends JsonPath>(document: TDocument, path: TPath): SchemaExpression<JsonExpressionMetadata<boolean, TDocument>, "function">;
|
|
1597
|
+
//#endregion
|
|
1598
|
+
//#region src/expressions/operators/arithmetic.d.ts
|
|
1599
|
+
type ArithmeticValidation<TLeft, TRight> = SqlCapabilityValidation<ExpressionSqlType<TLeft>, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<TRight, ExpressionSqlType<TLeft>>, SqlNumericLike> & SqlOrderValidation<ExpressionSqlType<TLeft>, OperandSqlType<TRight, ExpressionSqlType<TLeft>>>;
|
|
1600
|
+
declare const add: <T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ArithmeticValidation<TLeft, R>, right: R) => ResultExpression<unknown, R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1601
|
+
readonly kind: "result";
|
|
1602
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1603
|
+
readonly kind: "result";
|
|
1604
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1605
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1606
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1607
|
+
readonly kind: "result";
|
|
1608
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1609
|
+
readonly kind: "result";
|
|
1610
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1611
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1612
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_7) ? T_7 extends MetadataOf<TLeft> ? T_7 extends {
|
|
1613
|
+
readonly kind: "result";
|
|
1614
|
+
} ? T_7 : never : never : never) extends (infer T_8) ? T_8 extends (MetadataOf<TLeft> extends (infer T_9) ? T_9 extends MetadataOf<TLeft> ? T_9 extends {
|
|
1615
|
+
readonly kind: "result";
|
|
1616
|
+
} ? T_9 : never : never : never) ? T_8 extends {
|
|
1617
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1618
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_10) ? T_10 extends MetadataOf<TLeft> ? T_10 extends {
|
|
1619
|
+
readonly kind: "result";
|
|
1620
|
+
} ? T_10 : never : never : never) extends (infer T_11) ? T_11 extends (MetadataOf<TLeft> extends (infer T_12) ? T_12 extends MetadataOf<TLeft> ? T_12 extends {
|
|
1621
|
+
readonly kind: "result";
|
|
1622
|
+
} ? T_12 : never : never : never) ? T_11 extends {
|
|
1623
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1624
|
+
} ? TSqlType : SqlUnknown : never : never>>), "operator", NullabilityOf<R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_13) ? T_13 extends MetadataOf<TLeft> ? T_13 extends {
|
|
1625
|
+
readonly kind: "result";
|
|
1626
|
+
} ? T_13 : never : never : never) extends (infer T_14) ? T_14 extends (MetadataOf<TLeft> extends (infer T_15) ? T_15 extends MetadataOf<TLeft> ? T_15 extends {
|
|
1627
|
+
readonly kind: "result";
|
|
1628
|
+
} ? T_15 : never : never : never) ? T_14 extends {
|
|
1629
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1630
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_16) ? T_16 extends MetadataOf<TLeft> ? T_16 extends {
|
|
1631
|
+
readonly kind: "result";
|
|
1632
|
+
} ? T_16 : never : never : never) extends (infer T_17) ? T_17 extends (MetadataOf<TLeft> extends (infer T_18) ? T_18 extends MetadataOf<TLeft> ? T_18 extends {
|
|
1633
|
+
readonly kind: "result";
|
|
1634
|
+
} ? T_18 : never : never : never) ? T_17 extends {
|
|
1635
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1636
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_19) ? T_19 extends MetadataOf<TLeft> ? T_19 extends {
|
|
1637
|
+
readonly kind: "result";
|
|
1638
|
+
} ? T_19 : never : never : never) extends (infer T_20) ? T_20 extends (MetadataOf<TLeft> extends (infer T_21) ? T_21 extends MetadataOf<TLeft> ? T_21 extends {
|
|
1639
|
+
readonly kind: "result";
|
|
1640
|
+
} ? T_21 : never : never : never) ? T_20 extends {
|
|
1641
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1642
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_22) ? T_22 extends MetadataOf<TLeft> ? T_22 extends {
|
|
1643
|
+
readonly kind: "result";
|
|
1644
|
+
} ? T_22 : never : never : never) extends (infer T_23) ? T_23 extends (MetadataOf<TLeft> extends (infer T_24) ? T_24 extends MetadataOf<TLeft> ? T_24 extends {
|
|
1645
|
+
readonly kind: "result";
|
|
1646
|
+
} ? T_24 : never : never : never) ? T_23 extends {
|
|
1647
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1648
|
+
} ? TSqlType : SqlUnknown : never : never>>)>, (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_25) ? T_25 extends MetadataOf<TLeft> ? T_25 extends {
|
|
1649
|
+
readonly kind: "result";
|
|
1650
|
+
} ? T_25 : never : never : never) extends (infer T_26) ? T_26 extends (MetadataOf<TLeft> extends (infer T_27) ? T_27 extends MetadataOf<TLeft> ? T_27 extends {
|
|
1651
|
+
readonly kind: "result";
|
|
1652
|
+
} ? T_27 : never : never : never) ? T_26 extends {
|
|
1653
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1654
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_28) ? T_28 extends MetadataOf<TLeft> ? T_28 extends {
|
|
1655
|
+
readonly kind: "result";
|
|
1656
|
+
} ? T_28 : never : never : never) extends (infer T_29) ? T_29 extends (MetadataOf<TLeft> extends (infer T_30) ? T_30 extends MetadataOf<TLeft> ? T_30 extends {
|
|
1657
|
+
readonly kind: "result";
|
|
1658
|
+
} ? T_30 : never : never : never) ? T_29 extends {
|
|
1659
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1660
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_31) ? T_31 extends MetadataOf<TLeft> ? T_31 extends {
|
|
1661
|
+
readonly kind: "result";
|
|
1662
|
+
} ? T_31 : never : never : never) extends (infer T_32) ? T_32 extends (MetadataOf<TLeft> extends (infer T_33) ? T_33 extends MetadataOf<TLeft> ? T_33 extends {
|
|
1663
|
+
readonly kind: "result";
|
|
1664
|
+
} ? T_33 : never : never : never) ? T_32 extends {
|
|
1665
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1666
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_34) ? T_34 extends MetadataOf<TLeft> ? T_34 extends {
|
|
1667
|
+
readonly kind: "result";
|
|
1668
|
+
} ? T_34 : never : never : never) extends (infer T_35) ? T_35 extends (MetadataOf<TLeft> extends (infer T_36) ? T_36 extends MetadataOf<TLeft> ? T_36 extends {
|
|
1669
|
+
readonly kind: "result";
|
|
1670
|
+
} ? T_36 : never : never : never) ? T_35 extends {
|
|
1671
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1672
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_37) ? T_37 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_38) ? T_38 extends MetadataOf<TLeft> ? T_38 extends {
|
|
1673
|
+
readonly kind: "result";
|
|
1674
|
+
} ? T_38 : never : never : never) extends (infer T_39) ? T_39 extends (MetadataOf<TLeft> extends (infer T_40) ? T_40 extends MetadataOf<TLeft> ? T_40 extends {
|
|
1675
|
+
readonly kind: "result";
|
|
1676
|
+
} ? T_40 : never : never : never) ? T_39 extends {
|
|
1677
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1678
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_41) ? T_41 extends MetadataOf<TLeft> ? T_41 extends {
|
|
1679
|
+
readonly kind: "result";
|
|
1680
|
+
} ? T_41 : never : never : never) extends (infer T_42) ? T_42 extends (MetadataOf<TLeft> extends (infer T_43) ? T_43 extends MetadataOf<TLeft> ? T_43 extends {
|
|
1681
|
+
readonly kind: "result";
|
|
1682
|
+
} ? T_43 : never : never : never) ? T_42 extends {
|
|
1683
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1684
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_44) ? T_44 extends MetadataOf<TLeft> ? T_44 extends {
|
|
1685
|
+
readonly kind: "result";
|
|
1686
|
+
} ? T_44 : never : never : never) extends (infer T_45) ? T_45 extends (MetadataOf<TLeft> extends (infer T_46) ? T_46 extends MetadataOf<TLeft> ? T_46 extends {
|
|
1687
|
+
readonly kind: "result";
|
|
1688
|
+
} ? T_46 : never : never : never) ? T_45 extends {
|
|
1689
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1690
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_47) ? T_47 extends MetadataOf<TLeft> ? T_47 extends {
|
|
1691
|
+
readonly kind: "result";
|
|
1692
|
+
} ? T_47 : never : never : never) extends (infer T_48) ? T_48 extends (MetadataOf<TLeft> extends (infer T_49) ? T_49 extends MetadataOf<TLeft> ? T_49 extends {
|
|
1693
|
+
readonly kind: "result";
|
|
1694
|
+
} ? T_49 : never : never : never) ? T_48 extends {
|
|
1695
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1696
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_37 extends {
|
|
1697
|
+
readonly kind: "result";
|
|
1698
|
+
} ? T_37 : never : never : never) extends (infer T_50) ? T_50 extends (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_51) ? T_51 extends MetadataOf<TLeft> ? T_51 extends {
|
|
1699
|
+
readonly kind: "result";
|
|
1700
|
+
} ? T_51 : never : never : never) extends (infer T_52) ? T_52 extends (MetadataOf<TLeft> extends (infer T_53) ? T_53 extends MetadataOf<TLeft> ? T_53 extends {
|
|
1701
|
+
readonly kind: "result";
|
|
1702
|
+
} ? T_53 : never : never : never) ? T_52 extends {
|
|
1703
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1704
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_54) ? T_54 extends MetadataOf<TLeft> ? T_54 extends {
|
|
1705
|
+
readonly kind: "result";
|
|
1706
|
+
} ? T_54 : never : never : never) extends (infer T_55) ? T_55 extends (MetadataOf<TLeft> extends (infer T_56) ? T_56 extends MetadataOf<TLeft> ? T_56 extends {
|
|
1707
|
+
readonly kind: "result";
|
|
1708
|
+
} ? T_56 : never : never : never) ? T_55 extends {
|
|
1709
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1710
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_57) ? T_57 extends MetadataOf<TLeft> ? T_57 extends {
|
|
1711
|
+
readonly kind: "result";
|
|
1712
|
+
} ? T_57 : never : never : never) extends (infer T_58) ? T_58 extends (MetadataOf<TLeft> extends (infer T_59) ? T_59 extends MetadataOf<TLeft> ? T_59 extends {
|
|
1713
|
+
readonly kind: "result";
|
|
1714
|
+
} ? T_59 : never : never : never) ? T_58 extends {
|
|
1715
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1716
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_60) ? T_60 extends MetadataOf<TLeft> ? T_60 extends {
|
|
1717
|
+
readonly kind: "result";
|
|
1718
|
+
} ? T_60 : never : never : never) extends (infer T_61) ? T_61 extends (MetadataOf<TLeft> extends (infer T_62) ? T_62 extends MetadataOf<TLeft> ? T_62 extends {
|
|
1719
|
+
readonly kind: "result";
|
|
1720
|
+
} ? T_62 : never : never : never) ? T_61 extends {
|
|
1721
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1722
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_63) ? T_63 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_64) ? T_64 extends MetadataOf<TLeft> ? T_64 extends {
|
|
1723
|
+
readonly kind: "result";
|
|
1724
|
+
} ? T_64 : never : never : never) extends (infer T_65) ? T_65 extends (MetadataOf<TLeft> extends (infer T_66) ? T_66 extends MetadataOf<TLeft> ? T_66 extends {
|
|
1725
|
+
readonly kind: "result";
|
|
1726
|
+
} ? T_66 : never : never : never) ? T_65 extends {
|
|
1727
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1728
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_67) ? T_67 extends MetadataOf<TLeft> ? T_67 extends {
|
|
1729
|
+
readonly kind: "result";
|
|
1730
|
+
} ? T_67 : never : never : never) extends (infer T_68) ? T_68 extends (MetadataOf<TLeft> extends (infer T_69) ? T_69 extends MetadataOf<TLeft> ? T_69 extends {
|
|
1731
|
+
readonly kind: "result";
|
|
1732
|
+
} ? T_69 : never : never : never) ? T_68 extends {
|
|
1733
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1734
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_70) ? T_70 extends MetadataOf<TLeft> ? T_70 extends {
|
|
1735
|
+
readonly kind: "result";
|
|
1736
|
+
} ? T_70 : never : never : never) extends (infer T_71) ? T_71 extends (MetadataOf<TLeft> extends (infer T_72) ? T_72 extends MetadataOf<TLeft> ? T_72 extends {
|
|
1737
|
+
readonly kind: "result";
|
|
1738
|
+
} ? T_72 : never : never : never) ? T_71 extends {
|
|
1739
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1740
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_73) ? T_73 extends MetadataOf<TLeft> ? T_73 extends {
|
|
1741
|
+
readonly kind: "result";
|
|
1742
|
+
} ? T_73 : never : never : never) extends (infer T_74) ? T_74 extends (MetadataOf<TLeft> extends (infer T_75) ? T_75 extends MetadataOf<TLeft> ? T_75 extends {
|
|
1743
|
+
readonly kind: "result";
|
|
1744
|
+
} ? T_75 : never : never : never) ? T_74 extends {
|
|
1745
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1746
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_63 extends {
|
|
1747
|
+
readonly kind: "result";
|
|
1748
|
+
} ? T_63 : never : never : never) ? T_50 extends {
|
|
1749
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1750
|
+
} ? TSqlType : SqlUnknown : never : never>;
|
|
1751
|
+
declare const subtract: <T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ArithmeticValidation<TLeft, R>, right: R) => ResultExpression<unknown, R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1752
|
+
readonly kind: "result";
|
|
1753
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1754
|
+
readonly kind: "result";
|
|
1755
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1756
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1757
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1758
|
+
readonly kind: "result";
|
|
1759
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1760
|
+
readonly kind: "result";
|
|
1761
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1762
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1763
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_7) ? T_7 extends MetadataOf<TLeft> ? T_7 extends {
|
|
1764
|
+
readonly kind: "result";
|
|
1765
|
+
} ? T_7 : never : never : never) extends (infer T_8) ? T_8 extends (MetadataOf<TLeft> extends (infer T_9) ? T_9 extends MetadataOf<TLeft> ? T_9 extends {
|
|
1766
|
+
readonly kind: "result";
|
|
1767
|
+
} ? T_9 : never : never : never) ? T_8 extends {
|
|
1768
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1769
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_10) ? T_10 extends MetadataOf<TLeft> ? T_10 extends {
|
|
1770
|
+
readonly kind: "result";
|
|
1771
|
+
} ? T_10 : never : never : never) extends (infer T_11) ? T_11 extends (MetadataOf<TLeft> extends (infer T_12) ? T_12 extends MetadataOf<TLeft> ? T_12 extends {
|
|
1772
|
+
readonly kind: "result";
|
|
1773
|
+
} ? T_12 : never : never : never) ? T_11 extends {
|
|
1774
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1775
|
+
} ? TSqlType : SqlUnknown : never : never>>), "operator", NullabilityOf<R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_13) ? T_13 extends MetadataOf<TLeft> ? T_13 extends {
|
|
1776
|
+
readonly kind: "result";
|
|
1777
|
+
} ? T_13 : never : never : never) extends (infer T_14) ? T_14 extends (MetadataOf<TLeft> extends (infer T_15) ? T_15 extends MetadataOf<TLeft> ? T_15 extends {
|
|
1778
|
+
readonly kind: "result";
|
|
1779
|
+
} ? T_15 : never : never : never) ? T_14 extends {
|
|
1780
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1781
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_16) ? T_16 extends MetadataOf<TLeft> ? T_16 extends {
|
|
1782
|
+
readonly kind: "result";
|
|
1783
|
+
} ? T_16 : never : never : never) extends (infer T_17) ? T_17 extends (MetadataOf<TLeft> extends (infer T_18) ? T_18 extends MetadataOf<TLeft> ? T_18 extends {
|
|
1784
|
+
readonly kind: "result";
|
|
1785
|
+
} ? T_18 : never : never : never) ? T_17 extends {
|
|
1786
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1787
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_19) ? T_19 extends MetadataOf<TLeft> ? T_19 extends {
|
|
1788
|
+
readonly kind: "result";
|
|
1789
|
+
} ? T_19 : never : never : never) extends (infer T_20) ? T_20 extends (MetadataOf<TLeft> extends (infer T_21) ? T_21 extends MetadataOf<TLeft> ? T_21 extends {
|
|
1790
|
+
readonly kind: "result";
|
|
1791
|
+
} ? T_21 : never : never : never) ? T_20 extends {
|
|
1792
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1793
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_22) ? T_22 extends MetadataOf<TLeft> ? T_22 extends {
|
|
1794
|
+
readonly kind: "result";
|
|
1795
|
+
} ? T_22 : never : never : never) extends (infer T_23) ? T_23 extends (MetadataOf<TLeft> extends (infer T_24) ? T_24 extends MetadataOf<TLeft> ? T_24 extends {
|
|
1796
|
+
readonly kind: "result";
|
|
1797
|
+
} ? T_24 : never : never : never) ? T_23 extends {
|
|
1798
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1799
|
+
} ? TSqlType : SqlUnknown : never : never>>)>, (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_25) ? T_25 extends MetadataOf<TLeft> ? T_25 extends {
|
|
1800
|
+
readonly kind: "result";
|
|
1801
|
+
} ? T_25 : never : never : never) extends (infer T_26) ? T_26 extends (MetadataOf<TLeft> extends (infer T_27) ? T_27 extends MetadataOf<TLeft> ? T_27 extends {
|
|
1802
|
+
readonly kind: "result";
|
|
1803
|
+
} ? T_27 : never : never : never) ? T_26 extends {
|
|
1804
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1805
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_28) ? T_28 extends MetadataOf<TLeft> ? T_28 extends {
|
|
1806
|
+
readonly kind: "result";
|
|
1807
|
+
} ? T_28 : never : never : never) extends (infer T_29) ? T_29 extends (MetadataOf<TLeft> extends (infer T_30) ? T_30 extends MetadataOf<TLeft> ? T_30 extends {
|
|
1808
|
+
readonly kind: "result";
|
|
1809
|
+
} ? T_30 : never : never : never) ? T_29 extends {
|
|
1810
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1811
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_31) ? T_31 extends MetadataOf<TLeft> ? T_31 extends {
|
|
1812
|
+
readonly kind: "result";
|
|
1813
|
+
} ? T_31 : never : never : never) extends (infer T_32) ? T_32 extends (MetadataOf<TLeft> extends (infer T_33) ? T_33 extends MetadataOf<TLeft> ? T_33 extends {
|
|
1814
|
+
readonly kind: "result";
|
|
1815
|
+
} ? T_33 : never : never : never) ? T_32 extends {
|
|
1816
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1817
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_34) ? T_34 extends MetadataOf<TLeft> ? T_34 extends {
|
|
1818
|
+
readonly kind: "result";
|
|
1819
|
+
} ? T_34 : never : never : never) extends (infer T_35) ? T_35 extends (MetadataOf<TLeft> extends (infer T_36) ? T_36 extends MetadataOf<TLeft> ? T_36 extends {
|
|
1820
|
+
readonly kind: "result";
|
|
1821
|
+
} ? T_36 : never : never : never) ? T_35 extends {
|
|
1822
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1823
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_37) ? T_37 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_38) ? T_38 extends MetadataOf<TLeft> ? T_38 extends {
|
|
1824
|
+
readonly kind: "result";
|
|
1825
|
+
} ? T_38 : never : never : never) extends (infer T_39) ? T_39 extends (MetadataOf<TLeft> extends (infer T_40) ? T_40 extends MetadataOf<TLeft> ? T_40 extends {
|
|
1826
|
+
readonly kind: "result";
|
|
1827
|
+
} ? T_40 : never : never : never) ? T_39 extends {
|
|
1828
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1829
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_41) ? T_41 extends MetadataOf<TLeft> ? T_41 extends {
|
|
1830
|
+
readonly kind: "result";
|
|
1831
|
+
} ? T_41 : never : never : never) extends (infer T_42) ? T_42 extends (MetadataOf<TLeft> extends (infer T_43) ? T_43 extends MetadataOf<TLeft> ? T_43 extends {
|
|
1832
|
+
readonly kind: "result";
|
|
1833
|
+
} ? T_43 : never : never : never) ? T_42 extends {
|
|
1834
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1835
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_44) ? T_44 extends MetadataOf<TLeft> ? T_44 extends {
|
|
1836
|
+
readonly kind: "result";
|
|
1837
|
+
} ? T_44 : never : never : never) extends (infer T_45) ? T_45 extends (MetadataOf<TLeft> extends (infer T_46) ? T_46 extends MetadataOf<TLeft> ? T_46 extends {
|
|
1838
|
+
readonly kind: "result";
|
|
1839
|
+
} ? T_46 : never : never : never) ? T_45 extends {
|
|
1840
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1841
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_47) ? T_47 extends MetadataOf<TLeft> ? T_47 extends {
|
|
1842
|
+
readonly kind: "result";
|
|
1843
|
+
} ? T_47 : never : never : never) extends (infer T_48) ? T_48 extends (MetadataOf<TLeft> extends (infer T_49) ? T_49 extends MetadataOf<TLeft> ? T_49 extends {
|
|
1844
|
+
readonly kind: "result";
|
|
1845
|
+
} ? T_49 : never : never : never) ? T_48 extends {
|
|
1846
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1847
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_37 extends {
|
|
1848
|
+
readonly kind: "result";
|
|
1849
|
+
} ? T_37 : never : never : never) extends (infer T_50) ? T_50 extends (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_51) ? T_51 extends MetadataOf<TLeft> ? T_51 extends {
|
|
1850
|
+
readonly kind: "result";
|
|
1851
|
+
} ? T_51 : never : never : never) extends (infer T_52) ? T_52 extends (MetadataOf<TLeft> extends (infer T_53) ? T_53 extends MetadataOf<TLeft> ? T_53 extends {
|
|
1852
|
+
readonly kind: "result";
|
|
1853
|
+
} ? T_53 : never : never : never) ? T_52 extends {
|
|
1854
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1855
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_54) ? T_54 extends MetadataOf<TLeft> ? T_54 extends {
|
|
1856
|
+
readonly kind: "result";
|
|
1857
|
+
} ? T_54 : never : never : never) extends (infer T_55) ? T_55 extends (MetadataOf<TLeft> extends (infer T_56) ? T_56 extends MetadataOf<TLeft> ? T_56 extends {
|
|
1858
|
+
readonly kind: "result";
|
|
1859
|
+
} ? T_56 : never : never : never) ? T_55 extends {
|
|
1860
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1861
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_57) ? T_57 extends MetadataOf<TLeft> ? T_57 extends {
|
|
1862
|
+
readonly kind: "result";
|
|
1863
|
+
} ? T_57 : never : never : never) extends (infer T_58) ? T_58 extends (MetadataOf<TLeft> extends (infer T_59) ? T_59 extends MetadataOf<TLeft> ? T_59 extends {
|
|
1864
|
+
readonly kind: "result";
|
|
1865
|
+
} ? T_59 : never : never : never) ? T_58 extends {
|
|
1866
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1867
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_60) ? T_60 extends MetadataOf<TLeft> ? T_60 extends {
|
|
1868
|
+
readonly kind: "result";
|
|
1869
|
+
} ? T_60 : never : never : never) extends (infer T_61) ? T_61 extends (MetadataOf<TLeft> extends (infer T_62) ? T_62 extends MetadataOf<TLeft> ? T_62 extends {
|
|
1870
|
+
readonly kind: "result";
|
|
1871
|
+
} ? T_62 : never : never : never) ? T_61 extends {
|
|
1872
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1873
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_63) ? T_63 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_64) ? T_64 extends MetadataOf<TLeft> ? T_64 extends {
|
|
1874
|
+
readonly kind: "result";
|
|
1875
|
+
} ? T_64 : never : never : never) extends (infer T_65) ? T_65 extends (MetadataOf<TLeft> extends (infer T_66) ? T_66 extends MetadataOf<TLeft> ? T_66 extends {
|
|
1876
|
+
readonly kind: "result";
|
|
1877
|
+
} ? T_66 : never : never : never) ? T_65 extends {
|
|
1878
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1879
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_67) ? T_67 extends MetadataOf<TLeft> ? T_67 extends {
|
|
1880
|
+
readonly kind: "result";
|
|
1881
|
+
} ? T_67 : never : never : never) extends (infer T_68) ? T_68 extends (MetadataOf<TLeft> extends (infer T_69) ? T_69 extends MetadataOf<TLeft> ? T_69 extends {
|
|
1882
|
+
readonly kind: "result";
|
|
1883
|
+
} ? T_69 : never : never : never) ? T_68 extends {
|
|
1884
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1885
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_70) ? T_70 extends MetadataOf<TLeft> ? T_70 extends {
|
|
1886
|
+
readonly kind: "result";
|
|
1887
|
+
} ? T_70 : never : never : never) extends (infer T_71) ? T_71 extends (MetadataOf<TLeft> extends (infer T_72) ? T_72 extends MetadataOf<TLeft> ? T_72 extends {
|
|
1888
|
+
readonly kind: "result";
|
|
1889
|
+
} ? T_72 : never : never : never) ? T_71 extends {
|
|
1890
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1891
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_73) ? T_73 extends MetadataOf<TLeft> ? T_73 extends {
|
|
1892
|
+
readonly kind: "result";
|
|
1893
|
+
} ? T_73 : never : never : never) extends (infer T_74) ? T_74 extends (MetadataOf<TLeft> extends (infer T_75) ? T_75 extends MetadataOf<TLeft> ? T_75 extends {
|
|
1894
|
+
readonly kind: "result";
|
|
1895
|
+
} ? T_75 : never : never : never) ? T_74 extends {
|
|
1896
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1897
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_63 extends {
|
|
1898
|
+
readonly kind: "result";
|
|
1899
|
+
} ? T_63 : never : never : never) ? T_50 extends {
|
|
1900
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1901
|
+
} ? TSqlType : SqlUnknown : never : never>;
|
|
1902
|
+
declare const multiply: <T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ArithmeticValidation<TLeft, R>, right: R) => ResultExpression<unknown, R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
1903
|
+
readonly kind: "result";
|
|
1904
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
1905
|
+
readonly kind: "result";
|
|
1906
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
1907
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1908
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
1909
|
+
readonly kind: "result";
|
|
1910
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
1911
|
+
readonly kind: "result";
|
|
1912
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
1913
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1914
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_7) ? T_7 extends MetadataOf<TLeft> ? T_7 extends {
|
|
1915
|
+
readonly kind: "result";
|
|
1916
|
+
} ? T_7 : never : never : never) extends (infer T_8) ? T_8 extends (MetadataOf<TLeft> extends (infer T_9) ? T_9 extends MetadataOf<TLeft> ? T_9 extends {
|
|
1917
|
+
readonly kind: "result";
|
|
1918
|
+
} ? T_9 : never : never : never) ? T_8 extends {
|
|
1919
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1920
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_10) ? T_10 extends MetadataOf<TLeft> ? T_10 extends {
|
|
1921
|
+
readonly kind: "result";
|
|
1922
|
+
} ? T_10 : never : never : never) extends (infer T_11) ? T_11 extends (MetadataOf<TLeft> extends (infer T_12) ? T_12 extends MetadataOf<TLeft> ? T_12 extends {
|
|
1923
|
+
readonly kind: "result";
|
|
1924
|
+
} ? T_12 : never : never : never) ? T_11 extends {
|
|
1925
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1926
|
+
} ? TSqlType : SqlUnknown : never : never>>), "operator", NullabilityOf<R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_13) ? T_13 extends MetadataOf<TLeft> ? T_13 extends {
|
|
1927
|
+
readonly kind: "result";
|
|
1928
|
+
} ? T_13 : never : never : never) extends (infer T_14) ? T_14 extends (MetadataOf<TLeft> extends (infer T_15) ? T_15 extends MetadataOf<TLeft> ? T_15 extends {
|
|
1929
|
+
readonly kind: "result";
|
|
1930
|
+
} ? T_15 : never : never : never) ? T_14 extends {
|
|
1931
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1932
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_16) ? T_16 extends MetadataOf<TLeft> ? T_16 extends {
|
|
1933
|
+
readonly kind: "result";
|
|
1934
|
+
} ? T_16 : never : never : never) extends (infer T_17) ? T_17 extends (MetadataOf<TLeft> extends (infer T_18) ? T_18 extends MetadataOf<TLeft> ? T_18 extends {
|
|
1935
|
+
readonly kind: "result";
|
|
1936
|
+
} ? T_18 : never : never : never) ? T_17 extends {
|
|
1937
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1938
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_19) ? T_19 extends MetadataOf<TLeft> ? T_19 extends {
|
|
1939
|
+
readonly kind: "result";
|
|
1940
|
+
} ? T_19 : never : never : never) extends (infer T_20) ? T_20 extends (MetadataOf<TLeft> extends (infer T_21) ? T_21 extends MetadataOf<TLeft> ? T_21 extends {
|
|
1941
|
+
readonly kind: "result";
|
|
1942
|
+
} ? T_21 : never : never : never) ? T_20 extends {
|
|
1943
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1944
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_22) ? T_22 extends MetadataOf<TLeft> ? T_22 extends {
|
|
1945
|
+
readonly kind: "result";
|
|
1946
|
+
} ? T_22 : never : never : never) extends (infer T_23) ? T_23 extends (MetadataOf<TLeft> extends (infer T_24) ? T_24 extends MetadataOf<TLeft> ? T_24 extends {
|
|
1947
|
+
readonly kind: "result";
|
|
1948
|
+
} ? T_24 : never : never : never) ? T_23 extends {
|
|
1949
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1950
|
+
} ? TSqlType : SqlUnknown : never : never>>)>, (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_25) ? T_25 extends MetadataOf<TLeft> ? T_25 extends {
|
|
1951
|
+
readonly kind: "result";
|
|
1952
|
+
} ? T_25 : never : never : never) extends (infer T_26) ? T_26 extends (MetadataOf<TLeft> extends (infer T_27) ? T_27 extends MetadataOf<TLeft> ? T_27 extends {
|
|
1953
|
+
readonly kind: "result";
|
|
1954
|
+
} ? T_27 : never : never : never) ? T_26 extends {
|
|
1955
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1956
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_28) ? T_28 extends MetadataOf<TLeft> ? T_28 extends {
|
|
1957
|
+
readonly kind: "result";
|
|
1958
|
+
} ? T_28 : never : never : never) extends (infer T_29) ? T_29 extends (MetadataOf<TLeft> extends (infer T_30) ? T_30 extends MetadataOf<TLeft> ? T_30 extends {
|
|
1959
|
+
readonly kind: "result";
|
|
1960
|
+
} ? T_30 : never : never : never) ? T_29 extends {
|
|
1961
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1962
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_31) ? T_31 extends MetadataOf<TLeft> ? T_31 extends {
|
|
1963
|
+
readonly kind: "result";
|
|
1964
|
+
} ? T_31 : never : never : never) extends (infer T_32) ? T_32 extends (MetadataOf<TLeft> extends (infer T_33) ? T_33 extends MetadataOf<TLeft> ? T_33 extends {
|
|
1965
|
+
readonly kind: "result";
|
|
1966
|
+
} ? T_33 : never : never : never) ? T_32 extends {
|
|
1967
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1968
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_34) ? T_34 extends MetadataOf<TLeft> ? T_34 extends {
|
|
1969
|
+
readonly kind: "result";
|
|
1970
|
+
} ? T_34 : never : never : never) extends (infer T_35) ? T_35 extends (MetadataOf<TLeft> extends (infer T_36) ? T_36 extends MetadataOf<TLeft> ? T_36 extends {
|
|
1971
|
+
readonly kind: "result";
|
|
1972
|
+
} ? T_36 : never : never : never) ? T_35 extends {
|
|
1973
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1974
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_37) ? T_37 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_38) ? T_38 extends MetadataOf<TLeft> ? T_38 extends {
|
|
1975
|
+
readonly kind: "result";
|
|
1976
|
+
} ? T_38 : never : never : never) extends (infer T_39) ? T_39 extends (MetadataOf<TLeft> extends (infer T_40) ? T_40 extends MetadataOf<TLeft> ? T_40 extends {
|
|
1977
|
+
readonly kind: "result";
|
|
1978
|
+
} ? T_40 : never : never : never) ? T_39 extends {
|
|
1979
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1980
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_41) ? T_41 extends MetadataOf<TLeft> ? T_41 extends {
|
|
1981
|
+
readonly kind: "result";
|
|
1982
|
+
} ? T_41 : never : never : never) extends (infer T_42) ? T_42 extends (MetadataOf<TLeft> extends (infer T_43) ? T_43 extends MetadataOf<TLeft> ? T_43 extends {
|
|
1983
|
+
readonly kind: "result";
|
|
1984
|
+
} ? T_43 : never : never : never) ? T_42 extends {
|
|
1985
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1986
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_44) ? T_44 extends MetadataOf<TLeft> ? T_44 extends {
|
|
1987
|
+
readonly kind: "result";
|
|
1988
|
+
} ? T_44 : never : never : never) extends (infer T_45) ? T_45 extends (MetadataOf<TLeft> extends (infer T_46) ? T_46 extends MetadataOf<TLeft> ? T_46 extends {
|
|
1989
|
+
readonly kind: "result";
|
|
1990
|
+
} ? T_46 : never : never : never) ? T_45 extends {
|
|
1991
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1992
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_47) ? T_47 extends MetadataOf<TLeft> ? T_47 extends {
|
|
1993
|
+
readonly kind: "result";
|
|
1994
|
+
} ? T_47 : never : never : never) extends (infer T_48) ? T_48 extends (MetadataOf<TLeft> extends (infer T_49) ? T_49 extends MetadataOf<TLeft> ? T_49 extends {
|
|
1995
|
+
readonly kind: "result";
|
|
1996
|
+
} ? T_49 : never : never : never) ? T_48 extends {
|
|
1997
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
1998
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_37 extends {
|
|
1999
|
+
readonly kind: "result";
|
|
2000
|
+
} ? T_37 : never : never : never) extends (infer T_50) ? T_50 extends (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_51) ? T_51 extends MetadataOf<TLeft> ? T_51 extends {
|
|
2001
|
+
readonly kind: "result";
|
|
2002
|
+
} ? T_51 : never : never : never) extends (infer T_52) ? T_52 extends (MetadataOf<TLeft> extends (infer T_53) ? T_53 extends MetadataOf<TLeft> ? T_53 extends {
|
|
2003
|
+
readonly kind: "result";
|
|
2004
|
+
} ? T_53 : never : never : never) ? T_52 extends {
|
|
2005
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2006
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_54) ? T_54 extends MetadataOf<TLeft> ? T_54 extends {
|
|
2007
|
+
readonly kind: "result";
|
|
2008
|
+
} ? T_54 : never : never : never) extends (infer T_55) ? T_55 extends (MetadataOf<TLeft> extends (infer T_56) ? T_56 extends MetadataOf<TLeft> ? T_56 extends {
|
|
2009
|
+
readonly kind: "result";
|
|
2010
|
+
} ? T_56 : never : never : never) ? T_55 extends {
|
|
2011
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2012
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_57) ? T_57 extends MetadataOf<TLeft> ? T_57 extends {
|
|
2013
|
+
readonly kind: "result";
|
|
2014
|
+
} ? T_57 : never : never : never) extends (infer T_58) ? T_58 extends (MetadataOf<TLeft> extends (infer T_59) ? T_59 extends MetadataOf<TLeft> ? T_59 extends {
|
|
2015
|
+
readonly kind: "result";
|
|
2016
|
+
} ? T_59 : never : never : never) ? T_58 extends {
|
|
2017
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2018
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_60) ? T_60 extends MetadataOf<TLeft> ? T_60 extends {
|
|
2019
|
+
readonly kind: "result";
|
|
2020
|
+
} ? T_60 : never : never : never) extends (infer T_61) ? T_61 extends (MetadataOf<TLeft> extends (infer T_62) ? T_62 extends MetadataOf<TLeft> ? T_62 extends {
|
|
2021
|
+
readonly kind: "result";
|
|
2022
|
+
} ? T_62 : never : never : never) ? T_61 extends {
|
|
2023
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2024
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_63) ? T_63 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_64) ? T_64 extends MetadataOf<TLeft> ? T_64 extends {
|
|
2025
|
+
readonly kind: "result";
|
|
2026
|
+
} ? T_64 : never : never : never) extends (infer T_65) ? T_65 extends (MetadataOf<TLeft> extends (infer T_66) ? T_66 extends MetadataOf<TLeft> ? T_66 extends {
|
|
2027
|
+
readonly kind: "result";
|
|
2028
|
+
} ? T_66 : never : never : never) ? T_65 extends {
|
|
2029
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2030
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_67) ? T_67 extends MetadataOf<TLeft> ? T_67 extends {
|
|
2031
|
+
readonly kind: "result";
|
|
2032
|
+
} ? T_67 : never : never : never) extends (infer T_68) ? T_68 extends (MetadataOf<TLeft> extends (infer T_69) ? T_69 extends MetadataOf<TLeft> ? T_69 extends {
|
|
2033
|
+
readonly kind: "result";
|
|
2034
|
+
} ? T_69 : never : never : never) ? T_68 extends {
|
|
2035
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2036
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_70) ? T_70 extends MetadataOf<TLeft> ? T_70 extends {
|
|
2037
|
+
readonly kind: "result";
|
|
2038
|
+
} ? T_70 : never : never : never) extends (infer T_71) ? T_71 extends (MetadataOf<TLeft> extends (infer T_72) ? T_72 extends MetadataOf<TLeft> ? T_72 extends {
|
|
2039
|
+
readonly kind: "result";
|
|
2040
|
+
} ? T_72 : never : never : never) ? T_71 extends {
|
|
2041
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2042
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_73) ? T_73 extends MetadataOf<TLeft> ? T_73 extends {
|
|
2043
|
+
readonly kind: "result";
|
|
2044
|
+
} ? T_73 : never : never : never) extends (infer T_74) ? T_74 extends (MetadataOf<TLeft> extends (infer T_75) ? T_75 extends MetadataOf<TLeft> ? T_75 extends {
|
|
2045
|
+
readonly kind: "result";
|
|
2046
|
+
} ? T_75 : never : never : never) ? T_74 extends {
|
|
2047
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2048
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_63 extends {
|
|
2049
|
+
readonly kind: "result";
|
|
2050
|
+
} ? T_63 : never : never : never) ? T_50 extends {
|
|
2051
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2052
|
+
} ? TSqlType : SqlUnknown : never : never>;
|
|
2053
|
+
declare const divide: <T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ArithmeticValidation<TLeft, R>, right: R) => ResultExpression<unknown, R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
2054
|
+
readonly kind: "result";
|
|
2055
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
2056
|
+
readonly kind: "result";
|
|
2057
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
2058
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2059
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
2060
|
+
readonly kind: "result";
|
|
2061
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
2062
|
+
readonly kind: "result";
|
|
2063
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
2064
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2065
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_7) ? T_7 extends MetadataOf<TLeft> ? T_7 extends {
|
|
2066
|
+
readonly kind: "result";
|
|
2067
|
+
} ? T_7 : never : never : never) extends (infer T_8) ? T_8 extends (MetadataOf<TLeft> extends (infer T_9) ? T_9 extends MetadataOf<TLeft> ? T_9 extends {
|
|
2068
|
+
readonly kind: "result";
|
|
2069
|
+
} ? T_9 : never : never : never) ? T_8 extends {
|
|
2070
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2071
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_10) ? T_10 extends MetadataOf<TLeft> ? T_10 extends {
|
|
2072
|
+
readonly kind: "result";
|
|
2073
|
+
} ? T_10 : never : never : never) extends (infer T_11) ? T_11 extends (MetadataOf<TLeft> extends (infer T_12) ? T_12 extends MetadataOf<TLeft> ? T_12 extends {
|
|
2074
|
+
readonly kind: "result";
|
|
2075
|
+
} ? T_12 : never : never : never) ? T_11 extends {
|
|
2076
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2077
|
+
} ? TSqlType : SqlUnknown : never : never>>), "operator", NullabilityOf<R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_13) ? T_13 extends MetadataOf<TLeft> ? T_13 extends {
|
|
2078
|
+
readonly kind: "result";
|
|
2079
|
+
} ? T_13 : never : never : never) extends (infer T_14) ? T_14 extends (MetadataOf<TLeft> extends (infer T_15) ? T_15 extends MetadataOf<TLeft> ? T_15 extends {
|
|
2080
|
+
readonly kind: "result";
|
|
2081
|
+
} ? T_15 : never : never : never) ? T_14 extends {
|
|
2082
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2083
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_16) ? T_16 extends MetadataOf<TLeft> ? T_16 extends {
|
|
2084
|
+
readonly kind: "result";
|
|
2085
|
+
} ? T_16 : never : never : never) extends (infer T_17) ? T_17 extends (MetadataOf<TLeft> extends (infer T_18) ? T_18 extends MetadataOf<TLeft> ? T_18 extends {
|
|
2086
|
+
readonly kind: "result";
|
|
2087
|
+
} ? T_18 : never : never : never) ? T_17 extends {
|
|
2088
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2089
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_19) ? T_19 extends MetadataOf<TLeft> ? T_19 extends {
|
|
2090
|
+
readonly kind: "result";
|
|
2091
|
+
} ? T_19 : never : never : never) extends (infer T_20) ? T_20 extends (MetadataOf<TLeft> extends (infer T_21) ? T_21 extends MetadataOf<TLeft> ? T_21 extends {
|
|
2092
|
+
readonly kind: "result";
|
|
2093
|
+
} ? T_21 : never : never : never) ? T_20 extends {
|
|
2094
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2095
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_22) ? T_22 extends MetadataOf<TLeft> ? T_22 extends {
|
|
2096
|
+
readonly kind: "result";
|
|
2097
|
+
} ? T_22 : never : never : never) extends (infer T_23) ? T_23 extends (MetadataOf<TLeft> extends (infer T_24) ? T_24 extends MetadataOf<TLeft> ? T_24 extends {
|
|
2098
|
+
readonly kind: "result";
|
|
2099
|
+
} ? T_24 : never : never : never) ? T_23 extends {
|
|
2100
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2101
|
+
} ? TSqlType : SqlUnknown : never : never>>)>, (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_25) ? T_25 extends MetadataOf<TLeft> ? T_25 extends {
|
|
2102
|
+
readonly kind: "result";
|
|
2103
|
+
} ? T_25 : never : never : never) extends (infer T_26) ? T_26 extends (MetadataOf<TLeft> extends (infer T_27) ? T_27 extends MetadataOf<TLeft> ? T_27 extends {
|
|
2104
|
+
readonly kind: "result";
|
|
2105
|
+
} ? T_27 : never : never : never) ? T_26 extends {
|
|
2106
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2107
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_28) ? T_28 extends MetadataOf<TLeft> ? T_28 extends {
|
|
2108
|
+
readonly kind: "result";
|
|
2109
|
+
} ? T_28 : never : never : never) extends (infer T_29) ? T_29 extends (MetadataOf<TLeft> extends (infer T_30) ? T_30 extends MetadataOf<TLeft> ? T_30 extends {
|
|
2110
|
+
readonly kind: "result";
|
|
2111
|
+
} ? T_30 : never : never : never) ? T_29 extends {
|
|
2112
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2113
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_31) ? T_31 extends MetadataOf<TLeft> ? T_31 extends {
|
|
2114
|
+
readonly kind: "result";
|
|
2115
|
+
} ? T_31 : never : never : never) extends (infer T_32) ? T_32 extends (MetadataOf<TLeft> extends (infer T_33) ? T_33 extends MetadataOf<TLeft> ? T_33 extends {
|
|
2116
|
+
readonly kind: "result";
|
|
2117
|
+
} ? T_33 : never : never : never) ? T_32 extends {
|
|
2118
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2119
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_34) ? T_34 extends MetadataOf<TLeft> ? T_34 extends {
|
|
2120
|
+
readonly kind: "result";
|
|
2121
|
+
} ? T_34 : never : never : never) extends (infer T_35) ? T_35 extends (MetadataOf<TLeft> extends (infer T_36) ? T_36 extends MetadataOf<TLeft> ? T_36 extends {
|
|
2122
|
+
readonly kind: "result";
|
|
2123
|
+
} ? T_36 : never : never : never) ? T_35 extends {
|
|
2124
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2125
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_37) ? T_37 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_38) ? T_38 extends MetadataOf<TLeft> ? T_38 extends {
|
|
2126
|
+
readonly kind: "result";
|
|
2127
|
+
} ? T_38 : never : never : never) extends (infer T_39) ? T_39 extends (MetadataOf<TLeft> extends (infer T_40) ? T_40 extends MetadataOf<TLeft> ? T_40 extends {
|
|
2128
|
+
readonly kind: "result";
|
|
2129
|
+
} ? T_40 : never : never : never) ? T_39 extends {
|
|
2130
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2131
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_41) ? T_41 extends MetadataOf<TLeft> ? T_41 extends {
|
|
2132
|
+
readonly kind: "result";
|
|
2133
|
+
} ? T_41 : never : never : never) extends (infer T_42) ? T_42 extends (MetadataOf<TLeft> extends (infer T_43) ? T_43 extends MetadataOf<TLeft> ? T_43 extends {
|
|
2134
|
+
readonly kind: "result";
|
|
2135
|
+
} ? T_43 : never : never : never) ? T_42 extends {
|
|
2136
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2137
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_44) ? T_44 extends MetadataOf<TLeft> ? T_44 extends {
|
|
2138
|
+
readonly kind: "result";
|
|
2139
|
+
} ? T_44 : never : never : never) extends (infer T_45) ? T_45 extends (MetadataOf<TLeft> extends (infer T_46) ? T_46 extends MetadataOf<TLeft> ? T_46 extends {
|
|
2140
|
+
readonly kind: "result";
|
|
2141
|
+
} ? T_46 : never : never : never) ? T_45 extends {
|
|
2142
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2143
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_47) ? T_47 extends MetadataOf<TLeft> ? T_47 extends {
|
|
2144
|
+
readonly kind: "result";
|
|
2145
|
+
} ? T_47 : never : never : never) extends (infer T_48) ? T_48 extends (MetadataOf<TLeft> extends (infer T_49) ? T_49 extends MetadataOf<TLeft> ? T_49 extends {
|
|
2146
|
+
readonly kind: "result";
|
|
2147
|
+
} ? T_49 : never : never : never) ? T_48 extends {
|
|
2148
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2149
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_37 extends {
|
|
2150
|
+
readonly kind: "result";
|
|
2151
|
+
} ? T_37 : never : never : never) extends (infer T_50) ? T_50 extends (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_51) ? T_51 extends MetadataOf<TLeft> ? T_51 extends {
|
|
2152
|
+
readonly kind: "result";
|
|
2153
|
+
} ? T_51 : never : never : never) extends (infer T_52) ? T_52 extends (MetadataOf<TLeft> extends (infer T_53) ? T_53 extends MetadataOf<TLeft> ? T_53 extends {
|
|
2154
|
+
readonly kind: "result";
|
|
2155
|
+
} ? T_53 : never : never : never) ? T_52 extends {
|
|
2156
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2157
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_54) ? T_54 extends MetadataOf<TLeft> ? T_54 extends {
|
|
2158
|
+
readonly kind: "result";
|
|
2159
|
+
} ? T_54 : never : never : never) extends (infer T_55) ? T_55 extends (MetadataOf<TLeft> extends (infer T_56) ? T_56 extends MetadataOf<TLeft> ? T_56 extends {
|
|
2160
|
+
readonly kind: "result";
|
|
2161
|
+
} ? T_56 : never : never : never) ? T_55 extends {
|
|
2162
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2163
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_57) ? T_57 extends MetadataOf<TLeft> ? T_57 extends {
|
|
2164
|
+
readonly kind: "result";
|
|
2165
|
+
} ? T_57 : never : never : never) extends (infer T_58) ? T_58 extends (MetadataOf<TLeft> extends (infer T_59) ? T_59 extends MetadataOf<TLeft> ? T_59 extends {
|
|
2166
|
+
readonly kind: "result";
|
|
2167
|
+
} ? T_59 : never : never : never) ? T_58 extends {
|
|
2168
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2169
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_60) ? T_60 extends MetadataOf<TLeft> ? T_60 extends {
|
|
2170
|
+
readonly kind: "result";
|
|
2171
|
+
} ? T_60 : never : never : never) extends (infer T_61) ? T_61 extends (MetadataOf<TLeft> extends (infer T_62) ? T_62 extends MetadataOf<TLeft> ? T_62 extends {
|
|
2172
|
+
readonly kind: "result";
|
|
2173
|
+
} ? T_62 : never : never : never) ? T_61 extends {
|
|
2174
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2175
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_63) ? T_63 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_64) ? T_64 extends MetadataOf<TLeft> ? T_64 extends {
|
|
2176
|
+
readonly kind: "result";
|
|
2177
|
+
} ? T_64 : never : never : never) extends (infer T_65) ? T_65 extends (MetadataOf<TLeft> extends (infer T_66) ? T_66 extends MetadataOf<TLeft> ? T_66 extends {
|
|
2178
|
+
readonly kind: "result";
|
|
2179
|
+
} ? T_66 : never : never : never) ? T_65 extends {
|
|
2180
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2181
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_67) ? T_67 extends MetadataOf<TLeft> ? T_67 extends {
|
|
2182
|
+
readonly kind: "result";
|
|
2183
|
+
} ? T_67 : never : never : never) extends (infer T_68) ? T_68 extends (MetadataOf<TLeft> extends (infer T_69) ? T_69 extends MetadataOf<TLeft> ? T_69 extends {
|
|
2184
|
+
readonly kind: "result";
|
|
2185
|
+
} ? T_69 : never : never : never) ? T_68 extends {
|
|
2186
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2187
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_70) ? T_70 extends MetadataOf<TLeft> ? T_70 extends {
|
|
2188
|
+
readonly kind: "result";
|
|
2189
|
+
} ? T_70 : never : never : never) extends (infer T_71) ? T_71 extends (MetadataOf<TLeft> extends (infer T_72) ? T_72 extends MetadataOf<TLeft> ? T_72 extends {
|
|
2190
|
+
readonly kind: "result";
|
|
2191
|
+
} ? T_72 : never : never : never) ? T_71 extends {
|
|
2192
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2193
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_73) ? T_73 extends MetadataOf<TLeft> ? T_73 extends {
|
|
2194
|
+
readonly kind: "result";
|
|
2195
|
+
} ? T_73 : never : never : never) extends (infer T_74) ? T_74 extends (MetadataOf<TLeft> extends (infer T_75) ? T_75 extends MetadataOf<TLeft> ? T_75 extends {
|
|
2196
|
+
readonly kind: "result";
|
|
2197
|
+
} ? T_75 : never : never : never) ? T_74 extends {
|
|
2198
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2199
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_63 extends {
|
|
2200
|
+
readonly kind: "result";
|
|
2201
|
+
} ? T_63 : never : never : never) ? T_50 extends {
|
|
2202
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2203
|
+
} ? TSqlType : SqlUnknown : never : never>;
|
|
2204
|
+
declare const modulo: <T, TLeft extends ExpressionWithOutput<T>, R extends Operand<NoInfer<T>>>(left: TLeft & ArithmeticValidation<TLeft, R>, right: R) => ResultExpression<unknown, R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_1) ? T_1 extends MetadataOf<TLeft> ? T_1 extends {
|
|
2205
|
+
readonly kind: "result";
|
|
2206
|
+
} ? T_1 : never : never : never) extends (infer T_2) ? T_2 extends (MetadataOf<TLeft> extends (infer T_3) ? T_3 extends MetadataOf<TLeft> ? T_3 extends {
|
|
2207
|
+
readonly kind: "result";
|
|
2208
|
+
} ? T_3 : never : never : never) ? T_2 extends {
|
|
2209
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2210
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_4) ? T_4 extends MetadataOf<TLeft> ? T_4 extends {
|
|
2211
|
+
readonly kind: "result";
|
|
2212
|
+
} ? T_4 : never : never : never) extends (infer T_5) ? T_5 extends (MetadataOf<TLeft> extends (infer T_6) ? T_6 extends MetadataOf<TLeft> ? T_6 extends {
|
|
2213
|
+
readonly kind: "result";
|
|
2214
|
+
} ? T_6 : never : never : never) ? T_5 extends {
|
|
2215
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2216
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_7) ? T_7 extends MetadataOf<TLeft> ? T_7 extends {
|
|
2217
|
+
readonly kind: "result";
|
|
2218
|
+
} ? T_7 : never : never : never) extends (infer T_8) ? T_8 extends (MetadataOf<TLeft> extends (infer T_9) ? T_9 extends MetadataOf<TLeft> ? T_9 extends {
|
|
2219
|
+
readonly kind: "result";
|
|
2220
|
+
} ? T_9 : never : never : never) ? T_8 extends {
|
|
2221
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2222
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_10) ? T_10 extends MetadataOf<TLeft> ? T_10 extends {
|
|
2223
|
+
readonly kind: "result";
|
|
2224
|
+
} ? T_10 : never : never : never) extends (infer T_11) ? T_11 extends (MetadataOf<TLeft> extends (infer T_12) ? T_12 extends MetadataOf<TLeft> ? T_12 extends {
|
|
2225
|
+
readonly kind: "result";
|
|
2226
|
+
} ? T_12 : never : never : never) ? T_11 extends {
|
|
2227
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2228
|
+
} ? TSqlType : SqlUnknown : never : never>>), "operator", NullabilityOf<R | (TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_13) ? T_13 extends MetadataOf<TLeft> ? T_13 extends {
|
|
2229
|
+
readonly kind: "result";
|
|
2230
|
+
} ? T_13 : never : never : never) extends (infer T_14) ? T_14 extends (MetadataOf<TLeft> extends (infer T_15) ? T_15 extends MetadataOf<TLeft> ? T_15 extends {
|
|
2231
|
+
readonly kind: "result";
|
|
2232
|
+
} ? T_15 : never : never : never) ? T_14 extends {
|
|
2233
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2234
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_16) ? T_16 extends MetadataOf<TLeft> ? T_16 extends {
|
|
2235
|
+
readonly kind: "result";
|
|
2236
|
+
} ? T_16 : never : never : never) extends (infer T_17) ? T_17 extends (MetadataOf<TLeft> extends (infer T_18) ? T_18 extends MetadataOf<TLeft> ? T_18 extends {
|
|
2237
|
+
readonly kind: "result";
|
|
2238
|
+
} ? T_18 : never : never : never) ? T_17 extends {
|
|
2239
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2240
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_19) ? T_19 extends MetadataOf<TLeft> ? T_19 extends {
|
|
2241
|
+
readonly kind: "result";
|
|
2242
|
+
} ? T_19 : never : never : never) extends (infer T_20) ? T_20 extends (MetadataOf<TLeft> extends (infer T_21) ? T_21 extends MetadataOf<TLeft> ? T_21 extends {
|
|
2243
|
+
readonly kind: "result";
|
|
2244
|
+
} ? T_21 : never : never : never) ? T_20 extends {
|
|
2245
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2246
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_22) ? T_22 extends MetadataOf<TLeft> ? T_22 extends {
|
|
2247
|
+
readonly kind: "result";
|
|
2248
|
+
} ? T_22 : never : never : never) extends (infer T_23) ? T_23 extends (MetadataOf<TLeft> extends (infer T_24) ? T_24 extends MetadataOf<TLeft> ? T_24 extends {
|
|
2249
|
+
readonly kind: "result";
|
|
2250
|
+
} ? T_24 : never : never : never) ? T_23 extends {
|
|
2251
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2252
|
+
} ? TSqlType : SqlUnknown : never : never>>)>, (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_25) ? T_25 extends MetadataOf<TLeft> ? T_25 extends {
|
|
2253
|
+
readonly kind: "result";
|
|
2254
|
+
} ? T_25 : never : never : never) extends (infer T_26) ? T_26 extends (MetadataOf<TLeft> extends (infer T_27) ? T_27 extends MetadataOf<TLeft> ? T_27 extends {
|
|
2255
|
+
readonly kind: "result";
|
|
2256
|
+
} ? T_27 : never : never : never) ? T_26 extends {
|
|
2257
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2258
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_28) ? T_28 extends MetadataOf<TLeft> ? T_28 extends {
|
|
2259
|
+
readonly kind: "result";
|
|
2260
|
+
} ? T_28 : never : never : never) extends (infer T_29) ? T_29 extends (MetadataOf<TLeft> extends (infer T_30) ? T_30 extends MetadataOf<TLeft> ? T_30 extends {
|
|
2261
|
+
readonly kind: "result";
|
|
2262
|
+
} ? T_30 : never : never : never) ? T_29 extends {
|
|
2263
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2264
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_31) ? T_31 extends MetadataOf<TLeft> ? T_31 extends {
|
|
2265
|
+
readonly kind: "result";
|
|
2266
|
+
} ? T_31 : never : never : never) extends (infer T_32) ? T_32 extends (MetadataOf<TLeft> extends (infer T_33) ? T_33 extends MetadataOf<TLeft> ? T_33 extends {
|
|
2267
|
+
readonly kind: "result";
|
|
2268
|
+
} ? T_33 : never : never : never) ? T_32 extends {
|
|
2269
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2270
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_34) ? T_34 extends MetadataOf<TLeft> ? T_34 extends {
|
|
2271
|
+
readonly kind: "result";
|
|
2272
|
+
} ? T_34 : never : never : never) extends (infer T_35) ? T_35 extends (MetadataOf<TLeft> extends (infer T_36) ? T_36 extends MetadataOf<TLeft> ? T_36 extends {
|
|
2273
|
+
readonly kind: "result";
|
|
2274
|
+
} ? T_36 : never : never : never) ? T_35 extends {
|
|
2275
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2276
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_37) ? T_37 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_38) ? T_38 extends MetadataOf<TLeft> ? T_38 extends {
|
|
2277
|
+
readonly kind: "result";
|
|
2278
|
+
} ? T_38 : never : never : never) extends (infer T_39) ? T_39 extends (MetadataOf<TLeft> extends (infer T_40) ? T_40 extends MetadataOf<TLeft> ? T_40 extends {
|
|
2279
|
+
readonly kind: "result";
|
|
2280
|
+
} ? T_40 : never : never : never) ? T_39 extends {
|
|
2281
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2282
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_41) ? T_41 extends MetadataOf<TLeft> ? T_41 extends {
|
|
2283
|
+
readonly kind: "result";
|
|
2284
|
+
} ? T_41 : never : never : never) extends (infer T_42) ? T_42 extends (MetadataOf<TLeft> extends (infer T_43) ? T_43 extends MetadataOf<TLeft> ? T_43 extends {
|
|
2285
|
+
readonly kind: "result";
|
|
2286
|
+
} ? T_43 : never : never : never) ? T_42 extends {
|
|
2287
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2288
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_44) ? T_44 extends MetadataOf<TLeft> ? T_44 extends {
|
|
2289
|
+
readonly kind: "result";
|
|
2290
|
+
} ? T_44 : never : never : never) extends (infer T_45) ? T_45 extends (MetadataOf<TLeft> extends (infer T_46) ? T_46 extends MetadataOf<TLeft> ? T_46 extends {
|
|
2291
|
+
readonly kind: "result";
|
|
2292
|
+
} ? T_46 : never : never : never) ? T_45 extends {
|
|
2293
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2294
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_47) ? T_47 extends MetadataOf<TLeft> ? T_47 extends {
|
|
2295
|
+
readonly kind: "result";
|
|
2296
|
+
} ? T_47 : never : never : never) extends (infer T_48) ? T_48 extends (MetadataOf<TLeft> extends (infer T_49) ? T_49 extends MetadataOf<TLeft> ? T_49 extends {
|
|
2297
|
+
readonly kind: "result";
|
|
2298
|
+
} ? T_49 : never : never : never) ? T_48 extends {
|
|
2299
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2300
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_37 extends {
|
|
2301
|
+
readonly kind: "result";
|
|
2302
|
+
} ? T_37 : never : never : never) extends (infer T_50) ? T_50 extends (MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_51) ? T_51 extends MetadataOf<TLeft> ? T_51 extends {
|
|
2303
|
+
readonly kind: "result";
|
|
2304
|
+
} ? T_51 : never : never : never) extends (infer T_52) ? T_52 extends (MetadataOf<TLeft> extends (infer T_53) ? T_53 extends MetadataOf<TLeft> ? T_53 extends {
|
|
2305
|
+
readonly kind: "result";
|
|
2306
|
+
} ? T_53 : never : never : never) ? T_52 extends {
|
|
2307
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2308
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_54) ? T_54 extends MetadataOf<TLeft> ? T_54 extends {
|
|
2309
|
+
readonly kind: "result";
|
|
2310
|
+
} ? T_54 : never : never : never) extends (infer T_55) ? T_55 extends (MetadataOf<TLeft> extends (infer T_56) ? T_56 extends MetadataOf<TLeft> ? T_56 extends {
|
|
2311
|
+
readonly kind: "result";
|
|
2312
|
+
} ? T_56 : never : never : never) ? T_55 extends {
|
|
2313
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2314
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_57) ? T_57 extends MetadataOf<TLeft> ? T_57 extends {
|
|
2315
|
+
readonly kind: "result";
|
|
2316
|
+
} ? T_57 : never : never : never) extends (infer T_58) ? T_58 extends (MetadataOf<TLeft> extends (infer T_59) ? T_59 extends MetadataOf<TLeft> ? T_59 extends {
|
|
2317
|
+
readonly kind: "result";
|
|
2318
|
+
} ? T_59 : never : never : never) ? T_58 extends {
|
|
2319
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2320
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_60) ? T_60 extends MetadataOf<TLeft> ? T_60 extends {
|
|
2321
|
+
readonly kind: "result";
|
|
2322
|
+
} ? T_60 : never : never : never) extends (infer T_61) ? T_61 extends (MetadataOf<TLeft> extends (infer T_62) ? T_62 extends MetadataOf<TLeft> ? T_62 extends {
|
|
2323
|
+
readonly kind: "result";
|
|
2324
|
+
} ? T_62 : never : never : never) ? T_61 extends {
|
|
2325
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2326
|
+
} ? TSqlType : SqlUnknown : never : never>>> extends (infer T_63) ? T_63 extends MetadataOf<TLeft & SqlCapabilityValidation<(MetadataOf<TLeft> extends (infer T_64) ? T_64 extends MetadataOf<TLeft> ? T_64 extends {
|
|
2327
|
+
readonly kind: "result";
|
|
2328
|
+
} ? T_64 : never : never : never) extends (infer T_65) ? T_65 extends (MetadataOf<TLeft> extends (infer T_66) ? T_66 extends MetadataOf<TLeft> ? T_66 extends {
|
|
2329
|
+
readonly kind: "result";
|
|
2330
|
+
} ? T_66 : never : never : never) ? T_65 extends {
|
|
2331
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2332
|
+
} ? TSqlType : SqlUnknown : never : never, SqlNumericLike> & SqlCapabilityValidation<OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_67) ? T_67 extends MetadataOf<TLeft> ? T_67 extends {
|
|
2333
|
+
readonly kind: "result";
|
|
2334
|
+
} ? T_67 : never : never : never) extends (infer T_68) ? T_68 extends (MetadataOf<TLeft> extends (infer T_69) ? T_69 extends MetadataOf<TLeft> ? T_69 extends {
|
|
2335
|
+
readonly kind: "result";
|
|
2336
|
+
} ? T_69 : never : never : never) ? T_68 extends {
|
|
2337
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2338
|
+
} ? TSqlType : SqlUnknown : never : never>, SqlNumericLike> & SqlOrderValidation<(MetadataOf<TLeft> extends (infer T_70) ? T_70 extends MetadataOf<TLeft> ? T_70 extends {
|
|
2339
|
+
readonly kind: "result";
|
|
2340
|
+
} ? T_70 : never : never : never) extends (infer T_71) ? T_71 extends (MetadataOf<TLeft> extends (infer T_72) ? T_72 extends MetadataOf<TLeft> ? T_72 extends {
|
|
2341
|
+
readonly kind: "result";
|
|
2342
|
+
} ? T_72 : never : never : never) ? T_71 extends {
|
|
2343
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2344
|
+
} ? TSqlType : SqlUnknown : never : never, OperandSqlType<R, (MetadataOf<TLeft> extends (infer T_73) ? T_73 extends MetadataOf<TLeft> ? T_73 extends {
|
|
2345
|
+
readonly kind: "result";
|
|
2346
|
+
} ? T_73 : never : never : never) extends (infer T_74) ? T_74 extends (MetadataOf<TLeft> extends (infer T_75) ? T_75 extends MetadataOf<TLeft> ? T_75 extends {
|
|
2347
|
+
readonly kind: "result";
|
|
2348
|
+
} ? T_75 : never : never : never) ? T_74 extends {
|
|
2349
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2350
|
+
} ? TSqlType : SqlUnknown : never : never>>> ? T_63 extends {
|
|
2351
|
+
readonly kind: "result";
|
|
2352
|
+
} ? T_63 : never : never : never) ? T_50 extends {
|
|
2353
|
+
readonly sqlType: infer TSqlType extends AnySqlType;
|
|
2354
|
+
} ? TSqlType : SqlUnknown : never : never>;
|
|
2355
|
+
//#endregion
|
|
2356
|
+
//#region src/query/clauses/types.d.ts
|
|
2357
|
+
type ClausePlacement = 'before-select' | 'after-select';
|
|
2358
|
+
interface SelectClause<TMetadata = any> extends Fragment<TMetadata> {
|
|
2359
|
+
readonly clauseKind: string;
|
|
2360
|
+
readonly placement: ClausePlacement;
|
|
2361
|
+
readonly order: number;
|
|
2362
|
+
}
|
|
2363
|
+
type AnySelectClause = SelectClause<any>;
|
|
2364
|
+
//#endregion
|
|
2365
|
+
//#region src/query/clauses/distinct.d.ts
|
|
2366
|
+
interface DistinctClause extends SelectClause<never> {
|
|
2367
|
+
readonly clauseKind: 'distinct';
|
|
2368
|
+
}
|
|
2369
|
+
declare function distinct(): DistinctClause;
|
|
2370
|
+
//#endregion
|
|
2371
|
+
//#region src/query/clauses/having.d.ts
|
|
2372
|
+
interface HavingClause<TMetadata = never> extends SelectClause<TMetadata> {
|
|
2373
|
+
readonly clauseKind: 'having';
|
|
2374
|
+
readonly condition: BooleanExpression<any>;
|
|
2375
|
+
}
|
|
2376
|
+
type HavingComposition<TCondition extends BooleanExpression<any> | Omit$1> = TCondition extends Omit$1 ? Omit$1 : TCondition extends BooleanExpression<any> ? HavingClause<InheritedMetadata<TCondition>> : never;
|
|
2377
|
+
type HavingValidation<TCondition> = TCondition extends Omit$1 ? unknown : SqlCapabilityValidation<ExpressionSqlType<TCondition>, SqlBoolean>;
|
|
2378
|
+
declare function having<TCondition extends BooleanExpression<any> | Omit$1>(condition: TCondition & HavingValidation<TCondition>): HavingComposition<TCondition>;
|
|
2379
|
+
//#endregion
|
|
2380
|
+
//#region src/query/clauses/pagination.d.ts
|
|
2381
|
+
interface OffsetClause extends SelectClause<never> {
|
|
2382
|
+
readonly clauseKind: 'offset';
|
|
2383
|
+
readonly rows: number;
|
|
2384
|
+
}
|
|
2385
|
+
type AnyPaginationClause = OffsetClause | FetchClause;
|
|
2386
|
+
declare function offset(rows: number): OffsetClause;
|
|
2387
|
+
interface FetchClause<TRows extends number = number> extends SelectClause<never> {
|
|
2388
|
+
readonly clauseKind: 'fetch';
|
|
2389
|
+
readonly direction: 'FIRST' | 'NEXT';
|
|
2390
|
+
readonly rows: TRows;
|
|
2391
|
+
}
|
|
2392
|
+
declare function fetchFirst<const TRows extends number>(rows: TRows): FetchClause<TRows>;
|
|
2393
|
+
declare function fetchNext<const TRows extends number>(rows: TRows): FetchClause<TRows>;
|
|
2394
|
+
//#endregion
|
|
2395
|
+
//#region src/query/clauses/row-lock.d.ts
|
|
2396
|
+
interface RowLockOptions<TMode extends RowLockMode = RowLockMode, TWait extends RowLockWaitPolicy = RowLockWaitPolicy> {
|
|
2397
|
+
readonly mode?: TMode;
|
|
2398
|
+
readonly wait?: TWait;
|
|
2399
|
+
readonly waitPolicy?: TWait;
|
|
2400
|
+
}
|
|
2401
|
+
interface RowLockClause<TMode extends RowLockMode = RowLockMode, TWait extends RowLockWaitPolicy = RowLockWaitPolicy> extends SelectClause<RequiresCapabilityMeta<'row-locking'>> {
|
|
2402
|
+
readonly clauseKind: 'row-lock';
|
|
2403
|
+
readonly mode: TMode;
|
|
2404
|
+
readonly wait: TWait;
|
|
2405
|
+
}
|
|
2406
|
+
declare function rowLock(): RowLockClause<'update', 'default'>;
|
|
2407
|
+
declare function rowLock<TMode extends RowLockMode>(mode: TMode): RowLockClause<TMode, 'default'>;
|
|
2408
|
+
declare function rowLock<TMode extends RowLockMode, TWait extends RowLockWaitPolicy>(mode: TMode, wait: TWait): RowLockClause<TMode, TWait>;
|
|
2409
|
+
declare function rowLock(options: RowLockOptions): RowLockClause;
|
|
2410
|
+
//#endregion
|
|
2411
|
+
//#region src/query/clauses/where.d.ts
|
|
2412
|
+
interface WhereClause<TMetadata = never> extends SelectClause<TMetadata> {
|
|
2413
|
+
readonly clauseKind: 'where';
|
|
2414
|
+
readonly condition: BooleanExpression<any>;
|
|
2415
|
+
}
|
|
2416
|
+
type WhereComposition<TCondition extends BooleanExpression<any> | Omit$1> = TCondition extends Omit$1 ? Omit$1 : TCondition extends BooleanExpression<any> ? WhereClause<InheritedMetadata<TCondition>> : never;
|
|
2417
|
+
type WhereValidation<TCondition> = TCondition extends Omit$1 ? unknown : SqlCapabilityValidation<ExpressionSqlType<TCondition>, SqlBoolean>;
|
|
2418
|
+
declare function where<TCondition extends BooleanExpression<any> | Omit$1>(condition: TCondition & WhereValidation<TCondition>): WhereComposition<TCondition>;
|
|
2419
|
+
//#endregion
|
|
2420
|
+
//#region src/query/omit.d.ts
|
|
2421
|
+
/** An explicit placeholder for a safely omitted SELECT clause or projection field. */
|
|
2422
|
+
declare const omit: unique symbol;
|
|
2423
|
+
type Omit$1 = typeof omit;
|
|
2424
|
+
type OmittableSelectClause = DistinctClause | HavingClause<any> | OrderByClause<any> | OffsetClause | FetchClause | RowLockClause | WhereClause<any>;
|
|
2425
|
+
type SelectPart = AnySelectClause | Omit$1;
|
|
2426
|
+
type PresentClauses<TParts extends readonly SelectPart[]> = { readonly [TIndex in keyof TParts]: Exclude<TParts[TIndex], Omit$1>; };
|
|
2427
|
+
type InvalidOmittedClauses<TParts extends readonly SelectPart[]> = { [TIndex in keyof TParts]: Omit$1 extends TParts[TIndex] ? Exclude<TParts[TIndex], Omit$1> extends OmittableSelectClause ? never : Exclude<TParts[TIndex], Omit$1> : never; }[number];
|
|
2428
|
+
type OmissionValidation<TParts extends readonly SelectPart[]> = [InvalidOmittedClauses<TParts>] extends [never] ? unknown : QueryTypeValidation<'invalid-omission', 'select.omit', 'Use omit only for a conditional SELECT clause or projection field.', InvalidOmittedClauses<TParts>>;
|
|
2429
|
+
//#endregion
|
|
2430
|
+
//#region src/expressions/operators/logic.d.ts
|
|
2431
|
+
type BooleanOperand = BooleanExpression<any> | Omit$1;
|
|
2432
|
+
type PresentConditions<TConditions extends readonly BooleanOperand[]> = Exclude<TConditions[number], Omit$1>;
|
|
2433
|
+
type BooleanComposition<TConditions extends readonly BooleanOperand[]> = [PresentConditions<TConditions>] extends [never] ? Omit$1 : ResultExpression<boolean, PresentConditions<TConditions>, 'operator', NullabilityOf<PresentConditions<TConditions>>, SqlBoolean> | (Omit$1 extends TConditions[number] ? Omit$1 : never);
|
|
2434
|
+
type BooleanConditionsValidation<TConditions extends readonly unknown[]> = TConditions extends readonly [infer THead, ...infer TTail] ? (THead extends Omit$1 ? unknown : SqlCapabilityValidation<ExpressionSqlType<THead>, SqlBoolean>) & BooleanConditionsValidation<TTail> : unknown;
|
|
2435
|
+
declare function and<const TConditions extends readonly BooleanOperand[]>(...conditions: TConditions & BooleanConditionsValidation<TConditions>): BooleanComposition<TConditions>;
|
|
2436
|
+
declare function or<const TConditions extends readonly BooleanOperand[]>(...conditions: TConditions & BooleanConditionsValidation<TConditions>): BooleanComposition<TConditions>;
|
|
2437
|
+
declare function not<TCondition extends BooleanExpression<any>>(condition: TCondition & SqlCapabilityValidation<ExpressionSqlType<TCondition>, SqlBoolean>): ResultExpression<boolean, TCondition, "operator", NullabilityOf<TCondition>, SqlBoolean>;
|
|
2438
|
+
//#endregion
|
|
2439
|
+
//#region src/schema/alias.d.ts
|
|
2440
|
+
type SourceIndexes$1<T> = T extends {
|
|
2441
|
+
readonly indexes: infer TIndexes extends SourceIndexesRecord;
|
|
2442
|
+
} ? TIndexes : {};
|
|
2443
|
+
type AliasIdentity<TBase, TAlias extends string> = {
|
|
2444
|
+
readonly sourceKind: 'alias';
|
|
2445
|
+
readonly alias: TAlias;
|
|
2446
|
+
readonly base: TBase;
|
|
2447
|
+
};
|
|
2448
|
+
type AliasedSource<TBase extends Source<any, any, any, any, any>, TAlias extends string> = Source<AliasIdentity<SourceIdentity<TBase>, TAlias>, SourceRow<TBase>, RequiresOuterMetadataOf<TBase> | CapabilityMetadataOf<TBase>, SourceSqlTypeMap<TBase>, SourceConstraints<TBase>> & {
|
|
2449
|
+
readonly alias: TAlias;
|
|
2450
|
+
readonly base: TBase;
|
|
2451
|
+
readonly columns: SourceColumns<SourceRow<TBase>, AliasIdentity<SourceIdentity<TBase>, TAlias>, SourceSqlTypeMap<TBase>>;
|
|
2452
|
+
readonly constraints: SourceConstraints<TBase>;
|
|
2453
|
+
readonly indexes: SourceIndexes$1<TBase>;
|
|
2454
|
+
} & SourceColumns<SourceRow<TBase>, AliasIdentity<SourceIdentity<TBase>, TAlias>, SourceSqlTypeMap<TBase>>;
|
|
2455
|
+
type QueryAliasIdentity<TAlias extends string> = {
|
|
2456
|
+
readonly sourceKind: 'query-alias';
|
|
2457
|
+
readonly alias: TAlias;
|
|
2458
|
+
};
|
|
2459
|
+
type QuerySource<TRow extends object, TAlias extends string, TMetadata = never, TSqlTypes extends SourceSqlTypes<TRow> = UnknownSourceSqlTypes<TRow>> = Source<QueryAliasIdentity<TAlias>, TRow, TMetadata, TSqlTypes> & {
|
|
2460
|
+
readonly alias: TAlias;
|
|
2461
|
+
readonly query: Query<TRow, any, TMetadata, TSqlTypes>;
|
|
2462
|
+
readonly columns: SourceColumns<TRow, QueryAliasIdentity<TAlias>, TSqlTypes>;
|
|
2463
|
+
} & SourceColumns<TRow, QueryAliasIdentity<TAlias>, TSqlTypes>;
|
|
2464
|
+
declare function alias<TBase extends Source<any, any, any, any, any>, const TAlias extends string>(source: TBase, name: TAlias): AliasedSource<TBase, TAlias>;
|
|
2465
|
+
declare function alias<TQuery extends AnyQuery, const TAlias extends string>(query: TQuery, name: TAlias): QuerySource<QueryRow<TQuery>, TAlias, RequiresOuterMetadataOf<TQuery> | CapabilityMetadataOf<TQuery>, QuerySqlTypeMap<TQuery>>;
|
|
2466
|
+
type LateralIdentity<TAlias extends string> = {
|
|
2467
|
+
readonly sourceKind: 'lateral';
|
|
2468
|
+
readonly alias: TAlias;
|
|
2469
|
+
};
|
|
2470
|
+
type LateralSource<TQuery extends AnyQuery, TAlias extends string> = Source<LateralIdentity<TAlias>, QueryRow<TQuery>, RequiresOuterMetadataOf<TQuery> | CapabilityMetadataOf<TQuery>, QuerySqlTypeMap<TQuery>> & {
|
|
2471
|
+
readonly alias: TAlias;
|
|
2472
|
+
readonly query: TQuery;
|
|
2473
|
+
readonly columns: SourceColumns<QueryRow<TQuery>, LateralIdentity<TAlias>, QuerySqlTypeMap<TQuery>>;
|
|
2474
|
+
} & SourceColumns<QueryRow<TQuery>, LateralIdentity<TAlias>, QuerySqlTypeMap<TQuery>>;
|
|
2475
|
+
/** Render a query as a LATERAL source whose outer requirements stay visible. */
|
|
2476
|
+
declare function lateral<TQuery extends AnyQuery, const TAlias extends string>(query: TQuery, name: TAlias): LateralSource<TQuery, TAlias>;
|
|
2477
|
+
//#endregion
|
|
2478
|
+
//#region src/schema/registry.d.ts
|
|
2479
|
+
/** The first naming-policy version used by schema metadata. */
|
|
2480
|
+
declare const schemaNamingPolicyVersion: 1;
|
|
2481
|
+
/** A deterministic policy for names generated from logical schema IDs. */
|
|
2482
|
+
interface SchemaNamingPolicy {
|
|
2483
|
+
/** Versioned policy identifier stored with schema metadata. */
|
|
2484
|
+
readonly version: typeof schemaNamingPolicyVersion;
|
|
2485
|
+
/** Generate a physical table name from a logical table ID. */
|
|
2486
|
+
readonly tableName: (logicalId: string) => string;
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* The built-in naming policy for schema-generated physical names.
|
|
2490
|
+
*
|
|
2491
|
+
* Explicit names supplied to `table()` remain unchanged. The policy is used
|
|
2492
|
+
* by tooling when it needs a physical name for a logical table ID.
|
|
2493
|
+
*/
|
|
2494
|
+
declare const defaultSchemaNamingPolicy: SchemaNamingPolicy;
|
|
2495
|
+
/** A table record accepted by {@link schema}. */
|
|
2496
|
+
type SchemaTableRecord = Readonly<Record<string, AnyTable>>;
|
|
2497
|
+
/** A tuple form that can represent duplicate IDs for diagnostic testing. */
|
|
2498
|
+
type SchemaTableInput = readonly [string, AnyTable];
|
|
2499
|
+
/** Options that apply to a root schema registry. */
|
|
2500
|
+
interface SchemaOptions {
|
|
2501
|
+
/** Physical database namespace used by the schema, such as `public`. */
|
|
2502
|
+
readonly namespace?: string;
|
|
2503
|
+
/** Naming policy metadata used by snapshot tooling for generated names. */
|
|
2504
|
+
readonly namingPolicy?: SchemaNamingPolicy;
|
|
2505
|
+
}
|
|
2506
|
+
/** A physical-name record for one stable registry entry. */
|
|
2507
|
+
interface SchemaTableEntry<TId extends string = string, TTable extends AnyTable = AnyTable> {
|
|
2508
|
+
/** Stable logical ID taken from the schema registry key. */
|
|
2509
|
+
readonly id: TId;
|
|
2510
|
+
/** The query-facing table declaration retained by the registry. */
|
|
2511
|
+
readonly table: TTable;
|
|
2512
|
+
/** Physical SQL name used by the table declaration. */
|
|
2513
|
+
readonly physicalName: string;
|
|
2514
|
+
}
|
|
2515
|
+
type SchemaTableRegistry<TTables extends SchemaTableRecord> = { readonly [K in keyof TTables & string]: SchemaTableEntry<K, TTables[K]>; };
|
|
2516
|
+
type SchemaTableNames<TTables extends SchemaTableRecord> = Readonly<{ [K in keyof TTables & string]: string; }>;
|
|
2517
|
+
/** The root model returned by {@link schema}. */
|
|
2518
|
+
interface Schema<TTables extends SchemaTableRecord = SchemaTableRecord> {
|
|
2519
|
+
readonly schemaKind: 'schema';
|
|
2520
|
+
/** Tables keyed by stable logical ID. */
|
|
2521
|
+
readonly tables: Readonly<TTables>;
|
|
2522
|
+
/** Explicit registry entries with logical and physical identity separated. */
|
|
2523
|
+
readonly registry: SchemaTableRegistry<TTables>;
|
|
2524
|
+
/** Materialized physical names keyed by stable logical ID. */
|
|
2525
|
+
readonly tableNames: SchemaTableNames<TTables>;
|
|
2526
|
+
/** Optional database namespace. */
|
|
2527
|
+
readonly namespace: string | undefined;
|
|
2528
|
+
/** Versioned naming policy used by schema tooling. */
|
|
2529
|
+
readonly namingPolicy: SchemaNamingPolicy;
|
|
2530
|
+
}
|
|
2531
|
+
/** A structured validation finding produced while constructing a schema. */
|
|
2532
|
+
interface SchemaDiagnostic {
|
|
2533
|
+
readonly code: 'invalid-table-id' | 'duplicate-table-id' | 'duplicate-physical-name' | 'invalid-namespace' | 'generated-name-collision';
|
|
2534
|
+
readonly message: string;
|
|
2535
|
+
/** Location of the invalid or conflicting declaration. */
|
|
2536
|
+
readonly path: readonly (string | number)[];
|
|
2537
|
+
/** Other declaration locations involved in a collision, when applicable. */
|
|
2538
|
+
readonly relatedPaths?: readonly (readonly (string | number)[])[];
|
|
2539
|
+
}
|
|
2540
|
+
/** Error thrown when a root schema fails registry or naming validation. */
|
|
2541
|
+
declare class SchemaValidationError extends Error {
|
|
2542
|
+
readonly name = "SchemaValidationError";
|
|
2543
|
+
readonly diagnostics: readonly SchemaDiagnostic[];
|
|
2544
|
+
/** Alias matching validation libraries that call findings "issues". */
|
|
2545
|
+
readonly issues: readonly SchemaDiagnostic[];
|
|
2546
|
+
constructor(diagnostics: readonly SchemaDiagnostic[]);
|
|
2547
|
+
}
|
|
2548
|
+
type EntriesToTables<TEntries extends readonly SchemaTableInput[]> = { readonly [TEntry in TEntries[number] as TEntry[0]]: Extract<TEntries[number], readonly [TEntry[0], AnyTable]>[1]; };
|
|
2549
|
+
/**
|
|
2550
|
+
* Create an immutable root registry keyed by stable logical table IDs.
|
|
2551
|
+
*
|
|
2552
|
+
* The input keys are logical IDs. Each table keeps the physical name already
|
|
2553
|
+
* used by query rendering, so registering a table does not change its row
|
|
2554
|
+
* inference, source identity, or generated SQL. The optional namespace is
|
|
2555
|
+
* metadata for schema tooling and is not added to ordinary query rendering.
|
|
2556
|
+
*
|
|
2557
|
+
* @throws {@link SchemaValidationError} when IDs, physical names, namespaces,
|
|
2558
|
+
* or generated names collide or are invalid.
|
|
2559
|
+
*/
|
|
2560
|
+
declare function schema<const TTables extends SchemaTableRecord>(tables: TTables, options?: SchemaOptions): Schema<TTables>;
|
|
2561
|
+
/**
|
|
2562
|
+
* Tuple input is useful for integrations that need duplicate-ID diagnostics
|
|
2563
|
+
* before converting declarations into an object record.
|
|
2564
|
+
*/
|
|
2565
|
+
declare function schema<const TEntries extends readonly SchemaTableInput[]>(tables: TEntries, options?: SchemaOptions): Schema<EntriesToTables<TEntries>>;
|
|
2566
|
+
/** Generate a v1 physical name for a logical table ID. */
|
|
2567
|
+
declare function generatedTableName(logicalId: string, namingPolicy?: SchemaNamingPolicy): string;
|
|
2568
|
+
//#endregion
|
|
2569
|
+
//#region src/schema/expressions.d.ts
|
|
2570
|
+
/** SQL declaration context in which a schema expression will be emitted. */
|
|
2571
|
+
type SchemaExpressionMode = 'default' | 'generated' | 'check' | 'index';
|
|
2572
|
+
/** Stable error categories for schema-expression validation failures. */
|
|
2573
|
+
type SchemaExpressionErrorCode = 'not-deterministic' | 'unsupported-expression' | 'parameter' | 'unsupported-value' | 'column-not-allowed' | 'dialect-mismatch' | 'invalid-literal';
|
|
2574
|
+
/** Error raised before a schema expression can become persisted SQL. */
|
|
2575
|
+
declare class SchemaExpressionError extends TypeError {
|
|
2576
|
+
readonly code: SchemaExpressionErrorCode;
|
|
2577
|
+
readonly mode?: SchemaExpressionMode;
|
|
2578
|
+
constructor(code: SchemaExpressionErrorCode, message: string, mode?: SchemaExpressionMode);
|
|
2579
|
+
}
|
|
2580
|
+
/**
|
|
2581
|
+
* Restricted rendering surface made available to explicit schema extensions.
|
|
2582
|
+
* `parameter()` is retained for structural compatibility with query
|
|
2583
|
+
* renderers, but always throws; use `literal()` for deterministic values.
|
|
2584
|
+
*/
|
|
2585
|
+
interface SchemaRenderContext extends RenderContext {
|
|
2586
|
+
readonly schemaMode: SchemaExpressionMode;
|
|
2587
|
+
literal(value: unknown): void;
|
|
2588
|
+
readonly renderColumnReference: (columnName: string) => void;
|
|
2589
|
+
}
|
|
2590
|
+
/** Result of schema rendering. The parameter list is always empty. */
|
|
2591
|
+
interface RenderedSchemaExpression {
|
|
2592
|
+
readonly text: string;
|
|
2593
|
+
readonly parameters: readonly [];
|
|
2594
|
+
}
|
|
2595
|
+
/** Options for rendering a branded schema expression. */
|
|
2596
|
+
interface SchemaRenderOptions {
|
|
2597
|
+
readonly mode: SchemaExpressionMode;
|
|
2598
|
+
readonly dialect?: Dialect;
|
|
2599
|
+
}
|
|
2600
|
+
/** Compile-time gate used by schema renderers to reject ordinary query ASTs. */
|
|
2601
|
+
type SchemaExpressionInput<TExpression extends AnyExpression> = TExpression extends AnySchemaExpression ? TExpression : TExpression & {
|
|
2602
|
+
readonly __requires_deterministic_schema_expression__: never;
|
|
2603
|
+
};
|
|
2604
|
+
/** A dialect-tagged raw SQL expression for syntax Qubu does not model. */
|
|
2605
|
+
interface UnsafeSchemaSqlExpression extends SchemaExpression<never, 'unsafe'> {
|
|
2606
|
+
readonly schemaSqlDialect: string;
|
|
2607
|
+
readonly schemaSql: string;
|
|
2608
|
+
}
|
|
2609
|
+
/**
|
|
2610
|
+
* Normalize only line endings. Whitespace, quoting, and every other byte of
|
|
2611
|
+
* a raw schema expression remain under the extension author's control.
|
|
2612
|
+
*/
|
|
2613
|
+
declare function normalizeSchemaSql(sql: string): string;
|
|
2614
|
+
/**
|
|
2615
|
+
* Explicitly opt an audited expression into deterministic schema rendering.
|
|
2616
|
+
* The wrapper does not rewrite the renderer; it records the author's promise
|
|
2617
|
+
* so schema consumers can reject ordinary query extensions by default.
|
|
2618
|
+
*/
|
|
2619
|
+
declare function schemaExpression<TExpression extends AnyExpression>(expression: TExpression): SchemaExpression<MetadataOf<TExpression>, TExpression['expressionKind']>;
|
|
2620
|
+
/**
|
|
2621
|
+
* Define an extension with the restricted schema context. This is the typed
|
|
2622
|
+
* alternative to {@link unsafeSchemaSql} for deterministic custom syntax.
|
|
2623
|
+
*/
|
|
2624
|
+
declare function defineSchemaExpression<TMetadata = never, TKind extends ExpressionKind = 'function'>(kind: TKind, render: (context: SchemaRenderContext) => void): SchemaExpression<TMetadata, TKind>;
|
|
2625
|
+
/**
|
|
2626
|
+
* Create a dialect-specific raw schema expression. The SQL is parameter-free
|
|
2627
|
+
* by contract and is preserved exactly apart from CRLF/CR line-ending
|
|
2628
|
+
* normalization.
|
|
2629
|
+
*/
|
|
2630
|
+
declare function unsafeSchemaSql(dialect: string, sql: string): UnsafeSchemaSqlExpression;
|
|
2631
|
+
declare function unsafeSchemaSql(options: {
|
|
2632
|
+
readonly dialect: string;
|
|
2633
|
+
readonly sql: string;
|
|
2634
|
+
}): UnsafeSchemaSqlExpression;
|
|
2635
|
+
/** Identify a dialect-tagged raw schema expression. */
|
|
2636
|
+
declare function isUnsafeSchemaSql(value: unknown): value is UnsafeSchemaSqlExpression;
|
|
2637
|
+
/** Render a schema expression without ever creating query parameters. */
|
|
2638
|
+
declare function renderSchemaExpression<TExpression extends AnyExpression>(expression: SchemaExpressionInput<TExpression>, options: SchemaRenderOptions): RenderedSchemaExpression;
|
|
2639
|
+
declare function renderSchemaExpression<TExpression extends AnyExpression>(expression: SchemaExpressionInput<TExpression>, mode: SchemaExpressionMode, dialect?: Dialect): RenderedSchemaExpression;
|
|
2640
|
+
/** Convenience form for callers that only need the SQL text. */
|
|
2641
|
+
declare function renderSchemaSql<TExpression extends AnyExpression>(expression: SchemaExpressionInput<TExpression>, options: SchemaRenderOptions): string;
|
|
2642
|
+
//#endregion
|
|
2643
|
+
//#region src/schema/dialect.d.ts
|
|
2644
|
+
/**
|
|
2645
|
+
* Schema-only behavior layered onto a query dialect.
|
|
2646
|
+
*
|
|
2647
|
+
* The query policy is deliberately not repeated here: identifier quoting,
|
|
2648
|
+
* placeholders, JSON, casts, and capability identity all come from the
|
|
2649
|
+
* enclosing {@link SchemaDialect}.
|
|
2650
|
+
*/
|
|
2651
|
+
interface SchemaDialectHooks {
|
|
2652
|
+
/** Version of this dialect's schema metadata extension contract. */
|
|
2653
|
+
readonly version: number;
|
|
2654
|
+
/** Optional executable naming policy retained by snapshot metadata. */
|
|
2655
|
+
readonly namingPolicy?: SnapshotNamingPolicy;
|
|
2656
|
+
/** Validate engine-specific schema facts before common traversal. */
|
|
2657
|
+
readonly validate?: (schema: Schema<any>, context: SnapshotValidationContext) => readonly SnapshotDiagnostic[];
|
|
2658
|
+
/** Encode portable or native physical column storage. */
|
|
2659
|
+
readonly encodeStorage?: (storage: ColumnStorage, context: SnapshotStorageContext) => SnapshotStorage;
|
|
2660
|
+
/** Encode a deterministic expression for its declaration context. */
|
|
2661
|
+
readonly encodeExpression?: (expression: AnyExpression, context: SnapshotExpressionContext) => SnapshotExpression;
|
|
2662
|
+
/** Encode dialect-owned constraint, index, and identity metadata. */
|
|
2663
|
+
readonly encodeDialectExtension?: (extension: SchemaDialectExtension, context: SnapshotExtensionContext) => SnapshotDialectExtension;
|
|
2664
|
+
}
|
|
2665
|
+
/**
|
|
2666
|
+
* A schema dialect is a strict capability superset of a query dialect.
|
|
2667
|
+
*
|
|
2668
|
+
* A schema dialect must be created with {@link createSchemaDialect}; that
|
|
2669
|
+
* helper preserves the exact query rendering object and adds only schema
|
|
2670
|
+
* behavior and snapshot metadata.
|
|
2671
|
+
*/
|
|
2672
|
+
interface SchemaDialect<TCapabilities extends DialectCapability = DialectCapability> extends Dialect<TCapabilities> {
|
|
2673
|
+
readonly schema: SchemaDialectHooks;
|
|
2674
|
+
}
|
|
2675
|
+
/**
|
|
2676
|
+
* Add schema behavior to an existing query dialect without rebuilding any of
|
|
2677
|
+
* its identifier, literal, placeholder, JSON, cast, or capability policies.
|
|
2678
|
+
*/
|
|
2679
|
+
declare function createSchemaDialect<const TCapabilities extends DialectCapability = DialectCapability>(queryDialect: Dialect<TCapabilities>, schema: SchemaDialectHooks): SchemaDialect<TCapabilities>;
|
|
2680
|
+
//#endregion
|
|
2681
|
+
//#region src/query/selection.d.ts
|
|
2682
|
+
/**
|
|
2683
|
+
* Return every known source column as a named projection object.
|
|
2684
|
+
*
|
|
2685
|
+
* The result can be passed directly to `select()` or spread into a larger
|
|
2686
|
+
* projection, such as `{ ...all(users), displayName: upper(users.name) }`.
|
|
2687
|
+
*/
|
|
2688
|
+
declare function all<TSource extends AnySource>(source: TSource): SourceColumns<SourceRow<TSource>, SourceIdentity<TSource>, SourceSqlTypeMap<TSource>>;
|
|
2689
|
+
type SelectionObject = Record<string, AnyExpression | Omit$1>;
|
|
2690
|
+
type Selection = SelectionObject;
|
|
2691
|
+
type SelectionItems<TSelection> = TSelection extends SelectionObject ? Extract<TSelection[keyof TSelection], AnyExpression> : never;
|
|
2692
|
+
type NullableOutput<TOutput, TExpression, TNullableSources> = [Extract<NullabilityOf<TExpression>, TNullableSources>] extends [never] ? TOutput : TOutput | null;
|
|
2693
|
+
type Simplify<T> = { [K in keyof T]: T[K]; } & {};
|
|
2694
|
+
type SelectionExpression<TField> = Extract<TField, AnyExpression>;
|
|
2695
|
+
type RequiredSelectionKeys<TSelection extends SelectionObject> = { [K in keyof TSelection]-?: [SelectionExpression<TSelection[K]>] extends [never] ? never : Omit$1 extends TSelection[K] ? never : K; }[keyof TSelection];
|
|
2696
|
+
type OptionalSelectionKeys<TSelection extends SelectionObject> = { [K in keyof TSelection]-?: [SelectionExpression<TSelection[K]>] extends [never] ? never : Omit$1 extends TSelection[K] ? K : never; }[keyof TSelection];
|
|
2697
|
+
type SelectionFieldOutput<TField, TNullableSources> = SelectionExpression<TField> extends (infer TExpression extends AnyExpression) ? NullableOutput<ExpressionOutput<TExpression>, TExpression, TNullableSources> : never;
|
|
2698
|
+
type SelectionOutput<TSelection, TNullableSources = never> = TSelection extends SelectionObject ? Simplify<{ -readonly [K in RequiredSelectionKeys<TSelection>]: SelectionFieldOutput<TSelection[K], TNullableSources>; } & { -readonly [K in OptionalSelectionKeys<TSelection>]?: SelectionFieldOutput<TSelection[K], TNullableSources>; }> : never;
|
|
2699
|
+
type SelectionRequires<TSelection> = RequiresOf<SelectionItems<TSelection>>;
|
|
2700
|
+
type SelectionMetadata<TSelection> = InheritedMetadata<SelectionItems<TSelection>>;
|
|
2701
|
+
/** SQL result domains retained for each named projection field. */
|
|
2702
|
+
type SelectionSqlTypes<TSelection, TRow extends object = SelectionOutput<TSelection>> = { readonly [K in keyof TRow]: K extends keyof TSelection ? SqlTypeOf<TSelection[K]> : SqlUnknown; };
|
|
2703
|
+
//#endregion
|
|
2704
|
+
//#region src/query/clauses/group-by.d.ts
|
|
2705
|
+
interface GroupByClause<TMetadata = never> extends SelectClause<TMetadata> {
|
|
2706
|
+
readonly clauseKind: 'group-by';
|
|
2707
|
+
readonly expressions: readonly AnyExpression[];
|
|
2708
|
+
}
|
|
2709
|
+
declare function groupBy<const TExpressions extends readonly AnyExpression[]>(...expressions: TExpressions): GroupByClause<GroupingMeta<TExpressions[number], ColumnGroupingDependencies<TExpressions[number]>> | InheritedMetadata<TExpressions[number]>>;
|
|
2710
|
+
//#endregion
|
|
2711
|
+
//#region src/query/clauses/joins.d.ts
|
|
2712
|
+
type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS' | 'NATURAL';
|
|
2713
|
+
interface JoinClause<TSource extends AnySource = AnySource, TMetadata = never> extends SelectClause<TMetadata> {
|
|
2714
|
+
readonly clauseKind: 'join';
|
|
2715
|
+
readonly joinType: JoinType;
|
|
2716
|
+
readonly source: TSource;
|
|
2717
|
+
readonly condition?: BooleanExpression<any>;
|
|
2718
|
+
}
|
|
2719
|
+
declare function innerJoin<TSource extends AnySource, TCondition extends BooleanExpression<any>>(source: TSource, condition: TCondition): JoinClause<TSource, (MetadataOf<TCondition> extends (infer T) ? T extends MetadataOf<TCondition> ? T extends {
|
|
2720
|
+
readonly kind: "result" | "cardinality";
|
|
2721
|
+
} ? never : T : never : never) | Extract<MetadataOf<TSource>, {
|
|
2722
|
+
readonly kind: "requires-outer-source";
|
|
2723
|
+
}> | CapabilityMetadataOf<TSource>>;
|
|
2724
|
+
declare function leftJoin<TSource extends AnySource, TCondition extends BooleanExpression<any>>(source: TSource, condition: TCondition): JoinClause<TSource, (MetadataOf<TCondition> extends (infer T) ? T extends MetadataOf<TCondition> ? T extends {
|
|
2725
|
+
readonly kind: "result" | "cardinality";
|
|
2726
|
+
} ? never : T : never : never) | Extract<MetadataOf<TSource>, {
|
|
2727
|
+
readonly kind: "requires-outer-source";
|
|
2728
|
+
}> | CapabilityMetadataOf<TSource> | NullableSourceMeta<ProvidedSourceIdentity<TSource>>>;
|
|
2729
|
+
declare function rightJoin<TSource extends AnySource, TCondition extends BooleanExpression<any>>(source: TSource, condition: TCondition): JoinClause<TSource, (MetadataOf<TCondition> extends (infer T) ? T extends MetadataOf<TCondition> ? T extends {
|
|
2730
|
+
readonly kind: "result" | "cardinality";
|
|
2731
|
+
} ? never : T : never : never) | Extract<MetadataOf<TSource>, {
|
|
2732
|
+
readonly kind: "requires-outer-source";
|
|
2733
|
+
}> | CapabilityMetadataOf<TSource>>;
|
|
2734
|
+
declare function fullJoin<TSource extends AnySource, TCondition extends BooleanExpression<any>>(source: TSource, condition: TCondition): JoinClause<TSource, (MetadataOf<TCondition> extends (infer T) ? T extends MetadataOf<TCondition> ? T extends {
|
|
2735
|
+
readonly kind: "result" | "cardinality";
|
|
2736
|
+
} ? never : T : never : never) | Extract<MetadataOf<TSource>, {
|
|
2737
|
+
readonly kind: "requires-outer-source";
|
|
2738
|
+
}> | CapabilityMetadataOf<TSource>>;
|
|
2739
|
+
declare function crossJoin<TSource extends AnySource>(source: TSource): JoinClause<TSource, RequiresOuterMetadataOf<TSource> | CapabilityMetadataOf<TSource>>;
|
|
2740
|
+
declare function naturalJoin<TSource extends AnySource>(source: TSource): JoinClause<TSource, RequiresOuterMetadataOf<TSource> | CapabilityMetadataOf<TSource>>;
|
|
2741
|
+
//#endregion
|
|
2742
|
+
//#region src/query/clauses/from.d.ts
|
|
2743
|
+
interface FromClause<TSources extends readonly AnySource[] = readonly AnySource[], TMetadata = RequiresOuterMetadataOf<TSources[number]> | CapabilityMetadataOf<TSources[number]>> extends SelectClause<TMetadata> {
|
|
2744
|
+
readonly clauseKind: 'from';
|
|
2745
|
+
readonly sources: TSources;
|
|
2746
|
+
}
|
|
2747
|
+
declare function from<const TSources extends readonly [AnySource, ...AnySource[]]>(...sources: TSources): FromClause<TSources, RequiresOuterMetadataOf<TSources[number]> | CapabilityMetadataOf<TSources[number]>>;
|
|
2748
|
+
type FromSource<T> = T extends FromClause<infer TSources> ? TSources[number] extends (infer TSource) ? TSource extends Source<any, any, any, any, any> ? [SourceProvision<TSource>] extends [never] ? never : TSource : never : never : never;
|
|
2749
|
+
type FromScope<T> = T extends FromClause<infer TSources> ? ProvidedSourceIdentity<TSources[number]> : never;
|
|
2750
|
+
//#endregion
|
|
2751
|
+
//#region src/query/set.d.ts
|
|
2752
|
+
type SetOperator = 'UNION' | 'UNION ALL' | 'INTERSECT' | 'EXCEPT';
|
|
2753
|
+
interface SetQuery<TRow extends object = Record<string, unknown>, TCardinality extends QueryCardinality = QueryCardinality, TMetadata = never, TSqlTypes = UnknownSourceSqlTypes<TRow>> extends Query<TRow, TCardinality, TMetadata, TSqlTypes> {
|
|
2754
|
+
readonly queryKind: 'set';
|
|
2755
|
+
}
|
|
2756
|
+
type SetSqlCompatibilityFailures<TLeft, TRight> = { [K in keyof QuerySqlTypeMap<TLeft>]: K extends keyof QuerySqlTypeMap<TRight> ? SqlEqualityCompatible<QuerySqlTypeMap<TLeft>[K], QuerySqlTypeMap<TRight>[K]> extends true ? never : K : K; }[keyof QuerySqlTypeMap<TLeft>];
|
|
2757
|
+
type SetSqlValidation<TLeft, TRight> = [SetSqlCompatibilityFailures<TLeft, TRight>] extends [never] ? unknown : QueryTypeValidation<'incompatible-set-domain', 'set-operation.columns', 'Make corresponding set-operation fields use compatible SQL domains.', SetSqlCompatibilityFailures<TLeft, TRight>>;
|
|
2758
|
+
declare function union<TLeft extends Query<any, any, any, any>, TRight extends Query<QueryRow<TLeft>, any, any, any>>(left: TLeft & SetSqlValidation<TLeft, TRight>, right: TRight): SetQuery<QueryRow<TLeft & SetSqlValidation<TLeft, TRight>>, any, CapabilityMetadataOf<TRight | (TLeft & SetSqlValidation<TLeft, TRight>)>, QuerySqlTypeMap<TLeft & SetSqlValidation<TLeft, TRight>>>;
|
|
2759
|
+
declare function unionAll<TLeft extends Query<any, any, any, any>, TRight extends Query<QueryRow<TLeft>, any, any, any>>(left: TLeft & SetSqlValidation<TLeft, TRight>, right: TRight): SetQuery<QueryRow<TLeft & SetSqlValidation<TLeft, TRight>>, any, CapabilityMetadataOf<TRight | (TLeft & SetSqlValidation<TLeft, TRight>)>, QuerySqlTypeMap<TLeft & SetSqlValidation<TLeft, TRight>>>;
|
|
2760
|
+
declare function intersect<TLeft extends Query<any, any, any, any>, TRight extends Query<QueryRow<TLeft>, any, any, any>>(left: TLeft & SetSqlValidation<TLeft, TRight>, right: TRight): SetQuery<QueryRow<TLeft & SetSqlValidation<TLeft, TRight>>, any, CapabilityMetadataOf<TRight | (TLeft & SetSqlValidation<TLeft, TRight>)>, QuerySqlTypeMap<TLeft & SetSqlValidation<TLeft, TRight>>>;
|
|
2761
|
+
declare function except<TLeft extends Query<any, any, any, any>, TRight extends Query<QueryRow<TLeft>, any, any, any>>(left: TLeft & SetSqlValidation<TLeft, TRight>, right: TRight): SetQuery<QueryRow<TLeft & SetSqlValidation<TLeft, TRight>>, any, CapabilityMetadataOf<TRight | (TLeft & SetSqlValidation<TLeft, TRight>)>, QuerySqlTypeMap<TLeft & SetSqlValidation<TLeft, TRight>>>;
|
|
2762
|
+
//#endregion
|
|
2763
|
+
//#region src/query/clauses/with.d.ts
|
|
2764
|
+
type CteIdentity<TName extends string> = {
|
|
2765
|
+
readonly sourceKind: 'cte';
|
|
2766
|
+
readonly name: TName;
|
|
2767
|
+
};
|
|
2768
|
+
type CteSource<TName extends string, TRow extends object, TMetadata = never, TSqlTypes extends SourceSqlTypes<TRow> = UnknownSourceSqlTypes<TRow>> = Source<CteIdentity<TName>, TRow, TMetadata, TSqlTypes> & {
|
|
2769
|
+
readonly cteName: TName;
|
|
2770
|
+
readonly query: Query<TRow, any, TMetadata, TSqlTypes>;
|
|
2771
|
+
readonly columns: SourceColumns<TRow, CteIdentity<TName>, TSqlTypes>;
|
|
2772
|
+
} & SourceColumns<TRow, CteIdentity<TName>, TSqlTypes>;
|
|
2773
|
+
type CteMetadata<TQuery extends Query<any, any, any, any>> = RequiresOuterMetadataOf<TQuery> | CapabilityMetadataOf<TQuery>;
|
|
2774
|
+
type IsUnknown<T> = unknown extends T ? [keyof T] extends [never] ? true : false : false;
|
|
2775
|
+
type RecursiveMemberFieldFailures<TAnchor, TMember> = Exclude<keyof QueryRow<TAnchor>, keyof QueryRow<TMember>> | Exclude<keyof QueryRow<TMember>, keyof QueryRow<TAnchor>> | { [K in keyof QueryRow<TAnchor> & keyof QueryRow<TMember>]: [IsUnknown<QueryRow<TMember>[K]>] extends [true] ? never : [IsUnknown<QueryRow<TAnchor>[K]>] extends [true] ? never : [QueryRow<TMember>[K]] extends [QueryRow<TAnchor>[K]] ? never : K; }[keyof QueryRow<TAnchor> & keyof QueryRow<TMember>];
|
|
2776
|
+
type RecursiveMemberShapeValidation<TAnchor, TMember> = [RecursiveMemberFieldFailures<TAnchor, TMember>] extends [never] ? unknown : QueryTypeValidation<'incompatible-set-domain', 'recursive-cte.member', 'The recursive member must expose the anchor fields with compatible application types.', RecursiveMemberFieldFailures<TAnchor, TMember>>;
|
|
2777
|
+
type RecursiveMemberValidation<TAnchor, TMember> = RecursiveMemberShapeValidation<TAnchor, TMember> & SetSqlValidation<TAnchor, TMember>;
|
|
2778
|
+
type RecursiveCteSelf<TName extends string, TAnchor extends SelectQuery<any, any, any, any>> = CteSource<TName, QueryRow<TAnchor>, CteMetadata<TAnchor>, QuerySqlTypeMap<TAnchor>>;
|
|
2779
|
+
/** The typed source returned by {@link recursiveCte}. */
|
|
2780
|
+
type RecursiveCteSource<TName extends string, TAnchor extends SelectQuery<any, any, any, any>, TMember extends SelectQuery<any, any, any, any>> = CteSource<TName, QueryRow<TAnchor>, CteMetadata<TAnchor | TMember>, QuerySqlTypeMap<TAnchor>>;
|
|
2781
|
+
type AnyCteSource = Source<any, any, any, any, any> & {
|
|
2782
|
+
readonly cteName: string;
|
|
2783
|
+
readonly query: Query<any, any, any> & {
|
|
2784
|
+
readonly recursive?: boolean;
|
|
2785
|
+
};
|
|
2786
|
+
readonly columns: Record<string, unknown>;
|
|
2787
|
+
};
|
|
2788
|
+
declare function cte<const TName extends string, TQuery extends Query<any, any, any>>(name: TName, query: TQuery): CteSource<TName, QueryRow<TQuery>, RequiresOuterMetadataOf<TQuery> | CapabilityMetadataOf<TQuery>, QuerySqlTypeMap<TQuery>>;
|
|
2789
|
+
/**
|
|
2790
|
+
* Define a typed recursive `WITH` source from an anchor and one recursive
|
|
2791
|
+
* member. The callback receives a forward reference that must be introduced
|
|
2792
|
+
* through the member query's normal FROM or JOIN scope.
|
|
2793
|
+
*/
|
|
2794
|
+
declare function recursiveCte<const TName extends string, TAnchor extends SelectQuery<any, any, any, any>, TMember extends SelectQuery<any, any, any, any>>(name: TName, anchor: TAnchor, member: ((self: RecursiveCteSelf<TName, TAnchor>) => TMember) & ((self: RecursiveCteSelf<TName, TAnchor>) => TMember & RecursiveMemberValidation<NoInfer<TAnchor>, NoInfer<TMember>>)): RecursiveCteSource<TName, TAnchor, TMember>;
|
|
2795
|
+
interface WithClause<TMetadata = never> extends SelectClause<TMetadata> {
|
|
2796
|
+
readonly clauseKind: 'with';
|
|
2797
|
+
readonly ctes: readonly AnyCteSource[];
|
|
2798
|
+
}
|
|
2799
|
+
declare function withCte<const TCtes extends readonly AnyCteSource[]>(...ctes: TCtes): WithClause<RequiresOuterMetadataOf<TCtes[number]> | CapabilityMetadataOf<TCtes[number]>>;
|
|
2800
|
+
//#endregion
|
|
2801
|
+
//#region src/query/select/types.d.ts
|
|
2802
|
+
interface SelectQuery<TRow extends object = Record<string, unknown>, TCardinality extends QueryCardinality = QueryCardinality, TMetadata = never, TSqlTypes = UnknownSourceSqlTypes<TRow>> extends Query<TRow, TCardinality, TMetadata, TSqlTypes> {
|
|
2803
|
+
readonly queryKind: 'select';
|
|
2804
|
+
}
|
|
2805
|
+
type ExactlyOneSafeClause = DistinctClause | OrderByClause<any> | RowLockClause | WithClause;
|
|
2806
|
+
type AtMostOneClause = FetchClause<0 | 1>;
|
|
2807
|
+
type UnconditionalAtMostOneClause<TParts extends readonly SelectPart[]> = { [TIndex in keyof TParts]: Omit$1 extends TParts[TIndex] ? never : Extract<TParts[TIndex], AtMostOneClause>; }[number];
|
|
2808
|
+
type ConditionalPaginationClause<TParts extends readonly SelectPart[]> = { [TIndex in keyof TParts]: Omit$1 extends TParts[TIndex] ? Extract<TParts[TIndex], AnyPaginationClause> : never; }[number];
|
|
2809
|
+
/**
|
|
2810
|
+
* SELECT cardinality is intentionally conservative. A literal FETCH/LIMIT
|
|
2811
|
+
* bound of zero or one proves an upper bound only when it is unconditional;
|
|
2812
|
+
* an otherwise source-free query has one row unless a known row-reducing
|
|
2813
|
+
* clause is present. Conditional pagination, predicates, and arbitrary clauses
|
|
2814
|
+
* do not prove exactness.
|
|
2815
|
+
*/
|
|
2816
|
+
type SelectCardinality<TParts extends readonly SelectPart[]> = UnconditionalAtMostOneClause<TParts> extends never ? ConditionalPaginationClause<TParts> extends never ? Exclude<TParts[number], ExactlyOneSafeClause | Omit$1> extends never ? 'exactly-one' : 'many' : 'many' : 'zero-or-one';
|
|
2817
|
+
type ClauseScope<TClause> = TClause extends FromClause ? FromScope<TClause> : TClause extends JoinClause<infer TSource, any> ? ProvidedSourceIdentity<TSource> : never;
|
|
2818
|
+
type AvailableScope<TClauses extends readonly AnySelectClause[]> = ClauseScope<TClauses[number]>;
|
|
2819
|
+
type AvailableOuterScope<TClauses extends readonly AnySelectClause[]> = ProvidesOuterOf<TClauses[number]>;
|
|
2820
|
+
type NullableSources<TClauses extends readonly AnySelectClause[]> = NullableSourcesOf<TClauses[number]>;
|
|
2821
|
+
type RequiredScope<TSelection, TClauses extends readonly AnySelectClause[]> = SelectionRequires<TSelection> | RequiresOuterOf<SelectionItems<TSelection>> | RequiresOf<TClauses[number]> | RequiresOuterOf<TClauses[number]>;
|
|
2822
|
+
type MissingScope<TSelection, TClauses extends readonly AnySelectClause[]> = Exclude<RequiredScope<TSelection, TClauses>, AvailableScope<TClauses> | AvailableOuterScope<TClauses>>;
|
|
2823
|
+
type RequiredOuterScope<TSelection, TClauses extends readonly AnySelectClause[]> = Extract<Exclude<RequiredScope<TSelection, TClauses>, AvailableScope<TClauses>>, AvailableOuterScope<TClauses>>;
|
|
2824
|
+
type ScopeValidation<TSelection, TClauses extends readonly AnySelectClause[]> = [MissingScope<TSelection, TClauses>] extends [never] ? unknown : QueryTypeValidation<'missing-source', 'select.scope', 'Add a FROM, JOIN, or correlate() clause that provides the referenced source.', MissingScope<TSelection, TClauses>>;
|
|
2825
|
+
type GroupingRuleClause = HavingClause<any> | OrderByClause<any>;
|
|
2826
|
+
type HasGroupByClause<TClauses extends readonly AnySelectClause[]> = Extract<TClauses[number], GroupByClause<any>> extends never ? false : true;
|
|
2827
|
+
type HasHavingClause<TClauses extends readonly AnySelectClause[]> = Extract<TClauses[number], HavingClause<any>> extends never ? false : true;
|
|
2828
|
+
type GroupingRuleClauses<TClauses extends readonly AnySelectClause[]> = Extract<TClauses[number], GroupingRuleClause>;
|
|
2829
|
+
type RequiresGrouping<TSelection, TClauses extends readonly AnySelectClause[]> = HasGroupByClause<TClauses> extends true ? true : HasHavingClause<TClauses> extends true ? true : HasAggregate<SelectionItems<TSelection> | GroupingRuleClauses<TClauses>>;
|
|
2830
|
+
type ClauseSource<TClause> = TClause extends FromClause ? FromSource<TClause> : TClause extends JoinClause<infer TSource, any> ? TSource : never;
|
|
2831
|
+
type ConstraintDeterminesSource<TConstraint, TSource extends AnySource, TGroupedDependencies> = TConstraint extends {
|
|
2832
|
+
readonly kind: 'primary-key' | 'unique';
|
|
2833
|
+
readonly columns: infer TColumns;
|
|
2834
|
+
} ? TColumns extends readonly ColumnReference<string, any>[] ? [DependenciesOf<TColumns[number]>] extends [ColumnDependency<any, any>] ? [ColumnDependency<SourceIdentity<TSource>, DependenciesOf<TColumns[number]> extends ColumnDependency<any, infer TName extends string> ? TName : never>] extends [TGroupedDependencies] ? true : false : false : false : false;
|
|
2835
|
+
type IndexTermExpression$2<T> = T extends OrderTerm<any> ? T['expression'] : T;
|
|
2836
|
+
type IndexDeterminesSource<TIndex, TSource extends AnySource, TGroupedDependencies> = TIndex extends {
|
|
2837
|
+
readonly candidateKey: true;
|
|
2838
|
+
readonly terms: infer TTerms extends readonly unknown[];
|
|
2839
|
+
} ? [DependenciesOf<IndexTermExpression$2<TTerms[number]>>] extends [ColumnDependency<any, any>] ? [ColumnDependency<SourceIdentity<TSource>, DependenciesOf<IndexTermExpression$2<TTerms[number]>> extends ColumnDependency<any, infer TName extends string> ? TName : never>] extends [TGroupedDependencies] ? true : false : false : false;
|
|
2840
|
+
type SourceIndexes<T> = T extends {
|
|
2841
|
+
readonly indexes: infer TIndexes extends SourceIndexesRecord;
|
|
2842
|
+
} ? TIndexes : {};
|
|
2843
|
+
type DeterminedSourceIdentity<TSource, TGroupedDependencies> = TSource extends AnySource ? true extends ConstraintDeterminesSource<SourceConstraints<TSource>[keyof SourceConstraints<TSource>], TSource, TGroupedDependencies> ? SourceIdentity<TSource> : true extends IndexDeterminesSource<SourceIndexes<TSource>[keyof SourceIndexes<TSource>], TSource, TGroupedDependencies> ? SourceIdentity<TSource> : never : never;
|
|
2844
|
+
type FunctionallyDeterminedDependencies<TClauses extends readonly AnySelectClause[]> = ColumnDependency<DeterminedSourceIdentity<ClauseSource<TClauses[number]>, GroupingDependenciesOf<TClauses[number]>>, string>;
|
|
2845
|
+
type GroupingFailure<TExpression, TClauses extends readonly AnySelectClause[]> = TExpression extends unknown ? [VisibleDependenciesOf<TExpression>] extends [never] ? never : [Exclude<VisibleDependenciesOf<TExpression>, GroupingDependenciesOf<TClauses[number]> | FunctionallyDeterminedDependencies<TClauses>>] extends [never] ? never : [Extract<TExpression, GroupingKeysOf<TClauses[number]>>] extends [never] ? VisibleDependenciesOf<TExpression> : never : never;
|
|
2846
|
+
type SelectionGroupingFailures<TSelection, TClauses extends readonly AnySelectClause[]> = GroupingFailure<SelectionItems<TSelection>, TClauses>;
|
|
2847
|
+
type ClauseGroupingFailures<TClauses extends readonly AnySelectClause[]> = TClauses[number] extends (infer TClause) ? TClause extends GroupingRuleClause ? GroupingFailure<TClause, TClauses> : never : never;
|
|
2848
|
+
type GroupByAggregateFailures<TClauses extends readonly AnySelectClause[]> = TClauses[number] extends (infer TClause) ? TClause extends GroupByClause<any> ? HasAggregate<TClause> extends true ? TClause : never : never : never;
|
|
2849
|
+
type GroupingFailures<TSelection, TClauses extends readonly AnySelectClause[]> = SelectionGroupingFailures<TSelection, TClauses> | ClauseGroupingFailures<TClauses> | GroupByAggregateFailures<TClauses>;
|
|
2850
|
+
/**
|
|
2851
|
+
* Enforce the grouped-query rule: visible column dependencies must be grouped
|
|
2852
|
+
* or functionally determined by a grouped, declared key from the same source.
|
|
2853
|
+
* Aggregate arguments are consumed by the aggregate. Non-column GROUP BY
|
|
2854
|
+
* expressions are accepted as exact grouping keys only.
|
|
2855
|
+
*/
|
|
2856
|
+
type GroupingValidation<TSelection, TClauses extends readonly AnySelectClause[]> = RequiresGrouping<TSelection, TClauses> extends true ? [GroupingFailures<TSelection, TClauses>] extends [never] ? unknown : QueryTypeValidation<'invalid-grouping', 'select.grouping', 'Group every visible dependency or project it through an aggregate.', GroupingFailures<TSelection, TClauses>> : unknown;
|
|
2857
|
+
//#endregion
|
|
2858
|
+
//#region src/query/select.d.ts
|
|
2859
|
+
type SelectMetadata<TSelection, TClauses extends readonly AnySelectClause[]> = ([RequiredOuterScope<TSelection, TClauses>] extends [never] ? never : RequiresOuterSourceMeta<RequiredOuterScope<TSelection, TClauses>>) | CapabilityMetadataOf<SelectionItems<TSelection> | TClauses[number]>;
|
|
2860
|
+
declare function select<const TSelection extends Selection, const TParts extends readonly SelectPart[], TClauses extends readonly AnySelectClause[] = PresentClauses<TParts>>(selection: TSelection, ...parts: TParts & OmissionValidation<TParts> & ScopeValidation<TSelection, TClauses> & GroupingValidation<TSelection, TClauses>): SelectQuery<SelectionOutput<TSelection, NullableSources<TClauses>>, SelectCardinality<TParts>, SelectMetadata<TSelection, TClauses>, SelectionSqlTypes<TSelection, SelectionOutput<TSelection, NullableSources<TClauses>>>>;
|
|
2861
|
+
//#endregion
|
|
2862
|
+
//#region src/query/clauses/correlate.d.ts
|
|
2863
|
+
/**
|
|
2864
|
+
* Provision an enclosing source to a correlated SELECT. The clause emits no
|
|
2865
|
+
* SQL; select() consumes the provision and records any actually used source
|
|
2866
|
+
* as a requirement on the resulting query.
|
|
2867
|
+
*/
|
|
2868
|
+
interface CorrelateClause<TSources extends readonly AnySource[] = readonly AnySource[]> extends SelectClause<ProvidesOuterSourceMeta<SourceIdentity<TSources[number]>>> {
|
|
2869
|
+
readonly clauseKind: 'correlate';
|
|
2870
|
+
readonly sources: TSources;
|
|
2871
|
+
}
|
|
2872
|
+
declare function correlate<const TSources extends readonly [AnySource, ...AnySource[]]>(...sources: TSources): CorrelateClause<TSources>;
|
|
2873
|
+
//#endregion
|
|
2874
|
+
//#region src/query/mutation/returning.d.ts
|
|
2875
|
+
interface ReturningClause<TSelection extends Selection = Selection> extends Fragment<SelectionMetadata<TSelection>> {
|
|
2876
|
+
readonly clauseKind: 'returning';
|
|
2877
|
+
readonly selection: TSelection;
|
|
2878
|
+
readonly row: SelectionOutput<TSelection>;
|
|
2879
|
+
}
|
|
2880
|
+
type ReturningRow<T> = [T] extends [ReturningClause<infer TSelection>] ? SelectionOutput<TSelection> : Record<string, never>;
|
|
2881
|
+
/** SQL semantic domains retained by a mutation RETURNING projection. */
|
|
2882
|
+
type ReturningSqlTypes<T> = [T] extends [ReturningClause<infer TSelection>] ? SelectionSqlTypes<TSelection> : Record<string, never>;
|
|
2883
|
+
declare function returning<const TSelection extends Selection>(selection: TSelection): ReturningClause<TSelection>;
|
|
2884
|
+
//#endregion
|
|
2885
|
+
//#region src/query/mutation/types.d.ts
|
|
2886
|
+
type MutationKind = 'insert' | 'update' | 'delete';
|
|
2887
|
+
interface MutationQuery<TRow extends object = Record<string, unknown>, TKind extends MutationKind = MutationKind, TMetadata = never, TSqlTypes = UnknownSourceSqlTypes<TRow>> extends Query<TRow, 'many', TMetadata, TSqlTypes> {
|
|
2888
|
+
readonly queryKind: TKind;
|
|
2889
|
+
}
|
|
2890
|
+
type MutationCapabilityMetadata<T> = CapabilityMetadataOf<T>;
|
|
2891
|
+
interface AllowAllClause extends Fragment<never> {
|
|
2892
|
+
readonly clauseKind: 'allow-all';
|
|
2893
|
+
}
|
|
2894
|
+
declare function allowAll(): AllowAllClause;
|
|
2895
|
+
type MutationConditionClause = WhereClause<any>;
|
|
2896
|
+
type MutationClause = MutationConditionClause | AllowAllClause | MutationReturningClause;
|
|
2897
|
+
type MutationSafetyValidation<TClauses extends readonly unknown[]> = Extract<TClauses[number], MutationConditionClause | AllowAllClause> extends never ? QueryTypeValidation<'unsafe-mutation', 'mutation.safety', 'Add where(...) or allowAll() explicitly.'> : unknown;
|
|
2898
|
+
type MutationReturningClause = ReturningClause<any>;
|
|
2899
|
+
type MutationReturning<TClauses extends readonly unknown[]> = Extract<TClauses[number], MutationReturningClause>;
|
|
2900
|
+
type MutationRow<TClauses extends readonly unknown[]> = ReturningRow<MutationReturning<TClauses>>;
|
|
2901
|
+
type MutationSqlTypes<TClauses extends readonly unknown[]> = ReturningSqlTypes<MutationReturning<TClauses>>;
|
|
2902
|
+
type MutationScopeValidation<TSource, TClauses extends readonly unknown[]> = [Exclude<RequiresOf<TClauses[number]>, SourceIdentity<TSource>>] extends [never] ? unknown : QueryTypeValidation<'missing-source', 'mutation.scope', 'Use clauses that reference the mutation table or an explicitly correlated source.', Exclude<RequiresOf<TClauses[number]>, SourceIdentity<TSource>>>;
|
|
2903
|
+
//#endregion
|
|
2904
|
+
//#region src/query/mutation/update.d.ts
|
|
2905
|
+
/** A value, target-compatible expression, or explicitly omitted update field. */
|
|
2906
|
+
type UpdateAssignmentValue<T> = T | ExpressionWithOutput<T> | Omit$1;
|
|
2907
|
+
/** Writable table fields accepted by {@link update}. */
|
|
2908
|
+
type UpdateAssignments<TTable extends AnyTable> = { -readonly [K in keyof TableUpdateInput<TTable['definitions']>]?: UpdateAssignmentValue<TableUpdateInput<TTable['definitions']>[K]>; };
|
|
2909
|
+
type InvalidUpdateAssignments<TTable extends AnyTable, TAssignments> = TAssignments extends UpdateAssignments<TTable> ? Exclude<keyof TAssignments, keyof UpdateAssignments<TTable>> extends never ? unknown : QueryTypeValidation<'invalid-update', 'update.assignments', 'Use only columns declared by the update table.', Exclude<keyof TAssignments, keyof UpdateAssignments<TTable>>> : QueryTypeValidation<'invalid-update', 'update.assignments', 'Provide values or expressions matching the update table columns.', TAssignments>;
|
|
2910
|
+
type AssignmentScopeValidation<TTable extends AnyTable, TAssignments> = [Exclude<RequiresOf<TAssignments extends object ? TAssignments[keyof TAssignments] : never>, SourceIdentity<TTable>>] extends [never] ? unknown : QueryTypeValidation<'missing-source', 'update.assignments', 'Use expressions scoped to the update table.', Exclude<RequiresOf<TAssignments extends object ? TAssignments[keyof TAssignments] : never>, SourceIdentity<TTable>>>;
|
|
2911
|
+
declare function update<const TTable extends AnyTable, const TAssignments extends object, const TClauses extends readonly MutationClause[]>(table: TTable, assignments: TAssignments & InvalidUpdateAssignments<TTable, TAssignments> & AssignmentScopeValidation<TTable, TAssignments>, ...clauses: TClauses & MutationScopeValidation<TTable, TClauses> & MutationSafetyValidation<TClauses>): MutationQuery<MutationRow<TClauses>, 'update', MutationCapabilityMetadata<TClauses[number] | (TAssignments extends object ? TAssignments[keyof TAssignments] : never)>, MutationSqlTypes<TClauses>>;
|
|
2912
|
+
//#endregion
|
|
2913
|
+
//#region src/query/mutation/on-conflict.d.ts
|
|
2914
|
+
type ExcludedIdentity<TTableIdentity> = {
|
|
2915
|
+
readonly sourceKind: 'excluded';
|
|
2916
|
+
readonly table: TTableIdentity;
|
|
2917
|
+
};
|
|
2918
|
+
type ExcludedSource<TTable extends AnyTable> = Source<ExcludedIdentity<SourceIdentity<TTable>>, SourceRow<TTable>, never, ExcludedSqlTypes<TTable>> & SourceColumns<SourceRow<TTable>, ExcludedIdentity<SourceIdentity<TTable>>, ExcludedSqlTypes<TTable>>;
|
|
2919
|
+
type ExcludedSqlTypes<TTable extends AnyTable> = SourceSqlTypeMap<TTable> & SourceSqlTypes<SourceRow<TTable>>;
|
|
2920
|
+
/** Columns from the proposed INSERT row, available inside DO UPDATE. */
|
|
2921
|
+
declare function excluded<const TTable extends AnyTable>(table: TTable): ExcludedSource<TTable>;
|
|
2922
|
+
interface DoNothingAction {
|
|
2923
|
+
readonly actionKind: 'do-nothing';
|
|
2924
|
+
}
|
|
2925
|
+
interface DoUpdateAction<TAssignments extends object = object, TWhere extends WhereClause<any> | undefined = WhereClause<any> | undefined> {
|
|
2926
|
+
readonly actionKind: 'do-update';
|
|
2927
|
+
readonly assignments: TAssignments;
|
|
2928
|
+
readonly where: TWhere;
|
|
2929
|
+
}
|
|
2930
|
+
type ConflictAction = DoNothingAction | DoUpdateAction<any, any>;
|
|
2931
|
+
declare function doNothing(): DoNothingAction;
|
|
2932
|
+
declare function doUpdate<const TAssignments extends object>(assignments: TAssignments): DoUpdateAction<TAssignments, undefined>;
|
|
2933
|
+
declare function doUpdate<const TAssignments extends object, const TWhere extends WhereClause<any>>(assignments: TAssignments, whereClause: TWhere): DoUpdateAction<TAssignments, TWhere>;
|
|
2934
|
+
type TableConstraints<TTable extends AnyTable> = TTable extends {
|
|
2935
|
+
readonly constraints: infer TConstraints extends SourceConstraintsRecord;
|
|
2936
|
+
} ? TConstraints : never;
|
|
2937
|
+
type TableKeyConstraint<TTable extends AnyTable> = Extract<TableConstraints<TTable>[keyof TableConstraints<TTable>], KeyConstraint>;
|
|
2938
|
+
/** A declared primary or non-null unique key used as an upsert target. */
|
|
2939
|
+
type ConflictTarget<TTable extends AnyTable = AnyTable> = TableKeyConstraint<TTable>;
|
|
2940
|
+
type ConflictSources<TTable extends AnyTable> = SourceIdentity<TTable> | ExcludedIdentity<SourceIdentity<TTable>>;
|
|
2941
|
+
type ConflictAssignmentValidation<TTable extends AnyTable, TAssignments> = TAssignments extends UpdateAssignments<TTable> ? Exclude<keyof TAssignments, keyof UpdateAssignments<TTable>> extends never ? [Exclude<RequiresOf<TAssignments[keyof TAssignments]>, ConflictSources<TTable>>] extends [never] ? unknown : QueryTypeValidation<'missing-source', 'upsert.update.assignments', 'Use expressions scoped to the target table or excluded row.', Exclude<RequiresOf<TAssignments[keyof TAssignments]>, ConflictSources<TTable>>> : QueryTypeValidation<'invalid-update', 'upsert.update.assignments', 'Use only writable columns declared by the target table.', Exclude<keyof TAssignments, keyof UpdateAssignments<TTable>>> : QueryTypeValidation<'invalid-update', 'upsert.update.assignments', 'Provide values or expressions matching the target table update columns.', TAssignments>;
|
|
2942
|
+
type ConflictWhereValidation<TTable extends AnyTable, TWhere> = TWhere extends undefined ? unknown : [Exclude<RequiresOf<TWhere>, ConflictSources<TTable>>] extends [never] ? unknown : QueryTypeValidation<'missing-source', 'upsert.update.where', 'Use expressions scoped to the target table or excluded row.', Exclude<RequiresOf<TWhere>, ConflictSources<TTable>>>;
|
|
2943
|
+
type ConflictActionValidation<TTable extends AnyTable, TAction extends ConflictAction> = TAction extends DoUpdateAction<infer TAssignments, infer TWhere> ? ConflictAssignmentValidation<TTable, TAssignments> & ConflictWhereValidation<TTable, TWhere> : unknown;
|
|
2944
|
+
type ConflictActionCapabilities<TAction extends ConflictAction> = TAction extends DoUpdateAction<infer TAssignments, infer TWhere> ? CapabilityMetadataOf<TAssignments[keyof TAssignments] | Exclude<TWhere, undefined>> : never;
|
|
2945
|
+
interface OnConflictClause<TAction extends ConflictAction = ConflictAction> extends Fragment<RequiresCapabilityMeta<'on-conflict'> | ConflictActionCapabilities<TAction>> {
|
|
2946
|
+
readonly clauseKind: 'on-conflict';
|
|
2947
|
+
readonly target: KeyConstraint | undefined;
|
|
2948
|
+
readonly action: TAction;
|
|
2949
|
+
}
|
|
2950
|
+
type InsertClause = MutationReturningClause | OnConflictClause;
|
|
2951
|
+
declare function onConflict(action: DoNothingAction): OnConflictClause<DoNothingAction>;
|
|
2952
|
+
declare function onConflict<const TTable extends AnyTable, const TTarget extends ConflictTarget<TTable>, const TAction extends ConflictAction>(table: TTable, target: TTarget, action: TAction & ConflictActionValidation<TTable, TAction>): OnConflictClause<TAction>;
|
|
2953
|
+
//#endregion
|
|
2954
|
+
//#region src/query/mutation/insert.d.ts
|
|
2955
|
+
interface ValuesSource<TRows extends readonly object[] = readonly object[]> {
|
|
2956
|
+
readonly insertKind: 'values';
|
|
2957
|
+
readonly rows: TRows;
|
|
2958
|
+
}
|
|
2959
|
+
declare function values<const TRows extends readonly [object, ...object[]]>(...rows: TRows): ValuesSource<TRows>;
|
|
2960
|
+
interface DefaultValuesSource {
|
|
2961
|
+
readonly insertKind: 'default-values';
|
|
2962
|
+
}
|
|
2963
|
+
declare function defaultValues(): DefaultValuesSource;
|
|
2964
|
+
interface InsertSelectSource<TQuery extends Query<any, any, any> = Query<any, any, any>, TColumns extends readonly string[] = readonly string[]> {
|
|
2965
|
+
readonly insertKind: 'select';
|
|
2966
|
+
readonly query: TQuery;
|
|
2967
|
+
readonly columns: TColumns;
|
|
2968
|
+
}
|
|
2969
|
+
declare function insertSelect<TQuery extends Query<any, any, any>, const TColumns extends readonly [string, ...string[]]>(query: TQuery, columns: TColumns): InsertSelectSource<TQuery, TColumns>;
|
|
2970
|
+
type InsertSource = ValuesSource<any> | DefaultValuesSource | InsertSelectSource<any, any>;
|
|
2971
|
+
type InsertSourceCapabilityMetadata<TSource extends InsertSource> = TSource extends InsertSelectSource<infer TQuery, any> ? CapabilityMetadataOf<TQuery> : never;
|
|
2972
|
+
type InsertRow<TTable extends AnyTable> = TableInsertInput<TTable['definitions']>;
|
|
2973
|
+
type InvalidInsertRow<TTable extends AnyTable, TRow> = TRow extends InsertRow<TTable> ? Exclude<keyof TRow, keyof InsertRow<TTable>> extends never ? unknown : QueryTypeValidation<'invalid-insert', 'insert.values.columns', 'Use only columns declared by the insert table.', Exclude<keyof TRow, keyof InsertRow<TTable>>> : QueryTypeValidation<'invalid-insert', 'insert.values.row', 'Provide values matching the insert table columns.', TRow>;
|
|
2974
|
+
type ValidInsertSource<TTable extends AnyTable, TSource extends InsertSource> = TSource extends ValuesSource<infer TRows> ? TRows[number] extends (infer TRow) ? InvalidInsertRow<TTable, TRow> : never : TSource extends DefaultValuesSource ? Exclude<keyof TTable['definitions'], { [K in keyof TTable['definitions']]-?: ColumnIsGenerated<TTable['definitions'][K]> extends true ? K : TTable['definitions'][K] extends {
|
|
2975
|
+
hasDefault: true;
|
|
2976
|
+
} ? K : never; }[keyof TTable['definitions']]> extends never ? unknown : QueryTypeValidation<'invalid-insert', 'insert.default-values', 'Provide values for required columns or define defaults for them.', Exclude<keyof TTable['definitions'], { [K in keyof TTable['definitions']]-?: ColumnIsGenerated<TTable['definitions'][K]> extends true ? K : TTable['definitions'][K] extends {
|
|
2977
|
+
hasDefault: true;
|
|
2978
|
+
} ? K : never; }[keyof TTable['definitions']]>> : TSource extends InsertSelectSource<any, infer TColumns> ? Exclude<TColumns[number], keyof TTable['definitions']> extends never ? Exclude<{ [K in keyof TTable['definitions']]-?: ColumnIsGenerated<TTable['definitions'][K]> extends true ? never : ColumnHasDefault<TTable['definitions'][K]> extends true ? never : K; }[keyof TTable['definitions']], TColumns[number]> extends never ? unknown : QueryTypeValidation<'invalid-insert', 'insert.select.columns', 'Include every required insert column in the target list.', Exclude<{ [K in keyof TTable['definitions']]-?: ColumnIsGenerated<TTable['definitions'][K]> extends true ? never : ColumnHasDefault<TTable['definitions'][K]> extends true ? never : K; }[keyof TTable['definitions']], TColumns[number]>> : QueryTypeValidation<'invalid-insert', 'insert.select.columns', 'Use only columns declared by the insert table.', Exclude<TColumns[number], keyof TTable['definitions']>> : never;
|
|
2979
|
+
declare function insertInto<const TTable extends AnyTable, const TSource extends InsertSource, const TClauses extends readonly InsertClause[]>(table: TTable, source: TSource & ValidInsertSource<TTable, TSource>, ...clauses: TClauses & MutationScopeValidation<TTable, TClauses>): MutationQuery<MutationRow<TClauses>, 'insert', MutationCapabilityMetadata<TClauses[number]> | InsertSourceCapabilityMetadata<TSource>, MutationSqlTypes<TClauses>>;
|
|
2980
|
+
//#endregion
|
|
2981
|
+
//#region src/query/mutation/delete.d.ts
|
|
2982
|
+
declare function deleteFrom<const TTable extends AnyTable, const TClauses extends readonly MutationClause[]>(table: TTable, ...clauses: TClauses & MutationScopeValidation<TTable, TClauses> & MutationSafetyValidation<TClauses>): MutationQuery<MutationRow<TClauses>, 'delete', MutationCapabilityMetadata<TClauses[number]>, MutationSqlTypes<TClauses>>;
|
|
2983
|
+
//#endregion
|
|
2984
|
+
//#region src/query/clauses/order-by.d.ts
|
|
2985
|
+
type OrderDirection = 'ASC' | 'DESC';
|
|
2986
|
+
type NullsOrder = 'FIRST' | 'LAST';
|
|
2987
|
+
interface OrderTerm<TMetadata = never, TExpression extends AnyExpression = AnyExpression> extends Fragment<TMetadata> {
|
|
2988
|
+
readonly orderKind: 'term';
|
|
2989
|
+
readonly expression: TExpression;
|
|
2990
|
+
readonly direction?: OrderDirection;
|
|
2991
|
+
readonly nulls?: NullsOrder;
|
|
2992
|
+
}
|
|
2993
|
+
declare function order<TExpression extends AnyExpression>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>, direction?: OrderDirection, nulls?: NullsOrder): OrderTerm<MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> extends (infer T) ? T extends MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> ? T extends {
|
|
2994
|
+
readonly kind: "result" | "cardinality";
|
|
2995
|
+
} ? never : T : never : never, TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>>;
|
|
2996
|
+
declare function asc<TExpression extends AnyExpression>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>, nulls?: NullsOrder): OrderTerm<MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> extends (infer T) ? T extends MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> ? T extends {
|
|
2997
|
+
readonly kind: "result" | "cardinality";
|
|
2998
|
+
} ? never : T : never : never, TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>>;
|
|
2999
|
+
declare function desc<TExpression extends AnyExpression>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>, nulls?: NullsOrder): OrderTerm<MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> extends (infer T) ? T extends MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> ? T extends {
|
|
3000
|
+
readonly kind: "result" | "cardinality";
|
|
3001
|
+
} ? never : T : never : never, TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>>;
|
|
3002
|
+
declare function nullsFirst<TExpression extends AnyExpression>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>): OrderTerm<MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> extends (infer T) ? T extends MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> ? T extends {
|
|
3003
|
+
readonly kind: "result" | "cardinality";
|
|
3004
|
+
} ? never : T : never : never, TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>>;
|
|
3005
|
+
declare function nullsLast<TExpression extends AnyExpression>(expression: TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable>): OrderTerm<MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> extends (infer T) ? T extends MetadataOf<TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>> ? T extends {
|
|
3006
|
+
readonly kind: "result" | "cardinality";
|
|
3007
|
+
} ? never : T : never : never, TExpression & SqlCapabilityValidation<ExpressionSqlType<TExpression>, SqlOrderable<unknown>>>;
|
|
3008
|
+
interface OrderByClause<TMetadata = never> extends SelectClause<TMetadata> {
|
|
3009
|
+
readonly clauseKind: 'order-by';
|
|
3010
|
+
readonly terms: readonly OrderTerm<any>[];
|
|
3011
|
+
}
|
|
3012
|
+
type OrderByPart = AnyExpression | OrderTerm<any> | Omit$1;
|
|
3013
|
+
type PresentOrderParts<TParts extends readonly OrderByPart[]> = Exclude<TParts[number], Omit$1>;
|
|
3014
|
+
type OrderByComposition<TParts extends readonly OrderByPart[]> = [PresentOrderParts<TParts>] extends [never] ? Omit$1 : OrderByClause<InheritedMetadata<PresentOrderParts<TParts>>> | (Omit$1 extends TParts[number] ? Omit$1 : never);
|
|
3015
|
+
type OrderPartsValidation<TParts extends readonly unknown[]> = TParts extends readonly [infer THead, ...infer TTail] ? (THead extends Omit$1 ? unknown : THead extends AnyExpression ? SqlCapabilityValidation<ExpressionSqlType<THead>, SqlOrderable> : unknown) & OrderPartsValidation<TTail> : unknown;
|
|
3016
|
+
declare function orderBy<const TParts extends readonly OrderByPart[]>(...parts: TParts & OrderPartsValidation<TParts>): OrderByComposition<TParts>;
|
|
3017
|
+
//#endregion
|
|
3018
|
+
//#region src/schema/indexes.d.ts
|
|
3019
|
+
type IndexTerm = AnyExpression | OrderTerm<any>;
|
|
3020
|
+
/** PostgreSQL-specific index method and storage metadata. */
|
|
3021
|
+
interface PostgresIndexExtension extends SchemaDialectExtension<'postgresql'> {
|
|
3022
|
+
readonly method?: 'btree' | 'hash' | 'gist' | 'spgist' | 'gin' | 'brin';
|
|
3023
|
+
readonly concurrently?: boolean;
|
|
3024
|
+
readonly operatorClasses?: Readonly<Record<string, string>>;
|
|
3025
|
+
readonly storageParameters?: Readonly<Record<string, string | number | boolean>>;
|
|
3026
|
+
}
|
|
3027
|
+
/** SQLite-specific index metadata retained for a future adapter. */
|
|
3028
|
+
interface SqliteIndexExtension extends SchemaDialectExtension<'sqlite'> {
|
|
3029
|
+
readonly auto?: boolean;
|
|
3030
|
+
}
|
|
3031
|
+
/** MySQL-specific index algorithm, locking, and parser metadata. */
|
|
3032
|
+
interface MysqlIndexExtension extends SchemaDialectExtension<'mysql'> {
|
|
3033
|
+
readonly algorithm?: 'default' | 'inplace' | 'copy';
|
|
3034
|
+
readonly lock?: 'default' | 'none' | 'shared' | 'exclusive';
|
|
3035
|
+
readonly using?: 'btree' | 'hash' | 'rtree';
|
|
3036
|
+
readonly parser?: string;
|
|
3037
|
+
readonly keyBlockSize?: number;
|
|
3038
|
+
}
|
|
3039
|
+
/** First-party and user-defined dialect extensions for indexes. */
|
|
3040
|
+
type IndexDialectExtension = PostgresIndexExtension | SqliteIndexExtension | MysqlIndexExtension | (SchemaDialectExtension<string> & Readonly<Record<string, unknown>>);
|
|
3041
|
+
interface IndexOptions<TPredicate extends AnyExpression | undefined = AnyExpression | undefined, TExtension extends IndexDialectExtension | undefined = IndexDialectExtension | undefined> extends SchemaObjectNameOptions {
|
|
3042
|
+
readonly unique?: boolean;
|
|
3043
|
+
readonly where?: TPredicate;
|
|
3044
|
+
/** Columns stored in the index payload but not used as key terms. */
|
|
3045
|
+
readonly include?: readonly ColumnReference<string, any>[];
|
|
3046
|
+
/** Typed engine-specific index options. */
|
|
3047
|
+
readonly dialect?: TExtension;
|
|
3048
|
+
}
|
|
3049
|
+
type IndexTermExpression$1<TTerm> = TTerm extends OrderTerm<any> ? TTerm['expression'] : TTerm;
|
|
3050
|
+
type IsNullableIndexColumn<TColumn> = [DeclaredColumnNullabilityOf<TColumn>] extends [never] ? null extends OutputOf<TColumn> ? true : false : true extends DeclaredColumnNullabilityOf<TColumn> ? true : false;
|
|
3051
|
+
type IsEligibleColumn<TTerm> = IndexTermExpression$1<TTerm> extends (infer TExpression) ? TExpression extends ColumnReference<string, any> ? IsNullableIndexColumn<TExpression> extends true ? false : true : false : false;
|
|
3052
|
+
type AllEligibleColumns<TTerms extends readonly IndexTerm[]> = { [K in keyof TTerms]: IsEligibleColumn<TTerms[K]>; }[number] extends (infer TEligibility) ? false extends TEligibility ? true extends TEligibility ? boolean : false : true : false;
|
|
3053
|
+
type BooleanOption<TValue> = [Extract<TValue, true>] extends [never] ? false : [Exclude<TValue, true>] extends [never] ? true : boolean;
|
|
3054
|
+
type UniqueOption<TOptions> = 'unique' extends keyof TOptions ? BooleanOption<TOptions['unique']> : false;
|
|
3055
|
+
type PredicateOption<TOptions> = 'where' extends keyof TOptions ? TOptions['where'] : undefined;
|
|
3056
|
+
type DialectOption<TOptions> = TOptions extends {
|
|
3057
|
+
readonly dialect?: infer TDialect;
|
|
3058
|
+
} ? unknown extends TDialect ? IndexDialectExtension | undefined : TDialect : undefined;
|
|
3059
|
+
type PredicatePresence<TOptions> = [Exclude<PredicateOption<TOptions>, undefined>] extends [never] ? false : undefined extends PredicateOption<TOptions> ? boolean : true;
|
|
3060
|
+
type IsCandidateKey<TTerms extends readonly IndexTerm[], TOptions extends IndexOptions<any>> = UniqueOption<TOptions> extends (infer TUnique) ? PredicatePresence<TOptions> extends (infer THasPredicate) ? AllEligibleColumns<TTerms> extends (infer TEligible) ? TUnique extends false ? false : THasPredicate extends true ? false : TEligible extends false ? false : TUnique extends true ? THasPredicate extends false ? TEligible extends true ? true : boolean : boolean : boolean : false : false : false;
|
|
3061
|
+
/** Portable index metadata retained by a table and its aliases. */
|
|
3062
|
+
interface TableIndex<TTerms extends readonly IndexTerm[] = any, TOptions extends IndexOptions<any> = any> extends SchemaObjectIdentity {
|
|
3063
|
+
readonly kind: 'index';
|
|
3064
|
+
readonly terms: TTerms;
|
|
3065
|
+
readonly unique: UniqueOption<TOptions>;
|
|
3066
|
+
readonly predicate: PredicateOption<TOptions>;
|
|
3067
|
+
readonly includedColumns?: TOptions extends {
|
|
3068
|
+
readonly include: infer TIncluded;
|
|
3069
|
+
} ? TIncluded : undefined;
|
|
3070
|
+
readonly dialect?: DialectOption<TOptions>;
|
|
3071
|
+
readonly candidateKey: IsCandidateKey<TTerms, TOptions>;
|
|
3072
|
+
}
|
|
3073
|
+
/** The widened index shape accepted by source metadata records. */
|
|
3074
|
+
interface SourceIndex {
|
|
3075
|
+
readonly kind: 'index';
|
|
3076
|
+
readonly terms: readonly IndexTerm[];
|
|
3077
|
+
readonly unique: boolean;
|
|
3078
|
+
readonly predicate: AnyExpression | undefined;
|
|
3079
|
+
readonly includedColumns?: readonly ColumnReference<string, any>[];
|
|
3080
|
+
readonly dialect?: IndexDialectExtension;
|
|
3081
|
+
readonly candidateKey: boolean;
|
|
3082
|
+
}
|
|
3083
|
+
type SourceIndexesRecord = Readonly<Record<string, SourceIndex>>;
|
|
3084
|
+
/**
|
|
3085
|
+
* Validate portable and dialect-owned index facts for one target adapter.
|
|
3086
|
+
* Unsupported features are reported as data so a serializer can aggregate
|
|
3087
|
+
* diagnostics instead of failing during traversal with an opaque exception.
|
|
3088
|
+
*/
|
|
3089
|
+
declare function validateIndexDialect(indexMetadata: SourceIndex, dialect: string, path?: readonly (string | number)[]): readonly SchemaMetadataDiagnostic[];
|
|
3090
|
+
type ValidIndexExpression<T> = T extends AnyExpression ? HasAggregate<T> extends true ? never : HasWindow<T> extends true ? never : HasSubquery<T> extends true ? never : unknown : never;
|
|
3091
|
+
type InvalidIndexTerms<TTerms extends readonly IndexTerm[]> = { [K in keyof TTerms]: TTerms[K] extends OrderTerm<any> ? TTerms[K] extends {
|
|
3092
|
+
readonly nulls: 'FIRST' | 'LAST';
|
|
3093
|
+
} ? TTerms[K] : ValidIndexExpression<TTerms[K]['expression']> extends never ? TTerms[K] : never : ValidIndexExpression<TTerms[K]> extends never ? TTerms[K] : never; }[number];
|
|
3094
|
+
type IndexTermsValidation<TTerms extends readonly IndexTerm[]> = [InvalidIndexTerms<TTerms>] extends [never] ? unknown : never;
|
|
3095
|
+
/** Declare a portable column or expression index. */
|
|
3096
|
+
declare function index<const TTerms extends readonly [IndexTerm, ...IndexTerm[]], const TOptions extends IndexOptions<any> = {}>(terms: TTerms & IndexTermsValidation<NoInfer<TTerms>>, options?: TOptions): TableIndex<TTerms, TOptions>;
|
|
3097
|
+
//#endregion
|
|
3098
|
+
//#region src/schema/table.d.ts
|
|
3099
|
+
type TableDefinitions = Record<string, ColumnDefinition<any, any, any, any, any, any, any, any, any, any, any>>;
|
|
3100
|
+
type AnyTable = Source<any, any, any, any, any> & {
|
|
3101
|
+
readonly tableName: string;
|
|
3102
|
+
readonly definitions: TableDefinitions;
|
|
3103
|
+
/** Application field keys mapped to physical SQL column names. */
|
|
3104
|
+
readonly sqlNames: Readonly<Record<string, string>>;
|
|
3105
|
+
};
|
|
3106
|
+
type TableRow<TDefinitions extends TableDefinitions> = { -readonly [K in keyof TDefinitions]: ColumnOutput<TDefinitions[K]>; };
|
|
3107
|
+
/** SQL semantic domains derived from a table's column definitions. */
|
|
3108
|
+
type TableSqlTypes<TDefinitions extends TableDefinitions> = { readonly [K in keyof TDefinitions]: ColumnSqlType<TDefinitions[K]>; };
|
|
3109
|
+
type RequiredInsertKeys<TDefinitions extends TableDefinitions> = { [K in keyof TDefinitions]-?: ColumnHasDefault<TDefinitions[K]> extends true ? never : ColumnIsGenerated<TDefinitions[K]> extends true ? never : K; }[keyof TDefinitions];
|
|
3110
|
+
type OptionalInsertKeys<TDefinitions extends TableDefinitions> = Exclude<keyof TDefinitions, RequiredInsertKeys<TDefinitions>>;
|
|
3111
|
+
type TableInsertInput<TDefinitions extends TableDefinitions> = { -readonly [K in RequiredInsertKeys<TDefinitions>]: ColumnInsertInput<TDefinitions[K]>; } & { -readonly [K in OptionalInsertKeys<TDefinitions>]?: ColumnInsertInput<TDefinitions[K]>; };
|
|
3112
|
+
type TableUpdateInput<TDefinitions extends TableDefinitions> = { -readonly [K in keyof TDefinitions as ColumnIsGenerated<TDefinitions[K]> extends true ? never : K]?: ColumnUpdateInput<TDefinitions[K]>; };
|
|
3113
|
+
type TableIdentity<TName extends string> = {
|
|
3114
|
+
readonly sourceKind: 'table';
|
|
3115
|
+
readonly tableName: TName;
|
|
3116
|
+
};
|
|
3117
|
+
type TableColumns<TDefinitions extends TableDefinitions, TIdentity> = { readonly [K in keyof TDefinitions]: SourceColumns<TableRow<TDefinitions>, TIdentity, TableSqlTypes<TDefinitions>>[K] & DeclaredColumnNullability<ColumnIsNullable<TDefinitions[K]>>; };
|
|
3118
|
+
type Table<TName extends string = string, TDefinitions extends TableDefinitions = TableDefinitions, TConstraints extends SourceConstraintsRecord = {}, TIndexes extends SourceIndexesRecord = {}> = Source<TableIdentity<TName>, TableRow<TDefinitions>, never, TableSqlTypes<TDefinitions>, TConstraints> & {
|
|
3119
|
+
readonly tableName: TName;
|
|
3120
|
+
readonly definitions: TDefinitions;
|
|
3121
|
+
/** Application field keys mapped to physical SQL column names. */
|
|
3122
|
+
readonly sqlNames: Readonly<Record<keyof TDefinitions & string, string>>;
|
|
3123
|
+
readonly columns: TableColumns<TDefinitions, TableIdentity<TName>>;
|
|
3124
|
+
readonly constraints: TConstraints;
|
|
3125
|
+
readonly indexes: TIndexes;
|
|
3126
|
+
} & TableColumns<TDefinitions, TableIdentity<TName>>;
|
|
3127
|
+
/** Schema metadata that applies to a table as a relation. */
|
|
3128
|
+
interface TableOptions<TConstraints extends SourceConstraintsRecord = SourceConstraintsRecord, TIndexes extends SourceIndexesRecord = SourceIndexesRecord> {
|
|
3129
|
+
readonly constraints: TConstraints;
|
|
3130
|
+
readonly indexes: TIndexes;
|
|
3131
|
+
}
|
|
3132
|
+
type ConstraintColumns<TConstraint> = TConstraint extends KeyConstraint<any, infer TColumns> | UniqueConstraint<infer TColumns> | ForeignKeyConstraint<infer TColumns, any> ? TColumns[number] : never;
|
|
3133
|
+
type InvalidConstraintDependencies<TName extends string, TConstraints extends SourceConstraintsRecord> = Exclude<DependenciesOf<ConstraintColumns<TConstraints[keyof TConstraints]>>, ColumnDependency<TableIdentity<TName>, string>>;
|
|
3134
|
+
type InvalidExpression<TExpression, TName extends string> = TExpression extends AnyExpression ? Exclude<DependenciesOf<TExpression>, ColumnDependency<TableIdentity<TName>, string>> extends never ? HasAggregate<TExpression> extends true ? TExpression : HasWindow<TExpression> extends true ? TExpression : HasSubquery<TExpression> extends true ? TExpression : never : TExpression : TExpression;
|
|
3135
|
+
type ResolvedTarget<T> = T extends (() => infer TResolved) ? TResolved : T;
|
|
3136
|
+
type SameColumnTuple<TLeft extends readonly unknown[], TRight extends readonly unknown[]> = TLeft extends readonly [infer TLeftHead, ...infer TLeftTail] ? TRight extends readonly [infer TRightHead, ...infer TRightTail] ? [DependenciesOf<TLeftHead>] extends [DependenciesOf<TRightHead>] ? [DependenciesOf<TRightHead>] extends [DependenciesOf<TLeftHead>] ? SameColumnTuple<TLeftTail, TRightTail> : false : false : false : TRight extends readonly [] ? true : false;
|
|
3137
|
+
type IndexTermExpression<T> = T extends OrderTerm<any> ? T['expression'] : T;
|
|
3138
|
+
type IndexColumns<TTerms extends readonly IndexTerm[]> = { [K in keyof TTerms]: IndexTermExpression<TTerms[K]>; };
|
|
3139
|
+
type IndexIncludedColumns<TIndex> = TIndex extends {
|
|
3140
|
+
readonly includedColumns?: infer TIncluded;
|
|
3141
|
+
} ? Exclude<TIncluded, undefined> extends readonly unknown[] ? Exclude<TIncluded, undefined> : never : never;
|
|
3142
|
+
type InvalidIncludedColumns<TIncluded, TName extends string> = TIncluded extends readonly unknown[] ? Exclude<DependenciesOf<TIncluded[number]>, ColumnDependency<TableIdentity<TName>, string>> : never;
|
|
3143
|
+
type ConstraintsOf<T> = T extends {
|
|
3144
|
+
readonly constraints: infer TConstraints extends SourceConstraintsRecord;
|
|
3145
|
+
} ? TConstraints : {};
|
|
3146
|
+
type IndexesOf<T> = T extends {
|
|
3147
|
+
readonly indexes: infer TIndexes extends SourceIndexesRecord;
|
|
3148
|
+
} ? TIndexes : {};
|
|
3149
|
+
type HasMatchingConstraint<TColumns, TConstraints> = TConstraints extends SourceConstraintsRecord ? true extends { [K in keyof TConstraints]: TConstraints[K] extends (infer TConstraint) ? TConstraint extends {
|
|
3150
|
+
readonly kind: 'primary-key' | 'unique';
|
|
3151
|
+
readonly columns: infer TCandidate extends readonly unknown[];
|
|
3152
|
+
} ? TColumns extends readonly unknown[] ? SameColumnTuple<TColumns, TCandidate> : false : false : false; }[keyof TConstraints] ? true : false : false;
|
|
3153
|
+
type HasMatchingIndex<TColumns, TIndexes> = TIndexes extends SourceIndexesRecord ? true extends { [K in keyof TIndexes]: TIndexes[K] extends (infer TIndex) ? TIndex extends {
|
|
3154
|
+
readonly terms: infer TTerms extends readonly IndexTerm[];
|
|
3155
|
+
readonly candidateKey: infer TCandidateKey;
|
|
3156
|
+
} ? [TCandidateKey] extends [true] ? TColumns extends readonly unknown[] ? SameColumnTuple<TColumns, IndexColumns<TTerms>> : false : false : false : false; }[keyof TIndexes] ? true : false : false;
|
|
3157
|
+
type TargetMetadata<TTarget extends ForeignKeyTarget, TName extends string, TConstraints extends SourceConstraintsRecord, TIndexes extends SourceIndexesRecord> = [SourceIdentity<TTarget['table']>] extends [TableIdentity<TName>] ? [TableIdentity<TName>] extends [SourceIdentity<TTarget['table']>] ? readonly [TConstraints, TIndexes] : readonly [ConstraintsOf<TTarget['table']>, IndexesOf<TTarget['table']>] : readonly [ConstraintsOf<TTarget['table']>, IndexesOf<TTarget['table']>];
|
|
3158
|
+
type InvalidForeignKey<TConstraint extends ForeignKeyConstraint, TName extends string, TConstraints extends SourceConstraintsRecord, TIndexes extends SourceIndexesRecord> = ResolvedTarget<TConstraint['target']> extends (infer TTarget) ? TTarget extends ForeignKeyTarget ? Exclude<DependenciesOf<TTarget['columns'][number]>, ColumnDependency<SourceIdentity<TTarget['table']>, string>> extends never ? TargetMetadata<TTarget, TName, TConstraints, TIndexes> extends readonly [infer TTargetConstraints, infer TTargetIndexes] ? HasMatchingConstraint<TTarget['columns'], TTargetConstraints> extends true ? never : HasMatchingIndex<TTarget['columns'], TTargetIndexes> extends true ? never : TConstraint : TConstraint : TConstraint : TConstraint : TConstraint;
|
|
3159
|
+
type InvalidConstraint<TConstraint, TName extends string, TConstraints extends SourceConstraintsRecord, TIndexes extends SourceIndexesRecord> = TConstraint extends ForeignKeyConstraint ? InvalidForeignKey<TConstraint, TName, TConstraints, TIndexes> : TConstraint extends CheckConstraint<infer TExpression> ? InvalidExpression<TExpression, TName> : never;
|
|
3160
|
+
type InvalidConstraints<TName extends string, TConstraints extends SourceConstraintsRecord, TIndexes extends SourceIndexesRecord> = TConstraints[keyof TConstraints] extends (infer TConstraint) ? InvalidConstraint<TConstraint, TName, TConstraints, TIndexes> : never;
|
|
3161
|
+
type InvalidIndex<TIndex, TName extends string> = TIndex extends {
|
|
3162
|
+
readonly terms: infer TTerms extends readonly IndexTerm[];
|
|
3163
|
+
readonly predicate: infer TPredicate;
|
|
3164
|
+
} ? InvalidExpression<IndexTermExpression<TTerms[number]>, TName> | (TPredicate extends AnyExpression ? SqlTypeOf<TPredicate> extends SqlBoolean ? InvalidExpression<TPredicate, TName> : TPredicate : never) | InvalidIncludedColumns<IndexIncludedColumns<TIndex>, TName> : TIndex;
|
|
3165
|
+
type InvalidIndexes<TName extends string, TIndexes extends SourceIndexesRecord> = TIndexes[keyof TIndexes] extends (infer TIndex) ? InvalidIndex<TIndex, TName> : never;
|
|
3166
|
+
type ConstraintValidation<TName extends string, TConstraints extends SourceConstraintsRecord, TIndexes extends SourceIndexesRecord> = [InvalidConstraintDependencies<TName, TConstraints>] extends [never] ? [InvalidConstraints<TName, TConstraints, TIndexes>] extends [never] ? [InvalidIndexes<TName, TIndexes>] extends [never] ? unknown : {
|
|
3167
|
+
readonly __invalid_indexes__: InvalidIndexes<TName, TIndexes>;
|
|
3168
|
+
} : {
|
|
3169
|
+
readonly __invalid_constraints__: InvalidConstraints<TName, TConstraints, TIndexes>;
|
|
3170
|
+
} : {
|
|
3171
|
+
readonly __invalid_constraint_columns__: InvalidConstraintDependencies<TName, TConstraints>;
|
|
3172
|
+
};
|
|
3173
|
+
type TableMetadataCallback<TName extends string, TDefinitions extends TableDefinitions, TConstraints extends SourceConstraintsRecord, TIndexes extends SourceIndexesRecord> = (table: Table<TName, TDefinitions>) => TableOptions<TConstraints, TIndexes> & ConstraintValidation<TName, TConstraints, TIndexes>;
|
|
3174
|
+
declare function table<const TName extends string, const TDefinitions extends TableDefinitions>(name: TName, definitions: TDefinitions): Table<TName, TDefinitions>;
|
|
3175
|
+
declare function table<const TName extends string, const TDefinitions extends TableDefinitions, const TConstraints extends SourceConstraintsRecord, const TIndexes extends SourceIndexesRecord>(name: TName, definitions: TDefinitions, metadata: TableMetadataCallback<TName, TDefinitions, TConstraints, TIndexes>): Table<TName, TDefinitions, TConstraints, TIndexes>;
|
|
3176
|
+
//#endregion
|
|
3177
|
+
//#region src/schema/source.d.ts
|
|
3178
|
+
declare const sourceIdentity: unique symbol;
|
|
3179
|
+
type SourceKind = 'table' | 'table-alias' | 'query-alias' | 'lateral' | 'cte' | 'excluded' | 'custom' | 'table-function';
|
|
3180
|
+
/** SQL semantic domains keyed by the application fields of a source row. */
|
|
3181
|
+
type SourceSqlTypes<TRow extends object> = { readonly [K in keyof TRow]: AnySqlType; };
|
|
3182
|
+
/** A source SQL-domain map used when no stronger metadata was declared. */
|
|
3183
|
+
type UnknownSourceSqlTypes<TRow extends object> = { readonly [K in keyof TRow]: SqlUnknown; };
|
|
3184
|
+
type SourceColumns<TRow extends object, TIdentity, TSqlTypes extends SourceSqlTypes<TRow> = UnknownSourceSqlTypes<TRow>> = { readonly [K in keyof TRow]: K extends string ? ColumnReference<K, ResultMeta<Required<TRow>[K], TIdentity, TSqlTypes[K]> | RequiresSourceMeta<TIdentity> | ExpressionMeta<ColumnDependency<TIdentity, K>>> : never; };
|
|
3185
|
+
interface Source<TIdentity = unknown, TRow extends object = Record<string, unknown>, TMetadata = never, TSqlTypes extends SourceSqlTypes<TRow> = UnknownSourceSqlTypes<TRow>, TConstraints extends SourceConstraintsRecord = {}> extends Fragment<ResultMeta<readonly TRow[]> | ProvidesSourceMeta<TIdentity, TRow> | TMetadata> {
|
|
3186
|
+
readonly sourceKind: SourceKind;
|
|
3187
|
+
readonly [sourceIdentity]: TIdentity;
|
|
3188
|
+
readonly reference: Fragment<never>;
|
|
3189
|
+
readonly columns: SourceColumns<TRow, TIdentity, TSqlTypes>;
|
|
3190
|
+
readonly constraints: TConstraints;
|
|
3191
|
+
}
|
|
3192
|
+
type AnySource = Source<any, any, any, any, any>;
|
|
3193
|
+
/** The source-provision fact carried by a source-producing fragment. */
|
|
3194
|
+
type SourceProvision<T> = Extract<MetadataOf<T>, {
|
|
3195
|
+
readonly kind: 'provides-source';
|
|
3196
|
+
}>;
|
|
3197
|
+
type ProvidedSourceIdentity<T> = SourceProvision<T> extends ProvidesSourceMeta<infer TIdentity, any> ? TIdentity : never;
|
|
3198
|
+
type ProvidedSourceRow<T> = SourceProvision<T> extends ProvidesSourceMeta<any, infer TRow> ? TRow : never;
|
|
3199
|
+
type SourceIdentity<T> = T extends Source<infer TIdentity, any, any, any, any> ? TIdentity : never;
|
|
3200
|
+
type SourceRow<T> = T extends Source<any, infer TRow, any, any, any> ? TRow : never;
|
|
3201
|
+
/** Extract the field-to-SQL-domain map retained by a source. */
|
|
3202
|
+
type SourceSqlTypeMap<T> = T extends {
|
|
3203
|
+
readonly definitions: infer TDefinitions extends TableDefinitions;
|
|
3204
|
+
} ? TableSqlTypes<TDefinitions> : T extends Source<any, infer TRow, any, infer TSqlTypes, any> ? TSqlTypes & SourceSqlTypes<TRow> : never;
|
|
3205
|
+
/** Structured schema constraints declared for a source. */
|
|
3206
|
+
type SourceConstraints<T> = T extends {
|
|
3207
|
+
readonly constraints: infer TConstraints extends SourceConstraintsRecord;
|
|
3208
|
+
} ? TConstraints : never;
|
|
3209
|
+
interface CustomSourceOptions<TIdentity, TDefinitions extends TableDefinitions> {
|
|
3210
|
+
/** The type-level identity used by columns and source-scope validation. */
|
|
3211
|
+
readonly identity: TIdentity;
|
|
3212
|
+
/** The SQL fragment that renders the relation in FROM or JOIN. */
|
|
3213
|
+
readonly render: RenderFunction;
|
|
3214
|
+
/** The qualified reference used when rendering its columns. */
|
|
3215
|
+
readonly reference: Fragment<never>;
|
|
3216
|
+
/** Output definitions used to build the source's typed columns. */
|
|
3217
|
+
readonly columns: TDefinitions;
|
|
3218
|
+
readonly sourceKind?: SourceKind;
|
|
3219
|
+
}
|
|
3220
|
+
type CustomSource<TIdentity, TDefinitions extends TableDefinitions> = Source<TIdentity, TableRow<TDefinitions>, never, TableSqlTypes<TDefinitions>> & {
|
|
3221
|
+
readonly identity: TIdentity;
|
|
3222
|
+
readonly definitions: TDefinitions;
|
|
3223
|
+
readonly columns: SourceColumns<TableRow<TDefinitions>, TIdentity, TableSqlTypes<TDefinitions>>;
|
|
3224
|
+
} & SourceColumns<TableRow<TDefinitions>, TIdentity, TableSqlTypes<TDefinitions>>;
|
|
3225
|
+
declare function createSource<TIdentity, TRow extends object, TMetadata = never, TSqlTypes extends SourceSqlTypes<TRow> = UnknownSourceSqlTypes<TRow>, TConstraints extends SourceConstraintsRecord = {}>(sourceKind: SourceKind, render: RenderFunction, reference: Fragment<never>, constraints?: TConstraints): Source<TIdentity, TRow, TMetadata, TSqlTypes, TConstraints>;
|
|
3226
|
+
/**
|
|
3227
|
+
* Create a typed source-producing fragment for a custom FROM relation such as
|
|
3228
|
+
* a table-valued function. The renderer owns the relation syntax and may bind
|
|
3229
|
+
* values through context.parameter(); the source identity and output columns
|
|
3230
|
+
* remain available to the normal FROM/JOIN scope checks.
|
|
3231
|
+
*/
|
|
3232
|
+
declare function customSource<const TIdentity, const TDefinitions extends TableDefinitions>(options: CustomSourceOptions<TIdentity, TDefinitions>): CustomSource<TIdentity, TDefinitions>;
|
|
3233
|
+
/**
|
|
3234
|
+
* Add convenient direct column properties without allowing a column name to
|
|
3235
|
+
* overwrite the source's rendering or metadata primitives.
|
|
3236
|
+
*/
|
|
3237
|
+
declare function exposeColumns(target: object, columns: Record<string, unknown>): void;
|
|
3238
|
+
//#endregion
|
|
3239
|
+
//#region src/query/types.d.ts
|
|
3240
|
+
type Row = Record<string, unknown>;
|
|
3241
|
+
type QueryKind = 'select' | 'set' | 'insert' | 'update' | 'delete';
|
|
3242
|
+
interface Query<TRow extends object = Row, TCardinality extends QueryCardinality = QueryCardinality, TMetadata = never, TSqlTypes = SourceSqlTypes<TRow>> extends Fragment<ResultMeta<readonly TRow[]> | CardinalityMeta<TCardinality> | TMetadata> {
|
|
3243
|
+
readonly queryKind: QueryKind;
|
|
3244
|
+
readonly row: TRow;
|
|
3245
|
+
/** Type-only SQL domains of the named query projection. */
|
|
3246
|
+
readonly sqlTypes?: TSqlTypes;
|
|
3247
|
+
}
|
|
3248
|
+
type AnyQuery = Query<any, any, any, any>;
|
|
3249
|
+
type QueryRow<T> = T extends Query<infer TRow, any, any, any> ? TRow : never;
|
|
3250
|
+
/** Extract the field-to-SQL-domain map retained by a named query projection. */
|
|
3251
|
+
type QuerySqlTypeMap<T> = T extends Query<infer TRow, any, any, infer TSqlTypes> ? TSqlTypes & SourceSqlTypes<TRow> : never;
|
|
3252
|
+
//#endregion
|
|
3253
|
+
//#region src/core/dialect.d.ts
|
|
3254
|
+
/** Capabilities whose syntax must be explicitly supported by a dialect. */
|
|
3255
|
+
type DialectCapability = 'ilike' | 'json' | 'on-conflict' | 'row-locking';
|
|
3256
|
+
/**
|
|
3257
|
+
* Optional dialect hook used by schema expressions when a JavaScript value
|
|
3258
|
+
* must become SQL text instead of a query parameter.
|
|
3259
|
+
*
|
|
3260
|
+
* The hook is deliberately separate from {@link Dialect.placeholder}: schema
|
|
3261
|
+
* metadata is parameter-free and must never render a query placeholder.
|
|
3262
|
+
*/
|
|
3263
|
+
type SchemaLiteralRenderer = (value: unknown) => string;
|
|
3264
|
+
/** Scalar application types supported by the portable JSON renderer. */
|
|
3265
|
+
type JsonScalarKind = 'text' | 'number' | 'boolean';
|
|
3266
|
+
/** Dialect policy for portable scalar JSON reads and path existence checks. */
|
|
3267
|
+
interface DialectJson {
|
|
3268
|
+
renderScalar(context: RenderContext, document: AnyFragment, path: readonly (string | number)[], kind: JsonScalarKind): void;
|
|
3269
|
+
renderExists(context: RenderContext, document: AnyFragment, path: readonly (string | number)[]): void;
|
|
3270
|
+
}
|
|
3271
|
+
type PaginationKind = 'offset' | 'fetch';
|
|
3272
|
+
/** Logical built-in targets that a dialect can spell in CAST expressions. */
|
|
3273
|
+
type PortableCastType = 'integer' | 'decimal' | 'text' | 'boolean' | 'date' | 'timestamp' | 'uuid' | 'json' | 'bigint' | 'binary';
|
|
3274
|
+
/** A logical cast target whose concrete spelling is selected by a dialect. */
|
|
3275
|
+
interface PortableCastTarget<TType extends PortableCastType = PortableCastType> {
|
|
3276
|
+
readonly kind: 'portable-cast';
|
|
3277
|
+
readonly type: TType;
|
|
3278
|
+
}
|
|
3279
|
+
/** A trusted raw cast target supplied by a custom definition. */
|
|
3280
|
+
interface NamedCastTarget<TTypeName extends string = string> {
|
|
3281
|
+
readonly kind: 'named-cast';
|
|
3282
|
+
readonly typeName: TTypeName;
|
|
3283
|
+
}
|
|
3284
|
+
/** Runtime target carried by a definition that can be used with cast(). */
|
|
3285
|
+
type CastTarget = PortableCastTarget | NamedCastTarget;
|
|
3286
|
+
/** Dialect-specific spellings for built-in logical CAST targets. */
|
|
3287
|
+
type DialectCastTypes = Readonly<Partial<Record<PortableCastType, string>>>;
|
|
3288
|
+
interface PaginationPart {
|
|
3289
|
+
readonly kind: PaginationKind;
|
|
3290
|
+
readonly rows: number;
|
|
3291
|
+
readonly direction?: 'FIRST' | 'NEXT';
|
|
3292
|
+
}
|
|
3293
|
+
interface DialectPagination {
|
|
3294
|
+
/** Render a complete pagination group in dialect-specific syntax. */
|
|
3295
|
+
readonly render: (context: RenderContext, parts: readonly PaginationPart[]) => void;
|
|
3296
|
+
}
|
|
3297
|
+
type RowLockMode = 'update' | 'no-key-update' | 'share' | 'key-share';
|
|
3298
|
+
type RowLockWaitPolicy = 'default' | 'nowait' | 'skip-locked';
|
|
3299
|
+
interface DialectRowLocking {
|
|
3300
|
+
/** Render a dialect-supported row-locking clause. */
|
|
3301
|
+
readonly render: (context: RenderContext, mode: RowLockMode, wait: RowLockWaitPolicy) => void;
|
|
3302
|
+
}
|
|
3303
|
+
/** Output modes accepted by first-party EXPLAIN policies. */
|
|
3304
|
+
type ExplainFormat = 'text' | 'json' | 'xml' | 'yaml' | 'tree' | 'traditional' | 'query-plan' | 'bytecode';
|
|
3305
|
+
/** Dialect-independent EXPLAIN switches passed to a dialect policy. */
|
|
3306
|
+
interface ExplainRenderOptions {
|
|
3307
|
+
readonly analyze?: boolean;
|
|
3308
|
+
readonly verbose?: boolean;
|
|
3309
|
+
readonly buffers?: boolean;
|
|
3310
|
+
readonly format?: ExplainFormat;
|
|
3311
|
+
/** SQLite's high-level query-plan mode when true, bytecode when false. */
|
|
3312
|
+
readonly queryPlan?: boolean;
|
|
3313
|
+
}
|
|
3314
|
+
/** Dialect policy for wrapping one rendered query in EXPLAIN syntax. */
|
|
3315
|
+
interface DialectExplain {
|
|
3316
|
+
readonly render: (statement: string, queryKind: QueryKind, options: ExplainRenderOptions) => string;
|
|
3317
|
+
}
|
|
3318
|
+
interface Dialect<TCapabilities extends DialectCapability = DialectCapability> {
|
|
3319
|
+
readonly name: string;
|
|
3320
|
+
quoteIdentifier(identifier: string): string;
|
|
3321
|
+
placeholder(position: number): string;
|
|
3322
|
+
readonly pagination?: DialectPagination;
|
|
3323
|
+
/** Rendering policy for the typed SELECT row-locking clause. */
|
|
3324
|
+
readonly rowLocking?: DialectRowLocking;
|
|
3325
|
+
/** Rendering policy for Qubu's portable JSON operations. */
|
|
3326
|
+
readonly json?: DialectJson;
|
|
3327
|
+
/** Overrides for the standard spelling of logical CAST targets. */
|
|
3328
|
+
readonly castTypes?: DialectCastTypes;
|
|
3329
|
+
/** Optional SQL literal policy used by deterministic schema expressions. */
|
|
3330
|
+
readonly renderSchemaLiteral?: SchemaLiteralRenderer;
|
|
3331
|
+
/** Optional policy for dialect-specific EXPLAIN syntax and options. */
|
|
3332
|
+
readonly explain?: DialectExplain;
|
|
3333
|
+
/** Capabilities advertised by this dialect at the rendering boundary. */
|
|
3334
|
+
readonly capabilities?: readonly TCapabilities[];
|
|
3335
|
+
}
|
|
3336
|
+
interface DialectOptions<TCapabilities extends Exclude<DialectCapability, 'json'> = never, TJson extends DialectJson | undefined = DialectJson | undefined> {
|
|
3337
|
+
readonly name: string;
|
|
3338
|
+
readonly quoteIdentifier?: (identifier: string) => string;
|
|
3339
|
+
readonly placeholder: (position: number) => string;
|
|
3340
|
+
readonly pagination?: DialectPagination;
|
|
3341
|
+
/** Rendering policy for the typed SELECT row-locking clause. */
|
|
3342
|
+
readonly rowLocking?: DialectRowLocking;
|
|
3343
|
+
readonly json?: TJson;
|
|
3344
|
+
/** Overrides for the standard spelling of logical CAST targets. */
|
|
3345
|
+
readonly castTypes?: DialectCastTypes;
|
|
3346
|
+
/** Optional SQL literal policy used by deterministic schema expressions. */
|
|
3347
|
+
readonly renderSchemaLiteral?: SchemaLiteralRenderer;
|
|
3348
|
+
/** Optional policy for dialect-specific EXPLAIN syntax and options. */
|
|
3349
|
+
readonly explain?: DialectExplain;
|
|
3350
|
+
readonly capabilities?: readonly TCapabilities[];
|
|
3351
|
+
}
|
|
3352
|
+
/** Resolve a logical or explicitly named CAST target for a dialect. */
|
|
3353
|
+
declare function resolveCastTarget(dialect: Dialect, target: CastTarget): string;
|
|
3354
|
+
/**
|
|
3355
|
+
* Create a dialect from the few rendering decisions that SQL builders need
|
|
3356
|
+
* to leave open. More involved syntax can be supplied as a custom fragment.
|
|
3357
|
+
*/
|
|
3358
|
+
declare function createDialect<const TCapabilities extends Exclude<DialectCapability, 'json'> = never>(options: DialectOptions<TCapabilities, DialectJson> & {
|
|
3359
|
+
readonly json: DialectJson;
|
|
3360
|
+
}): Dialect<TCapabilities | 'json'>;
|
|
3361
|
+
declare function createDialect<const TCapabilities extends Exclude<DialectCapability, 'json'> = never>(options: DialectOptions<TCapabilities, undefined>): Dialect<TCapabilities>;
|
|
3362
|
+
/**
|
|
3363
|
+
* Check a capability at runtime for callers that intentionally bypass the
|
|
3364
|
+
* typed render boundary or use a dialect supplied by an older integration.
|
|
3365
|
+
*/
|
|
3366
|
+
declare function assertDialectCapability(dialect: Dialect, capability: DialectCapability): void;
|
|
3367
|
+
//#endregion
|
|
3368
|
+
//#region src/snapshot/types.d.ts
|
|
3369
|
+
/** The JSON object tag used by Qubu schema snapshots. */
|
|
3370
|
+
declare const schemaSnapshotFormat: "qubu-schema";
|
|
3371
|
+
/** The first canonical schema snapshot format version. */
|
|
3372
|
+
declare const schemaSnapshotVersion: 1;
|
|
3373
|
+
/** The first version of the dialect-extension envelope. */
|
|
3374
|
+
declare const schemaSnapshotDialectVersion: 1;
|
|
3375
|
+
/** The first version of the built-in naming-policy description. */
|
|
3376
|
+
declare const schemaSnapshotNamingPolicyVersion: 1;
|
|
3377
|
+
/** The neutral dialect used when no SQL engine adapter is selected. */
|
|
3378
|
+
declare const neutralSnapshotDialect: SnapshotDialect;
|
|
3379
|
+
/** A dialect identifier and independently versioned extension contract. */
|
|
3380
|
+
interface SnapshotDialect {
|
|
3381
|
+
readonly name: string;
|
|
3382
|
+
readonly version: number;
|
|
3383
|
+
}
|
|
3384
|
+
/** Naming-policy identity retained by a snapshot, without executable code. */
|
|
3385
|
+
interface SnapshotNamingPolicy {
|
|
3386
|
+
readonly name: string;
|
|
3387
|
+
readonly version: number;
|
|
3388
|
+
}
|
|
3389
|
+
/** A JSON-safe representation of a non-finite JavaScript number. */
|
|
3390
|
+
interface SnapshotSpecialNumber {
|
|
3391
|
+
readonly $number: 'NaN' | 'Infinity' | '-Infinity';
|
|
3392
|
+
}
|
|
3393
|
+
/** A JSON-safe representation of a JavaScript bigint. */
|
|
3394
|
+
interface SnapshotBigInt {
|
|
3395
|
+
readonly $bigint: string;
|
|
3396
|
+
}
|
|
3397
|
+
/** Values accepted inside versioned dialect extension data. */
|
|
3398
|
+
type SnapshotJsonValue = null | boolean | string | number | SnapshotSpecialNumber | SnapshotBigInt | readonly SnapshotJsonValue[] | {
|
|
3399
|
+
readonly [key: string]: SnapshotJsonValue;
|
|
3400
|
+
};
|
|
3401
|
+
/** A dialect-owned payload kept separate from portable schema facts. */
|
|
3402
|
+
interface SnapshotDialectExtension {
|
|
3403
|
+
readonly dialect: string;
|
|
3404
|
+
readonly version: number;
|
|
3405
|
+
readonly data: SnapshotJsonValue;
|
|
3406
|
+
}
|
|
3407
|
+
/** A portable or dialect-owned physical column declaration. */
|
|
3408
|
+
type SnapshotStorage = {
|
|
3409
|
+
readonly kind: 'portable';
|
|
3410
|
+
readonly type: string;
|
|
3411
|
+
} | {
|
|
3412
|
+
readonly kind: 'native';
|
|
3413
|
+
readonly dialect: string;
|
|
3414
|
+
readonly type: string;
|
|
3415
|
+
/** SQLite's derived type affinity, when the selected adapter records it. */
|
|
3416
|
+
readonly affinity?: 'blob' | 'integer' | 'numeric' | 'real' | 'text';
|
|
3417
|
+
};
|
|
3418
|
+
/** A deterministic expression after it crosses the snapshot data boundary. */
|
|
3419
|
+
interface SnapshotExpression {
|
|
3420
|
+
readonly kind: 'expression';
|
|
3421
|
+
readonly expressionKind: string;
|
|
3422
|
+
/** Canonical parameter-free text for the selected schema expression dialect. */
|
|
3423
|
+
readonly sql: string;
|
|
3424
|
+
/** Present only for an explicitly dialect-tagged unsafe expression. */
|
|
3425
|
+
readonly dialect?: string;
|
|
3426
|
+
}
|
|
3427
|
+
/** A default value retained independently from insert-write behavior. */
|
|
3428
|
+
type SnapshotDefault = {
|
|
3429
|
+
readonly kind: 'literal';
|
|
3430
|
+
readonly value: SnapshotLiteral;
|
|
3431
|
+
} | {
|
|
3432
|
+
readonly kind: 'expression';
|
|
3433
|
+
readonly expression: SnapshotExpression;
|
|
3434
|
+
} | {
|
|
3435
|
+
readonly kind: 'external';
|
|
3436
|
+
};
|
|
3437
|
+
/** Canonical literal values accepted by neutral schema metadata. */
|
|
3438
|
+
type SnapshotLiteral = {
|
|
3439
|
+
readonly kind: 'null';
|
|
3440
|
+
} | {
|
|
3441
|
+
readonly kind: 'boolean';
|
|
3442
|
+
readonly value: boolean;
|
|
3443
|
+
} | {
|
|
3444
|
+
readonly kind: 'string';
|
|
3445
|
+
readonly value: string;
|
|
3446
|
+
} | {
|
|
3447
|
+
readonly kind: 'number';
|
|
3448
|
+
readonly value: string;
|
|
3449
|
+
} | {
|
|
3450
|
+
readonly kind: 'bigint';
|
|
3451
|
+
readonly value: string;
|
|
3452
|
+
};
|
|
3453
|
+
/** A generated-column expression and its storage mode. */
|
|
3454
|
+
type SnapshotGeneratedColumn = {
|
|
3455
|
+
readonly kind: 'expression';
|
|
3456
|
+
readonly expression: SnapshotExpression;
|
|
3457
|
+
readonly mode: 'stored' | 'virtual';
|
|
3458
|
+
} | {
|
|
3459
|
+
readonly kind: 'external';
|
|
3460
|
+
};
|
|
3461
|
+
/** Identity behavior is deliberately separate from generated expressions. */
|
|
3462
|
+
interface SnapshotIdentity {
|
|
3463
|
+
readonly kind: 'identity';
|
|
3464
|
+
readonly generation: 'always' | 'by-default';
|
|
3465
|
+
readonly dialect?: SnapshotDialectExtension;
|
|
3466
|
+
}
|
|
3467
|
+
/** A canonical column record keyed by its stable logical field ID. */
|
|
3468
|
+
interface SnapshotColumn {
|
|
3469
|
+
readonly id: string;
|
|
3470
|
+
readonly physicalName: string;
|
|
3471
|
+
readonly nullable: boolean;
|
|
3472
|
+
readonly hasDefault: boolean;
|
|
3473
|
+
readonly generated: boolean;
|
|
3474
|
+
readonly storage?: SnapshotStorage;
|
|
3475
|
+
readonly default?: SnapshotDefault;
|
|
3476
|
+
readonly generatedColumn?: SnapshotGeneratedColumn;
|
|
3477
|
+
readonly identity?: SnapshotIdentity;
|
|
3478
|
+
/** MySQL's parameter-free column update expression, when supported. */
|
|
3479
|
+
readonly onUpdate?: SnapshotExpression;
|
|
3480
|
+
}
|
|
3481
|
+
/** An expression or bare column used by an index. */
|
|
3482
|
+
type SnapshotIndexTermExpression = {
|
|
3483
|
+
readonly kind: 'column';
|
|
3484
|
+
readonly column: string;
|
|
3485
|
+
} | {
|
|
3486
|
+
readonly kind: 'expression';
|
|
3487
|
+
readonly expression: SnapshotExpression;
|
|
3488
|
+
};
|
|
3489
|
+
/** One ordered index term. */
|
|
3490
|
+
type SnapshotIndexTerm = SnapshotIndexTermExpression | {
|
|
3491
|
+
readonly kind: 'order';
|
|
3492
|
+
readonly expression: SnapshotIndexTermExpression;
|
|
3493
|
+
readonly direction?: 'ASC' | 'DESC';
|
|
3494
|
+
readonly nulls?: 'FIRST' | 'LAST';
|
|
3495
|
+
};
|
|
3496
|
+
/** Common key metadata shared by primary and strict unique constraints. */
|
|
3497
|
+
interface SnapshotKeyConstraint {
|
|
3498
|
+
readonly id: string;
|
|
3499
|
+
readonly kind: 'primary-key' | 'unique';
|
|
3500
|
+
readonly physicalName: string;
|
|
3501
|
+
readonly columns: readonly string[];
|
|
3502
|
+
readonly deferrable?: boolean;
|
|
3503
|
+
readonly initially?: 'immediate' | 'deferred';
|
|
3504
|
+
readonly dialect?: SnapshotDialectExtension;
|
|
3505
|
+
}
|
|
3506
|
+
/** Nullable database uniqueness, intentionally not a candidate-key proof. */
|
|
3507
|
+
interface SnapshotUniqueConstraint {
|
|
3508
|
+
readonly id: string;
|
|
3509
|
+
readonly kind: 'unique-constraint';
|
|
3510
|
+
readonly physicalName: string;
|
|
3511
|
+
readonly columns: readonly string[];
|
|
3512
|
+
readonly nulls: 'distinct' | 'not-distinct';
|
|
3513
|
+
readonly deferrable?: boolean;
|
|
3514
|
+
readonly initially?: 'immediate' | 'deferred';
|
|
3515
|
+
readonly dialect?: SnapshotDialectExtension;
|
|
3516
|
+
}
|
|
3517
|
+
/** A foreign key whose target is represented only by logical IDs. */
|
|
3518
|
+
interface SnapshotForeignKey {
|
|
3519
|
+
readonly id: string;
|
|
3520
|
+
readonly kind: 'foreign-key';
|
|
3521
|
+
readonly physicalName: string;
|
|
3522
|
+
readonly columns: readonly string[];
|
|
3523
|
+
readonly target: {
|
|
3524
|
+
readonly table: string;
|
|
3525
|
+
readonly columns: readonly string[];
|
|
3526
|
+
};
|
|
3527
|
+
readonly onUpdate?: 'no-action' | 'restrict' | 'cascade' | 'set-null' | 'set-default';
|
|
3528
|
+
readonly onDelete?: 'no-action' | 'restrict' | 'cascade' | 'set-null' | 'set-default';
|
|
3529
|
+
readonly match?: 'simple' | 'full' | 'partial';
|
|
3530
|
+
readonly deferrable?: boolean;
|
|
3531
|
+
readonly initially?: 'immediate' | 'deferred';
|
|
3532
|
+
readonly dialect?: SnapshotDialectExtension;
|
|
3533
|
+
}
|
|
3534
|
+
/** A table check constraint with a detached expression value. */
|
|
3535
|
+
interface SnapshotCheckConstraint {
|
|
3536
|
+
readonly id: string;
|
|
3537
|
+
readonly kind: 'check';
|
|
3538
|
+
readonly physicalName: string;
|
|
3539
|
+
readonly expression: SnapshotExpression;
|
|
3540
|
+
readonly deferrable?: boolean;
|
|
3541
|
+
readonly initially?: 'immediate' | 'deferred';
|
|
3542
|
+
readonly dialect?: SnapshotDialectExtension;
|
|
3543
|
+
}
|
|
3544
|
+
/** Every constraint represented by the v1 neutral model. */
|
|
3545
|
+
type SnapshotConstraint = SnapshotKeyConstraint | SnapshotUniqueConstraint | SnapshotForeignKey | SnapshotCheckConstraint;
|
|
3546
|
+
/** A canonical index record keyed by its stable logical ID. */
|
|
3547
|
+
interface SnapshotIndex {
|
|
3548
|
+
readonly id: string;
|
|
3549
|
+
readonly kind: 'index';
|
|
3550
|
+
readonly physicalName: string;
|
|
3551
|
+
readonly terms: readonly SnapshotIndexTerm[];
|
|
3552
|
+
readonly unique: boolean;
|
|
3553
|
+
readonly candidateKey: boolean;
|
|
3554
|
+
readonly predicate?: SnapshotExpression;
|
|
3555
|
+
readonly includedColumns?: readonly string[];
|
|
3556
|
+
readonly dialect?: SnapshotDialectExtension;
|
|
3557
|
+
}
|
|
3558
|
+
/** A table record keyed by its stable logical registry ID. */
|
|
3559
|
+
interface SnapshotTable {
|
|
3560
|
+
readonly id: string;
|
|
3561
|
+
readonly physicalName: string;
|
|
3562
|
+
readonly columns: readonly SnapshotColumn[];
|
|
3563
|
+
readonly constraints: readonly SnapshotConstraint[];
|
|
3564
|
+
readonly indexes: readonly SnapshotIndex[];
|
|
3565
|
+
}
|
|
3566
|
+
/** The immutable canonical schema snapshot envelope. */
|
|
3567
|
+
interface SchemaSnapshot {
|
|
3568
|
+
readonly format: typeof schemaSnapshotFormat;
|
|
3569
|
+
readonly version: typeof schemaSnapshotVersion;
|
|
3570
|
+
readonly dialect: SnapshotDialect;
|
|
3571
|
+
readonly namingPolicy: SnapshotNamingPolicy;
|
|
3572
|
+
readonly namespace?: string;
|
|
3573
|
+
readonly tables: readonly SnapshotTable[];
|
|
3574
|
+
}
|
|
3575
|
+
/** Schema-expression context supplied to a dialect adapter. */
|
|
3576
|
+
interface SnapshotExpressionContext {
|
|
3577
|
+
readonly mode: 'default' | 'generated' | 'check' | 'index';
|
|
3578
|
+
readonly path: readonly (string | number)[];
|
|
3579
|
+
readonly dialect: SchemaDialect;
|
|
3580
|
+
}
|
|
3581
|
+
/** Storage context supplied to a dialect adapter. */
|
|
3582
|
+
interface SnapshotStorageContext {
|
|
3583
|
+
readonly path: readonly (string | number)[];
|
|
3584
|
+
readonly dialect: SchemaDialect;
|
|
3585
|
+
}
|
|
3586
|
+
/** Extension context supplied to a dialect adapter. */
|
|
3587
|
+
interface SnapshotExtensionContext {
|
|
3588
|
+
readonly path: readonly (string | number)[];
|
|
3589
|
+
readonly dialect: SchemaDialect;
|
|
3590
|
+
}
|
|
3591
|
+
/** Context supplied to an adapter's dialect-capability validation hook. */
|
|
3592
|
+
interface SnapshotValidationContext {
|
|
3593
|
+
readonly path: readonly (string | number)[];
|
|
3594
|
+
readonly dialect: SchemaDialect;
|
|
3595
|
+
}
|
|
3596
|
+
/**
|
|
3597
|
+
* Adapter boundary for the common traversal. Schema hooks live on
|
|
3598
|
+
* `dialect.schema`; the adapter only selects that schema dialect, so
|
|
3599
|
+
* PostgreSQL, SQLite, and MySQL can share the query rendering policy without
|
|
3600
|
+
* taking ownership of canonical ordering or cross-reference validation.
|
|
3601
|
+
*/
|
|
3602
|
+
interface SchemaSnapshotAdapter<TCapabilities extends DialectCapability = DialectCapability> {
|
|
3603
|
+
/** The query dialect plus its schema hooks and metadata. */
|
|
3604
|
+
readonly dialect: SchemaDialect<TCapabilities>;
|
|
3605
|
+
}
|
|
3606
|
+
/** Structured diagnostic categories emitted by snapshot tooling. */
|
|
3607
|
+
type SnapshotDiagnosticCode = 'invalid-schema' | 'invalid-value' | 'unsupported-expression' | 'dialect-mismatch' | 'unresolved-reference' | 'invalid-snapshot' | 'unknown-field' | 'future-version' | 'invalid-cross-reference' | 'non-canonical' | 'unsupported-dialect-option';
|
|
3608
|
+
/** A path-addressed snapshot diagnostic suitable for CLI or editor output. */
|
|
3609
|
+
interface SnapshotDiagnostic {
|
|
3610
|
+
readonly code: SnapshotDiagnosticCode;
|
|
3611
|
+
readonly message: string;
|
|
3612
|
+
readonly path: readonly (string | number)[];
|
|
3613
|
+
readonly relatedPaths?: readonly (readonly (string | number)[])[];
|
|
3614
|
+
}
|
|
3615
|
+
/** Result returned by the strict snapshot decoder. */
|
|
3616
|
+
type SnapshotDecodeResult = {
|
|
3617
|
+
readonly ok: true;
|
|
3618
|
+
readonly value: SchemaSnapshot;
|
|
3619
|
+
} | {
|
|
3620
|
+
readonly ok: false;
|
|
3621
|
+
readonly diagnostics: readonly SnapshotDiagnostic[];
|
|
3622
|
+
};
|
|
3623
|
+
/** Result returned by a non-throwing schema traversal helper. */
|
|
3624
|
+
type SnapshotCreateResult = {
|
|
3625
|
+
readonly ok: true;
|
|
3626
|
+
readonly value: SchemaSnapshot;
|
|
3627
|
+
} | {
|
|
3628
|
+
readonly ok: false;
|
|
3629
|
+
readonly diagnostics: readonly SnapshotDiagnostic[];
|
|
3630
|
+
};
|
|
3631
|
+
/** A schema snapshot input accepted by the canonical encoder. */
|
|
3632
|
+
type SchemaSnapshotInput = SchemaSnapshot | Readonly<Record<string, unknown>>;
|
|
3633
|
+
/** Expose the schema generic in tooling declarations without widening APIs. */
|
|
3634
|
+
type AnySchema = Schema<any>;
|
|
3635
|
+
//#endregion
|
|
3636
|
+
export { PaginationKind as $, ExplainReadOptions as $a, ColumnReference as $c, lower as $i, SubqueryMeta as $l, RequiredOuterScope as $n, SourceConstraint as $o, SchemaOptions as $r, boolean as $s, SqliteIndexExtension as $t, SnapshotStorage as A, between as Aa, ResolvedColumnBehavior as Ac, offset as Ai, HasSubquery as Al, UpdateAssignments as An, QueryValidationError as Ao, SelectionSqlTypes as Ar, ColumnStorageDeclarationOf as As, createSource as At, CastTarget as B, asValue as Ba, SchemaDialectName as Bc, subtract as Bi, ProvidesOuterSourceMeta as Bl, MutationSqlTypes as Bn, ConstraintTiming as Bo, SchemaRenderContext as Br, NativeStorage as Bs, TableMetadataCallback as Bt, SnapshotIndexTerm as C, isDistinctFrom as Ca, GeneratedColumnMode as Cc, omit as Ci, ExpressionMeta as Cl, ExcludedSource as Cn, qubu as Co, leftJoin as Cr, ColumnIsGenerated as Cs, SourceIdentity as Ct, SqlTypeSatisfies as Cu, SnapshotLiteral as D, lte as Da, IdentityGeneration as Dc, rowLock as Di, GroupingKeysOf as Dl, excluded as Dn, RenderedQuery as Do, Selection as Dr, ColumnOutput as Ds, SourceSqlTypeMap as Dt, SnapshotKeyConstraint as E, lt as Ea, IdentityDialectExtension as Ec, RowLockOptions as Ei, GroupingDependenciesOf as El, doUpdate as En, RenderOptions as Eo, groupBy as Er, ColumnOptions as Es, SourceRow as Et, neutralSnapshotDialect as F, isTrue as Fa, externalGeneratedColumn as Fc, SelectClause as Fi, NullabilityOf as Fl, MutationQuery as Fn, CatalogCheckSql as Fo, RenderedSchemaExpression as Fr, ColumnStorageType as Fs, Table as Ft, DialectJson as G, DriverValueEncoder as Ga, assertSchemaDialectSupport as Gc, jsonPath as Gi, RequiresCapabilityMeta as Gl, returning as Gn, ForeignKeyOptions as Go, normalizeSchemaSql as Gr, PortableStorageType as Gs, table as Gt, DialectCapability as H, value as Ha, SchemaMetadataValidationError as Hc, jsonBoolean as Hi, QueryCardinality as Hl, ReturningClause as Hn, FieldLikeOptions as Ho, UnsafeSchemaSqlExpression as Hr, PortableColumnStorage as Hs, TableRow as Ht, schemaSnapshotDialectVersion as I, Operand as Ia, generatedColumn as Ic, add as Ii, NullableSourceMeta as Il, MutationReturning as In, CheckConstraint as Io, SchemaExpressionError as Ir, ColumnStorageTypeOf as Is, TableColumns as It, DialectRowLocking as J, ExecutionResult as Ja, generatedSchemaObjectName as Jc, over as Ji, RequiresOuterOf as Jl, AvailableOuterScope as Jn, KeyConstraint as Jo, schemaExpression as Jr, StorageDialectOf as Js, IndexTerm as Jt, DialectOptions as K, ExecutionOptions as Ka, dialectMismatchDiagnostic as Kc, jsonText as Ki, RequiresOf as Kl, correlate as Kn, ForeignKeyTarget as Ko, renderSchemaExpression as Kr, StorageDeclarationOf as Ks, IndexDialectExtension as Kt, schemaSnapshotFormat as L, OperandNullability as La, identityColumn as Lc, divide as Li, NullableSourcesOf as Ll, MutationReturningClause as Ln, CheckConstraintOptions as Lo, SchemaExpressionErrorCode as Lr, ColumnUpdateInput as Ls, TableDefinitions as Lt, SnapshotTable as M, notIn as Ma, SqliteIdentityExtension as Mc, distinct as Mi, InheritedMetadata as Ml, AllowAllClause as Mn, QueryValidationIssue as Mo, SchemaDialect as Mr, ColumnStorageDialectOf as Ms, exposeColumns as Mt, SnapshotUniqueConstraint as N, isNotNull as Na, canonicalLiteral as Nc, AnySelectClause as Ni, InheritedMetadataOf as Nl, MutationClause as Nn, AnyKeyColumn as No, SchemaDialectHooks as Nr, ColumnStorageKindOf as Ns, sourceIdentity as Nt, SnapshotNamingPolicy as O, ne as Oa, LiteralDefaultDescriptor as Oc, fetchFirst as Oi, GroupingMeta as Ol, onConflict as On, render as Oo, SelectionObject as Or, ColumnSqlType as Os, SourceSqlTypes as Ot, SnapshotValidationContext as P, isNull as Pa, externalDefault as Pc, ClausePlacement as Pi, MetadataOf as Pl, MutationKind as Pn, CatalogCheckExpression as Po, createSchemaDialect as Pr, ColumnStorageOf as Ps, AnyTable as Pt, NamedCastTarget as Q, ExplainPlanRow as Qa, ColumnDependency as Qc, concat as Qi, SqlTypeOf as Ql, MissingScope as Qn, ReferentialAction as Qo, SchemaNamingPolicy as Qr, binary as Qs, SourceIndexesRecord as Qt, schemaSnapshotNamingPolicyVersion as R, OperandSqlType as Ra, resolveColumnBehavior as Rc, modulo as Ri, OutputOf as Rl, MutationRow as Rn, ConstraintDialectExtension as Ro, SchemaExpressionInput as Rr, DialectNativeStorage as Rs, TableIdentity as Rt, SnapshotIndex as S, gte as Sa, GeneratedColumnDescriptor as Sc, SelectPart as Si, DependenciesOf as Sl, DoUpdateAction as Sn, explain as So, innerJoin as Sr, ColumnInsertInput as Ss, SourceConstraints as St, SqlTimestamp as Su, SnapshotJsonValue as T, like as Ta, IdentityDescriptor as Tc, RowLockClause as Ti, FragmentMeta as Tl, doNothing as Tn, RenderCapabilityValidation as To, rightJoin as Tr, ColumnOnUpdateOf as Ts, SourceProvision as Tt, SqlUuid as Tu, DialectCastTypes as U, cast as Ua, SchemaObjectIdentity as Uc, jsonExists as Ui, RenderContext as Ul, ReturningRow as Un, ForeignKeyConstraint as Uo, defineSchemaExpression as Ur, PortableStorage as Us, TableSqlTypes as Ut, Dialect as V, typedValue as Va, SchemaMetadataDiagnostic as Vc, JsonPath as Vi, ProvidesSourceMeta as Vl, allowAll as Vn, FieldLike as Vo, SchemaRenderOptions as Vr, NativeStorageDescriptor as Vs, TableOptions as Vt, DialectExplain as W, typedCast as Wa, SchemaObjectNameOptions as Wc, jsonNumber as Wi, RenderFunction as Wl, ReturningSqlTypes as Wn, ForeignKeyMatch as Wo, isUnsafeSchemaSql as Wr, PortableStorageDescriptor as Ws, TableUpdateInput as Wt, ExplainRenderOptions as X, ExplainOptions as Xa, materializeSchemaObjectIdentity as Xc, rowNumber as Xi, RequiresSourceMeta as Xl, ClauseScope as Xn, MysqlConstraintExtension as Xo, Schema as Xr, StorageTypeOf as Xs, PostgresIndexExtension as Xt, ExplainFormat as Y, ExplainMutationOptions as Ya, isValidSchemaObjectName as Yc, rank as Yi, RequiresOuterSourceMeta as Yl, AvailableScope as Yn, KeyConstraintOptions as Yo, unsafeSchemaSql as Yr, StorageOf as Ys, MysqlIndexExtension as Yt, JsonScalarKind as Z, ExplainOptionsFor as Za, materializeSchemaObjectRecord as Zc, coalesce as Zi, ResultMeta as Zl, GroupingValidation as Zn, PostgresConstraintExtension as Zo, SchemaDiagnostic as Zr, bigint as Zs, SourceIndex as Zt, SnapshotExpressionContext as _, notExists as _a, DefaultDescriptor as _c, and as _i, AnyFragment as _l, insertSelect as _n, StreamingTransactionalQueryAdapter as _o, FromScope as _r, ColumnDefinition as _s, CustomSourceOptions as _t, SqlOrderCompatible as _u, SnapshotBigInt as a, count as aa, nativeStorage as ac, defaultSchemaNamingPolicy as ai, ExpressionNullability as al, desc as an, QubuExplainableStreamingTransactionalClient as ao, RecursiveCteSource as ar, UniqueConstraintOptions as as, SchemaLiteralRenderer as at, sequence as au, SnapshotGeneratedColumn as b, eq as ba, ExternalDefaultDescriptor as bc, Omit$1 as bi, CardinalityMeta as bl, ConflictTarget as bn, execute as bo, crossJoin as br, ColumnHasDefault as bs, Source as bt, SqlText as bu, SnapshotConstraint as c, min as ca, portableStorage as cc, schemaNamingPolicyVersion as ci, ExpressionSqlType as cl, order as cn, QubuStreamingExplainableClient as co, recursiveCte as cr, catalogForeignKey as cs, resolveCastTarget as ct, SqlBinary as cu, SnapshotDefault as d, SqlTag as da, uuid as dc, LateralIdentity as di, isExpression as dl, DefaultValuesSource as dn, QubuTransaction as do, SetQuery as dr, primaryKey as ds, QueryKind as dt, SqlDecimal as du, upper as ea, column as ec, SchemaTableEntry as ei, expressionFragment as el, TableIndex as en, ExplainRequest as eo, RequiredScope as er, SourceConstraintsRecord as es, PaginationPart as et, VisibleDependenciesOf as eu, SnapshotDiagnostic as f, TypedSqlTag as fa, CanonicalLiteral as fc, LateralSource as fi, makeExpression as fl, InsertSelectSource as fn, QubuTransactionalClient as fo, except as fr, references as fs, QueryRow as ft, SqlEqualityComparable as fu, SnapshotExpression as g, inQuery as ga, ColumnDefaultInput as gc, lateral as gi, AggregateMeta as gl, insertInto as gn, StreamingQueryAdapter as go, FromClause as gr, ColumnDefaultOf as gs, CustomSource as gt, SqlNumericLike as gu, SnapshotDialectExtension as h, exists as ha, ColumnDefault as hc, alias as hi, AggregateDependenciesOf as hl, defaultValues as hn, StreamableQuery as ho, unionAll as hr, validateConstraintDialect as hs, AnySource as ht, SqlJson as hu, SchemaSnapshotInput as i, avg as ia, nativeColumn as ic, SchemaValidationError as ii, ExpressionKind as il, asc as in, QubuExplainableClient as io, CteSource as ir, UniqueConstraint as is, RowLockWaitPolicy as it, parenthesize as iu, SnapshotStorageContext as j, inList as ja, SchemaLiteralValue as jc, having as ji, HasWindow as jl, update as jn, QueryValidationErrorCode as jo, all as jr, ColumnStorageDescriptor as js, customSource as jt, SnapshotSpecialNumber as k, notLike as ka, MysqlIdentityExtension as kc, fetchNext as ki, HasAggregate as kl, UpdateAssignmentValue as kn, QueryTypeValidation as ko, SelectionOutput as kr, ColumnStorage as ks, UnknownSourceSqlTypes as kt, SnapshotCreateResult as l, sum as la, text as lc, AliasIdentity as li, ExpressionWithOutput as ll, orderBy as ln, QubuStreamingTransaction as lo, withCte as lr, check as ls, AnyQuery as lt, SqlBoolean as lu, SnapshotDialect as m, caseWhen as ma, ColumnBehaviorErrorCode as mc, QuerySource as mi, withDialectCapability as ml, ValuesSource as mn, QueryExecutor as mo, union as mr, uniqueConstraint as ms, Row as mt, SqlInteger as mu, SchemaSnapshot as n, schemaCall as na, integer as nc, SchemaTableRecord as ni, AnySchemaExpression as nl, validateIndexDialect as nn, ExplainableQueryAdapter as no, SelectCardinality as nr, SqliteConstraintExtension as ns, PortableCastType as nt, fragment as nu, SnapshotCheckConstraint as o, countDistinct as oa, nullable as oc, generatedTableName as oi, ExpressionOutput as ol, nullsFirst as on, QubuExplainableTransactionalClient as oo, WithClause as or, UniqueNullSemantics as os, assertDialectCapability as ot, AnySqlType as ou, SnapshotDiagnosticCode as p, sql as pa, ColumnBehaviorError as pc, QueryAliasIdentity as pi, markExpressionCategory as pl, InsertSource as pn, QueryAdapter as po, intersect as pr, unique as ps, QuerySqlTypeMap as pt, SqlEqualityCompatible as pu, DialectPagination as q, ExecutionRequest as qa, freezeSchemaMetadata as qc, denseRank as qi, RequiresOuterMetadataOf as ql, select as qn, ForeignKeyTargetInput as qo, renderSchemaSql as qr, StorageDescriptor as qs, IndexOptions as qt, SchemaSnapshotAdapter as r, typedCall as ra, json as rc, SchemaTableRegistry as ri, Expression as rl, OrderTerm as rn, QubuClient as ro, SelectQuery as rr, TableLike as rs, RowLockMode as rt, isFragment as ru, SnapshotColumn as s, max as sa, numeric as sc, schema as si, ExpressionRequires as sl, nullsLast as sn, QubuStreamingClient as so, cte as sr, catalogCheck as ss, createDialect as st, SqlBigInt as su, AnySchema as t, call as ta, date as tc, SchemaTableNames as ti, AnyExpression as tl, index as tn, ExplainResult as to, ScopeValidation as tr, SourceLike as ts, PortableCastTarget as tt, WindowMeta as tu, SnapshotDecodeResult as u, SqlFragment as ua, timestamp as uc, AliasedSource as ui, SchemaExpression as ul, deleteFrom as un, QubuStreamingTransactionalClient as uo, SetOperator as ur, foreignKey as us, Query as ut, SqlDate as uu, SnapshotExtensionContext as v, scalar as va, ExpressionDefaultDescriptor as vc, not as vi, CapabilitiesOf as vl, values as vn, TransactionOptions as vo, FromSource as vr, ColumnFromOptions as vs, ProvidedSourceIdentity as vt, SqlOrderable as vu, SnapshotIndexTermExpression as w, isNotDistinctFrom as wa, GeneratedDescriptor as wc, where as wi, Fragment as wl, OnConflictClause as wn, stream as wo, naturalJoin as wr, ColumnIsNullable as ws, SourceKind as wt, SqlUnknown as wu, SnapshotIdentity as x, gt as xa, ExternalGeneratedColumnDescriptor as xc, OmittableSelectClause as xi, CardinalityOf as xl, DoNothingAction as xn, executeRows as xo, fullJoin as xr, ColumnIdentityOf as xs, SourceColumns as xt, SqlTextLike as xu, SnapshotForeignKey as y, ComparisonValidation as ya, ExpressionGeneratedColumnDescriptor as yc, or as yi, CapabilityMetadataOf as yl, ConflictAction as yn, TransactionalQueryAdapter as yo, from as yr, ColumnGeneratedOf as ys, ProvidedSourceRow as yt, SqlSemanticType as yu, schemaSnapshotVersion as z, SqlCapabilityValidation as za, SchemaDialectExtension as zc, multiply as zi, ProvidesOuterOf as zl, MutationScopeValidation as zn, ConstraintOptions as zo, SchemaExpressionMode as zr, NativeColumnStorage as zs, TableInsertInput as zt };
|