@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/paths.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export declare function dirname(path: string): string;
|
|
2
2
|
export declare function join(base: string, relative: string): string;
|
|
3
3
|
export declare function normalize(path: string): string | null;
|
|
4
|
-
export declare function isTypesPath(path: string): boolean;
|
|
5
|
-
export declare function typeNameFromPath(path: string): string;
|
|
6
|
-
export declare function hrefSuffix(href: string): string;
|
|
7
4
|
export declare function classifyHref(from: string, href: string): {
|
|
8
5
|
kind: 'skip';
|
|
9
6
|
} | {
|
|
@@ -12,4 +9,9 @@ export declare function classifyHref(from: string, href: string): {
|
|
|
12
9
|
} | {
|
|
13
10
|
kind: 'invalid';
|
|
14
11
|
};
|
|
12
|
+
export declare function target(from: string, href: string): string | null;
|
|
13
|
+
export declare function retarget(href: string, to: string): string;
|
|
14
|
+
export declare function relative(from: string, target: string): string;
|
|
15
|
+
export declare const SHELL_ROOMS = "/rooms/";
|
|
16
|
+
export declare function shellTarget(href: string, handle: string): string | null;
|
|
15
17
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAYrD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAUzE;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,eAAO,MAAM,WAAW,YAAY,CAAC;AAErC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAKvE"}
|
package/dist/paths.js
CHANGED
|
@@ -3,15 +3,18 @@ export function dirname(path) {
|
|
|
3
3
|
return index === -1 ? '' : path.slice(0, index);
|
|
4
4
|
}
|
|
5
5
|
export function join(base, relative) {
|
|
6
|
-
if (base === '')
|
|
6
|
+
if (base === '')
|
|
7
|
+
return relative;
|
|
7
8
|
return `${base}/${relative}`;
|
|
8
9
|
}
|
|
9
10
|
export function normalize(path) {
|
|
10
11
|
const parts = [];
|
|
11
|
-
for (const part of path.split('/')){
|
|
12
|
-
if (part === '' || part === '.')
|
|
12
|
+
for (const part of path.split('/')) {
|
|
13
|
+
if (part === '' || part === '.')
|
|
14
|
+
continue;
|
|
13
15
|
if (part === '..') {
|
|
14
|
-
if (parts.length === 0)
|
|
16
|
+
if (parts.length === 0)
|
|
17
|
+
return null;
|
|
15
18
|
parts.pop();
|
|
16
19
|
continue;
|
|
17
20
|
}
|
|
@@ -19,41 +22,48 @@ export function normalize(path) {
|
|
|
19
22
|
}
|
|
20
23
|
return parts.join('/');
|
|
21
24
|
}
|
|
22
|
-
export function
|
|
23
|
-
|
|
25
|
+
export function classifyHref(from, href) {
|
|
26
|
+
const trimmed = href.trim();
|
|
27
|
+
if (trimmed === '' || trimmed.startsWith('#'))
|
|
28
|
+
return { kind: 'skip' };
|
|
29
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed))
|
|
30
|
+
return { kind: 'skip' };
|
|
31
|
+
if (trimmed.startsWith('/'))
|
|
32
|
+
return { kind: 'invalid' };
|
|
33
|
+
const bare = trimmed.replace(/[?#].*$/, '');
|
|
34
|
+
if (bare === '')
|
|
35
|
+
return { kind: 'skip' };
|
|
36
|
+
const resolved = normalize(join(dirname(from), bare));
|
|
37
|
+
if (resolved === null || resolved === '')
|
|
38
|
+
return { kind: 'invalid' };
|
|
39
|
+
return { kind: 'path', path: resolved };
|
|
24
40
|
}
|
|
25
|
-
export function
|
|
26
|
-
const
|
|
27
|
-
return
|
|
41
|
+
export function target(from, href) {
|
|
42
|
+
const resolved = classifyHref(from, href);
|
|
43
|
+
return resolved.kind === 'path' ? resolved.path : null;
|
|
28
44
|
}
|
|
29
|
-
export function
|
|
45
|
+
export function retarget(href, to) {
|
|
30
46
|
const trimmed = href.trim();
|
|
31
47
|
const match = /[?#]/.exec(trimmed);
|
|
32
|
-
return match === null ?
|
|
48
|
+
return match === null ? to : to + trimmed.slice(match.index);
|
|
49
|
+
}
|
|
50
|
+
export function relative(from, target) {
|
|
51
|
+
const base = dirname(from)
|
|
52
|
+
.split('/')
|
|
53
|
+
.filter((part) => part !== '');
|
|
54
|
+
const parts = target.split('/');
|
|
55
|
+
let shared = 0;
|
|
56
|
+
while (shared < base.length && shared + 1 < parts.length && base[shared] === parts[shared]) {
|
|
57
|
+
shared += 1;
|
|
58
|
+
}
|
|
59
|
+
const up = Array.from({ length: base.length - shared }, () => '..');
|
|
60
|
+
return [...up, ...parts.slice(shared)].join('/');
|
|
61
|
+
}
|
|
62
|
+
export const SHELL_ROOMS = '/rooms/';
|
|
63
|
+
export function shellTarget(href, handle) {
|
|
64
|
+
const prefix = `${SHELL_ROOMS}${handle}/`;
|
|
65
|
+
if (!href.startsWith(prefix))
|
|
66
|
+
return null;
|
|
67
|
+
const path = normalize(href.slice(prefix.length).replace(/[?#].*$/s, ''));
|
|
68
|
+
return path === null || path === '' ? null : path;
|
|
33
69
|
}
|
|
34
|
-
export function classifyHref(from, href) {
|
|
35
|
-
const trimmed = href.trim();
|
|
36
|
-
if (trimmed === '' || trimmed.startsWith('#')) return {
|
|
37
|
-
kind: 'skip'
|
|
38
|
-
};
|
|
39
|
-
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) return {
|
|
40
|
-
kind: 'skip'
|
|
41
|
-
};
|
|
42
|
-
if (trimmed.startsWith('/')) return {
|
|
43
|
-
kind: 'invalid'
|
|
44
|
-
};
|
|
45
|
-
const bare = trimmed.replace(/[?#].*$/, '');
|
|
46
|
-
if (bare === '') return {
|
|
47
|
-
kind: 'skip'
|
|
48
|
-
};
|
|
49
|
-
const resolved = normalize(join(dirname(from), bare));
|
|
50
|
-
if (resolved === null || resolved === '') return {
|
|
51
|
-
kind: 'invalid'
|
|
52
|
-
};
|
|
53
|
-
return {
|
|
54
|
-
kind: 'path',
|
|
55
|
-
path: resolved
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//# sourceMappingURL=paths.js.map
|
package/dist/profile.js
CHANGED
package/dist/project.d.ts
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
import type { Document, Projection, ProjectionContext } from './types.js';
|
|
1
|
+
import type { Document, Extent, Projection, ProjectionContext, Refusal } from './types.js';
|
|
2
|
+
export type Piece = Extent & {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
};
|
|
5
|
+
export type Edit = Piece;
|
|
6
|
+
export type Input = {
|
|
7
|
+
readonly values: readonly Piece[];
|
|
8
|
+
readonly ranges: readonly Extent[];
|
|
9
|
+
readonly edits: readonly Edit[];
|
|
10
|
+
};
|
|
11
|
+
export type InputResult = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly input: Input;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly refusal: Refusal;
|
|
17
|
+
};
|
|
18
|
+
export declare function rangeText(content: string, range: Extent, edits: readonly Edit[]): string;
|
|
19
|
+
export declare function projectionInput(document: Document, file: string, context: ProjectionContext): InputResult;
|
|
2
20
|
export declare function project(document: Document, file: string, context?: ProjectionContext): Projection;
|
|
3
21
|
//# sourceMappingURL=project.d.ts.map
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG3F,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC;AAEzB,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAmCtD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,CASxF;AA4BD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GACzB,WAAW,CAyBb;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAA2C,GACnD,UAAU,CAMZ"}
|
package/dist/project.js
CHANGED
|
@@ -1,96 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { memberFacts } from './definition.js';
|
|
2
|
+
import { frontmatter } from './document.js';
|
|
3
3
|
import { linkInventory } from './links.js';
|
|
4
|
-
import {
|
|
4
|
+
import { target } from './paths.js';
|
|
5
5
|
import { refusal } from './refuse.js';
|
|
6
6
|
import { headingSpans } from './sections.js';
|
|
7
7
|
import { bodyStartOf } from './yaml.js';
|
|
8
|
-
function internalEdits(
|
|
9
|
-
const inventory = linkInventory(
|
|
8
|
+
function internalEdits(content, bodyStart, file, documentTargets) {
|
|
9
|
+
const inventory = linkInventory(content.slice(bodyStart));
|
|
10
10
|
const internal = new Set();
|
|
11
11
|
const edits = [];
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const uses = [...inventory.uses].sort((left, right) => left.end - left.start - (right.end - right.start));
|
|
13
|
+
for (const use of uses) {
|
|
14
|
+
const resolved = target(file, use.destination.href);
|
|
15
|
+
if (resolved === null || !documentTargets.has(resolved))
|
|
16
|
+
continue;
|
|
15
17
|
internal.add(use.destination.start);
|
|
18
|
+
const label = { start: bodyStart + use.labelStart, end: bodyStart + use.labelEnd };
|
|
19
|
+
const inner = edits
|
|
20
|
+
.filter((edit) => edit.start >= label.start && edit.end <= label.end)
|
|
21
|
+
.sort((left, right) => left.start - right.start);
|
|
16
22
|
edits.push({
|
|
17
|
-
start: use.start,
|
|
18
|
-
end: use.end,
|
|
19
|
-
text:
|
|
23
|
+
start: bodyStart + use.start,
|
|
24
|
+
end: bodyStart + use.end,
|
|
25
|
+
text: rangeText(content, label, inner),
|
|
20
26
|
});
|
|
21
27
|
}
|
|
22
|
-
for (const block of inventory.blocks){
|
|
23
|
-
if (!internal.has(block.destination.start))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end: block.end,
|
|
27
|
-
text: ''
|
|
28
|
-
});
|
|
28
|
+
for (const block of inventory.blocks) {
|
|
29
|
+
if (!internal.has(block.destination.start))
|
|
30
|
+
continue;
|
|
31
|
+
edits.push({ start: bodyStart + block.start, end: bodyStart + block.end, text: '' });
|
|
29
32
|
}
|
|
30
|
-
return edits.sort((left, right)=>left.start - right.start);
|
|
33
|
+
return edits.sort((left, right) => left.start - right.start);
|
|
31
34
|
}
|
|
32
|
-
function
|
|
35
|
+
export function rangeText(content, range, edits) {
|
|
33
36
|
let text = '';
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
let cursor = range.start;
|
|
38
|
+
for (const edit of edits) {
|
|
39
|
+
if (edit.start < cursor || edit.end > range.end)
|
|
40
|
+
continue;
|
|
41
|
+
text += content.slice(cursor, edit.start) + edit.text;
|
|
42
|
+
cursor = edit.end;
|
|
43
|
+
}
|
|
44
|
+
return text + content.slice(cursor, range.end);
|
|
45
|
+
}
|
|
46
|
+
function structural(spec) {
|
|
47
|
+
return spec.kind === 'list' && !spec.items.prose;
|
|
48
|
+
}
|
|
49
|
+
function proseValues(node, facts, values) {
|
|
50
|
+
if (facts === undefined)
|
|
51
|
+
return;
|
|
52
|
+
if (node.kind === 'scalar') {
|
|
53
|
+
if (facts.prose && typeof node.value === 'string')
|
|
54
|
+
values.push({ start: node.start, end: node.end, text: `${node.value}\n\n` });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (node.kind === 'seq') {
|
|
58
|
+
for (const item of node.items)
|
|
59
|
+
proseValues(item, facts.items, values);
|
|
60
|
+
return;
|
|
42
61
|
}
|
|
43
|
-
|
|
62
|
+
for (const entry of node.entries)
|
|
63
|
+
proseValues(entry.value, memberFacts(facts, entry.key), values);
|
|
44
64
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
65
|
+
function freeTextValues(definition, document) {
|
|
66
|
+
const root = frontmatter(document);
|
|
67
|
+
if (root === null)
|
|
68
|
+
return [];
|
|
69
|
+
const values = [];
|
|
70
|
+
proseValues(root, definition.frontmatter, values);
|
|
71
|
+
return values;
|
|
72
|
+
}
|
|
73
|
+
export function projectionInput(document, file, context) {
|
|
74
|
+
const content = document.content;
|
|
75
|
+
const bodyStart = bodyStartOf(content);
|
|
76
|
+
const edits = internalEdits(content, bodyStart, file, new Set(context.documentTargets));
|
|
51
77
|
const declared = document.type;
|
|
52
78
|
if (declared === undefined || declared === 'any') {
|
|
53
79
|
return {
|
|
54
80
|
ok: true,
|
|
55
|
-
|
|
56
|
-
[
|
|
57
|
-
0,
|
|
58
|
-
body.length
|
|
59
|
-
]
|
|
60
|
-
], edits)
|
|
81
|
+
input: { values: [], ranges: [{ start: bodyStart, end: content.length }], edits },
|
|
61
82
|
};
|
|
62
83
|
}
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
return {
|
|
66
|
-
ok: false,
|
|
67
|
-
refusal: refusal(file, 'unknown-type', {
|
|
68
|
-
location: 'type'
|
|
69
|
-
})
|
|
70
|
-
};
|
|
84
|
+
const definition = context.definition;
|
|
85
|
+
if (definition === undefined) {
|
|
86
|
+
return { ok: false, refusal: refusal(file, 'unknown-type', { location: 'type' }) };
|
|
71
87
|
}
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
]);
|
|
90
|
-
return {
|
|
91
|
-
ok: true,
|
|
92
|
-
text: projected(body, spans, edits)
|
|
93
|
-
};
|
|
88
|
+
const structure = new Set(Object.entries(definition.sections).flatMap(([name, spec]) => (structural(spec) ? [name] : [])));
|
|
89
|
+
const headings = headingSpans(content, bodyStart);
|
|
90
|
+
const ranges = [{ start: bodyStart, end: headings[0]?.headingStart ?? content.length }];
|
|
91
|
+
for (const heading of headings) {
|
|
92
|
+
if (structure.has(heading.name))
|
|
93
|
+
continue;
|
|
94
|
+
ranges.push({ start: heading.headingStart, end: heading.bodyEnd });
|
|
95
|
+
}
|
|
96
|
+
return { ok: true, input: { values: freeTextValues(definition, document), ranges, edits } };
|
|
97
|
+
}
|
|
98
|
+
export function project(document, file, context = { documentTargets: [] }) {
|
|
99
|
+
const result = projectionInput(document, file, context);
|
|
100
|
+
if (!result.ok)
|
|
101
|
+
return { ok: false, refusal: result.refusal };
|
|
102
|
+
const { values, ranges, edits } = result.input;
|
|
103
|
+
const prose = ranges.map((range) => rangeText(document.content, range, edits)).join('');
|
|
104
|
+
return { ok: true, text: values.map((value) => value.text).join('') + prose };
|
|
94
105
|
}
|
|
95
|
-
|
|
96
|
-
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"references.d.ts","sourceRoot":"","sources":["../src/references.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAwBtD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,SAAS,EAAE,CAI3F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { escapePointer, itemFacts, memberFacts, } from './definition.js';
|
|
2
|
+
import { isRecord } from './yaml.js';
|
|
3
|
+
function collect(value, facts, pointer, found) {
|
|
4
|
+
if (facts === undefined)
|
|
5
|
+
return;
|
|
6
|
+
if (typeof value === 'string') {
|
|
7
|
+
if (facts.reference !== undefined)
|
|
8
|
+
found.push({ pointer, value, to: facts.reference });
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
for (const [index, item] of value.entries())
|
|
13
|
+
collect(item, itemFacts(facts, index), `${pointer}/${index}`, found);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!isRecord(value))
|
|
17
|
+
return;
|
|
18
|
+
for (const [key, held] of Object.entries(value))
|
|
19
|
+
collect(held, memberFacts(facts, key), `${pointer}/${escapePointer(key)}`, found);
|
|
20
|
+
}
|
|
21
|
+
export function references(document, definition) {
|
|
22
|
+
const found = [];
|
|
23
|
+
collect(document.fields, definition.frontmatter, '', found);
|
|
24
|
+
return found;
|
|
25
|
+
}
|
package/dist/refuse.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refuse.d.ts","sourceRoot":"","sources":["../src/refuse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"refuse.d.ts","sourceRoot":"","sources":["../src/refuse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAC3D,OAAO,CAOT"}
|
package/dist/refuse.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
|
-
import { VERSION } from './version.js';
|
|
2
1
|
export function refusal(file, rule, extra) {
|
|
3
2
|
return {
|
|
4
3
|
file,
|
|
5
4
|
rule,
|
|
6
|
-
|
|
7
|
-
...extra?.
|
|
8
|
-
location: extra.location
|
|
9
|
-
},
|
|
10
|
-
...extra?.referrers === undefined ? {} : {
|
|
11
|
-
referrers: extra.referrers
|
|
12
|
-
}
|
|
5
|
+
...(extra?.location === undefined ? {} : { location: extra.location }),
|
|
6
|
+
...(extra?.referrers === undefined ? {} : { referrers: extra.referrers }),
|
|
13
7
|
};
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=refuse.js.map
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
export type SchemaRefusal = {
|
|
3
|
+
readonly rule: string;
|
|
4
|
+
readonly location: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function frontmatterRefusal(definition: Definition, fields: Readonly<Record<string, unknown>>): SchemaRefusal | undefined;
|
|
7
|
+
export declare function fitsItem(definition: Definition, section: string, text: string): boolean;
|
|
6
8
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAS5E,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA2KjF,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,aAAa,GAAG,SAAS,CAG3B;AAED,wBAAgB,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMvF"}
|
package/dist/schema.js
CHANGED
|
@@ -1,48 +1,163 @@
|
|
|
1
1
|
import { Validator } from '@cfworker/json-schema';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
import { escapePointer, refTarget } from './definition.js';
|
|
3
|
+
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD } from './fields.js';
|
|
4
|
+
import { interpretPlain, isRecord } from './yaml.js';
|
|
5
|
+
const STANDING_MAPS = ['properties', 'patternProperties'];
|
|
6
|
+
const STANDING = [
|
|
7
|
+
'additionalProperties',
|
|
8
|
+
'unevaluatedProperties',
|
|
9
|
+
'items',
|
|
10
|
+
'unevaluatedItems',
|
|
11
|
+
'contains',
|
|
12
|
+
];
|
|
13
|
+
const STANDING_LISTS = ['prefixItems'];
|
|
14
|
+
const IN_PLACE = ['if', 'then', 'else'];
|
|
15
|
+
const IN_PLACE_LISTS = ['allOf', 'anyOf', 'oneOf'];
|
|
16
|
+
const IN_PLACE_MAPS = ['dependentSchemas'];
|
|
17
|
+
const PASSING = new Set([
|
|
18
|
+
'properties',
|
|
19
|
+
'patternProperties',
|
|
20
|
+
'$ref',
|
|
21
|
+
'items',
|
|
22
|
+
'prefixItems',
|
|
23
|
+
'unevaluatedItems',
|
|
24
|
+
'allOf',
|
|
25
|
+
'if',
|
|
26
|
+
'dependentSchemas',
|
|
27
|
+
]);
|
|
28
|
+
const OPENING = new Set(['additionalProperties', 'unevaluatedProperties']);
|
|
29
|
+
const REQUIRED = /required property "([\s\S]*)"\.$/u;
|
|
30
|
+
const compiled = new WeakMap();
|
|
31
|
+
function mapped(value, map) {
|
|
32
|
+
return Object.fromEntries(Object.entries(value).map(([key, held]) => [key, map(held)]));
|
|
19
33
|
}
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
function objectSchema(node) {
|
|
35
|
+
const type = node.type;
|
|
36
|
+
return (type === 'object' ||
|
|
37
|
+
(Array.isArray(type) && type.includes('object')) ||
|
|
38
|
+
node.properties !== undefined ||
|
|
39
|
+
node.patternProperties !== undefined);
|
|
26
40
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
41
|
+
function inPlaceChildren(node) {
|
|
42
|
+
return [
|
|
43
|
+
...IN_PLACE.map((key) => node[key]),
|
|
44
|
+
...IN_PLACE_LISTS.flatMap((key) => (Array.isArray(node[key]) ? node[key] : [])),
|
|
45
|
+
...IN_PLACE_MAPS.flatMap((key) => (isRecord(node[key]) ? Object.values(node[key]) : [])),
|
|
46
|
+
];
|
|
29
47
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
function objecty(node, defs, seen) {
|
|
49
|
+
if (!isRecord(node))
|
|
50
|
+
return false;
|
|
51
|
+
if (objectSchema(node))
|
|
52
|
+
return true;
|
|
53
|
+
if (typeof node.$ref === 'string') {
|
|
54
|
+
const target = refTarget(node.$ref, defs)?.node;
|
|
55
|
+
if (target !== undefined &&
|
|
56
|
+
!seen.has(target) &&
|
|
57
|
+
objecty(target, defs, new Set([...seen, target])))
|
|
58
|
+
return true;
|
|
36
59
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
60
|
+
return inPlaceChildren(node).some((child) => objecty(child, defs, seen));
|
|
61
|
+
}
|
|
62
|
+
function closed(node, inPlace, defs, always = false) {
|
|
63
|
+
if (!isRecord(node))
|
|
64
|
+
return node;
|
|
65
|
+
const out = { ...node };
|
|
66
|
+
const standing = (held) => closed(held, false, defs);
|
|
67
|
+
const nested = (held) => closed(held, true, defs);
|
|
68
|
+
for (const key of STANDING_MAPS)
|
|
69
|
+
if (isRecord(node[key]))
|
|
70
|
+
out[key] = mapped(node[key], standing);
|
|
71
|
+
for (const key of STANDING)
|
|
72
|
+
if (node[key] !== undefined)
|
|
73
|
+
out[key] = standing(node[key]);
|
|
74
|
+
for (const key of STANDING_LISTS)
|
|
75
|
+
if (Array.isArray(node[key]))
|
|
76
|
+
out[key] = node[key].map(standing);
|
|
77
|
+
for (const key of IN_PLACE)
|
|
78
|
+
if (node[key] !== undefined)
|
|
79
|
+
out[key] = nested(node[key]);
|
|
80
|
+
for (const key of IN_PLACE_LISTS)
|
|
81
|
+
if (Array.isArray(node[key]))
|
|
82
|
+
out[key] = node[key].map(nested);
|
|
83
|
+
for (const key of IN_PLACE_MAPS)
|
|
84
|
+
if (isRecord(node[key]))
|
|
85
|
+
out[key] = mapped(node[key], nested);
|
|
86
|
+
if (isRecord(node.$defs))
|
|
87
|
+
out.$defs = mapped(node.$defs, nested);
|
|
88
|
+
if (!inPlace &&
|
|
89
|
+
node.additionalProperties === undefined &&
|
|
90
|
+
node.unevaluatedProperties === undefined &&
|
|
91
|
+
(always || objecty(node, defs, new Set())))
|
|
92
|
+
out.unevaluatedProperties = false;
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
function copied(value) {
|
|
96
|
+
return JSON.parse(JSON.stringify(value));
|
|
97
|
+
}
|
|
98
|
+
function compile(definition) {
|
|
99
|
+
const defs = copied(definition.shape.defs);
|
|
100
|
+
const { sections, member_document: _mark, ...root } = copied(definition.shape.schema);
|
|
101
|
+
const closedDefs = mapped(defs, (held) => closed(held, true, defs));
|
|
102
|
+
const declared = isRecord(root.properties) ? root.properties : {};
|
|
103
|
+
const properties = {
|
|
104
|
+
type: true,
|
|
105
|
+
[SITE_FIELD]: true,
|
|
106
|
+
[RECEIVED_FIELD]: true,
|
|
107
|
+
...(definition.memberDocument ? { [MEMBER_FIELD]: { type: 'string' } } : {}),
|
|
108
|
+
...declared,
|
|
109
|
+
};
|
|
110
|
+
const frontmatter = new Validator({ ...closed({ ...root, properties }, false, defs, true), $defs: closedDefs }, '2020-12', false);
|
|
111
|
+
const lists = new Map();
|
|
112
|
+
for (const [name, spec] of Object.entries(isRecord(sections) ? sections : {})) {
|
|
113
|
+
if (!isRecord(spec) || spec.kind !== 'list')
|
|
114
|
+
continue;
|
|
115
|
+
lists.set(name, new Validator({ ...closed(spec.items, false, defs), $defs: closedDefs }, '2020-12', false));
|
|
44
116
|
}
|
|
45
|
-
return
|
|
117
|
+
return { frontmatter, sections: lists };
|
|
118
|
+
}
|
|
119
|
+
function compiledOf(definition) {
|
|
120
|
+
const held = compiled.get(definition);
|
|
121
|
+
if (held !== undefined)
|
|
122
|
+
return held;
|
|
123
|
+
const made = compile(definition);
|
|
124
|
+
compiled.set(definition, made);
|
|
125
|
+
return made;
|
|
126
|
+
}
|
|
127
|
+
function pointer(location) {
|
|
128
|
+
return decodeURI(location.slice(1));
|
|
129
|
+
}
|
|
130
|
+
function refusalOf(errors) {
|
|
131
|
+
for (const [index, error] of errors.entries()) {
|
|
132
|
+
const next = errors[index + 1];
|
|
133
|
+
if (OPENING.has(error.keyword)) {
|
|
134
|
+
if (next?.keyword === 'false')
|
|
135
|
+
return { rule: 'undeclared-field', location: pointer(next.instanceLocation) };
|
|
136
|
+
if (next !== undefined)
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (PASSING.has(error.keyword) && next !== undefined)
|
|
140
|
+
continue;
|
|
141
|
+
if (error.keyword === 'required') {
|
|
142
|
+
const missing = REQUIRED.exec(error.error)?.[1] ?? '';
|
|
143
|
+
return {
|
|
144
|
+
rule: 'required',
|
|
145
|
+
location: `${pointer(error.instanceLocation)}/${escapePointer(missing)}`,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return { rule: error.keyword, location: pointer(error.instanceLocation) };
|
|
149
|
+
}
|
|
150
|
+
return { rule: 'schema', location: '' };
|
|
151
|
+
}
|
|
152
|
+
export function frontmatterRefusal(definition, fields) {
|
|
153
|
+
const result = compiledOf(definition).frontmatter.validate(fields);
|
|
154
|
+
return result.valid ? undefined : refusalOf(result.errors);
|
|
155
|
+
}
|
|
156
|
+
export function fitsItem(definition, section, text) {
|
|
157
|
+
const spec = definition.sections[section];
|
|
158
|
+
const validator = compiledOf(definition).sections.get(section);
|
|
159
|
+
if (spec?.kind !== 'list' || validator === undefined)
|
|
160
|
+
return false;
|
|
161
|
+
const typed = spec.items.type === 'string' ? text : interpretPlain(text);
|
|
162
|
+
return validator.validate(typed).valid;
|
|
46
163
|
}
|
|
47
|
-
|
|
48
|
-
//# sourceMappingURL=schema.js.map
|