@confect/core 10.0.0-next.2 → 10.0.0-next.21

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 (94) hide show
  1. package/CHANGELOG.md +531 -0
  2. package/README.md +3 -1
  3. package/dist/FunctionProvenance.d.ts +155 -65
  4. package/dist/FunctionProvenance.d.ts.map +1 -1
  5. package/dist/FunctionProvenance.js +51 -10
  6. package/dist/FunctionProvenance.js.map +1 -1
  7. package/dist/FunctionSpec.d.ts +314 -138
  8. package/dist/FunctionSpec.d.ts.map +1 -1
  9. package/dist/FunctionSpec.js +50 -13
  10. package/dist/FunctionSpec.js.map +1 -1
  11. package/dist/GenericId.d.ts.map +1 -1
  12. package/dist/GenericId.js +1 -1
  13. package/dist/GroupPath.d.ts +1 -4
  14. package/dist/GroupPath.d.ts.map +1 -1
  15. package/dist/GroupPath.js.map +1 -1
  16. package/dist/GroupSpec.d.ts +16 -10
  17. package/dist/GroupSpec.d.ts.map +1 -1
  18. package/dist/GroupSpec.js +34 -11
  19. package/dist/GroupSpec.js.map +1 -1
  20. package/dist/Identifier.d.ts.map +1 -1
  21. package/dist/Lazy.d.ts +2 -3
  22. package/dist/Lazy.d.ts.map +1 -1
  23. package/dist/Lazy.js +2 -3
  24. package/dist/Lazy.js.map +1 -1
  25. package/dist/MiddlewareSpec.d.ts +184 -0
  26. package/dist/MiddlewareSpec.d.ts.map +1 -0
  27. package/dist/MiddlewareSpec.js +55 -0
  28. package/dist/MiddlewareSpec.js.map +1 -0
  29. package/dist/PaginationError.d.ts +14 -0
  30. package/dist/PaginationError.d.ts.map +1 -0
  31. package/dist/PaginationError.js +25 -0
  32. package/dist/PaginationError.js.map +1 -0
  33. package/dist/PaginationOptions.d.ts +23 -0
  34. package/dist/PaginationOptions.d.ts.map +1 -0
  35. package/dist/PaginationOptions.js +29 -0
  36. package/dist/PaginationOptions.js.map +1 -0
  37. package/dist/PaginationResult.d.ts +1 -0
  38. package/dist/PaginationResult.d.ts.map +1 -1
  39. package/dist/PaginationResult.js.map +1 -1
  40. package/dist/Ref.d.ts +120 -39
  41. package/dist/Ref.d.ts.map +1 -1
  42. package/dist/Ref.js +94 -38
  43. package/dist/Ref.js.map +1 -1
  44. package/dist/Refs.d.ts +9 -4
  45. package/dist/Refs.d.ts.map +1 -1
  46. package/dist/Refs.js +3 -3
  47. package/dist/Refs.js.map +1 -1
  48. package/dist/SchemaToValidator.d.ts +99 -0
  49. package/dist/SchemaToValidator.d.ts.map +1 -0
  50. package/dist/SchemaToValidator.js +156 -0
  51. package/dist/SchemaToValidator.js.map +1 -0
  52. package/dist/Spec.d.ts +3 -2
  53. package/dist/Spec.d.ts.map +1 -1
  54. package/dist/Spec.js +1 -1
  55. package/dist/Spec.js.map +1 -1
  56. package/dist/SystemFields.d.ts +1 -1
  57. package/dist/SystemFields.d.ts.map +1 -1
  58. package/dist/SystemFields.js +2 -2
  59. package/dist/SystemFields.js.map +1 -1
  60. package/dist/Table.d.ts +74 -0
  61. package/dist/Table.d.ts.map +1 -0
  62. package/dist/Table.js +77 -0
  63. package/dist/Table.js.map +1 -0
  64. package/dist/Types.d.ts +8 -2
  65. package/dist/Types.d.ts.map +1 -1
  66. package/dist/Types.js.map +1 -1
  67. package/dist/UserIdentity.d.ts.map +1 -1
  68. package/dist/index.d.ts +5 -1
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +7 -3
  71. package/package.json +15 -14
  72. package/src/FunctionProvenance.ts +186 -31
  73. package/src/FunctionSpec.ts +313 -85
  74. package/src/GroupPath.ts +1 -6
  75. package/src/GroupSpec.ts +125 -18
  76. package/src/Lazy.ts +2 -3
  77. package/src/MiddlewareSpec.ts +356 -0
  78. package/src/PaginationError.ts +72 -0
  79. package/src/PaginationOptions.ts +23 -0
  80. package/src/PaginationResult.ts +4 -0
  81. package/src/Ref.ts +429 -208
  82. package/src/Refs.ts +41 -16
  83. package/src/SchemaToValidator.ts +603 -0
  84. package/src/Spec.ts +4 -4
  85. package/src/SystemFields.ts +6 -9
  86. package/src/Table.ts +426 -0
  87. package/src/Types.ts +9 -3
  88. package/src/index.ts +5 -1
  89. package/dist/Registry.d.ts +0 -24
  90. package/dist/Registry.d.ts.map +0 -1
  91. package/dist/Registry.js +0 -19
  92. package/dist/Registry.js.map +0 -1
  93. package/dist/tsconfig.src.tsbuildinfo +0 -1
  94. package/src/Registry.ts +0 -30
