foldkit-entity 0.16.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.
- package/README.md +121 -18
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +20 -0
- package/dist/conformance/index.js.map +1 -1
- package/dist/conformance/operator.d.ts.map +1 -1
- package/dist/conformance/operator.js +13 -4
- package/dist/conformance/operator.js.map +1 -1
- package/dist/entity.d.ts +13 -1
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +40 -12
- package/dist/entity.js.map +1 -1
- package/dist/evaluate.d.ts +1 -1
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +22 -18
- package/dist/evaluate.js.map +1 -1
- package/dist/expr.d.ts +70 -20
- package/dist/expr.d.ts.map +1 -1
- package/dist/expr.js +67 -47
- package/dist/expr.js.map +1 -1
- package/dist/held.js +11 -3
- package/dist/held.js.map +1 -1
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/invariant.d.ts.map +1 -1
- package/dist/invariant.js +25 -19
- package/dist/invariant.js.map +1 -1
- package/dist/law.d.ts.map +1 -1
- package/dist/law.js +3 -9
- package/dist/law.js.map +1 -1
- package/dist/lawCore.d.ts +42 -0
- package/dist/lawCore.d.ts.map +1 -0
- package/dist/lawCore.js +12 -0
- package/dist/lawCore.js.map +1 -0
- package/dist/memoryTable.d.ts +11 -0
- package/dist/memoryTable.d.ts.map +1 -0
- package/dist/memoryTable.js +69 -0
- package/dist/memoryTable.js.map +1 -0
- package/dist/operators.d.ts.map +1 -1
- package/dist/operators.js +2 -66
- package/dist/operators.js.map +1 -1
- package/dist/sets.js.map +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +40 -18
- package/dist/write.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,7 +159,7 @@ Object.keys(Blog.Post.members) // id, title, published, author, editor, comments
|
|
|
159
159
|
Entity's relation, so it is added after `Entity.relate`:
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
|
-
const
|
|
162
|
+
const CountedPost = Blog.Post.pipe(
|
|
163
163
|
Entity.derived({ commentTotal: Derived.count(Blog.Comment.relations.post) }),
|
|
164
164
|
)
|
|
165
165
|
```
|
|
@@ -173,7 +173,7 @@ Object.keys(Blog.Post.members) // id, title, published, author, editor, comments
|
|
|
173
173
|
relation of the same Entity: "did I comment on this post?"
|
|
174
174
|
|
|
175
175
|
```ts
|
|
176
|
-
const
|
|
176
|
+
const PostWithMyComment = Blog.Post.pipe(
|
|
177
177
|
Entity.derived({
|
|
178
178
|
myComment: Derived.exists(Blog.Comment.relations.post, {
|
|
179
179
|
viewer: Blog.Comment.relations.author,
|
|
@@ -201,8 +201,18 @@ Object.keys(Blog.Post.members) // id, title, published, author, editor, comments
|
|
|
201
201
|
that takes rows with a deleted post (`{ relation, owner }`), so Remote
|
|
202
202
|
removes those it holds while the delete is pending, counts and lists with
|
|
203
203
|
them, and `remote-drizzle`'s writer removes them where it deletes, on a store
|
|
204
|
-
without foreign keys too.
|
|
205
|
-
|
|
204
|
+
without foreign keys too.
|
|
205
|
+
- `Relation.one(Topic, { onDelete: 'restrict' })` says the row it points at
|
|
206
|
+
cannot be deleted while it points there: a topic with notes under it.
|
|
207
|
+
`Entity.restricting(Topic)` lists those relations, and `remote-drizzle`'s
|
|
208
|
+
writer refuses such a delete as `Refusal.referenced`, naming the relation
|
|
209
|
+
and none of the rows.
|
|
210
|
+
- `Relation.one(Folder, { optional: true, onDelete: 'setNull' })` says the
|
|
211
|
+
row stays and points nowhere when the row it points at is deleted: a doc
|
|
212
|
+
whose folder went. Only a link that may point nowhere can say it, and the
|
|
213
|
+
types refuse it without `optional: true`. `Entity.clearing(Folder)` lists
|
|
214
|
+
those relations; clearing a link is an update of the row, so each is held
|
|
215
|
+
to its own `Update` rules, as unlinking it in an update would be.
|
|
206
216
|
- Who may let a cascade take a row is said beside it. By default each row it
|
|
207
217
|
takes is held to its own `Delete` rule, for whoever deletes the row it
|
|
208
218
|
points at: a delete that would take a row they may not delete is refused
|
|
@@ -210,7 +220,7 @@ Object.keys(Blog.Post.members) // id, title, published, author, editor, comments
|
|
|
210
220
|
onDelete: 'cascade', authorizedBy: 'parent' })` says whoever may delete the
|
|
211
221
|
post may take these rows with it, whoever wrote them: a post's author
|
|
212
222
|
removing everyone's likes of it. `authorizedBy` is said only beside
|
|
213
|
-
`onDelete`, and reads back as the relation's `authorizedBy`.
|
|
223
|
+
`onDelete: 'cascade'`, and reads back as the relation's `authorizedBy`.
|
|
214
224
|
|
|
215
225
|
`Entity.relate` throws, and the types reject, a relation key that is already a
|
|
216
226
|
member, an owner that is not in the first argument, and a target that is not
|
|
@@ -390,11 +400,12 @@ as a value:
|
|
|
390
400
|
> only types from here in any case.
|
|
391
401
|
|
|
392
402
|
```ts
|
|
403
|
+
import { Schema } from 'effect'
|
|
393
404
|
import { Expr, Order } from 'foldkit-entity'
|
|
394
405
|
|
|
395
406
|
const byTitle = Expr.eq(Blog.Post.fields.title, Expr.input('title', Schema.String))
|
|
396
|
-
const
|
|
397
|
-
const
|
|
407
|
+
const isPublished = Expr.eq(Blog.Post.fields.published, true)
|
|
408
|
+
const newestTerms = [Order.desc(Blog.Post.fields.title), Order.asc(Blog.Post.fields.id)]
|
|
398
409
|
```
|
|
399
410
|
|
|
400
411
|
Building one performs no work: it reads nothing, names no database, and runs no
|
|
@@ -434,6 +445,40 @@ query whose predicates and order terms expand past `maxQueryNodes` (1,000)
|
|
|
434
445
|
nodes, counting a shared node on each path that reaches it, is refused where
|
|
435
446
|
it is built.
|
|
436
447
|
|
|
448
|
+
### Data-last: `step` with Effect's `pipe` and `flow`
|
|
449
|
+
|
|
450
|
+
Every comparison (`eq`, `lt`, `lte`, `gt`, `gte`, `contains`, `in`) and every
|
|
451
|
+
operator has a `step` member: the call without its subject. It builds exactly the
|
|
452
|
+
node the data-first call builds, so it is a spelling, not a second meaning.
|
|
453
|
+
|
|
454
|
+
```ts standalone
|
|
455
|
+
import { Schema, flow, pipe } from 'effect'
|
|
456
|
+
import { Collation, Entity, Expr, Text } from 'foldkit-entity'
|
|
457
|
+
|
|
458
|
+
const Post = Entity.define(
|
|
459
|
+
'Post',
|
|
460
|
+
Schema.Struct({ id: Schema.String, status: Schema.Literals(['draft', 'live']), upc: Schema.String }),
|
|
461
|
+
).pipe(Entity.annotateMembers({ upc: Collation.of(Collation.binary) }))
|
|
462
|
+
|
|
463
|
+
const isDraft = pipe(Post.fields.status, Expr.eq.step('draft'))
|
|
464
|
+
// the same node as Expr.eq(Post.fields.status, 'draft')
|
|
465
|
+
const startsWithA = pipe(Post.fields.upc, Text.startsWith.step('A'))
|
|
466
|
+
const draftOrLive = flow(Expr.in.step(['draft', 'live']))
|
|
467
|
+
const anyStatus = draftOrLive(Post.fields.status)
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
- `step` has one signature, so reads stay exact through `pipe` and `flow`
|
|
471
|
+
(`isDraft` reads `'Post'`, and `Query.where` still refuses a predicate over
|
|
472
|
+
another Entity). An overloaded callable would lose them, which is why it is a
|
|
473
|
+
member and not the function's own data-last form.
|
|
474
|
+
- A wrong value is refused at the step: `pipe(Post.fields.status, Expr.eq.step(42))`
|
|
475
|
+
is an error where it is written. `Expr.eq(Post.fields.status)` is still an arity error.
|
|
476
|
+
- A comparison's `step` takes the options its builder takes
|
|
477
|
+
(`Expr.lt.step('m', { collation })`); an operator's takes none, so a call that
|
|
478
|
+
needs a collation is written data-first. A step takes the arguments past the
|
|
479
|
+
first, then the first: `trim.step()` takes nothing, `Text.startsWith.step(prefix)` one.
|
|
480
|
+
- Data-first stays the form to learn first; a step earns its place in a chain.
|
|
481
|
+
|
|
437
482
|
### Asking a question that depends on an input, without branching on it
|
|
438
483
|
|
|
439
484
|
Since an input is a placeholder, a query cannot choose between two shapes based
|
|
@@ -498,15 +543,18 @@ a comparison with it holds of no row. `Expr.now` is the time, in milliseconds.
|
|
|
498
543
|
Neither is a field or an input: each interpreter reads them from the context
|
|
499
544
|
it is given.
|
|
500
545
|
|
|
501
|
-
```ts
|
|
546
|
+
```ts standalone
|
|
547
|
+
import { Option, Schema } from 'effect'
|
|
548
|
+
import { Entity, Expr, Query, evaluate } from 'foldkit-entity'
|
|
549
|
+
|
|
502
550
|
const User = Entity.define('User', Schema.Struct({ id: Schema.String }))
|
|
503
551
|
const Note = Entity.define('Note', Schema.Struct({ id: Schema.String, ownerId: Schema.String }))
|
|
504
552
|
|
|
505
|
-
const
|
|
553
|
+
const MyNotes = Query.from(Note).pipe(
|
|
506
554
|
Query.where(Expr.eq(Note.fields.ownerId, Expr.viewer(User))),
|
|
507
555
|
)
|
|
508
556
|
const ada = { entity: 'User', id: 'ada' }
|
|
509
|
-
evaluate(
|
|
557
|
+
evaluate(MyNotes, {}, [{ id: 'n1', ownerId: 'ada' }, { id: 'n2', ownerId: 'bo' }], {
|
|
510
558
|
context: { viewer: Option.some(ada), now: Option.none() },
|
|
511
559
|
})
|
|
512
560
|
// [{ id: 'n1', ownerId: 'ada' }]
|
|
@@ -524,10 +572,36 @@ declared with `Entity.sets`.
|
|
|
524
572
|
|
|
525
573
|
### Which rows: `Query`
|
|
526
574
|
|
|
575
|
+
<!-- docs-check standalone
|
|
576
|
+
import { Schema } from 'effect'
|
|
577
|
+
import { Collation, Derived, Entity, Expr, Order, Query, Relation } from 'foldkit-entity'
|
|
578
|
+
|
|
579
|
+
const BlogAuthor = Entity.define('Author', Schema.Struct({ id: Schema.String, name: Schema.String }))
|
|
580
|
+
const BlogComment = Entity.define('Comment', Schema.Struct({ id: Schema.String, body: Schema.String }))
|
|
581
|
+
const BlogPost = Entity.define(
|
|
582
|
+
'Post',
|
|
583
|
+
Schema.Struct({ id: Schema.String, title: Schema.String, published: Schema.Boolean }),
|
|
584
|
+
).pipe(Entity.derived({ commentCount: Derived.make(Schema.Number) }))
|
|
585
|
+
const Blog = Entity.relate(
|
|
586
|
+
{ Author: BlogAuthor, Post: BlogPost, Comment: BlogComment },
|
|
587
|
+
{
|
|
588
|
+
Post: {
|
|
589
|
+
author: Relation.one(BlogAuthor),
|
|
590
|
+
editor: Relation.one(BlogAuthor, { optional: true }),
|
|
591
|
+
comments: Relation.many(BlogComment),
|
|
592
|
+
},
|
|
593
|
+
Comment: { post: Relation.one(BlogPost), author: Relation.one(BlogAuthor) },
|
|
594
|
+
},
|
|
595
|
+
)
|
|
596
|
+
const byTitle = Expr.eq(Blog.Post.fields.title, Expr.input('title', Schema.String))
|
|
597
|
+
-->
|
|
598
|
+
|
|
527
599
|
A `Query` is an Entity to read, the predicates every row must hold, and the
|
|
528
600
|
order to read them in — composed with `pipe`, one immutable value per step:
|
|
529
601
|
|
|
530
602
|
```ts
|
|
603
|
+
import { Query } from 'foldkit-entity'
|
|
604
|
+
|
|
531
605
|
const published = Query.where(Expr.eq(Blog.Post.fields.published, true))
|
|
532
606
|
const newest = Query.orderBy(Order.desc(Blog.Post.fields.title))
|
|
533
607
|
|
|
@@ -556,6 +630,8 @@ declaration of what `title` means, and the client can tell which edits may move
|
|
|
556
630
|
a row:
|
|
557
631
|
|
|
558
632
|
```ts
|
|
633
|
+
import { type InputExpr } from 'foldkit-entity'
|
|
634
|
+
|
|
559
635
|
const PostSort = Schema.NullOr(
|
|
560
636
|
Schema.Struct({ by: Schema.Literals(['title', 'id']), direction: Schema.Literals(['asc', 'desc']) }),
|
|
561
637
|
)
|
|
@@ -673,6 +749,15 @@ A predicate may read the row a `one` relation points at, and ask whether any
|
|
|
673
749
|
row points at this one. Both start on the query's own row, so they belong in
|
|
674
750
|
its `where`:
|
|
675
751
|
|
|
752
|
+
<!-- docs-check
|
|
753
|
+
const UserFields = Entity.define('User', Schema.Struct({ id: Schema.String, handle: Schema.String }))
|
|
754
|
+
const PostFields = Entity.define('Post', Schema.Struct({ id: Schema.String, body: Schema.String }))
|
|
755
|
+
const FollowFields = Entity.define(
|
|
756
|
+
'Follow',
|
|
757
|
+
Schema.Struct({ id: Schema.String, followerId: Schema.String }),
|
|
758
|
+
)
|
|
759
|
+
-->
|
|
760
|
+
|
|
676
761
|
```ts
|
|
677
762
|
const { Post, User, Follow } = Entity.relate(
|
|
678
763
|
{ Post: PostFields, User: UserFields, Follow: FollowFields },
|
|
@@ -734,6 +819,9 @@ never sent it" are different answers. `Judge` reads a row as a holder has it
|
|
|
734
819
|
(`HeldRow`) and keeps the two apart:
|
|
735
820
|
|
|
736
821
|
```ts
|
|
822
|
+
import { Option } from 'effect'
|
|
823
|
+
import { Held, Judge } from 'foldkit-entity'
|
|
824
|
+
|
|
737
825
|
const holder = Held.rows([
|
|
738
826
|
{ entity: Post, rows: [{ id: 'p1', body: 'hi', author: 'u1' }, { id: 'p2', body: 'yo', author: 'u2' }] },
|
|
739
827
|
// Ada is held; u2 is not, and this holder may lack users.
|
|
@@ -877,6 +965,8 @@ tagged union whose cases hold the selected fields they have, typed as the
|
|
|
877
965
|
case holds them, and every selected relation and derived member.
|
|
878
966
|
|
|
879
967
|
```ts
|
|
968
|
+
import { type Selected } from 'foldkit-entity'
|
|
969
|
+
|
|
880
970
|
const Quote = Entity.select(Domain, { _tag: true, name: true, price: true })
|
|
881
971
|
type Quote = Selected<typeof Quote>
|
|
882
972
|
// { _tag: 'Available', name: string, price: number } | { _tag: 'Unconfirmed', name: string }
|
|
@@ -905,14 +995,14 @@ const CreatePostInput = Schema.Struct({
|
|
|
905
995
|
notify: Schema.Boolean,
|
|
906
996
|
})
|
|
907
997
|
|
|
908
|
-
const
|
|
998
|
+
const CreatePostById = Entity.input(Blog.Post, CreatePostInput, {
|
|
909
999
|
authorId: Relation.input(Blog.Post.relations.author),
|
|
910
1000
|
notify: Entity.unmapped,
|
|
911
1001
|
})
|
|
912
1002
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
1003
|
+
CreatePostById.members.title // Blog.Post.fields.title: it names a field, so it maps itself
|
|
1004
|
+
CreatePostById.members.authorId.relation.target() // Blog.Author: what a picker chooses from
|
|
1005
|
+
CreatePostById.members.notify // Entity.unmapped: about the operation, not the Post
|
|
916
1006
|
```
|
|
917
1007
|
|
|
918
1008
|
- A key that names a field, with a value that fits it, maps itself. Only the
|
|
@@ -1019,7 +1109,7 @@ relation. A value is a term of the write's context, `Expr.viewer` or
|
|
|
1019
1109
|
`Expr.now`, and `on` says which writes set it:
|
|
1020
1110
|
|
|
1021
1111
|
```ts
|
|
1022
|
-
const AuthoredPost = Blog.Post.pipe(Entity.sets({ author: Expr.viewer(Author) }, { on: 'create' }))
|
|
1112
|
+
const AuthoredPost = Blog.Post.pipe(Entity.sets({ author: Expr.viewer(Blog.Author) }, { on: 'create' }))
|
|
1023
1113
|
```
|
|
1024
1114
|
|
|
1025
1115
|
`Expr.viewer(Author)` is whoever asks: a `one` relation to an Author pointed
|
|
@@ -1133,7 +1223,7 @@ the row a write leaves: with `quantity = 10, reserved = 5`, an update setting
|
|
|
1133
1223
|
An **invariant** is what every stored row must hold, read over the row after a
|
|
1134
1224
|
write (`after`):
|
|
1135
1225
|
|
|
1136
|
-
```ts
|
|
1226
|
+
```ts standalone
|
|
1137
1227
|
import { Schema } from 'effect'
|
|
1138
1228
|
import { Entity, Expr } from 'foldkit-entity'
|
|
1139
1229
|
|
|
@@ -1227,6 +1317,18 @@ Entity, so a refusal names both. A declaration attaches to one Entity; reading
|
|
|
1227
1317
|
Entity's type (what it reads is checked against it), and match a refusal
|
|
1228
1318
|
against it rather than spelling the id again:
|
|
1229
1319
|
|
|
1320
|
+
<!-- docs-check standalone
|
|
1321
|
+
import { Schema } from 'effect'
|
|
1322
|
+
import { Entity, Expr } from 'foldkit-entity'
|
|
1323
|
+
import { Refusal } from 'foldkit-remote'
|
|
1324
|
+
|
|
1325
|
+
const InventoryFields = Entity.define(
|
|
1326
|
+
'Inventory',
|
|
1327
|
+
Schema.Struct({ id: Schema.String, quantity: Schema.Number, reserved: Schema.Number }),
|
|
1328
|
+
)
|
|
1329
|
+
declare const refusal: unknown
|
|
1330
|
+
-->
|
|
1331
|
+
|
|
1230
1332
|
```ts
|
|
1231
1333
|
export const reservedWithinQuantity = Entity.invariant<typeof InventoryFields>(
|
|
1232
1334
|
'reservedWithinQuantity',
|
|
@@ -1280,7 +1382,7 @@ A predicate an application asks in many places (in a public query, a
|
|
|
1280
1382
|
visitor's Read rule, an invariant) can be given a name. `Expr.operator`
|
|
1281
1383
|
declares one by what a call of it means:
|
|
1282
1384
|
|
|
1283
|
-
```ts
|
|
1385
|
+
```ts standalone
|
|
1284
1386
|
import { Schema } from 'effect'
|
|
1285
1387
|
import { Entity, Expr, Query } from 'foldkit-entity'
|
|
1286
1388
|
|
|
@@ -1329,7 +1431,7 @@ interpreter's implementation does, and every implementation is held to the
|
|
|
1329
1431
|
same statement of it. The kernel ships one, `Text.startsWith`; an application
|
|
1330
1432
|
declares its own and implements it, here for the in-memory interpreter:
|
|
1331
1433
|
|
|
1332
|
-
```ts
|
|
1434
|
+
```ts standalone
|
|
1333
1435
|
import { Schema } from 'effect'
|
|
1334
1436
|
import { Collation, Entity, Expr, Operators, Query, Text, evaluate } from 'foldkit-entity'
|
|
1335
1437
|
|
|
@@ -1571,6 +1673,7 @@ server on different deploys see which side is behind.
|
|
|
1571
1673
|
| `Expr.operator(id, { input, output, definedAs?, version?, description?, nulls?, collation?, laws? })` | An operator: defined by what a call means (`definedAs`, whose expansion every interpreter runs) or primitive (each interpreter's table implements it). Calling it builds a `Test` predicate (a boolean output) or a `Call` scalar. |
|
|
1572
1674
|
| `Expr.unsupported(nodes, { operations, operators })` | What these expressions need that an interpreter lacks: operations, then primitive operators by name. |
|
|
1573
1675
|
| `Text.startsWith(text, prefix, { collation? })` | Whether text begins with a prefix, under its collation; the kernel's primitive operator. |
|
|
1676
|
+
| `Expr.eq.step(value)` / `lt` / `lte` / `gt` / `gte.step(value, { collation? })` / `contains.step(search)` / `in.step(list)`; `operator.step(...rest)` | The call without its subject, for `pipe` and `flow`: `pipe(Post.fields.status, Expr.eq.step('draft'))` builds the node `Expr.eq(Post.fields.status, 'draft')` builds. One signature, so reads stay exact. |
|
|
1574
1677
|
| `Operators.memory(...)` / `implement` / `implementHandlingNulls` / `merge` / `override` / `checked` / `kernel` | Tables of in-memory implementations of primitive operators, passed to `evaluate` and every judge. |
|
|
1575
1678
|
| `Law.associative` / `commutative` / `idempotent` / `identity` / `absorbing` / `inverse` / `distributes` / `monotonic` / `preservesCollation` / `within` / `describe` | Laws an operator declares (`Expr.operator(id, { laws })`), checked where declared, described as JSON. |
|
|
1576
1679
|
| `Operators.withEvidence(table, evidence)` / `describeTable(table)` / `Evidence.Proven` | What is known of a table's implementations' laws, and the table as JSON. |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","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.ts","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;;qBA0CR,OAAO,cAAc;;;;;;qBAugBrB,gBAAgB,cAAc;;;;;iBA0D1B;WACN;WACA,MAAM;;WAEN,OAAO,SAAS;;qBAKd,UAAU,cAAc;;qBA0CxB,mBAAmB,cAAc"}
|
|
@@ -99,6 +99,8 @@ const labels = Expr.input("labels", Schema.Array(Schema.String));
|
|
|
99
99
|
const at = Expr.input("at", Timestamp);
|
|
100
100
|
/** An optional filter's input: none chosen is null. */
|
|
101
101
|
const maybeTag = Expr.input("maybeTag", Schema.NullOr(Schema.String));
|
|
102
|
+
/** An optional membership filter's input: none chosen is null. */
|
|
103
|
+
const maybeLabels = Expr.input("maybeLabels", Schema.NullOr(Schema.Array(Schema.String)));
|
|
102
104
|
const below = Expr.input("below", Schema.Number);
|
|
103
105
|
const from_ = Expr.input("from", Timestamp);
|
|
104
106
|
const until = Expr.input("until", Timestamp);
|
|
@@ -433,6 +435,24 @@ const cases = [
|
|
|
433
435
|
input: { maybeTag: "x" },
|
|
434
436
|
expected: ["b", "d"]
|
|
435
437
|
},
|
|
438
|
+
{
|
|
439
|
+
what: "an optional membership filter with no list chosen matches every row",
|
|
440
|
+
body: from.pipe(Query.where(Expr.whenGiven(maybeLabels, (given) => Expr.in(Subject.fields.label, given))), byId),
|
|
441
|
+
input: { maybeLabels: null },
|
|
442
|
+
expected: [
|
|
443
|
+
"a",
|
|
444
|
+
"b",
|
|
445
|
+
"c",
|
|
446
|
+
"d",
|
|
447
|
+
"e"
|
|
448
|
+
]
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
what: "an optional membership filter with a list chosen is that filter",
|
|
452
|
+
body: from.pipe(Query.where(Expr.whenGiven(maybeLabels, (given) => Expr.in(Subject.fields.label, given))), byId),
|
|
453
|
+
input: { maybeLabels: ["Other", "snake_case"] },
|
|
454
|
+
expected: ["c", "e"]
|
|
455
|
+
},
|
|
436
456
|
{
|
|
437
457
|
what: "an operand decided by the input alone settles an or either way",
|
|
438
458
|
body: from.pipe(Query.where(Expr.or(Expr.eq(present, true), Expr.eq(Subject.fields.rank, 1))), byId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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, Text, 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/** An optional filter's input: none chosen is null. */\nconst maybeTag = Expr.input('maybeTag', Schema.NullOr(Schema.String))\nconst below = Expr.input('below', Schema.Number)\nconst from_ = Expr.input('from', Timestamp)\nconst until = Expr.input('until', Timestamp)\nconst binary = { collation: Collation.binary }\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)\n/** Defined operators: an interpreter runs what each means, and needs nothing of its own. */\nconst tagged = Expr.operator('conformance.tagged', {\n input: [Schema.Unknown],\n output: Schema.Boolean,\n definedAs: value => Expr.isNotNull(value),\n})\nconst rankOf = Expr.operator('conformance.rankOf', {\n input: [Schema.Number],\n output: Schema.Number,\n definedAs: rank => rank,\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 // ---- and, or, not: SQL's three values -----------------------------------\n // `tag` is null on a and c, so a comparison of it is unknown there, and a\n // row is kept only on true.\n {\n what: 'or holds where one operand does, true beating unknown',\n body: from.pipe(\n Query.where(Expr.or(Expr.eq(Subject.fields.tag, 'x'), Expr.eq(Subject.fields.rank, 2))),\n byId,\n ),\n input: {},\n expected: ['a', 'b', 'd'],\n },\n {\n what: 'an and inside an or groups as written',\n body: from.pipe(\n Query.where(\n Expr.or(\n Expr.and(Expr.eq(Subject.fields.rank, 3), Expr.eq(Subject.fields.tag, 'x')),\n Expr.eq(Subject.fields.label, 'Intro'),\n ),\n ),\n byId,\n ),\n input: {},\n expected: ['a', 'd'],\n },\n {\n what: 'not of an unknown stays unknown, so a null matches neither side',\n body: from.pipe(Query.where(Expr.not(Expr.eq(Subject.fields.tag, 'x'))), byId),\n input: {},\n expected: ['e'],\n },\n {\n what: 'not of an and that is false, false beating unknown, holds',\n body: from.pipe(\n Query.where(\n Expr.not(Expr.and(Expr.eq(Subject.fields.tag, 'x'), Expr.eq(Subject.fields.rank, 1))),\n ),\n byId,\n ),\n input: {},\n expected: ['a', 'c', 'd', 'e'],\n },\n {\n what: 'everything but one value, nulls included, is said with isNull',\n body: from.pipe(\n Query.where(\n Expr.or(Expr.isNull(Subject.fields.tag), Expr.not(Expr.eq(Subject.fields.tag, 'x'))),\n ),\n byId,\n ),\n input: {},\n expected: ['a', 'c', 'e'],\n },\n {\n what: 'an optional filter with nothing chosen matches every row',\n body: from.pipe(\n Query.where(Expr.whenGiven(maybeTag, given => Expr.eq(Subject.fields.tag, given))),\n byId,\n ),\n input: { maybeTag: null },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'an optional filter with a value chosen is that filter',\n body: from.pipe(\n Query.where(Expr.whenGiven(maybeTag, given => Expr.eq(Subject.fields.tag, given))),\n byId,\n ),\n input: { maybeTag: 'x' },\n expected: ['b', 'd'],\n },\n {\n what: 'an operand decided by the input alone settles an or either way',\n body: from.pipe(\n Query.where(Expr.or(Expr.eq(present, true), Expr.eq(Subject.fields.rank, 1))),\n byId,\n ),\n input: { present: false },\n expected: ['b'],\n },\n // ---- comparisons -----------------------------------------------------------\n // Ranks are a 2, b 1, c 3, d 3, e 4; text only under a collation every\n // interpreter agrees on, and a date by its encoded ISO string.\n {\n what: 'lt holds where a number orders before the other',\n body: from.pipe(Query.where(Expr.lt(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['a', 'b'],\n },\n {\n what: 'gte holds where a number orders after the other, or with it',\n body: from.pipe(Query.where(Expr.gte(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['c', 'd', 'e'],\n },\n {\n what: 'a field written second compares the same: the input is above the rank',\n body: from.pipe(Query.where(Expr.gt(below, Expr.field(Subject.fields.rank))), byId),\n input: { below: 3 },\n expected: ['a', 'b'],\n },\n {\n what: 'a comparison that reads no field orders numbers as numbers: 9 is below 10',\n body: from.pipe(Query.where(Expr.lt(below, 10)), byId),\n input: { below: 9 },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'a range of dates compares their encoded ISO strings under binary',\n body: from.pipe(\n Query.where(\n Expr.and(\n Expr.gte(Subject.fields.at, from_, binary),\n Expr.lt(Subject.fields.at, until, binary),\n ),\n ),\n byId,\n ),\n input: { from: '2026-01-02T00:00:00.000Z', until: '2026-01-04T00:00:00.000Z' },\n expected: ['b', 'c', 'd'],\n },\n {\n what: 'text under binary orders by code point: capitals and digits before lower case',\n body: from.pipe(Query.where(Expr.lt(Subject.fields.label, 'a', binary)), byId),\n input: {},\n expected: ['a', 'c', 'd'],\n },\n {\n what: 'text under asciiFold orders with ASCII case folded',\n body: from.pipe(\n Query.where(Expr.lt(Subject.fields.label, 'j', { collation: Collation.asciiFold })),\n byId,\n ),\n input: {},\n expected: ['a', 'b', 'd'],\n },\n {\n what: 'a null compared is unknown, so it matches neither the comparison nor its not',\n body: from.pipe(Query.where(Expr.gte(Subject.fields.tag, 'x', binary)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'not of a comparison leaves a null out too',\n body: from.pipe(Query.where(Expr.not(Expr.gte(Subject.fields.tag, 'x', binary))), byId),\n input: {},\n expected: [],\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 // ---- defined operators -----------------------------------------------------\n {\n what: 'a defined operator matches the rows what it means does',\n body: from.pipe(Query.where(tagged(Subject.fields.tag)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a defined operator under not is the negation of what it means',\n body: from.pipe(Query.where(Expr.not(tagged(Subject.fields.tag))), byId),\n input: {},\n expected: ['a', 'c'],\n },\n {\n what: 'a defined operator over an input only is decided by the request',\n body: from.pipe(Query.where(Expr.or(tagged(maybeTag), Expr.eq(Subject.fields.rank, 3))), byId),\n input: { maybeTag: null },\n expected: ['c', 'd'],\n },\n {\n what: 'a defined scalar operator compares as what it means',\n body: from.pipe(Query.where(Expr.eq(rankOf(Subject.fields.rank), 3)), byId),\n input: {},\n expected: ['c', 'd'],\n },\n]\n\nconst prefix = Expr.input('prefix', Schema.NullOr(Schema.String))\nconst asciiFold = { collation: Collation.asciiFold }\n\n/**\n * Bodies calling the kernel's primitive operators (`Text.startsWith`). An\n * interpreter runs these once it implements them: the in-memory one through\n * `Operators.kernel`, a compiler through its own table.\n */\nexport const primitiveCases: ReadonlyArray<ConformanceCase> = [\n {\n what: 'startsWith under binary is exact about case',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, 'In', binary)), byId),\n input: {},\n expected: ['a'],\n },\n {\n what: 'startsWith under asciiFold folds ASCII case on both sides',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, 'IN', asciiFold)), byId),\n input: {},\n expected: ['a', 'b'],\n },\n {\n what: 'startsWith the empty prefix holds for every row with text',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, prefix, binary)), byId),\n input: { prefix: '' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'startsWith over null text is unknown, so its rows are not matched',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.tag, '', binary)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'startsWith a null prefix is unknown for every row',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, prefix, binary)), byId),\n input: { prefix: null },\n expected: [],\n },\n {\n what: 'startsWith reads % and _ as characters, never as like wildcards',\n body: from.pipe(\n Query.where(\n Expr.or(\n Text.startsWith(Subject.fields.label, '100%', binary),\n Text.startsWith(Subject.fields.label, 'sn_', binary),\n Text.startsWith(Subject.fields.label, 'O%', binary),\n ),\n ),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n {\n what: 'startsWith under not keeps a null unknown',\n body: from.pipe(Query.where(Expr.not(Text.startsWith(Subject.fields.tag, 'x', binary))), byId),\n input: {},\n expected: ['e'],\n },\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: 'a comparison refuses text holding NUL',\n body: from.pipe(\n Query.where(Expr.lt(Subject.fields.label, label, { collation: Collation.binary })),\n byId,\n ),\n input: { label: `b${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 // SQLite stores NaN as null; Postgres orders it after every number, equal to itself.\n {\n what: 'an equality refuses NaN',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.rank, below)), byId),\n input: { below: Number.NaN },\n },\n {\n what: 'a comparison refuses NaN',\n body: from.pipe(Query.where(Expr.gt(Subject.fields.rank, below)), byId),\n input: { below: Number.NaN },\n },\n {\n what: 'a membership test refuses a list holding NaN',\n body: from.pipe(\n Query.where(Expr.in(Subject.fields.rank, Expr.input('ranks', Schema.Array(Schema.Number)))),\n byId,\n ),\n input: { ranks: [1, Number.NaN] },\n },\n]\n\n/** As `refusals`, for bodies calling the kernel's primitive operators. */\nexport const primitiveRefusals: ReadonlyArray<ConformanceRefusal> = [\n {\n what: 'startsWith refuses a prefix holding NUL',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, prefix, binary)), byId),\n input: { prefix: `In${NUL}` },\n },\n]\nexport * from './operator.js'\nexport * from './relational.js'\nexport * from './variants.js'\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;CAC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AS,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC,CAAC,GAC1F,IACF;EACA,OAAO,EAAE,OAAO,CAAC,GAAG,GAAU,EAAE;CAClC;AACF;;AAGA,MAAa,oBAAuD,CAClE;CACE,MAAM;CACN,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,WAAW,QAAQ,OAAO,OAAO,QAAQ,MAAM,CAAC,GAAG,IAAI;CACxF,OAAO,EAAE,QAAQ,KAAK,MAAM;AAC9B,CACF"}
|
|
1
|
+
{"version":3,"file":"index.js","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, Text, 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/** An optional filter's input: none chosen is null. */\nconst maybeTag = Expr.input('maybeTag', Schema.NullOr(Schema.String))\n/** An optional membership filter's input: none chosen is null. */\nconst maybeLabels = Expr.input('maybeLabels', Schema.NullOr(Schema.Array(Schema.String)))\nconst below = Expr.input('below', Schema.Number)\nconst from_ = Expr.input('from', Timestamp)\nconst until = Expr.input('until', Timestamp)\nconst binary = { collation: Collation.binary }\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)\n/** Defined operators: an interpreter runs what each means, and needs nothing of its own. */\nconst tagged = Expr.operator('conformance.tagged', {\n input: [Schema.Unknown],\n output: Schema.Boolean,\n definedAs: value => Expr.isNotNull(value),\n})\nconst rankOf = Expr.operator('conformance.rankOf', {\n input: [Schema.Number],\n output: Schema.Number,\n definedAs: rank => rank,\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 // ---- and, or, not: SQL's three values -----------------------------------\n // `tag` is null on a and c, so a comparison of it is unknown there, and a\n // row is kept only on true.\n {\n what: 'or holds where one operand does, true beating unknown',\n body: from.pipe(\n Query.where(Expr.or(Expr.eq(Subject.fields.tag, 'x'), Expr.eq(Subject.fields.rank, 2))),\n byId,\n ),\n input: {},\n expected: ['a', 'b', 'd'],\n },\n {\n what: 'an and inside an or groups as written',\n body: from.pipe(\n Query.where(\n Expr.or(\n Expr.and(Expr.eq(Subject.fields.rank, 3), Expr.eq(Subject.fields.tag, 'x')),\n Expr.eq(Subject.fields.label, 'Intro'),\n ),\n ),\n byId,\n ),\n input: {},\n expected: ['a', 'd'],\n },\n {\n what: 'not of an unknown stays unknown, so a null matches neither side',\n body: from.pipe(Query.where(Expr.not(Expr.eq(Subject.fields.tag, 'x'))), byId),\n input: {},\n expected: ['e'],\n },\n {\n what: 'not of an and that is false, false beating unknown, holds',\n body: from.pipe(\n Query.where(\n Expr.not(Expr.and(Expr.eq(Subject.fields.tag, 'x'), Expr.eq(Subject.fields.rank, 1))),\n ),\n byId,\n ),\n input: {},\n expected: ['a', 'c', 'd', 'e'],\n },\n {\n what: 'everything but one value, nulls included, is said with isNull',\n body: from.pipe(\n Query.where(\n Expr.or(Expr.isNull(Subject.fields.tag), Expr.not(Expr.eq(Subject.fields.tag, 'x'))),\n ),\n byId,\n ),\n input: {},\n expected: ['a', 'c', 'e'],\n },\n {\n what: 'an optional filter with nothing chosen matches every row',\n body: from.pipe(\n Query.where(Expr.whenGiven(maybeTag, given => Expr.eq(Subject.fields.tag, given))),\n byId,\n ),\n input: { maybeTag: null },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'an optional filter with a value chosen is that filter',\n body: from.pipe(\n Query.where(Expr.whenGiven(maybeTag, given => Expr.eq(Subject.fields.tag, given))),\n byId,\n ),\n input: { maybeTag: 'x' },\n expected: ['b', 'd'],\n },\n {\n what: 'an optional membership filter with no list chosen matches every row',\n body: from.pipe(\n Query.where(Expr.whenGiven(maybeLabels, given => Expr.in(Subject.fields.label, given))),\n byId,\n ),\n input: { maybeLabels: null },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'an optional membership filter with a list chosen is that filter',\n body: from.pipe(\n Query.where(Expr.whenGiven(maybeLabels, given => Expr.in(Subject.fields.label, given))),\n byId,\n ),\n input: { maybeLabels: ['Other', 'snake_case'] },\n expected: ['c', 'e'],\n },\n {\n what: 'an operand decided by the input alone settles an or either way',\n body: from.pipe(\n Query.where(Expr.or(Expr.eq(present, true), Expr.eq(Subject.fields.rank, 1))),\n byId,\n ),\n input: { present: false },\n expected: ['b'],\n },\n // ---- comparisons -----------------------------------------------------------\n // Ranks are a 2, b 1, c 3, d 3, e 4; text only under a collation every\n // interpreter agrees on, and a date by its encoded ISO string.\n {\n what: 'lt holds where a number orders before the other',\n body: from.pipe(Query.where(Expr.lt(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['a', 'b'],\n },\n {\n what: 'gte holds where a number orders after the other, or with it',\n body: from.pipe(Query.where(Expr.gte(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['c', 'd', 'e'],\n },\n {\n what: 'a field written second compares the same: the input is above the rank',\n body: from.pipe(Query.where(Expr.gt(below, Expr.field(Subject.fields.rank))), byId),\n input: { below: 3 },\n expected: ['a', 'b'],\n },\n {\n what: 'a comparison that reads no field orders numbers as numbers: 9 is below 10',\n body: from.pipe(Query.where(Expr.lt(below, 10)), byId),\n input: { below: 9 },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'a range of dates compares their encoded ISO strings under binary',\n body: from.pipe(\n Query.where(\n Expr.and(\n Expr.gte(Subject.fields.at, from_, binary),\n Expr.lt(Subject.fields.at, until, binary),\n ),\n ),\n byId,\n ),\n input: { from: '2026-01-02T00:00:00.000Z', until: '2026-01-04T00:00:00.000Z' },\n expected: ['b', 'c', 'd'],\n },\n {\n what: 'text under binary orders by code point: capitals and digits before lower case',\n body: from.pipe(Query.where(Expr.lt(Subject.fields.label, 'a', binary)), byId),\n input: {},\n expected: ['a', 'c', 'd'],\n },\n {\n what: 'text under asciiFold orders with ASCII case folded',\n body: from.pipe(\n Query.where(Expr.lt(Subject.fields.label, 'j', { collation: Collation.asciiFold })),\n byId,\n ),\n input: {},\n expected: ['a', 'b', 'd'],\n },\n {\n what: 'a null compared is unknown, so it matches neither the comparison nor its not',\n body: from.pipe(Query.where(Expr.gte(Subject.fields.tag, 'x', binary)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'not of a comparison leaves a null out too',\n body: from.pipe(Query.where(Expr.not(Expr.gte(Subject.fields.tag, 'x', binary))), byId),\n input: {},\n expected: [],\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 // ---- defined operators -----------------------------------------------------\n {\n what: 'a defined operator matches the rows what it means does',\n body: from.pipe(Query.where(tagged(Subject.fields.tag)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a defined operator under not is the negation of what it means',\n body: from.pipe(Query.where(Expr.not(tagged(Subject.fields.tag))), byId),\n input: {},\n expected: ['a', 'c'],\n },\n {\n what: 'a defined operator over an input only is decided by the request',\n body: from.pipe(Query.where(Expr.or(tagged(maybeTag), Expr.eq(Subject.fields.rank, 3))), byId),\n input: { maybeTag: null },\n expected: ['c', 'd'],\n },\n {\n what: 'a defined scalar operator compares as what it means',\n body: from.pipe(Query.where(Expr.eq(rankOf(Subject.fields.rank), 3)), byId),\n input: {},\n expected: ['c', 'd'],\n },\n]\n\nconst prefix = Expr.input('prefix', Schema.NullOr(Schema.String))\nconst asciiFold = { collation: Collation.asciiFold }\n\n/**\n * Bodies calling the kernel's primitive operators (`Text.startsWith`). An\n * interpreter runs these once it implements them: the in-memory one through\n * `Operators.kernel`, a compiler through its own table.\n */\nexport const primitiveCases: ReadonlyArray<ConformanceCase> = [\n {\n what: 'startsWith under binary is exact about case',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, 'In', binary)), byId),\n input: {},\n expected: ['a'],\n },\n {\n what: 'startsWith under asciiFold folds ASCII case on both sides',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, 'IN', asciiFold)), byId),\n input: {},\n expected: ['a', 'b'],\n },\n {\n what: 'startsWith the empty prefix holds for every row with text',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, prefix, binary)), byId),\n input: { prefix: '' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'startsWith over null text is unknown, so its rows are not matched',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.tag, '', binary)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'startsWith a null prefix is unknown for every row',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, prefix, binary)), byId),\n input: { prefix: null },\n expected: [],\n },\n {\n what: 'startsWith reads % and _ as characters, never as like wildcards',\n body: from.pipe(\n Query.where(\n Expr.or(\n Text.startsWith(Subject.fields.label, '100%', binary),\n Text.startsWith(Subject.fields.label, 'sn_', binary),\n Text.startsWith(Subject.fields.label, 'O%', binary),\n ),\n ),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n {\n what: 'startsWith under not keeps a null unknown',\n body: from.pipe(Query.where(Expr.not(Text.startsWith(Subject.fields.tag, 'x', binary))), byId),\n input: {},\n expected: ['e'],\n },\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: 'a comparison refuses text holding NUL',\n body: from.pipe(\n Query.where(Expr.lt(Subject.fields.label, label, { collation: Collation.binary })),\n byId,\n ),\n input: { label: `b${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 // SQLite stores NaN as null; Postgres orders it after every number, equal to itself.\n {\n what: 'an equality refuses NaN',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.rank, below)), byId),\n input: { below: Number.NaN },\n },\n {\n what: 'a comparison refuses NaN',\n body: from.pipe(Query.where(Expr.gt(Subject.fields.rank, below)), byId),\n input: { below: Number.NaN },\n },\n {\n what: 'a membership test refuses a list holding NaN',\n body: from.pipe(\n Query.where(Expr.in(Subject.fields.rank, Expr.input('ranks', Schema.Array(Schema.Number)))),\n byId,\n ),\n input: { ranks: [1, Number.NaN] },\n },\n]\n\n/** As `refusals`, for bodies calling the kernel's primitive operators. */\nexport const primitiveRefusals: ReadonlyArray<ConformanceRefusal> = [\n {\n what: 'startsWith refuses a prefix holding NUL',\n body: from.pipe(Query.where(Text.startsWith(Subject.fields.label, prefix, binary)), byId),\n input: { prefix: `In${NUL}` },\n },\n]\nexport * from './operator.js'\nexport * from './relational.js'\nexport * from './variants.js'\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,MAAM,SAAS,O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AM;EACN,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,MAAM,KAAK,CAAC,GAAG,IAAI;EACtE,OAAO,EAAE,OAAO,IAAW;CAC7B;CACA;EACE,MAAM;EACN,MAAM,KAAK,KACT,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,MAAM,KAAK,MAAM,SAAS,OAAO,MAAM,OAAO,MAAM,CAAC,CAAC,CAAC,GAC1F,IACF;EACA,OAAO,EAAE,OAAO,CAAC,GAAG,GAAU,EAAE;CAClC;AACF;;AAGA,MAAa,oBAAuD,CAClE;CACE,MAAM;CACN,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,WAAW,QAAQ,OAAO,OAAO,QAAQ,MAAM,CAAC,GAAG,IAAI;CACxF,OAAO,EAAE,QAAQ,KAAK,MAAM;AAC9B,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","names":[],"sources":["../../src/conformance/operator.ts"],"mappings":";;;YAiCY,UAAU,KAAK;EACzB;aAAkB;;EAClB;aAAoB;;;qBAET,SAAO,KAAA,WAAA;;WAFU;;;WADH;;;;;;;YAUf,cAAc,KAAK;EAC7B;aAAkB,UAAU,cAAc;;EAC1C;aACW,KAAK;;aAEL;;EAEX;aACW,KAAK;aACL,MAAM;;aAEN,WAAW,OAAO,OAAO;aACzB,MAAM;aACN,OAAO;;;qBAGP,aAAW,KAAA,WAAA;;WARN,KAAA;WACC,MAAA;WAEK,WAAA,OAAO,OAAO;WACnB,MAAA;WACC,OAAA;;;WAZU,UAAA,cAAc;;;WAE1B,KAAA;WAEG;;;;;;YAiBT,UAAU,MAAM;;iBAGX;WACN,MAAM;WACN,WAAW,OAAO,OAAO;WACzB,UAAU,SAAS,eAAe;;iBAG5B;;WAEN;WACA,eAAe,cAAc;;
|
|
1
|
+
{"version":3,"file":"operator.d.ts","names":[],"sources":["../../src/conformance/operator.ts"],"mappings":";;;YAiCY,UAAU,KAAK;EACzB;aAAkB;;EAClB;aAAoB;;;qBAET,SAAO,KAAA,WAAA;;WAFU;;;WADH;;;;;;;YAUf,cAAc,KAAK;EAC7B;aAAkB,UAAU,cAAc;;EAC1C;aACW,KAAK;;aAEL;;EAEX;aACW,KAAK;aACL,MAAM;;aAEN,WAAW,OAAO,OAAO;aACzB,MAAM;aACN,OAAO;;;qBAGP,aAAW,KAAA,WAAA;;WARN,KAAA;WACC,MAAA;WAEK,WAAA,OAAO,OAAO;WACnB,MAAA;WACC,OAAA;;;WAZU,UAAA,cAAc;;;WAE1B,KAAA;WAEG;;;;;;YAiBT,UAAU,MAAM;;iBAGX;WACN,MAAM;WACN,WAAW,OAAO,OAAO;WACzB,UAAU,SAAS,eAAe;;iBAG5B;;WAEN;WACA,eAAe,cAAc;;qBA+V3B;;EAEX,SAAM,WACQ,oBAAkB;;;;;;;;EAWhC,OAAO,WAAW,cAAc,OAAO,MAAM,YAAY,OAAO,KAAG,IAC7D,SAAS,IAAI,MAAI,WACV,iBAAe;aAEf;aACA;aACA;QAEV;;;;;;EAyBH,SAAe,WAAW,cAAc,OAAO,MAAM,YAAY,OAAO,KAAG,IACrE,SAAS,IAAI,MAAI,KAChB,QAAM;aAEA;aACA;aACA;QAEV,QAAQ;;;;;;;;;;EAkCX,WAAiB,WAAW,cAAc,OAAO,MAAM,YAAY,OAAO,KAAG,IACvE,SAAS,IAAI,MAAI;aAEV,iBAAiB,SAAS,eAAe;aACzC,QAAQ,cAAc;aACtB;aACA;aACA,iBAAiB;QAE3B,QAAQ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Data, Option, Schema, SchemaAST } from "effect";
|
|
1
|
+
import { Data, Match, Option, Schema, SchemaAST } from "effect";
|
|
2
2
|
import { Collation, Evidence, Expr, Law, Operators, QueryEvaluateError, valueOfOperand } from "../index.js";
|
|
3
3
|
import { stampRun, stampTested } from "../tested.js";
|
|
4
4
|
import { tuplesOf } from "./tuples.js";
|
|
@@ -86,7 +86,13 @@ const sameValue = (left, right) => {
|
|
|
86
86
|
return left === right;
|
|
87
87
|
};
|
|
88
88
|
/** Two outcomes alike: equal values as stored, or both refusals. */
|
|
89
|
-
const same = (left, right) =>
|
|
89
|
+
const same = (left, right) => Match.valueTags(left, {
|
|
90
|
+
Refused: () => right._tag === "Refused",
|
|
91
|
+
Value: ({ value }) => Match.valueTags(right, {
|
|
92
|
+
Refused: () => false,
|
|
93
|
+
Value: (other) => sameValue(value, other.value)
|
|
94
|
+
})
|
|
95
|
+
});
|
|
90
96
|
/** Text by code point, as every interpreter's `binary` orders it; `<` compares UTF-16 units. */
|
|
91
97
|
const byCodePoint = (left, right) => {
|
|
92
98
|
const [a, b] = [[...left], [...right]];
|
|
@@ -228,8 +234,11 @@ const verdictOf = (op, laws, answered, options) => {
|
|
|
228
234
|
left,
|
|
229
235
|
right
|
|
230
236
|
});
|
|
231
|
-
if (left._tag === "Value" && right._tag === "Value")
|
|
232
|
-
|
|
237
|
+
if (left._tag === "Value" && right._tag === "Value") {
|
|
238
|
+
cases += 1;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (Option.isNone(refusal) && left._tag === "Refused") refusal = Option.some(left.reason);
|
|
233
242
|
}
|
|
234
243
|
if (cases === 0) return LawsVerdict.Unanswered({
|
|
235
244
|
law,
|