@agentshouse/mdmodel 0.1.0-ccf1367190878 → 0.1.0-cd5ace6e0b27a
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 +232 -182
- package/README.md +21 -22
- package/dist/definition.d.ts +18 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +176 -48
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +32 -21
- package/dist/document.d.ts +10 -6
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +424 -207
- package/dist/event.d.ts +78 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +201 -0
- package/dist/facts.d.ts +15 -0
- package/dist/facts.d.ts.map +1 -0
- package/dist/facts.js +41 -0
- package/dist/form.d.ts +4 -0
- package/dist/form.d.ts.map +1 -0
- package/dist/form.js +139 -0
- package/dist/index.d.ts +25 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -8
- package/dist/kinds.d.ts +18 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +150 -0
- package/dist/markdown.d.ts +51 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +271 -0
- package/dist/paths.d.ts +18 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +69 -15
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +356 -0
- package/dist/project.d.ts +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +44 -26
- package/dist/query/language.d.ts +254 -0
- package/dist/query/language.d.ts.map +1 -0
- package/dist/query/language.js +620 -0
- package/dist/query/match.d.ts +14 -0
- package/dist/query/match.d.ts.map +1 -0
- package/dist/query/match.js +150 -0
- package/dist/query/rows.d.ts +32 -0
- package/dist/query/rows.d.ts.map +1 -0
- package/dist/query/rows.js +161 -0
- package/dist/query/sql.d.ts +39 -0
- package/dist/query/sql.d.ts.map +1 -0
- package/dist/query/sql.js +285 -0
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +6 -1
- package/dist/reserved.d.ts +6 -0
- package/dist/reserved.d.ts.map +1 -0
- package/dist/reserved.js +21 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +55 -4
- package/dist/types.d.ts +46 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +31 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +387 -129
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +40 -14
- package/fixtures/README.md +34 -7
- package/fixtures/cases/conditional-section/context.json +1 -0
- package/fixtures/cases/conditional-section/expected.json +6 -0
- package/fixtures/cases/conditional-section/library/questions/hosting.md +9 -0
- package/fixtures/cases/conditional-section/library/questions/payments.md +12 -0
- package/fixtures/cases/conditional-section/schema.yaml +14 -0
- package/fixtures/cases/cross-room-link/context.json +1 -0
- package/fixtures/cases/cross-room-link/expected.json +1 -0
- package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
- package/fixtures/cases/cross-room-link/schema.yaml +3 -0
- package/fixtures/cases/cross-room-reference/context.json +1 -0
- package/fixtures/cases/cross-room-reference/expected.json +1 -0
- package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
- package/fixtures/cases/cross-room-reference/schema.yaml +9 -0
- package/fixtures/cases/equal-labels/context.json +1 -0
- package/fixtures/cases/equal-labels/expected.json +5 -0
- package/fixtures/cases/equal-labels/schema.yaml +4 -0
- package/fixtures/cases/labels-in-the-rooms-language/context.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/expected.json +1 -0
- package/fixtures/cases/labels-in-the-rooms-language/library/deals/atlas.md +6 -0
- package/fixtures/cases/labels-in-the-rooms-language/schema.yaml +9 -0
- package/fixtures/cases/lazy-list-item/context.json +1 -0
- package/fixtures/cases/lazy-list-item/expected.json +3 -0
- package/fixtures/cases/lazy-list-item/library/item.md +8 -0
- package/fixtures/cases/lazy-list-item/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
- package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
- package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
- package/fixtures/cases/long-value-past-six-levels/context.json +1 -0
- package/fixtures/cases/long-value-past-six-levels/expected.json +5 -0
- package/fixtures/cases/long-value-past-six-levels/schema.yaml +15 -0
- package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
- package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
- package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/context.json +1 -0
- package/fixtures/cases/member-on-another-type/expected.json +6 -0
- package/fixtures/cases/member-on-another-type/library/note.md +4 -0
- package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
- package/fixtures/cases/name-not-a-string/context.json +1 -0
- package/fixtures/cases/name-not-a-string/expected.json +5 -0
- package/fixtures/cases/name-not-a-string/schema.yaml +5 -0
- package/fixtures/cases/one-key-two-labels/context.json +1 -0
- package/fixtures/cases/one-key-two-labels/expected.json +5 -0
- package/fixtures/cases/one-key-two-labels/schema.yaml +5 -0
- package/fixtures/cases/one-key-two-types/context.json +1 -0
- package/fixtures/cases/one-key-two-types/expected.json +5 -0
- package/fixtures/cases/one-key-two-types/schema.yaml +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/expected.json +6 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
- package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
- package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
- package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
- package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
- package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
- package/fixtures/cases/thematic-break-in-a-list-section/context.json +1 -0
- package/fixtures/cases/thematic-break-in-a-list-section/expected.json +6 -0
- package/fixtures/cases/thematic-break-in-a-list-section/library/item.md +7 -0
- package/fixtures/cases/thematic-break-in-a-list-section/schema.yaml +3 -0
- package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
- package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
- package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
- package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
- package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
- package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
- package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
- package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +4 -0
- package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +6 -0
- package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
- package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
- package/fixtures/division.json +73 -28
- package/fixtures/preamble.json +24 -3
- package/fixtures/projection.json +105 -2
- package/fixtures/queries.json +964 -0
- package/package.json +16 -2
- package/dist/blocks.d.ts +0 -11
- package/dist/blocks.d.ts.map +0 -1
- package/dist/blocks.js +0 -76
- package/dist/condition.d.ts +0 -149
- package/dist/condition.d.ts.map +0 -1
- package/dist/condition.js +0 -500
- package/dist/links.d.ts +0 -27
- package/dist/links.d.ts.map +0 -1
- package/dist/links.js +0 -774
- package/dist/profile.d.ts +0 -6
- package/dist/profile.d.ts.map +0 -1
- package/dist/profile.js +0 -5
- package/dist/sections.d.ts +0 -11
- package/dist/sections.d.ts.map +0 -1
- package/dist/sections.js +0 -57
package/dist/event.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type Definition } from './definition.js';
|
|
2
|
+
import { type Kind } from './kinds.js';
|
|
3
|
+
import type { Candidate } from './query/match.js';
|
|
4
|
+
import type { Document, VerifiedModel } from './types.js';
|
|
5
|
+
type Scalar = string | number | boolean;
|
|
6
|
+
export type Fact = {
|
|
7
|
+
readonly kind: Kind;
|
|
8
|
+
readonly value: Scalar;
|
|
9
|
+
readonly member?: string;
|
|
10
|
+
} | {
|
|
11
|
+
readonly kind: 'prose';
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'null';
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: 'unreadable';
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'list';
|
|
18
|
+
readonly items: readonly Fact[];
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'object';
|
|
21
|
+
readonly fields: Readonly<Record<string, Fact>>;
|
|
22
|
+
};
|
|
23
|
+
export type DocumentFacts = {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly type: string | null;
|
|
27
|
+
readonly fields: Readonly<Record<string, Fact>>;
|
|
28
|
+
readonly sections: readonly string[];
|
|
29
|
+
};
|
|
30
|
+
export declare const TEXT_FIELD = "/text";
|
|
31
|
+
export declare const WRITE_DOORS: readonly ['browser', 'agent', 'client', 'function'];
|
|
32
|
+
export type WriteDoor = (typeof WRITE_DOORS)[number];
|
|
33
|
+
export type Actor = {
|
|
34
|
+
readonly user?: string;
|
|
35
|
+
readonly site?: string;
|
|
36
|
+
readonly app?: string;
|
|
37
|
+
readonly door?: WriteDoor;
|
|
38
|
+
};
|
|
39
|
+
export type DocumentEvent = {
|
|
40
|
+
readonly before: DocumentFacts | null;
|
|
41
|
+
readonly after: DocumentFacts | null;
|
|
42
|
+
readonly changed: readonly string[];
|
|
43
|
+
readonly by: Actor;
|
|
44
|
+
readonly moved_between_rooms: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type ItemFacts = {
|
|
47
|
+
readonly delivery: string;
|
|
48
|
+
readonly source: string | null;
|
|
49
|
+
readonly address: string | null;
|
|
50
|
+
readonly container: string | null;
|
|
51
|
+
readonly author: string | null;
|
|
52
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
53
|
+
readonly json: {
|
|
54
|
+
readonly value: unknown;
|
|
55
|
+
} | null;
|
|
56
|
+
};
|
|
57
|
+
export type MessageFacts = {
|
|
58
|
+
readonly sender: string;
|
|
59
|
+
readonly agent_function: string | null;
|
|
60
|
+
readonly path: string | null;
|
|
61
|
+
};
|
|
62
|
+
export type Resolved = {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly member?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare function facts(document: Pick<Document, 'type' | 'fields' | 'sections'>, at: {
|
|
67
|
+
readonly id: string;
|
|
68
|
+
readonly path: string;
|
|
69
|
+
}, model: VerifiedModel, resolve: (target: string) => Resolved | undefined): DocumentFacts;
|
|
70
|
+
export declare function prosePaths(facts: DocumentFacts): string[];
|
|
71
|
+
export declare function members(document: DocumentFacts, path: string): readonly string[];
|
|
72
|
+
export declare function pointed(value: unknown, pointer: string): unknown;
|
|
73
|
+
export declare function valuedChange(definition: Definition, pointer: string): boolean;
|
|
74
|
+
export declare function datePointers(definition: Definition): string[];
|
|
75
|
+
export declare function memberPointers(definition: Definition, memberType: string): string[];
|
|
76
|
+
export declare function candidateOf(document: DocumentFacts): Candidate;
|
|
77
|
+
export {};
|
|
78
|
+
//# sourceMappingURL=event.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAoB,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,QAAQ,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,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAClD,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,QAAQ,GAAG,SAAS,GAChD,aAAa,CAgBf;AAMD,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,EAAE,CAYzD;AA4BD,wBAAgB,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAWhF;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAahE;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAS7E;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CAK7D;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAOnF;AA+BD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,CAiB9D"}
|
package/dist/event.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { ARRAY_INDEX, escapePointer, fieldFacts, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
2
|
+
import { fitsKind, kindOf } from './kinds.js';
|
|
3
|
+
import { roomPath, target } from './paths.js';
|
|
4
|
+
import { plain } from './yaml.js';
|
|
5
|
+
export const TEXT_FIELD = '/text';
|
|
6
|
+
export const WRITE_DOORS = ['browser', 'agent', 'client', 'function'];
|
|
7
|
+
const PROSE = { kind: 'prose' };
|
|
8
|
+
const NULL = { kind: 'null' };
|
|
9
|
+
const UNREADABLE = { kind: 'unreadable' };
|
|
10
|
+
function referenceFact(value, place) {
|
|
11
|
+
if (typeof value !== 'string')
|
|
12
|
+
return UNREADABLE;
|
|
13
|
+
const reached = target(place.path, value) ?? roomPath(value);
|
|
14
|
+
const resolved = reached === null ? undefined : place.resolve(reached);
|
|
15
|
+
if (resolved === undefined)
|
|
16
|
+
return UNREADABLE;
|
|
17
|
+
return resolved.member === undefined
|
|
18
|
+
? { kind: 'reference', value: resolved.id }
|
|
19
|
+
: { kind: 'reference', value: resolved.id, member: resolved.member };
|
|
20
|
+
}
|
|
21
|
+
function factOf(value, declared, place) {
|
|
22
|
+
if (value === null)
|
|
23
|
+
return NULL;
|
|
24
|
+
if (Array.isArray(value)) {
|
|
25
|
+
if (declared?.type !== undefined && declared.type !== 'array')
|
|
26
|
+
return UNREADABLE;
|
|
27
|
+
return {
|
|
28
|
+
kind: 'list',
|
|
29
|
+
items: value.map((item, index) => factOf(item, declared === undefined ? undefined : itemFacts(declared, index), place)),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (plain(value)) {
|
|
33
|
+
if (declared?.type !== undefined && declared.type !== 'object')
|
|
34
|
+
return UNREADABLE;
|
|
35
|
+
const fields = Object.create(null);
|
|
36
|
+
for (const [key, held] of Object.entries(value))
|
|
37
|
+
fields[key] = factOf(held, declared === undefined ? undefined : memberFacts(declared, key), place);
|
|
38
|
+
return { kind: 'object', fields };
|
|
39
|
+
}
|
|
40
|
+
if (declared?.type === 'array' || declared?.type === 'object')
|
|
41
|
+
return UNREADABLE;
|
|
42
|
+
const kind = declared === undefined || declared.prose ? null : kindOf(declared);
|
|
43
|
+
if (kind === null)
|
|
44
|
+
return PROSE;
|
|
45
|
+
if (kind === 'reference')
|
|
46
|
+
return referenceFact(value, place);
|
|
47
|
+
return fitsKind(kind, declared, value) ? { kind, value: value } : UNREADABLE;
|
|
48
|
+
}
|
|
49
|
+
export function facts(document, at, model, resolve) {
|
|
50
|
+
const type = document.type ?? null;
|
|
51
|
+
const definition = type !== null && Object.hasOwn(model.types, type) ? model.types[type] : null;
|
|
52
|
+
const fields = Object.create(null);
|
|
53
|
+
const place = { path: at.path, resolve };
|
|
54
|
+
for (const [name, value] of Object.entries(document.fields)) {
|
|
55
|
+
const declared = definition === null ? undefined : fieldFacts(definition, name);
|
|
56
|
+
if (declared !== undefined)
|
|
57
|
+
fields[name] = factOf(value, declared, place);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
id: at.id,
|
|
61
|
+
path: `/${at.path}`,
|
|
62
|
+
type,
|
|
63
|
+
fields,
|
|
64
|
+
sections: Object.keys(document.sections).sort(),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function rootOf(facts, prefix) {
|
|
68
|
+
return { pointer: prefix, fact: { kind: 'object', fields: facts.fields } };
|
|
69
|
+
}
|
|
70
|
+
export function prosePaths(facts) {
|
|
71
|
+
const paths = facts.sections.map((heading) => `/sections/${heading}`);
|
|
72
|
+
const visit = ({ pointer, fact }) => {
|
|
73
|
+
if (fact.kind === 'prose')
|
|
74
|
+
paths.push(pointer);
|
|
75
|
+
if (fact.kind === 'list')
|
|
76
|
+
fact.items.forEach((item, index) => visit({ pointer: `${pointer}/${index}`, fact: item }));
|
|
77
|
+
if (fact.kind === 'object')
|
|
78
|
+
for (const [key, held] of Object.entries(fact.fields))
|
|
79
|
+
visit({ pointer: `${pointer}/${escapePointer(key)}`, fact: held });
|
|
80
|
+
};
|
|
81
|
+
visit(rootOf(facts, '/fields'));
|
|
82
|
+
return paths.sort();
|
|
83
|
+
}
|
|
84
|
+
function walked(start, pointer) {
|
|
85
|
+
let reached = [start];
|
|
86
|
+
for (const token of pointerSegments(pointer)) {
|
|
87
|
+
const step = ({ pointer: at, fact }) => {
|
|
88
|
+
if (fact.kind === 'object')
|
|
89
|
+
return Object.hasOwn(fact.fields, token)
|
|
90
|
+
? [{ pointer: `${at}/${escapePointer(token)}`, fact: fact.fields[token] }]
|
|
91
|
+
: [];
|
|
92
|
+
if (fact.kind !== 'list')
|
|
93
|
+
return [];
|
|
94
|
+
if (ARRAY_INDEX.test(token)) {
|
|
95
|
+
const item = fact.items[Number(token)];
|
|
96
|
+
return item === undefined ? [] : [{ pointer: `${at}/${token}`, fact: item }];
|
|
97
|
+
}
|
|
98
|
+
return fact.items
|
|
99
|
+
.map((item, index) => ({ pointer: `${at}/${index}`, fact: item }))
|
|
100
|
+
.flatMap(step);
|
|
101
|
+
};
|
|
102
|
+
reached = reached.flatMap(step);
|
|
103
|
+
}
|
|
104
|
+
return reached;
|
|
105
|
+
}
|
|
106
|
+
function expand(fact) {
|
|
107
|
+
return fact.kind === 'list' ? fact.items.flatMap(expand) : [fact];
|
|
108
|
+
}
|
|
109
|
+
export function members(document, path) {
|
|
110
|
+
if (!path.startsWith('/members/'))
|
|
111
|
+
return [];
|
|
112
|
+
return [
|
|
113
|
+
...new Set(walked(rootOf(document, '/members'), path.slice('/members'.length))
|
|
114
|
+
.flatMap(({ fact }) => expand(fact))
|
|
115
|
+
.flatMap((fact) => fact.kind === 'reference' && fact.member !== undefined ? [fact.member] : [])),
|
|
116
|
+
].sort();
|
|
117
|
+
}
|
|
118
|
+
export function pointed(value, pointer) {
|
|
119
|
+
let reached = value;
|
|
120
|
+
for (const token of pointerSegments(pointer)) {
|
|
121
|
+
if (Array.isArray(reached)) {
|
|
122
|
+
if (!ARRAY_INDEX.test(token))
|
|
123
|
+
return undefined;
|
|
124
|
+
reached = reached[Number(token)];
|
|
125
|
+
}
|
|
126
|
+
else if (plain(reached) && Object.hasOwn(reached, token)) {
|
|
127
|
+
reached = reached[token];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return reached;
|
|
134
|
+
}
|
|
135
|
+
export function valuedChange(definition, pointer) {
|
|
136
|
+
const reached = pointerFacts(definition, pointer);
|
|
137
|
+
return (reached !== undefined &&
|
|
138
|
+
!reached.through &&
|
|
139
|
+
reached.facts.type !== 'array' &&
|
|
140
|
+
!reached.facts.prose &&
|
|
141
|
+
kindOf(reached.facts) !== null);
|
|
142
|
+
}
|
|
143
|
+
export function datePointers(definition) {
|
|
144
|
+
return Object.entries(definition.fields)
|
|
145
|
+
.filter(([, held]) => kindOf(held) === 'date')
|
|
146
|
+
.map(([name]) => `/${escapePointer(name)}`)
|
|
147
|
+
.sort();
|
|
148
|
+
}
|
|
149
|
+
export function memberPointers(definition, memberType) {
|
|
150
|
+
return Object.entries(definition.fields)
|
|
151
|
+
.filter(([, held]) => (held.type === 'array' ? held.items : held)?.reference?.includes(memberType) === true)
|
|
152
|
+
.map(([name]) => `/members/${escapePointer(name)}`);
|
|
153
|
+
}
|
|
154
|
+
function plainOf(fact) {
|
|
155
|
+
if (fact.kind === 'list')
|
|
156
|
+
return fact.items.map(plainOf);
|
|
157
|
+
if (fact.kind === 'object')
|
|
158
|
+
return Object.fromEntries(Object.entries(fact.fields).flatMap(([key, held]) => {
|
|
159
|
+
const value = plainOf(held);
|
|
160
|
+
return value === undefined ? [] : [[key, value]];
|
|
161
|
+
}));
|
|
162
|
+
if (fact.kind === 'prose')
|
|
163
|
+
return true;
|
|
164
|
+
if (fact.kind === 'null')
|
|
165
|
+
return null;
|
|
166
|
+
if (fact.kind === 'unreadable')
|
|
167
|
+
return undefined;
|
|
168
|
+
return fact.value;
|
|
169
|
+
}
|
|
170
|
+
function shapeOf(fact) {
|
|
171
|
+
if (fact.kind === 'list')
|
|
172
|
+
return { type: 'array', prose: false, prefix: fact.items.map(shapeOf) };
|
|
173
|
+
if (fact.kind === 'object')
|
|
174
|
+
return {
|
|
175
|
+
type: 'object',
|
|
176
|
+
prose: false,
|
|
177
|
+
properties: Object.fromEntries(Object.entries(fact.fields).map(([key, held]) => [key, shapeOf(held)])),
|
|
178
|
+
};
|
|
179
|
+
if (fact.kind === 'date-time')
|
|
180
|
+
return { type: 'string', format: 'date-time', prose: false };
|
|
181
|
+
return { prose: false };
|
|
182
|
+
}
|
|
183
|
+
export function candidateOf(document) {
|
|
184
|
+
const fields = {};
|
|
185
|
+
const properties = {};
|
|
186
|
+
for (const [name, fact] of Object.entries(document.fields)) {
|
|
187
|
+
const value = plainOf(fact);
|
|
188
|
+
if (value === undefined)
|
|
189
|
+
continue;
|
|
190
|
+
fields[name] = value;
|
|
191
|
+
properties[name] = shapeOf(fact);
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
path: document.path.slice(1),
|
|
195
|
+
type: document.type,
|
|
196
|
+
fileId: document.id,
|
|
197
|
+
fields,
|
|
198
|
+
definition: { frontmatter: { type: 'object', prose: false, properties } },
|
|
199
|
+
text: null,
|
|
200
|
+
};
|
|
201
|
+
}
|
package/dist/facts.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Document, ParseResult, VerifiedModel } from './types.js';
|
|
2
|
+
export type SavedFacts = {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly fields: Readonly<Record<string, unknown>>;
|
|
5
|
+
readonly links: readonly string[];
|
|
6
|
+
};
|
|
7
|
+
export type ReferenceTarget = {
|
|
8
|
+
readonly location: string;
|
|
9
|
+
readonly to: readonly string[];
|
|
10
|
+
readonly target: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function referenceTarget(file: string, value: string): string | null;
|
|
13
|
+
export declare function referenceTargets(document: Document, file: string, model: VerifiedModel): readonly ReferenceTarget[];
|
|
14
|
+
export declare function documentFacts(file: string, parsed: ParseResult, model: VerifiedModel): SavedFacts | null;
|
|
15
|
+
//# sourceMappingURL=facts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"facts.d.ts","sourceRoot":"","sources":["../src/facts.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC;AAIF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAM1E;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,aAAa,GACnB,SAAS,eAAe,EAAE,CAO5B;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,EACnB,KAAK,EAAE,aAAa,GACnB,UAAU,GAAG,IAAI,CAenB"}
|
package/dist/facts.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BUILT_IN_TYPE } from './definition.js';
|
|
2
|
+
import { links, parse } from './document.js';
|
|
3
|
+
import { target } from './paths.js';
|
|
4
|
+
import { references } from './references.js';
|
|
5
|
+
const SETTINGS_AREA = 'settings/';
|
|
6
|
+
export function referenceTarget(file, value) {
|
|
7
|
+
if (value.trim() === '' || /[<>\n\r]/.test(value))
|
|
8
|
+
return null;
|
|
9
|
+
if (!value.includes('\\'))
|
|
10
|
+
return target(file, value);
|
|
11
|
+
const parsed = parse(`[](<${value}>)\n`, file);
|
|
12
|
+
if (!parsed.ok)
|
|
13
|
+
return null;
|
|
14
|
+
return links(parsed.document, file)[0]?.target ?? null;
|
|
15
|
+
}
|
|
16
|
+
export function referenceTargets(document, file, model) {
|
|
17
|
+
const type = document.type;
|
|
18
|
+
if (type === undefined || !Object.hasOwn(model.types, type))
|
|
19
|
+
return [];
|
|
20
|
+
return references(document, model.types[type]).flatMap(({ pointer, value, to }) => {
|
|
21
|
+
const target = referenceTarget(file, value);
|
|
22
|
+
return target === null ? [] : [{ location: pointer, to, target }];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
export function documentFacts(file, parsed, model) {
|
|
26
|
+
if (!parsed.ok)
|
|
27
|
+
return null;
|
|
28
|
+
const { document } = parsed;
|
|
29
|
+
return {
|
|
30
|
+
type: document.type ?? BUILT_IN_TYPE,
|
|
31
|
+
fields: document.fields,
|
|
32
|
+
links: file.startsWith(SETTINGS_AREA)
|
|
33
|
+
? []
|
|
34
|
+
: [
|
|
35
|
+
...new Set([
|
|
36
|
+
...links(document, file).map((link) => link.target),
|
|
37
|
+
...referenceTargets(document, file, model).map(({ target }) => target),
|
|
38
|
+
]),
|
|
39
|
+
].sort(),
|
|
40
|
+
};
|
|
41
|
+
}
|
package/dist/form.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../src/form.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,OAAO,EAIb,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiKhD,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,aAAa,GAAG,OAAO,GAAG,SAAS,CAY/F"}
|
package/dist/form.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { conjoined, escapePointer, OPENING, refuse, valueFacts, variantsOf, } from './definition.js';
|
|
2
|
+
import { isRecord } from './yaml.js';
|
|
3
|
+
const LONG_TEXT = 'text/markdown';
|
|
4
|
+
const NAME_FIELD = 'name';
|
|
5
|
+
const DEEPEST_HEADING = 6;
|
|
6
|
+
function described(declared, defs) {
|
|
7
|
+
const held = [];
|
|
8
|
+
let reached = new Set();
|
|
9
|
+
let next = declared;
|
|
10
|
+
while (next.length > 0) {
|
|
11
|
+
const conjunction = conjoined(next, defs, reached);
|
|
12
|
+
const fresh = conjunction.held.filter(({ node }) => !held.some((one) => one.node === node));
|
|
13
|
+
held.push(...fresh);
|
|
14
|
+
reached = conjunction.ancestry;
|
|
15
|
+
next = fresh.flatMap(variantsOf);
|
|
16
|
+
}
|
|
17
|
+
return held;
|
|
18
|
+
}
|
|
19
|
+
function grouped(entries) {
|
|
20
|
+
const groups = new Map();
|
|
21
|
+
for (const [key, placed] of entries)
|
|
22
|
+
groups.set(key, [...(groups.get(key) ?? []), placed]);
|
|
23
|
+
return groups;
|
|
24
|
+
}
|
|
25
|
+
function keyed(held, keyword) {
|
|
26
|
+
return grouped(held.flatMap(({ node, at }) => Object.entries(isRecord(node[keyword]) ? node[keyword] : {}).flatMap(([key, schema]) => isRecord(schema)
|
|
27
|
+
? [[key, { node: schema, at: `${at}/${keyword}/${escapePointer(key)}` }]]
|
|
28
|
+
: [])));
|
|
29
|
+
}
|
|
30
|
+
function under(held, keywords) {
|
|
31
|
+
return held.flatMap(({ node, at }) => keywords.flatMap((keyword) => {
|
|
32
|
+
const schema = node[keyword];
|
|
33
|
+
return isRecord(schema) ? [{ node: schema, at: `${at}/${keyword}` }] : [];
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
function tupled(held) {
|
|
37
|
+
return [
|
|
38
|
+
...grouped(held.flatMap(({ node, at }) => (Array.isArray(node.prefixItems) ? node.prefixItems : []).flatMap((schema, index) => isRecord(schema)
|
|
39
|
+
? [[String(index), { node: schema, at: `${at}/prefixItems/${index}` }]]
|
|
40
|
+
: []))).values(),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
function titleOf(node) {
|
|
44
|
+
return typeof node.title === 'string' ? node.title : undefined;
|
|
45
|
+
}
|
|
46
|
+
function formOf(node, defs) {
|
|
47
|
+
const type = valueFacts(node, defs).type;
|
|
48
|
+
return type === 'integer' ? 'number' : type;
|
|
49
|
+
}
|
|
50
|
+
function declarationFailure(declared, defs) {
|
|
51
|
+
let title;
|
|
52
|
+
let type;
|
|
53
|
+
for (const { node, at } of declared) {
|
|
54
|
+
const titled = titleOf(node);
|
|
55
|
+
if (titled !== undefined && title !== undefined && titled !== title)
|
|
56
|
+
return refuse('conflicting-label', `${at}/title`);
|
|
57
|
+
title ??= titled;
|
|
58
|
+
const typed = formOf(node, defs);
|
|
59
|
+
if (typed !== undefined && type !== undefined && typed !== type)
|
|
60
|
+
return refuse('conflicting-type', at);
|
|
61
|
+
type ??= typed;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
function labelFailure(fields) {
|
|
66
|
+
const labels = new Set();
|
|
67
|
+
for (const [key, declared] of fields) {
|
|
68
|
+
const titled = declared.find(({ node }) => titleOf(node) !== undefined);
|
|
69
|
+
const label = titled === undefined ? key : titleOf(titled.node);
|
|
70
|
+
if (labels.has(label))
|
|
71
|
+
return refuse('duplicate-label', titled === undefined ? declared[0].at : `${titled.at}/title`);
|
|
72
|
+
labels.add(label);
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
function nameFailure(declared, defs) {
|
|
77
|
+
if (declared === undefined)
|
|
78
|
+
return undefined;
|
|
79
|
+
const typed = declared.find(({ node }) => formOf(node, defs) !== undefined);
|
|
80
|
+
return typed !== undefined && formOf(typed.node, defs) === 'string'
|
|
81
|
+
? undefined
|
|
82
|
+
: refuse('name-type', (typed ?? declared[0]).at);
|
|
83
|
+
}
|
|
84
|
+
function idOf(node, ids) {
|
|
85
|
+
const held = ids.get(node);
|
|
86
|
+
if (held !== undefined)
|
|
87
|
+
return held;
|
|
88
|
+
ids.set(node, ids.size);
|
|
89
|
+
return ids.size - 1;
|
|
90
|
+
}
|
|
91
|
+
function positionFailure(declared, depth, walk) {
|
|
92
|
+
const held = described(declared, walk.defs);
|
|
93
|
+
const ids = held.map(({ node }) => idOf(node, walk.ids)).sort((left, right) => left - right);
|
|
94
|
+
const visited = `${ids.join(',')}@${Math.min(depth, DEEPEST_HEADING)}`;
|
|
95
|
+
if (walk.seen.has(visited))
|
|
96
|
+
return undefined;
|
|
97
|
+
walk.seen.add(visited);
|
|
98
|
+
const long = held.find(({ node }) => node.contentMediaType === LONG_TEXT);
|
|
99
|
+
if (long !== undefined && depth >= DEEPEST_HEADING)
|
|
100
|
+
return refuse('heading-depth', `${long.at}/contentMediaType`);
|
|
101
|
+
const fields = keyed(held, 'properties');
|
|
102
|
+
for (const one of fields.values()) {
|
|
103
|
+
const failure = declarationFailure(one, walk.defs);
|
|
104
|
+
if (failure !== undefined)
|
|
105
|
+
return failure;
|
|
106
|
+
}
|
|
107
|
+
const failure = labelFailure(fields) ??
|
|
108
|
+
(depth === 0 ? nameFailure(fields.get(NAME_FIELD), walk.defs) : undefined);
|
|
109
|
+
if (failure !== undefined)
|
|
110
|
+
return failure;
|
|
111
|
+
const parts = [
|
|
112
|
+
...fields.values(),
|
|
113
|
+
under(held, ['items']),
|
|
114
|
+
...tupled(held),
|
|
115
|
+
under(held, OPENING),
|
|
116
|
+
...keyed(held, 'patternProperties').values(),
|
|
117
|
+
];
|
|
118
|
+
for (const part of parts) {
|
|
119
|
+
const nested = part.length === 0 ? undefined : positionFailure(part, depth + 1, walk);
|
|
120
|
+
if (nested !== undefined)
|
|
121
|
+
return nested;
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
export function formFailure(model, provided) {
|
|
126
|
+
for (const [name, definition] of Object.entries(model.types)) {
|
|
127
|
+
if (provided !== undefined && Object.hasOwn(provided.types, name))
|
|
128
|
+
continue;
|
|
129
|
+
const { schema, defs } = definition.shape;
|
|
130
|
+
const failure = positionFailure([{ node: schema, at: `/${escapePointer(name)}` }], 0, {
|
|
131
|
+
defs,
|
|
132
|
+
ids: new Map(),
|
|
133
|
+
seen: new Set(),
|
|
134
|
+
});
|
|
135
|
+
if (failure !== undefined)
|
|
136
|
+
return failure;
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type { Actor,
|
|
3
|
-
export {
|
|
4
|
-
export type {
|
|
1
|
+
export { candidateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
|
|
2
|
+
export type { Actor, DocumentEvent, DocumentFacts, Fact, ItemFacts, MessageFacts, Resolved, WriteDoor, } from './event.js';
|
|
3
|
+
export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
|
|
4
|
+
export type { Kind, Ordering } from './kinds.js';
|
|
5
|
+
export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
|
|
6
|
+
export type { Clause, Continuation, Direction, DocumentQuery, DocumentShape, Filter, GroupKey, GroupOrder, GroupQuery, GroupSelect, GroupShape, HeldRooms, Key, KeyPlan, LocalQuery, OrderOptions, Place, Predicate, QueryErrorCode, QueryPlan, Related, RoomFacts, Scope, Select, Test, Value, Where, } from './query/language.js';
|
|
7
|
+
export { heldAt, matches } from './query/match.js';
|
|
8
|
+
export type { Candidate } from './query/match.js';
|
|
9
|
+
export { heldKind, indexed } from './query/rows.js';
|
|
10
|
+
export type { HeldKind, HeldLink, HeldValue, Indexed, Reach } from './query/rows.js';
|
|
11
|
+
export * as sql from './query/sql.js';
|
|
12
|
+
export { headingLines } from './markdown.js';
|
|
13
|
+
export type { HeadingLine } from './markdown.js';
|
|
5
14
|
export { divide } from './divide.js';
|
|
6
|
-
export { apply, bodyLinks,
|
|
15
|
+
export { apply, bodyLinks, create, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
|
|
16
|
+
export { documentFacts, referenceTarget, referenceTargets } from './facts.js';
|
|
17
|
+
export type { ReferenceTarget, SavedFacts } from './facts.js';
|
|
7
18
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
8
|
-
export { relative, retarget, target } from './paths.js';
|
|
9
|
-
export {
|
|
19
|
+
export { linkedPath, relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
20
|
+
export { openPatternBudget } from './pattern.js';
|
|
21
|
+
export type { LinkedPath, RoomTarget } from './paths.js';
|
|
10
22
|
export { project } from './project.js';
|
|
11
23
|
export { references } from './references.js';
|
|
12
|
-
export {
|
|
24
|
+
export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
|
|
25
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
|
|
13
26
|
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
14
|
-
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link,
|
|
15
|
-
export { checkDocument, resolves,
|
|
27
|
+
export type { ApplyResult, BodyResult, Change, DefinitionOf, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, TypedPath, UnlinkedBody, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
|
|
28
|
+
export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
29
|
+
export type { Assessment, Verdicts } from './validate.js';
|
|
16
30
|
export { VERSION } from './version.js';
|
|
17
|
-
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
|
31
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
|
|
18
32
|
export type { FrontmatterValue } from './yaml.js';
|
|
19
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,YAAY,EACZ,KAAK,EACL,cAAc,EACd,OAAO,EACP,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,KAAK,EACL,aAAa,EACb,aAAa,EACb,IAAI,EACJ,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,WAAW,EACX,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,UAAU,EACV,MAAM,EACN,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,UAAU,EACV,OAAO,EACP,KAAK,EACL,SAAS,EACT,MAAM,EACN,UAAU,EACV,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,MAAM,EACN,YAAY,EACZ,SAAS,EACT,aAAa,EACb,aAAa,EACb,MAAM,EACN,QAAQ,EACR,UAAU,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,SAAS,EACT,GAAG,EACH,OAAO,EACP,UAAU,EACV,YAAY,EACZ,KAAK,EACL,SAAS,EACT,cAAc,EACd,SAAS,EACT,OAAO,EACP,SAAS,EACT,KAAK,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,KAAK,GACN,MAAM,qBAA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idateOf, datePointers, facts, memberPointers, members, pointed, prosePaths, TEXT_FIELD, valuedChange, WRITE_DOORS, } from './event.js';
|
|
2
|
+
export { byCodePoint, compared, dated, fitsKind, instant, instantKey, kindOf, kindWords, } from './kinds.js';
|
|
3
|
+
export { bodied, cursorOf, decodedCursor, identityOf, invalid, known, placeText, planOf, QueryError, queryKey, } from './query/language.js';
|
|
4
|
+
export { heldAt, matches } from './query/match.js';
|
|
5
|
+
export { heldKind, indexed } from './query/rows.js';
|
|
6
|
+
export * as sql from './query/sql.js';
|
|
7
|
+
export { headingLines } from './markdown.js';
|
|
3
8
|
export { divide } from './divide.js';
|
|
4
|
-
export { apply, bodyLinks,
|
|
9
|
+
export { apply, bodyLinks, create, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, textSpans, unlinkBody, } from './document.js';
|
|
10
|
+
export { documentFacts, referenceTarget, referenceTargets } from './facts.js';
|
|
5
11
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
6
|
-
export { relative, retarget, target } from './paths.js';
|
|
7
|
-
export {
|
|
12
|
+
export { linkedPath, relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
13
|
+
export { openPatternBudget } from './pattern.js';
|
|
8
14
|
export { project } from './project.js';
|
|
9
15
|
export { references } from './references.js';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
16
|
+
export { CAPTURE_HOME, isDocumentPath, isReservedName, RESERVED_NAMES, ROOM_DESCRIPTION, } from './reserved.js';
|
|
17
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, untitled, } from './definition.js';
|
|
18
|
+
export { assess, assessReferences, bodyRoomLinks, checkDocument, definitionAt, readTypes, resolves, roomReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
12
19
|
export { VERSION } from './version.js';
|
|
13
|
-
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
|
20
|
+
export { bodyAfterFrontmatter, equalValue, frontmatterValue, plain } from './yaml.js';
|
package/dist/kinds.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ValueFacts } from './definition.js';
|
|
2
|
+
export type Kind = 'string' | 'number' | 'integer' | 'boolean' | 'date' | 'date-time' | 'time' | 'enum' | 'reference';
|
|
3
|
+
export type Ordering = {
|
|
4
|
+
readonly direction: 'asc' | 'desc';
|
|
5
|
+
readonly nulls: 'first' | 'last';
|
|
6
|
+
readonly stringSort: 'lexical' | 'locale';
|
|
7
|
+
readonly locale: string | undefined;
|
|
8
|
+
readonly localeOptions: Intl.CollatorOptions | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare function kindOf(facts: ValueFacts): Kind | null;
|
|
11
|
+
export declare function fitsKind(kind: Kind, facts: ValueFacts, value: unknown): boolean;
|
|
12
|
+
export declare function kindWords(facts: ValueFacts | undefined): readonly string[];
|
|
13
|
+
export declare function dated(value: unknown): value is string;
|
|
14
|
+
export declare function instant(value: unknown): bigint | undefined;
|
|
15
|
+
export declare function instantKey(value: unknown): string | null;
|
|
16
|
+
export declare function byCodePoint(left: string, right: string): number;
|
|
17
|
+
export declare function compared(left: unknown, right: unknown, ordering: Ordering): number;
|
|
18
|
+
//# sourceMappingURL=kinds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,MAAM,MAAM,IAAI,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,SAAS,GACT,MAAM,GACN,WAAW,GACX,MAAM,GACN,MAAM,GACN,WAAW,CAAC;AAEhB,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;IACnC,QAAQ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