@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c03f6cf931ca0
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 +424 -0
- package/README.md +41 -197
- 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 +87 -34
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +853 -144
- package/dist/divide.d.ts +3 -0
- package/dist/divide.d.ts.map +1 -0
- package/dist/divide.js +321 -0
- package/dist/document.d.ts +19 -3
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +1007 -188
- 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 +41 -0
- package/dist/fields.d.ts +6 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +10 -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 +836 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +463 -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 +9 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +13 -0
- package/dist/index.d.ts +41 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -5
- package/dist/kinds.d.ts +18 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +150 -0
- package/dist/markdown.d.ts +75 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +265 -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/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 +25 -5
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +206 -35
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +356 -0
- package/dist/project.d.ts +20 -1
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +80 -101
- package/dist/query/language.d.ts +254 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +620 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +150 -0
- package/dist/query/rows.d.ts +32 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +161 -0
- package/dist/query/sql.d.ts +39 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +285 -0
- package/dist/references.d.ts +4 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +30 -0
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +3 -10
- package/dist/reserved.d.ts +6 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +21 -0
- package/dist/room-types.d.ts +7 -0
- package/dist/room-types.d.ts.map +1 -0
- package/dist/room-types.js +136 -0
- package/dist/schema.d.ts +6 -5
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +143 -41
- package/dist/types.d.ts +101 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/validate.d.ts +35 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +388 -158
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -3
- package/dist/yaml.d.ts +9 -3
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +326 -201
- package/fixtures/README.md +128 -56
- package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
- package/fixtures/cases/absent-link-dangles/schema.yaml +5 -0
- package/fixtures/cases/absent-optional-field/expected.json +1 -0
- package/fixtures/cases/absent-optional-field/library/companies/acme.md +4 -0
- package/fixtures/cases/absent-optional-field/library/deals/lead.md +6 -0
- package/fixtures/cases/absent-optional-field/schema.yaml +55 -0
- package/fixtures/cases/absolute-link/expected.json +5 -0
- package/fixtures/cases/absolute-link/library/item.md +8 -0
- package/fixtures/cases/absolute-link/schema.yaml +5 -0
- package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +18 -0
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +18 -0
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-outside/context.json +1 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +7 -0
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +18 -0
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-outside/schema.yaml +32 -0
- package/fixtures/cases/binary-any-reference/expected.json +2 -2
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-document-collision/expected.json +1 -2
- package/fixtures/cases/binary-document-collision/schema.yaml +1 -0
- package/fixtures/cases/binary-image-dangles/expected.json +1 -0
- package/fixtures/cases/binary-image-dangles/schema.yaml +1 -0
- package/fixtures/cases/binary-link-dangles/expected.json +1 -0
- package/fixtures/cases/binary-link-dangles/schema.yaml +1 -0
- package/fixtures/cases/binary-link-outside-collection/expected.json +1 -2
- package/fixtures/cases/binary-link-outside-collection/schema.yaml +1 -0
- package/fixtures/cases/binary-prototype-reference/expected.json +2 -2
- package/fixtures/cases/binary-prototype-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-typed-reference/expected.json +2 -2
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
- package/fixtures/cases/boolean-field/context.json +1 -0
- package/fixtures/cases/boolean-field/expected.json +7 -0
- package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
- package/fixtures/cases/boolean-field/library/deals/renewal.md +56 -0
- package/fixtures/cases/boolean-field/schema.yaml +55 -0
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +5 -0
- package/fixtures/cases/closed-nested-object/context.json +1 -0
- package/fixtures/cases/closed-nested-object/expected.json +7 -0
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +57 -0
- package/fixtures/cases/closed-nested-object/schema.yaml +55 -0
- package/fixtures/cases/composed-root-reference/context.json +1 -0
- package/fixtures/cases/composed-root-reference/expected.json +6 -0
- package/fixtures/cases/composed-root-reference/library/a.md +5 -0
- package/fixtures/cases/composed-root-reference/schema.yaml +13 -0
- package/fixtures/cases/conditional-long-text/context.json +1 -0
- package/fixtures/cases/conditional-long-text/expected.json +7 -0
- package/fixtures/cases/conditional-long-text/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-long-text/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-long-text/schema.yaml +13 -0
- package/fixtures/cases/cross-room-link/context.json +1 -0
- package/fixtures/cases/cross-room-link/expected.json +1 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
- package/fixtures/cases/cross-room-link/schema.yaml +3 -0
- package/fixtures/cases/cross-room-reference/context.json +1 -0
- package/fixtures/cases/cross-room-reference/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.yaml +8 -0
- package/fixtures/cases/date-time-format/context.json +1 -0
- package/fixtures/cases/date-time-format/expected.json +7 -0
- package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
- package/fixtures/cases/date-time-format/library/deals/renewal.md +56 -0
- package/fixtures/cases/date-time-format/schema.yaml +55 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +1 -0
- package/fixtures/cases/default-unfilled/context.json +1 -0
- package/fixtures/cases/default-unfilled/expected.json +6 -0
- package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +54 -0
- package/fixtures/cases/default-unfilled/schema.yaml +55 -0
- package/fixtures/cases/defs-pattern/context.json +1 -0
- package/fixtures/cases/defs-pattern/expected.json +7 -0
- package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +56 -0
- package/fixtures/cases/defs-pattern/schema.yaml +55 -0
- package/fixtures/cases/dependent-rule/context.json +1 -0
- package/fixtures/cases/dependent-rule/expected.json +6 -0
- package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +55 -0
- package/fixtures/cases/dependent-rule/schema.yaml +55 -0
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +5 -0
- package/fixtures/cases/email-format/context.json +1 -0
- package/fixtures/cases/email-format/expected.json +7 -0
- package/fixtures/cases/email-format/library/companies/acme.md +4 -0
- package/fixtures/cases/email-format/library/deals/renewal.md +56 -0
- package/fixtures/cases/email-format/schema.yaml +55 -0
- package/fixtures/cases/equal-labels/context.json +1 -0
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.yaml +4 -0
- package/fixtures/cases/fenced-link-definition/library/item.md +1 -1
- package/fixtures/cases/fenced-link-definition/schema.yaml +5 -0
- package/fixtures/cases/field-enum/expected.json +3 -3
- package/fixtures/cases/field-enum/library/item.md +2 -2
- package/fixtures/cases/field-enum/schema.yaml +6 -0
- package/fixtures/cases/frontmatter-schema/context.json +1 -0
- package/fixtures/cases/frontmatter-schema/expected.json +5 -0
- package/fixtures/cases/frontmatter-schema/schema.yaml +5 -0
- package/fixtures/cases/integer-field/context.json +1 -0
- package/fixtures/cases/integer-field/expected.json +7 -0
- package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
- package/fixtures/cases/integer-field/library/deals/renewal.md +56 -0
- package/fixtures/cases/integer-field/schema.yaml +55 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -0
- package/fixtures/cases/json-schema-constructs/context.json +1 -0
- package/fixtures/cases/json-schema-constructs/expected.json +1 -0
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +56 -0
- package/fixtures/cases/json-schema-constructs/schema.yaml +55 -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.yaml +9 -0
- package/fixtures/cases/lazy-list-item/context.json +1 -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.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -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.yaml +3 -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.yaml +3 -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/other.md +3 -0
- package/fixtures/cases/list-items/library/page.md +26 -0
- package/fixtures/cases/list-items/schema.yaml +10 -0
- package/fixtures/cases/list-of-objects-closed/context.json +1 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +7 -0
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +56 -0
- package/fixtures/cases/list-of-objects-closed/schema.yaml +55 -0
- package/fixtures/cases/list-of-objects-item/context.json +1 -0
- package/fixtures/cases/list-of-objects-item/expected.json +7 -0
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +56 -0
- package/fixtures/cases/list-of-objects-item/schema.yaml +55 -0
- package/fixtures/cases/list-of-objects-reference/context.json +1 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +7 -0
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +17 -0
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
- package/fixtures/cases/list-of-objects-reference/schema.yaml +32 -0
- package/fixtures/cases/list-reference-path/context.json +1 -0
- package/fixtures/cases/list-reference-path/expected.json +7 -0
- package/fixtures/cases/list-reference-path/library/other.md +3 -0
- package/fixtures/cases/list-reference-path/library/page.md +5 -0
- package/fixtures/cases/list-reference-path/schema.yaml +3 -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/note.md +1 -0
- package/fixtures/cases/list-reference-type/library/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.yaml +3 -0
- package/fixtures/cases/list-size/context.json +1 -0
- package/fixtures/cases/list-size/expected.json +7 -0
- package/fixtures/cases/list-size/library/companies/acme.md +4 -0
- package/fixtures/cases/list-size/library/deals/renewal.md +58 -0
- package/fixtures/cases/list-size/schema.yaml +55 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -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.yaml +15 -0
- package/fixtures/cases/malformed-definition/expected.json +2 -4
- package/fixtures/cases/malformed-definition/schema.yaml +3 -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.yaml +6 -0
- package/fixtures/cases/member-document/context.json +1 -0
- package/fixtures/cases/member-document/expected.json +1 -0
- package/fixtures/cases/member-document/library/people/ana.md +5 -0
- package/fixtures/cases/member-document/schema.yaml +5 -0
- package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
- package/fixtures/cases/missing-required-field/expected.json +2 -3
- package/fixtures/cases/missing-required-field/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +6 -0
- package/fixtures/cases/misspelled-key/context.json +1 -0
- package/fixtures/cases/misspelled-key/expected.json +7 -0
- package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +57 -0
- package/fixtures/cases/misspelled-key/schema.yaml +55 -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.yaml +5 -0
- package/fixtures/cases/nested-defs/context.json +1 -0
- package/fixtures/cases/nested-defs/expected.json +7 -0
- package/fixtures/cases/nested-defs/library/deal.md +6 -0
- package/fixtures/cases/nested-defs/schema.yaml +11 -0
- package/fixtures/cases/nested-object-reference/context.json +1 -0
- package/fixtures/cases/nested-object-reference/expected.json +7 -0
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +17 -0
- package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-object-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-reference/context.json +1 -0
- package/fixtures/cases/nested-reference/expected.json +1 -0
- package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-reference/library/deals/renewal.md +18 -0
- package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-required-field/context.json +1 -0
- package/fixtures/cases/nested-required-field/expected.json +7 -0
- package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +55 -0
- package/fixtures/cases/nested-required-field/schema.yaml +55 -0
- package/fixtures/cases/numeric-range/context.json +1 -0
- package/fixtures/cases/numeric-range/expected.json +7 -0
- package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
- package/fixtures/cases/numeric-range/library/deals/renewal.md +56 -0
- package/fixtures/cases/numeric-range/schema.yaml +55 -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.yaml +5 -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.yaml +4 -0
- package/fixtures/cases/one-of-variant/context.json +1 -0
- package/fixtures/cases/one-of-variant/expected.json +7 -0
- package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +56 -0
- package/fixtures/cases/one-of-variant/schema.yaml +55 -0
- package/fixtures/cases/other-room-reference/context.json +1 -0
- package/fixtures/cases/other-room-reference/expected.json +7 -0
- package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +17 -0
- package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
- package/fixtures/cases/other-room-reference/schema.yaml +32 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -0
- package/fixtures/cases/prototype-field/expected.json +3 -3
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +5 -0
- package/fixtures/cases/quoted-link-definition/expected.json +1 -2
- package/fixtures/cases/quoted-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/quoted-link-definition/schema.yaml +1 -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.yaml +3 -0
- package/fixtures/cases/referenced-missing-file/expected.json +0 -1
- 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.yaml +10 -0
- package/fixtures/cases/remote-ref/context.json +1 -0
- package/fixtures/cases/remote-ref/expected.json +5 -0
- package/fixtures/cases/remote-ref/schema.yaml +3 -0
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- package/fixtures/cases/second-member-document/context.json +1 -0
- package/fixtures/cases/second-member-document/expected.json +5 -0
- package/fixtures/cases/second-member-document/schema.yaml +4 -0
- package/fixtures/cases/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/sections-keyword-refused/schema.yaml +6 -0
- package/fixtures/cases/shortcut-reference-link/context.json +1 -0
- package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
- package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
- package/fixtures/cases/shortcut-reference-link/schema.yaml +5 -0
- package/fixtures/cases/string-length/context.json +1 -0
- package/fixtures/cases/string-length/expected.json +7 -0
- package/fixtures/cases/string-length/library/companies/acme.md +4 -0
- package/fixtures/cases/string-length/library/deals/renewal.md +56 -0
- package/fixtures/cases/string-length/schema.yaml +55 -0
- package/fixtures/cases/submission-keys/context.json +1 -0
- package/fixtures/cases/submission-keys/expected.json +1 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
- package/fixtures/cases/submission-keys/schema.yaml +4 -0
- package/fixtures/cases/text-field-kind/context.json +1 -0
- package/fixtures/cases/text-field-kind/expected.json +3 -0
- package/fixtures/cases/text-field-kind/library/page.md +4 -0
- package/fixtures/cases/text-field-kind/schema.yaml +4 -0
- package/fixtures/cases/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.yaml +3 -0
- package/fixtures/cases/truncated-link-definition/expected.json +1 -2
- package/fixtures/cases/truncated-link-definition/library/notes/draft.md +1 -1
- package/fixtures/cases/truncated-link-definition/schema.yaml +1 -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.yaml +6 -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.yaml +6 -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.yaml +6 -0
- package/fixtures/cases/types-folder-content/context.json +1 -0
- package/fixtures/cases/types-folder-content/expected.json +1 -0
- package/fixtures/cases/types-folder-content/library/types/task.md +4 -0
- package/fixtures/cases/types-folder-content/schema.yaml +4 -0
- package/fixtures/cases/unclosed-frontmatter/expected.json +1 -2
- package/fixtures/cases/undeclared-field/expected.json +3 -3
- package/fixtures/cases/undeclared-field/library/item.md +2 -2
- package/fixtures/cases/undeclared-field/schema.yaml +5 -0
- package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +7 -0
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +16 -0
- package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
- package/fixtures/cases/unknown-type/context.json +1 -0
- package/fixtures/cases/unknown-type/expected.json +6 -0
- package/fixtures/cases/unknown-type/library/item.md +3 -0
- package/fixtures/cases/unknown-type/schema.yaml +3 -0
- package/fixtures/cases/unlisted-reference-type/context.json +1 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
- package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -0
- package/fixtures/cases/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.yaml +5 -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.yaml +5 -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.yaml +5 -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.yaml +5 -0
- package/fixtures/cases/unresolved-link/expected.json +1 -2
- package/fixtures/cases/unresolved-link/library/item.md +2 -2
- package/fixtures/cases/unresolved-link/schema.yaml +5 -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.yaml +15 -0
- package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -0
- package/fixtures/division.json +454 -0
- package/fixtures/forms.json +347 -0
- package/fixtures/preamble.json +26 -5
- package/fixtures/projection.json +204 -32
- package/fixtures/queries.json +964 -0
- package/package.json +20 -13
- package/dist/definition.js.map +0 -1
- package/dist/document.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/links.d.ts +0 -25
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -380
- package/dist/links.js.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -7
- package/dist/profile.js.map +0 -1
- package/dist/project.js.map +0 -1
- package/dist/refuse.js.map +0 -1
- package/dist/schema.js.map +0 -1
- package/dist/sections.d.ts +0 -10
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -79
- package/dist/sections.js.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/validate.js.map +0 -1
- package/dist/version.js.map +0 -1
- package/dist/yaml.js.map +0 -1
- package/fixtures/cases/binary-any-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-document-collision/library/types/note.md +0 -3
- package/fixtures/cases/binary-link-outside-collection/library/types/note.md +0 -3
- package/fixtures/cases/binary-prototype-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/note.md +0 -5
- package/fixtures/cases/binary-typed-reference/library/types/person.md +0 -3
- package/fixtures/cases/bracketed-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/declared-binary-links/library/types/note.md +0 -3
- package/fixtures/cases/duplicate-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/fenced-link-definition/library/types/task.md +0 -7
- package/fixtures/cases/field-enum/library/types/task.md +0 -8
- package/fixtures/cases/interrupted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/long-fence-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/malformed-definition/library/types/task.md +0 -5
- package/fixtures/cases/missing-binary-image/expected.json +0 -6
- package/fixtures/cases/missing-binary-image/library/types/note.md +0 -3
- package/fixtures/cases/missing-binary-link/expected.json +0 -6
- package/fixtures/cases/missing-binary-link/library/types/note.md +0 -3
- package/fixtures/cases/missing-required-field/library/types/task.md +0 -8
- package/fixtures/cases/missing-section-item-kind/expected.json +0 -7
- package/fixtures/cases/missing-section-item-kind/library/types/task.md +0 -7
- package/fixtures/cases/paragraph-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/prd-definition/library/types/task.md +0 -16
- package/fixtures/cases/prototype-field/library/types/task.md +0 -7
- package/fixtures/cases/quoted-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/referenced-missing-file/library/types/person.md +0 -5
- package/fixtures/cases/referenced-missing-file/library/types/task.md +0 -8
- package/fixtures/cases/structured-section/expected.json +0 -7
- package/fixtures/cases/structured-section/library/types/task.md +0 -8
- package/fixtures/cases/truncated-link-definition/library/types/note.md +0 -3
- package/fixtures/cases/undeclared-field/library/types/task.md +0 -7
- package/fixtures/cases/unresolved-link/library/types/task.md +0 -7
- package/fixtures/cases/valid-typed-document/library/types/person.md +0 -5
- package/fixtures/cases/valid-typed-document/library/types/task.md +0 -13
- package/fixtures/cases/wide-item-fence-link/library/types/note.md +0 -3
- package/markdown-syntax-profile.md +0 -9
- /package/fixtures/cases/{missing-section-item-kind → absent-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{prd-definition → absent-link-dangles}/expected.json +0 -0
- /package/fixtures/cases/{prd-definition → absent-optional-field}/context.json +0 -0
- /package/fixtures/cases/{structured-section → absolute-link}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-image → binary-image-dangles}/library/notes/draft.md +0 -0
- /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{missing-binary-link → binary-link-dangles}/library/notes/draft.md +0 -0
package/dist/pattern.js
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
const NativeRegExp = RegExp;
|
|
2
|
+
export const PATTERN_STATES = 1_000;
|
|
3
|
+
const VISIT_BUDGET = 100_000_000;
|
|
4
|
+
const HELD_PATTERNS = 512;
|
|
5
|
+
export class PatternTooCostly extends Error {
|
|
6
|
+
}
|
|
7
|
+
let scope = null;
|
|
8
|
+
const ASCII = 128;
|
|
9
|
+
class Unsupported extends Error {
|
|
10
|
+
}
|
|
11
|
+
const ATOM = 0;
|
|
12
|
+
const SPLIT = 1;
|
|
13
|
+
const ASSERT = 2;
|
|
14
|
+
const MATCH = 3;
|
|
15
|
+
class Atom {
|
|
16
|
+
literal;
|
|
17
|
+
ascii = new Int8Array(ASCII);
|
|
18
|
+
matcher;
|
|
19
|
+
constructor(source, literal) {
|
|
20
|
+
this.literal = literal;
|
|
21
|
+
this.matcher = new NativeRegExp(`^(?:${source})$`, 'u');
|
|
22
|
+
}
|
|
23
|
+
holds(point) {
|
|
24
|
+
if (this.literal !== null)
|
|
25
|
+
return point === this.literal;
|
|
26
|
+
if (point >= ASCII)
|
|
27
|
+
return this.matcher.test(String.fromCodePoint(point));
|
|
28
|
+
const known = this.ascii[point];
|
|
29
|
+
if (known !== 0)
|
|
30
|
+
return known > 0;
|
|
31
|
+
const held = this.matcher.test(String.fromCharCode(point));
|
|
32
|
+
this.ascii[point] = held ? 1 : -1;
|
|
33
|
+
return held;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
class Reader {
|
|
37
|
+
source;
|
|
38
|
+
at = 0;
|
|
39
|
+
constructor(source) {
|
|
40
|
+
this.source = source;
|
|
41
|
+
}
|
|
42
|
+
peek(offset = 0) {
|
|
43
|
+
return this.source[this.at + offset];
|
|
44
|
+
}
|
|
45
|
+
starts(text) {
|
|
46
|
+
return this.source.startsWith(text, this.at);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function digits(reader) {
|
|
50
|
+
const from = reader.at;
|
|
51
|
+
while (/[0-9]/.test(reader.peek() ?? ''))
|
|
52
|
+
reader.at += 1;
|
|
53
|
+
return reader.at === from ? null : Number(reader.source.slice(from, reader.at));
|
|
54
|
+
}
|
|
55
|
+
function escapeEnd(source, at) {
|
|
56
|
+
const next = source[at + 1];
|
|
57
|
+
if (next === 'c')
|
|
58
|
+
return at + 3;
|
|
59
|
+
if (next === 'x')
|
|
60
|
+
return at + 4;
|
|
61
|
+
if ((next === 'u' && source[at + 2] === '{') || next === 'p' || next === 'P')
|
|
62
|
+
return source.indexOf('}', at + 2) + 1;
|
|
63
|
+
if (next !== 'u')
|
|
64
|
+
return at + 2;
|
|
65
|
+
const end = at + 6;
|
|
66
|
+
const lead = Number.parseInt(source.slice(at + 2, end), 16);
|
|
67
|
+
const trail = /^\\u([0-9a-fA-F]{4})$/.exec(source.slice(end, end + 6))?.[1];
|
|
68
|
+
const paired = lead >= 0xd800 &&
|
|
69
|
+
lead <= 0xdbff &&
|
|
70
|
+
trail !== undefined &&
|
|
71
|
+
Number.parseInt(trail, 16) >= 0xdc00 &&
|
|
72
|
+
Number.parseInt(trail, 16) <= 0xdfff;
|
|
73
|
+
return paired ? end + 6 : end;
|
|
74
|
+
}
|
|
75
|
+
function classEnd(source, at) {
|
|
76
|
+
let i = at + 1;
|
|
77
|
+
while (source[i] !== ']')
|
|
78
|
+
i += source[i] === '\\' ? 2 : 1;
|
|
79
|
+
return i + 1;
|
|
80
|
+
}
|
|
81
|
+
function escaped(reader) {
|
|
82
|
+
const next = reader.peek(1);
|
|
83
|
+
if (next === 'b' || next === 'B') {
|
|
84
|
+
reader.at += 2;
|
|
85
|
+
return { kind: 'assert', assertion: next === 'b' ? 'boundary' : 'inside' };
|
|
86
|
+
}
|
|
87
|
+
if (/[1-9k]/.test(next))
|
|
88
|
+
throw new Unsupported();
|
|
89
|
+
const end = escapeEnd(reader.source, reader.at);
|
|
90
|
+
const source = reader.source.slice(reader.at, end);
|
|
91
|
+
reader.at = end;
|
|
92
|
+
return { kind: 'atom', source, literal: false };
|
|
93
|
+
}
|
|
94
|
+
function group(reader) {
|
|
95
|
+
reader.at += 1;
|
|
96
|
+
if (reader.starts('?:'))
|
|
97
|
+
reader.at += 2;
|
|
98
|
+
else if (reader.starts('?<') && !reader.starts('?<=') && !reader.starts('?<!'))
|
|
99
|
+
reader.at = reader.source.indexOf('>', reader.at) + 1;
|
|
100
|
+
else if (reader.peek() === '?')
|
|
101
|
+
throw new Unsupported();
|
|
102
|
+
const alternatives = disjunction(reader);
|
|
103
|
+
reader.at += 1;
|
|
104
|
+
return { kind: 'group', alternatives };
|
|
105
|
+
}
|
|
106
|
+
function atom(reader) {
|
|
107
|
+
const character = reader.peek();
|
|
108
|
+
if (character === '^' || character === '$') {
|
|
109
|
+
reader.at += 1;
|
|
110
|
+
return { kind: 'assert', assertion: character === '^' ? 'start' : 'end' };
|
|
111
|
+
}
|
|
112
|
+
if (character === '\\')
|
|
113
|
+
return escaped(reader);
|
|
114
|
+
if (character === '(')
|
|
115
|
+
return group(reader);
|
|
116
|
+
if (character === '[' || character === '.') {
|
|
117
|
+
const end = character === '[' ? classEnd(reader.source, reader.at) : reader.at + 1;
|
|
118
|
+
const source = reader.source.slice(reader.at, end);
|
|
119
|
+
reader.at = end;
|
|
120
|
+
return { kind: 'atom', source, literal: false };
|
|
121
|
+
}
|
|
122
|
+
const source = String.fromCodePoint(reader.source.codePointAt(reader.at));
|
|
123
|
+
reader.at += source.length;
|
|
124
|
+
return { kind: 'atom', source, literal: true };
|
|
125
|
+
}
|
|
126
|
+
function quantified(reader, node) {
|
|
127
|
+
const sign = reader.peek();
|
|
128
|
+
let least = 1;
|
|
129
|
+
let most = 1;
|
|
130
|
+
if (sign === '*' || sign === '+' || sign === '?') {
|
|
131
|
+
reader.at += 1;
|
|
132
|
+
least = sign === '+' ? 1 : 0;
|
|
133
|
+
most = sign === '?' ? 1 : Infinity;
|
|
134
|
+
}
|
|
135
|
+
else if (sign === '{') {
|
|
136
|
+
reader.at += 1;
|
|
137
|
+
least = digits(reader);
|
|
138
|
+
most = least;
|
|
139
|
+
if (reader.peek() === ',') {
|
|
140
|
+
reader.at += 1;
|
|
141
|
+
most = digits(reader) ?? Infinity;
|
|
142
|
+
}
|
|
143
|
+
reader.at += 1;
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
return { node, least, most };
|
|
147
|
+
if (reader.peek() === '?')
|
|
148
|
+
reader.at += 1;
|
|
149
|
+
if (least > PATTERN_STATES || (Number.isFinite(most) && most > PATTERN_STATES))
|
|
150
|
+
throw new Unsupported();
|
|
151
|
+
return { node, least, most };
|
|
152
|
+
}
|
|
153
|
+
function disjunction(reader) {
|
|
154
|
+
const alternatives = [[]];
|
|
155
|
+
while (reader.at < reader.source.length && reader.peek() !== ')') {
|
|
156
|
+
if (reader.peek() === '|') {
|
|
157
|
+
reader.at += 1;
|
|
158
|
+
alternatives.push([]);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
alternatives.at(-1).push(quantified(reader, atom(reader)));
|
|
162
|
+
}
|
|
163
|
+
return alternatives;
|
|
164
|
+
}
|
|
165
|
+
class Machine {
|
|
166
|
+
kinds = [];
|
|
167
|
+
outs = [];
|
|
168
|
+
alternates = [];
|
|
169
|
+
atoms = [];
|
|
170
|
+
assertions = [];
|
|
171
|
+
atomed = new Map();
|
|
172
|
+
state(kind, out, alternate = -1) {
|
|
173
|
+
if (this.kinds.length >= PATTERN_STATES)
|
|
174
|
+
throw new Unsupported();
|
|
175
|
+
this.kinds.push(kind);
|
|
176
|
+
this.outs.push(out);
|
|
177
|
+
this.alternates.push(alternate);
|
|
178
|
+
return this.kinds.length - 1;
|
|
179
|
+
}
|
|
180
|
+
atom(source, literal) {
|
|
181
|
+
const known = this.atomed.get(source);
|
|
182
|
+
if (known !== undefined)
|
|
183
|
+
return known;
|
|
184
|
+
this.atoms.push(new Atom(source, literal ? source.codePointAt(0) : null));
|
|
185
|
+
this.atomed.set(source, this.atoms.length - 1);
|
|
186
|
+
return this.atoms.length - 1;
|
|
187
|
+
}
|
|
188
|
+
node(node, next) {
|
|
189
|
+
if (node.kind === 'atom')
|
|
190
|
+
return this.state(ATOM, next, this.atom(node.source, node.literal));
|
|
191
|
+
if (node.kind === 'assert') {
|
|
192
|
+
this.assertions.push(node.assertion);
|
|
193
|
+
return this.state(ASSERT, next, this.assertions.length - 1);
|
|
194
|
+
}
|
|
195
|
+
return this.alternatives(node.alternatives, next);
|
|
196
|
+
}
|
|
197
|
+
alternatives(alternatives, next) {
|
|
198
|
+
let entry = this.sequence(alternatives.at(-1), next);
|
|
199
|
+
for (let index = alternatives.length - 2; index >= 0; index -= 1)
|
|
200
|
+
entry = this.state(SPLIT, this.sequence(alternatives[index], next), entry);
|
|
201
|
+
return entry;
|
|
202
|
+
}
|
|
203
|
+
sequence(terms, next) {
|
|
204
|
+
let entry = next;
|
|
205
|
+
for (let index = terms.length - 1; index >= 0; index -= 1)
|
|
206
|
+
entry = this.term(terms[index], entry);
|
|
207
|
+
return entry;
|
|
208
|
+
}
|
|
209
|
+
term({ node, least, most }, next) {
|
|
210
|
+
if (least === 1 && most === 1)
|
|
211
|
+
return this.node(node, next);
|
|
212
|
+
let entry = next;
|
|
213
|
+
if (most === Infinity) {
|
|
214
|
+
const loop = this.state(SPLIT, -1, next);
|
|
215
|
+
const body = this.node(node, loop);
|
|
216
|
+
if (body === loop)
|
|
217
|
+
return next;
|
|
218
|
+
this.outs[loop] = body;
|
|
219
|
+
entry = loop;
|
|
220
|
+
}
|
|
221
|
+
else
|
|
222
|
+
for (let copy = least; copy < most; copy += 1) {
|
|
223
|
+
const body = this.node(node, entry);
|
|
224
|
+
if (body === entry)
|
|
225
|
+
return next;
|
|
226
|
+
entry = this.state(SPLIT, body, entry);
|
|
227
|
+
}
|
|
228
|
+
for (let copy = 0; copy < least; copy += 1) {
|
|
229
|
+
const body = this.node(node, entry);
|
|
230
|
+
if (body === entry)
|
|
231
|
+
return next;
|
|
232
|
+
entry = body;
|
|
233
|
+
}
|
|
234
|
+
return entry;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function word(point) {
|
|
238
|
+
return ((point >= 0x30 && point <= 0x39) ||
|
|
239
|
+
(point >= 0x41 && point <= 0x5a) ||
|
|
240
|
+
(point >= 0x61 && point <= 0x7a) ||
|
|
241
|
+
point === 0x5f);
|
|
242
|
+
}
|
|
243
|
+
function holds(assertion, at, point, across) {
|
|
244
|
+
if (assertion === 'start')
|
|
245
|
+
return at === 0;
|
|
246
|
+
if (assertion === 'end')
|
|
247
|
+
return point === -1;
|
|
248
|
+
return assertion === 'boundary' ? across : !across;
|
|
249
|
+
}
|
|
250
|
+
class Linear {
|
|
251
|
+
machine;
|
|
252
|
+
start;
|
|
253
|
+
marks;
|
|
254
|
+
generation = 0;
|
|
255
|
+
constructor(machine, start) {
|
|
256
|
+
this.machine = machine;
|
|
257
|
+
this.start = start;
|
|
258
|
+
this.marks = new Float64Array(machine.kinds.length);
|
|
259
|
+
}
|
|
260
|
+
test(text) {
|
|
261
|
+
const { kinds, outs, alternates, atoms, assertions } = this.machine;
|
|
262
|
+
const marks = this.marks;
|
|
263
|
+
const budget = scope ?? { left: VISIT_BUDGET };
|
|
264
|
+
let seeds = [];
|
|
265
|
+
let wordBefore = false;
|
|
266
|
+
for (let at = 0;;) {
|
|
267
|
+
const point = at < text.length ? text.codePointAt(at) : -1;
|
|
268
|
+
const wordAt = word(point);
|
|
269
|
+
const across = wordBefore !== wordAt;
|
|
270
|
+
const generation = (this.generation += 1);
|
|
271
|
+
const active = [];
|
|
272
|
+
seeds.push(this.start);
|
|
273
|
+
while (seeds.length > 0) {
|
|
274
|
+
const state = seeds.pop();
|
|
275
|
+
if (marks[state] === generation)
|
|
276
|
+
continue;
|
|
277
|
+
marks[state] = generation;
|
|
278
|
+
if ((budget.left -= 1) < 0)
|
|
279
|
+
throw new PatternTooCostly();
|
|
280
|
+
const kind = kinds[state];
|
|
281
|
+
if (kind === MATCH)
|
|
282
|
+
return true;
|
|
283
|
+
if (kind === ATOM)
|
|
284
|
+
active.push(state);
|
|
285
|
+
else if (kind === SPLIT)
|
|
286
|
+
seeds.push(alternates[state], outs[state]);
|
|
287
|
+
else if (holds(assertions[alternates[state]], at, point, across))
|
|
288
|
+
seeds.push(outs[state]);
|
|
289
|
+
}
|
|
290
|
+
if (point === -1)
|
|
291
|
+
return false;
|
|
292
|
+
for (const state of active)
|
|
293
|
+
if (atoms[alternates[state]].holds(point))
|
|
294
|
+
seeds.push(outs[state]);
|
|
295
|
+
wordBefore = wordAt;
|
|
296
|
+
at += point > 0xffff ? 2 : 1;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function compiled(source) {
|
|
301
|
+
try {
|
|
302
|
+
new NativeRegExp(source, 'u');
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
try {
|
|
308
|
+
const alternatives = disjunction(new Reader(source));
|
|
309
|
+
const machine = new Machine();
|
|
310
|
+
const start = machine.alternatives(alternatives, machine.state(MATCH, -1));
|
|
311
|
+
return new Linear(machine, start);
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
if (error instanceof Unsupported)
|
|
315
|
+
return null;
|
|
316
|
+
throw error;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
const held = new Map();
|
|
320
|
+
export function linearPattern(source) {
|
|
321
|
+
if (held.has(source))
|
|
322
|
+
return held.get(source);
|
|
323
|
+
const made = compiled(source);
|
|
324
|
+
if (held.size >= HELD_PATTERNS)
|
|
325
|
+
held.delete(held.keys().next().value);
|
|
326
|
+
held.set(source, made);
|
|
327
|
+
return made;
|
|
328
|
+
}
|
|
329
|
+
export function withLinearRegExp(run) {
|
|
330
|
+
const native = globalThis.RegExp;
|
|
331
|
+
function LinearRegExp(source) {
|
|
332
|
+
new NativeRegExp(source, 'u');
|
|
333
|
+
return {
|
|
334
|
+
test(text) {
|
|
335
|
+
const pattern = linearPattern(source);
|
|
336
|
+
if (pattern === null)
|
|
337
|
+
throw new SyntaxError(`the pattern ${source} is not linear`);
|
|
338
|
+
return pattern.test(text);
|
|
339
|
+
},
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
globalThis.RegExp = LinearRegExp;
|
|
343
|
+
try {
|
|
344
|
+
return run();
|
|
345
|
+
}
|
|
346
|
+
finally {
|
|
347
|
+
globalThis.RegExp = native;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
export function openPatternBudget() {
|
|
351
|
+
const outer = scope;
|
|
352
|
+
scope = outer ?? { left: VISIT_BUDGET };
|
|
353
|
+
return () => {
|
|
354
|
+
scope = outer;
|
|
355
|
+
};
|
|
356
|
+
}
|
package/dist/project.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import type { Document, Projection, ProjectionContext } from './types.js';
|
|
1
|
+
import type { Document, Extent, Projection, ProjectionContext, Refusal } from './types.js';
|
|
2
|
+
export type Piece = Extent & {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
};
|
|
5
|
+
export type Edit = Piece;
|
|
6
|
+
export type Input = {
|
|
7
|
+
readonly values: readonly Piece[];
|
|
8
|
+
readonly ranges: readonly Extent[];
|
|
9
|
+
readonly edits: readonly Edit[];
|
|
10
|
+
};
|
|
11
|
+
export type InputResult = {
|
|
12
|
+
readonly ok: true;
|
|
13
|
+
readonly input: Input;
|
|
14
|
+
} | {
|
|
15
|
+
readonly ok: false;
|
|
16
|
+
readonly refusal: Refusal;
|
|
17
|
+
};
|
|
18
|
+
export declare function firstEditFrom(edits: readonly Edit[], start: number): number;
|
|
19
|
+
export declare function rangeText(content: string, range: Extent, edits: readonly Edit[]): string;
|
|
20
|
+
export declare function projectionInput(document: Document, file: string, context: ProjectionContext): InputResult;
|
|
2
21
|
export declare function project(document: Document, file: string, context?: ProjectionContext): Projection;
|
|
3
22
|
//# sourceMappingURL=project.d.ts.map
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG3F,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC;AAEzB,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAqCtD,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAS3E;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,CAWxF;AAOD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,iBAAiB,GACzB,WAAW,CA4Bb;AAED,wBAAgB,OAAO,CACrB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAA2C,GACnD,UAAU,CAMZ"}
|
package/dist/project.js
CHANGED
|
@@ -1,122 +1,101 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parse } from './document.js';
|
|
3
|
-
import { linkInventory } from './links.js';
|
|
1
|
+
import { bodyWith, readingOf } from './document.js';
|
|
4
2
|
import { classifyHref } from './paths.js';
|
|
5
3
|
import { refusal } from './refuse.js';
|
|
6
|
-
import { headingSpans } from './sections.js';
|
|
7
4
|
import { bodyStartOf } from './yaml.js';
|
|
8
|
-
function internalEdits(
|
|
9
|
-
const inventory = linkInventory(body);
|
|
5
|
+
function internalEdits(content, reading, file, documentTargets) {
|
|
10
6
|
const internal = new Set();
|
|
11
|
-
const
|
|
12
|
-
|
|
7
|
+
const uses = reading.uses
|
|
8
|
+
.filter((use) => {
|
|
13
9
|
const resolved = classifyHref(file, use.destination.href);
|
|
14
|
-
|
|
10
|
+
return (resolved.kind === 'room' || (resolved.kind === 'path' && documentTargets.has(resolved.path)));
|
|
11
|
+
})
|
|
12
|
+
.sort((left, right) => left.start - right.start);
|
|
13
|
+
const edits = [];
|
|
14
|
+
for (let index = uses.length - 1; index >= 0; index -= 1) {
|
|
15
|
+
const use = uses[index];
|
|
15
16
|
internal.add(use.destination.start);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const label = { start: use.labelStart, end: use.labelEnd };
|
|
18
|
+
const inner = [];
|
|
19
|
+
for (let nested = index + 1; nested < uses.length; nested += 1) {
|
|
20
|
+
const edit = edits[uses.length - 1 - nested];
|
|
21
|
+
if (edit.start >= label.end)
|
|
22
|
+
break;
|
|
23
|
+
if (edit.end <= label.end)
|
|
24
|
+
inner.push(edit);
|
|
25
|
+
}
|
|
26
|
+
edits.push({ start: use.start, end: use.end, text: rangeText(content, label, inner) });
|
|
21
27
|
}
|
|
22
|
-
for (const block of
|
|
23
|
-
if (!internal.has(block.destination.start))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
end: block.end,
|
|
27
|
-
text: ''
|
|
28
|
-
});
|
|
28
|
+
for (const block of reading.definitions) {
|
|
29
|
+
if (!internal.has(block.destination.start))
|
|
30
|
+
continue;
|
|
31
|
+
edits.push({ start: block.start, end: block.end, text: '' });
|
|
29
32
|
}
|
|
30
|
-
return edits.sort((left, right)=>left.start - right.start);
|
|
33
|
+
return edits.sort((left, right) => left.start - right.start);
|
|
31
34
|
}
|
|
32
|
-
function
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
text += body.slice(cursor, to);
|
|
35
|
+
export function firstEditFrom(edits, start) {
|
|
36
|
+
let low = 0;
|
|
37
|
+
let high = edits.length;
|
|
38
|
+
while (low < high) {
|
|
39
|
+
const middle = (low + high) >>> 1;
|
|
40
|
+
if (edits[middle].start < start)
|
|
41
|
+
low = middle + 1;
|
|
42
|
+
else
|
|
43
|
+
high = middle;
|
|
42
44
|
}
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
function structural(spec) {
|
|
46
|
-
return spec.kind === 'list' && spec.of.kind !== 'text';
|
|
45
|
+
return low;
|
|
47
46
|
}
|
|
48
|
-
function
|
|
47
|
+
export function rangeText(content, range, edits) {
|
|
49
48
|
let text = '';
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
let cursor = range.start;
|
|
50
|
+
for (let index = firstEditFrom(edits, range.start); index < edits.length; index += 1) {
|
|
51
|
+
const edit = edits[index];
|
|
52
|
+
if (edit.start > range.end)
|
|
53
|
+
break;
|
|
54
|
+
if (edit.start < cursor || edit.end > range.end)
|
|
54
55
|
continue;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
for (const item of value)if (typeof item === 'string') text += `${item}\n\n`;
|
|
56
|
+
text += content.slice(cursor, edit.start) + edit.text;
|
|
57
|
+
cursor = edit.end;
|
|
58
58
|
}
|
|
59
|
-
return text;
|
|
59
|
+
return text + content.slice(cursor, range.end);
|
|
60
|
+
}
|
|
61
|
+
function linked(edits, range) {
|
|
62
|
+
const at = firstEditFrom(edits, range.start);
|
|
63
|
+
return at < edits.length && edits[at].start < range.end;
|
|
60
64
|
}
|
|
61
|
-
export function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const edits = internalEdits(body, file, new Set(context.documentTargets));
|
|
65
|
+
export function projectionInput(document, file, context) {
|
|
66
|
+
const content = document.content;
|
|
67
|
+
const bodyStart = bodyStartOf(content);
|
|
68
|
+
const reading = readingOf(document);
|
|
69
|
+
const edits = internalEdits(content, reading, file, new Set(context.documentTargets));
|
|
67
70
|
const declared = document.type;
|
|
68
|
-
|
|
71
|
+
const definition = context.definition;
|
|
72
|
+
if (definition === undefined && declared !== undefined && declared !== 'any')
|
|
73
|
+
return { ok: false, refusal: refusal(file, 'unknown-type') };
|
|
74
|
+
const body = definition === undefined ? null : bodyWith(document, definition);
|
|
75
|
+
if (body === null || !('top' in body)) {
|
|
69
76
|
return {
|
|
70
77
|
ok: true,
|
|
71
|
-
|
|
72
|
-
[
|
|
73
|
-
0,
|
|
74
|
-
body.length
|
|
75
|
-
]
|
|
76
|
-
], edits)
|
|
78
|
+
input: { values: [], ranges: [{ start: bodyStart, end: content.length }], edits },
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
};
|
|
99
|
-
const structure = new Set(Object.entries(definition.sections).flatMap(([name, spec])=>structural(spec) ? [
|
|
100
|
-
name
|
|
101
|
-
] : []));
|
|
102
|
-
const headings = headingSpans(document.content, bodyStart);
|
|
103
|
-
const spans = [
|
|
104
|
-
[
|
|
105
|
-
0,
|
|
106
|
-
(headings[0]?.headingStart ?? document.content.length) - bodyStart
|
|
107
|
-
]
|
|
108
|
-
];
|
|
109
|
-
for (const heading of headings){
|
|
110
|
-
if (structure.has(heading.name)) continue;
|
|
111
|
-
spans.push([
|
|
112
|
-
heading.headingStart - bodyStart,
|
|
113
|
-
heading.bodyEnd - bodyStart
|
|
114
|
-
]);
|
|
115
|
-
}
|
|
116
|
-
return {
|
|
117
|
-
ok: true,
|
|
118
|
-
text: freeText(definition, document.fields) + projected(body, spans, edits)
|
|
119
|
-
};
|
|
81
|
+
const values = body.prose
|
|
82
|
+
.filter((one) => !one.markdown)
|
|
83
|
+
.map((one) => ({
|
|
84
|
+
start: one.start,
|
|
85
|
+
end: one.end,
|
|
86
|
+
text: `${linked(edits, one) ? rangeText(content, one, edits) : one.text}\n\n`,
|
|
87
|
+
}));
|
|
88
|
+
const ranges = [
|
|
89
|
+
...body.prose.filter((one) => one.markdown).map(({ start, end }) => ({ start, end })),
|
|
90
|
+
...body.free,
|
|
91
|
+
].sort((left, right) => left.start - right.start);
|
|
92
|
+
return { ok: true, input: { values, ranges, edits } };
|
|
93
|
+
}
|
|
94
|
+
export function project(document, file, context = { documentTargets: [] }) {
|
|
95
|
+
const result = projectionInput(document, file, context);
|
|
96
|
+
if (!result.ok)
|
|
97
|
+
return { ok: false, refusal: result.refusal };
|
|
98
|
+
const { values, ranges, edits } = result.input;
|
|
99
|
+
const prose = ranges.map((range) => rangeText(document.content, range, edits)).join('');
|
|
100
|
+
return { ok: true, text: values.map((value) => value.text).join('') + prose };
|
|
120
101
|
}
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=project.js.map
|