@grafctory/blue 0.0.0-stage → 0.15.1

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 (139) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +509 -2
  3. package/dist/boolean/assembler.d.ts +53 -0
  4. package/dist/boolean/assembler.d.ts.map +1 -0
  5. package/dist/boolean/assembler.js +78 -0
  6. package/dist/boolean/assembler.js.map +1 -0
  7. package/dist/boolean/index.d.ts +86 -0
  8. package/dist/boolean/index.d.ts.map +1 -0
  9. package/dist/boolean/index.js +99 -0
  10. package/dist/boolean/index.js.map +1 -0
  11. package/dist/boolean/validator.d.ts +30 -0
  12. package/dist/boolean/validator.d.ts.map +1 -0
  13. package/dist/boolean/validator.js +68 -0
  14. package/dist/boolean/validator.js.map +1 -0
  15. package/dist/dictionary/assembler.d.ts +70 -0
  16. package/dist/dictionary/assembler.d.ts.map +1 -0
  17. package/dist/dictionary/assembler.js +154 -0
  18. package/dist/dictionary/assembler.js.map +1 -0
  19. package/dist/dictionary/index.d.ts +211 -0
  20. package/dist/dictionary/index.d.ts.map +1 -0
  21. package/dist/dictionary/index.js +43 -0
  22. package/dist/dictionary/index.js.map +1 -0
  23. package/dist/dictionary/inference.d.ts +42 -0
  24. package/dist/dictionary/inference.d.ts.map +1 -0
  25. package/dist/dictionary/inference.js +17 -0
  26. package/dist/dictionary/inference.js.map +1 -0
  27. package/dist/dictionary/validator.d.ts +34 -0
  28. package/dist/dictionary/validator.d.ts.map +1 -0
  29. package/dist/dictionary/validator.js +91 -0
  30. package/dist/dictionary/validator.js.map +1 -0
  31. package/dist/index.core.d.ts +33 -0
  32. package/dist/index.core.d.ts.map +1 -0
  33. package/dist/index.core.js +149 -0
  34. package/dist/index.core.js.map +1 -0
  35. package/dist/index.d.ts +333 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +378 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/number/assembler.d.ts +70 -0
  40. package/dist/number/assembler.d.ts.map +1 -0
  41. package/dist/number/assembler.js +188 -0
  42. package/dist/number/assembler.js.map +1 -0
  43. package/dist/number/index.d.ts +329 -0
  44. package/dist/number/index.d.ts.map +1 -0
  45. package/dist/number/index.js +312 -0
  46. package/dist/number/index.js.map +1 -0
  47. package/dist/number/validator.d.ts +31 -0
  48. package/dist/number/validator.d.ts.map +1 -0
  49. package/dist/number/validator.js +57 -0
  50. package/dist/number/validator.js.map +1 -0
  51. package/dist/reference/accessors.d.ts +29 -0
  52. package/dist/reference/accessors.d.ts.map +1 -0
  53. package/dist/reference/accessors.js +38 -0
  54. package/dist/reference/accessors.js.map +1 -0
  55. package/dist/reference/assembler.d.ts +63 -0
  56. package/dist/reference/assembler.d.ts.map +1 -0
  57. package/dist/reference/assembler.js +127 -0
  58. package/dist/reference/assembler.js.map +1 -0
  59. package/dist/reference/index.d.ts +108 -0
  60. package/dist/reference/index.d.ts.map +1 -0
  61. package/dist/reference/index.js +40 -0
  62. package/dist/reference/index.js.map +1 -0
  63. package/dist/reference/validator.d.ts +33 -0
  64. package/dist/reference/validator.d.ts.map +1 -0
  65. package/dist/reference/validator.js +56 -0
  66. package/dist/reference/validator.js.map +1 -0
  67. package/dist/resource/accessors.d.ts +140 -0
  68. package/dist/resource/accessors.d.ts.map +1 -0
  69. package/dist/resource/accessors.js +173 -0
  70. package/dist/resource/accessors.js.map +1 -0
  71. package/dist/resource/assembler.d.ts +265 -0
  72. package/dist/resource/assembler.d.ts.map +1 -0
  73. package/dist/resource/assembler.js +816 -0
  74. package/dist/resource/assembler.js.map +1 -0
  75. package/dist/resource/index.d.ts +898 -0
  76. package/dist/resource/index.d.ts.map +1 -0
  77. package/dist/resource/index.js +160 -0
  78. package/dist/resource/index.js.map +1 -0
  79. package/dist/resource/inference.d.ts +310 -0
  80. package/dist/resource/inference.d.ts.map +1 -0
  81. package/dist/resource/inference.js +17 -0
  82. package/dist/resource/inference.js.map +1 -0
  83. package/dist/resource/validator.d.ts +158 -0
  84. package/dist/resource/validator.d.ts.map +1 -0
  85. package/dist/resource/validator.js +1031 -0
  86. package/dist/resource/validator.js.map +1 -0
  87. package/dist/string/assembler.d.ts +69 -0
  88. package/dist/string/assembler.d.ts.map +1 -0
  89. package/dist/string/assembler.js +143 -0
  90. package/dist/string/assembler.js.map +1 -0
  91. package/dist/string/index.d.ts +431 -0
  92. package/dist/string/index.d.ts.map +1 -0
  93. package/dist/string/index.js +528 -0
  94. package/dist/string/index.js.map +1 -0
  95. package/dist/string/validator.d.ts +30 -0
  96. package/dist/string/validator.d.ts.map +1 -0
  97. package/dist/string/validator.js +69 -0
  98. package/dist/string/validator.js.map +1 -0
  99. package/dist/union/accessors.d.ts +137 -0
  100. package/dist/union/accessors.d.ts.map +1 -0
  101. package/dist/union/accessors.js +253 -0
  102. package/dist/union/accessors.js.map +1 -0
  103. package/dist/union/assembler.d.ts +56 -0
  104. package/dist/union/assembler.d.ts.map +1 -0
  105. package/dist/union/assembler.js +140 -0
  106. package/dist/union/assembler.js.map +1 -0
  107. package/dist/union/index.d.ts +172 -0
  108. package/dist/union/index.d.ts.map +1 -0
  109. package/dist/union/index.js +45 -0
  110. package/dist/union/index.js.map +1 -0
  111. package/dist/union/inference.d.ts +30 -0
  112. package/dist/union/inference.d.ts.map +1 -0
  113. package/dist/union/inference.js +17 -0
  114. package/dist/union/inference.js.map +1 -0
  115. package/dist/union/validator.d.ts +94 -0
  116. package/dist/union/validator.d.ts.map +1 -0
  117. package/dist/union/validator.js +171 -0
  118. package/dist/union/validator.js.map +1 -0
  119. package/dist/value/accessors.d.ts +151 -0
  120. package/dist/value/accessors.d.ts.map +1 -0
  121. package/dist/value/accessors.js +468 -0
  122. package/dist/value/accessors.js.map +1 -0
  123. package/dist/value/assembler.d.ts +129 -0
  124. package/dist/value/assembler.d.ts.map +1 -0
  125. package/dist/value/assembler.js +248 -0
  126. package/dist/value/assembler.js.map +1 -0
  127. package/dist/value/index.d.ts +309 -0
  128. package/dist/value/index.d.ts.map +1 -0
  129. package/dist/value/index.js +26 -0
  130. package/dist/value/index.js.map +1 -0
  131. package/dist/value/inference.d.ts +292 -0
  132. package/dist/value/inference.d.ts.map +1 -0
  133. package/dist/value/inference.js +17 -0
  134. package/dist/value/inference.js.map +1 -0
  135. package/dist/value/validator.d.ts +76 -0
  136. package/dist/value/validator.d.ts.map +1 -0
  137. package/dist/value/validator.js +111 -0
  138. package/dist/value/validator.js.map +1 -0
  139. package/package.json +95 -4
