foldkit-entity 0.14.0 → 0.16.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.
Files changed (93) hide show
  1. package/README.md +147 -5
  2. package/dist/collation.d.ts +33 -2
  3. package/dist/collation.d.ts.map +1 -0
  4. package/dist/conformance/index.d.ts +4 -4
  5. package/dist/conformance/index.d.ts.map +1 -1
  6. package/dist/conformance/index.js +5 -7
  7. package/dist/conformance/index.js.map +1 -1
  8. package/dist/conformance/operator.d.ts +1 -2
  9. package/dist/conformance/operator.d.ts.map +1 -1
  10. package/dist/conformance/operator.js +2 -6
  11. package/dist/conformance/operator.js.map +1 -1
  12. package/dist/conformance/relational.d.ts +17 -17
  13. package/dist/conformance/relational.d.ts.map +1 -1
  14. package/dist/conformance/relational.js +1 -3
  15. package/dist/conformance/relational.js.map +1 -1
  16. package/dist/conformance/variants.d.ts +47 -0
  17. package/dist/conformance/variants.d.ts.map +1 -0
  18. package/dist/conformance/variants.js +126 -0
  19. package/dist/conformance/variants.js.map +1 -0
  20. package/dist/context.d.ts +60 -2
  21. package/dist/context.d.ts.map +1 -0
  22. package/dist/descriptor.d.ts +33 -0
  23. package/dist/descriptor.d.ts.map +1 -0
  24. package/dist/descriptor.js +137 -0
  25. package/dist/descriptor.js.map +1 -0
  26. package/dist/entity.d.ts +231 -0
  27. package/dist/entity.d.ts.map +1 -0
  28. package/dist/entity.js +436 -0
  29. package/dist/entity.js.map +1 -0
  30. package/dist/evaluate.d.ts +204 -2
  31. package/dist/evaluate.d.ts.map +1 -0
  32. package/dist/evaluate.js +51 -7
  33. package/dist/evaluate.js.map +1 -1
  34. package/dist/expr.d.ts +915 -2
  35. package/dist/expr.d.ts.map +1 -0
  36. package/dist/expr.js +50 -10
  37. package/dist/expr.js.map +1 -1
  38. package/dist/held.d.ts +112 -2
  39. package/dist/held.d.ts.map +1 -0
  40. package/dist/held.js +13 -2
  41. package/dist/held.js.map +1 -1
  42. package/dist/ids.d.ts +8 -0
  43. package/dist/ids.d.ts.map +1 -0
  44. package/dist/ids.js +8 -0
  45. package/dist/ids.js.map +1 -0
  46. package/dist/index.d.ts +400 -6
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +113 -12
  49. package/dist/index.js.map +1 -0
  50. package/dist/invariant.d.ts +123 -2
  51. package/dist/invariant.d.ts.map +1 -0
  52. package/dist/invariant.js +236 -1
  53. package/dist/invariant.js.map +1 -0
  54. package/dist/law.d.ts +264 -2
  55. package/dist/law.d.ts.map +1 -0
  56. package/dist/law.js +1 -1
  57. package/dist/operators.d.ts +170 -2
  58. package/dist/operators.d.ts.map +1 -0
  59. package/dist/operators.js +3 -3
  60. package/dist/readFilter.d.ts +8 -2
  61. package/dist/readFilter.d.ts.map +1 -0
  62. package/dist/sets.d.ts +18 -2
  63. package/dist/sets.d.ts.map +1 -0
  64. package/dist/sets.js +1 -1
  65. package/dist/shape.d.ts +23 -2
  66. package/dist/shape.d.ts.map +1 -0
  67. package/dist/tested.d.ts +8 -2
  68. package/dist/tested.d.ts.map +1 -0
  69. package/dist/text.d.ts +27 -2
  70. package/dist/text.d.ts.map +1 -0
  71. package/dist/text.js +1 -1
  72. package/dist/variants.d.ts +72 -0
  73. package/dist/variants.d.ts.map +1 -0
  74. package/dist/variants.js +76 -0
  75. package/dist/variants.js.map +1 -0
  76. package/dist/words.d.ts +17 -2
  77. package/dist/words.d.ts.map +1 -0
  78. package/dist/write.d.ts +312 -2
  79. package/dist/write.d.ts.map +1 -0
  80. package/dist/write.js +3 -3
  81. package/package.json +3 -3
  82. package/dist/collation-BB4YTIbY.d.ts +0 -34
  83. package/dist/collation-BB4YTIbY.d.ts.map +0 -1
  84. package/dist/index-48JeXG0A.d.ts +0 -2585
  85. package/dist/index-48JeXG0A.d.ts.map +0 -1
  86. package/dist/readFilter-CWMnFRVw.d.ts +0 -9
  87. package/dist/readFilter-CWMnFRVw.d.ts.map +0 -1
  88. package/dist/shape-LAowRf9f.d.ts +0 -23
  89. package/dist/shape-LAowRf9f.d.ts.map +0 -1
  90. package/dist/src-DKhUqLoC.js +0 -731
  91. package/dist/src-DKhUqLoC.js.map +0 -1
  92. package/dist/words-a4e9o-TK.d.ts +0 -18
  93. package/dist/words-a4e9o-TK.d.ts.map +0 -1
