@drfed/models 0.2.0-dev.698 → 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 CHANGED
@@ -11,14 +11,15 @@ Document validation
11
11
  -------------------
12
12
 
13
13
  `@drfed/models/document` exports synchronous
14
- `validateDocument(document: unknown)` and `prepareDocument(document, options)`,
15
- plus the `diagnosticReasons` registry. Public types are
16
- `DocumentValidationResult`, `Diagnostic`, `DiagnosticReason`,
17
- `DiagnosticCategory`, `DiagnosticSeverity`, `FieldPath`, `JsonValue`,
18
- `NormalizationChange`, `DocumentAuthority`, `ServerOwnedField`, and
19
- `DocumentPreparationOptions`. Pass parsed JSON, not JSON text. Validation
20
- performs no network access, database writes, permission checks, or delivery,
21
- and never mutates input.
14
+ `validateDocument(document: unknown)`, `prepareDocument(document, options)`,
15
+ and `describeDocument(document: unknown)`, plus the `DIAGNOSTIC_REASONS`
16
+ registry. Public types are `DocumentValidationResult`, `Diagnostic`,
17
+ `DiagnosticReason`, `DiagnosticCategory`, `DiagnosticSeverity`, `FieldPath`,
18
+ `JsonValue`, `NormalizationChange`, `DocumentAuthority`, `ServerOwnedField`,
19
+ `DocumentPreparationOptions`, `DocumentNode`, `DocumentNodeKind`, and
20
+ `DocumentIdentifier`. Pass
21
+ parsed JSON, not JSON text. Validation performs no network access, database
22
+ writes, permission checks, or delivery, and never mutates input.
22
23
 
23
24
  ### Consumer contract
24
25
 
@@ -53,12 +54,12 @@ Vocabulary errors describe malformed supported input. Support errors describe
53
54
  unimplemented types, properties, or representations and make `complete` false.
54
55
  Compatibility warnings do not automatically reject the document. An omitted
55
56
  context uses the standard ActivityStreams context with a warning. The exported
56
- authority category is used by prepareDocument for caller-reported denials and
57
- server-owned-field conflicts. validateDocument itself emits no authority
58
- findings.
57
+ authority category is used by `prepareDocument()` for caller-reported denials
58
+ and server-owned-field conflicts. `validateDocument()` itself emits no
59
+ authority findings.
59
60
 
60
61
  Document-only normalization proposes omission of empty arrays on supported,
61
- applicable properties. For example, a Note with `to: []` receives the
62
+ applicable properties. For example, a `Note` with `to: []` receives the
62
63
  `empty_property_list` warning and a removal change with reason
63
64
  `omit_empty_property_list`; its preview omits `to`. Present changes for an
64
65
  explicit caller decision. Validation does not apply them or save the preview.
@@ -70,6 +71,67 @@ document is preserved. Arrays containing any non-null identifier remain errors.
70
71
  It does not assign IDs or timestamps, replace actor/attribution identities,
71
72
  deduplicate recipients, or convert references to embedded values.
72
73
 
74
+ ### Describing documents for write paths
75
+
76
+ `describeDocument(document)` returns the documents the checker reads, as
77
+ `DocumentNode` values, or null unless validation completes without errors. Each
78
+ node has its original path, the standard name of the property embedding it,
79
+ its type IRI, a `kind` (`activity`, `actor`, `collection`, `link`, or
80
+ `object`), and a map from standard property names, including `id` and `type`,
81
+ to the source keys that supply them. Aliases, prefixed or full-IRI keys, and
82
+ `@id`/`@type` aliases are mapped exactly as validation maps them; custom
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.
116
+
117
+ ~~~~ ts
118
+ import { describeDocument } from "@drfed/models/document";
119
+
120
+ const nodes = describeDocument({
121
+ "@context": [
122
+ "https://www.w3.org/ns/activitystreams",
123
+ { by: { "@id": "as:actor", "@type": "@id" } },
124
+ ],
125
+ type: "Like",
126
+ by: "https://example.com/alice",
127
+ object: "https://example.com/posts/1",
128
+ });
129
+ // nodes?.[0].properties.get("actor") → ["by"]
130
+ ~~~~
131
+
132
+ Write paths use it to find identity claims, addressing, and relations by their
133
+ meaning instead of their spelling.
134
+
73
135
  ### Preparing server-owned creation fields
