@agentshouse/mdmodel 0.1.0-cabd61587647f → 0.1.0-cae8e240cefab

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.
Files changed (133) hide show
  1. package/API.md +175 -145
  2. package/README.md +7 -5
  3. package/dist/blocks.d.ts.map +1 -1
  4. package/dist/blocks.js +29 -7
  5. package/dist/definition.d.ts +3 -1
  6. package/dist/definition.d.ts.map +1 -1
  7. package/dist/definition.js +112 -24
  8. package/dist/divide.js +9 -9
  9. package/dist/document.d.ts +4 -4
  10. package/dist/document.d.ts.map +1 -1
  11. package/dist/document.js +41 -41
  12. package/dist/event.d.ts +78 -0
  13. package/dist/event.d.ts.map +1 -0
  14. package/dist/event.js +230 -0
  15. package/dist/facts.d.ts +15 -0
  16. package/dist/facts.d.ts.map +1 -0
  17. package/dist/facts.js +38 -0
  18. package/dist/index.d.ts +23 -8
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +14 -6
  21. package/dist/kinds.d.ts +19 -0
  22. package/dist/kinds.d.ts.map +1 -0
  23. package/dist/kinds.js +161 -0
  24. package/dist/links.d.ts +1 -0
  25. package/dist/links.d.ts.map +1 -1
  26. package/dist/links.js +85 -39
  27. package/dist/paths.d.ts +9 -1
  28. package/dist/paths.d.ts.map +1 -1
  29. package/dist/paths.js +28 -2
  30. package/dist/pattern.d.ts +10 -0
  31. package/dist/pattern.d.ts.map +1 -0
  32. package/dist/pattern.js +355 -0
  33. package/dist/project.d.ts.map +1 -1
  34. package/dist/project.js +7 -7
  35. package/dist/query/language.d.ts +254 -0
  36. package/dist/query/language.d.ts.map +1 -0
  37. package/dist/query/language.js +620 -0
  38. package/dist/query/match.d.ts +14 -0
  39. package/dist/query/match.d.ts.map +1 -0
  40. package/dist/query/match.js +147 -0
  41. package/dist/query/rows.d.ts +32 -0
  42. package/dist/query/rows.d.ts.map +1 -0
  43. package/dist/query/rows.js +161 -0
  44. package/dist/query/sql.d.ts +39 -0
  45. package/dist/query/sql.d.ts.map +1 -0
  46. package/dist/query/sql.js +284 -0
  47. package/dist/references.d.ts.map +1 -1
  48. package/dist/references.js +6 -1
  49. package/dist/reserved.d.ts +5 -0
  50. package/dist/reserved.d.ts.map +1 -0
  51. package/dist/reserved.js +20 -0
  52. package/dist/schema.d.ts +1 -0
  53. package/dist/schema.d.ts.map +1 -1
  54. package/dist/schema.js +55 -4
  55. package/dist/types.d.ts +34 -4
  56. package/dist/types.d.ts.map +1 -1
  57. package/dist/validate.d.ts +30 -5
  58. package/dist/validate.d.ts.map +1 -1
  59. package/dist/validate.js +359 -99
  60. package/dist/yaml.d.ts.map +1 -1
  61. package/dist/yaml.js +36 -3
  62. package/fixtures/README.md +26 -6
  63. package/fixtures/cases/conditional-section/context.json +1 -0
  64. package/fixtures/cases/conditional-section/expected.json +6 -0
  65. package/fixtures/cases/conditional-section/library/questions/hosting.md +9 -0
  66. package/fixtures/cases/conditional-section/library/questions/payments.md +12 -0
  67. package/fixtures/cases/conditional-section/schema.yaml +14 -0
  68. package/fixtures/cases/cross-room-link/context.json +1 -0
  69. package/fixtures/cases/cross-room-link/expected.json +1 -0
  70. package/fixtures/cases/cross-room-link/library/clients/acme.md +6 -0
  71. package/fixtures/cases/cross-room-link/schema.yaml +3 -0
  72. package/fixtures/cases/cross-room-reference/context.json +1 -0
  73. package/fixtures/cases/cross-room-reference/expected.json +1 -0
  74. package/fixtures/cases/cross-room-reference/library/clients/acme.md +9 -0
  75. package/fixtures/cases/cross-room-reference/schema.yaml +9 -0
  76. package/fixtures/cases/link-into-a-reserved-name/context.json +1 -0
  77. package/fixtures/cases/link-into-a-reserved-name/expected.json +5 -0
  78. package/fixtures/cases/link-into-a-reserved-name/library/notes/a.md +6 -0
  79. package/fixtures/cases/link-into-a-reserved-name/schema.yaml +3 -0
  80. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/context.json +1 -0
  81. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/expected.json +5 -0
  82. package/fixtures/cases/link-into-a-reserved-name-from-an-untyped-document/library/notes/b.md +5 -0
  83. package/fixtures/cases/member-on-an-untyped-document/context.json +1 -0
  84. package/fixtures/cases/member-on-an-untyped-document/expected.json +6 -0
  85. package/fixtures/cases/member-on-an-untyped-document/library/note.md +4 -0
  86. package/fixtures/cases/member-on-another-type/context.json +1 -0
  87. package/fixtures/cases/member-on-another-type/expected.json +6 -0
  88. package/fixtures/cases/member-on-another-type/library/note.md +4 -0
  89. package/fixtures/cases/member-on-another-type/schema.yaml +7 -0
  90. package/fixtures/cases/reference-into-a-reserved-name/context.json +1 -0
  91. package/fixtures/cases/reference-into-a-reserved-name/expected.json +6 -0
  92. package/fixtures/cases/reference-into-a-reserved-name/library/notes/a.md +4 -0
  93. package/fixtures/cases/reference-into-a-reserved-name/library/settings/brief.md +1 -0
  94. package/fixtures/cases/reference-into-a-reserved-name/schema.yaml +3 -0
  95. package/fixtures/cases/room-md-declares-a-type/context.json +1 -0
  96. package/fixtures/cases/room-md-declares-a-type/expected.json +6 -0
  97. package/fixtures/cases/room-md-declares-a-type/library/ROOM.md +5 -0
  98. package/fixtures/cases/typed-path-names-another-type/context.json +11 -0
  99. package/fixtures/cases/typed-path-names-another-type/expected.json +6 -0
  100. package/fixtures/cases/typed-path-names-another-type/library/settings/prefs/one.md +3 -0
  101. package/fixtures/cases/typed-path-names-another-type/schema.yaml +6 -0
  102. package/fixtures/cases/typed-path-names-its-type/context.json +11 -0
  103. package/fixtures/cases/typed-path-names-its-type/expected.json +3 -0
  104. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/deeper/two.md +1 -0
  105. package/fixtures/cases/typed-path-names-its-type/library/settings/prefs/one.md +4 -0
  106. package/fixtures/cases/typed-path-names-its-type/schema.yaml +6 -0
  107. package/fixtures/cases/typed-path-names-no-type/context.json +11 -0
  108. package/fixtures/cases/typed-path-names-no-type/expected.json +6 -0
  109. package/fixtures/cases/typed-path-names-no-type/library/settings/prefs/one.md +1 -0
  110. package/fixtures/cases/typed-path-names-no-type/schema.yaml +6 -0
  111. package/fixtures/cases/unnamed-typed-path-checks-its-fields/context.json +11 -0
  112. package/fixtures/cases/unnamed-typed-path-checks-its-fields/expected.json +6 -0
  113. package/fixtures/cases/unnamed-typed-path-checks-its-fields/library/rooms/team/tasks/plan.md +4 -0
  114. package/fixtures/cases/unnamed-typed-path-checks-its-fields/schema.yaml +5 -0
  115. package/fixtures/cases/unnamed-typed-path-names-a-type/context.json +11 -0
  116. package/fixtures/cases/unnamed-typed-path-names-a-type/expected.json +6 -0
  117. package/fixtures/cases/unnamed-typed-path-names-a-type/library/rooms/team/tasks/plan.md +6 -0
  118. package/fixtures/cases/unnamed-typed-path-names-a-type/schema.yaml +5 -0
  119. package/fixtures/cases/unnamed-typed-path-reads-its-type/context.json +11 -0
  120. package/fixtures/cases/unnamed-typed-path-reads-its-type/expected.json +3 -0
  121. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/plan.md +1 -0
  122. package/fixtures/cases/unnamed-typed-path-reads-its-type/library/rooms/team/tasks/plan.md +5 -0
  123. package/fixtures/cases/unnamed-typed-path-reads-its-type/schema.yaml +5 -0
  124. package/fixtures/cases/unnamed-typed-path-without-a-body/context.json +11 -0
  125. package/fixtures/cases/unnamed-typed-path-without-a-body/expected.json +5 -0
  126. package/fixtures/cases/unnamed-typed-path-without-a-body/library/rooms/team/tasks/plan.md +5 -0
  127. package/fixtures/cases/unnamed-typed-path-without-a-body/schema.yaml +5 -0
  128. package/fixtures/division.json +26 -26
  129. package/fixtures/queries.json +964 -0
  130. package/package.json +7 -2
  131. package/dist/condition.d.ts +0 -149
  132. package/dist/condition.d.ts.map +0 -1
  133. package/dist/condition.js +0 -500
