@agentshouse/mdmodel 0.1.0-cb304fd2c27f9 → 0.1.0-cbb41ab5ebbd2
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 +203 -173
- package/README.md +26 -25
- package/dist/body.d.ts +85 -0
- package/dist/body.d.ts.map +1 -0
- package/dist/body.js +1083 -0
- package/dist/built-in.d.ts +4 -0
- package/dist/built-in.d.ts.map +1 -0
- package/dist/built-in.js +19 -0
- package/dist/definition.d.ts +24 -11
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +188 -128
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +5 -4
- package/dist/document.d.ts +14 -9
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +759 -148
- 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 +39 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -13
- package/dist/indexed.d.ts +9 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +55 -0
- package/dist/kinds.d.ts +5 -2
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +80 -11
- 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 +88 -19
- package/dist/pattern.d.ts.map +1 -1
- package/dist/pattern.js +4 -3
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +33 -60
- package/dist/query/language.d.ts +45 -8
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +152 -58
- package/dist/query/match.d.ts +3 -1
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +40 -8
- package/dist/query/rows.d.ts +1 -1
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +2 -5
- package/dist/query/sql.d.ts +5 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +10 -4
- package/dist/query/walk.d.ts +63 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +263 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/refuse.d.ts +1 -0
- package/dist/refuse.d.ts.map +1 -1
- package/dist/refuse.js +1 -0
- package/dist/reserved.d.ts +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +2 -1
- 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 -3
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +9 -73
- package/dist/types.d.ts +15 -22
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +10 -5
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +150 -184
- package/dist/yaml.d.ts +4 -4
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +5 -12
- package/fixtures/README.md +49 -24
- 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-section → conditional-long-text}/expected.json +3 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/hosting.md +2 -2
- package/fixtures/cases/{conditional-section → conditional-long-text}/library/questions/payments.md +2 -2
- package/fixtures/cases/conditional-long-text/schema.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/library/notes/a.md +1 -1
- 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/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/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/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-another-type/library/note.md +1 -1
- 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/expected.json +2 -1
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +1 -1
- package/fixtures/cases/referenced-missing-file/library/a.md +2 -2
- package/fixtures/cases/referenced-missing-file/library/b.md +2 -2
- package/fixtures/cases/referenced-missing-file/schema.yaml +3 -4
- 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-its-type/library/settings/prefs/one.md +1 -1
- 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/library/rooms/team/tasks/plan.md +2 -1
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +3 -2
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +2 -2
- 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 +29 -8
- package/fixtures/projection.json +121 -18
- package/fixtures/queries.json +449 -3
- package/package.json +10 -1
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -91
- package/dist/condition.d.ts +0 -179
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -598
- package/dist/links.d.ts +0 -29
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -831
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
- package/fixtures/cases/conditional-section/schema.yaml +0 -14
- 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/{conditional-section → conditional-long-text}/context.json +0 -0
- /package/fixtures/cases/{missing-section-item-kind → equal-labels}/context.json +0 -0
- /package/fixtures/cases/{null-refused → 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/{open-map-value → lazy-list-item}/context.json +0 -0
- /package/fixtures/cases/{section-item-enum → list-item-enum}/context.json +0 -0
- /package/fixtures/cases/{section-item-kind → list-item-kind}/context.json +0 -0
- /package/fixtures/cases/{section-items → 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}/context.json +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}/context.json +0 -0
- /package/fixtures/cases/{section-reference-type → list-reference-type}/library/note.md +0 -0
- /package/fixtures/cases/{structured-section → long-value-past-six-levels}/context.json +0 -0
package/dist/query/language.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Definition } from '../definition.js';
|
|
1
|
+
import { type Definition, type ValueFacts } from '../definition.js';
|
|
2
2
|
export type Value = string | number | boolean | null;
|
|
3
3
|
export type Predicate = Value | {
|
|
4
4
|
$eq: Value;
|
|
@@ -37,6 +37,7 @@ export type Filter = {
|
|
|
37
37
|
types?: readonly string[];
|
|
38
38
|
where?: Where;
|
|
39
39
|
pathPrefix?: string;
|
|
40
|
+
outside?: readonly string[];
|
|
40
41
|
folder?: string;
|
|
41
42
|
paths?: readonly string[];
|
|
42
43
|
fileIds?: readonly string[];
|
|
@@ -48,7 +49,10 @@ export type Filter = {
|
|
|
48
49
|
};
|
|
49
50
|
text?: string;
|
|
50
51
|
};
|
|
51
|
-
export type Key = 'room' | 'path' | 'type' | 'folder' | {
|
|
52
|
+
export type Key = 'room' | 'path' | 'type' | 'folder' | 'size' | 'created' | 'updated' | {
|
|
53
|
+
field: string;
|
|
54
|
+
};
|
|
55
|
+
export type GroupKey = 'room' | 'type' | 'folder' | 'subfolder' | {
|
|
52
56
|
field: string;
|
|
53
57
|
};
|
|
54
58
|
export type Select = 'all' | {
|
|
@@ -60,7 +64,17 @@ export type Select = 'all' | {
|
|
|
60
64
|
change?: true;
|
|
61
65
|
fileId?: true;
|
|
62
66
|
revision?: true;
|
|
67
|
+
size?: true;
|
|
68
|
+
created?: true;
|
|
69
|
+
};
|
|
70
|
+
export type GroupSelect = {
|
|
71
|
+
size?: true;
|
|
72
|
+
updated?: true;
|
|
73
|
+
greatest?: {
|
|
74
|
+
field: string;
|
|
75
|
+
};
|
|
63
76
|
};
|
|
77
|
+
export type GroupOrder = 'count' | 'size' | 'updated' | 'greatest';
|
|
64
78
|
export type OrderOptions = {
|
|
65
79
|
nulls?: 'first' | 'last';
|
|
66
80
|
stringSort?: 'lexical' | 'locale';
|
|
@@ -79,10 +93,12 @@ export type DocumentQuery = Filter & {
|
|
|
79
93
|
total?: true;
|
|
80
94
|
};
|
|
81
95
|
export type GroupQuery = Filter & {
|
|
82
|
-
groupBy: readonly
|
|
96
|
+
groupBy: readonly GroupKey[];
|
|
97
|
+
select?: GroupSelect;
|
|
83
98
|
orderBy?: readonly {
|
|
84
|
-
by:
|
|
99
|
+
by: GroupOrder | GroupKey;
|
|
85
100
|
direction?: Direction;
|
|
101
|
+
nulls?: 'first' | 'last';
|
|
86
102
|
}[];
|
|
87
103
|
limit?: number;
|
|
88
104
|
after?: string;
|
|
@@ -148,6 +164,14 @@ export type KeyPlan = {
|
|
|
148
164
|
of: 'type';
|
|
149
165
|
} | {
|
|
150
166
|
of: 'folder';
|
|
167
|
+
} | {
|
|
168
|
+
of: 'subfolder';
|
|
169
|
+
} | {
|
|
170
|
+
of: 'size';
|
|
171
|
+
} | {
|
|
172
|
+
of: 'created';
|
|
173
|
+
} | {
|
|
174
|
+
of: 'updated';
|
|
151
175
|
} | {
|
|
152
176
|
of: 'field';
|
|
153
177
|
field: string;
|
|
@@ -162,6 +186,8 @@ export type DocumentShape = {
|
|
|
162
186
|
change: boolean;
|
|
163
187
|
fileId: boolean;
|
|
164
188
|
revision: boolean;
|
|
189
|
+
size: boolean;
|
|
190
|
+
created: boolean;
|
|
165
191
|
orderBy: readonly {
|
|
166
192
|
key: KeyPlan;
|
|
167
193
|
options: OrderOptions & {
|
|
@@ -172,9 +198,13 @@ export type DocumentShape = {
|
|
|
172
198
|
export type GroupShape = {
|
|
173
199
|
kind: 'groups';
|
|
174
200
|
groupBy: readonly KeyPlan[];
|
|
201
|
+
size: boolean;
|
|
202
|
+
updated: boolean;
|
|
203
|
+
greatest: string | null;
|
|
175
204
|
orderBy: readonly {
|
|
176
|
-
by:
|
|
205
|
+
by: GroupOrder | number;
|
|
177
206
|
direction: Direction;
|
|
207
|
+
nulls: 'first' | 'last' | null;
|
|
178
208
|
}[];
|
|
179
209
|
};
|
|
180
210
|
export type Continuation = {
|
|
@@ -185,6 +215,7 @@ export type QueryPlan = {
|
|
|
185
215
|
key: string;
|
|
186
216
|
rooms: readonly string[] | null;
|
|
187
217
|
root: Scope;
|
|
218
|
+
outside: readonly string[] | null;
|
|
188
219
|
folder: string | null;
|
|
189
220
|
paths: readonly string[] | null;
|
|
190
221
|
fileIds: readonly string[] | null;
|
|
@@ -200,15 +231,21 @@ export type QueryPlan = {
|
|
|
200
231
|
after: Continuation | null;
|
|
201
232
|
total: boolean;
|
|
202
233
|
};
|
|
234
|
+
export type Place = readonly (string | number)[];
|
|
235
|
+
type At = Place | string;
|
|
203
236
|
export declare class QueryError extends Error {
|
|
204
237
|
readonly code: QueryErrorCode;
|
|
238
|
+
readonly place: Place;
|
|
239
|
+
readonly accepts: readonly string[];
|
|
205
240
|
readonly retryable = false;
|
|
206
|
-
constructor(code: QueryErrorCode, at:
|
|
241
|
+
constructor(code: QueryErrorCode, at: At, problem: string, accepts?: readonly string[]);
|
|
207
242
|
}
|
|
208
243
|
type Entries = Readonly<Record<string, unknown>>;
|
|
209
244
|
export declare function bodied(shape: DocumentShape): boolean;
|
|
210
|
-
export declare function invalid(at:
|
|
211
|
-
export declare function
|
|
245
|
+
export declare function invalid(at: At, problem: string, accepts?: readonly string[]): never;
|
|
246
|
+
export declare function placeText(at: Place): string;
|
|
247
|
+
export declare function known(value: Entries, allowed: readonly string[], at: At): void;
|
|
248
|
+
export declare function textless(facts: ValueFacts): boolean;
|
|
212
249
|
export declare function planOf(input: unknown, facts: HeldRooms): QueryPlan;
|
|
213
250
|
export declare function cursorOf(values: readonly unknown[]): string;
|
|
214
251
|
export declare function decodedCursor(text: string): readonly unknown[] | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/query/language.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/query/language.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAEf,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAK1B,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAErD,MAAM,MAAM,SAAS,GACjB,KAAK,GACL;IAAE,GAAG,EAAE,KAAK,CAAA;CAAE,GACd;IAAE,GAAG,EAAE,KAAK,CAAA;CAAE,GACd;IAAE,GAAG,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,GAC1B;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAC;IAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,SAAS,KAAK,EAAE,CAAA;CAAE,GAC1B;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GACpB;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExB,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,CAAC,EAAE,SAAS,KAAK,EAAE,CAAC;IACxB,GAAG,CAAC,E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AC;AAyCjD,wBAAgB,MAAM,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAEpD;AAED,wBAAgB,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,KAAK,CAEvF;AAOD,wBAAgB,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,CAM3C;AAMD,wBAAgB,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,QAIvE;AAqED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAInD;AA4bD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAyBlE;AAmBD,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAE3D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,OAAO,EAAE,GAAG,IAAI,CAOrE;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE/C;AAaD,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAElD"}
|
package/dist/query/language.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import { pointerFacts, } from '../definition.js';
|
|
2
|
-
import { fitsKind, kindOf } from '../kinds.js';
|
|
1
|
+
import { crossedFacts, escapePointer, pointerFacts, pointerSegments, } from '../definition.js';
|
|
2
|
+
import { fitsKind, kindOf, kindWords } from '../kinds.js';
|
|
3
3
|
import { normalize } from '../paths.js';
|
|
4
4
|
import { plain } from '../yaml.js';
|
|
5
5
|
export class QueryError extends Error {
|
|
6
6
|
code;
|
|
7
|
+
place;
|
|
8
|
+
accepts;
|
|
7
9
|
retryable = false;
|
|
8
|
-
constructor(code, at, problem) {
|
|
9
|
-
super(`${code} at ${at}: ${problem}`);
|
|
10
|
+
constructor(code, at, problem, accepts = []) {
|
|
11
|
+
super(`${code} at ${placeText(placed(at))}: ${problem}`);
|
|
10
12
|
this.code = code;
|
|
13
|
+
this.place = placed(at);
|
|
14
|
+
this.accepts = accepts;
|
|
11
15
|
}
|
|
12
16
|
}
|
|
13
17
|
const RANGE = ['$gt', '$gte', '$lt', '$lte'];
|
|
@@ -17,6 +21,7 @@ const FILTER = [
|
|
|
17
21
|
'types',
|
|
18
22
|
'where',
|
|
19
23
|
'pathPrefix',
|
|
24
|
+
'outside',
|
|
20
25
|
'folder',
|
|
21
26
|
'paths',
|
|
22
27
|
'fileIds',
|
|
@@ -34,22 +39,42 @@ const PARTS = [
|
|
|
34
39
|
'change',
|
|
35
40
|
'fileId',
|
|
36
41
|
'revision',
|
|
42
|
+
'size',
|
|
43
|
+
'created',
|
|
37
44
|
];
|
|
45
|
+
const GROUP_PARTS = ['size', 'updated', 'greatest'];
|
|
46
|
+
const DOCUMENT_KEYS = ['room', 'path', 'type', 'folder', 'size', 'created', 'updated'];
|
|
47
|
+
const GROUP_KEYS = ['room', 'type', 'folder', 'subfolder'];
|
|
48
|
+
const GROUP_ORDERS = ['count', 'size', 'updated', 'greatest'];
|
|
38
49
|
const ORDER = ['by', 'direction', 'nulls', 'stringSort', 'locale', 'localeOptions'];
|
|
39
50
|
const STRAY_ESCAPE = /~(?![01])/u;
|
|
40
51
|
export function bodied(shape) {
|
|
41
52
|
return shape.sections !== null || shape.preamble || shape.markdown;
|
|
42
53
|
}
|
|
43
|
-
export function invalid(at, problem) {
|
|
44
|
-
throw new QueryError('invalid-query', at, problem);
|
|
54
|
+
export function invalid(at, problem, accepts = []) {
|
|
55
|
+
throw new QueryError('invalid-query', at, problem, accepts);
|
|
45
56
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
57
|
+
function placed(at) {
|
|
58
|
+
if (typeof at !== 'string')
|
|
59
|
+
return at;
|
|
60
|
+
return at === '' ? [] : [at];
|
|
61
|
+
}
|
|
62
|
+
export function placeText(at) {
|
|
63
|
+
return at.reduce((text, step) => {
|
|
64
|
+
if (typeof step === 'number')
|
|
65
|
+
return `${text}[${step}]`;
|
|
66
|
+
if (step.startsWith('/') || text === '')
|
|
67
|
+
return `${text}${step}`;
|
|
68
|
+
return `${text}.${step}`;
|
|
69
|
+
}, '');
|
|
70
|
+
}
|
|
71
|
+
function place(at, step) {
|
|
72
|
+
return [...placed(at), step];
|
|
48
73
|
}
|
|
49
74
|
export function known(value, allowed, at) {
|
|
50
75
|
for (const name of Object.keys(value)) {
|
|
51
76
|
if (!allowed.includes(name))
|
|
52
|
-
invalid(place(at, name), 'unknown part');
|
|
77
|
+
invalid(place(at, name), 'unknown part', allowed);
|
|
53
78
|
}
|
|
54
79
|
}
|
|
55
80
|
function list(input, at) {
|
|
@@ -69,7 +94,7 @@ function value(input, at) {
|
|
|
69
94
|
return input;
|
|
70
95
|
}
|
|
71
96
|
function values(input, at) {
|
|
72
|
-
return list(input, at).map((item, index) => value(item,
|
|
97
|
+
return list(input, at).map((item, index) => value(item, place(at, index)));
|
|
73
98
|
}
|
|
74
99
|
function names(input, at) {
|
|
75
100
|
const listed = list(input, at);
|
|
@@ -112,7 +137,7 @@ function fits(facts, value) {
|
|
|
112
137
|
const kind = kindOf(item);
|
|
113
138
|
return kind !== null && fitsKind(kind, item, value);
|
|
114
139
|
}
|
|
115
|
-
function textless(facts) {
|
|
140
|
+
export function textless(facts) {
|
|
116
141
|
const item = itemOf(facts);
|
|
117
142
|
if (item?.values !== undefined)
|
|
118
143
|
return !item.values.some((held) => typeof held === 'string');
|
|
@@ -128,7 +153,7 @@ function typing(facts, rooms, types, at) {
|
|
|
128
153
|
for (const name of types ?? []) {
|
|
129
154
|
if (name === 'any' || !available || declared.some((type) => type.name === name))
|
|
130
155
|
continue;
|
|
131
|
-
throw new QueryError('unknown-type', place(at, 'types'), `no model it reads declares ${name}
|
|
156
|
+
throw new QueryError('unknown-type', place(at, 'types'), `no model it reads declares ${name}`, [...new Set(declared.map((type) => type.name))].sort());
|
|
132
157
|
}
|
|
133
158
|
return {
|
|
134
159
|
untyped: types === null || types.includes('any') || !available,
|
|
@@ -148,7 +173,7 @@ function specs(typed, input, at) {
|
|
|
148
173
|
return spec === undefined ? [] : [spec];
|
|
149
174
|
});
|
|
150
175
|
if (declared.length === 0 && !typed.untyped) {
|
|
151
|
-
throw new QueryError('unknown-field', at, `no MD Type it reads declares ${field}
|
|
176
|
+
throw new QueryError('unknown-field', at, `no MD Type it reads declares ${field}`, nearby(typed.types, field));
|
|
152
177
|
}
|
|
153
178
|
if (!declared.some((spec) => spec.conditional))
|
|
154
179
|
return declared;
|
|
@@ -158,6 +183,24 @@ function specs(typed, input, at) {
|
|
|
158
183
|
conditional: true,
|
|
159
184
|
}));
|
|
160
185
|
}
|
|
186
|
+
function nearby(types, field) {
|
|
187
|
+
const segments = pointerSegments(field);
|
|
188
|
+
for (let length = segments.length - 1; length > 0; length -= 1) {
|
|
189
|
+
const prefix = segments
|
|
190
|
+
.slice(0, length)
|
|
191
|
+
.map((segment) => `/${escapePointer(segment)}`)
|
|
192
|
+
.join('');
|
|
193
|
+
const children = types.flatMap((type) => {
|
|
194
|
+
const reached = pointerFacts(type, prefix);
|
|
195
|
+
return (reached === undefined ? [] : crossedFacts(reached.facts)).flatMap((crossed) => Object.keys(crossed.properties ?? {}).map((key) => `${prefix}/${escapePointer(key)}`));
|
|
196
|
+
});
|
|
197
|
+
if (children.length > 0)
|
|
198
|
+
return [...new Set(children)].sort();
|
|
199
|
+
}
|
|
200
|
+
return [
|
|
201
|
+
...new Set(types.flatMap((type) => Object.keys(type.fields).map((name) => `/${escapePointer(name)}`))),
|
|
202
|
+
].sort();
|
|
203
|
+
}
|
|
161
204
|
function several(spec) {
|
|
162
205
|
return spec.through || spec.facts.type === 'array';
|
|
163
206
|
}
|
|
@@ -173,7 +216,9 @@ function kind(declared, checked, at) {
|
|
|
173
216
|
declared.some((spec) => fits(spec.facts, checked))) {
|
|
174
217
|
return;
|
|
175
218
|
}
|
|
176
|
-
throw new QueryError('wrong-kind', at, `${JSON.stringify(checked)} is not of its field's kind
|
|
219
|
+
throw new QueryError('wrong-kind', at, `${JSON.stringify(checked)} is not of its field's kind`, [
|
|
220
|
+
...new Set(declared.flatMap((spec) => kindWords(itemOf(spec.facts)))),
|
|
221
|
+
]);
|
|
177
222
|
}
|
|
178
223
|
function test(declared, input, at) {
|
|
179
224
|
if (!plain(input)) {
|
|
@@ -208,8 +253,9 @@ function test(declared, input, at) {
|
|
|
208
253
|
invalid(place(at, operators[1]), 'names a second operator');
|
|
209
254
|
const [operator] = operators;
|
|
210
255
|
const where = place(at, operator);
|
|
211
|
-
if (!SINGLE.includes(operator))
|
|
212
|
-
invalid(where, 'unknown operator');
|
|
256
|
+
if (!SINGLE.includes(operator)) {
|
|
257
|
+
invalid(where, 'unknown operator', [...SINGLE, ...RANGE]);
|
|
258
|
+
}
|
|
213
259
|
const operand = input[operator];
|
|
214
260
|
if (operator === '$eq' || operator === '$ne') {
|
|
215
261
|
const compared = value(operand, where);
|
|
@@ -218,7 +264,7 @@ function test(declared, input, at) {
|
|
|
218
264
|
}
|
|
219
265
|
if (operator === '$in' || operator === '$nin' || operator === '$all') {
|
|
220
266
|
const compared = values(operand, where);
|
|
221
|
-
compared.forEach((item, index) => kind(declared, item,
|
|
267
|
+
compared.forEach((item, index) => kind(declared, item, place(where, index)));
|
|
222
268
|
if (operator === '$in')
|
|
223
269
|
return { op: 'in', values: compared };
|
|
224
270
|
if (operator === '$nin')
|
|
@@ -254,10 +300,10 @@ function condition(typed, input, at) {
|
|
|
254
300
|
invalid(at, 'expects an object of field predicates');
|
|
255
301
|
const conditions = [];
|
|
256
302
|
for (const name of Object.keys(input).sort()) {
|
|
257
|
-
const where =
|
|
303
|
+
const where = place(at, name);
|
|
258
304
|
const entry = input[name];
|
|
259
305
|
if (name === '$and' || name === '$or') {
|
|
260
|
-
const nested = list(entry, where).map((item, index) => condition(typed, item,
|
|
306
|
+
const nested = list(entry, where).map((item, index) => condition(typed, item, place(where, index)));
|
|
261
307
|
if (nested.length === 0)
|
|
262
308
|
invalid(where, 'expects a nonempty list');
|
|
263
309
|
conditions.push(name === '$and' ? { every: nested } : { some: nested });
|
|
@@ -297,7 +343,7 @@ function hopOf(facts, rooms, root, input) {
|
|
|
297
343
|
if (!plain(input))
|
|
298
344
|
invalid('hop', 'expects an object');
|
|
299
345
|
known(input, RELATED, 'hop');
|
|
300
|
-
const field = referenceName(root, input.field, 'hop
|
|
346
|
+
const field = referenceName(root, input.field, ['hop', 'field']);
|
|
301
347
|
const { types, where, pathPrefix } = scope(facts, rooms, input, 'hop');
|
|
302
348
|
return { types, where, pathPrefix, field };
|
|
303
349
|
}
|
|
@@ -306,20 +352,22 @@ function backlinksOf(facts, rooms, input) {
|
|
|
306
352
|
invalid('backlinks', 'expects an object');
|
|
307
353
|
known(input, RELATED, 'backlinks');
|
|
308
354
|
const { typed, types, where, pathPrefix } = scope(facts, rooms, input, 'backlinks');
|
|
309
|
-
const field = input.field === undefined ? null : referenceName(typed, input.field, 'backlinks
|
|
355
|
+
const field = input.field === undefined ? null : referenceName(typed, input.field, ['backlinks', 'field']);
|
|
310
356
|
return { types, where, pathPrefix, field };
|
|
311
357
|
}
|
|
312
|
-
function
|
|
313
|
-
if (
|
|
314
|
-
|
|
358
|
+
function oneField(typed, input, at) {
|
|
359
|
+
if (specs(typed, input.field, place(at, 'field')).some(several)) {
|
|
360
|
+
invalid(place(at, 'field'), 'a path that can hold several values');
|
|
315
361
|
}
|
|
362
|
+
return input.field;
|
|
363
|
+
}
|
|
364
|
+
function keyPlan(typed, input, at, keys) {
|
|
365
|
+
if (typeof input === 'string' && keys.includes(input))
|
|
366
|
+
return { of: input };
|
|
316
367
|
if (plain(input) && Object.hasOwn(input, 'field') && Object.keys(input).length === 1) {
|
|
317
|
-
|
|
318
|
-
invalid(place(at, 'field'), 'a path that can hold several values');
|
|
319
|
-
}
|
|
320
|
-
return { of: 'field', field: input.field };
|
|
368
|
+
return { of: 'field', field: oneField(typed, input, at) };
|
|
321
369
|
}
|
|
322
|
-
return invalid(at,
|
|
370
|
+
return invalid(at, `expects ${keys.join(', ')} or a field`);
|
|
323
371
|
}
|
|
324
372
|
function direction(input, at) {
|
|
325
373
|
if (input === undefined)
|
|
@@ -328,16 +376,20 @@ function direction(input, at) {
|
|
|
328
376
|
invalid(at, 'expects asc or desc');
|
|
329
377
|
return input;
|
|
330
378
|
}
|
|
379
|
+
function nulls(input, at) {
|
|
380
|
+
if (input === undefined)
|
|
381
|
+
return null;
|
|
382
|
+
if (input !== 'first' && input !== 'last')
|
|
383
|
+
invalid(at, 'expects first or last');
|
|
384
|
+
return input;
|
|
385
|
+
}
|
|
331
386
|
function orderOptions(input, at) {
|
|
332
387
|
const options = {
|
|
333
388
|
direction: direction(input.direction, place(at, 'direction')),
|
|
334
389
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
339
|
-
options.nulls = input.nulls;
|
|
340
|
-
}
|
|
390
|
+
const placed = nulls(input.nulls, place(at, 'nulls'));
|
|
391
|
+
if (placed !== null)
|
|
392
|
+
options.nulls = placed;
|
|
341
393
|
if (input.stringSort !== undefined) {
|
|
342
394
|
if (input.stringSort !== 'lexical' && input.stringSort !== 'locale') {
|
|
343
395
|
invalid(place(at, 'stringSort'), 'expects lexical or locale');
|
|
@@ -375,9 +427,9 @@ function parts(typed, input, at, fields) {
|
|
|
375
427
|
const named = list(input, at);
|
|
376
428
|
named.forEach((name, index) => {
|
|
377
429
|
if (fields)
|
|
378
|
-
specs(typed, name,
|
|
430
|
+
specs(typed, name, place(at, index));
|
|
379
431
|
else if (typeof name !== 'string')
|
|
380
|
-
invalid(
|
|
432
|
+
invalid(place(at, index), 'expects a name');
|
|
381
433
|
});
|
|
382
434
|
return named;
|
|
383
435
|
}
|
|
@@ -390,12 +442,12 @@ function flag(input, at) {
|
|
|
390
442
|
}
|
|
391
443
|
function documentShape(typed, input) {
|
|
392
444
|
const orderBy = (input.orderBy === undefined ? [] : list(input.orderBy, 'orderBy')).map((clause, index) => {
|
|
393
|
-
const at =
|
|
445
|
+
const at = place('orderBy', index);
|
|
394
446
|
if (!plain(clause))
|
|
395
447
|
invalid(at, 'expects an order clause');
|
|
396
448
|
known(clause, ORDER, at);
|
|
397
449
|
return {
|
|
398
|
-
key: keyPlan(typed, clause.by, place(at, 'by'),
|
|
450
|
+
key: keyPlan(typed, clause.by, place(at, 'by'), DOCUMENT_KEYS),
|
|
399
451
|
options: orderOptions(clause, at),
|
|
400
452
|
};
|
|
401
453
|
});
|
|
@@ -411,6 +463,8 @@ function documentShape(typed, input) {
|
|
|
411
463
|
change: true,
|
|
412
464
|
fileId: true,
|
|
413
465
|
revision: true,
|
|
466
|
+
size: true,
|
|
467
|
+
created: true,
|
|
414
468
|
orderBy,
|
|
415
469
|
};
|
|
416
470
|
}
|
|
@@ -419,45 +473,84 @@ function documentShape(typed, input) {
|
|
|
419
473
|
known(select, PARTS, 'select');
|
|
420
474
|
return {
|
|
421
475
|
kind: 'documents',
|
|
422
|
-
fields: parts(typed, select.fields, 'select
|
|
423
|
-
sections: parts(typed, select.sections, 'select
|
|
424
|
-
preamble: flag(select.preamble, 'select
|
|
425
|
-
markdown: flag(select.markdown, 'select
|
|
426
|
-
backlinks: flag(select.backlinks, 'select
|
|
427
|
-
change: flag(select.change, 'select
|
|
428
|
-
fileId: flag(select.fileId, 'select
|
|
429
|
-
revision: flag(select.revision, 'select
|
|
476
|
+
fields: parts(typed, select.fields, ['select', 'fields'], true),
|
|
477
|
+
sections: parts(typed, select.sections, ['select', 'sections'], false),
|
|
478
|
+
preamble: flag(select.preamble, ['select', 'preamble']),
|
|
479
|
+
markdown: flag(select.markdown, ['select', 'markdown']),
|
|
480
|
+
backlinks: flag(select.backlinks, ['select', 'backlinks']),
|
|
481
|
+
change: flag(select.change, ['select', 'change']),
|
|
482
|
+
fileId: flag(select.fileId, ['select', 'fileId']),
|
|
483
|
+
revision: flag(select.revision, ['select', 'revision']),
|
|
484
|
+
size: flag(select.size, ['select', 'size']),
|
|
485
|
+
created: flag(select.created, ['select', 'created']),
|
|
430
486
|
orderBy,
|
|
431
487
|
};
|
|
432
488
|
}
|
|
489
|
+
function greatestOf(typed, input) {
|
|
490
|
+
if (input === undefined)
|
|
491
|
+
return null;
|
|
492
|
+
const at = ['select', 'greatest'];
|
|
493
|
+
if (!plain(input))
|
|
494
|
+
invalid(at, 'expects the field whose greatest value each group answers');
|
|
495
|
+
known(input, ['field'], at);
|
|
496
|
+
if (!Object.hasOwn(input, 'field'))
|
|
497
|
+
invalid(at, 'names no field');
|
|
498
|
+
return oneField(typed, input, at);
|
|
499
|
+
}
|
|
433
500
|
function groupShape(typed, input) {
|
|
434
|
-
const groupBy = list(input.groupBy, 'groupBy').map((key, index) => keyPlan(typed, key,
|
|
501
|
+
const groupBy = list(input.groupBy, 'groupBy').map((key, index) => keyPlan(typed, key, place('groupBy', index), GROUP_KEYS));
|
|
435
502
|
if (groupBy.length === 0)
|
|
436
503
|
invalid('groupBy', 'names no key');
|
|
504
|
+
const select = input.select ?? {};
|
|
505
|
+
if (!plain(select))
|
|
506
|
+
invalid('select', 'expects the totals each group answers');
|
|
507
|
+
known(select, GROUP_PARTS, 'select');
|
|
508
|
+
const greatest = greatestOf(typed, select.greatest);
|
|
437
509
|
const grouped = groupBy.map((key) => JSON.stringify(key));
|
|
438
510
|
const orderBy = (input.orderBy === undefined ? [] : list(input.orderBy, 'orderBy')).map((clause, index) => {
|
|
439
|
-
const at =
|
|
511
|
+
const at = place('orderBy', index);
|
|
440
512
|
if (!plain(clause))
|
|
441
513
|
invalid(at, 'expects an order clause');
|
|
442
|
-
known(clause, ['by', 'direction'], at);
|
|
443
|
-
const by = clause.by === '
|
|
444
|
-
?
|
|
445
|
-
: grouped.indexOf(JSON.stringify(keyPlan(typed, clause.by, place(at, 'by'),
|
|
514
|
+
known(clause, ['by', 'direction', 'nulls'], at);
|
|
515
|
+
const by = typeof clause.by === 'string' && GROUP_ORDERS.includes(clause.by)
|
|
516
|
+
? clause.by
|
|
517
|
+
: grouped.indexOf(JSON.stringify(keyPlan(typed, clause.by, place(at, 'by'), [...GROUP_ORDERS, ...GROUP_KEYS])));
|
|
446
518
|
if (by === -1)
|
|
447
519
|
invalid(place(at, 'by'), 'orders by a key the query does not group by');
|
|
448
|
-
|
|
520
|
+
if (by === 'greatest' && greatest === null) {
|
|
521
|
+
invalid(place(at, 'by'), 'orders by a greatest value the query does not select');
|
|
522
|
+
}
|
|
523
|
+
return {
|
|
524
|
+
by,
|
|
525
|
+
direction: direction(clause.direction, place(at, 'direction')),
|
|
526
|
+
nulls: nulls(clause.nulls, place(at, 'nulls')),
|
|
527
|
+
};
|
|
449
528
|
});
|
|
450
|
-
return {
|
|
529
|
+
return {
|
|
530
|
+
kind: 'groups',
|
|
531
|
+
groupBy,
|
|
532
|
+
size: flag(select.size, ['select', 'size']),
|
|
533
|
+
updated: flag(select.updated, ['select', 'updated']),
|
|
534
|
+
greatest,
|
|
535
|
+
orderBy,
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
function outsideOf(input) {
|
|
539
|
+
const listed = list(input, 'outside');
|
|
540
|
+
listed.forEach((item, index) => {
|
|
541
|
+
if (directory(item, place('outside', index)) === '') {
|
|
542
|
+
invalid(place('outside', index), 'names no directory');
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
return [...new Set(listed)].sort();
|
|
451
546
|
}
|
|
452
547
|
export function planOf(input, facts) {
|
|
453
548
|
if (!plain(input))
|
|
454
549
|
invalid('query', 'expects a query object');
|
|
455
550
|
const grouped = input.groupBy !== undefined;
|
|
456
|
-
if (grouped && input.select !== undefined)
|
|
457
|
-
invalid('select', 'a grouped query selects nothing');
|
|
458
551
|
if (!grouped && input.select === undefined)
|
|
459
552
|
invalid('select', 'a Document query must select');
|
|
460
|
-
known(input, [...FILTER, 'orderBy', 'limit', 'after', 'total',
|
|
553
|
+
known(input, [...FILTER, 'orderBy', 'limit', 'after', 'total', 'select', 'groupBy'], '');
|
|
461
554
|
const limit = limitOf(input.limit);
|
|
462
555
|
const rooms = input.rooms === undefined ? null : names(input.rooms, 'rooms');
|
|
463
556
|
const { typed, ...root } = scope(facts, rooms, input, '');
|
|
@@ -466,6 +559,7 @@ export function planOf(input, facts) {
|
|
|
466
559
|
key: queryKey(input),
|
|
467
560
|
rooms,
|
|
468
561
|
root,
|
|
562
|
+
outside: input.outside === undefined ? null : outsideOf(input.outside),
|
|
469
563
|
folder: input.folder === undefined ? null : directory(input.folder, 'folder'),
|
|
470
564
|
paths: input.paths === undefined ? null : pathsOf(input.paths),
|
|
471
565
|
fileIds: input.fileIds === undefined ? null : fileIdsOf(input.fileIds),
|
package/dist/query/match.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Definition } from '../definition.js';
|
|
2
2
|
import { type QueryPlan } from './language.js';
|
|
3
|
+
import { type HeldValue } from './rows.js';
|
|
3
4
|
export type Candidate = {
|
|
4
5
|
readonly path: string;
|
|
5
6
|
readonly type: string | null;
|
|
6
7
|
readonly fileId: string | null;
|
|
7
8
|
readonly fields: Readonly<Record<string, unknown>>;
|
|
8
|
-
readonly definition?: Definition
|
|
9
|
+
readonly definition?: Pick<Definition, 'root'>;
|
|
9
10
|
readonly text: string | null;
|
|
10
11
|
};
|
|
12
|
+
export declare function heldAt(candidate: Candidate, field: string): readonly HeldValue[];
|
|
11
13
|
export declare function matches(plan: QueryPlan, candidate: Candidate): boolean;
|
|
12
14
|
//# sourceMappingURL=match.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/query/match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../src/query/match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE9D,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AA4HF,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAEhF;AAiCD,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAYtE"}
|
package/dist/query/match.js
CHANGED
|
@@ -79,9 +79,12 @@ function tested(values, field, test) {
|
|
|
79
79
|
return rows.some((row) => row.kind === 'string' && row.value.startsWith(test.prefix));
|
|
80
80
|
}
|
|
81
81
|
if (test.op === 'all') {
|
|
82
|
-
return rows.some((row) =>
|
|
83
|
-
row.kind
|
|
84
|
-
|
|
82
|
+
return rows.some((row) => {
|
|
83
|
+
if (row.item !== -1 || row.kind !== 'array')
|
|
84
|
+
return false;
|
|
85
|
+
const items = itemsOf(values, row);
|
|
86
|
+
return test.values.every((value) => items.some((item) => same(item, value)));
|
|
87
|
+
});
|
|
85
88
|
}
|
|
86
89
|
return rows.some((row) => row.item === -1 && row.kind === 'array' && row.size === test.size);
|
|
87
90
|
}
|
|
@@ -92,14 +95,19 @@ function conditioned(values, condition) {
|
|
|
92
95
|
return condition.some.some((one) => conditioned(values, one));
|
|
93
96
|
return tested(values, condition.field, condition.test);
|
|
94
97
|
}
|
|
95
|
-
function scoped(candidate,
|
|
98
|
+
function scoped(candidate, scope) {
|
|
96
99
|
return ((scope.types === null || (candidate.type !== null && scope.types.includes(candidate.type))) &&
|
|
97
100
|
(scope.pathPrefix === null ||
|
|
98
101
|
scope.pathPrefix === '' ||
|
|
99
102
|
candidate.path.startsWith(`${scope.pathPrefix}/`)) &&
|
|
100
|
-
(scope.where === null ||
|
|
103
|
+
(scope.where === null ||
|
|
104
|
+
conditioned(indexed(candidate.path, candidate.fields, candidate.definition).values, scope.where)));
|
|
101
105
|
}
|
|
102
|
-
export function
|
|
106
|
+
export function heldAt(candidate, field) {
|
|
107
|
+
return reached(indexed(candidate.path, candidate.fields, candidate.definition).values, field);
|
|
108
|
+
}
|
|
109
|
+
const UNHELD = ['size', 'created', 'updated', 'greatest'];
|
|
110
|
+
function answerable(plan) {
|
|
103
111
|
if (plan.rooms !== null)
|
|
104
112
|
invalid('rooms', 'names Rooms, which one Document does not choose');
|
|
105
113
|
if (plan.hop !== null)
|
|
@@ -107,12 +115,36 @@ export function matches(plan, candidate) {
|
|
|
107
115
|
if (plan.backlinks !== null) {
|
|
108
116
|
invalid('backlinks', 'tests other Documents, which one Document cannot answer');
|
|
109
117
|
}
|
|
110
|
-
const
|
|
118
|
+
const shape = plan.shape;
|
|
119
|
+
const ordered = shape.kind === 'documents'
|
|
120
|
+
? shape.orderBy.map(({ key }) => key.of)
|
|
121
|
+
: shape.orderBy.map(({ by }) => by);
|
|
122
|
+
ordered.forEach((by, index) => {
|
|
123
|
+
if (typeof by === 'string' && UNHELD.includes(by)) {
|
|
124
|
+
invalid(['orderBy', index, 'by'], `orders by ${by}, which one Document does not hold`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
if (shape.kind === 'documents')
|
|
128
|
+
return;
|
|
129
|
+
for (const part of ['size', 'updated']) {
|
|
130
|
+
if (shape[part])
|
|
131
|
+
invalid(['select', part], 'totals other Documents, which one Document cannot');
|
|
132
|
+
}
|
|
133
|
+
if (shape.greatest !== null) {
|
|
134
|
+
invalid(['select', 'greatest'], 'compares other Documents, which one Document cannot');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function outside(plan, path) {
|
|
138
|
+
return (plan.outside ?? []).some((folder) => path === folder || path.startsWith(`${folder}/`));
|
|
139
|
+
}
|
|
140
|
+
export function matches(plan, candidate) {
|
|
141
|
+
answerable(plan);
|
|
111
142
|
return ((plan.paths === null || plan.paths.includes(candidate.path)) &&
|
|
112
143
|
(plan.fileIds === null ||
|
|
113
144
|
(candidate.fileId !== null && plan.fileIds.includes(candidate.fileId))) &&
|
|
114
145
|
(plan.folder === null || dirname(candidate.path) === plan.folder) &&
|
|
115
|
-
|
|
146
|
+
!outside(plan, candidate.path) &&
|
|
147
|
+
scoped(candidate, plan.root) &&
|
|
116
148
|
(plan.text === null ||
|
|
117
149
|
(candidate.text !== null && candidate.text.toLowerCase().includes(plan.text.toLowerCase()))));
|
|
118
150
|
}
|