@grafctory/blue 0.0.0-stage → 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 (139) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +524 -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 +178 -0
  18. package/dist/dictionary/assembler.js.map +1 -0
  19. package/dist/dictionary/index.d.ts +237 -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 +37 -0
  28. package/dist/dictionary/validator.d.ts.map +1 -0
  29. package/dist/dictionary/validator.js +106 -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 +903 -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 +1013 -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,903 @@
1
+ /**
2
+ * Resource shape types and operations.
3
+ *
4
+ * Defines the shapes describing linked data resources and the members they carry, and provides the factories stating
5
+ * them and the accessors reading them. The {@link resource} factory states a shape, extending the shapes it is given
6
+ * and closed over the members declared for it; the member factories give each member the shape its values are drawn
7
+ * from and how many of them a resource may carry.
8
+ *
9
+ * > [!IMPORTANT]
10
+ * > Resource shapes are **closed**: a validated resource carries only the members the shape declares, and any other
11
+ * > field is rejected.
12
+ *
13
+ * > [!IMPORTANT]
14
+ * > Every IRI a validated resource carries is absolute. Relative references are resolved against a base as client
15
+ * > input is decoded, before validation sees them.
16
+ *
17
+ * **Defining resource shapes**
18
+ *
19
+ * Give each member a range and a cardinality:
20
+ *
21
+ * ```typescript
22
+ * import { boolean } from '@grafctory/blue/boolean';
23
+ * import { integer } from '@grafctory/blue/number';
24
+ * import { id, nonempty, optional, required, resource } from '@grafctory/blue/resource';
25
+ * import { string } from '@grafctory/blue/string';
26
+ *
27
+ * const Product = resource({
28
+ * id: id(),
29
+ * name: required(string({ minLength: 1 })),
30
+ * price: required(integer({ minInclusive: 0 })),
31
+ * available: optional(boolean()),
32
+ * tags: nonempty(string())
33
+ * });
34
+ * ```
35
+ *
36
+ * The four named cardinalities cover `1..1`, `0..1`, `1..*` and `0..*`; {@link property} states any other bounds:
37
+ *
38
+ * ```typescript
39
+ * const Shape = resource({
40
+ * name: required(string()), // 1..1
41
+ * alias: optional(string()), // 0..1
42
+ * tags: nonempty(string()), // 1..*
43
+ * notes: multiple(string()), // 0..*
44
+ * codes: property(string(), { minCount: 2, maxCount: 5 }) // 2..5
45
+ * });
46
+ * ```
47
+ *
48
+ * A member ranging over a {@link dictionary!dictionary | dictionary} stands apart from its cardinality: it carries the
49
+ * language map whole at every one, never in an array, and the bounds count the values of its other alternatives alone.
50
+ *
51
+ * Each factory takes, after the range, the constraints the member carries beyond its cardinality, such as the
52
+ * predicate it maps to, the labels it carries, or whether it is serialised by default:
53
+ *
54
+ * ```typescript
55
+ * import { createNamespace } from '@grafctory/core/resource';
56
+ *
57
+ * const schema = createNamespace("http://schema.org/");
58
+ *
59
+ * const Person = resource({
60
+ * name: required(string(), { forward: schema })
61
+ * });
62
+ * ```
63
+ *
64
+ * **Linked and embedded resources**
65
+ *
66
+ * A member reaches another resource in one of two ways. A {@link reference!reference | reference} links a
67
+ * **standalone** resource, identified and managed in its own right; a resource shape included directly describes an
68
+ * **embedded** resource, carried inline with no identity of its own.
69
+ *
70
+ * ```typescript
71
+ * import { reference } from '@grafctory/blue/reference';
72
+ *
73
+ * const Rating = resource({
74
+ * average: required(number({ minInclusive: 0, maxInclusive: 5 })),
75
+ * reviews: required(number({ minInclusive: 0 }))
76
+ * });
77
+ *
78
+ * const Product = resource({
79
+ * id: id(),
80
+ * rating: optional(Rating), // embedded
81
+ * vendor: required(reference(Vendor)) // standalone
82
+ * });
83
+ * ```
84
+ *
85
+ * An embedded resource carries no {@link id} member: having no identity of its own, an identifier is rejected as a
86
+ * value is validated rather than as the shape is built, since an id-bearing embedded range reads exactly like an
87
+ * expanded captive target until a value is matched against it.
88
+ *
89
+ * A shape reaching itself defers the range, breaking the definition cycle:
90
+ *
91
+ * ```typescript
92
+ * function Category() {
93
+ * return resource({
94
+ * id: id(),
95
+ * name: required(string()),
96
+ * parent: optional(reference(Category))
97
+ * });
98
+ * }
99
+ * ```
100
+ *
101
+ * Only a link breaks the cycle. An embedded resource is carried inline, so a shape that embeds itself, directly or
102
+ * through other embedded resources or unions, admits no finite value and is rejected as its definition is resolved.
103
+ *
104
+ * **Inheritance**
105
+ *
106
+ * A shape extends the ones it is given first, carrying their members and constraints:
107
+ *
108
+ * ```typescript
109
+ * const NamedEntity = resource({
110
+ * id: id(),
111
+ * name: required(string({ minLength: 1 }))
112
+ * });
113
+ *
114
+ * const Employee = resource(NamedEntity, {
115
+ * department: required(string()),
116
+ * salary: required(integer({ minInclusive: 0 }))
117
+ * });
118
+ * ```
119
+ *
120
+ * > [!IMPORTANT]
121
+ * > Constraints accumulate: a value is held to the constraints the extending shape states **and** to every one it
122
+ * > inherits. An override tightens what it inherits and never relaxes it.
123
+ *
124
+ * A shape extending several others is held to each of them, whatever order they are listed in. A member stated by
125
+ * several parents takes the narrowest of their definitions, and a member the shape redeclares must narrow each one.
126
+ *
127
+ * A member reaching a resource is refined by re-pointing it at a shape extending the inherited target: the refinement
128
+ * states what it adds alone, as the narrower target carries the inherited definition through its own parents, the
129
+ * {@link ResourceConstraints.class | classes} it belongs to included, which every value the refined member admits is
130
+ * held to. A {@link union!union | union}-valued member is refined by dropping alternatives and tightening the ones it
131
+ * keeps, never by adding new ones.
132
+ *
133
+ * A member embedding the same shape along every inheritance path keeps that shape as declared, as in a diamond
134
+ * inheriting one declaration through two parents, so code comparing shapes by reference finds a single shape. A
135
+ * member embedding different shapes along different paths ranges over a new merged shape instead. This happens when
136
+ * an embedded member is re-pointed at a narrower shape, or when parents embed different shapes under the same member,
137
+ * and the merged shape is distinct from every declared one, the narrowest included. Separate calls build separate
138
+ * shapes, even where they state the same constraints, so a definition shared along several paths is passed as its
139
+ * factory, as in `optional(Image)`, rather than as `optional(Image())`, which builds a new shape at each call.
140
+ *
141
+ * **Reading a resource off a shape**
142
+ *
143
+ * {@link getShapeClass} and {@link getShapeClasses} resolve the classes the resources a shape describes belong to,
144
+ * {@link getShapeId} and {@link getShapeType} the names their identifier and class are stated under, and
145
+ * {@link getShapeProperties} the members they carry. Each resolves a deferred shape and crosses a link through to the
146
+ * resource behind it, answering with nothing where the shape reaches no resource at all.
147
+ *
148
+ * **Reading a state off a shape**
149
+ *
150
+ * {@link getStateId} returns the identifier a state carries, and {@link getStateEntries} returns its values, each
151
+ * typed by the value shape it matches. Both validate the state against the shape and reject it if it doesn't conform.
152
+ *
153
+ * @module
154
+ *
155
+ * @see {@link https://www.w3.org/TR/shacl/ SHACL - Shapes Constraint Language}
156
+ * @see {@link https://www.w3.org/TR/shacl/#ClosedConstraintComponent SHACL § 4.8.1 sh:closed}
157
+ */
158
+ import type { Identifier, Lazy, Optional } from "@grafctory/core";
159
+ import type { Namespace } from "@grafctory/core/resource";
160
+ import { type Validator } from "@grafctory/core/trace";
161
+ import type { Dictionary, Reference, Resource } from "@grafctory/qest/state";
162
+ import type { Range, Shape } from "../value/index.js";
163
+ import type { Declared, Unbounded } from "./inference.js";
164
+ export { getShapeClass, getShapeClasses, getShapeId, getShapeType, getShapeProperties, getStateId, getStateEntries, type Entry } from "./accessors.js";
165
+ /**
166
+ * Describes a linked data resource.
167
+ *
168
+ * Admits the [resources](https://www.w3.org/TR/rdf11-concepts/) a store holds: a record carrying the members the
169
+ * shape declares, and nothing else, so that what a resource may state is fixed by the shape rather than left to
170
+ * whoever writes it. A shape extends the shapes it lists as `parents`, carrying their members and constraints on top
171
+ * of its own.
172
+ *
173
+ * **Inheritance**
174
+ *
175
+ * Where a shape extends the ones it lists as `parents`, they are merged according to the following rules. The *child*
176
+ * is the extending shape; the *parent* is the inherited one.
177
+ *
178
+ * | Field | Override Rule |
179
+ * | ------------- | ------------------------------------------------------------------------------------- |
180
+ * | `kind` | Cannot be overridden |
181
+ * | `name` | Always from the child; not inherited |
182
+ * | `description` | Always from the child; not inherited |
183
+ * | `space` | Inherited; conflicting parents without a child override are reported as an error |
184
+ * | `class` | Always from the child; not inherited |
185
+ * | `classes` | Computed from the `class` of the shapes extended; never stated |
186
+ * | `pattern` | Only a trailing `/*` admits narrowing; any other case requires equality |
187
+ * | `in` | Child may only drop allowed identifiers |
188
+ * | `hasValue` | Child may only add required identifiers |
189
+ * | `members` | Declared members narrow every parent definition; others take the narrowest one |
190
+ * | `validators` | Union of the checks stated and the ones inherited; every check applies |
191
+ *
192
+ * A resource the child admits is an instance of every parent. A member stated by several parents therefore takes the
193
+ * definition narrowing all the others, whatever order the parents are listed in, and a member the child declares must
194
+ * narrow the definition of each parent stating it. If no parent definition narrows all the others, an error is
195
+ * reported unless the child redeclares the member to narrow each one, for instance by combining their bounds. Parents
196
+ * disagreeing on `hidden`, `name` or `description` are reconciled by a child stating its own value. A disagreement
197
+ * on any other facet can't be reconciled, as no override may change a facet restricting the values admitted.
198
+ *
199
+ * **Cross-field validation**
200
+ *
201
+ * - all merged `hasValue` entries must be members of the merged `in` set (if defined)
202
+ * - at most one `id` member and one `type` member, counted after inheritance
203
+ * - no two members may share a forward predicate, nor two a reverse predicate
204
+ * - a member stating a reverse predicate must range over resources alone (references, embedded resources, or unions
205
+ * of them)
206
+ *
207
+ * @typeParam P The shapes extended, possibly deferred to break definition cycles
208
+ * @typeParam M The members declared in the shape's own right
209
+ *
210
+ * @see {@link https://www.w3.org/TR/shacl/#node-shapes SHACL § 2.2 Node Shapes}
211
+ */
212
+ export type ResourceShape<P extends Parents = Parents, M extends Members = Members> = ResourceConstraints & {
213
+ /**
214
+ * Discriminator identifying this as a resource shape.
215
+ *
216
+ * **Inheritance** — cannot be overridden.
217
+ */
218
+ readonly kind: "resource";
219
+ /**
220
+ * The classes a resource belongs to beyond the one its shape states.
221
+ *
222
+ * Lists the {@link ResourceConstraints.class | class} every extended shape states, transitively and deduplicated,
223
+ * so that a caller may test a resource against a supertype without walking the inheritance chain itself. Each
224
+ * extended shape contributes the class it states, followed by the ones it inherits in turn, in the order the
225
+ * shapes are extended. A shape extending nothing that states a class is empty.
226
+ *
227
+ * Together with the class the shape states in its own right, this is the lineage a shape is held to where it stands
228
+ * in for another as a member range.
229
+ *
230
+ * **Inheritance** — computed from the `class` of the shapes extended; never stated.
231
+ *
232
+ * @see {@link https://www.w3.org/TR/shacl/#ClassConstraintComponent SHACL § 4.1.1 sh:class}
233
+ */
234
+ readonly classes: readonly Reference[];
235
+ /**
236
+ * The shapes extended, each possibly deferred to break definition cycles.
237
+ *
238
+ * Their members and constraints reach every resource this shape describes, so an extending shape states what it
239
+ * adds or tightens alone.
240
+ *
241
+ * **Inheritance** — states the shapes extended in the shape's own right, and is never itself inherited.
242
+ */
243
+ readonly parents: P;
244
+ /**
245
+ * The members a resource carries.
246
+ *
247
+ * Merged as the shape is built: the members declared in the shape's own right override the ones the extended shapes
248
+ * contribute, so a caller reads what a resource carries off the shape rather than by walking the inheritance chain.
249
+ * The shape is closed, so a resource carrying anything else is rejected.
250
+ *
251
+ * **Inheritance** — a declared member narrows the definition of every parent stating it; an undeclared member
252
+ * stated by several parents takes the narrowest definition, whatever order the parents are listed in.
253
+ */
254
+ readonly members: M;
255
+ };
256
+ /**
257
+ * Constraints accepted by the {@link resource} shape factory.
258
+ *
259
+ * States what a resource is called, where its members resolve their predicates, what class it belongs to and which
260
+ * identifiers it may be named by; the members it carries are stated apart.
261
+ *
262
+ * @see {@link https://www.w3.org/TR/shacl/#node-shapes SHACL § 2.2 Node Shapes}
263
+ */
264
+ export type ResourceConstraints = {
265
+ /**
266
+ * Human-readable name for the shape.
267
+ *
268
+ * Accepts a localised {@link Dictionary} or, as a shorthand for the English-only case, a plain
269
+ * {@link string!text | text} string, expanded to `{ en: <value> }` on the
270
+ * {@link ResourceShape.name | built shape}.
271
+ *
272
+ * **Inheritance** — always from the child; not inherited.
273
+ *
274
+ * @remarks
275
+ *
276
+ * SHACL defines sh:name only for property shapes; extended here to node shapes.
277
+ *
278
+ * @see {@link https://www.w3.org/TR/shacl/#name SHACL § 2.3.2.1 sh:name and sh:description}
279
+ */
280
+ readonly name?: string | Dictionary;
281
+ /**
282
+ * Human-readable description of the shape.
283
+ *
284
+ * Accepts a localised {@link Dictionary} or, as a shorthand for the English-only case, a
285
+ * {@link string!markdown | Markdown} string, expanded to `{ en: <value> }` on the
286
+ * {@link ResourceShape.description | built shape}.
287
+ *
288
+ * **Inheritance** — always from the child; not inherited.
289
+ *
290
+ * @remarks
291
+ *
292
+ * SHACL defines sh:description only for property shapes; extended here to node shapes.
293
+ *
294
+ * @see {@link https://www.w3.org/TR/shacl/#name SHACL § 2.3.2.1 sh:name and sh:description}
295
+ */
296
+ readonly description?: string | Dictionary;
297
+ /**
298
+ * Default namespace for mapping member names to predicates.
299
+ *
300
+ * A member stating neither a {@link PropertyConstraints.forward | forward} nor a
301
+ * {@link PropertyConstraints.reverse | reverse} mapping is stored under its own name resolved against this space.
302
+ *
303
+ * **Inheritance** — inherited; conflicting parents without a child override are reported as an error.
304
+ *
305
+ * @defaultValue the {@link @grafctory/core!base | base} namespace (`base:/#`)
306
+ */
307
+ readonly space?: Namespace;
308
+ /**
309
+ * Target class for resource instances.
310
+ *
311
+ * The absolute IRI naming the primary class a resource belongs to, stated by each shape in its own right. Where the
312
+ * shape declares a {@link type} member, that member carries this class as its value; the classes inherited on top
313
+ * of it are read off `classes`.
314
+ *
315
+ * A class is an obligation on the resources a shape describes, so a shape standing in for another as a member range
316
+ * must belong to every class that one declares, whether stated in its own right or inherited: a shape merely
317
+ * repeating the members of the one it stands in for is rejected.
318
+ *
319
+ * **Inheritance** — always from the child; not inherited.
320
+ *
321
+ * @see {@link https://www.w3.org/TR/shacl/#targetClass SHACL § 2.1.3.2 sh:targetClass}
322
+ */
323
+ readonly class?: Reference;
324
+ /**
325
+ * IRI path pattern that resource {@link Id identifiers} must match.
326
+ *
327
+ * Patterns are IRI-like templates: `{name}` stands for a single path segment and a trailing `/*` for one or more.
328
+ * A pattern ending in `/` names a container, such as a catalogue root, and matches only identifiers ending in that
329
+ * slash. Patterns may be absolute or root-relative; root-relative patterns match absolute IRIs, ignoring the
330
+ * origin. A `/*` wildcard standing alone on the root path admits every identifier under the origin, at any depth.
331
+ *
332
+ * The pattern binds only the identifier a resource states, so a resource stating no identifier is accepted.
333
+ *
334
+ * **Inheritance** — only the trailing `/*` wildcard admits narrowing: a child may replace `/*` with more specific
335
+ * segments (for example, `/products/*` to `/products/{id}/reviews/{rid}`), provided the fixed prefix matches.
336
+ * All other cases require exact equality; a mismatch is reported as an error.
337
+ *
338
+ * @defaultValue `undefined` (no pattern constraint)
339
+ *
340
+ * @example
341
+ * ```
342
+ * https://example.org/products/{sku} → https://example.org/products/ABC-456
343
+ * https://example.org/categories/* → https://example.org/categories/electronics/phones
344
+ * https://example.org/* → https://example.org/catalogues/2026
345
+ *
346
+ * /employees/{id} → https://example.org/employees/123
347
+ * /departments/* → https://example.org/departments/sales/emea
348
+ * ```
349
+ */
350
+ readonly pattern?: string;
351
+ /**
352
+ * Allowed resource {@link Id identifiers} (closed enumeration).
353
+ *
354
+ * When specified, resource identifiers must be members of this list. IRIs must be absolute. Empty arrays are
355
+ * ignored. The list binds only the identifier a resource states, so a resource stating no identifier is accepted.
356
+ *
357
+ * **Inheritance** — child may only drop allowed identifiers.
358
+ *
359
+ * @defaultValue `undefined` (no enumeration constraint)
360
+ *
361
+ * @see {@link https://www.w3.org/TR/shacl/#InConstraintComponent SHACL § 4.8.3 sh:in}
362
+ */
363
+ readonly in?: readonly Reference[];
364
+ /**
365
+ * Resource {@link Id identifiers} a resource must be named by.
366
+ *
367
+ * When specified, the identifier must equal every listed value, so a shape listing two or more admits no resource
368
+ * at all. IRIs must be absolute. Empty arrays are ignored.
369
+ *
370
+ * A resource stating no identifier is accepted, where SHACL would reject it as matching no listed value. A member
371
+ * ranging over values is held to its own `hasValue` even where it carries none, as an absent value never matches.
372
+ *
373
+ * **Inheritance** — child may only add required identifiers.
374
+ *
375
+ * @defaultValue `undefined` (no required values)
376
+ *
377
+ * @see {@link https://www.w3.org/TR/shacl/#HasValueConstraintComponent SHACL § 4.8.2 sh:hasValue}
378
+ */
379
+ readonly hasValue?: readonly Reference[];
380
+ /**
381
+ * Custom checks a resource must pass beyond the declarative constraints.
382
+ *
383
+ * Carries the constraints a shape cannot state declaratively: each is handed the whole resource and reports what
384
+ * it finds as a {@link @grafctory/core!Trace | Trace}, or `undefined` where the resource passes. Every check runs,
385
+ * so a resource is told everything that is wrong with it at once rather than one thing at a time, and each trace
386
+ * is keyed by the name of the check reporting it.
387
+ *
388
+ * > [!IMPORTANT]
389
+ * > Checks run only where a whole resource is validated, never against a retrieval template or the resources it
390
+ * > retrieves: a retrieval may leave out any member a check reads, failing the check on data it never asked for.
391
+ *
392
+ * **Inheritance** — union of the checks stated and the ones inherited; every check applies.
393
+ *
394
+ * @see {@link https://www.w3.org/TR/shacl/#constraints SHACL § 2.1.1 Constraint Components}
395
+ */
396
+ readonly validators?: readonly Validator<Resource>[];
397
+ };
398
+ /**
399
+ * The shapes a resource shape extends.
400
+ *
401
+ * Retains the order the shapes were stated in, so that a shape reached along several inheritance paths is resolved
402
+ * against a stable sequence; order carries no priority, as every extended shape contributes.
403
+ */
404
+ export type Parents = readonly Lazy<ResourceShape>[];
405
+ /**
406
+ * The members a resource carries, keyed by the name each is stated under.
407
+ *
408
+ * The name doubles as the field a resource states the member under and as the term resolved against the shape's
409
+ * {@link ResourceConstraints.space | space} where the member maps to no predicate of its own.
410
+ */
411
+ export type Members = {
412
+ readonly [field: Identifier]: Member;
413
+ };
414
+ /**
415
+ * A member a resource carries.
416
+ *
417
+ * Either of the two members naming a resource, {@link Id} and {@link Type}, or a {@link Property} carrying values of
418
+ * its own.
419
+ */
420
+ export type Member = Id | Type | Property;
421
+ /**
422
+ * The member naming a resource.
423
+ *
424
+ * Carries the absolute IRI a resource is identified by, mapped to the JSON-LD `@id` keyword. A shape states at most
425
+ * one, counted once inheritance has merged the members.
426
+ *
427
+ * @see {@link https://www.w3.org/TR/json-ld11/#node-identifiers JSON-LD 1.1 § 3.3 Node Identifiers}
428
+ */
429
+ export type Id = {
430
+ /**
431
+ * Discriminator identifying this as the member naming a resource.
432
+ *
433
+ * **Inheritance** — cannot be overridden.
434
+ */
435
+ readonly kind: "id";
436
+ /**
437
+ * Excludes the member from default serialisation.
438
+ *
439
+ * **Inheritance** — always from the most derived declaration, which replaces the inherited marker rather than
440
+ * merging with it; conflicting parents resolve to the first declared, and never to an error as they do for a
441
+ * {@link PropertyConstraints.hidden | property}.
442
+ *
443
+ * @defaultValue `undefined` (`false`)
444
+ */
445
+ readonly hidden?: boolean;
446
+ };
447
+ /**
448
+ * The member typing a resource.
449
+ *
450
+ * Carries the absolute IRI of the class a resource belongs to, mapped to the JSON-LD `@type` keyword. The value is
451
+ * derived from the {@link ResourceConstraints.class | class} the shape states, so a shape stating none admits no
452
+ * value for it. A shape states at most one, counted as {@link Id} is.
453
+ *
454
+ * @see {@link https://www.w3.org/TR/json-ld11/#specifying-the-type JSON-LD 1.1 § 3.5 Specifying the Type}
455
+ */
456
+ export type Type = {
457
+ /**
458
+ * Discriminator identifying this as the member typing a resource.
459
+ *
460
+ * **Inheritance** — cannot be overridden.
461
+ */
462
+ readonly kind: "type";
463
+ /**
464
+ * Excludes the member from default serialisation.
465
+ *
466
+ * **Inheritance** — always from the most derived declaration, which replaces the inherited marker rather than
467
+ * merging with it; conflicting parents resolve to the first declared, and never to an error as they do for a
468
+ * {@link PropertyConstraints.hidden | property}.
469
+ *
470
+ * @defaultValue `undefined` (`false`)
471
+ */
472
+ readonly hidden?: boolean;
473
+ };
474
+ /**
475
+ * A member carrying values of its own.
476
+ *
477
+ * Holds the {@link Range | range} its values are drawn from, stating their shape and how many of them a resource may
478
+ * carry, alongside the predicate the values are stored under and the labels the member is presented by. The predicate
479
+ * is an absolute IRI: a {@link Namespace} shorthand stated where the member is declared is resolved by the time the
480
+ * shape is built.
481
+ *
482
+ * Localised text stands apart from the cardinality: a member ranging over a
483
+ * {@link dictionary!DictionaryShape | dictionary} carries the language map whole, never in an array, whatever bounds
484
+ * it states; one ranging over a dictionary alongside other alternatives carries either the map or the values of those
485
+ * alternatives, never both, and the bounds count the latter alone.
486
+ *
487
+ * **Inheritance**
488
+ *
489
+ * Where a shape extends the ones it lists as `parents`, members stated on both sides are merged according to the
490
+ * following rules. The *child* is the extending shape; the *parent* is the inherited one.
491
+ *
492
+ * | Field | Override Rule |
493
+ * | ------------- | -------------------------------------------------------------------------------- |
494
+ * | `kind` | Cannot be overridden |
495
+ * | `hidden` | Inherited; child may replace it; conflicting parents require a child override |
496
+ * | `foreign` | Inherited; child may state it where the parent doesn't, never change it |
497
+ * | `captive` | Inherited; child may state it where the parent doesn't, never change it |
498
+ * | `name` | Inherited; child may replace it; conflicting parents require a child override |
499
+ * | `description` | Inherited; child may replace it; conflicting parents require a child override |
500
+ * | `forward` | Taken from the parent if the child states no mapping, else equal to the parent's |
501
+ * | `reverse` | Taken from the parent if the child states no mapping, else equal to the parent's |
502
+ * | `range` | Child may only narrow the inherited range, bound by bound and shape by shape |
503
+ *
504
+ * A child narrows the range it inherits by raising its lower bound, lowering its upper bound or restricting its
505
+ * shape, and never the other way round. A bound left unstated leaves that end unbounded rather than unsaid, so a
506
+ * child stating none inherits the bound the parent states.
507
+ *
508
+ * A child narrowing a {@link ResourceShape | resource} range states a shape belonging to every
509
+ * {@link ResourceConstraints.class | class} the inherited range declares, whether stated in its own right or
510
+ * inherited, so that a value of the narrowed member is a value of the inherited one, class included.
511
+ *
512
+ * A child overriding a {@link union!UnionShape | polymorphic} range either narrows it to the single alternative it
513
+ * restricts, restating no wrapper of its own, or states a union of its own whose every branch narrows a distinct
514
+ * inherited alternative, dropping the ones left unclaimed; a branch restricting none, or several, is rejected as
515
+ * ambiguous.
516
+ *
517
+ * **Cross-field validation**
518
+ *
519
+ * - the merged lower bound must not exceed the merged upper bound, which each may narrow on its own and still cross
520
+ *
521
+ * @typeParam R The shape the values are drawn from, possibly deferred to break definition cycles
522
+ * @typeParam L The least number of values admitted
523
+ * @typeParam U The greatest number of values admitted
524
+ *
525
+ * @see {@link https://www.w3.org/TR/shacl/#property-shapes SHACL § 2.3 Property Shapes}
526
+ */
527
+ export type Property<R extends Lazy<Shape> = Lazy<Shape>, L extends Optional<number> = Optional<number>, U extends Optional<number> = Optional<number>> = PropertyConstraints<Reference> & {
528
+ /**
529
+ * Discriminator identifying this as a member carrying values.
530
+ *
531
+ * **Inheritance** — cannot be overridden.
532
+ */
533
+ readonly kind: "property";
534
+ /**
535
+ * Value set the property carries.
536
+ *
537
+ * States the shape every value is drawn from and how many of them a resource may carry. A path resolved through
538
+ * the property yields a {@link Range} of the same form, so the range a property states and the one a path reaches
539
+ * are read alike.
540
+ *
541
+ * **Inheritance** — child may only narrow the inherited range, bound by bound and shape by shape.
542
+ */
543
+ readonly range: Range<R, L, U>;
544
+ };
545
+ /**
546
+ * Constraints accepted by the member factories.
547
+ *
548
+ * States how a member is stored, presented and owned, leaving its cardinality to the factory naming it and its
549
+ * {@link PropertyBounds | bounds} to the general-purpose one.
550
+ *
551
+ * @typeParam M The form the {@link PropertyConstraints.forward | forward} and
552
+ * {@link PropertyConstraints.reverse | reverse} mappings are stated in: a declaration accepts a {@link Namespace}
553
+ * shorthand alongside an absolute IRI; a built {@link Property | property} carries the IRI it resolves to
554
+ *
555
+ * @see {@link https://www.w3.org/TR/shacl/#property-shapes SHACL § 2.3 Property Shapes}
556
+ */
557
+ export type PropertyConstraints<M extends Reference | Namespace = Reference | Namespace> = {
558
+ /**
559
+ * Human-readable name for the property.
560
+ *
561
+ * Accepts a localised {@link Dictionary} or, as a shorthand for the English-only case, a plain
562
+ * {@link string!text | text} string, expanded to `{ en: <value> }` on the
563
+ * {@link Property | resolved property}.
564
+ *
565
+ * **Inheritance** — inherited; a child may replace it, as a label restricts no value the property admits. Parents
566
+ * stating conflicting labels require the child to state its own, or the extending shape is rejected.
567
+ *
568
+ * @defaultValue `undefined` (no label)
569
+ *
570
+ * @see {@link https://www.w3.org/TR/shacl/#name SHACL § 2.3.2.1 sh:name and sh:description}
571
+ */
572
+ readonly name?: string | Dictionary;
573
+ /**
574
+ * Human-readable description of the property.
575
+ *
576
+ * Accepts a localised {@link Dictionary} or, as a shorthand for the English-only case, a
577
+ * {@link string!markdown | Markdown} string, expanded to `{ en: <value> }` on the
578
+ * {@link Property | resolved property}.
579
+ *
580
+ * **Inheritance** — inherited; a child may replace it, as a description restricts no value the property admits.
581
+ * Parents stating conflicting descriptions require the child to state its own, or the extending shape is rejected.
582
+ *
583
+ * @defaultValue `undefined` (no description)
584
+ *
585
+ * @see {@link https://www.w3.org/TR/shacl/#name SHACL § 2.3.2.1 sh:name and sh:description}
586
+ */
587
+ readonly description?: string | Dictionary;
588
+ /**
589
+ * Excludes the member from default serialisation.
590
+ *
591
+ * **Inheritance** — inherited; conflicting parents without a child override are reported as an error.
592
+ *
593
+ * @defaultValue `undefined` (`false`)
594
+ */
595
+ readonly hidden?: boolean;
596
+ /**
597
+ * Marks the property as owned by the resources in its range.
598
+ *
599
+ * A foreign property is read-only for the resource declaring it: a retrieval template may ask for it, but a
600
+ * submitted value stating it is rejected, as the link is written by the resources it points at rather than by the
601
+ * one exposing it.
602
+ *
603
+ * > [!IMPORTANT]
604
+ * > A foreign property is independent from a {@link reverse} mapping. A `reverse` mapping writes an actual inverse
605
+ * > mapping; `foreign` exposes a read-only view over mappings another property owns and writes nothing on insert.
606
+ *
607
+ * **Inheritance** — inherited; a child may state it where the parent leaves it unstated, never change it, so a
608
+ * subtype may give up writing a member its supertype writes but never take up writing one left to the range.
609
+ *
610
+ * @defaultValue `undefined` (`false`)
611
+ */
612
+ readonly foreign?: boolean;
613
+ /**
614
+ * Marks the resources in the property range as unable to outlive the resource declaring it.
615
+ *
616
+ * A captive resource keeps an identity and a lifecycle of its own and may be created, updated and deleted on its
617
+ * own. It stays existentially dependent on the resource declaring the property, though, and is cascade-removed
618
+ * when that resource is deleted.
619
+ *
620
+ * > [!IMPORTANT]
621
+ * > Captivity is independent from embedding. An embedded resource has no identity or lifecycle of its own (an `id`
622
+ * > is rejected as a value is validated) and is always managed as part of the resource containing it; a captive
623
+ * > resource has both and may be managed on its own, but does not survive the resource declaring the property.
624
+ *
625
+ * **Inheritance** — inherited; a child may state it where the parent leaves it unstated, never change it, so a
626
+ * subtype may bind the lifecycle of a member its supertype leaves free but never free one its supertype binds.
627
+ *
628
+ * @defaultValue `undefined` (`false`)
629
+ */
630
+ readonly captive?: boolean;
631
+ /**
632
+ * Maps the property to an absolute IRI for direct mapping.
633
+ *
634
+ * Accepts an absolute IRI or, as a shorthand, a {@link Namespace} resolving the property name against it (for
635
+ * instance, `{ forward: schema }` on property `name` yields `http://schema.org/name`), narrowed on a built
636
+ * {@link Property | property} to the IRI it denotes.
637
+ *
638
+ * > [!IMPORTANT]
639
+ * > Both `forward` and {@link reverse} mappings write actual property values. This is independent from
640
+ * > {@link foreign}, which exposes a read-only view over mappings another property owns.
641
+ *
642
+ * **Inheritance** — inherited where the child states no mapping. A child stating either mapping must match the
643
+ * parent on both `forward` and {@link reverse}, including one the parent leaves unstated.
644
+ *
645
+ * @defaultValue `undefined` (the property name resolved against the {@link ResourceConstraints.space | space} of
646
+ * the shape declaring it, unless a {@link reverse} mapping is stated)
647
+ *
648
+ * @see {@link https://www.w3.org/TR/json-ld11/#iris JSON-LD 1.1 § 3.2 IRIs}
649
+ */
650
+ readonly forward?: M;
651
+ /**
652
+ * Maps the property to an absolute IRI for inverse mapping.
653
+ *
654
+ * Accepts an absolute IRI or, as a shorthand, a {@link Namespace} resolving the property name against it (for
655
+ * instance, `{ reverse: schema }` on property `employee` yields `http://schema.org/employee`), narrowed on a built
656
+ * {@link Property | property} to the IRI it denotes.
657
+ *
658
+ * > [!IMPORTANT]
659
+ * > Both {@link forward} and `reverse` mappings write actual property values. This is independent from
660
+ * > {@link foreign}, which exposes a read-only view over mappings another property owns.
661
+ *
662
+ * > [!IMPORTANT]
663
+ * > A reverse mapping makes each value the subject of the statement it writes, and a literal can't be a subject.
664
+ * > The mapping is therefore admitted only on members ranging over references, embedded resources, or unions of
665
+ * > them. The {@link resource} factory rejects a reverse mapping on a member admitting literals. A range deferred
666
+ * > to break a definition cycle is exempt from this check.
667
+ *
668
+ * **Inheritance** — inherited where the child states no mapping. A child stating either mapping must match the
669
+ * parent on both {@link forward} and `reverse`, including one the parent leaves unstated.
670
+ *
671
+ * @defaultValue `undefined` (no inverse mapping)
672
+ *
673
+ * @see {@link https://www.w3.org/TR/json-ld11/#reverse-properties JSON-LD 1.1 § 4.8 Reverse Properties}
674
+ */
675
+ readonly reverse?: M;
676
+ };
677
+ /**
678
+ * Property constraints admitting explicit cardinality bounds.
679
+ *
680
+ * Accepted by {@link property} for bounds beyond the four the cardinality factories name.
681
+ */
682
+ export type PropertyBounds = PropertyConstraints & {
683
+ /**
684
+ * Least number of values admitted.
685
+ *
686
+ * Left unstated, the member is unbounded below and a resource may leave it out. A member carrying a
687
+ * {@link dictionary!DictionaryShape | language map} satisfies the bound with the map alone, as it stands for the
688
+ * whole of what the member carries.
689
+ *
690
+ * **Inheritance** — child may only raise the lower bound.
691
+ *
692
+ * @defaultValue `undefined` (no lower bound)
693
+ *
694
+ * @see {@link https://www.w3.org/TR/shacl/#MinCountConstraintComponent SHACL § 4.2.1 sh:minCount}
695
+ */
696
+ readonly minCount?: Optional<number>;
697
+ /**
698
+ * Greatest number of values admitted.
699
+ *
700
+ * Left unstated, the member is unbounded above and a resource states its values as an array. A
701
+ * {@link dictionary!DictionaryShape | language map} is stated whole all the same, never in an array, and is not
702
+ * counted against the bound.
703
+ *
704
+ * **Inheritance** — child may only lower the upper bound.
705
+ *
706
+ * @defaultValue `undefined` (no upper bound)
707
+ *
708
+ * @see {@link https://www.w3.org/TR/shacl/#MaxCountConstraintComponent SHACL § 4.2.2 sh:maxCount}
709
+ */
710
+ readonly maxCount?: Optional<number>;
711
+ };
712
+ /**
713
+ * Creates a resource shape extending other shapes.
714
+ *
715
+ * Extends the shapes given, carrying their members and constraints without adding or narrowing any member. A shape
716
+ * extending nothing admits only resources carrying no members.
717
+ *
718
+ * @typeParam I The shapes extended, possibly deferred to break definition cycles
719
+ *
720
+ * @param args The shapes extended
721
+ *
722
+ * @returns An immutable shape admitting the resources the inherited members bound
723
+ *
724
+ * @throws {@link @grafctory/core!TraceError | TraceError} Where the extended shapes disagree on an inherited constraint,
725
+ * or the merged shape states two identifiers, two types, or two members mapping to the same predicate
726
+ */
727
+ export declare function resource<I extends Parents>(...args: [...inheritance: I]): ResourceShape<I, {}>;
728
+ /**
729
+ * Creates a resource shape extending other shapes with shape-level constraints.
730
+ *
731
+ * Extends the shapes given first, carrying their members and constraints, and holds every resource to the
732
+ * {@link ResourceConstraints constraints} stated after them. The shape carries only the members it inherits: a shape
733
+ * extending nothing admits only resources carrying no members.
734
+ *
735
+ * @typeParam I The shapes extended, possibly deferred to break definition cycles
736
+ *
737
+ * @param args The shapes extended, followed by the shape {@link ResourceConstraints constraints}
738
+ *
739
+ * @returns An immutable shape admitting the resources the inherited members and the constraints bound
740
+ *
741
+ * @throws {@link !TypeError TypeError} Where the identifier {@link ResourceConstraints.pattern | pattern} is malformed
742
+ * @throws {@link @grafctory/core!TraceError | TraceError} Where the extended shapes disagree on an inherited constraint,
743
+ * or the merged shape states two identifiers, two types, or two members mapping to the same predicate
744
+ */
745
+ export declare function resource<I extends Parents>(...args: [...inheritance: I, constraints: ResourceConstraints & {
746
+ readonly kind?: never;
747
+ }]): ResourceShape<I, {}>;
748
+ /**
749
+ * Creates a resource shape stating shape-level constraints.
750
+ *
751
+ * Extends the shapes given first, carrying their members and constraints on top of the ones declared here, and holds
752
+ * every resource to the {@link ResourceConstraints constraints} stated between them and the members: what it is
753
+ * called, the class it belongs to, the space its members resolve their predicates against, and the identifiers it may
754
+ * be named by.
755
+ *
756
+ * @typeParam I The shapes extended, possibly deferred to break definition cycles
757
+ * @typeParam M The members declared in the shape's own right
758
+ *
759
+ * @param args The shapes extended, followed by the shape {@link ResourceConstraints constraints} and the members
760
+ * declared
761
+ *
762
+ * @returns An immutable shape admitting the resources the members and constraints bound
763
+ *
764
+ * @throws {@link !TypeError TypeError} Where the identifier {@link ResourceConstraints.pattern | pattern} is malformed
765
+ * @throws {@link @grafctory/core!TraceError | TraceError} Where a member fails to narrow the one it overrides, the
766
+ * extended shapes disagree on an inherited constraint, the merged shape states two identifiers, two types, or
767
+ * two members mapping to the same predicate, or a member admitting literals states a reverse mapping
768
+ */
769
+ export declare function resource<I extends Parents, M extends Members>(...args: [...inheritance: I, constraints: ResourceConstraints & {
770
+ readonly kind?: never;
771
+ }, members: M]): ResourceShape<I, M>;
772
+ /**
773
+ * Creates a resource shape.
774
+ *
775
+ * Extends the shapes given ahead of the members, carrying their members and constraints on top of the ones declared
776
+ * here; a member redeclared over an inherited one narrows it. The shape is built merged, so that a caller reads the
777
+ * members a resource carries off the shape itself rather than by walking the inheritance chain.
778
+ *
779
+ * @typeParam I The shapes extended, possibly deferred to break definition cycles
780
+ * @typeParam M The members declared in the shape's own right
781
+ *
782
+ * @param args The shapes extended, followed by the members declared
783
+ *
784
+ * @returns An immutable shape admitting the resources the members bound
785
+ *
786
+ * @throws {@link @grafctory/core!TraceError | TraceError} Where a member fails to narrow the one it overrides, the
787
+ * extended shapes disagree on an inherited constraint, the merged shape states two identifiers, two types, or
788
+ * two members mapping to the same predicate, or a member admitting literals states a reverse mapping
789
+ */
790
+ export declare function resource<I extends Parents, M extends Members>(...args: [...inheritance: I, members: M]): ResourceShape<I, M>;
791
+ /**
792
+ * Creates the member naming a resource.
793
+ *
794
+ * Marks the member it is declared under as carrying the resource's identifier, mapping it to the JSON-LD `@id`
795
+ * keyword. A shape states at most one, counted once inheritance has merged the members: a marker reaching the shape
796
+ * under one name through several parents, or redeclared over an inherited one, is a single member, while two markers
797
+ * under distinct names are rejected.
798
+ *
799
+ * @param constraints Optional member constraints
800
+ * @param constraints.hidden Excludes the member from default serialisation
801
+ *
802
+ * @returns An immutable member naming the resource
803
+ *
804
+ * @see {@link https://www.w3.org/TR/json-ld11/#node-identifiers JSON-LD 1.1 § 3.3 Node Identifiers}
805
+ */
806
+ export declare function id(constraints?: {
807
+ readonly hidden?: boolean;
808
+ }): Id;
809
+ /**
810
+ * Creates the member typing a resource.
811
+ *
812
+ * Marks the member it is declared under as carrying the resource's class, mapping it to the JSON-LD `@type` keyword.
813
+ * The value is derived from the {@link ResourceConstraints.class | class} the shape states, so the member is active
814
+ * only on a shape stating one and a shape stating none rejects every value supplied for it: a shared supershape may
815
+ * thus declare the member once for the shapes extending it, each activating it by stating a class of its own. A shape
816
+ * states at most one, counted as {@link id} is.
817
+ *
818
+ * @param constraints Optional member constraints
819
+ * @param constraints.hidden Excludes the member from default serialisation
820
+ *
821
+ * @returns An immutable member typing the resource
822
+ *
823
+ * @see {@link https://www.w3.org/TR/json-ld11/#specifying-the-type JSON-LD 1.1 § 3.5 Specifying the Type}
824
+ */
825
+ export declare function type(constraints?: {
826
+ readonly hidden?: boolean;
827
+ }): Type;
828
+ /**
829
+ * Creates a member carrying any number of values.
830
+ *
831
+ * @typeParam R The shape the values are drawn from
832
+ * @typeParam C The stated constraints
833
+ *
834
+ * @param range The shape the values are drawn from, possibly deferred to break definition cycles
835
+ * @param constraints Optional member {@link PropertyConstraints constraints}
836
+ *
837
+ * @returns An immutable member admitting any number of values of `range`
838
+ */
839
+ export declare function multiple<R extends Lazy<Shape>, const C extends PropertyConstraints = {}>(range: R, constraints?: C): NoInfer<C> & Property<R, undefined, undefined>;
840
+ /**
841
+ * Creates a member carrying at least one value.
842
+ *
843
+ * @typeParam R The shape the values are drawn from
844
+ * @typeParam C The stated constraints
845
+ *
846
+ * @param range The shape the values are drawn from, possibly deferred to break definition cycles
847
+ * @param constraints Optional member {@link PropertyConstraints constraints}
848
+ *
849
+ * @returns An immutable member requiring at least one value of `range`
850
+ */
851
+ export declare function nonempty<R extends Lazy<Shape>, const C extends PropertyConstraints = {}>(range: R, constraints?: C): NoInfer<C> & Property<R, 1, undefined>;
852
+ /**
853
+ * Creates a member carrying at most one value.
854
+ *
855
+ * @typeParam R The shape the value is drawn from
856
+ * @typeParam C The stated constraints
857
+ *
858
+ * @param range The shape the value is drawn from, possibly deferred to break definition cycles
859
+ * @param constraints Optional member {@link PropertyConstraints constraints}
860
+ *
861
+ * @returns An immutable member admitting at most one value of `range`
862
+ */
863
+ export declare function optional<R extends Lazy<Shape>, const C extends PropertyConstraints = {}>(range: R, constraints?: C): NoInfer<C> & Property<R, undefined, 1>;
864
+ /**
865
+ * Creates a member carrying exactly one value.
866
+ *
867
+ * @typeParam R The shape the value is drawn from
868
+ * @typeParam C The stated constraints
869
+ *
870
+ * @param range The shape the value is drawn from, possibly deferred to break definition cycles
871
+ * @param constraints Optional member {@link PropertyConstraints constraints}
872
+ *
873
+ * @returns An immutable member requiring exactly one value of `range`
874
+ */
875
+ export declare function required<R extends Lazy<Shape>, const C extends PropertyConstraints = {}>(range: R, constraints?: C): NoInfer<C> & Property<R, 1, 1>;
876
+ /**
877
+ * Creates a member carrying a stated number of values.
878
+ *
879
+ * Reads the cardinality off the `minCount` and `maxCount` the {@link PropertyBounds | constraints} state, for the
880
+ * bounds the four named factories leave uncovered; a bound left unstated leaves that end unbounded. The bounds are
881
+ * carried by the range of the built {@link Property | property} alone, not restated beside its other constraints.
882
+ *
883
+ * @typeParam R The shape the values are drawn from
884
+ * @typeParam C The stated constraints and cardinality bounds
885
+ *
886
+ * @param range The shape the values are drawn from, possibly deferred to break definition cycles
887
+ * @param constraints Optional member {@link PropertyBounds constraints and bounds}
888
+ *
889
+ * @returns An immutable member admitting the stated number of values of `range`
890
+ *
891
+ * @throws {@link !TypeError TypeError} Where a bound is stated as a negative number, or the bounds cross, admitting no
892
+ * value at all
893
+ *
894
+ * @example
895
+ *
896
+ * ```typescript
897
+ * const Product = resource({
898
+ * tags: property(string(), { minCount: 2, maxCount: 5 })
899
+ * });
900
+ * ```
901
+ */
902
+ export declare function property<R extends Lazy<Shape>, const C extends PropertyBounds = {}>(range: R, constraints?: C): NoInfer<Unbounded<C>> & Property<R, Declared<C, "minCount">, Declared<C, "maxCount">>;
903
+ //# sourceMappingURL=index.d.ts.map