@agentshouse/mdmodel 0.1.0-c896b3d9398b1 → 0.1.0-cbce4f1da228f
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 +137 -133
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +33 -26
- package/dist/condition.d.ts +1 -1
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +16 -13
- package/dist/definition.d.ts +14 -0
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +217 -25
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +18 -8
- package/dist/document.d.ts +4 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +105 -68
- package/dist/fields.d.ts +2 -0
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +7 -0
- package/dist/index.d.ts +10 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/links.d.ts +2 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +23 -12
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +92 -12
- package/dist/project.d.ts +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +32 -9
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/schema.js +2 -2
- package/dist/types.d.ts +25 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +6 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +163 -111
- package/dist/yaml.d.ts +7 -3
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +72 -43
- package/fixtures/README.md +1 -1
- package/package.json +4 -2
package/API.md
CHANGED
|
@@ -41,15 +41,17 @@ if (parsed.ok) {
|
|
|
41
41
|
`MARKDOWN_SYNTAX_PROFILE` is the Markdown every reader here applies, GitHub Flavored Markdown
|
|
42
42
|
0.29, and `VERSION` is the MD model version.
|
|
43
43
|
|
|
44
|
-
`verify(schema)` reads one schema text, the MD Types of one Room or App: one
|
|
45
|
-
|
|
46
|
-
`$defs`
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
`
|
|
44
|
+
`verify(schema)` reads one schema text, the MD Types of one Room or App: one JSON Schema document
|
|
45
|
+
(draft 2020-12) in the YAML subset. Every top-level key but `$defs` names an MD Type holding the
|
|
46
|
+
JSON Schema of its frontmatter; `$defs` holds shapes the types reuse, reached by a `$ref` under
|
|
47
|
+
`#/$defs/` alone. `type` and the built-in `any` are never declared. The model adds its keywords:
|
|
48
|
+
`reference` on a string names one MD Type, several, `any` or `attachment`; `sections` declares a
|
|
49
|
+
type's H2 sections, each `{ kind: text }` or `{ kind: list, items }` over one string, number,
|
|
50
|
+
integer or boolean, optionally `required: true`; `member_document: true` marks at most one type. A
|
|
51
|
+
type alone takes `create_roles` and `delete_roles`, each a list of role names. On a field of a
|
|
52
|
+
type's own `properties` alone, `change_roles` and `initial_roles` each list role names, and
|
|
53
|
+
`transitions` lists `{ from, to, roles? }`, each end a scalar or `null`, on a field whose `type`,
|
|
54
|
+
`enum`, `const`, `$ref`, `allOf`, `anyOf`, `oneOf`, `if` and `not` admit no list or object.
|
|
53
55
|
|
|
54
56
|
```yaml
|
|
55
57
|
$defs:
|
|
@@ -64,64 +66,65 @@ plan:
|
|
|
64
66
|
contact: { member_document: true }
|
|
65
67
|
```
|
|
66
68
|
|
|
67
|
-
The model's `types` expose each MD Type's `name`, `memberDocument`, `sections`,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`pattern` or `reference`. Facts join `$ref` and `allOf`
|
|
73
|
-
the variants of `anyOf`, `oneOf`, `then`, `else` and `dependentSchemas`, a
|
|
74
|
-
variant's own keys `conditional`; a path without one `type`, `null` aside, has
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`
|
|
79
|
-
`
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
69
|
+
The model's `types` expose each MD Type's `name`, `memberDocument`, `sections`, `shape` (the type as
|
|
70
|
+
written, its rule keywords left out, with every `$defs` shape it reaches), `createRoles` and
|
|
71
|
+
`deleteRoles` when written, its `rules` by field as `changeRoles`, `initialRoles` and `transitions`,
|
|
72
|
+
the facts of its `frontmatter` and `fields`, its top-level ones: JSON `type`, `format`, `values`,
|
|
73
|
+
`reference` targets, `items`, `properties`, an open map's `patterns` and `additional`, and `prose`,
|
|
74
|
+
a string with no `enum`, `const`, `format`, `pattern` or `reference`. Facts join `$ref` and `allOf`
|
|
75
|
+
to their siblings and the variants of `anyOf`, `oneOf`, `then`, `else` and `dependentSchemas`, a
|
|
76
|
+
variant's own keys `conditional`; a path without one `type`, `null` aside, has none. A malformed
|
|
77
|
+
schema is refused whole, naming its `rule`, the keyword or the model's own, and the JSON Pointer
|
|
78
|
+
`location` it concerns, such as `/plan/properties/status/enum`, or `line <n>` outside the YAML
|
|
79
|
+
subset. `pointerFacts(definition, pointer)` reads the facts a frontmatter pointer reaches,
|
|
80
|
+
`itemFacts` and `memberFacts` take one step and `crossedFacts` reads a list's item facts;
|
|
81
|
+
`pointerSegments` and `escapePointer` split and write a pointer, `ARRAY_INDEX` matches an index
|
|
82
|
+
segment, and `ATTACHMENT` is the `reference` that admits any path.
|
|
83
|
+
|
|
84
|
+
`validate(library, context?, model?)` takes the resulting text Library and one `ValidationContext`
|
|
85
|
+
of `binaryTargets: readonly string[]`, none when omitted. Library keys and binary targets share one
|
|
86
|
+
canonical collection-relative path namespace; a path declared text and binary is refused. House
|
|
87
|
+
declares every binary file of the Room as a binary target, and the model reads no bytes. Ordinary
|
|
88
|
+
links and images in typed Documents may resolve to either membership, relative to the source
|
|
89
|
+
Document, and one to a path neither holds is not refused: it dangles, as a deleted file's links do.
|
|
90
|
+
A destination that is an absolute path or leaves the collection is `unresolved-link`. A binary
|
|
91
|
+
target supplies no Document or MD Type. `model` is the verified schema that types the Library, and
|
|
92
|
+
every Library member is content, whatever its Path. Without `model` the Library declares no type.
|
|
93
|
+
|
|
94
|
+
A typed Document's frontmatter satisfies its type's schema, every keyword with its JSON Schema
|
|
95
|
+
meaning, formats asserted and defaults never filled, except that an object schema declaring neither
|
|
96
|
+
`additionalProperties` nor `unevaluatedProperties` is closed: an undeclared key is refused as
|
|
97
|
+
`undeclared- field`. `TYPE_FIELD`, `SITE_FIELD` and `RECEIVED_FIELD` count as declared on every
|
|
98
|
+
type, and the string `MEMBER_FIELD` on the `member_document` type; `HOUSE_FIELDS` lists the four. A
|
|
99
|
+
refusal names the keyword, such as `required`, and the value's JSON Pointer, such as
|
|
100
|
+
`/shipping/city`. Every occurrence of a declared list section is a list of values of its item
|
|
101
|
+
schema, else `structured-section`; a reference item is one ordinary link alone, such as
|
|
102
|
+
`- [Ada](ada.md)`. A reference, at any depth or a section item, reaching a URL, a binary target, or a
|
|
103
|
+
Document of a type it does not name is `unresolved-reference`, and a frontmatter one reaching no
|
|
104
|
+
member is `referenced-missing-file` naming its `referrers`; `attachment` admits any path, and no
|
|
105
|
+
body link is a referrer. `validating` yields each path `validate` reads, then returns its verdict.
|
|
106
|
+
|
|
107
|
+
Validation returns acceptance or one refusal naming the file, the field or section, and the violated
|
|
108
|
+
rule. `parse`, `apply`, and `serialize` operate on a single text Document; they do not validate
|
|
109
|
+
collection membership or consume binary bytes. `apply` sets one typed field, including a list or an
|
|
110
|
+
object as a whole, replaces one existing section body or the preamble against that value's prior
|
|
111
|
+
content, or rewrites one Markdown link destination. A section need not be declared by the Document's
|
|
112
|
+
MD Type to be replaced. A section or preamble replacement that would hide a section the Document
|
|
113
|
+
carried behind a repeated, merged or fenced heading is refused as `overlapping-section` naming that
|
|
114
|
+
section. A field change does not reformat the rest of the file: an inline value is replaced where it
|
|
115
|
+
stands, and a value written after the key's line, an empty one or a block mapping or list, is
|
|
116
|
+
written after the key's colon in its place. A field holds a `FrontmatterValue`: null, a string, a
|
|
117
|
+
boolean, a finite number, a list without holes or a plain object of them, holding no cycle.
|
|
118
|
+
`frontmatterValue(value)` is that test, and `apply` refuses any other value as `frontmatter-fence`;
|
|
119
|
+
`equalValue(left, right)` compares two by value, whatever their key order, as `apply` compares a
|
|
120
|
+
field with its prior.
|
|
121
|
+
|
|
122
|
+
`Document.preamble` is a readonly string holding the exact source after frontmatter and before the
|
|
123
|
+
first section heading the section parser recognizes, `''` when empty, whitespace, newlines, a
|
|
124
|
+
leading H1 and any fenced text before the first section included. The closing frontmatter
|
|
125
|
+
delimiter and its line ending belong to frontmatter: `bodyAfterFrontmatter(content)` is the exact
|
|
126
|
+
source after them, the whole text when it opens no closed fence, and the preamble begins it.
|
|
127
|
+
`headingLines(content, from, to)` reads each ATX heading outside a fence, by `level` and `name`.
|
|
125
128
|
|
|
126
129
|
```ts
|
|
127
130
|
const parsed = parse(content);
|
|
@@ -136,15 +139,14 @@ if (parsed.ok) {
|
|
|
136
139
|
}
|
|
137
140
|
```
|
|
138
141
|
|
|
139
|
-
`apply(document, { kind: 'preamble', prior, value })` compares `prior` to the
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
and
|
|
144
|
-
and
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
field, section, and preamble edits keep their own prior values valid.
|
|
142
|
+
`apply(document, { kind: 'preamble', prior, value })` compares `prior` to the current preamble
|
|
143
|
+
exactly. A mismatch returns `{ outcome: 'stale', document }` with the unchanged current Document. A
|
|
144
|
+
match replaces only that source span, then parses a new immutable Document; the original is
|
|
145
|
+
unchanged. Frontmatter and section source outside the span retain their exact bytes, including
|
|
146
|
+
newline and heading syntax. As with section replacement, `value` is literal source: no newline or
|
|
147
|
+
separator is inserted, and the resulting source is parsed again. An invalid frontmatter result
|
|
148
|
+
receives the existing parse refusal. Independent field, section, and preamble edits keep their own
|
|
149
|
+
prior values valid.
|
|
148
150
|
|
|
149
151
|
For a moved link, use `links` and the `link` change below to obtain the rewritten Document, then
|
|
150
152
|
compare its public `preamble` and `sections` to the original. Submit the changed values with their
|
|
@@ -156,18 +158,27 @@ that resolve to a collection Path, each with the destination `href` exactly as w
|
|
|
156
158
|
`target` Path it resolves to relative to `file`. A `?query` or `#fragment` the destination carries
|
|
157
159
|
is part of `href` and not part of `target`. Entries are ordered by the position of the destination
|
|
158
160
|
text a rewrite would change, and one destination written the same way appears once however many
|
|
159
|
-
times it occurs. A destination that the syntax profile does not read as a link, one that is empty,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
`target(file, href)` is the collection Path one written destination resolves to relative to
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
161
|
+
times it occurs. A destination that the syntax profile does not read as a link, one that is empty, a
|
|
162
|
+
bare fragment, or carries a URL scheme, and one that leaves the collection are not in the inventory.
|
|
163
|
+
Frontmatter values are never link destinations. `linkOccurrences(document, file)` places each
|
|
164
|
+
occurrence by its `start` in `content`, and `fieldStart(document, pointer)` a frontmatter value.
|
|
165
|
+
|
|
166
|
+
`target(file, href)` is the collection Path one written destination resolves to relative to `file`,
|
|
167
|
+
by the rule `links` and `validate` read: surrounding spaces and the `?query` or `#fragment` it
|
|
168
|
+
carries are not part of that Path. It reads backslash escapes and character references, strips as a
|
|
169
|
+
URL does, then percent-encodings, so `plan\.md`, `plan.md` and `pl%61n.md` all name `plan.md`;
|
|
170
|
+
an escaped or referenced `?` or `#` starts the suffix. A destination that is empty, a bare fragment,
|
|
171
|
+
carries a URL scheme, starts at `/` once read, encodes no UTF-8 text, or leaves the collection
|
|
172
|
+
resolves to `null`. It reads a destination written anywhere, such as a typed reference field value,
|
|
173
|
+
which `links` never enumerates. `retarget(href, to)` is that destination rewritten to `to`, keeping
|
|
174
|
+
the `?query` or `#fragment` it carried, which is the destination the `link` change below writes. It
|
|
175
|
+
percent-encodes in `to` what `target` would decode, so it resolves to `to` again.
|
|
176
|
+
|
|
177
|
+
`checkDocument(file, content, model)` reads one Document alone by the same rules: `ok: false` where
|
|
178
|
+
`validate` refuses it, else its `type`, whether it is `typed`, and each reference's `target` and
|
|
179
|
+
`to`, which `resolves(reference, typeOf, binary)` says reaches a member `validate` accepts.
|
|
180
|
+
`sectionReferences(file, content, definition)` reads only the references of its `list` sections.
|
|
181
|
+
`parseFrontmatter(content, file?)` is `parse` without the body: `content`, `type` and `fields`.
|
|
171
182
|
|
|
172
183
|
`references(document, definition)` lists each frontmatter `reference` string at any depth as
|
|
173
184
|
`pointer`, `value` and `to`; `apply(document, { kind: 'reference', pointer, value, prior })`
|
|
@@ -194,18 +205,16 @@ profile reads back: bare when it carries no whitespace, does not open with `<`,
|
|
|
194
205
|
parentheses, otherwise inside angle brackets, which the original form is kept in when it still
|
|
195
206
|
fits. A destination that neither form can carry is refused as `unwritable-link`.
|
|
196
207
|
|
|
197
|
-
`project(document, file, context?)` is the Embedding projection input of one
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
contributes its
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
them, exactly as written. The Path and every other value stay outside, so
|
|
208
|
-
changing them alone leaves the projection unchanged.
|
|
208
|
+
`project(document, file, context?)` is the Embedding projection input of one Document: the prose a
|
|
209
|
+
consumer embeds, with every internal Markdown-document link reduced to the label a reader sees. A
|
|
210
|
+
Document that declares no MD type contributes its body after the frontmatter fence. A typed one
|
|
211
|
+
contributes its prose values, its preamble, and every H2 section its MD type does not declare as
|
|
212
|
+
structure, each with its own heading line and every occurrence of a repeated name, in Document
|
|
213
|
+
order: a declared text section, a list section of prose items and an undeclared section are in; a
|
|
214
|
+
list section of any other item schema is not. A prose value is a frontmatter string at any depth
|
|
215
|
+
whose schema is prose, projected bare and followed by a blank line, in the order the Document writes
|
|
216
|
+
them, exactly as written. The Path and every other value stay outside, so changing them alone leaves
|
|
217
|
+
the projection unchanged.
|
|
209
218
|
|
|
210
219
|
```ts
|
|
211
220
|
const parsed = parse(content);
|
|
@@ -218,16 +227,14 @@ if (parsed.ok) {
|
|
|
218
227
|
}
|
|
219
228
|
```
|
|
220
229
|
|
|
221
|
-
`ProjectionContext` carries `documentTargets`, the collection-relative Paths the
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
the model reads no bytes, resolves no authority, and classifies nothing it was
|
|
230
|
-
not given.
|
|
230
|
+
`ProjectionContext` carries `documentTargets`, the collection-relative Paths the caller holds as
|
|
231
|
+
Markdown documents, and `definition`, the verified MD Type the Document's `type` names, taken from
|
|
232
|
+
the model `verify` returned. A Document that declares a type the caller supplies no definition for
|
|
233
|
+
is refused as `unknown-type`. `documentTargets` is what makes a destination internal: a destination
|
|
234
|
+
resolving to a supplied Path is internal, and every other destination stays authored text, a binary
|
|
235
|
+
target and a Path nobody supplied alike. The caller supplies that membership, as it does for
|
|
236
|
+
`validate`; the model reads no bytes, resolves no authority, and classifies nothing it was not
|
|
237
|
+
given.
|
|
231
238
|
|
|
232
239
|
An internal link contributes its visible label and no destination, fragment, or
|
|
233
240
|
title, in the inline `[label](path)`, full `[label][id]`, collapsed
|
|
@@ -242,11 +249,10 @@ and `validate` read. `project` returns text and never rewrites the Document.
|
|
|
242
249
|
A `link` change leaves the projection of every Document it rewrites
|
|
243
250
|
byte-identical, while a changed visible label changes it.
|
|
244
251
|
|
|
245
|
-
`divide(document, file, context)` divides that same Embedding projection input
|
|
246
|
-
|
|
247
|
-
`
|
|
248
|
-
|
|
249
|
-
positions, so a caller stores the extent and hydrates the text it shows from
|
|
252
|
+
`divide(document, file, context)` divides that same Embedding projection input into ordered Spans
|
|
253
|
+
under the budget the caller supplies. Each Span carries the `text` to embed and the `start` and
|
|
254
|
+
`end` of the extent it addresses in the Document's own source, as UTF-8 byte offsets into that
|
|
255
|
+
source and never string positions, so a caller stores the extent and hydrates the text it shows from
|
|
250
256
|
the Document itself.
|
|
251
257
|
|
|
252
258
|
```ts
|
|
@@ -275,23 +281,19 @@ caller's number alone: the model holds no tokenizer, counts nothing else, and
|
|
|
275
281
|
refuses no input for being too long. A Document the caller supplies no
|
|
276
282
|
definition for carries the same `unknown-type` refusal `project` returns.
|
|
277
283
|
|
|
278
|
-
The division descends one level at a time, and only into the piece that does not
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
inside a single
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
heading
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
sentence level alone, where each Span after the first repeats its predecessor's
|
|
292
|
-
last sentence whenever the budget holds both; when it cannot hold both, the
|
|
293
|
-
Span carries its own sentence alone. An untyped input arrives without a
|
|
294
|
-
definition and descends the same ladder.
|
|
284
|
+
The division descends one level at a time, and only into the piece that does not fit: the whole
|
|
285
|
+
input, a heading node, adjacent sibling nodes packed under one parent, adjacent blocks inside a
|
|
286
|
+
node, sentences inside a block, and a bound cut inside a single sentence. A Span covers whole
|
|
287
|
+
heading nodes or one contiguous piece inside a single node, never a partial node beside another. A
|
|
288
|
+
Span that continues a node repeats that node's own heading line, projected like any other text and
|
|
289
|
+
so carrying an internal link's label rather than its destination, and never an ancestor's heading,
|
|
290
|
+
so renaming a heading costs what editing that heading's own body costs. A heading the budget cannot
|
|
291
|
+
hold beside any text is not repeated, a continuation piece that begins with an astral character the
|
|
292
|
+
room beside its heading cannot hold is carried without the heading, and a heading with no body of
|
|
293
|
+
its own leads its first child node rather than standing as a Span of nothing but itself. Overlap
|
|
294
|
+
exists at the sentence level alone, where each Span after the first repeats its predecessor's last
|
|
295
|
+
sentence whenever the budget holds both; when it cannot hold both, the Span carries its own sentence
|
|
296
|
+
alone. An untyped input arrives without a definition and descends the same ladder.
|
|
295
297
|
|
|
296
298
|
Division is total: every authored character of the input belongs to at least one
|
|
297
299
|
Span, and an input carrying no authored text divides into no Span at all. A
|
|
@@ -348,8 +350,10 @@ names it. A field absent on both sides never fires; `from: 'new'` admits only a
|
|
|
348
350
|
`to: 'deleted'` only a deletion, and listed values need that side to hold `field` `in` them.
|
|
349
351
|
|
|
350
352
|
`itemFires(condition, item, owner)` compares `source` and `address` where given and holds `match`
|
|
351
|
-
over `/delivery`, `/source`, `/
|
|
353
|
+
over `/delivery`, `/source`, `/container`, `/author`, `/has_attachment`,
|
|
352
354
|
`/headers/<name>` and `/json/<pointer>`, unknown for an item with no JSON. `prosePaths(facts)` lists
|
|
353
355
|
the prose and section paths whose text builds `changed`; `pointed(value, pointer)` reads a JSON
|
|
354
356
|
Pointer, `undefined` where nothing is; `dated(value)` checks a `YYYY-MM-DD` date, and
|
|
355
357
|
`instant(value)` reads an RFC 3339 time with its offset as epoch nanoseconds, a `bigint`.
|
|
358
|
+
`datePointers(fields)` lists, sorted, the `/fields/<name>` pointers of a type's date fields, the
|
|
359
|
+
only values a `DateCondition`'s `date` takes.
|
package/dist/blocks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../src/blocks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AA+BF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,EAAE,CA8BrF;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,CAe/E"}
|
package/dist/blocks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fenceSpans } from './links.js';
|
|
2
|
-
const HEADING = /^(#{1,6})(?!#)[ \t]+(.+?)[ \t]
|
|
1
|
+
import { fenceSpans, spanCursor } from './links.js';
|
|
2
|
+
const HEADING = /^(#{1,6})(?!#)[ \t]+(.+?)(?:[ \t]+#+)?[ \t]*$/;
|
|
3
3
|
function lineAt(content, from, to) {
|
|
4
4
|
const nl = content.indexOf('\n', from);
|
|
5
5
|
const end = nl === -1 || nl >= to ? to : nl;
|
|
@@ -7,40 +7,47 @@ function lineAt(content, from, to) {
|
|
|
7
7
|
return { text: raw.endsWith('\r') ? raw.slice(0, -1) : raw, next: end === to ? to : end + 1 };
|
|
8
8
|
}
|
|
9
9
|
function scan(content, from, to, visit) {
|
|
10
|
-
const
|
|
10
|
+
const fenced = spanCursor(fenceSpans(content.slice(from, to)));
|
|
11
11
|
let i = from;
|
|
12
12
|
while (i < to) {
|
|
13
13
|
const { text, next } = lineAt(content, i, to);
|
|
14
|
-
|
|
15
|
-
visit({
|
|
16
|
-
text,
|
|
17
|
-
start: i,
|
|
18
|
-
next,
|
|
19
|
-
fenced: fences.some(([start, end]) => at >= start && at < end),
|
|
20
|
-
});
|
|
14
|
+
visit({ text, start: i, next, fenced: fenced(i - from) !== undefined });
|
|
21
15
|
if (next === i)
|
|
22
16
|
break;
|
|
23
17
|
i = next;
|
|
24
18
|
}
|
|
25
19
|
}
|
|
20
|
+
const HASH = 0x23;
|
|
26
21
|
export function headingLines(content, from, to) {
|
|
27
22
|
const found = [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
23
|
+
let fenced = null;
|
|
24
|
+
let i = from;
|
|
25
|
+
while (i < to) {
|
|
26
|
+
const nl = content.indexOf('\n', i);
|
|
27
|
+
const end = nl === -1 || nl >= to ? to : nl;
|
|
28
|
+
const next = end === to ? to : end + 1;
|
|
29
|
+
if (content.charCodeAt(i) === HASH) {
|
|
30
|
+
fenced ??= spanCursor(fenceSpans(content.slice(from, to)));
|
|
31
|
+
if (fenced(i - from) === undefined) {
|
|
32
|
+
const { text } = lineAt(content, i, to);
|
|
33
|
+
const match = HEADING.exec(text);
|
|
34
|
+
const hashes = match?.[1];
|
|
35
|
+
const name = match?.[2];
|
|
36
|
+
if (hashes !== undefined && name !== undefined) {
|
|
37
|
+
found.push({
|
|
38
|
+
level: hashes.length,
|
|
39
|
+
name: name.trim(),
|
|
40
|
+
start: i,
|
|
41
|
+
textEnd: i + text.length,
|
|
42
|
+
next,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (next === i)
|
|
48
|
+
break;
|
|
49
|
+
i = next;
|
|
50
|
+
}
|
|
44
51
|
return found;
|
|
45
52
|
}
|
|
46
53
|
export function blockRanges(content, from, to) {
|
package/dist/condition.d.ts
CHANGED
|
@@ -120,7 +120,6 @@ export type ItemFacts = {
|
|
|
120
120
|
readonly source: string | null;
|
|
121
121
|
readonly address: string | null;
|
|
122
122
|
readonly has_attachment: boolean;
|
|
123
|
-
readonly provider: string | null;
|
|
124
123
|
readonly container: string | null;
|
|
125
124
|
readonly author: string | null;
|
|
126
125
|
readonly headers: Readonly<Record<string, string>>;
|
|
@@ -139,6 +138,7 @@ export declare function facts(document: Document, at: {
|
|
|
139
138
|
readonly path: string;
|
|
140
139
|
}, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
|
|
141
140
|
export declare function prosePaths(facts: DocumentFacts): string[];
|
|
141
|
+
export declare function datePointers(fields: Readonly<Record<string, ValueFacts>>): string[];
|
|
142
142
|
export declare function dated(value: unknown): value is string;
|
|
143
143
|
export declare function instant(value: unknown): bigint | undefined;
|
|
144
144
|
export declare function pointed(value: unknown, pointer: string): unknown;
|
package/dist/condition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../src/condition.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;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wBAAgB,KAAK,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAehG;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAO3F"}
|
package/dist/condition.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerSegments, } from './definition.js';
|
|
2
2
|
import { target } from './paths.js';
|
|
3
|
-
import { isRecord } from './yaml.js';
|
|
3
|
+
import { isRecord, plain } from './yaml.js';
|
|
4
4
|
export const WRITE_DOORS = ['browser', 'agent', 'client'];
|
|
5
5
|
const PROSE = { kind: 'prose' };
|
|
6
6
|
const NULL = { kind: 'null' };
|
|
@@ -205,11 +205,11 @@ function readActor(actor, path) {
|
|
|
205
205
|
: undefined;
|
|
206
206
|
return value === undefined ? undefined : single({ kind: 'actor', value });
|
|
207
207
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
export function datePointers(fields) {
|
|
209
|
+
return Object.entries(fields)
|
|
210
|
+
.filter(([, facts]) => facts.type === 'string' && facts.format === 'date')
|
|
211
|
+
.map(([name]) => `/fields/${name}`)
|
|
212
|
+
.sort();
|
|
213
213
|
}
|
|
214
214
|
export function dated(value) {
|
|
215
215
|
return (typeof value === 'string' && DATE.test(value) && instant(`${value}T00:00:00Z`) !== undefined);
|
|
@@ -300,13 +300,11 @@ function readItem(item, path) {
|
|
|
300
300
|
? item.delivery
|
|
301
301
|
: path === '/source'
|
|
302
302
|
? item.source
|
|
303
|
-
: path === '/
|
|
304
|
-
? item.
|
|
305
|
-
: path === '/
|
|
306
|
-
? item.
|
|
307
|
-
:
|
|
308
|
-
? item.author
|
|
309
|
-
: null;
|
|
303
|
+
: path === '/container'
|
|
304
|
+
? item.container
|
|
305
|
+
: path === '/author'
|
|
306
|
+
? item.author
|
|
307
|
+
: null;
|
|
310
308
|
return value === null ? undefined : single({ kind: 'string', value });
|
|
311
309
|
}
|
|
312
310
|
function wanted(value, owner) {
|
|
@@ -444,6 +442,11 @@ function valueOf(fact) {
|
|
|
444
442
|
.sort()
|
|
445
443
|
.map((key) => [key, valueOf(fact.fields[key])]),
|
|
446
444
|
};
|
|
445
|
+
if (fact.kind === 'time') {
|
|
446
|
+
const at = instant(fact.value);
|
|
447
|
+
if (at !== undefined)
|
|
448
|
+
return { kind: fact.kind, at: String(at) };
|
|
449
|
+
}
|
|
447
450
|
return 'value' in fact ? { kind: fact.kind, value: fact.value } : fact;
|
|
448
451
|
}
|
|
449
452
|
function signature(reached) {
|
package/dist/definition.d.ts
CHANGED
|
@@ -29,12 +29,26 @@ export type Shape = {
|
|
|
29
29
|
readonly schema: Readonly<Record<string, unknown>>;
|
|
30
30
|
readonly defs: Readonly<Record<string, unknown>>;
|
|
31
31
|
};
|
|
32
|
+
export type RuleValue = string | number | boolean | null;
|
|
33
|
+
export type Transition = {
|
|
34
|
+
readonly from: RuleValue;
|
|
35
|
+
readonly to: RuleValue;
|
|
36
|
+
readonly roles?: readonly string[];
|
|
37
|
+
};
|
|
38
|
+
export type FieldRules = {
|
|
39
|
+
readonly changeRoles?: readonly string[];
|
|
40
|
+
readonly initialRoles?: readonly string[];
|
|
41
|
+
readonly transitions?: readonly Transition[];
|
|
42
|
+
};
|
|
32
43
|
export type Definition = {
|
|
33
44
|
readonly name: string;
|
|
34
45
|
readonly memberDocument: boolean;
|
|
35
46
|
readonly frontmatter: ValueFacts;
|
|
36
47
|
readonly fields: Readonly<Record<string, ValueFacts>>;
|
|
37
48
|
readonly sections: Readonly<Record<string, SectionSpec>>;
|
|
49
|
+
readonly rules: Readonly<Record<string, FieldRules>>;
|
|
50
|
+
readonly createRoles?: readonly string[];
|
|
51
|
+
readonly deleteRoles?: readonly string[];
|
|
38
52
|
read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