@graview/core 0.2.3 → 0.2.5

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 (190) hide show
  1. package/dist/across-copies.d.ts +3 -0
  2. package/dist/across-copies.d.ts.map +1 -0
  3. package/dist/across-copies.js +39 -0
  4. package/dist/across-copies.js.map +1 -0
  5. package/dist/binding-served.d.ts +11 -2
  6. package/dist/binding-served.d.ts.map +1 -1
  7. package/dist/binding-served.js +19 -0
  8. package/dist/binding-served.js.map +1 -1
  9. package/dist/binding.d.ts +25 -0
  10. package/dist/binding.d.ts.map +1 -1
  11. package/dist/binding.js +128 -19
  12. package/dist/binding.js.map +1 -1
  13. package/dist/capabilities.js +1 -1
  14. package/dist/capabilities.js.map +1 -1
  15. package/dist/catalog.d.ts.map +1 -1
  16. package/dist/catalog.js +37 -1
  17. package/dist/catalog.js.map +1 -1
  18. package/dist/check.d.ts +3 -0
  19. package/dist/check.d.ts.map +1 -1
  20. package/dist/check.js +3 -0
  21. package/dist/check.js.map +1 -1
  22. package/dist/cited.d.ts +55 -0
  23. package/dist/cited.d.ts.map +1 -0
  24. package/dist/cited.js +48 -0
  25. package/dist/cited.js.map +1 -0
  26. package/dist/cli/check/cites.d.ts +4 -0
  27. package/dist/cli/check/cites.d.ts.map +1 -0
  28. package/dist/cli/check/cites.js +35 -0
  29. package/dist/cli/check/cites.js.map +1 -0
  30. package/dist/cli/check/context-of.d.ts +12 -0
  31. package/dist/cli/check/context-of.d.ts.map +1 -0
  32. package/dist/cli/check/context-of.js +25 -0
  33. package/dist/cli/check/context-of.js.map +1 -0
  34. package/dist/cli/check/index.d.ts +1 -0
  35. package/dist/cli/check/index.d.ts.map +1 -1
  36. package/dist/cli/check/index.js +1 -0
  37. package/dist/cli/check/index.js.map +1 -1
  38. package/dist/cli/check/policy.d.ts.map +1 -1
  39. package/dist/cli/check/policy.js +28 -3
  40. package/dist/cli/check/policy.js.map +1 -1
  41. package/dist/cli/check.d.ts.map +1 -1
  42. package/dist/cli/check.js +4 -12
  43. package/dist/cli/check.js.map +1 -1
  44. package/dist/cli/index.d.ts +1 -1
  45. package/dist/cli/index.d.ts.map +1 -1
  46. package/dist/cli/index.js +42 -3
  47. package/dist/cli/index.js.map +1 -1
  48. package/dist/compose-change.d.ts +33 -0
  49. package/dist/compose-change.d.ts.map +1 -0
  50. package/dist/compose-change.js +43 -0
  51. package/dist/compose-change.js.map +1 -0
  52. package/dist/compose-home.d.ts +46 -6
  53. package/dist/compose-home.d.ts.map +1 -1
  54. package/dist/compose-home.js +189 -47
  55. package/dist/compose-home.js.map +1 -1
  56. package/dist/compose.d.ts +6 -4
  57. package/dist/compose.d.ts.map +1 -1
  58. package/dist/compose.js +18 -39
  59. package/dist/compose.js.map +1 -1
  60. package/dist/composer-check.d.ts +16 -0
  61. package/dist/composer-check.d.ts.map +1 -0
  62. package/dist/composer-check.js +48 -0
  63. package/dist/composer-check.js.map +1 -0
  64. package/dist/composer.d.ts +19 -0
  65. package/dist/composer.d.ts.map +1 -0
  66. package/dist/composer.js +49 -0
  67. package/dist/composer.js.map +1 -0
  68. package/dist/css/faces-words.d.ts.map +1 -1
  69. package/dist/css/faces-words.js +2 -0
  70. package/dist/css/faces-words.js.map +1 -1
  71. package/dist/css/faces.d.ts +1 -1
  72. package/dist/css/faces.d.ts.map +1 -1
  73. package/dist/css/sanitize.d.ts +5 -1
  74. package/dist/css/sanitize.d.ts.map +1 -1
  75. package/dist/css/sanitize.js +16 -1
  76. package/dist/css/sanitize.js.map +1 -1
  77. package/dist/document/compile.d.ts.map +1 -1
  78. package/dist/document/compile.js +5 -2
  79. package/dist/document/compile.js.map +1 -1
  80. package/dist/document/compiled.d.ts.map +1 -1
  81. package/dist/document/compiled.js +6 -0
  82. package/dist/document/compiled.js.map +1 -1
  83. package/dist/document/design-findings.d.ts.map +1 -1
  84. package/dist/document/design-findings.js +2 -1
  85. package/dist/document/design-findings.js.map +1 -1
  86. package/dist/document/edit.d.ts +1 -1
  87. package/dist/document/edit.d.ts.map +1 -1
  88. package/dist/document/edit.js +184 -152
  89. package/dist/document/edit.js.map +1 -1
  90. package/dist/document/expr/evaluate.d.ts +3 -1
  91. package/dist/document/expr/evaluate.d.ts.map +1 -1
  92. package/dist/document/expr/evaluate.js +29 -1
  93. package/dist/document/expr/evaluate.js.map +1 -1
  94. package/dist/document/expr/typing.d.ts.map +1 -1
  95. package/dist/document/expr/typing.js +1 -0
  96. package/dist/document/expr/typing.js.map +1 -1
  97. package/dist/document/field-spec.d.ts.map +1 -1
  98. package/dist/document/field-spec.js +6 -1
  99. package/dist/document/field-spec.js.map +1 -1
  100. package/dist/document/format-findings.d.ts.map +1 -1
  101. package/dist/document/format-findings.js +8 -0
  102. package/dist/document/format-findings.js.map +1 -1
  103. package/dist/document/instantiate-template.d.ts.map +1 -1
  104. package/dist/document/instantiate-template.js +16 -1
  105. package/dist/document/instantiate-template.js.map +1 -1
  106. package/dist/document/rules.d.ts.map +1 -1
  107. package/dist/document/rules.js +4 -0
  108. package/dist/document/rules.js.map +1 -1
  109. package/dist/document/schema.d.ts +5 -0
  110. package/dist/document/schema.d.ts.map +1 -1
  111. package/dist/document/schema.js +7 -0
  112. package/dist/document/schema.js.map +1 -1
  113. package/dist/document/uncited-findings.d.ts +9 -0
  114. package/dist/document/uncited-findings.d.ts.map +1 -0
  115. package/dist/document/uncited-findings.js +10 -0
  116. package/dist/document/uncited-findings.js.map +1 -0
  117. package/dist/document.schema.json +12 -2
  118. package/dist/graph/graph.d.ts.map +1 -1
  119. package/dist/graph/graph.js +4 -0
  120. package/dist/graph/graph.js.map +1 -1
  121. package/dist/index.d.ts +5 -4
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +6 -4
  124. package/dist/index.js.map +1 -1
  125. package/dist/mutations/define-mutation.d.ts +8 -0
  126. package/dist/mutations/define-mutation.d.ts.map +1 -1
  127. package/dist/mutations/define-mutation.js +23 -1
  128. package/dist/mutations/define-mutation.js.map +1 -1
  129. package/dist/mutations/invalid-arguments.d.ts.map +1 -1
  130. package/dist/mutations/invalid-arguments.js +3 -0
  131. package/dist/mutations/invalid-arguments.js.map +1 -1
  132. package/dist/ops/revisions.d.ts.map +1 -1
  133. package/dist/ops/revisions.js +10 -3
  134. package/dist/ops/revisions.js.map +1 -1
  135. package/dist/ops/undo.d.ts.map +1 -1
  136. package/dist/ops/undo.js +49 -1
  137. package/dist/ops/undo.js.map +1 -1
  138. package/dist/permissions/policy.d.ts +19 -18
  139. package/dist/permissions/policy.d.ts.map +1 -1
  140. package/dist/permissions/policy.js +27 -22
  141. package/dist/permissions/policy.js.map +1 -1
  142. package/dist/permissions/types.d.ts.map +1 -1
  143. package/dist/permissions/types.js +3 -0
  144. package/dist/permissions/types.js.map +1 -1
  145. package/dist/persistence/memory.d.ts.map +1 -1
  146. package/dist/persistence/memory.js +6 -0
  147. package/dist/persistence/memory.js.map +1 -1
  148. package/dist/persistence/sql.d.ts.map +1 -1
  149. package/dist/persistence/sql.js +18 -0
  150. package/dist/persistence/sql.js.map +1 -1
  151. package/dist/persistence/types.d.ts +10 -0
  152. package/dist/persistence/types.d.ts.map +1 -1
  153. package/dist/refused.d.ts.map +1 -1
  154. package/dist/refused.js +3 -0
  155. package/dist/refused.js.map +1 -1
  156. package/dist/schema/cites.d.ts +30 -0
  157. package/dist/schema/cites.d.ts.map +1 -0
  158. package/dist/schema/cites.js +70 -0
  159. package/dist/schema/cites.js.map +1 -0
  160. package/dist/schema/files.d.ts +28 -0
  161. package/dist/schema/files.d.ts.map +1 -1
  162. package/dist/schema/files.js +13 -1
  163. package/dist/schema/files.js.map +1 -1
  164. package/dist/schema/reading.d.ts.map +1 -1
  165. package/dist/schema/reading.js +3 -2
  166. package/dist/schema/reading.js.map +1 -1
  167. package/dist/schema/schema.d.ts.map +1 -1
  168. package/dist/schema/schema.js +3 -0
  169. package/dist/schema/schema.js.map +1 -1
  170. package/dist/seen.d.ts +8 -0
  171. package/dist/seen.d.ts.map +1 -1
  172. package/dist/seen.js +6 -4
  173. package/dist/seen.js.map +1 -1
  174. package/dist/store.d.ts +12 -5
  175. package/dist/store.d.ts.map +1 -1
  176. package/dist/store.js +74 -35
  177. package/dist/store.js.map +1 -1
  178. package/dist/tidying.d.ts +2 -0
  179. package/dist/tidying.d.ts.map +1 -1
  180. package/dist/tidying.js +2 -0
  181. package/dist/tidying.js.map +1 -1
  182. package/dist/version.d.ts +1 -1
  183. package/dist/version.js +1 -1
  184. package/dist/views/types.d.ts +7 -0
  185. package/dist/views/types.d.ts.map +1 -1
  186. package/dist/views/types.js.map +1 -1
  187. package/dist/who.d.ts.map +1 -1
  188. package/dist/who.js +7 -3
  189. package/dist/who.js.map +1 -1
  190. package/package.json +5 -1
