better-convex 0.6.4 → 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.
Files changed (47) hide show
  1. package/dist/aggregate/index.d.ts +388 -0
  2. package/dist/aggregate/index.js +37 -0
  3. package/dist/{auth-client → auth/client}/index.js +1 -1
  4. package/dist/auth/http/index.d.ts +63 -0
  5. package/dist/auth/http/index.js +429 -0
  6. package/dist/auth/index.d.ts +18991 -175
  7. package/dist/auth/index.js +373 -686
  8. package/dist/{auth-nextjs → auth/nextjs}/index.d.ts +3 -5
  9. package/dist/{auth-nextjs → auth/nextjs}/index.js +3 -5
  10. package/dist/{caller-factory-B1FvYSKr.js → caller-factory-Dmgv8MLS.js} +15 -12
  11. package/dist/cli.mjs +2601 -13
  12. package/dist/codegen-Cz1idI3-.mjs +969 -0
  13. package/dist/{create-schema-orm-DplxTtYj.js → create-schema-orm-69VF4CFV.js} +4 -3
  14. package/dist/crpc/index.d.ts +2 -2
  15. package/dist/crpc/index.js +3 -3
  16. package/dist/{http-types-BRLY10NX.d.ts → http-types-BCf2wCgp.d.ts} +25 -25
  17. package/dist/meta-utils-DDVYp9Xf.js +117 -0
  18. package/dist/orm/index.d.ts +4 -3012
  19. package/dist/orm/index.js +9631 -2
  20. package/dist/{index-BQkhP2ny.d.ts → procedure-caller-CcjtUFvL.d.ts} +211 -74
  21. package/dist/query-context-BDSis9rT.js +1518 -0
  22. package/dist/query-context-DGExXZIV.d.ts +42 -0
  23. package/dist/react/index.d.ts +31 -35
  24. package/dist/react/index.js +145 -58
  25. package/dist/rsc/index.d.ts +4 -7
  26. package/dist/rsc/index.js +14 -10
  27. package/dist/runtime-B9xQFY8W.js +2280 -0
  28. package/dist/server/index.d.ts +3 -4
  29. package/dist/server/index.js +384 -10
  30. package/dist/{types-o-5rYcTr.d.ts → types-CIBGEYXq.d.ts} +4 -3
  31. package/dist/types-DgwvxKbT.d.ts +4 -0
  32. package/dist/watcher.mjs +8 -8
  33. package/dist/where-clause-compiler-CRP-i1Qa.d.ts +3463 -0
  34. package/package.json +14 -10
  35. package/dist/codegen-DkpPBVPn.mjs +0 -189
  36. package/dist/context-utils-DSuX99Da.d.ts +0 -17
  37. package/dist/meta-utils-DCpLSBWB.js +0 -41
  38. package/dist/orm-BKc-pwj_.js +0 -8821
  39. /package/dist/{auth-client → auth/client}/index.d.ts +0 -0
  40. /package/dist/{auth-config → auth/config}/index.d.ts +0 -0
  41. /package/dist/{auth-config → auth/config}/index.js +0 -0
  42. /package/dist/{create-schema-DhWXOhnU.js → create-schema-BdZOL6ns.js} +0 -0
  43. /package/dist/{customFunctions-C1okqCzL.js → customFunctions-CZnCwoR3.js} +0 -0
  44. /package/dist/{error-BZUhlhYz.js → error-Be4OcwwD.js} +0 -0
  45. /package/dist/{query-options-BL1Q0X7q.js → query-options-B0c1b6pZ.js} +0 -0
  46. /package/dist/{transformer-CTNSPjwp.js → transformer-Dh0w2py0.js} +0 -0
  47. /package/dist/{types-jftzhhuc.d.ts → types-DwGkkq2s.d.ts} +0 -0
