foldkit-entity 0.7.0 → 0.8.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.
- package/README.md +106 -4
- package/dist/conformance/index.d.mts +12 -1
- package/dist/conformance/index.d.mts.map +1 -1
- package/dist/conformance/index.mjs +218 -2
- package/dist/conformance/index.mjs.map +1 -1
- package/dist/index-DLz2yED-.d.mts +919 -0
- package/dist/index-DLz2yED-.d.mts.map +1 -0
- package/dist/index.d.mts +2 -642
- package/dist/index.mjs +2 -877
- package/dist/src-BtxgsdKb.mjs +1332 -0
- package/dist/src-BtxgsdKb.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -263,8 +263,12 @@ CreatePost.members.notify // Entity.unmapped: about the operation, not the Post
|
|
|
263
263
|
```
|
|
264
264
|
|
|
265
265
|
- A key that names a field, with a value that fits it, maps itself. Only the
|
|
266
|
-
present value has to fit: a key may be optional (a partial update)
|
|
267
|
-
`null` (clearing it),
|
|
266
|
+
present value has to fit: a key may be optional (a partial update), admit
|
|
267
|
+
`null` (clearing it), or hold an `Option` (an id absent for something new),
|
|
268
|
+
which is the input schema's rule to make.
|
|
269
|
+
A declared write (`Write.update`, `Write.insert`) writes what an `Option`
|
|
270
|
+
holds and nothing for one holding nothing or a key left out; its id may not
|
|
271
|
+
be absent, since it names the row it writes.
|
|
268
272
|
- Every other key needs an entry: a Field under another name, a relation's ids
|
|
269
273
|
with `Relation.input(relation)`, or `Entity.unmapped`. Nothing is inferred
|
|
270
274
|
from a name like `authorId`.
|
|
@@ -324,6 +328,33 @@ The schema is an ordinary `Schema.Struct`, so declare it once and give the same
|
|
|
324
328
|
value to the operation, for example `Mutation.make('CreatePost', { Input:
|
|
325
329
|
CreatePostInput, … })` in `foldkit-remote`.
|
|
326
330
|
|
|
331
|
+
### Declaring what an input writes
|
|
332
|
+
|
|
333
|
+
An input says what each key *is*; a `Write` says what an operation *does* with
|
|
334
|
+
them: `Write.update` one row, named by a key, setting every other key mapped to
|
|
335
|
+
a field; `Write.insert` a row under an id the client chose; or `Write.delete`
|
|
336
|
+
one, which sets nothing.
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
const EditPost = Entity.input(Blog.Post, EditPostInput)
|
|
340
|
+
const Edit = Write.update(EditPost, { id: 'id' })
|
|
341
|
+
|
|
342
|
+
Write.writes(Edit) // the fields any invocation may change
|
|
343
|
+
Write.bind(Edit, { id: 'p1', title: 'Compilers' })
|
|
344
|
+
// { entity: 'Post', id: 'p1', values: { title: 'Compilers' } }, as the store holds it
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
It is declared data, like a query body: nothing is written by building one, and
|
|
348
|
+
an Entity having a field grants no one the right to set it. `bind` encodes each
|
|
349
|
+
value through its field's schema, so the patch is in the store's shape, and
|
|
350
|
+
takes the keys to write when an author changed only some. `expect` names a key
|
|
351
|
+
holding the revision the row was read at, for an interpreter to write only a row
|
|
352
|
+
still at it. An unmapped key is not written. A key mapped to a `one` relation
|
|
353
|
+
points the row elsewhere: `bind` gives it as a ref in `links` (none for an
|
|
354
|
+
optional relation set to nothing), and each interpreter carries it its own way,
|
|
355
|
+
a ref key in a store, a foreign key in a table. A `many` relation or a nested
|
|
356
|
+
key is refused where the write is declared.
|
|
357
|
+
|
|
327
358
|
## Attaching metadata
|
|
328
359
|
|
|
329
360
|
An interpreter declares a [`foldkit-metadata`](../metadata/README.md) key and
|
|
@@ -423,6 +454,12 @@ name are two entries.
|
|
|
423
454
|
|
|
424
455
|
Every node is frozen as it is built, so a query is the value it was when
|
|
425
456
|
`Query.where` checked it: nothing can swap a field or a literal in afterwards.
|
|
457
|
+
|
|
458
|
+
A node can be shared (`Expr.eq(n, n)`), and the analysis visits each one once.
|
|
459
|
+
An interpreter does not: `evaluate` reads a predicate as a tree on every row,
|
|
460
|
+
and the SQL compiler writes a shared operand out wherever it appears. So
|
|
461
|
+
`Query.where` refuses predicates that expand past `maxQueryNodes` (1,000)
|
|
462
|
+
nodes, counting a shared node on each path that reaches it.
|
|
426
463
|
A node may be shared, `Expr.eq(n, n)`, and every walk over one visits each
|
|
427
464
|
node once, so a deeply shared predicate costs its size, not its paths.
|
|
428
465
|
|
|
@@ -455,6 +492,13 @@ not match `é`, though each matches itself. Text holding a NUL character is
|
|
|
455
492
|
refused by every interpreter here, since Postgres text cannot hold one and
|
|
456
493
|
SQLite's `like` stops at it.
|
|
457
494
|
|
|
495
|
+
**`in` asks whether a value is one of a list**, written out or given as an
|
|
496
|
+
input: `Expr.in(Todo.fields.projectId, input.projectIds)`. Each element is
|
|
497
|
+
compared as `eq` compares, and it reads as SQL's `in`: a null value is
|
|
498
|
+
unknown, so is no match against a list holding a null, and an empty list
|
|
499
|
+
matches no row (on Postgres too, which refuses `in ()`; the compiler says
|
|
500
|
+
`false` instead).
|
|
501
|
+
|
|
458
502
|
**It searches text, and the operand is constrained to text.** `contains` over a
|
|
459
503
|
number would compile to `lower(rank) like …`, which SQLite coerces into an
|
|
460
504
|
answer and Postgres rejects at runtime — so a non-text operand is a compile
|
|
@@ -488,6 +532,56 @@ before, so piping a fragment can only ever narrow a query, never silently undo
|
|
|
488
532
|
part of it. An earlier ordering term stays the more significant one, which is
|
|
489
533
|
what makes a later `Query.orderBy(Order.asc(id))` a tie-breaker. Neither ever replaces what a fragment added.
|
|
490
534
|
|
|
535
|
+
**A sort the reader picks is part of the body too.** `Order.chosen` maps each
|
|
536
|
+
name the input's sort can hold to a field, so the server and the client read one
|
|
537
|
+
declaration of what `title` means, and the client can tell which edits may move
|
|
538
|
+
a row:
|
|
539
|
+
|
|
540
|
+
```ts
|
|
541
|
+
const PostSort = Schema.NullOr(
|
|
542
|
+
Schema.Struct({ by: Schema.Literals(['title', 'id']), direction: Schema.Literals(['asc', 'desc']) }),
|
|
543
|
+
)
|
|
544
|
+
const sorted = (sort: InputExpr<typeof PostSort.Type>) =>
|
|
545
|
+
Query.from(Blog.Post).pipe(
|
|
546
|
+
Query.orderBy(Order.chosen(sort, { title: Blog.Post.fields.title, id: Blog.Post.fields.id })),
|
|
547
|
+
)
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
Every name the sort can hold needs a field, or it does not compile. A `null`
|
|
551
|
+
sort chooses none, and the terms after it decide. `Query.orderFor(query, input)`
|
|
552
|
+
is the fixed terms for one input, which is what every interpreter sorts by.
|
|
553
|
+
|
|
554
|
+
**Every order is total.** `orderFor` ends it on the Entity's id, ascending,
|
|
555
|
+
unless the terms already read the id, so rows with equal keys come out in one
|
|
556
|
+
order on every interpreter rather than each breaking ties its own way.
|
|
557
|
+
|
|
558
|
+
**How text orders is declared, or left to the server.** Left unsaid, SQLite
|
|
559
|
+
compares bytes, Postgres follows the database's locale and a JavaScript sort
|
|
560
|
+
follows UTF-16 code units. A field declares its collation, and every
|
|
561
|
+
interpreter that can honour it orders the same; one that cannot refuses:
|
|
562
|
+
|
|
563
|
+
```ts
|
|
564
|
+
const Tagged = Entity.define('Tagged', Schema.Struct({ id: Schema.String, name: Schema.String })).pipe(
|
|
565
|
+
Entity.annotateMembers({ name: Collation.of(Collation.asciiFold) }),
|
|
566
|
+
)
|
|
567
|
+
const byName = Query.from(Tagged).pipe(Query.orderBy(Order.asc(Tagged.fields.name)))
|
|
568
|
+
Query.placement(byName, {}) // { _tag: 'Placeable' }
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
- `Collation.binary` is code point order: SQLite `BINARY`, Postgres
|
|
572
|
+
`COLLATE "C"`. An id is `binary` unless it says otherwise.
|
|
573
|
+
- `Collation.asciiFold` folds ASCII letters, then compares by code point:
|
|
574
|
+
SQLite `NOCASE`, Postgres `lower(x COLLATE "C")`.
|
|
575
|
+
- `Collation.locale('en-US')` is the backend's own, ordered on the server and
|
|
576
|
+
never by a client.
|
|
577
|
+
|
|
578
|
+
A term overrides its field's: `Order.asc(field, { collation })`.
|
|
579
|
+
`Query.placement(query, input)` says whether a client can order the rows exactly
|
|
580
|
+
as the server does: every term over a number or a boolean (a row may lack it), or over text with a
|
|
581
|
+
portable collation. A body with no order, text with none declared, or a locale
|
|
582
|
+
is `NotPlaceable`, with the reason.
|
|
583
|
+
`foldkit-crud`'s `Sort.make(['title', 'id']).Schema` is such a sort.
|
|
584
|
+
|
|
491
585
|
The list of predicates **is** the conjunction — which is why no `Expr.and`
|
|
492
586
|
exists. A query wanting three conditions writes three `where`s. An `and`
|
|
493
587
|
operator is only needed for a conjunction nested inside something else, and no
|
|
@@ -552,6 +646,8 @@ from queries, not from what a database could express.
|
|
|
552
646
|
| `Entity.select(entity, { key: true or Selection })` | A Selection: what was selected (`members`) and the `schema` of the result. |
|
|
553
647
|
| `Entity.page(selection, { first, after } or { last, before })` | In a Selection, a `many` relation read as a page: `items`, `hasNext`, `hasPrevious`. |
|
|
554
648
|
| `Entity.fields(entity, ...keys)` | The schemas of those fields, by key, to spread into an input's struct. |
|
|
649
|
+
| `Write.update(input, { id, expect? })` | A declared update of one row: every key the input maps to a field, but the id and the expected revision. |
|
|
650
|
+
| `Write.writes(write)` / `Write.bind(write, value, keys?)` | The fields it may change; the row and values one input writes, encoded as the store holds them. |
|
|
555
651
|
| `Entity.input(entity, struct, mapping?)` | Experimental. Which member each key of an operation's input writes. |
|
|
556
652
|
| `Relation.nested(relation, input)` | In an input mapping: the key holds the target itself, written through `input`. |
|
|
557
653
|
| `Entity.selectFor(input)` | The Selection of the members an input writes: what an edit screen loads. |
|
|
@@ -566,15 +662,21 @@ from queries, not from what a database could express.
|
|
|
566
662
|
| `Expr.eq(left, right)` | Two values are the same; a field or a plain value on either side is coerced, and a predicate may stand where a boolean is wanted. |
|
|
567
663
|
| `Expr.isNull(field)` / `Expr.isNotNull(field)` | Whether a value is absent; one node, with the answer absence gives flipped. |
|
|
568
664
|
| `Expr.contains(field, search)` | Whether text contains text, over a text or nullable-text operand only. Containing the empty string is everything, but a null contains nothing. |
|
|
665
|
+
| `Expr.in(field, among)` | Whether a value is one of a list (written out, or an input), each compared as `eq` compares; SQL's `in`, an empty list matching nothing. |
|
|
569
666
|
| `Expr.field(field)` | One field of one Entity, as a scalar. |
|
|
570
667
|
| `Expr.input(key, schema)` | A value the query is given when it runs, as a placeholder. |
|
|
571
668
|
| `Expr.literal(value)` | A constant. Comparisons coerce one, so this is rarely written. |
|
|
572
|
-
| `Order.asc(expr)` / `Order.desc(expr)` | One term of an ordering, over a field or a scalar. |
|
|
669
|
+
| `Order.asc(expr, { nulls? })` / `Order.desc(expr, { nulls? })` | One term of an ordering, over a field or a scalar. Rows without a value go last ascending and first descending unless `nulls` says otherwise; every interpreter is told, since databases disagree when it is unsaid. |
|
|
670
|
+
| `Collation.binary` / `.asciiFold` / `.locale(name)` / `.of(collation)` | How a text field orders, as member metadata; see above. |
|
|
671
|
+
| `ReadFilter.of(members)` / `.members(metadata)` | Entity metadata: the members a server filters rows by under a rule the client does not run (an authorization rule; `foldkit-guard` attaches it). A client placing rows in a list fetches the list instead when one changes. Annotations add up. |
|
|
672
|
+
| `Query.placement(query, input)` | `Placeable`, or `NotPlaceable` with why: whether a client can order as the server does. |
|
|
673
|
+
| `Order.chosen(sort, choices)` | The field an input's sort names (`{ by, direction }`, or `null` for none), among `choices`. |
|
|
573
674
|
| `dependenciesOf(...nodes)` | The distinct fields, inputs, and operations those expressions use. |
|
|
574
675
|
| `Query.from(entity)` | Every row of an Entity: the query each step narrows. |
|
|
575
676
|
| `Query.where(...predicates)` | Pipe step keeping the rows those hold for; conjoins with what is there. |
|
|
576
677
|
| `Query.orderBy(...terms)` | Pipe step reading in that order; appends after existing terms. |
|
|
577
|
-
| `Query.
|
|
678
|
+
| `Query.orderFor(query, input)` | The fixed terms it orders by for one input, each chosen order resolved, ending on the id. |
|
|
679
|
+
| `Query.dependencies(query)` | What the whole query reads, with its fields also split by role: `predicate` (can change which rows match) and `order` (can change where a row sits). |
|
|
578
680
|
| `Query.unsupported(query, supported)` | The operations it needs that an interpreter does not run. |
|
|
579
681
|
| `Query.show(query)` / `Expr.show(node)` | The query or expression as readable text, for a person and not for an interpreter. |
|
|
580
682
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyQuery, Entity } from "../index
|
|
1
|
+
import { et as AnyQuery, s as Entity } from "../index-DLz2yED-.mjs";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
//#region src/conformance/index.d.ts
|
|
4
4
|
/** The one Entity every case reads, with a column of each kind that matters. */
|
|
@@ -42,5 +42,16 @@ export interface ConformanceCase {
|
|
|
42
42
|
readonly expected: ReadonlyArray<string>;
|
|
43
43
|
}
|
|
44
44
|
export declare const cases: ReadonlyArray<ConformanceCase>;
|
|
45
|
+
/**
|
|
46
|
+
* A body whose answer no two interpreters agree on, so every interpreter must
|
|
47
|
+
* refuse it rather than answer. Run each through yours and expect a failure.
|
|
48
|
+
*/
|
|
49
|
+
export interface ConformanceRefusal {
|
|
50
|
+
readonly what: string;
|
|
51
|
+
readonly body: AnyQuery;
|
|
52
|
+
/** The inputs, encoded, as in `ConformanceCase`. */
|
|
53
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
54
|
+
}
|
|
55
|
+
export declare const refusals: ReadonlyArray<ConformanceRefusal>;
|
|
45
56
|
//#endregion
|
|
46
57
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/conformance/index.ts"],"mappings":";;;;qBA4Ca,SAAO;;;;;;;;;;;;;;;iBAmBH;WACN;WACA;WACA;WACA;;WAEA;YACC;;qBAGC,MAAM,cAAc;iBAQhB;;WAEN;WACA,MAAM;;;;;;;WAON,OAAO,SAAS;;WAEhB,UAAU;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/conformance/index.ts"],"mappings":";;;;qBA4Ca,SAAO;;;;;;;;;;;;;;;iBAmBH;WACN;WACA;WACA;WACA;;WAEA;YACC;;qBAGC,MAAM,cAAc;iBAQhB;;WAEN;WACA,MAAM;;;;;;;WAON,OAAO,SAAS;;WAEhB,UAAU;;qBAuBR,OAAO,cAAc;;;;;iBAkUjB;WACN;WACA,MAAM;;WAEN,OAAO,SAAS;;qBAKd,UAAU,cAAc"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as Query, g as Order, h as Expr, n as Entity, x as Collation } from "../src-BtxgsdKb.mjs";
|
|
2
2
|
import { Schema, SchemaGetter } from "effect";
|
|
3
3
|
//#region src/conformance/index.ts
|
|
4
4
|
/**
|
|
@@ -92,7 +92,14 @@ const label = Expr.input("label", Schema.String);
|
|
|
92
92
|
const text = Expr.input("text", Schema.String);
|
|
93
93
|
const tag = Expr.input("tag", Schema.String);
|
|
94
94
|
const present = Expr.input("present", Schema.Boolean);
|
|
95
|
+
const labels = Expr.input("labels", Schema.Array(Schema.String));
|
|
95
96
|
const at = Expr.input("at", Timestamp);
|
|
97
|
+
/** A list sorted by what its reader picked: `Order.chosen`'s input. */
|
|
98
|
+
const sort = Expr.input("sort", Schema.NullOr(Schema.Struct({
|
|
99
|
+
by: Schema.Literals(["rank"]),
|
|
100
|
+
direction: Schema.Literals(["asc", "desc"])
|
|
101
|
+
})));
|
|
102
|
+
const chosen = Query.orderBy(Order.chosen(sort, { rank: Subject.fields.rank }), Order.asc(Subject.fields.id));
|
|
96
103
|
const cases = [
|
|
97
104
|
{
|
|
98
105
|
what: "eq matches a field against a literal",
|
|
@@ -257,6 +264,76 @@ const cases = [
|
|
|
257
264
|
input: { label: null },
|
|
258
265
|
expected: []
|
|
259
266
|
},
|
|
267
|
+
{
|
|
268
|
+
what: "in matches a field against a list written out",
|
|
269
|
+
body: from.pipe(Query.where(Expr.in(Subject.fields.rank, [1, 4])), byId),
|
|
270
|
+
input: {},
|
|
271
|
+
expected: ["b", "e"]
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
what: "in matches a field against the list the request supplies, exactly",
|
|
275
|
+
body: from.pipe(Query.where(Expr.in(Subject.fields.label, labels)), byId),
|
|
276
|
+
input: { labels: ["Other", "intro"] },
|
|
277
|
+
expected: ["c"]
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
what: "in against an empty list matches nothing",
|
|
281
|
+
body: from.pipe(Query.where(Expr.in(Subject.fields.label, labels)), byId),
|
|
282
|
+
input: { labels: [] },
|
|
283
|
+
expected: []
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
what: "in skips the rows whose column is null",
|
|
287
|
+
body: from.pipe(Query.where(Expr.in(Subject.fields.tag, ["x", "y"])), byId),
|
|
288
|
+
input: {},
|
|
289
|
+
expected: [
|
|
290
|
+
"b",
|
|
291
|
+
"d",
|
|
292
|
+
"e"
|
|
293
|
+
]
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
what: "in compared to false is its negation, and a null column stays unknown",
|
|
297
|
+
body: from.pipe(Query.where(Expr.eq(Expr.in(Subject.fields.tag, ["x"]), present)), byId),
|
|
298
|
+
input: { present: false },
|
|
299
|
+
expected: ["e"]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
what: "in against an empty list compared to false matches every row, null or not",
|
|
303
|
+
body: from.pipe(Query.where(Expr.eq(Expr.in(Subject.fields.tag, labels), present)), byId),
|
|
304
|
+
input: {
|
|
305
|
+
labels: [],
|
|
306
|
+
present: false
|
|
307
|
+
},
|
|
308
|
+
expected: [
|
|
309
|
+
"a",
|
|
310
|
+
"b",
|
|
311
|
+
"c",
|
|
312
|
+
"d",
|
|
313
|
+
"e"
|
|
314
|
+
]
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
what: "in asks of an input as of a field: every row, when the input is listed",
|
|
318
|
+
body: from.pipe(Query.where(Expr.in(text, ["x", "y"])), byId),
|
|
319
|
+
input: { text: "y" },
|
|
320
|
+
expected: [
|
|
321
|
+
"a",
|
|
322
|
+
"b",
|
|
323
|
+
"c",
|
|
324
|
+
"d",
|
|
325
|
+
"e"
|
|
326
|
+
]
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
what: "in asks of an input against an empty list: no row",
|
|
330
|
+
body: from.pipe(Query.where(Expr.in(text, labels)), byId),
|
|
331
|
+
input: {
|
|
332
|
+
text: "y",
|
|
333
|
+
labels: []
|
|
334
|
+
},
|
|
335
|
+
expected: []
|
|
336
|
+
},
|
|
260
337
|
{
|
|
261
338
|
what: "two predicates conjoin: every one must hold",
|
|
262
339
|
body: from.pipe(Query.where(Expr.eq(Subject.fields.rank, 3), Expr.isNotNull(Subject.fields.tag)), byId),
|
|
@@ -310,9 +387,148 @@ const cases = [
|
|
|
310
387
|
"a",
|
|
311
388
|
"b"
|
|
312
389
|
]
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
what: "puts rows without a value last ascending, unless told otherwise",
|
|
393
|
+
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag))),
|
|
394
|
+
input: {},
|
|
395
|
+
expected: [
|
|
396
|
+
"b",
|
|
397
|
+
"d",
|
|
398
|
+
"e",
|
|
399
|
+
"a",
|
|
400
|
+
"c"
|
|
401
|
+
]
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
what: "puts rows without a value first descending, unless told otherwise",
|
|
405
|
+
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag))),
|
|
406
|
+
input: {},
|
|
407
|
+
expected: [
|
|
408
|
+
"a",
|
|
409
|
+
"c",
|
|
410
|
+
"e",
|
|
411
|
+
"b",
|
|
412
|
+
"d"
|
|
413
|
+
]
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
what: "puts rows without a value first ascending when the term says so",
|
|
417
|
+
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag, { nulls: "first" }))),
|
|
418
|
+
input: {},
|
|
419
|
+
expected: [
|
|
420
|
+
"a",
|
|
421
|
+
"c",
|
|
422
|
+
"b",
|
|
423
|
+
"d",
|
|
424
|
+
"e"
|
|
425
|
+
]
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
what: "puts rows without a value last descending when the term says so",
|
|
429
|
+
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag, { nulls: "last" }))),
|
|
430
|
+
input: {},
|
|
431
|
+
expected: [
|
|
432
|
+
"e",
|
|
433
|
+
"b",
|
|
434
|
+
"d",
|
|
435
|
+
"a",
|
|
436
|
+
"c"
|
|
437
|
+
]
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
what: "breaks a tie by the id where the order does not say how",
|
|
441
|
+
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.rank))),
|
|
442
|
+
input: {},
|
|
443
|
+
expected: [
|
|
444
|
+
"e",
|
|
445
|
+
"c",
|
|
446
|
+
"d",
|
|
447
|
+
"a",
|
|
448
|
+
"b"
|
|
449
|
+
]
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
what: "orders by the field the input chose, ascending",
|
|
453
|
+
body: from.pipe(chosen),
|
|
454
|
+
input: { sort: {
|
|
455
|
+
by: "rank",
|
|
456
|
+
direction: "asc"
|
|
457
|
+
} },
|
|
458
|
+
expected: [
|
|
459
|
+
"b",
|
|
460
|
+
"a",
|
|
461
|
+
"c",
|
|
462
|
+
"d",
|
|
463
|
+
"e"
|
|
464
|
+
]
|
|
465
|
+
},
|
|
466
|
+
{
|
|
467
|
+
what: "orders by the field the input chose, descending, the next term breaking the tie",
|
|
468
|
+
body: from.pipe(chosen),
|
|
469
|
+
input: { sort: {
|
|
470
|
+
by: "rank",
|
|
471
|
+
direction: "desc"
|
|
472
|
+
} },
|
|
473
|
+
expected: [
|
|
474
|
+
"e",
|
|
475
|
+
"c",
|
|
476
|
+
"d",
|
|
477
|
+
"a",
|
|
478
|
+
"b"
|
|
479
|
+
]
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
what: "orders by the terms after a chosen order when the input chose none",
|
|
483
|
+
body: from.pipe(chosen),
|
|
484
|
+
input: { sort: null },
|
|
485
|
+
expected: [
|
|
486
|
+
"a",
|
|
487
|
+
"b",
|
|
488
|
+
"c",
|
|
489
|
+
"d",
|
|
490
|
+
"e"
|
|
491
|
+
]
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
what: "orders text by code point under a binary collation",
|
|
495
|
+
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.label, { collation: Collation.binary }))),
|
|
496
|
+
input: {},
|
|
497
|
+
expected: [
|
|
498
|
+
"d",
|
|
499
|
+
"a",
|
|
500
|
+
"c",
|
|
501
|
+
"b",
|
|
502
|
+
"e"
|
|
503
|
+
]
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
what: "orders text with ASCII case folded under an asciiFold collation",
|
|
507
|
+
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.label, { collation: Collation.asciiFold }))),
|
|
508
|
+
input: {},
|
|
509
|
+
expected: [
|
|
510
|
+
"d",
|
|
511
|
+
"a",
|
|
512
|
+
"b",
|
|
513
|
+
"c",
|
|
514
|
+
"e"
|
|
515
|
+
]
|
|
313
516
|
}
|
|
314
517
|
];
|
|
518
|
+
const NUL = String.fromCharCode(0);
|
|
519
|
+
const refusals = [{
|
|
520
|
+
what: "contains refuses a search holding NUL",
|
|
521
|
+
body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),
|
|
522
|
+
input: { label: `in${NUL}` }
|
|
523
|
+
}, {
|
|
524
|
+
what: "contains refuses searched text holding NUL",
|
|
525
|
+
body: from.pipe(Query.where(Expr.contains(text, label)), byId),
|
|
526
|
+
input: {
|
|
527
|
+
text: `a${NUL}b`,
|
|
528
|
+
label: "b"
|
|
529
|
+
}
|
|
530
|
+
}];
|
|
315
531
|
//#endregion
|
|
316
|
-
export { Subject, cases, rows };
|
|
532
|
+
export { Subject, cases, refusals, rows };
|
|
317
533
|
|
|
318
534
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/conformance/index.ts"],"sourcesContent":["/**\n * The conformance suite for a query body: what\n * [data-query-DESIGN §6.0.1](../../../docs/design/data-query-DESIGN.md) says\n * each operator means, as cases an interpreter can be run against.\n *\n * Exported rather than kept in this repository's tests, because the interpreter\n * most worth checking against it is one written elsewhere: run every case\n * through yours and compare the ids, in order, against `expected`.\n *\n * §18 names portable-kernel conformance as what the reference interpreter is\n * for. This is that, extracted: one set of cases, run against every interpreter\n * rather than each interpreter having its own tests that happen to agree.\n * `foldkit-remote-server` runs them over rows in memory;\n * `foldkit-remote-drizzle` compiles them to SQL and runs them against a real\n * SQLite. A body that means two things fails in whichever is wrong.\n *\n * The cases are chosen to make interpreters *disagree*, which is the only kind\n * that tests anything. A fixture whose values are all lowercase cannot tell a\n * case-sensitive `contains` from a case-insensitive one — that is not a\n * hypothetical, it is how `contains` reached a released package meaning three\n * different things.\n */\nimport { Schema, SchemaGetter } from 'effect'\nimport { Entity, Expr, Order, Query, type AnyQuery } from '../index.js'\n\n/**\n * A `Date` on the way in, an ISO string on the wire — the one fixture whose\n * **encoded form differs from its decoded form**.\n *\n * Every other column here encodes to itself, which is why the suite could not\n * previously see an interpreter comparing a decoded value against an encoded\n * row. That is not a hypothetical bug: a store holds wire values and decodes at\n * read, while a `QueryRef`'s input and a body's literals are written in domain\n * terms, so anything that runs a body over stored rows has to reconcile the two\n * and nothing was checking that it did.\n */\nconst Timestamp = Schema.Date.pipe(\n Schema.encodeTo(Schema.String, {\n decode: SchemaGetter.transform((iso: string) => new Date(iso)),\n encode: SchemaGetter.transform((at: Date) => at.toISOString()),\n }),\n)\n\n/** The one Entity every case reads, with a column of each kind that matters. */\nexport const Subject = Entity.define(\n 'Subject',\n Schema.Struct({\n id: Schema.String,\n /** Mixed case on purpose: a case-blind `contains` must be caught. */\n label: Schema.String,\n rank: Schema.Number,\n /** Nullable on purpose: three-valued logic has to be exercised. */\n tag: Schema.String,\n /** Encoded and decoded forms differ on purpose: see `Timestamp`. */\n at: Timestamp,\n }),\n)\n\n/**\n * How a row looks to an interpreter reading values, and to SQL as a table. The\n * index signature is what lets one be read by key without a cast, which is how\n * an interpreter over plain rows reads one.\n */\nexport interface ConformanceRow {\n readonly id: string\n readonly label: string\n readonly rank: number\n readonly tag: string | null\n /** The **encoded** form: what a store holds and an interpreter compares. */\n readonly at: string\n readonly [key: string]: unknown\n}\n\nexport const rows: ReadonlyArray<ConformanceRow> = [\n { id: 'a', label: 'Intro', rank: 2, tag: null, at: '2026-01-01T00:00:00.000Z' },\n { id: 'b', label: 'intro to sql', rank: 1, tag: 'x', at: '2026-01-02T00:00:00.000Z' },\n { id: 'c', label: 'Other', rank: 3, tag: null, at: '2026-01-02T00:00:00.000Z' },\n { id: 'd', label: '100% cotton', rank: 3, tag: 'x', at: '2026-01-03T00:00:00.000Z' },\n { id: 'e', label: 'snake_case', rank: 4, tag: 'y', at: '2026-01-04T00:00:00.000Z' },\n]\n\nexport interface ConformanceCase {\n /** What the case pins, as a sentence an interpreter fails by name. */\n readonly what: string\n readonly body: AnyQuery\n /**\n * The inputs, **encoded** — the space a store's rows are in, not the domain\n * space the body's types describe. For every column but `at` the two are the\n * same value, which is exactly why this has to be said rather than inferred\n * from the fixtures.\n */\n readonly input: Readonly<Record<string, unknown>>\n /** The ids the body matches, in the order it asks for. */\n readonly expected: ReadonlyArray<string>\n}\n\nconst from = Query.from(Subject)\nconst byId = Query.orderBy(Order.asc(Subject.fields.id))\nconst label = Expr.input('label', Schema.String)\nconst text = Expr.input('text', Schema.String)\nconst tag = Expr.input('tag', Schema.String)\nconst present = Expr.input('present', Schema.Boolean)\nconst at = Expr.input('at', Timestamp)\n\nexport const cases: ReadonlyArray<ConformanceCase> = [\n // ---- eq ------------------------------------------------------------------\n {\n what: 'eq matches a field against a literal',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['c', 'd'],\n },\n {\n what: 'eq matches a field against the value the request supplies',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.label, label)), byId),\n input: { label: 'Other' },\n expected: ['c'],\n },\n {\n what: 'eq is exact: a value that differs only by case does not match',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.label, label)), byId),\n input: { label: 'other' },\n expected: [],\n },\n {\n what: 'eq against null matches nothing, not even the rows that are null',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.tag, tag)), byId),\n input: { tag: null },\n expected: [],\n },\n {\n what: 'eq against a value skips the rows whose column is null',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.tag, 'x')), byId),\n input: {},\n expected: ['b', 'd'],\n },\n\n // ---- isNull / isNotNull --------------------------------------------------\n {\n what: 'isNull finds exactly the rows with no value',\n body: from.pipe(Query.where(Expr.isNull(Subject.fields.tag)), byId),\n input: {},\n expected: ['a', 'c'],\n },\n {\n what: 'isNotNull finds exactly the rest',\n body: from.pipe(Query.where(Expr.isNotNull(Subject.fields.tag)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a predicate compared to a true input is that predicate',\n body: from.pipe(Query.where(Expr.eq(Expr.isNotNull(Subject.fields.tag), present)), byId),\n input: { present: true },\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a predicate compared to a false input is its negation',\n body: from.pipe(Query.where(Expr.eq(Expr.isNotNull(Subject.fields.tag), present)), byId),\n input: { present: false },\n expected: ['a', 'c'],\n },\n ...[true, false].map(value => ({\n what: `a ${value} input compared to a predicate works in reverse order`,\n body: from.pipe(Query.where(Expr.eq(present, Expr.isNotNull(Subject.fields.tag))), byId),\n input: { present: value },\n expected: value ? ['b', 'd', 'e'] : ['a', 'c'],\n })),\n ...[true, false].map(value => ({\n what: `an unknown equality compared to ${value} stays unknown`,\n body: from.pipe(Query.where(Expr.eq(Expr.eq(Subject.fields.tag, tag), present)), byId),\n input: { tag: null, present: value },\n expected: [],\n })),\n\n // ---- contains ------------------------------------------------------------\n {\n what: 'contains ignores case, which is stated rather than left to the backend',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: 'INTRO' },\n expected: ['a', 'b'],\n },\n {\n what: 'contains matches anywhere in the value, not only at the start',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: 'to sql' },\n expected: ['b'],\n },\n {\n what: 'containing the empty string is everything',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'a percent is searched for literally, not as a wildcard',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '%' },\n expected: ['d'],\n },\n {\n what: 'an underscore is searched for literally, not as a single-character wildcard',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '_' },\n expected: ['e'],\n },\n {\n what: 'contains over a null column drops those rows, so it is not the same as no filter',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.tag, label)), byId),\n input: { label: '' },\n expected: ['b', 'd', 'e'],\n },\n // The text searched is an input here so the fixture rows stay ASCII: each\n // case asks the same of every row, so it matches all of them or none.\n {\n what: 'contains folds ASCII letters only: an accented capital does not match its lowercase',\n body: from.pipe(Query.where(Expr.contains(text, label)), byId),\n input: { text: 'Élan', label: 'é' },\n expected: [],\n },\n {\n what: 'contains still matches a non-ASCII letter written the same way',\n body: from.pipe(Query.where(Expr.contains(text, label)), byId),\n input: { text: 'Élan', label: 'Él' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'contains with a null search is unknown for every row',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: null },\n expected: [],\n },\n {\n what: 'an unknown containment compared to false stays unknown',\n body: from.pipe(Query.where(Expr.eq(Expr.contains(Subject.fields.label, label), false)), byId),\n input: { label: null },\n expected: [],\n },\n\n // ---- conjunction, which is the list rather than an operator ---------------\n {\n what: 'two predicates conjoin: every one must hold',\n body: from.pipe(\n Query.where(Expr.eq(Subject.fields.rank, 3), Expr.isNotNull(Subject.fields.tag)),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n {\n what: 'no predicate at all is every row',\n body: from.pipe(byId),\n input: {},\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n\n // ---- encoded values ------------------------------------------------------\n // The body's types say `Date`; a store's rows and a request's inputs are ISO\n // strings. An interpreter compares in the **encoded** space, and these are the\n // cases that say so — for every other column the two spaces hold the same\n // value, so nothing here could previously tell them apart.\n //\n // What happens when a caller passes a *decoded* value is deliberately not a\n // case, because the interpreters do not agree: the reference one matches\n // nothing, SQLite raises `datatype mismatch`, and a local engine does\n // whatever its own comparison does. `cases` are what interpreters must agree\n // about. The consequence is pinned in `packages/entity/test/encoding.test.ts`\n // instead, and it is the one that matters: **a runtime error cannot be relied\n // on to catch the mistake**, because one of the three answers is an empty\n // result that reads exactly like a correct one.\n {\n what: 'an input whose encoded form differs from its decoded one matches on the encoded one',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.at, at)), byId),\n input: { at: '2026-01-02T00:00:00.000Z' },\n expected: ['b', 'c'],\n },\n {\n what: 'a literal is encoded too, or it has the same problem as an input',\n body: from.pipe(\n Query.where(Expr.eq(Subject.fields.at, '2026-01-03T00:00:00.000Z' as never)),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n\n // ---- ordering ------------------------------------------------------------\n {\n what: 'orders ascending by a number',\n body: from.pipe(Query.orderBy(Order.asc(Subject.fields.rank), Order.asc(Subject.fields.id))),\n input: {},\n expected: ['b', 'a', 'c', 'd', 'e'],\n },\n {\n what: 'orders descending, and a later term breaks the tie',\n body: from.pipe(Query.orderBy(Order.desc(Subject.fields.rank), Order.asc(Subject.fields.id))),\n input: {},\n expected: ['e', 'c', 'd', 'a', 'b'],\n },\n // Ordering by text is deliberately not here. How text compares is the\n // backend's — SQLite by code point, TanStack by locale, Postgres by whatever\n // the database was created with — and §6.0.1 puts it outside the conformant\n // subset rather than pretending one of them is the rule. A case asserting an\n // order would only pin whichever engine was written first.\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;CACb;CAGA;EACE,MAAM;EACN,MAAM,KAAK,KACT,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,QAAQ,OAAO,GAAG,CAAC,GAC/E,IACF;EACA,OAAO,CAAC;EACR,UAAU,CAAC,GAAG;CAChB;CACA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,IAAI;EACpB,OAAO,CAAC;EACR,UAAU;GAAC;GAAK;GAAK;GAAK;GAAK;EAAG;CACpC;CAgBA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,IAAI,EAAE,CAAC,GAAG,IAAI;EACjE,OAAO,EAAE,IAAI,2BAA2B;EACxC,UAAU,CAAC,KAAK,GAAG;CACrB;CACA;EACE,MAAM;EACN,MAAM,KAAK,KACT,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,IAAI,0BAAmC,CAAC,GAC3E,IACF;EACA,OAAO,CAAC;EACR,UAAU,CAAC,GAAG;CAChB;CAGA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ,OAAO,IAAI,GAAG,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC,CAAC;EAC3F,OAAO,CAAC;EACR,UAAU;GAAC;GAAK;GAAK;GAAK;GAAK;EAAG;CACpC;CACA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,QAAQ,MAAM,KAAK,QAAQ,OAAO,IAAI,GAAG,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC,CAAC;EAC5F,OAAO,CAAC;EACR,UAAU;GAAC;GAAK;GAAK;GAAK;GAAK;EAAG;CACpC;AAMF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/conformance/index.ts"],"sourcesContent":["/**\n * The conformance suite for a query body: what\n * [data-query-DESIGN §6.0.1](../../../docs/design/data-query-DESIGN.md) says\n * each operator means, as cases an interpreter can be run against.\n *\n * Exported rather than kept in this repository's tests, because the interpreter\n * most worth checking against it is one written elsewhere: run every case\n * through yours and compare the ids, in order, against `expected`.\n *\n * §18 names portable-kernel conformance as what the reference interpreter is\n * for. This is that, extracted: one set of cases, run against every interpreter\n * rather than each interpreter having its own tests that happen to agree.\n * `foldkit-remote-server` runs them over rows in memory;\n * `foldkit-remote-drizzle` compiles them to SQL and runs them against a real\n * SQLite. A body that means two things fails in whichever is wrong.\n *\n * The cases are chosen to make interpreters *disagree*, which is the only kind\n * that tests anything. A fixture whose values are all lowercase cannot tell a\n * case-sensitive `contains` from a case-insensitive one — that is not a\n * hypothetical, it is how `contains` reached a released package meaning three\n * different things.\n */\nimport { Schema, SchemaGetter } from 'effect'\nimport { Collation, Entity, Expr, Order, Query, type AnyQuery } from '../index.js'\n\n/**\n * A `Date` on the way in, an ISO string on the wire — the one fixture whose\n * **encoded form differs from its decoded form**.\n *\n * Every other column here encodes to itself, which is why the suite could not\n * previously see an interpreter comparing a decoded value against an encoded\n * row. That is not a hypothetical bug: a store holds wire values and decodes at\n * read, while a `QueryRef`'s input and a body's literals are written in domain\n * terms, so anything that runs a body over stored rows has to reconcile the two\n * and nothing was checking that it did.\n */\nconst Timestamp = Schema.Date.pipe(\n Schema.encodeTo(Schema.String, {\n decode: SchemaGetter.transform((iso: string) => new Date(iso)),\n encode: SchemaGetter.transform((at: Date) => at.toISOString()),\n }),\n)\n\n/** The one Entity every case reads, with a column of each kind that matters. */\nexport const Subject = Entity.define(\n 'Subject',\n Schema.Struct({\n id: Schema.String,\n /** Mixed case on purpose: a case-blind `contains` must be caught. */\n label: Schema.String,\n rank: Schema.Number,\n /** Nullable on purpose: three-valued logic has to be exercised. */\n tag: Schema.String,\n /** Encoded and decoded forms differ on purpose: see `Timestamp`. */\n at: Timestamp,\n }),\n)\n\n/**\n * How a row looks to an interpreter reading values, and to SQL as a table. The\n * index signature is what lets one be read by key without a cast, which is how\n * an interpreter over plain rows reads one.\n */\nexport interface ConformanceRow {\n readonly id: string\n readonly label: string\n readonly rank: number\n readonly tag: string | null\n /** The **encoded** form: what a store holds and an interpreter compares. */\n readonly at: string\n readonly [key: string]: unknown\n}\n\nexport const rows: ReadonlyArray<ConformanceRow> = [\n { id: 'a', label: 'Intro', rank: 2, tag: null, at: '2026-01-01T00:00:00.000Z' },\n { id: 'b', label: 'intro to sql', rank: 1, tag: 'x', at: '2026-01-02T00:00:00.000Z' },\n { id: 'c', label: 'Other', rank: 3, tag: null, at: '2026-01-02T00:00:00.000Z' },\n { id: 'd', label: '100% cotton', rank: 3, tag: 'x', at: '2026-01-03T00:00:00.000Z' },\n { id: 'e', label: 'snake_case', rank: 4, tag: 'y', at: '2026-01-04T00:00:00.000Z' },\n]\n\nexport interface ConformanceCase {\n /** What the case pins, as a sentence an interpreter fails by name. */\n readonly what: string\n readonly body: AnyQuery\n /**\n * The inputs, **encoded** — the space a store's rows are in, not the domain\n * space the body's types describe. For every column but `at` the two are the\n * same value, which is exactly why this has to be said rather than inferred\n * from the fixtures.\n */\n readonly input: Readonly<Record<string, unknown>>\n /** The ids the body matches, in the order it asks for. */\n readonly expected: ReadonlyArray<string>\n}\n\nconst from = Query.from(Subject)\nconst byId = Query.orderBy(Order.asc(Subject.fields.id))\nconst label = Expr.input('label', Schema.String)\nconst text = Expr.input('text', Schema.String)\nconst tag = Expr.input('tag', Schema.String)\nconst present = Expr.input('present', Schema.Boolean)\nconst labels = Expr.input('labels', Schema.Array(Schema.String))\nconst at = Expr.input('at', Timestamp)\n/** A list sorted by what its reader picked: `Order.chosen`'s input. */\nconst sort = Expr.input(\n 'sort',\n Schema.NullOr(\n Schema.Struct({ by: Schema.Literals(['rank']), direction: Schema.Literals(['asc', 'desc']) }),\n ),\n)\nconst chosen = Query.orderBy(\n Order.chosen(sort, { rank: Subject.fields.rank }),\n Order.asc(Subject.fields.id),\n)\n\nexport const cases: ReadonlyArray<ConformanceCase> = [\n // ---- eq ------------------------------------------------------------------\n {\n what: 'eq matches a field against a literal',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['c', 'd'],\n },\n {\n what: 'eq matches a field against the value the request supplies',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.label, label)), byId),\n input: { label: 'Other' },\n expected: ['c'],\n },\n {\n what: 'eq is exact: a value that differs only by case does not match',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.label, label)), byId),\n input: { label: 'other' },\n expected: [],\n },\n {\n what: 'eq against null matches nothing, not even the rows that are null',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.tag, tag)), byId),\n input: { tag: null },\n expected: [],\n },\n {\n what: 'eq against a value skips the rows whose column is null',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.tag, 'x')), byId),\n input: {},\n expected: ['b', 'd'],\n },\n\n // ---- isNull / isNotNull --------------------------------------------------\n {\n what: 'isNull finds exactly the rows with no value',\n body: from.pipe(Query.where(Expr.isNull(Subject.fields.tag)), byId),\n input: {},\n expected: ['a', 'c'],\n },\n {\n what: 'isNotNull finds exactly the rest',\n body: from.pipe(Query.where(Expr.isNotNull(Subject.fields.tag)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a predicate compared to a true input is that predicate',\n body: from.pipe(Query.where(Expr.eq(Expr.isNotNull(Subject.fields.tag), present)), byId),\n input: { present: true },\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a predicate compared to a false input is its negation',\n body: from.pipe(Query.where(Expr.eq(Expr.isNotNull(Subject.fields.tag), present)), byId),\n input: { present: false },\n expected: ['a', 'c'],\n },\n ...[true, false].map(value => ({\n what: `a ${value} input compared to a predicate works in reverse order`,\n body: from.pipe(Query.where(Expr.eq(present, Expr.isNotNull(Subject.fields.tag))), byId),\n input: { present: value },\n expected: value ? ['b', 'd', 'e'] : ['a', 'c'],\n })),\n ...[true, false].map(value => ({\n what: `an unknown equality compared to ${value} stays unknown`,\n body: from.pipe(Query.where(Expr.eq(Expr.eq(Subject.fields.tag, tag), present)), byId),\n input: { tag: null, present: value },\n expected: [],\n })),\n\n // ---- contains ------------------------------------------------------------\n {\n what: 'contains ignores case, which is stated rather than left to the backend',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: 'INTRO' },\n expected: ['a', 'b'],\n },\n {\n what: 'contains matches anywhere in the value, not only at the start',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: 'to sql' },\n expected: ['b'],\n },\n {\n what: 'containing the empty string is everything',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'a percent is searched for literally, not as a wildcard',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '%' },\n expected: ['d'],\n },\n {\n what: 'an underscore is searched for literally, not as a single-character wildcard',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '_' },\n expected: ['e'],\n },\n {\n what: 'contains over a null column drops those rows, so it is not the same as no filter',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.tag, label)), byId),\n input: { label: '' },\n expected: ['b', 'd', 'e'],\n },\n // The text searched is an input here so the fixture rows stay ASCII: each\n // case asks the same of every row, so it matches all of them or none.\n {\n what: 'contains folds ASCII letters only: an accented capital does not match its lowercase',\n body: from.pipe(Query.where(Expr.contains(text, label)), byId),\n input: { text: 'Élan', label: 'é' },\n expected: [],\n },\n {\n what: 'contains still matches a non-ASCII letter written the same way',\n body: from.pipe(Query.where(Expr.contains(text, label)), byId),\n input: { text: 'Élan', label: 'Él' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'contains with a null search is unknown for every row',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: null },\n expected: [],\n },\n {\n what: 'an unknown containment compared to false stays unknown',\n body: from.pipe(Query.where(Expr.eq(Expr.contains(Subject.fields.label, label), false)), byId),\n input: { label: null },\n expected: [],\n },\n\n // ---- in ------------------------------------------------------------------\n {\n what: 'in matches a field against a list written out',\n body: from.pipe(Query.where(Expr.in(Subject.fields.rank, [1, 4])), byId),\n input: {},\n expected: ['b', 'e'],\n },\n {\n what: 'in matches a field against the list the request supplies, exactly',\n body: from.pipe(Query.where(Expr.in(Subject.fields.label, labels)), byId),\n input: { labels: ['Other', 'intro'] },\n expected: ['c'],\n },\n {\n what: 'in against an empty list matches nothing',\n body: from.pipe(Query.where(Expr.in(Subject.fields.label, labels)), byId),\n input: { labels: [] },\n expected: [],\n },\n {\n what: 'in skips the rows whose column is null',\n body: from.pipe(Query.where(Expr.in(Subject.fields.tag, ['x', 'y'])), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'in compared to false is its negation, and a null column stays unknown',\n body: from.pipe(Query.where(Expr.eq(Expr.in(Subject.fields.tag, ['x']), present)), byId),\n input: { present: false },\n expected: ['e'],\n },\n {\n what: 'in against an empty list compared to false matches every row, null or not',\n body: from.pipe(Query.where(Expr.eq(Expr.in(Subject.fields.tag, labels), present)), byId),\n input: { labels: [], present: false },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n\n {\n what: 'in asks of an input as of a field: every row, when the input is listed',\n body: from.pipe(Query.where(Expr.in(text, ['x', 'y'])), byId),\n input: { text: 'y' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'in asks of an input against an empty list: no row',\n body: from.pipe(Query.where(Expr.in(text, labels)), byId),\n input: { text: 'y', labels: [] },\n expected: [],\n },\n\n // ---- conjunction, which is the list rather than an operator ---------------\n {\n what: 'two predicates conjoin: every one must hold',\n body: from.pipe(\n Query.where(Expr.eq(Subject.fields.rank, 3), Expr.isNotNull(Subject.fields.tag)),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n {\n what: 'no predicate at all is every row',\n body: from.pipe(byId),\n input: {},\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n\n // ---- encoded values ------------------------------------------------------\n // The body's types say `Date`; a store's rows and a request's inputs are ISO\n // strings. An interpreter compares in the **encoded** space, and these are the\n // cases that say so — for every other column the two spaces hold the same\n // value, so nothing here could previously tell them apart.\n //\n // What happens when a caller passes a *decoded* value is deliberately not a\n // case, because the interpreters do not agree: the reference one matches\n // nothing, SQLite raises `datatype mismatch`, and a local engine does\n // whatever its own comparison does. `cases` are what interpreters must agree\n // about. The consequence is pinned in `packages/entity/test/encoding.test.ts`\n // instead, and it is the one that matters: **a runtime error cannot be relied\n // on to catch the mistake**, because one of the three answers is an empty\n // result that reads exactly like a correct one.\n {\n what: 'an input whose encoded form differs from its decoded one matches on the encoded one',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.at, at)), byId),\n input: { at: '2026-01-02T00:00:00.000Z' },\n expected: ['b', 'c'],\n },\n {\n what: 'a literal is encoded too, or it has the same problem as an input',\n body: from.pipe(\n Query.where(Expr.eq(Subject.fields.at, '2026-01-03T00:00:00.000Z' as never)),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n\n // ---- ordering ------------------------------------------------------------\n {\n what: 'orders ascending by a number',\n body: from.pipe(Query.orderBy(Order.asc(Subject.fields.rank), Order.asc(Subject.fields.id))),\n input: {},\n expected: ['b', 'a', 'c', 'd', 'e'],\n },\n {\n what: 'orders descending, and a later term breaks the tie',\n body: from.pipe(Query.orderBy(Order.desc(Subject.fields.rank), Order.asc(Subject.fields.id))),\n input: {},\n expected: ['e', 'c', 'd', 'a', 'b'],\n },\n {\n what: 'puts rows without a value last ascending, unless told otherwise',\n body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag))),\n input: {},\n expected: ['b', 'd', 'e', 'a', 'c'],\n },\n {\n what: 'puts rows without a value first descending, unless told otherwise',\n body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag))),\n input: {},\n expected: ['a', 'c', 'e', 'b', 'd'],\n },\n {\n what: 'puts rows without a value first ascending when the term says so',\n body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag, { nulls: 'first' }))),\n input: {},\n expected: ['a', 'c', 'b', 'd', 'e'],\n },\n {\n what: 'puts rows without a value last descending when the term says so',\n body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag, { nulls: 'last' }))),\n input: {},\n expected: ['e', 'b', 'd', 'a', 'c'],\n },\n {\n what: 'breaks a tie by the id where the order does not say how',\n body: from.pipe(Query.orderBy(Order.desc(Subject.fields.rank))),\n input: {},\n expected: ['e', 'c', 'd', 'a', 'b'],\n },\n {\n what: 'orders by the field the input chose, ascending',\n body: from.pipe(chosen),\n input: { sort: { by: 'rank', direction: 'asc' } },\n expected: ['b', 'a', 'c', 'd', 'e'],\n },\n {\n what: 'orders by the field the input chose, descending, the next term breaking the tie',\n body: from.pipe(chosen),\n input: { sort: { by: 'rank', direction: 'desc' } },\n expected: ['e', 'c', 'd', 'a', 'b'],\n },\n {\n what: 'orders by the terms after a chosen order when the input chose none',\n body: from.pipe(chosen),\n input: { sort: null },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n // ---- text, ordered by a declared collation -------------------------------\n {\n what: 'orders text by code point under a binary collation',\n body: from.pipe(\n Query.orderBy(Order.asc(Subject.fields.label, { collation: Collation.binary })),\n ),\n input: {},\n expected: ['d', 'a', 'c', 'b', 'e'],\n },\n {\n what: 'orders text with ASCII case folded under an asciiFold collation',\n body: from.pipe(\n Query.orderBy(Order.asc(Subject.fields.label, { collation: Collation.asciiFold })),\n ),\n input: {},\n expected: ['d', 'a', 'b', 'c', 'e'],\n },\n // Ordering by text with no declared collation is deliberately not here. How text compares is the\n // backend's — SQLite by code point, TanStack by locale, Postgres by whatever\n // the database was created with — and §6.0.1 puts it outside the conformant\n // subset rather than pretending one of them is the rule. A case asserting an\n // order would only pin whichever engine was written first.\n]\n\n/**\n * A body whose answer no two interpreters agree on, so every interpreter must\n * refuse it rather than answer. Run each through yours and expect a failure.\n */\nexport interface ConformanceRefusal {\n readonly what: string\n readonly body: AnyQuery\n /** The inputs, encoded, as in `ConformanceCase`. */\n readonly input: Readonly<Record<string, unknown>>\n}\n\nconst NUL = String.fromCharCode(0)\n\nexport const refusals: ReadonlyArray<ConformanceRefusal> = [\n // Postgres text cannot hold NUL and SQLite's `like` stops at it.\n {\n what: 'contains refuses a search holding NUL',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: `in${NUL}` },\n },\n {\n what: 'contains refuses searched text holding NUL',\n body: from.pipe(Query.where(Expr.contains(text, label)), byId),\n input: { text: `a${NUL}b`, label: 'b' },\n },\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,YAAY,OAAO,KAAK,KAC5B,OAAO,SAAS,OAAO,QAAQ;CAC7B,QAAQ,aAAa,WAAW,QAAgB,IAAI,KAAK,GAAG,CAAC;CAC7D,QAAQ,aAAa,WAAW,OAAa,GAAG,YAAY,CAAC;AAC/D,CAAC,CACH;;AAGA,MAAa,UAAU,OAAO,OAC5B,WACA,OAAO,OAAO;CACZ,IAAI,OAAO;;CAEX,OAAO,OAAO;CACd,MAAM,OAAO;;CAEb,KAAK,OAAO;;CAEZ,IAAI;AACN,CAAC,CACH;AAiBA,MAAa,OAAsC;CACjD;EAAE,IAAI;EAAK,OAAO;EAAS,MAAM;EAAG,KAAK;EAAM,IAAI;CAA2B;CAC9E;EAAE,IAAI;EAAK,OAAO;EAAgB,MAAM;EAAG,KAAK;EAAK,IAAI;CAA2B;CACpF;EAAE,IAAI;EAAK,OAAO;EAAS,MAAM;EAAG,KAAK;EAAM,IAAI;CAA2B;CAC9E;EAAE,IAAI;EAAK,OAAO;EAAe,MAAM;EAAG,KAAK;EAAK,IAAI;CAA2B;CACnF;EAAE,IAAI;EAAK,OAAO;EAAc,MAAM;EAAG,KAAK;EAAK,IAAI;CAA2B;AACpF;AAiBA,MAAM,OAAO,MAAM,KAAK,OAAO;AAC/B,MAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC;AACvD,MAAM,QAAQ,KAAK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