@@ -2,7 +2,7 @@ import { BIND_PERSON } from "../binding-served.js";
2
2
  import { BINDING_UNGRANTED } from "../binding-ungranted.js";
3
3
  import { DERIVED_ACTS, derivedActOf, derivedActsOf, givenWhenNeverArchived, givenWhenNeverTidied, RELATION_ACTS, relationActName, relationActsOf } from "../mutations/derived-names.js";
4
4
  import { documentRelations, givesRelationAct, renamedRelationAct } from "./relation-acts.js";
5
- import * as z from "zod";
5
+ import * as z from "../schema/zod.js";
6
6
  import { ExprSyntaxError, parseExpr } from "./expr/parse.js";
7
7
  import { printExpr } from "./expr/print.js";
8
8
  import { dollarOf, SUBJECT_NAME } from "./expr/subject.js";
@@ -68,6 +68,7 @@ export const EDIT_OPS = [
68
68
  "set-required",
69
69
  "set-default",
70
70
  "set-repeats",
71
+ "set-cites",
71
72
  "remove-field",
72
73
  "add-relation",
73
74
  "rename-relation",
@@ -129,204 +130,187 @@ const VIEW_NAME = /^[a-z0-9][a-z0-9-]{0,62}$/;
129
130
  * never edits one does not build sixty zod schemas to get there.
130
131
  */
131
132
  function buildShapes() {
132
- const kindName = z.string().regex(NAME, 'kind names are lower-case words joined by hyphens, like "guest-list"');
133
- const listKey = z.string().min(1).max(120);
134
- const listDirection = z.enum(["asc", "desc"]).optional();
135
- const listSortShape = z.union([listKey, z.object({ by: listKey, direction: listDirection, then: z.union([listKey, z.object({ by: listKey, direction: listDirection }).strict()]).optional() }).strict()]);
136
- const listGroupShape = z.union([listKey, z.object({ by: listKey, order: z.array(z.string().min(1).max(80)).max(40).optional(), closed: z.array(z.string().min(1).max(80)).max(40).optional() }).strict()]);
137
- const fieldName = z.string().regex(FIELD_NAME, 'field names are one word or camelCase, like "dueDate"');
138
- const edgeName = z.string().regex(EDGE_NAME, 'relation names are one camelCase word, like "tendedBy"');
139
- const actName = z.string().regex(NAME, 'act names are lower-case words joined by hyphens, like "mark-paid"');
140
- const lensTitle = z.string().min(1).max(80);
141
- const jobName = z.string().regex(NAME, 'job names are lower-case words joined by hyphens, like "unbooked-soon"');
133
+ const kindName = z.string().check(z.regex(NAME, 'kind names are lower-case words joined by hyphens, like "guest-list"'));
134
+ const listKey = z.string().check(z.minLength(1), z.maxLength(120));
135
+ const listDirection = z.optional(z.enum(["asc", "desc"]));
136
+ const listSortShape = z.union([listKey, z.strictObject({ by: listKey, direction: listDirection, then: z.optional(z.union([listKey, z.strictObject({ by: listKey, direction: listDirection })])) })]);
137
+ const listGroupShape = z.union([listKey, z.strictObject({ by: listKey, order: z.optional(z.array(z.string().check(z.minLength(1), z.maxLength(80))).check(z.maxLength(40))), closed: z.optional(z.array(z.string().check(z.minLength(1), z.maxLength(80))).check(z.maxLength(40))) })]);
138
+ const fieldName = z.string().check(z.regex(FIELD_NAME, 'field names are one word or camelCase, like "dueDate"'));
139
+ const edgeName = z.string().check(z.regex(EDGE_NAME, 'relation names are one camelCase word, like "tendedBy"'));
140
+ const actName = z.string().check(z.regex(NAME, 'act names are lower-case words joined by hyphens, like "mark-paid"'));
141
+ const lensTitle = z.string().check(z.minLength(1), z.maxLength(80));
142
+ const jobName = z.string().check(z.regex(NAME, 'job names are lower-case words joined by hyphens, like "unbooked-soon"'));
142
143
  return {
143
- "add-kind": z.object({ op: z.literal("add-kind"), kind: kindName, act: z.boolean().optional() }).passthrough(),
144
- "rename-kind": z.object({ op: z.literal("rename-kind"), kind: kindName, to: kindName, noun: z.string().min(1).max(40).optional(), plural: z.string().min(1).max(40).optional() }).strict(),
145
- "remove-kind": z.object({ op: z.literal("remove-kind"), kind: kindName }).strict(),
146
- "add-field": z.object({ op: z.literal("add-field"), kind: kindName, field: fieldName, fill: z.unknown().optional(), spec: z.record(z.string(), z.unknown()).optional() }).passthrough(),
147
- "rename-field": z.object({ op: z.literal("rename-field"), kind: kindName, field: fieldName, to: fieldName }).strict(),
148
- "retype-field": z.object({ op: z.literal("retype-field"), kind: kindName, field: fieldName, type: z.enum(FIELD_TYPES), options: z.array(z.string().min(1).max(80)).min(1).max(100).optional(), multiple: z.boolean().optional(), of: z.enum(["string", "number", "date", "image", "video", "file"]).optional(), format: z.enum(["money", "percent", "duration", "markdown"]).optional() }).strict(),
149
- "set-options": z.object({ op: z.literal("set-options"), kind: kindName, field: fieldName, add: z.array(z.string().min(1).max(80)).optional(), remove: z.array(z.string().min(1).max(80)).optional(), labels: z.record(z.string().min(1).max(80), z.union([z.string().min(1).max(80), z.null()])).optional() }).strict(),
150
- "set-format": z.object({ op: z.literal("set-format"), kind: kindName, field: fieldName, format: z.union([z.enum(["money", "percent", "duration", "markdown"]), z.null()]).optional(), unit: z.union([z.string().min(1).max(12), z.null()]).optional(), places: z.union([z.literal(0), z.null()]).optional() }).strict(),
151
- "set-range": z.object({ op: z.literal("set-range"), kind: kindName, field: fieldName, min: z.union([z.number(), z.null()]).optional(), max: z.union([z.number(), z.null()]).optional(), step: z.union([z.number().positive(), z.null()]).optional() }).strict(),
152
- "set-required": z.object({ op: z.literal("set-required"), kind: kindName, field: fieldName, required: z.boolean() }).strict(),
153
- "set-default": z.object({ op: z.literal("set-default"), kind: kindName, field: fieldName, default: z.unknown() }).strict(),
154
- "set-repeats": z.object({ op: z.literal("set-repeats"), kind: kindName, field: fieldName, repeats: z.boolean() }).strict(),
155
- "remove-field": z.object({ op: z.literal("remove-field"), kind: kindName, field: fieldName }).strict(),
156
- "add-relation": z.object({ op: z.literal("add-relation"), kind: kindName, relation: edgeName }).passthrough(),
157
- "rename-relation": z.object({ op: z.literal("rename-relation"), kind: kindName, relation: edgeName, to: edgeName }).strict(),
158
- "remove-relation": z.object({ op: z.literal("remove-relation"), kind: kindName, relation: edgeName }).strict(),
159
- "add-act": z.object({ op: z.literal("add-act"), act: actName, replace: z.boolean().optional() }).passthrough(),
160
- "remove-act": z.object({ op: z.literal("remove-act"), act: actName }).strict(),
161
- "add-rule": z.object({ op: z.literal("add-rule"), rule: actName, replace: z.boolean().optional() }).passthrough(),
162
- "remove-rule": z.object({ op: z.literal("remove-rule"), rule: actName }).strict(),
163
- "set-brand": z
164
- .object({
144
+ "add-kind": z.looseObject({ op: z.literal("add-kind"), kind: kindName, act: z.optional(z.boolean()) }),
145
+ "rename-kind": z.strictObject({ op: z.literal("rename-kind"), kind: kindName, to: kindName, noun: z.optional(z.string().check(z.minLength(1), z.maxLength(40))), plural: z.optional(z.string().check(z.minLength(1), z.maxLength(40))) }),
146
+ "remove-kind": z.strictObject({ op: z.literal("remove-kind"), kind: kindName }),
147
+ "add-field": z.looseObject({ op: z.literal("add-field"), kind: kindName, field: fieldName, fill: z.optional(z.unknown()), spec: z.optional(z.record(z.string(), z.unknown())) }),
148
+ "rename-field": z.strictObject({ op: z.literal("rename-field"), kind: kindName, field: fieldName, to: fieldName }),
149
+ "retype-field": z.strictObject({ op: z.literal("retype-field"), kind: kindName, field: fieldName, type: z.enum(FIELD_TYPES), options: z.optional(z.array(z.string().check(z.minLength(1), z.maxLength(80))).check(z.minLength(1), z.maxLength(100))), multiple: z.optional(z.boolean()), of: z.optional(z.enum(["string", "number", "date", "image", "video", "file"])), format: z.optional(z.enum(["money", "percent", "duration", "markdown"])) }),
150
+ "set-options": z.strictObject({ op: z.literal("set-options"), kind: kindName, field: fieldName, add: z.optional(z.array(z.string().check(z.minLength(1), z.maxLength(80)))), remove: z.optional(z.array(z.string().check(z.minLength(1), z.maxLength(80)))), labels: z.optional(z.record(z.string().check(z.minLength(1), z.maxLength(80)), z.union([z.string().check(z.minLength(1), z.maxLength(80)), z.null()]))) }),
151
+ "set-format": z.strictObject({ op: z.literal("set-format"), kind: kindName, field: fieldName, format: z.optional(z.union([z.enum(["money", "percent", "duration", "markdown"]), z.null()])), unit: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(12)), z.null()])), places: z.optional(z.union([z.literal(0), z.null()])) }),
152
+ "set-range": z.strictObject({ op: z.literal("set-range"), kind: kindName, field: fieldName, min: z.optional(z.union([z.number(), z.null()])), max: z.optional(z.union([z.number(), z.null()])), step: z.optional(z.union([z.number().check(z.positive()), z.null()])) }),
153
+ "set-required": z.strictObject({ op: z.literal("set-required"), kind: kindName, field: fieldName, required: z.boolean() }),
154
+ "set-default": z.strictObject({ op: z.literal("set-default"), kind: kindName, field: fieldName, default: z.unknown() }),
155
+ "set-repeats": z.strictObject({ op: z.literal("set-repeats"), kind: kindName, field: fieldName, repeats: z.boolean() }),
156
+ "set-cites": z.strictObject({ op: z.literal("set-cites"), kind: kindName, field: fieldName, cites: z.union([z.string().check(z.minLength(1), z.maxLength(80)), z.null()]) }),
157
+ "remove-field": z.strictObject({ op: z.literal("remove-field"), kind: kindName, field: fieldName }),
158
+ "add-relation": z.looseObject({ op: z.literal("add-relation"), kind: kindName, relation: edgeName }),
159
+ "rename-relation": z.strictObject({ op: z.literal("rename-relation"), kind: kindName, relation: edgeName, to: edgeName }),
160
+ "remove-relation": z.strictObject({ op: z.literal("remove-relation"), kind: kindName, relation: edgeName }),
161
+ "add-act": z.looseObject({ op: z.literal("add-act"), act: actName, replace: z.optional(z.boolean()) }),
162
+ "remove-act": z.strictObject({ op: z.literal("remove-act"), act: actName }),
163
+ "add-rule": z.looseObject({ op: z.literal("add-rule"), rule: actName, replace: z.optional(z.boolean()) }),
164
+ "remove-rule": z.strictObject({ op: z.literal("remove-rule"), rule: actName }),
165
+ "set-brand": z.strictObject({
165
166
  op: z.literal("set-brand"),
166
- accent: z.union([z.string(), z.null()]).optional(),
167
+ accent: z.optional(z.union([z.string(), z.null()])),
167
168
  // The page background (Roadmap f-brand-ground): one color, or one for each scheme; null for Graview's.
168
- ground: z.union([z.string(), z.object({ light: z.string().optional(), dark: z.string().optional() }).strict(), z.null()]).optional(),
169
- name: z.union([z.string().min(1).max(60), z.null()]).optional(),
170
- currency: z.union([z.string(), z.null()]).optional(),
171
- locale: z.union([z.string(), z.null()]).optional(),
169
+ ground: z.optional(z.union([z.string(), z.strictObject({ light: z.optional(z.string()), dark: z.optional(z.string()) }), z.null()])),
170
+ name: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(60)), z.null()])),
171
+ currency: z.optional(z.union([z.string(), z.null()])),
172
+ locale: z.optional(z.union([z.string(), z.null()])),
172
173
  // An IANA time zone its instants are said in (Roadmap f-app-time-zone).
