@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.
- package/LICENSE +201 -0
- package/README.md +509 -2
- package/dist/boolean/assembler.d.ts +53 -0
- package/dist/boolean/assembler.d.ts.map +1 -0
- package/dist/boolean/assembler.js +78 -0
- package/dist/boolean/assembler.js.map +1 -0
- package/dist/boolean/index.d.ts +86 -0
- package/dist/boolean/index.d.ts.map +1 -0
- package/dist/boolean/index.js +99 -0
- package/dist/boolean/index.js.map +1 -0
- package/dist/boolean/validator.d.ts +30 -0
- package/dist/boolean/validator.d.ts.map +1 -0
- package/dist/boolean/validator.js +68 -0
- package/dist/boolean/validator.js.map +1 -0
- package/dist/dictionary/assembler.d.ts +70 -0
- package/dist/dictionary/assembler.d.ts.map +1 -0
- package/dist/dictionary/assembler.js +154 -0
- package/dist/dictionary/assembler.js.map +1 -0
- package/dist/dictionary/index.d.ts +211 -0
- package/dist/dictionary/index.d.ts.map +1 -0
- package/dist/dictionary/index.js +43 -0
- package/dist/dictionary/index.js.map +1 -0
- package/dist/dictionary/inference.d.ts +42 -0
- package/dist/dictionary/inference.d.ts.map +1 -0
- package/dist/dictionary/inference.js +17 -0
- package/dist/dictionary/inference.js.map +1 -0
- package/dist/dictionary/validator.d.ts +34 -0
- package/dist/dictionary/validator.d.ts.map +1 -0
- package/dist/dictionary/validator.js +91 -0
- package/dist/dictionary/validator.js.map +1 -0
- package/dist/index.core.d.ts +33 -0
- package/dist/index.core.d.ts.map +1 -0
- package/dist/index.core.js +149 -0
- package/dist/index.core.js.map +1 -0
- package/dist/index.d.ts +333 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +378 -0
- package/dist/index.js.map +1 -0
- package/dist/number/assembler.d.ts +70 -0
- package/dist/number/assembler.d.ts.map +1 -0
- package/dist/number/assembler.js +188 -0
- package/dist/number/assembler.js.map +1 -0
- package/dist/number/index.d.ts +329 -0
- package/dist/number/index.d.ts.map +1 -0
- package/dist/number/index.js +312 -0
- package/dist/number/index.js.map +1 -0
- package/dist/number/validator.d.ts +31 -0
- package/dist/number/validator.d.ts.map +1 -0
- package/dist/number/validator.js +57 -0
- package/dist/number/validator.js.map +1 -0
- package/dist/reference/accessors.d.ts +29 -0
- package/dist/reference/accessors.d.ts.map +1 -0
- package/dist/reference/accessors.js +38 -0
- package/dist/reference/accessors.js.map +1 -0
- package/dist/reference/assembler.d.ts +63 -0
- package/dist/reference/assembler.d.ts.map +1 -0
- package/dist/reference/assembler.js +127 -0
- package/dist/reference/assembler.js.map +1 -0
- package/dist/reference/index.d.ts +108 -0
- package/dist/reference/index.d.ts.map +1 -0
- package/dist/reference/index.js +40 -0
- package/dist/reference/index.js.map +1 -0
- package/dist/reference/validator.d.ts +33 -0
- package/dist/reference/validator.d.ts.map +1 -0
- package/dist/reference/validator.js +56 -0
- package/dist/reference/validator.js.map +1 -0
- package/dist/resource/accessors.d.ts +140 -0
- package/dist/resource/accessors.d.ts.map +1 -0
- package/dist/resource/accessors.js +173 -0
- package/dist/resource/accessors.js.map +1 -0
- package/dist/resource/assembler.d.ts +265 -0
- package/dist/resource/assembler.d.ts.map +1 -0
- package/dist/resource/assembler.js +816 -0
- package/dist/resource/assembler.js.map +1 -0
- package/dist/resource/index.d.ts +898 -0
- package/dist/resource/index.d.ts.map +1 -0
- package/dist/resource/index.js +160 -0
- package/dist/resource/index.js.map +1 -0
- package/dist/resource/inference.d.ts +310 -0
- package/dist/resource/inference.d.ts.map +1 -0
- package/dist/resource/inference.js +17 -0
- package/dist/resource/inference.js.map +1 -0
- package/dist/resource/validator.d.ts +158 -0
- package/dist/resource/validator.d.ts.map +1 -0
- package/dist/resource/validator.js +1031 -0
- package/dist/resource/validator.js.map +1 -0
- package/dist/string/assembler.d.ts +69 -0
- package/dist/string/assembler.d.ts.map +1 -0
- package/dist/string/assembler.js +143 -0
- package/dist/string/assembler.js.map +1 -0
- package/dist/string/index.d.ts +431 -0
- package/dist/string/index.d.ts.map +1 -0
- package/dist/string/index.js +528 -0
- package/dist/string/index.js.map +1 -0
- package/dist/string/validator.d.ts +30 -0
- package/dist/string/validator.d.ts.map +1 -0
- package/dist/string/validator.js +69 -0
- package/dist/string/validator.js.map +1 -0
- package/dist/union/accessors.d.ts +137 -0
- package/dist/union/accessors.d.ts.map +1 -0
- package/dist/union/accessors.js +253 -0
- package/dist/union/accessors.js.map +1 -0
- package/dist/union/assembler.d.ts +56 -0
- package/dist/union/assembler.d.ts.map +1 -0
- package/dist/union/assembler.js +140 -0
- package/dist/union/assembler.js.map +1 -0
- package/dist/union/index.d.ts +172 -0
- package/dist/union/index.d.ts.map +1 -0
- package/dist/union/index.js +45 -0
- package/dist/union/index.js.map +1 -0
- package/dist/union/inference.d.ts +30 -0
- package/dist/union/inference.d.ts.map +1 -0
- package/dist/union/inference.js +17 -0
- package/dist/union/inference.js.map +1 -0
- package/dist/union/validator.d.ts +94 -0
- package/dist/union/validator.d.ts.map +1 -0
- package/dist/union/validator.js +171 -0
- package/dist/union/validator.js.map +1 -0
- package/dist/value/accessors.d.ts +151 -0
- package/dist/value/accessors.d.ts.map +1 -0
- package/dist/value/accessors.js +468 -0
- package/dist/value/accessors.js.map +1 -0
- package/dist/value/assembler.d.ts +129 -0
- package/dist/value/assembler.d.ts.map +1 -0
- package/dist/value/assembler.js +248 -0
- package/dist/value/assembler.js.map +1 -0
- package/dist/value/index.d.ts +309 -0
- package/dist/value/index.d.ts.map +1 -0
- package/dist/value/index.js +26 -0
- package/dist/value/index.js.map +1 -0
- package/dist/value/inference.d.ts +292 -0
- package/dist/value/inference.d.ts.map +1 -0
- package/dist/value/inference.js +17 -0
- package/dist/value/inference.js.map +1 -0
- package/dist/value/validator.d.ts +76 -0
- package/dist/value/validator.d.ts.map +1 -0
- package/dist/value/validator.js +111 -0
- package/dist/value/validator.js.map +1 -0
- package/package.json +95 -4
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import type { Variant } from "@grafctory/core/resource";
|
|
2
|
+
import type { Reference } from "@grafctory/qest/state";
|
|
3
|
+
import type { Legal } from "../value/inference.js";
|
|
4
|
+
/**
|
|
5
|
+
* Describes a textual value.
|
|
6
|
+
*
|
|
7
|
+
* Admits the [JSON strings](https://datatracker.ietf.org/doc/html/rfc8259#section-7) a resource may carry, bounded by
|
|
8
|
+
* length, lexical and enumeration constraints and typed as an
|
|
9
|
+
* [XSD 1.0](https://www.w3.org/TR/xmlschema-2/#built-in-datatypes) string or temporal datatype, so that a validated
|
|
10
|
+
* value carries the datatype the shape states rather than the one JSON leaves unsaid.
|
|
11
|
+
*
|
|
12
|
+
* **Inheritance**
|
|
13
|
+
*
|
|
14
|
+
* Where a {@link resource!ResourceShape} extends the shapes it lists as `parents`, string-valued members are merged
|
|
15
|
+
* according to the following rules. The *child* is the extending shape; the *parent* is the inherited one.
|
|
16
|
+
*
|
|
17
|
+
* | Field | Override Rule |
|
|
18
|
+
* | ----------- | ---------------------------------------------------------------------------------- |
|
|
19
|
+
* | `kind` | Cannot be overridden |
|
|
20
|
+
* | `datatype` | Must be strictly equal when both defined; the single defined value carries through |
|
|
21
|
+
* | `pattern` | Must be strictly equal when both defined; the single defined value carries through |
|
|
22
|
+
* | `minLength` | Child may only raise the minimum length |
|
|
23
|
+
* | `maxLength` | Child may only lower the maximum length |
|
|
24
|
+
* | `in` | Child may only drop allowed values |
|
|
25
|
+
* | `hasValue` | Child may only add required values |
|
|
26
|
+
*
|
|
27
|
+
* **Cross-field validation**
|
|
28
|
+
*
|
|
29
|
+
* - merged `minLength` must be ≤ merged `maxLength`
|
|
30
|
+
* - all merged `hasValue` entries must be members of the merged `in` set (if defined)
|
|
31
|
+
*
|
|
32
|
+
* @typeParam V The values the shape admits, narrowed to the enumerated ones where it states an
|
|
33
|
+
* {@link StringValueConstraints.in | enumeration} and the whole textual domain otherwise
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#string XSD 1.0 Part 2: Datatypes § 3.2.1 string}
|
|
36
|
+
*/
|
|
37
|
+
export type StringShape<V extends string = string> = StringConstraints<V, string> & {
|
|
38
|
+
/**
|
|
39
|
+
* Discriminator identifying this as a string shape.
|
|
40
|
+
*
|
|
41
|
+
* **Inheritance** — cannot be overridden.
|
|
42
|
+
*/
|
|
43
|
+
readonly kind: "string";
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Constraints accepted by the {@link string} shape factory.
|
|
47
|
+
*
|
|
48
|
+
* Adds the RDF datatype and the lexical pattern, which only the general-purpose factory accepts, to the
|
|
49
|
+
* {@link StringLengthConstraints length} and {@link StringValueConstraints value} constraints shared with the
|
|
50
|
+
* specialised factories.
|
|
51
|
+
*
|
|
52
|
+
* @typeParam V The values the enumeration admits
|
|
53
|
+
* @typeParam P The form a pattern takes: a regular expression or its source where one is stated, the source alone on a
|
|
54
|
+
* {@link StringShape | built shape}
|
|
55
|
+
*/
|
|
56
|
+
export type StringConstraints<V extends string = string, P extends string | RegExp = string | RegExp> = StringLengthConstraints & StringValueConstraints<V> & {
|
|
57
|
+
/**
|
|
58
|
+
* RDF datatype IRI for the textual literal.
|
|
59
|
+
*
|
|
60
|
+
* States the RDF datatype of validated JSON values, which carry none of their own.
|
|
61
|
+
*
|
|
62
|
+
* **Inheritance** — must be strictly equal when both parent and child define it; otherwise the single defined value
|
|
63
|
+
* carries through. A mismatch is reported as an error.
|
|
64
|
+
*
|
|
65
|
+
* @defaultValue `undefined` (falls back to `xsd:string`)
|
|
66
|
+
*
|
|
67
|
+
* @see {@link https://www.w3.org/TR/shacl/#DatatypeConstraintComponent SHACL § 4.1.2 sh:datatype}
|
|
68
|
+
*/
|
|
69
|
+
readonly datatype?: Reference;
|
|
70
|
+
/**
|
|
71
|
+
* Regular expression pattern that values must match.
|
|
72
|
+
*
|
|
73
|
+
* The pattern is matched without anchoring: the constraint holds when the pattern occurs anywhere within the value.
|
|
74
|
+
* Use anchors (`^` and `$`) to require a match against the complete string.
|
|
75
|
+
*
|
|
76
|
+
* **Inheritance** — must be strictly equal when both parent and child define it; otherwise the single defined value
|
|
77
|
+
* carries through. Within a {@link union!union | union}, this equality makes `pattern` a discriminator: two
|
|
78
|
+
* same-datatype string variants that differ only by `pattern` are distinct branches.
|
|
79
|
+
*
|
|
80
|
+
* @defaultValue `undefined` (no pattern constraint)
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://www.w3.org/TR/shacl/#PatternConstraintComponent SHACL § 4.4.3 sh:pattern}
|
|
83
|
+
*/
|
|
84
|
+
readonly pattern?: P;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Length bounds accepted by the string shape factories.
|
|
88
|
+
*
|
|
89
|
+
* Bounds the number of characters admitted by a shape, independently of its lexical format. Accepted on its own by the
|
|
90
|
+
* free-form {@link text} and {@link markdown} factories, whose content has no fixed length, and included in the full
|
|
91
|
+
* {@link StringConstraints} set.
|
|
92
|
+
*
|
|
93
|
+
* @see {@link https://www.w3.org/TR/shacl/#core-components-string SHACL § 4.4 String-based Constraint Components}
|
|
94
|
+
*/
|
|
95
|
+
export type StringLengthConstraints = {
|
|
96
|
+
/**
|
|
97
|
+
* Minimum string length in characters.
|
|
98
|
+
*
|
|
99
|
+
* **Inheritance** — child may only raise the minimum length.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue `undefined` (no minimum length)
|
|
102
|
+
*
|
|
103
|
+
* @see {@link https://www.w3.org/TR/shacl/#MinLengthConstraintComponent SHACL § 4.4.1 sh:minLength}
|
|
104
|
+
*/
|
|
105
|
+
readonly minLength?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Maximum string length in characters.
|
|
108
|
+
*
|
|
109
|
+
* **Inheritance** — child may only lower the maximum length.
|
|
110
|
+
*
|
|
111
|
+
* @defaultValue `undefined` (no maximum length)
|
|
112
|
+
*
|
|
113
|
+
* @see {@link https://www.w3.org/TR/shacl/#MaxLengthConstraintComponent SHACL § 4.4.2 sh:maxLength}
|
|
114
|
+
*/
|
|
115
|
+
readonly maxLength?: number;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Value constraints accepted by the string shape factories.
|
|
119
|
+
*
|
|
120
|
+
* Restricts the admissible values of a shape to a closed enumeration or pins values that must be present. Accepted on
|
|
121
|
+
* its own by the format-specific factories, whose lexical space is already fixed, and included in the full
|
|
122
|
+
* {@link StringConstraints} set.
|
|
123
|
+
*
|
|
124
|
+
* @typeParam V The values the enumeration admits
|
|
125
|
+
*
|
|
126
|
+
* @see {@link https://www.w3.org/TR/shacl/#core-components-others SHACL § 4.8 Other Constraint Components}
|
|
127
|
+
*/
|
|
128
|
+
export type StringValueConstraints<V extends string = string> = {
|
|
129
|
+
/**
|
|
130
|
+
* Allowed values (closed enumeration).
|
|
131
|
+
*
|
|
132
|
+
* When specified, values must be members of this list. Empty arrays are ignored; the {@link string} factory takes
|
|
133
|
+
* the list as bare arguments too. Closing the domain also narrows the value the shape describes to the listed
|
|
134
|
+
* values, wherever they are stated precisely enough to be told apart; a list whose values are only known to be
|
|
135
|
+
* strings leaves it as the whole textual domain.
|
|
136
|
+
*
|
|
137
|
+
* **Inheritance** — child may only drop allowed values.
|
|
138
|
+
*
|
|
139
|
+
* @defaultValue `undefined` (no enumeration constraint)
|
|
140
|
+
*
|
|
141
|
+
* @see {@link https://www.w3.org/TR/shacl/#InConstraintComponent SHACL § 4.8.3 sh:in}
|
|
142
|
+
*/
|
|
143
|
+
readonly in?: readonly V[];
|
|
144
|
+
/**
|
|
145
|
+
* Values a member must carry.
|
|
146
|
+
*
|
|
147
|
+
* When specified, all listed values must appear among the ones the member carries. Empty arrays are ignored.
|
|
148
|
+
*
|
|
149
|
+
* **Inheritance** — child may only add required values.
|
|
150
|
+
*
|
|
151
|
+
* @defaultValue `undefined` (no required values)
|
|
152
|
+
*
|
|
153
|
+
* @see {@link https://www.w3.org/TR/shacl/#HasValueConstraintComponent SHACL § 4.8.2 sh:hasValue}
|
|
154
|
+
*/
|
|
155
|
+
readonly hasValue?: readonly V[];
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Creates a string shape.
|
|
159
|
+
*
|
|
160
|
+
* Contradictory constraints are rejected as the shape is built, so a shape that exists admits at least one value.
|
|
161
|
+
*
|
|
162
|
+
* @typeParam C The stated constraints
|
|
163
|
+
*
|
|
164
|
+
* @param constraints Optional shape {@link StringConstraints constraints}
|
|
165
|
+
*
|
|
166
|
+
* @returns An immutable shape admitting the strings the constraints bound, narrowed to the values they enumerate
|
|
167
|
+
*
|
|
168
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
169
|
+
*/
|
|
170
|
+
export declare function string<const C extends StringConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
171
|
+
/**
|
|
172
|
+
* Creates a string shape admitting an enumerated set of values.
|
|
173
|
+
*
|
|
174
|
+
* Reads bare strings as the enumeration closing the domain to them, so that a set of admitted values is stated as
|
|
175
|
+
* `string("open", "closed")` rather than as `string({ in: ["open", "closed"] })`.
|
|
176
|
+
*
|
|
177
|
+
* @typeParam V The values the shape admits
|
|
178
|
+
*
|
|
179
|
+
* @param values The admitted values
|
|
180
|
+
*
|
|
181
|
+
* @returns An immutable shape admitting `values` alone
|
|
182
|
+
*/
|
|
183
|
+
export declare function string<const V extends readonly string[]>(...values: V): StringShape<V[number]>;
|
|
184
|
+
/**
|
|
185
|
+
* Creates a shape for single-line plain text values.
|
|
186
|
+
*
|
|
187
|
+
* Fixes the datatype to `xsd:string` and admits space-normalised single-line content: at least one non-whitespace
|
|
188
|
+
* character, no line breaks or tabs, no leading or trailing whitespace, and single spaces between words. Reach for it
|
|
189
|
+
* for labels, names and other short unformatted values that must survive rendering in any layout; reach for
|
|
190
|
+
* {@link markdown} where the content carries formatting or spans multiple lines.
|
|
191
|
+
*
|
|
192
|
+
* @param constraints Optional {@link StringLengthConstraints length bounds}
|
|
193
|
+
*
|
|
194
|
+
* @returns An immutable shape admitting single-line plain text
|
|
195
|
+
*
|
|
196
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
197
|
+
*/
|
|
198
|
+
export declare function text(constraints?: StringLengthConstraints): StringShape;
|
|
199
|
+
/**
|
|
200
|
+
* Creates a shape for Markdown text values.
|
|
201
|
+
*
|
|
202
|
+
* Fixes the datatype to `xsd:string` and admits any string within the stated length bounds. Whitespace carries meaning
|
|
203
|
+
* throughout Markdown, from indentation and blank lines to the trailing spaces that encode a hard break, so no lexical
|
|
204
|
+
* constraint is imposed and authored content survives ingestion verbatim. Reach for it for descriptions, abstracts and
|
|
205
|
+
* other long-form values whose formatting is meaningful; reach for {@link text} where the content must stay a single
|
|
206
|
+
* unformatted line.
|
|
207
|
+
*
|
|
208
|
+
* @param constraints Optional {@link StringLengthConstraints length bounds}
|
|
209
|
+
*
|
|
210
|
+
* @returns An immutable shape admitting Markdown text
|
|
211
|
+
*
|
|
212
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
213
|
+
*
|
|
214
|
+
* @see {@link https://commonmark.org/ CommonMark Spec}
|
|
215
|
+
*/
|
|
216
|
+
export declare function markdown(constraints?: StringLengthConstraints): StringShape;
|
|
217
|
+
/**
|
|
218
|
+
* Creates a shape for email address values.
|
|
219
|
+
*
|
|
220
|
+
* Fixes the datatype to `xsd:string`.
|
|
221
|
+
*
|
|
222
|
+
* @typeParam C The stated constraints
|
|
223
|
+
*
|
|
224
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
225
|
+
*
|
|
226
|
+
* @returns An immutable shape admitting email addresses, narrowed to the values the constraints enumerate
|
|
227
|
+
*
|
|
228
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
229
|
+
*
|
|
230
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc5321 RFC 5321 - Simple Mail Transfer Protocol}
|
|
231
|
+
*/
|
|
232
|
+
export declare function email<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
233
|
+
/**
|
|
234
|
+
* Creates a shape for telephone number values.
|
|
235
|
+
*
|
|
236
|
+
* Fixes the datatype to `xsd:string` and admits numbers in ITU-T E.164 notation: a leading `+`, a non-zero country code
|
|
237
|
+
* digit, and up to 14 further digits, with no spaces or separators (for example, `+15555550123`).
|
|
238
|
+
*
|
|
239
|
+
* @typeParam C The stated constraints
|
|
240
|
+
*
|
|
241
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
242
|
+
*
|
|
243
|
+
* @returns An immutable shape admitting E.164 telephone numbers, narrowed to the values the constraints enumerate
|
|
244
|
+
*
|
|
245
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
246
|
+
*
|
|
247
|
+
* @see {@link https://www.itu.int/rec/T-REC-E.164 ITU-T E.164 - International public telecommunication numbering plan}
|
|
248
|
+
*/
|
|
249
|
+
export declare function phone<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
250
|
+
/**
|
|
251
|
+
* Creates a shape for Internationalized Resource Identifier values.
|
|
252
|
+
*
|
|
253
|
+
* Fixes the datatype to `xsd:string`. IRIs generalise URIs (RFC 3986) and URLs by admitting the full Unicode character
|
|
254
|
+
* set beyond ASCII; the {@link Variant | variant} states which subset of the IRI hierarchy is accepted:
|
|
255
|
+
* `browsable` (HTTP and HTTPS links a browser can open), `hierarchical` (a scheme followed by an absolute path, with
|
|
256
|
+
* or without authority), `absolute` (scheme-based URIs/IRIs), `internal` (absolute or root-relative), or `relative`
|
|
257
|
+
* (any valid reference, including relative paths such as `../path` or `path`; the default).
|
|
258
|
+
*
|
|
259
|
+
* As a limitation, variants are told apart by their prefix rather than parsed against the full RFC 3987 grammar: the
|
|
260
|
+
* scheme, the leading slashes and, for `browsable`, the presence of a host. `relative` admits any whitespace-free
|
|
261
|
+
* sequence, and the stricter variants leave the rest of the reference unvalidated.
|
|
262
|
+
*
|
|
263
|
+
* @typeParam C The stated constraints
|
|
264
|
+
*
|
|
265
|
+
* @param constraints Optional {@link StringValueConstraints value constraints} and IRI {@link Variant | variant}
|
|
266
|
+
*
|
|
267
|
+
* @returns An immutable shape admitting IRIs of the stated variant, narrowed to the values the constraints enumerate
|
|
268
|
+
*
|
|
269
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
270
|
+
*
|
|
271
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc3987 RFC 3987 - Internationalized Resource Identifiers}
|
|
272
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc3986 RFC 3986 - URI Generic Syntax}
|
|
273
|
+
*/
|
|
274
|
+
export declare function iri<const C extends StringValueConstraints & {
|
|
275
|
+
readonly variant?: Variant;
|
|
276
|
+
} = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
277
|
+
/**
|
|
278
|
+
* Creates a shape for hierarchical URL values.
|
|
279
|
+
*
|
|
280
|
+
* Fixes the datatype to `xsd:string` and admits only URLs with a scheme and an absolute path, authority optional (for
|
|
281
|
+
* example, `https://example.net/path` or `base:/path`), as {@link iri} does with `variant: "hierarchical"` and under
|
|
282
|
+
* the same limitation: only the scheme and the leading slash are checked. Page addresses a browser can open take
|
|
283
|
+
* {@link iri} with `variant: "browsable"` instead, which admits only HTTP and HTTPS links.
|
|
284
|
+
*
|
|
285
|
+
* @typeParam C The stated constraints
|
|
286
|
+
*
|
|
287
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
288
|
+
*
|
|
289
|
+
* @returns An immutable shape admitting hierarchical URLs, narrowed to the values the constraints enumerate
|
|
290
|
+
*
|
|
291
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
292
|
+
*
|
|
293
|
+
* @see {@link https://datatracker.ietf.org/doc/html/rfc3986 RFC 3986 - URI Generic Syntax}
|
|
294
|
+
*/
|
|
295
|
+
export declare function url<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
296
|
+
/**
|
|
297
|
+
* Creates a shape for language tag values.
|
|
298
|
+
*
|
|
299
|
+
* Fixes the datatype to `xsd:string` and admits BCP 47 language tags identifying a natural language, from a bare
|
|
300
|
+
* language subtag to a fully qualified tag carrying script, region, variant, extension and private-use subtags (for
|
|
301
|
+
* example, `en`, `fr-CA`, `zh-Hans-CN`); subtags are matched case-insensitively, as the standard prescribes, and
|
|
302
|
+
* grandfathered tags are not accepted.
|
|
303
|
+
*
|
|
304
|
+
* Reach for it wherever a member records the language of a value; language *ranges*, which select values rather than
|
|
305
|
+
* identify a language, are constrained by {@link dictionary!DictionaryConstraints.languageIn | languageIn} instead.
|
|
306
|
+
*
|
|
307
|
+
* @typeParam C The stated constraints
|
|
308
|
+
*
|
|
309
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
310
|
+
*
|
|
311
|
+
* @returns An immutable shape admitting language tags, narrowed to the values the constraints enumerate
|
|
312
|
+
*
|
|
313
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
314
|
+
*
|
|
315
|
+
* @see {@link https://www.rfc-editor.org/info/bcp47 BCP 47 - Tags for Identifying Languages}
|
|
316
|
+
*/
|
|
317
|
+
export declare function tag<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
318
|
+
/**
|
|
319
|
+
* Creates a shape for ISO 8601 year values (YYYY).
|
|
320
|
+
*
|
|
321
|
+
* Fixes the datatype to `xsd:gYear` and admits an optional timezone indicator (`Z` for UTC or a ±hh:mm offset bounded
|
|
322
|
+
* to the ±14:00 range).
|
|
323
|
+
*
|
|
324
|
+
* @typeParam C The stated constraints
|
|
325
|
+
*
|
|
326
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
327
|
+
*
|
|
328
|
+
* @returns An immutable shape admitting ISO 8601 years, narrowed to the values the constraints enumerate
|
|
329
|
+
*
|
|
330
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
331
|
+
*
|
|
332
|
+
* @remarks
|
|
333
|
+
*
|
|
334
|
+
* XSD permits timezone indicators for gYear as a deviation from ISO 8601.
|
|
335
|
+
*
|
|
336
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#gYear XSD 1.0 Part 2: Datatypes § 3.2.11 gYear}
|
|
337
|
+
*/
|
|
338
|
+
export declare function year<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
339
|
+
/**
|
|
340
|
+
* Creates a shape for ISO 8601 calendar date values (YYYY-MM-DD).
|
|
341
|
+
*
|
|
342
|
+
* Fixes the datatype to `xsd:date` and bounds the month, the day and the optional timezone offset to their legal
|
|
343
|
+
* ranges. As a limitation of the lexical check, a day is bounded to 31 whatever month it falls in, so `2026-02-31` is
|
|
344
|
+
* admitted: callers needing a date the calendar carries check the day against the month themselves.
|
|
345
|
+
*
|
|
346
|
+
* @typeParam C The stated constraints
|
|
347
|
+
*
|
|
348
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
349
|
+
*
|
|
350
|
+
* @returns An immutable shape admitting ISO 8601 dates, narrowed to the values the constraints enumerate
|
|
351
|
+
*
|
|
352
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
353
|
+
*
|
|
354
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#date XSD 1.0 Part 2: Datatypes § 3.2.9 date}
|
|
355
|
+
*/
|
|
356
|
+
export declare function date<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
357
|
+
/**
|
|
358
|
+
* Creates a shape for ISO 8601 time of day values (hh:mm:ss).
|
|
359
|
+
*
|
|
360
|
+
* Fixes the datatype to `xsd:time` and bounds each field and the optional timezone offset to its legal range, with
|
|
361
|
+
* seconds optionally fractional. The `24:00:00` end-of-day form XSD defines is admitted, carrying no fraction beyond
|
|
362
|
+
* zeroes.
|
|
363
|
+
*
|
|
364
|
+
* @typeParam C The stated constraints
|
|
365
|
+
*
|
|
366
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
367
|
+
*
|
|
368
|
+
* @returns An immutable shape admitting ISO 8601 times, narrowed to the values the constraints enumerate
|
|
369
|
+
*
|
|
370
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
371
|
+
*
|
|
372
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#time XSD 1.0 Part 2: Datatypes § 3.2.8 time}
|
|
373
|
+
*/
|
|
374
|
+
export declare function time<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
375
|
+
/**
|
|
376
|
+
* Creates a shape for ISO 8601 date and time values (YYYY-MM-DDThh:mm:ss).
|
|
377
|
+
*
|
|
378
|
+
* Fixes the datatype to `xsd:dateTime` and bounds each field and the optional timezone offset to its legal range,
|
|
379
|
+
* under the same end-of-day rule as {@link time} and the same day limitation as {@link date}.
|
|
380
|
+
*
|
|
381
|
+
* @typeParam C The stated constraints
|
|
382
|
+
*
|
|
383
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
384
|
+
*
|
|
385
|
+
* @returns An immutable shape admitting ISO 8601 date and time values, narrowed to the values the constraints
|
|
386
|
+
* enumerate
|
|
387
|
+
*
|
|
388
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
389
|
+
*
|
|
390
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#dateTime XSD 1.0 Part 2: Datatypes § 3.2.7 dateTime}
|
|
391
|
+
*/
|
|
392
|
+
export declare function instant<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
393
|
+
/**
|
|
394
|
+
* Creates a shape for UTC timestamp values with millisecond precision (YYYY-MM-DDThh:mm:ss.sssZ).
|
|
395
|
+
*
|
|
396
|
+
* Requires exactly 3 fractional second digits and the UTC timezone (`Z` only), bounding each field to its legal range
|
|
397
|
+
* under the same day limitation as {@link date}; unlike {@link instant}, it admits no `24:00:00` end-of-day form, so a
|
|
398
|
+
* timestamp always states a time of day. Fixes the datatype to `xsd:dateTime` rather than the more specific
|
|
399
|
+
* `xsd:dateTimeStamp`, so values stay compatible with SPARQL temporal functions, which are defined over
|
|
400
|
+
* `xsd:dateTime`.
|
|
401
|
+
*
|
|
402
|
+
* @typeParam C The stated constraints
|
|
403
|
+
*
|
|
404
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
405
|
+
*
|
|
406
|
+
* @returns An immutable shape admitting UTC timestamps, narrowed to the values the constraints enumerate
|
|
407
|
+
*
|
|
408
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
409
|
+
*
|
|
410
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#dateTime XSD 1.0 Part 2: Datatypes § 3.2.7 dateTime}
|
|
411
|
+
*/
|
|
412
|
+
export declare function timestamp<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
413
|
+
/**
|
|
414
|
+
* Creates a shape for ISO 8601 duration values ([-]PnYnMnDTnHnMnS).
|
|
415
|
+
*
|
|
416
|
+
* Fixes the datatype to `xsd:duration` and requires at least one component, so that neither `P` nor a `T` designator
|
|
417
|
+
* carrying no time component is admitted. Components are stated in descending order of magnitude, and only seconds
|
|
418
|
+
* take a fraction.
|
|
419
|
+
*
|
|
420
|
+
* @typeParam C The stated constraints
|
|
421
|
+
*
|
|
422
|
+
* @param constraints Optional {@link StringValueConstraints value constraints}
|
|
423
|
+
*
|
|
424
|
+
* @returns An immutable shape admitting ISO 8601 durations, narrowed to the values the constraints enumerate
|
|
425
|
+
*
|
|
426
|
+
* @throws {@link @grafctory/core!TraceError | TraceError} Where the stated constraints contradict one another
|
|
427
|
+
*
|
|
428
|
+
* @see {@link https://www.w3.org/TR/xmlschema-2/#duration XSD 1.0 Part 2: Datatypes § 3.2.6 duration}
|
|
429
|
+
*/
|
|
430
|
+
export declare function duration<const C extends StringValueConstraints = {}>(constraints?: C): StringShape<Legal<C, string>>;
|
|
431
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAsJA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAkEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,MAAM,WAAW,CACtB,CAAC,SAAS,MAAM,GAAG,MAAM,IACtB,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG;IAElC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;CAEvB,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,CAC5B,CAAC,SAAS,MAAM,GAAG,MAAM,EACzB,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,IACxC,uBAAuB,GAAG,sBAAsB,CAAC,CAAC,CAAC,GAAG;IAEzD;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC;IAE9B;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;CAErB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAErC;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAE5B,CAAA;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAA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