@@ -1,17 +1,19 @@
1
1
  import type {
2
+ DefaultFunctionArgs,
2
3
  FunctionType,
3
4
  FunctionVisibility,
4
5
  RegisteredAction,
5
6
  RegisteredMutation,
6
7
  RegisteredQuery,
7
8
  } from "convex/server";
8
- import type { Schema } from "effect";
9
+ import type * as Schema from "effect/Schema";
9
10
  import * as Predicate from "effect/Predicate";
10
11
  import * as FunctionProvenance from "./FunctionProvenance";
11
12
  import { validateConfectFunctionIdentifier } from "./Identifier";
13
+ import type * as MiddlewareSpec from "./MiddlewareSpec";
12
14
  import * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
13
15
 
14
- export const TypeId = "@confect/core/FunctionSpec";
16
+ export const TypeId = "~@confect/core/FunctionSpec";
15
17
  export type TypeId = typeof TypeId;
16
18
 
17
19
  export const isFunctionSpec = (u: unknown): u is AnyWithProps =>
@@ -22,12 +24,44 @@ export interface FunctionSpec<
22
24
  FunctionVisibility_ extends FunctionVisibility,
23
25
  Name_ extends string,
24
26
  FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
27
+ MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,
25
28
  > {
26
29
  readonly [TypeId]: TypeId;
27
30
  readonly runtimeAndFunctionType: RuntimeAndFunctionType_;
28
31
  readonly functionVisibility: FunctionVisibility_;
29
32
  readonly name: Name_;
30
33
  readonly functionProvenance: FunctionProvenance_;
34
+ readonly middlewareSpecs: ReadonlyArray<MiddlewareSpecs_>;
35
+ }
36
+
37
+ export interface Builder<
38
+ RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
39
+ FunctionVisibility_ extends FunctionVisibility,
40
+ Name_ extends string,
41
+ FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
42
+ MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,
43
+ > extends FunctionSpec<
44
+ RuntimeAndFunctionType_,
45
+ FunctionVisibility_,
46
+ Name_,
47
+ FunctionProvenance_,
48
+ MiddlewareSpecs_
49
+ > {
50
+ middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(
51
+ middlewareSpec: MiddlewareSpec_ &
52
+ MiddlewareSpec.ValidateFunctionAttach<
53
+ MiddlewareSpec_,
54
+ RuntimeAndFunctionType_,
55
+ FunctionProvenance_,
56
+ MiddlewareSpecs_
57
+ >,
58
+ ): Builder<
59
+ RuntimeAndFunctionType_,
60
+ FunctionVisibility_,
61
+ Name_,
62
+ FunctionProvenance_,
63
+ MiddlewareSpecs_ | MiddlewareSpec_
64
+ >;
31
65
  }
32
66
 