173
- timeZone: z.union([z.string().min(1).max(64), z.null()]).optional(),
174
+ timeZone: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(64)), z.null()])),
174
175
  // The rest of the brand (FR-124, FR-125): each as the document holds it, null to clear it.
175
- logo: z
176
- .union([
177
- z.string().min(1),
178
- z.object({ src: z.string().min(1), alt: z.string().min(1).max(120).optional() }).strict(),
176
+ logo: z.optional(z.union([
177
+ z.string().check(z.minLength(1)),
178
+ z.strictObject({ src: z.string().check(z.minLength(1)), alt: z.optional(z.string().check(z.minLength(1), z.maxLength(120))) }),
179
179
  // One for each scheme; with no dark one, `darkFallback: "invert"` asks for the light one inverted in the dark.
180
- z.object({ light: z.string().min(1), dark: z.string().min(1).optional(), alt: z.string().min(1).max(120).optional(), darkFallback: z.literal("invert").optional() }).strict(),
180
+ z.strictObject({ light: z.string().check(z.minLength(1)), dark: z.optional(z.string().check(z.minLength(1))), alt: z.optional(z.string().check(z.minLength(1), z.maxLength(120))), darkFallback: z.optional(z.literal("invert")) }),
181
181
  z.null(),
182
- ])
183
- .optional(),
184
- favicon: z.union([z.string().min(1), z.object({ emoji: z.string() }).strict(), z.null()]).optional(),
185
- typography: z.union([z.object({ display: z.union([z.string().min(1).max(200), z.null()]).optional(), body: z.union([z.string().min(1).max(200), z.null()]).optional(), mono: z.union([z.string().min(1).max(200), z.null()]).optional() }).strict(), z.null()]).optional(),
186
- shape: z.union([z.object({ radius: z.union([z.number().min(0).max(32), z.null()]).optional(), density: z.union([z.number().min(0.75).max(1.5), z.null()]).optional() }).strict(), z.null()]).optional(),
187
- accents: z.union([z.record(z.string(), z.union([z.number().min(0).max(360), z.null()])), z.null()]).optional(),
188
- scheme: z.union([z.enum(["light", "dark", "auto"]), z.null()]).optional(),
182
+ ])),
183
+ favicon: z.optional(z.union([z.string().check(z.minLength(1)), z.strictObject({ emoji: z.string() }), z.null()])),
184
+ typography: z.optional(z.union([z.strictObject({ display: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(200)), z.null()])), body: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(200)), z.null()])), mono: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(200)), z.null()])) }), z.null()])),
185
+ shape: z.optional(z.union([z.strictObject({ radius: z.optional(z.union([z.number().check(z.gte(0), z.lte(32)), z.null()])), density: z.optional(z.union([z.number().check(z.gte(0.75), z.lte(1.5)), z.null()])) }), z.null()])),
186
+ accents: z.optional(z.union([z.record(z.string(), z.union([z.number().check(z.gte(0), z.lte(360)), z.null()])), z.null()])),
187
+ scheme: z.optional(z.union([z.enum(["light", "dark", "auto"]), z.null()])),
189
188
  // Whether the home draws the description as the line under the name (Roadmap f-home-subtitle-separate): false keeps it off, true or null draws it again.
