better-convex 0.8.4 → 0.9.1
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 +1 -2
- package/dist/aggregate/index.js +1 -1
- package/dist/auth/client/index.js +50 -29
- package/dist/auth/index.d.ts +74 -74
- package/dist/cli.mjs +33 -13
- package/dist/{codegen-BS36cYTH.mjs → codegen-CMQIKrqh.mjs} +37 -32
- package/dist/{id-DdAxiGby.js → id-BF_SaWhQ.js} +1 -1
- package/dist/orm/index.d.ts +2 -2
- package/dist/orm/index.js +98 -90
- package/dist/plugins/index.d.ts +4 -2
- package/dist/plugins/index.js +1 -1
- package/dist/plugins/ratelimit/index.d.ts +1 -2
- package/dist/plugins/ratelimit/index.js +2 -2
- package/dist/{runtime-oWZgeWOJ.js → runtime-B20PP4Qr.js} +2 -2
- package/dist/{schema-DVFZAlKx.js → schema-Cw5-LWTg.js} +2 -2
- package/dist/server/index.js +6 -3
- package/dist/{table-B7yzBihE.js → table-Bxqm450r.js} +107 -3
- package/dist/{text-enum-CFdcLUuw.js → text-enum-KyijdQ8Q.js} +1 -1
- package/dist/watcher.mjs +1 -1
- package/dist/{where-clause-compiler-_b1UHbYW.d.ts → where-clause-compiler-UavDdMUX.d.ts} +180 -163
- package/package.json +1 -1
|
@@ -2,7 +2,6 @@ import { a as ReturnTypeOrValue, i as KnownKeysOnly, o as Simplify, t as Assume
|
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Validator, Value } from "convex/values";
|
|
4
4
|
import { DefineSchemaOptions, FilterExpression, GenericDatabaseReader, GenericDatabaseWriter, GenericIndexFields, GenericSchema, GenericTableIndexes, GenericTableSearchIndexes, GenericTableVectorIndexes, IndexRange, IndexRangeBuilder, SchedulableFunctionReference, Scheduler, SchemaDefinition, TableDefinition, VectorFilterBuilder, internalActionGeneric, internalMutationGeneric } from "convex/server";
|
|
5
|
-
import { z } from "zod";
|
|
6
5
|
|
|
7
6
|
//#region src/orm/builders/column-builder.d.ts
|
|
8
7
|
/**
|
|
@@ -342,12 +341,23 @@ type OrmSchemaPlugin = {
|
|
|
342
341
|
tableNames: readonly string[];
|
|
343
342
|
inject: <TSchema extends Record<string, unknown>>(schema: TSchema) => TSchema & Record<string, unknown>;
|
|
344
343
|
};
|
|
344
|
+
type TablePolymorphicVariantRuntime = {
|
|
345
|
+
fieldNames: readonly string[];
|
|
346
|
+
requiredFieldNames: readonly string[];
|
|
347
|
+
};
|
|
348
|
+
type TablePolymorphicConfigRuntime = {
|
|
349
|
+
discriminator: string;
|
|
350
|
+
alias: string;
|
|
351
|
+
generatedFieldNames: readonly string[];
|
|
352
|
+
variants: Readonly<Record<string, TablePolymorphicVariantRuntime>>;
|
|
353
|
+
};
|
|
345
354
|
declare const TableName: unique symbol;
|
|
346
355
|
declare const Columns: unique symbol;
|
|
347
356
|
declare const Brand: unique symbol;
|
|
348
357
|
declare const RlsPolicies: unique symbol;
|
|
349
358
|
declare const EnableRLS: unique symbol;
|
|
350
359
|
declare const TableDeleteConfig: unique symbol;
|
|
360
|
+
declare const TablePolymorphic: unique symbol;
|
|
351
361
|
declare const OrmSchemaDefinition: unique symbol;
|
|
352
362
|
declare const OrmSchemaPluginTables: unique symbol;
|
|
353
363
|
//#endregion
|
|
@@ -696,8 +706,27 @@ type InferSelectModel<TTable extends ConvexTable<any>> = Simplify<Merge<{
|
|
|
696
706
|
id: string;
|
|
697
707
|
createdAt: number;
|
|
698
708
|
}, { [K in keyof TTable['_']['columns']]: GetColumnData<TTable['_']['columns'][K], 'query'> }>>;
|
|
699
|
-
type RequiredKeyOnly<TKey extends string, TColumn extends
|
|
700
|
-
type OptionalKeyOnly<TKey extends string, TColumn extends
|
|
709
|
+
type RequiredKeyOnly<TKey extends string, TColumn extends ColumnBuilderBase> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? never : TKey : never;
|
|
710
|
+
type OptionalKeyOnly<TKey extends string, TColumn extends ColumnBuilderBase> = TColumn['_']['notNull'] extends true ? TColumn['_']['hasDefault'] extends true ? TKey : never : TKey;
|
|
711
|
+
type InferInsertModelFromColumns<TColumns extends Record<string, ColumnBuilderBase>, TExcludeKeys extends string = never> = Simplify<{ [K in keyof TColumns & string as K extends TExcludeKeys ? never : RequiredKeyOnly<K, TColumns[K]>]: GetColumnData<TColumns[K], 'query'> } & { [K in keyof TColumns & string as K extends TExcludeKeys ? never : OptionalKeyOnly<K, TColumns[K]>]?: GetColumnData<TColumns[K], 'query'> | undefined }>;
|
|
712
|
+
type TablePolymorphicInsertMetadata<TTable extends ConvexTable<any>> = { [K in keyof TTable['_']['columns'] & string]: TTable['_']['columns'][K] extends {
|
|
713
|
+
__polymorphic: infer TMeta;
|
|
714
|
+
} ? TMeta extends {
|
|
715
|
+
variants: infer TVariants extends Record<string, Record<string, ColumnBuilderBase>>;
|
|
716
|
+
} ? {
|
|
717
|
+
discriminator: K;
|
|
718
|
+
variants: TVariants;
|
|
719
|
+
} : never : never }[keyof TTable['_']['columns'] & string];
|
|
720
|
+
type PolymorphicVariantFieldNames<TVariants extends Record<string, Record<string, ColumnBuilderBase>>> = Extract<TVariants[keyof TVariants & string] extends infer TVariantColumns ? TVariantColumns extends Record<string, ColumnBuilderBase> ? keyof TVariantColumns : never : never, string>;
|
|
721
|
+
type PolymorphicVariantInsertCase<TBase extends Record<string, unknown>, TDiscriminator extends string, TCase extends string, TVariantColumns extends Record<string, ColumnBuilderBase>, TAllGeneratedFields extends string> = Simplify<TBase & { [K in TDiscriminator]: TCase } & { [K in keyof TVariantColumns & string as RequiredKeyOnly<K, TVariantColumns[K]>]: GetColumnData<TVariantColumns[K], 'query'> } & { [K in keyof TVariantColumns & string as OptionalKeyOnly<K, TVariantColumns[K]>]?: GetColumnData<TVariantColumns[K], 'query'> | undefined } & { [K in Exclude<TAllGeneratedFields, keyof TVariantColumns & string>]?: never }>;
|
|
722
|
+
type PolymorphicVariantInsertUnion<TBase extends Record<string, unknown>, TMetadata extends {
|
|
723
|
+
discriminator: string;
|
|
724
|
+
variants: Record<string, Record<string, ColumnBuilderBase>>;
|
|
725
|
+
}> = { [TCase in keyof TMetadata['variants'] & string]: PolymorphicVariantInsertCase<TBase, TMetadata['discriminator'], TCase, TMetadata['variants'][TCase], PolymorphicVariantFieldNames<TMetadata['variants']>> }[keyof TMetadata['variants'] & string];
|
|
726
|
+
type InferPolymorphicInsertModel<TTable extends ConvexTable<any>, TMetadata extends {
|
|
727
|
+
discriminator: string;
|
|
728
|
+
variants: Record<string, Record<string, ColumnBuilderBase>>;
|
|
729
|
+
}> = PolymorphicVariantInsertUnion<InferInsertModelFromColumns<TTable['_']['columns'], TMetadata['discriminator'] | PolymorphicVariantFieldNames<TMetadata['variants']>>, TMetadata>;
|
|
701
730
|
/**
|
|
702
731
|
* Extract insert type from a ConvexTable (excludes system fields).
|
|
703
732
|
* Mirrors Drizzle behavior: required if notNull && no default, otherwise optional.
|
|
@@ -707,7 +736,7 @@ type OptionalKeyOnly<TKey extends string, TColumn extends ColumnBuilder<any, any
|
|
|
707
736
|
* type NewUser = InferInsertModel<typeof users>;
|
|
708
737
|
* // → { name: string }
|
|
709
738
|
*/
|
|
710
|
-
type InferInsertModel<TTable extends ConvexTable<any>> = Simplify<
|
|
739
|
+
type InferInsertModel<TTable extends ConvexTable<any>> = Simplify<[TablePolymorphicInsertMetadata<TTable>] extends [never] ? InferInsertModelFromColumns<TTable['_']['columns']> : InferPolymorphicInsertModel<TTable, Extract<TablePolymorphicInsertMetadata<TTable>, object>>>;
|
|
711
740
|
/**
|
|
712
741
|
* Extract column data type with mode-based handling (Drizzle pattern)
|
|
713
742
|
*
|
|
@@ -727,18 +756,15 @@ type InferInsertModel<TTable extends ConvexTable<any>> = Simplify<{ [K in keyof
|
|
|
727
756
|
* type AgeQuery = GetColumnData<typeof age, 'query'>; // number | null
|
|
728
757
|
* type AgeRaw = GetColumnData<typeof age, 'raw'>; // number
|
|
729
758
|
*/
|
|
730
|
-
type GetColumnData<TColumn extends
|
|
731
|
-
|
|
732
|
-
} ? TType : TColumn['_']['data'] : TColumn['_']['notNull'] extends true ? TColumn['_'] extends {
|
|
733
|
-
$type: infer TType;
|
|
734
|
-
} ? TType : TColumn['_']['data'] : (TColumn['_'] extends {
|
|
759
|
+
type GetColumnData<TColumn extends ColumnBuilderBase, TInferMode extends 'query' | 'raw' = 'query'> = TInferMode extends 'raw' ? ColumnDataWithOverride<TColumn> : TColumn['_']['notNull'] extends true ? ColumnDataWithOverride<TColumn> : ColumnDataWithOverride<TColumn> | null;
|
|
760
|
+
type ColumnDataWithOverride<TColumn extends ColumnBuilderBase> = TColumn['_'] extends {
|
|
735
761
|
$type: infer TType;
|
|
736
|
-
} ? TType
|
|
762
|
+
} ? unknown extends TType ? TColumn['_']['data'] : TType : TColumn['_']['data'];
|
|
737
763
|
type AggregateIndexMap<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = TTableConfig['table'] extends ConvexTable<any, any, any, any, infer TAggregateIndexes extends Record<string, string>> ? TAggregateIndexes : Record<string, string>;
|
|
738
764
|
type AggregateIndexedFieldName<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = Extract<{ [K in keyof AggregateIndexMap<TTableConfig>]: AggregateIndexMap<TTableConfig>[K] }[keyof AggregateIndexMap<TTableConfig>], string>;
|
|
739
765
|
type AggregateScalarFieldName<TTableConfig extends TableRelationalConfig> = Extract<keyof TTableConfig['table']['_']['columns'], string>;
|
|
740
766
|
type AggregateWhereFieldName<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = AggregateIndexedFieldName<TTableConfig>;
|
|
741
|
-
type AggregateWhereFieldValue<TTableConfig extends TableRelationalConfig, TFieldName extends string> = TFieldName extends keyof TTableConfig['table']['_']['columns'] ? TTableConfig['table']['_']['columns'][TFieldName] extends
|
|
767
|
+
type AggregateWhereFieldValue<TTableConfig extends TableRelationalConfig, TFieldName extends string> = TFieldName extends keyof TTableConfig['table']['_']['columns'] ? TTableConfig['table']['_']['columns'][TFieldName] extends ColumnBuilderBase ? GetColumnData<TTableConfig['table']['_']['columns'][TFieldName], 'query'> : unknown : unknown;
|
|
742
768
|
type AggregateWhereFieldFilter<TValue> = TValue | {
|
|
743
769
|
eq?: TValue | undefined;
|
|
744
770
|
in?: readonly TValue[] | undefined;
|
|
@@ -754,16 +780,6 @@ type AggregateNoScanWhere<TTableConfig extends TableRelationalConfig = TableRela
|
|
|
754
780
|
OR?: AggregateNoScanWhereBase<TTableConfig>[] | undefined;
|
|
755
781
|
}>;
|
|
756
782
|
type AggregateNoScanWhereArg<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = [AggregateWhereFieldName<TTableConfig>] extends [never] ? never : AggregateNoScanWhere<TTableConfig>;
|
|
757
|
-
type OneRelationName<TTableConfig extends TableRelationalConfig = TableRelationalConfig> = Extract<{ [K in keyof TTableConfig['relations']]: TTableConfig['relations'][K] extends One<any, any> ? K : never }[keyof TTableConfig['relations']], string>;
|
|
758
|
-
type PolymorphicZodSchema$1 = z.ZodDiscriminatedUnion<any, any>;
|
|
759
|
-
type PolymorphicDiscriminatorFromSchema$1<TSchema extends PolymorphicZodSchema$1 = PolymorphicZodSchema$1> = TSchema extends z.ZodDiscriminatedUnion<any, infer TDisc extends string> ? TDisc : string;
|
|
760
|
-
type PolymorphicCaseLiteralFromSchema$1<TSchema extends PolymorphicZodSchema$1 = PolymorphicZodSchema$1, TDiscriminator extends string = string> = Extract<z.output<TSchema> extends Record<TDiscriminator, infer TValue> ? TValue : never, string>;
|
|
761
|
-
type PolymorphicQueryConfig<TTableConfig extends TableRelationalConfig = TableRelationalConfig, TSchema extends PolymorphicZodSchema$1 = PolymorphicZodSchema$1, TDiscriminator extends string = PolymorphicDiscriminatorFromSchema$1<TSchema>> = {
|
|
762
|
-
schema: TSchema;
|
|
763
|
-
discriminator: TDiscriminator;
|
|
764
|
-
cases: Record<PolymorphicCaseLiteralFromSchema$1<TSchema, TDiscriminator>, OneRelationName<TTableConfig>>;
|
|
765
|
-
as?: string | undefined;
|
|
766
|
-
};
|
|
767
783
|
/**
|
|
768
784
|
* Query configuration for findMany/findFirst
|
|
769
785
|
*
|
|
@@ -788,6 +804,10 @@ type DBQueryConfig<TRelationType extends 'one' | 'many' = 'one' | 'many', _TIsRo
|
|
|
788
804
|
}, TTableConfig['relations'] & {
|
|
789
805
|
_count?: unknown;
|
|
790
806
|
}> | undefined;
|
|
807
|
+
/**
|
|
808
|
+
* Auto-include one() relations for discriminator-backed tables.
|
|
809
|
+
*/
|
|
810
|
+
withVariants?: true | undefined;
|
|
791
811
|
/**
|
|
792
812
|
* Extra computed fields (post-fetch, computed in JS at runtime)
|
|
793
813
|
*/
|
|
@@ -829,10 +849,6 @@ type DBQueryConfig<TRelationType extends 'one' | 'many' = 'one' | 'many', _TIsRo
|
|
|
829
849
|
* Stream-backed advanced query pipeline.
|
|
830
850
|
*/
|
|
831
851
|
pipeline?: _TIsRoot extends true ? FindManyPipelineConfig<TSchema, TTableConfig> : never;
|
|
832
|
-
/**
|
|
833
|
-
* Synthesize a discriminated-union relation field from one() cases.
|
|
834
|
-
*/
|
|
835
|
-
polymorphic?: PolymorphicQueryConfig<TTableConfig> | undefined;
|
|
836
852
|
/**
|
|
837
853
|
* Key-based page boundaries.
|
|
838
854
|
*/
|
|
@@ -1158,6 +1174,30 @@ type DBQueryConfigOrderBy<TTableConfig extends TableRelationalConfig> = DBQueryC
|
|
|
1158
1174
|
*/
|
|
1159
1175
|
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] };
|
|
1160
1176
|
type TableColumns<TTableConfig extends TableRelationalConfig> = TTableConfig['table']['_']['columns'] & SystemFields<TTableConfig['table']['_']['name']> & SystemFieldAliases<TTableConfig['table']['_']['name'], TTableConfig['table']['_']['columns']>;
|
|
1177
|
+
type TablePolymorphicMetadataFromColumn<TColumn, TDiscriminator extends string> = TColumn extends {
|
|
1178
|
+
__polymorphic: infer TMeta;
|
|
1179
|
+
} ? TMeta extends {
|
|
1180
|
+
as: infer TAlias extends string;
|
|
1181
|
+
variants: infer TVariants extends Record<string, Record<string, ColumnBuilderBase>>;
|
|
1182
|
+
} ? {
|
|
1183
|
+
as: TAlias;
|
|
1184
|
+
discriminator: TDiscriminator;
|
|
1185
|
+
variants: TVariants;
|
|
1186
|
+
} : never : never;
|
|
1187
|
+
type TablePolymorphicMetadata<TTableConfig extends TableRelationalConfig> = { [K in Extract<keyof TTableConfig['table']['_']['columns'], string>]: TablePolymorphicMetadataFromColumn<TTableConfig['table']['_']['columns'][K], K> }[Extract<keyof TTableConfig['table']['_']['columns'], string>];
|
|
1188
|
+
type PolymorphicResultFromMetadata<TMetadata> = TMetadata extends {
|
|
1189
|
+
as: infer TAlias extends string;
|
|
1190
|
+
discriminator: infer TDiscriminator extends string;
|
|
1191
|
+
variants: infer TVariants extends Record<string, Record<string, ColumnBuilderBase>>;
|
|
1192
|
+
} ? { [TCase in keyof TVariants & string]: { [K in TDiscriminator]: TCase } & { [K in TAlias]: InferModelFromColumns<TVariants[TCase]> } }[keyof TVariants & string] : {};
|
|
1193
|
+
type TablePolymorphicResult<TTableConfig extends TableRelationalConfig> = [TablePolymorphicMetadata<TTableConfig>] extends [never] ? {} : PolymorphicResultFromMetadata<TablePolymorphicMetadata<TTableConfig>>;
|
|
1194
|
+
type RelationNames<TTableConfig extends TableRelationalConfig> = Extract<keyof TTableConfig['relations'], string>;
|
|
1195
|
+
type OneRelationNames<TTableConfig extends TableRelationalConfig> = { [K in RelationNames<TTableConfig>]: TTableConfig['relations'][K] extends One<any, any> ? K : never }[RelationNames<TTableConfig>];
|
|
1196
|
+
type WithVariantsAutoWithConfig<TTableConfig extends TableRelationalConfig, _TSelection> = { [K in OneRelationNames<TTableConfig>]: true };
|
|
1197
|
+
type SelectedTableResult<TTableConfig extends TableRelationalConfig, TFullSelection extends Record<string, unknown>> = InferRelationalQueryTableResult<InferModelFromColumns<TableColumns<TTableConfig>>, TFullSelection['columns'] extends Record<string, unknown> ? TFullSelection['columns'] : 'Full'>;
|
|
1198
|
+
type TablePolymorphicResultForSelection<TTableConfig extends TableRelationalConfig, TFullSelection extends Record<string, unknown>> = [TablePolymorphicMetadata<TTableConfig>] extends [never] ? {} : TablePolymorphicMetadata<TTableConfig> extends {
|
|
1199
|
+
discriminator: infer TDiscriminator extends string;
|
|
1200
|
+
} ? TDiscriminator extends keyof SelectedTableResult<TTableConfig, TFullSelection> ? PolymorphicResultFromMetadata<TablePolymorphicMetadata<TTableConfig>> : {} : {};
|
|
1161
1201
|
type PaginatedResult<T> = {
|
|
1162
1202
|
page: T[];
|
|
1163
1203
|
continueCursor: string | null;
|
|
@@ -1165,11 +1205,7 @@ type PaginatedResult<T> = {
|
|
|
1165
1205
|
pageStatus?: 'SplitRecommended' | 'SplitRequired';
|
|
1166
1206
|
splitCursor?: string;
|
|
1167
1207
|
};
|
|
1168
|
-
type BuildQueryResult<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TFullSelection> = Equal<TFullSelection, true> extends true ? InferModelFromColumns<TableColumns<TTableConfig>> : TFullSelection extends Record<string, unknown> ? Simplify<
|
|
1169
|
-
polymorphic: infer TPolymorphicConfig;
|
|
1170
|
-
} ? TPolymorphicConfig extends {
|
|
1171
|
-
schema: infer TPolymorphicSchema extends z.ZodTypeAny;
|
|
1172
|
-
} ? z.output<TPolymorphicSchema> : {} : {}) & (TFullSelection extends {
|
|
1208
|
+
type BuildQueryResult<TSchema extends TablesRelationalConfig, TTableConfig extends TableRelationalConfig, TFullSelection> = Equal<TFullSelection, true> extends true ? Simplify<InferModelFromColumns<TableColumns<TTableConfig>> & TablePolymorphicResult<TTableConfig>> : TFullSelection extends Record<string, unknown> ? Simplify<SelectedTableResult<TTableConfig, TFullSelection> & (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['withVariants'] extends true ? BuildRelationResult<TSchema, WithVariantsAutoWithConfig<TTableConfig, TFullSelection>, TTableConfig['relations']> : {}) & TablePolymorphicResultForSelection<TTableConfig, TFullSelection> & (TFullSelection extends {
|
|
1173
1209
|
vectorSearch: infer TVectorSearch;
|
|
1174
1210
|
} ? [TVectorSearch] extends [undefined] ? {} : {
|
|
1175
1211
|
_score?: number;
|
|
@@ -1198,7 +1234,7 @@ type BuildRelationResult<TSchema extends TablesRelationalConfig, TInclude extend
|
|
|
1198
1234
|
* CRITICAL: No extends constraint to avoid type widening (convex-ents pattern)
|
|
1199
1235
|
* CRITICAL: Uses Merge instead of & to preserve NotNull phantom type brands
|
|
1200
1236
|
*/
|
|
1201
|
-
type InferModelFromColumns<TColumns> = TColumns extends Record<string,
|
|
1237
|
+
type InferModelFromColumns<TColumns> = TColumns extends Record<string, ColumnBuilderBase> ? Simplify<{ [K in keyof TColumns]: GetColumnData<TColumns[K], 'query'> }> : never;
|
|
1202
1238
|
/**
|
|
1203
1239
|
* Extract union of all values from an object type
|
|
1204
1240
|
* Pattern from Drizzle: drizzle-orm/src/relations.ts:145
|
|
@@ -1237,14 +1273,14 @@ type MutationReturningCountSelection = Record<string, true | {
|
|
|
1237
1273
|
where?: Record<string, unknown> | undefined;
|
|
1238
1274
|
} | undefined>;
|
|
1239
1275
|
type ReturningSelection<TTable extends ConvexTable<any>> = Record<string, TableColumnsForTable<TTable>[keyof TableColumnsForTable<TTable>] | MutationReturningCountSelection>;
|
|
1240
|
-
type ReturningResult<TSelection extends Record<string, unknown>> = Simplify<{ [K in keyof TSelection as K extends '_count' ? never : K]: TSelection[K] extends
|
|
1276
|
+
type ReturningResult<TSelection extends Record<string, unknown>> = Simplify<{ [K in keyof TSelection as K extends '_count' ? never : K]: TSelection[K] extends ColumnBuilderBase ? GetColumnData<TSelection[K], 'query'> : never } & (TSelection extends {
|
|
1241
1277
|
_count: infer TCount;
|
|
1242
1278
|
} ? TCount extends Record<string, unknown> ? {
|
|
1243
1279
|
_count: { [K in NonUndefinedKeysOnly$1<TCount> & string]: number };
|
|
1244
1280
|
} : {} : {})>;
|
|
1245
1281
|
type ReturningAll<TTable extends ConvexTable<any>> = InferSelectModel<TTable>;
|
|
1246
1282
|
type MutationReturning = true | Record<string, unknown> | undefined;
|
|
1247
|
-
type MutationResult<TTable extends ConvexTable<any>, TReturning extends MutationReturning> = TReturning extends true ? ReturningAll<TTable>[] : TReturning extends Record<string,
|
|
1283
|
+
type MutationResult<TTable extends ConvexTable<any>, TReturning extends MutationReturning> = TReturning extends true ? ReturningAll<TTable>[] : TReturning extends Record<string, ColumnBuilderBase> ? ReturningResult<TReturning>[] : undefined;
|
|
1248
1284
|
type MutationPaginateConfig = {
|
|
1249
1285
|
cursor: string | null;
|
|
1250
1286
|
limit: number;
|
|
@@ -1265,9 +1301,78 @@ type MutationPaginatedResult<TTable extends ConvexTable<any>, TReturning extends
|
|
|
1265
1301
|
})>;
|
|
1266
1302
|
type MutationExecuteResult<TTable extends ConvexTable<any>, TReturning extends MutationReturning, TMode extends MutationExecutionMode> = TMode extends 'paged' ? MutationPaginatedResult<TTable, TReturning> : MutationResult<TTable, TReturning>;
|
|
1267
1303
|
type InsertValue<TTable extends ConvexTable<any>> = InferInsertModel<TTable>;
|
|
1268
|
-
type UpdateSetValue<TColumn extends
|
|
1304
|
+
type UpdateSetValue<TColumn extends ColumnBuilderBase> = GetColumnData<TColumn, 'query'> | (TColumn['_']['notNull'] extends true ? never : UnsetToken) | undefined;
|
|
1269
1305
|
type UpdateSet<TTable extends ConvexTable<any>> = Simplify<{ [K in keyof TTable['_']['columns'] & string]?: UpdateSetValue<TTable['_']['columns'][K]> }>;
|
|
1270
1306
|
//#endregion
|
|
1307
|
+
//#region src/orm/builders/convex-column-builder.d.ts
|
|
1308
|
+
/**
|
|
1309
|
+
* Convex-specific column builder base class
|
|
1310
|
+
*
|
|
1311
|
+
* All Convex column builders (ConvexTextBuilder, ConvexIntegerBuilder, etc.)
|
|
1312
|
+
* inherit from this class.
|
|
1313
|
+
*/
|
|
1314
|
+
declare abstract class ConvexColumnBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends ColumnBuilder<T, TRuntimeConfig, {
|
|
1315
|
+
dialect: 'convex';
|
|
1316
|
+
}> {
|
|
1317
|
+
static readonly [entityKind]: string;
|
|
1318
|
+
/**
|
|
1319
|
+
* Build method - compiles builder to Convex validator
|
|
1320
|
+
*
|
|
1321
|
+
* Subclasses implement this to produce the correct validator:
|
|
1322
|
+
* - text() → v.string() or v.optional(v.string())
|
|
1323
|
+
* - integer() → v.number() or v.optional(v.number())
|
|
1324
|
+
* - etc.
|
|
1325
|
+
*
|
|
1326
|
+
* @returns Convex validator for this column
|
|
1327
|
+
*/
|
|
1328
|
+
abstract build(): Validator<any, any, any>;
|
|
1329
|
+
}
|
|
1330
|
+
//#endregion
|
|
1331
|
+
//#region src/orm/builders/text.d.ts
|
|
1332
|
+
/**
|
|
1333
|
+
* Initial type for ConvexTextBuilder
|
|
1334
|
+
* Used in factory function return types
|
|
1335
|
+
* Matches Drizzle's pattern with all required properties
|
|
1336
|
+
*/
|
|
1337
|
+
type ConvexTextBuilderInitial<TName extends string> = ConvexTextBuilder<{
|
|
1338
|
+
name: TName;
|
|
1339
|
+
dataType: 'string';
|
|
1340
|
+
columnType: 'ConvexText';
|
|
1341
|
+
data: string;
|
|
1342
|
+
driverParam: string;
|
|
1343
|
+
enumValues: undefined;
|
|
1344
|
+
}>;
|
|
1345
|
+
/**
|
|
1346
|
+
* Text column builder class
|
|
1347
|
+
* Compiles to v.string() or v.optional(v.string())
|
|
1348
|
+
*/
|
|
1349
|
+
declare class ConvexTextBuilder<T extends ColumnBuilderBaseConfig<'string', 'ConvexText'>> extends ConvexColumnBuilder<T> {
|
|
1350
|
+
static readonly [entityKind]: string;
|
|
1351
|
+
constructor(name: T['name']);
|
|
1352
|
+
/**
|
|
1353
|
+
* Expose Convex validator for schema integration
|
|
1354
|
+
*/
|
|
1355
|
+
get convexValidator(): Validator<any, any, any>;
|
|
1356
|
+
/**
|
|
1357
|
+
* Compile to Convex validator
|
|
1358
|
+
* .notNull() → v.string()
|
|
1359
|
+
* nullable → v.optional(v.string())
|
|
1360
|
+
*/
|
|
1361
|
+
build(): Validator<any, any, any>;
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* text() factory function
|
|
1365
|
+
*
|
|
1366
|
+
* Creates a text column builder.
|
|
1367
|
+
* Supports both named and unnamed columns (for later binding).
|
|
1368
|
+
*
|
|
1369
|
+
* @example
|
|
1370
|
+
* text() → unnamed column
|
|
1371
|
+
* text('col_name') → named column
|
|
1372
|
+
*/
|
|
1373
|
+
declare function text(): ConvexTextBuilderInitial<''>;
|
|
1374
|
+
declare function text<TName extends string>(name: TName): ConvexTextBuilderInitial<TName>;
|
|
1375
|
+
//#endregion
|
|
1271
1376
|
//#region src/orm/constraints.d.ts
|
|
1272
1377
|
type ConvexConstraintColumn = ColumnBuilderBase;
|
|
1273
1378
|
type ConvexForeignKeyColumns = [ConvexConstraintColumn, ...ConvexConstraintColumn[]];
|
|
@@ -1552,6 +1657,31 @@ declare class RlsPolicy<TCtx = any, TTable = ConvexTableWithColumns<any>> implem
|
|
|
1552
1657
|
declare function rlsPolicy<TCtx = any, TTable = ConvexTableWithColumns<any>>(name: string, config?: RlsPolicyConfig<TCtx, TTable>): RlsPolicy<TCtx, TTable>;
|
|
1553
1658
|
//#endregion
|
|
1554
1659
|
//#region src/orm/table.d.ts
|
|
1660
|
+
declare const DEFAULT_POLYMORPHIC_ALIAS: "details";
|
|
1661
|
+
type PolymorphicVariantDefinitions = Record<string, Record<string, ColumnBuilderBase>>;
|
|
1662
|
+
type PolymorphicDiscriminatorValue<TVariants extends PolymorphicVariantDefinitions> = Extract<keyof TVariants, string>;
|
|
1663
|
+
type PolymorphicTypeMetadata<TVariants extends PolymorphicVariantDefinitions = PolymorphicVariantDefinitions, TAlias extends string = string> = {
|
|
1664
|
+
as: TAlias;
|
|
1665
|
+
variants: TVariants;
|
|
1666
|
+
};
|
|
1667
|
+
type OverrideColumnMeta<TColumn extends ColumnBuilderBase, TOverrides extends object> = TColumn extends {
|
|
1668
|
+
_: infer TMeta extends object;
|
|
1669
|
+
} ? Omit<TColumn, '_'> & {
|
|
1670
|
+
_: Omit<TMeta, keyof TOverrides> & TOverrides;
|
|
1671
|
+
} : TColumn;
|
|
1672
|
+
type PolymorphicGeneratedColumn<TColumn extends ColumnBuilderBase> = OverrideColumnMeta<TColumn, {
|
|
1673
|
+
hasDefault: false;
|
|
1674
|
+
notNull: false;
|
|
1675
|
+
}>;
|
|
1676
|
+
type PolymorphicDiscriminatorColumn<TVariants extends PolymorphicVariantDefinitions = PolymorphicVariantDefinitions, TAlias extends string = typeof DEFAULT_POLYMORPHIC_ALIAS> = $Type<NotNull<ConvexTextBuilderInitial<''>>, PolymorphicDiscriminatorValue<TVariants>> & {
|
|
1677
|
+
__polymorphic: PolymorphicTypeMetadata<TVariants, TAlias>;
|
|
1678
|
+
};
|
|
1679
|
+
type ExtractPolymorphicVariants<TColumn> = TColumn extends {
|
|
1680
|
+
__polymorphic: infer TMeta;
|
|
1681
|
+
} ? TMeta extends PolymorphicTypeMetadata<infer TVariants extends PolymorphicVariantDefinitions, string> ? TVariants : never : never;
|
|
1682
|
+
type ExtractPolymorphicGeneratedColumns<TColumns> = SimplifyObject<UnionToIntersection<{ [K in keyof TColumns]: ExtractPolymorphicVariants<TColumns[K]> extends infer TVariants ? [TVariants] extends [never] ? {} : { [V in keyof TVariants & string]: { [F in keyof TVariants[V] & string]: TVariants[V][F] extends ColumnBuilderBase ? PolymorphicGeneratedColumn<TVariants[V][F]> : never } }[keyof TVariants & string] : {} }[keyof TColumns]>>;
|
|
1683
|
+
type MergeColumnObjects<TLeft, TRight> = { [K in keyof TLeft | keyof TRight]: K extends keyof TRight ? TRight[K] : K extends keyof TLeft ? TLeft[K] : never };
|
|
1684
|
+
type ExpandTableColumns<TColumns> = SimplifyObject<MergeColumnObjects<TColumns, ExtractPolymorphicGeneratedColumns<TColumns>>>;
|
|
1555
1685
|
/**
|
|
1556
1686
|
* Configuration for a Convex table
|
|
1557
1687
|
* Only supports column builders (text(), integer(), etc.)
|
|
@@ -1568,6 +1698,14 @@ type ColumnsWithTableName<TColumns, TName extends string> = { [K in keyof TColum
|
|
|
1568
1698
|
};
|
|
1569
1699
|
} : TColumns[K] };
|
|
1570
1700
|
type ColumnsWithSystemFields<TColumns, TName extends string> = ColumnsWithTableName<TColumns, TName> & (TColumns extends Record<string, unknown> ? SystemFieldsWithAliases<TName, TColumns> : SystemFieldsWithAliases<TName>);
|
|
1701
|
+
type DiscriminatorBuilderConfig<TVariants extends PolymorphicVariantDefinitions = PolymorphicVariantDefinitions, TAlias extends string = typeof DEFAULT_POLYMORPHIC_ALIAS> = {
|
|
1702
|
+
as?: TAlias;
|
|
1703
|
+
variants: TVariants;
|
|
1704
|
+
};
|
|
1705
|
+
declare function discriminator<const TVariants extends PolymorphicVariantDefinitions, const TAlias extends string>(config: DiscriminatorBuilderConfig<TVariants, TAlias> & {
|
|
1706
|
+
as: TAlias;
|
|
1707
|
+
}): PolymorphicDiscriminatorColumn<TVariants, TAlias>;
|
|
1708
|
+
declare function discriminator<const TVariants extends PolymorphicVariantDefinitions>(config: DiscriminatorBuilderConfig<TVariants>): PolymorphicDiscriminatorColumn<TVariants, typeof DEFAULT_POLYMORPHIC_ALIAS>;
|
|
1571
1709
|
type ConvexTableExtraConfigValue = ConvexIndexBuilder | ConvexAggregateIndexBuilder | ConvexRankIndexBuilder | ConvexSearchIndexBuilder | ConvexVectorIndexBuilder | ConvexForeignKeyBuilder | ConvexCheckBuilder | ConvexUniqueConstraintBuilder | ConvexDeletionBuilder | RlsPolicy;
|
|
1572
1710
|
type ConvexTableExtraConfig = Record<string, ConvexTableExtraConfigValue>;
|
|
1573
1711
|
type UnionToIntersection<T> = (T extends unknown ? (arg: T) => void : never) extends ((arg: infer U) => void) ? U : never;
|
|
@@ -1694,6 +1832,7 @@ interface ConvexTable<T extends TableConfig, Indexes extends GenericTableIndexes
|
|
|
1694
1832
|
[RlsPolicies]: RlsPolicy[];
|
|
1695
1833
|
[EnableRLS]: boolean;
|
|
1696
1834
|
[TableDeleteConfig]?: OrmTableDeleteConfig;
|
|
1835
|
+
[TablePolymorphic]?: readonly TablePolymorphicConfigRuntime[];
|
|
1697
1836
|
}
|
|
1698
1837
|
/**
|
|
1699
1838
|
* ConvexTable with columns as properties
|
|
@@ -1733,9 +1872,9 @@ type ConvexTableWithColumns<T extends TableConfig, Indexes extends GenericTableI
|
|
|
1733
1872
|
* index('by_email').on(t.email),
|
|
1734
1873
|
* ]);
|
|
1735
1874
|
*/
|
|
1736
|
-
type ConvexTableFnInternal = <TName extends string, TColumns, TExtraConfig extends ConvexTableExtraConfigValue[] | ConvexTableExtraConfig | undefined = undefined>(name: TName, columns: TColumns, extraConfig?: (self: ColumnsWithSystemFields<TColumns
|
|
1875
|
+
type ConvexTableFnInternal = <TName extends string, TColumns, TExtraConfig extends ConvexTableExtraConfigValue[] | ConvexTableExtraConfig | undefined = undefined>(name: TName, columns: TColumns, extraConfig?: (self: ColumnsWithSystemFields<ExpandTableColumns<TColumns>, TName>) => TExtraConfig) => ConvexTableWithColumns<{
|
|
1737
1876
|
name: TName;
|
|
1738
|
-
columns: ColumnsWithTableName<TColumns
|
|
1877
|
+
columns: ColumnsWithTableName<ExpandTableColumns<TColumns>, TName>;
|
|
1739
1878
|
}, InferDbIndexesFromExtraConfig<TExtraConfig>, InferSearchIndexesFromExtraConfig<TExtraConfig>, InferVectorIndexesFromExtraConfig<TExtraConfig>, NormalizeAggregateIndexMap<InferredAggregateIndexesFromExtraConfig<TExtraConfig>>>;
|
|
1740
1879
|
interface ConvexTableFn extends ConvexTableFnInternal {
|
|
1741
1880
|
withRLS: ConvexTableFnInternal;
|
|
@@ -1857,6 +1996,7 @@ declare class Many<TTargetTableName extends string> extends Relation<TTargetTabl
|
|
|
1857
1996
|
interface TableRelationalConfig {
|
|
1858
1997
|
defaults?: OrmRuntimeDefaults;
|
|
1859
1998
|
name: string;
|
|
1999
|
+
polymorphic?: readonly TablePolymorphicConfigRuntime[];
|
|
1860
2000
|
relations: RelationsRecord;
|
|
1861
2001
|
strict?: boolean;
|
|
1862
2002
|
table: SchemaEntry;
|
|
@@ -1967,30 +2107,6 @@ type CountBackfillStatusArgs = {
|
|
|
1967
2107
|
indexName?: string;
|
|
1968
2108
|
};
|
|
1969
2109
|
//#endregion
|
|
1970
|
-
//#region src/orm/builders/convex-column-builder.d.ts
|
|
1971
|
-
/**
|
|
1972
|
-
* Convex-specific column builder base class
|
|
1973
|
-
*
|
|
1974
|
-
* All Convex column builders (ConvexTextBuilder, ConvexIntegerBuilder, etc.)
|
|
1975
|
-
* inherit from this class.
|
|
1976
|
-
*/
|
|
1977
|
-
declare abstract class ConvexColumnBuilder<T extends ColumnBuilderBaseConfig<ColumnDataType, string> = ColumnBuilderBaseConfig<ColumnDataType, string>, TRuntimeConfig extends object = object> extends ColumnBuilder<T, TRuntimeConfig, {
|
|
1978
|
-
dialect: 'convex';
|
|
1979
|
-
}> {
|
|
1980
|
-
static readonly [entityKind]: string;
|
|
1981
|
-
/**
|
|
1982
|
-
* Build method - compiles builder to Convex validator
|
|
1983
|
-
*
|
|
1984
|
-
* Subclasses implement this to produce the correct validator:
|
|
1985
|
-
* - text() → v.string() or v.optional(v.string())
|
|
1986
|
-
* - integer() → v.number() or v.optional(v.number())
|
|
1987
|
-
* - etc.
|
|
1988
|
-
*
|
|
1989
|
-
* @returns Convex validator for this column
|
|
1990
|
-
*/
|
|
1991
|
-
abstract build(): Validator<any, any, any>;
|
|
1992
|
-
}
|
|
1993
|
-
//#endregion
|
|
1994
2110
|
//#region src/orm/builders/bigint.d.ts
|
|
1995
2111
|
/**
|
|
1996
2112
|
* Initial type for ConvexBigIntBuilder
|
|
@@ -2263,51 +2379,6 @@ declare class ConvexNumberBuilder<T extends ColumnBuilderBaseConfig<'number', 'C
|
|
|
2263
2379
|
declare function integer(): ConvexNumberBuilderInitial<''>;
|
|
2264
2380
|
declare function integer<TName extends string>(name: TName): ConvexNumberBuilderInitial<TName>;
|
|
2265
2381
|
//#endregion
|
|
2266
|
-
//#region src/orm/builders/text.d.ts
|
|
2267
|
-
/**
|
|
2268
|
-
* Initial type for ConvexTextBuilder
|
|
2269
|
-
* Used in factory function return types
|
|
2270
|
-
* Matches Drizzle's pattern with all required properties
|
|
2271
|
-
*/
|
|
2272
|
-
type ConvexTextBuilderInitial<TName extends string> = ConvexTextBuilder<{
|
|
2273
|
-
name: TName;
|
|
2274
|
-
dataType: 'string';
|
|
2275
|
-
columnType: 'ConvexText';
|
|
2276
|
-
data: string;
|
|
2277
|
-
driverParam: string;
|
|
2278
|
-
enumValues: undefined;
|
|
2279
|
-
}>;
|
|
2280
|
-
/**
|
|
2281
|
-
* Text column builder class
|
|
2282
|
-
* Compiles to v.string() or v.optional(v.string())
|
|
2283
|
-
*/
|
|
2284
|
-
declare class ConvexTextBuilder<T extends ColumnBuilderBaseConfig<'string', 'ConvexText'>> extends ConvexColumnBuilder<T> {
|
|
2285
|
-
static readonly [entityKind]: string;
|
|
2286
|
-
constructor(name: T['name']);
|
|
2287
|
-
/**
|
|
2288
|
-
* Expose Convex validator for schema integration
|
|
2289
|
-
*/
|
|
2290
|
-
get convexValidator(): Validator<any, any, any>;
|
|
2291
|
-
/**
|
|
2292
|
-
* Compile to Convex validator
|
|
2293
|
-
* .notNull() → v.string()
|
|
2294
|
-
* nullable → v.optional(v.string())
|
|
2295
|
-
*/
|
|
2296
|
-
build(): Validator<any, any, any>;
|
|
2297
|
-
}
|
|
2298
|
-
/**
|
|
2299
|
-
* text() factory function
|
|
2300
|
-
*
|
|
2301
|
-
* Creates a text column builder.
|
|
2302
|
-
* Supports both named and unnamed columns (for later binding).
|
|
2303
|
-
*
|
|
2304
|
-
* @example
|
|
2305
|
-
* text() → unnamed column
|
|
2306
|
-
* text('col_name') → named column
|
|
2307
|
-
*/
|
|
2308
|
-
declare function text(): ConvexTextBuilderInitial<''>;
|
|
2309
|
-
declare function text<TName extends string>(name: TName): ConvexTextBuilderInitial<TName>;
|
|
2310
|
-
//#endregion
|
|
2311
2382
|
//#region src/orm/builders/text-enum.d.ts
|
|
2312
2383
|
type EnumValues = readonly [string, ...string[]];
|
|
2313
2384
|
type ConvexTextEnumBuilderInitial<TName extends string, TValues extends EnumValues> = ConvexTextEnumBuilder<{
|
|
@@ -2773,7 +2844,8 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
|
|
|
2773
2844
|
private _mergeSearchFiltersWithWhereEq;
|
|
2774
2845
|
private _applyRelationsFilterToRows;
|
|
2775
2846
|
private _resolvePolymorphicFinalizeState;
|
|
2776
|
-
private
|
|
2847
|
+
private _resolveWithVariantsState;
|
|
2848
|
+
private _assertPolymorphicAliasCollisions;
|
|
2777
2849
|
private _synthesizePolymorphicRows;
|
|
2778
2850
|
private _finalizeRows;
|
|
2779
2851
|
private _getSchemaDefinitionOrThrow;
|
|
@@ -2912,35 +2984,7 @@ declare class GelRelationalQuery<TSchema extends TablesRelationalConfig, TTableC
|
|
|
2912
2984
|
}
|
|
2913
2985
|
//#endregion
|
|
2914
2986
|
//#region src/orm/query-builder.d.ts
|
|
2915
|
-
type
|
|
2916
|
-
relationType: 'one';
|
|
2917
|
-
} ? K : never }[keyof TTableConfig['relations']], string>;
|
|
2918
|
-
type PolymorphicZodSchema = z.ZodDiscriminatedUnion<any, any>;
|
|
2919
|
-
type PolymorphicDiscriminatorFromSchema<TSchema extends PolymorphicZodSchema = PolymorphicZodSchema> = TSchema extends z.ZodDiscriminatedUnion<any, infer TDisc extends string> ? TDisc : string;
|
|
2920
|
-
type PolymorphicCaseLiteralFromSchema<TSchema extends PolymorphicZodSchema = PolymorphicZodSchema, TDiscriminator extends string = string> = Extract<z.output<TSchema> extends Record<TDiscriminator, infer TValue> ? TValue : never, string>;
|
|
2921
|
-
type IsWidenedString<T extends string> = string extends T ? true : false;
|
|
2922
|
-
type ValidatePolymorphicConfig<TConfig, TTableConfig extends TableRelationalConfig> = TConfig extends {
|
|
2923
|
-
polymorphic: infer TPolymorphic;
|
|
2924
|
-
} ? [TPolymorphic] extends [undefined] ? unknown : TPolymorphic extends {
|
|
2925
|
-
schema: infer TSchema;
|
|
2926
|
-
discriminator: infer TDiscriminator;
|
|
2927
|
-
cases: infer TCases;
|
|
2928
|
-
} ? TSchema extends PolymorphicZodSchema ? TDiscriminator extends string ? TCases extends Record<string, OneRelationNameByType<TTableConfig>> ? [PolymorphicCaseLiteralFromSchema<TSchema, PolymorphicDiscriminatorFromSchema<TSchema>>] extends [Extract<keyof TCases, string>] ? [Extract<keyof TCases, string>] extends [PolymorphicCaseLiteralFromSchema<TSchema, PolymorphicDiscriminatorFromSchema<TSchema>>] ? IsWidenedString<TDiscriminator> extends true ? unknown : TDiscriminator extends PolymorphicDiscriminatorFromSchema<TSchema> ? unknown : {
|
|
2929
|
-
__polymorphicDiscriminatorMustMatchSchema__: never;
|
|
2930
|
-
} : {
|
|
2931
|
-
__polymorphicCasesCannotContainUnknownLiterals__: never;
|
|
2932
|
-
} : {
|
|
2933
|
-
__polymorphicCasesMustCoverAllDiscriminatorLiterals__: never;
|
|
2934
|
-
} : {
|
|
2935
|
-
__polymorphicCasesMustMapToOneRelations__: never;
|
|
2936
|
-
} : {
|
|
2937
|
-
__polymorphicDiscriminatorMustBeString__: never;
|
|
2938
|
-
} : {
|
|
2939
|
-
__polymorphicSchemaMustBeDiscriminatedUnion__: never;
|
|
2940
|
-
} : {
|
|
2941
|
-
__polymorphicConfigInvalid__: never;
|
|
2942
|
-
} : unknown;
|
|
2943
|
-
type EnforcedConfig<TConfig, TTableConfig extends TableRelationalConfig, THasIndex extends boolean = false> = ValidatePolymorphicConfig<TConfig, TTableConfig> & EnforceVectorSearchConstraints<EnforceSearchConstraints<EnforceCursorMaxScan<EnforceNoAllowFullScanWhenIndexed<EnforceWithIndexForWhere<TConfig, TTableConfig, THasIndex>, THasIndex>>, TTableConfig>, TTableConfig>;
|
|
2987
|
+
type EnforcedConfig<TConfig, TTableConfig extends TableRelationalConfig, THasIndex extends boolean = false> = EnforceVectorSearchConstraints<EnforceSearchConstraints<EnforceCursorMaxScan<EnforceNoAllowFullScanWhenIndexed<EnforceWithIndexForWhere<TConfig, TTableConfig, THasIndex>, THasIndex>>, TTableConfig>, TTableConfig>;
|
|
2944
2988
|
type DisallowWithIndexSearchOrVector<THasIndex extends boolean> = THasIndex extends true ? {
|
|
2945
2989
|
search?: never;
|
|
2946
2990
|
vectorSearch?: never;
|
|
@@ -3164,14 +3208,6 @@ declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TTa
|
|
|
3164
3208
|
* });
|
|
3165
3209
|
*/
|
|
3166
3210
|
findMany(config: RelationCountWithConfig<TSchema, TTableConfig> & EnforcedConfig<RelationCountWithConfig<TSchema, TTableConfig>, TTableConfig, THasIndex> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, FindManyResult<TSchema, TTableConfig, RelationCountWithConfig<TSchema, TTableConfig>>>;
|
|
3167
|
-
findMany<TPolymorphicSchema extends PolymorphicZodSchema, TPolymorphicDiscriminator extends PolymorphicDiscriminatorFromSchema<TPolymorphicSchema>, TPolymorphicCases extends Record<PolymorphicCaseLiteralFromSchema<TPolymorphicSchema, TPolymorphicDiscriminator>, OneRelationNameByType<TTableConfig>>, TConfig extends Omit<NonCursorConfigNoRelationCount<TSchema, TTableConfig>, 'polymorphic'> & {
|
|
3168
|
-
polymorphic: {
|
|
3169
|
-
schema: TPolymorphicSchema;
|
|
3170
|
-
discriminator: TPolymorphicDiscriminator;
|
|
3171
|
-
cases: TPolymorphicCases;
|
|
3172
|
-
as?: string | undefined;
|
|
3173
|
-
};
|
|
3174
|
-
}>(config: KnownKeysOnlyStrict<TConfig, NonCursorConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, FindManyResult<TSchema, TTableConfig, TConfig>>;
|
|
3175
3211
|
findMany<TConfig extends SearchPaginatedConfig<TSchema, TTableConfig>>(config: KnownKeysOnlyStrict<TConfig, SearchPaginatedConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, PaginatedResult<BuildQueryResult<TSchema, TTableConfig, TConfig>>>;
|
|
3176
3212
|
findMany<TConfig extends SearchNonPaginatedConfig<TSchema, TTableConfig>>(config: KnownKeysOnlyStrict<TConfig, SearchNonPaginatedConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>[]>;
|
|
3177
3213
|
findMany<TConfig extends VectorNonPaginatedConfig<TSchema, TTableConfig>>(config: KnownKeysOnlyStrict<TConfig, VectorNonPaginatedConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>[]>;
|
|
@@ -3193,14 +3229,6 @@ declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TTa
|
|
|
3193
3229
|
* });
|
|
3194
3230
|
*/
|
|
3195
3231
|
findFirst<TConfig extends SearchFindFirstConfig<TSchema, TTableConfig>>(config: KnownKeysOnlyStrict<TConfig, SearchFindFirstConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | null>;
|
|
3196
|
-
findFirst<TPolymorphicSchema extends PolymorphicZodSchema, TPolymorphicDiscriminator extends PolymorphicDiscriminatorFromSchema<TPolymorphicSchema>, TPolymorphicCases extends Record<PolymorphicCaseLiteralFromSchema<TPolymorphicSchema, TPolymorphicDiscriminator>, OneRelationNameByType<TTableConfig>>, TConfig extends Omit<FindFirstConfigNoSearch<TSchema, TTableConfig>, 'polymorphic'> & {
|
|
3197
|
-
polymorphic: {
|
|
3198
|
-
schema: TPolymorphicSchema;
|
|
3199
|
-
discriminator: TPolymorphicDiscriminator;
|
|
3200
|
-
cases: TPolymorphicCases;
|
|
3201
|
-
as?: string | undefined;
|
|
3202
|
-
};
|
|
3203
|
-
}>(config: KnownKeysOnlyStrict<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | null>;
|
|
3204
3232
|
findFirst<TConfig extends FindFirstConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnlyStrict<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig> | null>;
|
|
3205
3233
|
/**
|
|
3206
3234
|
* Find first row matching the query configuration, or throw if none exists.
|
|
@@ -3209,14 +3237,6 @@ declare class RelationalQueryBuilder<TSchema extends TablesRelationalConfig, TTa
|
|
|
3209
3237
|
* useful when callers expect a row to exist.
|
|
3210
3238
|
*/
|
|
3211
3239
|
findFirstOrThrow<TConfig extends SearchFindFirstConfig<TSchema, TTableConfig>>(config: KnownKeysOnlyStrict<TConfig, SearchFindFirstConfig<TSchema, TTableConfig>> & DisallowWithIndexSearchOrVector<THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>>;
|
|
3212
|
-
findFirstOrThrow<TPolymorphicSchema extends PolymorphicZodSchema, TPolymorphicDiscriminator extends PolymorphicDiscriminatorFromSchema<TPolymorphicSchema>, TPolymorphicCases extends Record<PolymorphicCaseLiteralFromSchema<TPolymorphicSchema, TPolymorphicDiscriminator>, OneRelationNameByType<TTableConfig>>, TConfig extends Omit<FindFirstConfigNoSearch<TSchema, TTableConfig>, 'polymorphic'> & {
|
|
3213
|
-
polymorphic: {
|
|
3214
|
-
schema: TPolymorphicSchema;
|
|
3215
|
-
discriminator: TPolymorphicDiscriminator;
|
|
3216
|
-
cases: TPolymorphicCases;
|
|
3217
|
-
as?: string | undefined;
|
|
3218
|
-
};
|
|
3219
|
-
}>(config: KnownKeysOnlyStrict<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>>;
|
|
3220
3240
|
findFirstOrThrow<TConfig extends FindFirstConfigNoSearch<TSchema, TTableConfig>>(config?: KnownKeysOnlyStrict<TConfig, FindFirstConfigNoSearch<TSchema, TTableConfig>> & EnforcedConfig<TConfig, TTableConfig, THasIndex>): GelRelationalQuery<TSchema, TTableConfig, BuildQueryResult<TSchema, TTableConfig, TConfig>>;
|
|
3221
3241
|
}
|
|
3222
3242
|
//#endregion
|
|
@@ -3400,9 +3420,6 @@ type MigrationCancelArgs = {
|
|
|
3400
3420
|
runId?: string;
|
|
3401
3421
|
};
|
|
3402
3422
|
//#endregion
|
|
3403
|
-
//#region src/orm/migrations/schema.d.ts
|
|
3404
|
-
declare function migrationPlugin(): OrmSchemaPlugin;
|
|
3405
|
-
//#endregion
|
|
3406
3423
|
//#region src/orm/triggers.d.ts
|
|
3407
3424
|
type MaybePromise<T> = T | Promise<T>;
|
|
3408
3425
|
type AnyRecord = Record<string, unknown>;
|
|
@@ -3675,4 +3692,4 @@ interface IndexLike {
|
|
|
3675
3692
|
indexName: string;
|
|
3676
3693
|
}
|
|
3677
3694
|
//#endregion
|
|
3678
|
-
export {
|
|
3695
|
+
export { DatabaseWithQuery as $, BuildRelationResult as $n, notInArray as $r, defineRelationsPart as $t, MigrationRunArgs as A, aggregateIndex as An, FieldReference as Ar, json as At, MigrationMigrateOne as B, ConvexUniqueConstraintBuilder as Bn, gt as Br, bigint as Bt, OrmBeforeResult as C, ConvexRankIndexBuilderOn as Cn, ReturningSelection as Cr, ConvexDateBuilderInitial as Ct, OrmTriggers as D, ConvexVectorIndexBuilder as Dn, unsetToken as Dr, ConvexCustomBuilderInitial as Dt, OrmTriggerContext as E, ConvexSearchIndexConfig as En, VectorSearchProvider as Er, ConvexCustomBuilder as Et, MigrationDirection as F, vectorIndex as Fn, between as Fr, ConvexBooleanBuilder as Ft, MigrationStep as G, unique as Gn, isNotNull as Gr, ManyConfig as Gt, MigrationRunStatus as H, ConvexUniqueConstraintConfig as Hn, ilike as Hr, CountBackfillKickoffArgs as Ht, MigrationDoc as I, ConvexCheckBuilder as In, contains as Ir, ConvexBooleanBuilderInitial as It, buildMigrationPlan as J, text as Jn, lt as Jr, RelationsBuilderColumnBase as Jt, MigrationTableName as K, ConvexTextBuilder as Kn, isNull as Kr, OneConfig as Kt, MigrationDocContext as L, ConvexCheckConfig as Ln, endsWith as Lr, boolean as Lt, MigrationStatusArgs as M, rankIndex as Mn, LogicalExpression as Mr, ConvexBytesBuilder as Mt, MigrationAppliedState as N, searchIndex as Nn, UnaryExpression as Nr, ConvexBytesBuilderInitial as Nt, defineTriggers as O, ConvexVectorIndexBuilderOn as On, BinaryExpression as Or, arrayOf as Ot, MigrationDefinition as P, uniqueIndex as Pn, and as Pr, bytes as Pt, DatabaseWithMutations as Q, BuildQueryResult as Qn, notBetween as Qr, defineRelations as Qt, MigrationDriftIssue as R, ConvexForeignKeyBuilder as Rn, eq as Rr, ConvexBigIntBuilder as Rt, scheduledDeleteFactory as S, ConvexRankIndexBuilder as Sn, ReturningResult as Sr, ConvexDateBuilder as St, OrmTriggerChange as T, ConvexSearchIndexBuilderOn as Tn, VectorQueryConfig as Tr, date as Tt, MigrationSet as U, check as Un, inArray as Ur, CountBackfillStatusArgs as Ut, MigrationPlan as V, ConvexUniqueConstraintBuilderOn as Vn, gte as Vr, CountBackfillChunkArgs as Vt, MigrationStateMap as W, foreignKey as Wn, isFieldReference as Wr, ExtractTablesWithRelations as Wt, defineMigrationSet as X, AggregateFieldValue as Xn, ne as Xr, TableRelationalConfig as Xt, defineMigration as Y, AggregateConfig as Yn, lte as Yr, RelationsBuilderColumnConfig as Yt, detectMigrationDrift as Z, AggregateResult as Zn, not as Zr, TablesRelationalConfig as Zt, OrmWriterCtx as _, IsPrimaryKey as _i, rlsRole as _n, OrderByClause as _r, ConvexNumberBuilderInitial as _t, TableConfigResult as a, OrmSchemaPluginTables as ai, OrmLifecycleChange as an, InferInsertModel as ar, extractRelationsConfig as at, scheduledMutationBatchFactory as b, ConvexIndexBuilder as bn, PredicateWhereIndexConfig as br, ConvexIdBuilderInitial as bt, OrmNotFoundError as c, AnyColumn as ci, convexTable as cn, InsertValue as cr, vector as ct, GenericOrmCtx as d, ColumnBuilderRuntimeConfig as di, RlsPolicy as dn, MutationExecutionMode as dr, ConvexTimestampMode as dt, or as ei, ConvexDeletionBuilder as en, CountConfig as er, OrmReader as et, OrmApiResult as f, ColumnBuilderTypeConfig as fi, RlsPolicyConfig as fn, MutationPaginateConfig as fr, timestamp as ft, OrmReaderCtx as g, HasDefault as gi, RlsRoleConfig as gn, MutationRunMode as gr, ConvexNumberBuilder as gt, OrmFunctions as h, DrizzleEntity as hi, RlsRole as hn, MutationReturning as hr, textEnum as ht, desc as i, OrmSchemaPlugin as ii, DiscriminatorBuilderConfig as in, GetColumnData as ir, EdgeMetadata as it, MigrationRunChunkArgs as j, index as jn, FilterExpression$1 as jr, objectOf as jt, MigrationCancelArgs as k, ConvexVectorIndexConfig as kn, ExpressionVisitor as kr, custom as kt, CreateOrmOptions as l, ColumnBuilder as li, deletion as ln, MutationExecuteConfig as lr, ConvexTimestampBuilder as lt, OrmClientWithApi as m, ColumnDataType as mi, rlsPolicy as mn, MutationResult as mr, ConvexTextEnumBuilderInitial as mt, defineSchema$1 as n, Brand as ni, ConvexTable as nn, DBQueryConfig as nr, RlsContext as nt, getTableColumns as o, TableName as oi, OrmLifecycleOperation as on, InferModelFromColumns as or, ConvexVectorBuilder as ot, OrmClientBase as p, ColumnBuilderWithTableName as pi, RlsPolicyToOption as pn, MutationPaginatedResult as pr, ConvexTextEnumBuilder as pt, MigrationWriteMode as q, ConvexTextBuilderInitial as qn, like as qr, RelationsBuilder as qt, asc as r, Columns as ri, ConvexTableWithColumns as rn, FilterOperators as rr, RlsMode as rt, getTableConfig as s, SystemFields as si, TableConfig as sn, InferSelectModel as sr, ConvexVectorBuilderInitial as st, WhereClauseResult as t, startsWith as ti, ConvexDeletionConfig as tn, CountResult as tr, OrmWriter as tt, GenericOrm as u, ColumnBuilderBaseConfig as ui, discriminator as un, MutationExecuteResult as ur, ConvexTimestampBuilderInitial as ut, createOrm as v, IsUnique as vi, ConvexAggregateIndexBuilder as vn, OrderDirection as vr, integer as vt, OrmTableTriggers as w, ConvexSearchIndexBuilder as wn, UpdateSet as wr, ConvexDateMode as wt, ScheduledDeleteArgs as x, ConvexIndexBuilderOn as xn, ReturningAll as xr, id as xt, ScheduledMutationBatchArgs as y, NotNull as yi, ConvexAggregateIndexBuilderOn as yn, PaginatedResult as yr, ConvexIdBuilder as yt, MigrationManifestEntry as z, ConvexForeignKeyConfig as zn, fieldRef as zr, ConvexBigIntBuilderInitial as zt };
|