33
67
  export interface Any {
@@ -38,21 +72,24 @@ export interface AnyWithProps extends FunctionSpec<
38
72
  RuntimeAndFunctionType.RuntimeAndFunctionType,
39
73
  FunctionVisibility,
40
74
  string,
41
- FunctionProvenance.FunctionProvenance
75
+ FunctionProvenance.FunctionProvenance,
76
+ MiddlewareSpec.AnyMiddlewareSpec
42
77
  > {}
43
78
 
44
79
  export interface AnyConfect extends FunctionSpec<
45
80
  RuntimeAndFunctionType.RuntimeAndFunctionType,
46
81
  FunctionVisibility,
47
82
  string,
48
- FunctionProvenance.AnyConfect
83
+ FunctionProvenance.AnyConfect,
84
+ MiddlewareSpec.AnyMiddlewareSpec
49
85
  > {}
50
86
 
51
87
  export interface AnyConvex extends FunctionSpec<
52
88
  RuntimeAndFunctionType.RuntimeAndFunctionType,
53
89
  FunctionVisibility,
54
90
  string,
55
- FunctionProvenance.AnyConvex
91
+ FunctionProvenance.AnyConvex,
92
+ MiddlewareSpec.AnyMiddlewareSpec
56
93
  > {}
57
94
 
58
95
  export interface AnyWithPropsWithRuntime<
@@ -61,7 +98,8 @@ export interface AnyWithPropsWithRuntime<
61
98
  RuntimeAndFunctionType.WithRuntime<Runtime>,
62
99
  FunctionVisibility,
63
100
  string,
64
- FunctionProvenance.FunctionProvenance
101
+ FunctionProvenance.FunctionProvenance,
102
+ MiddlewareSpec.AnyMiddlewareSpec
65
103
  > {}
66
104
 
67
105
  export interface AnyWithPropsWithFunctionType<
@@ -70,7 +108,8 @@ export interface AnyWithPropsWithFunctionType<
70
108
  RuntimeAndFunctionType_,
71
109
  FunctionVisibility,
72
110
  string,
73
- FunctionProvenance.FunctionProvenance
111
+ FunctionProvenance.FunctionProvenance,
112
+ MiddlewareSpec.AnyMiddlewareSpec
74
113
  > {}
75
114
 
76
115
  export interface AnyWithPropsWithFunctionProvenance<
@@ -79,7 +118,8 @@ export interface AnyWithPropsWithFunctionProvenance<
79
118
  RuntimeAndFunctionType.RuntimeAndFunctionType,
80
119
  FunctionVisibility,
81
120
  string,
82
- FunctionProvenance_
121
+ FunctionProvenance_,
122
+ MiddlewareSpec.AnyMiddlewareSpec
83
123
  > {}
84
124
 
85
125
  export type GetRuntimeAndFunctionType<FunctionSpec_ extends AnyWithProps> =
@@ -88,83 +128,122 @@ export type GetRuntimeAndFunctionType<FunctionSpec_ extends AnyWithProps> =
88
128
  export type GetFunctionVisibility<FunctionSpec_ extends AnyWithProps> =
89
129
  FunctionSpec_["functionVisibility"];
90
130
 
131
+ export type GetFunctionProvenance<FunctionSpec_ extends AnyWithProps> =
132
+ FunctionSpec_["functionProvenance"];
133
+
91
134
  export type Name<FunctionSpec_ extends AnyWithProps> = FunctionSpec_["name"];
92
135
 
136
+ export type MiddlewareSpecs<FunctionSpec_ extends AnyWithProps> =
137
+ FunctionSpec_["middlewareSpecs"][number];
138
+
139
+ /** The field map declared by a Confect-provenance spec. */
140
+ export type ArgsFields<FunctionSpec_ extends AnyWithProps> =
141
+ FunctionSpec_ extends {
142
+ readonly functionProvenance: {
143
+ readonly _tag: "Confect";
144
+ readonly "~ArgsFields": infer ArgsFields_ extends
145
+ FunctionProvenance.ArgsFields;
146
+ };
147
+ }
148
+ ? ArgsFields_
149
+ : FunctionSpec_ extends {
150
+ readonly functionProvenance: { readonly _tag: "Confect" };
151
+ }
152
+ ? FunctionProvenance.ArgsFields
153
+ : never;
154
+
155
+ /** The args schema assembled from a Confect-provenance spec's field map. */
156
+ export type ArgsSchema<FunctionSpec_ extends AnyWithProps> =
157
+ FunctionSpec_ extends {
158
+ readonly functionProvenance: {
159
+ readonly _tag: "Confect";
160
+ readonly "~ArgsFields": infer ArgsFields_ extends
161
+ FunctionProvenance.ArgsFields;
162
+ };
163
+ }
164
+ ? Schema.Struct<ArgsFields_>
165
+ : FunctionSpec_ extends {
166
+ readonly functionProvenance: {
167
+ readonly _tag: "Confect";
168
+ readonly args: infer ArgsSchema_ extends
169
+ FunctionProvenance.AnyArgsSchema;
170
+ };
171
+ }
172
+ ? ArgsSchema_
173
+ : never;
174
+
175
+ export type ReturnsSchema<FunctionSpec_ extends AnyWithProps> =
176
+ FunctionSpec_ extends {
177
+ readonly functionProvenance: {
178
+ readonly _tag: "Confect";
179
+ readonly returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;
180
+ };
181
+ }
182
+ ? ReturnsSchema_
183
+ : never;
184
+
185
+ export type ErrorSchema<FunctionSpec_ extends AnyWithProps> =
186
+ FunctionSpec_ extends {
187
+ readonly functionProvenance: {
188
+ readonly _tag: "Confect";
189
+ readonly error?: infer ErrorSchema_ extends Schema.Codec<any, any>;
190
+ };
191
+ }
192
+ ? ErrorSchema_
193
+ : never;
194
+
93
195
  export type Args<FunctionSpec_ extends AnyWithProps> = FunctionSpec_ extends {
94
- functionProvenance: {
95
- _tag: "Confect";
96
- args: infer ArgsSchema_ extends Schema.Codec<any, any>;
97
- };
196
+ readonly functionProvenance: { readonly _tag: "Confect" };
98
197
  }
99
- ? ArgsSchema_["Type"]
100
- : FunctionSpec_ extends {
101
- functionProvenance: { _tag: "Convex"; _args: infer Args_ };
102
- }
198
+ ? ArgsSchema<FunctionSpec_>["Type"]
199
+ : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<
200
+ infer Args_,
201
+ any
202
+ >
103
203
  ? Args_
104
204
  : never;
105
205
 
106
206
  export type Returns<FunctionSpec_ extends AnyWithProps> =
107
207
  FunctionSpec_ extends {
108
- functionProvenance: {
109
- _tag: "Confect";
110
- returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;
111
- };
208
+ readonly functionProvenance: { readonly _tag: "Confect" };
112
209
  }
113
- ? ReturnsSchema_["Type"]
114
- : FunctionSpec_ extends {
115
- functionProvenance: { _tag: "Convex"; _returns: infer Returns_ };
116
- }
210
+ ? ReturnsSchema<FunctionSpec_>["Type"]
211
+ : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<
212
+ any,
213
+ infer Returns_
214
+ >
117
215
  ? Awaited<Returns_>
118
216
  : never;
119
217
 
120
218
  export type EncodedArgs<FunctionSpec_ extends AnyWithProps> =
121
219
  FunctionSpec_ extends {
122
- functionProvenance: {
123
- _tag: "Confect";
124
- args: infer ArgsSchema_ extends Schema.Codec<any, any>;
125
- };
220
+ readonly functionProvenance: { readonly _tag: "Confect" };
126
221
  }
127
- ? ArgsSchema_["Encoded"]
128
- : FunctionSpec_ extends {
129
- functionProvenance: { _tag: "Convex"; _args: infer Args_ };
130
- }
222
+ ? ArgsSchema<FunctionSpec_>["Encoded"]
223
+ : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<
224
+ infer Args_,
225
+ any
226
+ >
131
227
  ? Args_
132
228
  : never;
133
229
 
134
230
  export type EncodedReturns<FunctionSpec_ extends AnyWithProps> =
135
231
  FunctionSpec_ extends {
136
- functionProvenance: {
137
- _tag: "Confect";
138
- returns: infer ReturnsSchema_ extends Schema.Codec<any, any>;
139
- };
232
+ readonly functionProvenance: { readonly _tag: "Confect" };
140
233
  }
141
- ? ReturnsSchema_["Encoded"]
142
- : FunctionSpec_ extends {
143
- functionProvenance: { _tag: "Convex"; _returns: infer Returns_ };
144
- }
234
+ ? ReturnsSchema<FunctionSpec_>["Encoded"]
235
+ : GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<
236
+ any,
237
+ infer Returns_
238
+ >
145
239
  ? Returns_
146
240
  : never;
147
241
 
148
- export type Error<FunctionSpec_ extends AnyWithProps> = FunctionSpec_ extends {
149
- functionProvenance: FunctionProvenance.Confect<
150
- any,
151
- any,
152
- infer ErrorSchema_ extends Schema.Codec<any, any>
153
- >;
154
- }
155
- ? ErrorSchema_["Type"]
156
- : never;
242
+ export type Error<FunctionSpec_ extends AnyWithProps> =
243
+ ErrorSchema<FunctionSpec_>["Type"];
157
244
 
158
245
  export type EncodedError<FunctionSpec_ extends AnyWithProps> =
159
- FunctionSpec_ extends {
160
- functionProvenance: FunctionProvenance.Confect<
161
- any,
162
- any,
163
- infer ErrorSchema_ extends Schema.Codec<any, any>
164
- >;
165
- }
166
- ? ErrorSchema_["Encoded"]
167
- : never;
246
+ ErrorSchema<FunctionSpec_>["Encoded"];
168
247
 
169
248
  export type WithName<
170
249
  FunctionSpec_ extends AnyWithProps,
@@ -202,53 +281,193 @@ export type WithoutName<
202
281
 
203
282
  const Proto = {
204
283
  [TypeId]: TypeId,
284
+
285
+ middleware(
286
+ this: AnyWithProps,
287
+ middlewareSpec: MiddlewareSpec.AnyMiddlewareSpec,
288
+ ) {
289
+ if (this.functionProvenance._tag === "Convex") {
290
+ throw new Error(
291
+ `Plain Convex function "${this.name}" cannot have middleware`,
292
+ );
293
+ }
294
+ const functionType = this.runtimeAndFunctionType.functionType;
295
+ if (!middlewareSpec.functionTypes[functionType]) {
296
+ throw new Error(
297
+ `Middleware "${middlewareSpec.key}" does not declare function type "${functionType}" of function "${this.name}"`,
298
+ );
299
+ }
300
+ if (
301
+ this.middlewareSpecs.some(
302
+ (existing) => existing.key === middlewareSpec.key,
303
+ )
304
+ ) {
305
+ throw new Error(
306
+ `Middleware "${middlewareSpec.key}" is already attached to function "${this.name}"`,
307
+ );
308
+ }
309
+
310
+ return Object.assign(Object.create(Proto), {
311
+ runtimeAndFunctionType: this.runtimeAndFunctionType,
312
+ functionVisibility: this.functionVisibility,
313
+ name: this.name,
314
+ functionProvenance: this.functionProvenance,
315
+ middlewareSpecs: [...this.middlewareSpecs, middlewareSpec],
316
+ });
317
+ },
205
318
  };
206
319
 
207
- const make =
208
- <
209
- RuntimeAndFunctionType_ extends
210
- RuntimeAndFunctionType.RuntimeAndFunctionType,
211
- FunctionVisibility_ extends FunctionVisibility,
212
- >(
213
- runtimeAndFunctionType: RuntimeAndFunctionType_,
214
- functionVisibility: FunctionVisibility_,
215
- ) =>
216
- <
320
+ interface Options {
321
+ readonly name: string;
322
+ readonly args?: () => FunctionProvenance.ArgsFields;
323
+ readonly returns: () => Schema.Codec<any, any>;
324
+ readonly error?: () => Schema.Codec<any, any>;
325
+ }
326
+
327
+ const make = <
328
+ RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
329
+ FunctionVisibility_ extends FunctionVisibility,
330
+ >(
331
+ runtimeAndFunctionType: RuntimeAndFunctionType_,
332
+ functionVisibility: FunctionVisibility_,
333
+ ) => {
334
+ function makeSpec<
217
335
  const Name_ extends string,
218
- Args_ extends Schema.Codec<any, any>,
336
+ const ArgsFields_ extends FunctionProvenance.ArgsFields,
219
337
  Returns_ extends Schema.Codec<any, any>,
220
338
  Error_ extends Schema.Codec<any, any> = never,
221
- >({
222
- name,
223
- args,
224
- returns,
225
- error,
226
- }: {
339
+ >(options: {
227
340
  name: Name_;
228
- args: () => Args_;
341
+ args: () => ArgsFields_;
229
342
  returns: () => Returns_;
230
343
  error?: () => Error_;
231
- }): FunctionSpec<
344
+ }): Builder<
232
345
  RuntimeAndFunctionType_,
233
346
  FunctionVisibility_,
234
347
  Name_,
235
- FunctionProvenance.Confect<Args_, Returns_, Error_>
236
- > => {
348
+ FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>
349
+ >;
350
+ function makeSpec<
351
+ const Name_ extends string,
352
+ Returns_ extends Schema.Codec<any, any>,
353
+ Error_ extends Schema.Codec<any, any> = never,
354
+ >(options: {
355
+ name: Name_;
356
+ args?: never;
357
+ returns: () => Returns_;
358
+ error?: () => Error_;
359
+ }): Builder<
360
+ RuntimeAndFunctionType_,
361
+ FunctionVisibility_,
362
+ Name_,
363
+ FunctionProvenance.Confect<{}, Returns_, Error_>
364
+ >;
365
+ function makeSpec({ name, args, returns, error }: Options) {
237
366
  validateConfectFunctionIdentifier(name);
238
367
 
239
368
  return Object.assign(Object.create(Proto), {
240
369
  runtimeAndFunctionType,
241
370
  functionVisibility,
242
371
  name,
243
- functionProvenance: FunctionProvenance.Confect(args, returns, error),
372
+ functionProvenance:
373
+ args === undefined
374
+ ? FunctionProvenance.Confect(() => ({}), returns, error)
375
+ : FunctionProvenance.Confect(args, returns, error),
376
+ middlewareSpecs: [],
244
377
  });
245
- };
378
+ }
379
+
380
+ return makeSpec;
381
+ };
382
+
383
+ /**
384
+ * `Schema.Struct` fields that must not declare `paginationOpts`. Used to
385
+ * reject a user args schema that redeclares the field the paginated
386
+ * constructors add themselves; the check reports at the `args` thunk with an
387
+ * unsatisfiable type when violated.
388
+ */
389
+ type ForbidPaginationOpts<
390
+ UserArgsFields extends FunctionProvenance.ArgsFields,
391
+ > = "paginationOpts" extends keyof UserArgsFields
392
+ ? { readonly paginationOpts: never }
393
+ : unknown;
394
+
395
+ interface PaginatedOptions {
396
+ readonly name: string;
397
+ readonly args?: () => FunctionProvenance.ArgsFields;
398
+ readonly item: () => Schema.Codec<any, any>;
399
+ readonly error?: () => Schema.Codec<any, any>;
400
+ }
401
+
402
+ const makePaginated = <
403
+ RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
404
+ FunctionVisibility_ extends FunctionVisibility,
405
+ >(
406
+ runtimeAndFunctionType: RuntimeAndFunctionType_,
407
+ functionVisibility: FunctionVisibility_,
408
+ ) => {
409
+ function makeSpec<
410
+ const Name_ extends string,
411
+ const UserArgsFields_ extends FunctionProvenance.ArgsFields,
412
+ Item_ extends Schema.Codec<any, any>,
413
+ Error_ extends Schema.Codec<any, any> = never,
414
+ >(options: {
415
+ name: Name_;
416
+ args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;
417
+ item: () => Item_;
418
+ error?: () => Error_;
419
+ }): Builder<
420
+ RuntimeAndFunctionType_,
421
+ FunctionVisibility_,
422
+ Name_,
423
+ FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>
424
+ >;
425
+ function makeSpec<
426
+ const Name_ extends string,
427
+ Item_ extends Schema.Codec<any, any>,
428
+ Error_ extends Schema.Codec<any, any> = never,
429
+ >(options: {
430
+ name: Name_;
431
+ args?: never;
432
+ item: () => Item_;
433
+ error?: () => Error_;
434
+ }): Builder<
435
+ RuntimeAndFunctionType_,
436
+ FunctionVisibility_,
437
+ Name_,
438
+ FunctionProvenance.ConfectPaginated<{}, Item_, Error_>
439
+ >;
440
+ function makeSpec({ name, args, item, error }: PaginatedOptions) {
441
+ validateConfectFunctionIdentifier(name);
442
+
443
+ return Object.assign(Object.create(Proto), {
444
+ runtimeAndFunctionType,
445
+ functionVisibility,
446
+ name,
447
+ functionProvenance:
448
+ args === undefined
449
+ ? FunctionProvenance.ConfectPaginated(() => ({}), item, error)
450
+ : FunctionProvenance.ConfectPaginated(args, item, error),
451
+ middlewareSpecs: [],
452
+ });
453
+ }
454
+
455
+ return makeSpec;
456
+ };
246
457
 
247
458
  export const publicQuery = make(RuntimeAndFunctionType.ConvexQuery, "public");
248
459
  export const internalQuery = make(
249
460
  RuntimeAndFunctionType.ConvexQuery,
250
461
  "internal",
251
462
  );
463
+ export const publicPaginatedQuery = makePaginated(
464
+ RuntimeAndFunctionType.ConvexQuery,
465
+ "public",
466
+ );
467
+ export const internalPaginatedQuery = makePaginated(
468
+ RuntimeAndFunctionType.ConvexQuery,
469
+ "internal",
470
+ );
252
471
  export const publicMutation = make(
253
472
  RuntimeAndFunctionType.ConvexMutation,
254
473
  "public",
@@ -285,11 +504,19 @@ type MatchingRegisteredFunction<
285
504
  : never;
286
505
 
287
506
  type ExtractArgs<F> =
288
- F extends RegisteredQuery<any, infer A, any>
507
+ F extends RegisteredQuery<any, infer A extends DefaultFunctionArgs, any>
289
508
  ? A
290
- : F extends RegisteredMutation<any, infer A, any>
509
+ : F extends RegisteredMutation<
510
+ any,
511
+ infer A extends DefaultFunctionArgs,
512
+ any
513
+ >
291
514
  ? A
292
- : F extends RegisteredAction<any, infer A, any>
515
+ : F extends RegisteredAction<
516
+ any,
517
+ infer A extends DefaultFunctionArgs,
518
+ any
519
+ >
293
520
  ? A
294
521
  : never;
295
522
 
@@ -319,7 +546,7 @@ const makeConvex =
319
546
  >() =>
320
547
  <const Name_ extends string>(
321
548
  name: Name_,
322
- ): FunctionSpec<
549
+ ): Builder<
323
550
  RuntimeAndFunctionType_,
324
551
  FunctionVisibility_,
325
552
  Name_,
@@ -335,6 +562,7 @@ const makeConvex =
335
562
  ExtractArgs<F>,
336
563
  ExtractReturns<F>
337
564
  >(),
565
+ middlewareSpecs: [],
338
566
  }) as any;
339
567
  };
340
568
 
package/src/GroupPath.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { Record } from "effect";
2
1
  import type * as GroupSpec from "./GroupSpec";
3
2
 
4
3
  /**
@@ -41,11 +40,7 @@ export type GroupAt<
41
40
  > = Group extends GroupSpec.AnyWithProps
42
41
  ? Path extends `${infer Head}.${infer Tail}`
43
42
  ? Group extends { readonly name: Head }
44
- ? Group extends {
45
- readonly groups: Record.ReadonlyRecord<string, infer SubGroup>;
46
- }
47
- ? GroupAt<SubGroup, Tail>
48
- : never
43
+ ? GroupAt<GroupSpec.Groups<Group>, Tail>
49
44
  : never
50
45
  : GroupSpec.WithName<Group, Path>
51
46
  : never;