package/dist/law.d.ts CHANGED
@@ -1,2 +1,264 @@
1
- import { _r as Side, gr as LawDescription, hr as Law } from "./index-48JeXG0A.js";
2
- export { Law, LawDescription, Side };
1
+ import { Data, Option, Schema } from "effect";
2
+ import { Operator } from "./expr.js";
3
+ /** An operator a law names as a witness: the inverse, or the operator distributed over. */
4
+ type AnyOperator = Operator<ReadonlyArray<Schema.Top>, Schema.Top>;
5
+ /** Which argument a witness stands in. */
6
+ export type Side = 'left' | 'right' | 'both';
7
+ /**
8
+ * A law, over its domain: by default every non-null value of the operator's
9
+ * input schemas; narrowed by `Law.within`.
10
+ */
11
+ export type Law = Data.TaggedEnum<{
12
+ /** `op(op(a, b), c) = op(a, op(b, c))` */
13
+ Associative: {
14
+ readonly domain: Option.Option<Schema.Top>;
15
+ };
16
+ /** `op(a, b) = op(b, a)` */
17
+ Commutative: {
18
+ readonly domain: Option.Option<Schema.Top>;
19
+ };
20
+ /** `op(a, a) = a` */
21
+ Idempotent: {
22
+ readonly domain: Option.Option<Schema.Top>;
23
+ };
24
+ /** `op(e, a) = a` (left), `op(a, e) = a` (right), or both. */
25
+ Identity: {
26
+ readonly domain: Option.Option<Schema.Top>;
27
+ readonly value: unknown;
28
+ readonly side: Side;
29
+ };
30
+ /** `op(z, a) = z` (left), `op(a, z) = z` (right), or both. */
31
+ Absorbing: {
32
+ readonly domain: Option.Option<Schema.Top>;
33
+ readonly value: unknown;
34
+ readonly side: Side;
35
+ };
36
+ /** `op(a, other(a)) = identity` */
37
+ Inverse: {
38
+ readonly domain: Option.Option<Schema.Top>;
39
+ readonly other: AnyOperator;
40
+ readonly identity: unknown;
41
+ };
42
+ /** `op(a, over(b, c)) = over(op(a, b), op(a, c))` */
43
+ Distributes: {
44
+ readonly domain: Option.Option<Schema.Top>;
45
+ readonly over: AnyOperator;
46
+ };
47
+ /** `a ≤ b` at `position` implies `op(…a…) ≤ op(…b…)`, or `≥` when decreasing. */
48
+ Monotonic: {
49
+ readonly domain: Option.Option<Schema.Top>;
50
+ readonly direction: 'increasing' | 'decreasing';
51
+ readonly position: number;
52
+ };
53
+ /** Folding the result equals folding the arguments first: its text keeps their collation (§7). */
54
+ PreservesCollation: {
55
+ readonly domain: Option.Option<Schema.Top>;
56
+ };
57
+ }>;
58
+ /**
59
+ * A law as JSON says it: what `Operators.describe` lists and evidence names.
60
+ * Its witnesses are values as stored and operators by name; its domain is a
61
+ * JSON Schema, or `null` for the operator's whole input.
62
+ */
63
+ export declare const LawDescription: Schema.Struct<{
64
+ readonly kind: Schema.String;
65
+ readonly witnesses: Schema.$Record<Schema.String, Schema.Unknown>;
66
+ readonly domain: Schema.Unknown;
67
+ }>;
68
+ export type LawDescription = typeof LawDescription.Type;
69
+ export declare const Law: {
70
+ associative: {
71
+ readonly _tag: "Associative";
72
+ readonly domain: Option.Option<Schema.Top>;
73
+ };
74
+ commutative: {
75
+ readonly _tag: "Commutative";
76
+ readonly domain: Option.Option<Schema.Top>;
77
+ };
78
+ idempotent: {
79
+ readonly _tag: "Idempotent";
80
+ readonly domain: Option.Option<Schema.Top>;
81
+ };
82
+ preservesCollation: {
83
+ readonly _tag: "PreservesCollation";
84
+ readonly domain: Option.Option<Schema.Top>;
85
+ };
86
+ /** `value` leaves the other argument as it is, from `side` (both by default). */
87
+ identity: (value: unknown, side?: Side) => Law;
88
+ /** `value` is the answer whatever the other argument, from `side` (both by default). */
89
+ absorbing: (value: unknown, side?: Side) => Law;
90
+ /** `other` undoes the operator: `op(a, other(a))` is `identity`. */
91
+ inverse: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(other: Operator<In, Out>, identity: unknown) => Law;
92
+ /** The operator distributes over `over`, from the left. */
93
+ distributes: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(over: Operator<In, Out>) => Law;
94
+ /** Moving the argument at `position` up moves the result up (or down, decreasing). */
95
+ monotonic: (direction: 'increasing' | 'decreasing', position: number) => Law;
96
+ /**
97
+ * The law over the values `domain` accepts only: a law that holds of the
98
+ * integers and not of every number, say, narrowed so it is tested where it
99
+ * is claimed.
100
+ */
101
+ within: (law: Law, domain: Schema.Top) => Law;
102
+ $match: {
103
+ <Cases extends { readonly [Tag in "Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]: (args: Extract<{
104
+ readonly _tag: "Absorbing";
105
+ readonly domain: Option.Option<Schema.Top>;
106
+ readonly value: unknown;
107
+ readonly side: Side;
108
+ } | {
109
+ readonly _tag: "Associative";
110
+ readonly domain: Option.Option<Schema.Top>;
111
+ } | {
112
+ readonly _tag: "Commutative";
113
+ readonly domain: Option.Option<Schema.Top>;
114
+ } | {
115
+ readonly _tag: "Distributes";
116
+ readonly domain: Option.Option<Schema.Top>;
117
+ readonly over: AnyOperator;
118
+ } | {
119
+ readonly _tag: "Idempotent";
120
+ readonly domain: Option.Option<Schema.Top>;
121
+ } | {
122
+ readonly _tag: "Identity";
123
+ readonly domain: Option.Option<Schema.Top>;
124
+ readonly value: unknown;
125
+ readonly side: Side;
126
+ } | {
127
+ readonly _tag: "Inverse";
128
+ readonly domain: Option.Option<Schema.Top>;
129
+ readonly other: AnyOperator;
130
+ readonly identity: unknown;
131
+ } | {
132
+ readonly _tag: "Monotonic";
133
+ readonly domain: Option.Option<Schema.Top>;
134
+ readonly direction: 'increasing' | 'decreasing';
135
+ readonly position: number;
136
+ } | {
137
+ readonly _tag: "PreservesCollation";
138
+ readonly domain: Option.Option<Schema.Top>;
139
+ }, {
140
+ readonly _tag: Tag;
141
+ }>) => any; }>(cases: Cases): (value: {
142
+ readonly _tag: "Absorbing";
143
+ readonly domain: Option.Option<Schema.Top>;
144
+ readonly value: unknown;
145
+ readonly side: Side;
146
+ } | {
147
+ readonly _tag: "Associative";
148
+ readonly domain: Option.Option<Schema.Top>;
149
+ } | {
150
+ readonly _tag: "Commutative";
151
+ readonly domain: Option.Option<Schema.Top>;
152
+ } | {
153
+ readonly _tag: "Distributes";
154
+ readonly domain: Option.Option<Schema.Top>;
155
+ readonly over: AnyOperator;
156
+ } | {
157
+ readonly _tag: "Idempotent";
158
+ readonly domain: Option.Option<Schema.Top>;
159
+ } | {
160
+ readonly _tag: "Identity";
161
+ readonly domain: Option.Option<Schema.Top>;
162
+ readonly value: unknown;
163
+ readonly side: Side;
164
+ } | {
165
+ readonly _tag: "Inverse";
166
+ readonly domain: Option.Option<Schema.Top>;
167
+ readonly other: AnyOperator;
168
+ readonly identity: unknown;
169
+ } | {
170
+ readonly _tag: "Monotonic";
171
+ readonly domain: Option.Option<Schema.Top>;
172
+ readonly direction: 'increasing' | 'decreasing';
173
+ readonly position: number;
174
+ } | {
175
+ readonly _tag: "PreservesCollation";
176
+ readonly domain: Option.Option<Schema.Top>;
177
+ }) => import("effect/Unify").Unify<ReturnType<Cases["Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]>>;
178
+ <Cases extends { readonly [Tag in "Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]: (args: Extract<{
179
+ readonly _tag: "Absorbing";
180
+ readonly domain: Option.Option<Schema.Top>;
181
+ readonly value: unknown;
182
+ readonly side: Side;
183
+ } | {
184
+ readonly _tag: "Associative";
185
+ readonly domain: Option.Option<Schema.Top>;
186
+ } | {
187
+ readonly _tag: "Commutative";
188
+ readonly domain: Option.Option<Schema.Top>;
189
+ } | {
190
+ readonly _tag: "Distributes";
191
+ readonly domain: Option.Option<Schema.Top>;
192
+ readonly over: AnyOperator;
193
+ } | {
194
+ readonly _tag: "Idempotent";
195
+ readonly domain: Option.Option<Schema.Top>;
196
+ } | {
197
+ readonly _tag: "Identity";
198
+ readonly domain: Option.Option<Schema.Top>;
199
+ readonly value: unknown;
200
+ readonly side: Side;
201
+ } | {
202
+ readonly _tag: "Inverse";
203
+ readonly domain: Option.Option<Schema.Top>;
204
+ readonly other: AnyOperator;
205
+ readonly identity: unknown;
206
+ } | {
207
+ readonly _tag: "Monotonic";
208
+ readonly domain: Option.Option<Schema.Top>;
209
+ readonly direction: 'increasing' | 'decreasing';
210
+ readonly position: number;
211
+ } | {
212
+ readonly _tag: "PreservesCollation";
213
+ readonly domain: Option.Option<Schema.Top>;
214
+ }, {
215
+ readonly _tag: Tag;
216
+ }>) => any; }>(value: {
217
+ readonly _tag: "Absorbing";
218
+ readonly domain: Option.Option<Schema.Top>;
219
+ readonly value: unknown;
220
+ readonly side: Side;
221
+ } | {
222
+ readonly _tag: "Associative";
223
+ readonly domain: Option.Option<Schema.Top>;
224
+ } | {
225
+ readonly _tag: "Commutative";
226
+ readonly domain: Option.Option<Schema.Top>;
227
+ } | {
228
+ readonly _tag: "Distributes";
229
+ readonly domain: Option.Option<Schema.Top>;
230
+ readonly over: AnyOperator;
231
+ } | {
232
+ readonly _tag: "Idempotent";
233
+ readonly domain: Option.Option<Schema.Top>;
234
+ } | {
235
+ readonly _tag: "Identity";
236
+ readonly domain: Option.Option<Schema.Top>;
237
+ readonly value: unknown;
238
+ readonly side: Side;
239
+ } | {
240
+ readonly _tag: "Inverse";
241
+ readonly domain: Option.Option<Schema.Top>;
242
+ readonly other: AnyOperator;
243
+ readonly identity: unknown;
244
+ } | {
245
+ readonly _tag: "Monotonic";
246
+ readonly domain: Option.Option<Schema.Top>;
247
+ readonly direction: 'increasing' | 'decreasing';
248
+ readonly position: number;
249
+ } | {
250
+ readonly _tag: "PreservesCollation";
251
+ readonly domain: Option.Option<Schema.Top>;
252
+ }, cases: Cases): import("effect/Unify").Unify<ReturnType<Cases["Absorbing" | "Associative" | "Commutative" | "Distributes" | "Idempotent" | "Identity" | "Inverse" | "Monotonic" | "PreservesCollation"]>>;
253
+ };
254
+ /**
255
+ * The operators a law, as JSON, calls besides its own (`inverse`'s and
256
+ * `distributes`' witnesses), by name: evidence of it is of their
257
+ * implementations too, and goes when one of them is replaced.
258
+ */
259
+ witnessesNamed: (law: LawDescription) => ReadonlyArray<string>;
260
+ /** The law as JSON: its kind, its witnesses (operators by name) and its domain's JSON Schema. */
261
+ describe: (law: Law) => LawDescription;
262
+ };
263
+ export {};
264
+ //# sourceMappingURL=law.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"law.d.ts","names":[],"sources":["../src/law.ts"],"mappings":";;;KAWK,cAAc,SAAS,cAAc,OAAO,MAAM,OAAO;;YAGlD;;;;;YAMA,MAAM,KAAK;;EAErB;aAAwB,QAAQ,OAAO,OAAO,OAAO;;;EAErD;aAAwB,QAAQ,OAAO,OAAO,OAAO;;;EAErD;aAAuB,QAAQ,OAAO,OAAO,OAAO;;;EAEpD;aACW,QAAQ,OAAO,OAAO,OAAO;aAC7B;aACA,MAAM;;;EAGjB;aACW,QAAQ,OAAO,OAAO,OAAO;aAC7B;aACA,MAAM;;;EAGjB;aACW,QAAQ,OAAO,OAAO,OAAO;aAC7B,OAAO;aACP;;;EAGX;aAAwB,QAAQ,OAAO,OAAO,OAAO;aAAe,MAAM;;;EAE1E;aACW,QAAQ,OAAO,OAAO,OAAO;aAC7B;aACA;;;EAGX;aAA+B,QAAQ,OAAO,OAAO,OAAO;;;;;;;;qBAWjD,gBAAc,OAAA;;;;;YAKf,wBAAwB,eAAe;qBAQtC;EACX;;aAzDgC,QAAA,OAAO,OAAO,OAAO;;EA0DrD;;aAxDgC,QAAA,OAAO,OAAO,OAAO;;EAyDrD;;aAvD+B,QAAA,OAAO,OAAO,OAAO;;EAwDpD;;aA5BuC,QAAA,OAAO,OAAO,OAAO;;;EA8B5D,WAAQ,gBAAiB,OAAQ,SAAgB;;EAGjD,YAAS,gBAAiB,OAAQ,SAAgB;;EAGlD,UAAU,WAAW,cAAc,OAAO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"effect";
2
+ import { jsonSchemaOf } from "./jsonSchema.js";
3
3
  // src/law.ts