74
136
 
75
137
  `prepareDocument(document, options)` returns the same DocumentValidationResult
@@ -101,15 +163,15 @@ values alone never request creation or modification of resources.
101
163
  Authority paths are caller-supplied diagnostic locations; they are not checked
102
164
  against writable document targets. This differs from server-owned field paths.
103
165
 
104
- Owned-field paths must name id, actor, attributedTo, published, or updated on
105
- existing supported root/nested documents. Supported aliases resolve to the same
106
- field; diagnostics and changes retain original source spellings and indexes.
107
- Conflicts in arrays point to the non-null entries. When filling an absent value,
108
- preparation prefers the requested key if it exists, then an existing alias,
109
- and otherwise adds the requested key.
110
- References and opaque extension data cannot be targets. The caller lists only
111
- the fields it owns for that explicit creation operation; no default fields are
112
- invented, and no values are generated from the clock or random IDs here.
166
+ Owned-field paths must name `id`, `actor`, `attributedTo`, `published`, or
167
+ `updated` on existing supported root/nested documents. Supported aliases
168
+ resolve to the same field; diagnostics and changes retain original source
169
+ spellings and indexes. Conflicts in arrays point to the non-null entries. When
170
+ filling an absent value, preparation prefers the requested key if it exists,
171
+ then an existing alias, and otherwise adds the requested key. References and
172
+ opaque extension data cannot be targets. The caller lists only the fields it
173
+ owns for that explicit creation operation; no default fields are invented, and
174
+ no values are generated from the clock or random IDs here.
113
175
 
114
176
  | Submitted value | Preparation behavior |
115
177
  | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
@@ -141,66 +203,71 @@ proposals remain unchanged.
141
203
  Denied authority, conflicts, unsupported input, and truncated diagnostics
142
204
  withhold both preview and changes. The input and trusted options are unchanged.
143
205
 
144
- #152 owns actual permission checks, value allocation, preview-to-commit
145
- coordination, persistence, and permission rechecks at write time. It must keep
146
- the committed values consistent with the accepted preview. This module neither
147
- saves anything nor adapts createObject. Both editors can display the shared
148
- results; saving, publication, and sending remain separate operations.
206
+ The common write operations in `@drfed/federation/local-write` own permission
207
+ checks, value allocation, preview-to-commit coordination, persistence, and
208
+ permission rechecks at write time, and commit exactly the values of an
209
+ accepted preview; see the [local write internals]. This module saves nothing.
210
+ Both editors can display the shared results; saving, publication, and sending
211
+ remain separate operations.
212
+
213
+ [local write internals]: https://drfed.org/internals/local-writes
149
214
 
150
215
  ### Supported types and properties
151
216
 
152
217
  The checker admits both activity base types and all 28 named activity subtypes,
153
- plus Object, Note, Article, Application, Group, Organization, Person, Service,
154
- Collection, OrderedCollection, CollectionPage, OrderedCollectionPage, Link,
155
- and Mention. Optional properties stay optional. Each document needs one
156
- supported type string; all type arrays, including singleton arrays, are
157
- unsupported. Unknown types are retained without being converted to Note.
218
+ plus `Object`, `Note`, `Article`, `Application`, `Group`, `Organization`,
219
+ `Person`, `Service`, `Collection`, `OrderedCollection`, `CollectionPage`,
220
+ `OrderedCollectionPage`, `Link`, and `Mention`. Optional properties stay
221
+ optional. Each document needs one supported `type` string; all `type` arrays,
222
+ including singleton arrays, are unsupported. Unknown types are retained without
223
+ being converted to `Note`.
158
224
 
159
225
  Type detection uses Fedify's public registry and inheritance, with an explicit
