@agentshouse/mdmodel 0.1.0-caefdbe3e3d42 → 0.1.0-caf6545f57b5d
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 +160 -158
- package/README.md +14 -15
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/definition.d.ts +20 -10
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +174 -123
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +5 -4
- package/dist/document.d.ts +14 -7
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +720 -110
- package/dist/event.d.ts +77 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +200 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +41 -0
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +1 -1
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +152 -0
- package/dist/index.d.ts +21 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -11
- package/dist/kinds.d.ts +2 -2
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +20 -11
- package/dist/markdown.d.ts +75 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +265 -0
- package/dist/paths.d.ts +10 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +74 -19
- package/dist/pattern.d.ts.map +1 -1
- package/dist/pattern.js +4 -3
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +33 -60
- package/dist/query/language.d.ts +43 -7
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +151 -57
- package/dist/query/match.d.ts +3 -1
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +40 -8
- package/dist/query/rows.d.ts +1 -1
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +7 -1
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +2 -1
- package/dist/schema.d.ts +0 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +5 -68
- package/dist/types.d.ts +14 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +8 -5
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +141 -179
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +4 -11
- package/fixtures/README.md +40 -23
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
- package/fixtures/cases/absent-optional-field/schema.yaml +10 -11
- package/fixtures/cases/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.yaml +2 -3
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/boolean-field/expected.json +2 -1
- package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
- package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/boolean-field/schema.yaml +10 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
- package/fixtures/cases/closed-nested-object/expected.json +2 -1
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
- package/fixtures/cases/closed-nested-object/schema.yaml +10 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/expected.json +3 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +1 -1
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
- package/fixtures/cases/cross-room-reference/schema.yaml +1 -2
- package/fixtures/cases/date-time-format/expected.json +2 -1
- package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
- package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/date-time-format/schema.yaml +10 -11
- package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
- package/fixtures/cases/default-unfilled/schema.yaml +10 -11
- package/fixtures/cases/defs-pattern/expected.json +2 -1
- package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
- package/fixtures/cases/defs-pattern/schema.yaml +10 -11
- package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
- package/fixtures/cases/dependent-rule/schema.yaml +10 -11
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
- package/fixtures/cases/email-format/expected.json +2 -1
- package/fixtures/cases/email-format/library/companies/acme.md +1 -1
- package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/email-format/schema.yaml +10 -11
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.yaml +4 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.yaml +2 -3
- package/fixtures/cases/field-enum/expected.json +2 -1
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.yaml +3 -4
- package/fixtures/cases/integer-field/expected.json +2 -1
- package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
- package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/integer-field/schema.yaml +10 -11
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
- package/fixtures/cases/json-schema-constructs/schema.yaml +10 -11
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
- package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
- package/fixtures/cases/lazy-list-item/expected.json +3 -0
- package/fixtures/cases/lazy-list-item/library/item.md +10 -0
- package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.yaml +3 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.yaml +3 -0
- package/fixtures/cases/list-items/expected.json +1 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.yaml +10 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
- package/fixtures/cases/list-of-objects-closed/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-item/expected.json +2 -1
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
- package/fixtures/cases/list-of-objects-item/schema.yaml +10 -11
- package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.yaml +3 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.yaml +3 -0
- package/fixtures/cases/list-size/expected.json +2 -1
- package/fixtures/cases/list-size/library/companies/acme.md +1 -1
- package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
- package/fixtures/cases/list-size/schema.yaml +10 -11
- package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
- package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
- package/fixtures/cases/malformed-list/context.json +1 -0
- package/fixtures/cases/malformed-list/expected.json +7 -0
- package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
- package/fixtures/cases/malformed-list/schema.yaml +6 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- package/fixtures/cases/member-on-another-type/library/note.md +1 -1
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +3 -4
- package/fixtures/cases/misspelled-key/expected.json +2 -1
- package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
- package/fixtures/cases/misspelled-key/schema.yaml +10 -11
- package/fixtures/cases/name-not-a-string/context.json +1 -0
- package/fixtures/cases/name-not-a-string/expected.json +5 -0
- package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
- package/fixtures/cases/nested-defs/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- package/fixtures/cases/nested-object-reference/expected.json +2 -1
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
- package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-required-field/expected.json +2 -1
- package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
- package/fixtures/cases/nested-required-field/schema.yaml +10 -11
- package/fixtures/cases/numeric-range/expected.json +2 -1
- package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
- package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
- package/fixtures/cases/numeric-range/schema.yaml +10 -11
- package/fixtures/cases/one-key-two-labels/context.json +1 -0
- package/fixtures/cases/one-key-two-labels/expected.json +5 -0
- package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
- package/fixtures/cases/one-key-two-types/context.json +1 -0
- package/fixtures/cases/one-key-two-types/expected.json +5 -0
- package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
- package/fixtures/cases/one-of-variant/expected.json +2 -1
- package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
- package/fixtures/cases/one-of-variant/schema.yaml +10 -11
- package/fixtures/cases/other-room-reference/expected.json +2 -1
- package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
- package/fixtures/cases/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +2 -3
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +2 -1
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
- package/fixtures/cases/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
- package/fixtures/cases/string-length/expected.json +2 -1
- package/fixtures/cases/string-length/library/companies/acme.md +1 -1
- package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
- package/fixtures/cases/string-length/schema.yaml +10 -11
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
- package/fixtures/cases/thematic-break-ends-the-values/schema.yaml +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +1 -1
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/undeclared-field/expected.json +2 -1
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.yaml +2 -3
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +2 -1
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +2 -3
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.yaml +5 -6
- package/fixtures/division.json +86 -41
- package/fixtures/forms.json +347 -0
- package/fixtures/preamble.json +26 -5
- package/fixtures/projection.json +121 -18
- package/fixtures/queries.json +51 -0
- package/package.json +10 -1
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -91
- package/dist/condition.d.ts +0 -179
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -598
- package/dist/links.d.ts +0 -29
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -831
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/conditional-section/schema.yaml +0 -14
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/null-refused/expected.json +0 -6
- package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
- package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
- package/fixtures/cases/null-refused/schema.yaml +0 -56
- package/fixtures/cases/open-map-value/expected.json +0 -6
- package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
- package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
- package/fixtures/cases/open-map-value/schema.yaml +0 -56
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -3
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -3
- package/fixtures/cases/section-items/library/page.md +0 -42
- package/fixtures/cases/section-items/schema.yaml +0 -10
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -3
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -3
- package/fixtures/cases/structured-section/expected.json +0 -6
- /package/fixtures/cases/{conditional-section → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{null-refused → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-items → labels-in-the-rooms-language}/expected.json +0 -0
- /package/fixtures/cases/{open-map-value → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → list-item-kind}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
- /package/fixtures/cases/{structured-section → long-value-past-six-levels}/context.json +0 -0
package/API.md
CHANGED
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
apply,
|
|
6
6
|
divide,
|
|
7
7
|
links,
|
|
8
|
-
MARKDOWN_SYNTAX_PROFILE,
|
|
9
8
|
parse,
|
|
10
9
|
project,
|
|
11
10
|
retarget,
|
|
@@ -19,7 +18,7 @@ import {
|
|
|
19
18
|
const checked = verify('task:\n properties:\n title: { type: string }\n');
|
|
20
19
|
if (checked.verdict === 'accept') {
|
|
21
20
|
validate(
|
|
22
|
-
{ 'tasks/one.md': '---\ntype: task\
|
|
21
|
+
{ 'tasks/one.md': '---\ntype: task\n---\n- **title**: Ship\n\n\n' },
|
|
23
22
|
{ binaryTargets: ['assets/figure.png'] },
|
|
24
23
|
checked.model,
|
|
25
24
|
);
|
|
@@ -36,24 +35,26 @@ if (parsed.ok) {
|
|
|
36
35
|
}
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
Every reader here reads a Document's body once, on first need, as one GitHub Flavored Markdown tree
|
|
39
|
+
without literal autolinks, which no reader counts as links, and `VERSION` is the MD model version.
|
|
41
40
|
|
|
42
41
|
`verify(schema)` reads one schema text, the MD Types of one Room or App: one JSON Schema document
|
|
43
42
|
(draft 2020-12) in the YAML subset. Every top-level key but `$defs` names an MD Type holding the
|
|
44
|
-
JSON Schema of its
|
|
43
|
+
JSON Schema of its Documents' values; `$defs` holds shapes the types reuse, reached by a `$ref` under
|
|
45
44
|
`#/$defs/` alone. `type` and the built-in `any` are never declared. The model adds its keywords:
|
|
46
45
|
`reference` on a string names one MD Type, several, `any` or `attachment`, and `cross_room: true`
|
|
47
|
-
beside it admits a Document in another Room, of a type that Room declares; `
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
in its `allOf` or in such a branch may repeat to ask a section for text, else `conditional-section`;
|
|
51
|
-
`member_document: true` marks at most one type. A type alone takes `create_roles` and
|
|
46
|
+
beside it admits a Document in another Room, of a type that Room declares; `title` is the label a
|
|
47
|
+
Document shows for a field and `contentMediaType: text/markdown` marks a string of Markdown text
|
|
48
|
+
written under its own heading; `member_document: true` marks at most one type. A type alone takes `create_roles` and
|
|
52
49
|
`delete_roles`, each a list of role names. `verify(schema, provided)` holds every type of a model
|
|
53
50
|
`provided` as its own, named only for those two and only if `provided.nameable` lists it. On a field
|
|
54
51
|
of a type's own `properties` alone, `change_roles` and `initial_roles` each list role names, and
|
|
55
52
|
`transitions` lists `{ from, to, roles? }`, each end a scalar or `null`, on a field whose `type`,
|
|
56
53
|
`enum`, `const`, `$ref`, `allOf`, `anyOf`, `oneOf`, `if` and `not` admit no list or object.
|
|
54
|
+
A field's label is its `title`, else its key; the fixtures' rule ids name `verify`'s label, `name` and nesting rules,
|
|
55
|
+
a value under a heading counting a level for each property or list item above it and none inside a `json` block.
|
|
56
|
+
`readTypes(schema, provided?)` returns the model of a schema `verify` already accepted, checking
|
|
57
|
+
none of these rules, and throws on a text it cannot read as types.
|
|
57
58
|
|
|
58
59
|
```yaml
|
|
59
60
|
$defs:
|
|
@@ -63,17 +64,18 @@ plan:
|
|
|
63
64
|
status: { enum: [active, done] }
|
|
64
65
|
owner: { type: string, reference: contact }
|
|
65
66
|
shipping: { $ref: '#/$defs/address' }
|
|
67
|
+
goals: { type: string, contentMediaType: text/markdown, title: Goals }
|
|
66
68
|
required: [status]
|
|
67
|
-
sections: { Goals: { kind: text, required: true } }
|
|
68
69
|
contact: { member_document: true }
|
|
69
70
|
```
|
|
70
71
|
|
|
71
|
-
The model's `types` expose each MD Type's `name`, `memberDocument`, `
|
|
72
|
+
The model's `types` expose each MD Type's `name`, `memberDocument`, `shape` (the type as
|
|
72
73
|
written, its rule keywords left out, with every `$defs` shape it reaches), `createRoles` and
|
|
73
74
|
`deleteRoles` when written, its `rules` by field as `changeRoles`, `initialRoles` and `transitions`,
|
|
74
75
|
the facts of its `frontmatter` and `fields`, its top-level ones: JSON `type`, `format`, `values`,
|
|
75
|
-
`reference` targets, `items`, `properties`, an open map's `patterns` and `additional`,
|
|
76
|
-
a string with no `enum`, `const`, `format`, `pattern` or `reference
|
|
76
|
+
`reference` targets, `items`, `properties`, an open map's `patterns` and `additional`, `prose`,
|
|
77
|
+
a string with no `enum`, `const`, `format`, `pattern` or `reference`, its `title`, `markdown` and `json`,
|
|
78
|
+
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`
|
|
77
79
|
to their siblings and the variants of `anyOf`, `oneOf`, `then`, `else` and `dependentSchemas`, a
|
|
78
80
|
variant's own keys `conditional`; a path without one `type`, `null` aside, has none. A malformed
|
|
79
81
|
schema is refused whole, naming its `rule`, the keyword or the model's own, and the JSON Pointer
|
|
@@ -92,61 +94,93 @@ a path neither holds is not refused: it dangles. One written `/rooms/<handle>/<p
|
|
|
92
94
|
another Room, which the caller checks; any other absolute path, or one that leaves the collection, is
|
|
93
95
|
`unresolved-link`. A binary target supplies no Document or MD Type. `model` types the Library. A typed
|
|
94
96
|
Document, `any` included, at an `isDocumentPath` (no `isReservedName` of `RESERVED_NAMES` first) linking
|
|
95
|
-
into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-md-type`. The context's `typedPaths` bind each `path`, a name's one `*` standing for any nonempty part, to a `type` of `model`: a Document there naming another, or naming any unless `named`, is `unknown-type` at `/type`, one not `named` is checked as it and stays `any`, and one whose
|
|
96
|
-
|
|
97
|
-
A typed Document
|
|
97
|
+
into a reserved name is `unresolved-link`; a typed `ROOM_DESCRIPTION` is `room-md-type`. `CAPTURE_HOME`, one of `RESERVED_NAMES`, names the Capture home at a Room's root. The context's `typedPaths` bind each `path`, a name's one `*` standing for any nonempty part, to a `type` of `model`: a Document there naming another, or naming any unless `named`, is `unknown-type` at `/type`, one not `named` is checked as it and stays `any`, and one whose free text holds nothing but whitespace is `required-body` if `body`.
|
|
98
|
+
|
|
99
|
+
A typed Document writes its values in its body, as Markdown, and its frontmatter holds only
|
|
100
|
+
`TYPE_FIELD`, `MEMBER_FIELD`, `SITE_FIELD` and `RECEIVED_FIELD` (`submitted`), which `parse` reads
|
|
101
|
+
into the same value; any other frontmatter key is `malformed-value`. The `#` line is the top-level
|
|
102
|
+
`name`; under it each short value is one line `- **Label**: value` of the value list, a boolean a
|
|
103
|
+
checkbox line `- [x] Label`, a reference a link whose text is no value, a group of short values an
|
|
104
|
+
indented list under its label and a list of plain values indented bullets. A string marked
|
|
105
|
+
`contentMediaType: text/markdown` or holding a line break, a group holding one and every other
|
|
106
|
+
list have their own heading, `##` at the top and one level deeper per nesting: rows of short values
|
|
107
|
+
as a table whose column headings are labels, any other list one heading per item, its `name` or its
|
|
108
|
+
number; a value with no single JSON type is one fenced `json` block under its heading. A label is the
|
|
109
|
+
field's `title`, else its key; an open map's key is written as it is. The reader takes values in any
|
|
110
|
+
order and spelling GitHub Flavored Markdown reads alike, a text value as a line or under its heading;
|
|
111
|
+
the value list is the one list directly under the `#` line whose first item is a value line. A value
|
|
112
|
+
written twice is `repeated-value`, a label naming no field of a closed object `unknown-label`, and a
|
|
113
|
+
value its form does not read `malformed-value`, each naming the value's pointer and its `line`.
|
|
114
|
+
Every other block is free text: the preamble, each section whose heading names no field, and
|
|
115
|
+
everything after a top-level thematic break, which also ends a value under a heading.
|
|
116
|
+
|
|
117
|
+
A typed Document's value satisfies its type's schema, every keyword with its JSON Schema
|
|
98
118
|
meaning, formats asserted and defaults never filled, except that an object schema declaring neither
|
|
99
119
|
`additionalProperties` nor `unevaluatedProperties` is closed: an undeclared key is refused as
|
|
100
120
|
`undeclared-field`. `TYPE_FIELD`, `SITE_FIELD` and `RECEIVED_FIELD` count as declared on every type,
|
|
101
121
|
and the string `MEMBER_FIELD` on the `member_document` type alone, else refused, `any` included;
|
|
102
|
-
`HOUSE_FIELDS` lists the four. A refusal names the keyword, such as `required`,
|
|
103
|
-
Pointer, such as `/shipping/city
|
|
104
|
-
its item schema, else `structured-section`; a reference item is one ordinary link alone, such as
|
|
105
|
-
`- [Ada](ada.md)`. A reference, at any depth or a section item, reaching a URL, a binary target, another
|
|
122
|
+
`HOUSE_FIELDS` lists the four. A refusal names the keyword, such as `required`, the value's JSON
|
|
123
|
+
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
|
|
106
124
|
Room without `cross_room` or the context's `anyRoom: true`, a Document of a type it does not name, or,
|
|
107
125
|
from an `isDocumentPath`, a reserved name is `unresolved-reference`, and a frontmatter one reaching no member is `referenced-missing-file`
|
|
108
126
|
naming its `referrers`; `attachment` admits any path, and no body link is a referrer. `validating` is
|
|
109
127
|
`validate` over a `ReadonlyMap` Library, yielding each path read with the references it `resolved`;
|
|
110
|
-
`assess(file,
|
|
111
|
-
and `
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
`assess(file, parsed, binary, model?, context?)` reads one member from its `parse` result, naming its
|
|
129
|
+
`type` and `targets`; `assessReferences(file, parsed, changed, model?, context?)` reads, unchecked
|
|
130
|
+
otherwise, only its references and links to the `changed` Paths, as `validate` reads them; and
|
|
131
|
+
`verdicts()` `add`s assessments in any order, its `verdict()` the one `validate` gives. `validateParsed(library, context?, model?)` is `validate` over a `ReadonlyMap` of `parse` results, for Documents a caller already holds. One `validate`
|
|
132
|
+
bounds the pattern work of all its members together, a value whose match would pass that bound
|
|
133
|
+
refused as `pattern`; `openPatternBudget()` opens one such bound over the assessments made until the
|
|
134
|
+
function it returns is called, and an inner one shares the outer.
|
|
135
|
+
|
|
136
|
+
Validation returns acceptance or one refusal naming the file, the field, its line and the violated
|
|
114
137
|
rule. `parse`, `apply`, and `serialize` operate on a single text Document; they do not validate
|
|
115
|
-
collection membership or consume binary bytes. `
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
collection membership or consume binary bytes. `parse(content, file?, definition?)` and
|
|
139
|
+
`apply(document, changes, definition?, nameOf?)` take the Document's MD Type definition: `parse` takes the
|
|
140
|
+
`Definition` itself or a `DefinitionOf`, a function from the type the frontmatter declares to its
|
|
141
|
+
definition, and a Document whose definition the caller does not hold reads only its frontmatter.
|
|
142
|
+
`Document.ranges` maps each value's pointer, nested ones included, to the source range it is written
|
|
143
|
+
in, and `Document.listEnd` is where its `#` line and value list end. `NAME_FIELD` is `name`.
|
|
144
|
+
`definitionAt(model, file, typedPaths?)` is the `DefinitionOf` of one Path, its typed Path's type
|
|
145
|
+
where one binds it and its declared type otherwise. `create(type, definition?)` is the Document of
|
|
146
|
+
a type that holds no value, the start of every Document a writer builds: it declares `type`, or
|
|
147
|
+
nothing for a type a Path binds. `apply` applies a list of changes in one pass however many: each
|
|
148
|
+
sets one typed field, a long text, a list or an object as a whole included, replaces one existing
|
|
149
|
+
section body, the preamble or the free text against its prior content, opens a section the Document
|
|
150
|
+
does not hold, or rewrites one link destination or one reference, as the given Document holds it.
|
|
151
|
+
With a definition a field change rewrites that value's lines alone and writes a new one at its
|
|
152
|
+
schema position, after the nearest field before it the Document holds; a value whose form changes
|
|
153
|
+
moves, and `undefined` removes it. A reference is written as a link whose text is `nameOf(value)`,
|
|
154
|
+
else the file name, and never changed after; a value no form carries is `malformed-value`, and a
|
|
155
|
+
section change naming a field's label `required-section`. Without one a field is written in the
|
|
156
|
+
frontmatter. A `{ kind: 'section', name, value, prior: undefined }` change opens a
|
|
157
|
+
section after the Document's last line, in the order the changes give, and is stale where the
|
|
158
|
+
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
|
|
119
159
|
all, and `{ outcome: 'stale', document, stale }` keeps the Document and lists the positions of each
|
|
120
160
|
change it does not hold and of each later change of a part an earlier one changes, such as a link
|
|
121
|
-
inside a replaced section. A section
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
161
|
+
inside a replaced section. A section, preamble or free text replacement that would hide a section the
|
|
162
|
+
Document carried behind a repeated, merged or fenced heading, or change a value, is refused as
|
|
163
|
+
`overlapping-section` naming that section or value. A frontmatter field change does not reformat
|
|
164
|
+
the rest of the file: an inline value is replaced where it stands, and a value written after the
|
|
165
|
+
key's line, an empty one or a block mapping or list, is written after the key's colon in its place.
|
|
166
|
+
A frontmatter field holds a `FrontmatterValue`: null, a string, a boolean, a finite number,
|
|
127
167
|
a list without holes or a plain object of them, no cycle, at most 63 deep. `frontmatterValue(value)`
|
|
128
168
|
is that test; `apply` refuses any other value and `parse` a frontmatter past 64 deep as
|
|
129
169
|
`frontmatter-fence`. `equalValue` compares two by value, whatever their key order, as `apply` does.
|
|
170
|
+
`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`.
|
|
130
171
|
|
|
131
|
-
`Document.preamble` is a readonly string holding the exact source after frontmatter
|
|
132
|
-
|
|
133
|
-
leading H1 and any fenced text
|
|
172
|
+
`Document.preamble` is a readonly string holding the exact source after frontmatter, or after the
|
|
173
|
+
`#` line and value list of a typed Document and their blank lines, and before the first section
|
|
174
|
+
heading, `''` when empty, whitespace, newlines, a leading H1 and any fenced text included. The closing frontmatter
|
|
134
175
|
delimiter and its line ending belong to frontmatter: `bodyAfterFrontmatter(content)` is the exact
|
|
135
176
|
source after them, the whole text when it opens no closed fence, and the preamble begins it.
|
|
136
|
-
`
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
prior: parsed.document.preamble,
|
|
144
|
-
value: 'Updated introduction.\n\n',
|
|
145
|
-
};
|
|
146
|
-
const result = apply(parsed.document, [change]);
|
|
147
|
-
if (result.outcome === 'applied') serialize(result.document);
|
|
148
|
-
}
|
|
149
|
-
```
|
|
177
|
+
`Document.text` is its free text, every part of its body that holds no value, in order;
|
|
178
|
+
`textSpans(document)` names where each part stands as `start`, `end` and `text`. A
|
|
179
|
+
`{ kind: 'text', prior, value }` change replaces it whole against its prior, keeping every value: a
|
|
180
|
+
typed Document that holds a value writes it after a thematic break below its values, so no line of
|
|
181
|
+
it reads as one. It is stale beside a preamble or section change it covers.
|
|
182
|
+
`headingLines(content, from, to)` reads each top-level heading, ATX or setext, by `level` and `name`;
|
|
183
|
+
a heading inside a code block, an HTML block, a quote or a list item is none.
|
|
150
184
|
|
|
151
185
|
A `{ kind: 'preamble', prior, value }` change compares `prior` to the current preamble exactly. A
|
|
152
186
|
mismatch is stale and leaves the current Document unchanged. A match replaces only that source span,
|
|
@@ -167,7 +201,7 @@ is part of `href` and not part of `target`. Entries are ordered by the position
|
|
|
167
201
|
text a rewrite would change, and one destination written the same way appears once however many
|
|
168
202
|
times it occurs. A destination that the syntax profile does not read as a link, one that is empty, a
|
|
169
203
|
bare fragment, or carries a URL scheme, and one that leaves the collection are not in the inventory.
|
|
170
|
-
Frontmatter values are never
|
|
204
|
+
Frontmatter values and the links that write reference values are never in it.
|
|
171
205
|
|
|
172
206
|
`target(file, href)` is the collection Path one written destination resolves to relative to `file`,
|
|
173
207
|
by the rule `links` and `validate` read: surrounding spaces and the `?query` or `#fragment` it
|
|
@@ -178,20 +212,28 @@ carries a URL scheme, starts at `/` once read, encodes no UTF-8 text, or leaves
|
|
|
178
212
|
resolves to `null`. It reads a destination written anywhere, such as a typed reference field value,
|
|
179
213
|
which `links` never enumerates. `roomTarget(href)` reads `/rooms/<handle>/<path>` as its `handle`
|
|
180
214
|
and `path`, else `null`, and `roomPath(href)` is its canonical text, the target `facts` resolves for
|
|
181
|
-
any reference written so. `
|
|
215
|
+
any reference written so. `linkedPath(from, href)` reads a link so, with the `handle` a
|
|
216
|
+
`/rooms/<handle>` one names, `''` for the Room's root and the heading its `#fragment` names, `from`
|
|
217
|
+
if it names no Path. `retarget(href, to)` is that destination rewritten to `to`, keeping the
|
|
182
218
|
`?query` or `#fragment` it carried, which is the destination the `link` change below writes. It
|
|
183
219
|
percent-encodes in `to` what `target` would decode, so it resolves to `to` again.
|
|
184
220
|
|
|
221
|
+
`untitled(definition)` is a definition without its `title`s at any depth, a property named `title`
|
|
222
|
+
kept, so two types that differ only in their labels compare equal.
|
|
223
|
+
|
|
185
224
|
`checkDocument(file, content, model, context?)` reads one Document as `validate` does in that
|
|
186
225
|
context: `ok: false` where it refuses, else its `type`, whether it is `typed`, and each reference's
|
|
187
226
|
`target` and `to`, which `resolves(reference, typeOf, binary)` says reaches a member `validate`
|
|
188
|
-
accepts. `
|
|
189
|
-
neither names another Room's, which `roomReferences(file, content, definition?)` lists by `kind`.
|
|
227
|
+
accepts. It names no other Room's, which `roomReferences(document, definition?)` lists by `kind`.
|
|
190
228
|
`parseFrontmatter(content, file?)` is `parse` without the body: `content`, `type`, `fields`.
|
|
191
229
|
|
|
192
|
-
`references(document, definition)` lists each
|
|
193
|
-
`
|
|
194
|
-
|
|
230
|
+
`references(document, definition)` lists each `reference` value at any depth as `pointer`,
|
|
231
|
+
`value` and `to`; a `{ kind: 'reference', pointer, value, prior }` change rewrites the destination
|
|
232
|
+
of the link that writes one, keeping its text, or is stale. `referenceTarget(file, value)` is the Path a value names
|
|
233
|
+
read as a link destination, else `null`; `referenceTargets(document, file, model)` lists each
|
|
234
|
+
reference's `location`, `to` and `target`. `documentFacts(file, parsed, model)`, `null` where the
|
|
235
|
+
text does not parse, is the `type` (`any` if none), `fields` and sorted distinct link and reference
|
|
236
|
+
`links` a save stores, no links under `settings/`. `relativize(document, file, handle, definition?, kept?)`
|
|
195
237
|
rewrites, in one `apply`, each link destination and reference written `/rooms/<handle>/<path>` and
|
|
196
238
|
not in `kept` to `relative(file, path)`, keeping its `?query` or `#fragment`. A text without
|
|
197
239
|
frontmatter, such as a captured body, is read from its first character: `relativizeBody(body, file, handle)` converts it
|
|
@@ -199,6 +241,8 @@ so, refusing a `/rooms/` one naming no Room's file as `unresolved-link`; `bodyLi
|
|
|
199
241
|
is its `links` and `bodyRoomLinks(body)` its other Rooms'. `relinkBody(body, file, moves)` writes,
|
|
200
242
|
in the `link` change's form, each destination whose Path keys `moves` as that value relative to
|
|
201
243
|
`file`, or as that value when it is a `/rooms/` path, and one whose `roomPath` does as that value.
|
|
244
|
+
`unlinkBody(body, hrefs)` cuts every link and reference definition whose written destination is
|
|
245
|
+
in `hrefs`, and answers the rest as `body` with `links`, each such destination written as one link.
|
|
202
246
|
|
|
203
247
|
```ts
|
|
204
248
|
target('items/six.md', ' ../projects/atlas.md#overview '); // 'projects/atlas.md'
|
|
@@ -218,13 +262,11 @@ fits. A destination that neither form can carry is refused as `unwritable-link`.
|
|
|
218
262
|
`project(document, file, context?)` is the Embedding projection input of one Document: the prose a
|
|
219
263
|
consumer embeds, with every internal Markdown-document link reduced to the label a reader sees. A
|
|
220
264
|
Document that declares no MD type contributes its body after the frontmatter fence. A typed one
|
|
221
|
-
contributes its prose values, its
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
them, exactly as written. The Path and every other value stay outside, so changing them alone leaves
|
|
227
|
-
the projection unchanged.
|
|
265
|
+
contributes its prose values, each bare without its label, first the ones written on a line, in a
|
|
266
|
+
cell or in a `json` block, each followed by a blank line, then its Markdown long values and its free
|
|
267
|
+
text, its preamble, each section whose heading names no field and what follows a thematic break,
|
|
268
|
+
in Document order. A prose value is a string at any depth whose schema is prose. The Path, every
|
|
269
|
+
label and every other value stay outside, so changing them alone leaves the projection unchanged.
|
|
228
270
|
|
|
229
271
|
```ts
|
|
230
272
|
const parsed = parse(content);
|
|
@@ -261,18 +303,6 @@ under the bound the caller supplies. Each Span carries the `text` to embed and t
|
|
|
261
303
|
of the extent it addresses in the Document's own source, as UTF-8 byte offsets and never string
|
|
262
304
|
positions, so a caller stores the extent and hydrates the text it shows from the Document itself.
|
|
263
305
|
|
|
264
|
-
```ts
|
|
265
|
-
const parsed = parse(content);
|
|
266
|
-
if (parsed.ok) {
|
|
267
|
-
const divided = divide(parsed.document, 'tasks/two.md', {
|
|
268
|
-
documentTargets: ['plans/q3.md', 'people/ana.md'],
|
|
269
|
-
definition: model.types.task,
|
|
270
|
-
bound: 2000,
|
|
271
|
-
});
|
|
272
|
-
if (divided.ok) for (const span of divided.spans) embed(span.text);
|
|
273
|
-
}
|
|
274
|
-
```
|
|
275
|
-
|
|
276
306
|
`DivisionContext` is a `ProjectionContext` and one `bound`, the greatest number of characters a
|
|
277
307
|
Span's embedded text may carry, counted the way JavaScript counts a string's length and not in the
|
|
278
308
|
bytes the extent is measured in. No Span's text is ever longer than the bound. A bound cut never
|
|
@@ -302,36 +332,43 @@ Division is total: every authored character of the input belongs to at least one
|
|
|
302
332
|
carrying no authored text divides into no Span at all. A Span's extent is the smallest range of the
|
|
303
333
|
source that contains everything the Span covers, so it spans what the input excludes between two
|
|
304
334
|
eligible pieces, and the extent addresses the authored source where the embedded text carries a
|
|
305
|
-
repeated heading, an internal link's visible label, or a
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
addresses that whole link, because a cut never falls inside link syntax.
|
|
335
|
+
repeated heading, an internal link's visible label, or a value the author escaped. A Span divided
|
|
336
|
+
out of one value written on a line addresses that whole value, and a Span carrying part of one
|
|
337
|
+
internal link's label addresses that whole link, because a cut never falls inside link syntax.
|
|
309
338
|
|
|
310
339
|
## Queries
|
|
311
340
|
|
|
312
|
-
`planOf(query, rooms)` checks one query against the MD Types of the Rooms `rooms` lists, each
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
`
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
341
|
+
`planOf(query, rooms)` checks one query against the MD Types of the Rooms `rooms` lists, each `{
|
|
342
|
+
locator, available, types }` with `listed` when the list is whole, and answers its `QueryPlan` or
|
|
343
|
+
throws a `QueryError` whose `code` is `invalid-query`, `unknown-type`, `unknown-field` or
|
|
344
|
+
`wrong-kind`, whose message names where, whose `place` is that place as the keys and indexes into
|
|
345
|
+
the query, which `placeText` writes as its message does, and whose `accepts` lists what it would
|
|
346
|
+
take there: the types or fields the Rooms declare, a field's `kindWords`, or the parts and operators
|
|
347
|
+
a query knows. A query is data: `types`, `where` field predicates by JSON Pointer (`$eq`, `$ne`,
|
|
348
|
+
`$in`, `$nin`, `$gt`, `$gte`, `$lt`, `$lte`, `$all`, `$size`, `$exists`, `$prefix`, `$and`, `$or`),
|
|
349
|
+
`pathPrefix`, `outside` (directories left out), `folder`, `paths`, `fileIds`, `hop`, `backlinks`,
|
|
350
|
+
`text`, then `select` or `groupBy`, `orderBy`, `limit`, `after` and `total`. A Document query
|
|
351
|
+
selects and orders by a row's `size`, `created` and its change's time `updated` beside `room`,
|
|
352
|
+
`path`, `type`, `folder` and a field. A group query groups by `room`, `type`, `folder`, `subfolder`
|
|
353
|
+
(the child folder of `pathPrefix` holding a row) or a field, selects each group's `size`, its
|
|
354
|
+
documents and files apart, its latest `updated` and the `greatest` value of a field, and orders by
|
|
355
|
+
`count`, those or its keys. `queryKey` and `identityOf` are a query's and a plan's canonical text,
|
|
356
|
+
`bodied` says a shape reads text, `cursorOf` and `decodedCursor` write and read the `after` a window
|
|
321
357
|
continues from, and `invalid`, `known` and `plain` are the check's refusal and tests.
|
|
322
358
|
|
|
323
|
-
`
|
|
324
|
-
and `fitsKind(kind, facts, value)` whether a value fits it: a `date`,
|
|
325
|
-
exactly what document validation admits as that format, a `date` is
|
|
326
|
-
compares as the instant `instant` reads, which `instantKey` writes as text
|
|
327
|
-
instant does, and a `reference` as the Room Path it resolves to. `compared(left,
|
|
328
|
-
ordering)` orders plain values: numbers and booleans, then text by locale or `byCodePoint`,
|
|
359
|
+
`Kind` is a kind a value compares as, `kindOf(facts)` a declared value's kind, `kindWords(facts)`
|
|
360
|
+
the values it takes in words, and `fitsKind(kind, facts, value)` whether a value fits it: a `date`,
|
|
361
|
+
`date-time` or `time` is exactly what document validation admits as that format, a `date` is
|
|
362
|
+
`dated`, a `date-time` compares as the instant `instant` reads, which `instantKey` writes as text
|
|
363
|
+
that sorts as the instant does, and a `reference` as the Room Path it resolves to. `compared(left,
|
|
364
|
+
right, ordering)` orders plain values: numbers and booleans, then text by locale or `byCodePoint`,
|
|
329
365
|
then lists item by item.
|
|
330
366
|
|
|
331
367
|
Two evaluators answer a plan's tests on one Document alike, a test on a missing value false and
|
|
332
368
|
its negation (`$ne`, `$nin`, `$exists: false`) true. `matches(plan, candidate)` answers in
|
|
333
369
|
memory over one `Candidate`: its `path`, `type`, `fileId`, `fields`, `definition` and the
|
|
334
|
-
`text` held
|
|
370
|
+
`text` held, and refuses a plan that orders by `size`, `created`, `updated` or `greatest`, or
|
|
371
|
+
selects a group's totals, which one Document cannot answer. The `sql` namespace compiles them to SQL over a collection: `indexed(path, fields,
|
|
335
372
|
definition)` derives a Document's values and field links, its date-times with their instants,
|
|
336
373
|
`sql.VALUE_TABLE` holds those values and `sql.insertedValues` writes them, and `sql.tests(alias,
|
|
337
374
|
plan)` tests a document row of `id`, `path`, `folder`, `type`, `file_id` and `content`, its
|
|
@@ -342,63 +379,28 @@ instant between numbers and text; `sql.fragment`, `sql.joined`, `sql.all`, `sql.
|
|
|
342
379
|
`sql.grouped`, `sql.listed` and `sql.exists` build statements, and `heldKind` is the index's value
|
|
343
380
|
kind. `fixtures/queries.json` holds both evaluators to one table.
|
|
344
381
|
|
|
345
|
-
##
|
|
346
|
-
|
|
347
|
-
`facts(document, { id, path }, model, resolve)` reads one Document as the `DocumentFacts` a
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
not fit its kind, such as a string in a number field, a
|
|
354
|
-
`resolve` maps to no `{ id, member? }`, is `unreadable`; a readable reference
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
`exists: true` holds where present and fails where absent, `exists: false` the reverse. `all` is
|
|
372
|
-
`false` if a part is, else `undefined` if a part is; `any` is `true` if a part is, else `undefined`
|
|
373
|
-
if a part is; `not` keeps `undefined`, so absence is tested with `exists`, never with `not`. `eq`
|
|
374
|
-
and `in` are `undefined` against a value of another JSON type and compare a `time` as an instant;
|
|
375
|
-
`prefix` reads only a string, never a reference or a member; `gt`, `gte`, `lt` and `lte` order
|
|
376
|
-
numbers, dates and times alone.
|
|
377
|
-
|
|
378
|
-
`fires(condition, event)` reads one change, `{ before, after, changed, by, moved_between_rooms }`:
|
|
379
|
-
each side's facts, `null` for a side the change lacks, the `changed` paths whose prose changed, the
|
|
380
|
-
actor a `by` test reads at the `ACTOR_PATHS`, its `/door` one of `WRITE_DOORS`, and whether it
|
|
381
|
-
moved between Rooms, which a set `moved_between_rooms` must match. `starts_matching` fires when the
|
|
382
|
-
Document is in `scope` and holds `match` after the change but not before, a creation only with
|
|
383
|
-
`new_documents: true`. `field_changes` fires when the Document's side, after or for a deletion
|
|
384
|
-
before, is in `scope` and holds `match`, and `field` changed: its facts differ, or with neither
|
|
385
|
-
`from` nor `to` `changed` names it, as it names `TEXT_FIELD`, `/text`, at any change of its text. A field on neither
|
|
386
|
-
side never fires; `from: 'new'` admits only a creation and `to: 'deleted'` only a deletion, and listed values need that side's `field` `in` them. `inScope(scope, side)` is the `scope` test `fires` makes of a side, read from its `id`, `path` and `type` alone, `false` for `null`.
|
|
387
|
-
|
|
388
|
-
`itemFires(condition, item)` compares `source` and `address` where given and holds `match` over the
|
|
389
|
-
`ITEM_PATHS`, a `/json` test unknown for an item with no JSON; `notificationFires(condition, notification)`
|
|
390
|
-
holds `match`, where given, over a delivered notification's Document facts, and `messageFires(condition, message)`
|
|
391
|
-
over a message's `MessageFacts` at the `MESSAGE_PATHS`, a `/agent_function` or `/path` test unknown where its request names none.
|
|
392
|
-
`prosePaths(facts)` lists the prose and section paths whose text builds `changed`; `pointed(value, pointer)` reads a JSON Pointer,
|
|
393
|
-
`undefined` where nothing is; `dated(value)` checks a `YYYY-MM-DD` date, and `instant(value)` reads what validation admits as a `date-time` as epoch nanoseconds, a `bigint`.
|
|
394
|
-
|
|
395
|
-
What a condition names of one MD Type: `datePointers(fields)` lists, sorted, its date fields as escaped
|
|
396
|
-
`/fields/` pointers, the only `date`s a `DateCondition` takes; `changeFields(definition)` lists each
|
|
397
|
-
declared field and section as a `field_changes` `field`, and `valuedChange(definition, field)` holds of
|
|
398
|
-
a field read as one value, never prose, a list or reached through one, the only `field` that takes a
|
|
399
|
-
`from` or a `to`; `memberPointers(definition, memberType)` lists the `/members/<name>` paths of the
|
|
400
|
-
fields referring to `memberType`, alone or in a list. `testOperators(definitions, path, memberType)`
|
|
401
|
-
lists the `CONDITION_OPERATORS` a test on a document `path` takes in any of those types, none where none
|
|
402
|
-
declares it or, for a member path, `memberPointers` lacks it: `exists` alone on a section, prose or an
|
|
403
|
-
object, `contains` and `exists` on a list, `prefix` on a string and `/path`, orderings on a number, date
|
|
404
|
-
or time, and `contains` through a list. `actorOperators(path)`, `itemOperators(path)` and `messageOperators(path)` list the tests on a `by`, item or message path, `itemKind(path)` an item value's kind, or `null`, as on `/json/`.
|
|
382
|
+
## Events
|
|
383
|
+
|
|
384
|
+
`facts(document, { id, path }, model, resolve)` reads one Document as the `DocumentFacts` of a
|
|
385
|
+
change: its `id`, its `path` with a leading `/`, its `type` or `null`, and a `Fact`
|
|
386
|
+
for each field it writes that its MD Type declares, held as its kind in the one table
|
|
387
|
+
of kinds: `reference`, `enum`, `number`, `integer`, `boolean`, `date`, `date-time`, `time` or
|
|
388
|
+
`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
|
|
389
|
+
`null` is `null`. A
|
|
390
|
+
value that does not fit its kind, such as a string in a number field, a fraction in an integer
|
|
391
|
+
field, a value outside its `enum` or a reference `resolve` maps to no `{ id, member? }`, is `unreadable`; a readable reference holds that
|
|
392
|
+
`id` and the `member` it binds, which `members(facts, path)` lists at a `/members/<pointer>`.
|
|
393
|
+
|
|
394
|
+
`candidateOf(facts)` is that Document as the `Candidate` `matches` answers over, so a query tests
|
|
395
|
+
the Document as the change saw it: at its Room Path, by its file ID, a reference as the `id` it
|
|
396
|
+
named, a prose value as present alone, an unreadable value as missing and a date-time as an instant.
|
|
397
|
+
`heldAt(candidate, pointer)` lists the values a pointer reaches there, its date-times with their
|
|
398
|
+
instants. `prosePaths(facts)` lists the prose field paths whose text a change compares, and
|
|
399
|
+
`TEXT_FIELD`, `/text`, names a Document's whole text; `WRITE_DOORS` are the ways a change is made.
|
|
400
|
+
`pointed(value, pointer)` reads a JSON Pointer, `undefined` where nothing is; `dated(value)` checks a
|
|
401
|
+
`YYYY-MM-DD` date, and `instant(value)` reads what validation admits as a `date-time` as epoch
|
|
402
|
+
nanoseconds, a `bigint`. Of one MD Type, `datePointers(definition)` lists, sorted, its date fields as
|
|
403
|
+
escaped pointers, `valuedChange(definition, pointer)` holds of a field read as one value, never
|
|
404
|
+
prose, a list or reached through one, the only field whose change is tested by its values, and
|
|
405
|
+
`memberPointers(definition, memberType)` the `/members/<name>` paths of the fields referring to
|
|
406
|
+
`memberType`, alone or in a list.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# `@agentshouse/mdmodel`
|
|
2
2
|
|
|
3
|
-
Typed Markdown documents: MD Types declared in JSON Schema,
|
|
4
|
-
deterministic application of one structured change to a Document, and one query language
|
|
3
|
+
Typed Markdown documents: MD Types declared in JSON Schema, whose values a Document writes in its
|
|
4
|
+
Markdown body, a reader, a writer and validator of them, the deterministic application of one structured change to a Document, and one query language
|
|
5
5
|
answered in SQL over a collection or in memory over one Document, plus a conformance
|
|
6
6
|
fixture corpus.
|
|
7
7
|
|
|
@@ -20,17 +20,16 @@ npm install @agentshouse/mdmodel
|
|
|
20
20
|
```ts
|
|
21
21
|
import { apply, parse, serialize, validate, verify } from '@agentshouse/mdmodel';
|
|
22
22
|
|
|
23
|
-
const checked = verify('task:\n properties:\n title: { type: string }\n');
|
|
23
|
+
const checked = verify('task:\n properties:\n title: { type: string, title: Title }\n');
|
|
24
24
|
if (checked.verdict === 'accept') {
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (next.outcome === 'applied') serialize(next.document);
|
|
25
|
+
const task = checked.model.types.task;
|
|
26
|
+
validate({ 'one.md': '---\ntype: task\n---\n- **Title**: Ship\n' }, undefined, checked.model);
|
|
27
|
+
const parsed = parse('---\ntype: task\n---\n- **Title**: Hello\n', 'one.md', task);
|
|
28
|
+
if (parsed.ok) {
|
|
29
|
+
const change = { kind: 'field', name: 'title', value: 'World', prior: 'Hello' } as const;
|
|
30
|
+
const next = apply(parsed.document, [change], task);
|
|
31
|
+
if (next.outcome === 'applied') serialize(next.document);
|
|
32
|
+
}
|
|
34
33
|
}
|
|
35
34
|
```
|
|
36
35
|
|
|
@@ -45,10 +44,10 @@ if (parsed.ok) {
|
|
|
45
44
|
| `links`, `target`, `retarget` | Inventory and rewrite link destinations |
|
|
46
45
|
| `escapePointer` | Write one key as a JSON Pointer token |
|
|
47
46
|
| `project`, `divide` | Embedding projection input and its division into Spans |
|
|
48
|
-
| `facts`, `
|
|
47
|
+
| `facts`, `candidateOf` | A Document as one change saw it, matched as one query candidate |
|
|
49
48
|
| `planOf`, `matches`, `sql` | Check a query, answer it over one Document or compile it to SQL |
|
|
50
|
-
| `
|
|
51
|
-
| `MEMBER_FIELD`, `SITE_FIELD`, `RECEIVED_FIELD` | The
|
|
49
|
+
| `VERSION` | The MD model version |
|
|
50
|
+
| `MEMBER_FIELD`, `SITE_FIELD`, `RECEIVED_FIELD` | The frontmatter keys validation counts as declared beyond a type's |
|
|
52
51
|
|
|
53
52
|
The full reference is in [`API.md`](API.md). The conformance corpus and its
|
|
54
53
|
verdict format and rule ids are described in [`fixtures/README.md`](fixtures/README.md).
|
package/dist/body.d.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type ValueFacts } from './definition.js';
|
|
2
|
+
import { type Reading, type SectionSpan } from './markdown.js';
|
|
3
|
+
import type { Extent } from './types.js';
|
|
4
|
+
export declare const NAME_FIELD = "name";
|
|
5
|
+
export declare const DEEPEST_HEADING = 6;
|
|
6
|
+
export type Form = 'text' | 'number' | 'boolean' | 'reference' | 'group' | 'list' | 'json';
|
|
7
|
+
export type Placement = {
|
|
8
|
+
readonly key: string;
|
|
9
|
+
readonly as: 'name' | 'line' | 'heading';
|
|
10
|
+
readonly start: number;
|
|
11
|
+
readonly end: number;
|
|
12
|
+
readonly next: number;
|
|
13
|
+
};
|
|
14
|
+
export type ProseText = Extent & {
|
|
15
|
+
readonly text: string;
|
|
16
|
+
readonly markdown: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type Destination = Extent & {
|
|
19
|
+
readonly bracketed: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type Body = {
|
|
22
|
+
readonly values: Readonly<Record<string, unknown>>;
|
|
23
|
+
readonly ranges: Readonly<Record<string, Extent>>;
|
|
24
|
+
readonly prose: readonly ProseText[];
|
|
25
|
+
readonly links: Readonly<Record<string, Destination>>;
|
|
26
|
+
readonly labels: readonly LabelAt[];
|
|
27
|
+
readonly top: readonly Placement[];
|
|
28
|
+
readonly name: Placement | null;
|
|
29
|
+
readonly list: Extent | null;
|
|
30
|
+
readonly listAt: number;
|
|
31
|
+
readonly head: number;
|
|
32
|
+
readonly preamble: Extent;
|
|
33
|
+
readonly sections: readonly SectionSpan[];
|
|
34
|
+
readonly free: readonly Extent[];
|
|
35
|
+
readonly ending: Extent | null;
|
|
36
|
+
readonly anchor: number;
|
|
37
|
+
};
|
|
38
|
+
export type BodyRefusal = {
|
|
39
|
+
readonly rule: string;
|
|
40
|
+
readonly location: string;
|
|
41
|
+
readonly at: number;
|
|
42
|
+
};
|
|
43
|
+
export declare function formOf(facts: ValueFacts | undefined): Form;
|
|
44
|
+
export declare function labelOf(key: string, facts: ValueFacts | undefined): string;
|
|
45
|
+
export declare function unescaped(text: string): string;
|
|
46
|
+
export declare function longText(value: string): string;
|
|
47
|
+
export type LabelAt = Extent & {
|
|
48
|
+
readonly path: string;
|
|
49
|
+
readonly written: 'line' | 'heading' | 'cell';
|
|
50
|
+
};
|
|
51
|
+
export declare function readBody(content: string, bodyStart: number, reading: Reading, root: ValueFacts): {
|
|
52
|
+
readonly ok: true;
|
|
53
|
+
readonly body: Body;
|
|
54
|
+
} | {
|
|
55
|
+
readonly ok: false;
|
|
56
|
+
readonly refusal: BodyRefusal;
|
|
57
|
+
};
|
|
58
|
+
export type Naming = (reference: string) => string | undefined;
|
|
59
|
+
export type Written = {
|
|
60
|
+
readonly ending: string;
|
|
61
|
+
readonly nameOf: Naming | undefined;
|
|
62
|
+
};
|
|
63
|
+
export declare function lineFits(text: string): boolean;
|
|
64
|
+
export declare function lineOfValue(key: string, facts: ValueFacts | undefined, value: unknown, indent: string, written: Written, pointer: string): string | null;
|
|
65
|
+
export declare function regionOfValue(key: string, facts: ValueFacts | undefined, value: unknown, level: number, written: Written, pointer: string, heading?: string): string;
|
|
66
|
+
export declare function groupBody(facts: ValueFacts, value: Record<string, unknown>, level: number, written: Written, pointer: string, root: boolean): string;
|
|
67
|
+
export type Placed = {
|
|
68
|
+
readonly as: 'name';
|
|
69
|
+
readonly text: string;
|
|
70
|
+
} | {
|
|
71
|
+
readonly as: 'line';
|
|
72
|
+
readonly text: string;
|
|
73
|
+
} | {
|
|
74
|
+
readonly as: 'heading';
|
|
75
|
+
readonly text: string;
|
|
76
|
+
};
|
|
77
|
+
export declare function placedValue(key: string, root: ValueFacts, value: unknown, written: Written): Placed | {
|
|
78
|
+
readonly unwritable: string;
|
|
79
|
+
};
|
|
80
|
+
export declare function bodyOrder(root: ValueFacts): readonly string[];
|
|
81
|
+
export declare function writtenValue(value: unknown, facts: ValueFacts | undefined): unknown;
|
|
82
|
+
export declare function labelAt(root: ValueFacts, path: string): string | undefined;
|
|
83
|
+
export declare function labelsIn(facts: ValueFacts, path?: string, into?: Map<string, string>): Map<string, string>;
|
|
84
|
+
export declare function writtenLabel(label: string, written: LabelAt['written']): string;
|
|
85
|
+
//# sourceMappingURL=body.d.ts.map
|