@agentshouse/mdmodel 0.1.0-cf5ccc9c47590 → 0.1.0-cf77876799aa0
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 +75 -65
- package/dist/condition.d.ts +15 -2
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +158 -51
- package/dist/definition.d.ts +2 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +35 -8
- package/dist/divide.js +9 -9
- package/dist/document.d.ts +4 -4
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +28 -30
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/links.d.ts +1 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +43 -28
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +3 -5
- package/dist/types.d.ts +8 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +25 -4
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +135 -65
- package/fixtures/README.md +5 -4
- package/fixtures/division.json +26 -26
- package/package.json +1 -1
package/dist/definition.js
CHANGED
|
@@ -24,9 +24,12 @@ const ANNOTATIONS = new Set([
|
|
|
24
24
|
'writeOnly',
|
|
25
25
|
]);
|
|
26
26
|
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
27
|
+
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
28
|
+
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
27
29
|
const DEFS_REFERENCE = '#/$defs/';
|
|
28
30
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
29
31
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
32
|
+
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
30
33
|
const HOUSE_KEYS = {
|
|
31
34
|
[TYPE_FIELD]: { prose: false },
|
|
32
35
|
[SITE_FIELD]: { prose: false },
|
|
@@ -45,12 +48,12 @@ export function pointerSegments(pointer) {
|
|
|
45
48
|
return pointer.split('/').slice(1).map(unescapePointer);
|
|
46
49
|
}
|
|
47
50
|
export function refTarget(reference, defs) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (segments.some((segment) => escapePointer(unescapePointer(segment)) !== segment))
|
|
51
|
+
const pointer = reference.slice('#'.length);
|
|
52
|
+
if (!reference.startsWith(DEFS_REFERENCE) ||
|
|
53
|
+
UNRESOLVED.test(reference) ||
|
|
54
|
+
!JSON_POINTER.test(pointer))
|
|
53
55
|
return undefined;
|
|
56
|
+
const [, name = '', ...rest] = pointerSegments(pointer);
|
|
54
57
|
if (!Object.hasOwn(defs, name))
|
|
55
58
|
return undefined;
|
|
56
59
|
let node = defs[name];
|
|
@@ -657,6 +660,24 @@ function unruled(schema) {
|
|
|
657
660
|
}
|
|
658
661
|
return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
|
|
659
662
|
}
|
|
663
|
+
function providedType(name, value, provided) {
|
|
664
|
+
const at = `/${escapePointer(name)}`;
|
|
665
|
+
if (!isRecord(value))
|
|
666
|
+
return refuse('schema', at);
|
|
667
|
+
const declared = Object.keys(value).find((key) => !PROVIDED_KEYWORDS.includes(key));
|
|
668
|
+
if (declared !== undefined)
|
|
669
|
+
return refuse('provided-type', `${at}/${escapePointer(declared)}`);
|
|
670
|
+
const { create_roles: createRoles, delete_roles: deleteRoles } = value;
|
|
671
|
+
if (createRoles !== undefined && !roleNames(createRoles))
|
|
672
|
+
return refuse('create_roles', `${at}/create_roles`);
|
|
673
|
+
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
674
|
+
return refuse('delete_roles', `${at}/delete_roles`);
|
|
675
|
+
return {
|
|
676
|
+
...provided,
|
|
677
|
+
...(createRoles === undefined ? {} : { createRoles }),
|
|
678
|
+
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
679
|
+
};
|
|
680
|
+
}
|
|
660
681
|
function readType(name, value, context) {
|
|
661
682
|
const at = `/${escapePointer(name)}`;
|
|
662
683
|
if (!isRecord(value))
|
|
@@ -712,7 +733,7 @@ function readType(name, value, context) {
|
|
|
712
733
|
function lineAt(text, offset) {
|
|
713
734
|
return text.slice(0, offset).split(/\r\n|\r|\n/).length;
|
|
714
735
|
}
|
|
715
|
-
export function readSchema(text) {
|
|
736
|
+
export function readSchema(text, provided = NO_TYPES) {
|
|
716
737
|
let root;
|
|
717
738
|
try {
|
|
718
739
|
root = jsValue(parseYamlMapping(text, 0, text.length));
|
|
@@ -730,7 +751,7 @@ export function readSchema(text) {
|
|
|
730
751
|
if (name === '' || name.startsWith('$') || name === BUILT_IN_TYPE || name === ATTACHMENT)
|
|
731
752
|
return refuse('schema-type-name', `/${escapePointer(name)}`);
|
|
732
753
|
}
|
|
733
|
-
const context = { defs, types: new Set(names) };
|
|
754
|
+
const context = { defs, types: new Set([...names, ...Object.keys(provided.types)]) };
|
|
734
755
|
for (const [name, def] of Object.entries(defs)) {
|
|
735
756
|
const failure = schemaFailure(def, `/$defs/${escapePointer(name)}`, context);
|
|
736
757
|
if (failure !== undefined)
|
|
@@ -739,7 +760,9 @@ export function readSchema(text) {
|
|
|
739
760
|
const types = Object.create(null);
|
|
740
761
|
let marked = false;
|
|
741
762
|
for (const name of names) {
|
|
742
|
-
const definition =
|
|
763
|
+
const definition = Object.hasOwn(provided.types, name)
|
|
764
|
+
? providedType(name, root[name], provided.types[name])
|
|
765
|
+
: readType(name, root[name], context);
|
|
743
766
|
if ('rule' in definition)
|
|
744
767
|
return definition;
|
|
745
768
|
if (definition.memberDocument) {
|
|
@@ -749,5 +772,9 @@ export function readSchema(text) {
|
|
|
749
772
|
}
|
|
750
773
|
types[name] = deepFreeze(definition);
|
|
751
774
|
}
|
|
775
|
+
for (const [name, definition] of Object.entries(provided.types)) {
|
|
776
|
+
if (!Object.hasOwn(types, name))
|
|
777
|
+
types[name] = definition;
|
|
778
|
+
}
|
|
752
779
|
return Object.freeze({ types: Object.freeze(types) });
|
|
753
780
|
}
|
package/dist/divide.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blockRanges, headingLines } from './blocks.js';
|
|
2
2
|
import { firstEditFrom, projectionInput, rangeText, } from './project.js';
|
|
3
3
|
import { refusal } from './refuse.js';
|
|
4
|
-
const
|
|
4
|
+
const SMALLEST_BOUND = 2;
|
|
5
5
|
function node(draft) {
|
|
6
6
|
return {
|
|
7
7
|
start: draft.start,
|
|
@@ -86,8 +86,8 @@ function isTrailingSurrogate(text, index) {
|
|
|
86
86
|
function characterLength(text, index) {
|
|
87
87
|
return isTrailingSurrogate(text, index + 1) ? 2 : 1;
|
|
88
88
|
}
|
|
89
|
-
function boundOf(cutting, from, to,
|
|
90
|
-
const limit = from +
|
|
89
|
+
function boundOf(cutting, from, to, bound) {
|
|
90
|
+
const limit = from + bound;
|
|
91
91
|
if (limit >= to)
|
|
92
92
|
return to;
|
|
93
93
|
for (let index = limit; index > from + 1; index -= 1) {
|
|
@@ -168,12 +168,12 @@ function valueCutting(value) {
|
|
|
168
168
|
};
|
|
169
169
|
}
|
|
170
170
|
function prefixOf(state, body) {
|
|
171
|
-
if (body.emitted === 0 || body.heading.length >= state.
|
|
171
|
+
if (body.emitted === 0 || body.heading.length >= state.bound)
|
|
172
172
|
return '';
|
|
173
173
|
return body.heading;
|
|
174
174
|
}
|
|
175
175
|
function available(state, body) {
|
|
176
|
-
return state.
|
|
176
|
+
return state.bound - prefixOf(state, body).length;
|
|
177
177
|
}
|
|
178
178
|
function emit(state, body, piece, bare = false) {
|
|
179
179
|
if (piece.text.trim() === '')
|
|
@@ -216,7 +216,7 @@ function divideBound(state, body, cutting, range) {
|
|
|
216
216
|
let start = range.start;
|
|
217
217
|
while (start < range.end) {
|
|
218
218
|
const bare = available(state, body) < characterLength(cutting.text, start);
|
|
219
|
-
const room = bare ? state.
|
|
219
|
+
const room = bare ? state.bound : available(state, body);
|
|
220
220
|
const stop = boundOf(cutting, start, range.end, room);
|
|
221
221
|
const piece = cutting.piece(start, stop);
|
|
222
222
|
if (cutting.masks.length === 0 || piece.text.length <= room) {
|
|
@@ -303,8 +303,8 @@ function divideInput(state, input) {
|
|
|
303
303
|
]);
|
|
304
304
|
}
|
|
305
305
|
export function divide(document, file, context) {
|
|
306
|
-
if (!Number.isInteger(context.
|
|
307
|
-
return { ok: false, refusal: refusal(file, 'division-
|
|
306
|
+
if (!Number.isInteger(context.bound) || context.bound < SMALLEST_BOUND) {
|
|
307
|
+
return { ok: false, refusal: refusal(file, 'division-bound') };
|
|
308
308
|
}
|
|
309
309
|
const result = projectionInput(document, file, context);
|
|
310
310
|
if (!result.ok)
|
|
@@ -312,7 +312,7 @@ export function divide(document, file, context) {
|
|
|
312
312
|
const state = {
|
|
313
313
|
content: document.content,
|
|
314
314
|
edits: result.input.edits,
|
|
315
|
-
|
|
315
|
+
bound: context.bound,
|
|
316
316
|
spans: [],
|
|
317
317
|
};
|
|
318
318
|
divideInput(state, result.input);
|
package/dist/document.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { type Definition } from './definition.js';
|
|
2
|
-
import
|
|
2
|
+
import { type LinkInventory } from './links.js';
|
|
3
|
+
import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, ParseResult } from './types.js';
|
|
3
4
|
import { type YamlMap } from './yaml.js';
|
|
5
|
+
export declare function inventoryOf(document: Document): LinkInventory;
|
|
4
6
|
export declare function parseFrontmatter(content: string, file?: string): FrontmatterResult;
|
|
5
7
|
export declare function parse(content: string, file?: string): ParseResult;
|
|
6
|
-
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition): ApplyResult;
|
|
8
|
+
export declare function relativize(document: Document, file: string, handle: string, definition?: Definition, kept?: ReadonlySet<string>): ApplyResult;
|
|
7
9
|
export declare function relativizeBody(body: string, file: string, handle: string): BodyResult;
|
|
8
10
|
export declare function relinkBody(body: string, file: string, moves: ReadonlyMap<string, string>): BodyResult;
|
|
9
11
|
export declare function links(document: Document, file: string): readonly Link[];
|
|
10
|
-
export declare function linkOccurrences(document: Document, file: string): readonly LinkOccurrence[];
|
|
11
12
|
export declare function bodyLinks(body: string, file: string): readonly Link[];
|
|
12
13
|
export declare function apply(document: Document, changes: readonly Change[]): ApplyResult;
|
|
13
14
|
export declare function serialize(document: Document): string;
|
|
14
|
-
export declare function fieldStart(document: Document, pointer: string): number | undefined;
|
|
15
15
|
export declare function frontmatter(document: Document): YamlMap | null;
|
|
16
16
|
//# sourceMappingURL=document.d.ts.map
|
package/dist/document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../src/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,YAAY,CAAC;AAcpB,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAcL,KAAK,OAAO,EAEb,MAAM,WAAW,CAAC;AAYnB,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAM7D;AA2DD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,iBAAiB,CAW9E;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,WAAW,CAgB7D;AAmED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,UAAU,EACvB,IAAI,GAAE,WAAW,CAAC,MAAM,CAAa,GACpC,WAAW,CAuBb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAUrF;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,UAAU,CAkBZ;AAeD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAEvE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,IAAI,EAAE,CAErE;AA4LD,wBAAgB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CA4CjF;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAEpD;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAE9D"}
|
package/dist/document.js
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import { ARRAY_INDEX, pointerSegments } from './definition.js';
|
|
2
|
-
import { hrefOccurrences } from './links.js';
|
|
2
|
+
import { destinations, hrefOccurrences, linkInventory, } from './links.js';
|
|
3
3
|
import { destinationPath, relative, retarget, roomPath, roomTarget, SHELL_ROOMS, shellTarget, target, } from './paths.js';
|
|
4
4
|
import { references } from './references.js';
|
|
5
5
|
import { headingSpans, sectionsRecord } from './sections.js';
|
|
6
6
|
import { refusal } from './refuse.js';
|
|
7
7
|
import { bodyStartAfterYaml, bodyStartOf, equalValue, extractFrontmatter, frontmatterValue, jsValue, lineEnding, mapEntry, parseYamlMapping, serializeJs, serializeKey, YamlError, } from './yaml.js';
|
|
8
8
|
const internals = new WeakMap();
|
|
9
|
+
const inventories = new WeakMap();
|
|
10
|
+
export function inventoryOf(document) {
|
|
11
|
+
const held = inventories.get(document);
|
|
12
|
+
if (held !== undefined)
|
|
13
|
+
return held;
|
|
14
|
+
const inventory = linkInventory(document.content.slice(bodyStartOf(document.content)));
|
|
15
|
+
inventories.set(document, inventory);
|
|
16
|
+
return inventory;
|
|
17
|
+
}
|
|
9
18
|
function refuse(file, rule, location) {
|
|
10
19
|
return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });
|
|
11
20
|
}
|
|
@@ -141,12 +150,16 @@ function scalarText(source, value) {
|
|
|
141
150
|
return JSON.stringify(value);
|
|
142
151
|
return serializeJs(value);
|
|
143
152
|
}
|
|
144
|
-
export function relativize(document, file, handle, definition) {
|
|
153
|
+
export function relativize(document, file, handle, definition, kept = new Set()) {
|
|
154
|
+
const relativized = (href) => {
|
|
155
|
+
const path = shellTarget(href, handle);
|
|
156
|
+
return path === null || kept.has(`${SHELL_ROOMS}${handle}/${path}`) ? null : path;
|
|
157
|
+
};
|
|
145
158
|
const changes = [];
|
|
146
159
|
for (const { pointer, value } of definition === undefined
|
|
147
160
|
? []
|
|
148
161
|
: references(document, definition)) {
|
|
149
|
-
const path =
|
|
162
|
+
const path = relativized(value);
|
|
150
163
|
if (path !== null)
|
|
151
164
|
changes.push({
|
|
152
165
|
kind: 'reference',
|
|
@@ -155,9 +168,8 @@ export function relativize(document, file, handle, definition) {
|
|
|
155
168
|
prior: value,
|
|
156
169
|
});
|
|
157
170
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
const path = shellTarget(href, handle);
|
|
171
|
+
for (const href of new Set(destinations(inventoryOf(document)).map(({ href }) => href))) {
|
|
172
|
+
const path = relativized(href);
|
|
161
173
|
if (path !== null)
|
|
162
174
|
changes.push({ kind: 'link', href, to: relative(file, path) });
|
|
163
175
|
}
|
|
@@ -180,7 +192,7 @@ export function relinkBody(body, file, moves) {
|
|
|
180
192
|
const to = from === null ? undefined : moves.get(from);
|
|
181
193
|
if (to === undefined)
|
|
182
194
|
continue;
|
|
183
|
-
const written = retarget(match.href, from.startsWith(SHELL_ROOMS) ? to : relative(file, to));
|
|
195
|
+
const written = retarget(match.href, from.startsWith(SHELL_ROOMS) || to.startsWith(SHELL_ROOMS) ? to : relative(file, to));
|
|
184
196
|
const text = destinationText(written, match.bracketed);
|
|
185
197
|
if (text === null)
|
|
186
198
|
return { outcome: 'refuse', refusal: refuse(file, 'unwritable-link', written) };
|
|
@@ -189,35 +201,25 @@ export function relinkBody(body, file, moves) {
|
|
|
189
201
|
}
|
|
190
202
|
return { outcome: 'applied', body: rewritten + body.slice(cursor) };
|
|
191
203
|
}
|
|
192
|
-
function
|
|
193
|
-
const found = [];
|
|
194
|
-
for (const occurrence of hrefOccurrences(text)) {
|
|
195
|
-
const resolved = target(file, occurrence.href);
|
|
196
|
-
if (resolved !== null)
|
|
197
|
-
found.push({ href: occurrence.href, target: resolved, start: offset + occurrence.start });
|
|
198
|
-
}
|
|
199
|
-
return found;
|
|
200
|
-
}
|
|
201
|
-
function linksIn(text, file) {
|
|
204
|
+
function linksIn(occurrences, file) {
|
|
202
205
|
const found = [];
|
|
203
206
|
const seen = new Set();
|
|
204
|
-
for (const occurrence of
|
|
207
|
+
for (const occurrence of occurrences) {
|
|
205
208
|
if (seen.has(occurrence.href))
|
|
206
209
|
continue;
|
|
210
|
+
const resolved = target(file, occurrence.href);
|
|
211
|
+
if (resolved === null)
|
|
212
|
+
continue;
|
|
207
213
|
seen.add(occurrence.href);
|
|
208
|
-
found.push({ href: occurrence.href, target:
|
|
214
|
+
found.push({ href: occurrence.href, target: resolved });
|
|
209
215
|
}
|
|
210
216
|
return found;
|
|
211
217
|
}
|
|
212
218
|
export function links(document, file) {
|
|
213
|
-
return linksIn(
|
|
214
|
-
}
|
|
215
|
-
export function linkOccurrences(document, file) {
|
|
216
|
-
const bodyStart = bodyStartOf(document.content);
|
|
217
|
-
return occurrencesIn(document.content.slice(bodyStart), file, bodyStart);
|
|
219
|
+
return linksIn(destinations(inventoryOf(document)), file);
|
|
218
220
|
}
|
|
219
221
|
export function bodyLinks(body, file) {
|
|
220
|
-
return linksIn(body, file);
|
|
222
|
+
return linksIn(hrefOccurrences(body), file);
|
|
221
223
|
}
|
|
222
224
|
function internalOf(document) {
|
|
223
225
|
const held = internals.get(document);
|
|
@@ -303,7 +305,7 @@ function planner(document, internal) {
|
|
|
303
305
|
const link = (href, to, at) => {
|
|
304
306
|
if (occurrences === undefined) {
|
|
305
307
|
occurrences = new Map();
|
|
306
|
-
for (const occurrence of
|
|
308
|
+
for (const occurrence of destinations(inventoryOf(document))) {
|
|
307
309
|
const same = occurrences.get(occurrence.href);
|
|
308
310
|
if (same === undefined)
|
|
309
311
|
occurrences.set(occurrence.href, [occurrence]);
|
|
@@ -458,10 +460,6 @@ export function apply(document, changes) {
|
|
|
458
460
|
export function serialize(document) {
|
|
459
461
|
return document.content;
|
|
460
462
|
}
|
|
461
|
-
export function fieldStart(document, pointer) {
|
|
462
|
-
const root = internals.get(document)?.root;
|
|
463
|
-
return root === null || root === undefined ? undefined : nodeAt(root, pointer)?.start;
|
|
464
|
-
}
|
|
465
463
|
export function frontmatter(document) {
|
|
466
464
|
return internals.get(document)?.root ?? null;
|
|
467
465
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, members, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
2
|
-
export type { Actor, Condition, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
|
|
1
|
+
export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, dated, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, instant, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, pointed, prosePaths, testOperators, valuedChange, WRITE_DOORS, } from './condition.js';
|
|
2
|
+
export type { Actor, Condition, ConditionOperator, ConditionScope, ConditionTest, ConditionValue, CronCondition, DateCondition, DocumentCondition, DocumentEvent, DocumentFacts, Fact, FactKind, ItemCondition, ItemFacts, Resolved, WriteDoor, } from './condition.js';
|
|
3
3
|
export { headingLines } from './blocks.js';
|
|
4
4
|
export type { HeadingLine } from './blocks.js';
|
|
5
5
|
export { divide } from './divide.js';
|
|
6
|
-
export { apply, bodyLinks,
|
|
6
|
+
export { apply, bodyLinks, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
7
7
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
8
8
|
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
9
9
|
export type { RoomTarget } from './paths.js';
|
|
10
10
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
11
11
|
export { project } from './project.js';
|
|
12
12
|
export { references } from './references.js';
|
|
13
|
-
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
13
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
14
14
|
export type { Definition, FieldRules, JsonType, PatternFacts, PointerFacts, RuleValue, SectionSpec, Shape, Transition, ValueFacts, } from './definition.js';
|
|
15
|
-
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link,
|
|
16
|
-
export { bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verify, } from './validate.js';
|
|
15
|
+
export type { ApplyResult, BodyResult, Change, Division, DivisionContext, Document, DocumentCheck, Frontmatter, FrontmatterResult, Library, ModelVerification, Link, ParseResult, Projection, ProjectionContext, Reached, Reference, Refusal, RoomReference, Span, Validation, ValidationContext, ValidationStep, VerifiedModel, } from './types.js';
|
|
16
|
+
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
17
|
+
export type { Assessment, Verdicts } from './validate.js';
|
|
17
18
|
export { VERSION } from './version.js';
|
|
18
19
|
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
|
19
20
|
export type { FrontmatterValue } from './yaml.js';
|
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,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,KAAK,EACL,SAAS,EACT,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,QAAQ,EACR,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EACL,KAAK,EACL,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,mB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Y,EACZ,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,UAAU,EACV,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,EACL,UAAU,EACV,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,EACX,UAAU,EACV,MAAM,EACN,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,iBAAiB,EACjB,IAAI,EACJ,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,OAAO,EACP,aAAa,EACb,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,MAAM,EACN,aAAa,EACb,aAAa,EACb,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export { dated, datePointers, factKind, facts, fires, holds, instant, itemFires, members, pointed, prosePaths, WRITE_DOORS, } from './condition.js';
|
|
1
|
+
export { ACTOR_PATHS, actorOperators, changeFields, CONDITION_OPERATORS, dated, datePointers, DOCUMENT_PATHS, factKind, facts, fires, holds, instant, ITEM_PATHS, itemFires, itemKind, itemOperators, memberPointers, members, pointed, prosePaths, testOperators, valuedChange, WRITE_DOORS, } from './condition.js';
|
|
2
2
|
export { headingLines } from './blocks.js';
|
|
3
3
|
export { divide } from './divide.js';
|
|
4
|
-
export { apply, bodyLinks,
|
|
4
|
+
export { apply, bodyLinks, links, parse, parseFrontmatter, relativize, relativizeBody, relinkBody, serialize, } from './document.js';
|
|
5
5
|
export { HOUSE_FIELDS, MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
6
6
|
export { relative, retarget, roomPath, roomTarget, target } from './paths.js';
|
|
7
7
|
export { MARKDOWN_SYNTAX_PROFILE } from './profile.js';
|
|
8
8
|
export { project } from './project.js';
|
|
9
9
|
export { references } from './references.js';
|
|
10
|
-
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
|
-
export { bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verify, } from './validate.js';
|
|
10
|
+
export { ARRAY_INDEX, ATTACHMENT, crossedFacts, escapePointer, itemFacts, JSON_POINTER, memberFacts, pointerFacts, pointerSegments, } from './definition.js';
|
|
11
|
+
export { assess, bodyRoomLinks, checkDocument, resolves, roomReferences, sectionReferences, validate, validating, verdicts, verify, } from './validate.js';
|
|
12
12
|
export { VERSION } from './version.js';
|
|
13
13
|
export { bodyAfterFrontmatter, equalValue, frontmatterValue } from './yaml.js';
|
package/dist/links.d.ts
CHANGED
|
@@ -24,5 +24,6 @@ export type LinkInventory = {
|
|
|
24
24
|
};
|
|
25
25
|
export declare function fenceSpans(text: string): readonly (readonly [number, number])[];
|
|
26
26
|
export declare function linkInventory(body: string): LinkInventory;
|
|
27
|
+
export declare function destinations(inventory: LinkInventory): readonly HrefOccurrence[];
|
|
27
28
|
export declare function hrefOccurrences(body: string): readonly HrefOccurrence[];
|
|
28
29
|
//# sourceMappingURL=links.d.ts.map
|
package/dist/links.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.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AS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAe/E;AAaD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAoEzD;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,cAAc,EAAE,CAIhF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,cAAc,EAAE,CAEvE"}
|
package/dist/links.js
CHANGED
|
@@ -27,6 +27,15 @@ const INLINE_RAW = new RegExp([
|
|
|
27
27
|
'<[A-Za-z][A-Za-z0-9+.-]{1,31}:[^\\x00-\\x20<>]*>',
|
|
28
28
|
"<[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*>",
|
|
29
29
|
].join('|'), 'y');
|
|
30
|
+
const BACKSLASH = 0x5c;
|
|
31
|
+
const BACKTICK = 0x60;
|
|
32
|
+
const LINE_FEED = 0x0a;
|
|
33
|
+
const CARRIAGE_RETURN = 0x0d;
|
|
34
|
+
const LESS_THAN = 0x3c;
|
|
35
|
+
const OPEN_BRACKET = 0x5b;
|
|
36
|
+
const CLOSE_BRACKET = 0x5d;
|
|
37
|
+
const EXCLAMATION = 0x21;
|
|
38
|
+
const OPEN_PAREN = 0x28;
|
|
30
39
|
const DELIMITER_ROW = /^\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
|
|
31
40
|
const GAP = /^[ \t\v\f]+/;
|
|
32
41
|
function endOfLine(text, from) {
|
|
@@ -164,10 +173,10 @@ function skipInlineCode(text, index, joins, unclosed) {
|
|
|
164
173
|
const runs = new Map();
|
|
165
174
|
let i = index + ticks;
|
|
166
175
|
while (i < text.length) {
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
176
|
+
const code = text.charCodeAt(i);
|
|
177
|
+
if (code === BACKTICK) {
|
|
169
178
|
let run = 0;
|
|
170
|
-
while (text
|
|
179
|
+
while (text.charCodeAt(i + run) === BACKTICK)
|
|
171
180
|
run += 1;
|
|
172
181
|
if (run === ticks)
|
|
173
182
|
return i + run;
|
|
@@ -175,9 +184,9 @@ function skipInlineCode(text, index, joins, unclosed) {
|
|
|
175
184
|
i += run;
|
|
176
185
|
continue;
|
|
177
186
|
}
|
|
178
|
-
if (
|
|
187
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
179
188
|
break;
|
|
180
|
-
if (
|
|
189
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
181
190
|
break;
|
|
182
191
|
i += 1;
|
|
183
192
|
}
|
|
@@ -200,21 +209,21 @@ function skipInlineSpace(text, start, joins) {
|
|
|
200
209
|
return afterIndent(text, readLine(text, i + 1, endOfLine(text, i + 1)));
|
|
201
210
|
}
|
|
202
211
|
function closeEnd(text, start, open, joins) {
|
|
203
|
-
const close = open === '(' ? ')' : open;
|
|
212
|
+
const close = (open === '(' ? ')' : open).charCodeAt(0);
|
|
204
213
|
let i = start;
|
|
205
214
|
while (i < text.length) {
|
|
206
|
-
const
|
|
215
|
+
const code = text.charCodeAt(i);
|
|
207
216
|
if (escapes(text, i)) {
|
|
208
217
|
i += 2;
|
|
209
218
|
continue;
|
|
210
219
|
}
|
|
211
|
-
if (
|
|
220
|
+
if (code === close)
|
|
212
221
|
return i + 1;
|
|
213
|
-
if (open === '(' &&
|
|
222
|
+
if (open === '(' && code === OPEN_PAREN)
|
|
214
223
|
return null;
|
|
215
|
-
if (
|
|
224
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
216
225
|
return null;
|
|
217
|
-
if (
|
|
226
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
218
227
|
return null;
|
|
219
228
|
i += 1;
|
|
220
229
|
}
|
|
@@ -511,23 +520,23 @@ function structure(text) {
|
|
|
511
520
|
return { joins, raw };
|
|
512
521
|
}
|
|
513
522
|
export function escapes(text, index) {
|
|
514
|
-
return text
|
|
523
|
+
return text.charCodeAt(index) === BACKSLASH && PUNCTUATION.test(text[index + 1] ?? '');
|
|
515
524
|
}
|
|
516
525
|
function referenceEnd(text, start, joins) {
|
|
517
526
|
let i = start;
|
|
518
527
|
while (i < text.length) {
|
|
519
|
-
const
|
|
528
|
+
const code = text.charCodeAt(i);
|
|
520
529
|
if (escapes(text, i)) {
|
|
521
530
|
i += 2;
|
|
522
531
|
continue;
|
|
523
532
|
}
|
|
524
|
-
if (
|
|
533
|
+
if (code === CLOSE_BRACKET)
|
|
525
534
|
return i + 1;
|
|
526
|
-
if (
|
|
535
|
+
if (code === OPEN_BRACKET)
|
|
527
536
|
return -1;
|
|
528
|
-
if (
|
|
537
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
529
538
|
return -1;
|
|
530
|
-
if (
|
|
539
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
531
540
|
return -1;
|
|
532
541
|
i += 1;
|
|
533
542
|
}
|
|
@@ -702,9 +711,10 @@ export function fenceSpans(text) {
|
|
|
702
711
|
function paragraphEnd(text, from, joins) {
|
|
703
712
|
let i = from;
|
|
704
713
|
while (i < text.length) {
|
|
705
|
-
|
|
714
|
+
const code = text.charCodeAt(i);
|
|
715
|
+
if (code === LINE_FEED && !joins.has(i))
|
|
706
716
|
return i;
|
|
707
|
-
if (
|
|
717
|
+
if (code === CARRIAGE_RETURN && text.charCodeAt(i + 1) !== LINE_FEED)
|
|
708
718
|
return i;
|
|
709
719
|
i += 1;
|
|
710
720
|
}
|
|
@@ -726,16 +736,16 @@ export function linkInventory(body) {
|
|
|
726
736
|
i = skipEnd;
|
|
727
737
|
continue;
|
|
728
738
|
}
|
|
729
|
-
const
|
|
739
|
+
const code = body.charCodeAt(i);
|
|
730
740
|
if (escapes(body, i)) {
|
|
731
741
|
i += 2;
|
|
732
742
|
continue;
|
|
733
743
|
}
|
|
734
|
-
if (
|
|
744
|
+
if (code === BACKTICK) {
|
|
735
745
|
i = skipInlineCode(body, i, joins, unclosed);
|
|
736
746
|
continue;
|
|
737
747
|
}
|
|
738
|
-
if (
|
|
748
|
+
if (code === LESS_THAN) {
|
|
739
749
|
if (i >= paragraph.end) {
|
|
740
750
|
const end = paragraphEnd(body, i, joins);
|
|
741
751
|
paragraph = { start: i, end, text: body.slice(i, end) };
|
|
@@ -747,18 +757,20 @@ export function linkInventory(body) {
|
|
|
747
757
|
continue;
|
|
748
758
|
}
|
|
749
759
|
}
|
|
750
|
-
if ((
|
|
760
|
+
if ((code === LINE_FEED && !joins.has(i)) ||
|
|
761
|
+
(code === CARRIAGE_RETURN && body.charCodeAt(i + 1) !== LINE_FEED))
|
|
751
762
|
openers.length = 0;
|
|
752
|
-
if (
|
|
763
|
+
if (code === OPEN_BRACKET ||
|
|
764
|
+
(code === EXCLAMATION && body.charCodeAt(i + 1) === OPEN_BRACKET)) {
|
|
753
765
|
const previous = openers.at(-1);
|
|
754
766
|
if (previous !== undefined)
|
|
755
767
|
previous.bracketAfter = true;
|
|
756
|
-
const image =
|
|
768
|
+
const image = code === EXCLAMATION;
|
|
757
769
|
openers.push({ at: image ? i + 1 : i, start: i, image, active: true, bracketAfter: false });
|
|
758
770
|
i += image ? 2 : 1;
|
|
759
771
|
continue;
|
|
760
772
|
}
|
|
761
|
-
if (
|
|
773
|
+
if (code === CLOSE_BRACKET) {
|
|
762
774
|
const opener = openers.pop();
|
|
763
775
|
const use = opener?.active ? closeLink(body, opener, i, definitions, joins) : null;
|
|
764
776
|
if (opener === undefined || use === null) {
|
|
@@ -777,9 +789,12 @@ export function linkInventory(body) {
|
|
|
777
789
|
}
|
|
778
790
|
return { uses, blocks };
|
|
779
791
|
}
|
|
780
|
-
export function
|
|
792
|
+
export function destinations(inventory) {
|
|
781
793
|
const byStart = new Map();
|
|
782
|
-
for (const use of
|
|
794
|
+
for (const use of inventory.uses)
|
|
783
795
|
byStart.set(use.destination.start, use.destination);
|
|
784
796
|
return [...byStart.values()].sort((left, right) => left.start - right.start);
|
|
785
797
|
}
|
|
798
|
+
export function hrefOccurrences(body) {
|
|
799
|
+
return destinations(linkInventory(body));
|
|
800
|
+
}
|
package/dist/project.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG3F,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,IAAI,GAAG,KAAK,CAAC;AAEzB,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CAAE,GAC5C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC;AA0CtD,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAS3E;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,MAAM,CAWxF;AA4BD,wBAAg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Q,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,iBAA2C,GACnD,UAAU,CAMZ"}
|
package/dist/project.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { memberFacts } from './definition.js';
|
|
2
|
-
import { frontmatter } from './document.js';
|
|
3
|
-
import { linkInventory } from './links.js';
|
|
2
|
+
import { frontmatter, inventoryOf } from './document.js';
|
|
4
3
|
import { roomTarget, target } from './paths.js';
|
|
5
4
|
import { refusal } from './refuse.js';
|
|
6
5
|
import { headingSpans } from './sections.js';
|
|
7
6
|
import { bodyStartOf } from './yaml.js';
|
|
8
|
-
function internalEdits(content, bodyStart, file, documentTargets) {
|
|
9
|
-
const inventory = linkInventory(content.slice(bodyStart));
|
|
7
|
+
function internalEdits(content, inventory, bodyStart, file, documentTargets) {
|
|
10
8
|
const internal = new Set();
|
|
11
9
|
const uses = inventory.uses
|
|
12
10
|
.filter((use) => {
|
|
@@ -98,7 +96,7 @@ function freeTextValues(definition, document) {
|
|
|
98
96
|
export function projectionInput(document, file, context) {
|
|
99
97
|
const content = document.content;
|
|
100
98
|
const bodyStart = bodyStartOf(content);
|
|
101
|
-
const edits = internalEdits(content, bodyStart, file, new Set(context.documentTargets));
|
|
99
|
+
const edits = internalEdits(content, inventoryOf(document), bodyStart, file, new Set(context.documentTargets));
|
|
102
100
|
const declared = document.type;
|
|
103
101
|
if (declared === undefined || declared === 'any') {
|
|
104
102
|
return {
|
package/dist/types.d.ts
CHANGED
|
@@ -13,13 +13,14 @@ export type ModelVerification = {
|
|
|
13
13
|
};
|
|
14
14
|
export type ValidationContext = {
|
|
15
15
|
readonly binaryTargets: readonly string[];
|
|
16
|
+
readonly anyRoom?: true;
|
|
16
17
|
};
|
|
17
18
|
export type ProjectionContext = {
|
|
18
19
|
readonly documentTargets: readonly string[];
|
|
19
20
|
readonly definition?: Definition;
|
|
20
21
|
};
|
|
21
22
|
export type DivisionContext = ProjectionContext & {
|
|
22
|
-
readonly
|
|
23
|
+
readonly bound: number;
|
|
23
24
|
};
|
|
24
25
|
export type Extent = {
|
|
25
26
|
readonly start: number;
|
|
@@ -60,6 +61,10 @@ export type Validation = {
|
|
|
60
61
|
} | ({
|
|
61
62
|
readonly verdict: 'refuse';
|
|
62
63
|
} & Refusal);
|
|
64
|
+
export type ValidationStep = {
|
|
65
|
+
readonly path: string;
|
|
66
|
+
readonly resolved: number;
|
|
67
|
+
};
|
|
63
68
|
export type Projection = {
|
|
64
69
|
readonly ok: true;
|
|
65
70
|
readonly text: string;
|
|
@@ -92,9 +97,6 @@ export type Link = {
|
|
|
92
97
|
readonly href: string;
|
|
93
98
|
readonly target: string;
|
|
94
99
|
};
|
|
95
|
-
export type LinkOccurrence = Link & {
|
|
96
|
-
readonly start: number;
|
|
97
|
-
};
|
|
98
100
|
export type Reference = {
|
|
99
101
|
readonly pointer: string;
|
|
100
102
|
readonly value: string;
|
|
@@ -112,11 +114,13 @@ export type RoomReference = {
|
|
|
112
114
|
readonly pointer: string;
|
|
113
115
|
readonly value: string;
|
|
114
116
|
readonly to: readonly string[];
|
|
117
|
+
readonly crossRoom?: true;
|
|
115
118
|
} | {
|
|
116
119
|
readonly kind: 'item';
|
|
117
120
|
readonly section: string;
|
|
118
121
|
readonly href: string;
|
|
119
122
|
readonly to: readonly string[];
|
|
123
|
+
readonly crossRoom?: true;
|
|
120
124
|
});
|
|
121
125
|
export type Change = {
|
|
122
126
|
readonly kind: 'field';
|