foldkit-entity 0.17.0 → 0.18.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 +466 -227
- package/dist/conformance/index.d.ts.map +1 -1
- package/dist/conformance/index.js +10 -4
- package/dist/conformance/index.js.map +1 -1
- package/dist/descriptor.d.ts +5 -1
- package/dist/descriptor.d.ts.map +1 -1
- package/dist/descriptor.js +6 -2
- package/dist/descriptor.js.map +1 -1
- package/dist/entity.d.ts +3 -2
- package/dist/entity.d.ts.map +1 -1
- package/dist/entity.js +5 -3
- package/dist/entity.js.map +1 -1
- package/dist/enumerate.d.ts +44 -0
- package/dist/enumerate.d.ts.map +1 -0
- package/dist/enumerate.js +128 -0
- package/dist/enumerate.js.map +1 -0
- package/dist/evaluate.d.ts +11 -5
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +27 -6
- package/dist/evaluate.js.map +1 -1
- package/dist/expr.d.ts +8 -2
- package/dist/expr.d.ts.map +1 -1
- package/dist/expr.js +19 -10
- package/dist/expr.js.map +1 -1
- package/dist/footprint.d.ts +120 -0
- package/dist/footprint.d.ts.map +1 -0
- package/dist/footprint.js +41 -0
- package/dist/footprint.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/invariant.d.ts +41 -11
- package/dist/invariant.d.ts.map +1 -1
- package/dist/invariant.js +83 -38
- package/dist/invariant.js.map +1 -1
- package/dist/lawIds.d.ts +15 -0
- package/dist/lawIds.d.ts.map +1 -0
- package/dist/lawIds.js +13 -0
- package/dist/lawIds.js.map +1 -0
- package/dist/laws.d.ts +308 -0
- package/dist/laws.d.ts.map +1 -0
- package/dist/laws.js +566 -0
- package/dist/laws.js.map +1 -0
- package/dist/operators.d.ts +1 -1
- package/dist/refine.d.ts +64 -0
- package/dist/refine.d.ts.map +1 -0
- package/dist/refine.js +104 -0
- package/dist/refine.js.map +1 -0
- package/dist/rows.d.ts +15 -0
- package/dist/rows.d.ts.map +1 -0
- package/dist/rows.js +23 -0
- package/dist/rows.js.map +1 -0
- package/dist/uncollated.d.ts +10 -0
- package/dist/uncollated.d.ts.map +1 -0
- package/dist/uncollated.js +18 -0
- package/dist/uncollated.js.map +1 -0
- package/dist/write.d.ts +64 -6
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +88 -12
- package/dist/write.js.map +1 -1
- package/package.json +3 -3
|
@@ -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;;qBA0CR,OAAO,cAAc;;;;;;
|
|
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;;;;;;qBA2gBrB,gBAAgB,cAAc;;;;;iBA0D1B;WACN;WACA,MAAM;;WAEN,OAAO,SAAS;;qBAKd,UAAU,cAAc;;qBA0CxB,mBAAmB,cAAc"}
|
|
@@ -580,7 +580,7 @@ const cases = [
|
|
|
580
580
|
},
|
|
581
581
|
{
|
|
582
582
|
what: "puts rows without a value last ascending, unless told otherwise",
|
|
583
|
-
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag))),
|
|
583
|
+
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag, { collation: Collation.binary }))),
|
|
584
584
|
input: {},
|
|
585
585
|
expected: [
|
|
586
586
|
"b",
|
|
@@ -592,7 +592,7 @@ const cases = [
|
|
|
592
592
|
},
|
|
593
593
|
{
|
|
594
594
|
what: "puts rows without a value first descending, unless told otherwise",
|
|
595
|
-
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag))),
|
|
595
|
+
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag, { collation: Collation.binary }))),
|
|
596
596
|
input: {},
|
|
597
597
|
expected: [
|
|
598
598
|
"a",
|
|
@@ -604,7 +604,10 @@ const cases = [
|
|
|
604
604
|
},
|
|
605
605
|
{
|
|
606
606
|
what: "puts rows without a value first ascending when the term says so",
|
|
607
|
-
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag, {
|
|
607
|
+
body: from.pipe(Query.orderBy(Order.asc(Subject.fields.tag, {
|
|
608
|
+
nulls: "first",
|
|
609
|
+
collation: Collation.binary
|
|
610
|
+
}))),
|
|
608
611
|
input: {},
|
|
609
612
|
expected: [
|
|
610
613
|
"a",
|
|
@@ -616,7 +619,10 @@ const cases = [
|
|
|
616
619
|
},
|
|
617
620
|
{
|
|
618
621
|
what: "puts rows without a value last descending when the term says so",
|
|
619
|
-
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag, {
|
|
622
|
+
body: from.pipe(Query.orderBy(Order.desc(Subject.fields.tag, {
|
|
623
|
+
nulls: "last",
|
|
624
|
+
collation: Collation.binary
|
|
625
|
+
}))),
|
|
620
626
|
input: {},
|
|
621
627
|
expected: [
|
|
622
628
|
"e",
|
|
@@ -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))\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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esContent":["/**\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, { collation: Collation.binary }))),\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, { collation: Collation.binary }))),\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(\n Query.orderBy(Order.asc(Subject.fields.tag, { nulls: 'first', collation: Collation.binary })),\n ),\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(\n Query.orderBy(Order.desc(Subject.fields.tag, { nulls: 'last', collation: Collation.binary })),\n ),\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":";;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AM,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"}
|
package/dist/descriptor.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Schema } from "effect";
|
|
|
2
2
|
import { Metadata } from "foldkit-metadata";
|
|
3
3
|
import { AnyEntity, EntityIdentity, EntityMember } from "./index.js";
|
|
4
4
|
import { EntitySet } from "./sets.js";
|
|
5
|
+
import { Invariant } from "./invariant.js";
|
|
5
6
|
/** What one descriptor holds of its own: its fields, and the metadata annotated on it. */
|
|
6
7
|
interface Parts {
|
|
7
8
|
readonly identity: EntityIdentity<string>;
|
|
@@ -17,11 +18,14 @@ export declare const make: (parts: Parts) => AnyEntity;
|
|
|
17
18
|
export declare const remake: (entity: AnyEntity, changed: Partial<Parts>) => AnyEntity;
|
|
18
19
|
/** The relations every descriptor of the Entity `identity` names holds. */
|
|
19
20
|
export declare const relationsOf: (identity: EntityIdentity<string>) => Readonly<Record<string, EntityMember>>;
|
|
20
|
-
/**
|
|
21
|
+
/** The invariants every descriptor of the Entity `identity` names judges. */
|
|
22
|
+
export declare const invariantsOfIdentity: (identity: EntityIdentity<string>) => ReadonlyArray<Invariant>;
|
|
23
|
+
/** Adds to the Entity's shared parts, which every descriptor of it then reads. */
|
|
21
24
|
export declare const extend: (entity: AnyEntity, added: {
|
|
22
25
|
readonly relations?: Readonly<Record<string, EntityMember>>;
|
|
23
26
|
readonly derived?: Readonly<Record<string, EntityMember>>;
|
|
24
27
|
readonly sets?: Readonly<Record<string, EntitySet>>;
|
|
28
|
+
readonly invariants?: ReadonlyArray<Invariant>;
|
|
25
29
|
}) => void;
|
|
26
30
|
export declare const mapValues: <A, B>(record: Readonly<Record<string, A>>, f: (value: A, key: string) => B) => Record<string, B>;
|
|
27
31
|
/**
|
package/dist/descriptor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.d.ts","names":[],"sources":["../src/descriptor.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"descriptor.d.ts","names":[],"sources":["../src/descriptor.ts"],"mappings":";;;;;;UA8CU;WACC,UAAU;WACV,QAAQ,OAAO,OAAO,OAAO,OAAO;WACpC,QAAQ,SAAS,eAAe;;WAEhC,WAAW,SAAS,eAAe;WACnC,UAAU;;qBAGR,SAAO,QAAA,WAAA;qBASP,OAAI,OAAW,UAAQ;;qBA6DvB,SAAM,QAAY,WAAS,SAAW,QAAQ,WAAS;;qBAIvD,cAAW,UACZ,2BACT,SAAS,eAAe;;qBAGd,uBAAoB,UAAc,2BAAyB,cAAc;;qBAIzE,SAAM,QACT,WAAS;WAEN,YAAY,SAAS,eAAe;WACpC,UAAU,SAAS,eAAe;WAClC,OAAO,SAAS,eAAe;WAC/B,aAAa,cAAc;;qBAa3B,YAAa,GAAG,GAAC,QACpB,SAAS,eAAe,KAAG,IAC/B,OAAO,GAAG,gBAAgB,MAC7B,eAAe;;;;;qBAOL,cAAY,QAAA,wBAAA"}
|
package/dist/descriptor.js
CHANGED
|
@@ -17,6 +17,7 @@ const shapeOf = (identity) => {
|
|
|
17
17
|
relations: {},
|
|
18
18
|
derived: {},
|
|
19
19
|
sets: {},
|
|
20
|
+
invariants: [],
|
|
20
21
|
revision: 0
|
|
21
22
|
};
|
|
22
23
|
shapes.set(identity, shape);
|
|
@@ -118,12 +119,15 @@ const remake = (entity, changed) => make({
|
|
|
118
119
|
});
|
|
119
120
|
/** The relations every descriptor of the Entity `identity` names holds. */
|
|
120
121
|
const relationsOf = (identity) => shapeOf(identity).relations;
|
|
121
|
-
/**
|
|
122
|
+
/** The invariants every descriptor of the Entity `identity` names judges. */
|
|
123
|
+
const invariantsOfIdentity = (identity) => shapeOf(identity).invariants;
|
|
124
|
+
/** Adds to the Entity's shared parts, which every descriptor of it then reads. */
|
|
122
125
|
const extend = (entity, added) => {
|
|
123
126
|
const shape = shapeOf(entity.identity);
|
|
124
127
|
for (const [key, member] of Object.entries(added.relations ?? {})) put(shape.relations, key, member);
|
|
125
128
|
for (const [key, member] of Object.entries(added.derived ?? {})) put(shape.derived, key, member);
|
|
126
129
|
for (const [key, set] of Object.entries(added.sets ?? {})) put(shape.sets, key, set);
|
|
130
|
+
if (added.invariants !== void 0) shape.invariants = Object.freeze([...shape.invariants, ...added.invariants]);
|
|
127
131
|
shape.revision += 1;
|
|
128
132
|
};
|
|
129
133
|
const mapValues = (record, f) => Object.fromEntries(Object.entries(record).map(([key, value]) => [key, f(value, key)]));
|
|
@@ -132,6 +136,6 @@ const mapValues = (record, f) => Object.fromEntries(Object.entries(record).map((
|
|
|
132
136
|
* invariant is built over its fields when first read.
|
|
133
137
|
*/
|
|
134
138
|
const variantBases = /* @__PURE__ */ new WeakMap();
|
|
135
|
-
export { extend, make, mapValues, partsOf, relationsOf, remake, variantBases };
|
|
139
|
+
export { extend, invariantsOfIdentity, make, mapValues, partsOf, relationsOf, remake, variantBases };
|
|
136
140
|
|
|
137
141
|
//# sourceMappingURL=descriptor.js.map
|
package/dist/descriptor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor.js","names":[],"sources":["../src/descriptor.ts"],"sourcesContent":["/**\n * What makes an Entity descriptor: its parts, the members every descriptor of\n * one Entity shares, and making a new descriptor from them. Apart from the\n * `Entity` namespace, so an invariant attaches itself without importing it.\n */\nimport { Option, Pipeable, type Schema } from 'effect'\nimport { Metadata } from 'foldkit-metadata'\nimport { EntityTypeId } from './ids.js'\nimport type { AnyEntity, EntityIdentity, EntityMember } from './index.js'\nimport { own, put } from './record.js'\nimport type { EntitySet } from './sets.js'\nimport { variantsOf } from './variants.js'\n\n/**\n * What every descriptor of one Entity shares: the members `Entity.relate`,\n * `Entity.derived` and `Entity.sets` add. It belongs to the identity, so a\n *
|
|
1
|
+
{"version":3,"file":"descriptor.js","names":[],"sources":["../src/descriptor.ts"],"sourcesContent":["/**\n * What makes an Entity descriptor: its parts, the members every descriptor of\n * one Entity shares, and making a new descriptor from them. Apart from the\n * `Entity` namespace, so an invariant attaches itself without importing it.\n */\nimport { Option, Pipeable, type Schema } from 'effect'\nimport { Metadata } from 'foldkit-metadata'\nimport { EntityTypeId } from './ids.js'\nimport type { AnyEntity, EntityIdentity, EntityMember } from './index.js'\nimport type { Invariant } from './invariant.js'\nimport { own, put } from './record.js'\nimport type { EntitySet } from './sets.js'\nimport { variantsOf } from './variants.js'\n\n/**\n * What every descriptor of one Entity shares: the members `Entity.relate`,\n * `Entity.derived` and `Entity.sets` add, and the invariants\n * `Entity.invariant` declares. It belongs to the identity, so a member added\n * through one descriptor is a member of every other, the one a relation's\n * `target()` returns and the one declared before `relate` alike. An invariant\n * is a fact about the stored row, so no descriptor may judge without it (#539).\n */\ninterface Shape {\n readonly relations: Record<string, EntityMember>\n readonly derived: Record<string, EntityMember>\n readonly sets: Record<string, EntitySet>\n /**\n * In the order they were declared. Replaced, never changed, so a reader that\n * kept it (a binding compiling its checks) keeps what it compiled.\n */\n invariants: ReadonlyArray<Invariant>\n /** Moves with every addition, so a descriptor knows when its view is stale. */\n revision: number\n}\n\nconst shapes = new WeakMap<EntityIdentity<string>, Shape>()\n\nconst shapeOf = (identity: EntityIdentity<string>): Shape => {\n const known = shapes.get(identity)\n if (known !== undefined) return known\n const shape: Shape = { relations: {}, derived: {}, sets: {}, invariants: [], revision: 0 }\n shapes.set(identity, shape)\n return shape\n}\n\n/** What one descriptor holds of its own: its fields, and the metadata annotated on it. */\ninterface Parts {\n readonly identity: EntityIdentity<string>\n readonly schema: Schema.Struct<Schema.Struct.Fields>\n readonly fields: Readonly<Record<string, EntityMember>>\n /** Metadata `annotateMembers` gave this descriptor's relations and derived members, by key. */\n readonly annotated: Readonly<Record<string, Metadata>>\n readonly metadata: Metadata\n}\n\nexport const partsOf = new WeakMap<AnyEntity, Parts>()\n\nconst EntityProto = {\n [EntityTypeId]: EntityTypeId,\n pipe() {\n return Pipeable.pipeArguments(this, arguments)\n },\n}\n\nexport const make = (parts: Parts): AnyEntity => {\n const shape = shapeOf(parts.identity)\n const fields = Object.freeze(parts.fields)\n // A shared member annotated here is a copy, made once, so it keeps its identity across reads.\n const copies = new WeakMap<EntityMember, EntityMember>()\n const annotate = (members: Readonly<Record<string, EntityMember>>) =>\n Object.freeze(\n mapValues(members, (member, key) => {\n const extra = own(parts.annotated, key)\n if (extra === undefined) return member\n const copied = copies.get(member)\n if (copied !== undefined) return copied\n const copy = Object.freeze({\n ...member,\n metadata: Metadata.combine([member.metadata, extra]),\n })\n copies.set(member, copy)\n return copy\n }),\n )\n let seen = -1\n let view: {\n readonly relations: Readonly<Record<string, EntityMember>>\n readonly derived: Readonly<Record<string, EntityMember>>\n readonly sets: Readonly<Record<string, EntitySet>>\n readonly members: Readonly<Record<string, EntityMember>>\n }\n const current = () => {\n if (seen !== shape.revision) {\n const relations = annotate(shape.relations)\n const derived = annotate(shape.derived)\n view = {\n relations,\n derived,\n sets: Object.freeze({ ...shape.sets }),\n members: Object.freeze({ ...fields, ...relations, ...derived }),\n }\n seen = shape.revision\n }\n return view\n }\n const entity = Object.create(EntityProto)\n Object.defineProperties(entity, {\n identity: { value: parts.identity, enumerable: true },\n name: { value: parts.identity.name, enumerable: true },\n schema: { value: parts.schema, enumerable: true },\n fields: { value: fields, enumerable: true },\n relations: { get: () => current().relations, enumerable: true },\n derived: { get: () => current().derived, enumerable: true },\n members: { get: () => current().members, enumerable: true },\n sets: { get: () => current().sets, enumerable: true },\n metadata: { value: parts.metadata, enumerable: true },\n })\n Option.map(variantsOf(parts.identity), ({ union }) =>\n Object.defineProperty(entity, 'variants', { value: union, enumerable: true }),\n )\n partsOf.set(entity, parts)\n return Object.freeze(entity)\n}\n\n/** A new descriptor of the same Entity, with some of its own parts changed. */\nexport const remake = (entity: AnyEntity, changed: Partial<Parts>): AnyEntity =>\n make({ ...partsOf.get(entity)!, ...changed })\n\n/** The relations every descriptor of the Entity `identity` names holds. */\nexport const relationsOf = (\n identity: EntityIdentity<string>,\n): Readonly<Record<string, EntityMember>> => shapeOf(identity).relations\n\n/** The invariants every descriptor of the Entity `identity` names judges. */\nexport const invariantsOfIdentity = (identity: EntityIdentity<string>): ReadonlyArray<Invariant> =>\n shapeOf(identity).invariants\n\n/** Adds to the Entity's shared parts, which every descriptor of it then reads. */\nexport const extend = (\n entity: AnyEntity,\n added: {\n readonly relations?: Readonly<Record<string, EntityMember>>\n readonly derived?: Readonly<Record<string, EntityMember>>\n readonly sets?: Readonly<Record<string, EntitySet>>\n readonly invariants?: ReadonlyArray<Invariant>\n },\n): void => {\n const shape = shapeOf(entity.identity)\n for (const [key, member] of Object.entries(added.relations ?? {}))\n put(shape.relations, key, member)\n for (const [key, member] of Object.entries(added.derived ?? {})) put(shape.derived, key, member)\n for (const [key, set] of Object.entries(added.sets ?? {})) put(shape.sets, key, set)\n if (added.invariants !== undefined)\n shape.invariants = Object.freeze([...shape.invariants, ...added.invariants])\n shape.revision += 1\n}\n\nexport const mapValues = <A, B>(\n record: Readonly<Record<string, A>>,\n f: (value: A, key: string) => B,\n): Record<string, B> =>\n Object.fromEntries(Object.entries(record).map(([key, value]) => [key, f(value, key)]))\n\n/**\n * A variant Entity's descriptor as declared, by its identity: each case's\n * invariant is built over its fields when first read.\n */\nexport const variantBases = new WeakMap<EntityIdentity<string>, AnyEntity>()\n"],"mappings":";;;;;;;;;;;AAmCA,MAAM,yBAAS,IAAI,QAAuC;AAE1D,MAAM,WAAW,aAA4C;CAC3D,MAAM,QAAQ,OAAO,IAAI,QAAQ;CACjC,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAe;EAAE,WAAW,CAAC;EA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KAAK,GAAG;CACnF,IAAI,MAAM,eAAe,KAAA,GACvB,MAAM,aAAa,OAAO,OAAO,CAAC,GAAG,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC;CAC7E,MAAM,YAAY;AACpB;AAEA,MAAa,aACX,QACA,MAEA,OAAO,YAAY,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,KAAK,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;;;;;AAMvF,MAAa,+BAAe,IAAI,QAA2C"}
|
package/dist/entity.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { Metadata } from "foldkit-metadata";
|
|
|
3
3
|
import { CheckCases, EntityVariants, StoredFields, VariantCases, VariantUnion } from "./variants.js";
|
|
4
4
|
import { AnyEntity, Cardinality, DerivedSpecs, Entities, Entity, EntityDerived, EntityField, EntityInput, EntityRelation, EntitySets, IdOf, IdSchemaOf, NestedInput, PageWindow, Related, RelationInput, RelationMap, Selection, SelectionPage, Unmapped, VariantEntity } from "./index.js";
|
|
5
5
|
import { SetOn } from "./sets.js";
|
|
6
|
-
import {
|
|
6
|
+
import { inState, refine, states } from "./refine.js";
|
|
7
|
+
import { JudgeInputOptions, check, invariant, invariantsOf as invariants, judge, judgeAgainst, judgeInput, judgedBy, readsBefore, rowFrom } from "./invariant.js";
|
|
7
8
|
import { OneRelation } from "./expr.js";
|
|
8
9
|
/** Unsatisfiable when a new key is already a member, so the pipe step is the error site. */
|
|
9
10
|
type Free<E extends AnyEntity, New> = keyof New & keyof E['members'] extends never ? unknown : {
|
|
@@ -239,5 +240,5 @@ export declare const selectFor: <E extends AnyEntity, Fields extends Schema.Stru
|
|
|
239
240
|
* an unmapped key, which the Entity knows nothing about.
|
|
240
241
|
*/
|
|
241
242
|
export declare const valuesFor: <E extends AnyEntity, Fields extends Schema.Struct.Fields, Members>(input: EntityInput<E, Fields, Members>, value: Readonly<Record<string, unknown>>) => Partial<Schema.Struct.Type<Fields>>;
|
|
242
|
-
export { check, invariant, invariants, isEntity as is, judge, judgeAgainst, judgeInput, readsBefore, isSameEntity as same };
|
|
243
|
+
export { type JudgeInputOptions, check, inState, invariant, invariants, isEntity as is, judge, judgeAgainst, judgeInput, judgedBy, readsBefore, refine, rowFrom, isSameEntity as same, states };
|
|
243
244
|
//# sourceMappingURL=entity.d.ts.map
|
package/dist/entity.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entity.d.ts","names":[],"sources":["../src/entity.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"entity.d.ts","names":[],"sources":["../src/entity.ts"],"mappings":";;;;;;;;;KA+DK,KAAK,UAAU,WAAW,aAAa,YAAY;WAEzC,sBAAsB,YAAY;;;KAG5C,WAAW,UAAU,WAAW,YAAY,mBAC9C,WAAW,MAAM,IAAI;WACX;WACA,UAAU,+BAA+B;KAE/C,yBAAyB,qBAExB,mBAEA,oBAAmB,UACtB;WAEY,mCAAmC;;KAG/C,YAAY,GAAG,YAAY,gBAC9B,UAAU,oBAAoB,YAAY,cAAc,SAAS,SAAS,KACtE,cAAc,MAAM,QAAQ,GAAG,IAAI,KAAK,KACxC,UAAU,aAAa,YAAY,cAAc,SAAS,KACxD,OAAO,MAAM,QAAQ,GAAG,IAAI;;KAI/B,eAAe,WAAW,UAAU,kBAC7B,WAAW,KAAK,gBAAgB,iBAE1B,WAAW,GAAG,KAAK,gBAAgB,GAAG,oBACxC,sCAAsC,GAAG,eAC7C,GAAG,GAAG;KAKb,UAAU,eAAe,aAAa,OAAO;WACvC,QAAQ,OAAO,QAAQ;WACvB,IAAI,WAAW;;KAGrB,aAAa,gCAAgC,UAAU;KAEvD,WAAW,UAAU,OAAO,cAAc,OAAO;WAC3C,OAAO,OAAO,OAAO;WACrB,SAAS,OAAO;WAChB,aAAa,OAAO;;;KAI1B,cAAc,KAAK;WACb;aACE,aAAa,UAAU,SAC9B;eAA0B,QAAQ,OAAO,OAAO;;;gBAItC,WAAW,aAAa,EAA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J,YAAY,cAAY,OAAS,SACvC,UAAU,WAAS,QAAU,IAAI,KAAK,GAAG,OAAO,WAAW,GAAG,SAAO,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;qBAyE1E,OACV,UAAU,WAAS,QAAU,WAAW,IAAE;WAAsB,IAAI;OAAO,QACnE,MAAI;;qBAYF,WAAQ,UACR,cACV,UAAU,WAAS,QAAU,MAAI;;qBAIvB,kBACV,UAAU,WAAS,sBAAwB,WAAW,gBAAgB,iBAAU,QACxE,MAAI;;;;;;;qBA4BF,QACX,UAAU,WACV,eAAe,OAAO,OAAO,cAEvB,cAAY,QAEV,GAAC,QACD,OAAO,OAAO,YAAO,eACX,aAAa,GAAG,QAAQ,0BACrC,UAAU,UAAU,aAAa,GAAG,QAAQ,aAC5C,SAAS,UAAU,aAAa,GAAG,QAAQ,cAC/C,YAAY,GAAG,QAAQ,aAAa,GAAG,QAAQ;;;;;;qBAiErC,SACX,UAAU,iBACJ,aAAa,oBAAoB,uBAAqB,QAEpD,MAAC,MACA,qBACI,KAAK,eAAe,YAAY;;;;;;;;qBAoBlC,YAAa,UAAU,WAAW,eAAe,OAAO,OAAO,QAAQ,SAAO,OAClF,YAAY,GAAG,QAAQ,UAAQ;WAClB,OAAO,SAAS;MACnC,UACD,WACA,YAAY,UACZ,gBAAgB,GAAG,YAAY,WAC/B,KAAK;;;;;;;qBAuBM,YAAa,UAAU,WAAW,eAAe,OAAO,OAAO,QAAQ,SAAO,OAClF,YAAY,GAAG,QAAQ,UAAQ,OAC/B,SAAS,6BACf,QAAQ,OAAO,OAAO,KAAK"}
|
package/dist/entity.js
CHANGED
|
@@ -5,9 +5,11 @@ import { own, put } from "./record.js";
|
|
|
5
5
|
import { declareVariants, registerVariants, variantsOf as variantsOf$1 } from "./variants.js";
|
|
6
6
|
import { extend, make, mapValues, partsOf, remake, variantBases } from "./descriptor.js";
|
|
7
7
|
import { Derivation } from "./index.js";
|
|
8
|
+
import { linkId } from "./rows.js";
|
|
8
9
|
import { checkedSet } from "./sets.js";
|
|
9
10
|
import { SchemaShape } from "./shape.js";
|
|
10
|
-
import {
|
|
11
|
+
import { inState, refine, states } from "./refine.js";
|
|
12
|
+
import { check, invariant, invariantsOf as invariants, judge, judgeAgainst, judgeInput, judgedBy, readsBefore, rowFrom } from "./invariant.js";
|
|
11
13
|
// src/entity.ts
|
|
12
14
|
/**
|
|
13
15
|
* The `Entity` namespace: declaring Entities, their relations and derived
|
|
@@ -435,7 +437,7 @@ const selectFor = (input, options = {}) => {
|
|
|
435
437
|
*/
|
|
436
438
|
const valuesFor = (input, value) => {
|
|
437
439
|
const members = input.members;
|
|
438
|
-
const idOf = (held) =>
|
|
440
|
+
const idOf = (held) => Option.getOrUndefined(linkId(held));
|
|
439
441
|
const entries = Object.entries(members).flatMap(([key, member]) => {
|
|
440
442
|
if (member._tag === "Unmapped") return [];
|
|
441
443
|
const written = Match.valueTags(member, {
|
|
@@ -459,6 +461,6 @@ const valuesFor = (input, value) => {
|
|
|
459
461
|
});
|
|
460
462
|
return Object.fromEntries(entries);
|
|
461
463
|
};
|
|
462
|
-
export { annotate, annotateMembers, cascading, check, clearing, define, defineVariants, derived, fields, input, invariant, invariants, isEntity as is, judge, judgeAgainst, judgeInput, page, readsBefore, relate, restricting, isSameEntity as same, select, selectFor, selectionSchema, sets, unmapped, valuesFor, variantsOf };
|
|
464
|
+
export { annotate, annotateMembers, cascading, check, clearing, define, defineVariants, derived, fields, inState, input, invariant, invariants, isEntity as is, judge, judgeAgainst, judgeInput, judgedBy, page, readsBefore, refine, relate, restricting, rowFrom, isSameEntity as same, select, selectFor, selectionSchema, sets, states, unmapped, valuesFor, variantsOf };
|
|
463
465
|
|
|
464
466
|
//# sourceMappingURL=entity.js.map
|