@agentshouse/mdmodel 0.1.0-ce6172ed6fa4c → 0.1.0-ce7e4efd1b42d
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/API.md +31 -97
- package/README.md +14 -14
- package/dist/definition.d.ts +5 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +18 -9
- package/dist/document.d.ts +2 -2
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +88 -69
- package/dist/event.js +1 -1
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/house-model.d.ts +50 -7
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +18 -5
- package/dist/index.d.ts +15 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/indexed.d.ts +9 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +55 -0
- package/dist/kinds.d.ts +3 -0
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +60 -0
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- package/dist/moment.d.ts +7 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +18 -0
- package/dist/not-ready.d.ts +2 -0
- package/dist/not-ready.d.ts.map +1 -0
- package/dist/not-ready.js +5 -0
- package/dist/paths.d.ts +5 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +14 -0
- package/dist/query/language.d.ts +2 -1
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +1 -1
- package/dist/query/match.d.ts +1 -1
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/rows.d.ts +1 -1
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +2 -5
- package/dist/query/sql.d.ts +5 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +3 -3
- package/dist/query/walk.d.ts +63 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +263 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/room-types.d.ts +1 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +0 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -7
- package/dist/types.d.ts +1 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +11 -7
- package/dist/yaml.d.ts +4 -4
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +1 -1
- package/fixtures/README.md +13 -48
- package/fixtures/preamble.json +4 -4
- package/fixtures/queries.json +397 -2
- package/package.json +1 -1
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -321
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -101
- package/fixtures/division.json +0 -454
- package/fixtures/projection.json +0 -358
package/API.md
CHANGED
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
```ts
|
|
4
4
|
import {
|
|
5
5
|
apply,
|
|
6
|
-
divide,
|
|
7
6
|
links,
|
|
8
7
|
parse,
|
|
9
|
-
project,
|
|
10
8
|
retarget,
|
|
11
9
|
serialize,
|
|
12
10
|
target,
|
|
@@ -46,7 +44,10 @@ JSON Schema of its Documents' values; `$defs` holds shapes the types reuse, reac
|
|
|
46
44
|
beside it admits a Document in another Room, of a type that Room declares; `title` is the label a
|
|
47
45
|
Document shows for a field and `contentMediaType: text/markdown` marks a string of Markdown text
|
|
48
46
|
written under its own heading; `member_document: true` marks at most one type. A type alone takes `create_roles` and
|
|
49
|
-
`delete_roles`, each a list of role names
|
|
47
|
+
`delete_roles`, each a list of role names, and `indexed`, which validates nothing: a list of its own top-level
|
|
48
|
+
fields, each admitting one plain value or `null`, a number, an integer, a boolean, or a choice, `date`,
|
|
49
|
+
`date-time`, `time` or `maxLength`-bounded string. `verifyIndexBounds(model, { perType, longestText })`
|
|
50
|
+
refuses a type past those bounds under the rule `indexed`. `verify(schema, provided)` holds every type of a model
|
|
50
51
|
`provided` as its own, named only for those two and only if `provided.nameable` lists it. On a field
|
|
51
52
|
of a type's own `properties` alone, `change_roles` and `initial_roles` each list role names, and
|
|
52
53
|
`transitions` lists `{ from, to, roles? }`, each end a scalar or `null`, on a field whose `type`,
|
|
@@ -72,7 +73,7 @@ contact: { member_document: true }
|
|
|
72
73
|
The model's `types` expose each MD Type's `name`, `memberDocument`, `shape` (the type as
|
|
73
74
|
written, its rule keywords left out, with every `$defs` shape it reaches), `createRoles` and
|
|
74
75
|
`deleteRoles` when written, its `rules` by field as `changeRoles`, `initialRoles` and `transitions`,
|
|
75
|
-
the facts of its `
|
|
76
|
+
the facts of its whole value, `root`, and of `fields`, its top-level ones: JSON `type`, `format`, `values`,
|
|
76
77
|
`reference` targets, `items`, `properties`, an open map's `patterns` and `additional`, `prose`,
|
|
77
78
|
a string with no `enum`, `const`, `format`, `pattern` or `reference`, its `title`, `markdown` and `json`,
|
|
78
79
|
a value written as one `json` block for no single JSON type, an open object or a union of objects. Facts join `$ref` and `allOf`
|
|
@@ -80,7 +81,7 @@ to their siblings and the variants of `anyOf`, `oneOf`, `then`, `else` and `depe
|
|
|
80
81
|
variant's own keys `conditional`; a path without one `type`, `null` aside, has none. A malformed
|
|
81
82
|
schema is refused whole, naming its `rule`, the keyword or the model's own, and the JSON Pointer
|
|
82
83
|
`location` it concerns, such as `/plan/properties/status/enum`, or `line <n>` outside the YAML
|
|
83
|
-
subset. `pointerFacts(definition, pointer)` reads the facts a
|
|
84
|
+
subset. `pointerFacts(definition, pointer)` reads the facts a pointer into the value reaches, `itemFacts`
|
|
84
85
|
and `memberFacts` take one step and `crossedFacts` reads a list's item facts; `JSON_POINTER` matches the
|
|
85
86
|
JSON Pointer grammar, `''` included, `pointerSegments` and `escapePointer` split and write a pointer,
|
|
86
87
|
`ARRAY_INDEX` matches an index segment, and `ATTACHMENT` is the `reference` that admits any path.
|
|
@@ -99,7 +100,7 @@ into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-m
|
|
|
99
100
|
`HOUSE_ROOM_TYPES` is the `provided` model of every Room, verified: the Inbox's `CHAT_TYPE` card, whose `channel` is one of `INBOX_CHANNEL_KINDS`, and its `CHAT_MESSAGE_TYPE` messages, the two `INBOX_TYPES` and its `nameable` ones, a Wayfinding map and its tickets, and every type of `HOUSE_MODEL`, the House model `HOUSE_MODEL_DECLARATION` declares, from which the `HouseModelType` names and the `HouseDocumentFields<type>` of each type's Document follow. `HOUSE_TYPED_PATHS` binds House's paths to their types: `settings/panel.md`, an App's preferences under `APP_PREFERENCES_HOME` and an Agent function document under `rooms/<handle>/agent-functions/`. Its `room`, `app` and `space` definitions are `ROOM_REFERENCE_PATTERN`, `APP_REFERENCE_PATTERN` and `SPACE_REFERENCE_PATTERN`: a prefix, `ROOM_REFERENCE_PREFIX`, `APP_REFERENCE_PREFIX` or `SPACE_REFERENCE_PREFIX`, then an ordinal, a dot and a check character; `REVISION_REFERENCE_PATTERN` reads a revision, `REVISION_REFERENCE_PREFIX`, its document's ordinal, a dot, the revision's and a check character, each character one `CROCKFORD_CHARACTER` of the lowercase Crockford alphabet `CROCKFORD_ALPHABET`, and `CROCKFORD_LEADING_CHARACTER` any of it but `0`.
|
|
100
101
|
|
|
101
102
|
A typed Document writes its values in its body, as Markdown, and its frontmatter holds only
|
|
102
|
-
`TYPE_FIELD`, `MEMBER_FIELD`, `SITE_FIELD` and `
|
|
103
|
+
`TYPE_FIELD`, `MEMBER_FIELD`, `SITE_FIELD` and `SUBMITTED_FIELD` (`submitted`), which `parse` reads
|
|
103
104
|
into the same value; any other frontmatter key is `malformed-value`. The `#` line is the top-level
|
|
104
105
|
`name`; under it each short value is one line `- **Label**: value` of the value list, a boolean a
|
|
105
106
|
checkbox line `- [x] Label`, a reference a link whose text is no value, a group of short values an
|
|
@@ -119,12 +120,12 @@ everything after a top-level thematic break, which also ends a value under a hea
|
|
|
119
120
|
A typed Document's value satisfies its type's schema, every keyword with its JSON Schema
|
|
120
121
|
meaning, formats asserted and defaults never filled, except that an object schema declaring neither
|
|
121
122
|
`additionalProperties` nor `unevaluatedProperties` is closed: an undeclared key is refused as
|
|
122
|
-
`undeclared-field`. `TYPE_FIELD`, `SITE_FIELD` and `
|
|
123
|
+
`undeclared-field`. `TYPE_FIELD`, `SITE_FIELD` and `SUBMITTED_FIELD` count as declared on every type,
|
|
123
124
|
and the string `MEMBER_FIELD` on the `member_document` type alone, else refused, `any` included;
|
|
124
125
|
`HOUSE_FIELDS` lists the four. A refusal names the keyword, such as `required`, the value's JSON
|
|
125
126
|
Pointer, such as `/shipping/city`, and the `line` the value is written on. A reference, at any depth, reaching a URL, a binary target, another
|
|
126
127
|
Room without `cross_room` or the context's `anyRoom: true`, a Document of a type it does not name, or,
|
|
127
|
-
from an `isDocumentPath`, a reserved name is `unresolved-reference`, and
|
|
128
|
+
from an `isDocumentPath`, a reserved name is `unresolved-reference`, and one reaching no member is `referenced-missing-file`
|
|
128
129
|
naming its `referrers`; `attachment` admits any path, and no body link is a referrer. `validating` is
|
|
129
130
|
`validate` over a `ReadonlyMap` Library, yielding each path read with the references it `resolved`;
|
|
130
131
|
`assess(file, parsed, binary, model?, context?)` reads one member from its `parse` result, naming its
|
|
@@ -154,10 +155,10 @@ With a definition a field change rewrites that value's lines alone and writes a
|
|
|
154
155
|
schema position, after the nearest field before it the Document holds; a value whose form changes
|
|
155
156
|
moves, and `undefined` removes it. A reference is written as a link whose text is `nameOf(value)`,
|
|
156
157
|
else the file name, and never changed after; a value no form carries is `malformed-value`, and a
|
|
157
|
-
section change naming a field's label `
|
|
158
|
+
section change naming a field's label `field-section`, at that field's key. Without one a field is written in the
|
|
158
159
|
frontmatter. A `{ kind: 'section', name, value, prior: undefined }` change opens a
|
|
159
160
|
section after the Document's last line, in the order the changes give, and is stale where the
|
|
160
|
-
Document holds that section. The Document a typed write of values returns carries the values it wrote, and reads its body only when a caller asks for what only the text holds; a write that carries text from outside, a Markdown value, a text value that does not fit its line, free text, a section or the preamble, or rewrites a link, reads the text it made. All apply or none: one refused refuses
|
|
161
|
+
Document holds that section; one with a prior text is stale where the Document lacks the section, a name no `## ` heading reads back as itself being `unwritable-section`, and a section's or the preamble's prior is compared as `partText(part)` reads it, its text without the blank lines around it, which a writer sends back. The Document a typed write of values returns carries the values it wrote, and reads its body only when a caller asks for what only the text holds; a write that carries text from outside, a Markdown value, a text value that does not fit its line, free text, a section or the preamble, or rewrites a link, reads the text it made. All apply or none: one refused refuses
|
|
161
162
|
all, and `{ outcome: 'stale', document, stale }` keeps the Document and lists the positions of each
|
|
162
163
|
change it does not hold and of each later change of a part an earlier one changes, such as a link
|
|
163
164
|
inside a replaced section. A section, preamble or free text replacement that would hide a section the
|
|
@@ -165,8 +166,8 @@ Document carried behind a repeated, merged or fenced heading, or change a value,
|
|
|
165
166
|
`overlapping-section` naming that section or value. A frontmatter field change does not reformat
|
|
166
167
|
the rest of the file: an inline value is replaced where it stands, and a value written after the
|
|
167
168
|
key's line, an empty one or a block mapping or list, is written after the key's colon in its place.
|
|
168
|
-
A
|
|
169
|
-
a list without holes or a plain object of them, no cycle, at most 63 deep. `
|
|
169
|
+
A field holds a `DocumentValue`: null, a string, a boolean, a finite number,
|
|
170
|
+
a list without holes or a plain object of them, no cycle, at most 63 deep. `documentValue(value)`
|
|
170
171
|
is that test; `apply` refuses any other value and `parse` a frontmatter past 64 deep as
|
|
171
172
|
`frontmatter-fence`. `equalValue` compares two by value, whatever their key order, as `apply` does.
|
|
172
173
|
`relabel(document, before, after)` is the Document's text with each label `before` wrote replaced by `after`'s, every other byte kept. `relabels(before, after)` is whether a Document of the type `before` defines would be relabelled under `after`: a field's label, its title else its key, differs between the two, or a field is labelled in only one. `labelAt(facts, pointer)` is the label of the value at `pointer` under `facts`.
|
|
@@ -220,14 +221,12 @@ if it names no Path. `retarget(href, to)` is that destination rewritten to `to`,
|
|
|
220
221
|
`?query` or `#fragment` it carried, which is the destination the `link` change below writes. It
|
|
221
222
|
percent-encodes in `to` what `target` would decode, so it resolves to `to` again.
|
|
222
223
|
|
|
223
|
-
`untitled(definition)` is a definition without its `title`s at any depth, a property named `title`
|
|
224
|
-
kept, so two types that differ only in their labels compare equal.
|
|
224
|
+
`untitled(definition)` is a definition without its `title`s at any depth, a property named `title` kept, so two types that differ only in their labels compare equal.
|
|
225
225
|
|
|
226
226
|
`checkDocument(file, content, model, context?)` reads one Document as `validate` does in that
|
|
227
227
|
context: `ok: false` where it refuses, else its `type`, whether it is `typed`, and each reference's
|
|
228
228
|
`target` and `to`, which `resolves(reference, typeOf, binary)` says reaches a member `validate`
|
|
229
229
|
accepts. It names no other Room's, which `roomReferences(document, definition?)` lists by `kind`.
|
|
230
|
-
`parseFrontmatter(content, file?)` is `parse` without the body: `content`, `type`, `fields`.
|
|
231
230
|
|
|
232
231
|
`references(document, definition)` lists each `reference` value at any depth as `pointer`,
|
|
233
232
|
`value` and `to`; a `{ kind: 'reference', pointer, value, prior }` change rewrites the destination
|
|
@@ -240,7 +239,7 @@ rewrites, in one `apply`, each link destination and reference written `/rooms/<h
|
|
|
240
239
|
not in `kept` to `relative(file, path)`, keeping its `?query` or `#fragment`. A text without
|
|
241
240
|
frontmatter, such as a captured body, is read from its first character: `relativizeBody(body, file, handle)` converts it
|
|
242
241
|
so, refusing a `/rooms/` one naming no Room's file as `unresolved-link`; `bodyLinks(body, file)`
|
|
243
|
-
is its `links` and `bodyRoomLinks(body)` its other Rooms'. `relinkBody(body, file, moves)` writes,
|
|
242
|
+
is its `links` and `bodyRoomLinks(body)` its other Rooms'. A keyed link, `/rooms/<handle>/<path>?key=<key>` as a body link or a reference value, stays as written, which no relativizing or relinking rewrites, out of `roomReferences` and `bodyRoomLinks` and naming no target validation checks; `keyedLink(href)` reads one as its `handle`, `path` and `key`, or `null` for any other href, `bodyKeyedLinks(body)` lists each in a body, and `keyedDestination(path, key)` writes one. `relinkBody(body, file, moves)` writes,
|
|
244
243
|
in the `link` change's form, each destination whose Path keys `moves` as that value relative to
|
|
245
244
|
`file`, or as that value when it is a `/rooms/` path, and one whose `roomPath` does as that value.
|
|
246
245
|
`unlinkBody(body, hrefs)` cuts every link and reference definition whose written destination is
|
|
@@ -261,82 +260,8 @@ profile reads back: bare when it carries no whitespace, does not open with `<`,
|
|
|
261
260
|
parentheses, otherwise inside angle brackets, which the original form is kept in when it still
|
|
262
261
|
fits. A destination that neither form can carry is refused as `unwritable-link`.
|
|
263
262
|
|
|
264
|
-
`
|
|
265
|
-
|
|
266
|
-
Document that declares no MD type contributes its body after the frontmatter fence. A typed one
|
|
267
|
-
contributes its prose values, each bare without its label, first the ones written on a line, in a
|
|
268
|
-
cell or in a `json` block, each followed by a blank line, then its Markdown long values and its free
|
|
269
|
-
text, its preamble, each section whose heading names no field and what follows a thematic break,
|
|
270
|
-
in Document order. A prose value is a string at any depth whose schema is prose. The Path, every
|
|
271
|
-
label and every other value stay outside, so changing them alone leaves the projection unchanged.
|
|
272
|
-
|
|
273
|
-
```ts
|
|
274
|
-
const parsed = parse(content);
|
|
275
|
-
if (parsed.ok) {
|
|
276
|
-
const projected = project(parsed.document, 'tasks/two.md', {
|
|
277
|
-
documentTargets: ['plans/q3.md', 'people/ana.md'],
|
|
278
|
-
definition: model.types.task,
|
|
279
|
-
});
|
|
280
|
-
if (projected.ok) embed(projected.text);
|
|
281
|
-
}
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
`ProjectionContext` carries `documentTargets`, the collection-relative Paths the caller holds as
|
|
285
|
-
Markdown documents, and `definition`, the verified MD Type the Document's `type` names, taken from
|
|
286
|
-
the model `verify` returned. A Document that declares a type the caller supplies no definition for
|
|
287
|
-
is refused as `unknown-type`. `documentTargets` is what makes a destination internal: a destination
|
|
288
|
-
resolving to a supplied Path is internal, as is one into another Room, and every other stays text, a
|
|
289
|
-
binary target and a Path nobody supplied alike. The caller supplies that membership, as it does for
|
|
290
|
-
`validate`; the model reads no bytes, resolves no authority, and classifies nothing unsupplied.
|
|
291
|
-
|
|
292
|
-
An internal link contributes its visible label and no destination, fragment, or title, in the inline
|
|
293
|
-
`[label](path)`, full `[label][id]`, collapsed `[label][]`, and shortcut `[label]` forms, and the
|
|
294
|
-
link reference definition an enumerated use resolves through leaves the projection with it. An image
|
|
295
|
-
at a supplied document target contributes its alt text the same way, because a move rewrites that
|
|
296
|
-
destination too. External URLs, binary targets, unsupplied destinations, bare fragments, code spans,
|
|
297
|
-
fenced code, and escaped syntax stay exactly as authored, read through the same syntax profile
|
|
298
|
-
`links` and `validate` read. `project` returns text and never rewrites the Document.
|
|
299
|
-
|
|
300
|
-
A `link` change leaves the projection of every Document it rewrites
|
|
301
|
-
byte-identical, while a changed visible label changes it.
|
|
302
|
-
|
|
303
|
-
`divide(document, file, context)` divides that same Embedding projection input into ordered Spans
|
|
304
|
-
under the bound the caller supplies. Each Span carries the `text` to embed and the `start` and `end`
|
|
305
|
-
of the extent it addresses in the Document's own source, as UTF-8 byte offsets and never string
|
|
306
|
-
positions, so a caller stores the extent and hydrates the text it shows from the Document itself.
|
|
307
|
-
|
|
308
|
-
`DivisionContext` is a `ProjectionContext` and one `bound`, the greatest number of characters a
|
|
309
|
-
Span's embedded text may carry, counted the way JavaScript counts a string's length and not in the
|
|
310
|
-
bytes the extent is measured in. No Span's text is ever longer than the bound. A bound cut never
|
|
311
|
-
divides a character: where the bound ends between the two halves of a surrogate pair, the cut falls
|
|
312
|
-
before the pair. A cut never falls inside link syntax either: it falls before an internal link, and
|
|
313
|
-
a label longer than a whole piece's room is divided at the bound like any other text. The smallest
|
|
314
|
-
bound is `2`, the length of one astral character; a bound that is not a whole number of at least
|
|
315
|
-
`2` is refused with `division-bound` before any division. The bound is the caller's number alone:
|
|
316
|
-
the model holds no tokenizer, counts nothing else, and refuses no input for being too long. A
|
|
317
|
-
Document the caller supplies no definition for carries the `unknown-type` refusal of `project`.
|
|
318
|
-
|
|
319
|
-
The division descends one level at a time, and only into the piece that does not fit: the whole
|
|
320
|
-
input, a heading node, adjacent sibling nodes packed under one parent, adjacent blocks inside a
|
|
321
|
-
node, sentences inside a block, and a bound cut inside a single sentence. A Span covers whole
|
|
322
|
-
heading nodes or one contiguous piece inside a single node, never a partial node beside another. A
|
|
323
|
-
Span that continues a node repeats that node's own heading line, projected like any other text and
|
|
324
|
-
so carrying an internal link's label rather than its destination, and never an ancestor's heading,
|
|
325
|
-
so renaming a heading costs what editing that heading's own body costs. A heading the bound cannot
|
|
326
|
-
hold beside any text is not repeated, a continuation piece that begins with an astral character the
|
|
327
|
-
room beside its heading cannot hold is carried without the heading, and a heading with no body of
|
|
328
|
-
its own leads its first child node rather than standing as a Span of nothing but itself. Overlap
|
|
329
|
-
exists at the sentence level alone, where each Span after the first repeats its predecessor's last
|
|
330
|
-
sentence whenever the bound holds both; when it cannot hold both, the Span carries its own sentence
|
|
331
|
-
alone. An untyped input arrives without a definition and descends the same ladder.
|
|
332
|
-
|
|
333
|
-
Division is total: every authored character of the input belongs to at least one Span, and an input
|
|
334
|
-
carrying no authored text divides into no Span at all. A Span's extent is the smallest range of the
|
|
335
|
-
source that contains everything the Span covers, so it spans what the input excludes between two
|
|
336
|
-
eligible pieces, and the extent addresses the authored source where the embedded text carries a
|
|
337
|
-
repeated heading, an internal link's visible label, or a value the author escaped. A Span divided
|
|
338
|
-
out of one value written on a line addresses that whole value, and a Span carrying part of one
|
|
339
|
-
internal link's label addresses that whole link, because a cut never falls inside link syntax.
|
|
263
|
+
`notReadyWaitMs(asked)` is how long a client told a Room's chunk list is not ready waits before it
|
|
264
|
+
asks again: 1, 2, 3, 5, 8, 11 and 15 seconds by `asked`, counted from zero, then 15 seconds.
|
|
340
265
|
|
|
341
266
|
## Queries
|
|
342
267
|
|
|
@@ -364,7 +289,11 @@ the values it takes in words, and `fitsKind(kind, facts, value)` whether a value
|
|
|
364
289
|
`dated`, a `date-time` compares as the instant `instant` reads, which `instantKey` writes as text
|
|
365
290
|
that sorts as the instant does, and a `reference` as the Room Path it resolves to. `compared(left,
|
|
366
291
|
right, ordering)` orders plain values: numbers and booleans, then text by locale or `byCodePoint`,
|
|
367
|
-
then lists item by item.
|
|
292
|
+
then lists item by item. `indexKey(facts, value)` is the key whose bytes order an indexed value so,
|
|
293
|
+
a date-time by its instant, text by code point, and a missing value with `null` first. `pageOrder(plan)` is the one order a page of
|
|
294
|
+
House's query walks, by Path or a field its types index, both by code point, and `walkOf(plan, model)` what drives that walk: an indexed
|
|
295
|
+
order as runs of keys, its continuation's, a missing value's and a range on that field, else the keys of the first top-level equality
|
|
296
|
+
or list on a field every named type indexes, else Path. Each refuses what no walk serves; `walkedValue` names a walked value as a continuation does. `countShape(plan)` says whether a plan asks a total or groups and refuses what no count serves, and `countOf(plan, model, where)` names a count's walk, in no order and from no continuation: those keys, else the range of the first top-level range on such a field, else Path, with every field it tests or groups by.
|
|
368
297
|
|
|
369
298
|
Two evaluators answer a plan's tests on one Document alike, a test on a missing value false and
|
|
370
299
|
its negation (`$ne`, `$nin`, `$exists: false`) true. `matches(plan, candidate)` answers in
|
|
@@ -372,14 +301,14 @@ memory over one `Candidate`: its `path`, `type`, `fileId`, `fields`, `definition
|
|
|
372
301
|
`text` held, and refuses a plan that orders by `size`, `created`, `updated` or `greatest`, or
|
|
373
302
|
selects a group's totals, which one Document cannot answer. The `sql` namespace compiles them to SQL over a collection: `indexed(path, fields,
|
|
374
303
|
definition)` derives a Document's values and field links, its date-times with their instants,
|
|
375
|
-
`sql.VALUE_TABLE` holds those values and `sql.insertedValues` writes
|
|
304
|
+
`sql.VALUE_TABLE` holds those values and `sql.insertedValues` writes those of many documents, and `sql.tests(alias,
|
|
376
305
|
plan)` tests a document row of `id`, `path`, `folder`, `type`, `file_id` and `content`, its
|
|
377
306
|
phrase through the function a connection registers as `sql.HOLDS_PHRASE` with `sql.holdsPhrase`.
|
|
378
307
|
`sql.scoped`, `sql.placed`, `sql.sorted`, `sql.beyond`, `sql.following` and `sql.sortValue`
|
|
379
308
|
render a scope, a pointer, an order and a window's continuation, a date-time ordering as its
|
|
380
309
|
instant between numbers and text; `sql.fragment`, `sql.joined`, `sql.all`, `sql.any`,
|
|
381
310
|
`sql.grouped`, `sql.listed` and `sql.exists` build statements, and `heldKind` is the index's value
|
|
382
|
-
kind. `fixtures/queries.json` holds both evaluators to one table.
|
|
311
|
+
kind. `fixtures/queries.json` holds both evaluators to one table, and `indexKey` to their order.
|
|
383
312
|
|
|
384
313
|
## Events
|
|
385
314
|
|
|
@@ -388,8 +317,7 @@ change: its `id`, its `path` with a leading `/`, its `type` or `null`, and a `Fa
|
|
|
388
317
|
for each field it writes that its MD Type declares, held as its kind in the one table
|
|
389
318
|
of kinds: `reference`, `enum`, `number`, `integer`, `boolean`, `date`, `date-time`, `time` or
|
|
390
319
|
`string`. A prose value, or one of no kind, is `prose`, a list or an object holds the facts of its members, and a value written
|
|
391
|
-
`null` is `null`. A
|
|
392
|
-
value that does not fit its kind, such as a string in a number field, a fraction in an integer
|
|
320
|
+
`null` is `null`. A value that does not fit its kind, such as a string in a number field, a fraction in an integer
|
|
393
321
|
field, a value outside its `enum` or a reference `resolve` maps to no `{ id, member? }`, is `unreadable`; a readable reference holds that
|
|
394
322
|
`id` and the `member` it binds, which `members(facts, path)` lists at a `/members/<pointer>`.
|
|
395
323
|
|
|
@@ -420,3 +348,9 @@ unknown extension `application/octet-stream`, and `fileExtension(type)` is the e
|
|
|
420
348
|
named by. `SCRIPT_MEDIA_TYPES` lists the types a script is declared under, `dataUrl(type, base64)`
|
|
421
349
|
and `dataUrlPattern(types)` write and match a base64 data URL, `formDataType(boundary)` is a
|
|
422
350
|
multipart form's type and `gitMediaType(service, part)` a Git transport's.
|
|
351
|
+
|
|
352
|
+
## Moments
|
|
353
|
+
|
|
354
|
+
`shownMoment(at, reader)` shows a `Date` to a person as a calendar does: its day and minute in the
|
|
355
|
+
`MomentReader`'s `language` and IANA time `zone`, naming no zone, or in UTC, named, where `zone` is
|
|
356
|
+
`null`. `shownDay(at, reader)` shows its day alone, in UTC where `zone` is `null`.
|
package/README.md
CHANGED
|
@@ -35,20 +35,20 @@ if (checked.verdict === 'accept') {
|
|
|
35
35
|
|
|
36
36
|
## API
|
|
37
37
|
|
|
38
|
-
| Export
|
|
39
|
-
|
|
|
40
|
-
| `verify`
|
|
41
|
-
| `validate`
|
|
42
|
-
| `parse`, `serialize`
|
|
43
|
-
| `apply`
|
|
44
|
-
| `links`, `target`, `retarget`
|
|
45
|
-
| `escapePointer`
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
49
|
-
| `
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
38
|
+
| Export | Purpose |
|
|
39
|
+
| ----------------------------------------------- | ------------------------------------------------------------------ |
|
|
40
|
+
| `verify` | Verify one schema text into a model of MD Types |
|
|
41
|
+
| `validate` | Validate a text Library; returns acceptance or one refusal |
|
|
42
|
+
| `parse`, `serialize` | Read and write one Document |
|
|
43
|
+
| `apply` | Apply field, section, preamble, link and reference changes at once |
|
|
44
|
+
| `links`, `target`, `retarget` | Inventory and rewrite link destinations |
|
|
45
|
+
| `escapePointer` | Write one key as a JSON Pointer token |
|
|
46
|
+
| `facts`, `candidateOf` | A Document as one change saw it, matched as one query candidate |
|
|
47
|
+
| `planOf`, `matches`, `sql` | Check a query, answer it over one Document or compile it to SQL |
|
|
48
|
+
| `VERSION` | The MD model version |
|
|
49
|
+
| `MEMBER_FIELD`, `SITE_FIELD`, `SUBMITTED_FIELD` | The frontmatter keys validation counts as declared beyond a type's |
|
|
50
|
+
| `MEDIA_TYPES`, `servedMediaType` | The media types House writes and the one table of file extensions |
|
|
51
|
+
| `shownMoment`, `shownDay` | A moment shown to a person in their language and time zone |
|
|
52
52
|
|
|
53
53
|
The full reference is in [`API.md`](API.md). The conformance corpus and its
|
|
54
54
|
verdict format and rule ids are described in [`fixtures/README.md`](fixtures/README.md).
|
package/dist/definition.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type ValueFacts = {
|
|
|
14
14
|
readonly prefix?: readonly ValueFacts[];
|
|
15
15
|
readonly items?: ValueFacts;
|
|
16
16
|
readonly properties?: Readonly<Record<string, ValueFacts>>;
|
|
17
|
+
readonly required?: readonly string[];
|
|
17
18
|
readonly patterns?: readonly PatternFacts[];
|
|
18
19
|
readonly additional?: ValueFacts;
|
|
19
20
|
};
|
|
@@ -39,11 +40,12 @@ export type FieldRules = {
|
|
|
39
40
|
export type Definition = {
|
|
40
41
|
readonly name: string;
|
|
41
42
|
readonly memberDocument: boolean;
|
|
42
|
-
readonly
|
|
43
|
+
readonly root: ValueFacts;
|
|
43
44
|
readonly fields: Readonly<Record<string, ValueFacts>>;
|
|
44
45
|
readonly rules: Readonly<Record<string, FieldRules>>;
|
|
45
46
|
readonly createRoles?: readonly string[];
|
|
46
47
|
readonly deleteRoles?: readonly string[];
|
|
48
|
+
readonly indexed?: readonly string[];
|
|
47
49
|
readonly shape: Shape;
|
|
48
50
|
};
|
|
49
51
|
export type Failure = {
|
|
@@ -58,6 +60,7 @@ export declare const JSON_TYPES: readonly JsonType[];
|
|
|
58
60
|
export declare const BUILT_IN_TYPE = "any";
|
|
59
61
|
export declare const ATTACHMENT = "attachment";
|
|
60
62
|
export declare const OPENING: readonly string[];
|
|
63
|
+
export declare const UNIONS: readonly string[];
|
|
61
64
|
export declare const ARRAY_INDEX: RegExp;
|
|
62
65
|
export declare const JSON_POINTER: RegExp;
|
|
63
66
|
export declare function refuse(rule: string, location: string): Failure;
|
|
@@ -75,6 +78,7 @@ export declare function conjoined(declared: readonly {
|
|
|
75
78
|
readonly ancestry: ReadonlySet<unknown>;
|
|
76
79
|
};
|
|
77
80
|
export declare function variantsOf({ node, at }: Placed): Placed[];
|
|
81
|
+
export declare function admitted(nodes: readonly unknown[], defs: Readonly<Record<string, unknown>>, ancestry: ReadonlySet<unknown>): Set<string> | null;
|
|
78
82
|
export declare function valueFacts(node: unknown, defs: Readonly<Record<string, unknown>>): ValueFacts;
|
|
79
83
|
export declare function itemFacts(facts: ValueFacts, index: number): ValueFacts | undefined;
|
|
80
84
|
export declare function memberFacts(facts: ValueFacts, key: string): ValueFacts | undefined;
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAEjG,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IAC5B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAA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,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAItF;AAqBD,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAc9F;AAmED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,CAY3D;AAmND,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,aAAwB,EAClC,OAAO,UAAO,GACb,aAAa,GAAG,OAAO,CA0CzB"}
|
package/dist/definition.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MEMBER_FIELD,
|
|
1
|
+
import { MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
|
|
2
2
|
import { MEDIA_TYPES } from './media-type.js';
|
|
3
3
|
import { linearPattern } from './pattern.js';
|
|
4
4
|
import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
|
|
@@ -30,14 +30,14 @@ const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
|
30
30
|
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
31
31
|
const DEFS_REFERENCE = '#/$defs/';
|
|
32
32
|
const UNBOUNDED_FORMAT = 'url';
|
|
33
|
-
const UNIONS = ['anyOf', 'oneOf'];
|
|
33
|
+
export const UNIONS = ['anyOf', 'oneOf'];
|
|
34
34
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
35
35
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
36
36
|
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
37
37
|
const HOUSE_KEYS = {
|
|
38
38
|
[TYPE_FIELD]: { prose: false },
|
|
39
39
|
[SITE_FIELD]: { prose: false },
|
|
40
|
-
[
|
|
40
|
+
[SUBMITTED_FIELD]: { prose: false },
|
|
41
41
|
};
|
|
42
42
|
export function refuse(rule, location) {
|
|
43
43
|
return { rule, location };
|
|
@@ -314,6 +314,7 @@ function joined(left, right) {
|
|
|
314
314
|
return shared === undefined ? [] : [{ pattern, facts: shared }];
|
|
315
315
|
});
|
|
316
316
|
const additional = both(left.additional, right.additional);
|
|
317
|
+
const required = (left.required ?? []).filter((name) => right.required?.includes(name) === true);
|
|
317
318
|
const title = left.title ?? right.title;
|
|
318
319
|
return {
|
|
319
320
|
...(type === undefined ? {} : { type }),
|
|
@@ -328,6 +329,7 @@ function joined(left, right) {
|
|
|
328
329
|
...(prefix === undefined ? {} : { prefix }),
|
|
329
330
|
...(items === undefined ? {} : { items }),
|
|
330
331
|
...(Object.keys(properties).length === 0 ? {} : { properties }),
|
|
332
|
+
...(required.length === 0 ? {} : { required }),
|
|
331
333
|
...(patterns.length === 0 ? {} : { patterns }),
|
|
332
334
|
...(additional === undefined ? {} : { additional }),
|
|
333
335
|
};
|
|
@@ -399,7 +401,7 @@ function narrowed(left, right) {
|
|
|
399
401
|
return left;
|
|
400
402
|
return new Set([...left].filter((one) => right.has(one)));
|
|
401
403
|
}
|
|
402
|
-
function admitted(nodes, defs, ancestry) {
|
|
404
|
+
export function admitted(nodes, defs, ancestry) {
|
|
403
405
|
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
404
406
|
let kept = null;
|
|
405
407
|
for (const { node } of conjunction.held) {
|
|
@@ -491,6 +493,9 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
491
493
|
: Array.from({ length: Math.max(...tuples.map((tuple) => tuple.length)) }, (_, index) => factsOf(tuples.flatMap((tuple) => (index < tuple.length ? [tuple[index]] : [])), defs, reached))));
|
|
492
494
|
const mapped = type === 'object' || type === undefined;
|
|
493
495
|
const properties = mapped ? propertiesOf(held, variants, defs, reached) : undefined;
|
|
496
|
+
const required = mapped
|
|
497
|
+
? [...new Set(held.flatMap((node) => (Array.isArray(node.required) ? node.required : [])))]
|
|
498
|
+
: [];
|
|
494
499
|
const patterns = mapped
|
|
495
500
|
? held.flatMap((node) => Object.entries(isRecord(node.patternProperties) ? node.patternProperties : {}).map(([pattern, schema]) => ({ pattern, facts: factsOf([schema], defs, reached) })))
|
|
496
501
|
: [];
|
|
@@ -513,6 +518,7 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
513
518
|
...(prefix === undefined ? {} : { prefix }),
|
|
514
519
|
...(items === undefined ? {} : { items }),
|
|
515
520
|
...(properties === undefined ? {} : { properties }),
|
|
521
|
+
...(required.length === 0 ? {} : { required }),
|
|
516
522
|
...(patterns.length === 0 ? {} : { patterns }),
|
|
517
523
|
...(additional === undefined ? {} : { additional }),
|
|
518
524
|
};
|
|
@@ -539,7 +545,7 @@ export function fieldFacts(definition, key) {
|
|
|
539
545
|
return definition.fields[key];
|
|
540
546
|
if (Object.hasOwn(HOUSE_KEYS, key))
|
|
541
547
|
return undefined;
|
|
542
|
-
return memberFacts(definition.
|
|
548
|
+
return memberFacts(definition.root, key);
|
|
543
549
|
}
|
|
544
550
|
function stepped({ facts, through, conditional }, token) {
|
|
545
551
|
if (facts.type === 'array' && ARRAY_INDEX.test(token)) {
|
|
@@ -644,7 +650,7 @@ function untitledFacts(facts) {
|
|
|
644
650
|
export function untitled(definition) {
|
|
645
651
|
return {
|
|
646
652
|
...definition,
|
|
647
|
-
|
|
653
|
+
root: untitledFacts(definition.root),
|
|
648
654
|
fields: Object.fromEntries(Object.entries(definition.fields).map(([key, held]) => [key, untitledFacts(held)])),
|
|
649
655
|
shape: {
|
|
650
656
|
schema: untitledSchema(definition.shape.schema),
|
|
@@ -784,13 +790,15 @@ function readType(name, value, context) {
|
|
|
784
790
|
const at = `/${escapePointer(name)}`;
|
|
785
791
|
if (!isRecord(value))
|
|
786
792
|
return refuse('schema', at);
|
|
787
|
-
const { member_document: mark, create_roles: createRoles, delete_roles: deleteRoles, ...ruled } = value;
|
|
793
|
+
const { member_document: mark, create_roles: createRoles, delete_roles: deleteRoles, indexed, ...ruled } = value;
|
|
788
794
|
if (mark !== undefined && typeof mark !== 'boolean')
|
|
789
795
|
return refuse('member_document', `${at}/member_document`);
|
|
790
796
|
if (createRoles !== undefined && !roleNames(createRoles))
|
|
791
797
|
return refuse('create_roles', `${at}/create_roles`);
|
|
792
798
|
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
793
799
|
return refuse('delete_roles', `${at}/delete_roles`);
|
|
800
|
+
if (indexed !== undefined && !strings(indexed))
|
|
801
|
+
return refuse('indexed', `${at}/indexed`);
|
|
794
802
|
const { schema, written } = unruled(ruled);
|
|
795
803
|
const failure = schemaFailure(schema, at, context);
|
|
796
804
|
if (failure !== undefined)
|
|
@@ -811,15 +819,16 @@ function readType(name, value, context) {
|
|
|
811
819
|
fields[MEMBER_FIELD] = { type: 'string', prose: false };
|
|
812
820
|
const defs = Object.create(null);
|
|
813
821
|
reachedDefs(value, context.defs, defs);
|
|
814
|
-
const { create_roles: _create, delete_roles: _delete, ...shaped } = value;
|
|
822
|
+
const { create_roles: _create, delete_roles: _delete, indexed: _indexed, ...shaped } = value;
|
|
815
823
|
return {
|
|
816
824
|
name,
|
|
817
825
|
memberDocument,
|
|
818
|
-
|
|
826
|
+
root: { ...root, properties: { ...HOUSE_KEYS, ...fields } },
|
|
819
827
|
fields,
|
|
820
828
|
rules,
|
|
821
829
|
...(createRoles === undefined ? {} : { createRoles }),
|
|
822
830
|
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
831
|
+
...(indexed === undefined ? {} : { indexed }),
|
|
823
832
|
shape: {
|
|
824
833
|
schema: written.size === 0 ? shaped : { ...shaped, properties: schema.properties },
|
|
825
834
|
defs,
|
package/dist/document.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type Body, type Naming } from './body.js';
|
|
2
2
|
import { type Definition } from './definition.js';
|
|
3
3
|
import { type HrefOccurrence, type Reading } from './markdown.js';
|
|
4
|
-
import type { ApplyResult, BodyResult,
|
|
4
|
+
import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
|
|
5
5
|
export declare function readingOf(document: Document): Reading;
|
|
6
6
|
export declare function bodyOf(document: Document): Body | null;
|
|
7
7
|
export declare function linkDestinations(document: Document): readonly HrefOccurrence[];
|
|
8
8
|
export declare function textSpans(document: Document): readonly Span[];
|
|
9
|
-
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
10
9
|
export declare function parse(content: string, file?: string, definition?: Definition | DefinitionOf): ParseResult;
|
|
11
10
|
export declare function create(type: string | undefined, definition?: Definition): Document;
|
|
12
11
|
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
|
|
@@ -16,6 +15,7 @@ export declare function unlinkBody(body: string, hrefs: ReadonlySet<string>): Un
|
|
|
16
15
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
17
16
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
18
17
|
export declare function bodyWith(document: Document, definition: Definition | undefined): Body | null | Refusal;
|
|
18
|
+
export declare function partText(part: string): string;
|
|
19
19
|
export declare function apply(document: Document, changes: readonly Change[], definition?: Definition, nameOf?: Naming): ApplyResult;
|
|
20
20
|
export declare function relabel(document: Document, before: Definition, after: Definition): string;
|
|
21
21
|
export declare function relabels(before: Definition, after: Definition): boolean;
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,IAAI,EACT,KAAK,MAAM,EAGZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts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