cvx-kit 0.1.21 → 0.1.23

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 (38) hide show
  1. package/README.md +10 -0
  2. package/dist/errors.d.mts +3 -3
  3. package/dist/errors.mjs +1 -1
  4. package/dist/errors.mjs.map +1 -1
  5. package/dist/modules/contracts/errors.d.mts +313 -0
  6. package/dist/modules/contracts/errors.mjs +1 -1
  7. package/dist/modules/contracts/errors.mjs.map +1 -1
  8. package/dist/modules/effect/client.d.mts +1 -0
  9. package/dist/querying/filter-boundary.d.mts +16 -0
  10. package/dist/querying/filter-boundary.mjs +2 -0
  11. package/dist/querying/filter-boundary.mjs.map +1 -0
  12. package/dist/querying/filters.d.mts +2 -2
  13. package/dist/querying/filters.mjs +1 -1
  14. package/dist/querying/filters.mjs.map +1 -1
  15. package/dist/querying/shared/filters.d.mts +11 -2
  16. package/dist/querying/shared/filters.mjs +1 -1
  17. package/dist/querying/shared/filters.mjs.map +1 -1
  18. package/dist/react/failures.d.mts +8 -5
  19. package/dist/react/failures.mjs +1 -1
  20. package/dist/react/failures.mjs.map +1 -1
  21. package/dist/react/use-command.d.mts +2 -1
  22. package/dist/react/use-command.mjs +1 -1
  23. package/dist/react/use-command.mjs.map +1 -1
  24. package/dist/react/use-paginated-list.d.mts +6 -2
  25. package/dist/react/use-paginated-list.mjs +1 -1
  26. package/dist/react/use-paginated-list.mjs.map +1 -1
  27. package/dist/react.d.mts +3 -3
  28. package/dist/react.mjs +1 -1
  29. package/dist/relations-public.d.mts +2 -2
  30. package/dist/relations.d.mts +5 -2
  31. package/dist/relations.mjs +1 -1
  32. package/dist/relations.mjs.map +1 -1
  33. package/dist/zod-registration.mjs +1 -1
  34. package/dist/zod-registration.mjs.map +1 -1
  35. package/dist/zod-table.d.mts +2 -1
  36. package/dist/zod-table.mjs +1 -1
  37. package/dist/zod-table.mjs.map +1 -1
  38. package/package.json +1 -1
package/README.md CHANGED
@@ -222,6 +222,16 @@ support equality, ranges, `and`, `or`, and `not`; many predicates use `some` or
222
222
  page. Parent, junction, target, and continuation reads all recheck authorization.
223
223
  `include` and `paginated(dto)` retain their existing behavior independently.
224
224
 
