@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c5a71fe539a49
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 +303 -0
- package/README.md +34 -189
- package/dist/blocks.d.ts +11 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +62 -0
- package/dist/condition.d.ts +137 -0
- package/dist/condition.d.ts.map +1 -0
- package/dist/condition.js +394 -0
- package/dist/definition.d.ts +46 -27
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +485 -152
- package/dist/divide.d.ts +3 -0
- package/dist/divide.d.ts.map +1 -0
- package/dist/divide.js +310 -0
- package/dist/document.d.ts +12 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +176 -124
- package/dist/fields.d.ts +4 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +3 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/links.d.ts +1 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +618 -224
- package/dist/paths.d.ts +5 -3
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +47 -37
- package/dist/profile.js +1 -3
- package/dist/project.d.ts +19 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +77 -94
- package/dist/references.d.ts +4 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +25 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +2 -10
- package/dist/schema.d.ts +7 -5
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +156 -41
- package/dist/sections.d.ts +2 -1
- package/dist/sections.d.ts.map +1 -1
- package/dist/sections.js +44 -66
- package/dist/types.d.ts +40 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/validate.d.ts +3 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +129 -142
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -3
- package/dist/yaml.d.ts +2 -0
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +262 -192
- package/fixtures/README.md +91 -56
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
- package/fixtures/cases/absent-optional-field/schema.yaml +56 -0
- package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-outside/context.json +1 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +6 -0
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-outside/schema.yaml +32 -0
- package/fixtures/cases/binary-any-reference/expected.json +1 -2
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-document-collision/expected.json +1 -2
- package/fixtures/cases/binary-document-collision/schema.yaml +1 -0
- package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +1 -0
- package/fixtures/cases/binary-prototype-reference/expected.json +1 -2
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-typed-reference/expected.json +1 -2
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
- package/fixtures/cases/boolean-field/context.json +1 -0
- package/fixtures/cases/boolean-field/expected.json +6 -0
- package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
- package/fixtures/cases/boolean-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/boolean-field/schema.yaml +56 -0
- package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
- package/fixtures/cases/closed-nested-object/context.json +1 -0
- package/fixtures/cases/closed-nested-object/expected.json +6 -0
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +32 -0
- package/fixtures/cases/closed-nested-object/schema.yaml +56 -0
- package/fixtures/cases/composed-root-reference/context.json +1 -0
- package/fixtures/cases/composed-root-reference/expected.json +6 -0
- package/fixtures/cases/composed-root-reference/library/a.md +5 -0
- package/fixtures/cases/composed-root-reference/schema.yaml +13 -0
- package/fixtures/cases/date-time-format/context.json +1 -0
- package/fixtures/cases/date-time-format/expected.json +6 -0
- package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
- package/fixtures/cases/date-time-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/date-time-format/schema.yaml +56 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +1 -0
- package/fixtures/cases/default-unfilled/context.json +1 -0
- package/fixtures/cases/default-unfilled/expected.json +6 -0
- package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +29 -0
- package/fixtures/cases/default-unfilled/schema.yaml +56 -0
- package/fixtures/cases/defs-pattern/context.json +1 -0
- package/fixtures/cases/defs-pattern/expected.json +6 -0
- package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +31 -0
- package/fixtures/cases/defs-pattern/schema.yaml +56 -0
- package/fixtures/cases/dependent-rule/context.json +1 -0
- package/fixtures/cases/dependent-rule/expected.json +6 -0
- package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +30 -0
- package/fixtures/cases/dependent-rule/schema.yaml +56 -0
- package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
- package/fixtures/cases/email-format/context.json +1 -0
- package/fixtures/cases/email-format/expected.json +6 -0
- package/fixtures/cases/email-format/library/companies/acme.md +4 -0
- package/fixtures/cases/email-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/email-format/schema.yaml +56 -0
- package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
- package/fixtures/cases/field-enum/expected.json +2 -3
- package/fixtures/cases/field-enum/schema.yaml +7 -0
- package/fixtures/cases/frontmatter-schema/context.json +1 -0
- package/fixtures/cases/frontmatter-schema/expected.json +5 -0
- package/fixtures/cases/frontmatter-schema/schema.yaml +5 -0
- package/fixtures/cases/integer-field/context.json +1 -0
- package/fixtures/cases/integer-field/expected.json +6 -0
- package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
- package/fixtures/cases/integer-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/integer-field/schema.yaml +56 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -0
- package/fixtures/cases/json-schema-constructs/context.json +1 -0
- package/fixtures/cases/json-schema-constructs/expected.json +1 -0
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +31 -0
- package/fixtures/cases/json-schema-constructs/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-closed/context.json +1 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +6 -0
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +32 -0
- package/fixtures/cases/list-of-objects-closed/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-item/context.json +1 -0
- package/fixtures/cases/list-of-objects-item/expected.json +6 -0
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-of-objects-item/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-reference/context.json +1 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +6 -0
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
- package/fixtures/cases/list-of-objects-reference/schema.yaml +32 -0
- package/fixtures/cases/list-size/context.json +1 -0
- package/fixtures/cases/list-size/expected.json +6 -0
- package/fixtures/cases/list-size/library/companies/acme.md +4 -0
- package/fixtures/cases/list-size/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-size/schema.yaml +56 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -0
- package/fixtures/cases/malformed-definition/expected.json +2 -4
- package/fixtures/cases/malformed-definition/schema.yaml +3 -0
- package/fixtures/cases/member-document/context.json +1 -0
- package/fixtures/cases/member-document/expected.json +1 -0
- package/fixtures/cases/member-document/library/people/ana.md +5 -0
- package/fixtures/cases/member-document/schema.yaml +5 -0
- package/fixtures/cases/missing-binary-image/expected.json +1 -2
- package/fixtures/cases/missing-binary-image/schema.yaml +1 -0
- package/fixtures/cases/missing-binary-link/expected.json +1 -2
- package/fixtures/cases/missing-binary-link/schema.yaml +1 -0
- package/fixtures/cases/missing-required-field/expected.json +2 -3
- package/fixtures/cases/missing-required-field/schema.yaml +7 -0
- package/fixtures/cases/missing-section-item-kind/expected.json +2 -4
- package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
- package/fixtures/cases/misspelled-key/context.json +1 -0
- package/fixtures/cases/misspelled-key/expected.json +6 -0
- package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +32 -0
- package/fixtures/cases/misspelled-key/schema.yaml +56 -0
- package/fixtures/cases/nested-defs/context.json +1 -0
- package/fixtures/cases/nested-defs/expected.json +6 -0
- package/fixtures/cases/nested-defs/library/deal.md +6 -0
- package/fixtures/cases/nested-defs/schema.yaml +11 -0
- package/fixtures/cases/nested-object-reference/context.json +1 -0
- package/fixtures/cases/nested-object-reference/expected.json +6 -0
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-object-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-reference/context.json +1 -0
- package/fixtures/cases/nested-reference/expected.json +1 -0
- package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-reference/library/deals/renewal.md +15 -0
- package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-required-field/context.json +1 -0
- package/fixtures/cases/nested-required-field/expected.json +6 -0
- package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +30 -0
- package/fixtures/cases/nested-required-field/schema.yaml +56 -0
- package/fixtures/cases/null-refused/context.json +1 -0
- package/fixtures/cases/null-refused/expected.json +6 -0
- package/fixtures/cases/null-refused/library/companies/acme.md +4 -0
- package/fixtures/cases/null-refused/library/deals/renewal.md +31 -0
- package/fixtures/cases/null-refused/schema.yaml +56 -0
- package/fixtures/cases/numeric-range/context.json +1 -0
- package/fixtures/cases/numeric-range/expected.json +6 -0
- package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
- package/fixtures/cases/numeric-range/library/deals/renewal.md +31 -0
- package/fixtures/cases/numeric-range/schema.yaml +56 -0
- package/fixtures/cases/one-of-variant/context.json +1 -0
- package/fixtures/cases/one-of-variant/expected.json +6 -0
- package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +31 -0
- package/fixtures/cases/one-of-variant/schema.yaml +56 -0
- package/fixtures/cases/open-map-value/context.json +1 -0
- package/fixtures/cases/open-map-value/expected.json +6 -0
- package/fixtures/cases/open-map-value/library/companies/acme.md +4 -0
- package/fixtures/cases/open-map-value/library/deals/renewal.md +31 -0
- package/fixtures/cases/open-map-value/schema.yaml +56 -0
- package/fixtures/cases/other-room-reference/context.json +1 -0
- package/fixtures/cases/other-room-reference/expected.json +6 -0
- package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
- package/fixtures/cases/other-room-reference/schema.yaml +32 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -0
- package/fixtures/cases/prototype-field/expected.json +2 -3
- package/fixtures/cases/prototype-field/schema.yaml +6 -0
- package/fixtures/cases/quoted-link-definition/expected.json +1 -2
- package/fixtures/cases/quoted-link-definition/schema.yaml +1 -0
- package/fixtures/cases/referenced-missing-file/expected.json +0 -1
- package/fixtures/cases/referenced-missing-file/schema.yaml +11 -0
- package/fixtures/cases/remote-ref/context.json +1 -0
- package/fixtures/cases/remote-ref/expected.json +5 -0
- package/fixtures/cases/remote-ref/schema.yaml +3 -0
- package/fixtures/cases/second-member-document/context.json +1 -0
- package/fixtures/cases/second-member-document/expected.json +5 -0
- package/fixtures/cases/second-member-document/schema.yaml +4 -0
- package/fixtures/cases/section-item-enum/context.json +1 -0
- package/fixtures/cases/section-item-enum/expected.json +6 -0
- package/fixtures/cases/section-item-enum/library/task.md +8 -0
- package/fixtures/cases/section-item-enum/schema.yaml +3 -0
- package/fixtures/cases/section-item-kind/context.json +1 -0
- package/fixtures/cases/section-item-kind/expected.json +6 -0
- package/fixtures/cases/section-item-kind/library/task.md +8 -0
- package/fixtures/cases/section-item-kind/schema.yaml +3 -0
- package/fixtures/cases/section-items/context.json +1 -0
- package/fixtures/cases/section-items/expected.json +1 -0
- package/fixtures/cases/section-items/library/other.md +3 -0
- package/fixtures/cases/section-items/library/page.md +42 -0
- package/fixtures/cases/section-items/schema.yaml +10 -0
- package/fixtures/cases/section-reference-path/context.json +1 -0
- package/fixtures/cases/section-reference-path/expected.json +6 -0
- package/fixtures/cases/section-reference-path/library/other.md +3 -0
- package/fixtures/cases/section-reference-path/library/page.md +7 -0
- package/fixtures/cases/section-reference-path/schema.yaml +3 -0
- package/fixtures/cases/section-reference-type/context.json +1 -0
- package/fixtures/cases/section-reference-type/expected.json +6 -0
- package/fixtures/cases/section-reference-type/library/note.md +1 -0
- package/fixtures/cases/section-reference-type/library/page.md +7 -0
- package/fixtures/cases/section-reference-type/schema.yaml +3 -0
- package/fixtures/cases/shortcut-reference-link/context.json +1 -0
- package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
- package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
- package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
- package/fixtures/cases/string-length/context.json +1 -0
- package/fixtures/cases/string-length/expected.json +6 -0
- package/fixtures/cases/string-length/library/companies/acme.md +4 -0
- package/fixtures/cases/string-length/library/deals/renewal.md +31 -0
- package/fixtures/cases/string-length/schema.yaml +56 -0
- package/fixtures/cases/structured-section/expected.json +1 -2
- package/fixtures/cases/structured-section/schema.yaml +7 -0
- package/fixtures/cases/submission-keys/context.json +1 -0
- package/fixtures/cases/submission-keys/expected.json +1 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
- package/fixtures/cases/submission-keys/schema.yaml +4 -0
- package/fixtures/cases/text-field-kind/context.json +1 -0
- package/fixtures/cases/text-field-kind/expected.json +6 -0
- package/fixtures/cases/text-field-kind/library/page.md +4 -0
- package/fixtures/cases/text-field-kind/schema.yaml +4 -0
- package/fixtures/cases/truncated-link-definition/expected.json +1 -2
- package/fixtures/cases/truncated-link-definition/schema.yaml +1 -0
- package/fixtures/cases/types-folder-content/context.json +1 -0
- package/fixtures/cases/types-folder-content/expected.json +1 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
- package/fixtures/cases/types-folder-content/schema.yaml +4 -0
- package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
- package/fixtures/cases/undeclared-field/expected.json +2 -3
- package/fixtures/cases/undeclared-field/schema.yaml +6 -0
- package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +6 -0
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +6 -0
- package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
- package/fixtures/cases/unknown-type/context.json +1 -0
- package/fixtures/cases/unknown-type/expected.json +6 -0
- package/fixtures/cases/unknown-type/library/item.md +3 -0
- package/fixtures/cases/unknown-type/schema.yaml +3 -0
- package/fixtures/cases/unlisted-reference-type/context.json +1 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
- package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -0
- package/fixtures/cases/unresolved-link/expected.json +1 -2
- package/fixtures/cases/unresolved-link/schema.yaml +6 -0
- package/fixtures/cases/valid-typed-document/schema.yaml +16 -0
- package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -0
- package/fixtures/division.json +409 -0
- package/fixtures/projection.json +90 -21
- package/package.json +3 -12
- package/dist/definition.js.map +0 -1
- package/dist/document.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/links.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/profile.js.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/refuse.js.map +0 -1
- package/dist/schema.js.map +0 -1
- package/dist/sections.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validate.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/yaml.js.map +0 -1
- package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
- package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
- package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
- package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
- package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/field-enum/library/types/task.md +0 -8
- package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
- package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
- package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
- package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
- package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
- package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/prd-definition/library/types/task.md +0 -16
- package/fixtures/cases/prototype-field/library/types/task.md +0 -7
- package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
- package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
- package/fixtures/cases/structured-section/library/types/task.md +0 -8
- package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
- package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
- package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
- package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
- package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
- package/markdown-syntax-profile.md +0 -9
- /package/fixtures/cases/{prd-definition → absent-optional-field}/context.json +0 -0
- /package/fixtures/cases/{prd-definition → absent-optional-field}/expected.json +0 -0
package/dist/yaml.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export class YamlError extends Error {
|
|
2
2
|
offset;
|
|
3
|
-
constructor(offset){
|
|
4
|
-
super('yaml')
|
|
3
|
+
constructor(offset) {
|
|
4
|
+
super('yaml');
|
|
5
|
+
this.offset = offset;
|
|
5
6
|
this.name = 'YamlError';
|
|
6
7
|
}
|
|
7
8
|
}
|
|
@@ -9,20 +10,26 @@ function peek(c) {
|
|
|
9
10
|
return c.i < c.end ? c.text[c.i] : '';
|
|
10
11
|
}
|
|
11
12
|
function skipEol(c) {
|
|
12
|
-
if (peek(c) === '\r')
|
|
13
|
-
|
|
13
|
+
if (peek(c) === '\r')
|
|
14
|
+
c.i += 1;
|
|
15
|
+
if (peek(c) === '\n')
|
|
16
|
+
c.i += 1;
|
|
14
17
|
}
|
|
15
18
|
function skipSpaces(c) {
|
|
16
|
-
while(peek(c) === ' ')
|
|
17
|
-
|
|
19
|
+
while (peek(c) === ' ')
|
|
20
|
+
c.i += 1;
|
|
21
|
+
if (peek(c) === '\t')
|
|
22
|
+
throw new YamlError(c.i);
|
|
18
23
|
}
|
|
19
24
|
function skipToEol(c) {
|
|
20
|
-
while(c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
25
|
+
while (c.i < c.end && peek(c) !== '\n' && peek(c) !== '\r')
|
|
26
|
+
c.i += 1;
|
|
21
27
|
}
|
|
22
28
|
function skipBlankAndComments(c) {
|
|
23
|
-
while(c.i < c.end){
|
|
29
|
+
while (c.i < c.end) {
|
|
24
30
|
skipSpaces(c);
|
|
25
|
-
if (peek(c) === '#')
|
|
31
|
+
if (peek(c) === '#')
|
|
32
|
+
skipToEol(c);
|
|
26
33
|
if (peek(c) === '\r' || peek(c) === '\n') {
|
|
27
34
|
skipEol(c);
|
|
28
35
|
continue;
|
|
@@ -31,7 +38,7 @@ function skipBlankAndComments(c) {
|
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
40
|
function skipFlowSpace(c) {
|
|
34
|
-
while(c.i < c.end){
|
|
41
|
+
while (c.i < c.end) {
|
|
35
42
|
const ch = peek(c);
|
|
36
43
|
if (ch === ' ' || ch === '\n' || ch === '\r') {
|
|
37
44
|
c.i += 1;
|
|
@@ -41,36 +48,40 @@ function skipFlowSpace(c) {
|
|
|
41
48
|
skipToEol(c);
|
|
42
49
|
continue;
|
|
43
50
|
}
|
|
44
|
-
if (ch === '\t')
|
|
51
|
+
if (ch === '\t')
|
|
52
|
+
throw new YamlError(c.i);
|
|
45
53
|
break;
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
function indentAt(c) {
|
|
49
57
|
let j = c.i;
|
|
50
|
-
while(j > 0 && c.text[j - 1] !== '\n'
|
|
58
|
+
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
59
|
+
j -= 1;
|
|
51
60
|
let n = 0;
|
|
52
|
-
while(j < c.i){
|
|
61
|
+
while (j < c.i) {
|
|
53
62
|
const ch = c.text[j];
|
|
54
|
-
if (ch === ' ')
|
|
55
|
-
|
|
56
|
-
else
|
|
63
|
+
if (ch === ' ')
|
|
64
|
+
n += 1;
|
|
65
|
+
else if (ch === '\t')
|
|
66
|
+
throw new YamlError(j);
|
|
67
|
+
else
|
|
68
|
+
break;
|
|
57
69
|
j += 1;
|
|
58
70
|
}
|
|
59
71
|
return n;
|
|
60
72
|
}
|
|
61
73
|
function scalar(value, start, end) {
|
|
62
|
-
return {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (text
|
|
72
|
-
|
|
73
|
-
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text)) return Number(text);
|
|
74
|
+
return { kind: 'scalar', value, start, end };
|
|
75
|
+
}
|
|
76
|
+
export function interpretPlain(text) {
|
|
77
|
+
if (text === 'true')
|
|
78
|
+
return true;
|
|
79
|
+
if (text === 'false')
|
|
80
|
+
return false;
|
|
81
|
+
if (text === 'null' || text === '')
|
|
82
|
+
return null;
|
|
83
|
+
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text))
|
|
84
|
+
return Number(text);
|
|
74
85
|
return text;
|
|
75
86
|
}
|
|
76
87
|
function parseQuoted(c) {
|
|
@@ -78,13 +89,14 @@ function parseQuoted(c) {
|
|
|
78
89
|
const start = c.i;
|
|
79
90
|
c.i += 1;
|
|
80
91
|
let out = '';
|
|
81
|
-
while(c.i < c.end){
|
|
92
|
+
while (c.i < c.end) {
|
|
82
93
|
const ch = peek(c);
|
|
83
94
|
if (ch === quote) {
|
|
84
95
|
c.i += 1;
|
|
85
96
|
return scalar(out, start, c.i);
|
|
86
97
|
}
|
|
87
|
-
if (ch === '\n' || ch === '\r')
|
|
98
|
+
if (ch === '\n' || ch === '\r')
|
|
99
|
+
throw new YamlError(c.i);
|
|
88
100
|
if (quote === "'" && ch === "'" && c.text[c.i + 1] === "'") {
|
|
89
101
|
out += "'";
|
|
90
102
|
c.i += 2;
|
|
@@ -93,11 +105,16 @@ function parseQuoted(c) {
|
|
|
93
105
|
if (quote === '"' && ch === '\\') {
|
|
94
106
|
c.i += 1;
|
|
95
107
|
const escaped = peek(c);
|
|
96
|
-
if (escaped === 'n')
|
|
97
|
-
|
|
98
|
-
else if (escaped === '
|
|
99
|
-
|
|
100
|
-
else
|
|
108
|
+
if (escaped === 'n')
|
|
109
|
+
out += '\n';
|
|
110
|
+
else if (escaped === 't')
|
|
111
|
+
out += '\t';
|
|
112
|
+
else if (escaped === '"')
|
|
113
|
+
out += '"';
|
|
114
|
+
else if (escaped === '\\')
|
|
115
|
+
out += '\\';
|
|
116
|
+
else
|
|
117
|
+
throw new YamlError(c.i);
|
|
101
118
|
c.i += 1;
|
|
102
119
|
continue;
|
|
103
120
|
}
|
|
@@ -108,90 +125,94 @@ function parseQuoted(c) {
|
|
|
108
125
|
}
|
|
109
126
|
function parsePlain(c, flow) {
|
|
110
127
|
const start = c.i;
|
|
111
|
-
while(c.i < c.end){
|
|
128
|
+
while (c.i < c.end) {
|
|
112
129
|
const ch = peek(c);
|
|
113
|
-
if (flow && (ch === ',' || ch === ']' || ch === '}'))
|
|
114
|
-
|
|
115
|
-
if (ch === '
|
|
130
|
+
if (flow && (ch === ',' || ch === ']' || ch === '}'))
|
|
131
|
+
break;
|
|
132
|
+
if (ch === '\n' || ch === '\r')
|
|
133
|
+
break;
|
|
134
|
+
if (ch === '#' && (c.i === start || c.text[c.i - 1] === ' ' || c.text[c.i - 1] === '\t'))
|
|
135
|
+
break;
|
|
116
136
|
c.i += 1;
|
|
117
137
|
}
|
|
118
|
-
if (c.i === start)
|
|
138
|
+
if (c.i === start)
|
|
139
|
+
throw new YamlError(c.i);
|
|
119
140
|
const raw = c.text.slice(start, c.i);
|
|
120
141
|
const trimmed = raw.trimEnd();
|
|
121
142
|
return scalar(interpretPlain(trimmed), start, start + trimmed.length);
|
|
122
143
|
}
|
|
123
144
|
function parseScalar(c, flow) {
|
|
124
145
|
const ch = peek(c);
|
|
125
|
-
if (ch === '"' || ch === "'")
|
|
146
|
+
if (ch === '"' || ch === "'")
|
|
147
|
+
return parseQuoted(c);
|
|
126
148
|
return parsePlain(c, flow);
|
|
127
149
|
}
|
|
128
150
|
function parseKey(c) {
|
|
129
151
|
const start = c.i;
|
|
130
152
|
if (peek(c) === '"' || peek(c) === "'") {
|
|
131
153
|
const quoted = parseQuoted(c);
|
|
132
|
-
if (typeof quoted.value !== 'string')
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
start,
|
|
136
|
-
end: c.i
|
|
137
|
-
};
|
|
154
|
+
if (typeof quoted.value !== 'string')
|
|
155
|
+
throw new YamlError(start);
|
|
156
|
+
return { name: quoted.value, start, end: c.i };
|
|
138
157
|
}
|
|
139
158
|
let end = c.i;
|
|
140
|
-
while(c.i < c.end){
|
|
159
|
+
while (c.i < c.end) {
|
|
141
160
|
const ch = peek(c);
|
|
142
|
-
if (ch === ':' ||
|
|
161
|
+
if (ch === ':' ||
|
|
162
|
+
ch === '\n' ||
|
|
163
|
+
ch === '\r' ||
|
|
164
|
+
ch === ',' ||
|
|
165
|
+
ch === '}' ||
|
|
166
|
+
ch === ']' ||
|
|
167
|
+
ch === '#' ||
|
|
168
|
+
ch === '{' ||
|
|
169
|
+
ch === '[') {
|
|
143
170
|
break;
|
|
144
171
|
}
|
|
145
172
|
c.i += 1;
|
|
146
|
-
if (ch !== ' ' && ch !== '\t')
|
|
173
|
+
if (ch !== ' ' && ch !== '\t')
|
|
174
|
+
end = c.i;
|
|
147
175
|
}
|
|
148
|
-
if (end === start)
|
|
176
|
+
if (end === start)
|
|
177
|
+
throw new YamlError(c.i);
|
|
149
178
|
c.i = end;
|
|
150
|
-
return {
|
|
151
|
-
name: c.text.slice(start, end),
|
|
152
|
-
start,
|
|
153
|
-
end
|
|
154
|
-
};
|
|
179
|
+
return { name: c.text.slice(start, end), start, end };
|
|
155
180
|
}
|
|
156
181
|
function parseFlowValue(c) {
|
|
157
182
|
skipFlowSpace(c);
|
|
158
183
|
const ch = peek(c);
|
|
159
|
-
if (ch === '{')
|
|
160
|
-
|
|
161
|
-
if (ch === '
|
|
184
|
+
if (ch === '{')
|
|
185
|
+
return parseFlowMap(c);
|
|
186
|
+
if (ch === '[')
|
|
187
|
+
return parseFlowSeq(c);
|
|
188
|
+
if (ch === '|' || ch === '>')
|
|
189
|
+
throw new YamlError(c.i);
|
|
162
190
|
return parseScalar(c, true);
|
|
163
191
|
}
|
|
164
192
|
function parseFlowMap(c) {
|
|
165
193
|
const start = c.i;
|
|
166
|
-
if (peek(c) !== '{')
|
|
194
|
+
if (peek(c) !== '{')
|
|
195
|
+
throw new YamlError(c.i);
|
|
167
196
|
c.i += 1;
|
|
168
197
|
skipFlowSpace(c);
|
|
169
198
|
const entries = [];
|
|
170
199
|
const seen = new Set();
|
|
171
200
|
if (peek(c) === '}') {
|
|
172
201
|
c.i += 1;
|
|
173
|
-
return {
|
|
174
|
-
kind: 'map',
|
|
175
|
-
entries,
|
|
176
|
-
start,
|
|
177
|
-
end: c.i
|
|
178
|
-
};
|
|
202
|
+
return { kind: 'map', entries, start, end: c.i };
|
|
179
203
|
}
|
|
180
|
-
while(c.i < c.end){
|
|
204
|
+
while (c.i < c.end) {
|
|
181
205
|
skipFlowSpace(c);
|
|
182
206
|
const key = parseKey(c);
|
|
183
207
|
skipFlowSpace(c);
|
|
184
|
-
if (peek(c) !== ':')
|
|
208
|
+
if (peek(c) !== ':')
|
|
209
|
+
throw new YamlError(c.i);
|
|
185
210
|
c.i += 1;
|
|
186
211
|
const value = parseFlowValue(c);
|
|
187
|
-
if (seen.has(key.name))
|
|
212
|
+
if (seen.has(key.name))
|
|
213
|
+
throw new YamlError(key.start);
|
|
188
214
|
seen.add(key.name);
|
|
189
|
-
entries.push({
|
|
190
|
-
key: key.name,
|
|
191
|
-
keyStart: key.start,
|
|
192
|
-
keyEnd: key.end,
|
|
193
|
-
value
|
|
194
|
-
});
|
|
215
|
+
entries.push({ key: key.name, keyStart: key.start, keyEnd: key.end, value });
|
|
195
216
|
skipFlowSpace(c);
|
|
196
217
|
if (peek(c) === ',') {
|
|
197
218
|
c.i += 1;
|
|
@@ -199,12 +220,7 @@ function parseFlowMap(c) {
|
|
|
199
220
|
}
|
|
200
221
|
if (peek(c) === '}') {
|
|
201
222
|
c.i += 1;
|
|
202
|
-
return {
|
|
203
|
-
kind: 'map',
|
|
204
|
-
entries,
|
|
205
|
-
start,
|
|
206
|
-
end: c.i
|
|
207
|
-
};
|
|
223
|
+
return { kind: 'map', entries, start, end: c.i };
|
|
208
224
|
}
|
|
209
225
|
throw new YamlError(c.i);
|
|
210
226
|
}
|
|
@@ -212,20 +228,16 @@ function parseFlowMap(c) {
|
|
|
212
228
|
}
|
|
213
229
|
function parseFlowSeq(c) {
|
|
214
230
|
const start = c.i;
|
|
215
|
-
if (peek(c) !== '[')
|
|
231
|
+
if (peek(c) !== '[')
|
|
232
|
+
throw new YamlError(c.i);
|
|
216
233
|
c.i += 1;
|
|
217
234
|
skipFlowSpace(c);
|
|
218
235
|
const items = [];
|
|
219
236
|
if (peek(c) === ']') {
|
|
220
237
|
c.i += 1;
|
|
221
|
-
return {
|
|
222
|
-
kind: 'seq',
|
|
223
|
-
items,
|
|
224
|
-
start,
|
|
225
|
-
end: c.i
|
|
226
|
-
};
|
|
238
|
+
return { kind: 'seq', items, start, end: c.i };
|
|
227
239
|
}
|
|
228
|
-
while(c.i < c.end){
|
|
240
|
+
while (c.i < c.end) {
|
|
229
241
|
items.push(parseFlowValue(c));
|
|
230
242
|
skipFlowSpace(c);
|
|
231
243
|
if (peek(c) === ',') {
|
|
@@ -235,12 +247,7 @@ function parseFlowSeq(c) {
|
|
|
235
247
|
}
|
|
236
248
|
if (peek(c) === ']') {
|
|
237
249
|
c.i += 1;
|
|
238
|
-
return {
|
|
239
|
-
kind: 'seq',
|
|
240
|
-
items,
|
|
241
|
-
start,
|
|
242
|
-
end: c.i
|
|
243
|
-
};
|
|
250
|
+
return { kind: 'seq', items, start, end: c.i };
|
|
244
251
|
}
|
|
245
252
|
throw new YamlError(c.i);
|
|
246
253
|
}
|
|
@@ -248,126 +255,191 @@ function parseFlowSeq(c) {
|
|
|
248
255
|
}
|
|
249
256
|
function parseValue(c, parentKeyIndent) {
|
|
250
257
|
skipSpaces(c);
|
|
251
|
-
if (peek(c) === '#')
|
|
258
|
+
if (peek(c) === '#')
|
|
259
|
+
skipToEol(c);
|
|
252
260
|
const ch = peek(c);
|
|
253
261
|
if (ch === '' || ch === '\n' || ch === '\r') {
|
|
254
262
|
skipEol(c);
|
|
255
263
|
skipBlankAndComments(c);
|
|
256
|
-
if (c.i >= c.end)
|
|
264
|
+
if (c.i >= c.end)
|
|
265
|
+
return scalar(null, c.i, c.i);
|
|
257
266
|
const nextIndent = indentAt(c);
|
|
258
|
-
if (nextIndent
|
|
259
|
-
|
|
260
|
-
if (
|
|
261
|
-
|
|
267
|
+
if (nextIndent === parentKeyIndent && seqAhead(c))
|
|
268
|
+
return parseBlockSeq(c, nextIndent);
|
|
269
|
+
if (nextIndent <= parentKeyIndent)
|
|
270
|
+
return scalar(null, c.i, c.i);
|
|
271
|
+
if (peek(c) === '-')
|
|
272
|
+
return parseBlockSeq(c, nextIndent);
|
|
273
|
+
if (peek(c) === '[')
|
|
274
|
+
return parseFlowSeq(c);
|
|
275
|
+
if (peek(c) === '{')
|
|
276
|
+
return parseFlowMap(c);
|
|
262
277
|
return parseBlockMap(c, nextIndent);
|
|
263
278
|
}
|
|
264
|
-
if (ch === '{')
|
|
265
|
-
|
|
266
|
-
if (ch === '
|
|
279
|
+
if (ch === '{')
|
|
280
|
+
return parseFlowMap(c);
|
|
281
|
+
if (ch === '[')
|
|
282
|
+
return parseFlowSeq(c);
|
|
283
|
+
if (ch === '|' || ch === '>')
|
|
284
|
+
throw new YamlError(c.i);
|
|
267
285
|
return parseScalar(c, false);
|
|
268
286
|
}
|
|
287
|
+
function seqAhead(c) {
|
|
288
|
+
const next = c.text[c.i + 1];
|
|
289
|
+
return peek(c) === '-' && (next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end);
|
|
290
|
+
}
|
|
291
|
+
function mappingAhead(c) {
|
|
292
|
+
const start = c.i;
|
|
293
|
+
try {
|
|
294
|
+
if (peek(c) === '{' || peek(c) === '[')
|
|
295
|
+
return false;
|
|
296
|
+
parseKey(c);
|
|
297
|
+
skipSpaces(c);
|
|
298
|
+
if (peek(c) !== ':')
|
|
299
|
+
return false;
|
|
300
|
+
const next = c.text[c.i + 1];
|
|
301
|
+
return next === ' ' || next === '\n' || next === '\r' || c.i + 1 >= c.end;
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
if (error instanceof YamlError)
|
|
305
|
+
return false;
|
|
306
|
+
throw error;
|
|
307
|
+
}
|
|
308
|
+
finally {
|
|
309
|
+
c.i = start;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function lineStartOf(c) {
|
|
313
|
+
let j = c.i;
|
|
314
|
+
while (j > 0 && c.text[j - 1] !== '\n' && c.text[j - 1] !== '\r')
|
|
315
|
+
j -= 1;
|
|
316
|
+
return j;
|
|
317
|
+
}
|
|
318
|
+
function valueEnd(value, marked) {
|
|
319
|
+
return value.kind === 'scalar' && value.start === value.end ? marked : value.end;
|
|
320
|
+
}
|
|
321
|
+
function parseSeqItem(c, indent) {
|
|
322
|
+
skipSpaces(c);
|
|
323
|
+
if (peek(c) !== '#' && peek(c) !== '\n' && peek(c) !== '\r' && c.i < c.end && mappingAhead(c))
|
|
324
|
+
return parseBlockMap(c, c.i - lineStartOf(c), true);
|
|
325
|
+
return parseValue(c, indent);
|
|
326
|
+
}
|
|
269
327
|
function parseBlockSeq(c, indent) {
|
|
270
328
|
const start = c.i;
|
|
271
329
|
const items = [];
|
|
272
330
|
let end = start;
|
|
273
|
-
while(c.i < c.end){
|
|
331
|
+
while (c.i < c.end) {
|
|
274
332
|
skipBlankAndComments(c);
|
|
275
|
-
if (c.i >= c.end)
|
|
276
|
-
|
|
277
|
-
if (
|
|
333
|
+
if (c.i >= c.end)
|
|
334
|
+
break;
|
|
335
|
+
if (indentAt(c) !== indent)
|
|
336
|
+
break;
|
|
337
|
+
if (peek(c) !== '-')
|
|
338
|
+
break;
|
|
278
339
|
c.i += 1;
|
|
279
|
-
|
|
280
|
-
|
|
340
|
+
const marked = c.i;
|
|
341
|
+
const item = parseSeqItem(c, indent);
|
|
342
|
+
items.push(item);
|
|
343
|
+
end = valueEnd(item, marked);
|
|
281
344
|
}
|
|
282
|
-
return {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
start,
|
|
286
|
-
end
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function parseBlockMap(c, indent) {
|
|
345
|
+
return { kind: 'seq', items, start, end };
|
|
346
|
+
}
|
|
347
|
+
function parseBlockMap(c, indent, inline = false) {
|
|
290
348
|
const start = c.i;
|
|
291
349
|
const entries = [];
|
|
292
350
|
const seen = new Set();
|
|
293
351
|
let end = start;
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
if (
|
|
297
|
-
|
|
298
|
-
|
|
352
|
+
let first = inline;
|
|
353
|
+
while (c.i < c.end) {
|
|
354
|
+
if (!first) {
|
|
355
|
+
skipBlankAndComments(c);
|
|
356
|
+
if (c.i >= c.end)
|
|
357
|
+
break;
|
|
358
|
+
if (indentAt(c) < indent)
|
|
359
|
+
break;
|
|
360
|
+
if (indentAt(c) > indent)
|
|
361
|
+
throw new YamlError(c.i);
|
|
362
|
+
}
|
|
363
|
+
first = false;
|
|
299
364
|
const key = parseKey(c);
|
|
300
365
|
skipSpaces(c);
|
|
301
|
-
if (peek(c) !== ':')
|
|
366
|
+
if (peek(c) !== ':')
|
|
367
|
+
throw new YamlError(c.i);
|
|
302
368
|
c.i += 1;
|
|
369
|
+
const marked = c.i;
|
|
303
370
|
const value = parseValue(c, indent);
|
|
304
|
-
if (seen.has(key.name))
|
|
371
|
+
if (seen.has(key.name))
|
|
372
|
+
throw new YamlError(key.start);
|
|
305
373
|
seen.add(key.name);
|
|
306
|
-
entries.push({
|
|
307
|
-
|
|
308
|
-
keyStart: key.start,
|
|
309
|
-
keyEnd: key.end,
|
|
310
|
-
value
|
|
311
|
-
});
|
|
312
|
-
end = c.i;
|
|
374
|
+
entries.push({ key: key.name, keyStart: key.start, keyEnd: key.end, value });
|
|
375
|
+
end = valueEnd(value, marked);
|
|
313
376
|
}
|
|
314
|
-
return {
|
|
315
|
-
kind: 'map',
|
|
316
|
-
entries,
|
|
317
|
-
start,
|
|
318
|
-
end
|
|
319
|
-
};
|
|
377
|
+
return { kind: 'map', entries, start, end };
|
|
320
378
|
}
|
|
321
379
|
export function parseYamlMapping(text, start, end) {
|
|
322
|
-
const c = {
|
|
323
|
-
text,
|
|
324
|
-
i: start,
|
|
325
|
-
end
|
|
326
|
-
};
|
|
380
|
+
const c = { text, i: start, end };
|
|
327
381
|
skipBlankAndComments(c);
|
|
328
|
-
if (c.i >= end)
|
|
329
|
-
kind: 'map',
|
|
330
|
-
entries: [],
|
|
331
|
-
start,
|
|
332
|
-
end
|
|
333
|
-
};
|
|
382
|
+
if (c.i >= end)
|
|
383
|
+
return { kind: 'map', entries: [], start, end };
|
|
334
384
|
if (peek(c) === '{') {
|
|
335
385
|
const mapped = parseFlowMap(c);
|
|
336
386
|
skipBlankAndComments(c);
|
|
337
|
-
if (c.i < end)
|
|
387
|
+
if (c.i < end)
|
|
388
|
+
throw new YamlError(c.i);
|
|
338
389
|
return mapped;
|
|
339
390
|
}
|
|
340
391
|
const mapped = parseBlockMap(c, indentAt(c));
|
|
341
392
|
skipBlankAndComments(c);
|
|
342
|
-
if (c.i < end)
|
|
393
|
+
if (c.i < end)
|
|
394
|
+
throw new YamlError(c.i);
|
|
343
395
|
return mapped;
|
|
344
396
|
}
|
|
345
397
|
export function jsValue(node) {
|
|
346
|
-
if (node.kind === 'scalar')
|
|
347
|
-
|
|
398
|
+
if (node.kind === 'scalar')
|
|
399
|
+
return node.value;
|
|
400
|
+
if (node.kind === 'seq')
|
|
401
|
+
return node.items.map(jsValue);
|
|
348
402
|
const record = Object.create(null);
|
|
349
|
-
for (const entry of node.entries)
|
|
403
|
+
for (const entry of node.entries)
|
|
404
|
+
record[entry.key] = jsValue(entry.value);
|
|
350
405
|
return record;
|
|
351
406
|
}
|
|
352
407
|
export function mapEntry(map, key) {
|
|
353
|
-
return map.entries.find((entry)=>entry.key === key);
|
|
408
|
+
return map.entries.find((entry) => entry.key === key);
|
|
354
409
|
}
|
|
355
410
|
export function isPlainSafe(text) {
|
|
356
|
-
if (text === '' || text === 'true' || text === 'false' || text === 'null')
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
|
|
411
|
+
if (text === '' || text === 'true' || text === 'false' || text === 'null')
|
|
412
|
+
return false;
|
|
413
|
+
if (/[\s#:{}[\],&*!|>'"%@`]/.test(text))
|
|
414
|
+
return false;
|
|
415
|
+
if (text.startsWith('-') || text.startsWith('?') || text.startsWith(':'))
|
|
416
|
+
return false;
|
|
417
|
+
if (/^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$/.test(text))
|
|
418
|
+
return false;
|
|
360
419
|
return true;
|
|
361
420
|
}
|
|
362
421
|
export function serializeJs(value) {
|
|
363
|
-
if (value === null)
|
|
364
|
-
|
|
365
|
-
if (value ===
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
|
|
422
|
+
if (value === null)
|
|
423
|
+
return 'null';
|
|
424
|
+
if (value === true)
|
|
425
|
+
return 'true';
|
|
426
|
+
if (value === false)
|
|
427
|
+
return 'false';
|
|
428
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
429
|
+
return JSON.stringify(value);
|
|
430
|
+
if (typeof value === 'string')
|
|
431
|
+
return isPlainSafe(value) ? value : JSON.stringify(value);
|
|
432
|
+
if (Array.isArray(value))
|
|
433
|
+
return `[${value.map(serializeJs).join(', ')}]`;
|
|
434
|
+
if (isRecord(value))
|
|
435
|
+
return `{${Object.entries(value)
|
|
436
|
+
.map(([key, held]) => `${serializeKey(key)}: ${serializeJs(held)}`)
|
|
437
|
+
.join(', ')}}`;
|
|
369
438
|
throw new YamlError(0);
|
|
370
439
|
}
|
|
440
|
+
export function isRecord(value) {
|
|
441
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
442
|
+
}
|
|
371
443
|
export function serializeKey(name) {
|
|
372
444
|
return isPlainSafe(name) || /^[A-Za-z][A-Za-z0-9_-]*$/.test(name) ? name : JSON.stringify(name);
|
|
373
445
|
}
|
|
@@ -383,47 +455,45 @@ export function bodyAfterFrontmatter(content) {
|
|
|
383
455
|
return content.slice(bodyStartOf(content));
|
|
384
456
|
}
|
|
385
457
|
export function extractFrontmatter(content) {
|
|
386
|
-
if (!content.startsWith('---'))
|
|
387
|
-
kind: 'none'
|
|
388
|
-
};
|
|
458
|
+
if (!content.startsWith('---'))
|
|
459
|
+
return { kind: 'none' };
|
|
389
460
|
const firstNl = content.indexOf('\n');
|
|
390
|
-
const firstLine = firstNl === -1
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
461
|
+
const firstLine = firstNl === -1
|
|
462
|
+
? content
|
|
463
|
+
: content.slice(0, content[firstNl - 1] === '\r' ? firstNl - 1 : firstNl);
|
|
464
|
+
if (!/^---[ \t]*$/.test(firstLine))
|
|
465
|
+
return { kind: 'none' };
|
|
466
|
+
if (firstNl === -1)
|
|
467
|
+
return { kind: 'unclosed' };
|
|
397
468
|
const yamlStart = firstNl + 1;
|
|
398
469
|
let i = yamlStart;
|
|
399
|
-
while(i <= content.length){
|
|
470
|
+
while (i <= content.length) {
|
|
400
471
|
const nl = content.indexOf('\n', i);
|
|
401
472
|
const lineEnd = nl === -1 ? content.length : nl;
|
|
402
473
|
let line = content.slice(i, lineEnd);
|
|
403
|
-
if (line.endsWith('\r'))
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
yamlStart,
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
if (nl === -1) return {
|
|
410
|
-
kind: 'unclosed'
|
|
411
|
-
};
|
|
474
|
+
if (line.endsWith('\r'))
|
|
475
|
+
line = line.slice(0, -1);
|
|
476
|
+
if (/^---[ \t]*$/.test(line))
|
|
477
|
+
return { kind: 'ok', yamlStart, yamlEnd: i };
|
|
478
|
+
if (nl === -1)
|
|
479
|
+
return { kind: 'unclosed' };
|
|
412
480
|
i = nl + 1;
|
|
413
481
|
}
|
|
414
|
-
return {
|
|
415
|
-
kind: 'unclosed'
|
|
416
|
-
};
|
|
482
|
+
return { kind: 'unclosed' };
|
|
417
483
|
}
|
|
418
484
|
export function equalValue(left, right) {
|
|
419
|
-
if (left === right)
|
|
485
|
+
if (left === right)
|
|
486
|
+
return true;
|
|
420
487
|
if (Array.isArray(left) && Array.isArray(right)) {
|
|
421
|
-
return left.length === right.length && left.every((item, index)=>equalValue(item, right[index]));
|
|
488
|
+
return (left.length === right.length && left.every((item, index) => equalValue(item, right[index])));
|
|
489
|
+
}
|
|
490
|
+
if (isRecord(left) && isRecord(right)) {
|
|
491
|
+
const keys = Object.keys(left);
|
|
492
|
+
return (keys.length === Object.keys(right).length &&
|
|
493
|
+
keys.every((key) => Object.hasOwn(right, key) && equalValue(left[key], right[key])));
|
|
422
494
|
}
|
|
423
495
|
return false;
|
|
424
496
|
}
|
|
425
497
|
export function lineEnding(content) {
|
|
426
498
|
return content.includes('\r\n') ? '\r\n' : '\n';
|
|
427
499
|
}
|
|
428
|
-
|
|
429
|
-
//# sourceMappingURL=yaml.js.map
|