4
4
  /**
5
5
  * Laws an operator declares (expr-operations-DESIGN §10): equations every
@@ -1,2 +1,170 @@
1
- import { Gt as MemoryImplementation, Jt as OperatorDescription, Kt as MemoryOperators, Ut as Evidence, Wt as ImplementedOperator, Xt as TestedEvidence, Yt as Operators, qt as OperatorContext } from "./index-48JeXG0A.js";
2
- export { Evidence, ImplementedOperator, MemoryImplementation, MemoryOperators, OperatorContext, OperatorDescription, Operators, TestedEvidence };
1
+ import { Data, Option, Schema } from "effect";
2
+ import { Collation } from "./collation.js";
3
+ import { Operator, OperatorDescriptor, OperatorTable } from "./expr.js";
4
+ import { LawDescription } from "./law.js";
5
+ import { testedByRunner } from "./tested.js";
6
+ /** What an implementation is told besides its arguments. */
7
+ export interface OperatorContext {
8
+ /** The collation the call compares text under, from its operator's `collation` rule. */
9
+ readonly collation: Option.Option<Collation>;
10
+ }
11
+ /** One operator's in-memory implementation: a pure function of stored values. */
12
+ export interface MemoryImplementation {
13
+ readonly operator: OperatorDescriptor;
14
+ readonly run: (args: ReadonlyArray<unknown>, context: OperatorContext) => unknown;
15
+ }
16
+ /**
17
+ * What is known of a law of an implementation, past its operator claiming it
18
+ * (expr-operations-DESIGN §10.3): `Tested`, it passed `Conformance.laws`'
19
+ * cases; `Proven`, a proof elsewhere says so under its assumptions, recorded
20
+ * and never checked here.
21
+ */
22
+ export type Evidence = Data.TaggedEnum<{
23
+ Tested: {
24
+ readonly operator: string;
25
+ readonly law: LawDescription;
26
+ readonly implementation: string;
27
+ readonly cases: number;
28
+ readonly seed: number;
29
+ };
30
+ Proven: {
31
+ readonly operator: string;
32
+ readonly law: LawDescription;
33
+ readonly reference: string;
34
+ readonly assumptions: ReadonlyArray<string>;
35
+ };
36
+ }>;
37
+ export declare const Evidence: Data.TaggedEnum.Constructor<{
38
+ readonly _tag: "Proven";
39
+ readonly operator: string;
40
+ readonly law: LawDescription;
41
+ readonly reference: string;
42
+ readonly assumptions: ReadonlyArray<string>;
43
+ } | {
44
+ readonly _tag: "Tested";
45
+ readonly operator: string;
46
+ readonly law: LawDescription;
47
+ readonly implementation: string;
48
+ readonly cases: number;
49
+ readonly seed: number;
50
+ }>;
51
+ /** A record of a law passing `Conformance.laws`' cases. */
52
+ export type TestedEvidence = Extract<Evidence, {
53
+ readonly _tag: 'Tested';
54
+ }>;
55
+ /**
56
+ * An operator as JSON, by its signature and never its body (a defined
57
+ * operator says `defined`, not what it means): what a server can publish of
58
+ * what a body may call, and a client compare with what it runs. Its schemas
59
+ * are each argument's and the result's stored side, as JSON Schemas.
60
+ */
61
+ export declare const OperatorDescription: Schema.Struct<{
62
+ /** By id, and `@version` past the first: what tables, evidence and refusals name. */
63
+ readonly name: Schema.String;
64
+ readonly id: Schema.String;
65
+ readonly version: Schema.Int;
66
+ readonly description: Schema.NullOr<Schema.String>;
67
+ readonly input: Schema.$Array<Schema.$Record<Schema.String, Schema.Unknown>>;
68
+ readonly output: Schema.$Record<Schema.String, Schema.Unknown>;
69
+ readonly nulls: Schema.Literals<readonly ["strict", "handled"]>;
70
+ readonly collation: Schema.Literals<readonly ["none", "operands", "required"]>;
71
+ readonly laws: Schema.$Array<Schema.Struct<{
72
+ readonly kind: Schema.String;
73
+ readonly witnesses: Schema.$Record<Schema.String, Schema.Unknown>;
74
+ readonly domain: Schema.Unknown;
75
+ }>>;
76
+ readonly defined: Schema.Boolean;
77
+ }>;
78
+ export type OperatorDescription = typeof OperatorDescription.Type;
79
+ /** One operator a table implements, as `Operators.describeTable` lists it: described, with its evidence. */
80
+ export interface ImplementedOperator extends OperatorDescription {
81
+ readonly evidence: ReadonlyArray<Evidence>;
82
+ }
83
+ /** The in-memory interpreter's implementations, by operator. */
84
+ export interface MemoryOperators extends OperatorTable {
85
+ readonly _tag: 'MemoryOperators';
86
+ readonly get: (operator: OperatorDescriptor) => Option.Option<MemoryImplementation['run']>;
87
+ /**
88
+ * The operator it implements under a name (`id`, or `id@version` past the
89
+ * first): how a computed assignment carried as data finds what to run.
90
+ */
91
+ readonly named: (name: string) => Option.Option<OperatorDescriptor>;
92
+ /** Whether each answer is checked against its operator's output schema: for tests. */
93
+ readonly checked: boolean;
94
+ readonly implementations: ReadonlyArray<MemoryImplementation>;
95
+ /** What is known of its implementations' laws: `Operators.withEvidence`. */
96
+ readonly evidence: ReadonlyArray<Evidence>;
97
+ }
98
+ type StoredOf<S extends Schema.Top> = Schema.Codec.Encoded<S>;
99
+ export declare const Operators: {
100
+ /**
101
+ * An implementation of a strict operator: a pure function of its arguments'
102
+ * stored values, never given a null (the kernel answers null, or unknown, for
103
+ * one first), and told the call's collation last.
104
+ *
105
+ * ```ts
106
+ * Operators.implement(startsWith, (text, prefix, { collation }) => text.startsWith(prefix))
107
+ * ```
108
+ */
109
+ implement: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(operator: Operator<In, Out>, run: (...args: [...{ readonly [K in keyof In]: NonNullable<StoredOf<In[K]>>; }, OperatorContext]) => StoredOf<Out>) => MemoryImplementation;
110
+ /**
111
+ * An implementation of an operator declared `nulls: 'handled'`: given nulls
112
+ * as they are, it answers for them; a predicate answers `null` for unknown.
113
+ */
114
+ implementHandlingNulls: <In extends ReadonlyArray<Schema.Top>, Out extends Schema.Top>(operator: Operator<In, Out>, run: (...args: [...{ readonly [K in keyof In]: StoredOf<In[K]>; }, OperatorContext]) => StoredOf<Out> | null) => MemoryImplementation;
115
+ /** A table of implementations. One operator implemented twice, or two under one name, is refused. */
116
+ memory: (...implementations: ReadonlyArray<MemoryImplementation>) => MemoryOperators;
117
+ /** Both tables' implementations. An operator both implement is refused: say which wins with `override`. */
118
+ merge: (left: MemoryOperators, right: MemoryOperators) => MemoryOperators;
119
+ /**
120
+ * The table with these implementations in place of its own for the same
121
+ * operators. Evidence of a replaced implementation goes with it: it was
122
+ * that implementation's.
123
+ */
124
+ override: (base: MemoryOperators, ...implementations: ReadonlyArray<MemoryImplementation>) => MemoryOperators;
125
+ /**
126
+ * The table with what is known of its implementations' laws recorded: each
127
+ * record of an operator it implements and a law that operator declares.
128
+ * `Conformance.laws` gives `Tested` records, each of the implementation it
129
+ * ran, and a table takes only those of its own; `Evidence.Proven` says a
130
+ * proof elsewhere covers one.
131
+ */
132
+ withEvidence: (base: MemoryOperators, evidence: ReadonlyArray<Evidence>) => MemoryOperators;
133
+ /**
134
+ * The memory implementation `Conformance.laws` tested a record on; none for
135
+ * a record of a runner (`Conformance.lawsBy`) or a proof.
136
+ */
137
+ testedOn: (record: Evidence) => Option.Option<MemoryImplementation>;
138
+ /**
139
+ * Whether `Conformance.lawsBy` made a record, through a runner: what an SQL
140
+ * table takes. Which runner it was, the database's or another, is the
141
+ * caller's word; a record built by hand, copied, or tested in memory is not.
142
+ */
143
+ testedByRunner: typeof testedByRunner;
144
+ /**
145
+ * Each operator the table implements, by name, with the laws it declares and
146
+ * the evidence the table records of them: what a server can publish of how
147
+ * it runs a body. JSON as it is.
148
+ */
149
+ describeTable: (base: MemoryOperators) => ReadonlyArray<ImplementedOperator>;
150
+ /**
151
+ * An operator as JSON (`OperatorDescription`): its name, version and
152
+ * description, each argument's and its result's stored side as a JSON
153
+ * Schema (as JSON carries it: a number also admits the strings `"Infinity"`,
154
+ * `"-Infinity"` and `"NaN"`), its null and collation rules, its laws, and
155
+ * whether it is defined. Its signature, never its body.
156
+ */
157
+ describe: (operator: {
158
+ readonly descriptor: OperatorDescriptor;
159
+ }) => OperatorDescription;
160
+ /**
161
+ * The table, checking every answer against its operator's output schema, so
162
+ * an implementation that answers the wrong kind fails where it answered. For
163
+ * tests: it costs a decode per call.
164
+ */
165
+ checked: (base: MemoryOperators) => MemoryOperators;
166
+ /** The kernel's own operators (`Text.startsWith`): every memory interpreter's default. */
167
+ kernel: MemoryOperators;
168
+ };
169
+ export {};
170
+ //# sourceMappingURL=operators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operators.d.ts","names":[],"sources":["../src/operators.ts"],"mappings":";;;;;;iB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;;;EAajC,WAAA;aAAW,YAAY;QAAuB;;;;;;EAQnD,UAAA,MAAA,oBAAkB"}
package/dist/operators.js CHANGED
@@ -1,9 +1,9 @@
1
+ import { Data, Equivalence, Option, Schema } from "effect";
1
2
  import { Collation } from "./collation.js";