190
- subtitle: z.union([z.boolean(), z.null()]).optional(),
189
+ subtitle: z.optional(z.union([z.boolean(), z.null()])),
191
190
  // The opening screen (Roadmap f-splash-in-document), whole; null for Graview's own.
192
- splash: z.union([z.object({ style: z.string(), image: z.string().min(1).optional(), title: z.string().min(1).max(80).optional(), kicker: z.string().min(1).max(80).optional(), shader: z.string().min(1).max(40).optional(), scheme: z.enum(["light", "dark", "device"]).optional() }).strict(), z.null()]).optional(),
191
+ splash: z.optional(z.union([z.strictObject({ style: z.string(), image: z.optional(z.string().check(z.minLength(1))), title: z.optional(z.string().check(z.minLength(1), z.maxLength(80))), kicker: z.optional(z.string().check(z.minLength(1), z.maxLength(80))), shader: z.optional(z.string().check(z.minLength(1), z.maxLength(40))), scheme: z.optional(z.enum(["light", "dark", "device"])) }), z.null()])),
193
192
  // What every worker view inherits (Roadmap f-app-wide-view-theme): a stylesheet that wins over each view's own (its length the sanitizer's to refuse, in `brandFindings`), and a fade between records; null clears either, or all of it.
194
- views: z
195
- .union([
196
- z
197
- .object({
198
- css: z.union([z.string().min(1), z.null()]).optional(),
199
- motion: z.union([z.enum(["none", "fade"]), z.null()]).optional(),
193
+ views: z.optional(z.union([
194
+ z.strictObject({
195
+ css: z.optional(z.union([z.string().check(z.minLength(1)), z.null()])),
196
+ motion: z.optional(z.union([z.enum(["none", "fade"]), z.null()])),
200
197
  // The faces it lends its views, whole (Roadmap f-view-authoring-friction-2026-11); judged by `brandFindings` (brand-views-font) as the stylesheet is.
201
- fonts: z.union([z.array(z.object({ family: z.string().min(1), src: z.string().min(1), weight: z.union([z.number(), z.string()]).optional(), style: z.enum(["normal", "italic"]).optional() }).strict()), z.null()]).optional(),
202
- })
203
- .strict(),
198
+ fonts: z.optional(z.union([z.array(z.strictObject({ family: z.string().check(z.minLength(1)), src: z.string().check(z.minLength(1)), weight: z.optional(z.union([z.number(), z.string()])), style: z.optional(z.enum(["normal", "italic"])) })), z.null()])),
199
+ }),
204
200
  z.null(),
205
- ])
206
- .optional(),
207
- })
208
- .strict(),
209
- "set-name": z.object({ op: z.literal("set-name"), name: z.string().min(1).max(80) }).strict(),
210
- "set-description": z.object({ op: z.literal("set-description"), description: z.union([z.string().min(1).max(500), z.null()]) }).strict(),
211
- "set-label": z.object({ op: z.literal("set-label"), kind: kindName, field: fieldName.optional(), label: z.union([z.string().min(1).max(300), z.null()]) }).strict(),
212
- "set-describe": z.object({ op: z.literal("set-describe"), kind: kindName, describe: z.union([z.string().min(1).max(300), z.null()]) }).strict(),
201
+ ])),
202
+ }),
203
+ "set-name": z.strictObject({ op: z.literal("set-name"), name: z.string().check(z.minLength(1), z.maxLength(80)) }),
204
+ "set-description": z.strictObject({ op: z.literal("set-description"), description: z.union([z.string().check(z.minLength(1), z.maxLength(500)), z.null()]) }),
205
+ "set-label": z.strictObject({ op: z.literal("set-label"), kind: kindName, field: z.optional(fieldName), label: z.union([z.string().check(z.minLength(1), z.maxLength(300)), z.null()]) }),
206
+ "set-describe": z.strictObject({ op: z.literal("set-describe"), kind: kindName, describe: z.union([z.string().check(z.minLength(1), z.maxLength(300)), z.null()]) }),
213
207
  // A kind's slot; the front page (`slot: "home"`, no kind); or a blocks lens's blocks, by its title (FR-84).
