@agentshouse/mdmodel 0.1.0-cd6a8e5bc7efc → 0.1.0-cdaa2262b2988
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 +108 -115
- package/README.md +15 -13
- package/dist/built-in.d.ts.map +1 -1
- package/dist/built-in.js +10 -1
- package/dist/definition.d.ts +10 -3
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +99 -21
- package/dist/document.d.ts +3 -2
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +113 -71
- package/dist/event.d.ts +4 -7
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +3 -2
- package/dist/facts.d.ts.map +1 -1
- package/dist/facts.js +8 -4
- package/dist/fields.d.ts +1 -1
- package/dist/fields.d.ts.map +1 -1
- package/dist/fields.js +2 -2
- package/dist/folders.d.ts +5 -0
- package/dist/folders.d.ts.map +1 -0
- package/dist/folders.js +19 -0
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +3 -2
- package/dist/house-model.d.ts +190 -24
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +99 -15
- package/dist/house-references/crockford.d.ts.map +1 -0
- package/dist/house-references/patterns.d.ts +13 -0
- package/dist/house-references/patterns.d.ts.map +1 -0
- package/dist/house-references/patterns.js +20 -0
- package/dist/index.d.ts +23 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -13
- package/dist/indexed.d.ts +10 -0
- package/dist/indexed.d.ts.map +1 -0
- package/dist/indexed.js +63 -0
- package/dist/kinds.d.ts +9 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +68 -0
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- 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 +9 -0
- package/dist/moment.d.ts.map +1 -0
- package/dist/moment.js +40 -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 +6 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +33 -3
- package/dist/query/language.d.ts +4 -1
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +8 -7
- package/dist/query/match.d.ts +1 -1
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +3 -24
- package/dist/query/rows.d.ts +6 -1
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +37 -8
- package/dist/query/sql.d.ts +10 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +22 -3
- package/dist/query/walk.d.ts +73 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +277 -0
- package/dist/references.d.ts +2 -2
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +1 -1
- package/dist/reserved.d.ts +1 -1
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +15 -6
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +19 -13
- package/dist/schema.d.ts +1 -1
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +6 -7
- package/dist/types.d.ts +11 -31
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +7 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +108 -46
- package/dist/view.d.ts +5 -0
- package/dist/view.d.ts.map +1 -0
- package/dist/view.js +27 -0
- package/dist/yaml.d.ts +7 -5
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +154 -33
- package/fixtures/README.md +64 -57
- package/fixtures/cases/absent-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/absent-optional-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/absolute-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-any-file/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/attachment-reference-outside/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-any-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-document-collision/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-image-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-dangles/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-link-outside-collection/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-prototype-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/binary-typed-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/block-scalar-frontmatter/expected.json +1 -0
- package/fixtures/cases/block-scalar-frontmatter/library/notes/literal.md +17 -0
- package/fixtures/cases/block-scalar-frontmatter/library/skills/notes/SKILL.md +10 -0
- package/fixtures/cases/boolean-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/{duplicate-link-definition/schema.yaml → bracketed-link-definition/schema.md} +2 -0
- package/fixtures/cases/closed-nested-object/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/composed-root-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/conditional-long-text/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-link/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/cross-room-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/date-time-format/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/declared-binary-links/schema.md +3 -0
- package/fixtures/cases/default-unfilled/schema.md +57 -0
- package/fixtures/cases/defs-pattern/schema.md +57 -0
- package/fixtures/cases/dependent-rule/schema.md +57 -0
- package/fixtures/cases/{bracketed-link-definition/schema.yaml → duplicate-link-definition/schema.md} +2 -0
- package/fixtures/cases/email-format/schema.md +57 -0
- package/fixtures/cases/equal-labels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/fenced-link-definition/schema.md +7 -0
- package/fixtures/cases/field-enum/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/context.json +1 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/expected.json +1 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/host.md +13 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/map.md +24 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/library/tickets/open.md +13 -0
- package/fixtures/cases/folder-keeps-a-built-in-type/schema.md +9 -0
- package/fixtures/cases/folder-keeps-a-record/context.json +1 -0
- package/fixtures/cases/folder-keeps-a-record/expected.json +1 -0
- package/fixtures/cases/folder-keeps-a-record/library/tickets/2026-11-16-d_1.r.md +13 -0
- package/fixtures/cases/folder-keeps-a-record/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-keeps-a-record/schema.md +9 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/context.json +1 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/expected.json +5 -0
- package/fixtures/cases/folder-names-no-type-of-the-schema/schema.md +7 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/context.json +1 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/expected.json +6 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/library/tickets/archive/2025/old.md +1 -0
- package/fixtures/cases/folder-nearer-entry-types-a-document/schema.md +15 -0
- package/fixtures/cases/folder-refuses-a-declared-any/context.json +1 -0
- package/fixtures/cases/folder-refuses-a-declared-any/expected.json +6 -0
- package/fixtures/cases/folder-refuses-a-declared-any/library/tickets/door.md +5 -0
- package/fixtures/cases/folder-refuses-a-declared-any/schema.md +9 -0
- package/fixtures/cases/folder-refuses-another-declared-type/context.json +1 -0
- package/fixtures/cases/folder-refuses-another-declared-type/expected.json +6 -0
- package/fixtures/cases/folder-refuses-another-declared-type/library/tickets/door.md +5 -0
- package/fixtures/cases/folder-refuses-another-declared-type/schema.md +12 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/context.json +1 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/expected.json +1 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/notes/plan.md +7 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/library/tickets/gate.md +7 -0
- package/fixtures/cases/folder-type-is-the-type-a-reference-reaches/schema.md +13 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/context.json +1 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/expected.json +6 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/library/tickets/2026/gate.md +1 -0
- package/fixtures/cases/folder-types-a-document-in-a-folder-below-it/schema.md +9 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/context.json +1 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/expected.json +7 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/library/tickets/door.md +3 -0
- package/fixtures/cases/folder-types-a-document-that-names-no-type/schema.md +9 -0
- package/fixtures/cases/folder-under-a-reserved-name/context.json +1 -0
- package/fixtures/cases/folder-under-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/folder-under-a-reserved-name/schema.md +7 -0
- package/fixtures/cases/folder-without-a-trailing-slash/context.json +1 -0
- package/fixtures/cases/folder-without-a-trailing-slash/expected.json +5 -0
- package/fixtures/cases/folder-without-a-trailing-slash/schema.md +7 -0
- package/fixtures/cases/frontmatter-construct/context.json +1 -0
- package/fixtures/cases/frontmatter-construct/expected.json +7 -0
- package/fixtures/cases/frontmatter-construct/library/note.md +6 -0
- package/fixtures/cases/integer-field/schema.md +57 -0
- package/fixtures/cases/interrupted-link-definition/schema.md +3 -0
- package/fixtures/cases/json-schema-constructs/schema.md +57 -0
- package/fixtures/cases/labels-in-the-rooms-language/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/lazy-list-item/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/link-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-enum/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-item-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-items/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-of-objects-closed/schema.md +57 -0
- package/fixtures/cases/list-of-objects-item/schema.md +57 -0
- package/fixtures/cases/list-of-objects-reference/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-path/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/list-size/schema.md +57 -0
- package/fixtures/cases/long-fence-link-definition/schema.md +3 -0
- package/fixtures/cases/long-value-past-six-levels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-definition/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/malformed-list/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/member-on-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/missing-required-field/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/misspelled-key/schema.md +57 -0
- package/fixtures/cases/name-not-a-string/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-defs/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/nested-object-reference/schema.md +34 -0
- package/fixtures/cases/nested-reference/schema.md +34 -0
- package/fixtures/cases/nested-required-field/schema.md +57 -0
- package/fixtures/cases/numeric-range/schema.md +57 -0
- package/fixtures/cases/one-key-two-labels/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/one-key-two-types/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/one-of-variant/schema.md +57 -0
- package/fixtures/cases/other-room-reference/schema.md +34 -0
- package/fixtures/cases/paragraph-link-definition/schema.md +3 -0
- package/fixtures/cases/prototype-field/schema.md +7 -0
- package/fixtures/cases/quoted-link-definition/schema.md +3 -0
- package/fixtures/cases/reference-into-a-reserved-name/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/reference-to-any-file-name/context.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/expected.json +1 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/100%.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/C#.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/My notes.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/[draft].md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/c (d).md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people/caf/303/251.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/people//320/236/321/202/321/207/321/221/321/202.md +4 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/bracket.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/cyrillic.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/decomposed.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/hash.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/parenthesis.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/percent.md +9 -0
- package/fixtures/cases/reference-to-any-file-name/library/tasks/spaced.md +9 -0
- package/fixtures/cases/{referenced-missing-file/schema.yaml → reference-to-any-file-name/schema.md} +2 -0
- package/fixtures/cases/referenced-missing-file/schema.md +12 -0
- package/fixtures/cases/referenced-missing-non-latin-file/context.json +1 -0
- package/fixtures/cases/referenced-missing-non-latin-file/expected.json +6 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/a.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/library/tasks/b.md +9 -0
- package/fixtures/cases/referenced-missing-non-latin-file/schema.md +12 -0
- package/fixtures/cases/remote-ref/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/schema-body-ignored/context.json +1 -0
- package/fixtures/cases/schema-body-ignored/expected.json +1 -0
- package/fixtures/cases/schema-body-ignored/schema.md +9 -0
- package/fixtures/cases/schema-type-named-folders/context.json +1 -0
- package/fixtures/cases/schema-type-named-folders/expected.json +5 -0
- package/fixtures/cases/schema-type-named-folders/schema.md +5 -0
- package/fixtures/cases/schema-type-named-type/context.json +1 -0
- package/fixtures/cases/schema-type-named-type/expected.json +5 -0
- package/fixtures/cases/{unknown-type/schema.yaml → schema-type-named-type/schema.md} +3 -1
- package/fixtures/cases/second-member-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/sections-keyword-refused/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/shortcut-reference-link/schema.md +7 -0
- package/fixtures/cases/string-length/schema.md +57 -0
- package/fixtures/cases/submission-keys/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/text-field-kind/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/thematic-break-ends-the-values/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/truncated-link-definition/schema.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/typed-path-names-its-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/typed-path-names-no-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/types-folder-content/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/undeclared-field/schema.md +7 -0
- package/fixtures/cases/unevaluated-items-closed/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unique-in-app-schema/context.json +1 -0
- package/fixtures/cases/unique-in-app-schema/expected.json +5 -0
- package/fixtures/cases/unique-in-app-schema/schema.yaml +7 -0
- package/fixtures/cases/unique-indexed-field/context.json +1 -0
- package/fixtures/cases/unique-indexed-field/expected.json +1 -0
- package/fixtures/cases/unique-indexed-field/library/tickets/first.md +8 -0
- package/fixtures/cases/unique-indexed-field/library/tickets/second.md +8 -0
- package/fixtures/cases/unique-indexed-field/schema.md +9 -0
- package/fixtures/cases/unique-off-indexed-field/context.json +1 -0
- package/fixtures/cases/unique-off-indexed-field/expected.json +5 -0
- package/fixtures/cases/unique-off-indexed-field/schema.md +9 -0
- package/fixtures/cases/unlisted-reference-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/unresolved-link/schema.md +7 -0
- package/fixtures/cases/valid-typed-document/{schema.yaml → schema.md} +2 -0
- package/fixtures/cases/wide-item-fence-link/schema.md +3 -0
- package/fixtures/forms.json +24 -0
- package/fixtures/preamble.json +4 -4
- package/fixtures/queries.json +1010 -2
- package/fixtures/references.json +15 -0
- package/package.json +2 -2
- package/dist/crockford.d.ts.map +0 -1
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -321
- package/dist/house-references.d.ts +0 -4
- package/dist/house-references.d.ts.map +0 -1
- package/dist/house-references.js +0 -7
- package/dist/project.d.ts +0 -22
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -101
- package/fixtures/cases/declared-binary-links/schema.yaml +0 -1
- package/fixtures/cases/default-unfilled/schema.yaml +0 -55
- package/fixtures/cases/defs-pattern/schema.yaml +0 -55
- package/fixtures/cases/dependent-rule/schema.yaml +0 -55
- package/fixtures/cases/email-format/schema.yaml +0 -55
- package/fixtures/cases/fenced-link-definition/schema.yaml +0 -5
- package/fixtures/cases/frontmatter-schema/expected.json +0 -5
- package/fixtures/cases/integer-field/schema.yaml +0 -55
- package/fixtures/cases/interrupted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/json-schema-constructs/schema.yaml +0 -55
- package/fixtures/cases/list-of-objects-closed/schema.yaml +0 -55
- package/fixtures/cases/list-of-objects-item/schema.yaml +0 -55
- package/fixtures/cases/list-size/schema.yaml +0 -55
- package/fixtures/cases/long-fence-link-definition/schema.yaml +0 -1
- package/fixtures/cases/misspelled-key/schema.yaml +0 -55
- package/fixtures/cases/nested-object-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-reference/schema.yaml +0 -32
- package/fixtures/cases/nested-required-field/schema.yaml +0 -55
- package/fixtures/cases/numeric-range/schema.yaml +0 -55
- package/fixtures/cases/one-of-variant/schema.yaml +0 -55
- package/fixtures/cases/other-room-reference/schema.yaml +0 -32
- package/fixtures/cases/paragraph-link-definition/schema.yaml +0 -1
- package/fixtures/cases/prototype-field/schema.yaml +0 -5
- package/fixtures/cases/quoted-link-definition/schema.yaml +0 -1
- package/fixtures/cases/shortcut-reference-link/schema.yaml +0 -5
- package/fixtures/cases/string-length/schema.yaml +0 -55
- package/fixtures/cases/truncated-link-definition/schema.yaml +0 -1
- package/fixtures/cases/undeclared-field/schema.yaml +0 -5
- package/fixtures/cases/unresolved-link/schema.yaml +0 -5
- package/fixtures/cases/wide-item-fence-link/schema.yaml +0 -1
- package/fixtures/division.json +0 -454
- package/fixtures/projection.json +0 -358
- /package/dist/{crockford.d.ts → house-references/crockford.d.ts} +0 -0
- /package/dist/{crockford.js → house-references/crockford.js} +0 -0
- /package/fixtures/cases/{frontmatter-schema → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
package/dist/query/language.js
CHANGED
|
@@ -30,6 +30,7 @@ const FILTER = [
|
|
|
30
30
|
'text',
|
|
31
31
|
];
|
|
32
32
|
const RELATED = ['types', 'where', 'pathPrefix', 'field'];
|
|
33
|
+
const HOP = [...RELATED, 'none'];
|
|
33
34
|
const PARTS = [
|
|
34
35
|
'fields',
|
|
35
36
|
'sections',
|
|
@@ -121,7 +122,7 @@ function phrase(input) {
|
|
|
121
122
|
invalid('text', 'expects a phrase');
|
|
122
123
|
return input;
|
|
123
124
|
}
|
|
124
|
-
function
|
|
125
|
+
function folderPath(input, at) {
|
|
125
126
|
if (typeof input !== 'string' || normalize(input) !== input) {
|
|
126
127
|
invalid(at, 'expects a normalized directory');
|
|
127
128
|
}
|
|
@@ -137,7 +138,7 @@ function fits(facts, value) {
|
|
|
137
138
|
const kind = kindOf(item);
|
|
138
139
|
return kind !== null && fitsKind(kind, item, value);
|
|
139
140
|
}
|
|
140
|
-
function textless(facts) {
|
|
141
|
+
export function textless(facts) {
|
|
141
142
|
const item = itemOf(facts);
|
|
142
143
|
if (item?.values !== undefined)
|
|
143
144
|
return !item.values.some((held) => typeof held === 'string');
|
|
@@ -326,7 +327,7 @@ function scope(facts, rooms, input, at) {
|
|
|
326
327
|
where: input.where === undefined || (plain(input.where) && Object.keys(input.where).length === 0)
|
|
327
328
|
? null
|
|
328
329
|
: condition(typed, input.where, place(at, 'where')),
|
|
329
|
-
pathPrefix: input.pathPrefix === undefined ? null :
|
|
330
|
+
pathPrefix: input.pathPrefix === undefined ? null : folderPath(input.pathPrefix, place(at, 'pathPrefix')),
|
|
330
331
|
};
|
|
331
332
|
}
|
|
332
333
|
function referenceName(typed, field, at) {
|
|
@@ -342,10 +343,10 @@ function referenceName(typed, field, at) {
|
|
|
342
343
|
function hopOf(facts, rooms, root, input) {
|
|
343
344
|
if (!plain(input))
|
|
344
345
|
invalid('hop', 'expects an object');
|
|
345
|
-
known(input,
|
|
346
|
+
known(input, HOP, 'hop');
|
|
346
347
|
const field = referenceName(root, input.field, ['hop', 'field']);
|
|
347
348
|
const { types, where, pathPrefix } = scope(facts, rooms, input, 'hop');
|
|
348
|
-
return { types, where, pathPrefix, field };
|
|
349
|
+
return { types, where, pathPrefix, field, none: flag(input.none, ['hop', 'none']) };
|
|
349
350
|
}
|
|
350
351
|
function backlinksOf(facts, rooms, input) {
|
|
351
352
|
if (!plain(input))
|
|
@@ -538,7 +539,7 @@ function groupShape(typed, input) {
|
|
|
538
539
|
function outsideOf(input) {
|
|
539
540
|
const listed = list(input, 'outside');
|
|
540
541
|
listed.forEach((item, index) => {
|
|
541
|
-
if (
|
|
542
|
+
if (folderPath(item, place('outside', index)) === '') {
|
|
542
543
|
invalid(place('outside', index), 'names no directory');
|
|
543
544
|
}
|
|
544
545
|
});
|
|
@@ -560,7 +561,7 @@ export function planOf(input, facts) {
|
|
|
560
561
|
rooms,
|
|
561
562
|
root,
|
|
562
563
|
outside: input.outside === undefined ? null : outsideOf(input.outside),
|
|
563
|
-
folder: input.folder === undefined ? null :
|
|
564
|
+
folder: input.folder === undefined ? null : folderPath(input.folder, 'folder'),
|
|
564
565
|
paths: input.paths === undefined ? null : pathsOf(input.paths),
|
|
565
566
|
fileIds: input.fileIds === undefined ? null : fileIdsOf(input.fileIds),
|
|
566
567
|
hop: input.hop === undefined ? null : hopOf(facts, rooms, typed, input.hop),
|
package/dist/query/match.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export type Candidate = {
|
|
|
6
6
|
readonly type: string | null;
|
|
7
7
|
readonly fileId: string | null;
|
|
8
8
|
readonly fields: Readonly<Record<string, unknown>>;
|
|
9
|
-
readonly definition?: Pick<Definition, '
|
|
9
|
+
readonly definition?: Pick<Definition, 'root'>;
|
|
10
10
|
readonly text: string | null;
|
|
11
11
|
};
|
|
12
12
|
export declare function heldAt(candidate: Candidate, field: string): readonly HeldValue[];
|
|
@@ -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;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,
|
|
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;AAqGF,wBAAgB,MAAM,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAMhF;AAiCD,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAYtE"}
|
package/dist/query/match.js
CHANGED
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import { byCodePoint, instantKey } from '../kinds.js';
|
|
2
2
|
import { dirname } from '../paths.js';
|
|
3
3
|
import { invalid, } from './language.js';
|
|
4
|
-
import { indexed,
|
|
4
|
+
import { indexed, placedIn } from './rows.js';
|
|
5
5
|
const BOUNDS = { gt: '>', gte: '>=', lt: '<', lte: '<=' };
|
|
6
|
-
function globbed(pattern) {
|
|
7
|
-
let source = '';
|
|
8
|
-
for (let at = 0; at < pattern.length; at += 1) {
|
|
9
|
-
const char = pattern[at];
|
|
10
|
-
if (char === '*')
|
|
11
|
-
source += '.*';
|
|
12
|
-
else if (char === '[') {
|
|
13
|
-
const end = pattern.indexOf(']', at);
|
|
14
|
-
source += pattern.slice(at, end + 1);
|
|
15
|
-
at = end;
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
source += char.replace(/[.\\^$+?()|{}/]/gu, '\\$&');
|
|
19
|
-
}
|
|
20
|
-
return new RegExp(`^${source}$`, 'u');
|
|
21
|
-
}
|
|
22
|
-
function reached(values, field) {
|
|
23
|
-
const { keys, places, glob } = placedOf(field, 'value');
|
|
24
|
-
const matched = glob ? globbed(places) : null;
|
|
25
|
-
return values.filter((row) => row.keys === keys && (matched === null ? row.places === places : matched.test(row.places)));
|
|
26
|
-
}
|
|
27
6
|
function holds(sign, operator) {
|
|
28
7
|
if (operator === '=')
|
|
29
8
|
return sign === 0;
|
|
@@ -59,7 +38,7 @@ function matching(values, held, wanted) {
|
|
|
59
38
|
(held.kind === 'array' && itemsOf(values, held).some((item) => same(item, value))));
|
|
60
39
|
}
|
|
61
40
|
function tested(values, field, test) {
|
|
62
|
-
const rows =
|
|
41
|
+
const rows = placedIn(values, field, 'value');
|
|
63
42
|
const present = rows.some((row) => row.item === -1);
|
|
64
43
|
if (test.op === 'exists')
|
|
65
44
|
return test.exists === present;
|
|
@@ -104,7 +83,7 @@ function scoped(candidate, scope) {
|
|
|
104
83
|
conditioned(indexed(candidate.path, candidate.fields, candidate.definition).values, scope.where)));
|
|
105
84
|
}
|
|
106
85
|
export function heldAt(candidate, field) {
|
|
107
|
-
return
|
|
86
|
+
return placedIn(indexed(candidate.path, candidate.fields, candidate.definition).values, field, 'value');
|
|
108
87
|
}
|
|
109
88
|
const UNHELD = ['size', 'created', 'updated', 'greatest'];
|
|
110
89
|
function answerable(plan) {
|
package/dist/query/rows.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type HeldLink = {
|
|
|
13
13
|
readonly kind: 'field';
|
|
14
14
|
readonly keys: string;
|
|
15
15
|
readonly places: string;
|
|
16
|
+
readonly handle: string | null;
|
|
16
17
|
readonly target: string;
|
|
17
18
|
readonly field: string;
|
|
18
19
|
};
|
|
@@ -27,6 +28,10 @@ export type Placed = {
|
|
|
27
28
|
readonly glob: boolean;
|
|
28
29
|
};
|
|
29
30
|
export declare function placedOf(pointer: string, reach: Reach): Placed;
|
|
31
|
+
export declare function placedIn<Row extends {
|
|
32
|
+
readonly keys: string;
|
|
33
|
+
readonly places: string;
|
|
34
|
+
}>(rows: readonly Row[], pointer: string, reach: Reach): readonly Row[];
|
|
30
35
|
export declare function heldKind(value: unknown): HeldKind;
|
|
31
|
-
export declare function indexed(path: string, fields: Readonly<Record<string, unknown>>, definition: Pick<Definition, '
|
|
36
|
+
export declare function indexed(path: string, fields: Readonly<Record<string, unknown>>, definition: Pick<Definition, 'root'> | undefined): Indexed;
|
|
32
37
|
//# sourceMappingURL=rows.d.ts.map
|
package/dist/query/rows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rows.d.ts","sourceRoot":"","sources":["../../src/query/rows.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,kBAAkB,CAAC;AAI1B,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEnG,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CA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E,KAAK,EAAE,KAAK,GAAG,MAAM,CAuB9D;AAgBD,wBAAgB,QAAQ,CAAC,GAAG,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACrF,IAAI,EAAE,SAAS,GAAG,EAAE,EACpB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,GACX,SAAS,GAAG,EAAE,CAOhB;AAyCD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAMjD;AAiGD,wBAAgB,OAAO,CACrB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,SAAS,GAC/C,OAAO,CAcT"}
|
package/dist/query/rows.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ARRAY_INDEX, escapePointer, itemFacts, memberFacts, } from '../definition.js';
|
|
2
|
-
import {
|
|
3
|
-
import { target } from '../paths.js';
|
|
2
|
+
import { instantOf } from '../kinds.js';
|
|
3
|
+
import { classifyHref, keyedLink, target } from '../paths.js';
|
|
4
4
|
export function placedOf(pointer, reach) {
|
|
5
5
|
const [first = '', ...rest] = pointer.split('/').slice(1);
|
|
6
6
|
const keys = [first];
|
|
@@ -25,6 +25,27 @@ export function placedOf(pointer, reach) {
|
|
|
25
25
|
glob: /[[*]/u.test(places),
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
function globbed(pattern) {
|
|
29
|
+
let source = '';
|
|
30
|
+
for (let at = 0; at < pattern.length; at += 1) {
|
|
31
|
+
const char = pattern[at];
|
|
32
|
+
if (char === '*')
|
|
33
|
+
source += '.*';
|
|
34
|
+
else if (char === '[') {
|
|
35
|
+
const end = pattern.indexOf(']', at);
|
|
36
|
+
source += pattern.slice(at, end + 1);
|
|
37
|
+
at = end;
|
|
38
|
+
}
|
|
39
|
+
else
|
|
40
|
+
source += char.replace(/[.\\^$+?()|{}/]/gu, '\\$&');
|
|
41
|
+
}
|
|
42
|
+
return new RegExp(`^${source}$`, 'u');
|
|
43
|
+
}
|
|
44
|
+
export function placedIn(rows, pointer, reach) {
|
|
45
|
+
const { keys, places, glob } = placedOf(pointer, reach);
|
|
46
|
+
const matched = glob ? globbed(places) : null;
|
|
47
|
+
return rows.filter((row) => row.keys === keys && (matched === null ? row.places === places : matched.test(row.places)));
|
|
48
|
+
}
|
|
28
49
|
function placesOf({ done, head, tail }) {
|
|
29
50
|
return `${done}/${head}${tail}.`;
|
|
30
51
|
}
|
|
@@ -47,6 +68,16 @@ function resolved(reading, facts, value) {
|
|
|
47
68
|
return value;
|
|
48
69
|
return target(reading.path, value) ?? undefined;
|
|
49
70
|
}
|
|
71
|
+
function linked(reading, facts, value) {
|
|
72
|
+
if (!referred(facts, value))
|
|
73
|
+
return null;
|
|
74
|
+
const named = classifyHref(reading.path, value);
|
|
75
|
+
if (named.kind === 'path')
|
|
76
|
+
return { handle: null, target: named.path };
|
|
77
|
+
return named.kind === 'room' && keyedLink(value) === null
|
|
78
|
+
? { handle: named.handle, target: named.path }
|
|
79
|
+
: null;
|
|
80
|
+
}
|
|
50
81
|
export function heldKind(value) {
|
|
51
82
|
if (value === undefined)
|
|
52
83
|
return 'undefined';
|
|
@@ -67,9 +98,6 @@ function scalarOf(value) {
|
|
|
67
98
|
return JSON.stringify(value);
|
|
68
99
|
return null;
|
|
69
100
|
}
|
|
70
|
-
function instantOf(facts, value) {
|
|
71
|
-
return facts !== undefined && kindOf(facts) === 'date-time' ? instantKey(value) : null;
|
|
72
|
-
}
|
|
73
101
|
function held(reading, at, places, value, items) {
|
|
74
102
|
reading.values.push({
|
|
75
103
|
keys: at.keys,
|
|
@@ -105,13 +133,14 @@ function record(reading, node, at) {
|
|
|
105
133
|
: resolved(reading, at.facts, node);
|
|
106
134
|
const places = placesOf(at);
|
|
107
135
|
held(reading, at, places, value, items);
|
|
108
|
-
|
|
136
|
+
const link = linked(reading, at.facts, node);
|
|
137
|
+
if (link === null)
|
|
109
138
|
return;
|
|
110
139
|
reading.links.push({
|
|
111
140
|
kind: 'field',
|
|
112
141
|
keys: at.keys,
|
|
113
142
|
places,
|
|
114
|
-
|
|
143
|
+
...link,
|
|
115
144
|
field: throughOf(at.keys, places),
|
|
116
145
|
});
|
|
117
146
|
}
|
|
@@ -154,7 +183,7 @@ export function indexed(path, fields, definition) {
|
|
|
154
183
|
head: '',
|
|
155
184
|
tail: '',
|
|
156
185
|
exact: `/${segment}`,
|
|
157
|
-
facts: definition === undefined ? undefined : memberFacts(definition.
|
|
186
|
+
facts: definition === undefined ? undefined : memberFacts(definition.root, name),
|
|
158
187
|
});
|
|
159
188
|
}
|
|
160
189
|
return { values: reading.values, links: reading.links };
|
package/dist/query/sql.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export type Following = {
|
|
|
19
19
|
readonly equal: Fragment;
|
|
20
20
|
};
|
|
21
21
|
export declare const VALUE_TABLE = "CREATE TABLE replica_values (doc INTEGER NOT NULL, keys TEXT NOT NULL, places TEXT NOT NULL, item INTEGER NOT NULL, kind TEXT NOT NULL, value, size INTEGER, instant TEXT, PRIMARY KEY (doc, keys, places, item)) WITHOUT ROWID";
|
|
22
|
+
export type Followed = {
|
|
23
|
+
readonly targets: (link: string, document: string) => Fragment;
|
|
24
|
+
readonly unfollowed: (link: string) => Fragment;
|
|
25
|
+
};
|
|
22
26
|
export declare const HOLDS_PHRASE = "holds_phrase";
|
|
23
27
|
export declare function holdsPhrase(_context: number, text: unknown, phrase: unknown): number;
|
|
24
28
|
export declare function fragment(sql: string, bind?: readonly SqlValue[]): Fragment;
|
|
@@ -28,10 +32,15 @@ export declare function any(parts: readonly Fragment[]): Fragment;
|
|
|
28
32
|
export declare function grouped(part: Fragment): Fragment;
|
|
29
33
|
export declare function listed(values: readonly SqlValue[]): Fragment;
|
|
30
34
|
export declare function exists(part: Fragment): Fragment;
|
|
31
|
-
export
|
|
35
|
+
export type HeldValues = {
|
|
36
|
+
readonly doc: number;
|
|
37
|
+
readonly values: readonly HeldValue[];
|
|
38
|
+
};
|
|
39
|
+
export declare function insertedValues(held: readonly HeldValues[]): Fragment;
|
|
32
40
|
export declare function placed(alias: string, field: string, reach: Reach): Fragment;
|
|
33
41
|
export declare function scoped(alias: string, scope: Scope, byPaths?: boolean): Fragment;
|
|
34
42
|
export declare function tests(alias: string, plan: QueryPlan): Fragment;
|
|
43
|
+
export declare function hopped(alias: string, hop: NonNullable<QueryPlan['hop']>, followed: Followed): Fragment;
|
|
35
44
|
export declare function sortValue(kind: SqlValue | undefined, value: unknown, instant: SqlValue | undefined): unknown;
|
|
36
45
|
export declare function sorted(collate: Collate, term: Term): Fragment;
|
|
37
46
|
export declare function beyond(collate: Collate, term: Term, value: unknown): Following;
|
package/dist/query/sql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql.d.ts","sourceRoot":"","sources":["../../src/query/sql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAU,SAAS,EAAE,KAAK,EAAe,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAEjE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAAC;AAEpE,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,CAAC;AAEpF,MAAM,MAAM,OAAO,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,KAAK,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CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,QAAQ,CAqB9D;AAED,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAClC,QAAQ,EAAE,QAAQ,GACjB,QAAQ,CA6BV;AAUD,wBAAgB,SAAS,CACvB,IAAI,EAAE,QAAQ,GAAG,SAAS,EAC1B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,QAAQ,GAAG,SAAS,WAG9B;AAsDD,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,QAAQ,CAc7D;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,CAgC9E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,EAAE,GAAG,EAAE,QAAQ,GAAG,QAAQ,CAM9E"}
|
package/dist/query/sql.js
CHANGED
|
@@ -54,9 +54,9 @@ function scalarText(value) {
|
|
|
54
54
|
return '-Infinity';
|
|
55
55
|
return JSON.stringify(value);
|
|
56
56
|
}
|
|
57
|
-
export function insertedValues(
|
|
58
|
-
const rows = values.map((value) => `[${JSON.stringify(value.keys)},${JSON.stringify(value.places)},${value.item},${JSON.stringify(value.kind)},${scalarText(value.value)},${JSON.stringify(value.size)},${JSON.stringify(value.instant)}]`);
|
|
59
|
-
return fragment('INSERT INTO replica_values (doc, keys, places, item, kind, value, size, instant) SELECT
|
|
57
|
+
export function insertedValues(held) {
|
|
58
|
+
const rows = held.flatMap(({ doc, values }) => values.map((value) => `[${doc},${JSON.stringify(value.keys)},${JSON.stringify(value.places)},${value.item},${JSON.stringify(value.kind)},${scalarText(value.value)},${JSON.stringify(value.size)},${JSON.stringify(value.instant)}]`));
|
|
59
|
+
return fragment('INSERT INTO replica_values (doc, keys, places, item, kind, value, size, instant) SELECT value ->> 0, value ->> 1, value ->> 2, value ->> 3, value ->> 4, value ->> 5, value ->> 6, value ->> 7 FROM json_each(?)', [`[${rows.join(',')}]`]);
|
|
60
60
|
}
|
|
61
61
|
export function placed(alias, field, reach) {
|
|
62
62
|
const { keys, places, glob } = placedOf(field, reach);
|
|
@@ -182,6 +182,25 @@ export function tests(alias, plan) {
|
|
|
182
182
|
: [fragment(`${HOLDS_PHRASE}(${alias}.content, ?)`, [plan.text.toLowerCase()])]),
|
|
183
183
|
]);
|
|
184
184
|
}
|
|
185
|
+
export function hopped(alias, hop, followed) {
|
|
186
|
+
const linked = exists(joined([
|
|
187
|
+
fragment('SELECT 1 FROM replica_links l JOIN '),
|
|
188
|
+
followed.targets('l', 'm'),
|
|
189
|
+
fragment(` WHERE l.doc = ${alias}.id AND l.kind = 'field' AND `),
|
|
190
|
+
grouped(placed('l', hop.field, 'link')),
|
|
191
|
+
fragment(' AND '),
|
|
192
|
+
grouped(scoped('m', hop)),
|
|
193
|
+
], ''));
|
|
194
|
+
if (!hop.none)
|
|
195
|
+
return linked;
|
|
196
|
+
const blind = exists(joined([
|
|
197
|
+
fragment(`SELECT 1 FROM replica_links l WHERE l.doc = ${alias}.id AND l.kind = 'field' AND `),
|
|
198
|
+
grouped(placed('l', hop.field, 'link')),
|
|
199
|
+
fragment(' AND '),
|
|
200
|
+
grouped(followed.unfollowed('l')),
|
|
201
|
+
], ''));
|
|
202
|
+
return all([not(linked), not(blind)]);
|
|
203
|
+
}
|
|
185
204
|
function instantMark(value) {
|
|
186
205
|
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
187
206
|
return null;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type Definition } from '../definition.js';
|
|
2
|
+
import type { VerifiedModel } from '../types.js';
|
|
3
|
+
import { type Direction, type QueryPlan } from './language.js';
|
|
4
|
+
export type KeyBound = {
|
|
5
|
+
readonly key: Uint8Array;
|
|
6
|
+
readonly inclusive: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type KeyRange = {
|
|
9
|
+
readonly lower: KeyBound;
|
|
10
|
+
readonly upper: KeyBound | null;
|
|
11
|
+
};
|
|
12
|
+
export type WalkRun = {
|
|
13
|
+
readonly by: 'key';
|
|
14
|
+
readonly key: Uint8Array;
|
|
15
|
+
readonly after: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
readonly by: 'range';
|
|
18
|
+
readonly range: KeyRange;
|
|
19
|
+
};
|
|
20
|
+
export type PageOrder = {
|
|
21
|
+
readonly by: 'path';
|
|
22
|
+
readonly direction: Direction;
|
|
23
|
+
} | {
|
|
24
|
+
readonly by: 'field';
|
|
25
|
+
readonly field: string;
|
|
26
|
+
readonly direction: Direction;
|
|
27
|
+
readonly nulls: 'first' | 'last';
|
|
28
|
+
readonly lexical: boolean;
|
|
29
|
+
readonly after: {
|
|
30
|
+
readonly key: Uint8Array;
|
|
31
|
+
readonly tie: unknown;
|
|
32
|
+
} | null;
|
|
33
|
+
};
|
|
34
|
+
export type Walk = {
|
|
35
|
+
readonly by: 'path';
|
|
36
|
+
readonly direction: Direction;
|
|
37
|
+
} | {
|
|
38
|
+
readonly by: 'keys';
|
|
39
|
+
readonly field: string;
|
|
40
|
+
readonly direction: Direction;
|
|
41
|
+
readonly types: readonly {
|
|
42
|
+
readonly type: string;
|
|
43
|
+
readonly keys: readonly Uint8Array[];
|
|
44
|
+
}[];
|
|
45
|
+
} | {
|
|
46
|
+
readonly by: 'order';
|
|
47
|
+
readonly field: string;
|
|
48
|
+
readonly direction: Direction;
|
|
49
|
+
readonly types: readonly {
|
|
50
|
+
readonly type: string;
|
|
51
|
+
readonly runs: readonly WalkRun[];
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
export type Count = {
|
|
55
|
+
readonly walk: Walk;
|
|
56
|
+
readonly fields: readonly string[];
|
|
57
|
+
};
|
|
58
|
+
export type WalkedFacts = {
|
|
59
|
+
readonly path: string;
|
|
60
|
+
readonly type: string | null;
|
|
61
|
+
readonly fields: Readonly<Record<string, unknown>> | null;
|
|
62
|
+
};
|
|
63
|
+
export declare function pageOrder(plan: QueryPlan): PageOrder;
|
|
64
|
+
export declare function walkOf(plan: QueryPlan, model: VerifiedModel): Walk;
|
|
65
|
+
export declare function countShape(plan: QueryPlan): boolean;
|
|
66
|
+
export declare function countOf(plan: QueryPlan, model: VerifiedModel, where: unknown): Count | null;
|
|
67
|
+
export declare function walkedValue(definition: Definition, field: string, value: unknown): unknown;
|
|
68
|
+
export type HopTarget = {
|
|
69
|
+
readonly handle: string | null;
|
|
70
|
+
readonly path: string;
|
|
71
|
+
};
|
|
72
|
+
export declare function hopTargets(plan: QueryPlan, model: VerifiedModel, row: WalkedFacts): HopTarget[];
|
|
73
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/query/walk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,UAAU,EAAmB,MAAM,kBAAkB,CAAC;AAEpG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EAIL,KAAK,SAAS,EAEd,KAAK,SAAS,EAEf,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC;AAEjF,MAAM,MAAM,QAAQ,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,CAAC;AAErF,MAAM,MAAM,OAAO,GACf;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,G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