2
- import { jsonSchemaOf } from "./jsonSchema.js";
3
3
  import { Law, LawDescription } from "./law.js";
4
- import { tableTested, testedByRunner } from "./tested.js";
5
4
  import { Text } from "./text.js";
6
- import { Data, Equivalence, Option, Schema } from "effect";
5
+ import { jsonSchemaOf } from "./jsonSchema.js";
6
+ import { tableTested, testedByRunner } from "./tested.js";
7
7
  // src/operators.ts
8
8
  /**
9
9
  * How the in-memory interpreter runs primitive operators: a table of
@@ -1,2 +1,8 @@
1
- import { t as ReadFilter } from "./readFilter-CWMnFRVw.js";
2
- export { ReadFilter };
1
+ import { Metadata } from "foldkit-metadata";
2
+ export declare const ReadFilter: {
3
+ /** Entity metadata: the rows the server lists depend on these members. */
4
+ of: (members: ReadonlyArray<string>) => Metadata;
5
+ /** The members an Entity's metadata names, every attachment's together. */
6
+ members: (metadata: Metadata) => ReadonlyArray<string>;
7
+ };
8
+ //# sourceMappingURL=readFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readFilter.d.ts","names":[],"sources":["../src/readFilter.ts"],"mappings":";qBAgBa;;EAEX,KAAE,SAAY,0BAAwB;;EAGtC,UAAO,UAAa,aAAW"}
package/dist/sets.d.ts CHANGED
@@ -1,2 +1,18 @@
1
- import { ct as ContextValue, dt as checkedSet, lt as EntitySet, ut as SetOn } from "./index-48JeXG0A.js";
2
- export { ContextValue, EntitySet, SetOn, checkedSet };
1
+ import { AnyEntity } from "./index.js";
2
+ import { NowExpr, ViewerExpr, ViewerPathExpr } from "./context.js";
3
+ /** The writes that set a member: every insert (`create`), or every insert and update (`write`). */
4
+ export type SetOn = 'create' | 'write';
5
+ /** A value the write's context gives: who asks, what their row holds, or when. */
6
+ export type ContextValue = ViewerExpr<unknown> | ViewerPathExpr<unknown> | NowExpr<unknown>;
7
+ /** One member `Entity.sets` names: its value, and the writes that set it. */
8
+ export interface EntitySet {
9
+ readonly value: ContextValue;
10
+ readonly on: SetOn;
11
+ }
12
+ /**
13
+ * `value` checked against the member `key` it sets, as `Entity.sets` was
14
+ * given them: a relation takes `Expr.viewer` of its target, a field stored as
15
+ * text the viewer's id, a field stored as a number the time.
16
+ */
17
+ export declare const checkedSet: (entity: AnyEntity, key: string, value: unknown, on: unknown) => EntitySet;
18
+ //# sourceMappingURL=sets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sets.d.ts","names":[],"sources":["../src/sets.ts"],"mappings":";;;YAUY;;YAGA,eAAe,sBAAsB,0BAA0B;;iBAG1D;WACN,OAAO;WACP,IAAI;;;;;;;qBAuBF,aAAU,QACb,WAAS,aACN,gBACG,gBAEb"}
package/dist/sets.js CHANGED
@@ -1,5 +1,5 @@
1
- import { SchemaShape } from "./shape.js";
2
1
  import { Match, Schema, SchemaAST } from "effect";