214
- "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(),
208
+ "set-view": z.strictObject({ op: z.literal("set-view"), kind: z.optional(kindName), slot: z.optional(z.enum([...VIEW_SLOTS, "home"])), lens: z.optional(lensTitle), blocks: z.union([z.array(z.unknown()).check(z.minLength(1)), z.null()]) }),
215
209
  // A view the host keeps, by its name (`view:<name>` or bare), and what it is called now (Roadmap f-rename-view).
216
- "rename-view": z.object({ op: z.literal("rename-view"), view: z.string().min(1).max(80), to: z.string().min(1).max(80) }).strict(),
217
- "set-glance": z.object({ op: z.literal("set-glance"), kind: kindName, fields: z.array(fieldName).max(20) }).strict(),
210
+ "rename-view": z.strictObject({ op: z.literal("rename-view"), view: z.string().check(z.minLength(1), z.maxLength(80)), to: z.string().check(z.minLength(1), z.maxLength(80)) }),
211
+ "set-glance": z.strictObject({ op: z.literal("set-glance"), kind: kindName, fields: z.array(fieldName).check(z.maxLength(20)) }),
218
212
  // 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.
219
- "set-page-fields": z
220
- .object({
213
+ "set-page-fields": z.strictObject({
221
214
  op: z.literal("set-page-fields"),
222
215
  kind: kindName,
223
- fields: z.array(fieldName).max(40),
224
- 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(),
225
- })
226
- .strict(),
227
- "add-lens": z
228
- .object({
216
+ fields: z.array(fieldName).check(z.maxLength(40)),
217
+ groups: z.optional(z.union([z.array(z.strictObject({ title: z.string().check(z.minLength(1), z.maxLength(60)), fields: z.array(fieldName).check(z.minLength(1), z.maxLength(40)) })).check(z.maxLength(12)), z.null()])),
218
+ }),
219
+ "add-lens": z.strictObject({
229
220
  op: z.literal("add-lens"),
230
221
  title: lensTitle,
231
- lens: z.string().min(1).max(40).optional(),
232
- on: kindName.optional(),
233
- bindings: z.record(z.string(), z.unknown()).optional(),
234
- options: z.record(z.string(), z.unknown()).optional(),
222
+ lens: z.optional(z.string().check(z.minLength(1), z.maxLength(40))),
223
+ on: z.optional(kindName),
224
+ bindings: z.optional(z.record(z.string(), z.unknown())),
225
+ options: z.optional(z.record(z.string(), z.unknown())),
235
226
  // False: the place's page leaves off the forms that begin its kind.
236
- create: z.boolean().optional(),
237
- at: z.number().int().min(0).optional(),
238
- replace: lensTitle.optional(),
239
- })
240
- .strict(),
241
- "remove-lens": z.object({ op: z.literal("remove-lens"), title: lensTitle, on: kindName.optional() }).strict(),
227
+ create: z.optional(z.boolean()),
228
+ at: z.optional(z.int().check(z.gte(0))),
229
+ replace: z.optional(lensTitle),
230
+ }),
231
+ "remove-lens": z.strictObject({ op: z.literal("remove-lens"), title: lensTitle, on: z.optional(kindName) }),
242
232
  // A lens kept off the bar's places, the page list and the home's gallery, still reached by its address, a link or navigate.
243
- "set-lens-hidden": z.object({ op: z.literal("set-lens-hidden"), title: lensTitle, on: kindName.optional(), hidden: z.boolean() }).strict(),
233
+ "set-lens-hidden": z.strictObject({ op: z.literal("set-lens-hidden"), title: lensTitle, on: z.optional(kindName), hidden: z.boolean() }),
244
234
  // Whether a place that lists records offers "Export CSV" (a lens, or a kind's list by its kind or plural): on unless switched off.