@@ -0,0 +1,309 @@
1
+ /**
2
+ * Value shape types and operations.
3
+ *
4
+ * Defines the {@link Shape} any value is validated against, derives TypeScript types from shapes, and provides the
5
+ * accessors for navigating them. Callers holding a shape don't need to know which kind of shape it is, and since value
6
+ * types are derived from the shapes describing them, the two can't drift apart.
7
+ *
8
+ * **Shape kinds**
9
+ *
10
+ * Each kind of shape is defined in its own module:
11
+ *
12
+ * - {@link boolean!BooleanShape | BooleanShape} — truth values
13
+ * - {@link number!NumberShape | NumberShape} — numeric values
14
+ * - {@link string!StringShape | StringShape} — textual values
15
+ * - {@link dictionary!DictionaryShape | DictionaryShape} — language-tagged maps
16
+ * - {@link reference!ReferenceShape | ReferenceShape} — links to standalone resources
17
+ * - {@link resource!ResourceShape | ResourceShape} — linked data resources
18
+ * - {@link union!UnionShape | UnionShape} — a value drawn from one of several alternatives
19
+ *
20
+ * <img src="../index.svg" alt="Shape hierarchy" style="width: 100%" />
21
+ *
22
+ * {@link sh} is the namespace of the SHACL terms shapes are modelled on.
23
+ *
24
+ * **Cardinality**
25
+ *
26
+ * A {@link Range} pairs a shape with the number of values allowed, and describes both the values of a declared member
27
+ * and the values a path resolves to. A range isn't a shape: the shape describes each value, the range how many there
28
+ * may be.
29
+ *
30
+ * **Value types**
31
+ *
32
+ * {@link State} is the type of a value described by a shape, and {@link Draft} the type of a resource or collection
33
+ * item to be persisted, with its identifier optional:
34
+ *
35
+ * ```typescript
36
+ * type Item = State<typeof Product>; // { readonly id: Reference, readonly name: string, … }
37
+ * type Seed = Draft<typeof Product>; // { readonly name: string, …, readonly id?: Reference }
38
+ * ```
39
+ *
40
+ * {@link blueprint} resolves the shape a draft posted to a collection property must satisfy, so that a new item can be
41
+ * validated before it is stored.
42
+ *
43
+ * **Retrieval types**
44
+ *
45
+ * {@link Model} and {@link Slice} are the models allowed for retrieving a resource or a collection it holds, so that a
46
+ * model naming members the shape doesn't declare fails to compile. {@link Match} and {@link Items} are the types of a
47
+ * retrieved resource and of the items of a retrieved collection, restricted to the members the model asks for, so
48
+ * callers get back exactly what they asked for:
49
+ *
50
+ * ```typescript
51
+ * type Read = Match<typeof Product, { name: {} }>; // { readonly name: string }
52
+ * type Rows = Items<typeof Catalog, { items: { name: {} } }>; // readonly { readonly name: string }[]
53
+ * ```
54
+ *
55
+ * {@link items} gets the items of the collection from a resource retrieved with a slice, typed as {@link Items}.
56
+ *
57
+ * **Navigation**
58
+ *
59
+ * {@link eager} resolves a shape or range deferred to break definition cycles, returning resource shapes with their
60
+ * inherited members merged in; repeated calls return the same value.
61
+ *
62
+ * {@link collection} resolves the collection property a slice names, whether the shape declares or inherits it.
63
+ *
64
+ * {@link effective} resolves the {@link Range} reached by a path and transform pipe, so that callers can type a
65
+ * projection column or a constraint operand without walking the shape themselves. Links are followed only when the
66
+ * path continues past them, and each branch of a union is explored in turn. Paths naming a member no branch declares,
67
+ * and pipes that can't apply to the values reached, are reported as issues.
68
+ *
69
+ * @module
70
+ *
71
+ * @see {@link https://www.w3.org/TR/shacl/ SHACL - Shapes Constraint Language}
72
+ */
73
+ import type { Eager, Lazy, Optional } from "@grafctory/core";
74
+ import { type Namespace } from "@grafctory/core/resource";
75
+ import type { Binding, Criteria, Template } from "@grafctory/qest/model";
76
+ import type { Resource, Value } from "@grafctory/qest/state";
77
+ import type { BooleanShape } from "../boolean/index.js";
78
+ import type { DictionaryShape } from "../dictionary/index.js";
79
+ import type { NumberShape } from "../number/index.js";
80
+ import type { ReferenceShape } from "../reference/index.js";
81
+ import type { ResourceShape } from "../resource/index.js";
82
+ import type { Repeated, Retrieved } from "../resource/inference.js";
83
+ import type { StringShape } from "../string/index.js";
84
+ import type { UnionShape } from "../union/index.js";
85
+ import type { Branch } from "../union/inference.js";
86
+ import type { Blueprint, Collecting, Detailed, Drafted, Entries, Plain, Row, Sole, Wanted } from "./inference.js";
87
+ export { blueprint, collection, eager, effective, items } from "./accessors.js";
88
+ /**
89
+ * SHACL vocabulary namespace.
90
+ *
91
+ * An open {@link Namespace} over `http://www.w3.org/ns/shacl#`, resolving any SHACL term as a named property.
92
+ *
93
+ * @see {@link https://www.w3.org/TR/shacl/ SHACL - Shapes Constraint Language}
94
+ */
95
+ export declare const sh: Namespace;
96
+ /**
97
+ * Value shape.
98
+ *
99
+ * Describes a plain value, localised text, a reference to a resource, a resource itself, or a value matching one of
100
+ * several alternatives. Resource shapes declare the members of their instances and may extend other resource shapes.
101
+ * The type of the described value is derived from the shape as {@link State}, so the two can't drift apart.
102
+ */
103
+ export type Shape = BooleanShape | NumberShape | StringShape | DictionaryShape | ReferenceShape | ResourceShape | UnionShape;
104
+ /**
105
+ * Cardinality-constrained value set.
106
+ *
107
+ * Describes both the values of a {@link resource!Property | property} and the values a path resolves to, stating the
108
+ * shape of each value and how many values are allowed.
109
+ *
110
+ * @typeParam R The shape of the values, possibly deferred to break definition cycles
111
+ * @typeParam L The minimum number of values
112
+ * @typeParam U The maximum number of values
113
+ */
114
+ export type Range<R extends Lazy<Shape> = Lazy<Shape>, L extends Optional<number> = Optional<number>, U extends Optional<number> = Optional<number>> = {
115
+ /**
116
+ * Minimum number of values.
117
+ *
118
+ * `undefined` sets no lower bound.
119
+ *
120
+ * @see {@link https://www.w3.org/TR/shacl/#MinCountConstraintComponent SHACL § 4.2.1 sh:minCount}
121
+ */
122
+ readonly minCount: L;
123
+ /**
124
+ * Maximum number of values.
125
+ *
126
+ * `undefined` sets no upper bound.
127
+ *
128
+ * @see {@link https://www.w3.org/TR/shacl/#MaxCountConstraintComponent SHACL § 4.2.2 sh:maxCount}
129
+ */
130
+ readonly maxCount: U;
131
+ /**
132
+ * Shape of every value in the set.
133
+ *
134
+ * May be deferred to break definition cycles: resolve it with {@link Eager} before reading it as a {@link Shape}.
135
+ */
136
+ readonly shape: R;
137
+ };
138
+ /**
139
+ * Resolves the value type of a shape.
140
+ *
141
+ * Scalar, localised and reference shapes resolve to their plain value. Resource shapes resolve to a record of their
142
+ * declared members merged over the inherited ones. Union shapes resolve to the value of any branch. A reference shape
143
+ * resolves to a {@link @grafctory/qest!Reference | Reference} to its target, never to the target resource itself. A
144
+ * bare {@link Shape}, standing for any kind of value, resolves to `never`; the bare
145
+ * {@link resource!ResourceShape | ResourceShape}, standing for any resource, resolves to
146
+ * {@link @grafctory/qest!Resource | Resource}, so the state of any resource shape is accepted where only a generic
147
+ * resource shape is known.
148
+ *
149
+ * In a resource, the identifier is the IRI of the resource and the type is the IRI of its class, undefined for untyped
150
+ * resources. A property holds a single value if it admits at most one, a read-only array otherwise, and a non-empty
151
+ * array if at least one value is required. Localised text is always a single language-tag-keyed map, never wrapped in
152
+ * an array, so a range admitting both localised text and other values holds either the map or the other values, never
153
+ * both.
154
+ *
155
+ * Optional members may be omitted. A member voided by an incompatible override in an extension accepts no value, so the
156
+ * conflict shows up as a member nothing can satisfy instead of the member silently disappearing.
157
+ *
158
+ * @typeParam S The shape, possibly deferred to break definition cycles
159
+ *
160
+ * @opaque
161
+ */
162
+ export type State<S extends Lazy<Shape>> = Shape extends Eager<S> ? never : ResourceShape extends Eager<S> ? Resource : S extends Lazy<{
163
+ readonly kind: "resource";
164
+ }> ? Retrieved<S> : S extends Lazy<{
165
+ readonly kind: "union";
166
+ }> ? State<Branch<S>> : Plain<S>;
167
+ /**
168
+ * Resolves the state of a resource to be persisted.
169
+ *
170
+ * Resolves to the {@link State | state} of a resource of the shape, with an optional identifier. The identifier is
171
+ * optional because the target of the operation already identifies the resource, or leaves the store to assign it on
172
+ * creation; if stated, it must agree with the target.
173
+ *
174
+ * Given a {@link Slice | slice} as well, resolves instead to the state of a new item for the collection it names,
175
+ * whether the collection property is declared or inherited. {@link blueprint} returns the shape such an item must
176
+ * satisfy, so it can be validated before it is stored. Resolves to `never` for properties holding values other than
177
+ * resources, which can't be drafted.
178
+ *
179
+ * The bare {@link resource!ResourceShape | ResourceShape} or a generic {@link @grafctory/qest!Template | Template}
180
+ * resolves to any {@link @grafctory/qest!Resource | Resource}, so any draft is accepted where only a generic shape or
181
+ * model is known.
182
+ *
183
+ * @typeParam S The resource shape, or the shape of the resource holding the collection, possibly deferred to break
184
+ * definition cycles
185
+ * @typeParam T The slice naming the collection property; omit it to draft the resource itself
186
+ *
187
+ * @opaque
188
+ */
189
+ export type Draft<S extends Lazy<ResourceShape>, T = never> = [
190
+ Blueprint<S, T>
191
+ ] extends [never] ? never : Drafted<Blueprint<S, T>>;
192
+ /**
193
+ * Resolves the models for retrieving a resource.
194
+ *
195
+ * Resolves to the {@link @grafctory/qest!Template | templates} a retrieval against the shape may use, so that a template
196
+ * naming members the shape doesn't declare, or requesting a member in a form its range doesn't support, fails to
197
+ * compile instead of failing in the store. Any member of the shape, declared or inherited, may be requested as:
198
+ *
199
+ * - **atomic** — `{}`, for any member
200
+ * - **template** — a nested template, checked against the shape of the linked or embedded resource
201
+ * - **locale** — a language-range map, for ranges admitting localised text
202
+ * - **union** — a branch map, for ranges mixing kinds of value, each branch in any form above
203
+ * - **query** — any form above, or a projection, merged with collection criteria, for multi-valued members
204
+ *
205
+ * Only forms are checked: filter, ordering and projection expressions are not validated against the shape. Since keys
206
+ * are compared structurally, a template mixing unknown members with known ones is accepted, unless the template is
207
+ * passed as `T`: a bound stated as `T extends Model<S, T>` rejects it. Every model is a
208
+ * {@link @grafctory/qest!Template | Template}, so stores can read it as one regardless of its shape.
209
+ *
210
+ * @typeParam S The resource shape, possibly deferred to break definition cycles
211
+ * @typeParam T The supplied template, typically inferred from the argument, with members the shape doesn't declare
212
+ * rejected; omit it to accept any template naming only members of the shape
213
+ *
214
+ * @opaque
215
+ */
216
+ export type Model<S extends Lazy<ResourceShape>, T = never> = Template & Entries<S, T>;
217
+ /**
218
+ * Resolves the type of the resource retrieved by a model.
219
+ *
220
+ * For a template, resolves to the {@link State | state} of the shape restricted to the members the template names,
221
+ * including those of nested templates. A collection requested with a projection holds the rows the projection
222
+ * computes. For a projection, resolves to the computed row, keyed by the name before each binding's `=`, with columns
223
+ * typed as any value a resource may hold. Depth, cardinality and optionality come from the shape: the model only
224
+ * selects which values to return. Filtering, ordering and pagination criteria don't affect the result type.
225
+ *
226
+ * Members the template omits are omitted from the match. A localised member asked for by the atomic placeholder
227
+ * resolves to the text language negotiation returns for it: a string or an array of strings, at the per-tag arity its
228
+ * shape states. Polymorphic members, localised members asked for per tag and projection columns keep the broad type
229
+ * the shape describes, since each value is resolved against its whole shape. Callers needing the branch a branch map
230
+ * selects, the tags a language range selects, or the type an expression computes, must narrow it themselves.
231
+ *
232
+ * Under the bare {@link resource!ResourceShape | ResourceShape}, every member the template names resolves to any
233
+ * {@link @grafctory/qest!Values | values}. A generic {@link @grafctory/qest!Template | Template} names no member at all
234
+ * and resolves to an empty record, with no member left for the shape to resolve.
235
+ *
236
+ * @typeParam S The shape the retrieval runs against, possibly deferred to break definition cycles
237
+ * @typeParam T The template or projection model of the retrieval, possibly with criteria
238
+ *
239
+ * @opaque
240
+ */
241
+ export type Match<S extends Lazy<ResourceShape>, T extends object> = Exclude<keyof T, keyof Criteria> extends Binding ? Row<T> : Detailed<S, Wanted<T>>;
242
+ /**
243
+ * Resolves the models for retrieving a resource restricted to a single collection.
244
+ *
245
+ * A slice is a specialised {@link Model | model} of the holding shape that targets a single collection, a property
246
+ * holding any number of resources. It names that property and nothing else, and states under it a
247
+ * {@link Model | template} or a {@link @grafctory/qest!Projection | projection} over the item shape, merged with
248
+ * filtering, ordering and pagination criteria for the collection. This way a collection retrieval is checked against
249
+ * the holding shape alone, just like a resource retrieval.
250
+ *
251
+ * {@link items} reads the retrieved items from the {@link Match | match}. {@link collection} resolves the property a
252
+ * slice names, and {@link blueprint} the shape new items of that collection must satisfy.
253
+ *
254
+ * Slices fail to compile if they name no property or more than one, or a property the shape doesn't declare. They also
255
+ * fail if the property isn't a collection, because it is single-valued or holds values other than resources, or if
256
+ * they request a member the item shape doesn't declare.
257
+ *
258
+ * The bare {@link resource!ResourceShape | ResourceShape} accepts any model naming a single property, and a generic
259
+ * {@link @grafctory/qest!Template | Template} is accepted as {@link Model} accepts it, so collection retrievals still
260
+ * compile where only a generic shape or model is known.
261
+ *
262
+ * @typeParam S The shape of the resource holding the collection, possibly deferred to break definition cycles
263
+ * @typeParam T The supplied model, typically inferred from the argument
264
+ *
265
+ * @opaque
266
+ */
267
+ export type Slice<S extends Lazy<ResourceShape>, T> = string extends keyof T ? Model<S, T> : ResourceShape extends Eager<S> ? Model<S, T> & Sole<keyof T> : Model<S, T> & Sole<keyof T> & {
268
+ readonly [F in keyof T]: F extends Repeated<S> ? Collecting<S, F, T[F]> : never;
269
+ };
270
+ /**
271
+ * Resolves the type of the items retrieved from a collection.
272
+ *
273
+ * Items are the array of {@link Frame | frames} that a {@link Slice | slice} retrieves from a collection.
274
+ * {@link items} extracts them from the {@link Match | match} of the retrieval, so callers don't need to look up the
275
+ * collection in the holding resource. Each frame is restricted to the members the slice asks for.
276
+ *
277
+ * Items are always an array, whatever the shape and model, so they are accepted wherever an iterable of items is
278
+ * expected, even in code generic over both. The bare {@link resource!ResourceShape | ResourceShape} or a generic
279
+ * {@link @grafctory/qest!Template | Template} resolves to an array of any {@link @grafctory/qest!Value | values}, so
280
+ * any collection result is accepted where only a generic shape or model is known.
281
+ *
282
+ * @typeParam S The shape of the resource holding the collection, possibly deferred to break definition cycles
283
+ * @typeParam T The slice, naming the collection property and the members wanted from each item, possibly
284
+ * with criteria; callers constrain it to the {@link Slice | slice} the shape allows, as with {@link Match}
285
+ *
286
+ * @opaque
287
+ */
288
+ export type Items<S extends Lazy<ResourceShape>, T extends object> = readonly Frame<S, T>[];
289
+ /**
290
+ * Resolves the type of a single item retrieved from a collection.
291
+ *
292
+ * A frame is one of the {@link Items | items} returned by a {@link Slice | slice} retrieval. For a template
293
+ * under the property, the item is restricted to the members the template names. For a projection, it is a computed
294
+ * row, keyed by the name before each binding's `=`. For an empty template, it is the item as stored, such as a
295
+ * {@link @grafctory/qest!Reference | reference}. Filtering, ordering and pagination criteria don't affect the item
296
+ * type. The bare {@link resource!ResourceShape | ResourceShape} or a generic
297
+ * {@link @grafctory/qest!Template | Template} resolves to any {@link @grafctory/qest!Value | value}.
298
+ *
299
+ * Code generic over the shape and the slice uses this type to name a single item, for instance to type the items
300
+ * flattened out of several retrievals.
301
+ *
302
+ * @typeParam S The shape of the resource holding the collection, possibly deferred to break definition cycles
303
+ * @typeParam T The slice, naming the collection property and the members wanted from each item, possibly
304
+ * with criteria; callers constrain it to the {@link Slice | slice} the shape allows, as with {@link Match}
305
+ *
306
+ * @opaque
307
+ */
308
+ export type Frame<S extends Lazy<ResourceShape>, T extends object> = string extends keyof T ? Value : Extract<Match<S, T>[keyof T & keyof Match<S, T>], readonly unknown[]>[number];
309
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/value/index.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB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AAC,CAAC,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA"}
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Copyright © 2025-2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { createNamespace } from "@grafctory/core/resource";
17
+ export { blueprint, collection, eager, effective, items } from "./accessors.js";
18
+ /**
19
+ * SHACL vocabulary namespace.
20
+ *
21
+ * An open {@link Namespace} over `http://www.w3.org/ns/shacl#`, resolving any SHACL term as a named property.
22
+ *
23
+ * @see {@link https://www.w3.org/TR/shacl/ SHACL - Shapes Constraint Language}
24
+ */
25
+ export const sh = createNamespace("http://www.w3.org/ns/shacl#");
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/value/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA4EH,OAAO,EAAE,eAAe,EAAkB,MAAM,0BAA0B,CAAC;AAc3E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGhF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,EAAE,GAAc,eAAe,CAAC,6BAA6B,CAAC,CAAC"}
@@ -0,0 +1,292 @@
1
+ /**
2
+ * Value inference.
3
+ *
4
+ * Type-level helpers behind the public value inference types: the plain value of a shape, the values allowed by
5
+ * enumeration constraints, the retrieval models allowed for each member, the collections a model may name, and the
6
+ * resources, rows and items a retrieval returns.
7
+ *
8
+ * > [!WARNING]
9
+ * > Provisional. Projection columns are typed as any value a resource may hold, since expressions are not checked
10
+ * > against the shape: callers needing a narrower type must state it themselves.
11
+ *
12
+ * @module
13
+ */
14
+ import type { Eager, Lazy, Optional } from "@grafctory/core";
15
+ import type { Atomic, Binding, Criteria, Locale, Projection, Query, Union } from "@grafctory/qest/model";
16
+ import type { Reference, Value, Values } from "@grafctory/qest/state";
17
+ import type { BooleanShape } from "../boolean/index.js";
18
+ import type { Coalesced, Tagged } from "../dictionary/inference.js";
19
+ import type { DictionaryShape } from "../dictionary/index.js";
20
+ import type { NumberShape } from "../number/index.js";
21
+ import type { ReferenceShape } from "../reference/index.js";
22
+ import type { Arity, Arrayed, Carried, Content, Identifier, Joined, Localised, Loose, Repeated, Slot } from "../resource/inference.js";
23
+ import type { Property, ResourceShape } from "../resource/index.js";
24
+ import type { StringShape } from "../string/index.js";
25
+ import type { Branch, Variant } from "../union/inference.js";
26
+ import type { Shape, State } from "./index.js";
27
+ /**
28
+ * Resolves the plain value type of a shape.
29
+ *
30
+ * Boolean, number and string shapes resolve to their primitive type, narrowed to the enumerated values if any.
31
+ * Dictionary shapes resolve to a language-tag-keyed map, with the per-tag cardinality set by the shape. Reference
32
+ * shapes resolve to a {@link Reference} to the target. Resource and union shapes have no plain value and resolve to
33
+ * `never`.
34
+ *
35
+ * @typeParam S The shape, possibly deferred to break definition cycles
36
+ */
37
+ export type Plain<S extends Lazy<Shape>> = Eager<S> extends BooleanShape<infer V> ? V : Eager<S> extends NumberShape<infer V> ? V : Eager<S> extends StringShape<infer V> ? V : Eager<S> extends infer D extends DictionaryShape ? Tagged<D> : Eager<S> extends ReferenceShape ? Reference : never;
38
+ /**
39
+ * Resolves the values allowed by a set of constraints.
40
+ *
41
+ * Resolves to the enumerated values if the constraints list them, either as an array or as a single value, and to the
42
+ * whole domain otherwise, so values of an enumerated shape are typed by the values they can actually take. Empty
43
+ * enumerations, and enumerations whose values are typed too broadly to tell apart, resolve to the whole domain.
44
+ *
45
+ * @typeParam C The constraints
46
+ * @typeParam D The domain of the values
47
+ */
48
+ export type Legal<C, D> = C extends {
49
+ readonly in: infer V extends readonly D[];
50
+ } ? [V[number]] extends [never] ? D : V[number] : C extends {
51
+ readonly in: infer V extends D;
52
+ } ? V : D;
53
+ /**
54
+ * Resolves the state of a resource to be persisted.
55
+ *
56
+ * Resolves to the state of the shape with an optional identifier.
57
+ *
58
+ * @typeParam S The resource shape, possibly deferred to break definition cycles
59
+ */
60
+ export type Drafted<S extends Lazy<ResourceShape>> = State<S> extends infer I ? Joined<{
61
+ readonly [K in keyof I as K extends Identifier<S> ? never : K]: I[K];
62
+ } & {
63
+ readonly [K in keyof I as K extends Identifier<S> ? K : never]?: I[K];
64
+ }> : never;
65
+ /**
66
+ * Resolves the entries a model may contain for the members of a resource.
67
+ *
68
+ * Every member of the shape, declared or inherited, is optional and may take any form its range supports; any other
69
+ * field of the supplied model accepts no value. There is no index signature, so a nested template naming no member of
70
+ * the resource is told apart from an atomic `{}` and rejected.
71
+ *
72
+ * @typeParam S The resource shape, possibly deferred to break definition cycles
73
+ * @typeParam T The supplied model, whose fields outside the members are rejected; omit it to reject nothing
74
+ */
75
+ export type Entries<S extends Lazy<ResourceShape>, T = never> = {
76
+ readonly [field in keyof Carried<S> | Strays<T, keyof Carried<S>>]?: field extends keyof Carried<S> ? Entry<Carried<S>[field]> : never;
77
+ };
78
+ /**
79
+ * Resolves the shape of the drafts posted to a resource or to one of its collection properties.
80
+ *
81
+ * Resolves to the shape a {@link Draft | draft} must satisfy. Without a slice, this is the resource shape itself. Given
82
+ * a slice, this is the shape of the new items of the collection property it names: the shape of the resources the
83
+ * property embeds, or of the ones its references point to, whether the property is declared or inherited. Resolves to
84
+ * `never` for properties holding values other than resources, such as plain values or unions of shapes. The bare
85
+ * resource shape, or a generic model naming no property, resolves to the bare resource shape, so drafts are still
86
+ * accepted where only a generic shape or model is known.
87
+ *
88
+ * @typeParam S The resource shape, or the shape of the resource holding the collection, possibly deferred to break
89
+ * definition cycles
90
+ * @typeParam T The slice naming the collection property; omit it to get the resource shape
91
+ */
92
+ export type Blueprint<S extends Lazy<ResourceShape>, T = never> = [
93
+ T
94
+ ] extends [never] ? S : string extends keyof T ? ResourceShape : ResourceShape extends Eager<S> ? S : {
95
+ [F in keyof T]: F extends Repeated<S> ? Linked<Carried<S>[F]> : never;
96
+ }[keyof T];
97
+ /**
98
+ * Resolves the models allowed for the items of a collection property.
99
+ *
100
+ * Resolves to the {@link Selection | selection models} of the item shape, or to `never` for properties holding values
101
+ * other than resources, which allow no model.
102
+ *
103
+ * @typeParam S The shape of the resource holding the collection
104
+ * @typeParam F The name of the collection property
105
+ * @typeParam T The supplied item model, whose fields outside what the item shape allows are rejected
106
+ */
107
+ export type Collecting<S extends Lazy<ResourceShape>, F extends Repeated<S>, T> = [
108
+ Linked<Carried<S>[F]>
109
+ ] extends [never] ? never : Selection<Linked<Carried<S>[F]>, T>;
110
+ /**
111
+ * Checks that a set of keys contains exactly one key.
112
+ *
113
+ * Resolves to `unknown`, which constrains nothing, for a single key, and to `never` for none or several.
114
+ *
115
+ * @typeParam K The keys to check
116
+ */
117
+ export type Sole<K extends PropertyKey> = {
118
+ [P in K]: [Exclude<K, P>] extends [never] ? unknown : never;
119
+ }[K];
120
+ /**
121
+ * Resolves what a template retrieves from a resource.
122
+ *
123
+ * Resolves to the value of the shape restricted to the members the template names, including those of nested
124
+ * templates, so callers get back exactly what they asked for. A collection requested with a projection holds the
125
+ * {@link Row | rows} the projection computes. Depth, cardinality and optionality come from the shape: the template
126
+ * only selects which values to return.
127
+ *
128
+ * Members the template omits are omitted from the result; a member the template doesn't narrow resolves as it would in
129
+ * {@link State}. The one exception is a localised member asked for by the atomic placeholder: it resolves to its
130
+ * {@link Coalesced | coalesced} text rather than to its tag-keyed map, as the retrieval returns it. The bare resource
131
+ * shape declares no member, so every member the template names resolves to any value a resource may hold.
132
+ *
133
+ * > [!WARNING]
134
+ * > Provisional. Every value type comes from the shape and the template contributes only the set of keys, so some
135
+ * > forms resolve to a broad type; callers needing the narrow type must state it themselves:
136
+ * >
137
+ * > - **polymorphic member**: `{ code: { "0": {} } }` resolves to the whole union, `string | number`, since branches
138
+ * > are not resolved one by one
139
+ * > - **projection column**: `{ vendors: { "n=name": {} } }` resolves to rows whose columns hold any value, since
140
+ * > bindings are not read as expressions
141
+ * > - **localised member**: `{ label: { "*": {} } }` resolves to the full tag map, since language ranges are not
142
+ * > narrowed
143
+ * >
144
+ * > All three are the same limit: a value is resolved against its whole shape, never against a single branch,
145
+ * > expression or language range within it.
146
+ *
147
+ * @typeParam S The shape the retrieval runs against, possibly deferred to break definition cycles
148
+ * @typeParam T The {@link Wanted | retrieval keys} of the template
149
+ */
150
+ export type Detailed<S extends Lazy<ResourceShape>, T> = ResourceShape extends Eager<S> ? {
151
+ readonly [field in keyof T]: Optional<Values>;
152
+ } : Loose<Pick<Carried<S>, keyof Carried<S> & keyof T>> extends infer M ? {
153
+ readonly [field in keyof M]: Narrowed<M[field], T[field & keyof T]>;
154
+ } : never;
155
+ /**
156
+ * Keeps the retrieval keys of a template.
157
+ *
158
+ * Resolves to the members named by plain identifiers, dropping constraint operators and projection bindings, which
159
+ * share the same key space, so the result is a valid template in its own right. A generic template names no member
160
+ * and keeps none.
161
+ *
162
+ * @typeParam T The template to read, or the entry a template states for a member
163
+ */
164
+ export type Wanted<T> = {
165
+ readonly [field in keyof T as string extends field ? never : field extends keyof Criteria | Binding ? never : field]: T[field];
166
+ };
167
+ /**
168
+ * Resolves a row returned by a projection.
169
+ *
170
+ * Has one column per binding, keyed by the name before the binding's `=`, so callers read rows by the names they
171
+ * chose; criteria keys mixed in with the bindings produce no column.
172
+ *
173
+ * @typeParam T The projection model
174
+ */
175
+ export type Row<T> = {
176
+ readonly [field in keyof T as Name<field>]: Optional<Value>;
177
+ };
178
+ /**
179
+ * Resolves the fields of a model that aren't among the allowed ones.
180
+ *
181
+ * Used to reject unknown fields when checking a model against a shape, so that an unknown member listed next to known
182
+ * ones is refused instead of slipping through. Only fields with literal names are checked: a model typed as a generic
183
+ * template has no named fields and is accepted as is.
184
+ *
185
+ * @typeParam T The supplied model, typically inferred from the argument
186
+ * @typeParam K The allowed fields, as literal names or patterns
187
+ */
188
+ type Strays<T, K extends PropertyKey> = string extends keyof T ? never : Exclude<keyof T & string, K>;
189
+ /**
190
+ * Resolves the retrieval models allowed for selecting resources.
191
+ *
192
+ * A selection model is either a {@link Model | template} allowed by the shape or a
193
+ * {@link @grafctory/qest!Projection | projection} computing rows, each merged with filtering, ordering and pagination
194
+ * criteria. A model passed as `T` must fit one of the two entirely: unknown members mixed with known ones, and members
195
+ * mixed with projection bindings, fail to compile.
196
+ *
197
+ * @typeParam S The shape of the selected resources, possibly deferred to break definition cycles
198
+ * @typeParam T The supplied model, whose fields outside what each alternative allows are rejected; omit it to accept
199
+ * any model fitting either alternative
200
+ */
201
+ type Selection<S extends Lazy<ResourceShape>, T = never> = Query<Entries<S, T> | Projection & {
202
+ readonly [field in Strays<T, Binding | keyof Criteria>]?: never;
203
+ }>;
204
+ /**
205
+ * Resolves the entry a model may contain for a member.
206
+ *
207
+ * Identifiers and types take an atomic. Properties take the forms their range supports; multi-valued properties also
208
+ * take a projection, and either form may be merged with collection criteria.
209
+ *
210
+ * @typeParam M The requested member
211
+ */
212
+ type Entry<M> = M extends Property<infer R> ? Arrayed<M> extends true ? Query<Placeholding<R> | Projection> : Placeholding<R> : Atomic;
213
+ /**
214
+ * Resolves the forms a range supports for one of its values.
215
+ *
216
+ * Resolves to an atomic, plus a nested template for each resource the range reaches, a locale if the range admits
217
+ * localised text, and a branch map if the range mixes kinds of value, with each branch taking any of these forms.
218
+ *
219
+ * @typeParam R The range, possibly deferred to break definition cycles
220
+ */
221
+ type Placeholding<R extends Lazy<Shape>> = Atomic | Expanded<R> | Tagging<R> | ([Branch<R>] extends [never] ? never : Union<Atomic | Expanded<R> | Tagging<R>>);
222
+ /**
223
+ * Resolves the locale a range supports, if it admits localised text.
224
+ *
225
+ * @typeParam R The range, possibly deferred to break definition cycles
226
+ */
227
+ type Tagging<R extends Lazy<Shape>> = [
228
+ Extract<Variant<R>, DictionaryShape>
229
+ ] extends [never] ? never : Locale;
230
+ /**
231
+ * Resolves the nested templates for the resources a range reaches.
232
+ *
233
+ * Covers both link targets and embedded resources, for every branch of the range; branches reaching no resource
234
+ * contribute no template.
235
+ *
236
+ * @typeParam R The range, possibly deferred to break definition cycles
237
+ */
238
+ type Expanded<R extends Lazy<Shape>> = Reached<Variant<R>> extends infer T ? T extends Lazy<ResourceShape> ? Entries<T> : never : never;
239
+ /**
240
+ * Resolves the resource a shape reaches.
241
+ *
242
+ * Resolves to the target of a link or to an embedded resource, and to `never` for shapes of any other kind; given a
243
+ * union of shapes, resolves each one separately.
244
+ *
245
+ * @typeParam V The eager shape
246
+ */
247
+ type Reached<V> = V extends ReferenceShape<infer T extends Lazy<ResourceShape>> ? T : V extends ResourceShape ? V : never;
248
+ /**
249
+ * Resolves the resource a range reaches.
250
+ *
251
+ * Resolves to the target of a link or to an embedded resource, and to `never` for ranges reaching no resource of their
252
+ * own, including ranges mixing several kinds of value and the bare shape.
253
+ *
254
+ * @typeParam R The range, possibly deferred to break definition cycles
255
+ */
256
+ type Target<R extends Lazy<Shape>> = Shape extends Eager<R> ? never : Reached<Eager<R>>;
257
+ /**
258
+ * Resolves the resource a member reaches.
259
+ *
260
+ * Resolves to the resource the {@link Target | range of a property reaches}, and to `never` for identifiers, types and
261
+ * voided members.
262
+ *
263
+ * @typeParam M The member to reach through
264
+ */
265
+ type Linked<M> = M extends Property<infer R> ? Target<R> : never;
266
+ /**
267
+ * Narrows the value of a member to what the template requests for it.
268
+ *
269
+ * If the entry is a projection over a collection, resolves to the {@link Row | rows} it computes. If the member reaches
270
+ * a resource and the template requests members of it, resolves to the {@link Detailed | detailed} resource at the
271
+ * cardinality of the member. If the entry is the atomic placeholder, resolves to the value the shape describes, with
272
+ * localised text in its {@link Coalesced | coalesced} form rather than as a tag-keyed map. Otherwise, as for a branch
273
+ * map or a language range, resolves to the value exactly as the shape describes it, tag-keyed maps included.
274
+ *
275
+ * @typeParam M The member to narrow
276
+ * @typeParam A The template entry for the member
277
+ */
278
+ type Narrowed<M, A> = [
279
+ Extract<Exclude<keyof A, keyof Criteria>, Binding>
280
+ ] extends [never] ? M extends Property<infer R, infer L, infer U> ? [keyof Wanted<A>] extends [never] ? Slot<R, L, U, Coalesced<Localised<R>>> : [Target<R>] extends [never] ? Content<M> : Arity<Detailed<Target<R>, Wanted<A>>, L, U> : Content<M> : readonly Row<A>[];
281
+ /**
282
+ * Maps a projection model key to the name of the column it produces.
283
+ *
284
+ * - **drops** `Criteria` constraint and pagination keys
285
+ * - **extracts** the name from computed `Binding` keys (`name=expression`)
286
+ * - **keeps** plain identifier keys unchanged
287
+ *
288
+ * @typeParam K The key to map
289
+ */
290
+ type Name<K> = K extends keyof Criteria ? never : K extends `${infer I}=${string}` ? I : K;
291
+ export {};
292
+ //# sourceMappingURL=inference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../src/value/inference.ts"],"names":[],"mappings":"AAgBA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACzG,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,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