@@ -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
- if (!reference.startsWith(DEFS_REFERENCE) || UNRESOLVED.test(reference))
49
- return undefined;
50
- const segments = reference.slice(DEFS_REFERENCE.length).split('/');
51
- const [name = '', ...rest] = segments.map(unescapePointer);
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
- if (typeof pattern !== 'string')
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);
@@ -103,7 +100,7 @@ function strings(value) {
103
100
  new Set(value).size === value.length);
104
101
  }
105
102
  function schemaFailure(value, at, context) {
106
- if (typeof value === 'boolean')
103
+ if (!context.checked || typeof value === 'boolean')
107
104
  return undefined;
108
105
  if (!isRecord(value))
109
106
  return refuse('schema', at);
@@ -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: TEXT,
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 || name === ATTACHMENT || context.types.has(name)));
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) => new RegExp(one.pattern, 'u').test(key));
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, checked) {
708
+ const at = `/${escapePointer(name)}`;
709
+ if (checked && 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 (checked && 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 { schema, written } = unruled(ruled);
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, checked = true) {
708
786
  let root;
709
787
  try {
710
788
  root = jsValue(parseYamlMapping(text, 0, text.length));
@@ -718,11 +796,15 @@ export function readSchema(text) {
718
796
  if (!isRecord(defs))
719
797
  return refuse('$defs', '/$defs');
720
798
  const names = Object.keys(root).filter((key) => key !== '$defs');
721
- for (const name of names) {
799
+ for (const name of checked ? names : []) {
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 = {
804
+ defs,
805
+ types: new Set([...names, ...Object.keys(provided.types)]),
806
+ checked,
807
+ };
726
808
  for (const [name, def] of Object.entries(defs)) {
727
809
  const failure = schemaFailure(def, `/$defs/${escapePointer(name)}`, context);
728
810
  if (failure !== undefined)
@@ -731,15 +813,21 @@ export function readSchema(text) {
731
813
  const types = Object.create(null);
732
814
  let marked = false;
733
815
  for (const name of names) {
734
- const definition = readType(name, root[name], context);
816
+ const definition = Object.hasOwn(provided.types, name)
817
+ ? providedType(name, root[name], provided, checked)
818
+ : readType(name, root[name], context);
735
819
  if ('rule' in definition)
736
820
  return definition;
737
- if (definition.memberDocument) {
821
+ if (checked && definition.memberDocument) {
738
822
  if (marked)
739
823
  return refuse('member_document', `/${escapePointer(name)}/member_document`);
740
824
  marked = true;
741
825
  }
742
826
  types[name] = deepFreeze(definition);
743
827
  }
828
+ for (const [name, definition] of Object.entries(provided.types)) {
829
+ if (!Object.hasOwn(types, name))
830
+ types[name] = definition;
831
+ }
744
832
  return Object.freeze({ types: Object.freeze(types) });
745
833
  }
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 SMALLEST_BUDGET = 2;
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, budget) {
90
- const limit = from + budget;
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.budget)
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.budget - prefixOf(state, body).length;
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.budget : available(state, body);
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.budget) || context.budget < SMALLEST_BUDGET) {
307
- return { ok: false, refusal: refusal(file, 'division-budget') };
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
- budget: context.budget,
315
+ bound: context.bound,
316
316
  spans: [],
317
317
  };
318
318
  divideInput(state, result.input);
@@ -1,16 +1,16 @@
1
1
  import { type Definition } from './definition.js';
2
- import type { ApplyResult, BodyResult, FrontmatterResult, Change, Document, Link, LinkOccurrence, ParseResult } from './types.js';
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
@@ -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;AAMhF,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,cAAc,EACd,WAAW,EAEZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAcL,KAAK,OAAO,EAEb,MAAM,WAAW,CAAC;AAmEnB,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,GACtB,WAAW,CAoBb;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CASrF;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EA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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,24 +1,35 @@
1
1
  import { ARRAY_INDEX, pointerSegments } from './definition.js';
2
- import { hrefOccurrences } from './links.js';
3
- import { destinationPath, relative, retarget, SHELL_ROOMS, shellTarget, target } from './paths.js';
2
+ import { destinations, hrefOccurrences, linkInventory, } from './links.js';
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
- const internals = new WeakMap();
8
+ const HELD = Symbol('held');
9
+ function heldOf(document) {
10
+ return document[HELD];
11
+ }
12
+ export function inventoryOf(document) {
13
+ const held = heldOf(document);
14
+ if (held?.inventory !== undefined)
15
+ return held.inventory;
16
+ const inventory = linkInventory(document.content.slice(bodyStartOf(document.content)));
17
+ if (held !== undefined)
18
+ held.inventory = inventory;
19
+ return inventory;
20
+ }
9
21
  function refuse(file, rule, location) {
10
22
  return location === undefined ? refusal(file, rule) : refusal(file, rule, { location });
11
23
  }
12
24
  function freezeDocument(content, type, fields, preamble, sections, internal) {
13
- const document = Object.freeze({
25
+ const held = { internal, inventory: undefined };
26
+ return Object.freeze(Object.defineProperty({
14
27
  content,
15
28
  type,
16
29
  fields: Object.freeze(fields),
17
30
  preamble,
18
31
  sections: Object.freeze(sections),
19
- });
20
- internals.set(document, internal);
21
- return document;
32
+ }, HELD, { value: held }));
22
33
  }
23
34
  function declaredType(fields) {
24
35
  const value = fields.type;
@@ -141,12 +152,16 @@ function scalarText(source, value) {
141
152
  return JSON.stringify(value);
142
153
  return serializeJs(value);
143
154
  }
144
- export function relativize(document, file, handle, definition) {
155
+ export function relativize(document, file, handle, definition, kept = new Set()) {
156
+ const relativized = (href) => {
157
+ const path = shellTarget(href, handle);
158
+ return path === null || kept.has(`${SHELL_ROOMS}${handle}/${path}`) ? null : path;
159
+ };
145
160
  const changes = [];
146
161
  for (const { pointer, value } of definition === undefined
147
162
  ? []
148
163
  : references(document, definition)) {
149
- const path = shellTarget(value, handle);
164
+ const path = relativized(value);
150
165
  if (path !== null)
151
166
  changes.push({
152
167
  kind: 'reference',
@@ -155,9 +170,8 @@ export function relativize(document, file, handle, definition) {
155
170
  prior: value,
156
171
  });
157
172
  }
158
- const body = document.content.slice(bodyStartOf(document.content));
159
- for (const href of new Set(hrefOccurrences(body).map((occurrence) => occurrence.href))) {
160
- const path = shellTarget(href, handle);
173
+ for (const href of new Set(destinations(inventoryOf(document)).map(({ href }) => href))) {
174
+ const path = relativized(href);
161
175
  if (path !== null)
162
176
  changes.push({ kind: 'link', href, to: relative(file, path) });
163
177
  }
@@ -167,7 +181,7 @@ export function relativizeBody(body, file, handle) {
167
181
  const relinkedBody = shellRelinked(body, file, handle);
168
182
  if (typeof relinkedBody !== 'string')
169
183
  return { outcome: 'refuse', refusal: relinkedBody };
170
- const elsewhere = hrefOccurrences(relinkedBody).find(({ href }) => destinationPath(href)?.startsWith(SHELL_ROOMS) === true);
184
+ const elsewhere = hrefOccurrences(relinkedBody).find(({ href }) => destinationPath(href)?.startsWith(SHELL_ROOMS) === true && roomTarget(href) === null);
171
185
  if (elsewhere !== undefined)
172
186
  return { outcome: 'refuse', refusal: refuse(file, 'unresolved-link', elsewhere.href) };
173
187
  return { outcome: 'applied', body: relinkedBody };
@@ -176,11 +190,11 @@ export function relinkBody(body, file, moves) {
176
190
  let rewritten = '';
177
191
  let cursor = 0;
178
192
  for (const match of hrefOccurrences(body)) {
179
- const from = target(file, match.href);
193
+ const from = target(file, match.href) ?? roomPath(match.href);
180
194
  const to = from === null ? undefined : moves.get(from);
181
195
  if (to === undefined)
182
196
  continue;
183
- const written = retarget(match.href, relative(file, to));
197
+ const written = retarget(match.href, from.startsWith(SHELL_ROOMS) || to.startsWith(SHELL_ROOMS) ? to : relative(file, to));
184
198
  const text = destinationText(written, match.bracketed);
185
199
  if (text === null)
186
200
  return { outcome: 'refuse', refusal: refuse(file, 'unwritable-link', written) };
@@ -189,40 +203,30 @@ export function relinkBody(body, file, moves) {
189
203
  }
190
204
  return { outcome: 'applied', body: rewritten + body.slice(cursor) };
191
205
  }
192
- function occurrencesIn(text, file, offset) {
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) {
206
+ function linksIn(occurrences, file) {
202
207
  const found = [];
203
208
  const seen = new Set();
204
- for (const occurrence of occurrencesIn(text, file, 0)) {
209
+ for (const occurrence of occurrences) {
205
210
  if (seen.has(occurrence.href))
206
211
  continue;
212
+ const resolved = target(file, occurrence.href);
213
+ if (resolved === null)
214
+ continue;
207
215
  seen.add(occurrence.href);
208
- found.push({ href: occurrence.href, target: occurrence.target });
216
+ found.push({ href: occurrence.href, target: resolved });
209
217
  }
210
218
  return found;
211
219
  }
212
220
  export function links(document, file) {
213
- return linksIn(document.content.slice(bodyStartOf(document.content)), file);
214
- }
215
- export function linkOccurrences(document, file) {
216
- const bodyStart = bodyStartOf(document.content);
217
- return occurrencesIn(document.content.slice(bodyStart), file, bodyStart);
221
+ return linksIn(destinations(inventoryOf(document)), file);
218
222
  }
219
223
  export function bodyLinks(body, file) {
220
- return linksIn(body, file);
224
+ return linksIn(hrefOccurrences(body), file);
221
225
  }
222
226
  function internalOf(document) {
223
- const held = internals.get(document);
227
+ const held = heldOf(document);
224
228
  if (held !== undefined)
225
- return held;
229
+ return held.internal;
226
230
  const read = opened(document.content, '');
227
231
  if (!read.ok)
228
232
  return read.refusal;
@@ -303,7 +307,7 @@ function planner(document, internal) {
303
307
  const link = (href, to, at) => {
304
308
  if (occurrences === undefined) {
305
309
  occurrences = new Map();
306
- for (const occurrence of hrefOccurrences(content.slice(internal.bodyStart))) {
310
+ for (const occurrence of destinations(inventoryOf(document))) {
307
311
  const same = occurrences.get(occurrence.href);
308
312
  if (same === undefined)
309
313
  occurrences.set(occurrence.href, [occurrence]);
@@ -458,10 +462,6 @@ export function apply(document, changes) {
458
462
  export function serialize(document) {
459
463
  return document.content;
460
464
  }
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
465
  export function frontmatter(document) {
466
- return internals.get(document)?.root ?? null;
466
+ return heldOf(document)?.internal.root ?? null;
467
467
  }
@@ -0,0 +1,78 @@
1
+ import { type Definition } from './definition.js';
2
+ import type { Candidate } from './query/match.js';
3
+ import type { Document, VerifiedModel } from './types.js';
4
+ export type FactKind = 'string' | 'number' | 'boolean' | 'date' | 'time' | 'enum' | 'reference';
5
+ type Scalar = string | number | boolean;
6
+ export type Fact = {
7
+ readonly kind: FactKind;
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;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG1D,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;AAEhG,KAAK,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAExC,MAAM,MAAM,IAAI,GACZ;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7E;IAAE,QAAQ,CAAC,IAAI,EAAE,O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