245
- "set-lens-export": z.object({ op: z.literal("set-lens-export"), title: lensTitle, on: kindName.optional(), export: z.boolean() }).strict(),
246
- "set-home": z.object({ op: z.literal("set-home"), blocks: z.union([z.array(z.unknown()).min(1), z.null()]) }).strict(),
247
- "arrange-pages": z
248
- .object({
235
+ "set-lens-export": z.strictObject({ op: z.literal("set-lens-export"), title: lensTitle, on: z.optional(kindName), export: z.boolean() }),
236
+ "set-home": z.strictObject({ op: z.literal("set-home"), blocks: z.union([z.array(z.unknown()).check(z.minLength(1)), z.null()]) }),
237
+ "arrange-pages": z.strictObject({
249
238
  op: z.literal("arrange-pages"),
250
239
  // A kind, or a view the host keeps: `view:<its name>`, or its title where the host says its views.
251
- order: z.union([z.array(z.string().min(1).max(80)).max(40), z.null()]).optional(),
252
- hide: z.union([z.array(kindName).max(40), z.null()]).optional(),
253
- first: z.union([z.string().min(1).max(80), z.null()]).optional(),
254
- primary: z.union([z.array(z.string().min(1).max(80)).max(40), z.null()]).optional(),
255
- scene: z.union([z.string().min(1).max(40), z.null()]).optional(),
256
- pages: z.union([z.string().min(1).max(40), z.null()]).optional(),
240
+ order: z.optional(z.union([z.array(z.string().check(z.minLength(1), z.maxLength(80))).check(z.maxLength(40)), z.null()])),
241
+ hide: z.optional(z.union([z.array(kindName).check(z.maxLength(40)), z.null()])),
242
+ first: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(80)), z.null()])),
243
+ primary: z.optional(z.union([z.array(z.string().check(z.minLength(1), z.maxLength(80))).check(z.maxLength(40)), z.null()])),
244
+ scene: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(40)), z.null()])),
245
+ pages: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(40)), z.null()])),
257
246
  // What a kind's list offers to filter by: `{ "request": ["status", "became.stage"] }`; null or [] gives a kind back its derived filters.
258
- filters: z.record(kindName, z.union([z.array(z.string().min(1).max(120)).max(40), z.null()])).optional(),
247
+ filters: z.optional(z.record(kindName, z.union([z.array(z.string().check(z.minLength(1), z.maxLength(120))).check(z.maxLength(40)), z.null()]))),
259
248
  // The order a kind's list opens in: `{ "feature": { "by": "score", "direction": "desc", "then": "label" } }` or a key; null gives it back its own.
260
- sort: z.record(kindName, z.union([listSortShape, z.null()])).optional(),
249
+ sort: z.optional(z.record(kindName, z.union([listSortShape, z.null()]))),
261
250
  // How a kind's list opens grouped: `{ "request": { "by": "status", "order": [...], "closed": ["done"] } }` or a field; null opens it ungrouped.
262
- group: z.record(kindName, z.union([listGroupShape, z.null()])).optional(),
251
+ group: z.optional(z.record(kindName, z.union([listGroupShape, z.null()]))),
263
252
  // The place a kind's list opens as, by a lens's title: `{ "task": "Tasks by status" }`; null opens it as a list again.
264
- opens: z.record(kindName, z.union([lensTitle, z.null()])).optional(),
253
+ opens: z.optional(z.record(kindName, z.union([lensTitle, z.null()]))),
265
254
  // The scene's word as a chat or a tool written before 0.1.17 sends it (FR-132's key, RESPELLED as `scene`).
266
- overview: z.union([z.string().min(1).max(40), z.null()]).optional(),
267
- })
268
- .strict(),
269
- "set-computed": z
270
- .object({
255
+ overview: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(40)), z.null()])),
256
+ }),
257
+ "set-computed": z.strictObject({
271
258
  op: z.literal("set-computed"),
272
259
  kind: kindName,
273
260
  name: fieldName,
274
- expr: z.union([z.string().min(1).max(2000), z.null()]).optional(),
275
- label: z.union([z.string().min(1).max(60), z.null()]).optional(),
276
- description: z.union([z.string().min(1).max(500), z.null()]).optional(),
261
+ expr: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(2000)), z.null()])),
262
+ label: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(60)), z.null()])),
263
+ description: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(500)), z.null()])),
277
264
  // Kept off a record's page, card and CSV, still worked out for a sort, a rule or a view (FR-217): true hides it, false or null shows it.
278
- hidden: z.union([z.boolean(), z.null()]).optional(),
279
- })
280
- .strict(),
265
+ hidden: z.optional(z.union([z.boolean(), z.null()])),
266
+ }),
281
267
  // Who the people are, and who may do and see what (FR-170): a grant and a sight as the document holds one.
282
- "set-people": z.object({ op: z.literal("set-people"), kind: kindName, people: z.boolean() }).strict(),
268
+ "set-people": z.strictObject({ op: z.literal("set-people"), kind: kindName, people: z.boolean() }),
283
269
  // Whether a kind's records are archived and merged, or only kept and removed (FR-173).
284
- "set-archives": z.object({ op: z.literal("set-archives"), kind: kindName, archives: z.boolean() }).strict(),
270
+ "set-archives": z.strictObject({ op: z.literal("set-archives"), kind: kindName, archives: z.boolean() }),
285
271
  // What the app's own actor may do on its own to a kind, or to one relation of it (`@graview/core/tidying`).
286
- "set-tidying": z.object({ op: z.literal("set-tidying"), kind: kindName, relation: z.optional(z.string()), tidying: z.enum(["never", "no-links", "allowed"]) }).strict(),
272
+ "set-tidying": z.strictObject({ op: z.literal("set-tidying"), kind: kindName, relation: z.optional(z.string()), tidying: z.enum(["never", "no-links", "allowed"]) }),
287
273
  // What the app says of suggestions as a whole (`tidying` at the top of the document): the votes at which the app's own actor makes one; null takes it away.
288
- "set-app-tidying": z.object({ op: z.literal("set-app-tidying"), autoAcceptAt: z.union([z.number().int().min(1).max(10_000), z.null()]) }).strict(),
274
+ "set-app-tidying": z.strictObject({ op: z.literal("set-app-tidying"), autoAcceptAt: z.union([z.int().check(z.gte(1), z.lte(10_000)), z.null()]) }),
289
275
  // What a kind follows (Roadmap f-keep-linked): the kind, the relation joining them and the fields worked out from it; null, it follows nothing.
290
- "set-derives": z.object({ op: z.literal("set-derives"), kind: kindName, derives: z.union([z.object({ from: kindName, via: z.string(), set: z.record(z.string(), z.unknown()) }).strict(), z.null()]) }).strict(),
291
- "add-grant": z.object({ op: z.literal("add-grant") }).passthrough(),
292
- "remove-grant": z.object({ op: z.literal("remove-grant") }).passthrough(),
293
- "add-sight": z.object({ op: z.literal("add-sight") }).passthrough(),
294
- "remove-sight": z.object({ op: z.literal("remove-sight") }).passthrough(),
276
+ "set-derives": z.strictObject({ op: z.literal("set-derives"), kind: kindName, derives: z.union([z.strictObject({ from: kindName, via: z.string(), set: z.record(z.string(), z.unknown()) }), z.null()]) }),
277
+ "add-grant": z.looseObject({ op: z.literal("add-grant") }),
278
+ "remove-grant": z.looseObject({ op: z.literal("remove-grant") }),
279
+ "add-sight": z.looseObject({ op: z.literal("add-sight") }),
280
+ "remove-sight": z.looseObject({ op: z.literal("remove-sight") }),
295
281
  // Who the app is for, in words (Roadmap f-app-jobs); null takes the sentence away.