160
- implemented-type set. Link and Mention use their exported classes because the
161
- installed registry excludes them. Models and federation share the catalog
226
+ implemented-type set. `Link` and `Mention` use their exported classes because
227
+ the installed registry excludes them. Models and federation share the catalog
162
228
  version of `@fedify/vocab` (currently 2.4.3); context data comes from the
163
229
  matching `@fedify/vocab-runtime`. Recognition by Fedify alone does not
164
230
  establish checker coverage. No vocabulary parser or full JSON-LD expansion runs
165
231
  here.
166
232
 
167
- In the table, Object includes its admitted subtypes, including activities,
233
+ In the table, `Object` includes its admitted subtypes, including activities,
168
234
  actors, and collections. References are absolute IRIs or supported embedded
169
- Object/Link values. Reference lists retain order, duplicates, and source
235
+ `Object`/`Link` values. Reference lists retain order, duplicates, and source
170
236
  indexes.
171
237
 
172
- | Applies to | Properties and rules |
173
- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
174
- | Object and Link | id: one IRI; mediaType: one MIME type; preview: references/lists; name/nameMap: text without HTML. |
175
- | Object | summary/content and summaryMap/contentMap: text, including HTML and empty strings; location and attributedTo: references/lists. |
176
- | Object | published, updated, startTime, endTime: one date-time each; to, cc, bto, bcc, audience: references/lists, with empty-array omission previews. |
177
- | Activity | actor, object, target, origin, result, instrument: references/lists. IntransitiveActivity, Arrive, Travel, and Question reject non-null object values. |
178
- | Actor types | preferredUsername: text; inbox/outbox: one IRI or embedded OrderedCollection or OrderedCollectionPage; following/followers/liked: one IRI or embedded Collection subtype. |
179
- | Collection and subtypes | items/orderedItems: references/lists; totalItems: non-negative integer; current/first/last: one IRI or CollectionPage subtype. Counts need not match visible members. |
180
- | CollectionPage subtypes | partOf: one IRI or Collection subtype; next/prev: one IRI or CollectionPage subtype. |
181
- | OrderedCollectionPage | startIndex: non-negative integer. |
182
- | Link and Mention | href: one IRI; hreflang: one language tag; rel: relation tokens/IRIs or lists; height/width: non-negative integers. Object-only fields, such as content and location, receive property\_not\_applicable. |
183
-
184
- Except for id, single-value properties accept a scalar or array containing at
238
+ | Applies to | Properties and rules |
239
+ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
240
+ | `Object` and `Link` | `id`: one IRI; `mediaType`: one MIME type; `preview`: references/lists; `name`/`nameMap`: text without HTML. |
241
+ | `Object` | `summary`/`content` and `summaryMap`/`contentMap`: text, including HTML and empty strings; `location` and `attributedTo`: references/lists. |
242
+ | `Object` | `published`, `updated`, `startTime`, `endTime`: one date-time each; `to`, `cc`, `bto`, `bcc`, `audience`: references/lists, with empty-array omission previews. |
243
+ | `Activity` | `actor`, `object`, `target`, `origin`, `result`, `instrument`: references/lists. `IntransitiveActivity`, `Arrive`, `Travel`, and `Question` reject non-null `object` values. |
244
+ | Actor types | `preferredUsername`: text; `inbox`/`outbox`: one IRI or embedded `OrderedCollection` or `OrderedCollectionPage`; `following`/`followers`/`liked`: one IRI or embedded `Collection` subtype. |
245
+ | `Collection` and subtypes | `items`/`orderedItems`: references/lists; `totalItems`: non-negative integer; `current`/`first`/`last`: one IRI or `CollectionPage` subtype. Counts need not match visible members. |
246
+ | `CollectionPage` subtypes | `partOf`: one IRI or `Collection` subtype; `next`/`prev`: one IRI or `CollectionPage` subtype. |
247
+ | `OrderedCollectionPage` | `startIndex`: non-negative integer. |
248
+ | `Link` and `Mention` | `href`: one IRI; `hreflang`: one language tag; `rel`: relation tokens/IRIs or lists; `height`/`width`: non-negative integers. `Object`-only fields, such as `content` and `location`, receive `property_not_applicable`. |
249
+
250
+ Except for `id`, single-value properties accept a scalar or array containing at
185
251
  most one non-null value; multiple values receive `invalid_multiplicity`. Null
