foldkit-entity 0.15.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +128 -17
  2. package/dist/conformance/index.d.ts.map +1 -1
  3. package/dist/conformance/index.js +20 -0
  4. package/dist/conformance/index.js.map +1 -1
  5. package/dist/conformance/operator.d.ts.map +1 -1
  6. package/dist/conformance/operator.js +13 -4
  7. package/dist/conformance/operator.js.map +1 -1
  8. package/dist/entity.d.ts +14 -2
  9. package/dist/entity.d.ts.map +1 -1
  10. package/dist/entity.js +41 -12
  11. package/dist/entity.js.map +1 -1
  12. package/dist/evaluate.d.ts +1 -1
  13. package/dist/evaluate.d.ts.map +1 -1
  14. package/dist/evaluate.js +22 -18
  15. package/dist/evaluate.js.map +1 -1
  16. package/dist/expr.d.ts +70 -20
  17. package/dist/expr.d.ts.map +1 -1
  18. package/dist/expr.js +67 -47
  19. package/dist/expr.js.map +1 -1
  20. package/dist/held.js +11 -3
  21. package/dist/held.js.map +1 -1
  22. package/dist/index.d.ts +38 -6
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +9 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/invariant.d.ts.map +1 -1
  27. package/dist/invariant.js +26 -20
  28. package/dist/invariant.js.map +1 -1
  29. package/dist/law.d.ts.map +1 -1
  30. package/dist/law.js +3 -9
  31. package/dist/law.js.map +1 -1
  32. package/dist/lawCore.d.ts +42 -0
  33. package/dist/lawCore.d.ts.map +1 -0
  34. package/dist/lawCore.js +12 -0
  35. package/dist/lawCore.js.map +1 -0
  36. package/dist/memoryTable.d.ts +11 -0
  37. package/dist/memoryTable.d.ts.map +1 -0
  38. package/dist/memoryTable.js +69 -0
  39. package/dist/memoryTable.js.map +1 -0
  40. package/dist/operators.d.ts.map +1 -1
  41. package/dist/operators.js +2 -66
  42. package/dist/operators.js.map +1 -1
  43. package/dist/sets.js.map +1 -1
  44. package/dist/write.d.ts +1 -1
  45. package/dist/write.d.ts.map +1 -1
  46. package/dist/write.js +40 -18
  47. package/dist/write.js.map +1 -1
  48. package/package.json +1 -1
package/dist/expr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Array, Option, Pipeable, Schema } from "effect";
1
+ import { Array as Array$1, Option, Pipeable, Schema } from "effect";
2
2
  import { AnyEntity, AnyVariantEntity, EntityField, EntityIdentity, EntityRelation, IdOf } from "./index.js";
3
3
  import { Collation as Collation$1 } from "./collation.js";
4
4
  import { NowExpr, ViewerExpr, ViewerPathExpr, viewer } from "./context.js";
@@ -121,7 +121,7 @@ export type OneRelation = EntityRelation<string, string, AnyEntity, 'one', boole
121
121
  export interface PathExpr<T> {
122
122
  readonly _tag: 'Path';
123
123
  /** The relations followed, in order, the first one the judged row's own. */
124
- readonly via: Array.NonEmptyReadonlyArray<OneRelation>;
124
+ readonly via: Array$1.NonEmptyReadonlyArray<OneRelation>;
125
125
  /** What is read on the row reached: a field of the last relation's target. */
126
126
  readonly field: FieldExpr<T>;
127
127
  }
