@agentshouse/mdmodel 0.1.0-c7d0474d0241e → 0.1.0-c7edc0d9d2d4a
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 +234 -173
- package/README.md +29 -26
- 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 +20 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +185 -85
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +5 -4
- package/dist/document.d.ts +14 -8
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +729 -135
- 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 +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +153 -0
- package/dist/house-model.d.ts +870 -0
- package/dist/house-model.d.ts.map +1 -0
- package/dist/house-model.js +472 -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 +40 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -9
- 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/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 +15 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +92 -20
- 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.map +1 -1
- package/dist/project.js +33 -60
- 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 +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 +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 +1 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +10 -23
- package/dist/types.d.ts +23 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +12 -6
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +250 -175
- package/dist/yaml.d.ts +4 -4
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +41 -15
- package/fixtures/README.md +57 -21
- package/fixtures/cases/absent-link-dangles/library/item.md +1 -1
- package/fixtures/cases/absent-link-dangles/schema.yaml +2 -3
- 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 +10 -11
- package/fixtures/cases/absolute-link/library/item.md +1 -1
- package/fixtures/cases/absolute-link/schema.yaml +2 -3
- 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-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-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/binary-any-reference/expected.json +2 -1
- package/fixtures/cases/binary-any-reference/library/notes/draft.md +1 -1
- 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-typed-reference/expected.json +2 -1
- package/fixtures/cases/binary-typed-reference/library/notes/draft.md +1 -1
- 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 +10 -11
- package/fixtures/cases/bracketed-link-definition/library/item.md +1 -1
- package/fixtures/cases/bracketed-link-definition/schema.yaml +2 -3
- 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 +10 -11
- package/fixtures/cases/composed-root-reference/library/a.md +2 -2
- 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/library/clients/acme.md +1 -1
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +4 -4
- package/fixtures/cases/cross-room-reference/schema.yaml +1 -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 +10 -11
- 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.yaml +10 -11
- 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.yaml +10 -11
- 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.yaml +10 -11
- package/fixtures/cases/duplicate-link-definition/library/item.md +1 -1
- package/fixtures/cases/duplicate-link-definition/schema.yaml +2 -3
- 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.yaml +10 -11
- 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 +2 -3
- 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.yaml +3 -4
- 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.yaml +10 -11
- 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.yaml +10 -11
- 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/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/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/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/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/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/expected.json +1 -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/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.yaml +10 -11
- 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.yaml +10 -11
- 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-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.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/page.md +6 -0
- package/fixtures/cases/list-reference-type/schema.yaml +3 -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.yaml +10 -11
- 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-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/library/people/ana.md +2 -2
- 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/library/item.md +1 -1
- package/fixtures/cases/missing-required-field/schema.yaml +3 -4
- 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.yaml +10 -11
- 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/expected.json +2 -1
- package/fixtures/cases/nested-defs/library/deal.md +3 -3
- 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-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-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.yaml +10 -11
- 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.yaml +10 -11
- 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/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.yaml +10 -11
- 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/prototype-field/expected.json +2 -1
- package/fixtures/cases/prototype-field/library/item.md +2 -2
- package/fixtures/cases/prototype-field/schema.yaml +2 -3
- 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/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
- 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/sections-keyword-refused/context.json +1 -0
- package/fixtures/cases/sections-keyword-refused/expected.json +5 -0
- package/fixtures/cases/{structured-section → sections-keyword-refused}/schema.yaml +1 -2
- package/fixtures/cases/shortcut-reference-link/library/item.md +1 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +2 -3
- 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.yaml +10 -11
- package/fixtures/cases/submission-keys/library/notes/visitor.md +2 -2
- package/fixtures/cases/text-field-kind/expected.json +1 -4
- package/fixtures/cases/text-field-kind/library/page.md +1 -1
- 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/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/library/types/task.md +1 -1
- 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.yaml +2 -3
- package/fixtures/cases/unevaluated-items-closed/expected.json +2 -1
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +13 -3
- 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/library/item.md +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +2 -3
- 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 +5 -6
- package/fixtures/division.json +86 -41
- package/fixtures/forms.json +347 -0
- package/fixtures/preamble.json +26 -5
- package/fixtures/projection.json +121 -18
- package/fixtures/queries.json +964 -0
- package/package.json +16 -2
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -69
- package/dist/condition.d.ts +0 -161
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -615
- package/dist/links.d.ts +0 -29
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -800
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- 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/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/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/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/structured-section/expected.json +0 -6
- /package/fixtures/cases/{missing-section-item-kind → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{null-refused → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{open-map-value → labels-in-the-rooms-language}/context.json +0 -0
- /package/fixtures/cases/{section-items → labels-in-the-rooms-language}/expected.json +0 -0
- /package/fixtures/cases/{section-item-enum → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{section-items → link-into-a-reserved-name}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → link-into-a-reserved-name-from-an-untyped-document}/context.json +0 -0
- /package/fixtures/cases/{section-reference-path → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-item-kind}/context.json +0 -0
- /package/fixtures/cases/{structured-section → list-items}/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/dist/condition.js
DELETED
|
@@ -1,615 +0,0 @@
|
|
|
1
|
-
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
2
|
-
import { roomPath, target } from './paths.js';
|
|
3
|
-
import { plain } from './yaml.js';
|
|
4
|
-
export const CONDITION_OPERATORS = [
|
|
5
|
-
'eq',
|
|
6
|
-
'in',
|
|
7
|
-
'exists',
|
|
8
|
-
'contains',
|
|
9
|
-
'gt',
|
|
10
|
-
'gte',
|
|
11
|
-
'lt',
|
|
12
|
-
'lte',
|
|
13
|
-
'prefix',
|
|
14
|
-
];
|
|
15
|
-
export const WRITE_DOORS = ['browser', 'agent', 'client'];
|
|
16
|
-
const PROSE = { kind: 'prose' };
|
|
17
|
-
const NULL = { kind: 'null' };
|
|
18
|
-
const UNREADABLE = { kind: 'unreadable' };
|
|
19
|
-
const UNREAD = { present: undefined, values: [undefined], items: [undefined] };
|
|
20
|
-
const NO_ITEM = { present: false, values: [], items: [] };
|
|
21
|
-
const DATE = /^\d{4}-\d{2}-\d{2}$/u;
|
|
22
|
-
const HEADER = /^\/headers\/[!#$%&'*+.^_`|~0-9a-z-]+$/u;
|
|
23
|
-
const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2}):(\d{2}))$/u;
|
|
24
|
-
export function factKind(facts) {
|
|
25
|
-
if (facts.reference !== undefined)
|
|
26
|
-
return 'reference';
|
|
27
|
-
if (facts.values !== undefined)
|
|
28
|
-
return 'enum';
|
|
29
|
-
if (facts.type === 'number' || facts.type === 'integer')
|
|
30
|
-
return 'number';
|
|
31
|
-
if (facts.type === 'boolean')
|
|
32
|
-
return 'boolean';
|
|
33
|
-
if (facts.type !== 'string')
|
|
34
|
-
return null;
|
|
35
|
-
if (facts.format === 'date')
|
|
36
|
-
return 'date';
|
|
37
|
-
if (facts.format === 'date-time')
|
|
38
|
-
return 'time';
|
|
39
|
-
return 'string';
|
|
40
|
-
}
|
|
41
|
-
function fits(kind, facts, value) {
|
|
42
|
-
if (!scalar(value))
|
|
43
|
-
return false;
|
|
44
|
-
if (kind === 'enum')
|
|
45
|
-
return (facts.values ?? []).includes(value);
|
|
46
|
-
if (kind === 'number')
|
|
47
|
-
return typeof value === 'number';
|
|
48
|
-
if (kind === 'boolean')
|
|
49
|
-
return typeof value === 'boolean';
|
|
50
|
-
if (typeof value !== 'string')
|
|
51
|
-
return false;
|
|
52
|
-
if (kind === 'date')
|
|
53
|
-
return dated(value);
|
|
54
|
-
if (kind === 'time')
|
|
55
|
-
return instant(value) !== undefined;
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
function factOf(value, declared, place) {
|
|
59
|
-
if (value === null)
|
|
60
|
-
return NULL;
|
|
61
|
-
if (Array.isArray(value)) {
|
|
62
|
-
if (declared?.type !== undefined && declared.type !== 'array')
|
|
63
|
-
return UNREADABLE;
|
|
64
|
-
return {
|
|
65
|
-
kind: 'list',
|
|
66
|
-
items: value.map((item, index) => factOf(item, declared === undefined ? undefined : itemFacts(declared, index), place)),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
if (plain(value)) {
|
|
70
|
-
if (declared?.type !== undefined && declared.type !== 'object')
|
|
71
|
-
return UNREADABLE;
|
|
72
|
-
const fields = Object.create(null);
|
|
73
|
-
for (const [key, held] of Object.entries(value))
|
|
74
|
-
fields[key] = factOf(held, declared === undefined ? undefined : memberFacts(declared, key), place);
|
|
75
|
-
return { kind: 'object', fields };
|
|
76
|
-
}
|
|
77
|
-
if (declared?.type === 'array' || declared?.type === 'object')
|
|
78
|
-
return UNREADABLE;
|
|
79
|
-
const kind = declared === undefined || declared.prose ? null : factKind(declared);
|
|
80
|
-
if (kind === null)
|
|
81
|
-
return PROSE;
|
|
82
|
-
if (!fits(kind, declared, value))
|
|
83
|
-
return UNREADABLE;
|
|
84
|
-
if (kind !== 'reference')
|
|
85
|
-
return { kind, value };
|
|
86
|
-
const reached = target(place.path, value) ?? roomPath(value);
|
|
87
|
-
const resolved = reached === null ? undefined : place.resolve(reached);
|
|
88
|
-
if (resolved === undefined)
|
|
89
|
-
return UNREADABLE;
|
|
90
|
-
return resolved.member === undefined
|
|
91
|
-
? { kind, value: resolved.id }
|
|
92
|
-
: { kind, value: resolved.id, member: resolved.member };
|
|
93
|
-
}
|
|
94
|
-
export function facts(document, at, model, resolve) {
|
|
95
|
-
const type = document.type ?? null;
|
|
96
|
-
const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
|
|
97
|
-
const fields = Object.create(null);
|
|
98
|
-
const place = { path: at.path, resolve };
|
|
99
|
-
for (const [name, value] of Object.entries(document.fields)) {
|
|
100
|
-
const declared = definition === null ? undefined : fieldFacts(definition, name);
|
|
101
|
-
if (declared !== undefined)
|
|
102
|
-
fields[name] = factOf(value, declared, place);
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
id: at.id,
|
|
106
|
-
path: `/${at.path}`,
|
|
107
|
-
type,
|
|
108
|
-
fields,
|
|
109
|
-
sections: Object.keys(document.sections).sort(),
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
function rootOf(facts, prefix) {
|
|
113
|
-
return { pointer: prefix, fact: { kind: 'object', fields: facts.fields } };
|
|
114
|
-
}
|
|
115
|
-
export function prosePaths(facts) {
|
|
116
|
-
const paths = facts.sections.map((heading) => `/sections/${heading}`);
|
|
117
|
-
const visit = ({ pointer, fact }) => {
|
|
118
|
-
if (fact.kind === 'prose')
|
|
119
|
-
paths.push(pointer);
|
|
120
|
-
if (fact.kind === 'list')
|
|
121
|
-
fact.items.forEach((item, index) => visit({ pointer: `${pointer}/${index}`, fact: item }));
|
|
122
|
-
if (fact.kind === 'object')
|
|
123
|
-
for (const [key, held] of Object.entries(fact.fields))
|
|
124
|
-
visit({ pointer: `${pointer}/${escapePointer(key)}`, fact: held });
|
|
125
|
-
};
|
|
126
|
-
visit(rootOf(facts, '/fields'));
|
|
127
|
-
return paths.sort();
|
|
128
|
-
}
|
|
129
|
-
function walked(start, pointer) {
|
|
130
|
-
let reached = [start];
|
|
131
|
-
let several = false;
|
|
132
|
-
let missing = false;
|
|
133
|
-
const each = (from, next) => from.flatMap((one) => {
|
|
134
|
-
const found = next(one);
|
|
135
|
-
if (found === null)
|
|
136
|
-
missing = true;
|
|
137
|
-
return found ?? [];
|
|
138
|
-
});
|
|
139
|
-
for (const token of pointerSegments(pointer)) {
|
|
140
|
-
const step = ({ pointer: at, fact }) => {
|
|
141
|
-
if (fact.kind === 'unreadable')
|
|
142
|
-
return [{ pointer: at, fact }];
|
|
143
|
-
if (fact.kind === 'object')
|
|
144
|
-
return Object.hasOwn(fact.fields, token)
|
|
145
|
-
? [{ pointer: `${at}/${escapePointer(token)}`, fact: fact.fields[token] }]
|
|
146
|
-
: null;
|
|
147
|
-
if (fact.kind !== 'list')
|
|
148
|
-
return null;
|
|
149
|
-
if (ARRAY_INDEX.test(token)) {
|
|
150
|
-
const item = fact.items[Number(token)];
|
|
151
|
-
return item === undefined ? null : [{ pointer: `${at}/${token}`, fact: item }];
|
|
152
|
-
}
|
|
153
|
-
several = true;
|
|
154
|
-
return each(fact.items.map((item, index) => ({ pointer: `${at}/${index}`, fact: item })), step);
|
|
155
|
-
};
|
|
156
|
-
reached = each(reached, step);
|
|
157
|
-
}
|
|
158
|
-
return { reached, several, missing };
|
|
159
|
-
}
|
|
160
|
-
function expand(fact) {
|
|
161
|
-
return fact.kind === 'list' ? fact.items.flatMap(expand) : [fact];
|
|
162
|
-
}
|
|
163
|
-
function fieldHeld(fact) {
|
|
164
|
-
if (fact.kind === 'unreadable')
|
|
165
|
-
return undefined;
|
|
166
|
-
if (fact.kind === 'null')
|
|
167
|
-
return { kind: 'null' };
|
|
168
|
-
return 'value' in fact ? { kind: fact.kind, value: fact.value } : { kind: 'prose' };
|
|
169
|
-
}
|
|
170
|
-
function memberHeld(fact) {
|
|
171
|
-
if (fact.kind === 'unreadable')
|
|
172
|
-
return undefined;
|
|
173
|
-
return fact.kind === 'reference' && fact.member !== undefined
|
|
174
|
-
? { kind: 'member', value: fact.member }
|
|
175
|
-
: null;
|
|
176
|
-
}
|
|
177
|
-
function single(held) {
|
|
178
|
-
return { present: true, values: [held], items: null };
|
|
179
|
-
}
|
|
180
|
-
function documentRead({ reached, several, missing }, held) {
|
|
181
|
-
if (reached.length === 0)
|
|
182
|
-
return missing ? undefined : NO_ITEM;
|
|
183
|
-
const facts = reached.map(({ fact }) => fact);
|
|
184
|
-
const kept = (all) => all.map(held).filter((value) => value !== null);
|
|
185
|
-
const unknown = missing ? [undefined] : [];
|
|
186
|
-
const values = kept(facts.filter((fact) => fact.kind !== 'list'));
|
|
187
|
-
const listed = several || facts.some((fact) => fact.kind === 'list');
|
|
188
|
-
const present = facts.some((fact) => fact.kind === 'list') || values.some(Boolean);
|
|
189
|
-
return {
|
|
190
|
-
present: present ? true : values.length > 0 ? undefined : false,
|
|
191
|
-
values: [...values, ...unknown],
|
|
192
|
-
items: listed ? [...kept(facts.flatMap(expand)), ...unknown] : null,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
function readDocument(facts, path) {
|
|
196
|
-
const own = tested(DOCUMENT_TESTS, path);
|
|
197
|
-
if (own !== undefined)
|
|
198
|
-
return own.read(facts, path);
|
|
199
|
-
if (path.startsWith('/sections/'))
|
|
200
|
-
return facts.sections.includes(path.slice('/sections/'.length))
|
|
201
|
-
? single({ kind: 'prose' })
|
|
202
|
-
: undefined;
|
|
203
|
-
if (path.startsWith('/fields/'))
|
|
204
|
-
return documentRead(walked(rootOf(facts, '/fields'), path.slice('/fields'.length)), fieldHeld);
|
|
205
|
-
if (path.startsWith('/members/'))
|
|
206
|
-
return documentRead(walked(rootOf(facts, '/members'), path.slice('/members'.length)), memberHeld);
|
|
207
|
-
return undefined;
|
|
208
|
-
}
|
|
209
|
-
export function datePointers(fields) {
|
|
210
|
-
return Object.entries(fields)
|
|
211
|
-
.filter(([, facts]) => facts.type === 'string' && facts.format === 'date')
|
|
212
|
-
.map(([name]) => `/fields/${escapePointer(name)}`)
|
|
213
|
-
.sort();
|
|
214
|
-
}
|
|
215
|
-
export function valuedChange(definition, field) {
|
|
216
|
-
if (!field.startsWith('/fields/'))
|
|
217
|
-
return false;
|
|
218
|
-
const reached = pointerFacts(definition, field.slice('/fields'.length));
|
|
219
|
-
return (reached !== undefined &&
|
|
220
|
-
!reached.through &&
|
|
221
|
-
reached.facts.type !== 'array' &&
|
|
222
|
-
!reached.facts.prose &&
|
|
223
|
-
factKind(reached.facts) !== null);
|
|
224
|
-
}
|
|
225
|
-
export function changeFields(definition) {
|
|
226
|
-
return [
|
|
227
|
-
...Object.keys(definition.fields).map((name) => `/fields/${escapePointer(name)}`),
|
|
228
|
-
...Object.keys(definition.sections).map((heading) => `/sections/${heading}`),
|
|
229
|
-
];
|
|
230
|
-
}
|
|
231
|
-
export function memberPointers(definition, memberType) {
|
|
232
|
-
return Object.entries(definition.fields)
|
|
233
|
-
.filter(([, facts]) => (facts.type === 'array' ? facts.items : facts)?.reference?.includes(memberType) === true)
|
|
234
|
-
.map(([name]) => `/members/${escapePointer(name)}`);
|
|
235
|
-
}
|
|
236
|
-
function kindOperators(kind) {
|
|
237
|
-
switch (kind) {
|
|
238
|
-
case 'string':
|
|
239
|
-
return ['eq', 'in', 'prefix', 'exists'];
|
|
240
|
-
case 'boolean':
|
|
241
|
-
return ['eq', 'exists'];
|
|
242
|
-
case 'number':
|
|
243
|
-
case 'date':
|
|
244
|
-
case 'time':
|
|
245
|
-
return ['eq', 'in', 'gt', 'gte', 'lt', 'lte', 'exists'];
|
|
246
|
-
default:
|
|
247
|
-
return ['eq', 'in', 'exists'];
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
function pointerOperators({ facts, through }) {
|
|
251
|
-
const scalar = facts.type === 'array' ? facts.items : facts;
|
|
252
|
-
const kind = scalar === undefined || scalar.prose ? null : factKind(scalar);
|
|
253
|
-
if (kind === null)
|
|
254
|
-
return ['exists'];
|
|
255
|
-
if (facts.type === 'array')
|
|
256
|
-
return ['contains', 'exists'];
|
|
257
|
-
const own = kindOperators(kind);
|
|
258
|
-
return through ? [...own.filter((operator) => operator !== 'exists'), 'contains', 'exists'] : own;
|
|
259
|
-
}
|
|
260
|
-
function typeOperators(definition, path, memberType) {
|
|
261
|
-
if (path.startsWith('/sections/'))
|
|
262
|
-
return Object.hasOwn(definition.sections, path.slice('/sections/'.length)) ? ['exists'] : [];
|
|
263
|
-
const pointer = path.startsWith('/fields/')
|
|
264
|
-
? path.slice('/fields'.length)
|
|
265
|
-
: memberType !== null && memberPointers(definition, memberType).includes(path)
|
|
266
|
-
? path.slice('/members'.length)
|
|
267
|
-
: undefined;
|
|
268
|
-
const reached = pointer === undefined ? undefined : pointerFacts(definition, pointer);
|
|
269
|
-
return reached === undefined ? [] : pointerOperators(reached);
|
|
270
|
-
}
|
|
271
|
-
function envelope(path, kind, value) {
|
|
272
|
-
return {
|
|
273
|
-
path,
|
|
274
|
-
names: (named) => named === path,
|
|
275
|
-
kind,
|
|
276
|
-
operators: kindOperators(kind),
|
|
277
|
-
read: (facts) => {
|
|
278
|
-
const held = value(facts);
|
|
279
|
-
return held === null || held === undefined ? undefined : single({ kind, value: held });
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
function tested(tests, path) {
|
|
284
|
-
return tests.find(({ names }) => names(path));
|
|
285
|
-
}
|
|
286
|
-
function reader(tests, facts) {
|
|
287
|
-
return (path) => tested(tests, path)?.read(facts, path);
|
|
288
|
-
}
|
|
289
|
-
const DOCUMENT_TESTS = [
|
|
290
|
-
{
|
|
291
|
-
path: '/path',
|
|
292
|
-
names: (named) => named === '/path',
|
|
293
|
-
kind: 'string',
|
|
294
|
-
operators: ['eq', 'in', 'prefix'],
|
|
295
|
-
read: (facts) => single({ kind: 'string', value: facts.path }),
|
|
296
|
-
},
|
|
297
|
-
envelope('/type', 'enum', (facts) => facts.type),
|
|
298
|
-
];
|
|
299
|
-
const ACTOR_TESTS = [
|
|
300
|
-
envelope('/user', 'enum', (actor) => actor.user),
|
|
301
|
-
envelope('/site', 'enum', (actor) => actor.site),
|
|
302
|
-
envelope('/door', 'enum', (actor) => actor.door),
|
|
303
|
-
];
|
|
304
|
-
const ITEM_TESTS = [
|
|
305
|
-
envelope('/delivery', 'enum', (item) => item.delivery),
|
|
306
|
-
envelope('/source', 'enum', (item) => item.source),
|
|
307
|
-
envelope('/container', 'string', (item) => item.container),
|
|
308
|
-
envelope('/author', 'string', (item) => item.author),
|
|
309
|
-
{
|
|
310
|
-
path: '/headers/<lowercase name>',
|
|
311
|
-
names: (named) => HEADER.test(named),
|
|
312
|
-
kind: 'string',
|
|
313
|
-
operators: kindOperators('string'),
|
|
314
|
-
read: (item, path) => {
|
|
315
|
-
const name = path.slice('/headers/'.length);
|
|
316
|
-
return Object.hasOwn(item.headers, name)
|
|
317
|
-
? single({ kind: 'string', value: item.headers[name] })
|
|
318
|
-
: undefined;
|
|
319
|
-
},
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
path: '/json/<JSON Pointer>',
|
|
323
|
-
names: (named) => named.startsWith('/json/'),
|
|
324
|
-
kind: null,
|
|
325
|
-
operators: CONDITION_OPERATORS,
|
|
326
|
-
read: (item, path) => item.json === null ? UNREAD : jsonRead(pointed(item.json.value, path.slice('/json'.length))),
|
|
327
|
-
},
|
|
328
|
-
];
|
|
329
|
-
export const DOCUMENT_PATHS = DOCUMENT_TESTS.map(({ path }) => path);
|
|
330
|
-
export const ACTOR_PATHS = ACTOR_TESTS.map(({ path }) => path);
|
|
331
|
-
export const ITEM_PATHS = ITEM_TESTS.map(({ path }) => path);
|
|
332
|
-
export function testOperators(definitions, path, memberType) {
|
|
333
|
-
const own = tested(DOCUMENT_TESTS, path);
|
|
334
|
-
if (own !== undefined)
|
|
335
|
-
return own.operators;
|
|
336
|
-
return [
|
|
337
|
-
...new Set(definitions.flatMap((definition) => typeOperators(definition, path, memberType))),
|
|
338
|
-
];
|
|
339
|
-
}
|
|
340
|
-
export function actorOperators(path) {
|
|
341
|
-
return tested(ACTOR_TESTS, path)?.operators ?? [];
|
|
342
|
-
}
|
|
343
|
-
export function itemOperators(path) {
|
|
344
|
-
return tested(ITEM_TESTS, path)?.operators ?? [];
|
|
345
|
-
}
|
|
346
|
-
export function itemKind(path) {
|
|
347
|
-
return tested(ITEM_TESTS, path)?.kind ?? null;
|
|
348
|
-
}
|
|
349
|
-
export function dated(value) {
|
|
350
|
-
return (typeof value === 'string' && DATE.test(value) && instant(`${value}T00:00:00Z`) !== undefined);
|
|
351
|
-
}
|
|
352
|
-
export function instant(value) {
|
|
353
|
-
if (typeof value !== 'string')
|
|
354
|
-
return undefined;
|
|
355
|
-
const parts = DATE_TIME.exec(value);
|
|
356
|
-
if (parts === null)
|
|
357
|
-
return undefined;
|
|
358
|
-
const [year, month, day, hour, minute, second, offsetHours, offsetMinutes] = [
|
|
359
|
-
1, 2, 3, 4, 5, 6, 9, 10,
|
|
360
|
-
].map((at) => Number(parts[at] ?? 0));
|
|
361
|
-
const at = new Date(0);
|
|
362
|
-
at.setUTCFullYear(year, month - 1, day);
|
|
363
|
-
at.setUTCHours(hour, minute, second);
|
|
364
|
-
if (at.getUTCFullYear() !== year ||
|
|
365
|
-
at.getUTCMonth() !== month - 1 ||
|
|
366
|
-
at.getUTCDate() !== day ||
|
|
367
|
-
at.getUTCHours() !== hour ||
|
|
368
|
-
at.getUTCMinutes() !== minute ||
|
|
369
|
-
offsetHours > 23 ||
|
|
370
|
-
offsetMinutes > 59)
|
|
371
|
-
return undefined;
|
|
372
|
-
const offset = (parts[8] === '-' ? -1 : 1) * (offsetHours * 60 + offsetMinutes);
|
|
373
|
-
const fraction = (parts[7] ?? '').padEnd(9, '0').slice(0, 9);
|
|
374
|
-
return (BigInt(at.getTime()) - BigInt(offset) * 60000n) * 1000000n + BigInt(fraction);
|
|
375
|
-
}
|
|
376
|
-
export function pointed(value, pointer) {
|
|
377
|
-
let reached = value;
|
|
378
|
-
for (const token of pointerSegments(pointer)) {
|
|
379
|
-
if (Array.isArray(reached)) {
|
|
380
|
-
if (!ARRAY_INDEX.test(token))
|
|
381
|
-
return undefined;
|
|
382
|
-
reached = reached[Number(token)];
|
|
383
|
-
}
|
|
384
|
-
else if (plain(reached) && Object.hasOwn(reached, token)) {
|
|
385
|
-
reached = reached[token];
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
return undefined;
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return reached;
|
|
392
|
-
}
|
|
393
|
-
function scalar(value) {
|
|
394
|
-
return (typeof value === 'string' ||
|
|
395
|
-
typeof value === 'boolean' ||
|
|
396
|
-
(typeof value === 'number' && Number.isFinite(value)));
|
|
397
|
-
}
|
|
398
|
-
function jsonHeld(value) {
|
|
399
|
-
if (typeof value === 'string')
|
|
400
|
-
return {
|
|
401
|
-
kind: dated(value) ? 'date' : instant(value) === undefined ? 'string' : 'time',
|
|
402
|
-
value,
|
|
403
|
-
};
|
|
404
|
-
if (typeof value === 'boolean')
|
|
405
|
-
return { kind: 'boolean', value };
|
|
406
|
-
return { kind: 'number', value };
|
|
407
|
-
}
|
|
408
|
-
function jsonRead(value) {
|
|
409
|
-
if (value === undefined)
|
|
410
|
-
return undefined;
|
|
411
|
-
if (scalar(value))
|
|
412
|
-
return single(jsonHeld(value));
|
|
413
|
-
if (!Array.isArray(value))
|
|
414
|
-
return single({ kind: 'prose' });
|
|
415
|
-
return { present: true, values: [], items: value.filter(scalar).map(jsonHeld), loose: true };
|
|
416
|
-
}
|
|
417
|
-
function equal(held, value) {
|
|
418
|
-
if (!('value' in held))
|
|
419
|
-
return undefined;
|
|
420
|
-
if (typeof value !== typeof held.value)
|
|
421
|
-
return undefined;
|
|
422
|
-
if (held.kind !== 'time')
|
|
423
|
-
return value === held.value;
|
|
424
|
-
const left = instant(held.value);
|
|
425
|
-
const right = instant(value);
|
|
426
|
-
return left === undefined || right === undefined ? undefined : left === right;
|
|
427
|
-
}
|
|
428
|
-
function sign(left, right) {
|
|
429
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
430
|
-
}
|
|
431
|
-
function ordered(held, value, compare) {
|
|
432
|
-
if (!('value' in held))
|
|
433
|
-
return undefined;
|
|
434
|
-
if (held.kind === 'number') {
|
|
435
|
-
if (typeof value !== 'number' || typeof held.value !== 'number')
|
|
436
|
-
return undefined;
|
|
437
|
-
return compare(Math.sign(held.value - value));
|
|
438
|
-
}
|
|
439
|
-
if (held.kind === 'date') {
|
|
440
|
-
if (!dated(value) || !dated(held.value))
|
|
441
|
-
return undefined;
|
|
442
|
-
return compare(sign(held.value, value));
|
|
443
|
-
}
|
|
444
|
-
if (held.kind !== 'time')
|
|
445
|
-
return undefined;
|
|
446
|
-
const at = instant(held.value);
|
|
447
|
-
const wanted = instant(value);
|
|
448
|
-
if (at === undefined || wanted === undefined)
|
|
449
|
-
return undefined;
|
|
450
|
-
return compare(sign(at, wanted));
|
|
451
|
-
}
|
|
452
|
-
function anyOf(truths) {
|
|
453
|
-
if (truths.some((truth) => truth === true))
|
|
454
|
-
return true;
|
|
455
|
-
return truths.some((truth) => truth === undefined) ? undefined : false;
|
|
456
|
-
}
|
|
457
|
-
function allOf(truths) {
|
|
458
|
-
if (truths.some((truth) => truth === false))
|
|
459
|
-
return false;
|
|
460
|
-
return truths.some((truth) => truth === undefined) ? undefined : true;
|
|
461
|
-
}
|
|
462
|
-
function compared(test, held) {
|
|
463
|
-
if ('eq' in test)
|
|
464
|
-
return equal(held, test.eq);
|
|
465
|
-
if ('in' in test)
|
|
466
|
-
return anyOf(test.in.map((value) => equal(held, value)));
|
|
467
|
-
if ('prefix' in test) {
|
|
468
|
-
if (!('value' in held) || typeof held.value !== 'string')
|
|
469
|
-
return undefined;
|
|
470
|
-
if (held.kind === 'number' || held.kind === 'reference' || held.kind === 'member')
|
|
471
|
-
return undefined;
|
|
472
|
-
return held.value.startsWith(test.prefix);
|
|
473
|
-
}
|
|
474
|
-
if ('gt' in test)
|
|
475
|
-
return ordered(held, test.gt, (sign) => sign > 0);
|
|
476
|
-
if ('gte' in test)
|
|
477
|
-
return ordered(held, test.gte, (sign) => sign >= 0);
|
|
478
|
-
if ('lt' in test)
|
|
479
|
-
return ordered(held, test.lt, (sign) => sign < 0);
|
|
480
|
-
return ordered(held, test.lte, (sign) => sign <= 0);
|
|
481
|
-
}
|
|
482
|
-
function leaf(test, read) {
|
|
483
|
-
if ('exists' in test) {
|
|
484
|
-
const present = read === undefined ? false : read.present;
|
|
485
|
-
return present === undefined ? undefined : present === test.exists;
|
|
486
|
-
}
|
|
487
|
-
if (read === undefined)
|
|
488
|
-
return undefined;
|
|
489
|
-
if ('contains' in test) {
|
|
490
|
-
if (read.items === null)
|
|
491
|
-
return undefined;
|
|
492
|
-
const truths = read.items.map((item) => item === undefined ? undefined : equal(item, test.contains));
|
|
493
|
-
return read.loose === true && !truths.includes(true) ? false : anyOf(truths);
|
|
494
|
-
}
|
|
495
|
-
if (read.values.length === 0)
|
|
496
|
-
return read === NO_ITEM ? false : undefined;
|
|
497
|
-
return anyOf(read.values.map((value) => (value === undefined ? undefined : compared(test, value))));
|
|
498
|
-
}
|
|
499
|
-
function evaluated(test, read) {
|
|
500
|
-
if ('all' in test)
|
|
501
|
-
return allOf(test.all.map((part) => evaluated(part, read)));
|
|
502
|
-
if ('any' in test)
|
|
503
|
-
return anyOf(test.any.map((part) => evaluated(part, read)));
|
|
504
|
-
if ('not' in test) {
|
|
505
|
-
const truth = evaluated(test.not, read);
|
|
506
|
-
return truth === undefined ? undefined : !truth;
|
|
507
|
-
}
|
|
508
|
-
return leaf(test, read(test.path));
|
|
509
|
-
}
|
|
510
|
-
export function members(document, path) {
|
|
511
|
-
if (!path.startsWith('/members/'))
|
|
512
|
-
return [];
|
|
513
|
-
const read = readDocument(document, path);
|
|
514
|
-
const values = read === undefined ? [] : [...read.values, ...(read.items ?? [])];
|
|
515
|
-
return [
|
|
516
|
-
...new Set(values.flatMap((value) => value !== undefined && value.kind === 'member' && 'value' in value
|
|
517
|
-
? [String(value.value)]
|
|
518
|
-
: [])),
|
|
519
|
-
].sort();
|
|
520
|
-
}
|
|
521
|
-
export function holds(test, document) {
|
|
522
|
-
return evaluated(test, (path) => readDocument(document, path));
|
|
523
|
-
}
|
|
524
|
-
function inScope(scope, document) {
|
|
525
|
-
if (document === null)
|
|
526
|
-
return false;
|
|
527
|
-
if ('type' in scope)
|
|
528
|
-
return document.type === scope.type;
|
|
529
|
-
if ('document' in scope)
|
|
530
|
-
return document.id === scope.document;
|
|
531
|
-
return scope.folder === '/' || document.path.startsWith(`${scope.folder}/`);
|
|
532
|
-
}
|
|
533
|
-
function matched(condition, test, document) {
|
|
534
|
-
if (!inScope(condition.scope, document))
|
|
535
|
-
return false;
|
|
536
|
-
return test === undefined || holds(test, document) === true;
|
|
537
|
-
}
|
|
538
|
-
function reachedAt(document, field) {
|
|
539
|
-
if (document === null)
|
|
540
|
-
return [];
|
|
541
|
-
if (field.startsWith('/sections/'))
|
|
542
|
-
return document.sections.includes(field.slice('/sections/'.length))
|
|
543
|
-
? [{ pointer: field, fact: PROSE }]
|
|
544
|
-
: [];
|
|
545
|
-
if (!field.startsWith('/fields/'))
|
|
546
|
-
return [];
|
|
547
|
-
return walked(rootOf(document, '/fields'), field.slice('/fields'.length)).reached;
|
|
548
|
-
}
|
|
549
|
-
function valueOf(fact) {
|
|
550
|
-
if (fact.kind === 'list')
|
|
551
|
-
return { kind: fact.kind, items: fact.items.map(valueOf) };
|
|
552
|
-
if (fact.kind === 'object')
|
|
553
|
-
return {
|
|
554
|
-
kind: fact.kind,
|
|
555
|
-
fields: Object.keys(fact.fields)
|
|
556
|
-
.sort()
|
|
557
|
-
.map((key) => [key, valueOf(fact.fields[key])]),
|
|
558
|
-
};
|
|
559
|
-
if (fact.kind === 'time') {
|
|
560
|
-
const at = instant(fact.value);
|
|
561
|
-
if (at !== undefined)
|
|
562
|
-
return { kind: fact.kind, at: String(at) };
|
|
563
|
-
}
|
|
564
|
-
return 'value' in fact ? { kind: fact.kind, value: fact.value } : fact;
|
|
565
|
-
}
|
|
566
|
-
function signature(reached) {
|
|
567
|
-
return JSON.stringify(reached.map(({ fact }) => valueOf(fact)));
|
|
568
|
-
}
|
|
569
|
-
function among(values, document, field) {
|
|
570
|
-
return holds({ path: field, in: values }, document) === true;
|
|
571
|
-
}
|
|
572
|
-
function fieldChanged(condition, event) {
|
|
573
|
-
const { field, from, to } = condition;
|
|
574
|
-
const before = reachedAt(event.before, field);
|
|
575
|
-
const after = reachedAt(event.after, field);
|
|
576
|
-
const pointers = [field, ...[...before, ...after].map(({ pointer }) => pointer)];
|
|
577
|
-
const prose = event.changed.some((changed) => pointers.some((pointer) => changed === pointer || changed.startsWith(`${pointer}/`)));
|
|
578
|
-
if (from === undefined && to === undefined && prose)
|
|
579
|
-
return true;
|
|
580
|
-
if (before.length === 0 && after.length === 0)
|
|
581
|
-
return false;
|
|
582
|
-
if (event.before !== null && event.after !== null && signature(before) === signature(after))
|
|
583
|
-
return false;
|
|
584
|
-
if (from === 'new'
|
|
585
|
-
? event.before !== null
|
|
586
|
-
: from !== undefined && (event.before === null || !among(from, event.before, field)))
|
|
587
|
-
return false;
|
|
588
|
-
if (to === 'deleted'
|
|
589
|
-
? event.after !== null
|
|
590
|
-
: to !== undefined && (event.after === null || !among(to, event.after, field)))
|
|
591
|
-
return false;
|
|
592
|
-
return true;
|
|
593
|
-
}
|
|
594
|
-
export function fires(condition, event) {
|
|
595
|
-
if (condition.moved_between_rooms !== undefined &&
|
|
596
|
-
condition.moved_between_rooms !== event.moved_between_rooms)
|
|
597
|
-
return false;
|
|
598
|
-
if (condition.by !== undefined && evaluated(condition.by, reader(ACTOR_TESTS, event.by)) !== true)
|
|
599
|
-
return false;
|
|
600
|
-
if (condition.mode === 'starts_matching') {
|
|
601
|
-
if (event.before === null && !condition.new_documents)
|
|
602
|
-
return false;
|
|
603
|
-
return (matched(condition, condition.match, event.after) &&
|
|
604
|
-
!matched(condition, condition.match, event.before));
|
|
605
|
-
}
|
|
606
|
-
const side = event.after ?? event.before;
|
|
607
|
-
return matched(condition, condition.match, side) && fieldChanged(condition, event);
|
|
608
|
-
}
|
|
609
|
-
export function itemFires(condition, item) {
|
|
610
|
-
if (condition.source !== undefined && item.source !== condition.source)
|
|
611
|
-
return false;
|
|
612
|
-
if (condition.address !== undefined && item.address !== condition.address)
|
|
613
|
-
return false;
|
|
614
|
-
return (condition.match === undefined || evaluated(condition.match, reader(ITEM_TESTS, item)) === true);
|
|
615
|
-
}
|
package/dist/links.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export declare function escapes(text: string, index: number): boolean;
|
|
2
|
-
export declare function spanCursor(spans: readonly (readonly [number, number])[]): (index: number) => number | undefined;
|
|
3
|
-
export type HrefOccurrence = {
|
|
4
|
-
readonly href: string;
|
|
5
|
-
readonly start: number;
|
|
6
|
-
readonly end: number;
|
|
7
|
-
readonly bracketed: boolean;
|
|
8
|
-
};
|
|
9
|
-
export type LinkUse = {
|
|
10
|
-
readonly start: number;
|
|
11
|
-
readonly end: number;
|
|
12
|
-
readonly labelStart: number;
|
|
13
|
-
readonly labelEnd: number;
|
|
14
|
-
readonly destination: HrefOccurrence;
|
|
15
|
-
};
|
|
16
|
-
export type DefinitionBlock = {
|
|
17
|
-
readonly start: number;
|
|
18
|
-
readonly end: number;
|
|
19
|
-
readonly destination: HrefOccurrence;
|
|
20
|
-
};
|
|
21
|
-
export type LinkInventory = {
|
|
22
|
-
readonly uses: readonly LinkUse[];
|
|
23
|
-
readonly blocks: readonly DefinitionBlock[];
|
|
24
|
-
};
|
|
25
|
-
export declare function fenceSpans(text: string): readonly (readonly [number, number])[];
|
|
26
|
-
export declare function linkInventory(body: string): LinkInventory;
|
|
27
|
-
export declare function destinations(inventory: LinkInventory): readonly HrefOccurrence[];
|
|
28
|
-
export declare function hrefOccurrences(body: string): readonly HrefOccurrence[];
|
|
29
|
-
//# sourceMappingURL=links.d.ts.map
|
package/dist/links.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AA2hBA,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D;AAyLD,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,GAC5C,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAOvC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,cAAc,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAe/E;AAaD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAoEzD;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,cAAc,EAAE,CAIhF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAEvE"}
|