2
+ import { SchemaShape } from "./shape.js";
3
3
  // src/sets.ts
4
4
  /**
5
5
  * What `Entity.sets` declares: members whose value is the write's context,
package/dist/shape.d.ts CHANGED
@@ -1,2 +1,23 @@
1
- import { t as SchemaShape } from "./shape-LAowRf9f.js";
2
- export { SchemaShape };
1
+ import { SchemaAST } from "effect";
2
+ declare const isNullish: (ast: SchemaAST.AST) => boolean;
3
+ declare const isText: (ast: SchemaAST.AST) => boolean;
4
+ /** What a schema's AST holds, read through Effect's own guards. */
5
+ export declare const SchemaShape: {
6
+ /** True for the `null` and `undefined` members that make a schema optional. */
7
+ isNullish: typeof isNullish;
8
+ /**
9
+ * The members of a schema with `null` and `undefined` set aside, so optional
10
+ * text is still text; a schema that is not a union is its one member.
11
+ */
12
+ present: (ast: SchemaAST.AST) => ReadonlyArray<SchemaAST.AST>;
13
+ /** True when every value the schema admits is a string. */
14
+ isText: typeof isText;
15
+ /**
16
+ * True when the AST is checked to hold integers (`Schema.isInt`, alone or in
17
+ * a group such as `isInt32`). Read it from a schema's encoded side to ask
18
+ * what the store holds.
19
+ */
20
+ holdsIntegers: (ast: SchemaAST.AST) => boolean;
21
+ };
22
+ export {};
23
+ //# sourceMappingURL=shape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.d.ts","names":[],"sources":["../src/shape.ts"],"mappings":";cAEM,YAAS,KAAS,UAAU;cAG5B,SAAM,KAAS,UAAU;;qBAkBlB;;;;;;;EAQI,UAAA,KAAA,UAAU,QAAM,cAAc,UAAU;;;;;;;;EAWlC,gBAAA,KAAA,UAAU"}
package/dist/tested.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- import { $t as tableTested, Qt as stampTested, Zt as stampRun, en as testedByRunner } from "./index-48JeXG0A.js";
2
- export { stampRun, stampTested, tableTested, testedByRunner };
1
+ import { Option } from "effect";
2
+ import { Evidence, MemoryOperators } from "./operators.js";
3
+ export declare const stampTested: (record: Evidence, operators: MemoryOperators) => void;
4
+ export declare const stampRun: (record: Evidence) => void;
5
+ /** The table `Conformance.laws` tested a record on. */
6
+ export declare const tableTested: (record: Evidence) => Option.Option<MemoryOperators>;
7
+ export declare const testedByRunner: (record: Evidence) => boolean;
8
+ //# sourceMappingURL=tested.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tested.d.ts","names":[],"sources":["../src/tested.ts"],"mappings":";;qBAea,cAAW,QAAY,UAAQ,WAAa;qBAI5C,WAAQ,QAAY;;qBAKpB,cAAW,QAAY,aAAW,OAAO,OAAO;qBAGhD,iBAAc,QAAY"}
package/dist/text.d.ts CHANGED
@@ -1,2 +1,27 @@
1
- import { st as Text } from "./index-48JeXG0A.js";
2
- export { Text };
1
+ import { Schema } from "effect";
2
+ export declare const Text: {
3
+ /**
4
+ * Whether the first text begins with the second, under the first's collation.
5
+ *
6
+ * | Case | Answer |
7
+ * | --- | --- |
8
+ * | either is null | unknown |
9
+ * | the prefix is `''` | true |
10
+ * | otherwise | whether it begins so, compared under the collation |
11
+ *
12
+ * The collation is the one its text operands share (a field's declared one,
13
+ * or a call's), or one given to the call. `binary` compares exactly;
14
+ * `asciiFold` folds ASCII letters on both sides. Operands declaring
15
+ * different collations, text with none, or a backend's locale are refused
16
+ * where the call is written.
17
+ * Prefixes are by character, so non-ASCII and astral text begin as they read,
18
+ * and half of an astral character begins nothing. A lone surrogate, which
19
+ * UTF-8 cannot hold, compares as U+FFFD, as a database stores it.
20
+ *
21
+ * ```ts
22
+ * Query.where(Text.startsWith(Product.fields.upc, input.search))
23
+ * ```
24
+ */
25
+ startsWith: import("./expr.js").Operator<readonly [Schema.NullOr<Schema.String>, Schema.NullOr<Schema.String>], Schema.Boolean>;
26
+ };
27
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","names":[],"sources":["../src/text.ts"],"mappings":";qBAOa;;;;;;;;;;;;;;;;;;;;;;;EAuBX,gCAAU,mBAAA,OAAA,OAAA,OAAA,SAAA,OAAA,OAAA,OAAA,UAAA,OAAA"}
package/dist/text.js CHANGED
@@ -1,5 +1,5 @@
1
- import { Expr } from "./expr.js";
2
1
  import { Schema } from "effect";
2
+ import { Expr } from "./expr.js";
3
3
  // src/text.ts
4
4
  /**
5
5
  * The kernel's text operators: primitive, so each interpreter implements them,