225
+ For large generated static APIs, opt into compact argument validators with
226
+ `paginationOpts(selection, { validator: 'compact' })` on a table or relation.
227
+ Use the resulting schema with cvx-kit's authenticated builders. Common filters
228
+ remain precisely typed; deeper generated filter branches become opaque where
229
+ native ID checks allow it. Full depth, node, membership, and value validation
230
+ still runs before customization or handler work. Use `PaginationFiltersInput`
231
+ from `cvx-kit/relations` to check deeper filter literals. See the
232
+ [compact filter guide](https://github.com/ImRLopezAG/cvx-kit/blob/main/skills/cvx-kit/references/querying.md#compact-generated-filter-validators)
233
+ for registration requirements and ID-heavy size limits.
234
+
225
235
  Chain `.when(value, 'index_name')` to choose the first present condition: `false`,
226
236
  `0`, and `''` are present; `null` and `undefined` are absent. The gate does not
227
237
  bind an index field; validated filters and server `.where(...)` constraints do.
package/dist/errors.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { DeclaredError, DeclaredFailure, DecodedFailure, ErrorContract, ErrorDefinitions, ErrorDetailParser, UnknownFailure, defineErrorContract, queryErrors } from "./modules/contracts/errors.mjs";
2
- import { FailureHandlers, decodeFailure, matchFailure } from "./react/failures.mjs";
1
+ import { DeclaredError, DeclaredFailure, DecodedFailure, ErrorContract, ErrorDefinitions, ErrorDetailParser, UnknownFailure, combineErrorContracts, decodeFailure, defineErrorContract, queryErrors } from "./modules/contracts/errors.mjs";
2
+ import { FailureHandlers, failureOf, isFailure, matchFailure } from "./react/failures.mjs";
3
3
  //#region src/errors.d.ts
4
4
  /** Structured application error carried across Convex function boundaries. */
5
5
  export declare class KitError extends Error {
@@ -22,5 +22,5 @@ export type ErrorFactory = {
22
22
  };
23
23
  export declare const defaultErrors: ErrorFactory;
24
24
  //#endregion
25
- export { type DeclaredError, type DeclaredFailure, type DecodedFailure, type ErrorContract, type ErrorDefinitions, type ErrorDetailParser, type FailureHandlers, type UnknownFailure, decodeFailure, defineErrorContract, matchFailure, queryErrors };
25
+ export { type DeclaredError, type DeclaredFailure, type DecodedFailure, type ErrorContract, type ErrorDefinitions, type ErrorDetailParser, type FailureHandlers, type UnknownFailure, combineErrorContracts, decodeFailure, defineErrorContract, failureOf, isFailure, matchFailure, queryErrors };
26
26
  //# sourceMappingURL=errors.d.mts.map
package/dist/errors.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{defineErrorContract as e,queryErrors as t}from"./modules/contracts/errors.mjs";import{decodeFailure as n,matchFailure as r}from"./react/failures.mjs";var i=class extends Error{code;constructor(e){super(e.message??e.code),this.name=`KitError`,this.code=e.code}};const a={throw(e){throw new i(e)}};export{i as KitError,n as decodeFailure,a as defaultErrors,e as defineErrorContract,r as matchFailure,t as queryErrors};
1
+ import{combineErrorContracts as e,decodeFailure as t,defineErrorContract as n,queryErrors as r}from"./modules/contracts/errors.mjs";import{failureOf as i,isFailure as a,matchFailure as o}from"./react/failures.mjs";var s=class extends Error{code;constructor(e){super(e.message??e.code),this.name=`KitError`,this.code=e.code}};const c={throw(e){throw new s(e)}};export{s as KitError,e as combineErrorContracts,t as decodeFailure,c as defaultErrors,n as defineErrorContract,i as failureOf,a as isFailure,o as matchFailure,r as queryErrors};
2
2
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["KitError","input","defaultErrors","decodeFailure","defineErrorContract","matchFailure","queryErrors"],"sources":["../src/errors.ts"],"sourcesContent":["/** Structured application error carried across Convex function boundaries. */\nexport class KitError extends Error {\n\treadonly code: string\n\n\tconstructor(input: { code: string; message?: string }) {\n\t\tsuper(input.message ?? input.code)\n\t\tthis.name = 'KitError'\n\t\tthis.code = input.code\n\t}\n}\n\nexport {\n\tdefineErrorContract,\n\tqueryErrors,\n\ttype ErrorContract,\n\ttype ErrorDefinitions,\n\ttype ErrorDetailParser,\n\ttype DeclaredError,\n\ttype DeclaredFailure,\n\ttype DecodedFailure,\n\ttype UnknownFailure,\n} from './modules/contracts/errors'\n\n/**\n * Injection seam for host error policy. Hosts with their own error taxonomy\n * (e.g. an App.errors singleton) adapt it to this shape; everyone else uses\n * the default factory below.\n */\nexport type ErrorFactory = {\n\tthrow(input: { code: string; message?: string }): never\n}\n\nexport const defaultErrors: ErrorFactory = {\n\tthrow(input) {\n\t\tthrow new KitError(input)\n\t},\n}\n\n// Pure helpers do not import React or server query-engine modules.\nexport { decodeFailure, matchFailure, type FailureHandlers } from './react/failures'\n"],"mappings":"6JACA,IAAaA,EAAb,cAA8B,KAAM,CACnC,KAEA,YAAY,EAA2C,CACtD,MAAMC,EAAM,SAAWA,EAAM,IAAI,EACjC,KAAK,KAAO,WACZ,KAAK,KAAOA,EAAM,IACnB,CACD,EAuBA,MAAaC,EAA8B,CAC1C,MAAM,EAAO,CACZ,MAAM,IAAIF,EAASC,CAAK,CACzB,CACD"}
1
+ {"version":3,"file":"errors.mjs","names":["KitError","input","defaultErrors","combineErrorContracts","decodeFailure","defineErrorContract","failureOf","isFailure","matchFailure","queryErrors"],"sources":["../src/errors.ts"],"sourcesContent":["/** Structured application error carried across Convex function boundaries. */\nexport class KitError extends Error {\n\treadonly code: string\n\n\tconstructor(input: { code: string; message?: string }) {\n\t\tsuper(input.message ?? input.code)\n\t\tthis.name = 'KitError'\n\t\tthis.code = input.code\n\t}\n}\n\nexport {\n\tdefineErrorContract,\n\tqueryErrors,\n\tcombineErrorContracts,\n\ttype ErrorContract,\n\ttype ErrorDefinitions,\n\ttype ErrorDetailParser,\n\ttype DeclaredError,\n\ttype DeclaredFailure,\n\ttype DecodedFailure,\n\ttype UnknownFailure,\n} from './modules/contracts/errors'\n\n/**\n * Injection seam for host error policy. Hosts with their own error taxonomy\n * (e.g. an App.errors singleton) adapt it to this shape; everyone else uses\n * the default factory below.\n */\nexport type ErrorFactory = {\n\tthrow(input: { code: string; message?: string }): never\n}\n\nexport const defaultErrors: ErrorFactory = {\n\tthrow(input) {\n\t\tthrow new KitError(input)\n\t},\n}\n\n// Pure helpers do not import React or server query-engine modules.\nexport {\n\tdecodeFailure,\n\tmatchFailure,\n\tfailureOf,\n\tisFailure,\n\ttype FailureHandlers,\n} from './react/failures'\n"],"mappings":"sNACA,IAAaA,EAAb,cAA8B,KAAM,CACnC,KAEA,YAAY,EAA2C,CACtD,MAAMC,EAAM,SAAWA,EAAM,IAAI,EACjC,KAAK,KAAO,WACZ,KAAK,KAAOA,EAAM,IACnB,CACD,EAwBA,MAAaC,EAA8B,CAC1C,MAAM,EAAO,CACZ,MAAM,IAAIF,EAASC,CAAK,CACzB,CACD"}
@@ -1,3 +1,4 @@
1
+ import { ConvexError } from "convex/values";
1
2
  //#region src/modules/contracts/errors.d.ts
2
3
  /** Explicit synchronous validators for the final public detail representation. */
3
4
  export type ErrorDetailParser<Output = unknown> = Readonly<{
@@ -33,12 +34,30 @@ export type ErrorContract<Definitions extends ErrorDefinitions> = Readonly<{
33
34
  create: <Key extends Code<Definitions>>(code: Key, details: Details<Definitions[NoInfer<Key>]>) => Extract<DeclaredError<Definitions>, {
34
35
  code: Key;
35
36
  }>;
37
+ envelope: <Key extends Code<Definitions>>(code: Key, details: Details<Definitions[NoInfer<Key>]>) => Extract<DeclaredFailure<Definitions>, {
38
+ code: Key;
39
+ }>;
40
+ toConvexError: <Key extends Code<Definitions>>(code: Key, details: Details<Definitions[NoInfer<Key>]>) => ConvexError<Extract<DeclaredFailure<Definitions>, {
41
+ code: Key;
42
+ }>>;
36
43
  project: (error: unknown) => DecodedFailure<Definitions>;
37
44
  /** Receives envelope data, e.g. ConvexError.data; never parses error messages. */
38
45
  decode: (payload: unknown) => DecodedFailure<Definitions>;
39
46
  }>;
40
47
  /** Closed safe codes, allowlisted details, and a versioned checked transport union. */
41
48
  export declare function defineErrorContract<const Definitions extends ErrorDefinitions>(definitions: Definitions): ErrorContract<Definitions>;
49
+ /** A structural decoder also accepts combined contracts without requiring constructors. */
50
+ export type FailureContract = Pick<ErrorContract<ErrorDefinitions>, 'decode'>;
51
+ export type FailureOf<Contract extends FailureContract> = ReturnType<Contract['decode']>;
52
+ type ProjectingContract = FailureContract & Pick<ErrorContract<ErrorDefinitions>, 'project'>;
53
+ /** Extract only ConvexError.data, including one bounded serialized JSON envelope. */
54
+ export declare function decodeFailure<Contract extends FailureContract>(error: unknown, contract: Contract): FailureOf<Contract>;
55
+ type CombinedErrorContract<Contracts extends readonly ProjectingContract[]> = Readonly<{
56
+ project: (error: unknown) => FailureOf<Contracts[number]> | UnknownFailure;
57
+ decode: (payload: unknown) => FailureOf<Contracts[number]> | UnknownFailure;
58
+ }>;
59
+ /** Ordered projection and decoding; duplicate codes retain the union of member details. */
60
+ export declare function combineErrorContracts<const Contracts extends readonly ProjectingContract[]>(...contracts: Contracts): CombinedErrorContract<Contracts>;
42
61
  /** Fixed, diagnostic-free transport shared by query endpoints and client recovery. */
43
62
  export declare const queryErrors: Readonly<{
44
63
  create: <Key extends Code<{
@@ -179,6 +198,300 @@ export declare const queryErrors: Readonly<{
179
198
  }>, {
180
199
  code: Key;
181
200
  }>;
201
+ envelope: <Key extends Code<{
202
+ readonly 'invalid-cursor': {
203
+ readonly message: "Invalid cursor";
204
+ readonly details: {};
205
+ };
206
+ readonly FIELD_GROUP_DENIED: {
207
+ readonly message: "Field group access denied";
208
+ readonly details: {};
209
+ };
210
+ readonly QUERY_FANOUT: {
211
+ readonly message: "Query fan-out limit exceeded";
212
+ readonly details: {};
213
+ };
214
+ readonly SEARCH_TEXT_REQUIRED: {
215
+ readonly message: "Search text required";
216
+ readonly details: {};
217
+ };
218
+ readonly SEARCH_END_CURSOR_UNSUPPORTED: {
219
+ readonly message: "Search end cursor unsupported";
220
+ readonly details: {};
221
+ };
222
+ readonly SEARCH_ORDER_UNSUPPORTED: {
223
+ readonly message: "Search ordering unsupported";
224
+ readonly details: {};
225
+ };
226
+ readonly SEARCH_RELATION_UNSUPPORTED: {
227
+ readonly message: "Relation search unsupported";
228
+ readonly details: {};
229
+ };
230
+ readonly SEARCH_OPTIONS_UNSUPPORTED: {
231
+ readonly message: "Search options unsupported";
232
+ readonly details: {};
233
+ };
234
+ readonly SEARCH_PROTOCOL_UNSUPPORTED: {
235
+ readonly message: "Search pagination protocol unsupported";
236
+ readonly details: {};
237
+ };
238
+ }>>(code: Key, details: Details<{
239
+ readonly 'invalid-cursor': {
240
+ readonly message: "Invalid cursor";
241
+ readonly details: {};
242
+ };
243
+ readonly FIELD_GROUP_DENIED: {
244
+ readonly message: "Field group access denied";
245
+ readonly details: {};
246
+ };
247
+ readonly QUERY_FANOUT: {
248
+ readonly message: "Query fan-out limit exceeded";
249
+ readonly details: {};
250
+ };
251
+ readonly SEARCH_TEXT_REQUIRED: {
252
+ readonly message: "Search text required";
253
+ readonly details: {};
254
+ };
255
+ readonly SEARCH_END_CURSOR_UNSUPPORTED: {
256
+ readonly message: "Search end cursor unsupported";
257
+ readonly details: {};
258
+ };
259
+ readonly SEARCH_ORDER_UNSUPPORTED: {
260
+ readonly message: "Search ordering unsupported";
261
+ readonly details: {};
262
+ };
263
+ readonly SEARCH_RELATION_UNSUPPORTED: {
264
+ readonly message: "Relation search unsupported";
265
+ readonly details: {};
266
+ };
267
+ readonly SEARCH_OPTIONS_UNSUPPORTED: {
268
+ readonly message: "Search options unsupported";
269
+ readonly details: {};
270
+ };
271
+ readonly SEARCH_PROTOCOL_UNSUPPORTED: {
272
+ readonly message: "Search pagination protocol unsupported";
273
+ readonly details: {};
274
+ };
275
+ }[NoInfer<Key>]>) => Extract<Readonly<{
276
+ _tag: 'DeclaredFailure';
277
+ version: 1;
278
+ code: "FIELD_GROUP_DENIED";
279
+ message: string;
280
+ details: {};
281
+ }>, {
282
+ code: Key;
283
+ }> | Extract<Readonly<{
284
+ _tag: 'DeclaredFailure';
285
+ version: 1;
286
+ code: "QUERY_FANOUT";
287
+ message: string;
288
+ details: {};
289
+ }>, {
290
+ code: Key;
291
+ }> | Extract<Readonly<{
292
+ _tag: 'DeclaredFailure';
293
+ version: 1;
294
+ code: "SEARCH_END_CURSOR_UNSUPPORTED";
295
+ message: string;
296
+ details: {};
297
+ }>, {
298
+ code: Key;
299
+ }> | Extract<Readonly<{
300
+ _tag: 'DeclaredFailure';
301
+ version: 1;
302
+ code: "SEARCH_OPTIONS_UNSUPPORTED";
303
+ message: string;
304
+ details: {};
305
+ }>, {
306
+ code: Key;
307
+ }> | Extract<Readonly<{
308
+ _tag: 'DeclaredFailure';
309
+ version: 1;
310
+ code: "SEARCH_ORDER_UNSUPPORTED";
311
+ message: string;
312
+ details: {};
313
+ }>, {
314
+ code: Key;
315
+ }> | Extract<Readonly<{
316
+ _tag: 'DeclaredFailure';
317
+ version: 1;
318
+ code: "SEARCH_PROTOCOL_UNSUPPORTED";
319
+ message: string;
320
+ details: {};
321
+ }>, {
322
+ code: Key;
323
+ }> | Extract<Readonly<{
324
+ _tag: 'DeclaredFailure';
325
+ version: 1;
326
+ code: "SEARCH_RELATION_UNSUPPORTED";
327
+ message: string;
328
+ details: {};
329
+ }>, {
330
+ code: Key;
331
+ }> | Extract<Readonly<{
332
+ _tag: 'DeclaredFailure';
333
+ version: 1;
334
+ code: "SEARCH_TEXT_REQUIRED";
335
+ message: string;
336
+ details: {};
337
+ }>, {
338
+ code: Key;
339
+ }> | Extract<Readonly<{
340
+ _tag: 'DeclaredFailure';
341
+ version: 1;
342
+ code: "invalid-cursor";
343
+ message: string;
344
+ details: {};
345
+ }>, {
346
+ code: Key;
347
+ }>;
348
+ toConvexError: <Key extends Code<{
349
+ readonly 'invalid-cursor': {
350
+ readonly message: "Invalid cursor";
351
+ readonly details: {};
352
+ };
353
+ readonly FIELD_GROUP_DENIED: {
354
+ readonly message: "Field group access denied";
355
+ readonly details: {};
356
+ };
357
+ readonly QUERY_FANOUT: {
358
+ readonly message: "Query fan-out limit exceeded";
359
+ readonly details: {};
360
+ };
361
+ readonly SEARCH_TEXT_REQUIRED: {
362
+ readonly message: "Search text required";
363
+ readonly details: {};
364
+ };
365
+ readonly SEARCH_END_CURSOR_UNSUPPORTED: {
366
+ readonly message: "Search end cursor unsupported";
367
+ readonly details: {};
368
+ };
369
+ readonly SEARCH_ORDER_UNSUPPORTED: {
370
+ readonly message: "Search ordering unsupported";
371
+ readonly details: {};
372
+ };
373
+ readonly SEARCH_RELATION_UNSUPPORTED: {
374
+ readonly message: "Relation search unsupported";
375
+ readonly details: {};
376
+ };
377
+ readonly SEARCH_OPTIONS_UNSUPPORTED: {
378
+ readonly message: "Search options unsupported";
379
+ readonly details: {};
380
+ };
381
+ readonly SEARCH_PROTOCOL_UNSUPPORTED: {
382
+ readonly message: "Search pagination protocol unsupported";
383
+ readonly details: {};
384
+ };
385
+ }>>(code: Key, details: Details<{
386
+ readonly 'invalid-cursor': {
387
+ readonly message: "Invalid cursor";
388
+ readonly details: {};
389
+ };
390
+ readonly FIELD_GROUP_DENIED: {
391
+ readonly message: "Field group access denied";
392
+ readonly details: {};
393
+ };
394
+ readonly QUERY_FANOUT: {
395
+ readonly message: "Query fan-out limit exceeded";
396
+ readonly details: {};
397
+ };
398
+ readonly SEARCH_TEXT_REQUIRED: {
399
+ readonly message: "Search text required";
400
+ readonly details: {};
401
+ };
402
+ readonly SEARCH_END_CURSOR_UNSUPPORTED: {
403
+ readonly message: "Search end cursor unsupported";
404
+ readonly details: {};
405
+ };
406
+ readonly SEARCH_ORDER_UNSUPPORTED: {
407
+ readonly message: "Search ordering unsupported";
408
+ readonly details: {};
409
+ };
410
+ readonly SEARCH_RELATION_UNSUPPORTED: {
411
+ readonly message: "Relation search unsupported";
412
+ readonly details: {};
413
+ };
414
+ readonly SEARCH_OPTIONS_UNSUPPORTED: {
415
+ readonly message: "Search options unsupported";
416
+ readonly details: {};
417
+ };
418
+ readonly SEARCH_PROTOCOL_UNSUPPORTED: {
419
+ readonly message: "Search pagination protocol unsupported";
420
+ readonly details: {};
421
+ };
422
+ }[NoInfer<Key>]>) => ConvexError<Extract<Readonly<{
423
+ _tag: 'DeclaredFailure';
424
+ version: 1;
425
+ code: "FIELD_GROUP_DENIED";
426
+ message: string;
427
+ details: {};
428
+ }>, {
429
+ code: Key;
430
+ }> | Extract<Readonly<{
431
+ _tag: 'DeclaredFailure';
432
+ version: 1;
433
+ code: "QUERY_FANOUT";
434
+ message: string;
435
+ details: {};
436
+ }>, {
437
+ code: Key;
438
+ }> | Extract<Readonly<{
439
+ _tag: 'DeclaredFailure';
440
+ version: 1;
441
+ code: "SEARCH_END_CURSOR_UNSUPPORTED";
442
+ message: string;
443
+ details: {};
444
+ }>, {
445
+ code: Key;
446
+ }> | Extract<Readonly<{
447
+ _tag: 'DeclaredFailure';
448
+ version: 1;
449
+ code: "SEARCH_OPTIONS_UNSUPPORTED";
450
+ message: string;
451
+ details: {};
452
+ }>, {
453
+ code: Key;
454
+ }> | Extract<Readonly<{
455
+ _tag: 'DeclaredFailure';
456
+ version: 1;
457
+ code: "SEARCH_ORDER_UNSUPPORTED";
458
+ message: string;
459
+ details: {};
460
+ }>, {
461
+ code: Key;
462
+ }> | Extract<Readonly<{
463
+ _tag: 'DeclaredFailure';
464
+ version: 1;
465
+ code: "SEARCH_PROTOCOL_UNSUPPORTED";
466
+ message: string;
467
+ details: {};
468
+ }>, {
469
+ code: Key;
470
+ }> | Extract<Readonly<{
471
+ _tag: 'DeclaredFailure';
472
+ version: 1;
473
+ code: "SEARCH_RELATION_UNSUPPORTED";
474
+ message: string;
475
+ details: {};
476
+ }>, {
477
+ code: Key;
478
+ }> | Extract<Readonly<{
479
+ _tag: 'DeclaredFailure';
480
+ version: 1;
481
+ code: "SEARCH_TEXT_REQUIRED";
482
+ message: string;
483
+ details: {};
484
+ }>, {
485
+ code: Key;
486
+ }> | Extract<Readonly<{
487
+ _tag: 'DeclaredFailure';
488
+ version: 1;
489
+ code: "invalid-cursor";
490
+ message: string;
491
+ details: {};
492
+ }>, {
493
+ code: Key;
494
+ }>>;
182
495
  project: (error: unknown) => DecodedFailure<{
183
496
  readonly 'invalid-cursor': {
184
497
  readonly message: "Invalid cursor";
@@ -1,2 +1,2 @@
1
- const e=Object.freeze({_tag:`UnknownFailure`,version:1});function t(t){let n=Object.fromEntries(Object.entries(t).map(([e,t])=>{if(!e||!t.message||t.message.length>200)throw Error(`Declared errors require a code and a public message of 1–200 characters`);return[e,{message:t.message,details:{...t.details}}]})),o=/* @__PURE__ */ new WeakMap;return{create(e,t){let r;try{if(!Object.hasOwn(n,e))throw Error(`Undeclared code`);let i=n[e];r={_tag:`DeclaredFailure`,version:1,code:e,message:i.message,details:a(i,t,!1)}}catch{throw Error(`Invalid declared error details`)}let s=Object.freeze({_tag:`DeclaredError`,code:e,details:i(r.details)});return o.set(s,r),s},project(t){if(typeof t!=`object`||!t)return e;let n=o.get(t);return n?i(n):e},decode(t){try{if(!r(t)||t._tag!==`DeclaredFailure`||t.version!==1||typeof t.code!=`string`||!Object.hasOwn(n,t.code)||Object.keys(t).length!==5||![`message`,`details`,`_tag`,`version`,`code`].every(e=>Object.hasOwn(t,e)))return e;let o=n[t.code];return t.message===o.message?(i(t.details),{_tag:`DeclaredFailure`,version:1,code:t.code,message:o.message,details:a(o,t.details,!0)}):e}catch{return e}}}}const n=t({"invalid-cursor":{message:`Invalid cursor`,details:{}},FIELD_GROUP_DENIED:{message:`Field group access denied`,details:{}},QUERY_FANOUT:{message:`Query fan-out limit exceeded`,details:{}},SEARCH_TEXT_REQUIRED:{message:`Search text required`,details:{}},SEARCH_END_CURSOR_UNSUPPORTED:{message:`Search end cursor unsupported`,details:{}},SEARCH_ORDER_UNSUPPORTED:{message:`Search ordering unsupported`,details:{}},SEARCH_RELATION_UNSUPPORTED:{message:`Relation search unsupported`,details:{}},SEARCH_OPTIONS_UNSUPPORTED:{message:`Search options unsupported`,details:{}},SEARCH_PROTOCOL_UNSUPPORTED:{message:`Search pagination protocol unsupported`,details:{}}});function r(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function i(e,t=/* @__PURE__ */ new Set){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`object`||!e||t.has(e))throw Error(`Invalid JSON`);t.add(e);try{if(Array.isArray(e)){let n=[];for(let r=0;r<e.length;r++)n.push(i(e[r],t));return n}if(!r(e))throw Error(`Invalid JSON`);return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,i(n,t)]))}finally{t.delete(e)}}function a(e,t,n){if(!r(t))throw Error(`Invalid details`);let a=Object.keys(e.details);if(n&&Object.keys(t).some(t=>!Object.hasOwn(e.details,t)))throw Error(`Undeclared detail`);return Object.fromEntries(a.map(n=>{if(!Object.hasOwn(t,n))throw Error(`Missing detail`);return[n,i(e.details[n].parse(t[n]))]}))}export{t as defineErrorContract,n as queryErrors};
1
+ import{ConvexError as e}from"convex/values";const t=Object.freeze({_tag:`UnknownFailure`,version:1});function n(n){let r=Object.fromEntries(Object.entries(n).map(([e,t])=>{if(!e||!t.message||t.message.length>200)throw Error(`Declared errors require a code and a public message of 1–200 characters`);return[e,{message:t.message,details:{...t.details}}]})),i=/* @__PURE__ */ new WeakMap,a={create(e,t){let n;try{if(!Object.hasOwn(r,e))throw Error(`Undeclared code`);let i=r[e];n={_tag:`DeclaredFailure`,version:1,code:e,message:i.message,details:c(i,t,!1)}}catch{throw Error(`Invalid declared error details`)}let a=Object.freeze({_tag:`DeclaredError`,code:e,details:s(n.details)});return i.set(a,n),a},envelope(e,t){return a.project(a.create(e,t))},toConvexError(t,n){return new e(a.envelope(t,n))},project(e){if(typeof e!=`object`||!e)return t;let n=i.get(e);return n?s(n):t},decode(e){try{if(!o(e)||e._tag!==`DeclaredFailure`||e.version!==1||typeof e.code!=`string`||!Object.hasOwn(r,e.code)||Object.keys(e).length!==5||![`message`,`details`,`_tag`,`version`,`code`].every(t=>Object.hasOwn(e,t)))return t;let n=r[e.code];return e.message===n.message?(s(e.details),{_tag:`DeclaredFailure`,version:1,code:e.code,message:n.message,details:c(n,e.details,!0)}):t}catch{return t}}};return a}function r(n,r){try{if(n instanceof e){let e=n.data;if(typeof e==`string`){if(e.length>65536||new TextEncoder().encode(e).byteLength>65536)return t;e=JSON.parse(e)}return r.decode(e)}}catch{}return t}function i(...e){let n=t;return{project(t){for(let n of e){let e=n.project(t);if(e._tag===`DeclaredFailure`)return e;let i=r(t,n);if(i._tag===`DeclaredFailure`)return i}return n},decode(t){for(let n of e){let e=n.decode(t);if(e._tag===`DeclaredFailure`)return e}return n}}}const a=n({"invalid-cursor":{message:`Invalid cursor`,details:{}},FIELD_GROUP_DENIED:{message:`Field group access denied`,details:{}},QUERY_FANOUT:{message:`Query fan-out limit exceeded`,details:{}},SEARCH_TEXT_REQUIRED:{message:`Search text required`,details:{}},SEARCH_END_CURSOR_UNSUPPORTED:{message:`Search end cursor unsupported`,details:{}},SEARCH_ORDER_UNSUPPORTED:{message:`Search ordering unsupported`,details:{}},SEARCH_RELATION_UNSUPPORTED:{message:`Relation search unsupported`,details:{}},SEARCH_OPTIONS_UNSUPPORTED:{message:`Search options unsupported`,details:{}},SEARCH_PROTOCOL_UNSUPPORTED:{message:`Search pagination protocol unsupported`,details:{}}});function o(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function s(e,t=/* @__PURE__ */ new Set){if(e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&Number.isFinite(e))return e;if(typeof e!=`object`||!e||t.has(e))throw Error(`Invalid JSON`);t.add(e);try{if(Array.isArray(e)){let n=[];for(let r=0;r<e.length;r++)n.push(s(e[r],t));return n}if(!o(e))throw Error(`Invalid JSON`);return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,s(n,t)]))}finally{t.delete(e)}}function c(e,t,n){if(!o(t))throw Error(`Invalid details`);let r=Object.keys(e.details);if(n&&Object.keys(t).some(t=>!Object.hasOwn(e.details,t)))throw Error(`Undeclared detail`);return Object.fromEntries(r.map(n=>{if(!Object.hasOwn(t,n))throw Error(`Missing detail`);return[n,s(e.details[n].parse(t[n]))]}))}export{i as combineErrorContracts,r as decodeFailure,n as defineErrorContract,a as queryErrors};
2
2
  //# sourceMappingURL=errors.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","names":["unknownFailure","defineErrorContract","declarations","definitions","code","definition","trusted","envelope","parseDetails","details","error","copyJson","isRecord","payload","key","queryErrors","value","prototype","ancestors","result","index","child","fields","strict","field"],"sources":["../../../src/modules/contracts/errors.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-unknown-parameters, anti-slop/no-unknown-returns, anti-slop/no-unknown-type-aliases, anti-slop/no-runtime-typeof, anti-slop/no-unsafe-dictionary-type -- This neutral contract validates unknown transport data and an explicitly keyed code/detail declaration. */\n\n/** Explicit synchronous validators for the final public detail representation. */\nexport type ErrorDetailParser<Output = unknown> = Readonly<{\n\tparse: (value: unknown) => Output\n}>\n\nexport type ErrorDefinitions = Readonly<\n\tRecord<\n\t\tstring,\n\t\tReadonly<{\n\t\t\tmessage: string\n\t\t\tdetails: Readonly<Record<string, ErrorDetailParser>>\n\t\t}>\n\t>\n>\n\ntype Code<Definitions extends ErrorDefinitions> = Extract<keyof Definitions, string>\ntype Details<Definition extends ErrorDefinitions[string]> =\n\tDefinition extends ErrorDefinitions[string]\n\t\t? { [Field in keyof Definition['details']]: ReturnType<Definition['details'][Field]['parse']> }\n\t\t: never\n\ndeclare const declaredErrorBrand: unique symbol\n\n/** Server failures are trusted only by the contract that created them. */\nexport type DeclaredError<Definitions extends ErrorDefinitions> = {\n\t[Key in Code<Definitions>]: Readonly<{\n\t\t_tag: 'DeclaredError'\n\t\tcode: Key\n\t\tdetails: Details<Definitions[Key]>\n\t\t[declaredErrorBrand]: true\n\t}>\n}[Code<Definitions>]\n\nexport type DeclaredFailure<Definitions extends ErrorDefinitions> = {\n\t[Key in Code<Definitions>]: Readonly<{\n\t\t_tag: 'DeclaredFailure'\n\t\tversion: 1\n\t\tcode: Key\n\t\tmessage: string\n\t\tdetails: Details<Definitions[Key]>\n\t}>\n}[Code<Definitions>]\n\nexport type UnknownFailure = Readonly<{ _tag: 'UnknownFailure'; version: 1 }>\nexport type DecodedFailure<Definitions extends ErrorDefinitions> =\n\tDeclaredFailure<Definitions> | UnknownFailure\n\nexport type ErrorContract<Definitions extends ErrorDefinitions> = Readonly<{\n\tcreate: <Key extends Code<Definitions>>(\n\t\tcode: Key,\n\t\tdetails: Details<Definitions[NoInfer<Key>]>,\n\t) => Extract<DeclaredError<Definitions>, { code: Key }>\n\tproject: (error: unknown) => DecodedFailure<Definitions>\n\t/** Receives envelope data, e.g. ConvexError.data; never parses error messages. */\n\tdecode: (payload: unknown) => DecodedFailure<Definitions>\n}>\n\nconst unknownFailure: UnknownFailure = Object.freeze({\n\t_tag: 'UnknownFailure',\n\tversion: 1,\n})\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\n/** Closed safe codes, allowlisted details, and a versioned checked transport union. */\nexport function defineErrorContract<const Definitions extends ErrorDefinitions>(\n\tdefinitions: Definitions,\n): ErrorContract<Definitions> {\n\t// SAFETY: the snapshot copies every declaration without changing its code, message or paired parsers.\n\tconst declarations = Object.fromEntries(\n\t\tObject.entries(definitions).map(([code, definition]) => {\n\t\t\tif (!code || !definition.message || definition.message.length > 200) {\n\t\t\t\tthrow Error('Declared errors require a code and a public message of 1–200 characters')\n\t\t\t}\n\t\t\treturn [code, { message: definition.message, details: { ...definition.details } }]\n\t\t}),\n\t) as Definitions\n\tconst trusted = new WeakMap<object, DeclaredFailure<Definitions>>()\n\treturn {\n\t\tcreate(code, details) {\n\t\t\tlet envelope: DeclaredFailure<Definitions>\n\t\t\ttry {\n\t\t\t\tif (!Object.hasOwn(declarations, code)) throw Error('Undeclared code')\n\t\t\t\tconst definition = declarations[code]\n\t\t\t\t// SAFETY: the selected closed declaration validates every field before construction.\n\t\t\t\tenvelope = {\n\t\t\t\t\t_tag: 'DeclaredFailure',\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tcode,\n\t\t\t\t\tmessage: definition.message,\n\t\t\t\t\tdetails: parseDetails(definition, details, false),\n\t\t\t\t} as DeclaredFailure<Definitions>\n\t\t\t} catch {\n\t\t\t\t// Validator messages, issue paths and provider causes remain private.\n\t\t\t\tthrow Error('Invalid declared error details')\n\t\t\t}\n\t\t\t// SAFETY: identity is registered below; the inaccessible brand cannot confer trust by itself.\n\t\t\tconst error = Object.freeze({\n\t\t\t\t_tag: 'DeclaredError',\n\t\t\t\tcode,\n\t\t\t\tdetails: copyJson(envelope.details),\n\t\t\t}) as Extract<DeclaredError<Definitions>, { code: typeof code }>\n\t\t\ttrusted.set(error, envelope)\n\t\t\treturn error\n\t\t},\n\t\tproject(error) {\n\t\t\tif (error === null || typeof error !== 'object') return unknownFailure\n\t\t\tconst envelope = trusted.get(error)\n\t\t\t// SAFETY: only validated contract-owned envelopes enter the private map.\n\t\t\treturn envelope ? (copyJson(envelope) as DeclaredFailure<Definitions>) : unknownFailure\n\t\t},\n\t\tdecode(payload) {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\t!isRecord(payload) ||\n\t\t\t\t\tpayload._tag !== 'DeclaredFailure' ||\n\t\t\t\t\tpayload.version !== 1 ||\n\t\t\t\t\ttypeof payload.code !== 'string' ||\n\t\t\t\t\t!Object.hasOwn(declarations, payload.code) ||\n\t\t\t\t\tObject.keys(payload).length !== 5 ||\n\t\t\t\t\t!['message', 'details', '_tag', 'version', 'code'].every((key) =>\n\t\t\t\t\t\tObject.hasOwn(payload, key),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn unknownFailure\n\t\t\t\t}\n\t\t\t\tconst definition = declarations[payload.code]\n\t\t\t\tif (payload.message !== definition.message) return unknownFailure\n\t\t\t\t// Validate raw transport JSON too: parsers must not hide non-JSON payloads.\n\t\t\t\tcopyJson(payload.details)\n\t\t\t\t// SAFETY: code membership and every allowlisted field have been checked independently.\n\t\t\t\treturn {\n\t\t\t\t\t_tag: 'DeclaredFailure',\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tcode: payload.code,\n\t\t\t\t\tmessage: definition.message,\n\t\t\t\t\tdetails: parseDetails(definition, payload.details, true),\n\t\t\t\t} as DeclaredFailure<Definitions>\n\t\t\t} catch {\n\t\t\t\treturn unknownFailure\n\t\t\t}\n\t\t},\n\t}\n}\n\n/** Fixed, diagnostic-free transport shared by query endpoints and client recovery. */\nexport const queryErrors = defineErrorContract({\n\t'invalid-cursor': { message: 'Invalid cursor', details: {} },\n\tFIELD_GROUP_DENIED: { message: 'Field group access denied', details: {} },\n\tQUERY_FANOUT: { message: 'Query fan-out limit exceeded', details: {} },\n\tSEARCH_TEXT_REQUIRED: { message: 'Search text required', details: {} },\n\tSEARCH_END_CURSOR_UNSUPPORTED: {\n\t\tmessage: 'Search end cursor unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_ORDER_UNSUPPORTED: {\n\t\tmessage: 'Search ordering unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_RELATION_UNSUPPORTED: {\n\t\tmessage: 'Relation search unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_OPTIONS_UNSUPPORTED: {\n\t\tmessage: 'Search options unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_PROTOCOL_UNSUPPORTED: {\n\t\tmessage: 'Search pagination protocol unsupported',\n\t\tdetails: {},\n\t},\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\tconst prototype = Object.getPrototypeOf(value)\n\treturn prototype === Object.prototype || prototype === null\n}\n\n/** Copy data without invoking toJSON or retaining mutable provider objects. */\nfunction copyJson(value: unknown, ancestors = new Set<object>()): Json {\n\tif (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n\tif (typeof value === 'number' && Number.isFinite(value)) return value\n\tif (typeof value !== 'object' || value === null || ancestors.has(value))\n\t\tthrow Error('Invalid JSON')\n\tancestors.add(value)\n\ttry {\n\t\tif (Array.isArray(value)) {\n\t\t\tconst result: Json[] = []\n\t\t\tfor (let index = 0; index < value.length; index++)\n\t\t\t\tresult.push(copyJson(value[index], ancestors))\n\t\t\treturn result\n\t\t}\n\t\tif (!isRecord(value)) throw Error('Invalid JSON')\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value).map(([key, child]) => [key, copyJson(child, ancestors)]),\n\t\t)\n\t} finally {\n\t\tancestors.delete(value)\n\t}\n}\n\nfunction parseDetails<const Definition extends ErrorDefinitions[string]>(\n\tdefinition: Definition,\n\tvalue: unknown,\n\tstrict: boolean,\n): Details<Definition> {\n\tif (!isRecord(value)) throw Error('Invalid details')\n\tconst fields = Object.keys(definition.details)\n\tif (strict && Object.keys(value).some((key) => !Object.hasOwn(definition.details, key))) {\n\t\tthrow Error('Undeclared detail')\n\t}\n\t// SAFETY: each declared field is validated by its paired parser before its JSON-safe copy is returned.\n\treturn Object.fromEntries(\n\t\tfields.map((field) => {\n\t\t\tif (!Object.hasOwn(value, field)) throw Error('Missing detail')\n\t\t\treturn [field, copyJson(definition.details[field].parse(value[field]))]\n\t\t}),\n\t) as Details<Definition>\n}\n"],"mappings":"AA2DA,MAAMA,EAAiC,OAAO,OAAO,CACpD,KAAM,iBACN,QAAS,CACV,CAAC,EAID,SAAgBC,EACf,EAC6B,CAE7B,IAAMC,EAAe,OAAO,YAC3B,OAAO,QAAQC,CAAW,CAAC,CAAC,KAAK,CAACC,EAAMC,KAAgB,CACvD,GAAI,CAACD,GAAQ,CAACC,EAAW,SAAWA,EAAW,QAAQ,OAAS,IAC/D,MAAM,MAAM,yEAAyE,EAEtF,MAAO,CAACD,EAAM,CAAE,QAASC,EAAW,QAAS,QAAS,CAAE,GAAGA,EAAW,OAAQ,CAAE,CAAC,CAClF,CAAC,CACF,EACMC,kBAAU,IAAI,QACpB,MAAO,CACN,OAAO,EAAM,EAAS,CACrB,IAAIC,EACJ,GAAI,CACH,GAAI,CAAC,OAAO,OAAOL,EAAcE,CAAI,EAAG,MAAM,MAAM,iBAAiB,EACrE,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ASR,EACR,EACA,EACA,EACsB,CACtB,GAAI,CAACI,EAASI,CAAK,EAAG,MAAM,MAAM,iBAAiB,EACnD,IAAMM,EAAS,OAAO,KAAKjB,EAAW,OAAO,EAC7C,GAAIkB,GAAU,OAAO,KAAKP,CAAK,CAAC,CAAC,KAAM,GAAQ,CAAC,OAAO,OAAOX,EAAW,QAASS,CAAG,CAAC,EACrF,MAAM,MAAM,mBAAmB,EAGhC,OAAO,OAAO,YACbQ,EAAO,IAAK,GAAU,CACrB,GAAI,CAAC,OAAO,OAAON,EAAOQ,CAAK,EAAG,MAAM,MAAM,gBAAgB,EAC9D,MAAO,CAACA,EAAOb,EAASN,EAAW,QAAQmB,EAAM,CAAC,MAAMR,EAAMQ,EAAM,CAAC,CAAC,CACvE,CAAC,CACF,CACD"}
1
+ {"version":3,"file":"errors.mjs","names":["unknownFailure","defineErrorContract","declarations","definitions","code","definition","trusted","contract","envelope","parseDetails","details","error","copyJson","ConvexError","isRecord","payload","key","decodeFailure","combineErrorContracts","contracts","unmatched","projected","decoded","queryErrors","value","prototype","ancestors","result","index","child","fields","strict","field"],"sources":["../../../src/modules/contracts/errors.ts"],"sourcesContent":["/* oxlint-disable anti-slop/no-unknown-parameters, anti-slop/no-unknown-returns, anti-slop/no-unknown-type-aliases, anti-slop/no-runtime-typeof, anti-slop/no-unsafe-dictionary-type -- This neutral contract validates unknown transport data and an explicitly keyed code/detail declaration. */\n\nimport { ConvexError } from 'convex/values'\n\n/** Explicit synchronous validators for the final public detail representation. */\nexport type ErrorDetailParser<Output = unknown> = Readonly<{\n\tparse: (value: unknown) => Output\n}>\n\nexport type ErrorDefinitions = Readonly<\n\tRecord<\n\t\tstring,\n\t\tReadonly<{\n\t\t\tmessage: string\n\t\t\tdetails: Readonly<Record<string, ErrorDetailParser>>\n\t\t}>\n\t>\n>\n\ntype Code<Definitions extends ErrorDefinitions> = Extract<keyof Definitions, string>\ntype Details<Definition extends ErrorDefinitions[string]> =\n\tDefinition extends ErrorDefinitions[string]\n\t\t? { [Field in keyof Definition['details']]: ReturnType<Definition['details'][Field]['parse']> }\n\t\t: never\n\ndeclare const declaredErrorBrand: unique symbol\n\n/** Server failures are trusted only by the contract that created them. */\nexport type DeclaredError<Definitions extends ErrorDefinitions> = {\n\t[Key in Code<Definitions>]: Readonly<{\n\t\t_tag: 'DeclaredError'\n\t\tcode: Key\n\t\tdetails: Details<Definitions[Key]>\n\t\t[declaredErrorBrand]: true\n\t}>\n}[Code<Definitions>]\n\nexport type DeclaredFailure<Definitions extends ErrorDefinitions> = {\n\t[Key in Code<Definitions>]: Readonly<{\n\t\t_tag: 'DeclaredFailure'\n\t\tversion: 1\n\t\tcode: Key\n\t\tmessage: string\n\t\tdetails: Details<Definitions[Key]>\n\t}>\n}[Code<Definitions>]\n\nexport type UnknownFailure = Readonly<{ _tag: 'UnknownFailure'; version: 1 }>\nexport type DecodedFailure<Definitions extends ErrorDefinitions> =\n\t| DeclaredFailure<Definitions>\n\t| UnknownFailure\n\nexport type ErrorContract<Definitions extends ErrorDefinitions> = Readonly<{\n\tcreate: <Key extends Code<Definitions>>(\n\t\tcode: Key,\n\t\tdetails: Details<Definitions[NoInfer<Key>]>,\n\t) => Extract<DeclaredError<Definitions>, { code: Key }>\n\tenvelope: <Key extends Code<Definitions>>(\n\t\tcode: Key,\n\t\tdetails: Details<Definitions[NoInfer<Key>]>,\n\t) => Extract<DeclaredFailure<Definitions>, { code: Key }>\n\ttoConvexError: <Key extends Code<Definitions>>(\n\t\tcode: Key,\n\t\tdetails: Details<Definitions[NoInfer<Key>]>,\n\t) => ConvexError<Extract<DeclaredFailure<Definitions>, { code: Key }>>\n\tproject: (error: unknown) => DecodedFailure<Definitions>\n\t/** Receives envelope data, e.g. ConvexError.data; never parses error messages. */\n\tdecode: (payload: unknown) => DecodedFailure<Definitions>\n}>\n\nconst unknownFailure: UnknownFailure = Object.freeze({\n\t_tag: 'UnknownFailure',\n\tversion: 1,\n})\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json }\n\n/** Closed safe codes, allowlisted details, and a versioned checked transport union. */\nexport function defineErrorContract<const Definitions extends ErrorDefinitions>(\n\tdefinitions: Definitions,\n): ErrorContract<Definitions> {\n\t// SAFETY: the snapshot copies every declaration without changing its code, message or paired parsers.\n\tconst declarations = Object.fromEntries(\n\t\tObject.entries(definitions).map(([code, definition]) => {\n\t\t\tif (!code || !definition.message || definition.message.length > 200) {\n\t\t\t\tthrow Error('Declared errors require a code and a public message of 1–200 characters')\n\t\t\t}\n\t\t\treturn [code, { message: definition.message, details: { ...definition.details } }]\n\t\t}),\n\t) as Definitions\n\tconst trusted = new WeakMap<object, DeclaredFailure<Definitions>>()\n\tconst contract: ErrorContract<Definitions> = {\n\t\tcreate(code, details) {\n\t\t\tlet envelope: DeclaredFailure<Definitions>\n\t\t\ttry {\n\t\t\t\tif (!Object.hasOwn(declarations, code)) throw Error('Undeclared code')\n\t\t\t\tconst definition = declarations[code]\n\t\t\t\t// SAFETY: the selected closed declaration validates every field before construction.\n\t\t\t\tenvelope = {\n\t\t\t\t\t_tag: 'DeclaredFailure',\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tcode,\n\t\t\t\t\tmessage: definition.message,\n\t\t\t\t\tdetails: parseDetails(definition, details, false),\n\t\t\t\t} as DeclaredFailure<Definitions>\n\t\t\t} catch {\n\t\t\t\t// Validator messages, issue paths and provider causes remain private.\n\t\t\t\tthrow Error('Invalid declared error details')\n\t\t\t}\n\t\t\t// SAFETY: identity is registered below; the inaccessible brand cannot confer trust by itself.\n\t\t\tconst error = Object.freeze({\n\t\t\t\t_tag: 'DeclaredError',\n\t\t\t\tcode,\n\t\t\t\tdetails: copyJson(envelope.details),\n\t\t\t}) as Extract<DeclaredError<Definitions>, { code: typeof code }>\n\t\t\ttrusted.set(error, envelope)\n\t\t\treturn error\n\t\t},\n\t\tenvelope(code, details) {\n\t\t\t// SAFETY: create validates the selected code; project retrieves its private validated envelope.\n\t\t\treturn contract.project(contract.create(code, details)) as Extract<\n\t\t\t\tDeclaredFailure<Definitions>,\n\t\t\t\t{ code: typeof code }\n\t\t\t>\n\t\t},\n\t\ttoConvexError(code, details) {\n\t\t\treturn new ConvexError(contract.envelope(code, details))\n\t\t},\n\t\tproject(error) {\n\t\t\tif (error === null || typeof error !== 'object') return unknownFailure\n\t\t\tconst envelope = trusted.get(error)\n\t\t\t// SAFETY: only validated contract-owned envelopes enter the private map.\n\t\t\treturn envelope ? (copyJson(envelope) as DeclaredFailure<Definitions>) : unknownFailure\n\t\t},\n\t\tdecode(payload) {\n\t\t\ttry {\n\t\t\t\tif (\n\t\t\t\t\t!isRecord(payload) ||\n\t\t\t\t\tpayload._tag !== 'DeclaredFailure' ||\n\t\t\t\t\tpayload.version !== 1 ||\n\t\t\t\t\ttypeof payload.code !== 'string' ||\n\t\t\t\t\t!Object.hasOwn(declarations, payload.code) ||\n\t\t\t\t\tObject.keys(payload).length !== 5 ||\n\t\t\t\t\t!['message', 'details', '_tag', 'version', 'code'].every((key) =>\n\t\t\t\t\t\tObject.hasOwn(payload, key),\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn unknownFailure\n\t\t\t\t}\n\t\t\t\tconst definition = declarations[payload.code]\n\t\t\t\tif (payload.message !== definition.message) return unknownFailure\n\t\t\t\t// Validate raw transport JSON too: parsers must not hide non-JSON payloads.\n\t\t\t\tcopyJson(payload.details)\n\t\t\t\t// SAFETY: code membership and every allowlisted field have been checked independently.\n\t\t\t\treturn {\n\t\t\t\t\t_tag: 'DeclaredFailure',\n\t\t\t\t\tversion: 1,\n\t\t\t\t\tcode: payload.code,\n\t\t\t\t\tmessage: definition.message,\n\t\t\t\t\tdetails: parseDetails(definition, payload.details, true),\n\t\t\t\t} as DeclaredFailure<Definitions>\n\t\t\t} catch {\n\t\t\t\treturn unknownFailure\n\t\t\t}\n\t\t},\n\t}\n\treturn contract\n}\n\n/** A structural decoder also accepts combined contracts without requiring constructors. */\nexport type FailureContract = Pick<ErrorContract<ErrorDefinitions>, 'decode'>\nexport type FailureOf<Contract extends FailureContract> = ReturnType<Contract['decode']>\ntype ProjectingContract = FailureContract & Pick<ErrorContract<ErrorDefinitions>, 'project'>\n\n/** Extract only ConvexError.data, including one bounded serialized JSON envelope. */\nexport function decodeFailure<Contract extends FailureContract>(\n\terror: unknown,\n\tcontract: Contract,\n): FailureOf<Contract> {\n\ttry {\n\t\tif (error instanceof ConvexError) {\n\t\t\tlet payload: unknown = error.data\n\t\t\tif (typeof payload === 'string') {\n\t\t\t\tif (payload.length > 65536 || new TextEncoder().encode(payload).byteLength > 65536)\n\t\t\t\t\t// SAFETY: every failure decoder includes UnknownFailure.\n\t\t\t\t\treturn unknownFailure as FailureOf<Contract>\n\t\t\t\tpayload = JSON.parse(payload)\n\t\t\t}\n\t\t\t// SAFETY: the structural contract owns the decoded union.\n\t\t\treturn contract.decode(payload) as FailureOf<Contract>\n\t\t}\n\t} catch {\n\t\t// Foreign errors, accessors and invalid JSON expose no diagnostics.\n\t}\n\t// SAFETY: every failure decoder includes UnknownFailure.\n\treturn unknownFailure as FailureOf<Contract>\n}\n\ntype CombinedErrorContract<Contracts extends readonly ProjectingContract[]> = Readonly<{\n\tproject: (error: unknown) => FailureOf<Contracts[number]> | UnknownFailure\n\tdecode: (payload: unknown) => FailureOf<Contracts[number]> | UnknownFailure\n}>\n\n/** Ordered projection and decoding; duplicate codes retain the union of member details. */\nexport function combineErrorContracts<const Contracts extends readonly ProjectingContract[]>(\n\t...contracts: Contracts\n): CombinedErrorContract<Contracts> {\n\tconst unmatched = unknownFailure\n\treturn {\n\t\tproject(error) {\n\t\t\tfor (const contract of contracts) {\n\t\t\t\tconst projected = contract.project(error)\n\t\t\t\tif (projected._tag === 'DeclaredFailure') {\n\t\t\t\t\t// SAFETY: this result belongs to a member of the inferred tuple.\n\t\t\t\t\treturn projected as FailureOf<Contracts[number]>\n\t\t\t\t}\n\t\t\t\tconst decoded = decodeFailure(error, contract)\n\t\t\t\tif (decoded._tag === 'DeclaredFailure') {\n\t\t\t\t\t// SAFETY: strict transported decoding preserves the same member union.\n\t\t\t\t\treturn decoded as FailureOf<Contracts[number]>\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn unmatched\n\t\t},\n\t\tdecode(payload) {\n\t\t\tfor (const contract of contracts) {\n\t\t\t\tconst decoded = contract.decode(payload)\n\t\t\t\tif (decoded._tag === 'DeclaredFailure') {\n\t\t\t\t\t// SAFETY: this result belongs to a member of the inferred tuple.\n\t\t\t\t\treturn decoded as FailureOf<Contracts[number]>\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn unmatched\n\t\t},\n\t}\n}\n\n/** Fixed, diagnostic-free transport shared by query endpoints and client recovery. */\nexport const queryErrors = defineErrorContract({\n\t'invalid-cursor': { message: 'Invalid cursor', details: {} },\n\tFIELD_GROUP_DENIED: { message: 'Field group access denied', details: {} },\n\tQUERY_FANOUT: { message: 'Query fan-out limit exceeded', details: {} },\n\tSEARCH_TEXT_REQUIRED: { message: 'Search text required', details: {} },\n\tSEARCH_END_CURSOR_UNSUPPORTED: {\n\t\tmessage: 'Search end cursor unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_ORDER_UNSUPPORTED: {\n\t\tmessage: 'Search ordering unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_RELATION_UNSUPPORTED: {\n\t\tmessage: 'Relation search unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_OPTIONS_UNSUPPORTED: {\n\t\tmessage: 'Search options unsupported',\n\t\tdetails: {},\n\t},\n\tSEARCH_PROTOCOL_UNSUPPORTED: {\n\t\tmessage: 'Search pagination protocol unsupported',\n\t\tdetails: {},\n\t},\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\tif (value === null || typeof value !== 'object' || Array.isArray(value)) return false\n\tconst prototype = Object.getPrototypeOf(value)\n\treturn prototype === Object.prototype || prototype === null\n}\n\n/** Copy data without invoking toJSON or retaining mutable provider objects. */\nfunction copyJson(value: unknown, ancestors = new Set<object>()): Json {\n\tif (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n\tif (typeof value === 'number' && Number.isFinite(value)) return value\n\tif (typeof value !== 'object' || value === null || ancestors.has(value))\n\t\tthrow Error('Invalid JSON')\n\tancestors.add(value)\n\ttry {\n\t\tif (Array.isArray(value)) {\n\t\t\tconst result: Json[] = []\n\t\t\tfor (let index = 0; index < value.length; index++)\n\t\t\t\tresult.push(copyJson(value[index], ancestors))\n\t\t\treturn result\n\t\t}\n\t\tif (!isRecord(value)) throw Error('Invalid JSON')\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries(value).map(([key, child]) => [key, copyJson(child, ancestors)]),\n\t\t)\n\t} finally {\n\t\tancestors.delete(value)\n\t}\n}\n\nfunction parseDetails<const Definition extends ErrorDefinitions[string]>(\n\tdefinition: Definition,\n\tvalue: unknown,\n\tstrict: boolean,\n): Details<Definition> {\n\tif (!isRecord(value)) throw Error('Invalid details')\n\tconst fields = Object.keys(definition.details)\n\tif (strict && Object.keys(value).some((key) => !Object.hasOwn(definition.details, key))) {\n\t\tthrow Error('Undeclared detail')\n\t}\n\t// SAFETY: each declared field is validated by its paired parser before its JSON-safe copy is returned.\n\treturn Object.fromEntries(\n\t\tfields.map((field) => {\n\t\t\tif (!Object.hasOwn(value, field)) throw Error('Missing detail')\n\t\t\treturn [field, copyJson(definition.details[field].parse(value[field]))]\n\t\t}),\n\t) as Details<Definition>\n}\n"],"mappings":"4CAsEA,MAAMA,EAAiC,OAAO,OAAO,CACpD,KAAM,iBACN,QAAS,CACV,CAAC,EAID,SAAgBC,EACf,EAC6B,CAE7B,IAAMC,EAAe,OAAO,YAC3B,OAAO,QAAQC,CAAW,CAAC,CAAC,KAAK,CAACC,EAAMC,KAAgB,CACvD,GAAI,CAACD,GAAQ,CAACC,EAAW,SAAWA,EAAW,QAAQ,OAAS,IAC/D,MAAM,MAAM,yEAAyE,EAEtF,MAAO,CAACD,EAAM,CAAE,QAASC,EAAW,QAAS,QAAS,CAAE,GAAGA,E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CACtB,GAAI,CAACK,EAASU,CAAK,EAAG,MAAM,MAAM,iBAAiB,EACnD,IAAMM,EAAS,OAAO,KAAKzB,EAAW,OAAO,EAC7C,GAAI0B,GAAU,OAAO,KAAKP,CAAK,CAAC,CAAC,KAAM,GAAQ,CAAC,OAAO,OAAOnB,EAAW,QAASW,CAAG,CAAC,EACrF,MAAM,MAAM,mBAAmB,EAGhC,OAAO,OAAO,YACbc,EAAO,IAAK,GAAU,CACrB,GAAI,CAAC,OAAO,OAAON,EAAOQ,CAAK,EAAG,MAAM,MAAM,gBAAgB,EAC9D,MAAO,CAACA,EAAOpB,EAASP,EAAW,QAAQ2B,EAAM,CAAC,MAAMR,EAAMQ,EAAM,CAAC,CAAC,CACvE,CAAC,CACF,CACD"}
@@ -2,6 +2,7 @@ import { OperationExecutor, OperationPublicResult, OperationTool, OperationToolC
2
2
  import { ContractDecoderError, ContractDecoderRequirements, ContractValidationError, EffectDecoder, decodeEffectContract, effectContract, effectSchema, effectStandardSchema } from "./schema.mjs";
3
3
  import { CallbackError, CallbackRequirements, EffectMiddlewareInput, EffectOperationArgument, EffectOperationError, EffectOperationHandlerResult, EffectOperationInput, EffectOperationRequirements, EffectOperationResult, EffectPreparation, EffectValue, effectOperationFactory } from "./operation.mjs";
4
4
  import { EffectZodApiBuilder, effectZodApiBuilder } from "./api-zod.mjs";
5
+ import "./agent-tools.mjs";
5
6
  import { EffectFoundationOptions, createEffectFoundation } from "./foundation.mjs";
6
7
  import { EffectIdempotencyPreparation, effectTransactionalIdempotency } from "./idempotency.mjs";
7
8
  import { EffectCrudConfig, EffectCrudContext, EffectCrudPage, EffectCrudPagination, EffectCrudRepository, EffectCrudTable, createEffectCrud } from "./crud.mjs";
@@ -0,0 +1,16 @@
1
+ import { z } from "zod";
2
+ import { GenericValidator } from "convex/values";
3
+ //#region src/querying/filter-boundary.d.ts
4
+ /** Private projection. The caller must install the captured semantic preflight. */
5
+ export declare function compactNativeFilter(schema: z.core.$ZodType): GenericValidator | undefined;
6
+ /** Conversion and preflight are one registration decision. Unsupported wrappers
7
+ * stay on the ordinary converter and never acquire a compact guard. */
8
+ interface ArgumentBoundary {
9
+ validator: Extract<GenericValidator, {
10
+ kind: 'object';
11
+ }>;
12
+ preflight(value: unknown): void;
13
+ }
14
+ export declare function compactArgumentBoundary(schema: z.core.$ZodObject): ArgumentBoundary;
15
+ //#endregion
16
+ //# sourceMappingURL=filter-boundary.d.mts.map
@@ -0,0 +1,2 @@
1
+ import{compactFilterMetadata as e}from"./shared/filters.mjs";import{zodToConvex as t}from"../zod-convex.mjs";import{z as n}from"zod";import{ConvexError as r,v as i}from"convex/values";import{vRequired as a}from"convex-helpers/validators";function o(n){let r=e(n);if(!r)return;let a=/* @__PURE__ */ new WeakMap,o=/* @__PURE__ */ new WeakMap;function s(e){let n=o.get(e);if(n)return n;let r=Object.fromEntries(Object.entries(e.fields).map(([e,n])=>[e,t(n)]));return o.set(e,r),r}function c(e,t){return Object.values(s(e)).some(u)?!0:t<4&&(Object.values(e.relations).some(e=>c(e.target,t+1))||Object.values(e.variants?.options??{}).some(e=>c(e,t+1)))}function d(e,t){let n=a.get(e)?.get(t);if(n)return n;if(t>1&&!c(e,t))return i.any();let r=Object.fromEntries(Object.entries(s(e)).map(([e,n])=>[e,t<=1||u(n)?n:n.isOptional===`optional`?i.optional(i.any()):i.any()])),o={...Object.fromEntries(Object.entries(r).filter(([t])=>![`and`,`or`,`not`,`fields`,...e.variants?[`variant`]:[]].includes(t))),fields:i.optional(i.object(r))};if(t<4){for(let[n,r]of Object.entries(e.relations)){let e=d(r.target,t+1);o[n]=i.optional(r.cardinality===`one`?i.union(e,i.null()):i.union(i.object({some:e}),i.object({none:e})))}e.variants&&Object.keys(e.variants.options).length&&(o.variant=i.optional(i.union(...Object.entries(e.variants.options).map(([e,n])=>i.object({tag:i.literal(e),filters:d(n,t+1)})))));let n=d(e,t+1);o.and=i.optional(i.array(n)),o.or=i.optional(i.array(n)),o.not=i.optional(n)}let l=i.object(o),f=a.get(e);return f||(f=/* @__PURE__ */ new Map,a.set(e,f)),f.set(t,l),l}function f(e,t){return Object.values(s(e)).every(l)&&(t===4||Object.values(e.relations).every(e=>f(e.target,t+1))&&Object.values(e.variants?.options??{}).every(e=>f(e,t+1)))}return f(r.grammar,0)?d(r.grammar,0):void 0}function s(s){let l=t(s),u=/* @__PURE__ */ new WeakMap;function d(t,s){let l=u.get(t);if(l)return l;let f=e(t),p=f&&o(t),m={validator:s};if(p&&f)m={validator:p,guard:(e,t)=>{let n=f.semantic.safeParse(e);if(!n.success)throw new r({ZodError:JSON.parse(JSON.stringify(n.error.issues.map(e=>({...e,path:[...t,...e.path]}))))})}};else if(t instanceof n.core.$ZodOptional){let e=d(t._zod.def.innerType,a(s));e.guard&&(m={validator:i.optional(e.validator),guard:(t,n)=>{t!==void 0&&e.guard(t,n)}})}else if(t instanceof n.core.$ZodObject&&s.kind===`object`){let e=Object.entries(t._zod.def.shape).map(([e,t])=>[e,d(t,s.fields[e])]);e.some(([,e])=>e.guard)&&(m={validator:i.object(Object.fromEntries(e.map(([e,t])=>[e,t.validator]))),guard:(t,n)=>{(t===null||Object(t)!==t||Array.isArray(t))&&c(n);let r=t,i=Object.getPrototypeOf(r);i!==Object.prototype&&i!==null&&c(n);for(let[t,i]of e)if(i.guard){let e=Object.getOwnPropertyDescriptor(r,t);e&&(!(`value`in e)||!e.enumerable)&&c([...n,t]),!e&&t in r&&c([...n,t]),i.guard(e?.value,[...n,t])}}})}return u.set(t,m),m}let f=d(s,l);if(f.validator.kind!==`object`)throw Error(`Expected object argument boundary`);return{validator:f.validator,preflight(e){f.guard?.(e,[])}}}function c(e){throw new r({ZodError:[{code:`custom`,path:e,message:`Unsupported filter layout or depth/node budget exceeded`}]})}function l(e){switch(e.kind){case`union`:return e.members.every(l);case`object`:return Object.values(e.fields).every(l);case`array`:return l(e.element);case`id`:case`string`:case`float64`:case`int64`:case`boolean`:case`null`:case`literal`:return!0;default:return!1}}function u(e){switch(e.kind){case`id`:return!0;case`union`:return e.members.some(u);case`object`:return Object.values(e.fields).some(u);case`array`:return u(e.element);default:return!1}}export{s as compactArgumentBoundary,o as compactNativeFilter};
2
+ //# sourceMappingURL=filter-boundary.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter-boundary.mjs","names":["compactNativeFilter","metadata","compactFilterMetadata","schema","completed","predicates","fields","cached","grammar","result","k","s","zodToConvex","needsIds","hasId","depth","r","g","expression","v","selected","key","value","properties","name","relation","target","tag","branch","child","depths","known","knownNative","compactArgumentBoundary","full","visit","node","projected","native","parsed","ConvexError","issue","path","z","vRequired","children","layoutError","object","prototype","descriptor","pair","validator"],"sources":["../../src/querying/filter-boundary.ts"],"sourcesContent":["import { z } from 'zod'\nimport {\n\tv,\n\tConvexError,\n\ttype Value,\n\ttype GenericValidator,\n\ttype PropertyValidators,\n} from 'convex/values'\nimport { vRequired } from 'convex-helpers/validators'\nimport { zodToConvex } from '../zod-convex'\nimport { compactFilterMetadata, MAX_FILTER_DEPTH, type FilterGrammar } from './shared/filters'\n\n/** Private projection. The caller must install the captured semantic preflight. */\nexport function compactNativeFilter(schema: z.core.$ZodType): GenericValidator | undefined {\n\tconst metadata = compactFilterMetadata(schema)\n\tif (!metadata) return undefined\n\tconst completed = new WeakMap<FilterGrammar, Map<number, GenericValidator>>()\n\tconst predicates = new WeakMap<FilterGrammar, PropertyValidators>()\n\tfunction fields(grammar: FilterGrammar): PropertyValidators {\n\t\tconst cached = predicates.get(grammar)\n\t\tif (cached) return cached\n\t\tconst result = Object.fromEntries(\n\t\t\tObject.entries(grammar.fields).map(([k, s]) => [k, zodToConvex(s)]),\n\t\t)\n\t\tpredicates.set(grammar, result)\n\t\treturn result\n\t}\n\tfunction needsIds(grammar: FilterGrammar, depth: number): boolean {\n\t\tif (Object.values(fields(grammar)).some(hasId)) return true\n\t\treturn (\n\t\t\tdepth < MAX_FILTER_DEPTH &&\n\t\t\t(Object.values(grammar.relations).some((r) => needsIds(r.target, depth + 1)) ||\n\t\t\t\tObject.values(grammar.variants?.options ?? {}).some((g) => needsIds(g, depth + 1)))\n\t\t)\n\t}\n\tfunction expression(grammar: FilterGrammar, depth: number): GenericValidator {\n\t\tconst cached = completed.get(grammar)?.get(depth)\n\t\tif (cached) return cached\n\t\tif (depth > 1 && !needsIds(grammar, depth)) return v.any()\n\t\tconst selected = Object.fromEntries(\n\t\t\tObject.entries(fields(grammar)).map(([key, value]) => [\n\t\t\t\tkey,\n\t\t\t\tdepth <= 1 || hasId(value)\n\t\t\t\t\t? value\n\t\t\t\t\t: value.isOptional === 'optional'\n\t\t\t\t\t\t? v.optional(v.any())\n\t\t\t\t\t\t: v.any(),\n\t\t\t]),\n\t\t)\n\t\tconst direct = Object.fromEntries(\n\t\t\tObject.entries(selected).filter(\n\t\t\t\t([key]) =>\n\t\t\t\t\t!['and', 'or', 'not', 'fields', ...(grammar.variants ? ['variant'] : [])].includes(key),\n\t\t\t),\n\t\t)\n\t\tconst properties: PropertyValidators = { ...direct, fields: v.optional(v.object(selected)) }\n\t\tif (depth < MAX_FILTER_DEPTH) {\n\t\t\tfor (const [name, relation] of Object.entries(grammar.relations)) {\n\t\t\t\tconst target = expression(relation.target, depth + 1)\n\t\t\t\tproperties[name] = v.optional(\n\t\t\t\t\trelation.cardinality === 'one'\n\t\t\t\t\t\t? v.union(target, v.null())\n\t\t\t\t\t\t: v.union(v.object({ some: target }), v.object({ none: target })),\n\t\t\t\t)\n\t\t\t}\n\t\t\tif (grammar.variants && Object.keys(grammar.variants.options).length)\n\t\t\t\tproperties.variant = v.optional(\n\t\t\t\t\tv.union(\n\t\t\t\t\t\t...Object.entries(grammar.variants.options).map(([tag, branch]) =>\n\t\t\t\t\t\t\tv.object({ tag: v.literal(tag), filters: expression(branch, depth + 1) }),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t)\n\t\t\tconst child = expression(grammar, depth + 1)\n\t\t\tproperties.and = v.optional(v.array(child))\n\t\t\tproperties.or = v.optional(v.array(child))\n\t\t\tproperties.not = v.optional(child)\n\t\t}\n\t\tconst result = v.object(properties)\n\t\tlet depths = completed.get(grammar)\n\t\tif (!depths) {\n\t\t\tdepths = new Map()\n\t\t\tcompleted.set(grammar, depths)\n\t\t}\n\t\tdepths.set(depth, result)\n\t\treturn result\n\t}\n\tfunction known(grammar: FilterGrammar, depth: number): boolean {\n\t\treturn (\n\t\t\tObject.values(fields(grammar)).every(knownNative) &&\n\t\t\t(depth === MAX_FILTER_DEPTH ||\n\t\t\t\t(Object.values(grammar.relations).every((relation) => known(relation.target, depth + 1)) &&\n\t\t\t\t\tObject.values(grammar.variants?.options ?? {}).every((branch) =>\n\t\t\t\t\t\tknown(branch, depth + 1),\n\t\t\t\t\t)))\n\t\t)\n\t}\n\treturn known(metadata.grammar, 0) ? expression(metadata.grammar, 0) : undefined\n}\n\n/** Conversion and preflight are one registration decision. Unsupported wrappers\n * stay on the ordinary converter and never acquire a compact guard. */\ninterface ArgumentBoundary {\n\tvalidator: Extract<GenericValidator, { kind: 'object' }>\n\t// oxlint-disable-next-line anti-slop/no-unknown-parameters -- This is the parser boundary for raw registered arguments.\n\tpreflight(value: unknown): void\n}\nexport function compactArgumentBoundary(schema: z.core.$ZodObject): ArgumentBoundary {\n\tconst full = zodToConvex(schema)\n\t// oxlint-disable-next-line anti-slop/no-unknown-parameters -- Guards parse untrusted registered values before customization.\n\ttype Guard = (value: unknown, path: string[]) => void\n\tinterface Pair {\n\t\tvalidator: GenericValidator\n\t\tguard?: Guard\n\t}\n\tconst completed = new WeakMap<z.core.$ZodType, Pair>()\n\tfunction visit(node: z.core.$ZodType, native: GenericValidator): Pair {\n\t\tconst cached = completed.get(node)\n\t\tif (cached) return cached\n\t\tconst metadata = compactFilterMetadata(node)\n\t\tconst projected = metadata && compactNativeFilter(node)\n\t\tlet result: Pair = { validator: native }\n\t\tif (projected && metadata) {\n\t\t\tresult = {\n\t\t\t\tvalidator: projected,\n\t\t\t\tguard: (value, path) => {\n\t\t\t\t\tconst parsed = metadata.semantic.safeParse(value)\n\t\t\t\t\tif (!parsed.success)\n\t\t\t\t\t\tthrow new ConvexError({\n\t\t\t\t\t\t\t// SAFETY: serialized issues are the existing helper-compatible Convex Value error payload.\n\t\t\t\t\t\t\tZodError: JSON.parse(\n\t\t\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\t\t\tparsed.error.issues.map((issue) => ({\n\t\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\t\tpath: [...path, ...issue.path],\n\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t) as Value[],\n\t\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t}\n\t\t} else if (node instanceof z.core.$ZodOptional) {\n\t\t\tconst child = visit(node._zod.def.innerType, vRequired(native))\n\t\t\tif (child.guard)\n\t\t\t\tresult = {\n\t\t\t\t\tvalidator: v.optional(child.validator),\n\t\t\t\t\tguard: (value, path) => {\n\t\t\t\t\t\tif (value !== undefined) child.guard!(value, path)\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t} else if (node instanceof z.core.$ZodObject && native.kind === 'object') {\n\t\t\tconst children = Object.entries(node._zod.def.shape).map(\n\t\t\t\t([key, child]) => [key, visit(child, native.fields[key])] as const,\n\t\t\t)\n\t\t\tif (children.some(([, child]) => child.guard))\n\t\t\t\tresult = {\n\t\t\t\t\tvalidator: v.object(\n\t\t\t\t\t\tObject.fromEntries(children.map(([key, child]) => [key, child.validator])),\n\t\t\t\t\t),\n\t\t\t\t\tguard: (value, path) => {\n\t\t\t\t\t\tif (value === null || Object(value) !== value || Array.isArray(value)) layoutError(path)\n\t\t\t\t\t\t// SAFETY: the boxing check above excludes primitive argument containers.\n\t\t\t\t\t\tconst object = value as object\n\t\t\t\t\t\tconst prototype = Object.getPrototypeOf(object)\n\t\t\t\t\t\tif (prototype !== Object.prototype && prototype !== null) layoutError(path)\n\t\t\t\t\t\tfor (const [key, child] of children)\n\t\t\t\t\t\t\tif (child.guard) {\n\t\t\t\t\t\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key)\n\t\t\t\t\t\t\t\tif (descriptor && (!('value' in descriptor) || !descriptor.enumerable))\n\t\t\t\t\t\t\t\t\tlayoutError([...path, key])\n\t\t\t\t\t\t\t\tif (!descriptor && key in object) layoutError([...path, key])\n\t\t\t\t\t\t\t\tchild.guard(descriptor?.value, [...path, key])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t}\n\t\tcompleted.set(node, result)\n\t\treturn result\n\t}\n\tconst pair = visit(schema, full)\n\tif (pair.validator.kind !== 'object') throw new Error('Expected object argument boundary')\n\treturn {\n\t\tvalidator: pair.validator,\n\t\tpreflight(value) {\n\t\t\tpair.guard?.(value, [])\n\t\t},\n\t}\n}\n\nfunction layoutError(path: string[]): never {\n\tthrow new ConvexError({\n\t\tZodError: [\n\t\t\t{ code: 'custom', path, message: 'Unsupported filter layout or depth/node budget exceeded' },\n\t\t],\n\t})\n}\n\nfunction knownNative(validator: GenericValidator): boolean {\n\tswitch (validator.kind) {\n\t\tcase 'union':\n\t\t\treturn validator.members.every(knownNative)\n\t\tcase 'object':\n\t\t\treturn Object.values(validator.fields).every(knownNative)\n\t\tcase 'array':\n\t\t\treturn knownNative(validator.element)\n\t\tcase 'id':\n\t\tcase 'string':\n\t\tcase 'float64':\n\t\tcase 'int64':\n\t\tcase 'boolean':\n\t\tcase 'null':\n\t\tcase 'literal':\n\t\t\treturn true\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nfunction hasId(validator: GenericValidator): boolean {\n\tswitch (validator.kind) {\n\t\tcase 'id':\n\t\t\treturn true\n\t\tcase 'union':\n\t\t\treturn validator.members.some(hasId)\n\t\tcase 'object':\n\t\t\treturn Object.values(validator.fields).some(hasId)\n\t\tcase 'array':\n\t\t\treturn hasId(validator.element)\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n"],"mappings":"8OAaA,SAAgBA,E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AAI,EAC/B,GAAIgB,EAAK,UAAU,OAAS,SAAU,MAAU,MAAM,mCAAmC,EACzF,MAAO,CACN,UAAWA,EAAK,UAChB,UAAU,EAAO,CAChBA,EAAK,QAAQ5B,EAAO,CAAC,CAAC,CACvB,CACD,CACD,CAEA,SAASwB,EAAY,EAAuB,CAC3C,MAAM,IAAIN,EAAY,CACrB,SAAU,CACT,CAAE,KAAM,SAAU,OAAM,QAAS,yDAA0D,CAC5F,CACD,CAAC,CACF,CAEA,SAASR,EAAY,EAAsC,CAC1D,OAAQmB,EAAU,KAAlB,CACC,IAAK,QACJ,OAAOA,EAAU,QAAQ,MAAMnB,CAAW,EAC3C,IAAK,SACJ,OAAO,OAAO,OAAOmB,EAAU,MAAM,CAAC,CAAC,MAAMnB,CAAW,EACzD,IAAK,QACJ,OAAOA,EAAYmB,EAAU,OAAO,EACrC,IAAK,KACL,IAAK,SACL,IAAK,UACL,IAAK,QACL,IAAK,UACL,IAAK,OACL,IAAK,UACJ,MAAO,GACR,QACC,MAAO,EACT,CACD,CAEA,SAASrC,EAAM,EAAsC,CACpD,OAAQqC,EAAU,KAAlB,CACC,IAAK,KACJ,MAAO,GACR,IAAK,QACJ,OAAOA,EAAU,QAAQ,KAAKrC,CAAK,EACpC,IAAK,SACJ,OAAO,OAAO,OAAOqC,EAAU,MAAM,CAAC,CAAC,KAAKrC,CAAK,EAClD,IAAK,QACJ,OAAOA,EAAMqC,EAAU,OAAO,EAC/B,QACC,MAAO,EACT,CACD"}
@@ -1,5 +1,5 @@
1
1
  import { FilterAst, FilterOperator, FilterScalar } from "./shared/ast.mjs";
2
- import { FieldSchemas, FilterGrammar, MAX_FILTER_DEPTH, MAX_FILTER_IN_VALUES, MAX_FILTER_NODES, relationFilterSchema } from "./shared/filters.mjs";
2
+ import { FieldSchemas, FilterGrammar, MAX_FILTER_DEPTH, MAX_FILTER_IN_VALUES, MAX_FILTER_NODES, PaginationValidatorOptions, relationFilterSchema } from "./shared/filters.mjs";
3
3
  import { ConvexValidatorFromZod } from "convex-helpers/server/zod4";
4
4
  import { z } from "zod";
5
5
  import { GenericId, GenericValidator } from "convex/values";
@@ -73,7 +73,7 @@ export type ScalarPaginationSchema<Fields extends FieldSchemas, Selection> = Pag
73
73
  /** Scalar-only schema constructor shared by table and future registry boundaries.
74
74
  * Convex metadata describes stored INPUT, so storage refinements/transforms never run here.
75
75
  */
76
- export declare function scalarPaginationSchema<Fields extends FieldSchemas, const Selection extends ScalarSelection<Fields>>(validators: Record<string, GenericValidator>, selection: ExactScalarSelection<Fields, Selection>): ScalarPaginationSchema<Fields, Selection>;
76
+ export declare function scalarPaginationSchema<Fields extends FieldSchemas, const Selection extends ScalarSelection<Fields>>(validators: Record<string, GenericValidator>, selection: ExactScalarSelection<Fields, Selection>, options?: PaginationValidatorOptions): ScalarPaginationSchema<Fields, Selection>;
77
77
  export declare function scalarPredicateSchema(validator: GenericValidator): z.ZodType;
78
78
  export interface QueryIndex {
79
79
  name: string;
@@ -1,2 +1,2 @@
1
- import{MAX_FILTER_DEPTH as e,MAX_FILTER_IN_VALUES as t,MAX_FILTER_NODES as n,boundedFilterSchema as r,normalizeFilters as i,paginationGrammar as a,relationFilterSchema as o,scalarPredicateFromSchema as s}from"./shared/filters.mjs";import{valueEqual as c}from"./shared/ast.mjs";import{convexToZod as l}from"convex-helpers/server/zod4";import{paginationOptsValidator as u}from"convex/server";import{z as d}from"zod";import{compareValues as f}from"convex/values";const p=100,m=l(u),h=m.strict().extend({onEmptyBudget:d.literal(`split`).optional(),numItems:m.shape.numItems.int().positive().max(100),maximumRowsRead:m.shape.maximumRowsRead.unwrap().int().positive().optional(),maximumBytesRead:m.shape.maximumBytesRead.unwrap().int().positive().optional()});function g(e,t){let n={};for(let[r,i]of Object.entries(t)){if(i!==!0||!Object.hasOwn(e,r))throw Error(`Invalid scalar filter selection "${r}"`);n[r]=_(e[r]).optional()}let i=r(n);return h.extend({filters:i.optional(),order:d.enum([`asc`,`desc`]).optional()})}function _(e){M(e);let t=l(e).nonoptional();return s(t,N(e),e.isOptional===`optional`)}const v=8;function y(e,t,n,r=[],i){return b(e,t,n,r,i).compiled}function b(e,t,n,r=[],o,s){let l=e.parse(t),u=l,d=o===void 0?void 0:e.parse({...u,filters:o}),p=a(e),m={kind:`and`,children:[E(i(u.filters,p)),E(i(d?.filters,p))]},h=k(m),g=A(m),_=O(m);for(let[e,t]of _){let n=t.filter(t=>(!h.values.has(e)||c(t,h.values.get(e)))&&(!g.has(e)||x(t,g.get(e))));_.set(e,n),n.length||(h.impossible=!0)}for(let[e,t]of g){if(t.lower&&t.upper){let e=f(t.lower.value,t.upper.value);(e>0||e===0&&(!t.lower.inclusive||!t.upper.inclusive))&&(h.impossible=!0)}h.values.has(e)&&!x(h.values.get(e),t)&&(h.impossible=!0)}let v=[...n].sort((e,t)=>e.name.localeCompare(t.name)||e.fields.join(`\0`).localeCompare(t.fields.join(`\0`))),y=r.find(e=>e.value!==null&&e.value!==void 0),b=null;if(s!==void 0){if(y)throw Error(`orderBy cannot be combined with an active when selector`);if(b=v.find(e=>e.name===s)??null,!b)throw Error(`Unknown ordering index "${s}"`)}else if(y){if(b=v.find(e=>e.name===y.index)??null,!b||j(b,h.values).length===0)throw Error(`Explicit index "${y.index}" is incompatible with guaranteed filters`)}else{let e=0,t=!1;for(let n of v){let r=j(n,h.values),i=_.has(n.fields[r.length]),a=r.length+Number(i),o=g.has(n.fields[a]);(a>e||a===e&&o&&!t)&&(b=n,e=a,t=o)}}let w=b?j(b,h.values):[];return{args:l,compiled:{sets:_,expansion:b&&!h.impossible?C(b,w,_,s!==void 0||!!y):null,residual:m,bindings:h.values,ranges:g,range:b?S(b,j(b,h.values),g):null,unsatisfiable:h.impossible,index:b,prefix:b?j(b,h.values):[]}}}function x(e,t){let n=t.lower&&f(e,t.lower.value),r=t.upper&&f(e,t.upper.value);return(n===void 0||n>0||n===0&&t.lower.inclusive)&&(r===void 0||r<0||r===0&&t.upper.inclusive)}function S(e,t,n){let r=e.fields[t.length],i=n.get(r);return i?{field:r,...i}:null}function C(e,t,n,r){let i=e.fields[t.length],a=n.get(i);if(!a?.length)return null;if(a.length>8){if(r)return null;let e=/* @__PURE__ */ Error(`QUERY_FANOUT`);throw w.add(e),e}return{field:i,values:a,comparator:r?`full-index`:`tail`}}const w=/* @__PURE__ */ new WeakSet;function T(e){return e instanceof Error&&w.has(e)}function E(e){if(e.kind===`scalar`&&e.operator===`in`&&Array.isArray(e.value))return{...e,value:D(e.value)};if(e.kind===`and`||e.kind===`or`){let t=e.children.map(E),n=e=>{if(e.kind===`scalar`&&e.operator===`eq`&&!Array.isArray(e.value))return{field:e.field,value:e.value};if(e.kind===`and`&&e.children.length===1)return n(e.children[0])},r=t.map(n),i=r[0];return e.kind===`or`&&i&&r.every(e=>e?.field===i.field)?{kind:`scalar`,field:i.field,operator:`in`,value:D(r.map(e=>e.value))}:{...e,children:t}}return e.kind===`not`||e.kind===`variant`?{...e,child:E(e.child)}:e.kind===`relation`&&e.predicate?{...e,predicate:E(e.predicate)}:e}function D(e){return[...e].sort(f).filter((e,t,n)=>t===0||!c(e,n[t-1]))}function O(e,t=/* @__PURE__ */ new Map){if(e.kind===`and`)for(let n of e.children)O(n,t);else if(e.kind===`variant`)O(e.child,t);else if(e.kind===`scalar`&&e.operator===`in`&&Array.isArray(e.value)){let n=t.get(e.field);t.set(e.field,n?e.value.filter(e=>n.some(t=>c(e,t))):e.value)}return t}function k(e){let t=/* @__PURE__ */ new Map;if(e.kind===`variant`)return k({kind:`and`,children:[{kind:`scalar`,field:e.discriminator,operator:`eq`,value:e.tag},e.child]});if(e.kind===`scalar`){e.operator===`eq`&&!Array.isArray(e.value)&&t.set(e.field,e.value);let n=Array.isArray(e.value)?e.value:void 0;return e.operator===`in`&&n?.length&&n.every(e=>c(e,n[0]))&&t.set(e.field,n[0]),{values:t,impossible:e.operator===`in`&&n?.length===0}}if(e.kind===`not`||e.kind===`relation`)return{values:t,impossible:!1};let n=e.children.map(k);if(e.kind===`or`){let e=n.filter(e=>!e.impossible);for(let[n,r]of e[0]?.values??[])e.every(e=>e.values.has(n)&&c(e.values.get(n),r))&&t.set(n,r);return{values:t,impossible:e.every(e=>e.impossible)}}let r=n.some(e=>e.impossible);for(let e of n)for(let[n,i]of e.values)t.has(n)&&!c(t.get(n),i)&&(r=!0),t.set(n,i);return{values:t,impossible:r}}function A(e,t=/* @__PURE__ */ new Map){if(e.kind===`and`)for(let n of e.children)A(n,t);else if(e.kind===`variant`)A(e.child,t);else if(e.kind===`scalar`&&!Array.isArray(e.value)){let n=e.operator===`gt`||e.operator===`gte`,r=e.operator===`lt`||e.operator===`lte`;if(n||r){let r=t.get(e.field)??{},i=n?`lower`:`upper`,a={value:e.value,inclusive:e.operator===`gte`||e.operator===`lte`},o=r[i],s=o?f(a.value,o.value):0;(!o||(n?s>0:s<0)||s===0&&!a.inclusive)&&(r[i]=a),t.set(e.field,r)}}return t}function j(e,t){let n=[];for(let r of e.fields){if(!t.has(r))break;n.push({field:r,value:t.get(r)})}return n}function M(e){switch(e.kind){case`id`:case`string`:case`float64`:case`int64`:case`boolean`:case`null`:case`literal`:return;case`union`:for(let t of e.members)M(t);return;default:throw Error(`Unsupported scalar filter kind "${e.kind}"`)}}function N(e){switch(e.kind){case`string`:case`float64`:case`int64`:return!0;case`literal`:return d.union([d.string(),d.number(),d.bigint()]).safeParse(e.value).success;case`union`:return e.members.every(N);default:return!1}}export{e as MAX_FILTER_DEPTH,t as MAX_FILTER_IN_VALUES,n as MAX_FILTER_NODES,v as MAX_INDEX_EXPANSION,p as MAX_PAGE_SIZE,y as compileFilters,C as expansionForIndex,T as isQueryFanoutError,h as nativePagination,b as parseFilterPlan,S as rangeForIndex,o as relationFilterSchema,g as scalarPaginationSchema,_ as scalarPredicateSchema,x as withinRange};
1
+ import{MAX_FILTER_DEPTH as e,MAX_FILTER_IN_VALUES as t,MAX_FILTER_NODES as n,boundedFilterSchema as r,normalizeFilters as i,paginationGrammar as a,relationFilterSchema as o,scalarPredicateFromSchema as s}from"./shared/filters.mjs";import{valueEqual as c}from"./shared/ast.mjs";import{convexToZod as l}from"convex-helpers/server/zod4";import{paginationOptsValidator as u}from"convex/server";import{z as d}from"zod";import{compareValues as f}from"convex/values";const p=100,m=l(u),h=m.strict().extend({onEmptyBudget:d.literal(`split`).optional(),numItems:m.shape.numItems.int().positive().max(100),maximumRowsRead:m.shape.maximumRowsRead.unwrap().int().positive().optional(),maximumBytesRead:m.shape.maximumBytesRead.unwrap().int().positive().optional()});function g(e,t,n){let i={};for(let[n,r]of Object.entries(t)){if(r!==!0||!Object.hasOwn(e,n))throw Error(`Invalid scalar filter selection "${n}"`);i[n]=_(e[n]).optional()}let a=r(i,n);return h.extend({filters:a.optional(),order:d.enum([`asc`,`desc`]).optional()})}function _(e){M(e);let t=l(e).nonoptional();return s(t,N(e),e.isOptional===`optional`)}const v=8;function y(e,t,n,r=[],i){return b(e,t,n,r,i).compiled}function b(e,t,n,r=[],o,s){let l=e.parse(t),u=l,d=o===void 0?void 0:e.parse({...u,filters:o}),p=a(e),m={kind:`and`,children:[E(i(u.filters,p)),E(i(d?.filters,p))]},h=k(m),g=A(m),_=O(m);for(let[e,t]of _){let n=t.filter(t=>(!h.values.has(e)||c(t,h.values.get(e)))&&(!g.has(e)||x(t,g.get(e))));_.set(e,n),n.length||(h.impossible=!0)}for(let[e,t]of g){if(t.lower&&t.upper){let e=f(t.lower.value,t.upper.value);(e>0||e===0&&(!t.lower.inclusive||!t.upper.inclusive))&&(h.impossible=!0)}h.values.has(e)&&!x(h.values.get(e),t)&&(h.impossible=!0)}let v=[...n].sort((e,t)=>e.name.localeCompare(t.name)||e.fields.join(`\0`).localeCompare(t.fields.join(`\0`))),y=r.find(e=>e.value!==null&&e.value!==void 0),b=null;if(s!==void 0){if(y)throw Error(`orderBy cannot be combined with an active when selector`);if(b=v.find(e=>e.name===s)??null,!b)throw Error(`Unknown ordering index "${s}"`)}else if(y){if(b=v.find(e=>e.name===y.index)??null,!b||j(b,h.values).length===0)throw Error(`Explicit index "${y.index}" is incompatible with guaranteed filters`)}else{let e=0,t=!1;for(let n of v){let r=j(n,h.values),i=_.has(n.fields[r.length]),a=r.length+Number(i),o=g.has(n.fields[a]);(a>e||a===e&&o&&!t)&&(b=n,e=a,t=o)}}let w=b?j(b,h.values):[];return{args:l,compiled:{sets:_,expansion:b&&!h.impossible?C(b,w,_,s!==void 0||!!y):null,residual:m,bindings:h.values,ranges:g,range:b?S(b,j(b,h.values),g):null,unsatisfiable:h.impossible,index:b,prefix:b?j(b,h.values):[]}}}function x(e,t){let n=t.lower&&f(e,t.lower.value),r=t.upper&&f(e,t.upper.value);return(n===void 0||n>0||n===0&&t.lower.inclusive)&&(r===void 0||r<0||r===0&&t.upper.inclusive)}function S(e,t,n){let r=e.fields[t.length],i=n.get(r);return i?{field:r,...i}:null}function C(e,t,n,r){let i=e.fields[t.length],a=n.get(i);if(!a?.length)return null;if(a.length>8){if(r)return null;let e=/* @__PURE__ */ Error(`QUERY_FANOUT`);throw w.add(e),e}return{field:i,values:a,comparator:r?`full-index`:`tail`}}const w=/* @__PURE__ */ new WeakSet;function T(e){return e instanceof Error&&w.has(e)}function E(e){if(e.kind===`scalar`&&e.operator===`in`&&Array.isArray(e.value))return{...e,value:D(e.value)};if(e.kind===`and`||e.kind===`or`){let t=e.children.map(E),n=e=>{if(e.kind===`scalar`&&e.operator===`eq`&&!Array.isArray(e.value))return{field:e.field,value:e.value};if(e.kind===`and`&&e.children.length===1)return n(e.children[0])},r=t.map(n),i=r[0];return e.kind===`or`&&i&&r.every(e=>e?.field===i.field)?{kind:`scalar`,field:i.field,operator:`in`,value:D(r.map(e=>e.value))}:{...e,children:t}}return e.kind===`not`||e.kind===`variant`?{...e,child:E(e.child)}:e.kind===`relation`&&e.predicate?{...e,predicate:E(e.predicate)}:e}function D(e){return[...e].sort(f).filter((e,t,n)=>t===0||!c(e,n[t-1]))}function O(e,t=/* @__PURE__ */ new Map){if(e.kind===`and`)for(let n of e.children)O(n,t);else if(e.kind===`variant`)O(e.child,t);else if(e.kind===`scalar`&&e.operator===`in`&&Array.isArray(e.value)){let n=t.get(e.field);t.set(e.field,n?e.value.filter(e=>n.some(t=>c(e,t))):e.value)}return t}function k(e){let t=/* @__PURE__ */ new Map;if(e.kind===`variant`)return k({kind:`and`,children:[{kind:`scalar`,field:e.discriminator,operator:`eq`,value:e.tag},e.child]});if(e.kind===`scalar`){e.operator===`eq`&&!Array.isArray(e.value)&&t.set(e.field,e.value);let n=Array.isArray(e.value)?e.value:void 0;return e.operator===`in`&&n?.length&&n.every(e=>c(e,n[0]))&&t.set(e.field,n[0]),{values:t,impossible:e.operator===`in`&&n?.length===0}}if(e.kind===`not`||e.kind===`relation`)return{values:t,impossible:!1};let n=e.children.map(k);if(e.kind===`or`){let e=n.filter(e=>!e.impossible);for(let[n,r]of e[0]?.values??[])e.every(e=>e.values.has(n)&&c(e.values.get(n),r))&&t.set(n,r);return{values:t,impossible:e.every(e=>e.impossible)}}let r=n.some(e=>e.impossible);for(let e of n)for(let[n,i]of e.values)t.has(n)&&!c(t.get(n),i)&&(r=!0),t.set(n,i);return{values:t,impossible:r}}function A(e,t=/* @__PURE__ */ new Map){if(e.kind===`and`)for(let n of e.children)A(n,t);else if(e.kind===`variant`)A(e.child,t);else if(e.kind===`scalar`&&!Array.isArray(e.value)){let n=e.operator===`gt`||e.operator===`gte`,r=e.operator===`lt`||e.operator===`lte`;if(n||r){let r=t.get(e.field)??{},i=n?`lower`:`upper`,a={value:e.value,inclusive:e.operator===`gte`||e.operator===`lte`},o=r[i],s=o?f(a.value,o.value):0;(!o||(n?s>0:s<0)||s===0&&!a.inclusive)&&(r[i]=a),t.set(e.field,r)}}return t}function j(e,t){let n=[];for(let r of e.fields){if(!t.has(r))break;n.push({field:r,value:t.get(r)})}return n}function M(e){switch(e.kind){case`id`:case`string`:case`float64`:case`int64`:case`boolean`:case`null`:case`literal`:return;case`union`:for(let t of e.members)M(t);return;default:throw Error(`Unsupported scalar filter kind "${e.kind}"`)}}function N(e){switch(e.kind){case`string`:case`float64`:case`int64`:return!0;case`literal`:return d.union([d.string(),d.number(),d.bigint()]).safeParse(e.value).success;case`union`:return e.members.every(N);default:return!1}}export{e as MAX_FILTER_DEPTH,t as MAX_FILTER_IN_VALUES,n as MAX_FILTER_NODES,v as MAX_INDEX_EXPANSION,p as MAX_PAGE_SIZE,y as compileFilters,C as expansionForIndex,T as isQueryFanoutError,h as nativePagination,b as parseFilterPlan,S as rangeForIndex,o as relationFilterSchema,g as scalarPaginationSchema,_ as scalarPredicateSchema,x as withinRange};
2
2
  //# sourceMappingURL=filters.mjs.map