296
- "set-purpose": z.object({ op: z.literal("set-purpose"), for: z.union([z.string().min(1).max(300), z.null()]) }).strict(),
282
+ "set-purpose": z.strictObject({ op: z.literal("set-purpose"), for: z.union([z.string().check(z.minLength(1), z.maxLength(300)), z.null()]) }),
297
283
  // A job as the document holds one (`purpose.jobs[]`), placed at `at` or last.
298
- "add-job": z.object({ op: z.literal("add-job"), job: z.record(z.string(), z.unknown()), at: z.number().int().min(0).optional() }).strict(),
284
+ "add-job": z.strictObject({ op: z.literal("add-job"), job: z.record(z.string(), z.unknown()), at: z.optional(z.int().check(z.gte(0))) }),
299
285
  // A job by its name, each key given set, null clearing an optional one.
300
- "edit-job": z
301
- .object({
286
+ "edit-job": z.strictObject({
302
287
  op: z.literal("edit-job"),
303
288
  name: jobName,
304
- ask: z.string().min(1).max(200).optional(),
305
- kind: kindName.optional(),
306
- where: z.union([z.string().min(1).max(2000), z.null()]).optional(),
307
- sort: z.union([listKey, z.object({ by: listKey, direction: listDirection }).strict(), z.null()]).optional(),
308
- act: z.union([actName, z.null()]).optional(),
309
- roles: z.union([z.array(z.string().regex(NAME)).min(1).max(40), z.null()]).optional(),
310
- })
311
- .strict(),
312
- "remove-job": z.object({ op: z.literal("remove-job"), name: jobName }).strict(),
289
+ ask: z.optional(z.string().check(z.minLength(1), z.maxLength(200))),
290
+ kind: z.optional(kindName),
291
+ where: z.optional(z.union([z.string().check(z.minLength(1), z.maxLength(2000)), z.null()])),
292
+ sort: z.optional(z.union([listKey, z.strictObject({ by: listKey, direction: listDirection }), z.null()])),
293
+ act: z.optional(z.union([actName, z.null()])),
294
+ roles: z.optional(z.union([z.array(z.string().check(z.regex(NAME))).check(z.minLength(1), z.maxLength(40)), z.null()])),
295
+ }),
296
+ "remove-job": z.strictObject({ op: z.literal("remove-job"), name: jobName }),
313
297
  // A device's screen (`devices.screens[]`, Roadmap f-device-nav-bar): a place and the word under its press, placed at `at` or last.
314
- "add-device-screen": z.object({ op: z.literal("add-device-screen"), screen: z.record(z.string(), z.unknown()), at: z.number().int().min(0).optional() }).strict(),
298
+ "add-device-screen": z.strictObject({ op: z.literal("add-device-screen"), screen: z.record(z.string(), z.unknown()), at: z.optional(z.int().check(z.gte(0))) }),
315
299
  // A screen by the place it shows, moved to `to` (0 first).
316
- "move-device-screen": z.object({ op: z.literal("move-device-screen"), place: z.string().min(1).max(200), to: z.number().int().min(0) }).strict(),
317
- "remove-device-screen": z.object({ op: z.literal("remove-device-screen"), place: z.string().min(1).max(200) }).strict(),
300
+ "move-device-screen": z.strictObject({ op: z.literal("move-device-screen"), place: z.string().check(z.minLength(1), z.maxLength(200)), to: z.int().check(z.gte(0)) }),
301
+ "remove-device-screen": z.strictObject({ op: z.literal("remove-device-screen"), place: z.string().check(z.minLength(1), z.maxLength(200)) }),
318
302
  // Another word people use for a kind, or for one of its fields (Roadmap f-learned-suggestions).
319
- "add-alias": z.object({ op: z.literal("add-alias"), kind: kindName, field: fieldName.optional(), alias: z.string().min(1).max(40) }).strict(),
303
+ "add-alias": z.strictObject({ op: z.literal("add-alias"), kind: kindName, field: z.optional(fieldName), alias: z.string().check(z.minLength(1), z.maxLength(40)) }),
320
304
  // All of a kind's or a field's other words at once; null or [] takes them away.
321
- "set-aliases": z.object({ op: z.literal("set-aliases"), kind: kindName, field: fieldName.optional(), aliases: z.union([z.array(z.string().min(1).max(40)).max(MOST_ALIASES), z.null()]) }).strict(),
305
+ "set-aliases": z.strictObject({ op: z.literal("set-aliases"), kind: kindName, field: z.optional(fieldName), aliases: z.union([z.array(z.string().check(z.minLength(1), z.maxLength(40))).check(z.maxLength(MOST_ALIASES)), z.null()]) }),
322
306
  // A connection declared whole, by its name: set where there was none, or replaced (FR-229); null takes it away.
323
- "set-connection": z.object({ op: z.literal("set-connection"), name: kindName, connection: z.union([z.record(z.string(), z.unknown()), z.null()]) }).strict(),
307
+ "set-connection": z.strictObject({ op: z.literal("set-connection"), name: kindName, connection: z.union([z.record(z.string(), z.unknown()), z.null()]) }),
324
308
  // A workflow by its name (Roadmap f-jobs-declared): added where there was none, replaced whole, removed, paused or resumed.
325
- "add-workflow": z.object({ op: z.literal("add-workflow"), name: kindName, workflow: z.record(z.string(), z.unknown()) }).strict(),
326
- "set-workflow": z.object({ op: z.literal("set-workflow"), name: kindName, workflow: z.record(z.string(), z.unknown()) }).strict(),
327
- "remove-workflow": z.object({ op: z.literal("remove-workflow"), name: kindName }).strict(),
328
- "pause-workflow": z.object({ op: z.literal("pause-workflow"), name: kindName }).strict(),
329
- "resume-workflow": z.object({ op: z.literal("resume-workflow"), name: kindName }).strict(),
309
+ "add-workflow": z.strictObject({ op: z.literal("add-workflow"), name: kindName, workflow: z.record(z.string(), z.unknown()) }),
310
+ "set-workflow": z.strictObject({ op: z.literal("set-workflow"), name: kindName, workflow: z.record(z.string(), z.unknown()) }),
311
+ "remove-workflow": z.strictObject({ op: z.literal("remove-workflow"), name: kindName }),
312
+ "pause-workflow": z.strictObject({ op: z.literal("pause-workflow"), name: kindName }),
313
+ "resume-workflow": z.strictObject({ op: z.literal("resume-workflow"), name: kindName }),
330
314
  };
331
315
  }
332
316
  let shapes;
@@ -1029,6 +1013,25 @@ class Editor {
1029
1013
  this.said.push(e.repeats ? `${e.kind}'s ${e.field} may repeat: weekly, monthly, on chosen days, until a day.` : `${e.kind}'s ${e.field} no longer repeats.`);
1030
1014
  return;
1031
1015
  }
