@agentshouse/mdmodel 0.1.0-c3c0e116a89f8 → 0.1.0-c3ebba90039b4
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 +200 -196
- package/README.md +25 -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 +28 -0
- package/dist/definition.d.ts +28 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +250 -126
- package/dist/document.d.ts +12 -6
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +705 -105
- package/dist/event.d.ts +1 -2
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +4 -4
- package/dist/facts.d.ts.map +1 -1
- package/dist/facts.js +7 -4
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/folders.d.ts +5 -0
- package/dist/folders.d.ts.map +1 -0
- package/dist/folders.js +19 -0
- 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 +30 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -10
- 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 +9 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +68 -0
- package/dist/markdown.d.ts +27 -7
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +25 -64
- 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 +102 -21
- package/dist/query/language.d.ts +4 -1
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +4 -3
- package/dist/query/match.d.ts +1 -1
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +3 -24
- package/dist/query/rows.d.ts +6 -1
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +37 -8
- package/dist/query/sql.d.ts +10 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +22 -3
- package/dist/query/walk.d.ts +73 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +277 -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 +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +15 -4
- 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 +21 -38
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +8 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +174 -174
- 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 +154 -33
- package/fixtures/README.md +93 -71
- 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/absent-optional-field/{schema.yaml → 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/boolean-field/{schema.yaml → 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/date-time-format/{schema.yaml → 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/folder-keeps-a-built-in-type/expected.json +1 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/host.md +13 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/map.md +24 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/open.md +13 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/schema.md +9 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/expected.json +5 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/schema.md +7 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/expected.json +6 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/library/tickets/archive/2025/old.md +1 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/schema.md +15 -0
- package/fixtures/cases/folder-refuses-a-declared-any/expected.json +6 -0
- package/fixtures/cases/folder-refuses-a-declared-any/library/tickets/door.md +5 -0
- package/fixtures/cases/folder-refuses-a-declared-any/schema.md +9 -0
- package/fixtures/cases/folder-refuses-another-declared-type/expected.json +6 -0
- package/fixtures/cases/folder-refuses-another-declared-type/library/tickets/door.md +5 -0
- package/fixtures/cases/folder-refuses-another-declared-type/schema.md +12 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/expected.json +1 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/notes/plan.md +7 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/gate.md +7 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/schema.md +13 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/expected.json +6 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/library/tickets/2026/gate.md +1 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/schema.md +9 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/expected.json +7 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/schema.md +9 -0
- package/fixtures/cases/folder-under-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/folder-under-a-reserved-name/schema.md +7 -0
- package/fixtures/cases/folder-without-a-trailing-slash/context.json +1 -0
- package/fixtures/cases/folder-without-a-trailing-slash/expected.json +5 -0
- package/fixtures/cases/folder-without-a-trailing-slash/schema.md +7 -0
- package/fixtures/cases/frontmatter-construct/context.json +1 -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/context.json +1 -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/library/item.md +3 -1
- 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/context.json +1 -0
- package/fixtures/cases/list-item-enum/expected.json +7 -0
- package/fixtures/cases/list-item-enum/library/task.md +7 -0
- package/fixtures/cases/list-item-enum/schema.md +5 -0
- package/fixtures/cases/list-item-kind/context.json +1 -0
- package/fixtures/cases/list-item-kind/expected.json +7 -0
- package/fixtures/cases/list-item-kind/library/task.md +6 -0
- package/fixtures/cases/list-item-kind/schema.md +5 -0
- package/fixtures/cases/list-items/context.json +1 -0
- package/fixtures/cases/list-items/expected.json +1 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.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/context.json +1 -0
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.md +5 -0
- package/fixtures/cases/list-reference-type/context.json +1 -0
- package/fixtures/cases/list-reference-type/expected.json +7 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.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/expected.json +2 -1
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -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-its-type/schema.yaml → typed-path-names-another-type/schema.md} +2 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +1 -1
- package/fixtures/cases/{typed-path-names-no-type/schema.yaml → typed-path-names-its-type/schema.md} +2 -0
- package/fixtures/cases/{typed-path-names-another-type/schema.yaml → typed-path-names-no-type/schema.md} +2 -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/library/rooms/team/tasks/plan.md +2 -1
- package/fixtures/cases/{unnamed-typed-path-without-a-body/schema.yaml → unnamed-typed-path-checks-its-fields/schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/{unnamed-typed-path-checks-its-fields/schema.yaml → unnamed-typed-path-names-a-type/schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/{unnamed-typed-path-names-a-type/schema.yaml → unnamed-typed-path-reads-its-type/schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
- package/fixtures/cases/{unnamed-typed-path-reads-its-type/schema.yaml → unnamed-typed-path-without-a-body/schema.md} +2 -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 +6 -6
- package/fixtures/queries.json +827 -2
- package/fixtures/references.json +15 -0
- package/package.json +2 -2
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -321
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -123
- 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/lazy-list-item/schema.yaml +0 -3
- 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/thematic-break-in-a-list-section/expected.json +0 -6
- package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +0 -7
- package/fixtures/cases/thematic-break-in-a-list-section/schema.yaml +0 -3
- 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 -454
- package/fixtures/projection.json +0 -358
- /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 → folder-keeps-a-built-in-type}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → folder-names-no-type-of-the-schema}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → folder-nearer-entry-types-a-document}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → folder-refuses-a-declared-any}/context.json +0 -0
- /package/fixtures/cases/{section-items → folder-refuses-another-declared-type}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → folder-type-is-the-type-a-reference-reaches}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → folder-types-a-document-in-a-folder-below-it}/context.json +0 -0
- /package/fixtures/cases/{structured-section → folder-types-a-document-that-names-no-type}/context.json +0 -0
- /package/fixtures/cases/{thematic-break-in-a-list-section → folder-under-a-reserved-name}/context.json +0 -0
- /package/fixtures/cases/{section-items → list-items}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-path → list-reference-path}/library/other.md +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
- /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
package/dist/definition.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
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';
|
|
3
|
+
import { normalize } from './paths.js';
|
|
2
4
|
import { linearPattern } from './pattern.js';
|
|
5
|
+
import { isReservedName } from './reserved.js';
|
|
3
6
|
import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
|
|
4
7
|
export const JSON_TYPES = [
|
|
5
8
|
'string',
|
|
@@ -12,7 +15,7 @@ export const JSON_TYPES = [
|
|
|
12
15
|
];
|
|
13
16
|
export const BUILT_IN_TYPE = 'any';
|
|
14
17
|
export const ATTACHMENT = 'attachment';
|
|
15
|
-
const
|
|
18
|
+
const RESERVED_TYPE_NAMES = [TYPE_FIELD];
|
|
16
19
|
const COMPOSITES = ['array', 'object'];
|
|
17
20
|
const ANNOTATIONS = new Set([
|
|
18
21
|
'$comment',
|
|
@@ -24,20 +27,29 @@ const ANNOTATIONS = new Set([
|
|
|
24
27
|
'readOnly',
|
|
25
28
|
'writeOnly',
|
|
26
29
|
]);
|
|
30
|
+
export const OPENING = ['additionalProperties', 'unevaluatedProperties'];
|
|
27
31
|
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
32
|
+
const UNIQUE = 'unique';
|
|
33
|
+
const FIELD_KEYWORDS = [...FIELD_RULES, UNIQUE];
|
|
28
34
|
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
29
35
|
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
36
|
+
const DEFS_SECTION = '$defs';
|
|
37
|
+
const ROLES_SECTION = 'roles';
|
|
38
|
+
export const FOLDERS_SECTION = 'folders';
|
|
39
|
+
const SECTIONS = [DEFS_SECTION, ROLES_SECTION, FOLDERS_SECTION];
|
|
40
|
+
const ROLE_NEEDS = ['read', 'write'];
|
|
30
41
|
const DEFS_REFERENCE = '#/$defs/';
|
|
31
42
|
const UNBOUNDED_FORMAT = 'url';
|
|
43
|
+
export const UNIONS = ['anyOf', 'oneOf'];
|
|
32
44
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
33
45
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
34
46
|
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
35
47
|
const HOUSE_KEYS = {
|
|
36
48
|
[TYPE_FIELD]: { prose: false },
|
|
37
49
|
[SITE_FIELD]: { prose: false },
|
|
38
|
-
[
|
|
50
|
+
[SUBMITTED_FIELD]: { prose: false },
|
|
39
51
|
};
|
|
40
|
-
function refuse(rule, location) {
|
|
52
|
+
export function refuse(rule, location) {
|
|
41
53
|
return { rule, location };
|
|
42
54
|
}
|
|
43
55
|
export function escapePointer(key) {
|
|
@@ -219,6 +231,7 @@ const KEYWORDS = {
|
|
|
219
231
|
node.cross_room === true));
|
|
220
232
|
},
|
|
221
233
|
cross_room: (value, _at, node) => typeof value === 'boolean' && node.reference !== undefined,
|
|
234
|
+
unique: () => false,
|
|
222
235
|
};
|
|
223
236
|
function sharedType(values) {
|
|
224
237
|
if (values.length === 0)
|
|
@@ -247,36 +260,41 @@ function firstOf(held, read) {
|
|
|
247
260
|
}
|
|
248
261
|
return undefined;
|
|
249
262
|
}
|
|
250
|
-
function conjoined(
|
|
263
|
+
export function conjoined(declared, defs, ancestry) {
|
|
251
264
|
const held = [];
|
|
252
265
|
const reached = new Set(ancestry);
|
|
253
|
-
const visit = (node) => {
|
|
254
|
-
if (!isRecord(node) || held.
|
|
266
|
+
const visit = (node, at) => {
|
|
267
|
+
if (!isRecord(node) || held.some((one) => one.node === node))
|
|
255
268
|
return;
|
|
256
|
-
held.push(node);
|
|
269
|
+
held.push({ node, at });
|
|
257
270
|
if (typeof node.$ref === 'string') {
|
|
258
271
|
const target = refTarget(node.$ref, defs)?.node;
|
|
259
272
|
if (target !== undefined && !reached.has(target)) {
|
|
260
273
|
reached.add(target);
|
|
261
|
-
visit(target);
|
|
274
|
+
visit(target, node.$ref.slice('#'.length));
|
|
262
275
|
}
|
|
263
276
|
}
|
|
264
277
|
if (Array.isArray(node.allOf))
|
|
265
|
-
|
|
266
|
-
visit(one);
|
|
278
|
+
node.allOf.forEach((one, index) => visit(one, `${at}/allOf/${index}`));
|
|
267
279
|
};
|
|
268
|
-
for (const node of
|
|
269
|
-
visit(node);
|
|
280
|
+
for (const { node, at } of declared)
|
|
281
|
+
visit(node, at);
|
|
270
282
|
return { held, ancestry: reached };
|
|
271
283
|
}
|
|
272
|
-
function variantsOf(node) {
|
|
284
|
+
export function variantsOf({ node, at }) {
|
|
285
|
+
const listed = (keyword) => {
|
|
286
|
+
const branches = node[keyword];
|
|
287
|
+
return Array.isArray(branches)
|
|
288
|
+
? branches.map((branch, index) => ({ node: branch, at: `${at}/${keyword}/${index}` }))
|
|
289
|
+
: [];
|
|
290
|
+
};
|
|
273
291
|
return [
|
|
274
|
-
...(
|
|
275
|
-
...(
|
|
276
|
-
node.then,
|
|
277
|
-
node.else,
|
|
278
|
-
...(isRecord(node.dependentSchemas) ?
|
|
279
|
-
].filter(isRecord);
|
|
292
|
+
...listed('anyOf'),
|
|
293
|
+
...listed('oneOf'),
|
|
294
|
+
{ node: node.then, at: `${at}/then` },
|
|
295
|
+
{ node: node.else, at: `${at}/else` },
|
|
296
|
+
...Object.entries(isRecord(node.dependentSchemas) ? node.dependentSchemas : {}).map(([key, branch]) => ({ node: branch, at: `${at}/dependentSchemas/${escapePointer(key)}` })),
|
|
297
|
+
].filter((one) => isRecord(one.node));
|
|
280
298
|
}
|
|
281
299
|
function united(left, right) {
|
|
282
300
|
if (left === undefined || right === undefined)
|
|
@@ -307,6 +325,8 @@ function joined(left, right) {
|
|
|
307
325
|
return shared === undefined ? [] : [{ pattern, facts: shared }];
|
|
308
326
|
});
|
|
309
327
|
const additional = both(left.additional, right.additional);
|
|
328
|
+
const required = (left.required ?? []).filter((name) => right.required?.includes(name) === true);
|
|
329
|
+
const title = left.title ?? right.title;
|
|
310
330
|
return {
|
|
311
331
|
...(type === undefined ? {} : { type }),
|
|
312
332
|
...(format === undefined ? {} : { format }),
|
|
@@ -314,9 +334,13 @@ function joined(left, right) {
|
|
|
314
334
|
...(reference === undefined ? {} : { reference }),
|
|
315
335
|
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
316
336
|
prose: left.prose && right.prose,
|
|
337
|
+
...(title === undefined ? {} : { title }),
|
|
338
|
+
...(left.markdown === true || right.markdown === true ? { markdown: true } : {}),
|
|
339
|
+
...(left.json === true || right.json === true ? { json: true } : {}),
|
|
317
340
|
...(prefix === undefined ? {} : { prefix }),
|
|
318
341
|
...(items === undefined ? {} : { items }),
|
|
319
342
|
...(Object.keys(properties).length === 0 ? {} : { properties }),
|
|
343
|
+
...(required.length === 0 ? {} : { required }),
|
|
320
344
|
...(patterns.length === 0 ? {} : { patterns }),
|
|
321
345
|
...(additional === undefined ? {} : { additional }),
|
|
322
346
|
};
|
|
@@ -368,12 +392,78 @@ function inheritedOf(held) {
|
|
|
368
392
|
return Object.keys(kept).length === 0 ? [] : [kept];
|
|
369
393
|
});
|
|
370
394
|
}
|
|
395
|
+
function typeSet(type) {
|
|
396
|
+
const listed = typeof type === 'string' ? [type] : Array.isArray(type) ? type : null;
|
|
397
|
+
return listed === null
|
|
398
|
+
? null
|
|
399
|
+
: new Set(listed.map((one) => (one === 'integer' ? 'number' : String(one))));
|
|
400
|
+
}
|
|
401
|
+
function valueType(value) {
|
|
402
|
+
if (value === null)
|
|
403
|
+
return 'null';
|
|
404
|
+
if (Array.isArray(value))
|
|
405
|
+
return 'array';
|
|
406
|
+
return typeof value;
|
|
407
|
+
}
|
|
408
|
+
function narrowed(left, right) {
|
|
409
|
+
if (left === null)
|
|
410
|
+
return right;
|
|
411
|
+
if (right === null)
|
|
412
|
+
return left;
|
|
413
|
+
return new Set([...left].filter((one) => right.has(one)));
|
|
414
|
+
}
|
|
415
|
+
export function admitted(nodes, defs, ancestry) {
|
|
416
|
+
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
417
|
+
let kept = null;
|
|
418
|
+
for (const { node } of conjunction.held) {
|
|
419
|
+
kept = narrowed(kept, typeSet(node.type));
|
|
420
|
+
if (Array.isArray(node.enum))
|
|
421
|
+
kept = narrowed(kept, new Set(node.enum.map(valueType)));
|
|
422
|
+
if (Object.hasOwn(node, 'const'))
|
|
423
|
+
kept = narrowed(kept, new Set([valueType(node.const)]));
|
|
424
|
+
for (const keyword of UNIONS) {
|
|
425
|
+
const branches = node[keyword];
|
|
426
|
+
if (!Array.isArray(branches))
|
|
427
|
+
continue;
|
|
428
|
+
let union = new Set();
|
|
429
|
+
for (const branch of branches) {
|
|
430
|
+
const one = admitted([branch], defs, conjunction.ancestry);
|
|
431
|
+
if (one === null) {
|
|
432
|
+
union = null;
|
|
433
|
+
break;
|
|
434
|
+
}
|
|
435
|
+
for (const type of one)
|
|
436
|
+
union.add(type);
|
|
437
|
+
}
|
|
438
|
+
kept = narrowed(kept, union);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
return kept;
|
|
442
|
+
}
|
|
443
|
+
function structuredUnion(held, defs, ancestry) {
|
|
444
|
+
return held.some((node) => UNIONS.some((keyword) => Array.isArray(node[keyword]) &&
|
|
445
|
+
node[keyword].some((branch) => {
|
|
446
|
+
const types = admitted([branch], defs, ancestry);
|
|
447
|
+
return types === null || types.has('object') || types.has('array');
|
|
448
|
+
})));
|
|
449
|
+
}
|
|
450
|
+
function openWhole(held) {
|
|
451
|
+
return held.some((node) => OPENING.some((keyword) => node[keyword] === true));
|
|
452
|
+
}
|
|
453
|
+
function writtenAsJson(held, defs, ancestry) {
|
|
454
|
+
const types = admitted(held, defs, ancestry);
|
|
455
|
+
if (types === null || types.size !== 1)
|
|
456
|
+
return true;
|
|
457
|
+
return structuredUnion(held, defs, ancestry) || (types.has('object') && openWhole(held));
|
|
458
|
+
}
|
|
371
459
|
function factsOf(nodes, defs, ancestry) {
|
|
372
|
-
const {
|
|
460
|
+
const conjunction = conjoined(nodes.map((node) => ({ node, at: '' })), defs, ancestry);
|
|
461
|
+
const reached = conjunction.ancestry;
|
|
462
|
+
const held = conjunction.held.map(({ node }) => node);
|
|
373
463
|
const inherited = inheritedOf(held);
|
|
374
|
-
const variants = new Map(held
|
|
464
|
+
const variants = new Map(conjunction.held
|
|
375
465
|
.flatMap(variantsOf)
|
|
376
|
-
.map((branch) => [branch, factsOf([branch, ...inherited], defs, reached)]));
|
|
466
|
+
.map(({ node: branch }) => [branch, factsOf([branch, ...inherited], defs, reached)]));
|
|
377
467
|
const unions = alternativesOf(held, variants);
|
|
378
468
|
const alternatives = unions.map((kept) => kept.reduce(joined));
|
|
379
469
|
const listed = [
|
|
@@ -414,13 +504,18 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
414
504
|
: Array.from({ length: Math.max(...tuples.map((tuple) => tuple.length)) }, (_, index) => factsOf(tuples.flatMap((tuple) => (index < tuple.length ? [tuple[index]] : [])), defs, reached))));
|
|
415
505
|
const mapped = type === 'object' || type === undefined;
|
|
416
506
|
const properties = mapped ? propertiesOf(held, variants, defs, reached) : undefined;
|
|
507
|
+
const required = mapped
|
|
508
|
+
? [...new Set(held.flatMap((node) => (Array.isArray(node.required) ? node.required : [])))]
|
|
509
|
+
: [];
|
|
417
510
|
const patterns = mapped
|
|
418
511
|
? held.flatMap((node) => Object.entries(isRecord(node.patternProperties) ? node.patternProperties : {}).map(([pattern, schema]) => ({ pattern, facts: factsOf([schema], defs, reached) })))
|
|
419
512
|
: [];
|
|
420
513
|
const opened = mapped
|
|
421
|
-
? held.flatMap((node) =>
|
|
514
|
+
? held.flatMap((node) => OPENING.map((keyword) => (node[keyword] === true ? {} : node[keyword])).filter(isRecord))
|
|
422
515
|
: [];
|
|
423
516
|
const additional = opened.length === 0 ? undefined : factsOf(opened, defs, reached);
|
|
517
|
+
const title = firstOf(nodes.filter(isRecord), (node) => typeof node.title === 'string' ? node.title : undefined);
|
|
518
|
+
const markdown = held.some((node) => node.contentMediaType === MEDIA_TYPES.markdown);
|
|
424
519
|
return {
|
|
425
520
|
...(type === undefined ? {} : { type }),
|
|
426
521
|
...(format === undefined ? {} : { format }),
|
|
@@ -428,9 +523,13 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
428
523
|
...(reference === undefined ? {} : { reference }),
|
|
429
524
|
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
430
525
|
prose,
|
|
526
|
+
...(title === undefined ? {} : { title }),
|
|
527
|
+
...(markdown ? { markdown: true } : {}),
|
|
528
|
+
...(writtenAsJson(held, defs, ancestry) ? { json: true } : {}),
|
|
431
529
|
...(prefix === undefined ? {} : { prefix }),
|
|
432
530
|
...(items === undefined ? {} : { items }),
|
|
433
531
|
...(properties === undefined ? {} : { properties }),
|
|
532
|
+
...(required.length === 0 ? {} : { required }),
|
|
434
533
|
...(patterns.length === 0 ? {} : { patterns }),
|
|
435
534
|
...(additional === undefined ? {} : { additional }),
|
|
436
535
|
};
|
|
@@ -457,7 +556,7 @@ export function fieldFacts(definition, key) {
|
|
|
457
556
|
return definition.fields[key];
|
|
458
557
|
if (Object.hasOwn(HOUSE_KEYS, key))
|
|
459
558
|
return undefined;
|
|
460
|
-
return memberFacts(definition.
|
|
559
|
+
return memberFacts(definition.root, key);
|
|
461
560
|
}
|
|
462
561
|
function stepped({ facts, through, conditional }, token) {
|
|
463
562
|
if (facts.type === 'array' && ARRAY_INDEX.test(token)) {
|
|
@@ -515,87 +614,60 @@ function reachedDefs(value, defs, reached) {
|
|
|
515
614
|
reachedDefs(held, defs, reached);
|
|
516
615
|
}
|
|
517
616
|
}
|
|
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 };
|
|
617
|
+
function untitledSchema(node) {
|
|
618
|
+
if (!isRecord(node))
|
|
619
|
+
return node;
|
|
620
|
+
const kept = {};
|
|
621
|
+
for (const [key, held] of Object.entries(node)) {
|
|
622
|
+
if (key === 'title' && typeof held === 'string')
|
|
536
623
|
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);
|
|
624
|
+
const check = Object.hasOwn(KEYWORDS, key) ? KEYWORDS[key] : undefined;
|
|
625
|
+
if (check === SCHEMA)
|
|
626
|
+
kept[key] = untitledSchema(held);
|
|
627
|
+
else if (check === SCHEMA_LIST && Array.isArray(held))
|
|
628
|
+
kept[key] = held.map(untitledSchema);
|
|
629
|
+
else if (check === SCHEMA_MAP && isRecord(held))
|
|
630
|
+
kept[key] = untitledMap(held);
|
|
631
|
+
else
|
|
632
|
+
kept[key] = held;
|
|
564
633
|
}
|
|
565
|
-
return
|
|
634
|
+
return kept;
|
|
566
635
|
}
|
|
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
|
-
|
|
636
|
+
function untitledMap(map) {
|
|
637
|
+
return Object.fromEntries(Object.entries(map).map(([key, held]) => [key, untitledSchema(held)]));
|
|
638
|
+
}
|
|
639
|
+
function untitledFacts(facts) {
|
|
640
|
+
const { title: _title, prefix, items, properties, patterns, additional, ...kept } = facts;
|
|
641
|
+
return {
|
|
642
|
+
...kept,
|
|
643
|
+
...(prefix === undefined ? {} : { prefix: prefix.map(untitledFacts) }),
|
|
644
|
+
...(items === undefined ? {} : { items: untitledFacts(items) }),
|
|
645
|
+
...(properties === undefined
|
|
646
|
+
? {}
|
|
647
|
+
: {
|
|
648
|
+
properties: Object.fromEntries(Object.entries(properties).map(([key, held]) => [key, untitledFacts(held)])),
|
|
649
|
+
}),
|
|
650
|
+
...(patterns === undefined
|
|
651
|
+
? {}
|
|
652
|
+
: {
|
|
653
|
+
patterns: patterns.map(({ pattern, facts: held }) => ({
|
|
654
|
+
pattern,
|
|
655
|
+
facts: untitledFacts(held),
|
|
656
|
+
})),
|
|
657
|
+
}),
|
|
658
|
+
...(additional === undefined ? {} : { additional: untitledFacts(additional) }),
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
export function untitled(definition) {
|
|
662
|
+
return {
|
|
663
|
+
...definition,
|
|
664
|
+
root: untitledFacts(definition.root),
|
|
665
|
+
fields: Object.fromEntries(Object.entries(definition.fields).map(([key, held]) => [key, untitledFacts(held)])),
|
|
666
|
+
shape: {
|
|
667
|
+
schema: untitledSchema(definition.shape.schema),
|
|
668
|
+
defs: untitledMap(definition.shape.defs),
|
|
669
|
+
},
|
|
670
|
+
};
|
|
599
671
|
}
|
|
600
672
|
function deepFreeze(value) {
|
|
601
673
|
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
@@ -696,12 +768,12 @@ function unruled(schema) {
|
|
|
696
768
|
return { schema, written };
|
|
697
769
|
const properties = Object.create(null);
|
|
698
770
|
for (const [field, node] of Object.entries(schema.properties)) {
|
|
699
|
-
if (!isRecord(node) || !
|
|
771
|
+
if (!isRecord(node) || !FIELD_KEYWORDS.some((keyword) => Object.hasOwn(node, keyword))) {
|
|
700
772
|
properties[field] = node;
|
|
701
773
|
continue;
|
|
702
774
|
}
|
|
703
775
|
written.set(field, node);
|
|
704
|
-
properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !
|
|
776
|
+
properties[field] = Object.fromEntries(Object.entries(node).filter(([keyword]) => !FIELD_KEYWORDS.includes(keyword)));
|
|
705
777
|
}
|
|
706
778
|
return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
|
|
707
779
|
}
|
|
@@ -729,29 +801,31 @@ function readType(name, value, context) {
|
|
|
729
801
|
const at = `/${escapePointer(name)}`;
|
|
730
802
|
if (!isRecord(value))
|
|
731
803
|
return refuse('schema', at);
|
|
732
|
-
const {
|
|
804
|
+
const { member_document: mark, create_roles: createRoles, delete_roles: deleteRoles, indexed, ...ruled } = value;
|
|
733
805
|
if (mark !== undefined && typeof mark !== 'boolean')
|
|
734
806
|
return refuse('member_document', `${at}/member_document`);
|
|
735
807
|
if (createRoles !== undefined && !roleNames(createRoles))
|
|
736
808
|
return refuse('create_roles', `${at}/create_roles`);
|
|
737
809
|
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
738
810
|
return refuse('delete_roles', `${at}/delete_roles`);
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
if ('failure' in read)
|
|
743
|
-
return read.failure;
|
|
744
|
-
const unbranched = withoutBranchSections(ruled, declared, at);
|
|
745
|
-
if ('failure' in unbranched)
|
|
746
|
-
return unbranched.failure;
|
|
747
|
-
const { schema, written } = unruled(unbranched.schema);
|
|
811
|
+
if (indexed !== undefined && !strings(indexed))
|
|
812
|
+
return refuse('indexed', `${at}/indexed`);
|
|
813
|
+
const { schema, written } = unruled(ruled);
|
|
748
814
|
const failure = schemaFailure(schema, at, context);
|
|
749
815
|
if (failure !== undefined)
|
|
750
816
|
return failure;
|
|
751
817
|
const rules = Object.create(null);
|
|
818
|
+
const unique = [];
|
|
752
819
|
for (const [field, keywords] of written) {
|
|
753
820
|
const properties = schema.properties;
|
|
754
821
|
const where = `${at}/properties/${escapePointer(field)}`;
|
|
822
|
+
if (Object.hasOwn(keywords, UNIQUE)) {
|
|
823
|
+
if (keywords[UNIQUE] !== true || indexed?.includes(field) !== true)
|
|
824
|
+
return refuse(UNIQUE, `${where}/${UNIQUE}`);
|
|
825
|
+
unique.push(field);
|
|
826
|
+
}
|
|
827
|
+
if (!FIELD_RULES.some((keyword) => Object.hasOwn(keywords, keyword)))
|
|
828
|
+
continue;
|
|
755
829
|
const ruling = fieldRules(keywords, properties[field], where, context.defs);
|
|
756
830
|
if ('rule' in ruling)
|
|
757
831
|
return ruling;
|
|
@@ -764,16 +838,17 @@ function readType(name, value, context) {
|
|
|
764
838
|
fields[MEMBER_FIELD] = { type: 'string', prose: false };
|
|
765
839
|
const defs = Object.create(null);
|
|
766
840
|
reachedDefs(value, context.defs, defs);
|
|
767
|
-
const { create_roles: _create, delete_roles: _delete, ...shaped } = value;
|
|
841
|
+
const { create_roles: _create, delete_roles: _delete, indexed: _indexed, ...shaped } = value;
|
|
768
842
|
return {
|
|
769
843
|
name,
|
|
770
844
|
memberDocument,
|
|
771
|
-
|
|
845
|
+
root: { ...root, properties: { ...HOUSE_KEYS, ...fields } },
|
|
772
846
|
fields,
|
|
773
|
-
sections: read.sections,
|
|
774
847
|
rules,
|
|
775
848
|
...(createRoles === undefined ? {} : { createRoles }),
|
|
776
849
|
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
850
|
+
...(indexed === undefined ? {} : { indexed }),
|
|
851
|
+
...(unique.length === 0 ? {} : { unique }),
|
|
777
852
|
shape: {
|
|
778
853
|
schema: written.size === 0 ? shaped : { ...shaped, properties: schema.properties },
|
|
779
854
|
defs,
|
|
@@ -783,22 +858,67 @@ function readType(name, value, context) {
|
|
|
783
858
|
function lineAt(text, offset) {
|
|
784
859
|
return text.slice(0, offset).split(/\r\n|\r|\n/).length;
|
|
785
860
|
}
|
|
786
|
-
|
|
861
|
+
function roleNeeds(value) {
|
|
862
|
+
const at = `/${ROLES_SECTION}`;
|
|
863
|
+
if (!isRecord(value))
|
|
864
|
+
return refuse(ROLES_SECTION, at);
|
|
865
|
+
const needs = Object.create(null);
|
|
866
|
+
for (const [role, need] of Object.entries(value)) {
|
|
867
|
+
if (role === '' || typeof need !== 'string' || !ROLE_NEEDS.includes(need))
|
|
868
|
+
return refuse(ROLES_SECTION, `${at}/${escapePointer(role)}`);
|
|
869
|
+
needs[role] = need;
|
|
870
|
+
}
|
|
871
|
+
return { needs };
|
|
872
|
+
}
|
|
873
|
+
function namedFolder(folder) {
|
|
874
|
+
const named = folder.slice(0, -1);
|
|
875
|
+
return (folder.endsWith('/') &&
|
|
876
|
+
named !== '' &&
|
|
877
|
+
normalize(named) === named &&
|
|
878
|
+
!isReservedName(named.split('/', 1)[0]));
|
|
879
|
+
}
|
|
880
|
+
function typedFolders(value, own, checked) {
|
|
881
|
+
const at = `/${FOLDERS_SECTION}`;
|
|
882
|
+
const typed = new Map();
|
|
883
|
+
if (!isRecord(value))
|
|
884
|
+
return checked ? refuse(FOLDERS_SECTION, at) : typed;
|
|
885
|
+
for (const [folder, type] of Object.entries(value)) {
|
|
886
|
+
if (namedFolder(folder) && typeof type === 'string' && own.has(type))
|
|
887
|
+
typed.set(type, [...(typed.get(type) ?? []), folder].sort());
|
|
888
|
+
else if (checked)
|
|
889
|
+
return refuse(FOLDERS_SECTION, `${at}/${escapePointer(folder)}`);
|
|
890
|
+
}
|
|
891
|
+
return typed;
|
|
892
|
+
}
|
|
893
|
+
export function readSchema(text, provided = NO_TYPES, checked = true, start = 0, end = text.length) {
|
|
787
894
|
let root;
|
|
788
895
|
try {
|
|
789
|
-
root = jsValue(parseYamlMapping(text,
|
|
896
|
+
root = jsValue(parseYamlMapping(text, start, end));
|
|
790
897
|
}
|
|
791
898
|
catch (error) {
|
|
792
899
|
if (error instanceof YamlError)
|
|
793
900
|
return refuse('schema-yaml', `line ${lineAt(text, error.offset)}`);
|
|
794
901
|
throw error;
|
|
795
902
|
}
|
|
796
|
-
const defs = root
|
|
903
|
+
const defs = root[DEFS_SECTION] ?? Object.create(null);
|
|
797
904
|
if (!isRecord(defs))
|
|
798
|
-
return refuse(
|
|
799
|
-
const
|
|
905
|
+
return refuse(DEFS_SECTION, `/${DEFS_SECTION}`);
|
|
906
|
+
const roles = Object.hasOwn(root, ROLES_SECTION) ? roleNeeds(root[ROLES_SECTION]) : undefined;
|
|
907
|
+
if (roles !== undefined && 'rule' in roles)
|
|
908
|
+
return roles;
|
|
909
|
+
const names = Object.keys(root).filter((key) => !SECTIONS.includes(key));
|
|
910
|
+
const own = new Set(names.filter((name) => !Object.hasOwn(provided.types, name)));
|
|
911
|
+
const folders = Object.hasOwn(root, FOLDERS_SECTION)
|
|
912
|
+
? typedFolders(root[FOLDERS_SECTION], own, checked)
|
|
913
|
+
: new Map();
|
|
914
|
+
if ('rule' in folders)
|
|
915
|
+
return folders;
|
|
800
916
|
for (const name of checked ? names : []) {
|
|
801
|
-
if (name === '' ||
|
|
917
|
+
if (name === '' ||
|
|
918
|
+
name.startsWith('$') ||
|
|
919
|
+
name === BUILT_IN_TYPE ||
|
|
920
|
+
name === ATTACHMENT ||
|
|
921
|
+
RESERVED_TYPE_NAMES.includes(name))
|
|
802
922
|
return refuse('schema-type-name', `/${escapePointer(name)}`);
|
|
803
923
|
}
|
|
804
924
|
const context = {
|
|
@@ -824,11 +944,15 @@ export function readSchema(text, provided = NO_TYPES, checked = true) {
|
|
|
824
944
|
return refuse('member_document', `/${escapePointer(name)}/member_document`);
|
|
825
945
|
marked = true;
|
|
826
946
|
}
|
|
827
|
-
|
|
947
|
+
const typed = folders.get(name);
|
|
948
|
+
types[name] = deepFreeze(typed === undefined ? definition : { ...definition, folders: typed });
|
|
828
949
|
}
|
|
829
950
|
for (const [name, definition] of Object.entries(provided.types)) {
|
|
830
951
|
if (!Object.hasOwn(types, name))
|
|
831
952
|
types[name] = definition;
|
|
832
953
|
}
|
|
833
|
-
return Object.freeze({
|
|
954
|
+
return Object.freeze({
|
|
955
|
+
types: Object.freeze(types),
|
|
956
|
+
...(roles === undefined ? {} : { roles: Object.freeze(roles.needs) }),
|
|
957
|
+
});
|
|
834
958
|
}
|
package/dist/document.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
+
import { type Body, type Naming } from './body.js';
|
|
1
2
|
import { type Definition } from './definition.js';
|
|
2
3
|
import { type HrefOccurrence, type Reading } from './markdown.js';
|
|
3
|
-
import type { ApplyResult, BodyResult,
|
|
4
|
-
import { type YamlMap } from './yaml.js';
|
|
4
|
+
import type { ApplyResult, BodyResult, Change, DefinitionOf, Document, Link, LinkSpan, ParseResult, Refusal, Span, UnlinkedBody } from './types.js';
|
|
5
5
|
export declare function readingOf(document: Document): Reading;
|
|
6
|
+
export declare function bodyOf(document: Document): Body | null;
|
|
6
7
|
export declare function linkDestinations(document: Document): readonly HrefOccurrence[];
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function parse(content: string, file?: string): ParseResult;
|
|
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;
|
|
12
14
|
export declare function unlinkBody(body: string, hrefs: ReadonlySet<string>): UnlinkedBody;
|
|
13
15
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
16
|
+
export declare function linkSpans(body: string): readonly LinkSpan[];
|
|
14
17
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
15
|
-
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;
|
|
16
23
|
export declare function serialize(document: Document): string;
|
|
17
|
-
export declare function frontmatter(document: Document): YamlMap | null;
|
|
18
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"}
|