@agentshouse/mdmodel 0.1.0-alpha.8 → 0.1.0-c2987f5d89720
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 +302 -0
- package/README.md +34 -175
- 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 -25
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +485 -146
- 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 +82 -73
- 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 +45 -67
- 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 -137
- 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 +263 -193
- package/fixtures/README.md +91 -55
- 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/context.json +1 -0
- package/fixtures/cases/missing-section-item-kind/expected.json +5 -0
- 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/context.json +1 -0
- package/fixtures/cases/prototype-field/expected.json +6 -0
- package/fixtures/cases/prototype-field/library/item.md +9 -0
- 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/context.json +1 -0
- package/fixtures/cases/undeclared-field/expected.json +6 -0
- package/fixtures/cases/undeclared-field/library/item.md +9 -0
- 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/library/tasks/one.md +1 -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 +109 -28
- 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/paragraph-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/prd-definition/library/types/task.md +0 -15
- 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/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 -12
- 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/sections.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Extent } from './types.js';
|
|
1
2
|
export type SectionSpan = {
|
|
2
3
|
readonly name: string;
|
|
3
4
|
readonly headingStart: number;
|
|
@@ -6,5 +7,5 @@ export type SectionSpan = {
|
|
|
6
7
|
};
|
|
7
8
|
export declare function headingSpans(content: string, bodyStart: number): SectionSpan[];
|
|
8
9
|
export declare function sectionsRecord(spans: readonly SectionSpan[], content: string): Record<string, string>;
|
|
9
|
-
export declare function
|
|
10
|
+
export declare function listItems(content: string, from: number, to: number): Extent[] | null;
|
|
10
11
|
//# sourceMappingURL=sections.d.ts.map
|
package/dist/sections.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../src/sections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAIF,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAc9E;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOxB;AASD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAoBpF"}
|
package/dist/sections.js
CHANGED
|
@@ -1,79 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
import { headingLines } from './blocks.js';
|
|
2
2
|
const ITEM = /^([ \t]*)([-*+]|\d+[.)])[ \t]+/;
|
|
3
|
-
function lineRange(content, from) {
|
|
4
|
-
const nl = content.indexOf('\n', from);
|
|
5
|
-
const end = nl === -1 ? content.length : nl;
|
|
6
|
-
let line = content.slice(from, end);
|
|
7
|
-
if (line.endsWith('\r')) line = line.slice(0, -1);
|
|
8
|
-
return {
|
|
9
|
-
line,
|
|
10
|
-
start: from,
|
|
11
|
-
next: nl === -1 ? content.length : nl + 1
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function fenceMarker(line) {
|
|
15
|
-
let i = 0;
|
|
16
|
-
while(i < 3 && (line[i] === ' ' || line[i] === '\t'))i += 1;
|
|
17
|
-
if (line.startsWith('```', i)) return '```';
|
|
18
|
-
if (line.startsWith('~~~', i)) return '~~~';
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
3
|
export function headingSpans(content, bodyStart) {
|
|
22
4
|
const found = [];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (match !== null && match[1] !== undefined) {
|
|
35
|
-
const name = match[1].trim();
|
|
36
|
-
if (found.length > 0) found[found.length - 1] = {
|
|
37
|
-
...found[found.length - 1],
|
|
38
|
-
bodyEnd: start
|
|
39
|
-
};
|
|
40
|
-
found.push({
|
|
41
|
-
name,
|
|
42
|
-
headingStart: start,
|
|
43
|
-
bodyStart: next,
|
|
44
|
-
bodyEnd: content.length
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (next === i) break;
|
|
49
|
-
i = next;
|
|
5
|
+
for (const heading of headingLines(content, bodyStart, content.length)) {
|
|
6
|
+
if (heading.level !== 2)
|
|
7
|
+
continue;
|
|
8
|
+
if (found.length > 0)
|
|
9
|
+
found[found.length - 1] = { ...found[found.length - 1], bodyEnd: heading.start };
|
|
10
|
+
found.push({
|
|
11
|
+
name: heading.name,
|
|
12
|
+
headingStart: heading.start,
|
|
13
|
+
bodyStart: heading.next,
|
|
14
|
+
bodyEnd: content.length,
|
|
15
|
+
});
|
|
50
16
|
}
|
|
51
17
|
return found;
|
|
52
18
|
}
|
|
53
19
|
export function sectionsRecord(spans, content) {
|
|
54
|
-
const record =
|
|
55
|
-
for (const span of spans){
|
|
56
|
-
if (record[span.name] === undefined)
|
|
20
|
+
const record = Object.create(null);
|
|
21
|
+
for (const span of spans) {
|
|
22
|
+
if (record[span.name] === undefined)
|
|
23
|
+
record[span.name] = content.slice(span.bodyStart, span.bodyEnd);
|
|
57
24
|
}
|
|
58
25
|
return record;
|
|
59
26
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
while(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
27
|
+
function trimmed(content, extent) {
|
|
28
|
+
let { start, end } = extent;
|
|
29
|
+
while (start < end && /\s/.test(content[start]))
|
|
30
|
+
start += 1;
|
|
31
|
+
while (end > start && /\s/.test(content[end - 1]))
|
|
32
|
+
end -= 1;
|
|
33
|
+
return { start, end };
|
|
34
|
+
}
|
|
35
|
+
export function listItems(content, from, to) {
|
|
36
|
+
const items = [];
|
|
37
|
+
let indent;
|
|
38
|
+
let start = from;
|
|
39
|
+
while (start < to) {
|
|
40
|
+
const newline = content.indexOf('\n', start);
|
|
41
|
+
const end = newline === -1 || newline >= to ? to : newline;
|
|
42
|
+
const line = content.slice(start, end);
|
|
43
|
+
start = end + 1;
|
|
44
|
+
if (line.trim() === '')
|
|
45
|
+
continue;
|
|
46
|
+
const item = ITEM.exec(line);
|
|
47
|
+
if (item !== null && (indent === undefined || item[1].length === indent)) {
|
|
48
|
+
indent = item[1].length;
|
|
49
|
+
items.push({ start: end - line.length + item[0].length, end });
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (indent === undefined || /^\s*/.exec(line)[0].length <= indent)
|
|
53
|
+
return null;
|
|
54
|
+
items[items.length - 1] = { start: items.at(-1).start, end };
|
|
75
55
|
}
|
|
76
|
-
return
|
|
56
|
+
return items.map((item) => trimmed(content, item));
|
|
77
57
|
}
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=sections.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
|
+
import type { Definition } from './definition.js';
|
|
1
2
|
export type Library = Readonly<Record<string, string>>;
|
|
3
|
+
export type VerifiedModel = {
|
|
4
|
+
readonly types: Readonly<Record<string, Definition>>;
|
|
5
|
+
};
|
|
6
|
+
export type ModelVerification = {
|
|
7
|
+
readonly verdict: 'accept';
|
|
8
|
+
readonly model: VerifiedModel;
|
|
9
|
+
} | {
|
|
10
|
+
readonly verdict: 'refuse';
|
|
11
|
+
readonly rule: string;
|
|
12
|
+
readonly location?: string;
|
|
13
|
+
};
|
|
2
14
|
export type ValidationContext = {
|
|
3
15
|
readonly binaryTargets: readonly string[];
|
|
4
16
|
};
|
|
5
17
|
export type ProjectionContext = {
|
|
6
18
|
readonly documentTargets: readonly string[];
|
|
7
|
-
readonly definition?:
|
|
19
|
+
readonly definition?: Definition;
|
|
20
|
+
};
|
|
21
|
+
export type DivisionContext = ProjectionContext & {
|
|
22
|
+
readonly budget: number;
|
|
23
|
+
};
|
|
24
|
+
export type Extent = {
|
|
25
|
+
readonly start: number;
|
|
26
|
+
readonly end: number;
|
|
27
|
+
};
|
|
28
|
+
export type Span = Extent & {
|
|
29
|
+
readonly text: string;
|
|
8
30
|
};
|
|
9
31
|
export type Document = {
|
|
10
32
|
readonly content: string;
|
|
@@ -16,7 +38,6 @@ export type Document = {
|
|
|
16
38
|
export type Refusal = {
|
|
17
39
|
readonly file: string;
|
|
18
40
|
readonly rule: string;
|
|
19
|
-
readonly version: string;
|
|
20
41
|
readonly location?: string;
|
|
21
42
|
readonly referrers?: readonly string[];
|
|
22
43
|
};
|
|
@@ -32,6 +53,13 @@ export type Projection = {
|
|
|
32
53
|
readonly ok: false;
|
|
33
54
|
readonly refusal: Refusal;
|
|
34
55
|
};
|
|
56
|
+
export type Division = {
|
|
57
|
+
readonly ok: true;
|
|
58
|
+
readonly spans: readonly Span[];
|
|
59
|
+
} | {
|
|
60
|
+
readonly ok: false;
|
|
61
|
+
readonly refusal: Refusal;
|
|
62
|
+
};
|
|
35
63
|
export type ParseResult = {
|
|
36
64
|
readonly ok: true;
|
|
37
65
|
readonly document: Document;
|
|
@@ -43,6 +71,11 @@ export type Link = {
|
|
|
43
71
|
readonly href: string;
|
|
44
72
|
readonly target: string;
|
|
45
73
|
};
|
|
74
|
+
export type Reference = {
|
|
75
|
+
readonly pointer: string;
|
|
76
|
+
readonly value: string;
|
|
77
|
+
readonly to: readonly string[];
|
|
78
|
+
};
|
|
46
79
|
export type Change = {
|
|
47
80
|
readonly kind: 'field';
|
|
48
81
|
readonly name: string;
|
|
@@ -61,6 +94,11 @@ export type Change = {
|
|
|
61
94
|
readonly kind: 'link';
|
|
62
95
|
readonly href: string;
|
|
63
96
|
readonly to: string;
|
|
97
|
+
} | {
|
|
98
|
+
readonly kind: 'reference';
|
|
99
|
+
readonly pointer: string;
|
|
100
|
+
readonly value: string;
|
|
101
|
+
readonly prior: string;
|
|
64
102
|
};
|
|
65
103
|
export type ApplyResult = {
|
|
66
104
|
readonly outcome: 'applied';
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,aAAa,G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AE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC"}
|
package/dist/types.js
CHANGED
package/dist/validate.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type { Library, Validation, ValidationContext } from './types.js';
|
|
2
|
-
export declare function
|
|
1
|
+
import type { Library, ModelVerification, Validation, ValidationContext, VerifiedModel } from './types.js';
|
|
2
|
+
export declare function verify(schema: string): ModelVerification;
|
|
3
|
+
export declare function validate(library: Library, context?: ValidationContext, model?: VerifiedModel): Validation;
|
|
3
4
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAGV,OAAO,EACP,iBAAiB,EAEjB,UAAU,EACV,iBAAiB,EACjB,aAAa,EACd,MAAM,YAAY,CAAC;AAwDpB,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,iBAAiB,CAQxD;AAED,wBAAgB,QAAQ,CACtB,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAyGZ"}
|
package/dist/validate.js
CHANGED
|
@@ -1,178 +1,170 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ATTACHMENT, BUILT_IN_TYPE, readSchema } from './definition.js';
|
|
2
2
|
import { parse } from './document.js';
|
|
3
|
-
import { hrefOccurrences } from './links.js';
|
|
4
|
-
import { classifyHref
|
|
3
|
+
import { hrefOccurrences, linkInventory } from './links.js';
|
|
4
|
+
import { classifyHref } from './paths.js';
|
|
5
|
+
import { references } from './references.js';
|
|
5
6
|
import { refusal } from './refuse.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { bodyAfterFrontmatter } from './yaml.js';
|
|
7
|
+
import { fitsItem, frontmatterRefusal } from './schema.js';
|
|
8
|
+
import { headingSpans, listItems } from './sections.js';
|
|
9
|
+
import { bodyAfterFrontmatter, bodyStartOf } from './yaml.js';
|
|
9
10
|
function refuse(file, rule, extra) {
|
|
10
|
-
return {
|
|
11
|
-
verdict: 'refuse',
|
|
12
|
-
...refusal(file, rule, extra)
|
|
13
|
-
};
|
|
11
|
+
return { verdict: 'refuse', ...refusal(file, rule, extra) };
|
|
14
12
|
}
|
|
15
|
-
function instanceType(document
|
|
16
|
-
if (isTypesPath(file)) return 'definition';
|
|
13
|
+
function instanceType(document) {
|
|
17
14
|
const raw = document.fields.type;
|
|
18
|
-
if (raw === undefined || raw === null)
|
|
19
|
-
|
|
15
|
+
if (raw === undefined || raw === null)
|
|
16
|
+
return BUILT_IN_TYPE;
|
|
17
|
+
if (typeof raw !== 'string' || raw === '')
|
|
18
|
+
return null;
|
|
20
19
|
return raw;
|
|
21
20
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
function reaches(file, href, to, documents, binaryTargets) {
|
|
22
|
+
const resolved = classifyHref(file, href);
|
|
23
|
+
if (resolved.kind !== 'path')
|
|
24
|
+
return false;
|
|
25
|
+
if (to.includes(ATTACHMENT))
|
|
26
|
+
return true;
|
|
27
|
+
if (binaryTargets.has(resolved.path))
|
|
28
|
+
return false;
|
|
29
|
+
const held = documents.get(resolved.path);
|
|
30
|
+
return held === undefined || (held.ok && to.includes(held.document.type ?? BUILT_IN_TYPE));
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
function itemHrefs(content, items) {
|
|
33
|
+
const bodyStart = bodyStartOf(content);
|
|
34
|
+
const { uses } = linkInventory(content.slice(bodyStart));
|
|
35
|
+
const hrefs = [];
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
const link = uses.find((use) => bodyStart + use.start === item.start &&
|
|
38
|
+
bodyStart + use.end === item.end &&
|
|
39
|
+
content[item.start] === '[');
|
|
40
|
+
if (link === undefined)
|
|
41
|
+
return null;
|
|
42
|
+
hrefs.push(link.destination.href);
|
|
43
|
+
}
|
|
44
|
+
return hrefs;
|
|
35
45
|
}
|
|
36
|
-
function
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
39
|
-
|
|
46
|
+
export function verify(schema) {
|
|
47
|
+
const read = readSchema(schema);
|
|
48
|
+
if ('types' in read)
|
|
49
|
+
return { verdict: 'accept', model: read };
|
|
50
|
+
return {
|
|
51
|
+
verdict: 'refuse',
|
|
52
|
+
rule: read.rule,
|
|
53
|
+
...(read.location === undefined ? {} : { location: read.location }),
|
|
54
|
+
};
|
|
40
55
|
}
|
|
41
|
-
export function validate(library, context = {
|
|
42
|
-
binaryTargets: []
|
|
43
|
-
}) {
|
|
56
|
+
export function validate(library, context = { binaryTargets: [] }, model = { types: {} }) {
|
|
44
57
|
const binaryTargets = new Set(context.binaryTargets);
|
|
45
58
|
const files = Object.keys(library).sort();
|
|
46
59
|
const documents = new Map();
|
|
47
|
-
for (const file of files){
|
|
48
|
-
if (binaryTargets.has(file))
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
if (binaryTargets.has(file))
|
|
62
|
+
return refuse(file, 'binary-target-document');
|
|
49
63
|
const parsed = parse(library[file], file);
|
|
50
64
|
documents.set(file, parsed);
|
|
51
|
-
if (!parsed.ok)
|
|
52
|
-
verdict: 'refuse',
|
|
53
|
-
...parsed.refusal
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const definitions = new Map();
|
|
57
|
-
for (const file of files){
|
|
58
|
-
if (!isTypesPath(file)) continue;
|
|
59
|
-
const parsed = documents.get(file);
|
|
60
|
-
if (parsed === undefined || !parsed.ok) continue;
|
|
61
|
-
const definition = readDefinition(file, parsed.document);
|
|
62
|
-
if ('rule' in definition) return {
|
|
63
|
-
verdict: 'refuse',
|
|
64
|
-
...definition
|
|
65
|
-
};
|
|
66
|
-
const existing = definitions.get(definition.name);
|
|
67
|
-
if (existing !== undefined) return refuse(file, 'definition-duplicate', {
|
|
68
|
-
location: definition.name
|
|
69
|
-
});
|
|
70
|
-
definitions.set(definition.name, definition);
|
|
65
|
+
if (!parsed.ok)
|
|
66
|
+
return { verdict: 'refuse', ...parsed.refusal };
|
|
71
67
|
}
|
|
72
|
-
|
|
68
|
+
const definitions = new Map(Object.entries(model.types));
|
|
69
|
+
const sectionReferences = new Map();
|
|
70
|
+
for (const file of files) {
|
|
73
71
|
const parsed = documents.get(file);
|
|
74
|
-
if (parsed === undefined || !parsed.ok)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (kind ===
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const definition = definitions.get(kind);
|
|
84
|
-
if (definition === undefined) return refuse(file, 'unknown-type', {
|
|
85
|
-
location: 'type'
|
|
86
|
-
});
|
|
87
|
-
const fieldFailure = validateFields(definition.fields, parsed.document.fields);
|
|
72
|
+
if (parsed === undefined || !parsed.ok)
|
|
73
|
+
continue;
|
|
74
|
+
const kind = instanceType(parsed.document);
|
|
75
|
+
if (kind === BUILT_IN_TYPE)
|
|
76
|
+
continue;
|
|
77
|
+
const definition = kind === null ? undefined : definitions.get(kind);
|
|
78
|
+
if (definition === undefined)
|
|
79
|
+
return refuse(file, 'unknown-type', { location: '/type' });
|
|
80
|
+
const fieldFailure = frontmatterRefusal(definition, parsed.document.fields);
|
|
88
81
|
if (fieldFailure !== undefined) {
|
|
89
|
-
return refuse(file, fieldFailure.rule, {
|
|
90
|
-
location: fieldFailure.field
|
|
91
|
-
});
|
|
82
|
+
return refuse(file, fieldFailure.rule, { location: fieldFailure.location });
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
const content = library[file];
|
|
85
|
+
const spans = headingSpans(content, bodyStartOf(content));
|
|
86
|
+
const references = [];
|
|
87
|
+
for (const [name, spec] of Object.entries(definition.sections)) {
|
|
88
|
+
const occurrences = spans.filter((one) => one.name === name);
|
|
89
|
+
if (occurrences.length === 0 && spec.required)
|
|
90
|
+
return refuse(file, 'required-section', { location: name });
|
|
91
|
+
if (spec.kind !== 'list')
|
|
99
92
|
continue;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
for (const span of occurrences) {
|
|
94
|
+
const items = listItems(content, span.bodyStart, span.bodyEnd);
|
|
95
|
+
if (items === null ||
|
|
96
|
+
items.some((item) => !fitsItem(definition, name, content.slice(item.start, item.end))))
|
|
97
|
+
return refuse(file, 'structured-section', { location: name });
|
|
98
|
+
if (spec.items.reference === undefined)
|
|
99
|
+
continue;
|
|
100
|
+
const hrefs = itemHrefs(content, items);
|
|
101
|
+
if (hrefs === null)
|
|
102
|
+
return refuse(file, 'structured-section', { location: name });
|
|
103
|
+
references.push({ section: name, to: spec.items.reference, hrefs });
|
|
105
104
|
}
|
|
106
105
|
}
|
|
106
|
+
sectionReferences.set(file, references);
|
|
107
107
|
}
|
|
108
|
-
for (const file of files){
|
|
108
|
+
for (const file of files) {
|
|
109
109
|
const parsed = documents.get(file);
|
|
110
|
-
if (parsed === undefined || !parsed.ok)
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
if (parsed === undefined || !parsed.ok)
|
|
111
|
+
continue;
|
|
112
|
+
const kind = instanceType(parsed.document);
|
|
113
|
+
if (kind === null || kind === BUILT_IN_TYPE)
|
|
114
|
+
continue;
|
|
113
115
|
const definition = definitions.get(kind);
|
|
114
|
-
if (definition === undefined)
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
for (const target of targets){
|
|
120
|
-
const resolved = classifyHref(file, target);
|
|
121
|
-
if (resolved.kind !== 'path' || binaryTargets.has(resolved.path)) return refuse(file, 'unresolved-reference', {
|
|
122
|
-
location: name
|
|
123
|
-
});
|
|
124
|
-
if (!documents.has(resolved.path)) continue;
|
|
125
|
-
const targetType = declaredTypeOf(library[resolved.path]);
|
|
126
|
-
if (targetType !== expected) return refuse(file, 'unresolved-reference', {
|
|
127
|
-
location: name
|
|
128
|
-
});
|
|
129
|
-
}
|
|
116
|
+
if (definition === undefined)
|
|
117
|
+
continue;
|
|
118
|
+
for (const { pointer, to, value } of references(parsed.document, definition)) {
|
|
119
|
+
if (!reaches(file, value, to, documents, binaryTargets))
|
|
120
|
+
return refuse(file, 'unresolved-reference', { location: pointer });
|
|
130
121
|
}
|
|
131
122
|
const body = bodyAfterFrontmatter(library[file]);
|
|
132
|
-
for (const occurrence of hrefOccurrences(body)){
|
|
123
|
+
for (const occurrence of hrefOccurrences(body)) {
|
|
133
124
|
const resolved = classifyHref(file, occurrence.href);
|
|
134
|
-
if (resolved.kind === 'skip')
|
|
135
|
-
|
|
125
|
+
if (resolved.kind === 'skip')
|
|
126
|
+
continue;
|
|
127
|
+
if (resolved.kind === 'invalid' ||
|
|
128
|
+
(!documents.has(resolved.path) && !binaryTargets.has(resolved.path))) {
|
|
136
129
|
return refuse(file, 'unresolved-link');
|
|
137
130
|
}
|
|
138
131
|
}
|
|
132
|
+
for (const { section, to, hrefs } of sectionReferences.get(file)) {
|
|
133
|
+
for (const href of hrefs) {
|
|
134
|
+
if (!reaches(file, href, to, documents, binaryTargets))
|
|
135
|
+
return refuse(file, 'unresolved-reference', { location: section });
|
|
136
|
+
}
|
|
137
|
+
}
|
|
139
138
|
}
|
|
140
139
|
const missing = new Map();
|
|
141
|
-
for (const file of files){
|
|
140
|
+
for (const file of files) {
|
|
142
141
|
const parsed = documents.get(file);
|
|
143
|
-
if (parsed === undefined || !parsed.ok)
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
if (parsed === undefined || !parsed.ok)
|
|
143
|
+
continue;
|
|
144
|
+
const kind = instanceType(parsed.document);
|
|
145
|
+
if (kind === null || kind === BUILT_IN_TYPE)
|
|
146
|
+
continue;
|
|
146
147
|
const definition = definitions.get(kind);
|
|
147
|
-
if (definition === undefined)
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
148
|
+
if (definition === undefined)
|
|
149
|
+
continue;
|
|
150
|
+
for (const { value, to } of references(parsed.document, definition)) {
|
|
151
|
+
if (to.includes(ATTACHMENT))
|
|
152
|
+
continue;
|
|
153
|
+
const resolved = classifyHref(file, value);
|
|
154
|
+
if (resolved.kind !== 'path')
|
|
155
|
+
continue;
|
|
156
|
+
if (documents.has(resolved.path) || binaryTargets.has(resolved.path))
|
|
157
|
+
continue;
|
|
158
|
+
const referrers = missing.get(resolved.path) ?? [];
|
|
159
|
+
referrers.push(file);
|
|
160
|
+
missing.set(resolved.path, referrers);
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
|
-
const missingPaths = [
|
|
162
|
-
...missing.keys()
|
|
163
|
-
].sort();
|
|
163
|
+
const missingPaths = [...missing.keys()].sort();
|
|
164
164
|
if (missingPaths.length > 0) {
|
|
165
165
|
const path = missingPaths[0];
|
|
166
|
-
const referrers = [
|
|
167
|
-
|
|
168
|
-
].sort();
|
|
169
|
-
return refuse(path, 'referenced-missing-file', {
|
|
170
|
-
referrers
|
|
171
|
-
});
|
|
166
|
+
const referrers = [...new Set(missing.get(path) ?? [])].sort();
|
|
167
|
+
return refuse(path, 'referenced-missing-file', { referrers });
|
|
172
168
|
}
|
|
173
|
-
return {
|
|
174
|
-
verdict: 'accept'
|
|
175
|
-
};
|
|
169
|
+
return { verdict: 'accept' };
|
|
176
170
|
}
|
|
177
|
-
|
|
178
|
-
//# sourceMappingURL=validate.js.map
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.0-alpha.
|
|
1
|
+
export declare const VERSION = "0.1.0-alpha.19";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,mBAAmB,CAAC"}
|
package/dist/version.js
CHANGED
package/dist/yaml.d.ts
CHANGED
|
@@ -27,11 +27,13 @@ export type YamlMap = {
|
|
|
27
27
|
readonly end: number;
|
|
28
28
|
};
|
|
29
29
|
export type YamlNode = YamlScalar | YamlSeq | YamlMap;
|
|
30
|
+
export declare function interpretPlain(text: string): string | number | boolean | null;
|
|
30
31
|
export declare function parseYamlMapping(text: string, start: number, end: number): YamlMap;
|
|
31
32
|
export declare function jsValue(node: YamlNode): unknown;
|
|
32
33
|
export declare function mapEntry(map: YamlMap, key: string): YamlEntry | undefined;
|
|
33
34
|
export declare function isPlainSafe(text: string): boolean;
|
|
34
35
|
export declare function serializeJs(value: unknown): string;
|
|
36
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
35
37
|
export declare function serializeKey(name: string): string;
|
|
36
38
|
export declare function bodyStartAfterYaml(content: string, yamlEnd: number): number;
|
|
37
39
|
export declare function bodyStartOf(content: string): number;
|
package/dist/yaml.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|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