186
252
  means absence, including null list entries. Empty arrays on supported
187
253
  properties receive `empty_property_list` and an inspectable omission preview;
188
- nested lists remain unsupported. Type and context arrays do not use this
254
+ nested lists remain unsupported. `type` and `@context` arrays do not use this
189
255
  omission rule. Unknown custom arrays are preserved as opaque data, while empty
190
256
  arrays on unsupported or inapplicable fields retain their existing errors.
191
257
  Identifiers require an IRI string when present. Null, empty arrays, and
192
258
  null-only arrays receive omission previews; arrays containing non-null values
193
259
  receive `invalid_value_shape`, even when they contain only one identifier.
194
- Embedded activity actors and Object `attributedTo` values must use Application,
195
- Group, Organization, Person, or Service for Fedify compatibility. Other
196
- ActivityStreams-permitted embedded types receive `unsupported_value_form`; IRI
197
- references remain supported without remote type checks. Object-only fields such
198
- as `attributedTo` on Link receive `property_not_applicable`. Link `preview` and
199
- `nameMap` remain supported by the vocabulary and Fedify's decoder. Collection
200
- navigation accepts embedded CollectionPage values for current, first, last,
201
- next, and prev, and Collection values for partOf, including subtypes. Embedded
202
- Links in these fields receive `unsupported_value_form` because Fedify rejects
203
- them. Diagnostics retain the original field/list paths.
260
+ Embedded activity actors and `Object` `attributedTo` values must use
261
+ `Application`, `Group`, `Organization`, `Person`, or `Service` for Fedify
262
+ compatibility. Other ActivityStreams-permitted embedded types receive
263
+ `unsupported_value_form`; IRI references remain supported without remote type
264
+ checks. `Object`-only fields such as `attributedTo` on `Link` receive
265
+ `property_not_applicable`. `Link` `preview` and `nameMap` remain supported by
266
+ the vocabulary and Fedify's decoder. `Collection` navigation accepts embedded
267
+ `CollectionPage` values for `current`, `first`, `last`, `next`, and `prev`, and
268
+ `Collection` values for `partOf`, including subtypes. Embedded `Link` values in
269
+ these fields receive `unsupported_value_form` because Fedify rejects them.
270
+ Diagnostics retain the original field/list paths.
204
271
 
205
272
  Text accepts strings, flat lists, and supported `@value`/`@language` objects.
206
273
  Language maps contain strings or null. Complex text attributes are unsupported.
@@ -213,15 +280,15 @@ unsupported. Validation preserves these values without adding seconds or
213
280
  truncating precision. Timestamp validation does not establish server ownership
214
281
  or ordering between fields.
215
282
 
216
- Question is supported standalone and inside Create/Update using shared rules.
217
- Its `oneOf`, `anyOf`, and `closed` fields remain unsupported pending #155's
218
- poll rules. Open-ended Question needs no choices. Other types without
219
- implemented rules, such as Place, receive support findings.
283
+ `Question` is supported standalone and inside `Create`/`Update` using shared
284
+ rules. Its `oneOf`, `anyOf`, and `closed` fields remain unsupported pending
285
+ #155's poll rules. Open-ended `Question` needs no choices. Other types without
286
+ implemented rules, such as `Place`, receive support findings.
220
287
 
221
- For 0.2.0, Object property rules for `tag`, `inReplyTo`, `url`, `attachment`,
288
+ For 0.2.0, `Object` property rules for `tag`, `inReplyTo`, `url`, `attachment`,
222
289
  `replies`, `icon`, `image`, `context`, `source`, `duration`, and `generator`
223
290
  remain unimplemented. Null values are treated as absent and preserved without