@@ -197,12 +197,12 @@ export interface InPredicate {
197
197
  */
198
198
  export interface AndPredicate {
199
199
  readonly _tag: 'And';
200
- readonly operands: Array.NonEmptyReadonlyArray<Predicate>;
200
+ readonly operands: Array$1.NonEmptyReadonlyArray<Predicate>;
201
201
  }
202
202
  /** At least one operand holds. Never empty, and never holding another `or`. */
203
203
  export interface OrPredicate {
204
204
  readonly _tag: 'Or';
205
- readonly operands: Array.NonEmptyReadonlyArray<Predicate>;
205
+ readonly operands: Array$1.NonEmptyReadonlyArray<Predicate>;
206
206
  }
207
207
  /**
208
208
  * The operand does not hold. As SQL's `not`, an unknown stays unknown, so a row
@@ -257,16 +257,20 @@ type OwnOperand<T> = EntityField<string, string, Schema.Constraint> | Expr<T> |
257
257
  /**
258
258
  * Type-only: the Entities a predicate's fields belong to, by name, so
259
259
  * `Query.where` can refuse one over another Entity where it is written. Never
260
- * set at run time; a predicate built without it (typed plain `Predicate`)
261
- * reads as unknown and is checked at run time only.
260
+ * set at run time. A node built without it (typed plain `Predicate`) names
261
+ * nothing, so it adds no name to a combination and the run-time ownership
262
+ * check is what proves it.
262
263
  */
263
264
  export interface Reads<Names extends string> {
264
265
  readonly '~reads'?: Names;
265
266
  }
266
267
  /**
267
268
  * The Entity names an operand reads: a field's own, a marked node's, none for
268
- * a value or an input. A node with no marker (a `Predicate` typed plainly)
269
- * reads as `string`, unknown.
269
+ * a value or an input. A node with no marker (`Predicate`, `Expr<string>`)
270
+ * answers `never`, not `string`: an unknown read contributes nothing, so
271
+ * `and(onAuthor, plain)` still reads `'Author'` and is refused over another
272
+ * Entity, where `string` would absorb every name it is unioned with and lose
273
+ * that refusal. Ownership of what the type cannot see is checked at run time.
270
274
  */
271
275
  export type ReadsOf<X> = X extends EntityField<infer Name, string, Schema.Constraint> ? Name : X extends EntityRelation<infer Name, string, AnyEntity, 'one', boolean> ? Name : X extends PlainValue | {
272
276
  readonly _tag: 'Literal' | 'Input' | 'Viewer' | 'Now';
@@ -359,11 +363,19 @@ export interface QueryDependencies extends Dependencies {
359
363
  * fall back past it.
360
364
  */
361
365
  export type OrderedOperand = EntityField<string, string, Schema.Constraint & Schema.Codec<number | string | Date | null, any, any, any>> | Expr<number> | Expr<number | null> | Expr<string> | Expr<string | null> | Expr<Date> | Expr<Date | null>;
366
+ /** What a comparison's other side may be, typed from the side it is applied to. */
367
+ type CompareRight<L> = ValueOf<L> | Expr<ValueOf<L>>;
368
+ /** Intersected onto the subject of a step, so a value that does not fit it is refused at the step. */
369
+ type Fits<Right, Allowed, Name extends string> = [Right] extends [Allowed] ? unknown : Invalid<`foldkit-entity: ${Name} was given a value that does not fit the operand it is applied to`>;
370
+ /** `Expr.lt` and its siblings' `step`: the comparison's right side and options, then its left. */
371
+ export type CompareStep = <const R>(right: R, options?: {
372
+ readonly collation?: Collation$1 | undefined;
373
+ }) => <L extends OrderedOperand>(left: L & Fits<R, CompareRight<L>, 'a comparison step'>) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
362
374
  /** `Expr.and` and `Expr.or`: one operand is that operand, and two or more are one node. */
363
375
  interface Connective<Node extends Predicate> {
364
376
  <P extends Predicate>(only: P): P;
365
377
  <A extends Predicate, B extends Predicate, Rest extends ReadonlyArray<Predicate>>(first: A, second: B, ...rest: Rest): Node & Reads<ReadsOf<A> | ReadsOf<B> | ReadsOf<Rest[number]>>;
366
- (...operands: Array.NonEmptyReadonlyArray<Predicate>): Predicate;
378
+ (...operands: Array$1.NonEmptyReadonlyArray<Predicate>): Predicate;
367
379
  }
368
380
  /** A schema's stored form, which is what an operator takes and gives. */
369
381
  type StoredOf<S extends Schema.Top> = Schema.Codec.Encoded<S>;
@@ -390,8 +402,19 @@ export interface Operator<In extends ReadonlyArray<Schema.Top>, Out extends Sche
390
402
  * or `required`, as `Expr.lt(field, value, { collation })` is.
391
403
  */
392
404
  <const A extends { readonly [K in keyof In]: ArgumentOf<In[K]>; }>(...args: [...A, CallOptions]): CallOf<Out> & Reads<ReadsOf<A[number]>>;
405
+ /**
406
+ * The call without its first argument, for `pipe` and `flow`:
407
+ * `pipe(Product.fields.upc, startsWith.step('A'))` builds the node
408
+ * `startsWith(Product.fields.upc, 'A')` builds. One signature, so reads stay
409
+ * exact through `pipe`, which an overload would lose. It takes no
410
+ * `CallOptions`; a call that needs a collation is written data-first.
411
+ */
412
+ readonly step: OperatorStep<In, Out>;
393
413
  readonly descriptor: OperatorDescriptor;
394
414
  }
415
+ type OperatorArguments<In extends ReadonlyArray<Schema.Top>> = { readonly [K in keyof In]: ArgumentOf<In[K]>; };
416
+ /** An operator's step: its arguments past the first, then the first. */
417
+ export type OperatorStep<In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top> = <const Rest extends (OperatorArguments<In> extends readonly [unknown, ...infer R] ? Readonly<R> : never)>(...rest: Rest) => <const Self extends (OperatorArguments<In> extends readonly [infer First, ...Array<unknown>] ? First : never)>(self: Self) => CallOf<Out> & Reads<ReadsOf<Self> | ReadsOf<Rest[number]>>;
395
418
  /** What a call may say past its arguments. */
396
419
  export interface CallOptions {
397
420
  /** The collation it compares text under, in place of its arguments' declared one. */
@@ -431,6 +454,19 @@ interface NextOf {
431
454
  <Name extends string, Key extends string, S extends Schema.Constraint>(field: EntityField<Name, Key, S>): NextExpr<Schema.Schema.Type<S>> & Reads<Name>;
432
455
  <Name extends string, Key extends string, Optional extends boolean>(relation: EntityRelation<Name, Key, AnyEntity, 'one', Optional>): NextExpr<Optional extends true ? string | null : string> & Reads<Name>;
433
456
  }
457
+ /** What `Expr.eq` accepts on the right, typed from its left. */
458
+ type EqRight<L> = ValueOf<L> | Expr<ValueOf<L>> | PathExpr<ValueOf<L> | null> | ViewerPathExpr<ValueOf<L> | null> | (boolean extends ValueOf<L> ? Predicate : never);
459
+ declare const eqCall: <L extends Operand<any> | PlainValue, R extends (L extends PlainValue ? Invalid<'foldkit-entity: Expr.eq takes the field on the left and the value on the right'> : EqRight<L>)>(left: L, right: R) => EqPredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
460
+ /** `Expr.eq.step`: the right side, then the left. */
461
+ export type EqStep = <const R>(right: R) => <L extends Operand<any>>(left: L & Fits<R, EqRight<L>, 'Expr.eq.step'>) => EqPredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
462
+ /** What `Expr.contains` searches for: a value or an input, never a row's own. */
463
+ type ContainsSearch = string | LiteralExpr<string> | InputExpr<string> | InputExpr<string | null>;
464
+ declare const containsCall: <L extends TextOperand>(value: L, search: ContainsSearch) => ContainsPredicate & Reads<ReadsOf<L>>;
465
+ /** `Expr.contains.step`: the search, then the text. */
466
+ export type ContainsStep = <const S extends ContainsSearch>(search: S) => <L extends TextOperand>(value: L) => ContainsPredicate & Reads<ReadsOf<L>>;
467
+ declare const inCall: <L extends Operand<any>>(value: L, among: ReadonlyArray<ValueOf<L>> | Expr<ReadonlyArray<ValueOf<L>>>) => InPredicate & Reads<ReadsOf<L>>;
468
+ /** `Expr.in.step`: the list or its input, then the value. */
469
+ export type InStep = <const R extends ReadonlyArray<unknown> | Expr<ReadonlyArray<unknown>>>(among: R) => <L extends Operand<any>>(value: L & Fits<R, ReadonlyArray<ValueOf<L>> | Expr<ReadonlyArray<ValueOf<L>>>, 'Expr.in.step'>) => InPredicate & Reads<ReadsOf<L>>;
434
470
  export declare const Expr: {
435
471
  /**
436
472
  * An operator, defined by what a call of it means: `definedAs` builds that
@@ -598,7 +634,9 @@ export declare const Expr: {
598
634
  * Expr.eq(Post.fields.status, 'active')
599
635
  * ```
600
636
  */
601
- eq: <L extends Operand<any> | PlainValue, R extends (L extends PlainValue ? Invalid<'foldkit-entity: Expr.eq takes the field on the left and the value on the right'> : ValueOf<L> | Expr<ValueOf<L>> | PathExpr<ValueOf<L> | null> | ViewerPathExpr<ValueOf<L> | null> | (boolean extends ValueOf<L> ? Predicate : never))>(left: L, right: R) => EqPredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
637
+ eq: typeof eqCall & {
638
+ step: EqStep;
639
+ };
602
640
  /**
603
641
  * Whether a field holds no value. Its opposite is `isNotNull`; both are the
604
642
  * one node, since a query asks which of the two it means, and `is not null`
@@ -623,7 +661,9 @@ export declare const Expr: {
623
661
  * nullable column that should match everything on an empty search says so:
624
662
  * `Expr.or(Expr.isNull(field), Expr.contains(field, input.search))`.
625
663
  */
626
- contains: <L extends TextOperand>(value: L, search: string | LiteralExpr<string> | InputExpr<string> | InputExpr<string | null>) => ContainsPredicate & Reads<ReadsOf<L>>;
664
+ contains: typeof containsCall & {
665
+ step: ContainsStep;
666
+ };
627
667
  /**
628
668
  * Whether a value is one of `among`: a list written out, or an input whose
629
669
  * value is one. Each element is compared as `eq` compares.
@@ -637,7 +677,9 @@ export declare const Expr: {
637
677
  * holding a null, and an empty list matches no row. A list written out is
638
678
  * copied, so changing the array afterwards does not change the query.
639
679
  */
640
- in: <L extends Operand<any>>(value: L, among: ReadonlyArray<ValueOf<L>> | Expr<ReadonlyArray<ValueOf<L>>>) => InPredicate & Reads<ReadsOf<L>>;
680
+ in: typeof inCall & {
681
+ step: InStep;
682
+ };
641
683
  /**
642
684
  * `left` orders before `right`. Numbers compare as numbers; text compares
643
685
  * under a collation, the one given or the field's declared one, which must be
@@ -651,21 +693,29 @@ export declare const Expr: {
651
693
  * Expr.and(Expr.gte(fields.at, input.from), Expr.lt(fields.at, input.until))
652
694
  * ```
653
695
  */
654
- lt: <L extends OrderedOperand, R extends ValueOf<L> | Expr<ValueOf<L>>>(left: L, right: R, options?: {
696
+ lt: (<L extends OrderedOperand, R extends CompareRight<L>>(left: L, right: R, options?: {
655
697
  readonly collation?: Collation$1 | undefined;
656
- }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
698
+ }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>) & {
699
+ step: CompareStep;
700
+ };
657
701
  /** `left` orders before `right`, or with it; see `Expr.lt`. */
658
- lte: <L extends OrderedOperand, R extends ValueOf<L> | Expr<ValueOf<L>>>(left: L, right: R, options?: {
702
+ lte: (<L extends OrderedOperand, R extends CompareRight<L>>(left: L, right: R, options?: {
659
703
  readonly collation?: Collation$1 | undefined;
660
- }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
704
+ }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>) & {
705
+ step: CompareStep;
706
+ };
661
707
  /** `left` orders after `right`; see `Expr.lt`. */
662
- gt: <L extends OrderedOperand, R extends ValueOf<L> | Expr<ValueOf<L>>>(left: L, right: R, options?: {
708
+ gt: (<L extends OrderedOperand, R extends CompareRight<L>>(left: L, right: R, options?: {
663
709
  readonly collation?: Collation$1 | undefined;
664
- }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
710
+ }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>) & {
711
+ step: CompareStep;
712
+ };
665
713
  /** `left` orders after `right`, or with it; see `Expr.lt`. */
666
- gte: <L extends OrderedOperand, R extends ValueOf<L> | Expr<ValueOf<L>>>(left: L, right: R, options?: {
714
+ gte: (<L extends OrderedOperand, R extends CompareRight<L>>(left: L, right: R, options?: {
667
715
  readonly collation?: Collation$1 | undefined;
668
- }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>;
716
+ }) => ComparePredicate & Reads<ReadsOf<L> | ReadsOf<R>>) & {
717
+ step: CompareStep;
718
+ };
669
719
  /**
670
720
  * Every operand holds, as one predicate to place inside another: `where`'s
671
721
  * list is already a conjunction, so this is for `or(and(a, b), c)`.
@@ -1 +1 @@
1
- {"version":3,"file":"expr.d.ts","names":["Collation","Law","Arr"],"sources":["../src/expr.ts"],"mappings":";;;;;;iBAgCiB,YAAY;WAClB;WACA,OAAO;;;;;;iBAOD,UAAU;WAChB;WACA,OAAO;WACP;WACA,QAAQ,OAAO,MAAM;;;;;;WAMrB,WAAW,OAAO,OAAOA;;;;;;;;iBASnB,UAAU;WAChB;WACA;WACA,QAAQ,OAAO,MAAM;;;;;;;iBAQf,SAAS;WACf;WACA,OAAO,UAAU;;;;;;;;iBASX;WACN;WACA;WACA;WACA,aAAa,OAAO;;WAEpB,OAAO,cAAc,OAAO;WAC5B,QAAQ,OAAO;;;;;;WAMf,WAAW,OAAO,WAAW,MAAM,cAAc,gBAAgB;;;;;;WAMjE;;;;;;;WAOA;;WAEA,MAAM,cAAcC;;;iBAId;;WAEN,MAAM,UAAU;;;;;;WAMhB,WAAW,eAAe;;;qBAIxB,aAAa;;;;;qBAMb,cAAW,UAAc,oBAAkB,WAAa;;;;;;iBAmBpD,SAAS;WACf;WACA,UAAU;WACV,MAAM,cAAc;WACpB,WAAW,OAAO,OAAO,KAAK;;WAE9B,WAAW,OAAO,OAAOD;;;YAIxB,cAAc,+BAA+B;;;;;;iBAOxC,SAAS;WACf;;WAEA,KAAKE,MAAI,sBAAsB;;WAE/B,OAAO,UAAU;;;YAIhB,KAAK,KACb,YAAY,KACZ,UAAU,KACV,UAAU,KACV,SAAS,KACT,SAAS,KACT,WAAW,KACX,Q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  import { absurd } from "effect/Function";
6
6
  import { Collation } from "./collation.js";
7
7
  import { now, viewer } from "./context.js";
8
- import { Law } from "./law.js";
8
+ import { Laws, lawKind } from "./lawCore.js";
9
9
  // src/expr.ts
10
10
  /**
11
11
  * `Expr` — a query's scalar computations as typed values.
@@ -204,16 +204,20 @@ const collationFor = (step, left, right, given) => {
204
204
  }));
205
205
  };
206
206
  /** `Expr.lt` and its three siblings: the operator fixed, the sides typed alike. */
207
- const comparison = (operator) => (left, right, options = {}) => {
208
- const leftSide = toExpr(left, operator);
209
- const rightSide = toExpr(right, operator);
210
- return node({
211
- _tag: "Compare",
212
- operator,
213
- left: leftSide,
214
- right: rightSide,
215
- collation: collationFor(operator, leftSide, rightSide, Option.fromUndefinedOr(options.collation))
216
- });
207
+ const comparison = (operator) => {
208
+ const compare = (left, right, options = {}) => {
209
+ const leftSide = toExpr(left, operator);
210
+ const rightSide = toExpr(right, operator);
211
+ return node({
212
+ _tag: "Compare",
213
+ operator,
214
+ left: leftSide,
215
+ right: rightSide,
216
+ collation: collationFor(operator, leftSide, rightSide, Option.fromUndefinedOr(options.collation))
217
+ });
218
+ };
219
+ const step = (right, options) => (left) => compare(left, right, options);
220
+ return Object.assign(compare, { step });
217
221
  };
218
222
  /** A connective's operands, each checked to be a predicate, with one of the same kind flattened in. */
219
223
  const connected = (step, kind, given) => {
@@ -261,11 +265,11 @@ const operatorId = /^[a-z][A-Za-z0-9]*(\.[a-z][A-Za-z0-9]*)+$/;
261
265
  * whose text keeps none.
262
266
  */
263
267
  const lawProblem = (law, input, output, collation) => {
264
- const name = Law.describe(law).kind;
268
+ const name = lawKind(law);
265
269
  const binary = () => input.length === 2 ? Option.none() : Option.some(`${name} is a law of an operator of two arguments, and this one takes ${input.length}`);
266
270
  const decodes = (value, schema, what) => Schema.is(Schema.toEncoded(schema))(value) ? Option.none() : Option.some(`${name}'s ${what} ${JSON.stringify(value)} does not decode as its schema`);
267
271
  const sides = (value, side) => Option.orElse(binary(), () => Option.orElse(side === "right" ? Option.none() : decodes(value, input[0], "left witness"), () => side === "left" ? Option.none() : decodes(value, input[1], "right witness")));
268
- return Law.$match(law, {
272
+ return Laws.$match(law, {
269
273
  Associative: binary,
270
274
  Commutative: binary,
271
275
  Idempotent: binary,
@@ -352,10 +356,13 @@ const callCollation = (id, rule, args) => {
352
356
  const fail = (what) => {
353
357
  throw new Error(`[foldkit-entity] ${id}: ${what}`);
354
358
  };
355
- const voters = args.flatMap((arg) => isPredicate(arg) || arg._tag === "Literal" || arg._tag === "Input" || sideKind(arg) !== "text" ? [] : [{
356
- arg,
357
- collation: collationOf(arg)
358
- }]);
359
+ const voters = args.flatMap((arg) => {
360
+ if (isPredicate(arg) || arg._tag === "Literal" || arg._tag === "Input" || sideKind(arg) !== "text") return [];
361
+ return [{
362
+ arg,
363
+ collation: collationOf(arg)
364
+ }];
365
+ });
359
366
  const collations = voters.flatMap(({ arg, collation }) => Option.match(collation, {
360
367
  onSome: (each) => [each],
361
368
  onNone: () => rule === "required" ? fail(`${showExpr(arg)} is text with no declared collation, so backends would compare it differently; declare Collation.binary or Collation.asciiFold on it`) : []
@@ -440,20 +447,24 @@ const makeOperator = (id, options) => {
440
447
  collation: carried
441
448
  });
442
449
  };
443
- return Object.freeze(Object.assign(call, { descriptor }));
450
+ const step = (...rest) => (self) => call(self, ...rest);
451
+ return Object.freeze(Object.assign(call, {
452
+ step,
453
+ descriptor
454
+ }));
444
455
  };
445
456
  /** Each defined call replaced by its expansion, deeply; built once per node. */
446
457
  const expandedCache = /* @__PURE__ */ new WeakMap();
447
458
  const expandedScalar = (scalar) => {
448
459
  const known = expandedCache.get(scalar);
449
460
  if (known !== void 0) return known;
450
- const result = scalar._tag === "Call" ? Option.match(scalar.expansion, {
461
+ const result = Match.value(scalar).pipe(Match.tag("Call", (call) => Option.match(call.expansion, {
451
462
  onSome: expandedScalar,
452
463
  onNone: () => node({
453
- ...scalar,
454
- args: scalar.args.map(expandedSide)
464
+ ...call,
465
+ args: call.args.map(expandedSide)
455
466
  })
456
- }) : scalar;
467
+ })), Match.orElse((other) => other));
457
468
  expandedCache.set(scalar, result);
458
469
  return result;
459
470
  };
@@ -627,6 +638,28 @@ const nextOf = ((member) => node({
627
638
  _tag: "Next",
628
639
  field: toOperand(member)
629
640
  }));
641
+ const eqCall = (left, right) => node({
642
+ _tag: "Eq",
643
+ left: toOperand(left),
644
+ right: toOperand(right)
645
+ });
646
+ const eq = Object.assign(eqCall, { step: ((right) => (left) => eqCall(left, right)) });
647
+ const containsCall = (value, search) => {
648
+ const operand = toOperand(search);
649
+ if (operand._tag !== "Literal" && operand._tag !== "Input") throw new Error(`[foldkit-entity] Expr.contains: the search is ${showExpr(operand)}; search for a value or an input`);
650
+ return node({
651
+ _tag: "Contains",
652
+ value: toExpr(value, "contains"),
653
+ search: operand
654
+ });
655
+ };
656
+ const contains = Object.assign(containsCall, { step: ((search) => (value) => containsCall(value, search)) });
657
+ const inCall = (value, among) => node({
658
+ _tag: "In",
659
+ value: toExpr(value, "in"),
660
+ among: Array.isArray(among) ? literal(Object.freeze([...among])) : toExpr(among, "in")
661
+ });
662
+ const inAmong = Object.assign(inCall, { step: ((among) => (value) => inCall(value, among)) });
630
663
  const Expr = {
631
664
  /**
632
665
  * An operator, defined by what a call of it means: `definedAs` builds that
@@ -790,11 +823,7 @@ const Expr = {
790
823
  * Expr.eq(Post.fields.status, 'active')
791
824
  * ```
792
825
  */
793
- eq: (left, right) => node({
794
- _tag: "Eq",
795
- left: toOperand(left),
796
- right: toOperand(right)
797
- }),
826
+ eq,
798
827
  /**
799
828
  * Whether a field holds no value. Its opposite is `isNotNull`; both are the
800
829
  * one node, since a query asks which of the two it means, and `is not null`
@@ -827,15 +856,7 @@ const Expr = {
827
856
  * nullable column that should match everything on an empty search says so:
828
857
  * `Expr.or(Expr.isNull(field), Expr.contains(field, input.search))`.
829
858
  */
830
- contains: (value, search) => {
831
- const operand = toOperand(search);
832
- if (operand._tag !== "Literal" && operand._tag !== "Input") throw new Error(`[foldkit-entity] Expr.contains: the search is ${showExpr(operand)}; search for a value or an input`);
833
- return node({
834
- _tag: "Contains",
835
- value: toExpr(value, "contains"),
836
- search: operand
837
- });
838
- },
859
+ contains,
839
860
  /**
840
861
  * Whether a value is one of `among`: a list written out, or an input whose
841
862
  * value is one. Each element is compared as `eq` compares.
@@ -849,11 +870,7 @@ const Expr = {
849
870
  * holding a null, and an empty list matches no row. A list written out is
850
871
  * copied, so changing the array afterwards does not change the query.
851
872
  */
852
- in: (value, among) => node({
853
- _tag: "In",
854
- value: toExpr(value, "in"),
855
- among: Array.isArray(among) ? literal(Object.freeze([...among])) : toExpr(among, "in")
856
- }),
873
+ in: inAmong,
857
874
  /**
858
875
  * `left` orders before `right`. Numbers compare as numbers; text compares
859
876
  * under a collation, the one given or the field's declared one, which must be
@@ -936,11 +953,11 @@ const substitutedSide = (side, rewrite) => isPredicate(side) ? substituted(side,
936
953
  * A scalar rewritten: a call's arguments and expansion each, so a field read
937
954
  * under it is rewritten as one read directly is; anything else by `rewrite`.
938
955
  */
939
- const substitutedScalar = (scalar, rewrite) => scalar._tag === "Call" ? node({
940
- ...scalar,
941
- args: Object.freeze(scalar.args.map((arg) => substitutedSide(arg, rewrite))),
942
- expansion: Option.map(scalar.expansion, (expansion) => substitutedScalar(expansion, rewrite))
943
- }) : rewrite(scalar);
956
+ const substitutedScalar = (scalar, rewrite) => Match.value(scalar).pipe(Match.tag("Call", (call) => node({
957
+ ...call,
958
+ args: Object.freeze(call.args.map((arg) => substitutedSide(arg, rewrite))),
959
+ expansion: Option.map(call.expansion, (expansion) => substitutedScalar(expansion, rewrite))
960
+ })), Match.orElse((other) => rewrite(other)));
944
961
  const substituted = (predicate, rewrite) => {
945
962
  switch (predicate._tag) {
946
963
  case "Eq": return node({
@@ -1343,7 +1360,10 @@ const fieldsIn = function* (expr, seen) {
1343
1360
  */
1344
1361
  const checkOwnership = (step, what, entity, nodes) => {
1345
1362
  const seen = /* @__PURE__ */ new Set();
1346
- for (const term of nodes) for (const field of fieldsIn(term, seen)) if (field.owner.token !== entity.identity.token) throw new Error(`[foldkit-entity] Query.${step}: ${what} reads ${field.owner.name}.${field.key}, but the query is from ${entity.name}`);
1363
+ for (const term of nodes) for (const field of fieldsIn(term, seen)) if (field.owner.token !== entity.identity.token) {
1364
+ const namesake = field.owner.name === entity.name ? `: the field belongs to another Entity defined with that name, and two definitions are two Entities` : "";
1365
+ throw new Error(`[foldkit-entity] Query.${step}: ${what} reads ${field.owner.name}.${field.key}, but the query is from ${entity.name}${namesake}`);
1366
+ }
1347
1367
  };
1348
1368
  /**
1349
1369
  * The most nodes a query's predicates may hold once every shared node is