@@ -0,0 +1,388 @@
1
+ import { Ft as ConvexTableWithColumns, J as ConvexTextBuilderInitial, Z as ConvexNumberBuilderInitial, et as ConvexIdBuilderInitial, st as ConvexCustomBuilderInitial } from "../where-clause-compiler-CRP-i1Qa.js";
2
+ import * as convex_values0 from "convex/values";
3
+ import { GenericId, Infer, Value } from "convex/values";
4
+ import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
5
+
6
+ //#region src/aggregate-core/schema.d.ts
7
+ declare const aggregateStorageTables: {
8
+ readonly aggregate_rank_node: ConvexTableWithColumns<{
9
+ name: "aggregate_rank_node";
10
+ columns: {
11
+ aggregate: ConvexCustomBuilderInitial<"", convex_values0.VObject<{
12
+ count: number;
13
+ sum: number;
14
+ }, {
15
+ count: convex_values0.VFloat64<number, "required">;
16
+ sum: convex_values0.VFloat64<number, "required">;
17
+ }, "required", "count" | "sum">> & {
18
+ _: {
19
+ tableName: "aggregate_rank_node";
20
+ };
21
+ } & {
22
+ _: {
23
+ fieldName: "aggregate";
24
+ };
25
+ };
26
+ items: ConvexCustomBuilderInitial<"", convex_values0.VArray<{
27
+ k: any;
28
+ v: any;
29
+ s: number;
30
+ }[], convex_values0.VObject<{
31
+ k: any;
32
+ v: any;
33
+ s: number;
34
+ }, {
35
+ k: convex_values0.VAny<any, "required", string>;
36
+ v: convex_values0.VAny<any, "required", string>;
37
+ s: convex_values0.VFloat64<number, "required">;
38
+ }, "required", "k" | "v" | "s" | `k.${string}` | `v.${string}`>, "required">> & {
39
+ _: {
40
+ notNull: true;
41
+ };
42
+ } & {
43
+ _: {
44
+ tableName: "aggregate_rank_node";
45
+ };
46
+ } & {
47
+ _: {
48
+ fieldName: "items";
49
+ };
50
+ };
51
+ subtrees: ConvexCustomBuilderInitial<"", convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">> & {
52
+ _: {
53
+ notNull: true;
54
+ };
55
+ } & {
56
+ _: {
57
+ tableName: "aggregate_rank_node";
58
+ };
59
+ } & {
60
+ _: {
61
+ fieldName: "subtrees";
62
+ };
63
+ };
64
+ };
65
+ }, {
66
+ by_creation_time: ["_creationTime"];
67
+ }, {}, {}, {}>;
68
+ readonly aggregate_rank_tree: ConvexTableWithColumns<{
69
+ name: "aggregate_rank_tree";
70
+ columns: {
71
+ aggregateName: ConvexTextBuilderInitial<""> & {
72
+ _: {
73
+ notNull: true;
74
+ };
75
+ } & {
76
+ _: {
77
+ tableName: "aggregate_rank_tree";
78
+ };
79
+ } & {
80
+ _: {
81
+ fieldName: "aggregateName";
82
+ };
83
+ };
84
+ maxNodeSize: ConvexNumberBuilderInitial<""> & {
85
+ _: {
86
+ notNull: true;
87
+ };
88
+ } & {
89
+ _: {
90
+ tableName: "aggregate_rank_tree";
91
+ };
92
+ } & {
93
+ _: {
94
+ fieldName: "maxNodeSize";
95
+ };
96
+ };
97
+ namespace: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
98
+ _: {
99
+ tableName: "aggregate_rank_tree";
100
+ };
101
+ } & {
102
+ _: {
103
+ fieldName: "namespace";
104
+ };
105
+ };
106
+ root: ConvexIdBuilderInitial<"", "aggregate_rank_node"> & {
107
+ _: {
108
+ notNull: true;
109
+ };
110
+ } & {
111
+ _: {
112
+ tableName: "aggregate_rank_tree";
113
+ };
114
+ } & {
115
+ _: {
116
+ fieldName: "root";
117
+ };
118
+ };
119
+ };
120
+ }, {
121
+ by_creation_time: ["_creationTime"];
122
+ by_namespace: ["namespace", "_creationTime"];
123
+ by_aggregate_name: ["aggregateName", "_creationTime"];
124
+ }, {}, {}, {}>;
125
+ };
126
+ //#endregion
127
+ //#region src/aggregate-core/btree.d.ts
128
+ type Key$2 = Value;
129
+ //#endregion
130
+ //#region src/aggregate-core/positions.d.ts
131
+ type Bound$1<K extends Key$2, ID extends string> = {
132
+ key: K;
133
+ id?: ID;
134
+ inclusive: boolean;
135
+ };
136
+ type SideBounds<K extends Key$2, ID extends string> = {
137
+ lower?: Bound$1<K, ID>;
138
+ upper?: Bound$1<K, ID>;
139
+ };
140
+ type TuplePrefix<K extends unknown[], P extends unknown[] = []> = P['length'] extends K['length'] ? P : P | TuplePrefix<K, [...P, K[P['length']]]>;
141
+ type Bounds$1<K extends Key$2, ID extends string> = SideBounds<K, ID> | (K extends unknown[] ? {
142
+ prefix: TuplePrefix<Extract<K, unknown[]>>;
143
+ } : never) | {
144
+ eq: K;
145
+ };
146
+ //#endregion
147
+ //#region src/aggregate-core/runtime.d.ts
148
+ type Key = Key$2;
149
+ type Bound<K extends Key, ID extends string> = Bound$1<K, ID>;
150
+ type Bounds<K extends Key, ID extends string> = Bounds$1<K, ID>;
151
+ type AggregateQueryCtx = {
152
+ db: GenericDatabaseReader<any>;
153
+ orm: unknown;
154
+ };
155
+ type AggregateMutationCtx = {
156
+ db: GenericDatabaseWriter<any>;
157
+ orm: unknown;
158
+ };
159
+ type RunQueryCtx = AggregateQueryCtx;
160
+ type RunMutationCtx = AggregateMutationCtx;
161
+ type Item<K extends Key, ID extends string> = {
162
+ id: ID;
163
+ key: K;
164
+ sumValue: number;
165
+ };
166
+ /**
167
+ * Write data to be aggregated, and read aggregated data.
168
+ */
169
+ declare class Aggregate<K extends Key, ID extends string, TNamespace extends Value | undefined = undefined> {
170
+ protected readonly aggregateName: string;
171
+ constructor(aggregateName: string);
172
+ count(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
173
+ bounds?: Bounds<K, ID>;
174
+ }, TNamespace>): Promise<number>;
175
+ countBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{
176
+ bounds?: Bounds<K, ID>;
177
+ }, TNamespace>): Promise<number[]>;
178
+ sum(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
179
+ bounds?: Bounds<K, ID>;
180
+ }, TNamespace>): Promise<number>;
181
+ sumBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{
182
+ bounds?: Bounds<K, ID>;
183
+ }, TNamespace>): Promise<number[]>;
184
+ at(ctx: RunQueryCtx, offset: number, ...opts: NamespacedOpts<{
185
+ bounds?: Bounds<K, ID>;
186
+ }, TNamespace>): Promise<Item<K, ID>>;
187
+ atBatch(ctx: RunQueryCtx, queries: NamespacedOptsBatch<{
188
+ offset: number;
189
+ bounds?: Bounds<K, ID>;
190
+ }, TNamespace>): Promise<Item<K, ID>[]>;
191
+ indexOf(ctx: RunQueryCtx, key: K, ...opts: NamespacedOpts<{
192
+ bounds?: Bounds<K, ID>;
193
+ id?: ID;
194
+ order?: 'asc' | 'desc';
195
+ }, TNamespace>): Promise<number>;
196
+ offsetOf(ctx: RunQueryCtx, key: K, namespace: TNamespace, id?: ID, bounds?: Bounds<K, ID>): Promise<number>;
197
+ offsetUntil(ctx: RunQueryCtx, key: K, namespace: TNamespace, id?: ID, bounds?: Bounds<K, ID>): Promise<number>;
198
+ min(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
199
+ bounds?: Bounds<K, ID>;
200
+ }, TNamespace>): Promise<Item<K, ID> | null>;
201
+ max(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
202
+ bounds?: Bounds<K, ID>;
203
+ }, TNamespace>): Promise<Item<K, ID> | null>;
204
+ random(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
205
+ bounds?: Bounds<K, ID>;
206
+ }, TNamespace>): Promise<Item<K, ID> | null>;
207
+ paginate(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
208
+ bounds?: Bounds<K, ID>;
209
+ cursor?: string;
210
+ order?: 'asc' | 'desc';
211
+ pageSize?: number;
212
+ }, TNamespace>): Promise<{
213
+ cursor: string;
214
+ isDone: boolean;
215
+ page: Item<K, ID>[];
216
+ }>;
217
+ iter(ctx: RunQueryCtx, ...opts: NamespacedOpts<{
218
+ bounds?: Bounds<K, ID>;
219
+ order?: 'asc' | 'desc';
220
+ pageSize?: number;
221
+ }, TNamespace>): AsyncGenerator<Item<K, ID>, void, undefined>;
222
+ _insert(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID, summand?: number): Promise<void>;
223
+ _delete(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID): Promise<void>;
224
+ _replace(ctx: RunMutationCtx, currentNamespace: TNamespace, currentKey: K, newNamespace: TNamespace, newKey: K, id: ID, summand?: number): Promise<void>;
225
+ _insertIfDoesNotExist(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID, summand?: number): Promise<void>;
226
+ _deleteIfExists(ctx: RunMutationCtx, namespace: TNamespace, key: K, id: ID): Promise<void>;
227
+ _replaceOrInsert(ctx: RunMutationCtx, currentNamespace: TNamespace, currentKey: K, newNamespace: TNamespace, newKey: K, id: ID, summand?: number): Promise<void>;
228
+ clear(ctx: RunMutationCtx, ...opts: NamespacedOpts<{
229
+ maxNodeSize?: number;
230
+ rootLazy?: boolean;
231
+ }, TNamespace>): Promise<void>;
232
+ makeRootLazy(ctx: RunMutationCtx, namespace: TNamespace): Promise<void>;
233
+ paginateNamespaces(ctx: RunQueryCtx, cursor?: string, pageSize?: number): Promise<{
234
+ cursor: string;
235
+ isDone: boolean;
236
+ page: TNamespace[];
237
+ }>;
238
+ iterNamespaces(ctx: RunQueryCtx, pageSize?: number): AsyncGenerator<TNamespace, void, undefined>;
239
+ clearAll(ctx: RunMutationCtx & RunQueryCtx, opts?: {
240
+ maxNodeSize?: number;
241
+ rootLazy?: boolean;
242
+ }): Promise<void>;
243
+ makeAllRootsLazy(ctx: RunMutationCtx & RunQueryCtx): Promise<void>;
244
+ }
245
+ type DirectAggregateType<K extends Key, ID extends string, TNamespace extends Value | undefined = undefined> = {
246
+ Key: K;
247
+ Id: ID;
248
+ Namespace?: TNamespace;
249
+ };
250
+ type AnyDirectAggregateType$1 = DirectAggregateType<Key, string, Value | undefined>;
251
+ type DirectAggregateNamespace<T extends AnyDirectAggregateType$1> = 'Namespace' extends keyof T ? T['Namespace'] : undefined;
252
+ declare class DirectAggregate$1<T extends AnyDirectAggregateType$1> extends Aggregate<T['Key'], T['Id'], DirectAggregateNamespace<T>> {
253
+ constructor(config: {
254
+ name: string;
255
+ });
256
+ insert(ctx: RunMutationCtx, args: NamespacedArgs<{
257
+ id: T['Id'];
258
+ key: T['Key'];
259
+ sumValue?: number;
260
+ }, DirectAggregateNamespace<T>>): Promise<void>;
261
+ delete(ctx: RunMutationCtx, args: NamespacedArgs<{
262
+ id: T['Id'];
263
+ key: T['Key'];
264
+ }, DirectAggregateNamespace<T>>): Promise<void>;
265
+ replace(ctx: RunMutationCtx, currentItem: NamespacedArgs<{
266
+ id: T['Id'];
267
+ key: T['Key'];
268
+ }, DirectAggregateNamespace<T>>, newItem: NamespacedArgs<{
269
+ key: T['Key'];
270
+ sumValue?: number;
271
+ }, DirectAggregateNamespace<T>>): Promise<void>;
272
+ insertIfDoesNotExist(ctx: RunMutationCtx, args: NamespacedArgs<{
273
+ id: T['Id'];
274
+ key: T['Key'];
275
+ sumValue?: number;
276
+ }, DirectAggregateNamespace<T>>): Promise<void>;
277
+ deleteIfExists(ctx: RunMutationCtx, args: NamespacedArgs<{
278
+ id: T['Id'];
279
+ key: T['Key'];
280
+ }, DirectAggregateNamespace<T>>): Promise<void>;
281
+ replaceOrInsert(ctx: RunMutationCtx, currentItem: NamespacedArgs<{
282
+ id: T['Id'];
283
+ key: T['Key'];
284
+ }, DirectAggregateNamespace<T>>, newItem: NamespacedArgs<{
285
+ key: T['Key'];
286
+ sumValue?: number;
287
+ }, DirectAggregateNamespace<T>>): Promise<void>;
288
+ }
289
+ type TableAggregateType<K extends Key, DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>, TNamespace extends Value | undefined = undefined> = {
290
+ DataModel: DataModel;
291
+ Key: K;
292
+ Namespace?: TNamespace;
293
+ TableName: TableName;
294
+ };
295
+ type AnyTableAggregateType$1 = TableAggregateType<Key, GenericDataModel, TableNamesInDataModel<GenericDataModel>, Value | undefined>;
296
+ type TableAggregateNamespace<T extends AnyTableAggregateType$1> = 'Namespace' extends keyof T ? T['Namespace'] : undefined;
297
+ type TableAggregateDocument<T extends AnyTableAggregateType$1> = DocumentByName<T['DataModel'], T['TableName']>;
298
+ type TableAggregateId<T extends AnyTableAggregateType$1> = GenericId<T['TableName']>;
299
+ type TableAggregateTrigger<Ctx, T extends AnyTableAggregateType$1> = Trigger<Ctx, T['DataModel'], T['TableName']>;
300
+ declare class TableAggregate$1<T extends AnyTableAggregateType$1> extends Aggregate<T['Key'], GenericId<T['TableName']>, TableAggregateNamespace<T>> {
301
+ constructor(options: {
302
+ name: string;
303
+ table: T['TableName'];
304
+ sortKey: (d: TableAggregateDocument<T>) => T['Key'];
305
+ sumValue?: (d: TableAggregateDocument<T>) => number;
306
+ } & (undefined extends TableAggregateNamespace<T> ? {
307
+ namespace?: (d: TableAggregateDocument<T>) => TableAggregateNamespace<T>;
308
+ } : {
309
+ namespace: (d: TableAggregateDocument<T>) => TableAggregateNamespace<T>;
310
+ }));
311
+ private readonly options;
312
+ insert(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
313
+ delete(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
314
+ replace(ctx: RunMutationCtx, oldDoc: TableAggregateDocument<T>, newDoc: TableAggregateDocument<T>): Promise<void>;
315
+ insertIfDoesNotExist(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
316
+ deleteIfExists(ctx: RunMutationCtx, doc: TableAggregateDocument<T>): Promise<void>;
317
+ replaceOrInsert(ctx: RunMutationCtx, oldDoc: TableAggregateDocument<T>, newDoc: TableAggregateDocument<T>): Promise<void>;
318
+ indexOfDoc(ctx: RunQueryCtx, doc: TableAggregateDocument<T>, opts?: {
319
+ id?: TableAggregateId<T>;
320
+ bounds?: Bounds<T['Key'], TableAggregateId<T>>;
321
+ order?: 'asc' | 'desc';
322
+ }): Promise<number>;
323
+ trigger<Ctx extends RunMutationCtx>(): TableAggregateTrigger<Ctx, T>;
324
+ idempotentTrigger<Ctx extends RunMutationCtx>(): TableAggregateTrigger<Ctx, T>;
325
+ }
326
+ type Trigger<Ctx, DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>> = (ctx: Ctx, change: Change<DataModel, TableName>) => Promise<void>;
327
+ type Change<DataModel extends GenericDataModel, TableName extends TableNamesInDataModel<DataModel>> = {
328
+ id: GenericId<TableName> | string;
329
+ } & ({
330
+ operation: 'insert';
331
+ oldDoc: null;
332
+ newDoc: DocumentByName<DataModel, TableName>;
333
+ } | {
334
+ operation: 'update';
335
+ oldDoc: DocumentByName<DataModel, TableName>;
336
+ newDoc: DocumentByName<DataModel, TableName>;
337
+ } | {
338
+ operation: 'delete';
339
+ oldDoc: DocumentByName<DataModel, TableName>;
340
+ newDoc: null;
341
+ });
342
+ type NamespacedArgs<Args, TNamespace> = (Args & {
343
+ namespace: TNamespace;
344
+ }) | (TNamespace extends undefined ? Args : never);
345
+ type NamespacedOpts<Opts, TNamespace> = [{
346
+ namespace: TNamespace;
347
+ } & Opts] | (undefined extends TNamespace ? [Opts?] : never);
348
+ type NamespacedOptsBatch<Opts, TNamespace> = Array<undefined extends TNamespace ? Opts : {
349
+ namespace: TNamespace;
350
+ } & Opts>;
351
+ //#endregion
352
+ //#region src/orm/aggregate.d.ts
353
+ type AggregateTriggerFactoryLike = {
354
+ trigger: () => (ctx: unknown, change: unknown) => Promise<void>;
355
+ };
356
+ type AggregateTriggerCtx<T extends AggregateTriggerFactoryLike> = Parameters<ReturnType<T['trigger']>>[0];
357
+ type AggregateTriggerChange<T extends AggregateTriggerFactoryLike> = Parameters<ReturnType<T['trigger']>>[1];
358
+ type AggregateTriggerOverload<T extends AggregateTriggerFactoryLike> = {
359
+ (): ReturnType<T['trigger']>;
360
+ <TChange, TCtx>(change: TChange, ctx: TCtx): Promise<void>;
361
+ };
362
+ type OrmCompatibleAggregate<T extends AggregateTriggerFactoryLike> = Omit<T, 'trigger'> & {
363
+ trigger: AggregateTriggerOverload<T>;
364
+ };
365
+ //#endregion
366
+ //#region src/aggregate/index.d.ts
367
+ type Key$1 = Key;
368
+ type AnyDirectAggregateType = DirectAggregateType<Key$1, string, Value | undefined>;
369
+ type AnyTableAggregateType = TableAggregateType<Key$1, any, any, Value | undefined>;
370
+ type CoreTrigger<T extends AnyTableAggregateType> = ReturnType<TableAggregate$1<T>['trigger']>;
371
+ type CoreIdempotentTrigger<T extends AnyTableAggregateType> = ReturnType<TableAggregate$1<T>['idempotentTrigger']>;
372
+ declare class TableAggregate<T extends AnyTableAggregateType> extends TableAggregate$1<T> {
373
+ trigger: {
374
+ (): CoreTrigger<T>;
375
+ <TChange, TCtx>(change: TChange, ctx: TCtx): Promise<void>;
376
+ };
377
+ idempotentTrigger: {
378
+ (): CoreIdempotentTrigger<T>;
379
+ <TChange, TCtx>(change: TChange, ctx: TCtx): Promise<void>;
380
+ };
381
+ constructor(...args: ConstructorParameters<typeof TableAggregate$1>);
382
+ }
383
+ declare class DirectAggregate<T extends AnyDirectAggregateType> extends DirectAggregate$1<T> {}
384
+ declare function createDirectAggregate<T extends AnyDirectAggregateType>(config: {
385
+ name: string;
386
+ }): DirectAggregate<T>;
387
+ //#endregion
388
+ export { type AggregateTriggerChange, type AggregateTriggerCtx, type AggregateTriggerFactoryLike, type Bound, type Bounds, DirectAggregate, type DirectAggregateType, type Item, type Key, type OrmCompatibleAggregate, type RunMutationCtx, type RunQueryCtx, TableAggregate, type TableAggregateType, aggregateStorageTables, createDirectAggregate };
@@ -0,0 +1,37 @@
1
+ import { n as TableAggregate$1, r as aggregateStorageTables, t as DirectAggregate$1 } from "../runtime-B9xQFY8W.js";
2
+
3
+ //#region src/aggregate/index.ts
4
+ const wrapTriggerFactory = (methodName, factory) => ((...args) => {
5
+ if (args.length === 0) return factory();
6
+ if (args.length === 2) {
7
+ const [change, ctx] = args;
8
+ return factory()(ctx, change);
9
+ }
10
+ throw new Error(`Invalid aggregate.${methodName} invocation. Use ${methodName}() or ${methodName}(change, ctx).`);
11
+ });
12
+ var TableAggregate = class extends TableAggregate$1 {
13
+ constructor(...args) {
14
+ super(...args);
15
+ const triggerFactory = super.trigger.bind(this);
16
+ const idempotentFactory = super.idempotentTrigger.bind(this);
17
+ Object.defineProperty(this, "trigger", {
18
+ configurable: true,
19
+ enumerable: false,
20
+ value: wrapTriggerFactory("trigger", triggerFactory),
21
+ writable: true
22
+ });
23
+ Object.defineProperty(this, "idempotentTrigger", {
24
+ configurable: true,
25
+ enumerable: false,
26
+ value: wrapTriggerFactory("idempotentTrigger", idempotentFactory),
27
+ writable: true
28
+ });
29
+ }
30
+ };
31
+ var DirectAggregate = class extends DirectAggregate$1 {};
32
+ function createDirectAggregate(config) {
33
+ return new DirectAggregate(config);
34
+ }
35
+
36
+ //#endregion
37
+ export { DirectAggregate, TableAggregate, aggregateStorageTables, createDirectAggregate };
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { a as FetchAccessTokenContext, b as CRPCClientError, l as decodeJwtExp, m as useAuthValue, p as useAuthStore, t as AuthProvider, x as defaultIsUnauthorized } from "../auth-store-DHapqI5u.js";
2
+ import { a as FetchAccessTokenContext, b as CRPCClientError, l as decodeJwtExp, m as useAuthValue, p as useAuthStore, t as AuthProvider, x as defaultIsUnauthorized } from "../../auth-store-DHapqI5u.js";
3
3
  import { convexClient } from "@convex-dev/better-auth/client/plugins";
4
4
  import { c } from "react/compiler-runtime";
5
5
  import { ConvexProviderWithAuth, useConvexAuth } from "convex/react";
@@ -0,0 +1,63 @@
1
+ import { t as GetAuth } from "../../types-DgwvxKbT.js";
2
+ import { HttpRouter } from "convex/server";
3
+ import { MiddlewareHandler } from "hono";
4
+
5
+ //#region src/auth/middleware.d.ts
6
+ interface AuthMiddlewareOptions {
7
+ /** Base path for auth routes (default: '/api/auth') */
8
+ basePath?: string;
9
+ /** Log request/response headers for debugging */
10
+ verbose?: boolean;
11
+ }
12
+ /**
13
+ * Create auth middleware that handles auth routes and OpenID well-known redirect.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * import { Hono } from 'hono';
18
+ * import { cors } from 'hono/cors';
19
+ * import { authMiddleware } from 'better-convex/auth/http';
20
+ * import { createHttpRouter } from 'better-convex/server';
21
+ *
22
+ * const app = new Hono();
23
+ * app.use('/api/*', cors({ origin: process.env.SITE_URL, credentials: true }));
24
+ * app.use(authMiddleware(getAuth));
25
+ *
26
+ * export default createHttpRouter(app, httpRouter);
27
+ * ```
28
+ */
29
+ declare function authMiddleware(getAuth: GetAuth<unknown, {
30
+ handler: (request: Request) => Promise<Response>;
31
+ }>, opts?: AuthMiddlewareOptions): MiddlewareHandler;
32
+ //#endregion
33
+ //#region src/auth/registerRoutes.d.ts
34
+ type AuthRouteContract = {
35
+ $context: Promise<{
36
+ options: {
37
+ trustedOrigins?: string[] | ((request: Request) => Promise<string[]> | string[]);
38
+ };
39
+ }>;
40
+ handler: (request: Request) => Promise<Response>;
41
+ options: {
42
+ basePath?: string;
43
+ baseURL?: string;
44
+ trustedOrigins?: string[] | ((request: Request) => Promise<string[]> | string[]);
45
+ };
46
+ };
47
+ declare const registerRoutes: (http: HttpRouter, getAuth: GetAuth<unknown, AuthRouteContract>, opts?: {
48
+ cors?: {
49
+ allowedHeaders?: string[];
50
+ allowedOrigins?: string[];
51
+ exposedHeaders?: string[];
52
+ } | boolean;
53
+ verbose?: boolean;
54
+ }) => void;
55
+ //#endregion
56
+ //#region src/auth-http/index.d.ts
57
+ /**
58
+ * Install Convex-safe polyfills required by Better Auth's HTTP handling.
59
+ * This runs automatically when importing `better-convex/auth/http`.
60
+ */
61
+ declare function installAuthHttpPolyfills(): void;
62
+ //#endregion
63
+ export { authMiddleware, installAuthHttpPolyfills, registerRoutes };