foldkit-entity 0.1.0 → 0.3.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 +256 -7
- package/dist/conformance/index.d.mts +46 -0
- package/dist/conformance/index.d.mts.map +1 -0
- package/dist/conformance/index.mjs +293 -0
- package/dist/conformance/index.mjs.map +1 -0
- package/dist/index.d.mts +344 -21
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +469 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/conformance/index.ts"],"sourcesContent":["/**\n * The conformance suite for a query body: what\n * [data-query-DESIGN §6.0.1](../../../docs/design/data-query-DESIGN.md) says\n * each operator means, as cases an interpreter can be run against.\n *\n * Exported rather than kept in this repository's tests, because the interpreter\n * most worth checking against it is one written elsewhere: run every case\n * through yours and compare the ids, in order, against `expected`.\n *\n * §18 names portable-kernel conformance as what the reference interpreter is\n * for. This is that, extracted: one set of cases, run against every interpreter\n * rather than each interpreter having its own tests that happen to agree.\n * `foldkit-remote-server` runs them over rows in memory;\n * `foldkit-remote-drizzle` compiles them to SQL and runs them against a real\n * SQLite. A body that means two things fails in whichever is wrong.\n *\n * The cases are chosen to make interpreters *disagree*, which is the only kind\n * that tests anything. A fixture whose values are all lowercase cannot tell a\n * case-sensitive `contains` from a case-insensitive one — that is not a\n * hypothetical, it is how `contains` reached a released package meaning three\n * different things.\n */\nimport { Schema, SchemaGetter } from 'effect'\nimport { Entity, Expr, Order, Query, type AnyQuery } from '../index.js'\n\n/**\n * A `Date` on the way in, an ISO string on the wire — the one fixture whose\n * **encoded form differs from its decoded form**.\n *\n * Every other column here encodes to itself, which is why the suite could not\n * previously see an interpreter comparing a decoded value against an encoded\n * row. That is not a hypothetical bug: a store holds wire values and decodes at\n * read, while a `QueryRef`'s input and a body's literals are written in domain\n * terms, so anything that runs a body over stored rows has to reconcile the two\n * and nothing was checking that it did.\n */\nconst Timestamp = Schema.Date.pipe(\n Schema.encodeTo(Schema.String, {\n decode: SchemaGetter.transform((iso: string) => new Date(iso)),\n encode: SchemaGetter.transform((at: Date) => at.toISOString()),\n }),\n)\n\n/** The one Entity every case reads, with a column of each kind that matters. */\nexport const Subject = Entity.define(\n 'Subject',\n Schema.Struct({\n id: Schema.String,\n /** Mixed case on purpose: a case-blind `contains` must be caught. */\n label: Schema.String,\n rank: Schema.Number,\n /** Nullable on purpose: three-valued logic has to be exercised. */\n tag: Schema.String,\n /** Encoded and decoded forms differ on purpose: see `Timestamp`. */\n at: Timestamp,\n }),\n)\n\n/**\n * How a row looks to an interpreter reading values, and to SQL as a table. The\n * index signature is what lets one be read by key without a cast, which is how\n * an interpreter over plain rows reads one.\n */\nexport interface ConformanceRow {\n readonly id: string\n readonly label: string\n readonly rank: number\n readonly tag: string | null\n /** The **encoded** form: what a store holds and an interpreter compares. */\n readonly at: string\n readonly [key: string]: unknown\n}\n\nexport const rows: ReadonlyArray<ConformanceRow> = [\n { id: 'a', label: 'Intro', rank: 2, tag: null, at: '2026-01-01T00:00:00.000Z' },\n { id: 'b', label: 'intro to sql', rank: 1, tag: 'x', at: '2026-01-02T00:00:00.000Z' },\n { id: 'c', label: 'Other', rank: 3, tag: null, at: '2026-01-02T00:00:00.000Z' },\n { id: 'd', label: '100% cotton', rank: 3, tag: 'x', at: '2026-01-03T00:00:00.000Z' },\n { id: 'e', label: 'snake_case', rank: 4, tag: 'y', at: '2026-01-04T00:00:00.000Z' },\n]\n\nexport interface ConformanceCase {\n /** What the case pins, as a sentence an interpreter fails by name. */\n readonly what: string\n readonly body: AnyQuery\n /**\n * The inputs, **encoded** — the space a store's rows are in, not the domain\n * space the body's types describe. For every column but `at` the two are the\n * same value, which is exactly why this has to be said rather than inferred\n * from the fixtures.\n */\n readonly input: Readonly<Record<string, unknown>>\n /** The ids the body matches, in the order it asks for. */\n readonly expected: ReadonlyArray<string>\n}\n\nconst from = Query.from(Subject)\nconst byId = Query.orderBy(Order.asc(Subject.fields.id))\nconst label = Expr.input('label', Schema.String)\nconst tag = Expr.input('tag', Schema.String)\nconst present = Expr.input('present', Schema.Boolean)\nconst at = Expr.input('at', Timestamp)\n\nexport const cases: ReadonlyArray<ConformanceCase> = [\n // ---- eq ------------------------------------------------------------------\n {\n what: 'eq matches a field against a literal',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.rank, 3)), byId),\n input: {},\n expected: ['c', 'd'],\n },\n {\n what: 'eq matches a field against the value the request supplies',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.label, label)), byId),\n input: { label: 'Other' },\n expected: ['c'],\n },\n {\n what: 'eq is exact: a value that differs only by case does not match',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.label, label)), byId),\n input: { label: 'other' },\n expected: [],\n },\n {\n what: 'eq against null matches nothing, not even the rows that are null',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.tag, tag)), byId),\n input: { tag: null },\n expected: [],\n },\n {\n what: 'eq against a value skips the rows whose column is null',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.tag, 'x')), byId),\n input: {},\n expected: ['b', 'd'],\n },\n\n // ---- isNull / isNotNull --------------------------------------------------\n {\n what: 'isNull finds exactly the rows with no value',\n body: from.pipe(Query.where(Expr.isNull(Subject.fields.tag)), byId),\n input: {},\n expected: ['a', 'c'],\n },\n {\n what: 'isNotNull finds exactly the rest',\n body: from.pipe(Query.where(Expr.isNotNull(Subject.fields.tag)), byId),\n input: {},\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a predicate compared to a true input is that predicate',\n body: from.pipe(Query.where(Expr.eq(Expr.isNotNull(Subject.fields.tag), present)), byId),\n input: { present: true },\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'a predicate compared to a false input is its negation',\n body: from.pipe(Query.where(Expr.eq(Expr.isNotNull(Subject.fields.tag), present)), byId),\n input: { present: false },\n expected: ['a', 'c'],\n },\n ...[true, false].map(value => ({\n what: `a ${value} input compared to a predicate works in reverse order`,\n body: from.pipe(Query.where(Expr.eq(present, Expr.isNotNull(Subject.fields.tag))), byId),\n input: { present: value },\n expected: value ? ['b', 'd', 'e'] : ['a', 'c'],\n })),\n ...[true, false].map(value => ({\n what: `an unknown equality compared to ${value} stays unknown`,\n body: from.pipe(Query.where(Expr.eq(Expr.eq(Subject.fields.tag, tag), present)), byId),\n input: { tag: null, present: value },\n expected: [],\n })),\n\n // ---- contains ------------------------------------------------------------\n {\n what: 'contains ignores case, which is stated rather than left to the backend',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: 'INTRO' },\n expected: ['a', 'b'],\n },\n {\n what: 'contains matches anywhere in the value, not only at the start',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: 'to sql' },\n expected: ['b'],\n },\n {\n what: 'containing the empty string is everything',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '' },\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n {\n what: 'a percent is searched for literally, not as a wildcard',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '%' },\n expected: ['d'],\n },\n {\n what: 'an underscore is searched for literally, not as a single-character wildcard',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: '_' },\n expected: ['e'],\n },\n {\n what: 'contains over a null column drops those rows, so it is not the same as no filter',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.tag, label)), byId),\n input: { label: '' },\n expected: ['b', 'd', 'e'],\n },\n {\n what: 'contains with a null search is unknown for every row',\n body: from.pipe(Query.where(Expr.contains(Subject.fields.label, label)), byId),\n input: { label: null },\n expected: [],\n },\n {\n what: 'an unknown containment compared to false stays unknown',\n body: from.pipe(Query.where(Expr.eq(Expr.contains(Subject.fields.label, label), false)), byId),\n input: { label: null },\n expected: [],\n },\n\n // ---- conjunction, which is the list rather than an operator ---------------\n {\n what: 'two predicates conjoin: every one must hold',\n body: from.pipe(\n Query.where(Expr.eq(Subject.fields.rank, 3), Expr.isNotNull(Subject.fields.tag)),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n {\n what: 'no predicate at all is every row',\n body: from.pipe(byId),\n input: {},\n expected: ['a', 'b', 'c', 'd', 'e'],\n },\n\n // ---- encoded values ------------------------------------------------------\n // The body's types say `Date`; a store's rows and a request's inputs are ISO\n // strings. An interpreter compares in the **encoded** space, and these are the\n // cases that say so — for every other column the two spaces hold the same\n // value, so nothing here could previously tell them apart.\n //\n // What happens when a caller passes a *decoded* value is deliberately not a\n // case, because the interpreters do not agree: the reference one matches\n // nothing, SQLite raises `datatype mismatch`, and a local engine does\n // whatever its own comparison does. `cases` are what interpreters must agree\n // about. The consequence is pinned in `packages/entity/test/encoding.test.ts`\n // instead, and it is the one that matters: **a runtime error cannot be relied\n // on to catch the mistake**, because one of the three answers is an empty\n // result that reads exactly like a correct one.\n {\n what: 'an input whose encoded form differs from its decoded one matches on the encoded one',\n body: from.pipe(Query.where(Expr.eq(Subject.fields.at, at)), byId),\n input: { at: '2026-01-02T00:00:00.000Z' },\n expected: ['b', 'c'],\n },\n {\n what: 'a literal is encoded too, or it has the same problem as an input',\n body: from.pipe(\n Query.where(Expr.eq(Subject.fields.at, '2026-01-03T00:00:00.000Z' as never)),\n byId,\n ),\n input: {},\n expected: ['d'],\n },\n\n // ---- ordering ------------------------------------------------------------\n {\n what: 'orders ascending by a number',\n body: from.pipe(Query.orderBy(Order.asc(Subject.fields.rank), Order.asc(Subject.fields.id))),\n input: {},\n expected: ['b', 'a', 'c', 'd', 'e'],\n },\n {\n what: 'orders descending, and a later term breaks the tie',\n body: from.pipe(Query.orderBy(Order.desc(Subject.fields.rank), Order.asc(Subject.fields.id))),\n input: {},\n expected: ['e', 'c', 'd', 'a', 'b'],\n },\n // Ordering by text is deliberately not here. How text compares is the\n // backend's — SQLite by code point, TanStack by locale, Postgres by whatever\n // the database was created with — and §6.0.1 puts it outside the conformant\n // subset rather than pretending one of them is the rule. A case asserting an\n // order would only pin whichever engine was written first.\n]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,YAAY,OAAO,KAAK,KAC5B,OAAO,SAAS,OAAO,QAAQ;CAC7B,QAAQ,aAAa,WAAW,QAAgB,IAAI,KAAK,GAAG,CAAC;CAC7D,QAAQ,aAAa,WAAW,OAAa,GAAG,YAAY,CAAC;AAC/D,CAAC,CACH;;AAGA,MAAa,UAAU,OAAO,OAC5B,WACA,OAAO,OAAO;CACZ,IAAI,OAAO;;CAEX,OAAO,OAAO;CACd,MAAM,OAAO;;CAEb,KAAK,OAAO;;CAEZ,IAAI;AACN,CAAC,CACH;AAiBA,MAAa,OAAsC;CACjD;EAAE,IAAI;EAAK,OAAO;EAAS,MAAM;EAAG,KAAK;EAAM,IAAI;CAA2B;CAC9E;EAAE,IAAI;EAAK,OAAO;EAAgB,MAAM;EAAG,KAAK;EAAK,IAAI;CAA2B;CACpF;EAAE,IAAI;EAAK,OAAO;EAAS,MAAM;EAAG,KAAK;EAAM,IAAI;CAA2B;CAC9E;EAAE,IAAI;EAAK,OAAO;EAAe,MAAM;EAAG,KAAK;EAAK,IAAI;CAA2B;CACnF;EAAE,IAAI;EAAK,OAAO;EAAc,MAAM;EAAG,KAAK;EAAK,IAAI;CAA2B;AACpF;AAiBA,MAAM,OAAO,MAAM,KAAK,OAAO;AAC/B,MAAM,OAAO,MAAM,QAAQ,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC;AACvD,MAAM,QAAQ,KAAK,MAAM,SAAS,OAAO,MAAM;AAC/C,MAAM,MAAM,KAAK,MAAM,OAAO,OAAO,MAAM;AAC3C,MAAM,UAAU,KAAK,MAAM,WAAW,OAAO,OAAO;AACpD,MAAM,KAAK,KAAK,MAAM,MAAM,SAAS;AAErC,MAAa,QAAwC;CAEnD;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,GA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K;EAAG;CACpC;CAgBA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,IAAI,EAAE,CAAC,GAAG,IAAI;EACjE,OAAO,EAAE,IAAI,2BAA2B;EACxC,UAAU,CAAC,KAAK,GAAG;CACrB;CACA;EACE,MAAM;EACN,MAAM,KAAK,KACT,MAAM,MAAM,KAAK,GAAG,QAAQ,OAAO,IAAI,0BAAmC,CAAC,GAC3E,IACF;EACA,OAAO,CAAC;EACR,UAAU,CAAC,GAAG;CAChB;CAGA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,QAAQ,MAAM,IAAI,QAAQ,OAAO,IAAI,GAAG,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC,CAAC;EAC3F,OAAO,CAAC;EACR,UAAU;GAAC;GAAK;GAAK;GAAK;GAAK;EAAG;CACpC;CACA;EACE,MAAM;EACN,MAAM,KAAK,KAAK,MAAM,QAAQ,MAAM,KAAK,QAAQ,OAAO,IAAI,GAAG,MAAM,IAAI,QAAQ,OAAO,EAAE,CAAC,CAAC;EAC5F,OAAO,CAAC;EACR,UAAU;GAAC;GAAK;GAAK;GAAK;GAAK;EAAG;CACpC;AAMF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,302 @@
|
|
|
1
1
|
import { Pipeable, Schema } from "effect";
|
|
2
2
|
import { Metadata } from "foldkit-metadata";
|
|
3
|
+
//#region src/expr.d.ts
|
|
4
|
+
/** A constant the query was written with. */
|
|
5
|
+
export interface LiteralExpr<T> {
|
|
6
|
+
readonly _tag: 'Literal';
|
|
7
|
+
readonly value: T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* One field of one Entity. `owner` is the Entity's identity rather than its
|
|
11
|
+
* name, so two Entities defined with the same name are not one column.
|
|
12
|
+
*/
|
|
13
|
+
export interface FieldExpr<T> {
|
|
14
|
+
readonly _tag: 'Field';
|
|
15
|
+
readonly owner: EntityIdentity<string>;
|
|
16
|
+
readonly key: string;
|
|
17
|
+
readonly schema: Schema.Codec<T, unknown>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A value the query is given when it runs. A definition's body is built once,
|
|
21
|
+
* so inside it an input is this placeholder and never the value: there is
|
|
22
|
+
* nothing yet to branch on, and a query that wants to depend on what was passed
|
|
23
|
+
* says so with an operation over the placeholder.
|
|
24
|
+
*/
|
|
25
|
+
export interface InputExpr<T> {
|
|
26
|
+
readonly _tag: 'Input';
|
|
27
|
+
readonly key: string;
|
|
28
|
+
readonly schema: Schema.Codec<T, unknown>;
|
|
29
|
+
}
|
|
30
|
+
/** A typed scalar: what a comparison compares. */
|
|
31
|
+
export type Expr<T> = LiteralExpr<T> | FieldExpr<T> | InputExpr<T>;
|
|
32
|
+
/** Any scalar, for the places that hold operands without caring what they are. */
|
|
33
|
+
export type AnyExpr = Expr<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* `Expr<boolean>`, in the shape the operations that exist can actually take.
|
|
36
|
+
* The design's kernel is all boolean-valued (`eq`, `and`, `isNull`,
|
|
37
|
+
* `contains`, …), so a predicate is its own type rather than a phantom
|
|
38
|
+
* parameter on a general operation node: `Predicate` and `Expr<string>` cannot
|
|
39
|
+
* then be confused, which a structural phantom would allow. A scalar-valued
|
|
40
|
+
* operation, if one is ever needed, joins `Expr` instead.
|
|
41
|
+
*/
|
|
42
|
+
export type Predicate = EqPredicate | NullPredicate | ContainsPredicate;
|
|
43
|
+
/** Two values are the same. */
|
|
44
|
+
export interface EqPredicate {
|
|
45
|
+
readonly _tag: 'Eq';
|
|
46
|
+
readonly left: Operandish;
|
|
47
|
+
readonly right: Operandish;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Whether a value is absent. `present` says which answer absence gives, so one
|
|
51
|
+
* node covers `is null` and `is not null` rather than two that differ by a
|
|
52
|
+
* negation nothing else can express.
|
|
53
|
+
*/
|
|
54
|
+
export interface NullPredicate {
|
|
55
|
+
readonly _tag: 'Null';
|
|
56
|
+
readonly operand: AnyExpr;
|
|
57
|
+
readonly present: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Whether a text value contains another. Containing the empty string is
|
|
61
|
+
* everything, which is what lets a search box with nothing typed in it be the
|
|
62
|
+
* same query as one with something — see `Expr.contains`.
|
|
63
|
+
*/
|
|
64
|
+
export interface ContainsPredicate {
|
|
65
|
+
readonly _tag: 'Contains';
|
|
66
|
+
readonly value: AnyExpr;
|
|
67
|
+
readonly search: Operandish;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Anything an operation can be given: a scalar, or a predicate where a boolean
|
|
71
|
+
* is wanted. `Expr.eq(Expr.isNotNull(archivedAt), input.archived)` is the
|
|
72
|
+
* second case, and it is how a query depends on an input without branching on
|
|
73
|
+
* it.
|
|
74
|
+
*/
|
|
75
|
+
export type Operandish = AnyExpr | Predicate;
|
|
76
|
+
/** A field, a scalar already built from one, or a predicate used as a boolean. */
|
|
77
|
+
type Operand<T> = EntityField<string, string, Schema.Constraint> | Expr<T> | Predicate;
|
|
78
|
+
/** What an operand is worth, so a comparison's other side is checked against it. */
|
|
79
|
+
export type ValueOf<E> = E extends EntityField<string, string, infer S> ? Schema.Schema.Type<S> : E extends Predicate ? boolean : E extends Expr<infer T> ? T : never;
|
|
80
|
+
/**
|
|
81
|
+
* A field or scalar whose value is text, or absent text.
|
|
82
|
+
*
|
|
83
|
+
* `Expr.contains` is a case-insensitive **text** search that compiles to
|
|
84
|
+
* `lower(column) like lower(?)`. Over a number that is nonsense which reaches
|
|
85
|
+
* the database — SQLite coerces and answers something, Postgres raises — so
|
|
86
|
+
* the operand is constrained here rather than discovered there.
|
|
87
|
+
*
|
|
88
|
+
* Null belongs in the type, because a nullable text column is a real and
|
|
89
|
+
* documented case: a null contains nothing, not even the empty string, so its
|
|
90
|
+
* rows drop out of a search that would otherwise match everything.
|
|
91
|
+
*
|
|
92
|
+
* Written as a **constraint on the type parameter** rather than as a check
|
|
93
|
+
* intersected onto the parameter (the `Invalid` idiom `foldkit-remote` uses for
|
|
94
|
+
* an unregistered descriptor). That idiom compares an already-resolved indexed
|
|
95
|
+
* access; here the check would be a conditional over the type being inferred,
|
|
96
|
+
* and inference falls back to the constraint — whose `Expr<any>` branch makes
|
|
97
|
+
* the check vacuously true, so every operand passes. A constraint cannot be
|
|
98
|
+
* defeated that way.
|
|
99
|
+
*/
|
|
100
|
+
export type TextOperand = EntityField<string, string, Schema.Constraint & Schema.Codec<string | null, any, any, any>> | Expr<string> | Expr<string | null>;
|
|
101
|
+
/** Whether a value is a predicate, and so usable where a boolean is wanted. */
|
|
102
|
+
export declare const isPredicate: (value: unknown) => value is Predicate;
|
|
103
|
+
/**
|
|
104
|
+
* Every operation the kernel has. An interpreter declares which of them it
|
|
105
|
+
* runs, and a body needing one it does not is refused rather than answered
|
|
106
|
+
* wrongly — see `Query.unsupported`.
|
|
107
|
+
*/
|
|
108
|
+
export type Operation = 'eq' | 'isNull' | 'isNotNull' | 'contains';
|
|
109
|
+
/** Which fields and inputs an expression reads, and which operations it uses. */
|
|
110
|
+
export interface Dependencies {
|
|
111
|
+
/** One entry per distinct field, as `Entity.key`. */
|
|
112
|
+
readonly fields: ReadonlyArray<{
|
|
113
|
+
readonly entity: string;
|
|
114
|
+
readonly key: string;
|
|
115
|
+
}>;
|
|
116
|
+
/** One entry per distinct input key. */
|
|
117
|
+
readonly inputs: ReadonlyArray<string>;
|
|
118
|
+
/** One entry per distinct operation, so an interpreter can refuse what it cannot run. */
|
|
119
|
+
readonly operations: ReadonlyArray<Operation>;
|
|
120
|
+
}
|
|
121
|
+
export declare const Expr: {
|
|
122
|
+
/** A constant. Comparisons coerce a plain value, so this is rarely written. */
|
|
123
|
+
literal: <T>(value: T) => LiteralExpr<T>;
|
|
124
|
+
/**
|
|
125
|
+
* A value the query is given when it runs. A definition builds these from its
|
|
126
|
+
* `Input` schema; written by hand only when constructing a body directly.
|
|
127
|
+
*/
|
|
128
|
+
input: <T>(key: string, schema: Schema.Codec<T, unknown>) => InputExpr<T>;
|
|
129
|
+
/** One field of one Entity, as a scalar. */
|
|
130
|
+
field: <Name extends string, Key extends string, S extends Schema.Constraint>(field: EntityField<Name, Key, S>) => FieldExpr<Schema.Schema.Type<S>>;
|
|
131
|
+
/**
|
|
132
|
+
* Two scalars are the same value. A field or a plain value on either side is
|
|
133
|
+
* coerced, so the common form reads as it means:
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
136
|
+
* Expr.eq(Post.fields.slug, input.slug)
|
|
137
|
+
* Expr.eq(Post.fields.status, 'active')
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
eq: <L extends Operand<any>>(left: L, right: ValueOf<L> | Expr<ValueOf<L>> | (boolean extends ValueOf<L> ? Predicate : never)) => EqPredicate;
|
|
141
|
+
/**
|
|
142
|
+
* Whether a field holds no value. Its opposite is `isNotNull`; both are the
|
|
143
|
+
* one node, because a query asks which of the two it means and nothing here
|
|
144
|
+
* can negate a predicate.
|
|
145
|
+
*/
|
|
146
|
+
isNull: <L extends Operand<any>>(operand: L) => NullPredicate;
|
|
147
|
+
/** Whether a field holds a value. */
|
|
148
|
+
isNotNull: <L extends Operand<any>>(operand: L) => NullPredicate;
|
|
149
|
+
/**
|
|
150
|
+
* Whether a text value contains `search`, anywhere in it. Containing the
|
|
151
|
+
* empty string is everything, so a search box with nothing typed in it is the
|
|
152
|
+
* same query as one with something — no branch, and no second query.
|
|
153
|
+
*
|
|
154
|
+
* **Case-insensitive**, which is what a search means, and which has to be
|
|
155
|
+
* said rather than left to the interpreter: SQLite's `like` ignores case and
|
|
156
|
+
* Postgres's does not, so a body that left it open would mean two things.
|
|
157
|
+
* Folding is ASCII-only, because that is what `lower` does in SQLite without
|
|
158
|
+
* ICU.
|
|
159
|
+
*
|
|
160
|
+
* **Over a column that can be null this is not the same as no filter.** A
|
|
161
|
+
* null contains nothing, not even the empty string, so its rows drop out. A
|
|
162
|
+
* nullable column that should match everything on an empty search says so:
|
|
163
|
+
* `Expr.or` does not exist yet, so for now such a column needs its own
|
|
164
|
+
* predicate or a native escape hatch.
|
|
165
|
+
*/
|
|
166
|
+
contains: <L extends TextOperand>(value: L, search: string | Expr<string>) => ContainsPredicate;
|
|
167
|
+
/** An expression as readable text; see `showExpr` for what it is and is not. */
|
|
168
|
+
show: (node: Operandish) => string;
|
|
169
|
+
};
|
|
170
|
+
/** One term of an ordering: a scalar and the direction to read it in. */
|
|
171
|
+
export interface OrderTerm {
|
|
172
|
+
readonly direction: 'asc' | 'desc';
|
|
173
|
+
readonly expr: AnyExpr;
|
|
174
|
+
}
|
|
175
|
+
export declare const Order: {
|
|
176
|
+
asc: <E extends Operand<any>>(expr: E) => OrderTerm;
|
|
177
|
+
desc: <E extends Operand<any>>(expr: E) => OrderTerm;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* What an expression reads and uses, for the planner and for an interpreter
|
|
181
|
+
* deciding whether it can run this query at all. Distinct entries only, in the
|
|
182
|
+
* order first seen, so the answer is stable enough to assert on.
|
|
183
|
+
*/
|
|
184
|
+
export declare const dependenciesOf: (...nodes: ReadonlyArray<AnyExpr | Predicate | OrderTerm>) => Dependencies;
|
|
185
|
+
/**
|
|
186
|
+
* Which rows a query is about, as a value: an Entity to read, the predicates
|
|
187
|
+
* every row must satisfy, and the order to read them in. It says nothing about
|
|
188
|
+
* which fields to return — that is a Selection — and nothing about pagination,
|
|
189
|
+
* liveness, or whether absence is an error, which belong to the consumer's read
|
|
190
|
+
* rather than to the relation.
|
|
191
|
+
*
|
|
192
|
+
* Composing one performs no work. `Query.from(Post)` names no table and opens
|
|
193
|
+
* no connection; an interpreter turns the value into a query when something
|
|
194
|
+
* asks it to.
|
|
195
|
+
*/
|
|
196
|
+
export interface Query<E extends AnyEntity> extends Pipeable.Pipeable {
|
|
197
|
+
readonly _tag: 'Query';
|
|
198
|
+
readonly entity: E;
|
|
199
|
+
/**
|
|
200
|
+
* Every predicate holds: the list *is* the conjunction. Keeping it a list
|
|
201
|
+
* rather than folding it into one `and` is what makes each `where` a reusable
|
|
202
|
+
* fragment, and it means no `Expr.and` exists until a query needs a
|
|
203
|
+
* conjunction nested inside something else.
|
|
204
|
+
*/
|
|
205
|
+
readonly where: ReadonlyArray<Predicate>;
|
|
206
|
+
/** In order of significance; a later `orderBy` appends less significant terms. */
|
|
207
|
+
readonly orderBy: ReadonlyArray<OrderTerm>;
|
|
208
|
+
}
|
|
209
|
+
/** A `Query` over any Entity, for the places that hold one without caring which. */
|
|
210
|
+
export type AnyQuery = Query<AnyEntity>;
|
|
211
|
+
export declare const Query: {
|
|
212
|
+
/** Every row of an Entity: the query each transformation narrows. */
|
|
213
|
+
from: <E extends AnyEntity>(entity: E) => Query<E>;
|
|
214
|
+
/**
|
|
215
|
+
* Narrows to the rows the predicate holds for. Two `where`s conjoin — the
|
|
216
|
+
* second never replaces the first — so a fragment can be written once and
|
|
217
|
+
* piped into any query over the same Entity:
|
|
218
|
+
*
|
|
219
|
+
* ```ts
|
|
220
|
+
* const published = Query.where(Expr.eq(Post.fields.published, true))
|
|
221
|
+
* Query.from(Post).pipe(published, Query.where(byTitle))
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
where: (...predicates: ReadonlyArray<Predicate>) => <E extends AnyEntity>(self: Query<E>) => Query<E>;
|
|
225
|
+
/**
|
|
226
|
+
* Reads the rows in this order. Two `orderBy`s append, so an earlier term
|
|
227
|
+
* stays the more significant one and a later call adds a tie-breaker rather
|
|
228
|
+
* than silently winning.
|
|
229
|
+
*/
|
|
230
|
+
orderBy: (...terms: ReadonlyArray<OrderTerm>) => <E extends AnyEntity>(self: Query<E>) => Query<E>;
|
|
231
|
+
/**
|
|
232
|
+
* What the whole query reads: the fields and inputs of every predicate and
|
|
233
|
+
* every ordering term, and the operations it uses.
|
|
234
|
+
*/
|
|
235
|
+
dependencies: (self: AnyQuery) => Dependencies;
|
|
236
|
+
/**
|
|
237
|
+
* The operations this query needs that `supported` does not list, in the
|
|
238
|
+
* order the query uses them. Empty means an interpreter declaring
|
|
239
|
+
* `supported` can answer it.
|
|
240
|
+
*
|
|
241
|
+
* An interpreter declares what it runs and refuses the rest, rather than
|
|
242
|
+
* ignoring an operation it does not implement — which would answer a
|
|
243
|
+
* different question and say nothing. The refusal is the interpreter's to
|
|
244
|
+
* raise: this only says what is missing, because what to do about it differs
|
|
245
|
+
* between one that compiles at registration and one that runs a body
|
|
246
|
+
* directly.
|
|
247
|
+
*
|
|
248
|
+
* ```ts
|
|
249
|
+
* const missing = Query.unsupported(body, ['eq', 'isNull', 'isNotNull'])
|
|
250
|
+
* if (missing.length > 0) throw new Error(`cannot run ${missing.join(', ')}`)
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
unsupported: (self: AnyQuery, supported: ReadonlyArray<Operation>) => ReadonlyArray<Operation>;
|
|
254
|
+
/**
|
|
255
|
+
* The whole query as readable text, one clause per line:
|
|
256
|
+
*
|
|
257
|
+
* ```text
|
|
258
|
+
* FROM Post
|
|
259
|
+
* WHERE Post.slug = $slug
|
|
260
|
+
* AND Post.published = true
|
|
261
|
+
* ORDER BY Post.updatedAt DESC
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* For an explanation or a diagnostic, never for an interpreter — see
|
|
265
|
+
* `Expr.show`. A query with no `where` or no `orderBy` omits that line rather
|
|
266
|
+
* than printing an empty one, so what is shown is what was written.
|
|
267
|
+
*/
|
|
268
|
+
show: (self: AnyQuery) => string;
|
|
269
|
+
};
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/evaluate.d.ts
|
|
272
|
+
/** A row as this interpreter reads one: values by field key. */
|
|
273
|
+
export type Row = Readonly<Record<string, unknown>>;
|
|
274
|
+
export declare class QueryEvaluateError extends Error {
|
|
275
|
+
constructor(message: string);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* The operations this interpreter runs. It is the reference, so this is the
|
|
279
|
+
* whole kernel — but it is declared rather than assumed, because an
|
|
280
|
+
* interpreter that gains an operator and forgets to say so is exactly what
|
|
281
|
+
* `Query.unsupported` exists to catch.
|
|
282
|
+
*/
|
|
283
|
+
export declare const supported: ReadonlyArray<Operation>;
|
|
284
|
+
/**
|
|
285
|
+
* Refuses a body needing an operation this interpreter does not run, rather
|
|
286
|
+
* than skipping it and answering a different question. Called by `evaluate`;
|
|
287
|
+
* call it directly to check a body once instead of on every run.
|
|
288
|
+
*/
|
|
289
|
+
export declare const assertSupported: (body: AnyQuery) => void;
|
|
290
|
+
/**
|
|
291
|
+
* The rows the body matches, in the order it asks for. Pure: it reads the rows
|
|
292
|
+
* it is given and nothing else.
|
|
293
|
+
*
|
|
294
|
+
* `input` holds the values this run was given, by the keys the body's
|
|
295
|
+
* placeholders were built with — the same record the query would be called
|
|
296
|
+
* with anywhere else.
|
|
297
|
+
*/
|
|
298
|
+
export declare const evaluate: (body: AnyQuery, input: Row, rows: ReadonlyArray<Row>) => ReadonlyArray<Row>;
|
|
299
|
+
//#endregion
|
|
3
300
|
//#region src/index.d.ts
|
|
4
301
|
export declare const EntityTypeId: unique symbol;
|
|
5
302
|
export type EntityTypeId = typeof EntityTypeId;
|
|
@@ -97,21 +394,41 @@ export type Related<Es extends Entities, Rs extends RelationMap<Es>, K extends k
|
|
|
97
394
|
type CheckRelations<Es extends Entities, Rs> = { readonly [K in keyof Rs]: K extends keyof Es ? { readonly [R in keyof Rs[K]]: R extends keyof Es[K]['members'] ? `"${R & string}" is already a member of ${Es[K]['name']}` : Rs[K][R]; } : 'not one of the entities being related'; };
|
|
98
395
|
export declare const SelectionTypeId: unique symbol;
|
|
99
396
|
export type SelectionTypeId = typeof SelectionTypeId;
|
|
100
|
-
/**
|
|
101
|
-
|
|
397
|
+
/**
|
|
398
|
+
* The schema that identifies one of an Entity: its `id` field when that is text
|
|
399
|
+
* (a plain string, a brand, a pattern), and plain text otherwise. An id is text
|
|
400
|
+
* because a ref travels and is stored as text; an Entity keyed by a number still
|
|
401
|
+
* has refs, and their ids are the number as text.
|
|
402
|
+
*/
|
|
403
|
+
export type IdSchemaOf<E> = E extends {
|
|
404
|
+
readonly fields: {
|
|
405
|
+
readonly id: {
|
|
406
|
+
readonly schema: infer S;
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
} ? S extends Schema.Constraint ? [S['Type']] extends [string] ? S : Schema.String : Schema.String : Schema.String;
|
|
410
|
+
/** What identifies one of an Entity: `IdOf<typeof Blog.Post>` is `PostId` when its `id` field is one. */
|
|
411
|
+
export type IdOf<E> = IdSchemaOf<E>['Type'];
|
|
412
|
+
/**
|
|
413
|
+
* What a relation selected with `true` yields: which Entity, and which one. `Id`
|
|
414
|
+
* is the target's own id type, so a ref to an Author cannot be used as a Post's.
|
|
415
|
+
*/
|
|
416
|
+
export interface EntityRef<Name extends string = string, Id extends string = string> {
|
|
102
417
|
readonly entity: Name;
|
|
103
|
-
readonly id:
|
|
418
|
+
readonly id: Id;
|
|
104
419
|
}
|
|
105
|
-
type RefSchema<
|
|
106
|
-
readonly entity: Schema.Literal<
|
|
107
|
-
readonly id:
|
|
420
|
+
type RefSchema<Target extends AnyEntity> = Schema.Struct<{
|
|
421
|
+
readonly entity: Schema.Literal<Target['name']>;
|
|
422
|
+
readonly id: IdSchemaOf<Target>;
|
|
108
423
|
}>;
|
|
109
424
|
/**
|
|
110
425
|
* A view of the Entity graph: which members to read, and the schema of the
|
|
111
426
|
* value that results. It says nothing about where the value comes from.
|
|
112
427
|
*/
|
|
113
|
-
export interface Selection<Name extends string, Members, S extends Schema.Constraint> {
|
|
428
|
+
export interface Selection<Name extends string, Members, S extends Schema.Constraint, Id extends string = string> {
|
|
114
429
|
readonly [SelectionTypeId]: SelectionTypeId;
|
|
430
|
+
/** Type-only: the id type of the Entity selected, so a reader can ask for the right one. Never set. */
|
|
431
|
+
readonly Id?: Id;
|
|
115
432
|
readonly entity: Entity<Name, any, any, any>;
|
|
116
433
|
/** What was selected, by member key: `true`, or a relation's nested Selection. */
|
|
117
434
|
readonly members: Members;
|
|
@@ -130,12 +447,6 @@ export interface PageWindow {
|
|
|
130
447
|
readonly after?: string | undefined;
|
|
131
448
|
readonly before?: string | undefined;
|
|
132
449
|
}
|
|
133
|
-
/** One page of a `many` relation: the items read, and whether more lie on either side. */
|
|
134
|
-
export interface Page<Item> {
|
|
135
|
-
readonly items: ReadonlyArray<Item>;
|
|
136
|
-
readonly hasNext: boolean;
|
|
137
|
-
readonly hasPrevious: boolean;
|
|
138
|
-
}
|
|
139
450
|
export declare const SelectionPageTypeId: unique symbol;
|
|
140
451
|
export type SelectionPageTypeId = typeof SelectionPageTypeId;
|
|
141
452
|
/** A Selection of a `many` relation's target, read a page at a time. */
|
|
@@ -151,7 +462,7 @@ type PageSchema<S extends Schema.Constraint> = Schema.Struct<{
|
|
|
151
462
|
}>;
|
|
152
463
|
type SelectionSpec<E extends AnyEntity, Spec> = { readonly [K in keyof Spec]: K extends keyof E['relations'] ? E['relations'][K] extends EntityRelation<any, any, infer Target, infer C, any> ? true | AnySelection<Target['name']> | (C extends 'many' ? SelectionPage<Target['name'], any> : never) : never : K extends keyof E['members'] ? true : `"${K & string}" is not a member of ${E['name']}`; };
|
|
153
464
|
type RelationShape<C extends Cardinality, Optional extends boolean, S extends Schema.Constraint> = C extends 'many' ? Schema.$Array<S> : Optional extends true ? Schema.NullOr<S> : S;
|
|
154
|
-
type SelectedSchema<Member, Selected> = Member extends EntityField<any, any, infer S> | EntityDerived<any, any, infer S> ? S : Member extends EntityRelation<any, any, infer Target, infer C, infer Optional> ? Selected extends SelectionPage<any, infer S> ? PageSchema<S> : RelationShape<C, Optional, Selected extends Selection<any, any, infer S> ? S : RefSchema<Target
|
|
465
|
+
type SelectedSchema<Member, Selected> = Member extends EntityField<any, any, infer S> | EntityDerived<any, any, infer S> ? S : Member extends EntityRelation<any, any, infer Target, infer C, infer Optional> ? Selected extends SelectionPage<any, infer S> ? PageSchema<S> : RelationShape<C, Optional, Selected extends Selection<any, any, infer S> ? S : RefSchema<Target>> : never;
|
|
155
466
|
type SelectionSchema<E extends AnyEntity, Spec> = Schema.Struct<{ readonly [K in keyof Spec & keyof E['members']]: SelectedSchema<E['members'][K], Spec[K]>; }>;
|
|
156
467
|
/** An input key that carries a relation's target: the id of a `one`, the ids of a `many`. */
|
|
157
468
|
export interface RelationInput<R extends EntityRelation<any, any, any, any, any>> {
|
|
@@ -175,7 +486,7 @@ export interface Unmapped {
|
|
|
175
486
|
/** What one key of an operation's input means in terms of the Entity. */
|
|
176
487
|
export type InputMember = EntityField<string, string, Schema.Constraint> | RelationInput<EntityRelation<string, string, AnyEntity, Cardinality, boolean>> | NestedInput<EntityRelation<string, string, AnyEntity, Cardinality, boolean>, EntityInput<AnyEntity, any, any>> | Unmapped;
|
|
177
488
|
/** The ids a relation takes as input: one id, a nullable id, or a list of ids. */
|
|
178
|
-
type RelationIds<R> = R extends EntityRelation<any, any,
|
|
489
|
+
type RelationIds<R> = R extends EntityRelation<any, any, infer Target, infer C, infer Optional> ? C extends 'many' ? ReadonlyArray<IdOf<Target>> : Optional extends true ? IdOf<Target> | null : IdOf<Target> : never;
|
|
179
490
|
/** What a nested input takes: the value of the target's input, or a list of them for a `many`. */
|
|
180
491
|
type NestedValues<R, I> = I extends EntityInput<any, infer Fields, any> ? R extends EntityRelation<any, any, any, 'many', any> ? ReadonlyArray<Schema.Struct.Type<Fields>> : Schema.Struct.Type<Fields> : never;
|
|
181
492
|
/**
|
|
@@ -187,8 +498,14 @@ type Present<T> = Exclude<T, null | undefined>;
|
|
|
187
498
|
type MappingFor<Name extends string, Input, M> = M extends Unmapped ? M : M extends EntityField<infer Owner, any, any> | RelationInput<EntityRelation<infer Owner, any, any, any, any>> | NestedInput<EntityRelation<infer Owner, any, any, any, any>, any> ? [Owner] extends [Name] ? M extends EntityField<any, any, infer S> ? Present<Input> extends Schema.Schema.Type<S> ? M : 'the input value does not fit this field' : M extends RelationInput<infer R> ? Present<Input> extends RelationIds<R> ? M : 'the input value is not the id shape of this relation' : M extends NestedInput<infer R, infer I> ? R extends EntityRelation<any, any, infer Target, any, any> ? I extends EntityInput<infer Of, any, any> ? [Of['name']] extends [Target['name']] ? Present<Input> extends NestedValues<R, I> ? M : 'the input value is not the value of the nested input' : `the nested input is of ${Of['name']}, not ${Target['name']}` : never : never : never : `this member belongs to ${Owner}` : 'map an input key to a Field, Relation.input(relation), Relation.nested(relation, input), or Entity.unmapped';
|
|
188
499
|
/** A key that names a field whose value it fits maps itself; every other key needs an entry. */
|
|
189
500
|
type SelfMapped<E extends AnyEntity, Fields extends Schema.Struct.Fields> = { [K in keyof Fields]: K extends keyof E['fields'] ? Present<Schema.Schema.Type<Fields[K]>> extends Schema.Schema.Type<E['fields'][K]['schema']> ? K : never : never; }[keyof Fields];
|
|
190
|
-
|
|
191
|
-
|
|
501
|
+
/**
|
|
502
|
+
* A mapping written as a member's key: `'title'` is that Field, and `'author'` is
|
|
503
|
+
* `Relation.input` of that relation. Nothing is inferred from the input key's own
|
|
504
|
+
* name; the member is still named, only more briefly.
|
|
505
|
+
*/
|
|
506
|
+
type Named<E extends AnyEntity, M> = M extends string ? M extends keyof E['fields'] ? E['fields'][M] : M extends keyof E['relations'] ? RelationInput<E['relations'][M]> : `"${M}" names no field or relation of ${E['name']}` : M;
|
|
507
|
+
type InputMapping<E extends AnyEntity, Fields extends Schema.Struct.Fields, Mapping> = { readonly [K in Exclude<keyof Fields, SelfMapped<E, Fields>>]: unknown; } & { readonly [K in keyof Mapping]: K extends keyof Fields ? Named<E, Mapping[K]> extends (infer Member) ? Member extends string ? Member : MappingFor<E['name'], Schema.Schema.Type<Fields[K]>, Member> extends Member ? Mapping[K] : MappingFor<E['name'], Schema.Schema.Type<Fields[K]>, Member> : never : `"${K & string}" is not a key of the input`; };
|
|
508
|
+
type InputMembers<E extends AnyEntity, Fields extends Schema.Struct.Fields, Mapping> = { readonly [K in keyof Fields]: K extends keyof Mapping ? Named<E, Mapping[K]> : K extends keyof E['fields'] ? E['fields'][K] : never; };
|
|
192
509
|
/**
|
|
193
510
|
* An operation's input read against an Entity: which member each input key
|
|
194
511
|
* writes. The operation decides what may be submitted; the Entity only says
|
|
@@ -220,11 +537,11 @@ export declare const Entity: {
|
|
|
220
537
|
* target, that Selection's value. `many` yields an array, an optional `one`
|
|
221
538
|
* is nullable.
|
|
222
539
|
*/
|
|
223
|
-
select: <E extends AnyEntity, const Spec>(entity: E, spec: Spec & SelectionSpec<E, Spec>) => Selection<E["name"], Spec, SelectionSchema<E, Spec>>;
|
|
540
|
+
select: <E extends AnyEntity, const Spec>(entity: E, spec: Spec & SelectionSpec<E, Spec>) => Selection<E["name"], Spec, SelectionSchema<E, Spec>, IdOf<E>>;
|
|
224
541
|
/**
|
|
225
542
|
* A `many` relation read a page at a time, in place of its Selection:
|
|
226
|
-
* `comments: Entity.page(CommentSummary, { first: 10 })`. The value is a
|
|
227
|
-
* of the Selection's values
|
|
543
|
+
* `comments: Entity.page(CommentSummary, { first: 10 })`. The value is a page
|
|
544
|
+
* of the Selection's values: `items`, `hasNext`, `hasPrevious`. Reading on from a cursor is another window.
|
|
228
545
|
*/
|
|
229
546
|
page: <Name extends string, S extends Schema.Constraint>(selection: Selection<Name, any, S>, window: PageWindow) => SelectionPage<Name, S>;
|
|
230
547
|
/** Adds readable members that are not part of `entity.schema`. */
|
|
@@ -242,11 +559,17 @@ export declare const Entity: {
|
|
|
242
559
|
input: <E extends AnyEntity, Fields extends Schema.Struct.Fields, const Mapping = {}>(entity: E, schema: Schema.Struct<Fields>, ...mapping: keyof InputMapping<E, Fields, Mapping> extends never ? [mapping?: Mapping & InputMapping<E, Fields, Mapping>] : [mapping: Mapping & InputMapping<E, Fields, Mapping>]) => EntityInput<E, Fields, InputMembers<E, Fields, Mapping>>;
|
|
243
560
|
/** For an input key that is about the operation rather than the Entity. */
|
|
244
561
|
unmapped: Unmapped;
|
|
562
|
+
/**
|
|
563
|
+
* The schemas of some of an Entity's fields, by key, to spread into an input's
|
|
564
|
+
* struct: `Schema.Struct({ ...Entity.fields(Post, 'id', 'title'), editorId: ... })`.
|
|
565
|
+
* The input then keeps the field's own rules, and its keys map themselves.
|
|
566
|
+
*/
|
|
567
|
+
fields: <E extends AnyEntity, const Keys extends ReadonlyArray<keyof E["fields"] & string>>(entity: E, ...keys: Keys) => { readonly [K in Keys[number]]: E["fields"][K]["schema"]; };
|
|
245
568
|
/**
|
|
246
569
|
* The Selection of every member an input writes, with each relation as refs:
|
|
247
570
|
* what an edit screen loads before it shows the input's current values.
|
|
248
571
|
*/
|
|
249
|
-
selectFor: <E extends AnyEntity, Fields extends Schema.Struct.Fields, Members>(input: EntityInput<E, Fields, Members>) => Selection<E["name"], WrittenSpec<Members>, SelectionSchema<E, WrittenSpec<Members
|
|
572
|
+
selectFor: <E extends AnyEntity, Fields extends Schema.Struct.Fields, Members>(input: EntityInput<E, Fields, Members>) => Selection<E["name"], WrittenSpec<Members>, SelectionSchema<E, WrittenSpec<Members>>, IdOf<E>>;
|
|
250
573
|
/**
|
|
251
574
|
* The input values that reproduce `value`, a value read through `selectFor`
|
|
252
575
|
* (or any Selection with those members): a field as it is, a relation as the
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/expr.ts","../src/evaluate.ts","../src/index.ts"],"mappings":";;;;iBAiBiB,YAAY;WAClB;WACA,OAAO;;;;;;iBAOD,UAAU;WAChB;WACA,OAAO;WACP;WACA,QAAQ,OAAO,MAAM;;;;;;;;iBASf,UAAU;WAChB;WACA;WACA,QAAQ,OAAO,MAAM;;;YAIpB,KAAK,KAAK,YAAY,KAAK,UAAU,KAAK,UAAU;;YAGpD,UAAU;;;;;;;;;YAUV,YAAY,cAAc,gBAAgB;;iBAGrC;WACN;WACA,MAAM;WACN,OAAO;;;;;;;iBAQD;WACN;WACA,SAAS;WACT;;;;;;;iBAQ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