@agentshouse/mdmodel 0.1.0-ccf1367190878 → 0.1.0-cd90851746292
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 +152 -142
- package/README.md +16 -19
- package/dist/blocks.d.ts.map +1 -1
- package/dist/blocks.js +35 -20
- package/dist/condition.d.ts +41 -10
- package/dist/condition.d.ts.map +1 -1
- package/dist/condition.js +218 -85
- package/dist/definition.d.ts +3 -1
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +105 -21
- package/dist/divide.d.ts.map +1 -1
- package/dist/divide.js +27 -17
- package/dist/document.d.ts +5 -5
- package/dist/document.d.ts.map +1 -1
- package/dist/document.js +304 -187
- package/dist/index.d.ts +9 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/links.d.ts +2 -0
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +107 -50
- package/dist/paths.d.ts +9 -1
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +28 -2
- package/dist/pattern.d.ts +10 -0
- package/dist/pattern.d.ts.map +1 -0
- package/dist/pattern.js +355 -0
- package/dist/project.d.ts +1 -0
- package/dist/project.d.ts.map +1 -1
- package/dist/project.js +38 -15
- package/dist/references.d.ts.map +1 -1
- package/dist/references.js +6 -1
- 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 +28 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/validate.d.ts +27 -3
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +219 -70
- package/dist/yaml.d.ts.map +1 -1
- package/dist/yaml.js +36 -3
- package/fixtures/README.md +9 -4
- 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/division.json +26 -26
- package/package.json +7 -2
package/dist/definition.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MEMBER_FIELD, RECEIVED_FIELD, SITE_FIELD, TYPE_FIELD } from './fields.js';
|
|
2
|
+
import { linearPattern } from './pattern.js';
|
|
2
3
|
import { equalValue, isRecord, jsValue, parseYamlMapping, YamlError } from './yaml.js';
|
|
3
4
|
export const JSON_TYPES = [
|
|
4
5
|
'string',
|
|
@@ -24,9 +25,13 @@ const ANNOTATIONS = new Set([
|
|
|
24
25
|
'writeOnly',
|
|
25
26
|
]);
|
|
26
27
|
const FIELD_RULES = ['change_roles', 'initial_roles', 'transitions'];
|
|
28
|
+
const PROVIDED_KEYWORDS = ['create_roles', 'delete_roles'];
|
|
29
|
+
const NO_TYPES = Object.freeze({ types: Object.freeze({}) });
|
|
27
30
|
const DEFS_REFERENCE = '#/$defs/';
|
|
31
|
+
const UNBOUNDED_FORMAT = 'url';
|
|
28
32
|
const UNRESOLVED = /[\u0000-\u001f\u007f%[\]\\^{|}]|\s$/u;
|
|
29
33
|
export const ARRAY_INDEX = /^(?:0|[1-9][0-9]*)$/u;
|
|
34
|
+
export const JSON_POINTER = /^(?:\/(?:[^~/]|~[01])*)*$/u;
|
|
30
35
|
const HOUSE_KEYS = {
|
|
31
36
|
[TYPE_FIELD]: { prose: false },
|
|
32
37
|
[SITE_FIELD]: { prose: false },
|
|
@@ -45,12 +50,12 @@ export function pointerSegments(pointer) {
|
|
|
45
50
|
return pointer.split('/').slice(1).map(unescapePointer);
|
|
46
51
|
}
|
|
47
52
|
export function refTarget(reference, defs) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (segments.some((segment) => escapePointer(unescapePointer(segment)) !== segment))
|
|
53
|
+
const pointer = reference.slice('#'.length);
|
|
54
|
+
if (!reference.startsWith(DEFS_REFERENCE) ||
|
|
55
|
+
UNRESOLVED.test(reference) ||
|
|
56
|
+
!JSON_POINTER.test(pointer))
|
|
53
57
|
return undefined;
|
|
58
|
+
const [, name = '', ...rest] = pointerSegments(pointer);
|
|
54
59
|
if (!Object.hasOwn(defs, name))
|
|
55
60
|
return undefined;
|
|
56
61
|
let node = defs[name];
|
|
@@ -81,15 +86,7 @@ export function refTarget(reference, defs) {
|
|
|
81
86
|
return { name, node };
|
|
82
87
|
}
|
|
83
88
|
function compiles(pattern) {
|
|
84
|
-
|
|
85
|
-
return false;
|
|
86
|
-
try {
|
|
87
|
-
new RegExp(pattern, 'u');
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
89
|
+
return typeof pattern === 'string' && linearPattern(pattern) !== null;
|
|
93
90
|
}
|
|
94
91
|
function finite(value) {
|
|
95
92
|
return typeof value === 'number' && Number.isFinite(value);
|
|
@@ -199,7 +196,7 @@ const KEYWORDS = {
|
|
|
199
196
|
uniqueItems: FLAG,
|
|
200
197
|
required: strings,
|
|
201
198
|
dependentRequired: (value) => isRecord(value) && Object.values(value).every(strings),
|
|
202
|
-
format:
|
|
199
|
+
format: (value) => typeof value === 'string' && value !== UNBOUNDED_FORMAT,
|
|
203
200
|
contentEncoding: TEXT,
|
|
204
201
|
contentMediaType: TEXT,
|
|
205
202
|
title: TEXT,
|
|
@@ -216,8 +213,12 @@ const KEYWORDS = {
|
|
|
216
213
|
return (Array.isArray(named) &&
|
|
217
214
|
named.length > 0 &&
|
|
218
215
|
strings(named) &&
|
|
219
|
-
named.every((name) => name === BUILT_IN_TYPE ||
|
|
216
|
+
named.every((name) => name === BUILT_IN_TYPE ||
|
|
217
|
+
name === ATTACHMENT ||
|
|
218
|
+
context.types.has(name) ||
|
|
219
|
+
node.cross_room === true));
|
|
220
220
|
},
|
|
221
|
+
cross_room: (value, _at, node) => typeof value === 'boolean' && node.reference !== undefined,
|
|
221
222
|
};
|
|
222
223
|
function sharedType(values) {
|
|
223
224
|
if (values.length === 0)
|
|
@@ -290,6 +291,7 @@ function joined(left, right) {
|
|
|
290
291
|
const format = left.format === right.format ? left.format : undefined;
|
|
291
292
|
const values = united(left.values, right.values);
|
|
292
293
|
const reference = united(left.reference, right.reference);
|
|
294
|
+
const crossRoom = left.crossRoom === true || right.crossRoom === true;
|
|
293
295
|
const items = both(left.items, right.items);
|
|
294
296
|
const prefix = left.prefix === undefined && right.prefix === undefined
|
|
295
297
|
? undefined
|
|
@@ -310,6 +312,7 @@ function joined(left, right) {
|
|
|
310
312
|
...(format === undefined ? {} : { format }),
|
|
311
313
|
...(values === undefined ? {} : { values }),
|
|
312
314
|
...(reference === undefined ? {} : { reference }),
|
|
315
|
+
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
313
316
|
prose: left.prose && right.prose,
|
|
314
317
|
...(prefix === undefined ? {} : { prefix }),
|
|
315
318
|
...(items === undefined ? {} : { items }),
|
|
@@ -388,6 +391,7 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
388
391
|
: Array.isArray(node.reference)
|
|
389
392
|
? node.reference
|
|
390
393
|
: undefined) ?? alternatives.find((facts) => facts.reference !== undefined)?.reference;
|
|
394
|
+
const crossRoom = firstOf(held, (node) => node.reference === undefined ? undefined : node.cross_room === true) ?? alternatives.find((facts) => facts.reference !== undefined)?.crossRoom === true;
|
|
391
395
|
const format = firstOf(held, (node) => (typeof node.format === 'string' ? node.format : undefined)) ??
|
|
392
396
|
alternatives.find((facts) => facts.format !== undefined)?.format;
|
|
393
397
|
const prose = type === 'string' &&
|
|
@@ -422,6 +426,7 @@ function factsOf(nodes, defs, ancestry) {
|
|
|
422
426
|
...(format === undefined ? {} : { format }),
|
|
423
427
|
...(values === undefined ? {} : { values }),
|
|
424
428
|
...(reference === undefined ? {} : { reference }),
|
|
429
|
+
...(reference !== undefined && crossRoom ? { crossRoom: true } : {}),
|
|
425
430
|
prose,
|
|
426
431
|
...(prefix === undefined ? {} : { prefix }),
|
|
427
432
|
...(items === undefined ? {} : { items }),
|
|
@@ -439,7 +444,7 @@ export function itemFacts(facts, index) {
|
|
|
439
444
|
export function memberFacts(facts, key) {
|
|
440
445
|
if (facts.properties !== undefined && Object.hasOwn(facts.properties, key))
|
|
441
446
|
return facts.properties[key];
|
|
442
|
-
const pattern = facts.patterns?.find((one) =>
|
|
447
|
+
const pattern = facts.patterns?.find((one) => linearPattern(one.pattern).test(key));
|
|
443
448
|
return pattern === undefined ? facts.additional : pattern.facts;
|
|
444
449
|
}
|
|
445
450
|
export function crossedFacts(facts) {
|
|
@@ -542,6 +547,56 @@ function readSections(value, at, context) {
|
|
|
542
547
|
}
|
|
543
548
|
return { sections };
|
|
544
549
|
}
|
|
550
|
+
function branchSectionsFailure(sections, declared, where) {
|
|
551
|
+
if (!isRecord(sections))
|
|
552
|
+
return refuse('sections', where);
|
|
553
|
+
for (const [name, spec] of Object.entries(sections)) {
|
|
554
|
+
const place = `${where}/${escapePointer(name)}`;
|
|
555
|
+
const own = isRecord(declared) && Object.hasOwn(declared, name) ? declared[name] : undefined;
|
|
556
|
+
if (!isRecord(spec) || !isRecord(own))
|
|
557
|
+
return refuse('sections', place);
|
|
558
|
+
const { required, ...kind } = spec;
|
|
559
|
+
const { required: _required, ...ownKind } = own;
|
|
560
|
+
if (required !== undefined && typeof required !== 'boolean')
|
|
561
|
+
return refuse('sections', `${place}/required`);
|
|
562
|
+
if (!equalValue(kind, ownKind))
|
|
563
|
+
return refuse('sections', place);
|
|
564
|
+
}
|
|
565
|
+
return undefined;
|
|
566
|
+
}
|
|
567
|
+
function withoutBranchSections(schema, declared, at) {
|
|
568
|
+
const kept = { ...schema };
|
|
569
|
+
if (Array.isArray(schema.allOf)) {
|
|
570
|
+
const entries = [];
|
|
571
|
+
for (const [index, entry] of schema.allOf.entries()) {
|
|
572
|
+
const read = isRecord(entry)
|
|
573
|
+
? withoutBranchSections(entry, declared, `${at}/allOf/${index}`)
|
|
574
|
+
: { schema: entry };
|
|
575
|
+
if ('failure' in read)
|
|
576
|
+
return read;
|
|
577
|
+
entries.push(read.schema);
|
|
578
|
+
}
|
|
579
|
+
kept.allOf = entries;
|
|
580
|
+
}
|
|
581
|
+
if (schema.if === undefined)
|
|
582
|
+
return { schema: kept };
|
|
583
|
+
for (const branch of ['then', 'else']) {
|
|
584
|
+
const held = schema[branch];
|
|
585
|
+
if (!isRecord(held))
|
|
586
|
+
continue;
|
|
587
|
+
const { sections, ...rest } = held;
|
|
588
|
+
const failure = sections === undefined
|
|
589
|
+
? undefined
|
|
590
|
+
: branchSectionsFailure(sections, declared, `${at}/${branch}/sections`);
|
|
591
|
+
if (failure !== undefined)
|
|
592
|
+
return { failure };
|
|
593
|
+
const read = withoutBranchSections(rest, declared, `${at}/${branch}`);
|
|
594
|
+
if ('failure' in read)
|
|
595
|
+
return read;
|
|
596
|
+
kept[branch] = read.schema;
|
|
597
|
+
}
|
|
598
|
+
return { schema: kept };
|
|
599
|
+
}
|
|
545
600
|
function deepFreeze(value) {
|
|
546
601
|
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
547
602
|
Object.freeze(value);
|
|
@@ -649,6 +704,26 @@ function unruled(schema) {
|
|
|
649
704
|
}
|
|
650
705
|
return { schema: written.size === 0 ? schema : { ...schema, properties }, written };
|
|
651
706
|
}
|
|
707
|
+
function providedType(name, value, provided) {
|
|
708
|
+
const at = `/${escapePointer(name)}`;
|
|
709
|
+
if (provided.nameable?.includes(name) !== true)
|
|
710
|
+
return refuse('provided-type', at);
|
|
711
|
+
if (!isRecord(value))
|
|
712
|
+
return refuse('schema', at);
|
|
713
|
+
const declared = Object.keys(value).find((key) => !PROVIDED_KEYWORDS.includes(key));
|
|
714
|
+
if (declared !== undefined)
|
|
715
|
+
return refuse('provided-type', `${at}/${escapePointer(declared)}`);
|
|
716
|
+
const { create_roles: createRoles, delete_roles: deleteRoles } = value;
|
|
717
|
+
if (createRoles !== undefined && !roleNames(createRoles))
|
|
718
|
+
return refuse('create_roles', `${at}/create_roles`);
|
|
719
|
+
if (deleteRoles !== undefined && !roleNames(deleteRoles))
|
|
720
|
+
return refuse('delete_roles', `${at}/delete_roles`);
|
|
721
|
+
return {
|
|
722
|
+
...provided.types[name],
|
|
723
|
+
...(createRoles === undefined ? {} : { createRoles }),
|
|
724
|
+
...(deleteRoles === undefined ? {} : { deleteRoles }),
|
|
725
|
+
};
|
|
726
|
+
}
|
|
652
727
|
function readType(name, value, context) {
|
|
653
728
|
const at = `/${escapePointer(name)}`;
|
|
654
729
|
if (!isRecord(value))
|
|
@@ -665,7 +740,10 @@ function readType(name, value, context) {
|
|
|
665
740
|
: readSections(declared, `${at}/sections`, context);
|
|
666
741
|
if ('failure' in read)
|
|
667
742
|
return read.failure;
|
|
668
|
-
const
|
|
743
|
+
const unbranched = withoutBranchSections(ruled, declared, at);
|
|
744
|
+
if ('failure' in unbranched)
|
|
745
|
+
return unbranched.failure;
|
|
746
|
+
const { schema, written } = unruled(unbranched.schema);
|
|
669
747
|
const failure = schemaFailure(schema, at, context);
|
|
670
748
|
if (failure !== undefined)
|
|
671
749
|
return failure;
|
|
@@ -704,7 +782,7 @@ function readType(name, value, context) {
|
|
|
704
782
|
function lineAt(text, offset) {
|
|
705
783
|
return text.slice(0, offset).split(/\r\n|\r|\n/).length;
|
|
706
784
|
}
|
|
707
|
-
export function readSchema(text) {
|
|
785
|
+
export function readSchema(text, provided = NO_TYPES) {
|
|
708
786
|
let root;
|
|
709
787
|
try {
|
|
710
788
|
root = jsValue(parseYamlMapping(text, 0, text.length));
|
|
@@ -722,7 +800,7 @@ export function readSchema(text) {
|
|
|
722
800
|
if (name === '' || name.startsWith('$') || name === BUILT_IN_TYPE || name === ATTACHMENT)
|
|
723
801
|
return refuse('schema-type-name', `/${escapePointer(name)}`);
|
|
724
802
|
}
|
|
725
|
-
const context = { defs, types: new Set(names) };
|
|
803
|
+
const context = { defs, types: new Set([...names, ...Object.keys(provided.types)]) };
|
|
726
804
|
for (const [name, def] of Object.entries(defs)) {
|
|
727
805
|
const failure = schemaFailure(def, `/$defs/${escapePointer(name)}`, context);
|
|
728
806
|
if (failure !== undefined)
|
|
@@ -731,7 +809,9 @@ export function readSchema(text) {
|
|
|
731
809
|
const types = Object.create(null);
|
|
732
810
|
let marked = false;
|
|
733
811
|
for (const name of names) {
|
|
734
|
-
const definition =
|
|
812
|
+
const definition = Object.hasOwn(provided.types, name)
|
|
813
|
+
? providedType(name, root[name], provided)
|
|
814
|
+
: readType(name, root[name], context);
|
|
735
815
|
if ('rule' in definition)
|
|
736
816
|
return definition;
|
|
737
817
|
if (definition.memberDocument) {
|
|
@@ -741,5 +821,9 @@ export function readSchema(text) {
|
|
|
741
821
|
}
|
|
742
822
|
types[name] = deepFreeze(definition);
|
|
743
823
|
}
|
|
824
|
+
for (const [name, definition] of Object.entries(provided.types)) {
|
|
825
|
+
if (!Object.hasOwn(types, name))
|
|
826
|
+
types[name] = definition;
|
|
827
|
+
}
|
|
744
828
|
return Object.freeze({ types: Object.freeze(types) });
|
|
745
829
|
}
|
package/dist/divide.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"divide.d.ts","sourceRoot":"","sources":["../src/divide.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"divide.d.ts","sourceRoot":"","sources":["../src/divide.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAgB,MAAM,YAAY,CAAC;AAwXpF,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,GAAG,QAAQ,CAc3F"}
|
package/dist/divide.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blockRanges, headingLines } from './blocks.js';
|
|
2
|
-
import { projectionInput, rangeText } from './project.js';
|
|
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) {
|
|
@@ -131,16 +131,26 @@ function textOf(state, extent) {
|
|
|
131
131
|
return rangeText(state.content, extent, state.edits);
|
|
132
132
|
}
|
|
133
133
|
function sourceCutting(state, extent) {
|
|
134
|
-
|
|
134
|
+
const source = state.content.slice(extent.start, extent.end);
|
|
135
135
|
const masks = [];
|
|
136
|
-
for (
|
|
137
|
-
|
|
136
|
+
for (let index = firstEditFrom(state.edits, extent.start); index < state.edits.length; index += 1) {
|
|
137
|
+
const edit = state.edits[index];
|
|
138
|
+
if (edit.start > extent.end)
|
|
139
|
+
break;
|
|
140
|
+
if (edit.end > extent.end)
|
|
138
141
|
continue;
|
|
139
|
-
|
|
140
|
-
const to = edit.end - extent.start;
|
|
141
|
-
text = `${text.slice(0, from)}${'x'.repeat(to - from)}${text.slice(to)}`;
|
|
142
|
-
masks.push({ start: from, end: to });
|
|
142
|
+
masks.push({ start: edit.start - extent.start, end: edit.end - extent.start });
|
|
143
143
|
}
|
|
144
|
+
let text = '';
|
|
145
|
+
let cursor = 0;
|
|
146
|
+
for (const mask of masks) {
|
|
147
|
+
if (mask.end <= cursor)
|
|
148
|
+
continue;
|
|
149
|
+
const from = Math.max(mask.start, cursor);
|
|
150
|
+
text += `${source.slice(cursor, from)}${'x'.repeat(mask.end - from)}`;
|
|
151
|
+
cursor = mask.end;
|
|
152
|
+
}
|
|
153
|
+
text += source.slice(cursor);
|
|
144
154
|
return {
|
|
145
155
|
text,
|
|
146
156
|
masks,
|
|
@@ -158,12 +168,12 @@ function valueCutting(value) {
|
|
|
158
168
|
};
|
|
159
169
|
}
|
|
160
170
|
function prefixOf(state, body) {
|
|
161
|
-
if (body.emitted === 0 || body.heading.length >= state.
|
|
171
|
+
if (body.emitted === 0 || body.heading.length >= state.bound)
|
|
162
172
|
return '';
|
|
163
173
|
return body.heading;
|
|
164
174
|
}
|
|
165
175
|
function available(state, body) {
|
|
166
|
-
return state.
|
|
176
|
+
return state.bound - prefixOf(state, body).length;
|
|
167
177
|
}
|
|
168
178
|
function emit(state, body, piece, bare = false) {
|
|
169
179
|
if (piece.text.trim() === '')
|
|
@@ -206,7 +216,7 @@ function divideBound(state, body, cutting, range) {
|
|
|
206
216
|
let start = range.start;
|
|
207
217
|
while (start < range.end) {
|
|
208
218
|
const bare = available(state, body) < characterLength(cutting.text, start);
|
|
209
|
-
const room = bare ? state.
|
|
219
|
+
const room = bare ? state.bound : available(state, body);
|
|
210
220
|
const stop = boundOf(cutting, start, range.end, room);
|
|
211
221
|
const piece = cutting.piece(start, stop);
|
|
212
222
|
if (cutting.masks.length === 0 || piece.text.length <= room) {
|
|
@@ -293,8 +303,8 @@ function divideInput(state, input) {
|
|
|
293
303
|
]);
|
|
294
304
|
}
|
|
295
305
|
export function divide(document, file, context) {
|
|
296
|
-
if (!Number.isInteger(context.
|
|
297
|
-
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') };
|
|
298
308
|
}
|
|
299
309
|
const result = projectionInput(document, file, context);
|
|
300
310
|
if (!result.ok)
|
|
@@ -302,7 +312,7 @@ export function divide(document, file, context) {
|
|
|
302
312
|
const state = {
|
|
303
313
|
content: document.content,
|
|
304
314
|
edits: result.input.edits,
|
|
305
|
-
|
|
315
|
+
bound: context.bound,
|
|
306
316
|
spans: [],
|
|
307
317
|
};
|
|
308
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
|
-
export declare function apply(document: Document,
|
|
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;AAgBnB,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAM7D;AAgED,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"}
|