@graview/core 0.1.17 → 0.1.19

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 (158) hide show
  1. package/README.md +6 -0
  2. package/dist/arrangement.d.ts.map +1 -1
  3. package/dist/arrangement.js +1 -1
  4. package/dist/arrangement.js.map +1 -1
  5. package/dist/blocks.d.ts +2 -2
  6. package/dist/blocks.d.ts.map +1 -1
  7. package/dist/blocks.js +1 -1
  8. package/dist/blocks.js.map +1 -1
  9. package/dist/capabilities.js +1 -1
  10. package/dist/capabilities.js.map +1 -1
  11. package/dist/capital.d.ts +3 -0
  12. package/dist/capital.d.ts.map +1 -0
  13. package/dist/capital.js +3 -0
  14. package/dist/capital.js.map +1 -0
  15. package/dist/cli/check/relations.d.ts +9 -0
  16. package/dist/cli/check/relations.d.ts.map +1 -1
  17. package/dist/cli/check/relations.js +50 -1
  18. package/dist/cli/check/relations.js.map +1 -1
  19. package/dist/cli/check.d.ts.map +1 -1
  20. package/dist/cli/check.js +2 -1
  21. package/dist/cli/check.js.map +1 -1
  22. package/dist/cli/describe.d.ts.map +1 -1
  23. package/dist/cli/describe.js +3 -2
  24. package/dist/cli/describe.js.map +1 -1
  25. package/dist/compiled.js +12 -1
  26. package/dist/compiled.js.map +1 -1
  27. package/dist/days.d.ts +12 -0
  28. package/dist/days.d.ts.map +1 -0
  29. package/dist/days.js +33 -0
  30. package/dist/days.js.map +1 -0
  31. package/dist/document/blocks.d.ts +11 -1
  32. package/dist/document/blocks.d.ts.map +1 -1
  33. package/dist/document/blocks.js +94 -2
  34. package/dist/document/blocks.js.map +1 -1
  35. package/dist/document/compile.d.ts.map +1 -1
  36. package/dist/document/compile.js +2 -0
  37. package/dist/document/compile.js.map +1 -1
  38. package/dist/document/compiled.d.ts.map +1 -1
  39. package/dist/document/compiled.js +9 -1
  40. package/dist/document/compiled.js.map +1 -1
  41. package/dist/document/describe-coverage.d.ts +1 -1
  42. package/dist/document/describe-coverage.d.ts.map +1 -1
  43. package/dist/document/describe-place.d.ts +3 -1
  44. package/dist/document/describe-place.d.ts.map +1 -1
  45. package/dist/document/describe-place.js +17 -11
  46. package/dist/document/describe-place.js.map +1 -1
  47. package/dist/document/diff.d.ts.map +1 -1
  48. package/dist/document/diff.js +11 -5
  49. package/dist/document/diff.js.map +1 -1
  50. package/dist/document/edit.d.ts +1 -1
  51. package/dist/document/edit.d.ts.map +1 -1
  52. package/dist/document/edit.js +63 -7
  53. package/dist/document/edit.js.map +1 -1
  54. package/dist/document/expr/evaluate.d.ts +1 -1
  55. package/dist/document/expr/evaluate.d.ts.map +1 -1
  56. package/dist/document/migrate.d.ts +2 -1
  57. package/dist/document/migrate.d.ts.map +1 -1
  58. package/dist/document/migrate.js +1 -1
  59. package/dist/document/migrate.js.map +1 -1
  60. package/dist/document/page-fields.d.ts +11 -0
  61. package/dist/document/page-fields.d.ts.map +1 -0
  62. package/dist/document/page-fields.js +59 -0
  63. package/dist/document/page-fields.js.map +1 -0
  64. package/dist/document/rules.d.ts.map +1 -1
  65. package/dist/document/rules.js +5 -0
  66. package/dist/document/rules.js.map +1 -1
  67. package/dist/document/schema.d.ts +14 -0
  68. package/dist/document/schema.d.ts.map +1 -1
  69. package/dist/document/schema.js +10 -0
  70. package/dist/document/schema.js.map +1 -1
  71. package/dist/document/template.d.ts +1 -1
  72. package/dist/document/template.d.ts.map +1 -1
  73. package/dist/document/template.js +5 -2
  74. package/dist/document/template.js.map +1 -1
  75. package/dist/document/to-document.d.ts +2 -1
  76. package/dist/document/to-document.d.ts.map +1 -1
  77. package/dist/document/to-document.js +6 -0
  78. package/dist/document/to-document.js.map +1 -1
  79. package/dist/index.d.ts +10 -7
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +7 -5
  82. package/dist/index.js.map +1 -1
  83. package/dist/intelligence-bridge.d.ts +28 -0
  84. package/dist/intelligence-bridge.d.ts.map +1 -1
  85. package/dist/intelligence-bridge.js +10 -0
  86. package/dist/intelligence-bridge.js.map +1 -1
  87. package/dist/invariants/engine.d.ts.map +1 -1
  88. package/dist/invariants/engine.js +14 -1
  89. package/dist/invariants/engine.js.map +1 -1
  90. package/dist/mutations/form.d.ts +2 -0
  91. package/dist/mutations/form.d.ts.map +1 -1
  92. package/dist/mutations/form.js +1 -1
  93. package/dist/mutations/form.js.map +1 -1
  94. package/dist/mutations/node-ref.d.ts +4 -1
  95. package/dist/mutations/node-ref.d.ts.map +1 -1
  96. package/dist/mutations/node-ref.js +3 -1
  97. package/dist/mutations/node-ref.js.map +1 -1
  98. package/dist/places.d.ts +16 -0
  99. package/dist/places.d.ts.map +1 -1
  100. package/dist/places.js +29 -20
  101. package/dist/places.js.map +1 -1
  102. package/dist/refusal.d.ts +3 -26
  103. package/dist/refusal.d.ts.map +1 -1
  104. package/dist/refusal.js +1 -25
  105. package/dist/refusal.js.map +1 -1
  106. package/dist/refused.d.ts +26 -1
  107. package/dist/refused.d.ts.map +1 -1
  108. package/dist/refused.js +25 -0
  109. package/dist/refused.js.map +1 -1
  110. package/dist/retry.d.ts +52 -0
  111. package/dist/retry.d.ts.map +1 -0
  112. package/dist/retry.js +91 -0
  113. package/dist/retry.js.map +1 -0
  114. package/dist/scaffold/project.d.ts.map +1 -1
  115. package/dist/scaffold/project.js +5 -0
  116. package/dist/scaffold/project.js.map +1 -1
  117. package/dist/scaffold/ui.d.ts.map +1 -1
  118. package/dist/scaffold/ui.js +17 -7
  119. package/dist/scaffold/ui.js.map +1 -1
  120. package/dist/scene-districts.d.ts.map +1 -1
  121. package/dist/scene-districts.js +2 -2
  122. package/dist/scene-districts.js.map +1 -1
  123. package/dist/schema/define-node.d.ts +85 -2
  124. package/dist/schema/define-node.d.ts.map +1 -1
  125. package/dist/schema/define-node.js +137 -18
  126. package/dist/schema/define-node.js.map +1 -1
  127. package/dist/schema/types.d.ts +20 -0
  128. package/dist/schema/types.d.ts.map +1 -1
  129. package/dist/search.d.ts +1 -1
  130. package/dist/search.d.ts.map +1 -1
  131. package/dist/search.js +60 -18
  132. package/dist/search.js.map +1 -1
  133. package/dist/store.d.ts +7 -0
  134. package/dist/store.d.ts.map +1 -1
  135. package/dist/store.js +13 -1
  136. package/dist/store.js.map +1 -1
  137. package/dist/sync/conflict.d.ts +1 -1
  138. package/dist/sync/conflict.d.ts.map +1 -1
  139. package/dist/sync/engine.d.ts +2 -10
  140. package/dist/sync/engine.d.ts.map +1 -1
  141. package/dist/sync/engine.js.map +1 -1
  142. package/dist/sync/types.d.ts +9 -0
  143. package/dist/sync/types.d.ts.map +1 -1
  144. package/dist/version.d.ts +1 -1
  145. package/dist/version.js +1 -1
  146. package/dist/via.d.ts +15 -0
  147. package/dist/via.d.ts.map +1 -0
  148. package/dist/via.js +29 -0
  149. package/dist/via.js.map +1 -0
  150. package/dist/views/types.d.ts +46 -0
  151. package/dist/views/types.d.ts.map +1 -1
  152. package/dist/views/types.js +34 -1
  153. package/dist/views/types.js.map +1 -1
  154. package/dist/who.d.ts +0 -6
  155. package/dist/who.d.ts.map +1 -1
  156. package/dist/who.js +0 -20
  157. package/dist/who.js.map +1 -1
  158. package/package.json +5 -1
