better-convex 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate/index.d.ts +388 -0
- package/dist/aggregate/index.js +37 -0
- package/dist/{auth-client → auth/client}/index.js +1 -1
- package/dist/auth/http/index.d.ts +63 -0
- package/dist/auth/http/index.js +429 -0
- package/dist/auth/index.d.ts +19001 -185
- package/dist/auth/index.js +373 -686
- package/dist/{auth-nextjs → auth/nextjs}/index.d.ts +3 -4
- package/dist/{auth-nextjs → auth/nextjs}/index.js +3 -5
- package/dist/{caller-factory-B1FvYSKr.js → caller-factory-Dmgv8MLS.js} +15 -12
- package/dist/cli.mjs +2601 -13
- package/dist/codegen-Cz1idI3-.mjs +969 -0
- package/dist/{create-schema-orm-DplxTtYj.js → create-schema-orm-69VF4CFV.js} +4 -3
- package/dist/crpc/index.d.ts +2 -2
- package/dist/crpc/index.js +3 -3
- package/dist/{http-types-BRLY10NX.d.ts → http-types-BCf2wCgp.d.ts} +25 -25
- package/dist/meta-utils-DDVYp9Xf.js +117 -0
- package/dist/orm/index.d.ts +4 -3012
- package/dist/orm/index.js +9631 -2
- package/dist/{index-BQkhP2ny.d.ts → procedure-caller-CcjtUFvL.d.ts} +211 -74
- package/dist/query-context-BDSis9rT.js +1518 -0
- package/dist/query-context-DGExXZIV.d.ts +42 -0
- package/dist/react/index.d.ts +31 -35
- package/dist/react/index.js +145 -58
- package/dist/rsc/index.d.ts +4 -7
- package/dist/rsc/index.js +14 -10
- package/dist/runtime-B9xQFY8W.js +2280 -0
- package/dist/server/index.d.ts +3 -4
- package/dist/server/index.js +384 -10
- package/dist/{types-o-5rYcTr.d.ts → types-CIBGEYXq.d.ts} +4 -3
- package/dist/types-DgwvxKbT.d.ts +4 -0
- package/dist/watcher.mjs +8 -8
- package/dist/where-clause-compiler-CRP-i1Qa.d.ts +3463 -0
- package/package.json +14 -10
- package/dist/codegen-DkpPBVPn.mjs +0 -189
- package/dist/context-utils-DSuX99Da.d.ts +0 -17
- package/dist/meta-utils-DCpLSBWB.js +0 -41
- package/dist/orm-CleikBIV.js +0 -8820
- /package/dist/{auth-client → auth/client}/index.d.ts +0 -0
- /package/dist/{auth-config → auth/config}/index.d.ts +0 -0
- /package/dist/{auth-config → auth/config}/index.js +0 -0
- /package/dist/{create-schema-DhWXOhnU.js → create-schema-BdZOL6ns.js} +0 -0
- /package/dist/{customFunctions-C1okqCzL.js → customFunctions-CZnCwoR3.js} +0 -0
- /package/dist/{error-BZUhlhYz.js → error-Be4OcwwD.js} +0 -0
- /package/dist/{query-options-BL1Q0X7q.js → query-options-B0c1b6pZ.js} +0 -0
- /package/dist/{transformer-CTNSPjwp.js → transformer-Dh0w2py0.js} +0 -0
- /package/dist/{types-jftzhhuc.d.ts → types-DwGkkq2s.d.ts} +0 -0
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,3012 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#region src/orm/builders/column-builder.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Core data types supported by column builders
|
|
9
|
-
* Maps to Convex types: string, number (float64), boolean, bigint (int64), vector
|
|
10
|
-
*/
|
|
11
|
-
type ColumnDataType = 'string' | 'number' | 'boolean' | 'bigint' | 'bytes' | 'any' | 'vector';
|
|
12
|
-
type ForeignKeyAction = 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
|
|
13
|
-
interface ColumnReferenceConfig {
|
|
14
|
-
name?: string;
|
|
15
|
-
onUpdate?: ForeignKeyAction;
|
|
16
|
-
onDelete?: ForeignKeyAction;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Base configuration for all column builders
|
|
20
|
-
* Stores type-level metadata extracted by TypeScript
|
|
21
|
-
* Matches Drizzle's ColumnBuilderBaseConfig structure
|
|
22
|
-
*/
|
|
23
|
-
interface ColumnBuilderBaseConfig<TDataType extends ColumnDataType, TColumnType extends string> {
|
|
24
|
-
name: string;
|
|
25
|
-
dataType: TDataType;
|
|
26
|
-
columnType: TColumnType;
|
|
27
|
-
data: unknown;
|
|
28
|
-
driverParam: unknown;
|
|
29
|
-
enumValues: string[] | undefined;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Runtime configuration stored in builder instance
|
|
33
|
-
* Updated by chaining methods (.notNull(), .default(), etc.)
|
|
34
|
-
*/
|
|
35
|
-
interface ColumnBuilderRuntimeConfig<TData> {
|
|
36
|
-
name: string;
|
|
37
|
-
tableName?: string;
|
|
38
|
-
table?: unknown;
|
|
39
|
-
referenceTable?: string;
|
|
40
|
-
notNull: boolean;
|
|
41
|
-
default: TData | undefined;
|
|
42
|
-
defaultFn?: (() => unknown) | undefined;
|
|
43
|
-
onUpdateFn?: (() => unknown) | undefined;
|
|
44
|
-
hasDefault: boolean;
|
|
45
|
-
primaryKey: boolean;
|
|
46
|
-
isUnique: boolean;
|
|
47
|
-
uniqueName?: string;
|
|
48
|
-
uniqueNulls?: 'distinct' | 'not distinct';
|
|
49
|
-
foreignKeyConfigs: {
|
|
50
|
-
ref: () => ColumnBuilderBase;
|
|
51
|
-
config: ColumnReferenceConfig;
|
|
52
|
-
}[];
|
|
53
|
-
dataType: string;
|
|
54
|
-
columnType: string;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Phantom type configuration - never instantiated, just for TypeScript
|
|
58
|
-
* Tracks type-level state through method chaining
|
|
59
|
-
* Matches Drizzle's exact structure
|
|
60
|
-
*/
|
|
61
|
-
type ColumnBuilderTypeConfig<T extends ColumnBuilderBaseConfig<ColumnDataType, string>, TTypeConfig extends object> = Simplify<{
|
|
62
|
-
brand: 'ColumnBuilder';
|
|
63
|
-
name: T['name'];
|
|
64
|
-
dataType: T['dataType'];
|
|
65
|
-
columnType: T['columnType'];
|
|
66
|
-
data: T['data'];
|
|
67
|
-
driverParam: T['driverParam'];
|
|
68
|
-
notNull: T extends {
|
|
69
|
-
notNull: infer U;
|
|
70
|
-
} ? U : boolean;
|
|
71
|
-
hasDefault: T extends {
|
|
72
|
-
hasDefault: infer U;
|
|
73
|
-
} ? U : boolean;
|
|
74
|
-
isPrimaryKey: T extends {
|
|
75
|
-
isPrimaryKey: infer U;
|
|
76
|
-
} ? U : boolean;
|
|
77
|
-
isUnique: T extends {
|
|
78
|
-
isUnique: infer U;
|
|
79
|
-
} ? U : boolean;
|
|
80
|
-
enumValues: T['enumValues'];
|
|
81
|
-
} & TTypeConfig>;
|
|
82
|
-
/**
|
|
83
|
-
* entityKind symbol for runtime type checking
|
|
84
|
-
* Following Drizzle's pattern for type guards
|
|
85
|
-
*/
|
|
86
|
-
declare const entityKind: unique symbol;
|
|
87
|
-
interface DrizzleEntity {
|
|
88
|
-
[entityKind]: string;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* ColumnBuilderBase interface - defines the phantom _ property
|
|
92
|
-
* This interface is crucial for proper type intersection with NotNull/HasDefault/etc.
|
|
93
|
-
*/
|
|
94
|
-
interface ColumnBuilderBase<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TTypeConfig extends object = object> {
|
|
95
|
-
_: ColumnBuilderTypeConfig<T, TTypeConfig>;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Use as the return type for self-referencing `.references()` callbacks.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* parentId: text().references((): AnyColumn => commentsTable.id, { onDelete: 'cascade' })
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
type AnyColumn = ColumnBuilderBase;
|
|
106
|
-
/**
|
|
107
|
-
* Base ColumnBuilder abstract class
|
|
108
|
-
*
|
|
109
|
-
* All column builders inherit from this class.
|
|
110
|
-
* Implements chaining methods and stores runtime config.
|
|
111
|
-
*/
|
|
112
|
-
declare abstract class ColumnBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object, TTypeConfig extends object = object> implements ColumnBuilderBase<T, TTypeConfig>, DrizzleEntity {
|
|
113
|
-
static readonly [entityKind]: string;
|
|
114
|
-
readonly [entityKind]: string;
|
|
115
|
-
/**
|
|
116
|
-
* Phantom property - never instantiated, just for types
|
|
117
|
-
* Accumulates type info through method chaining
|
|
118
|
-
*/
|
|
119
|
-
_: ColumnBuilderTypeConfig<T, TTypeConfig>;
|
|
120
|
-
/**
|
|
121
|
-
* Runtime configuration - actual mutable state
|
|
122
|
-
*/
|
|
123
|
-
protected config: ColumnBuilderRuntimeConfig<T['data']> & TRuntimeConfig;
|
|
124
|
-
constructor(name: T['name'], dataType: T['dataType'], columnType: T['columnType']);
|
|
125
|
-
/**
|
|
126
|
-
* Mark column as NOT NULL
|
|
127
|
-
* Returns type-branded instance with notNull: true
|
|
128
|
-
*/
|
|
129
|
-
notNull(): NotNull<this>;
|
|
130
|
-
/**
|
|
131
|
-
* Override the TypeScript type for this column.
|
|
132
|
-
* Mirrors Drizzle's $type() (type-only, no runtime validation changes).
|
|
133
|
-
*/
|
|
134
|
-
$type<TType>(): $Type<this, TType>;
|
|
135
|
-
/**
|
|
136
|
-
* Set default value for column
|
|
137
|
-
* Makes field optional on insert
|
|
138
|
-
*/
|
|
139
|
-
default(value: ColumnData<this>): HasDefault<this>;
|
|
140
|
-
/**
|
|
141
|
-
* Set default function for column (runtime evaluated on insert).
|
|
142
|
-
* Mirrors Drizzle's $defaultFn() / $default().
|
|
143
|
-
*/
|
|
144
|
-
$defaultFn(fn: () => ColumnData<this>): HasDefault<this>;
|
|
145
|
-
/**
|
|
146
|
-
* Alias of $defaultFn for Drizzle parity.
|
|
147
|
-
*/
|
|
148
|
-
$default(fn: () => ColumnData<this>): HasDefault<this>;
|
|
149
|
-
/**
|
|
150
|
-
* Set on-update function for column (runtime evaluated on update).
|
|
151
|
-
* Mirrors Drizzle's $onUpdateFn() / $onUpdate().
|
|
152
|
-
*/
|
|
153
|
-
$onUpdateFn(fn: () => ColumnData<this>): HasDefault<this>;
|
|
154
|
-
/**
|
|
155
|
-
* Alias of $onUpdateFn for Drizzle parity.
|
|
156
|
-
*/
|
|
157
|
-
$onUpdate(fn: () => ColumnData<this>): HasDefault<this>;
|
|
158
|
-
/**
|
|
159
|
-
* Mark column as primary key
|
|
160
|
-
* Implies NOT NULL
|
|
161
|
-
*/
|
|
162
|
-
primaryKey(): IsPrimaryKey<NotNull<this>>;
|
|
163
|
-
/**
|
|
164
|
-
* Mark column as UNIQUE
|
|
165
|
-
* Mirrors Drizzle column unique API
|
|
166
|
-
*/
|
|
167
|
-
unique(name?: string, config?: {
|
|
168
|
-
nulls: 'distinct' | 'not distinct';
|
|
169
|
-
}): IsUnique<this>;
|
|
170
|
-
/**
|
|
171
|
-
* Define a foreign key reference
|
|
172
|
-
* Mirrors Drizzle column references() API
|
|
173
|
-
*/
|
|
174
|
-
references(ref: () => ColumnBuilderBase, config?: ColumnReferenceConfig): this;
|
|
175
|
-
/**
|
|
176
|
-
* Build method - must be implemented by subclasses
|
|
177
|
-
* Compiles builder to Convex validator
|
|
178
|
-
*
|
|
179
|
-
* @returns Convex validator for this column
|
|
180
|
-
*/
|
|
181
|
-
abstract build(): Validator<any, any, any>;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Type utilities for phantom type branding
|
|
185
|
-
* Drizzle's EXACT pattern - verified working
|
|
186
|
-
*/
|
|
187
|
-
/**
|
|
188
|
-
* Brand a builder as NOT NULL
|
|
189
|
-
* Removes | null from extracted type
|
|
190
|
-
*/
|
|
191
|
-
type NotNull<T extends ColumnBuilderBase> = T & {
|
|
192
|
-
_: {
|
|
193
|
-
notNull: true;
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
/**
|
|
197
|
-
* Brand a builder with a table name
|
|
198
|
-
* Used for relation typing (fields/references must match table)
|
|
199
|
-
*/
|
|
200
|
-
type ColumnBuilderWithTableName<T extends ColumnBuilderBase, TTableName extends string> = T & {
|
|
201
|
-
_: {
|
|
202
|
-
tableName: TTableName;
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* Brand a builder as UNIQUE
|
|
207
|
-
*/
|
|
208
|
-
type IsUnique<T extends ColumnBuilderBase> = T & {
|
|
209
|
-
_: {
|
|
210
|
-
isUnique: true;
|
|
211
|
-
};
|
|
212
|
-
};
|
|
213
|
-
/**
|
|
214
|
-
* Brand a builder with a default value
|
|
215
|
-
* Makes field optional on insert
|
|
216
|
-
*/
|
|
217
|
-
type HasDefault<T extends ColumnBuilderBase> = T & {
|
|
218
|
-
_: {
|
|
219
|
-
hasDefault: true;
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
type ColumnData<TBuilder extends ColumnBuilderBase> = TBuilder['_'] extends {
|
|
223
|
-
$type: infer TType;
|
|
224
|
-
} ? TType : TBuilder['_']['data'];
|
|
225
|
-
type $Type<TBuilder extends ColumnBuilderBase, TType> = TBuilder & {
|
|
226
|
-
_: {
|
|
227
|
-
$type: TType;
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Brand a builder as a primary key
|
|
232
|
-
* Implies NOT NULL
|
|
233
|
-
*/
|
|
234
|
-
type IsPrimaryKey<T extends ColumnBuilderBase> = T & {
|
|
235
|
-
_: {
|
|
236
|
-
isPrimaryKey: true;
|
|
237
|
-
notNull: true;
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/orm/builders/convex-column-builder.d.ts
|
|
242
|
-
/**
|
|
243
|
-
* Convex-specific column builder base class
|
|
244
|
-
*
|
|
245
|
-
* All Convex column builders (ConvexTextBuilder, ConvexIntegerBuilder, etc.)
|
|
246
|
-
* inherit from this class.
|
|
247
|
-
*/
|
|
248
|
-
declare abstract class ConvexColumnBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends ColumnBuilder<T, TRuntimeConfig, {
|
|
249
|
-
dialect: 'convex';
|
|
250
|
-
}> {
|
|
251
|
-
static readonly [entityKind]: string;
|
|
252
|
-
/**
|
|
253
|
-
* Build method - compiles builder to Convex validator
|
|
254
|
-
*
|
|
255
|
-
* Subclasses implement this to produce the correct validator:
|
|
256
|
-
* - text() → v.string() or v.optional(v.string())
|
|
257
|
-
* - integer() → v.number() or v.optional(v.number())
|
|
258
|
-
* - etc.
|
|
259
|
-
*
|
|
260
|
-
* @returns Convex validator for this column
|
|
261
|
-
*/
|
|
262
|
-
abstract build(): Validator<any, any, any>;
|
|
263
|
-
}
|
|
264
|
-
//#endregion
|
|
265
|
-
//#region src/orm/builders/bigint.d.ts
|
|
266
|
-
/**
|
|
267
|
-
* Initial type for ConvexBigIntBuilder
|
|
268
|
-
*/
|
|
269
|
-
type ConvexBigIntBuilderInitial<TName extends string> = ConvexBigIntBuilder<{
|
|
270
|
-
name: TName;
|
|
271
|
-
dataType: 'bigint';
|
|
272
|
-
columnType: 'ConvexBigInt';
|
|
273
|
-
data: bigint;
|
|
274
|
-
driverParam: bigint;
|
|
275
|
-
enumValues: undefined;
|
|
276
|
-
}>;
|
|
277
|
-
/**
|
|
278
|
-
* BigInt column builder class
|
|
279
|
-
* Compiles to v.int64() or v.optional(v.int64())
|
|
280
|
-
*/
|
|
281
|
-
declare class ConvexBigIntBuilder<T extends ColumnBuilderBaseConfig<'bigint', 'ConvexBigInt'>> extends ConvexColumnBuilder<T> {
|
|
282
|
-
static readonly [entityKind]: string;
|
|
283
|
-
constructor(name: T['name']);
|
|
284
|
-
/**
|
|
285
|
-
* Expose Convex validator for schema integration
|
|
286
|
-
*/
|
|
287
|
-
get convexValidator(): Validator<any, any, any>;
|
|
288
|
-
/**
|
|
289
|
-
* Compile to Convex validator
|
|
290
|
-
* .notNull() → v.int64()
|
|
291
|
-
* nullable → v.optional(v.int64())
|
|
292
|
-
*/
|
|
293
|
-
build(): Validator<any, any, any>;
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* bigint() factory function
|
|
297
|
-
*
|
|
298
|
-
* Creates a bigint column builder (int64 in Convex).
|
|
299
|
-
* For JavaScript bigint values.
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* bigint() → unnamed column
|
|
303
|
-
* bigint('col_name') → named column
|
|
304
|
-
*/
|
|
305
|
-
declare function bigint(): ConvexBigIntBuilderInitial<''>;
|
|
306
|
-
declare function bigint<TName extends string>(name: TName): ConvexBigIntBuilderInitial<TName>;
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/orm/builders/boolean.d.ts
|
|
309
|
-
/**
|
|
310
|
-
* Initial type for ConvexBooleanBuilder
|
|
311
|
-
*/
|
|
312
|
-
type ConvexBooleanBuilderInitial<TName extends string> = ConvexBooleanBuilder<{
|
|
313
|
-
name: TName;
|
|
314
|
-
dataType: 'boolean';
|
|
315
|
-
columnType: 'ConvexBoolean';
|
|
316
|
-
data: boolean;
|
|
317
|
-
driverParam: boolean;
|
|
318
|
-
enumValues: undefined;
|
|
319
|
-
}>;
|
|
320
|
-
/**
|
|
321
|
-
* Boolean column builder class
|
|
322
|
-
* Compiles to v.boolean() or v.optional(v.boolean())
|
|
323
|
-
*/
|
|
324
|
-
declare class ConvexBooleanBuilder<T extends ColumnBuilderBaseConfig<'boolean', 'ConvexBoolean'>> extends ConvexColumnBuilder<T> {
|
|
325
|
-
static readonly [entityKind]: string;
|
|
326
|
-
constructor(name: T['name']);
|
|
327
|
-
/**
|
|
328
|
-
* Expose Convex validator for schema integration
|
|
329
|
-
*/
|
|
330
|
-
get convexValidator(): Validator<any, any, any>;
|
|
331
|
-
/**
|
|
332
|
-
* Compile to Convex validator
|
|
333
|
-
* .notNull() → v.boolean()
|
|
334
|
-
* nullable → v.optional(v.boolean())
|
|
335
|
-
*/
|
|
336
|
-
build(): Validator<any, any, any>;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* boolean() factory function
|
|
340
|
-
*
|
|
341
|
-
* Creates a boolean column builder.
|
|
342
|
-
*
|
|
343
|
-
* @example
|
|
344
|
-
* boolean() → unnamed column
|
|
345
|
-
* boolean('col_name') → named column
|
|
346
|
-
*/
|
|
347
|
-
declare function boolean(): ConvexBooleanBuilderInitial<''>;
|
|
348
|
-
declare function boolean<TName extends string>(name: TName): ConvexBooleanBuilderInitial<TName>;
|
|
349
|
-
//#endregion
|
|
350
|
-
//#region src/orm/builders/bytes.d.ts
|
|
351
|
-
type ConvexBytesBuilderInitial<TName extends string> = ConvexBytesBuilder<{
|
|
352
|
-
name: TName;
|
|
353
|
-
dataType: 'bytes';
|
|
354
|
-
columnType: 'ConvexBytes';
|
|
355
|
-
data: ArrayBuffer;
|
|
356
|
-
driverParam: ArrayBuffer;
|
|
357
|
-
enumValues: undefined;
|
|
358
|
-
}>;
|
|
359
|
-
declare class ConvexBytesBuilder<T extends ColumnBuilderBaseConfig<'bytes', 'ConvexBytes'>> extends ConvexColumnBuilder<T> {
|
|
360
|
-
static readonly [entityKind]: string;
|
|
361
|
-
constructor(name: T['name']);
|
|
362
|
-
get convexValidator(): Validator<any, any, any>;
|
|
363
|
-
build(): Validator<any, any, any>;
|
|
364
|
-
}
|
|
365
|
-
declare function bytes(): ConvexBytesBuilderInitial<''>;
|
|
366
|
-
declare function bytes<TName extends string>(name: TName): ConvexBytesBuilderInitial<TName>;
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/orm/builders/custom.d.ts
|
|
369
|
-
type AnyValidator = Validator<any, any, any>;
|
|
370
|
-
type ConvexCustomBuilderInitial<TName extends string, TValidator extends AnyValidator> = ConvexCustomBuilder<{
|
|
371
|
-
name: TName;
|
|
372
|
-
dataType: 'any';
|
|
373
|
-
columnType: 'ConvexCustom';
|
|
374
|
-
data: TValidator['type'];
|
|
375
|
-
driverParam: TValidator['type'];
|
|
376
|
-
enumValues: undefined;
|
|
377
|
-
}, TValidator>;
|
|
378
|
-
declare class ConvexCustomBuilder<T extends ColumnBuilderBaseConfig<'any', 'ConvexCustom'>, TValidator extends AnyValidator> extends ConvexColumnBuilder<T, {
|
|
379
|
-
validator: TValidator;
|
|
380
|
-
}> {
|
|
381
|
-
static readonly [entityKind]: string;
|
|
382
|
-
constructor(name: T['name'], validator: TValidator);
|
|
383
|
-
get convexValidator(): Validator<any, any, any>;
|
|
384
|
-
build(): Validator<any, any, any>;
|
|
385
|
-
}
|
|
386
|
-
declare function custom<TValidator extends AnyValidator>(validator: TValidator): ConvexCustomBuilderInitial<'', TValidator>;
|
|
387
|
-
declare function custom<TName extends string, TValidator extends AnyValidator>(name: TName, validator: TValidator): ConvexCustomBuilderInitial<TName, TValidator>;
|
|
388
|
-
/**
|
|
389
|
-
* Convenience wrapper for Convex "JSON" values.
|
|
390
|
-
*
|
|
391
|
-
* Note: This is Convex JSON (runtime `v.any()`), not SQL JSON/JSONB.
|
|
392
|
-
*/
|
|
393
|
-
declare function json<T = Value>(): $Type<ConvexCustomBuilderInitial<"", convex_values69.VAny<any, "required", string>>, T>;
|
|
394
|
-
//#endregion
|
|
395
|
-
//#region src/orm/builders/date.d.ts
|
|
396
|
-
type ConvexDateMode = 'string' | 'date';
|
|
397
|
-
type ConvexDateBuilderConfig<TName extends string, TMode extends ConvexDateMode> = {
|
|
398
|
-
name: TName;
|
|
399
|
-
dataType: 'string';
|
|
400
|
-
columnType: 'ConvexDate';
|
|
401
|
-
data: TMode extends 'date' ? Date : string;
|
|
402
|
-
driverParam: string;
|
|
403
|
-
enumValues: undefined;
|
|
404
|
-
};
|
|
405
|
-
type ConvexDateBuilderInitial<TName extends string, TMode extends ConvexDateMode = 'string'> = ConvexDateBuilder<ConvexDateBuilderConfig<TName, TMode>, TMode>;
|
|
406
|
-
type ConvexDateRuntimeConfig<TMode extends ConvexDateMode> = {
|
|
407
|
-
mode: TMode;
|
|
408
|
-
};
|
|
409
|
-
type ConvexDateBuilderArg<TMode extends ConvexDateMode> = {
|
|
410
|
-
mode?: TMode;
|
|
411
|
-
};
|
|
412
|
-
declare class ConvexDateBuilder<T extends ColumnBuilderBaseConfig<'string', 'ConvexDate'>, TMode extends ConvexDateMode = ConvexDateMode> extends ConvexColumnBuilder<T, ConvexDateRuntimeConfig<TMode>> {
|
|
413
|
-
static readonly [entityKind]: string;
|
|
414
|
-
constructor(name: T['name'], mode: TMode);
|
|
415
|
-
get convexValidator(): Validator<any, any, any>;
|
|
416
|
-
defaultNow(): HasDefault<this>;
|
|
417
|
-
build(): Validator<any, any, any>;
|
|
418
|
-
}
|
|
419
|
-
declare function date(): ConvexDateBuilderInitial<'', 'string'>;
|
|
420
|
-
declare function date<TName extends string>(name: TName): ConvexDateBuilderInitial<TName, 'string'>;
|
|
421
|
-
declare function date<TMode extends ConvexDateMode>(config: ConvexDateBuilderArg<TMode>): ConvexDateBuilderInitial<'', TMode>;
|
|
422
|
-
declare function date<TName extends string, TMode extends ConvexDateMode>(name: TName, config: ConvexDateBuilderArg<TMode>): ConvexDateBuilderInitial<TName, TMode>;
|
|
423
|
-
//#endregion
|
|
424
|
-
//#region src/orm/builders/id.d.ts
|
|
425
|
-
/**
|
|
426
|
-
* Initial type for ConvexIdBuilder
|
|
427
|
-
* Includes table name in type for branded Id
|
|
428
|
-
*/
|
|
429
|
-
type ConvexIdBuilderInitial<TName extends string, TTableName extends string> = ConvexIdBuilder<{
|
|
430
|
-
name: TName;
|
|
431
|
-
dataType: 'string';
|
|
432
|
-
columnType: 'ConvexId';
|
|
433
|
-
data: GenericId<TTableName>;
|
|
434
|
-
driverParam: GenericId<TTableName>;
|
|
435
|
-
enumValues: undefined;
|
|
436
|
-
}>;
|
|
437
|
-
/**
|
|
438
|
-
* ID column builder class
|
|
439
|
-
* Compiles to v.id(tableName) or v.optional(v.id(tableName))
|
|
440
|
-
*/
|
|
441
|
-
declare class ConvexIdBuilder<T extends ColumnBuilderBaseConfig<'string', 'ConvexId'>> extends ConvexColumnBuilder<T> {
|
|
442
|
-
private tableName;
|
|
443
|
-
static readonly [entityKind]: string;
|
|
444
|
-
constructor(name: T['name'], tableName: string);
|
|
445
|
-
/**
|
|
446
|
-
* Expose Convex validator for schema integration
|
|
447
|
-
*/
|
|
448
|
-
get convexValidator(): Validator<any, any, any>;
|
|
449
|
-
/**
|
|
450
|
-
* Compile to Convex validator
|
|
451
|
-
* .notNull() → v.id(tableName)
|
|
452
|
-
* nullable → v.optional(v.id(tableName))
|
|
453
|
-
*/
|
|
454
|
-
build(): Validator<any, any, any>;
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* id() factory function
|
|
458
|
-
*
|
|
459
|
-
* Creates an ID reference column builder (foreign key).
|
|
460
|
-
* Requires table name to generate branded Id type.
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* id('users') → unnamed column referencing users table
|
|
464
|
-
*/
|
|
465
|
-
declare function id<TTableName extends string>(tableName: TTableName): ConvexIdBuilderInitial<'', TTableName>;
|
|
466
|
-
//#endregion
|
|
467
|
-
//#region src/orm/builders/number.d.ts
|
|
468
|
-
/**
|
|
469
|
-
* Initial type for ConvexNumberBuilder
|
|
470
|
-
*/
|
|
471
|
-
type ConvexNumberBuilderInitial<TName extends string> = ConvexNumberBuilder<{
|
|
472
|
-
name: TName;
|
|
473
|
-
dataType: 'number';
|
|
474
|
-
columnType: 'ConvexNumber';
|
|
475
|
-
data: number;
|
|
476
|
-
driverParam: number;
|
|
477
|
-
enumValues: undefined;
|
|
478
|
-
}>;
|
|
479
|
-
/**
|
|
480
|
-
* Number column builder class
|
|
481
|
-
* Compiles to v.number() or v.optional(v.number())
|
|
482
|
-
*/
|
|
483
|
-
declare class ConvexNumberBuilder<T extends ColumnBuilderBaseConfig<'number', 'ConvexNumber'>> extends ConvexColumnBuilder<T> {
|
|
484
|
-
static readonly [entityKind]: string;
|
|
485
|
-
constructor(name: T['name']);
|
|
486
|
-
/**
|
|
487
|
-
* Expose Convex validator for schema integration
|
|
488
|
-
*/
|
|
489
|
-
get convexValidator(): Validator<any, any, any>;
|
|
490
|
-
/**
|
|
491
|
-
* Compile to Convex validator
|
|
492
|
-
* .notNull() → v.number()
|
|
493
|
-
* nullable → v.optional(v.number())
|
|
494
|
-
*/
|
|
495
|
-
build(): Validator<any, any, any>;
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* integer() factory function
|
|
499
|
-
*
|
|
500
|
-
* Drizzle-parity numeric builder.
|
|
501
|
-
* In Convex this maps to v.number() (Float64).
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* integer() → unnamed column
|
|
505
|
-
* integer('col_name') → named column
|
|
506
|
-
*/
|
|
507
|
-
declare function integer(): ConvexNumberBuilderInitial<''>;
|
|
508
|
-
declare function integer<TName extends string>(name: TName): ConvexNumberBuilderInitial<TName>;
|
|
509
|
-
//#endregion
|
|
510
|
-
//#region src/orm/builders/system-fields.d.ts
|
|
511
|
-
/**
|
|
512
|
-
* System ID field builder (public id, internal _id)
|
|
513
|
-
* Always present, always non-null
|
|
514
|
-
*/
|
|
515
|
-
type ConvexSystemIdConfig = ColumnBuilderBaseConfig<'string', 'ConvexSystemId'> & {
|
|
516
|
-
data: string;
|
|
517
|
-
driverParam: string;
|
|
518
|
-
enumValues: undefined;
|
|
519
|
-
};
|
|
520
|
-
declare class ConvexSystemIdBuilder<_TTableName extends string> extends ColumnBuilder<ConvexSystemIdConfig, {}, {
|
|
521
|
-
notNull: true;
|
|
522
|
-
}> {
|
|
523
|
-
static readonly [entityKind]: string;
|
|
524
|
-
readonly [entityKind]: string;
|
|
525
|
-
constructor();
|
|
526
|
-
build(): convex_values69.VString<string, "required">;
|
|
527
|
-
/**
|
|
528
|
-
* Convex validator - runtime access
|
|
529
|
-
* System fields use v.string() for _id
|
|
530
|
-
*/
|
|
531
|
-
get convexValidator(): convex_values69.VString<string, "required">;
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* System creation time field builder (_creationTime)
|
|
535
|
-
* Always present, always non-null, always a number (milliseconds)
|
|
536
|
-
*/
|
|
537
|
-
type ConvexSystemCreationTimeConfig = ColumnBuilderBaseConfig<'number', 'ConvexSystemCreationTime'> & {
|
|
538
|
-
data: number;
|
|
539
|
-
driverParam: number;
|
|
540
|
-
enumValues: undefined;
|
|
541
|
-
};
|
|
542
|
-
declare class ConvexSystemCreationTimeBuilder extends ColumnBuilder<ConvexSystemCreationTimeConfig, {}, {
|
|
543
|
-
notNull: true;
|
|
544
|
-
}> {
|
|
545
|
-
static readonly [entityKind]: string;
|
|
546
|
-
readonly [entityKind]: string;
|
|
547
|
-
constructor();
|
|
548
|
-
build(): convex_values69.VFloat64<number, "required">;
|
|
549
|
-
/**
|
|
550
|
-
* Convex validator - runtime access
|
|
551
|
-
* System fields use v.number() for _creationTime
|
|
552
|
-
*/
|
|
553
|
-
get convexValidator(): convex_values69.VFloat64<number, "required">;
|
|
554
|
-
}
|
|
555
|
-
type ConvexSystemCreatedAtConfig = ColumnBuilderBaseConfig<'number', 'ConvexSystemCreatedAt'> & {
|
|
556
|
-
data: number;
|
|
557
|
-
driverParam: number;
|
|
558
|
-
enumValues: undefined;
|
|
559
|
-
};
|
|
560
|
-
declare class ConvexSystemCreatedAtBuilder extends ColumnBuilder<ConvexSystemCreatedAtConfig, {}, {
|
|
561
|
-
notNull: true;
|
|
562
|
-
}> {
|
|
563
|
-
static readonly [entityKind]: string;
|
|
564
|
-
readonly [entityKind]: string;
|
|
565
|
-
constructor();
|
|
566
|
-
build(): convex_values69.VFloat64<number, "required">;
|
|
567
|
-
get convexValidator(): convex_values69.VFloat64<number, "required">;
|
|
568
|
-
}
|
|
569
|
-
/**
|
|
570
|
-
* Create system field builders for a table
|
|
571
|
-
* These are automatically added to every ConvexTable
|
|
572
|
-
*/
|
|
573
|
-
type SystemFields<TName extends string> = {
|
|
574
|
-
id: ColumnBuilderWithTableName<ConvexSystemIdBuilder<TName>, TName>;
|
|
575
|
-
};
|
|
576
|
-
type InternalSystemFields<TName extends string> = {
|
|
577
|
-
_creationTime: ColumnBuilderWithTableName<ConvexSystemCreationTimeBuilder, TName>;
|
|
578
|
-
};
|
|
579
|
-
type SystemFieldAliases<TName extends string, TColumns extends Record<string, unknown> = {}> = 'createdAt' extends keyof TColumns ? {} : {
|
|
580
|
-
createdAt: ColumnBuilderWithTableName<ConvexSystemCreatedAtBuilder, TName>;
|
|
581
|
-
};
|
|
582
|
-
type SystemFieldsWithAliases<TName extends string, TColumns extends Record<string, unknown> = {}> = SystemFields<TName> & InternalSystemFields<TName> & SystemFieldAliases<TName, TColumns>;
|
|
583
|
-
//#endregion
|
|
584
|
-
//#region src/orm/builders/text.d.ts
|
|
585
|
-
/**
|
|
586
|
-
* Initial type for ConvexTextBuilder
|
|
587
|
-
* Used in factory function return types
|
|
588
|
-
* Matches Drizzle's pattern with all required properties
|
|
589
|
-
*/
|
|
590
|
-
type ConvexTextBuilderInitial<TName extends string> = ConvexTextBuilder<{
|
|
591
|
-
name: TName;
|
|
592
|
-
dataType: 'string';
|
|
593
|
-
columnType: 'ConvexText';
|
|
594
|
-
data: string;
|
|
595
|
-
driverParam: string;
|
|
596
|
-
enumValues: undefined;
|
|
597
|
-
}>;
|
|
598
|
-
/**
|
|
599
|
-
* Text column builder class
|
|
600
|
-
* Compiles to v.string() or v.optional(v.string())
|
|
601
|
-
*/
|
|
602
|
-
declare class ConvexTextBuilder<T extends ColumnBuilderBaseConfig<'string', 'ConvexText'>> extends ConvexColumnBuilder<T> {
|
|
603
|
-
static readonly [entityKind]: string;
|
|
604
|
-
constructor(name: T['name']);
|
|
605
|
-
/**
|
|
606
|
-
* Expose Convex validator for schema integration
|
|
607
|
-
*/
|
|
608
|
-
get convexValidator(): Validator<any, any, any>;
|
|
609
|
-
/**
|
|
610
|
-
* Compile to Convex validator
|
|
611
|
-
* .notNull() → v.string()
|
|
612
|
-
* nullable → v.optional(v.string())
|
|
613
|
-
*/
|
|
614
|
-
build(): Validator<any, any, any>;
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* text() factory function
|
|
618
|
-
*
|
|
619
|
-
* Creates a text column builder.
|
|
620
|
-
* Supports both named and unnamed columns (for later binding).
|
|
621
|
-
*
|
|
622
|
-
* @example
|
|
623
|
-
* text() → unnamed column
|
|
624
|
-
* text('col_name') → named column
|
|
625
|
-
*/
|
|
626
|
-
declare function text(): ConvexTextBuilderInitial<''>;
|
|
627
|
-
declare function text<TName extends string>(name: TName): ConvexTextBuilderInitial<TName>;
|
|
628
|
-
//#endregion
|
|
629
|
-
//#region src/orm/builders/text-enum.d.ts
|
|
630
|
-
type EnumValues = readonly [string, ...string[]];
|
|
631
|
-
type ConvexTextEnumBuilderInitial<TName extends string, TValues extends EnumValues> = ConvexTextEnumBuilder<{
|
|
632
|
-
name: TName;
|
|
633
|
-
dataType: 'string';
|
|
634
|
-
columnType: 'ConvexText';
|
|
635
|
-
data: TValues[number];
|
|
636
|
-
driverParam: TValues[number];
|
|
637
|
-
enumValues: TValues[number][];
|
|
638
|
-
}>;
|
|
639
|
-
declare class ConvexTextEnumBuilder<T extends ColumnBuilderBaseConfig<'string', 'ConvexText'>> extends ConvexColumnBuilder<T, {
|
|
640
|
-
values: string[];
|
|
641
|
-
}> {
|
|
642
|
-
static readonly [entityKind]: string;
|
|
643
|
-
constructor(name: T['name'], values: readonly string[]);
|
|
644
|
-
private _enumValidator;
|
|
645
|
-
get convexValidator(): Validator<any, any, any>;
|
|
646
|
-
build(): Validator<any, any, any>;
|
|
647
|
-
}
|
|
648
|
-
declare function textEnum<const TValues extends EnumValues>(values: TValues): ConvexTextEnumBuilderInitial<'', TValues>;
|
|
649
|
-
//#endregion
|
|
650
|
-
//#region src/orm/builders/timestamp.d.ts
|
|
651
|
-
type ConvexTimestampMode = 'date' | 'string';
|
|
652
|
-
type ConvexTimestampBuilderConfig<TName extends string, TMode extends ConvexTimestampMode> = {
|
|
653
|
-
name: TName;
|
|
654
|
-
dataType: 'number';
|
|
655
|
-
columnType: 'ConvexTimestamp';
|
|
656
|
-
data: TMode extends 'string' ? string : Date;
|
|
657
|
-
driverParam: number;
|
|
658
|
-
enumValues: undefined;
|
|
659
|
-
};
|
|
660
|
-
type ConvexTimestampBuilderInitial<TName extends string, TMode extends ConvexTimestampMode = 'date'> = ConvexTimestampBuilder<ConvexTimestampBuilderConfig<TName, TMode>, TMode>;
|
|
661
|
-
type ConvexTimestampRuntimeConfig<TMode extends ConvexTimestampMode> = {
|
|
662
|
-
mode: TMode;
|
|
663
|
-
};
|
|
664
|
-
type ConvexTimestampBuilderArg<TMode extends ConvexTimestampMode> = {
|
|
665
|
-
mode?: TMode;
|
|
666
|
-
};
|
|
667
|
-
declare class ConvexTimestampBuilder<T extends ColumnBuilderBaseConfig<'number', 'ConvexTimestamp'>, TMode extends ConvexTimestampMode = ConvexTimestampMode> extends ConvexColumnBuilder<T, ConvexTimestampRuntimeConfig<TMode>> {
|
|
668
|
-
static readonly [entityKind]: string;
|
|
669
|
-
constructor(name: T['name'], mode: TMode);
|
|
670
|
-
get convexValidator(): Validator<any, any, any>;
|
|
671
|
-
defaultNow(): HasDefault<this>;
|
|
672
|
-
build(): Validator<any, any, any>;
|
|
673
|
-
}
|
|
674
|
-
declare function timestamp(): ConvexTimestampBuilderInitial<'', 'date'>;
|
|
675
|
-
declare function timestamp<TName extends string>(name: TName): ConvexTimestampBuilderInitial<TName, 'date'>;
|
|
676
|
-
declare function timestamp<TMode extends ConvexTimestampMode>(config: ConvexTimestampBuilderArg<TMode>): ConvexTimestampBuilderInitial<'', TMode>;
|
|
677
|
-
declare function timestamp<TName extends string, TMode extends ConvexTimestampMode>(name: TName, config: ConvexTimestampBuilderArg<TMode>): ConvexTimestampBuilderInitial<TName, TMode>;
|
|
678
|
-
//#endregion
|
|
679
|
-
//#region src/orm/builders/vector.d.ts
|
|
680
|
-
/**
|
|
681
|
-
* Initial type for ConvexVectorBuilder
|
|
682
|
-
*/
|
|
683
|
-
type ConvexVectorBuilderInitial<TName extends string> = ConvexVectorBuilder<{
|
|
684
|
-
name: TName;
|
|
685
|
-
dataType: 'vector';
|
|
686
|
-
columnType: 'ConvexVector';
|
|
687
|
-
data: number[];
|
|
688
|
-
driverParam: number[];
|
|
689
|
-
enumValues: undefined;
|
|
690
|
-
}>;
|
|
691
|
-
/**
|
|
692
|
-
* Vector column builder class
|
|
693
|
-
* Compiles to v.array(v.float64()) or v.optional(v.array(v.float64()))
|
|
694
|
-
*/
|
|
695
|
-
declare class ConvexVectorBuilder<T extends ColumnBuilderBaseConfig<'vector', 'ConvexVector'>> extends ConvexColumnBuilder<T, {
|
|
696
|
-
dimensions: number;
|
|
697
|
-
}> {
|
|
698
|
-
static readonly [entityKind]: string;
|
|
699
|
-
constructor(name: T['name'], dimensions: number);
|
|
700
|
-
get dimensions(): number;
|
|
701
|
-
/**
|
|
702
|
-
* Expose Convex validator for schema integration
|
|
703
|
-
*/
|
|
704
|
-
get convexValidator(): Validator<any, any, any>;
|
|
705
|
-
/**
|
|
706
|
-
* Compile to Convex validator
|
|
707
|
-
* .notNull() → v.array(v.float64())
|
|
708
|
-
* nullable → v.optional(v.array(v.float64()))
|
|
709
|
-
*/
|
|
710
|
-
build(): Validator<any, any, any>;
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* vector() factory function
|
|
714
|
-
*
|
|
715
|
-
* Creates a vector column builder with fixed dimensions.
|
|
716
|
-
*
|
|
717
|
-
* @example
|
|
718
|
-
* vector(1536) → unnamed column
|
|
719
|
-
* vector('embedding', 1536) → named column
|
|
720
|
-
*/
|
|
721
|
-
declare function vector(dimensions: number): ConvexVectorBuilderInitial<''>;
|
|
722
|
-
declare function vector<TName extends string>(name: TName, dimensions: number): ConvexVectorBuilderInitial<TName>;
|
|
723
|
-
//#endregion
|
|
724
|
-
//#region src/orm/filter-expression.d.ts
|
|
725
|
-
/**
|
|
726
|
-
* Extract TypeScript type from a column builder
|
|
727
|
-
* Uses phantom `_` property to get type info
|
|
728
|
-
*/
|
|
729
|
-
type ColumnToType<TBuilder extends ColumnBuilder<any, any, any>> = TBuilder['_']['notNull'] extends true ? TBuilder['_']['data'] : TBuilder['_']['data'] | null;
|
|
730
|
-
/**
|
|
731
|
-
* Unique symbol for FilterExpression brand
|
|
732
|
-
* Prevents structural typing - only expressions created by factory functions are valid
|
|
733
|
-
*/
|
|
734
|
-
declare const FilterExpressionBrand: unique symbol;
|
|
735
|
-
/**
|
|
736
|
-
* Base filter expression interface
|
|
737
|
-
* All filter expressions (binary, logical, unary) implement this interface
|
|
738
|
-
*
|
|
739
|
-
* @template TValue - The TypeScript type this expression evaluates to
|
|
740
|
-
*/
|
|
741
|
-
interface FilterExpression<_TValue = boolean> {
|
|
742
|
-
/** Brand symbol for nominal typing */
|
|
743
|
-
readonly [FilterExpressionBrand]: true;
|
|
744
|
-
/** Expression type discriminator */
|
|
745
|
-
readonly type: 'binary' | 'logical' | 'unary';
|
|
746
|
-
/** Operator string (eq, and, not, etc.) */
|
|
747
|
-
readonly operator: string;
|
|
748
|
-
/** Expression operands (FieldReference, values, or nested expressions) */
|
|
749
|
-
readonly operands: readonly any[];
|
|
750
|
-
/** Accept visitor for traversal */
|
|
751
|
-
accept<R>(visitor: ExpressionVisitor<R>): R;
|
|
752
|
-
}
|
|
753
|
-
/**
|
|
754
|
-
* Binary operator expression (eq, ne, gt, gte, lt, lte, inArray, notInArray)
|
|
755
|
-
* Compares field to value: field eq value
|
|
756
|
-
*
|
|
757
|
-
* @template TField - Field type being compared
|
|
758
|
-
*/
|
|
759
|
-
interface BinaryExpression<TField = any> extends FilterExpression<boolean> {
|
|
760
|
-
readonly type: 'binary';
|
|
761
|
-
readonly operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'inArray' | 'notInArray' | 'arrayContains' | 'arrayContained' | 'arrayOverlaps' | 'like' | 'ilike' | 'notLike' | 'notIlike' | 'startsWith' | 'endsWith' | 'contains';
|
|
762
|
-
/** [field, value] or [field, array] for inArray/notInArray */
|
|
763
|
-
readonly operands: readonly [FieldReference<TField>, TField | TField[]];
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Logical operator expression (and, or)
|
|
767
|
-
* Combines multiple filter expressions
|
|
768
|
-
*/
|
|
769
|
-
interface LogicalExpression extends FilterExpression<boolean> {
|
|
770
|
-
readonly type: 'logical';
|
|
771
|
-
readonly operator: 'and' | 'or';
|
|
772
|
-
/** Array of nested filter expressions */
|
|
773
|
-
readonly operands: readonly FilterExpression<boolean>[];
|
|
774
|
-
}
|
|
775
|
-
/**
|
|
776
|
-
* Unary operator expression (not, isNull, isNotNull)
|
|
777
|
-
* Negates or checks null state of an expression
|
|
778
|
-
*/
|
|
779
|
-
interface UnaryExpression extends FilterExpression<boolean> {
|
|
780
|
-
readonly type: 'unary';
|
|
781
|
-
readonly operator: 'not' | 'isNull' | 'isNotNull';
|
|
782
|
-
/** Single nested filter expression or field reference for null checks */
|
|
783
|
-
readonly operands: readonly [FilterExpression<boolean> | FieldReference<any>];
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* CRITICAL: FieldReference abstraction
|
|
787
|
-
*
|
|
788
|
-
* Decouples filter expressions from M2 table configuration
|
|
789
|
-
* Allows filter expressions to reference fields without knowing about validators
|
|
790
|
-
*
|
|
791
|
-
* @template TValue - TypeScript type of the field
|
|
792
|
-
*/
|
|
793
|
-
interface FieldReference<TValue = unknown> {
|
|
794
|
-
readonly __brand: 'FieldReference';
|
|
795
|
-
readonly fieldName: string;
|
|
796
|
-
/** Phantom type for type inference - not present at runtime */
|
|
797
|
-
readonly __type?: TValue;
|
|
798
|
-
}
|
|
799
|
-
/**
|
|
800
|
-
* Create a field reference
|
|
801
|
-
* Used internally by operator functions
|
|
802
|
-
*/
|
|
803
|
-
declare function fieldRef<T>(fieldName: string): FieldReference<T>;
|
|
804
|
-
/**
|
|
805
|
-
* Type guard for FieldReference
|
|
806
|
-
*/
|
|
807
|
-
declare function isFieldReference(value: any): value is FieldReference<any>;
|
|
808
|
-
/**
|
|
809
|
-
* Column wrapper - combines builder with column name
|
|
810
|
-
* Used in where clause to pass column objects to operators
|
|
811
|
-
* Following Drizzle's pattern: operators receive columns, not extracted types
|
|
812
|
-
*
|
|
813
|
-
* @template TBuilder - The column builder type
|
|
814
|
-
* @template TName - The column name (string literal)
|
|
815
|
-
*/
|
|
816
|
-
interface Column<TBuilder extends ColumnBuilder<any, any, any> = any, TName extends string = string> {
|
|
817
|
-
readonly builder: TBuilder;
|
|
818
|
-
readonly columnName: TName;
|
|
819
|
-
}
|
|
820
|
-
type ColumnArgument<TBuilder extends ColumnBuilder<any, any, any>> = Column<TBuilder, string> | TBuilder;
|
|
821
|
-
/**
|
|
822
|
-
* Create a column wrapper
|
|
823
|
-
* Used internally by query builder's _createColumnProxies
|
|
824
|
-
*/
|
|
825
|
-
/**
|
|
826
|
-
* Expression visitor interface for tree traversal
|
|
827
|
-
* Extensible pattern - add new visit methods without modifying expression classes
|
|
828
|
-
*
|
|
829
|
-
* @template R - Return type of visit operations
|
|
830
|
-
*/
|
|
831
|
-
interface ExpressionVisitor<R = void> {
|
|
832
|
-
visitBinary(expr: BinaryExpression): R;
|
|
833
|
-
visitLogical(expr: LogicalExpression): R;
|
|
834
|
-
visitUnary(expr: UnaryExpression): R;
|
|
835
|
-
}
|
|
836
|
-
/**
|
|
837
|
-
* Equality operator: field == value
|
|
838
|
-
*
|
|
839
|
-
* @example
|
|
840
|
-
* const filter = eq(cols.name, 'Alice');
|
|
841
|
-
*/
|
|
842
|
-
declare function eq<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, value: ColumnToType<TBuilder>): BinaryExpression<ColumnToType<TBuilder>>;
|
|
843
|
-
/**
|
|
844
|
-
* Not equal operator: field != value
|
|
845
|
-
*/
|
|
846
|
-
declare function ne<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, value: ColumnToType<TBuilder>): BinaryExpression<ColumnToType<TBuilder>>;
|
|
847
|
-
/**
|
|
848
|
-
* Greater than operator: field > value
|
|
849
|
-
*/
|
|
850
|
-
declare function gt<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, value: ColumnToType<TBuilder>): BinaryExpression<ColumnToType<TBuilder>>;
|
|
851
|
-
/**
|
|
852
|
-
* Greater than or equal operator: field >= value
|
|
853
|
-
*/
|
|
854
|
-
declare function gte<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, value: ColumnToType<TBuilder>): BinaryExpression<ColumnToType<TBuilder>>;
|
|
855
|
-
/**
|
|
856
|
-
* Less than operator: field < value
|
|
857
|
-
*/
|
|
858
|
-
declare function lt<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, value: ColumnToType<TBuilder>): BinaryExpression<ColumnToType<TBuilder>>;
|
|
859
|
-
/**
|
|
860
|
-
* Less than or equal operator: field <= value
|
|
861
|
-
*/
|
|
862
|
-
declare function lte<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, value: ColumnToType<TBuilder>): BinaryExpression<ColumnToType<TBuilder>>;
|
|
863
|
-
/**
|
|
864
|
-
* Between operator: field BETWEEN min AND max (inclusive)
|
|
865
|
-
*
|
|
866
|
-
* Sugar for and(gte(field, min), lte(field, max)).
|
|
867
|
-
*/
|
|
868
|
-
declare function between<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, min: ColumnToType<TBuilder>, max: ColumnToType<TBuilder>): FilterExpression<boolean>;
|
|
869
|
-
/**
|
|
870
|
-
* Not between operator: field < min OR field > max
|
|
871
|
-
*
|
|
872
|
-
* Sugar for or(lt(field, min), gt(field, max)).
|
|
873
|
-
*/
|
|
874
|
-
declare function notBetween<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, min: ColumnToType<TBuilder>, max: ColumnToType<TBuilder>): FilterExpression<boolean>;
|
|
875
|
-
/**
|
|
876
|
-
* LIKE operator: SQL-style pattern matching with % wildcards
|
|
877
|
-
* Note: Implemented as post-filter (Convex has no native LIKE)
|
|
878
|
-
*
|
|
879
|
-
* @example
|
|
880
|
-
* const users = await db.query.users.findMany({
|
|
881
|
-
* where: like(users.name, '%alice%'),
|
|
882
|
-
* });
|
|
883
|
-
*/
|
|
884
|
-
declare function like<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, pattern: string): BinaryExpression<string>;
|
|
885
|
-
/**
|
|
886
|
-
* ILIKE operator: Case-insensitive LIKE
|
|
887
|
-
* Note: Implemented as post-filter (Convex has no native LIKE)
|
|
888
|
-
*
|
|
889
|
-
* @example
|
|
890
|
-
* const users = await db.query.users.findMany({
|
|
891
|
-
* where: ilike(users.name, '%ALICE%'),
|
|
892
|
-
* });
|
|
893
|
-
*/
|
|
894
|
-
declare function ilike<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, pattern: string): BinaryExpression<string>;
|
|
895
|
-
/**
|
|
896
|
-
* startsWith operator: Check if string starts with prefix
|
|
897
|
-
* Optimized for prefix matching
|
|
898
|
-
*
|
|
899
|
-
* @example
|
|
900
|
-
* const users = await db.query.users.findMany({
|
|
901
|
-
* where: startsWith(users.email, 'admin@'),
|
|
902
|
-
* });
|
|
903
|
-
*/
|
|
904
|
-
declare function startsWith<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, prefix: string): BinaryExpression<string>;
|
|
905
|
-
/**
|
|
906
|
-
* endsWith operator: Check if string ends with suffix
|
|
907
|
-
*
|
|
908
|
-
* @example
|
|
909
|
-
* const users = await db.query.users.findMany({
|
|
910
|
-
* where: endsWith(users.email, '@example.com'),
|
|
911
|
-
* });
|
|
912
|
-
*/
|
|
913
|
-
declare function endsWith<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, suffix: string): BinaryExpression<string>;
|
|
914
|
-
/**
|
|
915
|
-
* contains operator: Check if string contains substring
|
|
916
|
-
* Can use search index for optimization when available
|
|
917
|
-
*
|
|
918
|
-
* @example
|
|
919
|
-
* const posts = await db.query.posts.findMany({
|
|
920
|
-
* where: contains(posts.title, 'javascript'),
|
|
921
|
-
* });
|
|
922
|
-
*/
|
|
923
|
-
declare function contains<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, substring: string): BinaryExpression<string>;
|
|
924
|
-
/**
|
|
925
|
-
* Logical AND: all expressions must be true
|
|
926
|
-
* Filters out undefined expressions (following Drizzle pattern)
|
|
927
|
-
*
|
|
928
|
-
* @example
|
|
929
|
-
* const filter = and(
|
|
930
|
-
* eq(fieldRef('age'), 25),
|
|
931
|
-
* eq(fieldRef('name'), 'Alice')
|
|
932
|
-
* );
|
|
933
|
-
*/
|
|
934
|
-
declare function and(...expressions: (FilterExpression<boolean> | undefined)[]): LogicalExpression | undefined;
|
|
935
|
-
/**
|
|
936
|
-
* Logical OR: at least one expression must be true
|
|
937
|
-
* Filters out undefined expressions (following Drizzle pattern)
|
|
938
|
-
*
|
|
939
|
-
* @example
|
|
940
|
-
* const filter = or(
|
|
941
|
-
* eq(fieldRef('status'), 'active'),
|
|
942
|
-
* eq(fieldRef('status'), 'pending')
|
|
943
|
-
* );
|
|
944
|
-
*/
|
|
945
|
-
declare function or(...expressions: (FilterExpression<boolean> | undefined)[]): LogicalExpression | undefined;
|
|
946
|
-
/**
|
|
947
|
-
* Logical NOT: negates expression
|
|
948
|
-
*
|
|
949
|
-
* @example
|
|
950
|
-
* const filter = not(eq(fieldRef('isDeleted'), true));
|
|
951
|
-
*/
|
|
952
|
-
declare function not(expression: FilterExpression<boolean>): UnaryExpression;
|
|
953
|
-
/**
|
|
954
|
-
* Array membership operator: field IN array
|
|
955
|
-
*
|
|
956
|
-
* @example
|
|
957
|
-
* const filter = inArray(cols.status, ['active', 'pending']);
|
|
958
|
-
*/
|
|
959
|
-
declare function inArray<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, values: readonly ColumnToType<TBuilder>[]): BinaryExpression<ColumnToType<TBuilder>>;
|
|
960
|
-
/**
|
|
961
|
-
* Array exclusion operator: field NOT IN array
|
|
962
|
-
* Validates array is non-empty at construction time
|
|
963
|
-
*
|
|
964
|
-
* @example
|
|
965
|
-
* const filter = notInArray(cols.role, ['admin', 'moderator']);
|
|
966
|
-
*/
|
|
967
|
-
declare function notInArray<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>, values: readonly ColumnToType<TBuilder>[]): BinaryExpression<ColumnToType<TBuilder>>;
|
|
968
|
-
/**
|
|
969
|
-
* Null check operator: field IS NULL
|
|
970
|
-
* Type validation: Only works with nullable fields
|
|
971
|
-
*
|
|
972
|
-
* @example
|
|
973
|
-
* const filter = isNull(cols.deletedAt);
|
|
974
|
-
*/
|
|
975
|
-
declare function isNull<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>): UnaryExpression;
|
|
976
|
-
/**
|
|
977
|
-
* Not null check operator: field IS NOT NULL
|
|
978
|
-
* Type validation: Only works with nullable fields
|
|
979
|
-
*
|
|
980
|
-
* @example
|
|
981
|
-
* const filter = isNotNull(cols.deletedAt);
|
|
982
|
-
*/
|
|
983
|
-
declare function isNotNull<TBuilder extends ColumnBuilder<any, any, any>>(col: ColumnArgument<TBuilder>): UnaryExpression;
|
|
984
|
-
//#endregion
|
|
985
|
-
//#region src/orm/constraints.d.ts
|
|
986
|
-
type ConvexConstraintColumn = ColumnBuilderBase;
|
|
987
|
-
type ConvexForeignKeyColumns = [ConvexConstraintColumn, ...ConvexConstraintColumn[]];
|
|
988
|
-
interface ConvexUniqueConstraintConfig {
|
|
989
|
-
name?: string;
|
|
990
|
-
columns: ConvexConstraintColumn[];
|
|
991
|
-
nullsNotDistinct: boolean;
|
|
992
|
-
}
|
|
993
|
-
interface ConvexForeignKeyConfig<TColumns extends ConvexForeignKeyColumns = ConvexForeignKeyColumns> {
|
|
994
|
-
name?: string;
|
|
995
|
-
columns: TColumns;
|
|
996
|
-
foreignColumns: { [K in keyof TColumns]: ConvexConstraintColumn };
|
|
997
|
-
onUpdate?: ForeignKeyAction;
|
|
998
|
-
onDelete?: ForeignKeyAction;
|
|
999
|
-
}
|
|
1000
|
-
declare class ConvexUniqueConstraintBuilderOn {
|
|
1001
|
-
private name?;
|
|
1002
|
-
static readonly [entityKind] = "ConvexUniqueConstraintBuilderOn";
|
|
1003
|
-
readonly [entityKind] = "ConvexUniqueConstraintBuilderOn";
|
|
1004
|
-
constructor(name?: string | undefined);
|
|
1005
|
-
on(...columns: [ConvexConstraintColumn, ...ConvexConstraintColumn[]]): ConvexUniqueConstraintBuilder;
|
|
1006
|
-
}
|
|
1007
|
-
declare class ConvexUniqueConstraintBuilder {
|
|
1008
|
-
static readonly [entityKind] = "ConvexUniqueConstraintBuilder";
|
|
1009
|
-
readonly [entityKind] = "ConvexUniqueConstraintBuilder";
|
|
1010
|
-
_: {
|
|
1011
|
-
brand: 'ConvexUniqueConstraintBuilder';
|
|
1012
|
-
};
|
|
1013
|
-
config: ConvexUniqueConstraintConfig;
|
|
1014
|
-
constructor(name: string | undefined, columns: ConvexConstraintColumn[]);
|
|
1015
|
-
nullsNotDistinct(): this;
|
|
1016
|
-
}
|
|
1017
|
-
declare class ConvexForeignKeyBuilder {
|
|
1018
|
-
static readonly [entityKind] = "ConvexForeignKeyBuilder";
|
|
1019
|
-
readonly [entityKind] = "ConvexForeignKeyBuilder";
|
|
1020
|
-
_: {
|
|
1021
|
-
brand: 'ConvexForeignKeyBuilder';
|
|
1022
|
-
};
|
|
1023
|
-
config: ConvexForeignKeyConfig;
|
|
1024
|
-
constructor(config: ConvexForeignKeyConfig);
|
|
1025
|
-
onUpdate(action: ForeignKeyAction): this;
|
|
1026
|
-
onDelete(action: ForeignKeyAction): this;
|
|
1027
|
-
}
|
|
1028
|
-
declare function unique(name?: string): ConvexUniqueConstraintBuilderOn;
|
|
1029
|
-
declare function foreignKey<TColumns extends ConvexForeignKeyColumns>(config: ConvexForeignKeyConfig<TColumns>): ConvexForeignKeyBuilder;
|
|
1030
|
-
interface ConvexCheckConfig {
|
|
1031
|
-
name: string;
|
|
1032
|
-
expression: FilterExpression<boolean>;
|
|
1033
|
-
}
|
|
1034
|
-
declare class ConvexCheckBuilder {
|
|
1035
|
-
static readonly [entityKind] = "ConvexCheckBuilder";
|
|
1036
|
-
readonly [entityKind] = "ConvexCheckBuilder";
|
|
1037
|
-
_: {
|
|
1038
|
-
brand: 'ConvexCheckBuilder';
|
|
1039
|
-
};
|
|
1040
|
-
config: ConvexCheckConfig;
|
|
1041
|
-
constructor(name: string, expression: FilterExpression<boolean>);
|
|
1042
|
-
}
|
|
1043
|
-
declare function check(name: string, expression: FilterExpression<boolean>): ConvexCheckBuilder;
|
|
1044
|
-
//#endregion
|
|
1045
|
-
//#region src/orm/symbols.d.ts
|
|
1046
|
-
/**
|
|
1047
|
-
* Symbol-based metadata storage for ORM tables
|
|
1048
|
-
* Following Drizzle's pattern for type-safe runtime introspection
|
|
1049
|
-
*/
|
|
1050
|
-
type OrmRuntimeDefaults = {
|
|
1051
|
-
defaultLimit?: number;
|
|
1052
|
-
relationFanOutMaxKeys?: number;
|
|
1053
|
-
mutationBatchSize?: number;
|
|
1054
|
-
mutationLeafBatchSize?: number;
|
|
1055
|
-
mutationMaxRows?: number;
|
|
1056
|
-
mutationMaxBytesPerBatch?: number;
|
|
1057
|
-
mutationScheduleCallCap?: number;
|
|
1058
|
-
mutationExecutionMode?: 'sync' | 'async';
|
|
1059
|
-
mutationAsyncDelayMs?: number;
|
|
1060
|
-
};
|
|
1061
|
-
type OrmDeleteMode = 'hard' | 'soft' | 'scheduled';
|
|
1062
|
-
type OrmTableDeleteConfig = {
|
|
1063
|
-
mode: OrmDeleteMode;
|
|
1064
|
-
delayMs?: number;
|
|
1065
|
-
};
|
|
1066
|
-
declare const TableName: unique symbol;
|
|
1067
|
-
declare const Columns: unique symbol;
|
|
1068
|
-
declare const Brand: unique symbol;
|
|
1069
|
-
declare const RlsPolicies: unique symbol;
|
|
1070
|
-
declare const EnableRLS: unique symbol;
|
|
1071
|
-
declare const TableDeleteConfig: unique symbol;
|
|
1072
|
-
declare const TableLifecycleHooks: unique symbol;
|
|
1073
|
-
declare const OrmSchemaDefinition: unique symbol;
|
|
1074
|
-
//#endregion
|
|
1075
|
-
//#region src/orm/unset-token.d.ts
|
|
1076
|
-
declare const unsetToken: unique symbol;
|
|
1077
|
-
type UnsetToken = typeof unsetToken;
|
|
1078
|
-
//#endregion
|
|
1079
|
-
//#region src/orm/types.d.ts
|
|
1080
|
-
/**
|
|
1081
|
-
* Value or array helper (Drizzle pattern).
|
|
1082
|
-
*/
|
|
1083
|
-
type ValueOrArray<T> = T | T[];
|
|
1084
|
-
/**
|
|
1085
|
-
* Type equality check - returns true if X and Y are exactly the same type
|
|
1086
|
-
* Pattern from Drizzle: drizzle-orm/src/utils.ts:172
|
|
1087
|
-
*/
|
|
1088
|
-
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
1089
|
-
/**
|
|
1090
|
-
* Merge two object types without using intersection
|
|
1091
|
-
* Intersection can cause TypeScript to lose phantom type brands
|
|
1092
|
-
* This manually combines keys from both types
|
|
1093
|
-
*/
|
|
1094
|
-
type Merge<A, B> = { [K in keyof A | keyof B]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never };
|
|
1095
|
-
type IndexKey = (Value | undefined)[];
|
|
1096
|
-
type FindManyUnionSource<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = {
|
|
1097
|
-
where?: RelationsFilter<TTableConfig, any> | WhereCallback<TTableConfig>;
|
|
1098
|
-
};
|
|
1099
|
-
type PipelineRelationName<TTableConfig extends TableRelationalConfig> = Extract<keyof TTableConfig['relations'], string>;
|
|
1100
|
-
type FindManyPipelineFlatMapConfig<TTableConfig extends TableRelationalConfig = TableRelationalConfig, TRelationName extends PipelineRelationName<TTableConfig> = PipelineRelationName<TTableConfig>> = {
|
|
1101
|
-
relation: TRelationName;
|
|
1102
|
-
where?: unknown;
|
|
1103
|
-
orderBy?: unknown;
|
|
1104
|
-
limit?: number;
|
|
1105
|
-
includeParent?: boolean;
|
|
1106
|
-
};
|
|
1107
|
-
type FindManyPipelineFlatMapStage<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = {
|
|
1108
|
-
flatMap: FindManyPipelineFlatMapConfig<TTableConfig>;
|
|
1109
|
-
};
|
|
1110
|
-
type FindManyPipelineFilterWithStage<TRow = unknown> = {
|
|
1111
|
-
filterWith: (row: TRow) => boolean | Promise<boolean>;
|
|
1112
|
-
};
|
|
1113
|
-
type FindManyPipelineMapStage<TRow = unknown, TOutput = unknown> = {
|
|
1114
|
-
map: (row: TRow) => TOutput | null | Promise<TOutput | null>;
|
|
1115
|
-
};
|
|
1116
|
-
type FindManyPipelineDistinctStage = {
|
|
1117
|
-
distinct: {
|
|
1118
|
-
fields: string[];
|
|
1119
|
-
};
|
|
1120
|
-
};
|
|
1121
|
-
type FindManyPipelineStageForInput<TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableConfig extends TableRelationalConfig = TableRelationalConfig, TRow = BuildQueryResult<TSchema, TTableConfig, true>> = FindManyPipelineFilterWithStage<TRow> | FindManyPipelineMapStage<TRow> | FindManyPipelineDistinctStage | FindManyPipelineFlatMapStage<TTableConfig>;
|
|
1122
|
-
type FindManyPipelineConfig<TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableConfig extends TableRelationalConfig = TableRelationalConfig, TStages extends readonly unknown[] = readonly FindManyPipelineStageForInput<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, true>>[]> = {
|
|
1123
|
-
union?: FindManyUnionSource<TTableConfig>[];
|
|
1124
|
-
interleaveBy?: string[];
|
|
1125
|
-
stages?: TStages;
|
|
1126
|
-
};
|
|
1127
|
-
type FindManyPageByKeyConfig = {
|
|
1128
|
-
index?: string;
|
|
1129
|
-
order?: 'asc' | 'desc';
|
|
1130
|
-
startKey?: IndexKey;
|
|
1131
|
-
startInclusive?: boolean;
|
|
1132
|
-
endKey?: IndexKey;
|
|
1133
|
-
endInclusive?: boolean;
|
|
1134
|
-
targetMaxRows?: number;
|
|
1135
|
-
absoluteMaxRows?: number;
|
|
1136
|
-
};
|
|
1137
|
-
type KeyPageResult<T> = {
|
|
1138
|
-
page: T[];
|
|
1139
|
-
indexKeys: IndexKey[];
|
|
1140
|
-
hasMore: boolean;
|
|
1141
|
-
};
|
|
1142
|
-
/**
|
|
1143
|
-
* Extract full document type from a ConvexTable (includes system fields)
|
|
1144
|
-
* Uses GetColumnData in 'query' mode to respect notNull brands
|
|
1145
|
-
*
|
|
1146
|
-
* @example
|
|
1147
|
-
* const users = convexTable('users', { name: text().notNull() });
|
|
1148
|
-
* type User = InferSelectModel<typeof users>;
|
|
1149
|
-
* // → { id: string, createdAt: number, name: string }
|
|
1150
|
-
*
|
|
1151
|
-
* const posts = convexTable('posts', { title: text() }); // nullable
|
|
1152
|
-
* type Post = InferSelectModel<typeof posts>;
|
|
1153
|
-
* // → { id: string, createdAt: number, title: string | null }
|
|
1154
|
-
*/
|
|
1155
|
-
type InferSelectModel<TTable extends ConvexTable<any>> = Simplify<Merge<{
|
|
1156
|
-
id: string;
|
|
1157
|
-
createdAt: number;
|
|
1158
|
-
}, { [K in keyof TTable['_']['columns']]: GetColumnData<TTable['_']['columns'][K], 'query'> }>>;
|
|
1159
|
-
type RequiredKeyOnly<TKey extends string, TColumn extends ColumnBuilder<any, any, any>> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? never : TKey : never;
|
|
1160
|
-
type OptionalKeyOnly<TKey extends string, TColumn extends ColumnBuilder<any, any, any>> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? TKey : never : TKey;
|
|
1161
|
-
/**
|
|
1162
|
-
* Extract insert type from a ConvexTable (excludes system fields).
|
|
1163
|
-
* Mirrors Drizzle behavior: required if notNull && no default, otherwise optional.
|
|
1164
|
-
*
|
|
1165
|
-
* @example
|
|
1166
|
-
* const users = convexTable('users', { name: text().notNull() });
|
|
1167
|
-
* type NewUser = InferInsertModel<typeof users>;
|
|
1168
|
-
* // → { name: string }
|
|
1169
|
-
*/
|
|
1170
|
-
type InferInsertModel<TTable extends ConvexTable<any>> = Simplify<{ [K in keyof TTable['_']['columns'] & string as RequiredKeyOnly<K, TTable['_']['columns'][K]>]: GetColumnData<TTable['_']['columns'][K], 'query'> } & { [K in keyof TTable['_']['columns'] & string as OptionalKeyOnly<K, TTable['_']['columns'][K]>]?: GetColumnData<TTable['_']['columns'][K], 'query'> | undefined }>;
|
|
1171
|
-
/**
|
|
1172
|
-
* Extract column data type with mode-based handling (Drizzle pattern)
|
|
1173
|
-
*
|
|
1174
|
-
* Following Drizzle's GetColumnData pattern for consistent type extraction:
|
|
1175
|
-
* - 'raw' mode: Returns base data type without null (for inserts, operator comparisons)
|
|
1176
|
-
* - 'query' mode: Respects notNull brand, adds | null for nullable fields (for selects)
|
|
1177
|
-
*
|
|
1178
|
-
* @template TColumn - Column builder type
|
|
1179
|
-
* @template TInferMode - 'query' (default, adds | null) or 'raw' (base type only)
|
|
1180
|
-
*
|
|
1181
|
-
* @example
|
|
1182
|
-
* const name = text().notNull();
|
|
1183
|
-
* type NameQuery = GetColumnData<typeof name, 'query'>; // string
|
|
1184
|
-
* type NameRaw = GetColumnData<typeof name, 'raw'>; // string
|
|
1185
|
-
*
|
|
1186
|
-
* const age = integer(); // nullable
|
|
1187
|
-
* type AgeQuery = GetColumnData<typeof age, 'query'>; // number | null
|
|
1188
|
-
* type AgeRaw = GetColumnData<typeof age, 'raw'>; // number
|
|
1189
|
-
*/
|
|
1190
|
-
type GetColumnData<TColumn extends ColumnBuilder<any, any, any>, TInferMode extends 'query' | 'raw' = 'query'> = TInferMode extends 'raw' ? TColumn['_'] extends {
|
|
1191
|
-
$type: infer TType;
|
|
1192
|
-
} ? TType : TColumn['_']['data'] : TColumn['_']['notNull'] extends true ? TColumn['_'] extends {
|
|
1193
|
-
$type: infer TType;
|
|
1194
|
-
} ? TType : TColumn['_']['data'] : (TColumn['_'] extends {
|
|
1195
|
-
$type: infer TType;
|
|
1196
|
-
} ? TType : TColumn['_']['data']) | null;
|
|
1197
|
-
/**
|
|
1198
|
-
* Query configuration for findMany/findFirst
|
|
1199
|
-
*
|
|
1200
|
-
* @template TRelationType - 'one' or 'many' determines available options
|
|
1201
|
-
* @template TSchema - Full schema configuration
|
|
1202
|
-
* @template TTableConfig - Configuration for the queried table
|
|
1203
|
-
*/
|
|
1204
|
-
type DBQueryConfig<TRelationType extends 'one' | 'many' = 'one' | 'many', _TIsRoot extends boolean = boolean, TSchema extends TablesRelationalConfig = TablesRelationalConfig, TTableConfig extends TableRelationalConfig = TableRelationalConfig> = {
|
|
1205
|
-
/**
|
|
1206
|
-
* Column selection - pick specific columns to return
|
|
1207
|
-
* If omitted, all columns are selected
|
|
1208
|
-
*/
|
|
1209
|
-
columns?: { [K in keyof TableColumns<TTableConfig>]?: boolean } | undefined;
|
|
1210
|
-
/**
|
|
1211
|
-
* Relation loading - specify which relations to include
|
|
1212
|
-
* Can be `true` for default config or nested config object
|
|
1213
|
-
*/
|
|
1214
|
-
with?: KnownKeysOnly<{ [K in keyof TTableConfig['relations']]?: true | DBQueryConfig<TTableConfig['relations'][K] extends One<any, any> ? 'one' : 'many', false, TSchema, FindTableByDBName<TSchema, TTableConfig['relations'][K]['targetTableName']>> | undefined }, TTableConfig['relations']> | undefined;
|
|
1215
|
-
/**
|
|
1216
|
-
* Extra computed fields (post-fetch, computed in JS at runtime)
|
|
1217
|
-
*/
|
|
1218
|
-
extras?: Record<string, Value | ((row: InferModelFromColumns<TableColumns<TTableConfig>>) => Value)> | ((fields: Simplify<[TableColumns<TTableConfig>] extends [never] ? {} : TableColumns<TTableConfig>>) => Record<string, Value | ((row: InferModelFromColumns<TableColumns<TTableConfig>>) => Value)>) | undefined;
|
|
1219
|
-
/**
|
|
1220
|
-
* Order results - callback or object syntax
|
|
1221
|
-
*/
|
|
1222
|
-
orderBy?: DBQueryConfigOrderBy<TTableConfig> | undefined; /** Skip first N results */
|
|
1223
|
-
offset?: number | undefined;
|
|
1224
|
-
/**
|
|
1225
|
-
* Cursor pagination (Convex native). When `cursor` is provided, `limit` is
|
|
1226
|
-
* required and the result type changes to a paginated shape.
|
|
1227
|
-
*
|
|
1228
|
-
* - First page: cursor: null
|
|
1229
|
-
* - Next page: cursor: previous.continueCursor
|
|
1230
|
-
*/
|
|
1231
|
-
cursor?: _TIsRoot extends true ? string | null : never;
|
|
1232
|
-
/**
|
|
1233
|
-
* Pin the end boundary to a previously returned cursor.
|
|
1234
|
-
* Only valid with cursor pagination.
|
|
1235
|
-
*/
|
|
1236
|
-
endCursor?: _TIsRoot extends true ? string | null : never;
|
|
1237
|
-
/**
|
|
1238
|
-
* Maximum documents to scan during predicate `where(fn)` pagination.
|
|
1239
|
-
* Only valid when `cursor` is provided.
|
|
1240
|
-
*/
|
|
1241
|
-
maxScan?: _TIsRoot extends true ? number : never;
|
|
1242
|
-
/**
|
|
1243
|
-
* Full-text search query configuration.
|
|
1244
|
-
* Only available on tables that declare search indexes.
|
|
1245
|
-
*/
|
|
1246
|
-
search?: SearchQueryConfig<TTableConfig> | undefined;
|
|
1247
|
-
/**
|
|
1248
|
-
* Vector search query configuration.
|
|
1249
|
-
* Only available on tables that declare vector indexes.
|
|
1250
|
-
*/
|
|
1251
|
-
vectorSearch?: VectorQueryConfig<TTableConfig> | undefined;
|
|
1252
|
-
/**
|
|
1253
|
-
* Stream-backed advanced query pipeline.
|
|
1254
|
-
*/
|
|
1255
|
-
pipeline?: _TIsRoot extends true ? FindManyPipelineConfig<TSchema, TTableConfig> : never;
|
|
1256
|
-
/**
|
|
1257
|
-
* Key-based page boundaries.
|
|
1258
|
-
*/
|
|
1259
|
-
pageByKey?: _TIsRoot extends true ? FindManyPageByKeyConfig : never;
|
|
1260
|
-
} & (TRelationType extends 'many' ? {
|
|
1261
|
-
/** Limit number of results */limit?: number | undefined;
|
|
1262
|
-
} : {}) & {
|
|
1263
|
-
/**
|
|
1264
|
-
* Relation-aware filter object (v1) or callback expression.
|
|
1265
|
-
*/
|
|
1266
|
-
where?: RelationsFilter<TTableConfig, TSchema> | WhereCallback<TTableConfig> | undefined;
|
|
1267
|
-
/**
|
|
1268
|
-
* Allow full scans when no index can be used.
|
|
1269
|
-
*/
|
|
1270
|
-
allowFullScan?: boolean | undefined;
|
|
1271
|
-
};
|
|
1272
|
-
type PredicateWhereClause<TTableConfig extends TableRelationalConfig> = {
|
|
1273
|
-
readonly __kind: 'predicate';
|
|
1274
|
-
readonly predicate: (row: InferModelFromColumns<TableColumns<TTableConfig>>) => boolean | Promise<boolean>;
|
|
1275
|
-
};
|
|
1276
|
-
type WhereCallback<TTableConfig extends TableRelationalConfig> = (table: TTableConfig['table'], operators: FilterOperators<TTableConfig>) => FilterExpression<boolean> | PredicateWhereClause<TTableConfig> | undefined;
|
|
1277
|
-
type PredicateWhereIndexMap<TTableConfig extends TableRelationalConfig> = TTableConfig['table'] extends ConvexTable<any, infer TIndexes, any, any> ? TIndexes : Record<string, GenericIndexFields>;
|
|
1278
|
-
type PredicateWhereIndexName<TTableConfig extends TableRelationalConfig> = Extract<keyof PredicateWhereIndexMap<TTableConfig>, string>;
|
|
1279
|
-
type PredicateWhereNamedIndex<TTableConfig extends TableRelationalConfig, TIndexName extends string> = TIndexName extends PredicateWhereIndexName<TTableConfig> ? PredicateWhereIndexMap<TTableConfig>[TIndexName] extends GenericIndexFields ? PredicateWhereIndexMap<TTableConfig>[TIndexName] : GenericIndexFields : GenericIndexFields;
|
|
1280
|
-
type PredicateWhereIndexConfig<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = [PredicateWhereIndexName<TTableConfig>] extends [never] ? {
|
|
1281
|
-
name: string;
|
|
1282
|
-
range?: (q: IndexRangeBuilder<InferModelFromColumns<TableColumns<TTableConfig>>, GenericIndexFields>) => IndexRange;
|
|
1283
|
-
} : { [TIndexName in PredicateWhereIndexName<TTableConfig>]: {
|
|
1284
|
-
name: TIndexName;
|
|
1285
|
-
range?: (q: IndexRangeBuilder<InferModelFromColumns<TableColumns<TTableConfig>>, PredicateWhereNamedIndex<TTableConfig, TIndexName>>) => IndexRange;
|
|
1286
|
-
} }[PredicateWhereIndexName<TTableConfig>];
|
|
1287
|
-
type SearchIndexMap<TTableConfig extends TableRelationalConfig> = TTableConfig['table'] extends ConvexTable<any, any, infer TSearchIndexes, any> ? TSearchIndexes : Record<string, {
|
|
1288
|
-
searchField: string;
|
|
1289
|
-
filterFields: string;
|
|
1290
|
-
}>;
|
|
1291
|
-
type SearchIndexName<TTableConfig extends TableRelationalConfig> = Extract<keyof SearchIndexMap<TTableConfig>, string>;
|
|
1292
|
-
type SearchIndexConfigByName<TTableConfig extends TableRelationalConfig, TIndexName extends SearchIndexName<TTableConfig>> = SearchIndexMap<TTableConfig>[TIndexName];
|
|
1293
|
-
type SearchFilterFieldNames<TTableConfig extends TableRelationalConfig, TIndexName extends SearchIndexName<TTableConfig>> = SearchIndexConfigByName<TTableConfig, TIndexName> extends {
|
|
1294
|
-
filterFields: infer TFilterFields extends string;
|
|
1295
|
-
} ? TFilterFields : never;
|
|
1296
|
-
type SearchFilterValueForField<TTableConfig extends TableRelationalConfig, TFieldName extends string> = TFieldName extends keyof TableColumns<TTableConfig> ? TableColumns<TTableConfig>[TFieldName] extends ColumnBuilder<any, any, any> ? GetColumnData<TableColumns<TTableConfig>[TFieldName], 'raw'> : never : never;
|
|
1297
|
-
type SearchFiltersForIndex<TTableConfig extends TableRelationalConfig, TIndexName extends SearchIndexName<TTableConfig>> = Partial<{ [K in SearchFilterFieldNames<TTableConfig, TIndexName>]: SearchFilterValueForField<TTableConfig, K> }>;
|
|
1298
|
-
type SearchQueryConfig<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = [SearchIndexName<TTableConfig>] extends [never] ? never : { [TIndexName in SearchIndexName<TTableConfig>]: {
|
|
1299
|
-
index: TIndexName;
|
|
1300
|
-
query: string;
|
|
1301
|
-
filters?: SearchFiltersForIndex<TTableConfig, TIndexName> | undefined;
|
|
1302
|
-
} }[SearchIndexName<TTableConfig>];
|
|
1303
|
-
type SearchWhereFilter<TTableConfig extends TableRelationalConfig> = TableFilter<TTableConfig['table']>;
|
|
1304
|
-
type VectorIndexMap<TTableConfig extends TableRelationalConfig> = TTableConfig['table'] extends ConvexTable<any, any, any, infer TVectorIndexes> ? TVectorIndexes : Record<string, {
|
|
1305
|
-
vectorField: string;
|
|
1306
|
-
dimensions: number;
|
|
1307
|
-
filterFields: string;
|
|
1308
|
-
}>;
|
|
1309
|
-
type VectorIndexName<TTableConfig extends TableRelationalConfig> = Extract<keyof VectorIndexMap<TTableConfig>, string>;
|
|
1310
|
-
type VectorIndexConfigByName<TTableConfig extends TableRelationalConfig, TIndexName extends VectorIndexName<TTableConfig>> = VectorIndexMap<TTableConfig>[TIndexName];
|
|
1311
|
-
type VectorFilterFieldNames<TTableConfig extends TableRelationalConfig, TIndexName extends VectorIndexName<TTableConfig>> = VectorIndexConfigByName<TTableConfig, TIndexName> extends {
|
|
1312
|
-
filterFields: infer TFilterFields extends string;
|
|
1313
|
-
} ? TFilterFields : never;
|
|
1314
|
-
type VectorFilterForIndex<TTableConfig extends TableRelationalConfig, TIndexName extends VectorIndexName<TTableConfig>> = (q: VectorFilterBuilder<InferModelFromColumns<TableColumns<TTableConfig>>, VectorIndexConfigByName<TTableConfig, TIndexName>>) => FilterExpression$1<boolean>;
|
|
1315
|
-
type VectorQueryConfig<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = [VectorIndexName<TTableConfig>] extends [never] ? never : { [TIndexName in VectorIndexName<TTableConfig>]: {
|
|
1316
|
-
index: TIndexName;
|
|
1317
|
-
vector: number[];
|
|
1318
|
-
limit: number;
|
|
1319
|
-
includeScore?: boolean | undefined;
|
|
1320
|
-
filter?: (VectorFilterFieldNames<TTableConfig, TIndexName> extends never ? never : VectorFilterForIndex<TTableConfig, TIndexName>) | undefined;
|
|
1321
|
-
} }[VectorIndexName<TTableConfig>];
|
|
1322
|
-
type VectorSearchProvider = (tableName: string, indexName: string, query: {
|
|
1323
|
-
vector: number[];
|
|
1324
|
-
limit: number;
|
|
1325
|
-
filter?: ((q: any) => unknown) | undefined;
|
|
1326
|
-
}) => Promise<Array<{
|
|
1327
|
-
_id: GenericId<string> | string;
|
|
1328
|
-
_score: number;
|
|
1329
|
-
}>>;
|
|
1330
|
-
type FullScanOperatorKey = 'arrayContains' | 'arrayContained' | 'arrayOverlaps' | 'ilike' | 'notLike' | 'notIlike' | 'endsWith' | 'contains' | 'RAW';
|
|
1331
|
-
type HasFullScanOperatorKey<T> = Extract<keyof T, FullScanOperatorKey> extends never ? false : true;
|
|
1332
|
-
type DepthPrev = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8];
|
|
1333
|
-
type HasStaticFullScanWhere<TWhere, TDepth extends number = 6> = [TDepth] extends [0] ? false : TWhere extends ((...args: any[]) => any) ? false : TWhere extends string | number | boolean | bigint | null | undefined ? false : TWhere extends readonly (infer TItem)[] ? HasStaticFullScanWhere<TItem, DepthPrev[TDepth]> : TWhere extends object ? HasFullScanOperatorKey<TWhere> extends true ? true : 'NOT' extends keyof TWhere ? true : true extends { [K in keyof TWhere]-?: HasStaticFullScanWhere<TWhere[K], DepthPrev[TDepth]> }[keyof TWhere] ? true : false : false;
|
|
1334
|
-
type ReturnsPredicateClause<TWhere> = TWhere extends ((...args: any[]) => infer TResult) ? Extract<NonNullable<TResult>, PredicateWhereClause<any>> extends never ? false : true : false;
|
|
1335
|
-
type EnforceWithIndexForWhere<TConfig, _TTableConfig extends TableRelationalConfig, THasIndex extends boolean> = THasIndex extends true ? TConfig : TConfig extends {
|
|
1336
|
-
where: infer TWhere;
|
|
1337
|
-
} ? ReturnsPredicateClause<TWhere> extends true ? never : HasStaticFullScanWhere<TWhere> extends true ? never : TConfig : TConfig;
|
|
1338
|
-
type EnforceNoAllowFullScanWhenIndexed<TConfig, THasIndex extends boolean> = THasIndex extends true ? Omit<TConfig, 'allowFullScan'> & {
|
|
1339
|
-
allowFullScan?: never;
|
|
1340
|
-
} : TConfig;
|
|
1341
|
-
type EnforceCursorMaxScan<TConfig> = TConfig extends {
|
|
1342
|
-
cursor: string | null;
|
|
1343
|
-
} ? TConfig extends {
|
|
1344
|
-
where: infer TWhere;
|
|
1345
|
-
} ? HasStaticFullScanWhere<TWhere> extends true ? Omit<TConfig, 'allowFullScan'> & {
|
|
1346
|
-
maxScan: number;
|
|
1347
|
-
allowFullScan?: never;
|
|
1348
|
-
} : TConfig : TConfig : TConfig;
|
|
1349
|
-
type EnforceSearchConstraints<TConfig, TTableConfig extends TableRelationalConfig> = 'search' extends keyof TConfig ? TConfig extends {
|
|
1350
|
-
search: infer TSearch;
|
|
1351
|
-
} ? [TSearch] extends [undefined] ? TConfig : Omit<TConfig, 'where' | 'orderBy' | 'vectorSearch'> & {
|
|
1352
|
-
search: TSearch;
|
|
1353
|
-
where?: SearchWhereFilter<TTableConfig> | undefined;
|
|
1354
|
-
orderBy?: never;
|
|
1355
|
-
vectorSearch?: never;
|
|
1356
|
-
} : TConfig : TConfig;
|
|
1357
|
-
type EnforceVectorSearchConstraints<TConfig, _TTableConfig extends TableRelationalConfig> = 'vectorSearch' extends keyof TConfig ? TConfig extends {
|
|
1358
|
-
vectorSearch: infer TVectorSearch;
|
|
1359
|
-
} ? [TVectorSearch] extends [undefined] ? TConfig : Omit<TConfig, 'search' | 'where' | 'orderBy' | 'cursor' | 'maxScan' | 'offset' | 'limit' | 'allowFullScan'> & {
|
|
1360
|
-
vectorSearch: TVectorSearch;
|
|
1361
|
-
search?: never;
|
|
1362
|
-
where?: never;
|
|
1363
|
-
orderBy?: never;
|
|
1364
|
-
cursor?: never;
|
|
1365
|
-
maxScan?: never;
|
|
1366
|
-
offset?: never;
|
|
1367
|
-
limit?: never;
|
|
1368
|
-
allowFullScan?: never;
|
|
1369
|
-
} : TConfig : TConfig;
|
|
1370
|
-
/**
|
|
1371
|
-
* Filter operators available in where clause
|
|
1372
|
-
* Following Drizzle pattern: accept column builders directly, extract types with GetColumnData
|
|
1373
|
-
*
|
|
1374
|
-
* Operators use 'raw' mode for comparisons (no null union in comparison values)
|
|
1375
|
-
* Runtime wraps builders with column() helper for FilterExpression construction
|
|
1376
|
-
*/
|
|
1377
|
-
interface FilterOperators<TTableConfig extends TableRelationalConfig = TableRelationalConfig> {
|
|
1378
|
-
and(...expressions: (FilterExpression<boolean> | undefined)[]): FilterExpression<boolean> | undefined;
|
|
1379
|
-
or(...expressions: (FilterExpression<boolean> | undefined)[]): FilterExpression<boolean> | undefined;
|
|
1380
|
-
not(expression: FilterExpression<boolean>): FilterExpression<boolean>;
|
|
1381
|
-
eq<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, value: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1382
|
-
ne<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, value: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1383
|
-
gt<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, value: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1384
|
-
gte<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, value: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1385
|
-
lt<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, value: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1386
|
-
lte<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, value: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1387
|
-
between<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, min: GetColumnData<TBuilder, 'raw'>, max: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1388
|
-
notBetween<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, min: GetColumnData<TBuilder, 'raw'>, max: GetColumnData<TBuilder, 'raw'>): FilterExpression<boolean>;
|
|
1389
|
-
inArray<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, values: readonly GetColumnData<TBuilder, 'raw'>[]): FilterExpression<boolean>;
|
|
1390
|
-
notInArray<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, values: readonly GetColumnData<TBuilder, 'raw'>[]): FilterExpression<boolean>;
|
|
1391
|
-
arrayContains<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, values: readonly GetColumnData<TBuilder, 'raw'>[]): FilterExpression<boolean>;
|
|
1392
|
-
arrayContained<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, values: readonly GetColumnData<TBuilder, 'raw'>[]): FilterExpression<boolean>;
|
|
1393
|
-
arrayOverlaps<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, values: readonly GetColumnData<TBuilder, 'raw'>[]): FilterExpression<boolean>;
|
|
1394
|
-
isNull<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder extends {
|
|
1395
|
-
_: {
|
|
1396
|
-
notNull: true;
|
|
1397
|
-
};
|
|
1398
|
-
} ? never : TBuilder): FilterExpression<boolean>;
|
|
1399
|
-
isNotNull<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder): FilterExpression<boolean>;
|
|
1400
|
-
like<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, pattern: string): FilterExpression<boolean>;
|
|
1401
|
-
ilike<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, pattern: string): FilterExpression<boolean>;
|
|
1402
|
-
notLike<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, pattern: string): FilterExpression<boolean>;
|
|
1403
|
-
notIlike<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, pattern: string): FilterExpression<boolean>;
|
|
1404
|
-
startsWith<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, prefix: string): FilterExpression<boolean>;
|
|
1405
|
-
endsWith<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, suffix: string): FilterExpression<boolean>;
|
|
1406
|
-
contains<TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder, substring: string): FilterExpression<boolean>;
|
|
1407
|
-
predicate(predicate: (row: InferModelFromColumns<TableColumns<TTableConfig>>) => boolean | Promise<boolean>): PredicateWhereClause<TTableConfig>;
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* Order by clause - represents a single field ordering
|
|
1411
|
-
* Following Drizzle pattern for type-safe ordering
|
|
1412
|
-
*
|
|
1413
|
-
* @template TColumn - Column builder type
|
|
1414
|
-
*/
|
|
1415
|
-
interface OrderByClause<TColumn extends ColumnBuilder<any, any, any>> {
|
|
1416
|
-
readonly column: Column<TColumn, string>;
|
|
1417
|
-
readonly direction: 'asc' | 'desc';
|
|
1418
|
-
}
|
|
1419
|
-
/**
|
|
1420
|
-
* Order by input - either a column builder (default ASC)
|
|
1421
|
-
* or an explicit order by clause from asc()/desc().
|
|
1422
|
-
*/
|
|
1423
|
-
type OrderByValue<TColumn extends ColumnBuilder<any, any, any> = ColumnBuilder<any, any, any>> = OrderByClause<TColumn> | TColumn;
|
|
1424
|
-
/**
|
|
1425
|
-
* Order direction helpers
|
|
1426
|
-
*/
|
|
1427
|
-
interface OrderDirection {
|
|
1428
|
-
asc: <TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder) => OrderByClause<TBuilder>;
|
|
1429
|
-
desc: <TBuilder extends ColumnBuilder<any, any, any>>(field: TBuilder) => OrderByClause<TBuilder>;
|
|
1430
|
-
}
|
|
1431
|
-
type DBQueryConfigOrderByCallback<TTable extends ConvexTable<any>> = (table: TTable, operators: OrderDirection) => ValueOrArray<OrderByValue> | undefined;
|
|
1432
|
-
type DBQueryConfigOrderByObject<TColumns extends Record<string, unknown>> = { [K in keyof TColumns]?: 'asc' | 'desc' | undefined };
|
|
1433
|
-
type DBQueryConfigOrderBy<TTableConfig extends TableRelationalConfig> = DBQueryConfigOrderByCallback<TTableConfig['table']> | DBQueryConfigOrderByObject<TableColumns<TTableConfig>>;
|
|
1434
|
-
/**
|
|
1435
|
-
* Build query result type from configuration
|
|
1436
|
-
* Handles column selection and relation loading
|
|
1437
|
-
*
|
|
1438
|
-
* @template TSchema - Full schema configuration
|
|
1439
|
-
* @template TTableConfig - Configuration for queried table
|
|
1440
|
-
* @template TConfig - Query configuration (true | config object)
|
|
1441
|
-
*/
|
|
1442
|
-
/**
|
|
1443
|
-
* Infer selected columns from a raw selection using Drizzle v1 semantics.
|
|
1444
|
-
* - Any `true` => include-only
|
|
1445
|
-
* - All `false` => exclude-only
|
|
1446
|
-
* - Empty / all undefined => no columns
|
|
1447
|
-
*/
|
|
1448
|
-
type InferRelationalQueryTableResult<TRawSelection extends Record<string, unknown>, TSelectedFields extends Record<string, unknown> | 'Full' = 'Full'> = TSelectedFields extends 'Full' ? TRawSelection : { [K in Equal<Exclude<TSelectedFields[keyof TSelectedFields & keyof TRawSelection], undefined>, false> extends true ? Exclude<keyof TRawSelection, NonUndefinedKeysOnly$1<TSelectedFields>> : { [K in keyof TSelectedFields]: Equal<TSelectedFields[K], true> extends true ? K : never }[keyof TSelectedFields] & keyof TRawSelection]: TRawSelection[K] };
|
|
1449
|
-
type TableColumns<TTableConfig extends TableRelationalConfig> = TTableConfig['table']['_']['columns'] & SystemFields<TTableConfig['table']['_']['name']> & SystemFieldAliases<TTableConfig['table']['_']['name'], TTableConfig['table']['_']['columns']>;
|
|
1450
|
-
type PaginatedResult<T> = {
|
|
1451
|
-
page: T[];
|
|
1452
|
-
continueCursor: string | null;
|
|
1453
|
-
isDone: boolean;
|
|
1454
|
-
pageStatus?: 'SplitRecommended' | 'SplitRequired';
|
|
1455
|
-
splitCursor?: string;
|
|
1456
|
-
};
|
|
1457
|
-
type BuildQueryResult<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TFullSelection> = Equal<TFullSelection, true> extends true ? InferModelFromColumns<TableColumns<TTableConfig>> : TFullSelection extends Record<string, unknown> ? Simplify<InferRelationalQueryTableResult<InferModelFromColumns<TableColumns<TTableConfig>>, TFullSelection['columns'] extends Record<string, unknown> ? TFullSelection['columns'] : 'Full'> & (Exclude<TFullSelection['extras'], undefined> extends Record<string, unknown> | ((...args: any[]) => Record<string, unknown>) ? ReturnTypeOrValue<Exclude<TFullSelection['extras'], undefined>> extends infer TExtras extends Record<string, unknown> ? { [K in NonUndefinedKeysOnly$1<TExtras>]: ReturnTypeOrValue<TExtras[K]> } : {} : {}) & (Exclude<TFullSelection['with'], undefined> extends Record<string, unknown> ? BuildRelationResult<TSchema, Exclude<TFullSelection['with'], undefined>, TTableConfig['relations']> : {}) & (TFullSelection extends {
|
|
1458
|
-
vectorSearch: infer TVectorSearch;
|
|
1459
|
-
} ? [TVectorSearch] extends [undefined] ? {} : {
|
|
1460
|
-
_score?: number;
|
|
1461
|
-
} : {})> : never;
|
|
1462
|
-
/**
|
|
1463
|
-
* Build relation result types from `with` configuration
|
|
1464
|
-
* Maps each included relation to its result type (T | null for one, T[] for many)
|
|
1465
|
-
*
|
|
1466
|
-
* Following Drizzle's exact pattern for type inference
|
|
1467
|
-
*
|
|
1468
|
-
* @template TSchema - Full schema configuration
|
|
1469
|
-
* @template TInclude - Relations to include from `with` config
|
|
1470
|
-
* @template TRelations - Available relations on the table
|
|
1471
|
-
*/
|
|
1472
|
-
type BuildRelationResult<TSchema extends TablesRelationalConfig, TInclude extends Record<string, unknown>, TRelations extends RelationsRecord> = { [K in NonUndefinedKeysOnly$1<TInclude> & keyof TRelations]: TRelations[K] extends infer TRel extends Relation<any> ? BuildQueryResult<TSchema, FindTableByDBName<TSchema, TRel['targetTableName']>, Assume<TInclude[K], true | Record<string, unknown>>> extends infer TResult ? TRel extends One<any, any> ? TResult | (Equal<TRel['optional'], true> extends true ? null : TInclude[K] extends Record<string, unknown> ? TInclude[K]['where'] extends Record<string, any> ? null : never : never) : TResult[] : never : never };
|
|
1473
|
-
/**
|
|
1474
|
-
* Extract TypeScript types from column validators
|
|
1475
|
-
* Includes system fields for query results
|
|
1476
|
-
* Following Drizzle pattern: query results always include system fields
|
|
1477
|
-
* Uses GetColumnData in 'query' mode to respect notNull brands
|
|
1478
|
-
*
|
|
1479
|
-
* CRITICAL: No extends constraint to avoid type widening (convex-ents pattern)
|
|
1480
|
-
* CRITICAL: Uses Merge instead of & to preserve NotNull phantom type brands
|
|
1481
|
-
*/
|
|
1482
|
-
type InferModelFromColumns<TColumns> = TColumns extends Record<string, ColumnBuilder<any, any, any>> ? Simplify<{ [K in keyof TColumns]: GetColumnData<TColumns[K], 'query'> }> : never;
|
|
1483
|
-
/**
|
|
1484
|
-
* Extract union of all values from an object type
|
|
1485
|
-
* Pattern from Drizzle: drizzle-orm/src/relations.ts:145
|
|
1486
|
-
*/
|
|
1487
|
-
type ExtractObjectValues<T> = T[keyof T];
|
|
1488
|
-
/**
|
|
1489
|
-
* Find table configuration by database name
|
|
1490
|
-
* Pattern from Drizzle: drizzle-orm/src/relations.ts:198-208
|
|
1491
|
-
*
|
|
1492
|
-
* Uses mapped type with key remapping to avoid `infer` widening.
|
|
1493
|
-
* The `as` clause filters to only matching keys, then ExtractObjectValues
|
|
1494
|
-
* extracts the single table value without creating unions.
|
|
1495
|
-
*/
|
|
1496
|
-
type FindTableByDBName<TSchema extends TablesRelationalConfig, TDBName extends string> = ExtractObjectValues<{ [K in keyof TSchema as TSchema[K]['name'] extends TDBName ? K : never]: TSchema[K] }>;
|
|
1497
|
-
type PipelineFlatMapTargetRow<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TRelationName extends PipelineRelationName<TTableConfig>> = TTableConfig['relations'][TRelationName] extends infer TRelation extends Relation<any> ? BuildQueryResult<TSchema, FindTableByDBName<TSchema, TRelation['targetTableName']>, true> : never;
|
|
1498
|
-
type PipelineFlatMapOutput<TCurrentRow, TFlatMapConfig, TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = TFlatMapConfig extends {
|
|
1499
|
-
relation: infer TRelationName extends PipelineRelationName<TTableConfig>;
|
|
1500
|
-
} ? TFlatMapConfig extends {
|
|
1501
|
-
includeParent: false;
|
|
1502
|
-
} ? PipelineFlatMapTargetRow<TSchema, TTableConfig, TRelationName> : {
|
|
1503
|
-
parent: TCurrentRow;
|
|
1504
|
-
child: PipelineFlatMapTargetRow<TSchema, TTableConfig, TRelationName>;
|
|
1505
|
-
} : never;
|
|
1506
|
-
type ApplyPipelineStage<TCurrentRow, TStage, TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = TStage extends FindManyPipelineFilterWithStage<any> ? TCurrentRow : TStage extends {
|
|
1507
|
-
map: (...args: any[]) => infer TMapOutput;
|
|
1508
|
-
} ? NonNullable<Awaited<TMapOutput>> : TStage extends FindManyPipelineDistinctStage ? TCurrentRow : TStage extends {
|
|
1509
|
-
flatMap: infer TFlatMapConfig;
|
|
1510
|
-
} ? PipelineFlatMapOutput<TCurrentRow, TFlatMapConfig, TSchema, TTableConfig> : TCurrentRow;
|
|
1511
|
-
/**
|
|
1512
|
-
* Filter object keys to only non-undefined values
|
|
1513
|
-
* Used to filter `with` config to only included relations
|
|
1514
|
-
*/
|
|
1515
|
-
type NonUndefinedKeysOnly$1<T> = ExtractObjectValues<{ [K in keyof T as T[K] extends undefined ? never : K]: K }> & keyof T;
|
|
1516
|
-
type TableColumnsForTable<TTable extends ConvexTable<any>> = TTable['_']['columns'] & SystemFields<TTable['_']['name']> & SystemFieldAliases<TTable['_']['name'], TTable['_']['columns']>;
|
|
1517
|
-
type ReturningSelection<TTable extends ConvexTable<any>> = Record<string, TableColumnsForTable<TTable>[keyof TableColumnsForTable<TTable>]>;
|
|
1518
|
-
type ReturningResult<TSelection extends Record<string, ColumnBuilder<any, any, any>>> = Simplify<{ [K in keyof TSelection]: TSelection[K] extends ColumnBuilder<any, any, any> ? GetColumnData<TSelection[K], 'query'> : never }>;
|
|
1519
|
-
type ReturningAll<TTable extends ConvexTable<any>> = InferSelectModel<TTable>;
|
|
1520
|
-
type MutationReturning = true | Record<string, ColumnBuilder<any, any, any>> | undefined;
|
|
1521
|
-
type MutationResult<TTable extends ConvexTable<any>, TReturning extends MutationReturning> = TReturning extends true ? ReturningAll<TTable>[] : TReturning extends Record<string, ColumnBuilder<any, any, any>> ? ReturningResult<TReturning>[] : undefined;
|
|
1522
|
-
type MutationPaginateConfig = {
|
|
1523
|
-
cursor: string | null;
|
|
1524
|
-
limit: number;
|
|
1525
|
-
};
|
|
1526
|
-
type MutationRunMode = 'sync' | 'async';
|
|
1527
|
-
type MutationExecuteConfig = {
|
|
1528
|
-
mode?: MutationRunMode;
|
|
1529
|
-
batchSize?: number;
|
|
1530
|
-
delayMs?: number;
|
|
1531
|
-
};
|
|
1532
|
-
type MutationAsyncConfig = Omit<MutationExecuteConfig, 'mode'>;
|
|
1533
|
-
type MutationExecutionMode = 'single' | 'paged';
|
|
1534
|
-
type MutationPaginatedResult<TTable extends ConvexTable<any>, TReturning extends MutationReturning> = Simplify<{
|
|
1535
|
-
continueCursor: string | null;
|
|
1536
|
-
isDone: boolean;
|
|
1537
|
-
numAffected: number;
|
|
1538
|
-
} & (MutationResult<TTable, TReturning> extends undefined ? {} : {
|
|
1539
|
-
page: MutationResult<TTable, TReturning>;
|
|
1540
|
-
})>;
|
|
1541
|
-
type MutationExecuteResult<TTable extends ConvexTable<any>, TReturning extends MutationReturning, TMode extends MutationExecutionMode> = TMode extends 'paged' ? MutationPaginatedResult<TTable, TReturning> : MutationResult<TTable, TReturning>;
|
|
1542
|
-
type InsertValue<TTable extends ConvexTable<any>> = InferInsertModel<TTable>;
|
|
1543
|
-
type UpdateSetValue<TColumn extends ColumnBuilder<any, any, any>> = GetColumnData<TColumn, 'query'> | (TColumn['_']['notNull'] extends true ? never : UnsetToken) | undefined;
|
|
1544
|
-
type UpdateSet<TTable extends ConvexTable<any>> = Simplify<{ [K in keyof TTable['_']['columns'] & string]?: UpdateSetValue<TTable['_']['columns'][K]> }>;
|
|
1545
|
-
//#endregion
|
|
1546
|
-
//#region src/orm/indexes.d.ts
|
|
1547
|
-
type ConvexIndexColumn = ColumnBuilderBase;
|
|
1548
|
-
interface ConvexIndexConfig<TName extends string = string, TColumns extends readonly ConvexIndexColumn[] = ConvexIndexColumn[], TUnique extends boolean = boolean> {
|
|
1549
|
-
name: TName;
|
|
1550
|
-
columns: TColumns;
|
|
1551
|
-
unique: TUnique;
|
|
1552
|
-
where?: unknown;
|
|
1553
|
-
}
|
|
1554
|
-
interface ConvexSearchIndexConfig<TName extends string = string, TSearchField extends ConvexIndexColumn = ConvexIndexColumn, TFilterFields extends readonly ConvexIndexColumn[] = ConvexIndexColumn[]> {
|
|
1555
|
-
name: TName;
|
|
1556
|
-
searchField: TSearchField;
|
|
1557
|
-
filterFields: TFilterFields;
|
|
1558
|
-
staged: boolean;
|
|
1559
|
-
}
|
|
1560
|
-
interface ConvexVectorIndexConfig<TName extends string = string, TVectorField extends ConvexIndexColumn = ConvexIndexColumn, TFilterFields extends readonly ConvexIndexColumn[] = ConvexIndexColumn[]> {
|
|
1561
|
-
name: TName;
|
|
1562
|
-
vectorField: TVectorField;
|
|
1563
|
-
dimensions: number;
|
|
1564
|
-
filterFields: TFilterFields;
|
|
1565
|
-
staged: boolean;
|
|
1566
|
-
}
|
|
1567
|
-
declare class ConvexIndexBuilderOn<TName extends string = string, TUnique extends boolean = boolean> {
|
|
1568
|
-
private name;
|
|
1569
|
-
private unique;
|
|
1570
|
-
static readonly [entityKind] = "ConvexIndexBuilderOn";
|
|
1571
|
-
readonly [entityKind] = "ConvexIndexBuilderOn";
|
|
1572
|
-
constructor(name: TName, unique: TUnique);
|
|
1573
|
-
on<TColumns extends [ConvexIndexColumn, ...ConvexIndexColumn[]]>(...columns: TColumns): ConvexIndexBuilder<TName, TColumns, TUnique>;
|
|
1574
|
-
}
|
|
1575
|
-
declare class ConvexIndexBuilder<TName extends string = string, TColumns extends readonly [ConvexIndexColumn, ...ConvexIndexColumn[]] = [ConvexIndexColumn, ...ConvexIndexColumn[]], TUnique extends boolean = boolean> {
|
|
1576
|
-
static readonly [entityKind] = "ConvexIndexBuilder";
|
|
1577
|
-
readonly [entityKind] = "ConvexIndexBuilder";
|
|
1578
|
-
_: {
|
|
1579
|
-
brand: 'ConvexIndexBuilder';
|
|
1580
|
-
name: TName;
|
|
1581
|
-
columns: TColumns;
|
|
1582
|
-
unique: TUnique;
|
|
1583
|
-
};
|
|
1584
|
-
config: ConvexIndexConfig<TName, TColumns, TUnique>;
|
|
1585
|
-
constructor(name: TName, columns: TColumns, unique: TUnique);
|
|
1586
|
-
/**
|
|
1587
|
-
* Partial index conditions are not supported in Convex.
|
|
1588
|
-
* This method is kept for Drizzle API parity.
|
|
1589
|
-
*/
|
|
1590
|
-
where(condition: unknown): this;
|
|
1591
|
-
}
|
|
1592
|
-
declare class ConvexSearchIndexBuilderOn<TName extends string = string> {
|
|
1593
|
-
private name;
|
|
1594
|
-
static readonly [entityKind] = "ConvexSearchIndexBuilderOn";
|
|
1595
|
-
readonly [entityKind] = "ConvexSearchIndexBuilderOn";
|
|
1596
|
-
constructor(name: TName);
|
|
1597
|
-
on<TSearchField extends ConvexIndexColumn>(searchField: TSearchField): ConvexSearchIndexBuilder<TName, TSearchField>;
|
|
1598
|
-
}
|
|
1599
|
-
declare class ConvexSearchIndexBuilder<TName extends string = string, TSearchField extends ConvexIndexColumn = ConvexIndexColumn, TFilterFields extends readonly ConvexIndexColumn[] = ConvexIndexColumn[]> {
|
|
1600
|
-
static readonly [entityKind] = "ConvexSearchIndexBuilder";
|
|
1601
|
-
readonly [entityKind] = "ConvexSearchIndexBuilder";
|
|
1602
|
-
_: {
|
|
1603
|
-
brand: 'ConvexSearchIndexBuilder';
|
|
1604
|
-
name: TName;
|
|
1605
|
-
searchField: TSearchField;
|
|
1606
|
-
filterFields: TFilterFields;
|
|
1607
|
-
};
|
|
1608
|
-
config: ConvexSearchIndexConfig<TName, TSearchField, TFilterFields>;
|
|
1609
|
-
constructor(name: TName, searchField: TSearchField);
|
|
1610
|
-
filter<TNextFilterFields extends readonly ConvexIndexColumn[]>(...fields: TNextFilterFields): ConvexSearchIndexBuilder<TName, TSearchField, TNextFilterFields>;
|
|
1611
|
-
staged(): this;
|
|
1612
|
-
}
|
|
1613
|
-
type ConvexVectorIndexConfigInternal = Omit<ConvexVectorIndexConfig<string, ConvexIndexColumn, readonly ConvexIndexColumn[]>, 'dimensions'> & {
|
|
1614
|
-
dimensions?: number;
|
|
1615
|
-
};
|
|
1616
|
-
declare class ConvexVectorIndexBuilderOn<TName extends string = string> {
|
|
1617
|
-
private name;
|
|
1618
|
-
static readonly [entityKind] = "ConvexVectorIndexBuilderOn";
|
|
1619
|
-
readonly [entityKind] = "ConvexVectorIndexBuilderOn";
|
|
1620
|
-
constructor(name: TName);
|
|
1621
|
-
on<TVectorField extends ConvexIndexColumn>(vectorField: TVectorField): ConvexVectorIndexBuilder<TName, TVectorField>;
|
|
1622
|
-
}
|
|
1623
|
-
declare class ConvexVectorIndexBuilder<TName extends string = string, TVectorField extends ConvexIndexColumn = ConvexIndexColumn, TFilterFields extends readonly ConvexIndexColumn[] = ConvexIndexColumn[]> {
|
|
1624
|
-
static readonly [entityKind] = "ConvexVectorIndexBuilder";
|
|
1625
|
-
readonly [entityKind] = "ConvexVectorIndexBuilder";
|
|
1626
|
-
_: {
|
|
1627
|
-
brand: 'ConvexVectorIndexBuilder';
|
|
1628
|
-
name: TName;
|
|
1629
|
-
vectorField: TVectorField;
|
|
1630
|
-
filterFields: TFilterFields;
|
|
1631
|
-
};
|
|
1632
|
-
config: ConvexVectorIndexConfigInternal & {
|
|
1633
|
-
name: TName;
|
|
1634
|
-
vectorField: TVectorField;
|
|
1635
|
-
filterFields: TFilterFields;
|
|
1636
|
-
};
|
|
1637
|
-
constructor(name: TName, vectorField: TVectorField);
|
|
1638
|
-
dimensions(dimensions: number): this;
|
|
1639
|
-
filter<TNextFilterFields extends readonly ConvexIndexColumn[]>(...fields: TNextFilterFields): ConvexVectorIndexBuilder<TName, TVectorField, TNextFilterFields>;
|
|
1640
|
-
staged(): this;
|
|
1641
|
-
}
|
|
1642
|
-
declare function index<TName extends string>(name: TName): ConvexIndexBuilderOn<TName, false>;
|
|
1643
|
-
declare function uniqueIndex<TName extends string>(name: TName): ConvexIndexBuilderOn<TName, true>;
|
|
1644
|
-
declare function searchIndex<TName extends string>(name: TName): ConvexSearchIndexBuilderOn<TName>;
|
|
1645
|
-
declare function vectorIndex<TName extends string>(name: TName): ConvexVectorIndexBuilderOn<TName>;
|
|
1646
|
-
//#endregion
|
|
1647
|
-
//#region src/orm/rls/roles.d.ts
|
|
1648
|
-
interface RlsRoleConfig {
|
|
1649
|
-
createDb?: boolean;
|
|
1650
|
-
createRole?: boolean;
|
|
1651
|
-
inherit?: boolean;
|
|
1652
|
-
}
|
|
1653
|
-
declare class RlsRole implements RlsRoleConfig {
|
|
1654
|
-
readonly name: string;
|
|
1655
|
-
static readonly [entityKind]: string;
|
|
1656
|
-
readonly [entityKind]: string;
|
|
1657
|
-
/** @internal */
|
|
1658
|
-
_existing?: boolean;
|
|
1659
|
-
/** @internal */
|
|
1660
|
-
readonly createDb: RlsRoleConfig['createDb'];
|
|
1661
|
-
/** @internal */
|
|
1662
|
-
readonly createRole: RlsRoleConfig['createRole'];
|
|
1663
|
-
/** @internal */
|
|
1664
|
-
readonly inherit: RlsRoleConfig['inherit'];
|
|
1665
|
-
constructor(name: string, config?: RlsRoleConfig);
|
|
1666
|
-
existing(): this;
|
|
1667
|
-
}
|
|
1668
|
-
declare function rlsRole(name: string, config?: RlsRoleConfig): RlsRole;
|
|
1669
|
-
//#endregion
|
|
1670
|
-
//#region src/orm/rls/policies.d.ts
|
|
1671
|
-
type RlsPolicyToOption = 'public' | 'current_role' | 'current_user' | 'session_user' | (string & {}) | RlsRole | RlsPolicyToOption[];
|
|
1672
|
-
type PolicyExpression<TCtx, TTable> = FilterExpression<boolean> | ((ctx: TCtx, table: TTable) => FilterExpression<boolean> | Promise<FilterExpression<boolean>>);
|
|
1673
|
-
interface RlsPolicyConfig<TCtx = any, TTable = ConvexTableWithColumns<any>> {
|
|
1674
|
-
as?: 'permissive' | 'restrictive';
|
|
1675
|
-
for?: 'all' | 'select' | 'insert' | 'update' | 'delete';
|
|
1676
|
-
to?: RlsPolicyToOption;
|
|
1677
|
-
using?: PolicyExpression<TCtx, TTable>;
|
|
1678
|
-
withCheck?: PolicyExpression<TCtx, TTable>;
|
|
1679
|
-
}
|
|
1680
|
-
declare class RlsPolicy<TCtx = any, TTable = ConvexTableWithColumns<any>> implements RlsPolicyConfig<TCtx, TTable> {
|
|
1681
|
-
readonly name: string;
|
|
1682
|
-
static readonly [entityKind]: string;
|
|
1683
|
-
readonly [entityKind]: string;
|
|
1684
|
-
readonly as: RlsPolicyConfig<TCtx, TTable>['as'];
|
|
1685
|
-
readonly for: RlsPolicyConfig<TCtx, TTable>['for'];
|
|
1686
|
-
readonly to: RlsPolicyConfig<TCtx, TTable>['to'];
|
|
1687
|
-
readonly using: RlsPolicyConfig<TCtx, TTable>['using'];
|
|
1688
|
-
readonly withCheck: RlsPolicyConfig<TCtx, TTable>['withCheck'];
|
|
1689
|
-
/** @internal */
|
|
1690
|
-
_linkedTable?: ConvexTable<any>;
|
|
1691
|
-
constructor(name: string, config?: RlsPolicyConfig<TCtx, TTable>);
|
|
1692
|
-
link(table: ConvexTable<any>): this;
|
|
1693
|
-
}
|
|
1694
|
-
declare function rlsPolicy<TCtx = any, TTable = ConvexTableWithColumns<any>>(name: string, config?: RlsPolicyConfig<TCtx, TTable>): RlsPolicy<TCtx, TTable>;
|
|
1695
|
-
//#endregion
|
|
1696
|
-
//#region src/orm/table.d.ts
|
|
1697
|
-
/**
|
|
1698
|
-
* Configuration for a Convex table
|
|
1699
|
-
* Only supports column builders (text(), integer(), etc.)
|
|
1700
|
-
*
|
|
1701
|
-
* CRITICAL: No extends constraint on TColumns to avoid type widening (convex-ents pattern)
|
|
1702
|
-
*/
|
|
1703
|
-
interface TableConfig<TName extends string = string, TColumns = any> {
|
|
1704
|
-
name: TName;
|
|
1705
|
-
columns: TColumns;
|
|
1706
|
-
}
|
|
1707
|
-
type ColumnsWithTableName<TColumns, TName extends string> = { [K in keyof TColumns]: TColumns[K] extends ColumnBuilderBase ? ColumnBuilderWithTableName<TColumns[K], TName> & {
|
|
1708
|
-
_: {
|
|
1709
|
-
fieldName: K extends string ? K : never;
|
|
1710
|
-
};
|
|
1711
|
-
} : TColumns[K] };
|
|
1712
|
-
type ColumnsWithSystemFields<TColumns, TName extends string> = ColumnsWithTableName<TColumns, TName> & (TColumns extends Record<string, unknown> ? SystemFieldsWithAliases<TName, TColumns> : SystemFieldsWithAliases<TName>);
|
|
1713
|
-
type ConvexTableExtraConfigValue = ConvexIndexBuilder | ConvexSearchIndexBuilder | ConvexVectorIndexBuilder | ConvexForeignKeyBuilder | ConvexCheckBuilder | ConvexUniqueConstraintBuilder | ConvexDeletionBuilder | ConvexLifecycleBuilder | OrmTriggerLike | RlsPolicy;
|
|
1714
|
-
type ConvexTableExtraConfig = Record<string, ConvexTableExtraConfigValue>;
|
|
1715
|
-
type UnionToIntersection<T> = (T extends unknown ? (arg: T) => void : never) extends ((arg: infer U) => void) ? U : never;
|
|
1716
|
-
type SimplifyObject<T> = { [K in keyof T]: T[K] };
|
|
1717
|
-
type ExtraConfigValues<TExtraConfig> = TExtraConfig extends readonly (infer TValue)[] ? TValue : TExtraConfig extends Record<string, infer TValue> ? TValue : never;
|
|
1718
|
-
type ColumnNameFromBuilder<TColumn extends ColumnBuilderBase> = TColumn extends {
|
|
1719
|
-
_: {
|
|
1720
|
-
fieldName: infer TFieldName extends string;
|
|
1721
|
-
};
|
|
1722
|
-
} ? TFieldName : never;
|
|
1723
|
-
type IndexFieldTupleFromColumns<TColumns extends readonly [ConvexIndexColumn, ...ConvexIndexColumn[]]> = [...{ [K in keyof TColumns]: TColumns[K] extends ConvexIndexColumn ? ColumnNameFromBuilder<TColumns[K]> : never }, '_creationTime'];
|
|
1724
|
-
type InferDbIndexRecordFromExtraValue<TValue> = TValue extends ConvexIndexBuilder<infer TName extends string, infer TColumns extends readonly [ConvexIndexColumn, ...ConvexIndexColumn[]], boolean> ? Record<TName, IndexFieldTupleFromColumns<TColumns>> : {};
|
|
1725
|
-
type SearchFilterFieldsUnionFromColumns<TColumns extends readonly ConvexIndexColumn[]> = TColumns[number] extends infer TColumn extends ConvexIndexColumn ? ColumnNameFromBuilder<TColumn> : never;
|
|
1726
|
-
type InferSearchIndexRecordFromExtraValue<TValue> = TValue extends ConvexSearchIndexBuilder<infer TName extends string, infer TSearchField extends ConvexIndexColumn, infer TFilterFields extends readonly ConvexIndexColumn[]> ? Record<TName, {
|
|
1727
|
-
searchField: ColumnNameFromBuilder<TSearchField>;
|
|
1728
|
-
filterFields: SearchFilterFieldsUnionFromColumns<TFilterFields>;
|
|
1729
|
-
}> : {};
|
|
1730
|
-
type InferVectorIndexRecordFromExtraValue<TValue> = TValue extends ConvexVectorIndexBuilder<infer TName extends string, infer TVectorField extends ConvexIndexColumn, infer TFilterFields extends readonly ConvexIndexColumn[]> ? Record<TName, {
|
|
1731
|
-
vectorField: ColumnNameFromBuilder<TVectorField>;
|
|
1732
|
-
dimensions: number;
|
|
1733
|
-
filterFields: SearchFilterFieldsUnionFromColumns<TFilterFields>;
|
|
1734
|
-
}> : {};
|
|
1735
|
-
type InferredDbIndexesFromExtraConfig<TExtraConfig> = UnionToIntersection<InferDbIndexRecordFromExtraValue<ExtraConfigValues<Exclude<TExtraConfig, undefined>>>>;
|
|
1736
|
-
type InferredSearchIndexesFromExtraConfig<TExtraConfig> = UnionToIntersection<InferSearchIndexRecordFromExtraValue<ExtraConfigValues<Exclude<TExtraConfig, undefined>>>>;
|
|
1737
|
-
type InferredVectorIndexesFromExtraConfig<TExtraConfig> = UnionToIntersection<InferVectorIndexRecordFromExtraValue<ExtraConfigValues<Exclude<TExtraConfig, undefined>>>>;
|
|
1738
|
-
type NormalizeDbIndexMap<TIndexMap> = { [K in keyof TIndexMap as K extends string ? K : never]: TIndexMap[K] extends string[] ? TIndexMap[K] : never };
|
|
1739
|
-
type NormalizeSearchIndexMap<TIndexMap> = { [K in keyof TIndexMap as K extends string ? K : never]: TIndexMap[K] extends {
|
|
1740
|
-
searchField: infer TSearchField extends string;
|
|
1741
|
-
filterFields: infer TFilterFields extends string;
|
|
1742
|
-
} ? {
|
|
1743
|
-
searchField: TSearchField;
|
|
1744
|
-
filterFields: TFilterFields;
|
|
1745
|
-
} : never };
|
|
1746
|
-
type NormalizeVectorIndexMap<TIndexMap> = { [K in keyof TIndexMap as K extends string ? K : never]: TIndexMap[K] extends {
|
|
1747
|
-
vectorField: infer TVectorField extends string;
|
|
1748
|
-
dimensions: infer TDimensions extends number;
|
|
1749
|
-
filterFields: infer TFilterFields extends string;
|
|
1750
|
-
} ? {
|
|
1751
|
-
vectorField: TVectorField;
|
|
1752
|
-
dimensions: TDimensions;
|
|
1753
|
-
filterFields: TFilterFields;
|
|
1754
|
-
} : never };
|
|
1755
|
-
type InferDbIndexesFromExtraConfig<TExtraConfig> = SimplifyObject<{
|
|
1756
|
-
by_creation_time: ['_creationTime'];
|
|
1757
|
-
} & NormalizeDbIndexMap<InferredDbIndexesFromExtraConfig<TExtraConfig>>>;
|
|
1758
|
-
type InferSearchIndexesFromExtraConfig<TExtraConfig> = SimplifyObject<NormalizeSearchIndexMap<InferredSearchIndexesFromExtraConfig<TExtraConfig>>>;
|
|
1759
|
-
type InferVectorIndexesFromExtraConfig<TExtraConfig> = SimplifyObject<NormalizeVectorIndexMap<InferredVectorIndexesFromExtraConfig<TExtraConfig>>>;
|
|
1760
|
-
type ConvexDeletionConfig = {
|
|
1761
|
-
mode: OrmDeleteMode;
|
|
1762
|
-
delayMs?: number;
|
|
1763
|
-
};
|
|
1764
|
-
type OrmLifecycleOperation = 'insert' | 'update' | 'delete';
|
|
1765
|
-
type OrmLifecycleChange<TDoc = Record<string, unknown>> = {
|
|
1766
|
-
id: unknown;
|
|
1767
|
-
} & ({
|
|
1768
|
-
operation: 'insert';
|
|
1769
|
-
oldDoc: null;
|
|
1770
|
-
newDoc: TDoc;
|
|
1771
|
-
} | {
|
|
1772
|
-
operation: 'update';
|
|
1773
|
-
oldDoc: TDoc;
|
|
1774
|
-
newDoc: TDoc;
|
|
1775
|
-
} | {
|
|
1776
|
-
operation: 'delete';
|
|
1777
|
-
oldDoc: TDoc;
|
|
1778
|
-
newDoc: null;
|
|
1779
|
-
});
|
|
1780
|
-
type OrmLifecycleChangeFor<TOperation extends OrmLifecycleOperation | 'change', TDoc = Record<string, unknown>> = TOperation extends 'insert' ? Extract<OrmLifecycleChange<TDoc>, {
|
|
1781
|
-
operation: 'insert';
|
|
1782
|
-
}> : TOperation extends 'update' ? Extract<OrmLifecycleChange<TDoc>, {
|
|
1783
|
-
operation: 'update';
|
|
1784
|
-
}> : TOperation extends 'delete' ? Extract<OrmLifecycleChange<TDoc>, {
|
|
1785
|
-
operation: 'delete';
|
|
1786
|
-
}> : OrmLifecycleChange<TDoc>;
|
|
1787
|
-
type OrmLifecycleHandler<TOperation extends OrmLifecycleOperation | 'change' = 'change', TDoc = Record<string, unknown>> = (ctx: {
|
|
1788
|
-
db: unknown;
|
|
1789
|
-
innerDb: unknown;
|
|
1790
|
-
} & Record<string, unknown>, change: OrmLifecycleChangeFor<TOperation, TDoc>) => Promise<void> | void;
|
|
1791
|
-
type OrmLifecycleConfig = {
|
|
1792
|
-
operation: 'insert';
|
|
1793
|
-
handler: OrmLifecycleHandler<'insert'>;
|
|
1794
|
-
} | {
|
|
1795
|
-
operation: 'update';
|
|
1796
|
-
handler: OrmLifecycleHandler<'update'>;
|
|
1797
|
-
} | {
|
|
1798
|
-
operation: 'delete';
|
|
1799
|
-
handler: OrmLifecycleHandler<'delete'>;
|
|
1800
|
-
} | {
|
|
1801
|
-
operation: 'change';
|
|
1802
|
-
handler: OrmLifecycleHandler<'change'>;
|
|
1803
|
-
};
|
|
1804
|
-
type OrmTriggerLike<TDoc = Record<string, unknown>, TCtx = Record<string, unknown>> = {
|
|
1805
|
-
bivarianceHack: (ctx: TCtx, change: OrmLifecycleChange<TDoc>) => Promise<void> | void;
|
|
1806
|
-
}['bivarianceHack'];
|
|
1807
|
-
declare class ConvexDeletionBuilder {
|
|
1808
|
-
readonly config: ConvexDeletionConfig;
|
|
1809
|
-
static readonly [entityKind] = "ConvexDeletionBuilder";
|
|
1810
|
-
readonly [entityKind] = "ConvexDeletionBuilder";
|
|
1811
|
-
constructor(config: ConvexDeletionConfig);
|
|
1812
|
-
}
|
|
1813
|
-
declare function deletion(mode: OrmDeleteMode, options?: {
|
|
1814
|
-
delayMs?: number;
|
|
1815
|
-
}): ConvexDeletionBuilder;
|
|
1816
|
-
declare class ConvexLifecycleBuilder {
|
|
1817
|
-
readonly config: OrmLifecycleConfig;
|
|
1818
|
-
static readonly [entityKind] = "ConvexLifecycleBuilder";
|
|
1819
|
-
readonly [entityKind] = "ConvexLifecycleBuilder";
|
|
1820
|
-
constructor(config: OrmLifecycleConfig);
|
|
1821
|
-
}
|
|
1822
|
-
declare function onInsert<TDoc = Record<string, unknown>>(handler: OrmLifecycleHandler<'insert', TDoc>): ConvexLifecycleBuilder;
|
|
1823
|
-
declare function onUpdate<TDoc = Record<string, unknown>>(handler: OrmLifecycleHandler<'update', TDoc>): ConvexLifecycleBuilder;
|
|
1824
|
-
declare function onDelete<TDoc = Record<string, unknown>>(handler: OrmLifecycleHandler<'delete', TDoc>): ConvexLifecycleBuilder;
|
|
1825
|
-
declare function onChange<TDoc = Record<string, unknown>>(handler: OrmLifecycleHandler<'change', TDoc>): ConvexLifecycleBuilder;
|
|
1826
|
-
/**
|
|
1827
|
-
* ConvexTable interface with type branding
|
|
1828
|
-
* Extends TableDefinition for schema compatibility
|
|
1829
|
-
* Adds phantom types for type inference
|
|
1830
|
-
*
|
|
1831
|
-
* Following Drizzle pattern: columns are exposed as table properties
|
|
1832
|
-
* via mapped type for type safety + Object.assign for runtime access
|
|
1833
|
-
*/
|
|
1834
|
-
interface ConvexTable<T extends TableConfig, Indexes extends GenericTableIndexes = {}, SearchIndexes extends GenericTableSearchIndexes = {}, VectorIndexes extends GenericTableVectorIndexes = {}> extends TableDefinition<Validator<any, any, any>, Indexes, SearchIndexes, VectorIndexes> {
|
|
1835
|
-
/**
|
|
1836
|
-
* Type brand for generic type extraction
|
|
1837
|
-
* Uses `declare readonly` to avoid runtime overhead
|
|
1838
|
-
*/
|
|
1839
|
-
readonly _: {
|
|
1840
|
-
readonly brand: 'ConvexTable';
|
|
1841
|
-
readonly name: T['name'];
|
|
1842
|
-
readonly columns: T['columns'];
|
|
1843
|
-
readonly inferSelect: InferSelectModel<ConvexTable<T>>;
|
|
1844
|
-
readonly inferInsert: InferInsertModel<ConvexTable<T>>;
|
|
1845
|
-
};
|
|
1846
|
-
/**
|
|
1847
|
-
* Inferred types for select and insert operations
|
|
1848
|
-
* Following Drizzle's pattern: $inferSelect and $inferInsert properties
|
|
1849
|
-
*/
|
|
1850
|
-
readonly $inferSelect: InferSelectModel<ConvexTable<T>>;
|
|
1851
|
-
readonly $inferInsert: InferInsertModel<ConvexTable<T>>;
|
|
1852
|
-
/**
|
|
1853
|
-
* Symbol-based metadata storage
|
|
1854
|
-
*/
|
|
1855
|
-
[TableName]: T['name'];
|
|
1856
|
-
[Columns]: T['columns'];
|
|
1857
|
-
[Brand]: 'ConvexTable';
|
|
1858
|
-
[RlsPolicies]: RlsPolicy[];
|
|
1859
|
-
[EnableRLS]: boolean;
|
|
1860
|
-
[TableDeleteConfig]?: OrmTableDeleteConfig;
|
|
1861
|
-
[TableLifecycleHooks]: OrmLifecycleConfig[];
|
|
1862
|
-
/**
|
|
1863
|
-
* Convex schema validator
|
|
1864
|
-
*/
|
|
1865
|
-
validator: Validator<any, any, any>;
|
|
1866
|
-
tableName: T['name'];
|
|
1867
|
-
}
|
|
1868
|
-
/**
|
|
1869
|
-
* ConvexTable with columns as properties
|
|
1870
|
-
* Following Drizzle's PgTableWithColumns pattern
|
|
1871
|
-
* Mapped type makes columns accessible: table.columnName
|
|
1872
|
-
* Includes public system fields (id, createdAt) available on all Convex documents
|
|
1873
|
-
*/
|
|
1874
|
-
type ConvexTableWithColumns<T extends TableConfig, Indexes extends GenericTableIndexes = {}, SearchIndexes extends GenericTableSearchIndexes = {}, VectorIndexes extends GenericTableVectorIndexes = {}> = ConvexTable<T, Indexes, SearchIndexes, VectorIndexes> & { [Key in keyof T['columns']]: T['columns'][Key] } & SystemFields<T['name']> & SystemFieldAliases<T['name'], T['columns']>;
|
|
1875
|
-
/**
|
|
1876
|
-
* Create a type-safe Convex table definition
|
|
1877
|
-
*
|
|
1878
|
-
* Uses Drizzle-style column builders:
|
|
1879
|
-
* - text().notNull(), integer(), boolean(), etc.
|
|
1880
|
-
*
|
|
1881
|
-
* @param name - Table name (must be valid Convex table name)
|
|
1882
|
-
* @param columns - Column builders
|
|
1883
|
-
* @returns ConvexTable instance compatible with defineSchema()
|
|
1884
|
-
*
|
|
1885
|
-
* @example
|
|
1886
|
-
* import { convexTable, text, integer } from 'better-convex/orm';
|
|
1887
|
-
*
|
|
1888
|
-
* const users = convexTable('users', {
|
|
1889
|
-
* name: text().notNull(),
|
|
1890
|
-
* email: text().notNull(),
|
|
1891
|
-
* age: integer(),
|
|
1892
|
-
* });
|
|
1893
|
-
*
|
|
1894
|
-
* // Use in schema - works with defineSchema()
|
|
1895
|
-
* export default defineSchema({ users });
|
|
1896
|
-
*
|
|
1897
|
-
* // Extract types
|
|
1898
|
-
* type User = InferSelectModel<typeof users>;
|
|
1899
|
-
* type NewUser = InferInsertModel<typeof users>;
|
|
1900
|
-
*
|
|
1901
|
-
* // Indexes
|
|
1902
|
-
* const usersWithIndex = convexTable('users', { email: text() }, (t) => [
|
|
1903
|
-
* index('by_email').on(t.email),
|
|
1904
|
-
* ]);
|
|
1905
|
-
*/
|
|
1906
|
-
type ConvexTableFnInternal = <TName extends string, TColumns, TExtraConfig extends ConvexTableExtraConfigValue[] | ConvexTableExtraConfig | undefined = undefined>(name: TName, columns: TColumns, extraConfig?: (self: ColumnsWithSystemFields<TColumns, TName>) => TExtraConfig) => ConvexTableWithColumns<{
|
|
1907
|
-
name: TName;
|
|
1908
|
-
columns: ColumnsWithTableName<TColumns, TName>;
|
|
1909
|
-
}, InferDbIndexesFromExtraConfig<TExtraConfig>, InferSearchIndexesFromExtraConfig<TExtraConfig>, InferVectorIndexesFromExtraConfig<TExtraConfig>>;
|
|
1910
|
-
interface ConvexTableFn extends ConvexTableFnInternal {
|
|
1911
|
-
withRLS: ConvexTableFnInternal;
|
|
1912
|
-
}
|
|
1913
|
-
declare const convexTable: ConvexTableFn;
|
|
1914
|
-
//#endregion
|
|
1915
|
-
//#region src/orm/relations.d.ts
|
|
1916
|
-
type SchemaEntry = ConvexTable<any>;
|
|
1917
|
-
type Schema = Record<string, SchemaEntry>;
|
|
1918
|
-
type ExtractTablesFromSchema<TSchema extends Record<string, unknown>> = { [K in keyof TSchema as TSchema[K] extends SchemaEntry ? K extends string ? K : never : never]: Extract<TSchema[K], SchemaEntry> };
|
|
1919
|
-
type IncludeEveryTable<TTables extends Schema> = { [K in keyof TTables]: {} };
|
|
1920
|
-
declare class RelationsBuilderTable<TTableName extends string = string> {
|
|
1921
|
-
static readonly [entityKind]: string;
|
|
1922
|
-
protected readonly _: {
|
|
1923
|
-
readonly name: TTableName;
|
|
1924
|
-
readonly table: SchemaEntry;
|
|
1925
|
-
};
|
|
1926
|
-
constructor(table: SchemaEntry, name: TTableName);
|
|
1927
|
-
}
|
|
1928
|
-
interface RelationsBuilderColumnConfig<TTableName extends string = string> {
|
|
1929
|
-
readonly tableName: TTableName;
|
|
1930
|
-
readonly column: ColumnBuilder<any, any, any>;
|
|
1931
|
-
readonly through?: RelationsBuilderColumnBase;
|
|
1932
|
-
readonly key: string;
|
|
1933
|
-
}
|
|
1934
|
-
interface RelationsBuilderColumnBase<TTableName extends string = string> {
|
|
1935
|
-
_: RelationsBuilderColumnConfig<TTableName>;
|
|
1936
|
-
}
|
|
1937
|
-
declare class RelationsBuilderColumn<TTableName extends string = string> implements RelationsBuilderColumnBase<TTableName> {
|
|
1938
|
-
static readonly [entityKind]: string;
|
|
1939
|
-
readonly _: {
|
|
1940
|
-
readonly tableName: TTableName;
|
|
1941
|
-
readonly column: ColumnBuilder<any, any, any>;
|
|
1942
|
-
readonly key: string;
|
|
1943
|
-
};
|
|
1944
|
-
constructor(column: ColumnBuilder<any, any, any>, tableName: TTableName, key: string);
|
|
1945
|
-
through(column: RelationsBuilderColumn): RelationsBuilderJunctionColumn<TTableName>;
|
|
1946
|
-
}
|
|
1947
|
-
declare class RelationsBuilderJunctionColumn<TTableName extends string = string> implements RelationsBuilderColumnBase<TTableName> {
|
|
1948
|
-
static readonly [entityKind]: string;
|
|
1949
|
-
readonly _: {
|
|
1950
|
-
readonly tableName: TTableName;
|
|
1951
|
-
readonly column: ColumnBuilder<any, any, any>;
|
|
1952
|
-
readonly through: RelationsBuilderColumnBase;
|
|
1953
|
-
readonly key: string;
|
|
1954
|
-
};
|
|
1955
|
-
constructor(column: ColumnBuilder<any, any, any>, tableName: TTableName, key: string, through: RelationsBuilderColumnBase);
|
|
1956
|
-
}
|
|
1957
|
-
interface OneConfig<TTargetTable extends SchemaEntry, TOptional extends boolean> {
|
|
1958
|
-
from?: RelationsBuilderColumnBase | [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]];
|
|
1959
|
-
to?: RelationsBuilderColumnBase | [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]];
|
|
1960
|
-
where?: TableFilter<TTargetTable>;
|
|
1961
|
-
optional?: TOptional;
|
|
1962
|
-
alias?: string;
|
|
1963
|
-
}
|
|
1964
|
-
type AnyOneConfig = OneConfig<SchemaEntry, boolean>;
|
|
1965
|
-
interface ManyConfig<TTargetTable extends SchemaEntry> {
|
|
1966
|
-
from?: RelationsBuilderColumnBase | [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]];
|
|
1967
|
-
to?: RelationsBuilderColumnBase | [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]];
|
|
1968
|
-
where?: TableFilter<TTargetTable>;
|
|
1969
|
-
alias?: string;
|
|
1970
|
-
}
|
|
1971
|
-
type AnyManyConfig = ManyConfig<SchemaEntry>;
|
|
1972
|
-
type OneFn<TTargetTable extends SchemaEntry, TTargetTableName extends string> = <TOptional extends boolean = true>(config?: OneConfig<TTargetTable, TOptional>) => One<TTargetTableName, TOptional>;
|
|
1973
|
-
type ManyFn<TTargetTable extends SchemaEntry, TTargetTableName extends string> = (config?: ManyConfig<TTargetTable>) => Many<TTargetTableName>;
|
|
1974
|
-
declare class RelationsHelperStatic<TTables extends Schema> {
|
|
1975
|
-
static readonly [entityKind]: string;
|
|
1976
|
-
constructor(tables: TTables);
|
|
1977
|
-
one: { [K in keyof TTables]: OneFn<TTables[K], K & string> };
|
|
1978
|
-
many: { [K in keyof TTables]: ManyFn<TTables[K], K & string> };
|
|
1979
|
-
}
|
|
1980
|
-
type RelationsBuilderColumns<TTable extends SchemaEntry, TTableName extends string> = { [K in keyof GetTableColumns<TTable>]: RelationsBuilderColumn<TTableName> };
|
|
1981
|
-
type GetTableColumns<TTable extends SchemaEntry> = TTable extends ConvexTable<any> ? TTable['_']['columns'] & SystemFields<TTable['_']['name']> & SystemFieldAliases<TTable['_']['name'], TTable['_']['columns']> : never;
|
|
1982
|
-
type RelationsBuilderTables<TSchema extends Schema> = { [TTableName in keyof TSchema]: RelationsBuilderColumns<TSchema[TTableName], TTableName & string> & RelationsBuilderTable<TTableName & string> };
|
|
1983
|
-
type RelationsBuilder<TSchema extends Schema> = RelationsBuilderTables<TSchema> & RelationsHelperStatic<TSchema>;
|
|
1984
|
-
type RelationsBuilderConfigValue = RelationsRecord | undefined;
|
|
1985
|
-
type RelationsBuilderConfig<TTables extends Schema> = { [TTableName in keyof TTables]?: RelationsBuilderConfigValue };
|
|
1986
|
-
type AnyRelationsBuilderConfig = Record<string, RelationsBuilderConfigValue>;
|
|
1987
|
-
type RelationsRecord = Record<string, AnyRelation>;
|
|
1988
|
-
declare abstract class Relation<TTargetTableName extends string = string> {
|
|
1989
|
-
readonly targetTableName: TTargetTableName;
|
|
1990
|
-
static readonly [entityKind]: string;
|
|
1991
|
-
readonly $brand: 'RelationV2';
|
|
1992
|
-
readonly relationType: 'many' | 'one';
|
|
1993
|
-
fieldName: string;
|
|
1994
|
-
sourceColumns: ColumnBuilder<any, any, any>[];
|
|
1995
|
-
targetColumns: ColumnBuilder<any, any, any>[];
|
|
1996
|
-
alias: string | undefined;
|
|
1997
|
-
where: Record<string, unknown> | undefined;
|
|
1998
|
-
sourceTable: SchemaEntry;
|
|
1999
|
-
targetTable: SchemaEntry;
|
|
2000
|
-
through?: {
|
|
2001
|
-
source: RelationsBuilderColumnBase[];
|
|
2002
|
-
target: RelationsBuilderColumnBase[];
|
|
2003
|
-
};
|
|
2004
|
-
throughTable?: SchemaEntry;
|
|
2005
|
-
isReversed?: boolean;
|
|
2006
|
-
/** @internal */
|
|
2007
|
-
sourceColumnTableNames: string[];
|
|
2008
|
-
/** @internal */
|
|
2009
|
-
targetColumnTableNames: string[];
|
|
2010
|
-
constructor(targetTable: SchemaEntry, targetTableName: TTargetTableName);
|
|
2011
|
-
}
|
|
2012
|
-
type AnyRelation = Relation<string>;
|
|
2013
|
-
declare class One<TTargetTableName extends string, TOptional extends boolean = boolean> extends Relation<TTargetTableName> {
|
|
2014
|
-
static readonly [entityKind]: string;
|
|
2015
|
-
protected $relationBrand: 'OneV2';
|
|
2016
|
-
readonly relationType: "one";
|
|
2017
|
-
readonly optional: TOptional;
|
|
2018
|
-
constructor(tables: Schema, targetTable: SchemaEntry, targetTableName: TTargetTableName, config: AnyOneConfig | undefined);
|
|
2019
|
-
}
|
|
2020
|
-
declare class Many<TTargetTableName extends string> extends Relation<TTargetTableName> {
|
|
2021
|
-
readonly config: AnyManyConfig | undefined;
|
|
2022
|
-
static readonly [entityKind]: string;
|
|
2023
|
-
protected $relationBrand: 'ManyV2';
|
|
2024
|
-
readonly relationType: "many";
|
|
2025
|
-
constructor(tables: Schema, targetTable: SchemaEntry, targetTableName: TTargetTableName, config: AnyManyConfig | undefined);
|
|
2026
|
-
}
|
|
2027
|
-
interface TableRelationalConfig {
|
|
2028
|
-
table: SchemaEntry;
|
|
2029
|
-
name: string;
|
|
2030
|
-
relations: RelationsRecord;
|
|
2031
|
-
strict?: boolean;
|
|
2032
|
-
defaults?: OrmRuntimeDefaults;
|
|
2033
|
-
}
|
|
2034
|
-
type TablesRelationalConfig<SchemaDef extends SchemaDefinition$1<any, boolean> = SchemaDefinition$1<any, true>, Tables extends Record<string, TableRelationalConfig> = Record<string, TableRelationalConfig>> = Tables & {
|
|
2035
|
-
[OrmSchemaDefinition]?: SchemaDef;
|
|
2036
|
-
};
|
|
2037
|
-
type RelationsConfigWithSchema<TConfig extends AnyRelationsBuilderConfig, TTables extends Schema> = TablesRelationalConfig<SchemaDefinition$1<TTables, true>, ExtractTablesWithRelations<TConfig, TTables>>;
|
|
2038
|
-
type RelationsPartsConfigWithSchema<TConfig extends AnyRelationsBuilderConfig, TTables extends Schema> = TablesRelationalConfig<SchemaDefinition$1<TTables, true>, ExtractTablesWithRelationsParts<TConfig, TTables>>;
|
|
2039
|
-
type Placeholder = {
|
|
2040
|
-
readonly __placeholder?: true;
|
|
2041
|
-
};
|
|
2042
|
-
type SQLWrapper = {
|
|
2043
|
-
readonly __sqlWrapper?: true;
|
|
2044
|
-
};
|
|
2045
|
-
interface SQLOperator {
|
|
2046
|
-
sql: (...args: any[]) => unknown;
|
|
2047
|
-
}
|
|
2048
|
-
interface RelationFieldsFilterInternals<T> {
|
|
2049
|
-
eq?: T | Placeholder | undefined;
|
|
2050
|
-
ne?: T | Placeholder | undefined;
|
|
2051
|
-
gt?: T | Placeholder | undefined;
|
|
2052
|
-
gte?: T | Placeholder | undefined;
|
|
2053
|
-
lt?: T | Placeholder | undefined;
|
|
2054
|
-
lte?: T | Placeholder | undefined;
|
|
2055
|
-
between?: [T | Placeholder, T | Placeholder] | Placeholder | undefined;
|
|
2056
|
-
notBetween?: [T | Placeholder, T | Placeholder] | Placeholder | undefined;
|
|
2057
|
-
in?: (T | Placeholder)[] | Placeholder | undefined;
|
|
2058
|
-
notIn?: (T | Placeholder)[] | Placeholder | undefined;
|
|
2059
|
-
arrayContains?: (T extends Array<infer E> ? (E | Placeholder)[] : (T | Placeholder)[]) | Placeholder | undefined;
|
|
2060
|
-
arrayContained?: (T extends Array<infer E> ? (E | Placeholder)[] : (T | Placeholder)[]) | Placeholder | undefined;
|
|
2061
|
-
arrayOverlaps?: (T extends Array<infer E> ? (E | Placeholder)[] : (T | Placeholder)[]) | Placeholder | undefined;
|
|
2062
|
-
like?: string | Placeholder | undefined;
|
|
2063
|
-
ilike?: string | Placeholder | undefined;
|
|
2064
|
-
notLike?: string | Placeholder | undefined;
|
|
2065
|
-
notIlike?: string | Placeholder | undefined;
|
|
2066
|
-
startsWith?: string | Placeholder | undefined;
|
|
2067
|
-
endsWith?: string | Placeholder | undefined;
|
|
2068
|
-
contains?: string | Placeholder | undefined;
|
|
2069
|
-
isNull?: true | undefined;
|
|
2070
|
-
isNotNull?: true | undefined;
|
|
2071
|
-
NOT?: RelationsFieldFilter<T> | undefined;
|
|
2072
|
-
OR?: RelationsFieldFilter<T>[] | undefined;
|
|
2073
|
-
AND?: RelationsFieldFilter<T>[] | undefined;
|
|
2074
|
-
}
|
|
2075
|
-
type RelationsFieldFilter<T = unknown> = RelationFieldsFilterInternals<T> | (unknown extends T ? never : T extends string | number | boolean | bigint | null | undefined ? T : T extends object ? never : T) | Placeholder;
|
|
2076
|
-
interface RelationsFilterCommons<TTable extends TableRelationalConfig = TableRelationalConfig, TSchema extends TablesRelationalConfig = TablesRelationalConfig> {
|
|
2077
|
-
OR?: RelationsFilter<TTable, TSchema>[] | undefined;
|
|
2078
|
-
NOT?: RelationsFilter<TTable, TSchema> | undefined;
|
|
2079
|
-
AND?: RelationsFilter<TTable, TSchema>[] | undefined;
|
|
2080
|
-
RAW?: SQLWrapper | ((table: TTable['table'], operators: SQLOperator) => unknown) | undefined;
|
|
2081
|
-
}
|
|
2082
|
-
type RelationsFilterColumns<TColumns extends Record<string, unknown>> = { [K in keyof TColumns]?: (TColumns[K] extends {
|
|
2083
|
-
_: {
|
|
2084
|
-
data: infer Data;
|
|
2085
|
-
};
|
|
2086
|
-
} ? RelationsFieldFilter<Data> : RelationsFieldFilter<unknown>) | undefined };
|
|
2087
|
-
type FindTargetTableInRelationalConfig<TConfig extends TablesRelationalConfig, TRelation extends AnyRelation> = TConfig[TRelation['targetTableName']];
|
|
2088
|
-
type RelationsFilterRelations<TTable extends TableRelationalConfig, TSchema extends TablesRelationalConfig, TRelations extends RelationsRecord = TTable['relations']> = { [K in keyof TRelations]?: boolean | RelationsFilter<FindTargetTableInRelationalConfig<TSchema, TRelations[K]>, TSchema> | undefined };
|
|
2089
|
-
type RelationsFilter<TTable extends TableRelationalConfig, TSchema extends TablesRelationalConfig, TColumns extends Record<string, unknown> = GetTableColumns<TTable['table']>> = TTable['relations'] extends Record<string, never> ? TableFilter<TTable['table']> : Simplify<RelationsFilterColumns<TColumns> & RelationsFilterRelations<TTable, TSchema> & RelationsFilterCommons<TTable, TSchema>>;
|
|
2090
|
-
interface TableFilterCommons<TTable extends SchemaEntry = SchemaEntry, TColumns extends Record<string, unknown> = GetTableColumns<TTable>> {
|
|
2091
|
-
OR?: TableFilter<TTable, TColumns>[] | undefined;
|
|
2092
|
-
NOT?: TableFilter<TTable, TColumns> | undefined;
|
|
2093
|
-
AND?: TableFilter<TTable, TColumns>[] | undefined;
|
|
2094
|
-
RAW?: SQLWrapper | ((table: TTable, operators: SQLOperator) => unknown) | undefined;
|
|
2095
|
-
}
|
|
2096
|
-
type TableFilterColumns<TColumns extends Record<string, unknown>> = { [K in keyof TColumns]?: (TColumns[K] extends {
|
|
2097
|
-
_: {
|
|
2098
|
-
data: infer Data;
|
|
2099
|
-
};
|
|
2100
|
-
} ? RelationsFieldFilter<Data> : RelationsFieldFilter<unknown>) | undefined };
|
|
2101
|
-
type TableFilter<TTable extends SchemaEntry = SchemaEntry, TColumns extends Record<string, unknown> = GetTableColumns<TTable>> = Simplify<TableFilterColumns<TColumns> & TableFilterCommons<TTable, TColumns>>;
|
|
2102
|
-
type ExtractTablesWithRelations<TConfig extends AnyRelationsBuilderConfig, TTables extends Schema> = { [K in keyof TTables]: {
|
|
2103
|
-
table: TTables[K];
|
|
2104
|
-
name: K & string;
|
|
2105
|
-
relations: TConfig extends { [CK in K]: Record<string, any> } ? TConfig[K] : {};
|
|
2106
|
-
} };
|
|
2107
|
-
type ExtractTablesWithRelationsParts<TConfig extends AnyRelationsBuilderConfig, TTables extends Schema> = { [K in NonUndefinedKeysOnly<TConfig> & keyof TTables]: {
|
|
2108
|
-
table: TTables[K & string];
|
|
2109
|
-
name: K & string;
|
|
2110
|
-
relations: TConfig[K] extends Record<string, any> ? TConfig[K] : {};
|
|
2111
|
-
} };
|
|
2112
|
-
type NonUndefinedKeysOnly<T> = { [K in keyof T]: T[K] extends undefined ? never : K }[keyof T];
|
|
2113
|
-
/** Builds relational config for every table in schema */
|
|
2114
|
-
declare function defineRelations<TSchema extends Record<string, unknown>, TTables extends Schema = ExtractTablesFromSchema<TSchema>>(schema: TSchema): RelationsConfigWithSchema<{}, TTables>;
|
|
2115
|
-
/** Builds relational config for every table in schema */
|
|
2116
|
-
declare function defineRelations<TSchema extends Record<string, unknown>, TConfig extends RelationsBuilderConfig<TTables>, TTables extends Schema = ExtractTablesFromSchema<TSchema>>(schema: TSchema, relations: (helpers: RelationsBuilder<TTables>) => TConfig): RelationsConfigWithSchema<TConfig, TTables>;
|
|
2117
|
-
/** Builds relational config only for tables present in relational config */
|
|
2118
|
-
declare function defineRelationsPart<TSchema extends Record<string, unknown>, TTables extends Schema = ExtractTablesFromSchema<TSchema>>(schema: TSchema): RelationsPartsConfigWithSchema<IncludeEveryTable<TTables>, TTables>;
|
|
2119
|
-
/** Builds relational config only for tables present in relational config */
|
|
2120
|
-
declare function defineRelationsPart<TSchema extends Record<string, unknown>, TConfig extends RelationsBuilderConfig<TTables>, TTables extends Schema = ExtractTablesFromSchema<TSchema>>(schema: TSchema, relations: (helpers: RelationsBuilder<TTables>) => TConfig): RelationsPartsConfigWithSchema<TConfig, TTables>;
|
|
2121
|
-
//#endregion
|
|
2122
|
-
//#region src/orm/rls/types.d.ts
|
|
2123
|
-
type RlsMode = 'enforce' | 'skip';
|
|
2124
|
-
type RlsContext = {
|
|
2125
|
-
/**
|
|
2126
|
-
* Optional mode override. Defaults to "enforce".
|
|
2127
|
-
*/
|
|
2128
|
-
mode?: RlsMode;
|
|
2129
|
-
/**
|
|
2130
|
-
* Request context passed to policy builders.
|
|
2131
|
-
*/
|
|
2132
|
-
ctx?: unknown;
|
|
2133
|
-
/**
|
|
2134
|
-
* Optional role resolver for enforcing policy "to" clauses.
|
|
2135
|
-
*/
|
|
2136
|
-
roleResolver?: (ctx: unknown) => string[];
|
|
2137
|
-
};
|
|
2138
|
-
//#endregion
|
|
2139
|
-
//#region src/orm/mutation-utils.d.ts
|
|
2140
|
-
type UniqueIndexDefinition = {
|
|
2141
|
-
name: string;
|
|
2142
|
-
fields: string[];
|
|
2143
|
-
nullsNotDistinct: boolean;
|
|
2144
|
-
};
|
|
2145
|
-
type CheckDefinition = {
|
|
2146
|
-
name: string;
|
|
2147
|
-
expression: FilterExpression<boolean>;
|
|
2148
|
-
};
|
|
2149
|
-
type SerializedFieldReference = {
|
|
2150
|
-
fieldName: string;
|
|
2151
|
-
};
|
|
2152
|
-
type SerializedBinaryExpression = {
|
|
2153
|
-
type: 'binary';
|
|
2154
|
-
operator: BinaryExpression['operator'];
|
|
2155
|
-
field: SerializedFieldReference;
|
|
2156
|
-
value: unknown;
|
|
2157
|
-
};
|
|
2158
|
-
type SerializedLogicalExpression = {
|
|
2159
|
-
type: 'logical';
|
|
2160
|
-
operator: LogicalExpression['operator'];
|
|
2161
|
-
operands: SerializedFilterExpression[];
|
|
2162
|
-
};
|
|
2163
|
-
type SerializedUnaryExpression = {
|
|
2164
|
-
type: 'unary';
|
|
2165
|
-
operator: UnaryExpression['operator'];
|
|
2166
|
-
operand: SerializedFilterExpression | SerializedFieldReference;
|
|
2167
|
-
};
|
|
2168
|
-
type SerializedFilterExpression = SerializedBinaryExpression | SerializedLogicalExpression | SerializedUnaryExpression;
|
|
2169
|
-
type ForeignKeyDefinition = {
|
|
2170
|
-
name?: string;
|
|
2171
|
-
columns: string[];
|
|
2172
|
-
foreignColumns: string[];
|
|
2173
|
-
foreignTableName: string;
|
|
2174
|
-
foreignTable?: ConvexTable<any>;
|
|
2175
|
-
onDelete?: ForeignKeyAction;
|
|
2176
|
-
onUpdate?: ForeignKeyAction;
|
|
2177
|
-
};
|
|
2178
|
-
declare function getUniqueIndexes(table: ConvexTable<any>): UniqueIndexDefinition[];
|
|
2179
|
-
declare function getChecks(table: ConvexTable<any>): CheckDefinition[];
|
|
2180
|
-
declare function getForeignKeys(table: ConvexTable<any>): ForeignKeyDefinition[];
|
|
2181
|
-
type DeleteMode = OrmDeleteMode;
|
|
2182
|
-
type CascadeMode = 'hard' | 'soft';
|
|
2183
|
-
//#endregion
|
|
2184
|
-
//#region src/orm/query-promise.d.ts
|
|
2185
|
-
/**
|
|
2186
|
-
* Query Promise - Lazy query execution via Promise interface
|
|
2187
|
-
*
|
|
2188
|
-
* Implements Drizzle's QueryPromise pattern:
|
|
2189
|
-
* - Queries don't execute until awaited or .then() is called
|
|
2190
|
-
* - Implements full Promise interface (then/catch/finally)
|
|
2191
|
-
* - Subclasses provide execute() implementation
|
|
2192
|
-
*
|
|
2193
|
-
* @example
|
|
2194
|
-
* const query = ctx.db.query.users.findMany();
|
|
2195
|
-
* // Query not executed yet
|
|
2196
|
-
* const users = await query; // Now executed
|
|
2197
|
-
*/
|
|
2198
|
-
/**
|
|
2199
|
-
* Abstract base class for promise-based query execution
|
|
2200
|
-
*
|
|
2201
|
-
* @template T - The result type returned by the query
|
|
2202
|
-
*
|
|
2203
|
-
* Pattern from Drizzle ORM: query-promise.ts:27-31
|
|
2204
|
-
*/
|
|
2205
|
-
declare abstract class QueryPromise<T> implements Promise<T> {
|
|
2206
|
-
/**
|
|
2207
|
-
* Promise tag for debugging and type identification
|
|
2208
|
-
*/
|
|
2209
|
-
[Symbol.toStringTag]: string;
|
|
2210
|
-
/**
|
|
2211
|
-
* Promise.then() implementation - delegates to execute()
|
|
2212
|
-
* This enables lazy evaluation: queries only run when awaited
|
|
2213
|
-
*/
|
|
2214
|
-
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
|
|
2215
|
-
/**
|
|
2216
|
-
* Promise.catch() implementation - delegates to execute()
|
|
2217
|
-
*/
|
|
2218
|
-
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
|
|
2219
|
-
/**
|
|
2220
|
-
* Promise.finally() implementation - delegates to execute()
|
|
2221
|
-
*/
|
|
2222
|
-
finally(onFinally?: (() => void) | undefined | null): Promise<T>;
|
|
2223
|
-
/**
|
|
2224
|
-
* Execute the query and return results
|
|
2225
|
-
* Subclasses must implement this method
|
|
2226
|
-
*
|
|
2227
|
-
* @returns Promise resolving to query results
|
|
2228
|
-
*/
|
|
2229
|
-
abstract execute(): Promise<T>;
|
|
2230
|
-
}
|
|
2231
|
-
//#endregion
|
|
2232
|
-
//#region src/orm/delete.d.ts
|
|
2233
|
-
type ConvexDeleteWithout<T extends ConvexDeleteBuilder<any, any, any>, K extends string> = Omit<T, K>;
|
|
2234
|
-
declare class ConvexDeleteBuilder<TTable extends ConvexTable<any>, TReturning extends MutationReturning = undefined, TMode extends MutationExecutionMode = 'single'> extends QueryPromise<MutationExecuteResult<TTable, TReturning, TMode>> {
|
|
2235
|
-
private db;
|
|
2236
|
-
private table;
|
|
2237
|
-
readonly _: {
|
|
2238
|
-
readonly table: TTable;
|
|
2239
|
-
readonly returning: TReturning;
|
|
2240
|
-
readonly mode: TMode;
|
|
2241
|
-
readonly result: MutationExecuteResult<TTable, TReturning, TMode>;
|
|
2242
|
-
};
|
|
2243
|
-
private whereExpression?;
|
|
2244
|
-
private returningFields?;
|
|
2245
|
-
private allowFullScanFlag;
|
|
2246
|
-
private deleteModeOverride?;
|
|
2247
|
-
private cascadeMode?;
|
|
2248
|
-
private scheduledDelayMs?;
|
|
2249
|
-
private executionModeOverride?;
|
|
2250
|
-
private paginateConfig?;
|
|
2251
|
-
constructor(db: GenericDatabaseWriter<any>, table: TTable);
|
|
2252
|
-
where(expression: FilterExpression<boolean>): this;
|
|
2253
|
-
returning(): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, true, TMode>, 'returning'>;
|
|
2254
|
-
returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, TSelection, TMode>, 'returning'>;
|
|
2255
|
-
paginate(config: MutationPaginateConfig): ConvexDeleteWithout<ConvexDeleteBuilder<TTable, TReturning, 'paged'>, 'paginate'>;
|
|
2256
|
-
allowFullScan(): this;
|
|
2257
|
-
private getIdEquality;
|
|
2258
|
-
soft(): this;
|
|
2259
|
-
hard(): this;
|
|
2260
|
-
scheduled(config: {
|
|
2261
|
-
delayMs: number;
|
|
2262
|
-
}): this;
|
|
2263
|
-
private resolveDeleteModeAndDelay;
|
|
2264
|
-
cascade(config: {
|
|
2265
|
-
mode: CascadeMode;
|
|
2266
|
-
}): this;
|
|
2267
|
-
executeAsync(...args: TMode extends 'single' ? [config?: MutationAsyncConfig] : [config: never]): Promise<TMode extends 'single' ? MutationExecuteResult<TTable, TReturning, 'single'> : never>;
|
|
2268
|
-
execute(...args: TMode extends 'single' ? [config?: MutationExecuteConfig] : [config?: never]): Promise<MutationExecuteResult<TTable, TReturning, TMode>>;
|
|
2269
|
-
}
|
|
2270
|
-
//#endregion
|
|
2271
|
-
//#region src/orm/extractRelationsConfig.d.ts
|
|
2272
|
-
/**
|
|
2273
|
-
* M2-M3 CONTRACT: EdgeMetadata interface
|
|
2274
|
-
* Consumed by query builder for relation traversal
|
|
2275
|
-
*/
|
|
2276
|
-
interface EdgeMetadata {
|
|
2277
|
-
/** Source table name (ts name) */
|
|
2278
|
-
sourceTable: string;
|
|
2279
|
-
/** Relation field name on source */
|
|
2280
|
-
edgeName: string;
|
|
2281
|
-
/** Target table name (ts name) */
|
|
2282
|
-
targetTable: string;
|
|
2283
|
-
/** Cardinality: one-to-one/many-to-one or one-to-many */
|
|
2284
|
-
cardinality: 'one' | 'many';
|
|
2285
|
-
/** Primary source field name (best-effort) */
|
|
2286
|
-
fieldName: string;
|
|
2287
|
-
/** Source field names (from) */
|
|
2288
|
-
sourceFields: string[];
|
|
2289
|
-
/** Target field names (to) */
|
|
2290
|
-
targetFields: string[];
|
|
2291
|
-
/**
|
|
2292
|
-
* True when the FK columns on the source side are nullable (i.e. the relation
|
|
2293
|
-
* can be absent). Used to avoid rejecting optional/self-referencing relations
|
|
2294
|
-
* as "circular dependencies".
|
|
2295
|
-
*/
|
|
2296
|
-
sourceNullable: boolean;
|
|
2297
|
-
/** Inverse edge if bidirectional relation */
|
|
2298
|
-
inverseEdge?: EdgeMetadata;
|
|
2299
|
-
/** Index name for efficient lookups */
|
|
2300
|
-
indexName: string;
|
|
2301
|
-
/** Index fields for compound indexes */
|
|
2302
|
-
indexFields: string[];
|
|
2303
|
-
/** Relation optional (one only) */
|
|
2304
|
-
optional: boolean;
|
|
2305
|
-
/** Alias for disambiguation (v1 rename of relationName) */
|
|
2306
|
-
alias?: string;
|
|
2307
|
-
/** Many-to-many through info */
|
|
2308
|
-
through?: {
|
|
2309
|
-
table: string;
|
|
2310
|
-
sourceFields: string[];
|
|
2311
|
-
targetFields: string[];
|
|
2312
|
-
};
|
|
2313
|
-
}
|
|
2314
|
-
/**
|
|
2315
|
-
* Extract relations configuration from defineRelations output
|
|
2316
|
-
*/
|
|
2317
|
-
declare function extractRelationsConfig(schema: TablesRelationalConfig): EdgeMetadata[];
|
|
2318
|
-
//#endregion
|
|
2319
|
-
//#region src/orm/insert.d.ts
|
|
2320
|
-
type InsertOnConflictDoNothingConfig<_TTable extends ConvexTable<any>> = {
|
|
2321
|
-
target?: ColumnBuilder<any, any, any> | ColumnBuilder<any, any, any>[];
|
|
2322
|
-
where?: FilterExpression<boolean>;
|
|
2323
|
-
};
|
|
2324
|
-
type InsertOnConflictDoUpdateConfig<TTable extends ConvexTable<any>> = {
|
|
2325
|
-
target: ColumnBuilder<any, any, any> | ColumnBuilder<any, any, any>[];
|
|
2326
|
-
set: UpdateSet<TTable>;
|
|
2327
|
-
where?: FilterExpression<boolean>;
|
|
2328
|
-
targetWhere?: FilterExpression<boolean>;
|
|
2329
|
-
setWhere?: FilterExpression<boolean>;
|
|
2330
|
-
};
|
|
2331
|
-
type ConvexInsertWithout<T extends ConvexInsertBuilder<any, any>, K extends string> = Omit<T, K>;
|
|
2332
|
-
declare class ConvexInsertBuilder<TTable extends ConvexTable<any>, TReturning extends MutationReturning = undefined> extends QueryPromise<MutationResult<TTable, TReturning>> {
|
|
2333
|
-
private db;
|
|
2334
|
-
private table;
|
|
2335
|
-
readonly _: {
|
|
2336
|
-
readonly table: TTable;
|
|
2337
|
-
readonly returning: TReturning;
|
|
2338
|
-
readonly result: MutationResult<TTable, TReturning>;
|
|
2339
|
-
};
|
|
2340
|
-
private valuesList;
|
|
2341
|
-
private returningFields?;
|
|
2342
|
-
private conflictConfig?;
|
|
2343
|
-
private allowFullScanFlag;
|
|
2344
|
-
constructor(db: GenericDatabaseWriter<any>, table: TTable);
|
|
2345
|
-
values(values: InsertValue<TTable> | InsertValue<TTable>[]): this;
|
|
2346
|
-
returning(): ConvexInsertWithout<ConvexInsertBuilder<TTable, true>, 'returning'>;
|
|
2347
|
-
returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexInsertWithout<ConvexInsertBuilder<TTable, TSelection>, 'returning'>;
|
|
2348
|
-
allowFullScan(): this;
|
|
2349
|
-
onConflictDoNothing(config?: InsertOnConflictDoNothingConfig<TTable>): ConvexInsertWithout<this, 'onConflictDoNothing' | 'onConflictDoUpdate'>;
|
|
2350
|
-
onConflictDoUpdate(config: InsertOnConflictDoUpdateConfig<TTable>): ConvexInsertWithout<this, 'onConflictDoNothing' | 'onConflictDoUpdate'>;
|
|
2351
|
-
execute(): Promise<MutationResult<TTable, TReturning>>;
|
|
2352
|
-
private resolveReturningRow;
|
|
2353
|
-
private handleConflict;
|
|
2354
|
-
private findConflictRow;
|
|
2355
|
-
private findAnyUniqueConflictRow;
|
|
2356
|
-
}
|
|
2357
|
-
//#endregion
|
|
2358
|
-
//#region src/orm/query.d.ts
|
|
2359
|
-
/**
|
|
2360
|
-
* Relational query builder with promise-based execution
|
|
2361
|
-
*
|
|
2362
|
-
* @template TResult - The final result type after execution
|
|
2363
|
-
*
|
|
2364
|
-
* Pattern from Drizzle: gel-core/query-builders/query.ts:32-62
|
|
2365
|
-
*/
|
|
2366
|
-
declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TResult> extends QueryPromise<TResult> {
|
|
2367
|
-
private schema;
|
|
2368
|
-
private tableConfig;
|
|
2369
|
-
private edgeMetadata;
|
|
2370
|
-
private db;
|
|
2371
|
-
private config;
|
|
2372
|
-
private mode;
|
|
2373
|
-
private _allEdges?;
|
|
2374
|
-
private rls?;
|
|
2375
|
-
private relationLoading?;
|
|
2376
|
-
private vectorSearchProvider?;
|
|
2377
|
-
private configuredIndex?;
|
|
2378
|
-
/**
|
|
2379
|
-
* Type brand for result type extraction
|
|
2380
|
-
* Critical for Expect<Equal<>> type tests to work correctly
|
|
2381
|
-
* Following Drizzle pattern: allows TypeScript to infer result type before await
|
|
2382
|
-
*/
|
|
2383
|
-
readonly _: {
|
|
2384
|
-
readonly result: TResult;
|
|
2385
|
-
};
|
|
2386
|
-
private allowFullScan;
|
|
2387
|
-
constructor(schema: TSchema, tableConfig: TTableConfig, edgeMetadata: EdgeMetadata[], db: GenericDatabaseReader<any>, config: DBQueryConfig<'one' | 'many', boolean, TSchema, TTableConfig>, mode: 'many' | 'first' | 'firstOrThrow', _allEdges?: EdgeMetadata[] | undefined, // M6.5 Phase 2: All edges for nested loading
|
|
2388
|
-
rls?: RlsContext | undefined, relationLoading?: {
|
|
2389
|
-
concurrency?: number;
|
|
2390
|
-
} | undefined, vectorSearchProvider?: VectorSearchProvider | undefined, configuredIndex?: PredicateWhereIndexConfig<TTableConfig> | undefined);
|
|
2391
|
-
private _usesSystemCreatedAtAlias;
|
|
2392
|
-
private _assertNoLegacyPublicFieldName;
|
|
2393
|
-
private _normalizePublicFieldName;
|
|
2394
|
-
private _normalizeComparableValue;
|
|
2395
|
-
private _toPublicRow;
|
|
2396
|
-
private _extractIdOnlyWhere;
|
|
2397
|
-
private _returnSelectedRows;
|
|
2398
|
-
private _applyRlsSelectFilter;
|
|
2399
|
-
private _isColumnBuilder;
|
|
2400
|
-
private _isOrderByClause;
|
|
2401
|
-
private _normalizeOrderByValue;
|
|
2402
|
-
private _normalizeOrderBy;
|
|
2403
|
-
private _orderBySpecs;
|
|
2404
|
-
private _resolveNonPaginatedLimit;
|
|
2405
|
-
private _compareByOrderSpecs;
|
|
2406
|
-
private _getTableConfigByDbName;
|
|
2407
|
-
private _matchLike;
|
|
2408
|
-
/**
|
|
2409
|
-
* Evaluate a filter expression against a fetched row
|
|
2410
|
-
* Used for post-fetch filtering (string operators, etc.)
|
|
2411
|
-
*/
|
|
2412
|
-
private _evaluatePostFetchFilter;
|
|
2413
|
-
private _isRecord;
|
|
2414
|
-
private _isPlaceholder;
|
|
2415
|
-
private _isSQLWrapper;
|
|
2416
|
-
private _evaluateFieldFilter;
|
|
2417
|
-
private _evaluateTableFilter;
|
|
2418
|
-
private _evaluateRelationsFilter;
|
|
2419
|
-
private _buildFieldFilterExpression;
|
|
2420
|
-
private _buildFilterExpression;
|
|
2421
|
-
private _mergeWithConfig;
|
|
2422
|
-
private _buildFilterWithConfig;
|
|
2423
|
-
private _stripFilterRelations;
|
|
2424
|
-
private _hasSearchDisallowedRelationFilter;
|
|
2425
|
-
private _searchFilterValuesEqual;
|
|
2426
|
-
private _extractSearchEqFromWhereField;
|
|
2427
|
-
private _mergeSearchFiltersWithWhereEq;
|
|
2428
|
-
private _applyRelationsFilterToRows;
|
|
2429
|
-
private _finalizeRows;
|
|
2430
|
-
private _getSchemaDefinitionOrThrow;
|
|
2431
|
-
private _applyEqBounds;
|
|
2432
|
-
private _buildTableFilterPredicate;
|
|
2433
|
-
private _assertWhereIndexRequirement;
|
|
2434
|
-
private _isFilterExpressionNode;
|
|
2435
|
-
private _isPredicateWhereClause;
|
|
2436
|
-
private _createFilterOperators;
|
|
2437
|
-
private _resolveWhereCallbackExpression;
|
|
2438
|
-
private _buildBasePipelineStream;
|
|
2439
|
-
private _buildUnionSourceStream;
|
|
2440
|
-
private _applyFlatMapStage;
|
|
2441
|
-
private _applyPipelineStages;
|
|
2442
|
-
/**
|
|
2443
|
-
* Execute the query and return results
|
|
2444
|
-
* Phase 4 implementation with WhereClauseCompiler integration
|
|
2445
|
-
*/
|
|
2446
|
-
execute(): Promise<TResult>;
|
|
2447
|
-
/**
|
|
2448
|
-
* Convert query config to Convex query parameters
|
|
2449
|
-
* Phase 4 implementation with WhereClauseCompiler
|
|
2450
|
-
*/
|
|
2451
|
-
private _toConvexQuery;
|
|
2452
|
-
private _buildRelationKey;
|
|
2453
|
-
private _buildIndexPredicate;
|
|
2454
|
-
private _buildFilterPredicate;
|
|
2455
|
-
private _queryByFields;
|
|
2456
|
-
private _getColumns;
|
|
2457
|
-
/**
|
|
2458
|
-
* Apply a single filter expression to a Convex query builder
|
|
2459
|
-
* Used for index filters (eq operations)
|
|
2460
|
-
*/
|
|
2461
|
-
private _applyFilterToQuery;
|
|
2462
|
-
/**
|
|
2463
|
-
* Convert FilterExpression to Convex filter function
|
|
2464
|
-
* Uses visitor pattern to traverse expression tree
|
|
2465
|
-
*/
|
|
2466
|
-
private _toConvexExpression;
|
|
2467
|
-
/**
|
|
2468
|
-
* Get edge metadata for a target table
|
|
2469
|
-
* Helper for recursive relation loading
|
|
2470
|
-
*/
|
|
2471
|
-
private _getTargetTableEdges;
|
|
2472
|
-
private _getRelationConcurrency;
|
|
2473
|
-
private _getRelationFanOutKeyCap;
|
|
2474
|
-
private _enforceRelationFanOutKeyCap;
|
|
2475
|
-
private _mapWithConcurrency;
|
|
2476
|
-
/**
|
|
2477
|
-
* Load relations for query results
|
|
2478
|
-
* M6.5 Phase 2 implementation: Recursive relation loading with depth limiting
|
|
2479
|
-
*
|
|
2480
|
-
* @param rows - Array of parent records to load relations for
|
|
2481
|
-
* @param withConfig - Relation configuration object
|
|
2482
|
-
* @param depth - Current recursion depth (default 0)
|
|
2483
|
-
* @param maxDepth - Maximum recursion depth (default 3)
|
|
2484
|
-
* @param targetTableEdges - Edge metadata for nested relations (optional, defaults to this.edgeMetadata)
|
|
2485
|
-
*/
|
|
2486
|
-
private _loadRelations;
|
|
2487
|
-
/**
|
|
2488
|
-
* Load a single relation for all rows
|
|
2489
|
-
* Handles both one() and many() cardinality
|
|
2490
|
-
* M6.5 Phase 2: Added support for nested relations
|
|
2491
|
-
*/
|
|
2492
|
-
private _loadSingleRelation;
|
|
2493
|
-
/**
|
|
2494
|
-
* Load one() relation (many-to-one or one-to-one)
|
|
2495
|
-
* Example: posts.author where posts.authorId → users.id
|
|
2496
|
-
* M6.5 Phase 2: Added support for nested relations
|
|
2497
|
-
*/
|
|
2498
|
-
private _loadOneRelation;
|
|
2499
|
-
/**
|
|
2500
|
-
* Load many() relation (one-to-many)
|
|
2501
|
-
* Example: users.posts where posts.authorId → users.id
|
|
2502
|
-
*
|
|
2503
|
-
* For many() relations, use the configured from/to fields to match rows.
|
|
2504
|
-
* Supports .through() for many-to-many relations via a junction table.
|
|
2505
|
-
* M6.5 Phase 2: Added support for nested relations
|
|
2506
|
-
* M6.5 Phase 3: Added support for where filters, orderBy, and per-parent limit
|
|
2507
|
-
*/
|
|
2508
|
-
private _loadManyRelation;
|
|
2509
|
-
private _applyExtras;
|
|
2510
|
-
/**
|
|
2511
|
-
* Select specific columns from rows
|
|
2512
|
-
* Phase 5 implementation
|
|
2513
|
-
*/
|
|
2514
|
-
private _selectColumns;
|
|
2515
|
-
}
|
|
2516
|
-
//#endregion
|
|
2517
|
-
//#region src/orm/query-builder.d.ts
|
|
2518
|
-
type EnforcedConfig<TConfig, TTableConfig extends TableRelationalConfig, THasIndex extends boolean = false> = EnforceVectorSearchConstraints<EnforceSearchConstraints<EnforceCursorMaxScan<EnforceNoAllowFullScanWhenIndexed<EnforceWithIndexForWhere<TConfig, TTableConfig, THasIndex>, THasIndex>>, TTableConfig>, TTableConfig>;
|
|
2519
|
-
type DisallowWithIndexSearchOrVector<THasIndex extends boolean> = THasIndex extends true ? {
|
|
2520
|
-
search?: never;
|
|
2521
|
-
vectorSearch?: never;
|
|
2522
|
-
} : unknown;
|
|
2523
|
-
type PredicateIndexName<TTableConfig extends TableRelationalConfig> = PredicateWhereIndexConfig<TTableConfig> extends {
|
|
2524
|
-
name: infer TIndexName extends string;
|
|
2525
|
-
} ? TIndexName : string;
|
|
2526
|
-
type PredicateIndexConfigByName<TTableConfig extends TableRelationalConfig, TIndexName extends PredicateIndexName<TTableConfig>> = Extract<PredicateWhereIndexConfig<TTableConfig>, {
|
|
2527
|
-
name: TIndexName;
|
|
2528
|
-
}>;
|
|
2529
|
-
type SearchPaginatedConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<CursorPaginatedConfig<TSchema, TTableConfig>, 'search' | 'vectorSearch' | 'where' | 'orderBy'> & {
|
|
2530
|
-
search: SearchQueryConfig<TTableConfig>;
|
|
2531
|
-
vectorSearch?: never;
|
|
2532
|
-
where?: SearchWhereFilter<TTableConfig> | undefined;
|
|
2533
|
-
orderBy?: never;
|
|
2534
|
-
pipeline?: never;
|
|
2535
|
-
pageByKey?: never;
|
|
2536
|
-
endCursor?: never;
|
|
2537
|
-
};
|
|
2538
|
-
type SearchNonPaginatedConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<NonCursorConfig<TSchema, TTableConfig>, 'search' | 'vectorSearch' | 'where' | 'orderBy'> & {
|
|
2539
|
-
search: SearchQueryConfig<TTableConfig>;
|
|
2540
|
-
vectorSearch?: never;
|
|
2541
|
-
where?: SearchWhereFilter<TTableConfig> | undefined;
|
|
2542
|
-
orderBy?: never;
|
|
2543
|
-
pipeline?: never;
|
|
2544
|
-
pageByKey?: never;
|
|
2545
|
-
endCursor?: never;
|
|
2546
|
-
};
|
|
2547
|
-
type SearchFindFirstConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<DBQueryConfig<'many', true, TSchema, TTableConfig>, 'limit' | 'search' | 'vectorSearch' | 'where' | 'orderBy' | 'cursor' | 'maxScan' | 'pipeline'> & {
|
|
2548
|
-
search: SearchQueryConfig<TTableConfig>;
|
|
2549
|
-
vectorSearch?: never;
|
|
2550
|
-
where?: SearchWhereFilter<TTableConfig> | undefined;
|
|
2551
|
-
orderBy?: never;
|
|
2552
|
-
pipeline?: never;
|
|
2553
|
-
};
|
|
2554
|
-
type VectorNonPaginatedConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<DBQueryConfig<'many', true, TSchema, TTableConfig>, 'vectorSearch' | 'search' | 'where' | 'orderBy' | 'offset' | 'limit' | 'cursor' | 'maxScan' | 'allowFullScan' | 'pipeline'> & {
|
|
2555
|
-
vectorSearch: VectorQueryConfig<TTableConfig>;
|
|
2556
|
-
search?: never;
|
|
2557
|
-
where?: never;
|
|
2558
|
-
orderBy?: never;
|
|
2559
|
-
offset?: never;
|
|
2560
|
-
limit?: never;
|
|
2561
|
-
cursor?: never;
|
|
2562
|
-
maxScan?: never;
|
|
2563
|
-
allowFullScan?: never;
|
|
2564
|
-
pipeline?: never;
|
|
2565
|
-
pageByKey?: never;
|
|
2566
|
-
endCursor?: never;
|
|
2567
|
-
};
|
|
2568
|
-
type FindManyResult<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TConfig> = TConfig extends {
|
|
2569
|
-
pageByKey: FindManyPageByKeyConfig;
|
|
2570
|
-
} ? KeyPageResult<BuildQueryResult<TSchema, TTableConfig, TConfig>> : TConfig extends {
|
|
2571
|
-
cursor: string | null;
|
|
2572
|
-
} ? PaginatedResult<BuildQueryResult<TSchema, TTableConfig, TConfig>> : BuildQueryResult<TSchema, TTableConfig, TConfig>[];
|
|
2573
|
-
type CursorPaginatedConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<DBQueryConfig<'many', true, TSchema, TTableConfig>, 'cursor' | 'limit' | 'pageByKey' | 'allowFullScan' | 'pipeline'> & {
|
|
2574
|
-
cursor: string | null;
|
|
2575
|
-
limit: number;
|
|
2576
|
-
offset?: never;
|
|
2577
|
-
pageByKey?: never;
|
|
2578
|
-
allowFullScan?: never;
|
|
2579
|
-
pipeline?: never;
|
|
2580
|
-
};
|
|
2581
|
-
type NonCursorConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<DBQueryConfig<'many', true, TSchema, TTableConfig>, 'maxScan' | 'endCursor' | 'pipeline'> & {
|
|
2582
|
-
cursor?: never;
|
|
2583
|
-
maxScan?: never;
|
|
2584
|
-
endCursor?: never;
|
|
2585
|
-
pipeline?: never;
|
|
2586
|
-
};
|
|
2587
|
-
type KeyPageConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<NonCursorConfigNoSearch<TSchema, TTableConfig>, 'pageByKey' | 'cursor' | 'maxScan' | 'endCursor' | 'offset' | 'pipeline'> & {
|
|
2588
|
-
pageByKey: FindManyPageByKeyConfig;
|
|
2589
|
-
cursor?: never;
|
|
2590
|
-
maxScan?: never;
|
|
2591
|
-
endCursor?: never;
|
|
2592
|
-
offset?: never;
|
|
2593
|
-
pipeline?: never;
|
|
2594
|
-
};
|
|
2595
|
-
type CursorPaginatedConfigNoSearch<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<CursorPaginatedConfig<TSchema, TTableConfig>, 'search'> & {
|
|
2596
|
-
search?: undefined;
|
|
2597
|
-
vectorSearch?: undefined;
|
|
2598
|
-
};
|
|
2599
|
-
type NonCursorConfigNoSearch<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<NonCursorConfig<TSchema, TTableConfig>, 'search'> & {
|
|
2600
|
-
search?: undefined;
|
|
2601
|
-
vectorSearch?: undefined;
|
|
2602
|
-
};
|
|
2603
|
-
type FindFirstConfigNoSearch<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<DBQueryConfig<'many', true, TSchema, TTableConfig>, 'limit' | 'search' | 'vectorSearch' | 'cursor' | 'maxScan' | 'endCursor' | 'pipeline' | 'pageByKey'> & {
|
|
2604
|
-
search?: undefined;
|
|
2605
|
-
vectorSearch?: undefined;
|
|
2606
|
-
endCursor?: never;
|
|
2607
|
-
pipeline?: never;
|
|
2608
|
-
pageByKey?: never;
|
|
2609
|
-
};
|
|
2610
|
-
type SelectPipelineBaseConfig<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = Omit<DBQueryConfig<'many', true, TSchema, TTableConfig>, 'cursor' | 'maxScan' | 'endCursor' | 'pageByKey' | 'pipeline' | 'with' | 'extras' | 'columns' | 'search' | 'vectorSearch' | 'offset'> & {
|
|
2611
|
-
cursor?: never;
|
|
2612
|
-
maxScan?: never;
|
|
2613
|
-
endCursor?: never;
|
|
2614
|
-
pageByKey?: never;
|
|
2615
|
-
pipeline?: never;
|
|
2616
|
-
with?: never;
|
|
2617
|
-
extras?: never;
|
|
2618
|
-
columns?: never;
|
|
2619
|
-
search?: never;
|
|
2620
|
-
vectorSearch?: never;
|
|
2621
|
-
offset?: never;
|
|
2622
|
-
};
|
|
2623
|
-
type ComposeFlatMapOutput<TCurrentRow, TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TRelationName extends Extract<keyof TTableConfig['relations'], string>, TIncludeParent extends boolean | undefined> = ApplyPipelineStage<TCurrentRow, {
|
|
2624
|
-
flatMap: {
|
|
2625
|
-
relation: TRelationName;
|
|
2626
|
-
includeParent: TIncludeParent;
|
|
2627
|
-
};
|
|
2628
|
-
}, TSchema, TTableConfig>;
|
|
2629
|
-
type PaginateConfig = {
|
|
2630
|
-
cursor: string | null;
|
|
2631
|
-
limit: number;
|
|
2632
|
-
endCursor?: string | null;
|
|
2633
|
-
maxScan?: number;
|
|
2634
|
-
};
|
|
2635
|
-
type QueryFactory<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig> = <TResult>(config: DBQueryConfig<'many', true, TSchema, TTableConfig>, mode: 'many' | 'first' | 'firstOrThrow', configuredIndex?: PredicateWhereIndexConfig<TTableConfig>) => GelRelationalQuery<TSchema, TTableConfig, TResult>;
|
|
2636
|
-
declare class RelationalSelectChain<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TRow, THasIndex extends boolean = false> extends QueryPromise<TRow[]> {
|
|
2637
|
-
private readonly createQuery;
|
|
2638
|
-
private readonly configuredIndex?;
|
|
2639
|
-
private readonly config;
|
|
2640
|
-
private readonly pipeline;
|
|
2641
|
-
constructor(createQuery: QueryFactory<TSchema, TTableConfig>, config: SelectPipelineBaseConfig<TSchema, TTableConfig>, pipeline?: FindManyPipelineConfig<TSchema, TTableConfig>, configuredIndex?: PredicateWhereIndexConfig<TTableConfig> | undefined);
|
|
2642
|
-
private withConfig;
|
|
2643
|
-
private withPipeline;
|
|
2644
|
-
private appendStage;
|
|
2645
|
-
private asManyConfig;
|
|
2646
|
-
execute(): Promise<TRow[]>;
|
|
2647
|
-
where(where: SelectPipelineBaseConfig<TSchema, TTableConfig>['where']): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2648
|
-
withIndex<TIndexName extends PredicateIndexName<TTableConfig>>(indexName: TIndexName, range?: PredicateIndexConfigByName<TTableConfig, TIndexName>['range']): RelationalSelectChain<TSchema, TTableConfig, TRow, true>;
|
|
2649
|
-
orderBy(orderBy: SelectPipelineBaseConfig<TSchema, TTableConfig>['orderBy']): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2650
|
-
limit(limit: number): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2651
|
-
allowFullScan(this: RelationalSelectChain<TSchema, TTableConfig, TRow, false>, allowFullScan: boolean): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2652
|
-
map<TOutput>(map: (row: TRow) => TOutput | null | Promise<TOutput | null>): RelationalSelectChain<TSchema, TTableConfig, NonNullable<Awaited<TOutput>>>;
|
|
2653
|
-
filter(filter: (row: TRow) => boolean | Promise<boolean>): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2654
|
-
distinct(distinct: {
|
|
2655
|
-
fields: string[];
|
|
2656
|
-
}): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2657
|
-
flatMap<TRelationName extends Extract<keyof TTableConfig['relations'], string>, TIncludeParent extends boolean | undefined = undefined>(relation: TRelationName, options?: Omit<FindManyPipelineFlatMapConfig<TTableConfig, TRelationName>, 'relation'> & {
|
|
2658
|
-
includeParent?: TIncludeParent;
|
|
2659
|
-
}): RelationalSelectChain<TSchema, TTableConfig, ComposeFlatMapOutput<TRow, TSchema, TTableConfig, TRelationName, TIncludeParent>>;
|
|
2660
|
-
union(union: FindManyUnionSource<TTableConfig>[]): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2661
|
-
interleaveBy(interleaveBy: string[]): RelationalSelectChain<TSchema, TTableConfig, TRow>;
|
|
2662
|
-
paginate(config: PaginateConfig): GelRelationalQuery<TSchema, TTableConfig, PaginatedResult<TRow>>;
|
|
2663
|
-
pageByKey(pageByKey: FindManyPageByKeyConfig): GelRelationalQuery<TSchema, TTableConfig, KeyPageResult<TRow>>;
|
|
2664
|
-
first(): GelRelationalQuery<TSchema, TTableConfig, TRow | undefined>;
|
|
2665
|
-
firstOrThrow(): GelRelationalQuery<TSchema, TTableConfig, TRow>;
|
|
2666
|
-
}
|
|
2667
|
-
/**
|
|
2668
|
-
* Query builder for a specific table
|
|
2669
|
-
*
|
|
2670
|
-
* Uses HKT (Higher-Kinded Type) pattern to prevent type widening.
|
|
2671
|
-
* The readonly `_` interface anchors the result type, preventing TypeScript
|
|
2672
|
-
* from re-evaluating TSchema[K] as a union of all tables.
|
|
2673
|
-
*
|
|
2674
|
-
* Pattern from Drizzle ORM:
|
|
2675
|
-
* drizzle-orm/src/pg-core/query-builders/select.ts:167-179
|
|
2676
|
-
*
|
|
2677
|
-
* @template TSchema - Full schema configuration
|
|
2678
|
-
* @template TTableConfig - Configuration for this specific table
|
|
2679
|
-
*/
|
|
2680
|
-
declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, THasIndex extends boolean = false> {
|
|
2681
|
-
private schema;
|
|
2682
|
-
private tableConfig;
|
|
2683
|
-
private edgeMetadata;
|
|
2684
|
-
private db;
|
|
2685
|
-
private allEdges?;
|
|
2686
|
-
private rls?;
|
|
2687
|
-
private relationLoading?;
|
|
2688
|
-
private vectorSearch?;
|
|
2689
|
-
private queryIndex?;
|
|
2690
|
-
/**
|
|
2691
|
-
* Type anchor for HKT pattern
|
|
2692
|
-
* Stores base result type in immutable property to prevent TypeScript from
|
|
2693
|
-
* widening types during mapped type evaluation. Methods construct their
|
|
2694
|
-
* return types (array, single, paginated) from this base type.
|
|
2695
|
-
*/
|
|
2696
|
-
readonly _: {
|
|
2697
|
-
readonly schema: TSchema;
|
|
2698
|
-
readonly tableConfig: TTableConfig;
|
|
2699
|
-
readonly baseResult: BuildQueryResult<TSchema, TTableConfig, true>;
|
|
2700
|
-
};
|
|
2701
|
-
constructor(schema: TSchema, tableConfig: TTableConfig, edgeMetadata: EdgeMetadata[], db: GenericDatabaseReader<any>, allEdges?: EdgeMetadata[] | undefined, // M6.5 Phase 2: All edges for nested loading
|
|
2702
|
-
rls?: RlsContext | undefined, relationLoading?: {
|
|
2703
|
-
concurrency?: number;
|
|
2704
|
-
} | undefined, vectorSearch?: VectorSearchProvider | undefined, queryIndex?: PredicateWhereIndexConfig<TTableConfig> | undefined);
|
|
2705
|
-
private createQuery;
|
|
2706
|
-
select(): RelationalSelectChain<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, true>, THasIndex>;
|
|
2707
|
-
withIndex<TIndexName extends PredicateIndexName<TTableConfig>>(indexName: TIndexName, range?: PredicateIndexConfigByName<TTableConfig, TIndexName>['range']): RelationalQueryBuilder<TSchema, TTableConfig, true>;
|
|
2708
|
-
/**
|
|
2709
|
-
* Find many rows matching the query configuration
|
|
2710
|
-
*
|
|
2711
|
-
* @template TConfig - Query configuration type
|
|
2712
|
-
* @param config - Optional query configuration (columns, with, where, orderBy, limit, offset)
|
|
2713
|
-
* @returns Query promise that resolves to array of results
|
|
2714
|
-
*
|
|
2715
|
-
* @example
|
|
2716
|
-
* const users = await ctx.db.query.users.findMany({
|
|
2717
|
-
* columns: { id: true, name: true },
|
|
2718
|
-
* with: { posts: { limit: 5 } },
|
|
2719
|
-
* where: { name: 'Alice' },
|
|
2720
|
-
* limit: 10
|
|
2721
|
-
* });
|
|
2722
|
-
*/
|
|
2723
|
-
findMany<TConfig extends SearchPaginatedConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, SearchPaginatedConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, PaginatedResult<BuildQueryResult<TSchema, TTableConfig, TConfig>>>;
|
|
2724
|
-
findMany<TConfig extends SearchNonPaginatedConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, SearchNonPaginatedConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>[]>;
|
|
2725
|
-
findMany<TConfig extends VectorNonPaginatedConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, VectorNonPaginatedConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>[]>;
|
|
2726
|
-
findMany<TConfig extends CursorPaginatedConfigNoSearch<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, CursorPaginatedConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, PaginatedResult<BuildQueryResult<TSchema, TTableConfig, TConfig>>>;
|
|
2727
|
-
findMany<TConfig extends NonCursorConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnly<TConfig, NonCursorConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, FindManyResult<TSchema, TTableConfig, TConfig>>;
|
|
2728
|
-
findMany<TConfig extends KeyPageConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, KeyPageConfig<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, KeyPageResult<BuildQueryResult<TSchema, TTableConfig, TConfig>>>;
|
|
2729
|
-
/**
|
|
2730
|
-
* Find first row matching the query configuration
|
|
2731
|
-
* Automatically applies limit: 1
|
|
2732
|
-
*
|
|
2733
|
-
* @template TConfig - Query configuration type (without limit)
|
|
2734
|
-
* @param config - Optional query configuration (columns, with, where, orderBy, offset)
|
|
2735
|
-
* @returns Query promise that resolves to single result or undefined
|
|
2736
|
-
*
|
|
2737
|
-
* @example
|
|
2738
|
-
* const user = await ctx.db.query.users.findFirst({
|
|
2739
|
-
* where: { email: 'alice@example.com' },
|
|
2740
|
-
* with: { profile: true }
|
|
2741
|
-
* });
|
|
2742
|
-
*/
|
|
2743
|
-
findFirst<TConfig extends SearchFindFirstConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, SearchFindFirstConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | undefined>;
|
|
2744
|
-
findFirst<TConfig extends FindFirstConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnly<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | undefined>;
|
|
2745
|
-
/**
|
|
2746
|
-
* Find first row matching the query configuration, or throw if none exists.
|
|
2747
|
-
*
|
|
2748
|
-
* This is the ergonomic companion to `findFirst()` (Prisma-style),
|
|
2749
|
-
* useful when callers expect a row to exist.
|
|
2750
|
-
*/
|
|
2751
|
-
findFirstOrThrow<TConfig extends SearchFindFirstConfig<TSchema, TTableConfig>>(config: KnownKeysOnly<TConfig, SearchFindFirstConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>>;
|
|
2752
|
-
findFirstOrThrow<TConfig extends FindFirstConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnly<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>>;
|
|
2753
|
-
}
|
|
2754
|
-
//#endregion
|
|
2755
|
-
//#region src/orm/update.d.ts
|
|
2756
|
-
type ConvexUpdateWithout<T extends ConvexUpdateBuilder<any, any, any>, K extends string> = Omit<T, K>;
|
|
2757
|
-
declare class ConvexUpdateBuilder<TTable extends ConvexTable<any>, TReturning extends MutationReturning = undefined, TMode extends MutationExecutionMode = 'single'> extends QueryPromise<MutationExecuteResult<TTable, TReturning, TMode>> {
|
|
2758
|
-
private db;
|
|
2759
|
-
private table;
|
|
2760
|
-
readonly _: {
|
|
2761
|
-
readonly table: TTable;
|
|
2762
|
-
readonly returning: TReturning;
|
|
2763
|
-
readonly mode: TMode;
|
|
2764
|
-
readonly result: MutationExecuteResult<TTable, TReturning, TMode>;
|
|
2765
|
-
};
|
|
2766
|
-
private setValues?;
|
|
2767
|
-
private whereExpression?;
|
|
2768
|
-
private returningFields?;
|
|
2769
|
-
private allowFullScanFlag;
|
|
2770
|
-
private paginateConfig?;
|
|
2771
|
-
private executionModeOverride?;
|
|
2772
|
-
constructor(db: GenericDatabaseWriter<any>, table: TTable);
|
|
2773
|
-
set(values: UpdateSet<TTable>): this;
|
|
2774
|
-
where(expression: FilterExpression<boolean>): this;
|
|
2775
|
-
returning(): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, true, TMode>, 'returning'>;
|
|
2776
|
-
returning<TSelection extends ReturningSelection<TTable>>(fields: TSelection): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, TSelection, TMode>, 'returning'>;
|
|
2777
|
-
paginate(config: MutationPaginateConfig): ConvexUpdateWithout<ConvexUpdateBuilder<TTable, TReturning, 'paged'>, 'paginate'>;
|
|
2778
|
-
allowFullScan(): this;
|
|
2779
|
-
private getIdEquality;
|
|
2780
|
-
executeAsync(...args: TMode extends 'single' ? [config?: MutationAsyncConfig] : [config: never]): Promise<TMode extends 'single' ? MutationExecuteResult<TTable, TReturning, 'single'> : never>;
|
|
2781
|
-
execute(...args: TMode extends 'single' ? [config?: MutationExecuteConfig] : [config?: never]): Promise<MutationExecuteResult<TTable, TReturning, TMode>>;
|
|
2782
|
-
}
|
|
2783
|
-
//#endregion
|
|
2784
|
-
//#region src/orm/database.d.ts
|
|
2785
|
-
/**
|
|
2786
|
-
* Database with query builder API
|
|
2787
|
-
*
|
|
2788
|
-
* @template TSchema - Schema configuration with tables and relations
|
|
2789
|
-
*
|
|
2790
|
-
* Following Drizzle's pattern: Validate schema BEFORE mapped type to prevent type widening.
|
|
2791
|
-
* The conditional check outside the mapped type prevents distributive conditional behavior
|
|
2792
|
-
* that causes TSchema[K] to widen to a union of all table types.
|
|
2793
|
-
*
|
|
2794
|
-
* Pattern from: drizzle-orm/src/pg-core/db.ts lines 50-54
|
|
2795
|
-
* Key insight: TSchema[K] must be captured at mapping time, not evaluated in conditionals later.
|
|
2796
|
-
*/
|
|
2797
|
-
type DatabaseWithQuery<TSchema extends TablesRelationalConfig> = Pick<GenericDatabaseReader<any>, 'system'> & {
|
|
2798
|
-
query: TSchema extends Record<string, never> ? {
|
|
2799
|
-
error: 'Schema is empty - did you forget to add tables?';
|
|
2800
|
-
} : { [K in keyof TSchema]: RelationalQueryBuilder<TSchema, TSchema[K]> };
|
|
2801
|
-
};
|
|
2802
|
-
type DatabaseWithMutations<TSchema extends TablesRelationalConfig> = DatabaseWithQuery<TSchema> & {
|
|
2803
|
-
insert<TTable extends ConvexTable<any>>(table: TTable): ConvexInsertBuilder<TTable>;
|
|
2804
|
-
update<TTable extends ConvexTable<any>>(table: TTable): ConvexUpdateBuilder<TTable>;
|
|
2805
|
-
delete<TTable extends ConvexTable<any>>(table: TTable): ConvexDeleteBuilder<TTable>;
|
|
2806
|
-
};
|
|
2807
|
-
type OrmReader<TSchema extends TablesRelationalConfig> = DatabaseWithQuery<TSchema> & {
|
|
2808
|
-
skipRules: DatabaseWithQuery<TSchema>;
|
|
2809
|
-
};
|
|
2810
|
-
type OrmWriter<TSchema extends TablesRelationalConfig> = DatabaseWithMutations<TSchema> & {
|
|
2811
|
-
skipRules: DatabaseWithMutations<TSchema>;
|
|
2812
|
-
};
|
|
2813
|
-
type CreateDatabaseOptions = {
|
|
2814
|
-
scheduler?: Scheduler;
|
|
2815
|
-
scheduledDelete?: SchedulableFunctionReference;
|
|
2816
|
-
scheduledMutationBatch?: SchedulableFunctionReference;
|
|
2817
|
-
vectorSearch?: VectorSearchProvider;
|
|
2818
|
-
rls?: RlsContext;
|
|
2819
|
-
relationLoading?: {
|
|
2820
|
-
concurrency?: number;
|
|
2821
|
-
};
|
|
2822
|
-
};
|
|
2823
|
-
//#endregion
|
|
2824
|
-
//#region src/orm/scheduled-delete.d.ts
|
|
2825
|
-
type ScheduledDeleteArgs = {
|
|
2826
|
-
table: string;
|
|
2827
|
-
id: GenericId<any>;
|
|
2828
|
-
cascadeMode?: CascadeMode;
|
|
2829
|
-
deletionTime?: number;
|
|
2830
|
-
};
|
|
2831
|
-
declare function scheduledDeleteFactory<TSchema extends TablesRelationalConfig>(schema: TSchema, edgeMetadata: EdgeMetadata[], scheduledMutationBatch: SchedulableFunctionReference): (ctx: {
|
|
2832
|
-
db: GenericDatabaseWriter<any>;
|
|
2833
|
-
scheduler: Scheduler;
|
|
2834
|
-
}, args: ScheduledDeleteArgs) => Promise<void>;
|
|
2835
|
-
//#endregion
|
|
2836
|
-
//#region src/orm/scheduled-mutation-batch.d.ts
|
|
2837
|
-
type ScheduledMutationWorkType = 'root-update' | 'root-delete' | 'cascade-delete' | 'cascade-update';
|
|
2838
|
-
type ScheduledMutationBatchArgs = {
|
|
2839
|
-
workType?: ScheduledMutationWorkType;
|
|
2840
|
-
mode?: 'sync' | 'async';
|
|
2841
|
-
operation: 'update' | 'delete';
|
|
2842
|
-
table: string;
|
|
2843
|
-
where?: SerializedFilterExpression;
|
|
2844
|
-
allowFullScan?: boolean;
|
|
2845
|
-
update?: Record<string, unknown>;
|
|
2846
|
-
deleteMode?: DeleteMode;
|
|
2847
|
-
cascadeMode?: CascadeMode;
|
|
2848
|
-
foreignIndexName?: string;
|
|
2849
|
-
foreignSourceColumns?: string[];
|
|
2850
|
-
targetValues?: unknown;
|
|
2851
|
-
newValues?: unknown;
|
|
2852
|
-
foreignAction?: 'cascade' | 'set null' | 'set default' | 'restrict' | 'no action';
|
|
2853
|
-
cursor: string | null;
|
|
2854
|
-
batchSize: number;
|
|
2855
|
-
maxBytesPerBatch?: number;
|
|
2856
|
-
delayMs: number;
|
|
2857
|
-
};
|
|
2858
|
-
declare function scheduledMutationBatchFactory<TSchema extends TablesRelationalConfig>(schema: TSchema, edgeMetadata: EdgeMetadata[], scheduledMutationBatch: SchedulableFunctionReference): (ctx: {
|
|
2859
|
-
db: GenericDatabaseWriter<any>;
|
|
2860
|
-
scheduler: Scheduler;
|
|
2861
|
-
}, args: ScheduledMutationBatchArgs) => Promise<void>;
|
|
2862
|
-
//#endregion
|
|
2863
|
-
//#region src/orm/create-orm.d.ts
|
|
2864
|
-
type OrmFunctions = {
|
|
2865
|
-
scheduledMutationBatch: SchedulableFunctionReference;
|
|
2866
|
-
scheduledDelete: SchedulableFunctionReference;
|
|
2867
|
-
};
|
|
2868
|
-
type CreateOrmOptions = Omit<CreateDatabaseOptions, never>;
|
|
2869
|
-
type OrmWriterCtx = {
|
|
2870
|
-
db: GenericDatabaseWriter<any>;
|
|
2871
|
-
scheduler?: Scheduler;
|
|
2872
|
-
vectorSearch?: VectorSearchProvider;
|
|
2873
|
-
};
|
|
2874
|
-
type OrmReaderCtx = {
|
|
2875
|
-
db: GenericDatabaseReader<any>;
|
|
2876
|
-
scheduler?: Scheduler;
|
|
2877
|
-
vectorSearch?: VectorSearchProvider;
|
|
2878
|
-
};
|
|
2879
|
-
type OrmSource = GenericDatabaseReader<any> | GenericDatabaseWriter<any> | OrmReaderCtx | OrmWriterCtx;
|
|
2880
|
-
type OrmResult<TSource extends OrmSource, TSchema extends TablesRelationalConfig> = TSource extends GenericDatabaseWriter<any> | OrmWriterCtx ? OrmWriter<TSchema> : OrmReader<TSchema>;
|
|
2881
|
-
type GenericOrm<Ctx extends {
|
|
2882
|
-
db: GenericDatabaseReader<any> | GenericDatabaseWriter<any>;
|
|
2883
|
-
}, TSchema extends TablesRelationalConfig> = Ctx extends {
|
|
2884
|
-
db: GenericDatabaseWriter<any>;
|
|
2885
|
-
} ? OrmWriter<TSchema> : OrmReader<TSchema>;
|
|
2886
|
-
type GenericOrmCtx<Ctx extends {
|
|
2887
|
-
db: GenericDatabaseReader<any> | GenericDatabaseWriter<any>;
|
|
2888
|
-
}, TSchema extends TablesRelationalConfig> = Ctx & {
|
|
2889
|
-
orm: GenericOrm<Ctx, TSchema>;
|
|
2890
|
-
};
|
|
2891
|
-
type CreateOrmConfigBase<TSchema extends TablesRelationalConfig> = {
|
|
2892
|
-
schema: TSchema;
|
|
2893
|
-
internalMutation?: typeof internalMutationGeneric;
|
|
2894
|
-
};
|
|
2895
|
-
type CreateOrmConfigWithFunctions<TSchema extends TablesRelationalConfig> = CreateOrmConfigBase<TSchema> & {
|
|
2896
|
-
ormFunctions: OrmFunctions;
|
|
2897
|
-
};
|
|
2898
|
-
type CreateOrmConfigWithoutFunctions<TSchema extends TablesRelationalConfig> = CreateOrmConfigBase<TSchema> & {
|
|
2899
|
-
ormFunctions?: undefined;
|
|
2900
|
-
};
|
|
2901
|
-
type OrmFactory<TSchema extends TablesRelationalConfig> = <TSource extends OrmSource>(source: TSource, options?: CreateOrmOptions) => OrmResult<TSource, TSchema>;
|
|
2902
|
-
type OrmApiResult = {
|
|
2903
|
-
scheduledMutationBatch: ReturnType<typeof internalMutationGeneric>;
|
|
2904
|
-
scheduledDelete: ReturnType<typeof internalMutationGeneric>;
|
|
2905
|
-
};
|
|
2906
|
-
type OrmClientBase<TSchema extends TablesRelationalConfig> = {
|
|
2907
|
-
db: OrmFactory<TSchema>;
|
|
2908
|
-
with: <TContext extends OrmReaderCtx | OrmWriterCtx>(ctx: TContext, options?: CreateOrmOptions) => GenericOrmCtx<TContext, TSchema>;
|
|
2909
|
-
};
|
|
2910
|
-
type OrmClientWithApi<TSchema extends TablesRelationalConfig> = OrmClientBase<TSchema> & {
|
|
2911
|
-
api: () => OrmApiResult;
|
|
2912
|
-
};
|
|
2913
|
-
declare function createOrm<TSchema extends TablesRelationalConfig>(config: CreateOrmConfigWithoutFunctions<TSchema>): OrmClientBase<TSchema>;
|
|
2914
|
-
declare function createOrm<TSchema extends TablesRelationalConfig>(config: CreateOrmConfigWithFunctions<TSchema>): OrmClientWithApi<TSchema>;
|
|
2915
|
-
//#endregion
|
|
2916
|
-
//#region src/orm/errors.d.ts
|
|
2917
|
-
declare class OrmNotFoundError extends Error {
|
|
2918
|
-
readonly table?: string | undefined;
|
|
2919
|
-
constructor(message: string, table?: string | undefined);
|
|
2920
|
-
}
|
|
2921
|
-
//#endregion
|
|
2922
|
-
//#region src/orm/index-utils.d.ts
|
|
2923
|
-
declare function getIndexes(table: ConvexTable<any>): {
|
|
2924
|
-
name: string;
|
|
2925
|
-
fields: string[];
|
|
2926
|
-
}[];
|
|
2927
|
-
//#endregion
|
|
2928
|
-
//#region src/orm/introspection.d.ts
|
|
2929
|
-
declare function getTableColumns<TTable extends ConvexTable<any>>(table: TTable): TTable[typeof Columns] & SystemFields<TTable['_']['name']> & SystemFieldAliases<TTable['_']['name'], TTable[typeof Columns]>;
|
|
2930
|
-
type TableConfigResult<TTable extends ConvexTable<any>> = {
|
|
2931
|
-
name: string;
|
|
2932
|
-
columns: ReturnType<typeof getTableColumns<TTable>>;
|
|
2933
|
-
indexes: ReturnType<typeof getIndexes>;
|
|
2934
|
-
uniqueIndexes: ReturnType<typeof getUniqueIndexes>;
|
|
2935
|
-
foreignKeys: ReturnType<typeof getForeignKeys>;
|
|
2936
|
-
checks: ReturnType<typeof getChecks>;
|
|
2937
|
-
rls: {
|
|
2938
|
-
enabled: boolean;
|
|
2939
|
-
policies: RlsPolicy[];
|
|
2940
|
-
};
|
|
2941
|
-
};
|
|
2942
|
-
declare function getTableConfig<TTable extends ConvexTable<any>>(table: TTable): TableConfigResult<TTable>;
|
|
2943
|
-
//#endregion
|
|
2944
|
-
//#region src/orm/order-by.d.ts
|
|
2945
|
-
/**
|
|
2946
|
-
* Create ascending order clause
|
|
2947
|
-
* Following Drizzle pattern for type-safe ordering
|
|
2948
|
-
*
|
|
2949
|
-
* @example
|
|
2950
|
-
* const posts = await db.query.posts.findMany({
|
|
2951
|
-
* orderBy: asc(posts._creationTime),
|
|
2952
|
-
* });
|
|
2953
|
-
*/
|
|
2954
|
-
declare function asc<TBuilder extends ColumnBuilder<any, any, any>>(builder: TBuilder): OrderByClause<TBuilder>;
|
|
2955
|
-
/**
|
|
2956
|
-
* Create descending order clause
|
|
2957
|
-
* Following Drizzle pattern for type-safe ordering
|
|
2958
|
-
*
|
|
2959
|
-
* @example
|
|
2960
|
-
* const posts = await db.query.posts.findMany({
|
|
2961
|
-
* orderBy: desc(posts._creationTime),
|
|
2962
|
-
* });
|
|
2963
|
-
*/
|
|
2964
|
-
declare function desc<TBuilder extends ColumnBuilder<any, any, any>>(builder: TBuilder): OrderByClause<TBuilder>;
|
|
2965
|
-
//#endregion
|
|
2966
|
-
//#region src/orm/schema.d.ts
|
|
2967
|
-
type BetterConvexSchemaOptions<StrictTableNameTypes extends boolean> = DefineSchemaOptions$1<StrictTableNameTypes> & {
|
|
2968
|
-
strict?: boolean;
|
|
2969
|
-
defaults?: OrmRuntimeDefaults;
|
|
2970
|
-
};
|
|
2971
|
-
/**
|
|
2972
|
-
* Better Convex schema definition
|
|
2973
|
-
*
|
|
2974
|
-
* Wraps Convex's defineSchema to keep schema authoring inside better-convex.
|
|
2975
|
-
* Mirrors drizzle's schema-first approach while returning a Convex-compatible
|
|
2976
|
-
* SchemaDefinition for codegen and convex-test.
|
|
2977
|
-
*/
|
|
2978
|
-
declare function defineSchema<TSchema extends GenericSchema$1, StrictTableNameTypes extends boolean = true>(schema: TSchema, options?: BetterConvexSchemaOptions<StrictTableNameTypes>): SchemaDefinition$1<TSchema, StrictTableNameTypes>;
|
|
2979
|
-
//#endregion
|
|
2980
|
-
//#region src/orm/where-clause-compiler.d.ts
|
|
2981
|
-
/**
|
|
2982
|
-
* Result of compiling a where clause
|
|
2983
|
-
* Contains index selection and filter expressions
|
|
2984
|
-
*/
|
|
2985
|
-
interface WhereClauseResult {
|
|
2986
|
-
/** Planning strategy used for index compilation */
|
|
2987
|
-
strategy: IndexStrategy;
|
|
2988
|
-
/** Selected index for query optimization (null if no suitable index) */
|
|
2989
|
-
selectedIndex: IndexLike | null;
|
|
2990
|
-
/** Filters that can use the index (eq/range on indexed fields) */
|
|
2991
|
-
indexFilters: FilterExpression<boolean>[];
|
|
2992
|
-
/** Multi-probe filter groups for OR/inArray index union plans */
|
|
2993
|
-
probeFilters: FilterExpression<boolean>[][];
|
|
2994
|
-
/** Filters applied after index scan (gt, lt, and, or, not) */
|
|
2995
|
-
postFilters: FilterExpression<boolean>[];
|
|
2996
|
-
}
|
|
2997
|
-
type IndexStrategy = 'none' | 'singleIndex' | 'rangeIndex' | 'multiProbe';
|
|
2998
|
-
/**
|
|
2999
|
-
* Compiles FilterExpression trees into optimized Convex queries
|
|
3000
|
-
*
|
|
3001
|
-
* Algorithm:
|
|
3002
|
-
* 1. Extract field references from expression tree
|
|
3003
|
-
* 2. Score available indexes by field match quality
|
|
3004
|
-
* 3. Select best index (exact > prefix > partial)
|
|
3005
|
-
* 4. Split filters into index-compatible vs post-filters
|
|
3006
|
-
*/
|
|
3007
|
-
interface IndexLike {
|
|
3008
|
-
indexName: string;
|
|
3009
|
-
indexFields: string[];
|
|
3010
|
-
}
|
|
3011
|
-
//#endregion
|
|
3012
|
-
export { type AnyColumn, type BinaryExpression, Brand, type BuildQueryResult, type BuildRelationResult, type ColumnBuilder, type ColumnBuilderBaseConfig, type ColumnBuilderRuntimeConfig, type ColumnBuilderTypeConfig, type ColumnBuilderWithTableName, type ColumnDataType, Columns, type ConvexBigIntBuilder, type ConvexBigIntBuilderInitial, type ConvexBooleanBuilder, type ConvexBooleanBuilderInitial, type ConvexBytesBuilder, type ConvexBytesBuilderInitial, type ConvexCheckBuilder, type ConvexCheckConfig, type ConvexCustomBuilder, type ConvexCustomBuilderInitial, type ConvexDateBuilder, type ConvexDateBuilderInitial, type ConvexDateMode, type ConvexDeletionBuilder, type ConvexDeletionConfig, type ConvexForeignKeyBuilder, type ConvexForeignKeyConfig, type ConvexIdBuilder, type ConvexIdBuilderInitial, type ConvexIndexBuilder, type ConvexIndexBuilderOn, type ConvexLifecycleBuilder, type ConvexNumberBuilder, type ConvexNumberBuilderInitial, type ConvexSearchIndexBuilder, type ConvexSearchIndexBuilderOn, type ConvexSearchIndexConfig, type ConvexTable, type ConvexTextBuilder, type ConvexTextBuilderInitial, type ConvexTextEnumBuilder, type ConvexTextEnumBuilderInitial, type ConvexTimestampBuilder, type ConvexTimestampBuilderInitial, type ConvexTimestampMode, type ConvexUniqueConstraintBuilder, type ConvexUniqueConstraintBuilderOn, type ConvexUniqueConstraintConfig, type ConvexVectorBuilder, type ConvexVectorBuilderInitial, type ConvexVectorIndexBuilder, type ConvexVectorIndexBuilderOn, type ConvexVectorIndexConfig, type CreateOrmOptions, type DBQueryConfig, type DatabaseWithMutations, type DatabaseWithQuery, type DefineSchemaOptions, type DrizzleEntity, type EdgeMetadata, type ExpressionVisitor, type ExtractTablesWithRelations, type FieldReference, type FilterExpression, type FilterOperators, type GenericOrm, type GenericOrmCtx, type GenericSchema, type GetColumnData, type HasDefault, type InferInsertModel, type InferModelFromColumns, type InferSelectModel, type InsertValue, type IsPrimaryKey, type IsUnique, type LogicalExpression, type ManyConfig, type MutationAsyncConfig, type MutationExecuteConfig, type MutationExecuteResult, type MutationExecutionMode, type MutationPaginateConfig, type MutationPaginatedResult, type MutationResult, type MutationReturning, type MutationRunMode, type NotNull, type OneConfig, type OrderByClause, type OrderDirection, type OrmApiResult, type OrmClientBase, type OrmClientWithApi, type OrmFunctions, type OrmLifecycleChange, type OrmLifecycleConfig, type OrmLifecycleHandler, type OrmLifecycleOperation, OrmNotFoundError, type OrmReader, type OrmReaderCtx, type OrmTriggerLike, type OrmWriter, type OrmWriterCtx, type PaginatedResult, type PredicateWhereIndexConfig, type RelationsBuilder, type RelationsBuilderColumnBase, type RelationsBuilderColumnConfig, type ReturningAll, type ReturningResult, type ReturningSelection, type RlsContext, type RlsMode, RlsPolicy, type RlsPolicyConfig, type RlsPolicyToOption, RlsRole, type RlsRoleConfig, type ScheduledDeleteArgs, type ScheduledMutationBatchArgs, type SchemaDefinition, type SystemFields, type TableConfig, type TableConfigResult, TableName, type TableRelationalConfig, type TablesRelationalConfig, type UnaryExpression, type UpdateSet, type VectorQueryConfig, type VectorSearchProvider, type WhereClauseResult, and, asc, between, bigint, boolean, bytes, check, contains, convexTable, createOrm, custom, date, defineRelations, defineRelationsPart, defineSchema, deletion, desc, endsWith, eq, extractRelationsConfig, fieldRef, foreignKey, getTableColumns, getTableConfig, gt, gte, id, ilike, inArray, index, integer, isFieldReference, isNotNull, isNull, json, like, lt, lte, ne, not, notBetween, notInArray, onChange, onDelete, onInsert, onUpdate, or, rlsPolicy, rlsRole, scheduledDeleteFactory, scheduledMutationBatchFactory, searchIndex, startsWith, text, textEnum, timestamp, unique, uniqueIndex, unsetToken, vector, vectorIndex };
|
|
1
|
+
import { $ as ConvexIdBuilder, $n as VectorSearchProvider, $t as ConvexRankIndexBuilderOn, A as DatabaseWithQuery, An as FilterOperators, Ar as Columns, At as defineRelations, B as ConvexTimestampBuilder, Bn as MutationPaginatedResult, Br as DrizzleEntity, Bt as deletion, C as OrmBeforeResult, Cn as AggregateFieldValue, Cr as ne, Ct as ManyConfig, D as OrmTriggers, Dn as CountConfig, Dr as or, Dt as RelationsBuilderColumnConfig, E as OrmTriggerContext, En as BuildRelationResult, Er as notInArray, Et as RelationsBuilderColumnBase, F as EdgeMetadata, Fn as InsertValue, Fr as ColumnBuilderBaseConfig, G as ConvexTextEnumBuilderInitial, Gn as OrderDirection, Gt as RlsRole, H as ConvexTimestampMode, Hn as MutationReturning, Hr as IsPrimaryKey, Ht as RlsPolicyConfig, I as extractRelationsConfig, In as MutationExecuteConfig, Ir as ColumnBuilderRuntimeConfig, It as OrmLifecycleChange, J as ConvexTextBuilderInitial, Jn as ReturningAll, Jt as ConvexAggregateIndexBuilder, K as textEnum, Kn as PaginatedResult, Kt as RlsRoleConfig, L as ConvexVectorBuilder, Ln as MutationExecuteResult, Lr as ColumnBuilderTypeConfig, Lt as OrmLifecycleOperation, M as OrmWriter, Mn as InferInsertModel, Mr as SystemFields, Mt as ConvexDeletionBuilder, N as RlsContext, Nn as InferModelFromColumns, Nr as AnyColumn, Nt as ConvexDeletionConfig, O as defineTriggers, On as CountResult, Or as startsWith, Ot as TableRelationalConfig, P as RlsMode, Pn as InferSelectModel, Pr as ColumnBuilder, Pt as ConvexTable, Q as integer, Qn as VectorQueryConfig, Qt as ConvexRankIndexBuilder, R as ConvexVectorBuilderInitial, Rn as MutationExecutionMode, Rr as ColumnBuilderWithTableName, Rt as TableConfig, S as scheduledDeleteFactory, Sn as AggregateConfig, Sr as lte, St as ExtractTablesWithRelations, T as OrmTriggerChange, Tn as BuildQueryResult, Tr as notBetween, Tt as RelationsBuilder, U as timestamp, Un as MutationRunMode, Ur as IsUnique, Ut as RlsPolicyToOption, V as ConvexTimestampBuilderInitial, Vn as MutationResult, Vr as HasDefault, Vt as RlsPolicy, W as ConvexTextEnumBuilder, Wn as OrderByClause, Wr as NotNull, Wt as rlsPolicy, X as ConvexNumberBuilder, Xn as ReturningSelection, Xt as ConvexIndexBuilder, Y as text, Yn as ReturningResult, Yt as ConvexAggregateIndexBuilderOn, Z as ConvexNumberBuilderInitial, Zn as UpdateSet, Zt as ConvexIndexBuilderOn, _ as OrmWriterCtx, _n as ConvexUniqueConstraintBuilderOn, _r as isFieldReference, _t as ConvexBigIntBuilderInitial, a as TableConfigResult, an as ConvexVectorIndexConfig, ar as LogicalExpression, at as date, b as scheduledMutationBatchFactory, bn as foreignKey, br as like, bt as CountBackfillKickoffArgs, c as OrmNotFoundError, cn as rankIndex, cr as between, ct as custom, d as GenericOrmCtx, dn as vectorIndex, dr as eq, dt as ConvexBytesBuilderInitial, en as ConvexSearchIndexBuilder, er as unsetToken, et as ConvexIdBuilderInitial, f as OrmApiResult, fn as ConvexCheckBuilder, fr as fieldRef, ft as bytes, g as OrmReaderCtx, gn as ConvexUniqueConstraintBuilder, gr as inArray, gt as ConvexBigIntBuilder, h as OrmFunctions, hn as ConvexForeignKeyConfig, hr as ilike, ht as boolean, i as desc, in as ConvexVectorIndexBuilderOn, ir as FilterExpression, it as ConvexDateMode, j as OrmReader, jn as GetColumnData, jr as TableName, jt as defineRelationsPart, k as DatabaseWithMutations, kn as DBQueryConfig, kr as Brand, kt as TablesRelationalConfig, l as CreateOrmOptions, ln as searchIndex, lr as contains, lt as json, m as OrmClientWithApi, mn as ConvexForeignKeyBuilder, mr as gte, mt as ConvexBooleanBuilderInitial, n as defineSchema, nn as ConvexSearchIndexConfig, nr as ExpressionVisitor, nt as ConvexDateBuilder, o as getTableColumns, on as aggregateIndex, or as UnaryExpression, ot as ConvexCustomBuilder, p as OrmClientBase, pn as ConvexCheckConfig, pr as gt, pt as ConvexBooleanBuilder, q as ConvexTextBuilder, qn as PredicateWhereIndexConfig, qt as rlsRole, r as asc, rn as ConvexVectorIndexBuilder, rr as FieldReference, rt as ConvexDateBuilderInitial, s as getTableConfig, sn as index, sr as and, st as ConvexCustomBuilderInitial, t as WhereClauseResult, tn as ConvexSearchIndexBuilderOn, tr as BinaryExpression, tt as id, u as GenericOrm, un as uniqueIndex, ur as endsWith, ut as ConvexBytesBuilder, v as createOrm, vn as ConvexUniqueConstraintConfig, vr as isNotNull, vt as bigint, w as OrmTableTriggers, wn as AggregateResult, wr as not, wt as OneConfig, x as ScheduledDeleteArgs, xn as unique, xr as lt, xt as CountBackfillStatusArgs, y as ScheduledMutationBatchArgs, yn as check, yr as isNull, yt as CountBackfillChunkArgs, z as vector, zn as MutationPaginateConfig, zr as ColumnDataType, zt as convexTable } from "../where-clause-compiler-CRP-i1Qa.js";
|
|
2
|
+
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-DGExXZIV.js";
|
|
3
|
+
import { DefineSchemaOptions, GenericSchema, SchemaDefinition } from "convex/server";
|
|
4
|
+
export { type AggregateConfig, type AggregateFieldValue, type AggregateResult, type AnyColumn, type BinaryExpression, Brand, type BuildQueryResult, type BuildRelationResult, type ColumnBuilder, type ColumnBuilderBaseConfig, type ColumnBuilderRuntimeConfig, type ColumnBuilderTypeConfig, type ColumnBuilderWithTableName, type ColumnDataType, Columns, type ConvexAggregateIndexBuilder, type ConvexAggregateIndexBuilderOn, type ConvexBigIntBuilder, type ConvexBigIntBuilderInitial, type ConvexBooleanBuilder, type ConvexBooleanBuilderInitial, type ConvexBytesBuilder, type ConvexBytesBuilderInitial, type ConvexCheckBuilder, type ConvexCheckConfig, type ConvexCustomBuilder, type ConvexCustomBuilderInitial, type ConvexDateBuilder, type ConvexDateBuilderInitial, type ConvexDateMode, type ConvexDeletionBuilder, type ConvexDeletionConfig, type ConvexForeignKeyBuilder, type ConvexForeignKeyConfig, type ConvexIdBuilder, type ConvexIdBuilderInitial, type ConvexIndexBuilder, type ConvexIndexBuilderOn, type ConvexNumberBuilder, type ConvexNumberBuilderInitial, type ConvexRankIndexBuilder, type ConvexRankIndexBuilderOn, type ConvexSearchIndexBuilder, type ConvexSearchIndexBuilderOn, type ConvexSearchIndexConfig, type ConvexTable, type ConvexTextBuilder, type ConvexTextBuilderInitial, type ConvexTextEnumBuilder, type ConvexTextEnumBuilderInitial, type ConvexTimestampBuilder, type ConvexTimestampBuilderInitial, type ConvexTimestampMode, type ConvexUniqueConstraintBuilder, type ConvexUniqueConstraintBuilderOn, type ConvexUniqueConstraintConfig, type ConvexVectorBuilder, type ConvexVectorBuilderInitial, type ConvexVectorIndexBuilder, type ConvexVectorIndexBuilderOn, type ConvexVectorIndexConfig, type CountBackfillChunkArgs, type CountBackfillKickoffArgs, type CountBackfillStatusArgs, type CountConfig, type CountResult, type CreateOrmOptions, type DBQueryConfig, type DatabaseWithMutations, type DatabaseWithQuery, type DefineSchemaOptions, type DocByCtx, type DrizzleEntity, type EdgeMetadata, type ExpressionVisitor, type ExtractTablesWithRelations, type FieldReference, type FilterExpression, type FilterOperators, type GenericOrm, type GenericOrmCtx, type GenericSchema, type GetColumnData, type HasDefault, type InferInsertModel, type InferModelFromColumns, type InferSelectModel, type InsertValue, type IsPrimaryKey, type IsUnique, type LogicalExpression, type LookupByIdResultByCtx, type ManyConfig, type MutationExecuteConfig, type MutationExecuteResult, type MutationExecutionMode, type MutationPaginateConfig, type MutationPaginatedResult, type MutationResult, type MutationReturning, type MutationRunMode, type NotNull, type OneConfig, type OrderByClause, type OrderDirection, type OrmApiResult, type OrmBeforeResult, type OrmClientBase, type OrmClientWithApi, type OrmFunctions, type OrmLifecycleChange, type OrmLifecycleOperation, OrmNotFoundError, type OrmReader, type OrmReaderCtx, type OrmTableTriggers, type OrmTriggerChange, type OrmTriggerContext, type OrmTriggers, type OrmWriter, type OrmWriterCtx, type PaginatedResult, type PredicateWhereIndexConfig, type QueryCtxWithOptionalOrmQueryTable, type QueryCtxWithOrmQueryTable, type QueryCtxWithPreferredOrmQueryTable, type RelationsBuilder, type RelationsBuilderColumnBase, type RelationsBuilderColumnConfig, type ReturningAll, type ReturningResult, type ReturningSelection, type RlsContext, type RlsMode, RlsPolicy, type RlsPolicyConfig, type RlsPolicyToOption, RlsRole, type RlsRoleConfig, type ScheduledDeleteArgs, type ScheduledMutationBatchArgs, type SchemaDefinition, type SystemFields, type TableConfig, type TableConfigResult, TableName, type TableRelationalConfig, type TablesRelationalConfig, type UnaryExpression, type UpdateSet, type VectorQueryConfig, type VectorSearchProvider, type WhereClauseResult, aggregateIndex, and, asc, between, bigint, boolean, bytes, check, contains, convexTable, createOrm, custom, date, defineRelations, defineRelationsPart, defineSchema, defineTriggers, deletion, desc, endsWith, eq, extractRelationsConfig, fieldRef, foreignKey, getByIdWithOrmQueryFallback, getTableColumns, getTableConfig, gt, gte, id, ilike, inArray, index, integer, isFieldReference, isNotNull, isNull, json, like, lt, lte, ne, not, notBetween, notInArray, or, rankIndex, rlsPolicy, rlsRole, scheduledDeleteFactory, scheduledMutationBatchFactory, searchIndex, startsWith, text, textEnum, timestamp, unique, uniqueIndex, unsetToken, vector, vectorIndex };
|