@agentshouse/mdmodel 0.1.0-ccf1367190878 → 0.1.0-cd1d3e3874c43
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 +283 -276
- package/README.md +28 -29
- 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 +26 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +233 -89
- package/dist/document.d.ts +16 -9
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1000 -254
- 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 +45 -16
- 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 +25 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +129 -18
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +356 -0
- 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 +129 -0
- package/dist/query/rows.d.ts +36 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +179 -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 +69 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +274 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +7 -2
- 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 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +10 -23
- package/dist/types.d.ts +42 -34
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +34 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +349 -152
- package/dist/yaml.d.ts +7 -5
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +190 -43
- package/fixtures/README.md +93 -65
- 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-long-text/expected.json +7 -0
- package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/expected.json +1 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
- package/fixtures/cases/cross-room-link/schema.yaml +3 -0
- package/fixtures/cases/cross-room-reference/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.yaml +8 -0
- 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/context.json +1 -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/context.json +1 -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/context.json +1 -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 +16 -2
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -76
- package/dist/condition.d.ts +0 -149
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -500
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -310
- package/dist/links.d.ts +0 -27
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -774
- 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 -21
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -105
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- 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/{missing-section-item-kind → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{section-items → block-scalar-frontmatter}/expected.json +0 -0
- /package/fixtures/cases/{null-refused → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → cross-room-link}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → cross-room-reference}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{section-items → frontmatter-construct}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{structured-section → link-into-a-reserved-name-from-an-untyped-document}/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/yaml.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
export class YamlError extends Error {
|
|
2
2
|
offset;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
construct;
|
|
4
|
+
constructor(offset, construct) {
|
|
5
|
+
super();
|
|
5
6
|
this.offset = offset;
|
|
7
|
+
this.construct = construct;
|
|
6
8
|
this.name = 'YamlError';
|
|
7
9
|
}
|
|
8
10
|
}
|
|
11
|
+
const YAML_DEPTH_MAX = 64;
|
|
12
|
+
function nested(c, parse) {
|
|
13
|
+
if (c.depth >= YAML_DEPTH_MAX)
|
|
14
|
+
throw new YamlError(c.i, 'nesting');
|
|
15
|
+
c.depth += 1;
|
|
16
|
+
try {
|
|
17
|
+
return parse();
|
|
18
|
+
}
|
|
19
|
+
finally {
|
|
20
|
+
c.depth -= 1;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
9
23
|
function peek(c) {
|
|
10
24
|
return c.i < c.end ? c.text[c.i] : '';
|
|
11
25
|
}
|
|
@@ -19,7 +33,7 @@ function skipSpaces(c) {
|
|
|
19
33
|
while (peek(c) === ' ')
|
|
20
34
|
c.i += 1;
|
|
21
35
|
if (peek(c) === '\t')
|
|
22
|
-
throw new YamlError(c.i);
|
|
36
|
+
throw new YamlError(c.i, 'tab');
|
|
23
37
|
}
|
|
24
38
|
function skipToEol(c) {
|
|
25
39
|
while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
@@ -49,7 +63,7 @@ function skipFlowSpace(c) {
|
|
|
49
63
|
continue;
|
|
50
64
|
}
|
|
51
65
|
if (ch === '\t')
|
|
52
|
-
throw new YamlError(c.i);
|
|
66
|
+
throw new YamlError(c.i, 'tab');
|
|
53
67
|
break;
|
|
54
68
|
}
|
|
55
69
|
}
|
|
@@ -63,14 +77,17 @@ function indentAt(c) {
|
|
|
63
77
|
if (ch === ' ')
|
|
64
78
|
n += 1;
|
|
65
79
|
else if (ch === '\t')
|
|
66
|
-
throw new YamlError(j);
|
|
80
|
+
throw new YamlError(j, 'tab');
|
|
67
81
|
else
|
|
68
82
|
break;
|
|
69
83
|
j += 1;
|
|
70
84
|
}
|
|
71
85
|
return n;
|
|
72
86
|
}
|
|
87
|
+
const UNHELD_TEXT = /[\0\ud800-\udfff]/u;
|
|
73
88
|
function scalar(value, start, end) {
|
|
89
|
+
if (typeof value === 'string' && UNHELD_TEXT.test(value))
|
|
90
|
+
throw new YamlError(start, 'unheld-character');
|
|
74
91
|
return { kind: 'scalar', value, start, end };
|
|
75
92
|
}
|
|
76
93
|
export function interpretPlain(text) {
|
|
@@ -104,7 +121,7 @@ function parseEscape(c) {
|
|
|
104
121
|
}
|
|
105
122
|
const hex = c.text.slice(c.i + 1, c.i + 5);
|
|
106
123
|
if (escaped !== 'u' || c.i + 5 > c.end || !/^[0-9A-Fa-f]{4}$/.test(hex))
|
|
107
|
-
throw new YamlError(c.i);
|
|
124
|
+
throw new YamlError(c.i, 'escape');
|
|
108
125
|
c.i += 5;
|
|
109
126
|
return String.fromCharCode(Number.parseInt(hex, 16));
|
|
110
127
|
}
|
|
@@ -125,7 +142,7 @@ function parseQuoted(c) {
|
|
|
125
142
|
return scalar(out, start, c.i);
|
|
126
143
|
}
|
|
127
144
|
if (ch === '\n' || ch === '\r')
|
|
128
|
-
throw new YamlError(c.i);
|
|
145
|
+
throw new YamlError(c.i, 'multi-line-scalar');
|
|
129
146
|
if (quote === '"' && ch === '\\') {
|
|
130
147
|
out += parseEscape(c);
|
|
131
148
|
continue;
|
|
@@ -133,7 +150,7 @@ function parseQuoted(c) {
|
|
|
133
150
|
out += ch;
|
|
134
151
|
c.i += 1;
|
|
135
152
|
}
|
|
136
|
-
throw new YamlError(c.i);
|
|
153
|
+
throw new YamlError(c.i, 'multi-line-scalar');
|
|
137
154
|
}
|
|
138
155
|
function parsePlain(c, flow) {
|
|
139
156
|
const start = c.i;
|
|
@@ -148,7 +165,7 @@ function parsePlain(c, flow) {
|
|
|
148
165
|
c.i += 1;
|
|
149
166
|
}
|
|
150
167
|
if (c.i === start)
|
|
151
|
-
throw new YamlError(c.i);
|
|
168
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
152
169
|
const raw = c.text.slice(start, c.i);
|
|
153
170
|
const trimmed = raw.trimEnd();
|
|
154
171
|
return scalar(interpretPlain(trimmed), start, start + trimmed.length);
|
|
@@ -159,12 +176,12 @@ function parseScalar(c, flow) {
|
|
|
159
176
|
return parseQuoted(c);
|
|
160
177
|
return parsePlain(c, flow);
|
|
161
178
|
}
|
|
162
|
-
function parseKey(c) {
|
|
179
|
+
function parseKey(c, refused) {
|
|
163
180
|
const start = c.i;
|
|
164
181
|
if (peek(c) === '"' || peek(c) === "'") {
|
|
165
182
|
const quoted = parseQuoted(c);
|
|
166
183
|
if (typeof quoted.value !== 'string')
|
|
167
|
-
throw new YamlError(start);
|
|
184
|
+
throw new YamlError(start, refused);
|
|
168
185
|
return { name: quoted.value, start, end: c.i };
|
|
169
186
|
}
|
|
170
187
|
let end = c.i;
|
|
@@ -186,7 +203,7 @@ function parseKey(c) {
|
|
|
186
203
|
end = c.i;
|
|
187
204
|
}
|
|
188
205
|
if (end === start)
|
|
189
|
-
throw new YamlError(c.i);
|
|
206
|
+
throw new YamlError(c.i, refused);
|
|
190
207
|
c.i = end;
|
|
191
208
|
return { name: c.text.slice(start, end), start, end };
|
|
192
209
|
}
|
|
@@ -198,13 +215,25 @@ function parseFlowValue(c) {
|
|
|
198
215
|
if (ch === '[')
|
|
199
216
|
return parseFlowSeq(c);
|
|
200
217
|
if (ch === '|' || ch === '>')
|
|
201
|
-
throw new YamlError(c.i);
|
|
218
|
+
throw new YamlError(c.i, 'block-scalar-in-flow');
|
|
202
219
|
return parseScalar(c, true);
|
|
203
220
|
}
|
|
221
|
+
function closed(c, parse) {
|
|
222
|
+
const start = c.i;
|
|
223
|
+
try {
|
|
224
|
+
return parse();
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
if (error instanceof YamlError && error.offset >= c.end)
|
|
228
|
+
throw new YamlError(start, 'flow-collection');
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
204
232
|
function parseFlowMap(c) {
|
|
233
|
+
return nested(c, () => closed(c, () => flowMap(c)));
|
|
234
|
+
}
|
|
235
|
+
function flowMap(c) {
|
|
205
236
|
const start = c.i;
|
|
206
|
-
if (peek(c) !== '{')
|
|
207
|
-
throw new YamlError(c.i);
|
|
208
237
|
c.i += 1;
|
|
209
238
|
skipFlowSpace(c);
|
|
210
239
|
const entries = [];
|
|
@@ -215,15 +244,15 @@ function parseFlowMap(c) {
|
|
|
215
244
|
}
|
|
216
245
|
while (c.i < c.end) {
|
|
217
246
|
skipFlowSpace(c);
|
|
218
|
-
const key = parseKey(c);
|
|
247
|
+
const key = parseKey(c, 'flow-collection');
|
|
219
248
|
skipFlowSpace(c);
|
|
220
249
|
if (peek(c) !== ':')
|
|
221
|
-
throw new YamlError(c.i);
|
|
250
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
222
251
|
c.i += 1;
|
|
223
252
|
const after = c.i;
|
|
224
253
|
const value = parseFlowValue(c);
|
|
225
254
|
if (seen.has(key.name))
|
|
226
|
-
throw new YamlError(key.start);
|
|
255
|
+
throw new YamlError(key.start, 'duplicate-key');
|
|
227
256
|
seen.add(key.name);
|
|
228
257
|
entries.push({ key: key.name, after, value });
|
|
229
258
|
skipFlowSpace(c);
|
|
@@ -235,14 +264,15 @@ function parseFlowMap(c) {
|
|
|
235
264
|
c.i += 1;
|
|
236
265
|
return { kind: 'map', entries, start, end: c.i };
|
|
237
266
|
}
|
|
238
|
-
throw new YamlError(c.i);
|
|
267
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
239
268
|
}
|
|
240
|
-
throw new YamlError(c.i);
|
|
269
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
241
270
|
}
|
|
242
271
|
function parseFlowSeq(c) {
|
|
272
|
+
return nested(c, () => closed(c, () => flowSeq(c)));
|
|
273
|
+
}
|
|
274
|
+
function flowSeq(c) {
|
|
243
275
|
const start = c.i;
|
|
244
|
-
if (peek(c) !== '[')
|
|
245
|
-
throw new YamlError(c.i);
|
|
246
276
|
c.i += 1;
|
|
247
277
|
skipFlowSpace(c);
|
|
248
278
|
const items = [];
|
|
@@ -262,9 +292,9 @@ function parseFlowSeq(c) {
|
|
|
262
292
|
c.i += 1;
|
|
263
293
|
return { kind: 'seq', items, start, end: c.i };
|
|
264
294
|
}
|
|
265
|
-
throw new YamlError(c.i);
|
|
295
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
266
296
|
}
|
|
267
|
-
throw new YamlError(c.i);
|
|
297
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
268
298
|
}
|
|
269
299
|
function parseValue(c, parentKeyIndent) {
|
|
270
300
|
const at = c.i;
|
|
@@ -288,6 +318,8 @@ function parseValue(c, parentKeyIndent) {
|
|
|
288
318
|
return parseFlowSeq(c);
|
|
289
319
|
if (peek(c) === '{')
|
|
290
320
|
return parseFlowMap(c);
|
|
321
|
+
if (peek(c) === '|' || peek(c) === '>')
|
|
322
|
+
return parseBlockScalar(c, parentKeyIndent);
|
|
291
323
|
return parseBlockMap(c, nextIndent);
|
|
292
324
|
}
|
|
293
325
|
if (ch === '{')
|
|
@@ -295,9 +327,106 @@ function parseValue(c, parentKeyIndent) {
|
|
|
295
327
|
if (ch === '[')
|
|
296
328
|
return parseFlowSeq(c);
|
|
297
329
|
if (ch === '|' || ch === '>')
|
|
298
|
-
|
|
330
|
+
return parseBlockScalar(c, parentKeyIndent);
|
|
299
331
|
return parseScalar(c, false);
|
|
300
332
|
}
|
|
333
|
+
function scalarLine(c, start) {
|
|
334
|
+
let at = start;
|
|
335
|
+
while (at < c.end && c.text[at] === ' ')
|
|
336
|
+
at += 1;
|
|
337
|
+
const indent = at - start;
|
|
338
|
+
while (at < c.end && c.text[at] !== '\n' && c.text[at] !== '\r')
|
|
339
|
+
at += 1;
|
|
340
|
+
let next = at;
|
|
341
|
+
if (next < c.end && c.text[next] === '\r')
|
|
342
|
+
next += 1;
|
|
343
|
+
if (next < c.end && c.text[next] === '\n')
|
|
344
|
+
next += 1;
|
|
345
|
+
return { start, indent, end: at, next };
|
|
346
|
+
}
|
|
347
|
+
function blank(line) {
|
|
348
|
+
return line.start + line.indent === line.end;
|
|
349
|
+
}
|
|
350
|
+
function folded(texts) {
|
|
351
|
+
let out = '';
|
|
352
|
+
let previous = null;
|
|
353
|
+
let empty = 0;
|
|
354
|
+
for (const text of texts) {
|
|
355
|
+
if (text === null) {
|
|
356
|
+
empty += 1;
|
|
357
|
+
continue;
|
|
358
|
+
}
|
|
359
|
+
const spaced = text.startsWith(' ') || text.startsWith('\t');
|
|
360
|
+
if (previous === null)
|
|
361
|
+
out += '\n'.repeat(empty);
|
|
362
|
+
else if (previous === 'text' && !spaced)
|
|
363
|
+
out += empty === 0 ? ' ' : '\n'.repeat(empty);
|
|
364
|
+
else
|
|
365
|
+
out += '\n'.repeat(empty + 1);
|
|
366
|
+
out += text;
|
|
367
|
+
previous = spaced ? 'spaced' : 'text';
|
|
368
|
+
empty = 0;
|
|
369
|
+
}
|
|
370
|
+
return out;
|
|
371
|
+
}
|
|
372
|
+
function parseBlockScalar(c, parentIndent) {
|
|
373
|
+
const start = c.i;
|
|
374
|
+
const fold = peek(c) === '>';
|
|
375
|
+
c.i += 1;
|
|
376
|
+
let chomping = '';
|
|
377
|
+
let explicit = 0;
|
|
378
|
+
for (;;) {
|
|
379
|
+
const ch = peek(c);
|
|
380
|
+
if (chomping === '' && (ch === '-' || ch === '+'))
|
|
381
|
+
chomping = ch;
|
|
382
|
+
else if (explicit === 0 && ch >= '1' && ch <= '9')
|
|
383
|
+
explicit = Number(ch);
|
|
384
|
+
else
|
|
385
|
+
break;
|
|
386
|
+
c.i += 1;
|
|
387
|
+
}
|
|
388
|
+
const header = c.i;
|
|
389
|
+
if (peek(c) === ' ' || peek(c) === '\t') {
|
|
390
|
+
skipSpaces(c);
|
|
391
|
+
if (peek(c) === '#')
|
|
392
|
+
skipToEol(c);
|
|
393
|
+
}
|
|
394
|
+
if (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
395
|
+
throw new YamlError(c.i, 'block-scalar-header');
|
|
396
|
+
skipEol(c);
|
|
397
|
+
const lines = [];
|
|
398
|
+
let indent = explicit === 0 ? null : parentIndent + explicit;
|
|
399
|
+
let leading = 0;
|
|
400
|
+
while (c.i < c.end) {
|
|
401
|
+
const line = scalarLine(c, c.i);
|
|
402
|
+
if (indent === null && blank(line))
|
|
403
|
+
leading = Math.max(leading, line.indent);
|
|
404
|
+
else if (indent === null) {
|
|
405
|
+
if (line.indent <= parentIndent)
|
|
406
|
+
break;
|
|
407
|
+
if (leading > line.indent)
|
|
408
|
+
throw new YamlError(line.start + line.indent, 'indentation');
|
|
409
|
+
indent = line.indent;
|
|
410
|
+
}
|
|
411
|
+
if (indent !== null && !blank(line) && line.indent < indent)
|
|
412
|
+
break;
|
|
413
|
+
lines.push(line);
|
|
414
|
+
c.i = line.next;
|
|
415
|
+
}
|
|
416
|
+
const texts = lines.map((line) => indent === null || (blank(line) && line.indent <= indent)
|
|
417
|
+
? null
|
|
418
|
+
: c.text.slice(line.start + indent, line.end));
|
|
419
|
+
let last = texts.length - 1;
|
|
420
|
+
while (last >= 0 && texts[last] === null)
|
|
421
|
+
last -= 1;
|
|
422
|
+
const content = texts.slice(0, last + 1);
|
|
423
|
+
const body = fold ? folded(content) : content.map((text) => text ?? '').join('\n');
|
|
424
|
+
const broken = (line) => line.next > line.end;
|
|
425
|
+
const final = last >= 0 && broken(lines[last]) ? '\n' : '';
|
|
426
|
+
const kept = '\n'.repeat(lines.slice(last + 1).filter(broken).length);
|
|
427
|
+
const value = chomping === '-' ? body : chomping === '+' ? body + final + kept : body + final;
|
|
428
|
+
return scalar(value, start, last >= 0 ? lines[last].end : header);
|
|
429
|
+
}
|
|
301
430
|
function seqAhead(c) {
|
|
302
431
|
const next = c.text[c.i + 1];
|
|
303
432
|
return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
|
|
@@ -307,22 +436,27 @@ function mappingAhead(c) {
|
|
|
307
436
|
try {
|
|
308
437
|
if (peek(c) === '{' || peek(c) === '[')
|
|
309
438
|
return false;
|
|
310
|
-
parseKey(c);
|
|
439
|
+
parseKey(c, 'mapping-entry');
|
|
311
440
|
skipSpaces(c);
|
|
312
441
|
if (peek(c) !== ':')
|
|
313
442
|
return false;
|
|
314
443
|
const next = c.text[c.i + 1];
|
|
315
444
|
return next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end;
|
|
316
445
|
}
|
|
317
|
-
catch
|
|
318
|
-
|
|
319
|
-
return false;
|
|
320
|
-
throw error;
|
|
446
|
+
catch {
|
|
447
|
+
return false;
|
|
321
448
|
}
|
|
322
449
|
finally {
|
|
323
450
|
c.i = start;
|
|
324
451
|
}
|
|
325
452
|
}
|
|
453
|
+
function plainScalar(c, node) {
|
|
454
|
+
return node?.kind === 'scalar' && node.end > node.start && !`"'|>`.includes(c.text[node.start]);
|
|
455
|
+
}
|
|
456
|
+
function deeperLine(c, held) {
|
|
457
|
+
const continued = plainScalar(c, held) && !mappingAhead(c);
|
|
458
|
+
return new YamlError(c.i, continued ? 'multi-line-scalar' : 'indentation');
|
|
459
|
+
}
|
|
326
460
|
function lineStartOf(c) {
|
|
327
461
|
let j = c.i;
|
|
328
462
|
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
@@ -336,6 +470,9 @@ function parseSeqItem(c, indent) {
|
|
|
336
470
|
return parseValue(c, indent);
|
|
337
471
|
}
|
|
338
472
|
function parseBlockSeq(c, indent) {
|
|
473
|
+
return nested(c, () => blockSeq(c, indent));
|
|
474
|
+
}
|
|
475
|
+
function blockSeq(c, indent) {
|
|
339
476
|
const start = c.i;
|
|
340
477
|
const items = [];
|
|
341
478
|
let end = start;
|
|
@@ -343,7 +480,9 @@ function parseBlockSeq(c, indent) {
|
|
|
343
480
|
skipBlankAndComments(c);
|
|
344
481
|
if (c.i >= c.end)
|
|
345
482
|
break;
|
|
346
|
-
if (indentAt(c)
|
|
483
|
+
if (indentAt(c) > indent)
|
|
484
|
+
throw deeperLine(c, items[items.length - 1]);
|
|
485
|
+
if (indentAt(c) < indent)
|
|
347
486
|
break;
|
|
348
487
|
if (peek(c) !== '-')
|
|
349
488
|
break;
|
|
@@ -355,6 +494,9 @@ function parseBlockSeq(c, indent) {
|
|
|
355
494
|
return { kind: 'seq', items, start, end };
|
|
356
495
|
}
|
|
357
496
|
function parseBlockMap(c, indent, inline = false) {
|
|
497
|
+
return nested(c, () => blockMap(c, indent, inline));
|
|
498
|
+
}
|
|
499
|
+
function blockMap(c, indent, inline) {
|
|
358
500
|
const start = c.i;
|
|
359
501
|
const entries = [];
|
|
360
502
|
const seen = new Set();
|
|
@@ -368,18 +510,18 @@ function parseBlockMap(c, indent, inline = false) {
|
|
|
368
510
|
if (indentAt(c) < indent)
|
|
369
511
|
break;
|
|
370
512
|
if (indentAt(c) > indent)
|
|
371
|
-
throw
|
|
513
|
+
throw deeperLine(c, entries[entries.length - 1]?.value);
|
|
372
514
|
}
|
|
373
515
|
first = false;
|
|
374
|
-
const key = parseKey(c);
|
|
516
|
+
const key = parseKey(c, 'mapping-entry');
|
|
375
517
|
skipSpaces(c);
|
|
376
518
|
if (peek(c) !== ':')
|
|
377
|
-
throw new YamlError(c.i);
|
|
519
|
+
throw new YamlError(c.i, 'mapping-entry');
|
|
378
520
|
c.i += 1;
|
|
379
521
|
const after = c.i;
|
|
380
522
|
const value = parseValue(c, indent);
|
|
381
523
|
if (seen.has(key.name))
|
|
382
|
-
throw new YamlError(key.start);
|
|
524
|
+
throw new YamlError(key.start, 'duplicate-key');
|
|
383
525
|
seen.add(key.name);
|
|
384
526
|
entries.push({ key: key.name, after, value });
|
|
385
527
|
end = value.end;
|
|
@@ -387,7 +529,7 @@ function parseBlockMap(c, indent, inline = false) {
|
|
|
387
529
|
return { kind: 'map', entries, start, end };
|
|
388
530
|
}
|
|
389
531
|
export function parseYamlMapping(text, start, end) {
|
|
390
|
-
const c = { text, i: start, end };
|
|
532
|
+
const c = { text, i: start, end, depth: 0 };
|
|
391
533
|
skipBlankAndComments(c);
|
|
392
534
|
if (c.i >= end)
|
|
393
535
|
return { kind: 'map', entries: [], start, end };
|
|
@@ -395,13 +537,13 @@ export function parseYamlMapping(text, start, end) {
|
|
|
395
537
|
const mapped = parseFlowMap(c);
|
|
396
538
|
skipBlankAndComments(c);
|
|
397
539
|
if (c.i < end)
|
|
398
|
-
throw new YamlError(c.i);
|
|
540
|
+
throw new YamlError(c.i, 'flow-collection');
|
|
399
541
|
return mapped;
|
|
400
542
|
}
|
|
401
543
|
const mapped = parseBlockMap(c, indentAt(c));
|
|
402
544
|
skipBlankAndComments(c);
|
|
403
545
|
if (c.i < end)
|
|
404
|
-
throw new YamlError(c.i);
|
|
546
|
+
throw new YamlError(c.i, 'indentation');
|
|
405
547
|
return mapped;
|
|
406
548
|
}
|
|
407
549
|
export function jsValue(node) {
|
|
@@ -439,19 +581,25 @@ function listed(value) {
|
|
|
439
581
|
return keys.length === value.length && keys.every((key, index) => key === String(index));
|
|
440
582
|
}
|
|
441
583
|
function heldWithin(value, within) {
|
|
442
|
-
if (
|
|
584
|
+
if (typeof value === 'string')
|
|
585
|
+
return !UNHELD_TEXT.test(value);
|
|
586
|
+
if (value === null || typeof value === 'boolean')
|
|
443
587
|
return true;
|
|
444
588
|
if (typeof value === 'number')
|
|
445
589
|
return Number.isFinite(value);
|
|
446
590
|
if (typeof value !== 'object' || within.includes(value))
|
|
447
591
|
return false;
|
|
592
|
+
if (within.length + 1 >= YAML_DEPTH_MAX)
|
|
593
|
+
return false;
|
|
448
594
|
const path = [...within, value];
|
|
449
595
|
const held = (item) => heldWithin(item, path);
|
|
450
596
|
if (Array.isArray(value))
|
|
451
597
|
return listed(value) && value.every(held);
|
|
452
|
-
return plain(value) &&
|
|
598
|
+
return (plain(value) &&
|
|
599
|
+
Object.keys(value).every((key) => !UNHELD_TEXT.test(key)) &&
|
|
600
|
+
Object.values(value).every(held));
|
|
453
601
|
}
|
|
454
|
-
export function
|
|
602
|
+
export function documentValue(value) {
|
|
455
603
|
return heldWithin(value, []);
|
|
456
604
|
}
|
|
457
605
|
export function serializeJs(value) {
|
|
@@ -495,7 +643,7 @@ export function extractFrontmatter(content) {
|
|
|
495
643
|
return { kind: 'unclosed' };
|
|
496
644
|
const yamlStart = firstNl + 1;
|
|
497
645
|
let i = yamlStart;
|
|
498
|
-
|
|
646
|
+
for (;;) {
|
|
499
647
|
const nl = content.indexOf('\n', i);
|
|
500
648
|
const lineEnd = nl === -1 ? content.length : nl;
|
|
501
649
|
let line = content.slice(i, lineEnd);
|
|
@@ -507,7 +655,6 @@ export function extractFrontmatter(content) {
|
|
|
507
655
|
return { kind: 'unclosed' };
|
|
508
656
|
i = nl + 1;
|
|
509
657
|
}
|
|
510
|
-
return { kind: 'unclosed' };
|
|
511
658
|
}
|
|
512
659
|
export function equalValue(left, right) {
|
|
513
660
|
if (left === right)
|