@agentshouse/mdmodel 0.1.0-ca6c012c54fb0 → 0.1.0-caaa5bad9995d
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 +246 -229
- package/README.md +27 -25
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/definition.d.ts +25 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +235 -136
- package/dist/document.d.ts +16 -9
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +786 -149
- package/dist/event.d.ts +77 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +200 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +42 -0
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +153 -0
- package/dist/house-model.d.ts +912 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +502 -0
- package/dist/house-references/crockford.d.ts +4 -0
- package/dist/house-references/crockford.d.ts.map +1 -0
- package/dist/house-references/crockford.js +3 -0
- package/dist/house-references/patterns.d.ts +13 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +20 -0
- package/dist/index.d.ts +44 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -12
- package/dist/indexed.d.ts +10 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +63 -0
- package/dist/kinds.d.ts +26 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +218 -0
- package/dist/markdown.d.ts +71 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +232 -0
- package/dist/media-type.d.ts +72 -0
- package/dist/media-type.d.ts.map +1 -0
- package/dist/media-type.js +157 -0
- package/dist/moment.d.ts +7 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +18 -0
- package/dist/not-ready.d.ts +2 -0
- package/dist/not-ready.d.ts.map +1 -0
- package/dist/not-ready.js +5 -0
- package/dist/paths.d.ts +16 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +107 -22
- package/dist/pattern.d.ts.map +1 -1
- package/dist/pattern.js +4 -3
- package/dist/query/language.d.ts +257 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +621 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +129 -0
- package/dist/query/rows.d.ts +36 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +179 -0
- package/dist/query/sql.d.ts +45 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +296 -0
- package/dist/query/walk.d.ts +69 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +274 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +2 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +17 -5
- package/dist/room-types.d.ts +8 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +144 -0
- package/dist/schema.d.ts +1 -3
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +9 -73
- package/dist/types.d.ts +32 -43
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +14 -6
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +225 -187
- package/dist/view.d.ts +5 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +27 -0
- package/dist/yaml.d.ts +7 -5
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +158 -44
- package/fixtures/README.md +103 -70
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.md +7 -0
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +1 -1
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +3 -3
- package/fixtures/cases/{date-time-format/schema.yaml → absent-optional-field/schema.md} +12 -11
- package/fixtures/cases/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.md +7 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-any-file/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +2 -1
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +13 -10
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +1 -1
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +1 -1
- package/fixtures/cases/attachment-reference-outside/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -1
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
- package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
- package/fixtures/cases/boolean-field/expected.json +2 -1
- package/fixtures/cases/boolean-field/library/companies/acme.md +1 -1
- package/fixtures/cases/boolean-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/{absent-optional-field/schema.yaml → boolean-field/schema.md} +12 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.md +7 -0
- package/fixtures/cases/closed-nested-object/expected.json +2 -1
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +1 -1
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +50 -25
- package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +12 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/{conditional-section → conditional-long-text}/expected.json +3 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
- package/fixtures/cases/conditional-long-text/schema.md +15 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +1 -1
- package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
- package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +3 -2
- package/fixtures/cases/date-time-format/expected.json +2 -1
- package/fixtures/cases/date-time-format/library/companies/acme.md +1 -1
- package/fixtures/cases/date-time-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/{boolean-field/schema.yaml → date-time-format/schema.md} +12 -11
- package/fixtures/cases/declared-binary-links/schema.md +3 -0
- package/fixtures/cases/default-unfilled/library/companies/acme.md +1 -1
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +47 -22
- package/fixtures/cases/default-unfilled/schema.md +57 -0
- package/fixtures/cases/defs-pattern/expected.json +2 -1
- package/fixtures/cases/defs-pattern/library/companies/acme.md +1 -1
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +49 -24
- package/fixtures/cases/defs-pattern/schema.md +57 -0
- package/fixtures/cases/dependent-rule/library/companies/acme.md +1 -1
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +48 -23
- package/fixtures/cases/dependent-rule/schema.md +57 -0
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.md +7 -0
- package/fixtures/cases/email-format/expected.json +2 -1
- package/fixtures/cases/email-format/library/companies/acme.md +1 -1
- package/fixtures/cases/email-format/library/deals/renewal.md +49 -24
- package/fixtures/cases/email-format/schema.md +57 -0
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.md +6 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.md +7 -0
- package/fixtures/cases/field-enum/expected.json +2 -1
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.md +8 -0
- package/fixtures/cases/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- package/fixtures/cases/integer-field/expected.json +2 -1
- package/fixtures/cases/integer-field/library/companies/acme.md +1 -1
- package/fixtures/cases/integer-field/library/deals/renewal.md +49 -24
- package/fixtures/cases/integer-field/schema.md +57 -0
- package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +1 -1
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +49 -24
- package/fixtures/cases/json-schema-constructs/schema.md +57 -0
- package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +7 -0
- package/fixtures/cases/labels-in-the-rooms-language/schema.md +11 -0
- package/fixtures/cases/lazy-list-item/expected.json +3 -0
- package/fixtures/cases/lazy-list-item/library/item.md +10 -0
- package/fixtures/cases/lazy-list-item/schema.md +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.md +5 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.md +5 -0
- package/fixtures/cases/list-items/expected.json +1 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.md +12 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +2 -1
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +49 -25
- package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
- package/fixtures/cases/list-of-objects-item/expected.json +2 -1
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +49 -24
- package/fixtures/cases/list-of-objects-item/schema.md +57 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +2 -1
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +1 -1
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +1 -1
- package/fixtures/cases/list-of-objects-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.md +5 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.md +5 -0
- package/fixtures/cases/list-size/expected.json +2 -1
- package/fixtures/cases/list-size/library/companies/acme.md +1 -1
- package/fixtures/cases/list-size/library/deals/renewal.md +51 -24
- package/fixtures/cases/list-size/schema.md +57 -0
- package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
- package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
- package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
- package/fixtures/cases/long-value-past-six-levels/schema.md +17 -0
- package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-list/context.json +1 -0
- package/fixtures/cases/malformed-list/expected.json +7 -0
- package/fixtures/cases/{structured-section → malformed-list}/library/item.md +1 -1
- package/fixtures/cases/malformed-list/schema.md +8 -0
- package/fixtures/cases/member-document/library/people/ana.md +2 -2
- package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-on-another-type/library/note.md +1 -1
- package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.md +8 -0
- package/fixtures/cases/misspelled-key/expected.json +2 -1
- package/fixtures/cases/misspelled-key/library/companies/acme.md +1 -1
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +50 -25
- package/fixtures/cases/misspelled-key/schema.md +57 -0
- package/fixtures/cases/name-not-a-string/context.json +1 -0
- package/fixtures/cases/name-not-a-string/expected.json +5 -0
- package/fixtures/cases/name-not-a-string/schema.md +7 -0
- package/fixtures/cases/nested-defs/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-object-reference/expected.json +2 -1
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/nested-object-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-object-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-object-reference/schema.md +34 -0
- package/fixtures/cases/nested-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-reference/library/deals/renewal.md +13 -10
- package/fixtures/cases/nested-reference/library/places/depot.md +1 -1
- package/fixtures/cases/nested-reference/library/products/seats.md +1 -1
- package/fixtures/cases/nested-reference/library/products/support.md +1 -1
- package/fixtures/cases/nested-reference/schema.md +34 -0
- package/fixtures/cases/nested-required-field/expected.json +2 -1
- package/fixtures/cases/nested-required-field/library/companies/acme.md +1 -1
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +48 -23
- package/fixtures/cases/nested-required-field/schema.md +57 -0
- package/fixtures/cases/numeric-range/expected.json +2 -1
- package/fixtures/cases/numeric-range/library/companies/acme.md +1 -1
- package/fixtures/cases/numeric-range/library/deals/renewal.md +49 -24
- package/fixtures/cases/numeric-range/schema.md +57 -0
- package/fixtures/cases/one-key-two-labels/context.json +1 -0
- package/fixtures/cases/one-key-two-labels/expected.json +5 -0
- package/fixtures/cases/one-key-two-labels/schema.md +7 -0
- package/fixtures/cases/one-key-two-types/context.json +1 -0
- package/fixtures/cases/one-key-two-types/expected.json +5 -0
- package/fixtures/cases/one-key-two-types/schema.md +6 -0
- package/fixtures/cases/one-of-variant/expected.json +2 -1
- package/fixtures/cases/one-of-variant/library/companies/acme.md +1 -1
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +49 -24
- package/fixtures/cases/one-of-variant/schema.md +57 -0
- package/fixtures/cases/other-room-reference/expected.json +2 -1
- package/fixtures/cases/other-room-reference/library/companies/acme.md +1 -1
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +12 -9
- package/fixtures/cases/other-room-reference/library/places/depot.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/seats.md +1 -1
- package/fixtures/cases/other-room-reference/library/products/support.md +1 -1
- package/fixtures/cases/other-room-reference/schema.md +34 -0
- package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
- package/fixtures/cases/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.md +7 -0
- package/fixtures/cases/quoted-link-definition/schema.md +3 -0
- package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +7 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.md +5 -0
- package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/schema.md +12 -0
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.md +12 -0
- package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
- package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
- package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/schema-body-ignored/context.json +1 -0
- package/fixtures/cases/schema-body-ignored/expected.json +1 -0
- package/fixtures/cases/schema-body-ignored/schema.md +9 -0
- package/fixtures/cases/schema-type-named-folders/context.json +1 -0
- package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
- package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
- package/fixtures/cases/schema-type-named-type/context.json +1 -0
- package/fixtures/cases/schema-type-named-type/expected.json +5 -0
- package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
- package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section/schema.yaml → sections-keyword-refused/schema.md} +3 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
- package/fixtures/cases/string-length/expected.json +2 -1
- package/fixtures/cases/string-length/library/companies/acme.md +1 -1
- package/fixtures/cases/string-length/library/deals/renewal.md +49 -24
- package/fixtures/cases/string-length/schema.md +57 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/thematic-break-ends-the-values/context.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/expected.json +1 -0
- package/fixtures/cases/thematic-break-ends-the-values/library/item.md +10 -0
- package/fixtures/cases/thematic-break-ends-the-values/schema.md +5 -0
- package/fixtures/cases/truncated-link-definition/schema.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.md +8 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.md +8 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.md +8 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +1 -1
- package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/undeclared-field/expected.json +2 -1
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.md +7 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unique-in-app-schema/context.json +1 -0
- package/fixtures/cases/unique-in-app-schema/expected.json +5 -0
- package/fixtures/cases/unique-in-app-schema/schema.yaml +7 -0
- package/fixtures/cases/unique-indexed-field/context.json +1 -0
- package/fixtures/cases/unique-indexed-field/expected.json +1 -0
- package/fixtures/cases/unique-indexed-field/library/tickets/first.md +8 -0
- package/fixtures/cases/unique-indexed-field/library/tickets/second.md +8 -0
- package/fixtures/cases/unique-indexed-field/schema.md +9 -0
- package/fixtures/cases/unique-off-indexed-field/context.json +1 -0
- package/fixtures/cases/unique-off-indexed-field/expected.json +5 -0
- package/fixtures/cases/unique-off-indexed-field/schema.md +9 -0
- package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +7 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.md +7 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.md +7 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.md +7 -0
- package/fixtures/cases/unresolved-link/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.md +7 -0
- package/fixtures/cases/valid-typed-document/library/people/ada.md +1 -1
- package/fixtures/cases/valid-typed-document/library/tasks/one.md +11 -11
- package/fixtures/cases/valid-typed-document/schema.md +17 -0
- package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
- package/fixtures/forms.json +371 -0
- package/fixtures/preamble.json +29 -8
- package/fixtures/queries.json +1562 -0
- package/fixtures/references.json +15 -0
- package/package.json +10 -1
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -91
- package/dist/condition.d.ts +0 -181
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -633
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -320
- package/dist/links.d.ts +0 -29
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -831
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -128
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/absent-link-dangles/schema.yaml +0 -6
- package/fixtures/cases/absolute-link/schema.yaml +0 -6
- package/fixtures/cases/bracketed-link-definition/schema.yaml +0 -6
- package/fixtures/cases/conditional-section/schema.yaml +0 -14
- package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
- package/fixtures/cases/default-unfilled/schema.yaml +0 -56
- package/fixtures/cases/defs-pattern/schema.yaml +0 -56
- package/fixtures/cases/dependent-rule/schema.yaml +0 -56
- package/fixtures/cases/duplicate-link-definition/schema.yaml +0 -6
- package/fixtures/cases/email-format/schema.yaml +0 -56
- package/fixtures/cases/fenced-link-definition/schema.yaml +0 -6
- package/fixtures/cases/field-enum/schema.yaml +0 -7
- package/fixtures/cases/frontmatter-schema/expected.json +0 -5
- package/fixtures/cases/integer-field/schema.yaml +0 -56
- package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/json-schema-constructs/schema.yaml +0 -56
- package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -56
- package/fixtures/cases/list-of-objects-item/schema.yaml +0 -56
- package/fixtures/cases/list-size/schema.yaml +0 -56
- package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
- package/fixtures/cases/missing-required-field/schema.yaml +0 -7
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -5
- package/fixtures/cases/missing-section-item-kind/schema.yaml +0 -6
- package/fixtures/cases/misspelled-key/schema.yaml +0 -56
- package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-required-field/schema.yaml +0 -56
- package/fixtures/cases/null-refused/expected.json +0 -6
- package/fixtures/cases/null-refused/library/companies/acme.md +0 -4
- package/fixtures/cases/null-refused/library/deals/renewal.md +0 -31
- package/fixtures/cases/null-refused/schema.yaml +0 -56
- package/fixtures/cases/numeric-range/schema.yaml +0 -56
- package/fixtures/cases/one-of-variant/schema.yaml +0 -56
- package/fixtures/cases/open-map-value/expected.json +0 -6
- package/fixtures/cases/open-map-value/library/companies/acme.md +0 -4
- package/fixtures/cases/open-map-value/library/deals/renewal.md +0 -31
- package/fixtures/cases/open-map-value/schema.yaml +0 -56
- package/fixtures/cases/other-room-reference/schema.yaml +0 -32
- package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
- package/fixtures/cases/prototype-field/schema.yaml +0 -6
- package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/referenced-missing-file/schema.yaml +0 -11
- package/fixtures/cases/section-item-enum/expected.json +0 -6
- package/fixtures/cases/section-item-enum/library/task.md +0 -8
- package/fixtures/cases/section-item-enum/schema.yaml +0 -3
- package/fixtures/cases/section-item-kind/expected.json +0 -6
- package/fixtures/cases/section-item-kind/library/task.md +0 -8
- package/fixtures/cases/section-item-kind/schema.yaml +0 -3
- package/fixtures/cases/section-items/library/page.md +0 -42
- package/fixtures/cases/section-items/schema.yaml +0 -10
- package/fixtures/cases/section-reference-path/expected.json +0 -6
- package/fixtures/cases/section-reference-path/library/page.md +0 -7
- package/fixtures/cases/section-reference-path/schema.yaml +0 -3
- package/fixtures/cases/section-reference-type/expected.json +0 -6
- package/fixtures/cases/section-reference-type/library/page.md +0 -7
- package/fixtures/cases/section-reference-type/schema.yaml +0 -3
- package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -6
- package/fixtures/cases/string-length/schema.yaml +0 -56
- package/fixtures/cases/structured-section/expected.json +0 -6
- package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
- package/fixtures/cases/undeclared-field/schema.yaml +0 -6
- package/fixtures/cases/unresolved-link/schema.yaml +0 -6
- package/fixtures/cases/valid-typed-document/schema.yaml +0 -16
- package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
- package/fixtures/division.json +0 -409
- package/fixtures/projection.json +0 -255
- /package/fixtures/cases/{conditional-section → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{section-items → block-scalar-frontmatter}/expected.json +0 -0
- /package/fixtures/cases/{frontmatter-schema → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{null-refused → frontmatter-construct}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-item-kind}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → list-items}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-path}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{structured-section → list-reference-type}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
- /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
package/dist/definition.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { MEMBER_FIELD,
|
|
1
|
+
import { MEMBER_FIELD, SITE_FIELD, SUBMITTED_FIELD, TYPE_FIELD } from './fields.js';
|
|
2
|
+
import { MEDIA_TYPES } from './media-type.js';
|
|
2
3
|
import { linearPattern } from './pattern.js';
|
|
3
4
|
import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
|
|
4
5
|
export const JSON_TYPES = [
|
|
@@ -12,7 +13,7 @@ export const JSON_TYPES = [
|
|
|
12
13
|
];
|
|
13
14
|
export const BUILT_IN_TYPE = 'any';
|
|
14
15
|
export const ATTACHMENT = 'attachment';
|
|
15
|
-
const
|
|
16
|
+
const RESERVED_TYPE_NAMES = [TYPE_FIELD, 'folders'];
|
|
16
17
|
const COMPOSITES = ['array', 'object'];
|
|
17
18
|
const ANNOTATIONS = new Set([
|
|
18
19
|
'$comment',
|
|
@@ -24,21 +25,29 @@ const ANNOTATIONS = new Set([
|
|
|
24
25
|
'readOnly',
|
|
25
26
|
'writeOnly',
|
|
26
27
|
]);
|
|
28
|
+
export const OPENING = ['additionalProperties', 'unevaluatedProperties'];
|
|
27
29
|
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
30
|
+
const UNIQUE = 'unique';
|
|
31
|
+
const FIELD_KEYWORDS = [...FIELD_RULES, UNIQUE];
|
|
28
32
|
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
29
33
|
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
34
|
+
const DEFS_SECTION = '$defs';
|
|
35
|
+
const ROLES_SECTION = 'roles';
|
|
36
|
+
const SECTIONS = [DEFS_SECTION, ROLES_SECTION];
|
|
37
|
+
const ROLE_NEEDS = ['read', 'write'];
|
|
30
38
|
const DEFS_REFERENCE = '#/$defs/';
|
|
31
39
|
const UNBOUNDED_FORMAT = 'url';
|
|
40
|
+
export const UNIONS = ['anyOf', 'oneOf'];
|
|
32
41
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
33
42
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
34
43
|
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
35
44
|
const HOUSE_KEYS = {
|
|
36
45
|
[TYPE_FIELD]: { prose: false },
|
|
37
46
|
[SITE_FIELD]: { prose: false },
|
|
38
|
-
[
|
|
47
|
+
[SUBMITTED_FIELD]: { prose: false },
|
|
39
48
|
};
|
|
40
|
-
function refuse(rule, location) {
|
|
41
|
-
return
|
|
49
|
+
export function refuse(rule, location) {
|
|
50
|
+
return { rule, location };
|
|
42
51
|
}
|
|
43
52
|
export function escapePointer(key) {
|
|
44
53
|
return key.replaceAll('~', '~0').replaceAll('/', '~1');
|
|
@@ -100,7 +109,7 @@ function strings(value) {
|
|
|
100
109
|
new Set(value).size === value.length);
|
|
101
110
|
}
|
|
102
111
|
function schemaFailure(value, at, context) {
|
|
103
|
-
if (typeof value === 'boolean')
|
|
112
|
+
if (!context.checked || typeof value === 'boolean')
|
|
104
113
|
return undefined;
|
|
105
114
|
if (!isRecord(value))
|
|
106
115
|
return refuse('schema', at);
|
|
@@ -219,6 +228,7 @@ const KEYWORDS = {
|
|
|
219
228
|
node.cross_room === true));
|
|
220
229
|
},
|
|
221
230
|
cross_room: (value, _at, node) => typeof value === 'boolean' && node.reference !== undefined,
|
|
231
|
+
unique: () => false,
|
|
222
232
|
};
|
|
223
233
|
function sharedType(values) {
|
|
224
234
|
if (values.length === 0)
|
|
@@ -247,36 +257,41 @@ function firstOf(held, read) {
|
|
|
247
257
|
}
|
|
248
258
|
return undefined;
|
|
249
259
|
}
|
|
250
|
-
function conjoined(
|
|
260
|
+
export function conjoined(declared, defs, ancestry) {
|
|
251
261
|
const held = [];
|
|
252
262
|
const reached = new Set(ancestry);
|
|
253
|
-
const visit = (node) => {
|
|
254
|
-
if (!isRecord(node) || held.
|
|
263
|
+
const visit = (node, at) => {
|
|
264
|
+
if (!isRecord(node) || held.some((one) => one.node === node))
|
|
255
265
|
return;
|
|
256
|
-
held.push(node);
|
|
266
|
+
held.push({ node, at });
|
|
257
267
|
if (typeof node.$ref === 'string') {
|
|
258
268
|
const target = refTarget(node.$ref, defs)?.node;
|
|
259
269
|
if (target !== undefined && !reached.has(target)) {
|
|
260
270
|
reached.add(target);
|
|
261
|
-
visit(target);
|
|
271
|
+
visit(target, node.$ref.slice('#'.length));
|
|
262
272
|
}
|
|
263
273
|
}
|
|
264
274
|
if (Array.isArray(node.allOf))
|
|
265
|
-
|
|
266
|
-
visit(one);
|
|
275
|
+
node.allOf.forEach((one, index) => visit(one, `${at}/allOf/${index}`));
|
|
267
276
|
};
|
|
268
|
-
for (const node of
|
|
269
|
-
visit(node);
|
|
277
|
+
for (const { node, at } of declared)
|
|
278
|
+
visit(node, at);
|
|
270
279
|
return { held, ancestry: reached };
|
|
271
280
|
}
|
|
272
|
-
function variantsOf(node) {
|
|
281
|
+
export function variantsOf({ node, at }) {
|
|
282
|
+
const listed = (keyword) => {
|
|
283
|
+
const branches = node[keyword];
|
|
284
|
+
return Array.isArray(branches)
|
|
285
|
+
? branches.map((branch, index) => ({ node: branch, at: `${at}/${keyword}/${index}` }))
|
|
286
|
+
: [];
|
|
287
|
+
};
|
|
273
288
|
return [
|
|
274
|
-
...(
|
|
275
|
-
...(
|
|
276
|
-
node.then,
|
|
277
|
-
node.else,
|
|
278
|
-
...(isRecord(node.dependentSchemas) ?
|
|
279
|
-
].filter(isRecord);
|
|
289
|
+
...listed('anyOf'),
|
|
290
|
+
...listed('oneOf'),
|
|
291
|
+
{ node: node.then, at: `${at}/then` },
|
|
292
|
+
{ node: node.else, at: `${at}/else` },
|
|
293
|
+
...Object.entries(isRecord(node.dependentSchemas) ? node.dependentSchemas : {}).map(([key, branch]) => ({ node: branch, at: `${at}/dependentSchemas/${escapePointer(key)}` })),
|
|
294
|
+
].filter((one) => isRecord(one.node));
|
|
280
295
|
}
|
|
281
296
|
function united(left, right) {
|
|
282
297
|
if (left === undefined || right === undefined)
|
|
@@ -307,6 +322,8 @@ function joined(left, right) {
|
|
|
307
322
|
return shared === undefined ? [] : [{ pattern, facts: shared }];
|
|
308
323
|
});
|
|
309
324
|
const additional = both(left.additional, right.additional);
|
|
325
|
+
const required = (left.required ?? []).filter((name) => right.required?.includes(name) === true);
|
|
326
|
+
const title = left.title ?? right.title;
|
|
310
327
|
return {
|
|
311
328
|
...(type === undefined ? {} : { type }),
|
|
312
329
|
...(format === undefined ? {} : { format }),
|
|
@@ -314,9 +331,13 @@ function joined(left, right) {
|
|
|
314
331
|
...(reference === undefined ? {} : { reference }),
|
|
315
332
|
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
316
333
|
prose: left.prose && right.prose,
|
|
334
|
+
...(title === undefined ? {} : { title }),
|
|
335
|
+
...(left.markdown === true || right.markdown === true ? { markdown: true } : {}),
|
|
336
|
+
...(left.json === true || right.json === true ? { json: true } : {}),
|
|
317
337
|
...(prefix === undefined ? {} : { prefix }),
|
|
318
338
|
...(items === undefined ? {} : { items }),
|
|
319
339
|
...(Object.keys(properties).length === 0 ? {} : { properties }),
|
|
340
|
+
...(required.length === 0 ? {} : { required }),
|
|
320
341
|
...(patterns.length === 0 ? {} : { patterns }),
|
|
321
342
|
...(additional === undefined ? {} : { additional }),
|
|
322
343
|
};
|
|
@@ -368,12 +389,78 @@ function inheritedOf(held) {
|
|
|
368
389
|
return Object.keys(kept).length === 0 ? [] : [kept];
|
|
369
390
|
});
|
|
370
391
|
}
|
|
392
|
+
function typeSet(type) {
|
|
393
|
+
const listed = typeof type === 'string' ? [type] : Array.isArray(type) ? type : null;
|
|
394
|
+
return listed === null
|
|
395
|
+
? null
|
|
396
|
+
: new Set(listed.map((one) => (one === 'integer' ? 'number' : String(one))));
|
|
397
|
+
}
|
|
398
|
+
function valueType(value) {
|
|
399
|
+
if (value === null)
|
|
400
|
+
return 'null';
|
|
401
|
+
if (Array.isArray(value))
|
|
402
|
+
return 'array';
|
|
403
|
+
return typeof value;
|
|
404
|
+
}
|
|
405
|
+
function narrowed(left, right) {
|
|
406
|
+
if (left === null)
|
|
407
|
+
return right;
|
|
408
|
+
if (right === null)
|
|
409
|
+
return left;
|
|
410
|
+
return new Set([...left].filter((one) => right.has(one)));
|
|
411
|
+
}
|
|
412
|
+
export function admitted(nodes, defs, ancestry) {
|
|
413
|
+
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
414
|
+
let kept = null;
|
|
415
|
+
for (const { node } of conjunction.held) {
|
|
416
|
+
kept = narrowed(kept, typeSet(node.type));
|
|
417
|
+
if (Array.isArray(node.enum))
|
|
418
|
+
kept = narrowed(kept, new Set(node.enum.map(valueType)));
|
|
419
|
+
if (Object.hasOwn(node, 'const'))
|
|
420
|
+
kept = narrowed(kept, new Set([valueType(node.const)]));
|
|
421
|
+
for (const keyword of UNIONS) {
|
|
422
|
+
const branches = node[keyword];
|
|
423
|
+
if (!Array.isArray(branches))
|
|
424
|
+
continue;
|
|
425
|
+
let union = new Set();
|
|
426
|
+
for (const branch of branches) {
|
|
427
|
+
const one = admitted([branch], defs, conjunction.ancestry);
|
|
428
|
+
if (one === null) {
|
|
429
|
+
union = null;
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
for (const type of one)
|
|
433
|
+
union.add(type);
|
|
434
|
+
}
|
|
435
|
+
kept = narrowed(kept, union);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return kept;
|
|
439
|
+
}
|
|
440
|
+
function structuredUnion(held, defs, ancestry) {
|
|
441
|
+
return held.some((node) => UNIONS.some((keyword) => Array.isArray(node[keyword]) &&
|
|
442
|
+
node[keyword].some((branch) => {
|
|
443
|
+
const types = admitted([branch], defs, ancestry);
|
|
444
|
+
return types === null || types.has('object') || types.has('array');
|
|
445
|
+
})));
|
|
446
|
+
}
|
|
447
|
+
function openWhole(held) {
|
|
448
|
+
return held.some((node) => OPENING.some((keyword) => node[keyword] === true));
|
|
449
|
+
}
|
|
450
|
+
function writtenAsJson(held, defs, ancestry) {
|
|
451
|
+
const types = admitted(held, defs, ancestry);
|
|
452
|
+
if (types === null || types.size !== 1)
|
|
453
|
+
return true;
|
|
454
|
+
return structuredUnion(held, defs, ancestry) || (types.has('object') && openWhole(held));
|
|
455
|
+
}
|
|
371
456
|
function factsOf(nodes, defs, ancestry) {
|
|
372
|
-
const {
|
|
457
|
+
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
458
|
+
const reached = conjunction.ancestry;
|
|
459
|
+
const held = conjunction.held.map(({ node }) => node);
|
|
373
460
|
const inherited = inheritedOf(held);
|
|
374
|
-
const variants = new Map(held
|
|
461
|
+
const variants = new Map(conjunction.held
|
|
375
462
|
.flatMap(variantsOf)
|
|
376
|
-
.map((branch) => [branch, factsOf([branch, ...inherited], defs, reached)]));
|
|
463
|
+
.map(({ node: branch }) => [branch, factsOf([branch, ...inherited], defs, reached)]));
|
|
377
464
|
const unions = alternativesOf(held, variants);
|
|
378
465
|
const alternatives = unions.map((kept) => kept.reduce(joined));
|
|
379
466
|
const listed = [
|
|
@@ -414,13 +501,18 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
414
501
|
: Array.from({ length: Math.max(...tuples.map((tuple) => tuple.length)) }, (_, index) => factsOf(tuples.flatMap((tuple) => (index < tuple.length ? [tuple[index]] : [])), defs, reached))));
|
|
415
502
|
const mapped = type === 'object' || type === undefined;
|
|
416
503
|
const properties = mapped ? propertiesOf(held, variants, defs, reached) : undefined;
|
|
504
|
+
const required = mapped
|
|
505
|
+
? [...new Set(held.flatMap((node) => (Array.isArray(node.required) ? node.required : [])))]
|
|
506
|
+
: [];
|
|
417
507
|
const patterns = mapped
|
|
418
508
|
? held.flatMap((node) => Object.entries(isRecord(node.patternProperties) ? node.patternProperties : {}).map(([pattern, schema]) => ({ pattern, facts: factsOf([schema], defs, reached) })))
|
|
419
509
|
: [];
|
|
420
510
|
const opened = mapped
|
|
421
|
-
? held.flatMap((node) =>
|
|
511
|
+
? held.flatMap((node) => OPENING.map((keyword) => (node[keyword] === true ? {} : node[keyword])).filter(isRecord))
|
|
422
512
|
: [];
|
|
423
513
|
const additional = opened.length === 0 ? undefined : factsOf(opened, defs, reached);
|
|
514
|
+
const title = firstOf(nodes.filter(isRecord), (node) => typeof node.title === 'string' ? node.title : undefined);
|
|
515
|
+
const markdown = held.some((node) => node.contentMediaType === MEDIA_TYPES.markdown);
|
|
424
516
|
return {
|
|
425
517
|
...(type === undefined ? {} : { type }),
|
|
426
518
|
...(format === undefined ? {} : { format }),
|
|
@@ -428,9 +520,13 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
428
520
|
...(reference === undefined ? {} : { reference }),
|
|
429
521
|
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
430
522
|
prose,
|
|
523
|
+
...(title === undefined ? {} : { title }),
|
|
524
|
+
...(markdown ? { markdown: true } : {}),
|
|
525
|
+
...(writtenAsJson(held, defs, ancestry) ? { json: true } : {}),
|
|
431
526
|
...(prefix === undefined ? {} : { prefix }),
|
|
432
527
|
...(items === undefined ? {} : { items }),
|
|
433
528
|
...(properties === undefined ? {} : { properties }),
|
|
529
|
+
...(required.length === 0 ? {} : { required }),
|
|
434
530
|
...(patterns.length === 0 ? {} : { patterns }),
|
|
435
531
|
...(additional === undefined ? {} : { additional }),
|
|
436
532
|
};
|
|
@@ -457,7 +553,7 @@ export function fieldFacts(definition, key) {
|
|
|
457
553
|
return definition.fields[key];
|
|
458
554
|
if (Object.hasOwn(HOUSE_KEYS, key))
|
|
459
555
|
return undefined;
|
|
460
|
-
return memberFacts(definition.
|
|
556
|
+
return memberFacts(definition.root, key);
|
|
461
557
|
}
|
|
462
558
|
function stepped({ facts, through, conditional }, token) {
|
|
463
559
|
if (facts.type === 'array' && ARRAY_INDEX.test(token)) {
|
|
@@ -515,87 +611,60 @@ function reachedDefs(value, defs, reached) {
|
|
|
515
611
|
reachedDefs(held, defs, reached);
|
|
516
612
|
}
|
|
517
613
|
}
|
|
518
|
-
function
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
const where = `${at}/${escapePointer(name)}`;
|
|
525
|
-
if (!isRecord(spec) || (spec.kind !== 'text' && spec.kind !== 'list'))
|
|
526
|
-
return failed('sections', where);
|
|
527
|
-
const allowed = spec.kind === 'list' ? ['kind', 'required', 'items'] : ['kind', 'required'];
|
|
528
|
-
const extra = Object.keys(spec).find((key) => !allowed.includes(key));
|
|
529
|
-
if (extra !== undefined)
|
|
530
|
-
return failed('sections', `${where}/${escapePointer(extra)}`);
|
|
531
|
-
if (spec.required !== undefined && typeof spec.required !== 'boolean')
|
|
532
|
-
return failed('sections', `${where}/required`);
|
|
533
|
-
const required = spec.required === true;
|
|
534
|
-
if (spec.kind === 'text') {
|
|
535
|
-
sections[name] = { kind: 'text', required };
|
|
614
|
+
function untitledSchema(node) {
|
|
615
|
+
if (!isRecord(node))
|
|
616
|
+
return node;
|
|
617
|
+
const kept = {};
|
|
618
|
+
for (const [key, held] of Object.entries(node)) {
|
|
619
|
+
if (key === 'title' && typeof held === 'string')
|
|
536
620
|
continue;
|
|
537
|
-
|
|
538
|
-
if (
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
sections[name] = { kind: 'list', required, items };
|
|
547
|
-
}
|
|
548
|
-
return { sections };
|
|
549
|
-
}
|
|
550
|
-
function branchSectionsFailure(sections, declared, where) {
|
|
551
|
-
if (!isRecord(sections))
|
|
552
|
-
return refuse('sections', where);
|
|
553
|
-
for (const [name, spec] of Object.entries(sections)) {
|
|
554
|
-
const place = `${where}/${escapePointer(name)}`;
|
|
555
|
-
const own = isRecord(declared) && Object.hasOwn(declared, name) ? declared[name] : undefined;
|
|
556
|
-
if (!isRecord(spec) || !isRecord(own))
|
|
557
|
-
return refuse('sections', place);
|
|
558
|
-
const { required, ...kind } = spec;
|
|
559
|
-
const { required: _required, ...ownKind } = own;
|
|
560
|
-
if (required !== undefined && typeof required !== 'boolean')
|
|
561
|
-
return refuse('sections', `${place}/required`);
|
|
562
|
-
if (!equalValue(kind, ownKind))
|
|
563
|
-
return refuse('sections', place);
|
|
621
|
+
const check = Object.hasOwn(KEYWORDS, key) ? KEYWORDS[key] : undefined;
|
|
622
|
+
if (check === SCHEMA)
|
|
623
|
+
kept[key] = untitledSchema(held);
|
|
624
|
+
else if (check === SCHEMA_LIST && Array.isArray(held))
|
|
625
|
+
kept[key] = held.map(untitledSchema);
|
|
626
|
+
else if (check === SCHEMA_MAP && isRecord(held))
|
|
627
|
+
kept[key] = untitledMap(held);
|
|
628
|
+
else
|
|
629
|
+
kept[key] = held;
|
|
564
630
|
}
|
|
565
|
-
return
|
|
631
|
+
return kept;
|
|
566
632
|
}
|
|
567
|
-
function
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
633
|
+
function untitledMap(map) {
|
|
634
|
+
return Object.fromEntries(Object.entries(map).map(([key, held]) => [key, untitledSchema(held)]));
|
|
635
|
+
}
|
|
636
|
+
function untitledFacts(facts) {
|
|
637
|
+
const { title: _title, prefix, items, properties, patterns, additional, ...kept } = facts;
|
|
638
|
+
return {
|
|
639
|
+
...kept,
|
|
640
|
+
...(prefix === undefined ? {} : { prefix: prefix.map(untitledFacts) }),
|
|
641
|
+
...(items === undefined ? {} : { items: untitledFacts(items) }),
|
|
642
|
+
...(properties === undefined
|
|
643
|
+
? {}
|
|
644
|
+
: {
|
|
645
|
+
properties: Object.fromEntries(Object.entries(properties).map(([key, held]) => [key, untitledFacts(held)])),
|
|
646
|
+
}),
|
|
647
|
+
...(patterns === undefined
|
|
648
|
+
? {}
|
|
649
|
+
: {
|
|
650
|
+
patterns: patterns.map(({ pattern, facts: held }) => ({
|
|
651
|
+
pattern,
|
|
652
|
+
facts: untitledFacts(held),
|
|
653
|
+
})),
|
|
654
|
+
}),
|
|
655
|
+
...(additional === undefined ? {} : { additional: untitledFacts(additional) }),
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
export function untitled(definition) {
|
|
659
|
+
return {
|
|
660
|
+
...definition,
|
|
661
|
+
root: untitledFacts(definition.root),
|
|
662
|
+
fields: Object.fromEntries(Object.entries(definition.fields).map(([key, held]) => [key, untitledFacts(held)])),
|
|
663
|
+
shape: {
|
|
664
|
+
schema: untitledSchema(definition.shape.schema),
|
|
665
|
+
defs: untitledMap(definition.shape.defs),
|
|
666
|
+
},
|
|
667
|
+
};
|
|
599
668
|
}
|
|
600
669
|
function deepFreeze(value) {
|
|
601
670
|
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
@@ -634,8 +703,9 @@ function composites(node, defs, seen) {
|
|
|
634
703
|
const target = typeof node.$ref === 'string' ? refTarget(node.$ref, defs)?.node : undefined;
|
|
635
704
|
const conditioned = () => {
|
|
636
705
|
const met = composites(node.then ?? true, defs, seen);
|
|
637
|
-
|
|
638
|
-
|
|
706
|
+
const condition = composites(node.if, defs, seen);
|
|
707
|
+
const otherwise = composites(node.else ?? true, defs, seen);
|
|
708
|
+
return COMPOSITES.filter((kind) => (condition.includes(kind) && met.includes(kind)) || otherwise.includes(kind));
|
|
639
709
|
};
|
|
640
710
|
const bounds = [
|
|
641
711
|
typed(node.type),
|
|
@@ -695,23 +765,23 @@ function unruled(schema) {
|
|
|
695
765
|
return { schema, written };
|
|
696
766
|
const properties = Object.create(null);
|
|
697
767
|
for (const [field, node] of Object.entries(schema.properties)) {
|
|
698
|
-
if (!isRecord(node) || !
|
|
768
|
+
if (!isRecord(node) || !FIELD_KEYWORDS.some((keyword) => Object.hasOwn(node, keyword))) {
|
|
699
769
|
properties[field] = node;
|
|
700
770
|
continue;
|
|
701
771
|
}
|
|
702
772
|
written.set(field, node);
|
|
703
|
-
properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !
|
|
773
|
+
properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !FIELD_KEYWORDS.includes(keyword)));
|
|
704
774
|
}
|
|
705
775
|
return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
|
|
706
776
|
}
|
|
707
|
-
function providedType(name, value, provided) {
|
|
777
|
+
function providedType(name, value, provided, checked) {
|
|
708
778
|
const at = `/${escapePointer(name)}`;
|
|
709
|
-
if (provided.nameable?.includes(name) !== true)
|
|
779
|
+
if (checked && provided.nameable?.includes(name) !== true)
|
|
710
780
|
return refuse('provided-type', at);
|
|
711
781
|
if (!isRecord(value))
|
|
712
782
|
return refuse('schema', at);
|
|
713
783
|
const declared = Object.keys(value).find((key) => !PROVIDED_KEYWORDS.includes(key));
|
|
714
|
-
if (declared !== undefined)
|
|
784
|
+
if (checked && declared !== undefined)
|
|
715
785
|
return refuse('provided-type', `${at}/${escapePointer(declared)}`);
|
|
716
786
|
const { create_roles: createRoles, delete_roles: deleteRoles } = value;
|
|
717
787
|
if (createRoles !== undefined && !roleNames(createRoles))
|
|
@@ -728,29 +798,31 @@ function readType(name, value, context) {
|
|
|
728
798
|
const at = `/${escapePointer(name)}`;
|
|
729
799
|
if (!isRecord(value))
|
|
730
800
|
return refuse('schema', at);
|
|
731
|
-
const {
|
|
801
|
+
const { member_document: mark, create_roles: createRoles, delete_roles: deleteRoles, indexed, ...ruled } = value;
|
|
732
802
|
if (mark !== undefined && typeof mark !== 'boolean')
|
|
733
803
|
return refuse('member_document', `${at}/member_document`);
|
|
734
804
|
if (createRoles !== undefined && !roleNames(createRoles))
|
|
735
805
|
return refuse('create_roles', `${at}/create_roles`);
|
|
736
806
|
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
737
807
|
return refuse('delete_roles', `${at}/delete_roles`);
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if ('failure' in read)
|
|
742
|
-
return read.failure;
|
|
743
|
-
const unbranched = withoutBranchSections(ruled, declared, at);
|
|
744
|
-
if ('failure' in unbranched)
|
|
745
|
-
return unbranched.failure;
|
|
746
|
-
const { schema, written } = unruled(unbranched.schema);
|
|
808
|
+
if (indexed !== undefined && !strings(indexed))
|
|
809
|
+
return refuse('indexed', `${at}/indexed`);
|
|
810
|
+
const { schema, written } = unruled(ruled);
|
|
747
811
|
const failure = schemaFailure(schema, at, context);
|
|
748
812
|
if (failure !== undefined)
|
|
749
813
|
return failure;
|
|
750
814
|
const rules = Object.create(null);
|
|
815
|
+
const unique = [];
|
|
751
816
|
for (const [field, keywords] of written) {
|
|
752
817
|
const properties = schema.properties;
|
|
753
818
|
const where = `${at}/properties/${escapePointer(field)}`;
|
|
819
|
+
if (Object.hasOwn(keywords, UNIQUE)) {
|
|
820
|
+
if (keywords[UNIQUE] !== true || indexed?.includes(field) !== true)
|
|
821
|
+
return refuse(UNIQUE, `${where}/${UNIQUE}`);
|
|
822
|
+
unique.push(field);
|
|
823
|
+
}
|
|
824
|
+
if (!FIELD_RULES.some((keyword) => Object.hasOwn(keywords, keyword)))
|
|
825
|
+
continue;
|
|
754
826
|
const ruling = fieldRules(keywords, properties[field], where, context.defs);
|
|
755
827
|
if ('rule' in ruling)
|
|
756
828
|
return ruling;
|
|
@@ -763,16 +835,17 @@ function readType(name, value, context) {
|
|
|
763
835
|
fields[MEMBER_FIELD] = { type: 'string', prose: false };
|
|
764
836
|
const defs = Object.create(null);
|
|
765
837
|
reachedDefs(value, context.defs, defs);
|
|
766
|
-
const { create_roles: _create, delete_roles: _delete, ...shaped } = value;
|
|
838
|
+
const { create_roles: _create, delete_roles: _delete, indexed: _indexed, ...shaped } = value;
|
|
767
839
|
return {
|
|
768
840
|
name,
|
|
769
841
|
memberDocument,
|
|
770
|
-
|
|
842
|
+
root: { ...root, properties: { ...HOUSE_KEYS, ...fields } },
|
|
771
843
|
fields,
|
|
772
|
-
sections: read.sections,
|
|
773
844
|
rules,
|
|
774
845
|
...(createRoles === undefined ? {} : { createRoles }),
|
|
775
846
|
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
847
|
+
...(indexed === undefined ? {} : { indexed }),
|
|
848
|
+
...(unique.length === 0 ? {} : { unique }),
|
|
776
849
|
shape: {
|
|
777
850
|
schema: written.size === 0 ? shaped : { ...shaped, properties: schema.properties },
|
|
778
851
|
defs,
|
|
@@ -782,25 +855,48 @@ function readType(name, value, context) {
|
|
|
782
855
|
function lineAt(text, offset) {
|
|
783
856
|
return text.slice(0, offset).split(/\r\n|\r|\n/).length;
|
|
784
857
|
}
|
|
785
|
-
|
|
858
|
+
function roleNeeds(value) {
|
|
859
|
+
const at = `/${ROLES_SECTION}`;
|
|
860
|
+
if (!isRecord(value))
|
|
861
|
+
return refuse(ROLES_SECTION, at);
|
|
862
|
+
const needs = Object.create(null);
|
|
863
|
+
for (const [role, need] of Object.entries(value)) {
|
|
864
|
+
if (role === '' || typeof need !== 'string' || !ROLE_NEEDS.includes(need))
|
|
865
|
+
return refuse(ROLES_SECTION, `${at}/${escapePointer(role)}`);
|
|
866
|
+
needs[role] = need;
|
|
867
|
+
}
|
|
868
|
+
return { needs };
|
|
869
|
+
}
|
|
870
|
+
export function readSchema(text, provided = NO_TYPES, checked = true, start = 0, end = text.length) {
|
|
786
871
|
let root;
|
|
787
872
|
try {
|
|
788
|
-
root = jsValue(parseYamlMapping(text,
|
|
873
|
+
root = jsValue(parseYamlMapping(text, start, end));
|
|
789
874
|
}
|
|
790
875
|
catch (error) {
|
|
791
876
|
if (error instanceof YamlError)
|
|
792
877
|
return refuse('schema-yaml', `line ${lineAt(text, error.offset)}`);
|
|
793
878
|
throw error;
|
|
794
879
|
}
|
|
795
|
-
const defs = root
|
|
880
|
+
const defs = root[DEFS_SECTION] ?? Object.create(null);
|
|
796
881
|
if (!isRecord(defs))
|
|
797
|
-
return refuse(
|
|
798
|
-
const
|
|
799
|
-
|
|
800
|
-
|
|
882
|
+
return refuse(DEFS_SECTION, `/${DEFS_SECTION}`);
|
|
883
|
+
const roles = Object.hasOwn(root, ROLES_SECTION) ? roleNeeds(root[ROLES_SECTION]) : undefined;
|
|
884
|
+
if (roles !== undefined && 'rule' in roles)
|
|
885
|
+
return roles;
|
|
886
|
+
const names = Object.keys(root).filter((key) => !SECTIONS.includes(key));
|
|
887
|
+
for (const name of checked ? names : []) {
|
|
888
|
+
if (name === '' ||
|
|
889
|
+
name.startsWith('$') ||
|
|
890
|
+
name === BUILT_IN_TYPE ||
|
|
891
|
+
name === ATTACHMENT ||
|
|
892
|
+
RESERVED_TYPE_NAMES.includes(name))
|
|
801
893
|
return refuse('schema-type-name', `/${escapePointer(name)}`);
|
|
802
894
|
}
|
|
803
|
-
const context = {
|
|
895
|
+
const context = {
|
|
896
|
+
defs,
|
|
897
|
+
types: new Set([...names, ...Object.keys(provided.types)]),
|
|
898
|
+
checked,
|
|
899
|
+
};
|
|
804
900
|
for (const [name, def] of Object.entries(defs)) {
|
|
805
901
|
const failure = schemaFailure(def, `/$defs/${escapePointer(name)}`, context);
|
|
806
902
|
if (failure !== undefined)
|
|
@@ -810,11 +906,11 @@ export function readSchema(text, provided = NO_TYPES) {
|
|
|
810
906
|
let marked = false;
|
|
811
907
|
for (const name of names) {
|
|
812
908
|
const definition = Object.hasOwn(provided.types, name)
|
|
813
|
-
? providedType(name, root[name], provided)
|
|
909
|
+
? providedType(name, root[name], provided, checked)
|
|
814
910
|
: readType(name, root[name], context);
|
|
815
911
|
if ('rule' in definition)
|
|
816
912
|
return definition;
|
|
817
|
-
if (definition.memberDocument) {
|
|
913
|
+
if (checked && definition.memberDocument) {
|
|
818
914
|
if (marked)
|
|
819
915
|
return refuse('member_document', `/${escapePointer(name)}/member_document`);
|
|
820
916
|
marked = true;
|
|
@@ -825,5 +921,8 @@ export function readSchema(text, provided = NO_TYPES) {
|
|
|
825
921
|
if (!Object.hasOwn(types, name))
|
|
826
922
|
types[name] = definition;
|
|
827
923
|
}
|
|
828
|
-
return Object.freeze({
|
|
924
|
+
return Object.freeze({
|
|
925
|
+
types: Object.freeze(types),
|
|
926
|
+
...(roles === undefined ? {} : { roles: Object.freeze(roles.needs) }),
|
|
927
|
+
});
|
|
829
928
|
}
|
package/dist/document.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
import { type Body, type Naming } from './body.js';
|
|
1
2
|
import { type Definition } from './definition.js';
|
|
2
|
-
import { type
|
|
3
|
-
import type { ApplyResult, BodyResult,
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function parse(content: string, file?: string): ParseResult;
|
|
3
|
+
import { type HrefOccurrence, type Reading } from './markdown.js';
|
|
4
|
+
import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, LinkSpan, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
|
|
5
|
+
export declare function readingOf(document: Document): Reading;
|
|
6
|
+
export declare function bodyOf(document: Document): Body | null;
|
|
7
|
+
export declare function linkDestinations(document: Document): readonly HrefOccurrence[];
|
|
8
|
+
export declare function textSpans(document: Document): readonly Span[];
|
|
9
|
+
export declare function parse(content: string, file?: string, definition?: Definition | DefinitionOf): ParseResult;
|
|
10
|
+
export declare function create(type: string | undefined, definition?: Definition): Document;
|
|
9
11
|
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
|
|
10
12
|
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
|
11
13
|
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
14
|
+
export declare function unlinkBody(body: string, hrefs: ReadonlySet<string>): UnlinkedBody;
|
|
12
15
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
16
|
+
export declare function linkSpans(body: string): readonly LinkSpan[];
|
|
13
17
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
14
|
-
export declare function
|
|
18
|
+
export declare function bodyWith(document: Document, definition: Definition | undefined): Body | null | Refusal;
|
|
19
|
+
export declare function partText(part: string): string;
|
|
20
|
+
export declare function apply(document: Document, changes: readonly Change[], definition?: Definition, nameOf?: Naming): ApplyResult;
|
|
21
|
+
export declare function relabel(document: Document, before: Definition, after: Definition): string;
|
|
22
|
+
export declare function relabels(before: Definition, after: Definition): boolean;
|
|
15
23
|
export declare function serialize(document: Document): string;
|
|
16
|
-
export declare function frontmatter(document: Document): YamlMap | null;
|
|
17
24
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,IAAI,EACT,KAAK,MAAM,EAGZ,MAAM,WAAW,CAAC;AACnB,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EASL,KAAK,cAAc,EACnB,KAAK,OAAO,EAEb,MAAM,eAAe,CAAC;AAevB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,YAAY,EACZ,QAAQ,EAER,IAAI,EACJ,QAAQ,EACR,WAAW,EACX,OAAO,EACP,IAAI,EACJ,YAAY,EACb,MAAM,YAAY,CAAC;AAoDpB,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAKrD;AAeD,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,IAAI,CAGtD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,cAAc,EAAE,CAQ9E;AAiCD,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,IAAI,EAAE,CAM7D;AA6FD,wBAAgB,KAAK,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,SAAK,EACT,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GACrC,WAAW,CA8Cb;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,UAAU,CAAC,EAAE,UAAU,GAAG,QAAQ,CAQlF;AA2CD,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,UAAU,EACvB,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GACpC,WAAW,CAuBb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAUrF;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,UAAU,CAmBZ;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,YAAY,CAqBjF;AAeD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,QAAQ,EAAE,CAwB3D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAErE;AAgCD,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,GAAG,SAAS,GACjC,IAAI,GAAG,IAAI,GAAG,OAAO,CAMvB;AAqKD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7C;AAgfD,wBAAgB,KAAK,CACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,UAAU,CAAC,EAAE,UAAU,EACvB,MAAM,CAAC,EAAE,MAAM,GACd,WAAW,CA2Gb;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,CAYzF;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAEvE;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD"}
|