224
- diagnostics or normalization. On Object documents, non-null values produce
291
+ diagnostics or normalization. On `Object` documents, non-null values produce
225
292
  `unsupported_property` errors and set `complete: false`, preventing successful
226
293
  validation even when their values are valid ActivityStreams. This limits which
227
294
  documents pasted from fediverse servers can pass validation. Unknown custom
@@ -271,9 +338,10 @@ values must be strings or arrays of strings; malformed entries receive
271
338
  `invalid_value_shape` at the original keyword or list-entry path. These shape
272
339
  checks do not require custom type strings to appear in the implemented-type
273
340
  set. An `@json` value's payload remains ordinary JSON, including keys spelled
274
- `@id` or `@type`, and is checked only for JSON safety. These bounded checks do
275
- not establish full JSON-LD validity or interpret nested contexts and keyword
276
- aliases.
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.
277
345
 
278
346
  This warning policy does not admit unknown types, unsupported contexts,
279
347
  JSON-LD keywords, or known vocabulary properties without implemented rules.
@@ -309,7 +377,8 @@ category and severity are checked against the registry. Input preservation and
309
377
  preview contents are asserted. Additional tests exercise network avoidance,
310
378
  contexts, representation limits, and nested traversal. Preparation tests
311
379
  exercise supplied authority outcomes and generated-field previews. Database
312
- permission enforcement and transaction integration remain #152 responsibilities.
380
+ permission enforcement and transaction integration are tested with the common
381
+ write operations in `@drfed/federation`.
313
382
 
314
383
  [the fixture file]: ../../fixtures/document-validation/initial.json
315
384
  [the document tests]: src/document.test.ts
@@ -330,12 +399,15 @@ Resource revisions
330
399
 
331
400
  `@drfed/models/resource-revision` provides trusted append and history reads for
332
401
  full ActivityStreams JSON, with compare-and-swap heads and terminal deletion
333
- markers. Existing local and inbound Create writers capture their documents in
402
+ markers. Existing local and inbound `Create` writers capture their documents in
334
403
  the same transaction. Retained JSON can contain blind recipients; model reads
335
404
  do not authorize access or prepare wire documents.
336
405
 
337
- See the [resource revision internals] for API examples, projections, legacy
338
- upgrades and the boundaries of editor, federation and dispatch integration.
406
+ `writeTypedResourceRevision()` edits or deletes an object that also has a
407
+ legacy typed row, keeping the row, its current addressing, and the history in
408
+ step. See the [resource revision internals] for API examples, projections,
409
+ legacy upgrades and the boundaries of editor, federation and dispatch
410
+ integration.
339
411
 
340
412
  [resource revision internals]: https://drfed.org/internals/resource-revisions
341
413
 