@@ -16,6 +16,8 @@ import { canonicalize } from "./canonical.js";
16
16
  import { quotedAtTheEnd } from "./quote.js";
17
17
  import { respellDocument } from "./respell.js";
18
18
  import { accentProblem } from "../theme/accent.js";
19
+ import { pageFieldFindings, pageNames, renamedOnPage, withoutOnPage } from "./page-fields.js";
20
+ import { capitalize } from "../capital.js";
19
21
  /** The ops, for tool schemas and the guide. */
20
22
  export const EDIT_OPS = [
21
23
  "add-kind",
@@ -43,6 +45,7 @@ export const EDIT_OPS = [
43
45
  "set-describe",
44
46
  "set-view",
45
47
  "set-glance",
48
+ "set-page-fields",
46
49
  "add-lens",
47
50
  "remove-lens",
48
51
  "set-home",
@@ -100,6 +103,15 @@ const SHAPES = {
100
103
  // A kind's slot; the front page (`slot: "home"`, no kind); or a blocks lens's blocks, by its title (FR-84).
101
104
  "set-view": z.object({ op: z.literal("set-view"), kind: kindName.optional(), slot: z.enum([...VIEW_SLOTS, "home"]).optional(), lens: lensTitle.optional(), blocks: z.union([z.array(z.unknown()).min(1), z.null()]) }).strict(),
102
105
  "set-glance": z.object({ op: z.literal("set-glance"), kind: kindName, fields: z.array(fieldName).max(20) }).strict(),
106
+ // How a record's page orders and groups its facts (FR-148): these first, then each group under its title; none of either takes the choice away.
107
+ "set-page-fields": z
108
+ .object({
109
+ op: z.literal("set-page-fields"),
110
+ kind: kindName,
111
+ fields: z.array(fieldName).max(40),
112
+ groups: z.union([z.array(z.object({ title: z.string().min(1).max(60), fields: z.array(fieldName).min(1).max(40) }).strict()).max(12), z.null()]).optional(),
113
+ })
114
+ .strict(),
103
115
  "add-lens": z
104
116
  .object({
105
117
  op: z.literal("add-lens"),
@@ -548,7 +560,7 @@ class Editor {
548
560
  if (unknown)
549
561
  return this.fail(i, "accents", `"${unknown}" is not a kind this app has; it has ${Object.keys(this.doc.kinds).join(", ")}`);
550
562
  }
551
- merge("accents", (kind, hue) => (hue === null ? `${cap(kind)} goes back to its own hue.` : `${cap(kind)} is drawn at hue ${hue}°.`), "Every kind goes back to its own hue.");
563
+ merge("accents", (kind, hue) => (hue === null ? `${capitalize(kind)} goes back to its own hue.` : `${capitalize(kind)} is drawn at hue ${hue}°.`), "Every kind goes back to its own hue.");
552
564
  if (e.scheme !== undefined) {
553
565
  if (e.scheme === null || e.scheme === "auto")
554
566
  delete brand["scheme"];
@@ -759,6 +771,8 @@ class Editor {
759
771
  }
760
772
  return;
761
773
  }
774
+ case "set-page-fields":
775
+ return this.setPageFields(i, e);
762
776
  case "add-lens":
763
777
  return this.addLens(i, e);
764
778
  case "remove-lens":
@@ -771,6 +785,28 @@ class Editor {
771
785
  return this.setComputed(i, e);
772
786
  }
773
787
  }
788
+ /** How a record's page orders and groups its facts (FR-148): judged as the compile judges `kinds.<kind>.page`. */
789
+ setPageFields(i, e) {
790
+ const spec = this.kind(i, e.kind);
791
+ if (!spec)
792
+ return;
793
+ const fields = e.fields;
794
+ const groups = e.groups ?? [];
795
+ const noun = spec.noun ?? words(e.kind);
796
+ const a = /^[aeiou]/i.test(noun) ? "An" : "A";
797
+ if (fields.length === 0 && groups.length === 0) {
798
+ delete spec.page;
799
+ this.said.push(`${a} ${noun}'s page shows its facts in the order the kind declares them.`);
800
+ return;
801
+ }
802
+ const page = { ...(fields.length > 0 ? { fields: [...fields] } : {}), ...(groups.length > 0 ? { groups: groups.map((group) => ({ title: group.title, fields: [...group.fields] })) } : {}) };
803
+ const wrong = pageFieldFindings(e.kind, { ...spec, page }, "")[0];
804
+ if (wrong)
805
+ return this.fail(i, wrong.path.replace(/^\./, ""), wrong.message, wrong.fix);
806
+ spec.page = page;
807
+ const shown = [...(fields.length > 0 ? [`${listOf(fields)} first`] : []), ...groups.map((group) => `${listOf(group.fields)} under "${group.title}"`)];
808
+ this.said.push(`${a} ${noun}'s page shows ${listOf(shown)}, and the rest ${groups.length > 0 ? 'under "Details"' : "after them"}.`);
809
+ }
774
810
  // ── views, the front page, lenses, the arrangement, what is worked out (FR-84) ──
775
811
  /** Blocks checked where they will stand: an error refuses the edit at that path, so a chat is told before anything is previewed. */
776
812
  blocksHold(i, at) {
@@ -819,13 +855,13 @@ class Editor {
819
855
  delete views[e.kind];
820
856
  if (Object.keys(views).length === 0)
821
857
  delete this.doc.views;
822
- this.said.push(`${cap(withA(noun))} ${e.slot} goes back to Graview's own look.`);
858
+ this.said.push(`${capitalize(withA(noun))} ${e.slot} goes back to Graview's own look.`);
823
859
  return;
824
860
  }
825
861
  (views[e.kind] ??= {})[e.slot] = e.blocks;
826
862
  if (!this.blocksHold(i, `views.${e.kind}.${e.slot}`))
827
863
  return;
828
- this.said.push(`${cap(withA(noun))} ${e.slot} gets a look of its own: ${blockWords(e.blocks)}.`);
864
+ this.said.push(`${capitalize(withA(noun))} ${e.slot} gets a look of its own: ${blockWords(e.blocks)}.`);
829
865
  }
830
866
  setHome(i, blocks) {
831
867
  const views = (this.doc.views ??= {});
@@ -941,7 +977,7 @@ class Editor {
941
977
  if (index < 0)
942
978
  return;
943
979
  const said = this.removeLensAt(index);
944
- this.said.push(`${cap(said.replace(/ \(the app opens at its home again\)$/, ""))} is removed${said.endsWith("again)") ? "; the app opens at its home again" : ""}.`);
980
+ this.said.push(`${capitalize(said.replace(/ \(the app opens at its home again\)$/, ""))} is removed${said.endsWith("again)") ? "; the app opens at its home again" : ""}.`);
945
981
  }
946
982
  arrangePages(i, given) {
947
983
  // `overview` is the scene's word as 0.1.15 and 0.1.16 took it (FR-134): read as `scene`, which wins when both are said.
@@ -1013,7 +1049,7 @@ class Editor {
1013
1049
  }
1014
1050
  if (Object.keys(pages).length === 0)
1015
1051
  delete this.doc.pages;
1016
- this.said.push(`${cap(listOf(said))}.`);
1052
+ this.said.push(`${capitalize(listOf(said))}.`);
1017
1053
  }
1018
1054
  /** Whether `first` names something the app can open on: home, a kind or its plural, a titled lens. */
1019
1055
  opens(first) {
@@ -1031,7 +1067,7 @@ class Editor {
1031
1067
  if (!spec)
1032
1068
  return;
1033
1069
  const name = e.name;
1034
- const plural = cap(pluralWords(this.doc, e.kind));
1070
+ const plural = capitalize(pluralWords(this.doc, e.kind));
1035
1071
  const existing = spec.computed?.[name];
1036
1072
  if (e.expr === null) {
1037
1073
  if (existing === undefined)
@@ -1340,6 +1376,10 @@ class Editor {
1340
1376
  spec.glance = spec.glance.map((name) => (name === field ? to : name));
1341
1377
  touched.push(`${kind}'s glance`);
1342
1378
  }
1379
+ if (pageNames(spec.page, field)) {
1380
+ spec.page = renamedOnPage(spec.page, field, to);
1381
+ touched.push(`${kind}'s page`);
1382
+ }
1343
1383
  for (const x of this.fills) {
1344
1384
  if (x.kind === kind && x.field === field)
1345
1385
  x.field = to;
@@ -1470,6 +1510,16 @@ class Editor {
1470
1510
  gone.push(`${kind}'s glance`);
1471
1511
  }
1472
1512
  }
1513
+ // Its page shows the fields that are left; one that showed only this one goes back to the declared order.
1514
+ if (pageNames(spec.page, field)) {
1515
+ const page = withoutOnPage(spec.page, field);
1516
+ if (page)
1517
+ spec.page = page;
1518
+ else {
1519
+ delete spec.page;
1520
+ gone.push(`${kind}'s page order`);
1521
+ }
1522
+ }
1473
1523
  for (const x of [...this.fills])
1474
1524
  if (x.kind === kind && (x.field === field || x.from === field))
1475
1525
  this.fills.splice(this.fills.indexOf(x), 1);
@@ -1966,6 +2016,13 @@ class Editor {
1966
2016
  if (spec.glance.length === 0)
1967
2017
  delete spec.glance;
1968
2018
  }
2019
+ if (pageNames(spec.page, name)) {
2020
+ const page = withoutOnPage(spec.page, name);
2021
+ if (page)
2022
+ spec.page = page;
2023
+ else
2024
+ delete spec.page;
2025
+ }
1969
2026
  }
1970
2027
  this.dropping.delete(key);
1971
2028
  return gone;
@@ -2173,7 +2230,6 @@ function mapBlocks(blocks, f) {
2173
2230
  return out;
2174
2231
  }
2175
2232
  // ── words for what changed ───────────────────────────────────────────────────
2176
- const cap = (text) => text.charAt(0).toUpperCase() + text.slice(1);
2177
2233
  const withA = (noun) => `${/^[aeiou]/i.test(noun) ? "an" : "a"} ${noun}`;
2178
2234
  const nounOf = (doc, kind) => doc.kinds[kind]?.noun ?? words(kind);
2179
2235
  /** A kind's plural as a person reads it: "packages", "people and teams". */