@drfed/models 0.2.0-dev.703 → 0.2.0-dev.712
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -10
- package/dist/document.d.mts +64 -5
- package/dist/document.d.mts.map +1 -1
- package/dist/document.mjs +314 -104
- package/dist/document.mjs.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Document validation
|
|
|
12
12
|
|
|
13
13
|
`@drfed/models/document` exports synchronous
|
|
14
14
|
`validateDocument(document: unknown)`, `prepareDocument(document, options)`,
|
|
15
|
-
and `describeDocument(document: unknown)`, plus the `
|
|
15
|
+
and `describeDocument(document: unknown)`, plus the `DIAGNOSTIC_REASONS`
|
|
16
16
|
registry. Public types are `DocumentValidationResult`, `Diagnostic`,
|
|
17
17
|
`DiagnosticReason`, `DiagnosticCategory`, `DiagnosticSeverity`, `FieldPath`,
|
|
18
18
|
`JsonValue`, `NormalizationChange`, `DocumentAuthority`, `ServerOwnedField`,
|
|
@@ -80,12 +80,39 @@ its type IRI, a `kind` (`activity`, `actor`, `collection`, `link`, or
|
|
|
80
80
|
`object`), and a map from standard property names, including `id` and `type`,
|
|
81
81
|
to the source keys that supply them. Aliases, prefixed or full-IRI keys, and
|
|
82
82
|
`@id`/`@type` aliases are mapped exactly as validation maps them; custom
|
|
83
|
-
extension
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
extension keys are not listed. Each node also lists the string IRI references
|
|
84
|
+
in its own reference properties (`id`, `actor`, `object`, addressing, `href`,
|
|
85
|
+
and so on) as `DocumentIdentifier` values, with the original path and value
|
|
86
|
+
and the IRI after compact-IRI prefix expansion: `as:Public` resolves to the
|
|
87
|
+
full Public IRI, and a context-defined prefix can make `local:alice` name
|
|
88
|
+
another host.
|
|
89
|
+
|
|
90
|
+
Custom extension values are not read as documents, but a JSON-LD processor
|
|
91
|
+
reads the node objects in them with the context they inherit. Each node lists
|
|
92
|
+
those in its own extension values, outside JSON literals, as its `extensions`:
|
|
93
|
+
`ExtensionNode` values with a path, an embedding property, a property map and
|
|
94
|
+
IRI references as a node has, and the `parent` node object, `types` and the
|
|
95
|
+
`kind` of a known type too. Keys are matched by IRI whatever their container,
|
|
96
|
+
and values are read through `@set` and `@list` objects. A node object with a
|
|
97
|
+
`@context` of its own, or inside one, is `uninterpreted`, with no properties,
|
|
98
|
+
since the checker does not read that context. So is one whose reference
|
|
99
|
+
property holds anything but absolute IRIs, a blank node identifier as its
|
|
100
|
+
`id`, and node objects: a value object, a language map, a string its key does
|
|
101
|
+
not coerce to an IRI, a relative reference, a blank node identifier, which may
|
|
102
|
+
name a node object defined apart, or a `@set` or `@list` object with a
|
|
103
|
+
`@context` of its own; and one with more than one `id` or `href`, or a node
|
|
104
|
+
object as one, or with properties nested by `@nest` or reversed by `@reverse`,
|
|
105
|
+
or one whose `id` is used elsewhere in the document, as the `id` of another
|
|
106
|
+
node object or a reference outside its own properties, since it is then not
|
|
107
|
+
read apart; a `Link` whose `href` is its own `id` is read. A value or a list
|
|
108
|
+
object with keys other than keywords, or a value that is an object but no JSON
|
|
109
|
+
literal, which are no valid JSON-LD, or one with keys a context of its own may
|
|
110
|
+
alias, is reported as an uninterpreted node object. The value of a value
|
|
111
|
+
object, or of a key with a `@language` container that is a language map, is
|
|
112
|
+
never read for node objects; an object in a language map is no valid JSON-LD,
|
|
113
|
+
and is reported as an uninterpreted node object. A blank node identifier is
|
|
114
|
+
never expanded as a compact IRI, whatever term `_` names, so a type spelled as
|
|
115
|
+
one is unsupported.
|
|
89
116
|
|
|
90
117
|
~~~~ ts
|
|
91
118
|
import { describeDocument } from "@drfed/models/document";
|
|
@@ -311,9 +338,10 @@ values must be strings or arrays of strings; malformed entries receive
|
|
|
311
338
|
`invalid_value_shape` at the original keyword or list-entry path. These shape
|
|
312
339
|
checks do not require custom type strings to appear in the implemented-type
|
|
313
340
|
set. An `@json` value's payload remains ordinary JSON, including keys spelled
|
|
314
|
-
`@id` or `@type`, and is checked only for JSON safety
|
|
315
|
-
|
|
316
|
-
|
|
341
|
+
`@id` or `@type`, and is checked only for JSON safety; so is the payload of a
|
|
342
|
+
value object whose `@type` is spelled with a keyword alias, such as `type`.
|
|
343
|
+
These bounded checks do not establish full JSON-LD validity or interpret
|
|
344
|
+
nested contexts.
|
|
317
345
|
|
|
318
346
|
This warning policy does not admit unknown types, unsupported contexts,
|
|
319
347
|
JSON-LD keywords, or known vocabulary properties without implemented rules.
|
package/dist/document.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ type FieldPath = readonly (string | number)[];
|
|
|
4
4
|
type DiagnosticCategory = "vocabulary" | "authority" | "support" | "compatibility";
|
|
5
5
|
type DiagnosticSeverity = "error" | "warning";
|
|
6
6
|
/** Stable classifications; human-readable diagnostic messages may change. */
|
|
7
|
-
declare const
|
|
7
|
+
declare const DIAGNOSTIC_REASONS: {
|
|
8
8
|
readonly invalid_document_root: {
|
|
9
9
|
readonly category: "vocabulary";
|
|
10
10
|
readonly severity: "error";
|
|
@@ -90,7 +90,7 @@ declare const diagnosticReasons: {
|
|
|
90
90
|
readonly severity: "warning";
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
type DiagnosticReason = keyof typeof
|
|
93
|
+
type DiagnosticReason = keyof typeof DIAGNOSTIC_REASONS;
|
|
94
94
|
interface Diagnostic {
|
|
95
95
|
readonly reason: DiagnosticReason;
|
|
96
96
|
readonly category: DiagnosticCategory;
|
|
@@ -150,7 +150,7 @@ interface DocumentPreparationOptions {
|
|
|
150
150
|
readonly serverOwnedFields: readonly ServerOwnedField[];
|
|
151
151
|
}
|
|
152
152
|
/** The ActivityStreams properties that address a document's recipients. */
|
|
153
|
-
declare const
|
|
153
|
+
declare const ADDRESSING_PROPERTIES: readonly ["to", "cc", "bto", "bcc", "audience"];
|
|
154
154
|
/**
|
|
155
155
|
* Checks the implemented Activity Vocabulary types, including nested
|
|
156
156
|
* activity objects, without network access or writes. Embedded objects inherit
|
|
@@ -224,6 +224,63 @@ interface DocumentNode {
|
|
|
224
224
|
* documents belong to those documents' nodes.
|
|
225
225
|
*/
|
|
226
226
|
readonly identifiers: readonly DocumentIdentifier[];
|
|
227
|
+
/**
|
|
228
|
+
* The JSON-LD node objects inside this document's own opaque extension
|
|
229
|
+
* values, at any depth, in traversal order.
|
|
230
|
+
*/
|
|
231
|
+
readonly extensions: readonly ExtensionNode[];
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A JSON-LD node object inside an opaque extension value. The checker does
|
|
235
|
+
* not read it as a vocabulary document, but a JSON-LD processor reads its
|
|
236
|
+
* keys with the context it inherits, so its standard properties are named
|
|
237
|
+
* as a described document's are, whatever their type coercion.
|
|
238
|
+
*/
|
|
239
|
+
interface ExtensionNode {
|
|
240
|
+
/** Source path of the node object. */
|
|
241
|
+
readonly path: FieldPath;
|
|
242
|
+
/**
|
|
243
|
+
* The standard name of the property that holds the node object in another
|
|
244
|
+
* one, whatever its source spelling; absent directly under an extension
|
|
245
|
+
* property.
|
|
246
|
+
*/
|
|
247
|
+
readonly property?: string;
|
|
248
|
+
/** The path of the node object whose `property` holds this one. */
|
|
249
|
+
readonly parent?: FieldPath;
|
|
250
|
+
/**
|
|
251
|
+
* Whether the checker cannot read all of the node object: it, or one
|
|
252
|
+
* around it in the extension value, has a `@context` of its own, which the
|
|
253
|
+
* checker does not read, or a reference property holds something other
|
|
254
|
+
* than absolute IRIs, a blank node identifier as its `id`, and node
|
|
255
|
+
* objects, such as a value object, a language map, a string the
|
|
256
|
+
* property's alias does not coerce to an IRI, a relative reference or a
|
|
257
|
+
* blank node identifier, or it has more than one `id` or `href`, or a node
|
|
258
|
+
* object as one, or it nests properties with `@nest` or reverses them with
|
|
259
|
+
* `@reverse`, or its `id` is used elsewhere in the document, as the `id` of
|
|
260
|
+
* another node object or a reference outside its own properties, so that
|
|
261
|
+
* it is not read apart; a `Link` whose `href` is its own `id` is read. An
|
|
262
|
+
* uninterpreted node object has no properties, identifiers or types when
|
|
263
|
+
* its context is unread.
|
|
264
|
+
*/
|
|
265
|
+
readonly uninterpreted: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* Standard property names mapped to the source keys that supply them,
|
|
268
|
+
* matched by IRI whatever their type coercion or container.
|
|
269
|
+
*/
|
|
270
|
+
readonly properties: ReadonlyMap<string, readonly string[]>;
|
|
271
|
+
/**
|
|
272
|
+
* String IRI references held by the node object's own standard
|
|
273
|
+
* properties, through arrays and `@set` or `@list` objects, with compact
|
|
274
|
+
* IRIs expanded through the context's prefixes.
|
|
275
|
+
*/
|
|
276
|
+
readonly identifiers: readonly DocumentIdentifier[];
|
|
277
|
+
/** The type IRIs, with terms and compact IRIs expanded. */
|
|
278
|
+
readonly types: readonly string[];
|
|
279
|
+
/**
|
|
280
|
+
* The vocabulary category of its types the checker knows: `link` if one
|
|
281
|
+
* is a link type, or else that of the first.
|
|
282
|
+
*/
|
|
283
|
+
readonly kind?: DocumentNodeKind;
|
|
227
284
|
}
|
|
228
285
|
/** One IRI reference as written and as the context resolves it. */
|
|
229
286
|
interface DocumentIdentifier {
|
|
@@ -240,11 +297,13 @@ interface DocumentIdentifier {
|
|
|
240
297
|
* Describes the vocabulary documents the checker reads, so that write paths
|
|
241
298
|
* interpret aliases, full-IRI keys, and keyword aliases exactly as
|
|
242
299
|
* validation did, instead of matching literal key spellings. Opaque
|
|
243
|
-
* extension values are not
|
|
300
|
+
* extension values are not read as vocabulary documents, but the JSON-LD
|
|
301
|
+
* node objects in them are described as extensions of the document that
|
|
302
|
+
* holds them.
|
|
244
303
|
* @returns The root and every embedded document in traversal order, or
|
|
245
304
|
* `null` unless validation completes without errors.
|
|
246
305
|
*/
|
|
247
306
|
declare function describeDocument(document: unknown): readonly DocumentNode[] | null;
|
|
248
307
|
//#endregion
|
|
249
|
-
export { Diagnostic, DiagnosticCategory, DiagnosticReason, DiagnosticSeverity, DocumentAuthority, DocumentIdentifier, DocumentNode, DocumentNodeKind, DocumentPreparationOptions, DocumentValidationResult, FieldPath, JsonValue, NormalizationChange, ServerOwnedField,
|
|
308
|
+
export { ADDRESSING_PROPERTIES, DIAGNOSTIC_REASONS, Diagnostic, DiagnosticCategory, DiagnosticReason, DiagnosticSeverity, DocumentAuthority, DocumentIdentifier, DocumentNode, DocumentNodeKind, DocumentPreparationOptions, DocumentValidationResult, ExtensionNode, FieldPath, JsonValue, NormalizationChange, ServerOwnedField, describeDocument, prepareDocument, validateDocument };
|
|
250
309
|
//# sourceMappingURL=document.d.mts.map
|
package/dist/document.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.mts","names":[],"sources":["../src/document.ts"],"mappings":";;KAqEY;KAEA;KAMA;;cAGC;;aACc;aAAwB;;;aAC/B;aAAwB;;;aACnB;aAAwB;;;aAChC;aAAwB;;;aACnB;aAAwB;;;aACpB;aAAwB;;;aACrB;aAAwB;;;aAChC;aAAwB;;;aACZ;aAAuB;;;aACvB;aAAuB;;;aACvB;aAAqB;;;aACxB;aAAqB;;;aAC7B;aAAqB;;;aACjB;aAAqB;;;aACnB;aAAqB;;;aAClB;aAAqB;;;aACtB;aAAqB;;;aAE/C;aACA;;;aAGA;aACA;;;aAEqB;aAA2B;;;aAC7B;aAA2B;;;KAStC,gCAAgC;UAE3B;WACN,QAAQ;WACR,UAAU;WACV,UAAU;WACV,MAAM;WACN;;KAGC,wDAKC;YACG,cAAc;;;KAGlB;WAEG;WACA;WACA,MAAM;WACN,OAAO;WACP;;WAGA;WACA;WACA,MAAM;WACN,QAAQ;WACR,OAAO;WACP;;WAGA;WACA;WACA,MAAM;WACN,QAAQ;WACR;;UAGE;;WAEN;WACA,sBAAsB;WACtB;cAAiC,cAAc;;WAC/C,kBAAkB;;;UAIZ;WACN;;WAEA,MAAM;;;UAIA;;WAEN,MAAM;WACN;;;UAIM;;WAEN,qBAAqB,sBAAsB;WAC3C,4BAA4B;;;cAQ1B;;;;;;;;;;;;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