@agentshouse/mdmodel 0.1.0-cf26f43c2e4d9 → 0.1.0-cf46fc494ee20
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 +234 -237
- package/README.md +27 -25
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/definition.d.ts +24 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +188 -128
- package/dist/document.d.ts +15 -8
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +769 -140
- 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 +2 -2
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +153 -0
- package/dist/house-model.d.ts +920 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +504 -0
- package/dist/house-references/crockford.d.ts +4 -0
- package/dist/house-references/crockford.d.ts.map +1 -0
- package/dist/house-references/crockford.js +3 -0
- package/dist/house-references/patterns.d.ts +9 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +13 -0
- package/dist/index.d.ts +44 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -11
- package/dist/indexed.d.ts +9 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +55 -0
- package/dist/kinds.d.ts +21 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +210 -0
- package/dist/markdown.d.ts +71 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +232 -0
- package/dist/media-type.d.ts +72 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +157 -0
- package/dist/moment.d.ts +7 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +18 -0
- package/dist/not-ready.d.ts +2 -0
- package/dist/not-ready.d.ts.map +1 -0
- package/dist/not-ready.js +5 -0
- package/dist/paths.d.ts +16 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +107 -22
- package/dist/pattern.d.ts.map +1 -1
- package/dist/pattern.js +4 -3
- package/dist/query/language.d.ts +257 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +621 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +150 -0
- package/dist/query/rows.d.ts +32 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +158 -0
- package/dist/query/sql.d.ts +45 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +296 -0
- package/dist/query/walk.d.ts +63 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +263 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +7 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +32 -0
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +137 -0
- package/dist/schema.d.ts +1 -3
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +9 -73
- package/dist/types.d.ts +22 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +12 -6
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +227 -179
- package/dist/yaml.d.ts +7 -5
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +166 -45
- package/fixtures/README.md +92 -69
- 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/block-scalar-frontmatter/library/notes/literal.md +17 -0
- package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
- 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/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- 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/expected.json +1 -0
- 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/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
- 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/context.json +1 -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/context.json +1 -0
- 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/context.json +1 -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/context.json +1 -0
- 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-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
- 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/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/schema.yaml +10 -0
- 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/referenced-missing-non-latin-file/context.json +1 -0
- package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/schema.yaml +10 -0
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- 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-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
- 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/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
- 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/forms.json +371 -0
- package/fixtures/preamble.json +29 -8
- package/fixtures/queries.json +1562 -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 -163
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -617
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -320
- 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/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -128
- 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/division.json +0 -409
- package/fixtures/projection.json +0 -255
- /package/fixtures/cases/{conditional-section → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{section-items → block-scalar-frontmatter}/expected.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{null-refused → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → frontmatter-construct}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → link-into-a-reserved-name}/context.json +0 -0
- /package/fixtures/cases/{section-items → link-into-a-reserved-name-from-an-untyped-document}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{structured-section → list-item-kind}/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}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
package/dist/validate.js
CHANGED
|
@@ -1,16 +1,83 @@
|
|
|
1
|
-
import { ATTACHMENT, BUILT_IN_TYPE, readSchema } from './definition.js';
|
|
2
|
-
import { parse } from './document.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { ATTACHMENT, BUILT_IN_TYPE, readSchema, } from './definition.js';
|
|
2
|
+
import { linkDestinations, links, parse } from './document.js';
|
|
3
|
+
import { MEMBER_FIELD } from './fields.js';
|
|
4
|
+
import { formFailure } from './form.js';
|
|
5
|
+
import { indexedFailure } from './indexed.js';
|
|
6
|
+
import { hrefOccurrences, lineBreaks, lineNumber } from './markdown.js';
|
|
7
|
+
import { classifyHref, keyedLink, roomTarget } from './paths.js';
|
|
5
8
|
import { references } from './references.js';
|
|
9
|
+
import { isDocumentPath, ROOM_DESCRIPTION } from './reserved.js';
|
|
6
10
|
import { refusal } from './refuse.js';
|
|
7
|
-
import {
|
|
11
|
+
import { schemaRefusal } from './schema.js';
|
|
8
12
|
import { openPatternBudget, PatternTooCostly } from './pattern.js';
|
|
9
|
-
import { headingSpans, listItems } from './sections.js';
|
|
10
|
-
import { bodyAfterFrontmatter, bodyStartOf } from './yaml.js';
|
|
11
13
|
function refuse(file, rule, extra) {
|
|
12
14
|
return { verdict: 'refuse', ...refusal(file, rule, extra) };
|
|
13
15
|
}
|
|
16
|
+
const LINE_BREAKS = new WeakMap();
|
|
17
|
+
function lineAt(document, location) {
|
|
18
|
+
let pointer = location;
|
|
19
|
+
for (;;) {
|
|
20
|
+
const range = document.ranges[pointer];
|
|
21
|
+
if (range !== undefined) {
|
|
22
|
+
const breaks = LINE_BREAKS.get(document) ?? lineBreaks(document.content);
|
|
23
|
+
LINE_BREAKS.set(document, breaks);
|
|
24
|
+
return lineNumber(breaks, range.start);
|
|
25
|
+
}
|
|
26
|
+
if (pointer === '')
|
|
27
|
+
return undefined;
|
|
28
|
+
pointer = pointer.slice(0, pointer.lastIndexOf('/'));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function placedRefusal(file, document, rule, location) {
|
|
32
|
+
const line = lineAt(document, location);
|
|
33
|
+
return refuse(file, rule, { location, ...(line === undefined ? {} : { line }) });
|
|
34
|
+
}
|
|
35
|
+
function unmarkedMember(file, document, definition) {
|
|
36
|
+
return Object.hasOwn(document.fields, MEMBER_FIELD) && definition?.memberDocument !== true
|
|
37
|
+
? refuse(file, 'undeclared-field', { location: `/${MEMBER_FIELD}` })
|
|
38
|
+
: null;
|
|
39
|
+
}
|
|
40
|
+
function reservedLink(file, document, changed) {
|
|
41
|
+
return (document.type !== undefined &&
|
|
42
|
+
isDocumentPath(file) &&
|
|
43
|
+
links(document, file).some((link) => !isDocumentPath(link.target) && (changed?.has(link.target) ?? true)));
|
|
44
|
+
}
|
|
45
|
+
function describedRoom(file, document) {
|
|
46
|
+
return file === ROOM_DESCRIPTION && document.type !== undefined
|
|
47
|
+
? refuse(file, 'room-md-type', { location: '/type' })
|
|
48
|
+
: null;
|
|
49
|
+
}
|
|
50
|
+
function nameFits(pattern, name) {
|
|
51
|
+
const at = pattern.indexOf('*');
|
|
52
|
+
if (at === -1)
|
|
53
|
+
return pattern === name;
|
|
54
|
+
const head = pattern.slice(0, at);
|
|
55
|
+
const tail = pattern.slice(at + 1);
|
|
56
|
+
return name.length > head.length + tail.length && name.startsWith(head) && name.endsWith(tail);
|
|
57
|
+
}
|
|
58
|
+
function typedPathOf(file, typedPaths = []) {
|
|
59
|
+
const names = file.split('/');
|
|
60
|
+
return typedPaths.find(({ path }) => {
|
|
61
|
+
const patterns = path.split('/');
|
|
62
|
+
return (patterns.length === names.length &&
|
|
63
|
+
patterns.every((pattern, at) => nameFits(pattern, names[at])));
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const HELD_TEXT = /\S/u;
|
|
67
|
+
function typedPathRefusal(file, document, typedPath) {
|
|
68
|
+
if (typedPath === undefined)
|
|
69
|
+
return null;
|
|
70
|
+
if (document.type !== (typedPath.named ? typedPath.type : undefined))
|
|
71
|
+
return refuse(file, 'unknown-type', { location: '/type' });
|
|
72
|
+
return typedPath.body && !HELD_TEXT.test(document.text) ? refuse(file, 'required-body') : null;
|
|
73
|
+
}
|
|
74
|
+
function kindOf(document, typedPath) {
|
|
75
|
+
return typedPath !== undefined && !typedPath.named ? typedPath.type : instanceType(document);
|
|
76
|
+
}
|
|
77
|
+
export function definitionAt(model, file, typedPaths) {
|
|
78
|
+
const typedPath = typedPathOf(file, typedPaths);
|
|
79
|
+
return (type) => definitionOf(typedPath !== undefined && !typedPath.named ? typedPath.type : (type ?? BUILT_IN_TYPE), model);
|
|
80
|
+
}
|
|
14
81
|
function instanceType(document) {
|
|
15
82
|
const raw = document.fields.type;
|
|
16
83
|
if (raw === undefined || raw === null)
|
|
@@ -37,156 +104,106 @@ function missing(reference, typeOf, binary) {
|
|
|
37
104
|
export function resolves(reference, typeOf, binary) {
|
|
38
105
|
return reaches(reference, typeOf, binary) && !missing(reference, typeOf, binary);
|
|
39
106
|
}
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const bodyStart = bodyStartOf(content);
|
|
46
|
-
held = linkInventory(content.slice(bodyStart)).uses.map((use) => ({
|
|
47
|
-
...use,
|
|
48
|
-
start: bodyStart + use.start,
|
|
49
|
-
end: bodyStart + use.end,
|
|
50
|
-
}));
|
|
51
|
-
return held;
|
|
107
|
+
function schemaRefused(failure) {
|
|
108
|
+
return {
|
|
109
|
+
verdict: 'refuse',
|
|
110
|
+
rule: failure.rule,
|
|
111
|
+
...(failure.location === undefined ? {} : { location: failure.location }),
|
|
52
112
|
};
|
|
53
113
|
}
|
|
54
|
-
function itemHrefs(content, items, uses) {
|
|
55
|
-
const hrefs = [];
|
|
56
|
-
for (const item of items) {
|
|
57
|
-
const link = uses().find((use) => use.start === item.start && use.end === item.end && content[item.start] === '[');
|
|
58
|
-
if (link === undefined)
|
|
59
|
-
return null;
|
|
60
|
-
hrefs.push(link.destination.href);
|
|
61
|
-
}
|
|
62
|
-
return hrefs;
|
|
63
|
-
}
|
|
64
114
|
export function verify(schema, provided) {
|
|
65
115
|
const read = readSchema(schema, provided);
|
|
116
|
+
if (!('types' in read))
|
|
117
|
+
return schemaRefused(read);
|
|
118
|
+
const failure = formFailure(read, provided) ?? indexedFailure(read);
|
|
119
|
+
return failure === undefined ? { verdict: 'accept', model: read } : schemaRefused(failure);
|
|
120
|
+
}
|
|
121
|
+
export function readTypes(schema, provided) {
|
|
122
|
+
const read = readSchema(schema, provided, false);
|
|
66
123
|
if ('types' in read)
|
|
67
|
-
return
|
|
68
|
-
|
|
69
|
-
verdict: 'refuse',
|
|
70
|
-
rule: read.rule,
|
|
71
|
-
...(read.location === undefined ? {} : { location: read.location }),
|
|
72
|
-
};
|
|
124
|
+
return read;
|
|
125
|
+
throw new Error(`the schema reads as no types: ${read.rule} ${read.location ?? ''}`.trim());
|
|
73
126
|
}
|
|
74
|
-
function structure(file,
|
|
127
|
+
function structure(file, document, definition) {
|
|
75
128
|
if (definition === undefined)
|
|
76
|
-
return
|
|
77
|
-
const fieldFailure =
|
|
78
|
-
if (fieldFailure !== undefined)
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
const spans = headingSpans(content, bodyStartOf(content));
|
|
82
|
-
const uses = usesIn(content);
|
|
83
|
-
const sections = [];
|
|
84
|
-
const conditioned = conditionedSections(definition, document.fields);
|
|
85
|
-
for (const [name, spec] of Object.entries(definition.sections)) {
|
|
86
|
-
const occurrences = spans.filter((one) => one.name === name);
|
|
87
|
-
if (occurrences.length === 0 && spec.required)
|
|
88
|
-
return { refusal: refuse(file, 'required-section', { location: name }) };
|
|
89
|
-
if (conditioned.includes(name) &&
|
|
90
|
-
occurrences.every((span) => content.slice(span.bodyStart, span.bodyEnd).trim() === ''))
|
|
91
|
-
return { refusal: refuse(file, 'conditional-section', { location: name }) };
|
|
92
|
-
if (spec.kind !== 'list')
|
|
93
|
-
continue;
|
|
94
|
-
for (const span of occurrences) {
|
|
95
|
-
const items = listItems(content, span.bodyStart, span.bodyEnd);
|
|
96
|
-
if (items === null ||
|
|
97
|
-
items.some((item) => !fitsItem(definition, name, content.slice(item.start, item.end))))
|
|
98
|
-
return { refusal: refuse(file, 'structured-section', { location: name }) };
|
|
99
|
-
if (spec.items.reference === undefined)
|
|
100
|
-
continue;
|
|
101
|
-
const hrefs = itemHrefs(content, items, uses);
|
|
102
|
-
if (hrefs === null)
|
|
103
|
-
return { refusal: refuse(file, 'structured-section', { location: name }) };
|
|
104
|
-
sections.push({
|
|
105
|
-
section: name,
|
|
106
|
-
to: spec.items.reference,
|
|
107
|
-
crossRoom: spec.items.crossRoom === true,
|
|
108
|
-
hrefs,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return { sections };
|
|
129
|
+
return refuse(file, 'unknown-type', { location: '/type' });
|
|
130
|
+
const fieldFailure = schemaRefusal(definition, document.fields);
|
|
131
|
+
if (fieldFailure !== undefined)
|
|
132
|
+
return placedRefusal(file, document, fieldFailure.rule, fieldFailure.location);
|
|
133
|
+
return unmarkedMember(file, document, definition);
|
|
113
134
|
}
|
|
114
|
-
function linked(file,
|
|
115
|
-
return
|
|
135
|
+
function linked(file, document) {
|
|
136
|
+
return linkDestinations(document).every((occurrence) => classifyHref(file, occurrence.href).kind !== 'invalid');
|
|
116
137
|
}
|
|
117
138
|
function reached(file, href, to) {
|
|
118
139
|
const resolved = classifyHref(file, href);
|
|
119
140
|
return { target: resolved.kind === 'path' ? resolved.path : null, to };
|
|
120
141
|
}
|
|
142
|
+
function referred(file, href, to) {
|
|
143
|
+
const reference = reached(file, href, to);
|
|
144
|
+
return reference.target !== null &&
|
|
145
|
+
isDocumentPath(file) &&
|
|
146
|
+
!isDocumentPath(reference.target) &&
|
|
147
|
+
!to.includes(ATTACHMENT)
|
|
148
|
+
? { target: null, to }
|
|
149
|
+
: reference;
|
|
150
|
+
}
|
|
121
151
|
function crossing(file, href, crossRoom) {
|
|
122
|
-
return crossRoom === true && classifyHref(file, href).kind === 'room';
|
|
152
|
+
return (keyedLink(href) !== null || (crossRoom === true && classifyHref(file, href).kind === 'room'));
|
|
123
153
|
}
|
|
124
|
-
function definitionOf(
|
|
125
|
-
const kind = instanceType(document);
|
|
154
|
+
function definitionOf(kind, model) {
|
|
126
155
|
return kind === null || !Object.hasOwn(model.types, kind) ? undefined : model.types[kind];
|
|
127
156
|
}
|
|
128
157
|
export function checkDocument(file, content, model, context = {}) {
|
|
129
158
|
const anyRoom = context.anyRoom === true;
|
|
130
|
-
const parsed = parse(content, file);
|
|
159
|
+
const parsed = parse(content, file, definitionAt(model, file, context.typedPaths));
|
|
131
160
|
if (!parsed.ok)
|
|
132
161
|
return { ok: false };
|
|
133
162
|
const document = parsed.document;
|
|
134
163
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
164
|
+
const typedPath = typedPathOf(file, context.typedPaths);
|
|
165
|
+
if (describedRoom(file, document) !== null ||
|
|
166
|
+
typedPathRefusal(file, document, typedPath) !== null ||
|
|
167
|
+
reservedLink(file, document))
|
|
168
|
+
return { ok: false };
|
|
169
|
+
const kind = kindOf(document, typedPath);
|
|
170
|
+
if (kind === BUILT_IN_TYPE)
|
|
171
|
+
return unmarkedMember(file, document, undefined) === null
|
|
172
|
+
? { ok: true, type, typed: false, references: [] }
|
|
173
|
+
: { ok: false };
|
|
174
|
+
const definition = definitionOf(kind, model);
|
|
175
|
+
if (structure(file, document, definition) !== null ||
|
|
176
|
+
definition === undefined ||
|
|
177
|
+
!linked(file, document))
|
|
140
178
|
return { ok: false };
|
|
141
179
|
return {
|
|
142
180
|
ok: true,
|
|
143
181
|
type,
|
|
144
182
|
typed: true,
|
|
145
|
-
references: [
|
|
146
|
-
...references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [reached(file, value, to)]),
|
|
147
|
-
...read.sections.flatMap(({ to, crossRoom, hrefs }) => hrefs.flatMap((href) => crossing(file, href, anyRoom || crossRoom) ? [] : [reached(file, href, to)])),
|
|
148
|
-
],
|
|
183
|
+
references: references(document, definition).flatMap(({ value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom) ? [] : [referred(file, value, to)]),
|
|
149
184
|
};
|
|
150
185
|
}
|
|
151
|
-
|
|
152
|
-
const referring = (name) => {
|
|
153
|
-
const spec = Object.hasOwn(definition.sections, name) ? definition.sections[name] : undefined;
|
|
154
|
-
return spec?.kind === 'list' && spec.items.reference !== undefined ? spec.items : undefined;
|
|
155
|
-
};
|
|
156
|
-
if (!Object.keys(definition.sections).some((name) => referring(name) !== undefined))
|
|
157
|
-
return [];
|
|
158
|
-
const uses = usesIn(content);
|
|
186
|
+
function roomLinks(occurrences) {
|
|
159
187
|
const found = [];
|
|
160
|
-
for (const
|
|
161
|
-
const
|
|
162
|
-
if (items === undefined)
|
|
163
|
-
continue;
|
|
164
|
-
const listed = listItems(content, span.bodyStart, span.bodyEnd);
|
|
165
|
-
const hrefs = listed === null ? null : itemHrefs(content, listed, uses);
|
|
166
|
-
for (const href of hrefs ?? [])
|
|
167
|
-
if (!crossing(file, href, items.crossRoom))
|
|
168
|
-
found.push(reached(file, href, items.reference));
|
|
169
|
-
}
|
|
170
|
-
return found;
|
|
171
|
-
}
|
|
172
|
-
export function bodyRoomLinks(body) {
|
|
173
|
-
const found = [];
|
|
174
|
-
for (const href of new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))) {
|
|
175
|
-
const room = roomTarget(href);
|
|
188
|
+
for (const href of new Set(occurrences.map((occurrence) => occurrence.href))) {
|
|
189
|
+
const room = keyedLink(href) === null ? roomTarget(href) : null;
|
|
176
190
|
if (room !== null)
|
|
177
191
|
found.push({ kind: 'link', href, ...room });
|
|
178
192
|
}
|
|
179
193
|
return found;
|
|
180
194
|
}
|
|
181
|
-
export function
|
|
182
|
-
|
|
195
|
+
export function bodyRoomLinks(body) {
|
|
196
|
+
return roomLinks(hrefOccurrences(body));
|
|
197
|
+
}
|
|
198
|
+
export function bodyKeyedLinks(body) {
|
|
199
|
+
return [...new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))].flatMap((href) => keyedLink(href) ?? []);
|
|
200
|
+
}
|
|
201
|
+
export function roomReferences(document, definition) {
|
|
202
|
+
const found = roomLinks(linkDestinations(document));
|
|
183
203
|
if (definition === undefined)
|
|
184
204
|
return found;
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
return found;
|
|
188
|
-
for (const { pointer, value, to, crossRoom } of references(parsed.document, definition)) {
|
|
189
|
-
const room = roomTarget(value);
|
|
205
|
+
for (const { pointer, value, to, crossRoom } of references(document, definition)) {
|
|
206
|
+
const room = keyedLink(value) === null ? roomTarget(value) : null;
|
|
190
207
|
if (room !== null)
|
|
191
208
|
found.push({
|
|
192
209
|
kind: 'field',
|
|
@@ -197,48 +214,42 @@ export function roomReferences(file, content, definition) {
|
|
|
197
214
|
...(crossRoom ? { crossRoom } : {}),
|
|
198
215
|
});
|
|
199
216
|
}
|
|
200
|
-
const uses = usesIn(content);
|
|
201
|
-
for (const span of headingSpans(content, bodyStartOf(content))) {
|
|
202
|
-
const spec = Object.hasOwn(definition.sections, span.name)
|
|
203
|
-
? definition.sections[span.name]
|
|
204
|
-
: undefined;
|
|
205
|
-
if (spec?.kind !== 'list' || spec.items.reference === undefined)
|
|
206
|
-
continue;
|
|
207
|
-
const listed = listItems(content, span.bodyStart, span.bodyEnd);
|
|
208
|
-
for (const href of (listed === null ? null : itemHrefs(content, listed, uses)) ?? []) {
|
|
209
|
-
const room = roomTarget(href);
|
|
210
|
-
if (room !== null)
|
|
211
|
-
found.push({
|
|
212
|
-
kind: 'item',
|
|
213
|
-
section: span.name,
|
|
214
|
-
href,
|
|
215
|
-
to: spec.items.reference,
|
|
216
|
-
...room,
|
|
217
|
-
...(spec.items.crossRoom === true ? { crossRoom: true } : {}),
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
217
|
return found;
|
|
222
218
|
}
|
|
223
219
|
function least(refused, file, verdict) {
|
|
224
220
|
return refused === undefined || file < refused.file ? { file, verdict } : refused;
|
|
225
221
|
}
|
|
226
|
-
|
|
227
|
-
const
|
|
222
|
+
function placedAt(document, reference, location) {
|
|
223
|
+
const line = lineAt(document, location);
|
|
224
|
+
return line === undefined ? { reference, location } : { reference, location, line };
|
|
225
|
+
}
|
|
226
|
+
export function assess(file, parsed, binary, model = { types: {} }, context = {}) {
|
|
227
|
+
const unread = { file, type: undefined, targets: [], structured: null, fields: [] };
|
|
228
228
|
if (binary)
|
|
229
229
|
return { ...unread, read: refuse(file, 'binary-target-document'), linked: true };
|
|
230
|
-
const parsed = parse(content, file);
|
|
231
230
|
if (!parsed.ok)
|
|
232
231
|
return { ...unread, read: { verdict: 'refuse', ...parsed.refusal }, linked: true };
|
|
233
232
|
const document = parsed.document;
|
|
234
233
|
const type = document.type ?? BUILT_IN_TYPE;
|
|
235
234
|
const typed = { file, type, read: null, structured: null };
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
const typedPath = typedPathOf(file, context.typedPaths);
|
|
236
|
+
const described = describedRoom(file, document) ?? typedPathRefusal(file, document, typedPath);
|
|
237
|
+
if (described !== null)
|
|
238
|
+
return { ...typed, targets: [], structured: described, fields: [], linked: true };
|
|
239
|
+
const kind = kindOf(document, typedPath);
|
|
240
|
+
if (kind === BUILT_IN_TYPE) {
|
|
241
|
+
const structured = unmarkedMember(file, document, undefined);
|
|
242
|
+
return {
|
|
243
|
+
...typed,
|
|
244
|
+
targets: [],
|
|
245
|
+
structured,
|
|
246
|
+
fields: [],
|
|
247
|
+
linked: !reservedLink(file, document),
|
|
248
|
+
};
|
|
238
249
|
}
|
|
239
|
-
const definition = definitionOf(
|
|
250
|
+
const definition = definitionOf(kind, model);
|
|
240
251
|
try {
|
|
241
|
-
return structured(file,
|
|
252
|
+
return structured(file, typed, document, definition, context);
|
|
242
253
|
}
|
|
243
254
|
catch (error) {
|
|
244
255
|
if (!(error instanceof PatternTooCostly))
|
|
@@ -249,42 +260,70 @@ export function assess(file, content, binary, model = { types: {} }, context = {
|
|
|
249
260
|
structured: refuse(file, 'pattern', { location: '' }),
|
|
250
261
|
fields: [],
|
|
251
262
|
linked: true,
|
|
252
|
-
sections: [],
|
|
253
263
|
};
|
|
254
264
|
}
|
|
255
265
|
}
|
|
256
|
-
function structured(file,
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
259
|
-
return {
|
|
260
|
-
...typed,
|
|
261
|
-
targets: [],
|
|
262
|
-
structured: 'refusal' in read ? read.refusal : null,
|
|
263
|
-
fields: [],
|
|
264
|
-
linked: true,
|
|
265
|
-
sections: [],
|
|
266
|
-
};
|
|
266
|
+
function structured(file, typed, document, definition, context) {
|
|
267
|
+
const refused = structure(file, document, definition);
|
|
268
|
+
if (refused !== null || definition === undefined) {
|
|
269
|
+
return { ...typed, targets: [], structured: refused, fields: [], linked: true };
|
|
267
270
|
}
|
|
268
271
|
const anyRoom = context.anyRoom === true;
|
|
269
272
|
const fields = references(document, definition).flatMap(({ pointer, value, to, crossRoom }) => crossing(file, value, anyRoom || crossRoom)
|
|
270
273
|
? []
|
|
271
|
-
: [
|
|
272
|
-
const
|
|
274
|
+
: [placedAt(document, referred(file, value, to), pointer)]);
|
|
275
|
+
const targets = new Set();
|
|
276
|
+
for (const { reference } of fields) {
|
|
277
|
+
if (reference.target !== null)
|
|
278
|
+
targets.add(reference.target);
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
...typed,
|
|
282
|
+
targets: [...targets],
|
|
283
|
+
fields,
|
|
284
|
+
linked: linked(file, document) && !reservedLink(file, document),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
export function assessReferences(file, parsed, changed, model = { types: {} }, context = {}) {
|
|
288
|
+
const unread = {
|
|
289
|
+
file,
|
|
290
|
+
type: undefined,
|
|
291
|
+
targets: [],
|
|
292
|
+
read: null,
|
|
293
|
+
structured: null,
|
|
294
|
+
fields: [],
|
|
295
|
+
linked: true,
|
|
296
|
+
};
|
|
297
|
+
if (!parsed.ok)
|
|
298
|
+
return unread;
|
|
299
|
+
const { document } = parsed;
|
|
300
|
+
const definition = definitionOf(kindOf(document, typedPathOf(file, context.typedPaths)), model);
|
|
301
|
+
const fields = definition === undefined
|
|
273
302
|
? []
|
|
274
|
-
:
|
|
303
|
+
: references(document, definition).flatMap(({ pointer, value, to }) => {
|
|
304
|
+
const resolved = classifyHref(file, value);
|
|
305
|
+
return resolved.kind === 'path' && changed.has(resolved.path)
|
|
306
|
+
? [placedAt(document, referred(file, value, to), pointer)]
|
|
307
|
+
: [];
|
|
308
|
+
});
|
|
275
309
|
const targets = new Set();
|
|
276
|
-
for (const { reference } of
|
|
310
|
+
for (const { reference } of fields) {
|
|
277
311
|
if (reference.target !== null)
|
|
278
312
|
targets.add(reference.target);
|
|
279
313
|
}
|
|
280
|
-
return {
|
|
314
|
+
return {
|
|
315
|
+
...unread,
|
|
316
|
+
type: document.type ?? BUILT_IN_TYPE,
|
|
317
|
+
targets: [...targets],
|
|
318
|
+
fields,
|
|
319
|
+
linked: !reservedLink(file, document, changed),
|
|
320
|
+
};
|
|
281
321
|
}
|
|
282
322
|
export function verdicts() {
|
|
283
323
|
let read;
|
|
284
324
|
let structured;
|
|
285
325
|
let referred;
|
|
286
326
|
let missed;
|
|
287
|
-
const unreached = (placed, typeOf, binary) => placed.find(({ reference }) => !reaches(reference, typeOf, binary));
|
|
288
327
|
return {
|
|
289
328
|
add(assessment, typeOf, binary) {
|
|
290
329
|
const { file } = assessment;
|
|
@@ -296,22 +335,19 @@ export function verdicts() {
|
|
|
296
335
|
structured = least(structured, file, assessment.structured);
|
|
297
336
|
return 0;
|
|
298
337
|
}
|
|
299
|
-
const field =
|
|
338
|
+
const field = assessment.fields.find(({ reference }) => !reaches(reference, typeOf, binary));
|
|
300
339
|
if (field !== undefined) {
|
|
301
|
-
referred = least(referred, file, refuse(file, 'unresolved-reference', {
|
|
340
|
+
referred = least(referred, file, refuse(file, 'unresolved-reference', {
|
|
341
|
+
location: field.location,
|
|
342
|
+
...(field.line === undefined ? {} : { line: field.line }),
|
|
343
|
+
}));
|
|
302
344
|
return 0;
|
|
303
345
|
}
|
|
304
346
|
if (!assessment.linked) {
|
|
305
347
|
referred = least(referred, file, refuse(file, 'unresolved-link'));
|
|
306
348
|
return 0;
|
|
307
349
|
}
|
|
308
|
-
const
|
|
309
|
-
if (section !== undefined) {
|
|
310
|
-
referred = least(referred, file, refuse(file, 'unresolved-reference', { location: section.location }));
|
|
311
|
-
return 0;
|
|
312
|
-
}
|
|
313
|
-
const all = [...assessment.fields, ...assessment.sections];
|
|
314
|
-
for (const { reference } of all) {
|
|
350
|
+
for (const { reference } of assessment.fields) {
|
|
315
351
|
if (!missing(reference, typeOf, binary))
|
|
316
352
|
continue;
|
|
317
353
|
const path = reference.target;
|
|
@@ -320,7 +356,7 @@ export function verdicts() {
|
|
|
320
356
|
if (path === missed.path && missed.referrers.at(-1) !== file)
|
|
321
357
|
missed.referrers.push(file);
|
|
322
358
|
}
|
|
323
|
-
return
|
|
359
|
+
return assessment.fields.length;
|
|
324
360
|
},
|
|
325
361
|
verdict() {
|
|
326
362
|
const refused = read ?? structured ?? referred;
|
|
@@ -335,15 +371,22 @@ export function verdicts() {
|
|
|
335
371
|
},
|
|
336
372
|
};
|
|
337
373
|
}
|
|
374
|
+
function* read(library, context, model) {
|
|
375
|
+
for (const [file, content] of library)
|
|
376
|
+
yield [file, parse(content, file, definitionAt(model, file, context.typedPaths))];
|
|
377
|
+
}
|
|
338
378
|
export function* validating(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
379
|
+
return yield* judging(read(library, context, model), context, model);
|
|
380
|
+
}
|
|
381
|
+
function* judging(library, context, model) {
|
|
339
382
|
const binaryTargets = new Set(context.binaryTargets);
|
|
340
383
|
const binary = (path) => binaryTargets.has(path);
|
|
341
384
|
const types = new Map();
|
|
342
385
|
const assessments = [];
|
|
343
386
|
const closeBudget = openPatternBudget();
|
|
344
387
|
try {
|
|
345
|
-
for (const [file,
|
|
346
|
-
const assessment = assess(file,
|
|
388
|
+
for (const [file, parsed] of library) {
|
|
389
|
+
const assessment = assess(file, parsed, binary(file), model, context);
|
|
347
390
|
if (assessment.type !== undefined)
|
|
348
391
|
types.set(file, assessment.type);
|
|
349
392
|
assessments.push(assessment);
|
|
@@ -360,10 +403,15 @@ export function* validating(library, context = { binaryTargets: [] }, model = {
|
|
|
360
403
|
closeBudget();
|
|
361
404
|
}
|
|
362
405
|
}
|
|
363
|
-
|
|
364
|
-
const steps = validating(new Map(Object.entries(library)), context, model);
|
|
406
|
+
function finished(steps) {
|
|
365
407
|
let step = steps.next();
|
|
366
408
|
while (step.done !== true)
|
|
367
409
|
step = steps.next();
|
|
368
410
|
return step.value;
|
|
369
411
|
}
|
|
412
|
+
export function validate(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
413
|
+
return finished(validating(new Map(Object.entries(library)), context, model));
|
|
414
|
+
}
|
|
415
|
+
export function validateParsed(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
416
|
+
return finished(judging(library, context, model));
|
|
417
|
+
}
|
package/dist/yaml.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export type YamlConstruct = 'tab' | 'multi-line-scalar' | 'escape' | 'unheld-character' | 'block-scalar-header' | 'block-scalar-in-flow' | 'flow-collection' | 'mapping-entry' | 'duplicate-key' | 'indentation' | 'nesting';
|
|
1
2
|
export declare class YamlError extends Error {
|
|
2
3
|
readonly offset: number;
|
|
3
|
-
|
|
4
|
+
readonly construct: YamlConstruct;
|
|
5
|
+
constructor(offset: number, construct: YamlConstruct);
|
|
4
6
|
}
|
|
5
7
|
export type YamlScalar = {
|
|
6
8
|
readonly kind: 'scalar';
|
|
@@ -31,12 +33,12 @@ export declare function parseYamlMapping(text: string, start: number, end: numbe
|
|
|
31
33
|
export declare function jsValue(node: YamlNode): unknown;
|
|
32
34
|
export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
|
|
33
35
|
export declare function isPlainSafe(text: string): boolean;
|
|
34
|
-
export type
|
|
35
|
-
readonly [name: string]:
|
|
36
|
+
export type DocumentValue = string | number | boolean | null | readonly DocumentValue[] | {
|
|
37
|
+
readonly [name: string]: DocumentValue;
|
|
36
38
|
};
|
|
37
39
|
export declare function plain(value: unknown): value is Record<string, unknown>;
|
|
38
|
-
export declare function
|
|
39
|
-
export declare function serializeJs(value:
|
|
40
|
+
export declare function documentValue(value: unknown): value is DocumentValue;
|
|
41
|
+
export declare function serializeJs(value: DocumentValue): string;
|
|
40
42
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
41
43
|
export declare function serializeKey(name: string): string;
|
|
42
44
|
export declare function bodyStartAfterYaml(content: string, yamlEnd: number): number;
|
package/dist/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"yaml.d.ts","sourceRoot":"","sources":["../src/yaml.ts"],"names":[],"mappings":"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"}
|