@@ -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 diagnosticReasons: {
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 diagnosticReasons;
93
+ type DiagnosticReason = keyof typeof DIAGNOSTIC_REASONS;
94
94
  interface Diagnostic {
95
95
  readonly reason: DiagnosticReason;
96
96
  readonly category: DiagnosticCategory;
@@ -149,6 +149,8 @@ interface DocumentPreparationOptions {
149
149
  readonly authority: readonly [DocumentAuthority, ...DocumentAuthority[]];
150
150
  readonly serverOwnedFields: readonly ServerOwnedField[];
151
151
  }
152
+ /** The ActivityStreams properties that address a document's recipients. */
153
+ declare const ADDRESSING_PROPERTIES: readonly ["to", "cc", "bto", "bcc", "audience"];
152
154
  /**
153
155
  * Checks the implemented Activity Vocabulary types, including nested
154
156
  * activity objects, without network access or writes. Embedded objects inherit
@@ -195,6 +197,113 @@ declare function validateDocument(document: unknown): DocumentValidationResult;
195
197
  * @returns Original-input diagnostics and any explicit creation preview changes.
196
198
  */
197
199
  declare function prepareDocument(document: unknown, options: DocumentPreparationOptions): DocumentValidationResult;
200
+ /** The vocabulary category of a described document. */
201
+ type DocumentNodeKind = "activity" | "actor" | "collection" | "link" | "object";
202
+ /** One document reached by vocabulary traversal, as the checker read it. */
203
+ interface DocumentNode {
204
+ /** Source path of the document; `[]` is the root. */
205
+ readonly path: FieldPath;
206
+ /**
207
+ * The standard name of the property that embeds the document, whatever
208
+ * its source spelling; absent for the root.
209
+ */
210
+ readonly property?: string;
211
+ /** The ActivityStreams type IRI, such as `…/activitystreams#Note`. */
212
+ readonly type: string;
213
+ readonly kind: DocumentNodeKind;
214
+ /**
215
+ * Standard property names, including `id` and `type`, mapped to the source
216
+ * keys that supply them, in source key order. Custom extension keys are
217
+ * not listed.
218
+ */
219
+ readonly properties: ReadonlyMap<string, readonly string[]>;
220
+ /**
221
+ * String IRI references held by this document's own reference properties
222
+ * (`id`, `actor`, `object`, addressing, `href`, and so on), with compact
223
+ * IRIs expanded through the context's prefixes. Values inside embedded
224
+ * documents belong to those documents' nodes.
225
+ */
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;
284
+ }
285
+ /** One IRI reference as written and as the context resolves it. */
286
+ interface DocumentIdentifier {
287
+ /** The standard property name, such as `actor` or `to`. */
288
+ readonly property: string;
289
+ /** Source path of the value, including its list index if any. */
290
+ readonly path: FieldPath;
291
+ /** The value as written. */
292
+ readonly value: string;
293
+ /** The value with a compact IRI prefix expanded. */
294
+ readonly iri: string;
295
+ }
296
+ /**
297
+ * Describes the vocabulary documents the checker reads, so that write paths
298
+ * interpret aliases, full-IRI keys, and keyword aliases exactly as
299
+ * validation did, instead of matching literal key spellings. Opaque
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.
303
+ * @returns The root and every embedded document in traversal order, or
304
+ * `null` unless validation completes without errors.
305
+ */
306
+ declare function describeDocument(document: unknown): readonly DocumentNode[] | null;
198
307
  //#endregion
199
- export { Diagnostic, DiagnosticCategory, DiagnosticReason, DiagnosticSeverity, DocumentAuthority, DocumentPreparationOptions, DocumentValidationResult, FieldPath, JsonValue, NormalizationChange, ServerOwnedField, diagnosticReasons, prepareDocument, validateDocument };
308
+ export { ADDRESSING_PROPERTIES, DIAGNOSTIC_REASONS, Diagnostic, DiagnosticCategory, DiagnosticReason, DiagnosticSeverity, DocumentAuthority, DocumentIdentifier, DocumentNode, DocumentNodeKind, DocumentPreparationOptions, DocumentValidationResult, ExtensionNode, FieldPath, JsonValue, NormalizationChange, ServerOwnedField, describeDocument, prepareDocument, validateDocument };
200
309
  //# sourceMappingURL=document.d.mts.map
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8yDvB,iBAAiB,oBAAoB;;;;;;;;;;;;;;;;;;iBA0QrC,gBACd,mBACA,SAAS,6BACR"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+9DG,iBAAiB,oBAAoB;;;;;;;;;;;;;;;;;;iBA0QrC,gBACd,mBACA,SAAS,6BACR;;KAsGS;;UAQK;;WAEN,MAAM;;;;;WAKN;;WAEA;WACA,MAAM;;;;;;WAMN,YAAY;;;;;;;WAOZ,sBAAsB;;;;;WAKtB,qBAAqB;;;;;;;;UASf;;WAEN,MAAM;;;;;;WAMN;;WAEA,SAAS;;;;;;;;;;;;;;;;WAgBT;;;;;WAKA,YAAY;;;;;;WAMZ,sBAAsB;;WAEtB;;;;;WAKA,OAAO;;;UAID;;WAEN;;WAEA,MAAM;;WAEN;;WAEA;;;;;;;;;;;;iBA6TK,iBACd,6BACU"}