@agentshouse/mdmodel 0.1.0-ca3c1be3cd1a3 → 0.1.0-caaa5bad9995d
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 +56 -104
- package/README.md +0 -1
- package/dist/definition.d.ts +2 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +48 -9
- package/dist/document.d.ts +3 -1
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +69 -17
- package/dist/facts.d.ts.map +1 -1
- package/dist/facts.js +3 -2
- package/dist/house-model.d.ts +67 -25
- package/dist/house-model.d.ts.map +1 -1
- package/dist/house-model.js +44 -14
- package/dist/house-references/patterns.d.ts +5 -1
- package/dist/house-references/patterns.d.ts.map +1 -1
- package/dist/house-references/patterns.js +8 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -9
- package/dist/indexed.d.ts +1 -0
- package/dist/indexed.d.ts.map +1 -1
- package/dist/indexed.js +8 -0
- package/dist/kinds.d.ts +7 -1
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +19 -0
- package/dist/markdown.d.ts +0 -4
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -34
- package/dist/paths.d.ts +1 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +20 -4
- package/dist/query/language.d.ts +4 -1
- package/dist/query/language.d.ts.map +1 -1
- package/dist/query/language.js +4 -3
- package/dist/query/match.d.ts.map +1 -1
- package/dist/query/match.js +3 -24
- package/dist/query/rows.d.ts +4 -0
- package/dist/query/rows.d.ts.map +1 -1
- package/dist/query/rows.js +21 -0
- package/dist/query/sql.d.ts +7 -1
- package/dist/query/sql.d.ts.map +1 -1
- package/dist/query/sql.js +14 -3
- package/dist/query/walk.d.ts +69 -0
- package/dist/query/walk.d.ts.map +1 -0
- package/dist/query/walk.js +274 -0
- package/dist/reserved.d.ts +1 -0
- package/dist/reserved.d.ts.map +1 -1
- package/dist/reserved.js +15 -4
- package/dist/room-types.d.ts +2 -1
- package/dist/room-types.d.ts.map +1 -1
- package/dist/room-types.js +8 -0
- package/dist/types.d.ts +10 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +2 -0
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +41 -12
- 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 +3 -1
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +153 -32
- package/fixtures/README.md +53 -56
- 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/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 +413 -1
- package/fixtures/references.json +15 -0
- package/package.json +1 -1
- package/dist/divide.d.ts +0 -3
- package/dist/divide.d.ts.map +0 -1
- package/dist/divide.js +0 -321
- 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/fixtures/cases/{frontmatter-schema → block-scalar-frontmatter}/context.json +0 -0
- /package/fixtures/cases/{frontmatter-schema/schema.yaml → unknown-type/schema.md} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
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 declare function hopTargets(plan: QueryPlan, model: VerifiedModel, row: WalkedFacts): string[];
|
|
69
|
+
//# 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,C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AoBnD;AAwCD,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAqB3F;AAED,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAG1F;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,EAAE,CAO5F"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { escapePointer, pointerSegments } from '../definition.js';
|
|
2
|
+
import { byCodePoint, indexKey, instantOf, sortedKey } from '../kinds.js';
|
|
3
|
+
import { definitionAt } from '../validate.js';
|
|
4
|
+
import { plain } from '../yaml.js';
|
|
5
|
+
import { invalid, textless, } from './language.js';
|
|
6
|
+
import { indexed, placedIn } from './rows.js';
|
|
7
|
+
function keyOrder(left, right) {
|
|
8
|
+
for (let at = 0; at < Math.min(left.length, right.length); at += 1) {
|
|
9
|
+
if (left[at] !== right[at])
|
|
10
|
+
return left[at] - right[at];
|
|
11
|
+
}
|
|
12
|
+
return left.length - right.length;
|
|
13
|
+
}
|
|
14
|
+
function tighter(held, bound, sign) {
|
|
15
|
+
if (held === null)
|
|
16
|
+
return bound;
|
|
17
|
+
const order = sign * keyOrder(bound.key, held.key);
|
|
18
|
+
return order > 0 || (order === 0 && !bound.inclusive) ? bound : held;
|
|
19
|
+
}
|
|
20
|
+
function everyValue(facts) {
|
|
21
|
+
return { lower: { key: indexKey(facts, null), inclusive: false }, upper: null };
|
|
22
|
+
}
|
|
23
|
+
function rangeOf(facts, bounds) {
|
|
24
|
+
let { lower } = everyValue(facts);
|
|
25
|
+
let upper = null;
|
|
26
|
+
for (const [operator, value] of bounds) {
|
|
27
|
+
const bound = { key: indexKey(facts, value), inclusive: operator.endsWith('e') };
|
|
28
|
+
if (operator.startsWith('g'))
|
|
29
|
+
lower = tighter(lower, bound, 1);
|
|
30
|
+
else
|
|
31
|
+
upper = tighter(upper, bound, -1);
|
|
32
|
+
}
|
|
33
|
+
return { lower, upper };
|
|
34
|
+
}
|
|
35
|
+
function distinct(keys) {
|
|
36
|
+
return [...new Map(keys.map((key) => [key.join(','), key])).values()];
|
|
37
|
+
}
|
|
38
|
+
function testedKeys(facts, test) {
|
|
39
|
+
if (test.op === 'eq')
|
|
40
|
+
return { keys: [indexKey(facts, test.value)] };
|
|
41
|
+
if (test.op === 'in')
|
|
42
|
+
return { keys: distinct(test.values.map((value) => indexKey(facts, value))) };
|
|
43
|
+
if (test.op === 'range')
|
|
44
|
+
return { range: rangeOf(facts, test.bounds) };
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function conjuncts(where) {
|
|
48
|
+
if (where === null || 'some' in where)
|
|
49
|
+
return [];
|
|
50
|
+
return 'every' in where ? where.every.flatMap(conjuncts) : [where];
|
|
51
|
+
}
|
|
52
|
+
function named(pointer) {
|
|
53
|
+
const segments = pointerSegments(pointer);
|
|
54
|
+
return segments.length === 1 ? segments[0] : null;
|
|
55
|
+
}
|
|
56
|
+
function indexing(model, types, field) {
|
|
57
|
+
const definitions = types.map((type) => Object.hasOwn(model.types, type) ? model.types[type] : null);
|
|
58
|
+
return definitions.every((definition) => definition?.indexed?.includes(field) === true)
|
|
59
|
+
? definitions
|
|
60
|
+
: null;
|
|
61
|
+
}
|
|
62
|
+
function afterOf(plan) {
|
|
63
|
+
const values = plan.after?.values ?? null;
|
|
64
|
+
if (values === null)
|
|
65
|
+
return null;
|
|
66
|
+
const key = sortedKey(values[0]);
|
|
67
|
+
if (key === null)
|
|
68
|
+
invalid('after', 'expects the next an earlier result of this query returned');
|
|
69
|
+
return { key, tie: values[1] };
|
|
70
|
+
}
|
|
71
|
+
export function pageOrder(plan) {
|
|
72
|
+
if (plan.shape.kind !== 'documents')
|
|
73
|
+
return invalid('groupBy', 'a page answers Documents');
|
|
74
|
+
const [term, second] = plan.shape.orderBy;
|
|
75
|
+
if (second !== undefined)
|
|
76
|
+
invalid(['orderBy', 1], 'a page orders by one term');
|
|
77
|
+
if (term === undefined)
|
|
78
|
+
return { by: 'path', direction: 'asc' };
|
|
79
|
+
const { key, options } = term;
|
|
80
|
+
if (key.of === 'path') {
|
|
81
|
+
if (options.stringSort !== 'lexical')
|
|
82
|
+
invalid(['orderBy', 0, 'stringSort'], 'a page orders Paths by code point, as lexical');
|
|
83
|
+
return { by: 'path', direction: options.direction };
|
|
84
|
+
}
|
|
85
|
+
const field = key.of === 'field' ? named(key.field) : null;
|
|
86
|
+
if (field === null)
|
|
87
|
+
return invalid(['orderBy', 0, 'by'], 'a page orders by Path or by a field its types index');
|
|
88
|
+
if (plan.root.types === null)
|
|
89
|
+
invalid('types', 'an order by a field names the types whose index it walks');
|
|
90
|
+
return {
|
|
91
|
+
by: 'field',
|
|
92
|
+
field,
|
|
93
|
+
direction: options.direction,
|
|
94
|
+
nulls: options.nulls ?? 'first',
|
|
95
|
+
lexical: options.stringSort === 'lexical',
|
|
96
|
+
after: afterOf(plan),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function keysWalk(plan, model, direction) {
|
|
100
|
+
const types = plan.root.types;
|
|
101
|
+
for (const { field: pointer, test } of conjuncts(plan.root.where)) {
|
|
102
|
+
const field = named(pointer);
|
|
103
|
+
if (types === null || field === null || (test.op !== 'eq' && test.op !== 'in'))
|
|
104
|
+
continue;
|
|
105
|
+
const definitions = indexing(model, types, field);
|
|
106
|
+
if (definitions === null)
|
|
107
|
+
continue;
|
|
108
|
+
return {
|
|
109
|
+
by: 'keys',
|
|
110
|
+
field,
|
|
111
|
+
direction,
|
|
112
|
+
types: definitions.map((definition) => ({
|
|
113
|
+
type: definition.name,
|
|
114
|
+
keys: testedKeys(definition.fields[field], test).keys,
|
|
115
|
+
})),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return { by: 'path', direction };
|
|
119
|
+
}
|
|
120
|
+
function common(types) {
|
|
121
|
+
const [first, ...rest] = types;
|
|
122
|
+
return (first?.indexed ?? [])
|
|
123
|
+
.filter((field) => rest.every((definition) => definition.indexed?.includes(field)))
|
|
124
|
+
.map((field) => `/${escapePointer(field)}`);
|
|
125
|
+
}
|
|
126
|
+
function ranged(facts, tests) {
|
|
127
|
+
if (tests.length === 0)
|
|
128
|
+
return null;
|
|
129
|
+
return tests
|
|
130
|
+
.map(({ test }) => testedKeys(facts, test).range)
|
|
131
|
+
.reduce((held, range) => ({
|
|
132
|
+
lower: tighter(held.lower, range.lower, 1),
|
|
133
|
+
upper: range.upper === null ? held.upper : tighter(held.upper, range.upper, -1),
|
|
134
|
+
}));
|
|
135
|
+
}
|
|
136
|
+
function past(range, key, direction) {
|
|
137
|
+
const beyond = { key, inclusive: false };
|
|
138
|
+
return direction === 'asc'
|
|
139
|
+
? { ...range, lower: tighter(range.lower, beyond, 1) }
|
|
140
|
+
: { ...range, upper: tighter(range.upper, beyond, -1) };
|
|
141
|
+
}
|
|
142
|
+
function runsOf(facts, order, range) {
|
|
143
|
+
const missing = indexKey(facts, null);
|
|
144
|
+
const cursor = order.after?.key ?? null;
|
|
145
|
+
const amongNulls = cursor !== null && keyOrder(cursor, missing) === 0;
|
|
146
|
+
const nulls = range === null ? [{ by: 'key', key: missing, after: amongNulls }] : [];
|
|
147
|
+
const span = range ?? everyValue(facts);
|
|
148
|
+
if (cursor === null || amongNulls) {
|
|
149
|
+
if (order.nulls === 'first')
|
|
150
|
+
return [...nulls, { by: 'range', range: span }];
|
|
151
|
+
return amongNulls ? nulls : [{ by: 'range', range: span }, ...nulls];
|
|
152
|
+
}
|
|
153
|
+
const values = [
|
|
154
|
+
{ by: 'key', key: cursor, after: true },
|
|
155
|
+
{ by: 'range', range: past(span, cursor, order.direction) },
|
|
156
|
+
];
|
|
157
|
+
return order.nulls === 'first' ? values : [...values, ...nulls];
|
|
158
|
+
}
|
|
159
|
+
function unindexed(model, types, at, problem) {
|
|
160
|
+
const declared = types.flatMap((type) => Object.hasOwn(model.types, type) ? [model.types[type]] : []);
|
|
161
|
+
return invalid(at, problem, declared.length === types.length ? common(declared) : []);
|
|
162
|
+
}
|
|
163
|
+
export function walkOf(plan, model) {
|
|
164
|
+
const order = pageOrder(plan);
|
|
165
|
+
if (order.by === 'path')
|
|
166
|
+
return keysWalk(plan, model, order.direction);
|
|
167
|
+
const types = plan.root.types;
|
|
168
|
+
const definitions = indexing(model, types, order.field);
|
|
169
|
+
if (definitions === null)
|
|
170
|
+
return unindexed(model, types, ['orderBy', 0, 'by'], 'orders by a field every type it names indexes');
|
|
171
|
+
if (!order.lexical &&
|
|
172
|
+
definitions.some((definition) => !textless(definition.fields[order.field])))
|
|
173
|
+
invalid(['orderBy', 0, 'stringSort'], 'a page orders text by code point, as lexical');
|
|
174
|
+
const bounding = conjuncts(plan.root.where).filter(({ field, test }) => test.op === 'range' && named(field) === order.field);
|
|
175
|
+
return {
|
|
176
|
+
by: 'order',
|
|
177
|
+
field: order.field,
|
|
178
|
+
direction: order.direction,
|
|
179
|
+
types: definitions.map((definition) => {
|
|
180
|
+
const facts = definition.fields[order.field];
|
|
181
|
+
return { type: definition.name, runs: runsOf(facts, order, ranged(facts, bounding)) };
|
|
182
|
+
}),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
export function countShape(plan) {
|
|
186
|
+
const { shape } = plan;
|
|
187
|
+
if (shape.kind === 'documents' && !plan.total)
|
|
188
|
+
return false;
|
|
189
|
+
if (plan.root.types === null)
|
|
190
|
+
invalid('types', 'a count names the types whose index it reads');
|
|
191
|
+
if (plan.text !== null)
|
|
192
|
+
invalid('text', 'a count tests no text');
|
|
193
|
+
if (plan.hop !== null)
|
|
194
|
+
invalid('hop', 'a count tests no hop');
|
|
195
|
+
if (shape.kind === 'documents')
|
|
196
|
+
return true;
|
|
197
|
+
if (plan.total)
|
|
198
|
+
invalid('total', 'a page of groups answers no total');
|
|
199
|
+
const key = shape.groupBy[0];
|
|
200
|
+
if (shape.groupBy.length > 1)
|
|
201
|
+
invalid(['groupBy', 1], 'a page groups by one field');
|
|
202
|
+
if (key.of !== 'field' || named(key.field) === null)
|
|
203
|
+
invalid(['groupBy', 0], 'a page groups by a field its types index');
|
|
204
|
+
for (const part of ['size', 'updated', 'greatest'])
|
|
205
|
+
if (shape[part] !== false && shape[part] !== null)
|
|
206
|
+
invalid(['select', part], 'a group selects only its count');
|
|
207
|
+
shape.orderBy.forEach(({ by }, index) => {
|
|
208
|
+
if (typeof by === 'string' && by !== 'count')
|
|
209
|
+
invalid(['orderBy', index, 'by'], 'a page of groups orders by its count or its key');
|
|
210
|
+
});
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
function testedPlaces(where, at) {
|
|
214
|
+
if (!plain(where))
|
|
215
|
+
return [];
|
|
216
|
+
return Object.keys(where)
|
|
217
|
+
.sort()
|
|
218
|
+
.flatMap((name) => name === '$and' || name === '$or'
|
|
219
|
+
? where[name].flatMap((part, index) => testedPlaces(part, [...at, name, index]))
|
|
220
|
+
: [{ pointer: name, place: [...at, name] }]);
|
|
221
|
+
}
|
|
222
|
+
function countWalk(plan, model) {
|
|
223
|
+
const keyed = keysWalk(plan, model, 'asc');
|
|
224
|
+
if (keyed.by !== 'path')
|
|
225
|
+
return keyed;
|
|
226
|
+
const tests = conjuncts(plan.root.where);
|
|
227
|
+
for (const { field: pointer, test } of tests) {
|
|
228
|
+
const field = named(pointer);
|
|
229
|
+
if (test.op !== 'range' || field === null)
|
|
230
|
+
continue;
|
|
231
|
+
const definitions = indexing(model, plan.root.types, field);
|
|
232
|
+
if (definitions === null)
|
|
233
|
+
continue;
|
|
234
|
+
const bounding = tests.filter((bounded) => bounded.test.op === 'range' && bounded.field === pointer);
|
|
235
|
+
return {
|
|
236
|
+
by: 'order',
|
|
237
|
+
field,
|
|
238
|
+
direction: 'asc',
|
|
239
|
+
types: definitions.map((definition) => ({
|
|
240
|
+
type: definition.name,
|
|
241
|
+
runs: [{ by: 'range', range: ranged(definition.fields[field], bounding) }],
|
|
242
|
+
})),
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
return keyed;
|
|
246
|
+
}
|
|
247
|
+
export function countOf(plan, model, where) {
|
|
248
|
+
if (!countShape(plan))
|
|
249
|
+
return null;
|
|
250
|
+
const types = plan.root.types;
|
|
251
|
+
const grouped = plan.shape.kind === 'groups'
|
|
252
|
+
? [{ pointer: plan.shape.groupBy[0].field, place: ['groupBy', 0] }]
|
|
253
|
+
: [];
|
|
254
|
+
const fields = [...grouped, ...testedPlaces(where, ['where'])].map(({ pointer, place }) => {
|
|
255
|
+
const field = named(pointer);
|
|
256
|
+
if (field === null || indexing(model, types, field) === null)
|
|
257
|
+
return unindexed(model, types, place, place[0] === 'groupBy'
|
|
258
|
+
? 'groups by a field every type it names indexes'
|
|
259
|
+
: 'a count tests only fields every type it names indexes');
|
|
260
|
+
return field;
|
|
261
|
+
});
|
|
262
|
+
return { walk: countWalk(plan, model), fields: [...new Set(fields)].sort() };
|
|
263
|
+
}
|
|
264
|
+
export function walkedValue(definition, field, value) {
|
|
265
|
+
const instant = instantOf(definition.fields[field], value);
|
|
266
|
+
return instant === null ? (value ?? null) : { instant };
|
|
267
|
+
}
|
|
268
|
+
export function hopTargets(plan, model, row) {
|
|
269
|
+
if (plan.hop === null || row.type === null || row.fields === null)
|
|
270
|
+
return [];
|
|
271
|
+
const definition = definitionAt(model, row.path)(row.type);
|
|
272
|
+
const { links } = indexed(row.path, row.fields, definition);
|
|
273
|
+
return [...new Set(placedIn(links, plan.hop.field, 'link').map(({ target }) => target))].sort(byCodePoint);
|
|
274
|
+
}
|
package/dist/reserved.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const ROOM_DESCRIPTION = "ROOM.md";
|
|
2
2
|
export declare const CAPTURE_HOME = "capture";
|
|
3
3
|
export declare const RESERVED_NAMES: readonly string[];
|
|
4
|
+
export declare function foldedName(name: string): string;
|
|
4
5
|
export declare function isReservedName(name: string): boolean;
|
|
5
6
|
export declare function isDocumentPath(path: string): boolean;
|
|
6
7
|
//# sourceMappingURL=reserved.d.ts.map
|
package/dist/reserved.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;
|
|
1
|
+
{"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../src/reserved.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAE1C,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAO3C,CAAC;AAYF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI/C;AAID,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD"}
|
package/dist/reserved.js
CHANGED
|
@@ -8,12 +8,23 @@ export const RESERVED_NAMES = [
|
|
|
8
8
|
'agents',
|
|
9
9
|
'house',
|
|
10
10
|
];
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const DOTLESS_I = 'ı';
|
|
12
|
+
const CHEROKEE_SMALL = /[\u13F8-\u13FD\uAB70-\uABBF]/u;
|
|
13
|
+
function foldedPoint(point) {
|
|
14
|
+
if (point === DOTLESS_I)
|
|
15
|
+
return point;
|
|
16
|
+
const folded = point.toLowerCase().toUpperCase().toLowerCase();
|
|
17
|
+
return CHEROKEE_SMALL.test(folded) ? folded.toUpperCase() : folded;
|
|
13
18
|
}
|
|
14
|
-
|
|
19
|
+
export function foldedName(name) {
|
|
20
|
+
let folded = '';
|
|
21
|
+
for (const point of name.normalize('NFC'))
|
|
22
|
+
folded += foldedPoint(point);
|
|
23
|
+
return folded.normalize('NFC');
|
|
24
|
+
}
|
|
25
|
+
const FOLDED_RESERVED_NAMES = new Set(RESERVED_NAMES.map(foldedName));
|
|
15
26
|
export function isReservedName(name) {
|
|
16
|
-
return FOLDED_RESERVED_NAMES.has(
|
|
27
|
+
return FOLDED_RESERVED_NAMES.has(foldedName(name));
|
|
17
28
|
}
|
|
18
29
|
export function isDocumentPath(path) {
|
|
19
30
|
const first = path.split('/', 1)[0];
|
package/dist/room-types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const CHAT_TYPE = "chat";
|
|
2
2
|
export declare const CHAT_MESSAGE_TYPE = "chat-message";
|
|
3
3
|
export declare const INBOX_TYPES: readonly string[];
|
|
4
|
-
export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', 'whatsapp', 'messenger', 'instagram', 'tiktok'];
|
|
4
|
+
export declare const INBOX_CHANNEL_KINDS: readonly ['telegram-bot', 'telegram-business', 'whatsapp', 'messenger', 'instagram', 'tiktok', 'viber'];
|
|
5
5
|
export type InboxChannelKind = (typeof INBOX_CHANNEL_KINDS)[number];
|
|
6
|
+
export declare const VIEW_TYPE = "view";
|
|
6
7
|
export declare const ROOM_TYPES_TEXT: string;
|
|
7
8
|
//# sourceMappingURL=room-types.d.ts.map
|
package/dist/room-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,
|
|
1
|
+
{"version":3,"file":"room-types.d.ts","sourceRoot":"","sources":["../src/room-types.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,SAAS,SAAS,CAAC;AAEhC,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmC,CAAC;AAE7E,eAAO,MAAM,mBAAmB,YAC9B,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,WAAW,EACX,QAAQ,EACR,OAAO,CACC,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMpE,eAAO,MAAM,SAAS,SAAS,CAAC;AA8BhC,eAAO,MAAM,eAAe,QAuGhB,CAAC"}
|
package/dist/room-types.js
CHANGED
|
@@ -10,9 +10,11 @@ export const INBOX_CHANNEL_KINDS = [
|
|
|
10
10
|
'messenger',
|
|
11
11
|
'instagram',
|
|
12
12
|
'tiktok',
|
|
13
|
+
'viber',
|
|
13
14
|
];
|
|
14
15
|
const WAYFINDING_MAP_TYPE = 'wayfinding-map';
|
|
15
16
|
const WAYFINDING_TICKET_TYPE = 'wayfinding-ticket';
|
|
17
|
+
export const VIEW_TYPE = 'view';
|
|
16
18
|
const WAYFINDING_MAP_TEXTS = [
|
|
17
19
|
['destination', 'Destination'],
|
|
18
20
|
['notes', 'Notes'],
|
|
@@ -132,5 +134,11 @@ export const ROOM_TYPES_TEXT = [
|
|
|
132
134
|
' else: { properties: { conversation: false } }',
|
|
133
135
|
' - if: { properties: { status: { enum: [done, out-of-scope] } }, required: [status] }',
|
|
134
136
|
' then: { required: [answer], properties: { answer: { minLength: 1, title: Answer } } }',
|
|
137
|
+
`${VIEW_TYPE}:`,
|
|
138
|
+
' properties:',
|
|
139
|
+
' name: { type: string, title: Name }',
|
|
140
|
+
' description: { type: string, title: Description }',
|
|
141
|
+
' query: { type: object, additionalProperties: true, title: Query }',
|
|
142
|
+
' required: [name, description, query]',
|
|
135
143
|
'',
|
|
136
144
|
].join('\n');
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { Definition } from './definition.js';
|
|
2
2
|
export type Library = Readonly<Record<string, string>>;
|
|
3
|
+
export type RoleNeed = 'read' | 'write';
|
|
3
4
|
export type VerifiedModel = {
|
|
4
5
|
readonly types: Readonly<Record<string, Definition>>;
|
|
5
6
|
readonly nameable?: readonly string[];
|
|
7
|
+
readonly roles?: Readonly<Record<string, RoleNeed>>;
|
|
6
8
|
};
|
|
7
9
|
export type ModelVerification = {
|
|
8
10
|
readonly verdict: 'accept';
|
|
@@ -23,13 +25,6 @@ export type ValidationContext = {
|
|
|
23
25
|
readonly anyRoom?: true;
|
|
24
26
|
readonly typedPaths?: readonly TypedPath[];
|
|
25
27
|
};
|
|
26
|
-
export type ProjectionContext = {
|
|
27
|
-
readonly documentTargets: readonly string[];
|
|
28
|
-
readonly definition?: Definition;
|
|
29
|
-
};
|
|
30
|
-
export type DivisionContext = ProjectionContext & {
|
|
31
|
-
readonly bound: number;
|
|
32
|
-
};
|
|
33
28
|
export type Extent = {
|
|
34
29
|
readonly start: number;
|
|
35
30
|
readonly end: number;
|
|
@@ -76,20 +71,6 @@ export type ValidationStep = {
|
|
|
76
71
|
readonly path: string;
|
|
77
72
|
readonly resolved: number;
|
|
78
73
|
};
|
|
79
|
-
export type Projection = {
|
|
80
|
-
readonly ok: true;
|
|
81
|
-
readonly text: string;
|
|
82
|
-
} | {
|
|
83
|
-
readonly ok: false;
|
|
84
|
-
readonly refusal: Refusal;
|
|
85
|
-
};
|
|
86
|
-
export type Division = {
|
|
87
|
-
readonly ok: true;
|
|
88
|
-
readonly spans: readonly Span[];
|
|
89
|
-
} | {
|
|
90
|
-
readonly ok: false;
|
|
91
|
-
readonly refusal: Refusal;
|
|
92
|
-
};
|
|
93
74
|
export type ParseResult = {
|
|
94
75
|
readonly ok: true;
|
|
95
76
|
readonly document: Document;
|
|
@@ -166,6 +147,14 @@ export type BodyResult = {
|
|
|
166
147
|
readonly outcome: 'refuse';
|
|
167
148
|
readonly refusal: Refusal;
|
|
168
149
|
};
|
|
150
|
+
export type LinkSpan = {
|
|
151
|
+
readonly start: number;
|
|
152
|
+
readonly end: number;
|
|
153
|
+
readonly label: Extent | null;
|
|
154
|
+
readonly href: string;
|
|
155
|
+
readonly destination: Extent;
|
|
156
|
+
readonly bracketed: boolean;
|
|
157
|
+
};
|
|
169
158
|
export type UnlinkedBody = {
|
|
170
159
|
readonly body: string;
|
|
171
160
|
readonly links: ReadonlyMap<string, string>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEvD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,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AAC;AAEN,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAC5D;IACE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export declare function definitionAt(model: VerifiedModel, file: string, typedPa
|
|
|
5
5
|
export declare function resolves(reference: Reached, typeOf: (path: string) => string | undefined, binary: (path: string) => boolean): boolean;
|
|
6
6
|
export declare function verify(schema: string, provided?: VerifiedModel): ModelVerification;
|
|
7
7
|
export declare function readTypes(schema: string, provided?: VerifiedModel): VerifiedModel;
|
|
8
|
+
export declare function verifySchemaDocument(document: string, provided?: VerifiedModel): ModelVerification;
|
|
9
|
+
export declare function readSchemaDocument(document: string, provided?: VerifiedModel): VerifiedModel;
|
|
8
10
|
type Placing = Pick<ValidationContext, 'anyRoom' | 'typedPaths'>;
|
|
9
11
|
export declare function checkDocument(file: string, content: string, model: VerifiedModel, context?: Placing): DocumentCheck;
|
|
10
12
|
export declare function bodyRoomLinks(body: string): RoomReference[];
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAQjF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,aAAa,EACb,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AA6FpB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,GAChC,YAAY,CAOd;AA8BD,wBAAgB,QAAQ,CACtB,SAAS,EAAE,OAAO,EAClB,MAAM,EAAE,CA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GAAE,aAA6B,GACnC,UAAU,CAEZ;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,EACzC,OAAO,GAAE,iBAAyC,EAClD,KAAK,GAAE,aAA6B,GACnC,UAAU,CAEZ"}
|
package/dist/validate.js
CHANGED
|
@@ -2,13 +2,15 @@ import { ATTACHMENT, BUILT_IN_TYPE, readSchema, } from './definition.js';
|
|
|
2
2
|
import { linkDestinations, links, parse } from './document.js';
|
|
3
3
|
import { MEMBER_FIELD } from './fields.js';
|
|
4
4
|
import { formFailure } from './form.js';
|
|
5
|
-
import { indexedFailure } from './indexed.js';
|
|
5
|
+
import { indexedFailure, uniqueFailure } from './indexed.js';
|
|
6
6
|
import { hrefOccurrences, lineBreaks, lineNumber } from './markdown.js';
|
|
7
7
|
import { classifyHref, keyedLink, roomTarget } from './paths.js';
|
|
8
8
|
import { references } from './references.js';
|
|
9
9
|
import { isDocumentPath, ROOM_DESCRIPTION } from './reserved.js';
|
|
10
10
|
import { refusal } from './refuse.js';
|
|
11
11
|
import { schemaRefusal } from './schema.js';
|
|
12
|
+
import { viewRefusal } from './view.js';
|
|
13
|
+
import { extractFrontmatter } from './yaml.js';
|
|
12
14
|
import { openPatternBudget, PatternTooCostly } from './pattern.js';
|
|
13
15
|
function refuse(file, rule, extra) {
|
|
14
16
|
return { verdict: 'refuse', ...refusal(file, rule, extra) };
|
|
@@ -111,23 +113,50 @@ function schemaRefused(failure) {
|
|
|
111
113
|
...(failure.location === undefined ? {} : { location: failure.location }),
|
|
112
114
|
};
|
|
113
115
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
const NO_FRONTMATTER = { start: 0, end: 0 };
|
|
117
|
+
function frontmatterOf(document) {
|
|
118
|
+
const fence = extractFrontmatter(document);
|
|
119
|
+
if (fence.kind === 'none')
|
|
120
|
+
return NO_FRONTMATTER;
|
|
121
|
+
if (fence.kind === 'unclosed')
|
|
122
|
+
return { rule: 'schema-yaml', location: 'line 1' };
|
|
123
|
+
return { start: fence.yamlStart, end: fence.yamlEnd };
|
|
124
|
+
}
|
|
125
|
+
function verified(text, provided, { start, end }, document) {
|
|
126
|
+
const read = readSchema(text, provided, true, start, end);
|
|
116
127
|
if (!('types' in read))
|
|
117
128
|
return schemaRefused(read);
|
|
118
|
-
const failure = formFailure(read, provided) ??
|
|
129
|
+
const failure = formFailure(read, provided) ??
|
|
130
|
+
indexedFailure(read) ??
|
|
131
|
+
(document ? undefined : uniqueFailure(read));
|
|
119
132
|
return failure === undefined ? { verdict: 'accept', model: read } : schemaRefused(failure);
|
|
120
133
|
}
|
|
121
|
-
|
|
122
|
-
const read = readSchema(
|
|
134
|
+
function typesRead(text, provided, { start, end }) {
|
|
135
|
+
const read = readSchema(text, provided, false, start, end);
|
|
123
136
|
if ('types' in read)
|
|
124
137
|
return read;
|
|
125
138
|
throw new Error(`the schema reads as no types: ${read.rule} ${read.location ?? ''}`.trim());
|
|
126
139
|
}
|
|
127
|
-
function
|
|
140
|
+
export function verify(schema, provided) {
|
|
141
|
+
return verified(schema, provided, { start: 0, end: schema.length }, false);
|
|
142
|
+
}
|
|
143
|
+
export function readTypes(schema, provided) {
|
|
144
|
+
return typesRead(schema, provided, { start: 0, end: schema.length });
|
|
145
|
+
}
|
|
146
|
+
export function verifySchemaDocument(document, provided) {
|
|
147
|
+
const held = frontmatterOf(document);
|
|
148
|
+
return 'rule' in held ? schemaRefused(held) : verified(document, provided, held, true);
|
|
149
|
+
}
|
|
150
|
+
export function readSchemaDocument(document, provided) {
|
|
151
|
+
const held = frontmatterOf(document);
|
|
152
|
+
if ('rule' in held)
|
|
153
|
+
throw new Error(`the schema reads as no types: ${held.rule} ${held.location}`);
|
|
154
|
+
return typesRead(document, provided, held);
|
|
155
|
+
}
|
|
156
|
+
function structure(file, document, definition, model) {
|
|
128
157
|
if (definition === undefined)
|
|
129
158
|
return refuse(file, 'unknown-type', { location: '/type' });
|
|
130
|
-
const fieldFailure = schemaRefusal(definition, document.fields);
|
|
159
|
+
const fieldFailure = schemaRefusal(definition, document.fields) ?? viewRefusal(definition, document.fields, model);
|
|
131
160
|
if (fieldFailure !== undefined)
|
|
132
161
|
return placedRefusal(file, document, fieldFailure.rule, fieldFailure.location);
|
|
133
162
|
return unmarkedMember(file, document, definition);
|
|
@@ -172,7 +201,7 @@ export function checkDocument(file, content, model, context = {}) {
|
|
|
172
201
|
? { ok: true, type, typed: false, references: [] }
|
|
173
202
|
: { ok: false };
|
|
174
203
|
const definition = definitionOf(kind, model);
|
|
175
|
-
if (structure(file, document, definition) !== null ||
|
|
204
|
+
if (structure(file, document, definition, model) !== null ||
|
|
176
205
|
definition === undefined ||
|
|
177
206
|
!linked(file, document))
|
|
178
207
|
return { ok: false };
|
|
@@ -249,7 +278,7 @@ export function assess(file, parsed, binary, model = { types: {} }, context = {}
|
|
|
249
278
|
}
|
|
250
279
|
const definition = definitionOf(kind, model);
|
|
251
280
|
try {
|
|
252
|
-
return structured(file, typed, document, definition, context);
|
|
281
|
+
return structured(file, typed, document, definition, model, context);
|
|
253
282
|
}
|
|
254
283
|
catch (error) {
|
|
255
284
|
if (!(error instanceof PatternTooCostly))
|
|
@@ -263,8 +292,8 @@ export function assess(file, parsed, binary, model = { types: {} }, context = {}
|
|
|
263
292
|
};
|
|
264
293
|
}
|
|
265
294
|
}
|
|
266
|
-
function structured(file, typed, document, definition, context) {
|
|
267
|
-
const refused = structure(file, document, definition);
|
|
295
|
+
function structured(file, typed, document, definition, model, context) {
|
|
296
|
+
const refused = structure(file, document, definition, model);
|
|
268
297
|
if (refused !== null || definition === undefined) {
|
|
269
298
|
return { ...typed, targets: [], structured: refused, fields: [], linked: true };
|
|
270
299
|
}
|
package/dist/view.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
import type { SchemaRefusal } from './schema.js';
|
|
3
|
+
import type { VerifiedModel } from './types.js';
|
|
4
|
+
export declare function viewRefusal(definition: Definition, fields: Readonly<Record<string, unknown>>, model: VerifiedModel): SchemaRefusal | undefined;
|
|
5
|
+
//# sourceMappingURL=view.d.ts.map
|