1016
+ case "set-cites": {
1017
+ // Where its value came from (Roadmap f-field-cites-marker): a field or relation of the same kind, never itself.
1018
+ const f = this.field(i, e.kind, e.field);
1019
+ if (!f)
1020
+ return;
1021
+ if (e.cites === null) {
1022
+ delete f.cites;
1023
+ this.said.push(`${e.kind}'s ${e.field} no longer says what cites it.`);
1024
+ return;
1025
+ }
1026
+ const spec = this.doc.kinds[e.kind];
1027
+ if (e.cites === e.field)
1028
+ return this.fail(i, "cites", `${e.kind}'s ${e.field} cannot cite itself; name the field or relation that holds where it came from`);
1029
+ if (!spec.fields[e.cites] && !spec.edges?.[e.cites])
1030
+ return this.fail(i, "cites", `${e.kind} has no field or relation "${e.cites}" to hold the citation`);
1031
+ f.cites = e.cites;
1032
+ this.said.push(`${e.kind}'s ${e.field} is cited by its ${e.cites}: a record holding a ${e.field} with no ${e.cites} is said to be uncited.`);
1033
+ return;
1034
+ }
1032
1035
  case "remove-field":
1033
1036
  return this.removeField(i, e.kind, e.field);
1034
1037
  case "add-relation":
@@ -2821,7 +2824,7 @@ class Editor {
2821
2824
  if (!(asArray(act.on).includes(to) || act.creates === to || (act.effects ?? []).some((x) => x.create === to)))
2822
2825
  continue;
2823
2826
  const next = swapToken(name, from, to);
2824
- if (next !== name && !this.doc.acts[next] && NAME.test(next)) {
2827
+ if (next !== name && next !== BIND_PERSON && !this.doc.acts[next] && NAME.test(next)) {
2825
2828
  this.renameAct(name, next);
2826
2829
  touched.push(`act ${name} → ${next}`);
2827
2830
  }
@@ -3023,6 +3026,13 @@ class Editor {
3023
3026
  for (const [k, v] of Object.entries(spec.fields))
3024
3027
  fields[k === field ? to : k] = v;
3025
3028
  spec.fields = fields;
3029
+ // A field cited by this one is cited by it under its new name (Roadmap f-field-cites-marker).
3030
+ for (const [name, other] of Object.entries(fields)) {
3031
+ if (other.cites !== field)
3032
+ continue;
3033
+ other.cites = to;
3034
+ touched.push(`${kind}'s ${name} citation`);
3035
+ }
3026
3036
  const origin = this.fieldOrigin.get(`${kind}.${field}`);
3027
3037
  this.fieldOrigin.delete(`${kind}.${field}`);
3028
3038
  this.fieldOrigin.set(`${kind}.${to}`, origin);
@@ -3324,6 +3334,7 @@ class Editor {
3324
3334
  for (const x of [...this.fills])
3325
3335
  if (x.kind === kind && (x.field === field || x.from === field))
3326
3336
  this.fills.splice(this.fills.indexOf(x), 1);
3337
+ gone.push(...dropCitesOf(spec, kind, field));
3327
3338
  this.said.push(`${kind} loses its ${field} field, and every value in it${gone.length ? `; ${listOf(gone)} ${gone.length === 1 ? "goes" : "go"} with it` : ""}.`);
3328
3339
  }
3329
3340
  // ── relations ──
@@ -3394,6 +3405,13 @@ class Editor {
3394
3405
  edges[to].renamedFrom = origin;
3395
3406
  else
3396
3407
  delete edges[to].renamedFrom;
3408
+ // A field this relation cites is cited by it under its new name (Roadmap f-field-cites-marker).
3409
+ for (const [name, field] of Object.entries(s.fields)) {
3410
+ if (field.cites !== relation)
3411
+ continue;
3412
+ field.cites = to;
3413
+ touched.push(`${k}'s ${name} citation`);
3414
+ }
3397
3415
  }
3398
3416
  this.said.push(`The "${relation}" relation is renamed to "${to}"; its links are kept${touched.length ? `, and ${listOf(touched)} follow${touched.length === 1 ? "s" : ""}` : ""}.`);
3399
3417
  }
@@ -3411,6 +3429,7 @@ class Editor {
3411
3429
  return this.fail(i, "relation", `a sight shows what "${relation}" joins to each seat's own record`, "change the policy's sight first");
3412
3430
  const gone = [];
3413
3431
  this.dropRelation(kind, relation, gone);
3432
+ gone.push(...dropCitesOf(spec, kind, relation));
3414
3433
  this.said.push(`The "${relation}" relation from ${kind} is removed, with every link of that kind${gone.length ? `; ${listOf(gone)} ${gone.length === 1 ? "goes" : "go"} with it` : ""}.`);
3415
3434
  }
3416
3435
  dropRelation(kind, relation, gone) {
@@ -3436,6 +3455,8 @@ class Editor {
3436
3455
  // ── acts and rules ──
3437
3456
  addAct(i, e) {
3438
3457
  const { op: _op, act, replace, ...rest } = e;
3458
+ if (act === BIND_PERSON)
3459
+ return this.failAs("binding-act-taken", i, "act", `"${BIND_PERSON}" is a name the framework keeps for an act of its own`, "give the act another name");
3439
3460
  if (this.doc.acts?.[act] && !replace)
3440
3461
  return this.fail(i, "act", `there is already an act "${act}"`, "pass replace: true to change it, or pick another name");
3441
3462
  const parsed = ActSpec.safeParse(rest);
@@ -3669,7 +3690,7 @@ class Editor {
3669
3690
  if (r.t === "field") {
3670
3691
  for (const name of [...renamedArgs.keys()]) {
3671
3692
  const next = swapToken(name, kebab(r.from), kebab(r.to));
3672
- if (next !== name && !doc.acts[next] && NAME.test(next)) {
3693
+ if (next !== name && next !== BIND_PERSON && !doc.acts[next] && NAME.test(next)) {
3673
3694
  this.renameAct(name, next);
3674
3695
  const at = touched.indexOf(`act ${name}`);
3675
3696
  if (at >= 0)
@@ -4617,4 +4638,15 @@ function renamedAct(act, from, to) {
4617
4638
  const derived = derivedActOf(act);
4618
4639
  return derived && derived.kind === from ? `${derived.act}-${to}` : act;
4619
4640
  }
4641
+ /** A kind's fields that said this field or relation cites them say nothing now (Roadmap f-field-cites-marker): what goes, in words. */
4642
+ function dropCitesOf(spec, kind, name) {
4643
+ const gone = [];
4644
+ for (const [field, f] of Object.entries(spec.fields ?? {})) {
4645
+ if (f.cites !== name)
4646
+ continue;
4647
+ delete f.cites;
4648
+ gone.push(`${kind}'s ${field} citation`);
4649
+ }
4650
+ return gone;
4651
+ }
4620
4652
  //# sourceMappingURL=edit.js.map