foldkit-entity 0.13.0 → 0.15.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 +962 -512
- package/dist/collation.d.ts +33 -0
- package/dist/collation.d.ts.map +1 -0
- package/dist/collation.js +46 -0
- package/dist/collation.js.map +1 -0
- package/dist/conformance/index.d.ts +66 -0
- package/dist/conformance/index.d.ts.map +1 -0
- package/dist/conformance/{index.mjs → index.js} +22 -360
- package/dist/conformance/index.js.map +1 -0
- package/dist/conformance/operator.d.ts +115 -0
- package/dist/conformance/operator.d.ts.map +1 -0
- package/dist/conformance/operator.js +354 -0
- package/dist/conformance/operator.js.map +1 -0
- package/dist/conformance/relational.d.ts +240 -0
- package/dist/conformance/relational.d.ts.map +1 -0
- package/dist/conformance/relational.js +425 -0
- package/dist/conformance/relational.js.map +1 -0
- package/dist/conformance/tuples.d.ts +8 -0
- package/dist/conformance/tuples.d.ts.map +1 -0
- package/dist/conformance/tuples.js +43 -0
- package/dist/conformance/tuples.js.map +1 -0
- package/dist/conformance/variants.d.ts +47 -0
- package/dist/conformance/variants.d.ts.map +1 -0
- package/dist/conformance/variants.js +126 -0
- package/dist/conformance/variants.js.map +1 -0
- package/dist/context.d.ts +60 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +36 -0
- package/dist/context.js.map +1 -0
- package/dist/descriptor.d.ts +33 -0
- package/dist/descriptor.d.ts.map +1 -0
- package/dist/descriptor.js +137 -0
- package/dist/descriptor.js.map +1 -0
- package/dist/entity.d.ts +231 -0
- package/dist/entity.d.ts.map +1 -0
- package/dist/entity.js +435 -0
- package/dist/entity.js.map +1 -0
- package/dist/evaluate.d.ts +204 -0
- package/dist/evaluate.d.ts.map +1 -0
- package/dist/evaluate.js +765 -0
- package/dist/evaluate.js.map +1 -0
- package/dist/expr.d.ts +915 -0
- package/dist/expr.d.ts.map +1 -0
- package/dist/expr.js +1630 -0
- package/dist/expr.js.map +1 -0
- package/dist/held.d.ts +112 -0
- package/dist/held.d.ts.map +1 -0
- package/dist/held.js +155 -0
- package/dist/held.js.map +1 -0
- package/dist/ids.d.ts +8 -0
- package/dist/ids.d.ts.map +1 -0
- package/dist/ids.js +8 -0
- package/dist/ids.js.map +1 -0
- package/dist/index.d.ts +380 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/invariant.d.ts +123 -0
- package/dist/invariant.d.ts.map +1 -0
- package/dist/invariant.js +236 -0
- package/dist/invariant.js.map +1 -0
- package/dist/jsonSchema.d.ts +3 -0
- package/dist/jsonSchema.d.ts.map +1 -0
- package/dist/jsonSchema.js +17 -0
- package/dist/jsonSchema.js.map +1 -0
- package/dist/law.d.ts +264 -0
- package/dist/law.d.ts.map +1 -0
- package/dist/law.js +111 -0
- package/dist/law.js.map +1 -0
- package/dist/operators.d.ts +170 -0
- package/dist/operators.d.ts.map +1 -0
- package/dist/operators.js +207 -0
- package/dist/operators.js.map +1 -0
- package/dist/readFilter.d.ts +8 -0
- package/dist/readFilter.d.ts.map +1 -0
- package/dist/readFilter.js +23 -0
- package/dist/readFilter.js.map +1 -0
- package/dist/record.d.ts +11 -0
- package/dist/record.d.ts.map +1 -0
- package/dist/record.js +21 -0
- package/dist/record.js.map +1 -0
- package/dist/sets.d.ts +18 -0
- package/dist/sets.d.ts.map +1 -0
- package/dist/sets.js +57 -0
- package/dist/sets.js.map +1 -0
- package/dist/shape.d.ts +23 -0
- package/dist/shape.d.ts.map +1 -0
- package/dist/shape.js +30 -0
- package/dist/shape.js.map +1 -0
- package/dist/tested.d.ts +8 -0
- package/dist/tested.d.ts.map +1 -0
- package/dist/tested.js +25 -0
- package/dist/tested.js.map +1 -0
- package/dist/text.d.ts +27 -0
- package/dist/text.d.ts.map +1 -0
- package/dist/text.js +39 -0
- package/dist/text.js.map +1 -0
- package/dist/variants.d.ts +72 -0
- package/dist/variants.d.ts.map +1 -0
- package/dist/variants.js +76 -0
- package/dist/variants.js.map +1 -0
- package/dist/words.d.ts +17 -0
- package/dist/words.d.ts.map +1 -0
- package/dist/words.js +22 -0
- package/dist/words.js.map +1 -0
- package/dist/write.d.ts +312 -0
- package/dist/write.d.ts.map +1 -0
- package/dist/write.js +520 -0
- package/dist/write.js.map +1 -0
- package/package.json +8 -8
- package/dist/conformance/index.d.mts +0 -274
- package/dist/conformance/index.d.mts.map +0 -1
- package/dist/conformance/index.mjs.map +0 -1
- package/dist/index-hu8IYlNc.d.mts +0 -2228
- package/dist/index-hu8IYlNc.d.mts.map +0 -1
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +0 -1
- package/dist/src-DBAilaDV.mjs +0 -3061
- package/dist/src-DBAilaDV.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operator.js","names":[],"sources":["../../src/conformance/operator.ts"],"sourcesContent":["/**\n * An operator held to what it declares (expr-operations-DESIGN §10.4): its\n * laws tested against an implementation, and one set of calls run through\n * every implementation given, their answers and refusals compared.\n *\n * Cases are drawn from a fixed sample of each kind of value (text with the\n * empty string, mixed case, non-ASCII, an astral character and `like`'s\n * wildcards; numbers with zero, negatives and a fraction; both booleans), kept\n * where the operator's input schema and the law's domain decode them, and\n * chosen by a seeded shuffle when there are more than asked for, so a run is\n * repeatable.\n */\nimport { Data, Option, Schema, SchemaAST } from 'effect'\nimport {\n Collation,\n Evidence,\n Expr,\n Law,\n Operators,\n QueryEvaluateError,\n valueOfOperand,\n type LawDescription,\n type MemoryOperators,\n type Operandish,\n type Operator,\n type TestedEvidence,\n} from '../index.js'\nimport { stampRun, stampTested } from '../tested.js'\nimport { tuplesOf } from './tuples.js'\n\ntype AnyOperator = Operator<ReadonlyArray<Schema.Top>, Schema.Top>\n\n/** What an implementation said of one call: a value, or that it refused it. */\nexport type Outcome = Data.TaggedEnum<{\n Value: { readonly value: unknown }\n Refused: { readonly reason: string }\n}>\nexport const Outcome = Data.taggedEnum<Outcome>()\n\n/**\n * What `Conformance.laws` found: every law held, with the evidence; the first\n * case one did not; or a law no case of which both sides answered, which\n * shows nothing of it.\n */\nexport type LawsVerdict = Data.TaggedEnum<{\n Holds: { readonly evidence: ReadonlyArray<TestedEvidence> }\n Unanswered: {\n readonly law: LawDescription\n /** Why the first refused call was refused. */\n readonly reason: string\n }\n Counterexample: {\n readonly law: LawDescription\n readonly args: ReadonlyArray<unknown>\n /** The collation the calls were made under, for an operator that compares text. */\n readonly collation: Option.Option<Collation>\n readonly left: Outcome\n readonly right: Outcome\n }\n}>\nexport const LawsVerdict = Data.taggedEnum<LawsVerdict>()\n\n/**\n * One way to run a call: its value, or a throw for a call it refuses. A call\n * of a predicate answers its truth, unknown as `null`.\n */\nexport type Runner = (call: Operandish) => unknown\n\n/** A call the implementations did not agree on, with what each said. */\nexport interface Disagreement {\n readonly args: ReadonlyArray<unknown>\n readonly collation: Option.Option<Collation>\n readonly outcomes: Readonly<Record<string, Outcome>>\n}\n\nexport interface OperatorReport {\n /** How many calls ran, each through every implementation. */\n readonly cases: number\n readonly disagreements: ReadonlyArray<Disagreement>\n}\n\nconst NUL = String.fromCharCode(0)\n// 'B' sorts before 'a' by code point and after it folded: what tells the collations apart.\n// `%`, `_` and `\\` are what `like` reads as wildcards and its escape.\nconst texts = [\n '',\n 'a',\n 'A',\n 'ab',\n 'aB',\n 'b',\n 'B',\n 'é',\n 'É',\n String.fromCodePoint(0x1f600),\n '%',\n '_',\n '\\\\',\n]\nconst numbers = [-2, -1, 0, 1, 2, 7, 0.5, -0.5, 1e6]\nconst booleans = [true, false]\n\n/** The sample values of a stored kind, before any schema narrows them. */\nconst candidates = (ast: SchemaAST.AST): ReadonlyArray<unknown> => {\n if (SchemaAST.isString(ast) || SchemaAST.isTemplateLiteral(ast)) return texts\n if (SchemaAST.isNumber(ast)) return numbers\n if (SchemaAST.isBoolean(ast)) return booleans\n if (SchemaAST.isLiteral(ast)) return [ast.literal]\n if (SchemaAST.isUnion(ast)) return ast.types.flatMap(candidates)\n return []\n}\n\n/** Whether a stored value is one `schema` stores. */\nconst decodes = (schema: Schema.Top) => (value: unknown) =>\n Schema.is(Schema.toEncoded(schema))(value)\n\n/** The non-null samples every schema of `schemas` decodes, and the domain too when one is given. */\nconst samplesOf = (\n schemas: ReadonlyArray<Schema.Top>,\n domain: Option.Option<Schema.Top>,\n): ReadonlyArray<unknown> =>\n [...new Set(candidates(Schema.toEncoded(schemas[0]!).ast))].filter(\n value =>\n value !== null &&\n schemas.every(schema => decodes(schema)(value)) &&\n Option.match(domain, { onNone: () => true, onSome: within => decodes(within)(value) }),\n )\n\n/** A plain object: what JSON makes, and nothing whose data sits in a prototype. */\nconst isRecord = (value: unknown): value is Readonly<Record<string, unknown>> => {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return false\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n}\n\n/** A plain object's keys holding a value: one holding `undefined` is as absent, as JSON writes it. */\nconst keysOf = (record: Readonly<Record<string, unknown>>): ReadonlyArray<string> =>\n Object.keys(record).filter(key => record[key] !== undefined)\n\n/**\n * Two stored values alike, structurally. Not by their JSON, which writes\n * `Infinity` and `NaN` as `null`: a division by zero answering `Infinity` in\n * memory and null in SQL would read as agreeing. An object that is not plain\n * (its data in a prototype: a Date) is compared by its JSON, a Date's its time.\n */\nconst sameValue = (left: unknown, right: unknown): boolean => {\n if (typeof left === 'number' && typeof right === 'number') {\n return left === right || (Number.isNaN(left) && Number.isNaN(right))\n }\n if (Array.isArray(left) && Array.isArray(right)) {\n return left.length === right.length && left.every((each, i) => sameValue(each, right[i]))\n }\n if (isRecord(left) && isRecord(right)) {\n const keys = keysOf(left)\n return (\n keys.length === keysOf(right).length &&\n keys.every(key => Object.hasOwn(right, key) && sameValue(left[key], right[key]))\n )\n }\n if (typeof left === 'object' && left !== null && typeof right === 'object' && right !== null) {\n return JSON.stringify(left) === JSON.stringify(right)\n }\n return left === right\n}\n\n/** Two outcomes alike: equal values as stored, or both refusals. */\nconst same = (left: Outcome, right: Outcome): boolean =>\n left._tag === 'Refused' || right._tag === 'Refused'\n ? left._tag === right._tag\n : sameValue(left.value, right.value)\n\n/** Text by code point, as every interpreter's `binary` orders it; `<` compares UTF-16 units. */\nconst byCodePoint = (left: string, right: string): number => {\n const [a, b] = [[...left], [...right]]\n for (let i = 0; i < Math.min(a.length, b.length); i++) {\n const sign = a[i]!.codePointAt(0)! - b[i]!.codePointAt(0)!\n if (sign !== 0) return sign\n }\n return a.length - b.length\n}\n\n/** Two values of one kind in order: numbers, booleans, text by code point. */\nconst orderOf = (left: unknown, right: unknown): number =>\n typeof left === 'string' && typeof right === 'string'\n ? byCodePoint(left, right)\n : Number(left) - Number(right)\n\n/** A call of `op`, given `collation` when its rule takes one. */\nconst callOf = (\n op: AnyOperator,\n args: ReadonlyArray<unknown>,\n collation: Option.Option<Collation>,\n): Operandish =>\n Option.match(collation, {\n onNone: () => op(...args),\n onSome: each => op(...args, { collation: each }),\n })\n\n/** One side of an equation: a call to run (its text folded first, for a collation law), or a value. */\ntype Side = { readonly node: Operandish; readonly fold: boolean } | { readonly value: unknown }\n\n/** One equation for one tuple: its two sides, and what makes their outcomes keep the law. */\ninterface Plan {\n readonly args: ReadonlyArray<unknown>\n readonly collation: Option.Option<Collation>\n readonly left: Side\n readonly right: Side\n readonly holds: (left: Outcome, right: Outcome) => boolean\n}\n\n/** Each law `op` declares, with its equations: what `laws` and `lawsBy` evaluate. */\ninterface LawPlans {\n readonly law: LawDescription\n readonly plans: ReadonlyArray<Plan>\n}\n\nconst foldText = (value: unknown): unknown =>\n typeof value === 'string' ? Collation.foldAscii(value) : value\n\nconst nameOf = (op: AnyOperator): string =>\n op.descriptor.version === 1 ? op.descriptor.id : `${op.descriptor.id}@${op.descriptor.version}`\n\n/**\n * The equations of every law `op` declares, over up to `limit` tuples a law\n * chosen by `seed`. Nothing is run: a memory table and an SQL runner\n * evaluate the same plans.\n */\nconst lawPlans = (op: AnyOperator, limit: number, seed: number): ReadonlyArray<LawPlans> => {\n const { descriptor } = op\n const comparesText = (each: AnyOperator) => each.descriptor.collation !== 'none'\n // Each operator is called under a collation only where it compares text.\n const under = (each: AnyOperator, collation: Option.Option<Collation>) =>\n comparesText(each) ? collation : Option.none<Collation>()\n const run = (node: Operandish): Side => ({ node, fold: false })\n const value = (held: unknown): Side => ({ value: held })\n return descriptor.laws.map(law => {\n const shared = samplesOf(descriptor.input, law.domain)\n const tuples = (arity: number) =>\n tuplesOf(\n Array.from({ length: arity }, () => shared),\n limit,\n seed,\n )\n // The kernel compares text only under a collation, and literals bring none. An\n // implementation is told the collation, and may answer differently under each:\n // a pass under each where `op`, or a witness the law calls, compares text.\n const witnesses = Law.$match(law, {\n Inverse: ({ other }) => [other],\n Distributes: ({ over }) => [over],\n Associative: () => [],\n Commutative: () => [],\n Idempotent: () => [],\n Identity: () => [],\n Absorbing: () => [],\n Monotonic: () => [],\n PreservesCollation: () => [],\n })\n const collations = [op, ...witnesses].some(comparesText)\n ? [Option.some(Collation.binary), Option.some(Collation.asciiFold)]\n : [Option.none<Collation>()]\n const plans = collations.flatMap((collation): ReadonlyArray<Plan> => {\n const call = (...args: ReadonlyArray<unknown>) => callOf(op, args, under(op, collation))\n // A witness operator is called as `op` is: under the collation when it compares text.\n const witness = (other: AnyOperator, ...args: ReadonlyArray<unknown>) =>\n callOf(other, args, under(other, collation))\n const equal = (args: ReadonlyArray<unknown>, left: Side, right: Side): Plan => ({\n args,\n collation,\n left,\n right,\n holds: same,\n })\n const sided = (\n witness: unknown,\n side: 'left' | 'right' | 'both',\n answer: (a: unknown) => unknown,\n ) =>\n tuples(1).flatMap(([a]) => [\n ...(side === 'right'\n ? []\n : [equal([witness, a], run(call(witness, a)), value(answer(a)))]),\n ...(side === 'left'\n ? []\n : [equal([a, witness], run(call(a, witness)), value(answer(a)))]),\n ])\n return Law.$match(law, {\n Associative: () =>\n tuples(3).map(([a, b, c]) =>\n equal([a, b, c], run(call(call(a, b), c)), run(call(a, call(b, c)))),\n ),\n Commutative: () =>\n tuples(2).map(([a, b]) => equal([a, b], run(call(a, b)), run(call(b, a)))),\n Idempotent: () => tuples(1).map(([a]) => equal([a], run(call(a, a)), value(a))),\n Identity: ({ value: witness, side }) => sided(witness, side, a => a),\n Absorbing: ({ value: witness, side }) => sided(witness, side, () => witness),\n Inverse: ({ other, identity }) =>\n tuples(1).map(([a]) => equal([a], run(call(a, witness(other, a))), value(identity))),\n Distributes: ({ over }) =>\n tuples(3).map(([a, b, c]) =>\n equal(\n [a, b, c],\n run(call(a, witness(over, b, c))),\n run(witness(over, call(a, b), call(a, c))),\n ),\n ),\n Monotonic: ({ direction, position }) => {\n // Text in order as the collation orders it, folded under asciiFold.\n const under = (held: unknown) =>\n Option.exists(collation, each => each._tag === 'AsciiFold') ? foldText(held) : held\n const order = (left: unknown, right: unknown) => orderOf(under(left), under(right))\n const each = descriptor.input.map(schema => samplesOf([schema], law.domain))\n const pairs = each[position]!.flatMap(low =>\n each[position]!.filter(high => order(low, high) < 0).map(high => [low, high] as const),\n )\n const rest = each.filter((_, index) => index !== position)\n const sign = direction === 'increasing' ? 1 : -1\n return tuplesOf<unknown>([pairs, ...rest], limit, seed).map(([pair, ...others]) => {\n const [low, high] = pair as readonly [unknown, unknown]\n const at = (held: unknown) => {\n const args = [...others]\n args.splice(position, 0, held)\n return args\n }\n return {\n args: at(low),\n collation,\n left: run(call(...at(low))),\n right: run(call(...at(high))),\n // Equal outcomes agree, as under every other law: two refusals (no case),\n // and two equal infinities, whose difference `order` reads is NaN.\n holds: (left: Outcome, right: Outcome) =>\n same(left, right) ||\n (left._tag === 'Value' &&\n right._tag === 'Value' &&\n sign * order(left.value, right.value) <= 0),\n }\n })\n },\n // A law about the fold itself: its equations are made once, in the asciiFold pass.\n PreservesCollation: () =>\n Option.exists(collation, each => each._tag === 'AsciiFold')\n ? tuples(2).map(([a, b]) =>\n equal(\n [a, b],\n { node: call(a, b), fold: true },\n { node: call(foldText(a), foldText(b)), fold: true },\n ),\n )\n : [],\n })\n })\n if (plans.length === 0) {\n throw new Error(\n `[foldkit-entity] Conformance.laws: no sample of ${nameOf(op)}'s arguments is in ${Law.describe(law).kind}'s domain`,\n )\n }\n return { law: Law.describe(law), plans }\n })\n}\n\n/**\n * The verdict over laws whose calls' outcomes `answered` gives: the first\n * failure, or evidence of each. Two sides that both refuse agree, as a law\n * over values says nothing of a call neither answers, but they are no case of\n * it: a law is shown only by the cases whose sides both answer a value, and\n * one with none is `Unanswered`.\n */\nconst verdictOf = (\n op: AnyOperator,\n laws: ReadonlyArray<LawPlans>,\n answered: (node: Operandish) => Outcome,\n options: { readonly implementation: string; readonly seed: number },\n): LawsVerdict => {\n const outcomes = (side: Side): Outcome => {\n if ('value' in side) return Outcome.Value({ value: side.value })\n const outcome = answered(side.node)\n return side.fold\n ? Outcome.$match(outcome, {\n Value: ({ value }) => Outcome.Value({ value: foldText(value) }),\n Refused: refused => refused,\n })\n : outcome\n }\n const evidence: Array<TestedEvidence> = []\n for (const { law, plans } of laws) {\n let cases = 0\n let refusal = Option.none<string>()\n for (const plan of plans) {\n const left = outcomes(plan.left)\n const right = outcomes(plan.right)\n if (!plan.holds(left, right)) {\n return LawsVerdict.Counterexample({\n law,\n args: plan.args,\n collation: plan.collation,\n left,\n right,\n })\n }\n if (left._tag === 'Value' && right._tag === 'Value') cases += 1\n else if (Option.isNone(refusal) && left._tag === 'Refused') refusal = Option.some(left.reason)\n }\n if (cases === 0) {\n return LawsVerdict.Unanswered({\n law,\n reason: Option.getOrElse(refusal, () => 'no call was answered'),\n })\n }\n evidence.push(\n Evidence.Tested({\n operator: nameOf(op),\n law,\n implementation: options.implementation,\n cases,\n seed: options.seed,\n }),\n )\n }\n return LawsVerdict.Holds({ evidence })\n}\n\nexport const Conformance = {\n /** A runner of calls through a memory table: `Conformance.operator`'s for the in-memory interpreter. */\n memory:\n (operators: MemoryOperators): Runner =>\n call =>\n valueOfOperand(call, { operators }),\n\n /**\n * Tests every law `op` declares against `operators`' implementation of it,\n * up to `cases` tuples a law (200 by default), chosen by `seed` (0); a law\n * of both sides checks each tuple from each. Holds with a `Tested` record a\n * law, which `Operators.withEvidence` keeps; or the first case a law fails,\n * with both sides.\n */\n laws: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(\n op: Operator<In, Out>,\n operators: MemoryOperators,\n options: {\n readonly implementation?: string | undefined\n readonly cases?: number | undefined\n readonly seed?: number | undefined\n } = {},\n ): LawsVerdict => {\n const operator: AnyOperator = op\n const seed = options.seed ?? 0\n const outcome = (node: Operandish): Outcome => {\n try {\n return Outcome.Value({ value: valueOfOperand(node, { operators }) })\n } catch (error) {\n if (error instanceof QueryEvaluateError) return Outcome.Refused({ reason: error.message })\n throw error\n }\n }\n const verdict = verdictOf(operator, lawPlans(operator, options.cases ?? 200, seed), outcome, {\n implementation: options.implementation ?? 'memory',\n seed,\n })\n // Each record is of this table's implementations, its witnesses' too, which `withEvidence` checks.\n if (verdict._tag === 'Holds') verdict.evidence.forEach(record => stampTested(record, operators))\n return verdict\n },\n\n /**\n * As `laws`, each call run by `run` instead of a memory table: an SQL\n * implementation selected from a database, say, whose evidence a binding's\n * SQL table records. A throw is a refusal.\n */\n lawsBy: async <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(\n op: Operator<In, Out>,\n run: Runner,\n options: {\n readonly implementation: string\n readonly cases?: number | undefined\n readonly seed?: number | undefined\n },\n ): Promise<LawsVerdict> => {\n const operator: AnyOperator = op\n const seed = options.seed ?? 0\n const laws = lawPlans(operator, options.cases ?? 200, seed)\n const answers = new Map<Operandish, Outcome>()\n for (const { plans } of laws) {\n for (const side of plans.flatMap(plan => [plan.left, plan.right])) {\n if (!('node' in side) || answers.has(side.node)) continue\n try {\n answers.set(side.node, Outcome.Value({ value: await run(side.node) }))\n } catch (error) {\n answers.set(side.node, Outcome.Refused({ reason: String(error) }))\n }\n }\n }\n // Every call was run above, so each has its answer.\n const verdict = verdictOf(operator, laws, node => answers.get(node)!, {\n implementation: options.implementation,\n seed,\n })\n // Each record is a runner's, which an SQL table's `withEvidence` checks.\n if (verdict._tag === 'Holds') verdict.evidence.forEach(stampRun)\n return verdict\n },\n\n /**\n * Runs one set of calls of `op` through every implementation and compares\n * what each answered or refused. The calls are `cases` (argument tuples, as\n * stored), or generated: each argument a sample of its kind, null where its\n * schema admits one, and text holding NUL, under `binary` and `asciiFold` where the operator compares\n * text, up to `limit` (300) chosen by `seed` (0). A defined operator's\n * expansion is run beside the others, as `expansion`, by `expansionTable`\n * (the kernel's when not given).\n */\n operator: async <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(\n op: Operator<In, Out>,\n options: {\n readonly implementations: Readonly<Record<string, Runner>>\n readonly cases?: ReadonlyArray<ReadonlyArray<unknown>> | undefined\n readonly limit?: number | undefined\n readonly seed?: number | undefined\n readonly expansionTable?: MemoryOperators | undefined\n },\n ): Promise<OperatorReport> => {\n const operator: AnyOperator = op\n const { descriptor } = operator\n const runners: Record<string, Runner> = { ...options.implementations }\n if (Option.isSome(descriptor.definedAs)) {\n if (Object.hasOwn(runners, 'expansion')) {\n throw new Error(\n `[foldkit-entity] Conformance.operator: \"expansion\" names the expansion of ${nameOf(operator)}, which runs beside the implementations; name yours otherwise`,\n )\n }\n const table = options.expansionTable ?? Operators.kernel\n runners.expansion = call => valueOfOperand(Expr.expanded(call), { operators: table })\n }\n const generated = () =>\n tuplesOf(\n descriptor.input.map(schema => {\n const text = candidates(Schema.toEncoded(schema).ast).some(\n value => typeof value === 'string',\n )\n // Null only where the schema admits it: a call refuses a null literal otherwise.\n const nulls = decodes(schema)(null) ? [null] : []\n return [...nulls, ...samplesOf([schema], Option.none()), ...(text ? [`a${NUL}`] : [])]\n }),\n options.limit ?? 300,\n options.seed ?? 0,\n )\n const collations =\n descriptor.collation === 'none'\n ? [Option.none<Collation>()]\n : [Option.some(Collation.binary), Option.some(Collation.asciiFold)]\n const disagreements: Array<Disagreement> = []\n let cases = 0\n for (const args of options.cases ?? generated()) {\n for (const collation of collations) {\n cases += 1\n const call = callOf(operator, args, collation)\n // No prototype: an implementation named `__proto__` would set it, not a key.\n const outcomes: Record<string, Outcome> = Object.create(null)\n for (const [name, run] of Object.entries(runners)) {\n try {\n outcomes[name] = Outcome.Value({ value: await run(call) })\n } catch (error) {\n outcomes[name] = Outcome.Refused({ reason: String(error) })\n }\n }\n const [first, ...others] = Object.values(outcomes)\n if (first !== undefined && others.some(each => !same(first, each))) {\n disagreements.push({ args, collation, outcomes })\n }\n }\n }\n return { cases, disagreements }\n },\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqCA,MAAa,UAAU,KAAK,WAAoB;AAuBhD,MAAa,cAAc,KAAK,WAAwB;AAqBxD,MAAM,MAAM,OAAO,aAAa,CAAC;AAGjC,MAAM,QAAQ;CACZ;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,OAAO,cAAc,MAAO;CAC5B;CACA;CACA;AACF;AACA,MAAM,UAAU;CAAC;CAAI;CAAI;CAAG;CAAG;CAAG;CAAG;CAAK;CAAM;AAAG;AACnD,MAAM,WAAW,CAAC,MAAM,KAAK;;AAG7B,MAAM,cAAc,QAA+C;CACjE,IAAI,UAAU,SAAS,GAAG,KAAK,UAAU,kBAAkB,GAAG,GAAG,OAAO;CACxE,IAAI,UAAU,SAAS,GAAG,GAAG,OAAO;CACpC,IAAI,UAAU,UAAU,GAAG,GAAG,OAAO;CACrC,IAAI,UAAU,UAAU,GAAG,GAAG,OAAO,CAAC,IAAI,OAAO;CACjD,IAAI,UAAU,QAAQ,GAAG,GAAG,OAAO,IAAI,MAAM,QAAQ,UAAU;CAC/D,OAAO,CAAC;AACV;;AAGA,MAAM,WAAW,YAAwB,UACvC,OAAO,GAAG,OAAO,UAAU,MAAM,CAAC,CAAC,CAAC,KAAK;;AAG3C,MAAM,aACJ,SACA,WAEA,CAAC,GAAG,IAAI,IAAI,WAAW,OAAO,UAAU,QAAQ,EAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAC1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AAM,OAAO,OAAO,UAAU,MAAM,SAAS;GAE7C,MAAM,WAAoC,OAAO,OAAO,IAAI;GAC5D,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,OAAO,GAC9C,IAAI;IACF,SAAS,QAAQ,QAAQ,MAAM,EAAE,OAAO,MAAM,IAAI,IAAI,EAAE,CAAC;GAC3D,SAAS,OAAO;IACd,SAAS,QAAQ,QAAQ,QAAQ,EAAE,QAAQ,OAAO,KAAK,EAAE,CAAC;GAC5D;GAEF,MAAM,CAAC,OAAO,GAAG,UAAU,OAAO,OAAO,QAAQ;GACjD,IAAI,UAAU,KAAA,KAAa,OAAO,MAAK,SAAQ,CAAC,KAAK,OAAO,IAAI,CAAC,GAC/D,cAAc,KAAK;IAAE;IAAM;IAAW;GAAS,CAAC;EAEpD;EAEF,OAAO;GAAE;GAAO;EAAc;CAChC;AACF"}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import { AnyEntity, AnyQuery, Entity, EntityRef, ExprContext, HeldTable } from "../index.js";
|
|
3
|
+
/**
|
|
4
|
+
* A member is on a team or none; a badge is a member's; a pin is a team's.
|
|
5
|
+
* Stored as foreign keys named after each relation plus `_id`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Relational: {
|
|
8
|
+
readonly Team: Entity<"Team", {
|
|
9
|
+
readonly id: Schema.String;
|
|
10
|
+
readonly name: Schema.String;
|
|
11
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
12
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
13
|
+
}, import("../index.js").RelatedSpecs<{
|
|
14
|
+
readonly Team: Entity<"Team", {
|
|
15
|
+
readonly id: Schema.String;
|
|
16
|
+
readonly name: Schema.String;
|
|
17
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
18
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
19
|
+
}, {}, {}>;
|
|
20
|
+
readonly Member: Entity<"Member", {
|
|
21
|
+
readonly id: Schema.String;
|
|
22
|
+
readonly handle: Schema.String;
|
|
23
|
+
readonly rank: Schema.Number;
|
|
24
|
+
}, {}, {}>;
|
|
25
|
+
readonly Badge: Entity<"Badge", {
|
|
26
|
+
readonly id: Schema.String;
|
|
27
|
+
readonly kind: Schema.String;
|
|
28
|
+
}, {}, {}>;
|
|
29
|
+
readonly Pin: Entity<"Pin", {
|
|
30
|
+
readonly id: Schema.String;
|
|
31
|
+
readonly label: Schema.String;
|
|
32
|
+
}, {}, {}>;
|
|
33
|
+
}, {
|
|
34
|
+
readonly Member: {
|
|
35
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
36
|
+
readonly id: Schema.String;
|
|
37
|
+
readonly name: Schema.String;
|
|
38
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
39
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
40
|
+
}, {}, {}>, "one", true>;
|
|
41
|
+
};
|
|
42
|
+
readonly Badge: {
|
|
43
|
+
member: import("../index.js").RelationSpec<Entity<"Member", {
|
|
44
|
+
readonly id: Schema.String;
|
|
45
|
+
readonly handle: Schema.String;
|
|
46
|
+
readonly rank: Schema.Number;
|
|
47
|
+
}, {}, {}>, "one", false>;
|
|
48
|
+
};
|
|
49
|
+
readonly Pin: {
|
|
50
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
51
|
+
readonly id: Schema.String;
|
|
52
|
+
readonly name: Schema.String;
|
|
53
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
54
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
55
|
+
}, {}, {}>, "one", false>;
|
|
56
|
+
};
|
|
57
|
+
}, "Team">, {}>;
|
|
58
|
+
readonly Member: Entity<"Member", {
|
|
59
|
+
readonly id: Schema.String;
|
|
60
|
+
readonly handle: Schema.String;
|
|
61
|
+
readonly rank: Schema.Number;
|
|
62
|
+
}, import("../index.js").RelatedSpecs<{
|
|
63
|
+
readonly Team: Entity<"Team", {
|
|
64
|
+
readonly id: Schema.String;
|
|
65
|
+
readonly name: Schema.String;
|
|
66
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
67
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
68
|
+
}, {}, {}>;
|
|
69
|
+
readonly Member: Entity<"Member", {
|
|
70
|
+
readonly id: Schema.String;
|
|
71
|
+
readonly handle: Schema.String;
|
|
72
|
+
readonly rank: Schema.Number;
|
|
73
|
+
}, {}, {}>;
|
|
74
|
+
readonly Badge: Entity<"Badge", {
|
|
75
|
+
readonly id: Schema.String;
|
|
76
|
+
readonly kind: Schema.String;
|
|
77
|
+
}, {}, {}>;
|
|
78
|
+
readonly Pin: Entity<"Pin", {
|
|
79
|
+
readonly id: Schema.String;
|
|
80
|
+
readonly label: Schema.String;
|
|
81
|
+
}, {}, {}>;
|
|
82
|
+
}, {
|
|
83
|
+
readonly Member: {
|
|
84
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
85
|
+
readonly id: Schema.String;
|
|
86
|
+
readonly name: Schema.String;
|
|
87
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
88
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
89
|
+
}, {}, {}>, "one", true>;
|
|
90
|
+
};
|
|
91
|
+
readonly Badge: {
|
|
92
|
+
member: import("../index.js").RelationSpec<Entity<"Member", {
|
|
93
|
+
readonly id: Schema.String;
|
|
94
|
+
readonly handle: Schema.String;
|
|
95
|
+
readonly rank: Schema.Number;
|
|
96
|
+
}, {}, {}>, "one", false>;
|
|
97
|
+
};
|
|
98
|
+
readonly Pin: {
|
|
99
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
100
|
+
readonly id: Schema.String;
|
|
101
|
+
readonly name: Schema.String;
|
|
102
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
103
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
104
|
+
}, {}, {}>, "one", false>;
|
|
105
|
+
};
|
|
106
|
+
}, "Member">, {}>;
|
|
107
|
+
readonly Badge: Entity<"Badge", {
|
|
108
|
+
readonly id: Schema.String;
|
|
109
|
+
readonly kind: Schema.String;
|
|
110
|
+
}, import("../index.js").RelatedSpecs<{
|
|
111
|
+
readonly Team: Entity<"Team", {
|
|
112
|
+
readonly id: Schema.String;
|
|
113
|
+
readonly name: Schema.String;
|
|
114
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
115
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
116
|
+
}, {}, {}>;
|
|
117
|
+
readonly Member: Entity<"Member", {
|
|
118
|
+
readonly id: Schema.String;
|
|
119
|
+
readonly handle: Schema.String;
|
|
120
|
+
readonly rank: Schema.Number;
|
|
121
|
+
}, {}, {}>;
|
|
122
|
+
readonly Badge: Entity<"Badge", {
|
|
123
|
+
readonly id: Schema.String;
|
|
124
|
+
readonly kind: Schema.String;
|
|
125
|
+
}, {}, {}>;
|
|
126
|
+
readonly Pin: Entity<"Pin", {
|
|
127
|
+
readonly id: Schema.String;
|
|
128
|
+
readonly label: Schema.String;
|
|
129
|
+
}, {}, {}>;
|
|
130
|
+
}, {
|
|
131
|
+
readonly Member: {
|
|
132
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
133
|
+
readonly id: Schema.String;
|
|
134
|
+
readonly name: Schema.String;
|
|
135
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
136
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
137
|
+
}, {}, {}>, "one", true>;
|
|
138
|
+
};
|
|
139
|
+
readonly Badge: {
|
|
140
|
+
member: import("../index.js").RelationSpec<Entity<"Member", {
|
|
141
|
+
readonly id: Schema.String;
|
|
142
|
+
readonly handle: Schema.String;
|
|
143
|
+
readonly rank: Schema.Number;
|
|
144
|
+
}, {}, {}>, "one", false>;
|
|
145
|
+
};
|
|
146
|
+
readonly Pin: {
|
|
147
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
148
|
+
readonly id: Schema.String;
|
|
149
|
+
readonly name: Schema.String;
|
|
150
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
151
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
152
|
+
}, {}, {}>, "one", false>;
|
|
153
|
+
};
|
|
154
|
+
}, "Badge">, {}>;
|
|
155
|
+
readonly Pin: Entity<"Pin", {
|
|
156
|
+
readonly id: Schema.String;
|
|
157
|
+
readonly label: Schema.String;
|
|
158
|
+
}, import("../index.js").RelatedSpecs<{
|
|
159
|
+
readonly Team: Entity<"Team", {
|
|
160
|
+
readonly id: Schema.String;
|
|
161
|
+
readonly name: Schema.String;
|
|
162
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
163
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
164
|
+
}, {}, {}>;
|
|
165
|
+
readonly Member: Entity<"Member", {
|
|
166
|
+
readonly id: Schema.String;
|
|
167
|
+
readonly handle: Schema.String;
|
|
168
|
+
readonly rank: Schema.Number;
|
|
169
|
+
}, {}, {}>;
|
|
170
|
+
readonly Badge: Entity<"Badge", {
|
|
171
|
+
readonly id: Schema.String;
|
|
172
|
+
readonly kind: Schema.String;
|
|
173
|
+
}, {}, {}>;
|
|
174
|
+
readonly Pin: Entity<"Pin", {
|
|
175
|
+
readonly id: Schema.String;
|
|
176
|
+
readonly label: Schema.String;
|
|
177
|
+
}, {}, {}>;
|
|
178
|
+
}, {
|
|
179
|
+
readonly Member: {
|
|
180
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
181
|
+
readonly id: Schema.String;
|
|
182
|
+
readonly name: Schema.String;
|
|
183
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
184
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
185
|
+
}, {}, {}>, "one", true>;
|
|
186
|
+
};
|
|
187
|
+
readonly Badge: {
|
|
188
|
+
member: import("../index.js").RelationSpec<Entity<"Member", {
|
|
189
|
+
readonly id: Schema.String;
|
|
190
|
+
readonly handle: Schema.String;
|
|
191
|
+
readonly rank: Schema.Number;
|
|
192
|
+
}, {}, {}>, "one", false>;
|
|
193
|
+
};
|
|
194
|
+
readonly Pin: {
|
|
195
|
+
team: import("../index.js").RelationSpec<Entity<"Team", {
|
|
196
|
+
readonly id: Schema.String;
|
|
197
|
+
readonly name: Schema.String;
|
|
198
|
+
/** Null on purpose: a path reaching a row whose field is null. */
|
|
199
|
+
readonly region: Schema.NullOr<Schema.String>;
|
|
200
|
+
}, {}, {}>, "one", false>;
|
|
201
|
+
};
|
|
202
|
+
}, "Pin">, {}>;
|
|
203
|
+
};
|
|
204
|
+
/** A row as the suite writes one: fields, and each `one` relation as the id it points at. */
|
|
205
|
+
export type RelationalRow = Readonly<Record<string, string | number | null>>;
|
|
206
|
+
/** One Entity's rows: those the reader may see, and those its visibility rule hides. */
|
|
207
|
+
export interface RelationalTable {
|
|
208
|
+
readonly entity: AnyEntity;
|
|
209
|
+
readonly visible: ReadonlyArray<RelationalRow>;
|
|
210
|
+
/**
|
|
211
|
+
* Rows the reader may not see. SQL's rule hides a Team named `Hidden` and a
|
|
212
|
+
* Badge of kind `secret`; a holder never has them.
|
|
213
|
+
*/
|
|
214
|
+
readonly hidden: ReadonlyArray<RelationalRow>;
|
|
215
|
+
}
|
|
216
|
+
export declare const relationalTables: ReadonlyArray<RelationalTable>;
|
|
217
|
+
export interface RelationalCase {
|
|
218
|
+
readonly what: string;
|
|
219
|
+
readonly body: AnyQuery;
|
|
220
|
+
/** Encoded, as `ConformanceCase.input`. */
|
|
221
|
+
readonly input: Readonly<Record<string, unknown>>;
|
|
222
|
+
/** The ids of the visible rows the body matches, by id. */
|
|
223
|
+
readonly expected: ReadonlyArray<string>;
|
|
224
|
+
/** Who asks, or null for a visitor; a case that reads no viewer has none. */
|
|
225
|
+
readonly viewer?: EntityRef | null;
|
|
226
|
+
}
|
|
227
|
+
/** What a case's `Expr.viewer` reads: who asks, or a visitor where nobody does. */
|
|
228
|
+
export declare const relationalContext: (c: RelationalCase) => ExprContext;
|
|
229
|
+
export declare const relationalCases: ReadonlyArray<RelationalCase>;
|
|
230
|
+
/** The tables a holder has, from what the reader may see of each, and which rows it judges. */
|
|
231
|
+
export interface HeldWorld {
|
|
232
|
+
readonly what: string;
|
|
233
|
+
readonly tables: ReadonlyArray<HeldTable>;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* What a holder might have, first everything the reader may see. Each later
|
|
237
|
+
* one lacks something a case reads, so some judgement in it is unknown.
|
|
238
|
+
*/
|
|
239
|
+
export declare const heldWorlds: ReadonlyArray<HeldWorld>;
|
|
240
|
+
//# sourceMappingURL=relational.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relational.d.ts","names":[],"sources":["../../src/conformance/relational.ts"],"mappings":";;;;;;qBAuCa;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGC,4BAAI,aAAA;;;;;;;;MACL,8BAAM,aAAA;;;;;;;MACR,4BAAI,aAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAKH,gBAAgB,SAAS;;iBAGpB;WACN,QAAQ;WACR,SAAS,cAAc;;;;;WAKvB,QAAQ,cAAc;;qBAGpB,kBAAkB,cAAc;iBA2C5B;WACN;WACA,MAAM;;WAEN,OAAO,SAAS;;WAEhB,UAAU;;WAEV,SAAS;;;qBAIP,oBAAiB,GAAO,mBAAiB;qBAoBzC,iBAAiB,cAAc;;iBAmM3B;WACN;WACA,QAAQ,cAAc;;;;;;qBAmBpB,YAAY,cAAc"}
|