@agentshouse/mdmodel 0.1.0-alpha.9 → 0.1.0-c08b2adadd2fe
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 +408 -0
- package/README.md +38 -194
- package/dist/definition.d.ts +72 -27
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +839 -145
- 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 +17 -3
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +514 -189
- package/dist/event.d.ts +78 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +201 -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/index.d.ts +30 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -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 +51 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +271 -0
- package/dist/paths.d.ts +15 -4
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +156 -36
- 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 +98 -97
- 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.map +1 -1
- package/dist/refuse.js +2 -10
- package/dist/reserved.d.ts +6 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +21 -0
- package/dist/schema.d.ts +8 -5
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +207 -41
- package/dist/types.d.ts +114 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -3
- package/dist/validate.d.ts +34 -2
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +449 -159
- 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 +113 -56
- package/fixtures/cases/absent-link-dangles/library/item.md +8 -0
- package/fixtures/cases/absent-link-dangles/schema.yaml +6 -0
- package/fixtures/cases/absent-optional-field/context.json +1 -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 +56 -0
- package/fixtures/cases/absolute-link/context.json +1 -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 +6 -0
- package/fixtures/cases/attachment-reference-any-file/context.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/expected.json +1 -0
- package/fixtures/cases/attachment-reference-any-file/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-any-file/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-any-file/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-dangles/context.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/expected.json +1 -0
- package/fixtures/cases/attachment-reference-dangles/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-dangles/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-dangles/schema.yaml +32 -0
- package/fixtures/cases/attachment-reference-outside/context.json +1 -0
- package/fixtures/cases/attachment-reference-outside/expected.json +6 -0
- package/fixtures/cases/attachment-reference-outside/library/companies/acme.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/deals/renewal.md +15 -0
- package/fixtures/cases/attachment-reference-outside/library/places/depot.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/seats.md +4 -0
- package/fixtures/cases/attachment-reference-outside/library/products/support.md +4 -0
- package/fixtures/cases/attachment-reference-outside/schema.yaml +32 -0
- package/fixtures/cases/binary-any-reference/expected.json +1 -2
- package/fixtures/cases/binary-any-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-document-collision/expected.json +1 -2
- package/fixtures/cases/binary-document-collision/schema.yaml +1 -0
- package/fixtures/cases/binary-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 +1 -2
- package/fixtures/cases/binary-prototype-reference/schema.yaml +4 -0
- package/fixtures/cases/binary-typed-reference/expected.json +1 -2
- package/fixtures/cases/binary-typed-reference/schema.yaml +5 -0
- package/fixtures/cases/boolean-field/context.json +1 -0
- package/fixtures/cases/boolean-field/expected.json +6 -0
- package/fixtures/cases/boolean-field/library/companies/acme.md +4 -0
- package/fixtures/cases/boolean-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/boolean-field/schema.yaml +56 -0
- package/fixtures/cases/bracketed-link-definition/schema.yaml +6 -0
- package/fixtures/cases/closed-nested-object/context.json +1 -0
- package/fixtures/cases/closed-nested-object/expected.json +6 -0
- package/fixtures/cases/closed-nested-object/library/companies/acme.md +4 -0
- package/fixtures/cases/closed-nested-object/library/deals/renewal.md +32 -0
- package/fixtures/cases/closed-nested-object/schema.yaml +56 -0
- package/fixtures/cases/composed-root-reference/context.json +1 -0
- package/fixtures/cases/composed-root-reference/expected.json +6 -0
- package/fixtures/cases/composed-root-reference/library/a.md +5 -0
- package/fixtures/cases/composed-root-reference/schema.yaml +13 -0
- package/fixtures/cases/conditional-section/context.json +1 -0
- package/fixtures/cases/conditional-section/expected.json +6 -0
- package/fixtures/cases/conditional-section/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-section/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-section/schema.yaml +14 -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 +9 -0
- package/fixtures/cases/date-time-format/context.json +1 -0
- package/fixtures/cases/date-time-format/expected.json +6 -0
- package/fixtures/cases/date-time-format/library/companies/acme.md +4 -0
- package/fixtures/cases/date-time-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/date-time-format/schema.yaml +56 -0
- package/fixtures/cases/declared-binary-links/schema.yaml +1 -0
- package/fixtures/cases/default-unfilled/context.json +1 -0
- package/fixtures/cases/default-unfilled/expected.json +6 -0
- package/fixtures/cases/default-unfilled/library/companies/acme.md +4 -0
- package/fixtures/cases/default-unfilled/library/deals/renewal.md +29 -0
- package/fixtures/cases/default-unfilled/schema.yaml +56 -0
- package/fixtures/cases/defs-pattern/context.json +1 -0
- package/fixtures/cases/defs-pattern/expected.json +6 -0
- package/fixtures/cases/defs-pattern/library/companies/acme.md +4 -0
- package/fixtures/cases/defs-pattern/library/deals/renewal.md +31 -0
- package/fixtures/cases/defs-pattern/schema.yaml +56 -0
- package/fixtures/cases/dependent-rule/context.json +1 -0
- package/fixtures/cases/dependent-rule/expected.json +6 -0
- package/fixtures/cases/dependent-rule/library/companies/acme.md +4 -0
- package/fixtures/cases/dependent-rule/library/deals/renewal.md +30 -0
- package/fixtures/cases/dependent-rule/schema.yaml +56 -0
- package/fixtures/cases/duplicate-link-definition/schema.yaml +6 -0
- package/fixtures/cases/email-format/context.json +1 -0
- package/fixtures/cases/email-format/expected.json +6 -0
- package/fixtures/cases/email-format/library/companies/acme.md +4 -0
- package/fixtures/cases/email-format/library/deals/renewal.md +31 -0
- package/fixtures/cases/email-format/schema.yaml +56 -0
- package/fixtures/cases/fenced-link-definition/schema.yaml +6 -0
- package/fixtures/cases/field-enum/expected.json +2 -3
- package/fixtures/cases/field-enum/schema.yaml +7 -0
- package/fixtures/cases/frontmatter-schema/context.json +1 -0
- package/fixtures/cases/frontmatter-schema/expected.json +5 -0
- package/fixtures/cases/frontmatter-schema/schema.yaml +5 -0
- package/fixtures/cases/integer-field/context.json +1 -0
- package/fixtures/cases/integer-field/expected.json +6 -0
- package/fixtures/cases/integer-field/library/companies/acme.md +4 -0
- package/fixtures/cases/integer-field/library/deals/renewal.md +31 -0
- package/fixtures/cases/integer-field/schema.yaml +56 -0
- package/fixtures/cases/interrupted-link-definition/schema.yaml +1 -0
- package/fixtures/cases/json-schema-constructs/context.json +1 -0
- package/fixtures/cases/json-schema-constructs/expected.json +1 -0
- package/fixtures/cases/json-schema-constructs/library/companies/acme.md +4 -0
- package/fixtures/cases/json-schema-constructs/library/deals/renewal.md +31 -0
- package/fixtures/cases/json-schema-constructs/schema.yaml +56 -0
- package/fixtures/cases/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 +8 -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-of-objects-closed/context.json +1 -0
- package/fixtures/cases/list-of-objects-closed/expected.json +6 -0
- package/fixtures/cases/list-of-objects-closed/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-closed/library/deals/renewal.md +32 -0
- package/fixtures/cases/list-of-objects-closed/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-item/context.json +1 -0
- package/fixtures/cases/list-of-objects-item/expected.json +6 -0
- package/fixtures/cases/list-of-objects-item/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-item/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-of-objects-item/schema.yaml +56 -0
- package/fixtures/cases/list-of-objects-reference/context.json +1 -0
- package/fixtures/cases/list-of-objects-reference/expected.json +6 -0
- package/fixtures/cases/list-of-objects-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/list-of-objects-reference/library/places/depot.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/seats.md +4 -0
- package/fixtures/cases/list-of-objects-reference/library/products/support.md +4 -0
- package/fixtures/cases/list-of-objects-reference/schema.yaml +32 -0
- package/fixtures/cases/list-size/context.json +1 -0
- package/fixtures/cases/list-size/expected.json +6 -0
- package/fixtures/cases/list-size/library/companies/acme.md +4 -0
- package/fixtures/cases/list-size/library/deals/renewal.md +31 -0
- package/fixtures/cases/list-size/schema.yaml +56 -0
- package/fixtures/cases/long-fence-link-definition/schema.yaml +1 -0
- package/fixtures/cases/malformed-definition/expected.json +2 -4
- package/fixtures/cases/malformed-definition/schema.yaml +3 -0
- package/fixtures/cases/member-document/context.json +1 -0
- package/fixtures/cases/member-document/expected.json +1 -0
- package/fixtures/cases/member-document/library/people/ana.md +5 -0
- package/fixtures/cases/member-document/schema.yaml +5 -0
- package/fixtures/cases/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/schema.yaml +7 -0
- package/fixtures/cases/missing-section-item-kind/expected.json +2 -4
- package/fixtures/cases/missing-section-item-kind/schema.yaml +6 -0
- package/fixtures/cases/misspelled-key/context.json +1 -0
- package/fixtures/cases/misspelled-key/expected.json +6 -0
- package/fixtures/cases/misspelled-key/library/companies/acme.md +4 -0
- package/fixtures/cases/misspelled-key/library/deals/renewal.md +32 -0
- package/fixtures/cases/misspelled-key/schema.yaml +56 -0
- package/fixtures/cases/nested-defs/context.json +1 -0
- package/fixtures/cases/nested-defs/expected.json +6 -0
- package/fixtures/cases/nested-defs/library/deal.md +6 -0
- package/fixtures/cases/nested-defs/schema.yaml +11 -0
- package/fixtures/cases/nested-object-reference/context.json +1 -0
- package/fixtures/cases/nested-object-reference/expected.json +6 -0
- package/fixtures/cases/nested-object-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-object-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/nested-object-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-object-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-object-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-reference/context.json +1 -0
- package/fixtures/cases/nested-reference/expected.json +1 -0
- package/fixtures/cases/nested-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-reference/library/deals/renewal.md +15 -0
- package/fixtures/cases/nested-reference/library/places/depot.md +4 -0
- package/fixtures/cases/nested-reference/library/products/seats.md +4 -0
- package/fixtures/cases/nested-reference/library/products/support.md +4 -0
- package/fixtures/cases/nested-reference/schema.yaml +32 -0
- package/fixtures/cases/nested-required-field/context.json +1 -0
- package/fixtures/cases/nested-required-field/expected.json +6 -0
- package/fixtures/cases/nested-required-field/library/companies/acme.md +4 -0
- package/fixtures/cases/nested-required-field/library/deals/renewal.md +30 -0
- package/fixtures/cases/nested-required-field/schema.yaml +56 -0
- package/fixtures/cases/null-refused/context.json +1 -0
- package/fixtures/cases/null-refused/expected.json +6 -0
- package/fixtures/cases/null-refused/library/companies/acme.md +4 -0
- package/fixtures/cases/null-refused/library/deals/renewal.md +31 -0
- package/fixtures/cases/null-refused/schema.yaml +56 -0
- package/fixtures/cases/numeric-range/context.json +1 -0
- package/fixtures/cases/numeric-range/expected.json +6 -0
- package/fixtures/cases/numeric-range/library/companies/acme.md +4 -0
- package/fixtures/cases/numeric-range/library/deals/renewal.md +31 -0
- package/fixtures/cases/numeric-range/schema.yaml +56 -0
- package/fixtures/cases/one-of-variant/context.json +1 -0
- package/fixtures/cases/one-of-variant/expected.json +6 -0
- package/fixtures/cases/one-of-variant/library/companies/acme.md +4 -0
- package/fixtures/cases/one-of-variant/library/deals/renewal.md +31 -0
- package/fixtures/cases/one-of-variant/schema.yaml +56 -0
- package/fixtures/cases/open-map-value/context.json +1 -0
- package/fixtures/cases/open-map-value/expected.json +6 -0
- package/fixtures/cases/open-map-value/library/companies/acme.md +4 -0
- package/fixtures/cases/open-map-value/library/deals/renewal.md +31 -0
- package/fixtures/cases/open-map-value/schema.yaml +56 -0
- package/fixtures/cases/other-room-reference/context.json +1 -0
- package/fixtures/cases/other-room-reference/expected.json +6 -0
- package/fixtures/cases/other-room-reference/library/companies/acme.md +4 -0
- package/fixtures/cases/other-room-reference/library/deals/renewal.md +14 -0
- package/fixtures/cases/other-room-reference/library/places/depot.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/seats.md +4 -0
- package/fixtures/cases/other-room-reference/library/products/support.md +4 -0
- package/fixtures/cases/other-room-reference/schema.yaml +32 -0
- package/fixtures/cases/paragraph-link-definition/schema.yaml +1 -0
- package/fixtures/cases/prototype-field/expected.json +2 -3
- package/fixtures/cases/prototype-field/schema.yaml +6 -0
- package/fixtures/cases/quoted-link-definition/expected.json +1 -2
- package/fixtures/cases/quoted-link-definition/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 +6 -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/schema.yaml +11 -0
- package/fixtures/cases/remote-ref/context.json +1 -0
- package/fixtures/cases/remote-ref/expected.json +5 -0
- package/fixtures/cases/remote-ref/schema.yaml +3 -0
- package/fixtures/cases/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/section-item-enum/context.json +1 -0
- package/fixtures/cases/section-item-enum/expected.json +6 -0
- package/fixtures/cases/section-item-enum/library/task.md +8 -0
- package/fixtures/cases/section-item-enum/schema.yaml +3 -0
- package/fixtures/cases/section-item-kind/context.json +1 -0
- package/fixtures/cases/section-item-kind/expected.json +6 -0
- package/fixtures/cases/section-item-kind/library/task.md +8 -0
- package/fixtures/cases/section-item-kind/schema.yaml +3 -0
- package/fixtures/cases/section-items/context.json +1 -0
- package/fixtures/cases/section-items/expected.json +1 -0
- package/fixtures/cases/section-items/library/other.md +3 -0
- package/fixtures/cases/section-items/library/page.md +42 -0
- package/fixtures/cases/section-items/schema.yaml +10 -0
- package/fixtures/cases/section-reference-path/context.json +1 -0
- package/fixtures/cases/section-reference-path/expected.json +6 -0
- package/fixtures/cases/section-reference-path/library/other.md +3 -0
- package/fixtures/cases/section-reference-path/library/page.md +7 -0
- package/fixtures/cases/section-reference-path/schema.yaml +3 -0
- package/fixtures/cases/section-reference-type/context.json +1 -0
- package/fixtures/cases/section-reference-type/expected.json +6 -0
- package/fixtures/cases/section-reference-type/library/note.md +1 -0
- package/fixtures/cases/section-reference-type/library/page.md +7 -0
- package/fixtures/cases/section-reference-type/schema.yaml +3 -0
- package/fixtures/cases/shortcut-reference-link/context.json +1 -0
- package/fixtures/cases/shortcut-reference-link/expected.json +5 -0
- package/fixtures/cases/shortcut-reference-link/library/item.md +10 -0
- package/fixtures/cases/shortcut-reference-link/schema.yaml +6 -0
- package/fixtures/cases/string-length/context.json +1 -0
- package/fixtures/cases/string-length/expected.json +6 -0
- package/fixtures/cases/string-length/library/companies/acme.md +4 -0
- package/fixtures/cases/string-length/library/deals/renewal.md +31 -0
- package/fixtures/cases/string-length/schema.yaml +56 -0
- package/fixtures/cases/structured-section/expected.json +1 -2
- package/fixtures/cases/structured-section/schema.yaml +7 -0
- package/fixtures/cases/submission-keys/context.json +1 -0
- package/fixtures/cases/submission-keys/expected.json +1 -0
- package/fixtures/cases/submission-keys/library/notes/visitor.md +8 -0
- package/fixtures/cases/submission-keys/schema.yaml +4 -0
- package/fixtures/cases/text-field-kind/context.json +1 -0
- package/fixtures/cases/text-field-kind/expected.json +6 -0
- package/fixtures/cases/text-field-kind/library/page.md +4 -0
- package/fixtures/cases/text-field-kind/schema.yaml +4 -0
- package/fixtures/cases/thematic-break-in-a-list-section/context.json +1 -0
- package/fixtures/cases/thematic-break-in-a-list-section/expected.json +6 -0
- package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +7 -0
- package/fixtures/cases/thematic-break-in-a-list-section/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 +2 -3
- package/fixtures/cases/undeclared-field/schema.yaml +6 -0
- package/fixtures/cases/unevaluated-items-closed/context.json +1 -0
- package/fixtures/cases/unevaluated-items-closed/expected.json +6 -0
- package/fixtures/cases/unevaluated-items-closed/library/trip.md +6 -0
- package/fixtures/cases/unevaluated-items-closed/schema.yaml +10 -0
- package/fixtures/cases/unknown-type/context.json +1 -0
- package/fixtures/cases/unknown-type/expected.json +6 -0
- package/fixtures/cases/unknown-type/library/item.md +3 -0
- package/fixtures/cases/unknown-type/schema.yaml +3 -0
- package/fixtures/cases/unlisted-reference-type/context.json +1 -0
- package/fixtures/cases/unlisted-reference-type/expected.json +5 -0
- package/fixtures/cases/unlisted-reference-type/schema.yaml +3 -0
- package/fixtures/cases/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 +4 -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 +6 -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 +5 -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 +1 -1
- package/fixtures/cases/unresolved-link/schema.yaml +6 -0
- package/fixtures/cases/valid-typed-document/schema.yaml +16 -0
- package/fixtures/cases/wide-item-fence-link/schema.yaml +1 -0
- package/fixtures/division.json +454 -0
- package/fixtures/preamble.json +24 -3
- package/fixtures/projection.json +194 -22
- 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/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/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/{prd-definition → absent-link-dangles}/context.json +0 -0
- /package/fixtures/cases/{prd-definition → absent-link-dangles}/expected.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/event.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
import { type Kind } from './kinds.js';
|
|
3
|
+
import type { Candidate } from './query/match.js';
|
|
4
|
+
import type { Document, VerifiedModel } from './types.js';
|
|
5
|
+
type Scalar = string | number | boolean;
|
|
6
|
+
export type Fact = {
|
|
7
|
+
readonly kind: Kind;
|
|
8
|
+
readonly value: Scalar;
|
|
9
|
+
readonly member?: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'prose';
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'null';
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'unreadable';
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'list';
|
|
18
|
+
readonly items: readonly Fact[];
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'object';
|
|
21
|
+
readonly fields: Readonly<Record<string, Fact>>;
|
|
22
|
+
};
|
|
23
|
+
export type DocumentFacts = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly type: string | null;
|
|
27
|
+
readonly fields: Readonly<Record<string, Fact>>;
|
|
28
|
+
readonly sections: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
export declare const TEXT_FIELD = "/text";
|
|
31
|
+
export declare const WRITE_DOORS: readonly ['browser', 'agent', 'client', 'function'];
|
|
32
|
+
export type WriteDoor = (typeof WRITE_DOORS)[number];
|
|
33
|
+
export type Actor = {
|
|
34
|
+
readonly user?: string;
|
|
35
|
+
readonly site?: string;
|
|
36
|
+
readonly app?: string;
|
|
37
|
+
readonly door?: WriteDoor;
|
|
38
|
+
};
|
|
39
|
+
export type DocumentEvent = {
|
|
40
|
+
readonly before: DocumentFacts | null;
|
|
41
|
+
readonly after: DocumentFacts | null;
|
|
42
|
+
readonly changed: readonly string[];
|
|
43
|
+
readonly by: Actor;
|
|
44
|
+
readonly moved_between_rooms: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type ItemFacts = {
|
|
47
|
+
readonly delivery: string;
|
|
48
|
+
readonly source: string | null;
|
|
49
|
+
readonly address: string | null;
|
|
50
|
+
readonly container: string | null;
|
|
51
|
+
readonly author: string | null;
|
|
52
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
53
|
+
readonly json: {
|
|
54
|
+
readonly value: unknown;
|
|
55
|
+
} | null;
|
|
56
|
+
};
|
|
57
|
+
export type MessageFacts = {
|
|
58
|
+
readonly sender: string;
|
|
59
|
+
readonly agent_function: string | null;
|
|
60
|
+
readonly path: string | null;
|
|
61
|
+
};
|
|
62
|
+
export type Resolved = {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly member?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare function facts(document: Pick<Document, 'type' | 'fields' | 'sections'>, at: {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly path: string;
|
|
69
|
+
}, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
|
|
70
|
+
export declare function prosePaths(facts: DocumentFacts): string[];
|
|
71
|
+
export declare function members(document: DocumentFacts, path: string): readonly string[];
|
|
72
|
+
export declare function pointed(value: unknown, pointer: string): unknown;
|
|
73
|
+
export declare function valuedChange(definition: Definition, pointer: string): boolean;
|
|
74
|
+
export declare function datePointers(definition: Definition): string[];
|
|
75
|
+
export declare function memberPointers(definition: Definition, memberType: string): string[];
|
|
76
|
+
export declare function candidateOf(document: DocumentFacts): Candidate;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,UAAU,EAEh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.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
2
|
+
import { fitsKind, kindOf } from './kinds.js';
|
|
3
|
+
import { roomPath, target } from './paths.js';
|
|
4
|
+
import { plain } from './yaml.js';
|
|
5
|
+
export const TEXT_FIELD = '/text';
|
|
6
|
+
export const WRITE_DOORS = ['browser', 'agent', 'client', 'function'];
|
|
7
|
+
const PROSE = { kind: 'prose' };
|
|
8
|
+
const NULL = { kind: 'null' };
|
|
9
|
+
const UNREADABLE = { kind: 'unreadable' };
|
|
10
|
+
function referenceFact(value, place) {
|
|
11
|
+
if (typeof value !== 'string')
|
|
12
|
+
return UNREADABLE;
|
|
13
|
+
const reached = target(place.path, value) ?? roomPath(value);
|
|
14
|
+
const resolved = reached === null ? undefined : place.resolve(reached);
|
|
15
|
+
if (resolved === undefined)
|
|
16
|
+
return UNREADABLE;
|
|
17
|
+
return resolved.member === undefined
|
|
18
|
+
? { kind: 'reference', value: resolved.id }
|
|
19
|
+
: { kind: 'reference', value: resolved.id, member: resolved.member };
|
|
20
|
+
}
|
|
21
|
+
function factOf(value, declared, place) {
|
|
22
|
+
if (value === null)
|
|
23
|
+
return NULL;
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
if (declared?.type !== undefined && declared.type !== 'array')
|
|
26
|
+
return UNREADABLE;
|
|
27
|
+
return {
|
|
28
|
+
kind: 'list',
|
|
29
|
+
items: value.map((item, index) => factOf(item, declared === undefined ? undefined : itemFacts(declared, index), place)),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (plain(value)) {
|
|
33
|
+
if (declared?.type !== undefined && declared.type !== 'object')
|
|
34
|
+
return UNREADABLE;
|
|
35
|
+
const fields = Object.create(null);
|
|
36
|
+
for (const [key, held] of Object.entries(value))
|
|
37
|
+
fields[key] = factOf(held, declared === undefined ? undefined : memberFacts(declared, key), place);
|
|
38
|
+
return { kind: 'object', fields };
|
|
39
|
+
}
|
|
40
|
+
if (declared?.type === 'array' || declared?.type === 'object')
|
|
41
|
+
return UNREADABLE;
|
|
42
|
+
const kind = declared === undefined || declared.prose ? null : kindOf(declared);
|
|
43
|
+
if (kind === null)
|
|
44
|
+
return PROSE;
|
|
45
|
+
if (kind === 'reference')
|
|
46
|
+
return referenceFact(value, place);
|
|
47
|
+
return fitsKind(kind, declared, value) ? { kind, value: value } : UNREADABLE;
|
|
48
|
+
}
|
|
49
|
+
export function facts(document, at, model, resolve) {
|
|
50
|
+
const type = document.type ?? null;
|
|
51
|
+
const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
|
|
52
|
+
const fields = Object.create(null);
|
|
53
|
+
const place = { path: at.path, resolve };
|
|
54
|
+
for (const [name, value] of Object.entries(document.fields)) {
|
|
55
|
+
const declared = definition === null ? undefined : fieldFacts(definition, name);
|
|
56
|
+
if (declared !== undefined)
|
|
57
|
+
fields[name] = factOf(value, declared, place);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
id: at.id,
|
|
61
|
+
path: `/${at.path}`,
|
|
62
|
+
type,
|
|
63
|
+
fields,
|
|
64
|
+
sections: Object.keys(document.sections).sort(),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function rootOf(facts, prefix) {
|
|
68
|
+
return { pointer: prefix, fact: { kind: 'object', fields: facts.fields } };
|
|
69
|
+
}
|
|
70
|
+
export function prosePaths(facts) {
|
|
71
|
+
const paths = facts.sections.map((heading) => `/sections/${heading}`);
|
|
72
|
+
const visit = ({ pointer, fact }) => {
|
|
73
|
+
if (fact.kind === 'prose')
|
|
74
|
+
paths.push(pointer);
|
|
75
|
+
if (fact.kind === 'list')
|
|
76
|
+
fact.items.forEach((item, index) => visit({ pointer: `${pointer}/${index}`, fact: item }));
|
|
77
|
+
if (fact.kind === 'object')
|
|
78
|
+
for (const [key, held] of Object.entries(fact.fields))
|
|
79
|
+
visit({ pointer: `${pointer}/${escapePointer(key)}`, fact: held });
|
|
80
|
+
};
|
|
81
|
+
visit(rootOf(facts, '/fields'));
|
|
82
|
+
return paths.sort();
|
|
83
|
+
}
|
|
84
|
+
function walked(start, pointer) {
|
|
85
|
+
let reached = [start];
|
|
86
|
+
for (const token of pointerSegments(pointer)) {
|
|
87
|
+
const step = ({ pointer: at, fact }) => {
|
|
88
|
+
if (fact.kind === 'object')
|
|
89
|
+
return Object.hasOwn(fact.fields, token)
|
|
90
|
+
? [{ pointer: `${at}/${escapePointer(token)}`, fact: fact.fields[token] }]
|
|
91
|
+
: [];
|
|
92
|
+
if (fact.kind !== 'list')
|
|
93
|
+
return [];
|
|
94
|
+
if (ARRAY_INDEX.test(token)) {
|
|
95
|
+
const item = fact.items[Number(token)];
|
|
96
|
+
return item === undefined ? [] : [{ pointer: `${at}/${token}`, fact: item }];
|
|
97
|
+
}
|
|
98
|
+
return fact.items
|
|
99
|
+
.map((item, index) => ({ pointer: `${at}/${index}`, fact: item }))
|
|
100
|
+
.flatMap(step);
|
|
101
|
+
};
|
|
102
|
+
reached = reached.flatMap(step);
|
|
103
|
+
}
|
|
104
|
+
return reached;
|
|
105
|
+
}
|
|
106
|
+
function expand(fact) {
|
|
107
|
+
return fact.kind === 'list' ? fact.items.flatMap(expand) : [fact];
|
|
108
|
+
}
|
|
109
|
+
export function members(document, path) {
|
|
110
|
+
if (!path.startsWith('/members/'))
|
|
111
|
+
return [];
|
|
112
|
+
return [
|
|
113
|
+
...new Set(walked(rootOf(document, '/members'), path.slice('/members'.length))
|
|
114
|
+
.flatMap(({ fact }) => expand(fact))
|
|
115
|
+
.flatMap((fact) => fact.kind === 'reference' && fact.member !== undefined ? [fact.member] : [])),
|
|
116
|
+
].sort();
|
|
117
|
+
}
|
|
118
|
+
export function pointed(value, pointer) {
|
|
119
|
+
let reached = value;
|
|
120
|
+
for (const token of pointerSegments(pointer)) {
|
|
121
|
+
if (Array.isArray(reached)) {
|
|
122
|
+
if (!ARRAY_INDEX.test(token))
|
|
123
|
+
return undefined;
|
|
124
|
+
reached = reached[Number(token)];
|
|
125
|
+
}
|
|
126
|
+
else if (plain(reached) && Object.hasOwn(reached, token)) {
|
|
127
|
+
reached = reached[token];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return reached;
|
|
134
|
+
}
|
|
135
|
+
export function valuedChange(definition, pointer) {
|
|
136
|
+
const reached = pointerFacts(definition, pointer);
|
|
137
|
+
return (reached !== undefined &&
|
|
138
|
+
!reached.through &&
|
|
139
|
+
reached.facts.type !== 'array' &&
|
|
140
|
+
!reached.facts.prose &&
|
|
141
|
+
kindOf(reached.facts) !== null);
|
|
142
|
+
}
|
|
143
|
+
export function datePointers(definition) {
|
|
144
|
+
return Object.entries(definition.fields)
|
|
145
|
+
.filter(([, held]) => kindOf(held) === 'date')
|
|
146
|
+
.map(([name]) => `/${escapePointer(name)}`)
|
|
147
|
+
.sort();
|
|
148
|
+
}
|
|
149
|
+
export function memberPointers(definition, memberType) {
|
|
150
|
+
return Object.entries(definition.fields)
|
|
151
|
+
.filter(([, held]) => (held.type === 'array' ? held.items : held)?.reference?.includes(memberType) === true)
|
|
152
|
+
.map(([name]) => `/members/${escapePointer(name)}`);
|
|
153
|
+
}
|
|
154
|
+
function plainOf(fact) {
|
|
155
|
+
if (fact.kind === 'list')
|
|
156
|
+
return fact.items.map(plainOf);
|
|
157
|
+
if (fact.kind === 'object')
|
|
158
|
+
return Object.fromEntries(Object.entries(fact.fields).flatMap(([key, held]) => {
|
|
159
|
+
const value = plainOf(held);
|
|
160
|
+
return value === undefined ? [] : [[key, value]];
|
|
161
|
+
}));
|
|
162
|
+
if (fact.kind === 'prose')
|
|
163
|
+
return true;
|
|
164
|
+
if (fact.kind === 'null')
|
|
165
|
+
return null;
|
|
166
|
+
if (fact.kind === 'unreadable')
|
|
167
|
+
return undefined;
|
|
168
|
+
return fact.value;
|
|
169
|
+
}
|
|
170
|
+
function shapeOf(fact) {
|
|
171
|
+
if (fact.kind === 'list')
|
|
172
|
+
return { type: 'array', prose: false, prefix: fact.items.map(shapeOf) };
|
|
173
|
+
if (fact.kind === 'object')
|
|
174
|
+
return {
|
|
175
|
+
type: 'object',
|
|
176
|
+
prose: false,
|
|
177
|
+
properties: Object.fromEntries(Object.entries(fact.fields).map(([key, held]) => [key, shapeOf(held)])),
|
|
178
|
+
};
|
|
179
|
+
if (fact.kind === 'date-time')
|
|
180
|
+
return { type: 'string', format: 'date-time', prose: false };
|
|
181
|
+
return { prose: false };
|
|
182
|
+
}
|
|
183
|
+
export function candidateOf(document) {
|
|
184
|
+
const fields = {};
|
|
185
|
+
const properties = {};
|
|
186
|
+
for (const [name, fact] of Object.entries(document.fields)) {
|
|
187
|
+
const value = plainOf(fact);
|
|
188
|
+
if (value === undefined)
|
|
189
|
+
continue;
|
|
190
|
+
fields[name] = value;
|
|
191
|
+
properties[name] = shapeOf(fact);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
path: document.path.slice(1),
|
|
195
|
+
type: document.type,
|
|
196
|
+
fileId: document.id,
|
|
197
|
+
fields,
|
|
198
|
+
definition: { frontmatter: { type: 'object', prose: false, properties } },
|
|
199
|
+
text: null,
|
|
200
|
+
};
|
|
201
|
+
}
|
package/dist/facts.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Document, ParseResult, VerifiedModel } from './types.js';
|
|
2
|
+
export type SavedFacts = {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
5
|
+
readonly links: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export type ReferenceTarget = {
|
|
8
|
+
readonly location: string;
|
|
9
|
+
readonly to: readonly string[];
|
|
10
|
+
readonly target: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function referenceTarget(file: string, value: string): string | null;
|
|
13
|
+
export declare function referenceTargets(document: Document, file: string, model: VerifiedModel): readonly ReferenceTarget[];
|
|
14
|
+
export declare function documentFacts(file: string, parsed: ParseResult, model: VerifiedModel): SavedFacts | null;
|
|
15
|
+
//# sourceMappingURL=facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,SAAS,eAAe,EAAE,CAO5B;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,GACnB,UAAU,GAAG,IAAI,CAenB"}
|
package/dist/facts.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BUILT_IN_TYPE } from './definition.js';
|
|
2
|
+
import { links, parse } from './document.js';
|
|
3
|
+
import { target } from './paths.js';
|
|
4
|
+
import { references } from './references.js';
|
|
5
|
+
const SETTINGS_AREA = 'settings/';
|
|
6
|
+
export function referenceTarget(file, value) {
|
|
7
|
+
if (value.trim() === '' || /[<>\n\r]/.test(value))
|
|
8
|
+
return null;
|
|
9
|
+
if (!value.includes('\\'))
|
|
10
|
+
return target(file, value);
|
|
11
|
+
const parsed = parse(`[](<${value}>)\n`, file);
|
|
12
|
+
if (!parsed.ok)
|
|
13
|
+
return null;
|
|
14
|
+
return links(parsed.document, file)[0]?.target ?? null;
|
|
15
|
+
}
|
|
16
|
+
export function referenceTargets(document, file, model) {
|
|
17
|
+
const type = document.type;
|
|
18
|
+
if (type === undefined || !Object.hasOwn(model.types, type))
|
|
19
|
+
return [];
|
|
20
|
+
return references(document, model.types[type]).flatMap(({ pointer, value, to }) => {
|
|
21
|
+
const target = referenceTarget(file, value);
|
|
22
|
+
return target === null ? [] : [{ location: pointer, to, target }];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function documentFacts(file, parsed, model) {
|
|
26
|
+
if (!parsed.ok)
|
|
27
|
+
return null;
|
|
28
|
+
const { document } = parsed;
|
|
29
|
+
return {
|
|
30
|
+
type: document.type ?? BUILT_IN_TYPE,
|
|
31
|
+
fields: document.fields,
|
|
32
|
+
links: file.startsWith(SETTINGS_AREA)
|
|
33
|
+
? []
|
|
34
|
+
: [
|
|
35
|
+
...new Set([
|
|
36
|
+
...links(document, file).map((link) => link.target),
|
|
37
|
+
...referenceTargets(document, file, model).map(({ target }) => target),
|
|
38
|
+
]),
|
|
39
|
+
].sort(),
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const TYPE_FIELD = "type";
|
|
2
|
+
export declare const MEMBER_FIELD = "member";
|
|
3
|
+
export declare const SITE_FIELD = "site";
|
|
4
|
+
export declare const RECEIVED_FIELD = "received";
|
|
5
|
+
export declare const HOUSE_FIELDS: readonly string[];
|
|
6
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/fields.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,YAAY,WAAW,CAAC;AAErC,eAAO,MAAM,UAAU,SAAS,CAAC;AAEjC,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,eAAO,MAAM,YAAY,EAAE,SAAS,MAAM,EAKzC,CAAC"}
|
package/dist/fields.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { candidateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
|
|
2
|
+
export type { Actor, DocumentEvent, DocumentFacts, Fact, ItemFacts, MessageFacts, Resolved, WriteDoor, } from './event.js';
|
|
3
|
+
export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
|
|
4
|
+
export type { Kind, Ordering } from './kinds.js';
|
|
5
|
+
export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
|
|
6
|
+
export type { Clause, Continuation, Direction, DocumentQuery, DocumentShape, Filter, GroupKey, GroupOrder, GroupQuery, GroupSelect, GroupShape, HeldRooms, Key, KeyPlan, LocalQuery, OrderOptions, Place, Predicate, QueryErrorCode, QueryPlan, Related, RoomFacts, Scope, Select, Test, Value, Where, } from './query/language.js';
|
|
7
|
+
export { heldAt, matches } from './query/match.js';
|
|
8
|
+
export type { Candidate } from './query/match.js';
|
|
9
|
+
export { heldKind, indexed } from './query/rows.js';
|
|
10
|
+
export type { HeldKind, HeldLink, HeldValue, Indexed, Reach } from './query/rows.js';
|
|
11
|
+
export * as sql from './query/sql.js';
|
|
12
|
+
export { headingLines } from './markdown.js';
|
|
13
|
+
export type { HeadingLine } from './markdown.js';
|
|
14
|
+
export { divide } from './divide.js';
|
|
15
|
+
export { apply, bodyLinks, create, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
|
|
16
|
+
export { documentFacts, referenceTarget, referenceTargets } from './facts.js';
|
|
17
|
+
export type { ReferenceTarget, SavedFacts } from './facts.js';
|
|
18
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
19
|
+
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
20
|
+
export { openPatternBudget } from './pattern.js';
|
|
21
|
+
export type { RoomTarget } from './paths.js';
|
|
3
22
|
export { project } from './project.js';
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
23
|
+
export { references } from './references.js';
|
|
24
|
+
export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
|
|
25
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
|
|
26
|
+
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
27
|
+
export type { ApplyResult, BodyResult, Change, DefinitionOf, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, TypedPath, UnlinkedBody, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
|
|
28
|
+
export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
29
|
+
export type { Assessment, Verdicts } from './validate.js';
|
|
6
30
|
export { VERSION } from './version.js';
|
|
31
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
|
|
32
|
+
export type { FrontmatterValue } from './yaml.js';
|
|
7
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,KAAK,EACL,aAAa,EACb,aAAa,EACb,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,UAAU,EACV,OAAO,EACP,KAAK,EACL,SAAS,EACT,MAAM,EACN,UAAU,EACV,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,MAAM,EACN,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,GAAG,EACH,OAAO,EACP,UAAU,EACV,YAAY,EACZ,KAAK,EACL,SAAS,EACT,cAAc,EACd,SAAS,EACT,OAAO,EACP,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 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
1
|
+
export { candidateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
|
|
2
|
+
export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
|
|
3
|
+
export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
|
|
4
|
+
export { heldAt, matches } from './query/match.js';
|
|
5
|
+
export { heldKind, indexed } from './query/rows.js';
|
|
6
|
+
export * as sql from './query/sql.js';
|
|
7
|
+
export { headingLines } from './markdown.js';
|
|
8
|
+
export { divide } from './divide.js';
|
|
9
|
+
export { apply, bodyLinks, create, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
|
|
10
|
+
export { documentFacts, referenceTarget, referenceTargets } from './facts.js';
|
|
11
|
+
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
12
|
+
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
13
|
+
export { openPatternBudget } from './pattern.js';
|
|
3
14
|
export { project } from './project.js';
|
|
4
|
-
export {
|
|
15
|
+
export { references } from './references.js';
|
|
16
|
+
export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
|
|
17
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
|
|
18
|
+
export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
5
19
|
export { VERSION } from './version.js';
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
20
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
|
package/dist/kinds.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ValueFacts } from './definition.js';
|
|
2
|
+
export type Kind = 'string' | 'number' | 'integer' | 'boolean' | 'date' | 'date-time' | 'time' | 'enum' | 'reference';
|
|
3
|
+
export type Ordering = {
|
|
4
|
+
readonly direction: 'asc' | 'desc';
|
|
5
|
+
readonly nulls: 'first' | 'last';
|
|
6
|
+
readonly stringSort: 'lexical' | 'locale';
|
|
7
|
+
readonly locale: string | undefined;
|
|
8
|
+
readonly localeOptions: Intl.CollatorOptions | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare function kindOf(facts: ValueFacts): Kind | null;
|
|
11
|
+
export declare function fitsKind(kind: Kind, facts: ValueFacts, value: unknown): boolean;
|
|
12
|
+
export declare function kindWords(facts: ValueFacts | undefined): readonly string[];
|
|
13
|
+
export declare function dated(value: unknown): value is string;
|
|
14
|
+
export declare function instant(value: unknown): bigint | undefined;
|
|
15
|
+
export declare function instantKey(value: unknown): string | null;
|
|
16
|
+
export declare function byCodePoint(left: string, right: string): number;
|
|
17
|
+
export declare function compared(left: unknown, right: unknown, ordering: Ordering): number;
|
|
18
|
+
//# sourceMappingURL=kinds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,MAAM,IAAI,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,GACN,WAAW,GACX,MAAM,GACN,MAAM,GACN,WAAW,CAAC;AAEhB,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;CAC1D,CAAC;AASF,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,IAAI,CAWrD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAW/E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,SAAS,GAAG,SAAS,MAAM,EAAE,CAe1E;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAErD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAqB1D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGxD;AAaD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/D;AA4BD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAMlF"}
|
package/dist/kinds.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { format } from '@cfworker/json-schema';
|
|
2
|
+
import { normalize } from './paths.js';
|
|
3
|
+
const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})[Tt\s](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?(?:[Zz]|([+-])(\d{2})(?::?(\d{2}))?)$/u;
|
|
4
|
+
const BEFORE_YEAR_ZERO = 62200000000000000000n;
|
|
5
|
+
const INSTANT_DIGITS = 21;
|
|
6
|
+
export function kindOf(facts) {
|
|
7
|
+
if (facts.reference !== undefined)
|
|
8
|
+
return 'reference';
|
|
9
|
+
if (facts.values !== undefined)
|
|
10
|
+
return 'enum';
|
|
11
|
+
if (facts.type === 'number')
|
|
12
|
+
return 'number';
|
|
13
|
+
if (facts.type === 'integer')
|
|
14
|
+
return 'integer';
|
|
15
|
+
if (facts.type === 'boolean')
|
|
16
|
+
return 'boolean';
|
|
17
|
+
if (facts.type !== 'string')
|
|
18
|
+
return null;
|
|
19
|
+
if (facts.format === 'date')
|
|
20
|
+
return 'date';
|
|
21
|
+
if (facts.format === 'date-time')
|
|
22
|
+
return 'date-time';
|
|
23
|
+
if (facts.format === 'time')
|
|
24
|
+
return 'time';
|
|
25
|
+
return 'string';
|
|
26
|
+
}
|
|
27
|
+
export function fitsKind(kind, facts, value) {
|
|
28
|
+
if (kind === 'enum')
|
|
29
|
+
return (facts.values ?? []).includes(value);
|
|
30
|
+
if (kind === 'number')
|
|
31
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
32
|
+
if (kind === 'integer')
|
|
33
|
+
return Number.isSafeInteger(value);
|
|
34
|
+
if (kind === 'boolean')
|
|
35
|
+
return typeof value === 'boolean';
|
|
36
|
+
if (typeof value !== 'string')
|
|
37
|
+
return false;
|
|
38
|
+
if (kind === 'reference')
|
|
39
|
+
return value !== '' && normalize(value) === value;
|
|
40
|
+
if (kind === 'date')
|
|
41
|
+
return dated(value);
|
|
42
|
+
if (kind === 'date-time')
|
|
43
|
+
return instant(value) !== undefined;
|
|
44
|
+
if (kind === 'time')
|
|
45
|
+
return format.time(value);
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
export function kindWords(facts) {
|
|
49
|
+
const kind = facts === undefined ? null : kindOf(facts);
|
|
50
|
+
if (kind === 'enum')
|
|
51
|
+
return (facts.values ?? []).map((value) => typeof value === 'string' ? value : JSON.stringify(value));
|
|
52
|
+
if (kind === 'number')
|
|
53
|
+
return ['a number'];
|
|
54
|
+
if (kind === 'integer')
|
|
55
|
+
return ['an integer'];
|
|
56
|
+
if (kind === 'boolean')
|
|
57
|
+
return ['true', 'false'];
|
|
58
|
+
if (kind === 'date')
|
|
59
|
+
return ['a date as YYYY-MM-DD'];
|
|
60
|
+
if (kind === 'date-time')
|
|
61
|
+
return ['a date-time with its offset, such as 2026-10-10T09:30:00Z'];
|
|
62
|
+
if (kind === 'time')
|
|
63
|
+
return ['a time as HH:MM:SS'];
|
|
64
|
+
if (kind === 'reference')
|
|
65
|
+
return [`the Room Path of a ${facts.reference.join(' or ')} document, such as notes/a.md`];
|
|
66
|
+
return kind === 'string' ? ['a string'] : [];
|
|
67
|
+
}
|
|
68
|
+
export function dated(value) {
|
|
69
|
+
return typeof value === 'string' && format.date(value);
|
|
70
|
+
}
|
|
71
|
+
export function instant(value) {
|
|
72
|
+
if (typeof value !== 'string' || !format['date-time'](value))
|
|
73
|
+
return undefined;
|
|
74
|
+
const parts = DATE_TIME.exec(value);
|
|
75
|
+
const [year, month, day, hour, minute, second, offsetHours, offsetMinutes] = [
|
|
76
|
+
1, 2, 3, 4, 5, 6, 9, 10,
|
|
77
|
+
].map((at) => Number(parts[at] ?? 0));
|
|
78
|
+
const at = new Date(0);
|
|
79
|
+
at.setUTCFullYear(year, month - 1, day);
|
|
80
|
+
at.setUTCHours(hour, minute, second);
|
|
81
|
+
const offset = (parts[8] === '-' ? -1 : 1) * (offsetHours * 60 + offsetMinutes);
|
|
82
|
+
const fraction = (parts[7] ?? '').padEnd(9, '0').slice(0, 9);
|
|
83
|
+
return (BigInt(at.getTime()) - BigInt(offset) * 60000n) * 1000000n + BigInt(fraction);
|
|
84
|
+
}
|
|
85
|
+
export function instantKey(value) {
|
|
86
|
+
const at = instant(value);
|
|
87
|
+
return at === undefined ? null : (at + BEFORE_YEAR_ZERO).toString().padStart(INSTANT_DIGITS, '0');
|
|
88
|
+
}
|
|
89
|
+
function rank(value) {
|
|
90
|
+
if (typeof value === 'boolean' || typeof value === 'number')
|
|
91
|
+
return 1;
|
|
92
|
+
if (typeof value === 'string')
|
|
93
|
+
return 2;
|
|
94
|
+
return Array.isArray(value) ? 3 : 4;
|
|
95
|
+
}
|
|
96
|
+
function unit(code) {
|
|
97
|
+
if (code >= 0xd800 && code < 0xe000)
|
|
98
|
+
return code + 0x2000;
|
|
99
|
+
return code >= 0xe000 ? code - 0x800 : code;
|
|
100
|
+
}
|
|
101
|
+
export function byCodePoint(left, right) {
|
|
102
|
+
for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
|
|
103
|
+
const ours = left.charCodeAt(at);
|
|
104
|
+
const theirs = right.charCodeAt(at);
|
|
105
|
+
if (ours !== theirs)
|
|
106
|
+
return unit(ours) - unit(theirs);
|
|
107
|
+
}
|
|
108
|
+
return left.length - right.length;
|
|
109
|
+
}
|
|
110
|
+
function ascending(left, right, ordering) {
|
|
111
|
+
if (left == null && right == null)
|
|
112
|
+
return 0;
|
|
113
|
+
if (left == null)
|
|
114
|
+
return ordering.nulls === 'first' ? -1 : 1;
|
|
115
|
+
if (right == null)
|
|
116
|
+
return ordering.nulls === 'first' ? 1 : -1;
|
|
117
|
+
const ranked = rank(left) - rank(right);
|
|
118
|
+
if (ranked !== 0)
|
|
119
|
+
return ranked;
|
|
120
|
+
if (typeof left === 'string' && typeof right === 'string') {
|
|
121
|
+
return ordering.stringSort === 'locale'
|
|
122
|
+
? left.localeCompare(right, ordering.locale, ordering.localeOptions)
|
|
123
|
+
: byCodePoint(left, right);
|
|
124
|
+
}
|
|
125
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
126
|
+
for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
|
|
127
|
+
const result = ascending(left[at], right[at], ordering);
|
|
128
|
+
if (result !== 0)
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
return left.length - right.length;
|
|
132
|
+
}
|
|
133
|
+
if (typeof left === 'object')
|
|
134
|
+
return 0;
|
|
135
|
+
const held = left;
|
|
136
|
+
const other = right;
|
|
137
|
+
if (held < other)
|
|
138
|
+
return -1;
|
|
139
|
+
if (held > other)
|
|
140
|
+
return 1;
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
export function compared(left, right, ordering) {
|
|
144
|
+
if (ordering.direction === 'asc')
|
|
145
|
+
return ascending(left, right, ordering);
|
|
146
|
+
return ascending(right, left, {
|
|
147
|
+
...ordering,
|
|
148
|
+
nulls: ordering.nulls === 'first' ? 'last' : 'first',
|
|
149
|
+
});
|
|
150
|
+
}
|