@graview/core 0.1.0

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 (327) hide show
  1. package/LICENSE +96 -0
  2. package/README.md +35 -0
  3. package/dist/app.d.ts +294 -0
  4. package/dist/app.d.ts.map +1 -0
  5. package/dist/app.js +49 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/arrange.d.ts +185 -0
  8. package/dist/arrange.d.ts.map +1 -0
  9. package/dist/arrange.js +456 -0
  10. package/dist/arrange.js.map +1 -0
  11. package/dist/beginning.d.ts +65 -0
  12. package/dist/beginning.d.ts.map +1 -0
  13. package/dist/beginning.js +94 -0
  14. package/dist/beginning.js.map +1 -0
  15. package/dist/bind.d.ts +42 -0
  16. package/dist/bind.d.ts.map +1 -0
  17. package/dist/bind.js +26 -0
  18. package/dist/bind.js.map +1 -0
  19. package/dist/city.d.ts +93 -0
  20. package/dist/city.d.ts.map +1 -0
  21. package/dist/city.js +160 -0
  22. package/dist/city.js.map +1 -0
  23. package/dist/cli/check/arrangement.d.ts +13 -0
  24. package/dist/cli/check/arrangement.d.ts.map +1 -0
  25. package/dist/cli/check/arrangement.js +63 -0
  26. package/dist/cli/check/arrangement.js.map +1 -0
  27. package/dist/cli/check/beginnings.d.ts +16 -0
  28. package/dist/cli/check/beginnings.d.ts.map +1 -0
  29. package/dist/cli/check/beginnings.js +53 -0
  30. package/dist/cli/check/beginnings.js.map +1 -0
  31. package/dist/cli/check/brand.d.ts +17 -0
  32. package/dist/cli/check/brand.d.ts.map +1 -0
  33. package/dist/cli/check/brand.js +153 -0
  34. package/dist/cli/check/brand.js.map +1 -0
  35. package/dist/cli/check/city.d.ts +17 -0
  36. package/dist/cli/check/city.d.ts.map +1 -0
  37. package/dist/cli/check/city.js +58 -0
  38. package/dist/cli/check/city.js.map +1 -0
  39. package/dist/cli/check/context.d.ts +50 -0
  40. package/dist/cli/check/context.d.ts.map +1 -0
  41. package/dist/cli/check/context.js +37 -0
  42. package/dist/cli/check/context.js.map +1 -0
  43. package/dist/cli/check/fields.d.ts +16 -0
  44. package/dist/cli/check/fields.d.ts.map +1 -0
  45. package/dist/cli/check/fields.js +237 -0
  46. package/dist/cli/check/fields.js.map +1 -0
  47. package/dist/cli/check/index.d.ts +14 -0
  48. package/dist/cli/check/index.d.ts.map +1 -0
  49. package/dist/cli/check/index.js +14 -0
  50. package/dist/cli/check/index.js.map +1 -0
  51. package/dist/cli/check/intelligence.d.ts +17 -0
  52. package/dist/cli/check/intelligence.d.ts.map +1 -0
  53. package/dist/cli/check/intelligence.js +136 -0
  54. package/dist/cli/check/intelligence.js.map +1 -0
  55. package/dist/cli/check/lenses.d.ts +17 -0
  56. package/dist/cli/check/lenses.d.ts.map +1 -0
  57. package/dist/cli/check/lenses.js +239 -0
  58. package/dist/cli/check/lenses.js.map +1 -0
  59. package/dist/cli/check/migrations.d.ts +16 -0
  60. package/dist/cli/check/migrations.d.ts.map +1 -0
  61. package/dist/cli/check/migrations.js +43 -0
  62. package/dist/cli/check/migrations.js.map +1 -0
  63. package/dist/cli/check/modules.d.ts +16 -0
  64. package/dist/cli/check/modules.d.ts.map +1 -0
  65. package/dist/cli/check/modules.js +123 -0
  66. package/dist/cli/check/modules.js.map +1 -0
  67. package/dist/cli/check/policy.d.ts +16 -0
  68. package/dist/cli/check/policy.d.ts.map +1 -0
  69. package/dist/cli/check/policy.js +90 -0
  70. package/dist/cli/check/policy.js.map +1 -0
  71. package/dist/cli/check/relations.d.ts +29 -0
  72. package/dist/cli/check/relations.d.ts.map +1 -0
  73. package/dist/cli/check/relations.js +279 -0
  74. package/dist/cli/check/relations.js.map +1 -0
  75. package/dist/cli/check/routes.d.ts +16 -0
  76. package/dist/cli/check/routes.d.ts.map +1 -0
  77. package/dist/cli/check/routes.js +31 -0
  78. package/dist/cli/check/routes.js.map +1 -0
  79. package/dist/cli/check/settings.d.ts +16 -0
  80. package/dist/cli/check/settings.d.ts.map +1 -0
  81. package/dist/cli/check/settings.js +81 -0
  82. package/dist/cli/check/settings.js.map +1 -0
  83. package/dist/cli/check.d.ts +36 -0
  84. package/dist/cli/check.d.ts.map +1 -0
  85. package/dist/cli/check.js +76 -0
  86. package/dist/cli/check.js.map +1 -0
  87. package/dist/cli/create.d.ts +20 -0
  88. package/dist/cli/create.d.ts.map +1 -0
  89. package/dist/cli/create.js +251 -0
  90. package/dist/cli/create.js.map +1 -0
  91. package/dist/cli/describe.d.ts +35 -0
  92. package/dist/cli/describe.d.ts.map +1 -0
  93. package/dist/cli/describe.js +230 -0
  94. package/dist/cli/describe.js.map +1 -0
  95. package/dist/cli/docs.d.ts +11 -0
  96. package/dist/cli/docs.d.ts.map +1 -0
  97. package/dist/cli/docs.js +152 -0
  98. package/dist/cli/docs.js.map +1 -0
  99. package/dist/cli/index.d.ts +18 -0
  100. package/dist/cli/index.d.ts.map +1 -0
  101. package/dist/cli/index.js +281 -0
  102. package/dist/cli/index.js.map +1 -0
  103. package/dist/extend.d.ts +23 -0
  104. package/dist/extend.d.ts.map +1 -0
  105. package/dist/extend.js +53 -0
  106. package/dist/extend.js.map +1 -0
  107. package/dist/graph/diff.d.ts +31 -0
  108. package/dist/graph/diff.d.ts.map +1 -0
  109. package/dist/graph/diff.js +71 -0
  110. package/dist/graph/diff.js.map +1 -0
  111. package/dist/graph/graph.d.ts +69 -0
  112. package/dist/graph/graph.d.ts.map +1 -0
  113. package/dist/graph/graph.js +284 -0
  114. package/dist/graph/graph.js.map +1 -0
  115. package/dist/graph/primitives.d.ts +52 -0
  116. package/dist/graph/primitives.d.ts.map +1 -0
  117. package/dist/graph/primitives.js +62 -0
  118. package/dist/graph/primitives.js.map +1 -0
  119. package/dist/graph/tracked.d.ts +31 -0
  120. package/dist/graph/tracked.d.ts.map +1 -0
  121. package/dist/graph/tracked.js +69 -0
  122. package/dist/graph/tracked.js.map +1 -0
  123. package/dist/graph/types.d.ts +34 -0
  124. package/dist/graph/types.d.ts.map +1 -0
  125. package/dist/graph/types.js +0 -0
  126. package/dist/graph/types.js.map +1 -0
  127. package/dist/index.d.ts +100 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/index.js +90 -0
  130. package/dist/index.js.map +1 -0
  131. package/dist/installation.d.ts +112 -0
  132. package/dist/installation.d.ts.map +1 -0
  133. package/dist/installation.js +193 -0
  134. package/dist/installation.js.map +1 -0
  135. package/dist/intelligence-bridge.d.ts +73 -0
  136. package/dist/intelligence-bridge.d.ts.map +1 -0
  137. package/dist/intelligence-bridge.js +31 -0
  138. package/dist/intelligence-bridge.js.map +1 -0
  139. package/dist/invariants/engine.d.ts +36 -0
  140. package/dist/invariants/engine.d.ts.map +1 -0
  141. package/dist/invariants/engine.js +88 -0
  142. package/dist/invariants/engine.js.map +1 -0
  143. package/dist/invariants/types.d.ts +75 -0
  144. package/dist/invariants/types.d.ts.map +1 -0
  145. package/dist/invariants/types.js +2 -0
  146. package/dist/invariants/types.js.map +1 -0
  147. package/dist/modules.d.ts +75 -0
  148. package/dist/modules.d.ts.map +1 -0
  149. package/dist/modules.js +87 -0
  150. package/dist/modules.js.map +1 -0
  151. package/dist/mutations/decidable.d.ts +26 -0
  152. package/dist/mutations/decidable.d.ts.map +1 -0
  153. package/dist/mutations/decidable.js +39 -0
  154. package/dist/mutations/decidable.js.map +1 -0
  155. package/dist/mutations/define-mutation.d.ts +32 -0
  156. package/dist/mutations/define-mutation.d.ts.map +1 -0
  157. package/dist/mutations/define-mutation.js +181 -0
  158. package/dist/mutations/define-mutation.js.map +1 -0
  159. package/dist/mutations/derive-edits.d.ts +75 -0
  160. package/dist/mutations/derive-edits.d.ts.map +1 -0
  161. package/dist/mutations/derive-edits.js +240 -0
  162. package/dist/mutations/derive-edits.js.map +1 -0
  163. package/dist/mutations/form.d.ts +63 -0
  164. package/dist/mutations/form.d.ts.map +1 -0
  165. package/dist/mutations/form.js +113 -0
  166. package/dist/mutations/form.js.map +1 -0
  167. package/dist/mutations/node-ref.d.ts +83 -0
  168. package/dist/mutations/node-ref.d.ts.map +1 -0
  169. package/dist/mutations/node-ref.js +113 -0
  170. package/dist/mutations/node-ref.js.map +1 -0
  171. package/dist/mutations/types.d.ts +136 -0
  172. package/dist/mutations/types.d.ts.map +1 -0
  173. package/dist/mutations/types.js +2 -0
  174. package/dist/mutations/types.js.map +1 -0
  175. package/dist/ops/log.d.ts +35 -0
  176. package/dist/ops/log.d.ts.map +1 -0
  177. package/dist/ops/log.js +103 -0
  178. package/dist/ops/log.js.map +1 -0
  179. package/dist/ops/types.d.ts +52 -0
  180. package/dist/ops/types.d.ts.map +1 -0
  181. package/dist/ops/types.js +2 -0
  182. package/dist/ops/types.js.map +1 -0
  183. package/dist/ops/undo.d.ts +33 -0
  184. package/dist/ops/undo.d.ts.map +1 -0
  185. package/dist/ops/undo.js +65 -0
  186. package/dist/ops/undo.js.map +1 -0
  187. package/dist/permissions/policy.d.ts +68 -0
  188. package/dist/permissions/policy.d.ts.map +1 -0
  189. package/dist/permissions/policy.js +191 -0
  190. package/dist/permissions/policy.js.map +1 -0
  191. package/dist/permissions/types.d.ts +78 -0
  192. package/dist/permissions/types.d.ts.map +1 -0
  193. package/dist/permissions/types.js +17 -0
  194. package/dist/permissions/types.js.map +1 -0
  195. package/dist/persistence/memory.d.ts +6 -0
  196. package/dist/persistence/memory.d.ts.map +1 -0
  197. package/dist/persistence/memory.js +31 -0
  198. package/dist/persistence/memory.js.map +1 -0
  199. package/dist/persistence/sqlite.d.ts +59 -0
  200. package/dist/persistence/sqlite.d.ts.map +1 -0
  201. package/dist/persistence/sqlite.js +131 -0
  202. package/dist/persistence/sqlite.js.map +1 -0
  203. package/dist/persistence/types.d.ts +22 -0
  204. package/dist/persistence/types.d.ts.map +1 -0
  205. package/dist/persistence/types.js +2 -0
  206. package/dist/persistence/types.js.map +1 -0
  207. package/dist/presence.d.ts +38 -0
  208. package/dist/presence.d.ts.map +1 -0
  209. package/dist/presence.js +50 -0
  210. package/dist/presence.js.map +1 -0
  211. package/dist/scaffold/domain.d.ts +8 -0
  212. package/dist/scaffold/domain.d.ts.map +1 -0
  213. package/dist/scaffold/domain.js +331 -0
  214. package/dist/scaffold/domain.js.map +1 -0
  215. package/dist/scaffold/index.d.ts +66 -0
  216. package/dist/scaffold/index.d.ts.map +1 -0
  217. package/dist/scaffold/index.js +142 -0
  218. package/dist/scaffold/index.js.map +1 -0
  219. package/dist/scaffold/lens.d.ts +31 -0
  220. package/dist/scaffold/lens.d.ts.map +1 -0
  221. package/dist/scaffold/lens.js +176 -0
  222. package/dist/scaffold/lens.js.map +1 -0
  223. package/dist/scaffold/names.d.ts +44 -0
  224. package/dist/scaffold/names.d.ts.map +1 -0
  225. package/dist/scaffold/names.js +69 -0
  226. package/dist/scaffold/names.js.map +1 -0
  227. package/dist/scaffold/project.d.ts +41 -0
  228. package/dist/scaffold/project.d.ts.map +1 -0
  229. package/dist/scaffold/project.js +604 -0
  230. package/dist/scaffold/project.js.map +1 -0
  231. package/dist/scaffold/ui.d.ts +15 -0
  232. package/dist/scaffold/ui.d.ts.map +1 -0
  233. package/dist/scaffold/ui.js +536 -0
  234. package/dist/scaffold/ui.js.map +1 -0
  235. package/dist/schema/define-node.d.ts +132 -0
  236. package/dist/schema/define-node.d.ts.map +1 -0
  237. package/dist/schema/define-node.js +254 -0
  238. package/dist/schema/define-node.js.map +1 -0
  239. package/dist/schema/figures.d.ts +42 -0
  240. package/dist/schema/figures.d.ts.map +1 -0
  241. package/dist/schema/figures.js +220 -0
  242. package/dist/schema/figures.js.map +1 -0
  243. package/dist/schema/json-schema.d.ts +39 -0
  244. package/dist/schema/json-schema.d.ts.map +1 -0
  245. package/dist/schema/json-schema.js +74 -0
  246. package/dist/schema/json-schema.js.map +1 -0
  247. package/dist/schema/schema.d.ts +43 -0
  248. package/dist/schema/schema.d.ts.map +1 -0
  249. package/dist/schema/schema.js +102 -0
  250. package/dist/schema/schema.js.map +1 -0
  251. package/dist/schema/types.d.ts +201 -0
  252. package/dist/schema/types.d.ts.map +1 -0
  253. package/dist/schema/types.js +2 -0
  254. package/dist/schema/types.js.map +1 -0
  255. package/dist/search.d.ts +215 -0
  256. package/dist/search.d.ts.map +1 -0
  257. package/dist/search.js +449 -0
  258. package/dist/search.js.map +1 -0
  259. package/dist/settings.d.ts +30 -0
  260. package/dist/settings.d.ts.map +1 -0
  261. package/dist/settings.js +74 -0
  262. package/dist/settings.js.map +1 -0
  263. package/dist/store.d.ts +284 -0
  264. package/dist/store.d.ts.map +1 -0
  265. package/dist/store.js +660 -0
  266. package/dist/store.js.map +1 -0
  267. package/dist/studio-door.d.ts +187 -0
  268. package/dist/studio-door.d.ts.map +1 -0
  269. package/dist/studio-door.js +20 -0
  270. package/dist/studio-door.js.map +1 -0
  271. package/dist/sync/conflict.d.ts +37 -0
  272. package/dist/sync/conflict.d.ts.map +1 -0
  273. package/dist/sync/conflict.js +56 -0
  274. package/dist/sync/conflict.js.map +1 -0
  275. package/dist/sync/engine.d.ts +118 -0
  276. package/dist/sync/engine.d.ts.map +1 -0
  277. package/dist/sync/engine.js +341 -0
  278. package/dist/sync/engine.js.map +1 -0
  279. package/dist/sync/google-calendar.d.ts +54 -0
  280. package/dist/sync/google-calendar.d.ts.map +1 -0
  281. package/dist/sync/google-calendar.js +167 -0
  282. package/dist/sync/google-calendar.js.map +1 -0
  283. package/dist/sync/types.d.ts +125 -0
  284. package/dist/sync/types.d.ts.map +1 -0
  285. package/dist/sync/types.js +6 -0
  286. package/dist/sync/types.js.map +1 -0
  287. package/dist/temporal/effectivity.d.ts +75 -0
  288. package/dist/temporal/effectivity.d.ts.map +1 -0
  289. package/dist/temporal/effectivity.js +89 -0
  290. package/dist/temporal/effectivity.js.map +1 -0
  291. package/dist/testing.d.ts +63 -0
  292. package/dist/testing.d.ts.map +1 -0
  293. package/dist/testing.js +194 -0
  294. package/dist/testing.js.map +1 -0
  295. package/dist/theme/contrast.d.ts +47 -0
  296. package/dist/theme/contrast.d.ts.map +1 -0
  297. package/dist/theme/contrast.js +172 -0
  298. package/dist/theme/contrast.js.map +1 -0
  299. package/dist/theme/derive.d.ts +81 -0
  300. package/dist/theme/derive.d.ts.map +1 -0
  301. package/dist/theme/derive.js +171 -0
  302. package/dist/theme/derive.js.map +1 -0
  303. package/dist/theme/kit.d.ts +106 -0
  304. package/dist/theme/kit.d.ts.map +1 -0
  305. package/dist/theme/kit.js +84 -0
  306. package/dist/theme/kit.js.map +1 -0
  307. package/dist/theme/palettes.d.ts +32 -0
  308. package/dist/theme/palettes.d.ts.map +1 -0
  309. package/dist/theme/palettes.js +96 -0
  310. package/dist/theme/palettes.js.map +1 -0
  311. package/dist/theme/types.d.ts +131 -0
  312. package/dist/theme/types.d.ts.map +1 -0
  313. package/dist/theme/types.js +23 -0
  314. package/dist/theme/types.js.map +1 -0
  315. package/dist/views/types.d.ts +89 -0
  316. package/dist/views/types.d.ts.map +1 -0
  317. package/dist/views/types.js +88 -0
  318. package/dist/views/types.js.map +1 -0
  319. package/dist/watched.d.ts +33 -0
  320. package/dist/watched.d.ts.map +1 -0
  321. package/dist/watched.js +50 -0
  322. package/dist/watched.js.map +1 -0
  323. package/dist/who.d.ts +26 -0
  324. package/dist/who.d.ts.map +1 -0
  325. package/dist/who.js +20 -0
  326. package/dist/who.js.map +1 -0
  327. package/package.json +77 -0
package/LICENSE ADDED
@@ -0,0 +1,96 @@
1
+ Elastic License 2.0
2
+
3
+ ## Acceptance
4
+
5
+ By using the software, you agree to all of the terms and conditions below.
6
+
7
+ ## Copyright License
8
+
9
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
10
+ non-sublicensable, non-transferable license to use, copy, distribute, make
11
+ available, and prepare derivative works of the software, in each case subject
12
+ to the limitations and conditions below.
13
+
14
+ ## Limitations
15
+
16
+ You may not provide the software to third parties as a hosted or managed
17
+ service, where the service provides users with access to any substantial set
18
+ of the features or functionality of the software.
19
+
20
+ You may not move, change, disable, or circumvent the license key
21
+ functionality in the software, and you may not remove or obscure any
22
+ functionality in the software that is protected by the license key.
23
+
24
+ You may not alter, remove, or obscure any licensing, copyright, or other
25
+ notices of the licensor in the software. Any use of the licensor's trademarks
26
+ is subject to applicable law.
27
+
28
+ ## Patents
29
+
30
+ The licensor grants you a license, under any patent claims the licensor can
31
+ license, or becomes able to license, to make, have made, use, sell, offer for
32
+ sale, import and have imported the software, in each case subject to the
33
+ limitations and conditions in this license. This license does not cover any
34
+ patent claims that you cause to be infringed by modifications or additions to
35
+ the software. If you or your company make any written claim that the software
36
+ infringes or contributes to infringement of any patent, your patent license
37
+ for the software granted under these terms ends immediately. If your company
38
+ makes such a claim, your patent license ends immediately for work on behalf
39
+ of your company.
40
+
41
+ ## Notices
42
+
43
+ You must ensure that anyone who gets a copy of any part of the software from
44
+ you also gets a copy of these terms.
45
+
46
+ If you modify the software, you must include in any modified copies of the
47
+ software prominent notices stating that you have modified the software.
48
+
49
+ ## No Other Rights
50
+
51
+ These terms do not imply any licenses other than those expressly granted in
52
+ these terms.
53
+
54
+ ## Termination
55
+
56
+ If you use the software in violation of these terms, such use is not
57
+ licensed, and your licenses will automatically terminate. If the licensor
58
+ provides you with a notice of your violation, and you cease all violation of
59
+ this license no later than 30 days after you receive that notice, your
60
+ licenses will be reinstated retroactively. However, if you violate these
61
+ terms after such reinstatement, any additional violation of these terms will
62
+ cause your licenses to terminate automatically and permanently.
63
+
64
+ ## No Liability
65
+
66
+ *As far as the law allows, the software comes as is, without any warranty or
67
+ condition, and the licensor will not be liable to you for any damages arising
68
+ out of these terms or the use or nature of the software, under any kind of
69
+ legal claim.*
70
+
71
+ ## Definitions
72
+
73
+ The **licensor** is the entity offering these terms, and the **software** is
74
+ the software the licensor makes available under these terms, including any
75
+ portion of it.
76
+
77
+ **you** refers to the individual or entity agreeing to these terms.
78
+
79
+ **your company** is any legal entity, sole proprietorship, or other kind of
80
+ organization that you work for, plus all organizations that have control
81
+ over, are under the control of, or are under common control with that
82
+ organization. **control** means ownership of substantially all the assets of
83
+ an entity, or the power to direct its management and policies by vote,
84
+ contract, or otherwise. Control can be direct or indirect.
85
+
86
+ **your licenses** are all the licenses granted to you for the software under
87
+ these terms.
88
+
89
+ **use** means anything you do with the software requiring one of your
90
+ licenses.
91
+
92
+ **trademark** means trademarks, service marks, and similar rights.
93
+
94
+ ---
95
+
96
+ Copyright 2025-2026 En Dash Consulting
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @graview/core
2
+
3
+ Everything a Graview app declares, and the checker that verifies it.
4
+
5
+ - **Schema** — `defineNode` and `createSchema`. Zod is the single source of
6
+ runtime validation, TypeScript types and JSON Schema.
7
+ - **Graph** — nodes and edges, with a tracked reader so a mutation records
8
+ what it read as well as what it wrote.
9
+ - **Mutations** — `defineMutation`. Every change is a typed, named,
10
+ describable act; nothing writes the graph directly.
11
+ - **Invariants** — rules that judge the graph and name the mutations that
12
+ would repair them. That naming is the seam derived affordances ride on.
13
+ - **Operation log** — the graph is a fold over it. Author, intent, reads and
14
+ writes on every op, which is what makes selective undo a dependency
15
+ question rather than a stack.
16
+ - **Permissions** — a `Principal` is an `Author` with roles, so what the log
17
+ blames is what the policy judged.
18
+ - **Theme** — the token contract, the two shipped palettes, and a contrast
19
+ checker that measures a brand's palette before it ships.
20
+ - **`graview check`** — reads a declaration and reports what is wrong with it,
21
+ in terms an agent can act on.
22
+
23
+ ```sh
24
+ npx graview create my-app # a product on Graview, started (also: npm create graview)
25
+ npx graview check ./dist/domain/app.js
26
+ npx graview docs ./dist/domain/app.js
27
+ ```
28
+
29
+ `create` writes the declaration split into domain and UI, a shell, a headless
30
+ test and a CI workflow, initialises a repository, installs, and says what to
31
+ do next. `--link <path>` consumes the framework from a sibling checkout by
32
+ path instead of a registry — the only way that works until the packages are
33
+ published — and refuses a framework that is not built.
34
+ The generator behind it is `@graview/core/scaffold`, a pure function from a
35
+ name and a first kind to a list of files, for a host that provisions apps.
package/dist/app.d.ts ADDED
@@ -0,0 +1,294 @@
1
+ import type { ArrangementWords } from "./arrange.js";
2
+ import type { InvariantDefinition } from "./invariants/types.js";
3
+ import type { AnyMutationDefinition } from "./mutations/types.js";
4
+ import type { Policy } from "./permissions/types.js";
5
+ import type { Brand } from "./theme/types.js";
6
+ import type { ModuleMap } from "./modules.js";
7
+ import type { GraphSnapshot } from "./graph/types.js";
8
+ import type { Primitive } from "./graph/primitives.js";
9
+ import type { AnySchema } from "./schema/schema.js";
10
+ import type { ViewRegistry } from "./views/types.js";
11
+ /**
12
+ * Everything one application declares, in one object. `graview check` and
13
+ * the docs generator both read exactly this — an app that can be checked is
14
+ * an app whose whole surface is declared rather than assembled at runtime.
15
+ */
16
+ /**
17
+ * A role bound to a node kind, an edge kind, or a field of one of the kinds
18
+ * another role already named.
19
+ *
20
+ * The third form arrived with the third lens. A board binds `slots` to a kind
21
+ * and `fill` to an edge, but `x` and `y` are FIELDS of whatever `slots` turned
22
+ * out to be — so the binding says which role supplies the kind, and the check
23
+ * can then verify the field actually exists on it. That is a stronger check
24
+ * than either of the first two shapes had.
25
+ */
26
+ export type EntityBinding = {
27
+ readonly kind: string;
28
+ } | {
29
+ readonly edge: string;
30
+ }
31
+ /**
32
+ * A RELATIONSHIP THAT RUNS THROUGH A NODE.
33
+ *
34
+ * One edge kind covers the relationships that are a bare edge —
35
+ * requirements↔deliverables, skills↔drills. It cannot express the ones
36
+ * where the relationship IS a thing with fields of its own: a concern is
37
+ * addressed by a practice, applied by a routine, which covers a ground.
38
+ * "Is this concern covered on this ground?" is a two-hop question with a
39
+ * node in the middle, and the node in the middle is not incidental — it is
40
+ * where the cadence and the season live.
41
+ *
42
+ * `path` is that walk, named by edge kind, from the COLUMN end to the ROW
43
+ * end. Each step follows an edge of that kind in either direction, because
44
+ * an edge has two readings and which one a domain declared is not the
45
+ * picture's business. The nodes passed through come back with the cell, so
46
+ * pressing "mosquitoes are covered in the Back Lawn" can show WHICH
47
+ * routine does it and when it next runs.
48
+ *
49
+ * Generalises well past one domain: controls↔risks through a policy,
50
+ * tests↔behaviours through a suite, staff↔shifts through a rota line.
51
+ * Wherever the relationship has attributes, it is a node.
52
+ */
53
+ | {
54
+ readonly path: readonly string[];
55
+ } | {
56
+ readonly field: string;
57
+ readonly on: string;
58
+ };
59
+ export interface LensDeclaration {
60
+ readonly name: string;
61
+ readonly requiredRoles: readonly string[];
62
+ /**
63
+ * WHERE THE REUSE WAS PROVED — for a lens this app wrote.
64
+ *
65
+ * "Build it against a domain it was not designed for, and if you cannot
66
+ * write that test, say so plainly: you wrote a view" is the best
67
+ * instruction in `graview-lens` and the one nothing can check. The checker
68
+ * asks about every app-authored lens (`lens-authored-here`) precisely
69
+ * because it cannot know the answer — and a question that can only ever be
70
+ * acknowledged is one people learn to scroll past, which is what the note
71
+ * severity exists to avoid.
72
+ *
73
+ * So the declaration answers it. A path to the test that builds this lens
74
+ * in another domain quiets the note and appears in `graview describe`,
75
+ * where a reader can go and look. It is a claim the author makes, like
76
+ * every `description` here; what it buys is that the claim is written down
77
+ * next to the thing it is about, rather than remembered.
78
+ */
79
+ readonly provenBy?: string;
80
+ /** Defaults to `fields`, which is what every lens did before there were two. */
81
+ readonly binds?: "fields" | "entities";
82
+ /**
83
+ * What the picture opens arranged by, in the arrangement grammar —
84
+ * `{ group: "held-at", filter: "is:current" }` — so the checker can hold
85
+ * it to the bound kind's declaration and `describe` can say it. The lens
86
+ * options carry the same words to the picture (`arrangedBy`).
87
+ */
88
+ readonly arrangedBy?: ArrangementWords;
89
+ readonly bindings?: Readonly<Record<string, Readonly<Record<string, string>>>> | Readonly<Record<string, EntityBinding>>;
90
+ }
91
+ export interface GraviewApp<S extends AnySchema = AnySchema> {
92
+ readonly name: string;
93
+ readonly schema: S;
94
+ readonly mutations?: readonly AnyMutationDefinition<S>[];
95
+ readonly invariants?: readonly InvariantDefinition<S>[];
96
+ readonly views?: ViewRegistry<S, unknown>;
97
+ /**
98
+ * Roles a lens requires an app to bind, and what it binds them to.
99
+ *
100
+ * Two shapes, because there turned out to be two kinds of lens. A `fields`
101
+ * lens maps a KIND's own field names onto its roles — the timeline asks an
102
+ * app which of its fields are `start` and `end`. An `entities` lens maps
103
+ * roles onto whole kinds and edges — the coverage matrix asks which kind is
104
+ * the rows, which is the columns, and which edge fills a cell.
105
+ *
106
+ * The first shape was assumed to be the only one until a second lens
107
+ * existed, which is the usual way that assumption gets found.
108
+ */
109
+ readonly lenses?: readonly LensDeclaration[];
110
+ /**
111
+ * Who may run what. Declared on the app so `graview check` can read it —
112
+ * a mutation no role can ever run and a role that may do nothing are both
113
+ * mistakes in the declaration, findable before anyone meets a button they
114
+ * cannot press.
115
+ */
116
+ readonly policy?: Policy;
117
+ /**
118
+ * The name, the palette and the typography this installation wears.
119
+ *
120
+ * Declared so `graview check` can verify it: a custom palette can be wrong
121
+ * in ways nobody notices — a secondary colour that clears 4.5:1 on a dark
122
+ * ground and fails badly on paper — and contrast is a property the
123
+ * framework can measure rather than trust.
124
+ */
125
+ readonly brand?: Brand;
126
+ /**
127
+ * Named parts of the declaration a workspace can turn on and off.
128
+ *
129
+ * Declared on the app so `graview check` can hold the boundaries: a
130
+ * module naming a kind nobody declared, a requirement naming a module
131
+ * nobody wrote, or an always-on kind whose edge reaches into a module —
132
+ * a line that would dangle the moment someone turns that module off.
133
+ */
134
+ readonly modules?: ModuleMap;
135
+ /**
136
+ * The intelligence this installation runs on, declared.
137
+ *
138
+ * Three kinds share one seam: `graph` (structural derivations, no model),
139
+ * `llm` (a model behind one completion function), `external` (someone
140
+ * else's agent over the derived tool surface). `may` narrows a provider
141
+ * to named mutations — the allowlist `graview check` can verify and a
142
+ * hosted deployment can meter. "Add AI" is an entry here, never a second
143
+ * path to the store.
144
+ */
145
+ readonly intelligence?: readonly IntelligenceProviderDeclaration[];
146
+ /**
147
+ * The declaration's data-schema version, and the migrations that carry a
148
+ * stored graph forward through it.
149
+ *
150
+ * OP-LOG-NATIVE on purpose: a migration answers with primitives — the
151
+ * same vocabulary every other change speaks — so applying one is itself
152
+ * logged, attributed, and invertible (a patch carries its before). The
153
+ * `ship` engine runs them; `graview check` verifies the chain reaches
154
+ * this version with no gaps, because a migration discovered missing at
155
+ * deploy time is the most expensive place to discover it.
156
+ */
157
+ readonly version?: number;
158
+ readonly migrations?: readonly MigrationDeclaration[];
159
+ /**
160
+ * Settings that belong to the READER rather than to the installation.
161
+ *
162
+ * Text size, motion, anything else a person sets for themselves and keeps
163
+ * in their own browser. Declared here for the same reason everything else
164
+ * is: the profile pane draws exactly what the app declares, so adding a
165
+ * setting is a line in the declaration rather than a control somebody
166
+ * wires into a shell — and `graview check` can refuse one nothing could
167
+ * ever honour, which is a control that does nothing.
168
+ */
169
+ readonly settings?: readonly SettingDeclaration[];
170
+ }
171
+ /**
172
+ * One thing a reader may set for themselves.
173
+ *
174
+ * `honoured` is a CLOSED SET, and that is the point of declaring settings
175
+ * at all: the shell knows two ways to carry a person's answer to every
176
+ * surface at once, and a setting that names neither is a control nobody
177
+ * could act on. The checker says so before anybody meets it.
178
+ *
179
+ * "root-font-size" — a CSS length set on <html>. Every surface the
180
+ * framework draws is sized in `rem`, so one answer
181
+ * resizes the whole app, the routed face included,
182
+ * without a single component hearing about it.
183
+ * "root-attribute" — `data-graview-<name>` on <html>, for the theme's
184
+ * own CSS (and an app's) to read. How motion is
185
+ * carried: the stylesheet already honours the
186
+ * system's preference; this lets a person override it.
187
+ */
188
+ export interface SettingDeclaration {
189
+ /** Kebab-case, unique in the app; becomes the storage key and the attribute. */
190
+ readonly name: string;
191
+ /** What a person is choosing, in their words. */
192
+ readonly title: string;
193
+ readonly description?: string;
194
+ readonly honoured: "root-font-size" | "root-attribute";
195
+ /** The answers, in order. At least two — one choice is not a setting. */
196
+ readonly options: readonly {
197
+ readonly value: string;
198
+ readonly label: string;
199
+ }[];
200
+ /** Where a reader who has never chosen starts. Must be one of the options. */
201
+ readonly initial: string;
202
+ }
203
+ export interface MigrationDeclaration {
204
+ readonly from: number;
205
+ readonly to: number;
206
+ readonly title: string;
207
+ /** Primitives that carry a `from`-shaped stored graph to `to`. */
208
+ readonly apply: (snapshot: GraphSnapshot) => readonly Primitive[];
209
+ }
210
+ /**
211
+ * THE FOUR DOORS a browser app has to a model.
212
+ *
213
+ * "paste" — a prompt to copy out and an answer to paste back. Works
214
+ * everywhere, needs nothing, and is the floor every provider
215
+ * should keep: a person with a model open in another tab.
216
+ * "mcp" — an assistant already holding the tool surface reaches in.
217
+ * "key" — the person's own key, typed into this browser. Whoever
218
+ * declares this owes an answer about where the key lives.
219
+ * "local" — a process on this machine, spawned by the dev server and
220
+ * called from the page. Free, private, and only ever there
221
+ * while somebody is running the app from a terminal.
222
+ */
223
+ export type IntelligenceReach = "paste" | "mcp" | "key" | "local";
224
+ /**
225
+ * WHAT KIND OF THING ANSWERS.
226
+ *
227
+ * "graph" — the declaration itself: starter data and the repairs an
228
+ * invariant already named. Keyless, always there.
229
+ * "llm" — a model reached through one completion function. Prose in,
230
+ * prose out, proposals read out of the prose.
231
+ * "external" — somebody's own agent, arriving over the derived tool
232
+ * surface with its own model behind it.
233
+ * "decision" — a model that answers TYPED questions and nothing else: a
234
+ * Choice over named options, a Score over an ordered rubric,
235
+ * a truth with a confidence. It writes no prose and cannot
236
+ * propose an arbitrary call, so a chat seat must not offer
237
+ * it, a field that wants filling should, and the checker
238
+ * refuses it an act whose arguments it could not decide.
239
+ */
240
+ export type IntelligenceKind = "graph" | "llm" | "external" | "decision";
241
+ /** What a provider of some kind can be asked for. */
242
+ export type IntelligenceCapability = "prose" | "decide" | "propose";
243
+ /**
244
+ * The capabilities each kind serves, derived from the kind alone — so a
245
+ * surface asks whether a provider CAN before it offers one, rather than
246
+ * remembering which names talk.
247
+ */
248
+ export declare function providerCan(provider: {
249
+ readonly kind: IntelligenceKind;
250
+ }, capability: IntelligenceCapability): boolean;
251
+ /**
252
+ * THE LADDER HAS TWO AXES, and this is the table that keeps a switch from
253
+ * lying about it. Prose is one axis — a Responder answers in it, and a
254
+ * decision provider has none. A decision is the other — which surface is
255
+ * this, does this practice address that concern — and it can be answered
256
+ * by the graph's own rules, by a decision provider exactly, or by a model
257
+ * with the whole parse-and-refuse layer behind it. A kind declares which
258
+ * it serves; a surface asks for a capability, never for a kind; and what a
259
+ * kind cannot serve falls down to the graph, which is keyless and always
260
+ * there.
261
+ */
262
+ export declare function capabilitiesOf(kind: IntelligenceKind): readonly IntelligenceCapability[];
263
+ /** What a capability is for, in a reader's words. */
264
+ export declare function describeCapability(capability: IntelligenceCapability): string;
265
+ export interface IntelligenceProviderDeclaration {
266
+ readonly name: string;
267
+ readonly kind: IntelligenceKind;
268
+ readonly description?: string;
269
+ /** Mutation names this provider may propose or call. Absent means all. */
270
+ readonly may?: readonly string[];
271
+ /**
272
+ * How words and photographs actually REACH this provider.
273
+ *
274
+ * A provider could be named and bounded and not reached: the declaration
275
+ * said what a model may do and nothing about how a person's photograph
276
+ * gets to it, so nothing derived from it could say either — a seat could
277
+ * not offer "send from here" or "copy the prompt" according to what was
278
+ * declared, the checker could not ask a keyed provider where its key
279
+ * lives, and the docs could not list the doors. Absent means the provider
280
+ * says nothing about its doors, which is what every app said until now.
281
+ */
282
+ readonly reach?: readonly IntelligenceReach[];
283
+ /**
284
+ * Where a `local` reach answers: the dev-server path the bridge serves.
285
+ *
286
+ * Named here so the same string is the checker's evidence that a local
287
+ * reach was actually wired, and the path `useLocalIntelligence()` probes.
288
+ */
289
+ readonly bridge?: string;
290
+ /** Where a `key` reach keeps the key, in the app's own words. */
291
+ readonly keyStorage?: string;
292
+ }
293
+ export declare function defineApp<S extends AnySchema>(app: GraviewApp<S>): GraviewApp<S>;
294
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,w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WAAW,+BAA+B;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,SAAS,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAEhF"}
package/dist/app.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The capabilities each kind serves, derived from the kind alone — so a
3
+ * surface asks whether a provider CAN before it offers one, rather than
4
+ * remembering which names talk.
5
+ */
6
+ export function providerCan(provider, capability) {
7
+ return capabilitiesOf(provider.kind).includes(capability);
8
+ }
9
+ /**
10
+ * THE LADDER HAS TWO AXES, and this is the table that keeps a switch from
11
+ * lying about it. Prose is one axis — a Responder answers in it, and a
12
+ * decision provider has none. A decision is the other — which surface is
13
+ * this, does this practice address that concern — and it can be answered
14
+ * by the graph's own rules, by a decision provider exactly, or by a model
15
+ * with the whole parse-and-refuse layer behind it. A kind declares which
16
+ * it serves; a surface asks for a capability, never for a kind; and what a
17
+ * kind cannot serve falls down to the graph, which is keyless and always
18
+ * there.
19
+ */
20
+ export function capabilitiesOf(kind) {
21
+ switch (kind) {
22
+ case "graph":
23
+ return ["decide", "propose"];
24
+ case "decision":
25
+ return ["decide"];
26
+ case "llm":
27
+ case "external":
28
+ return ["prose", "decide", "propose"];
29
+ default:
30
+ return [];
31
+ }
32
+ }
33
+ /** What a capability is for, in a reader's words. */
34
+ export function describeCapability(capability) {
35
+ switch (capability) {
36
+ case "prose":
37
+ return "talks — answers in sentences";
38
+ case "decide":
39
+ return "decides — answers a typed question with a confidence";
40
+ case "propose":
41
+ return "proposes — offers calls to declared acts";
42
+ default:
43
+ return capability;
44
+ }
45
+ }
46
+ export function defineApp(app) {
47
+ return app;
48
+ }
49
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAoPA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,QAA6C,EAC7C,UAAkC;IAElC,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,cAAc,CAAC,IAAsB;IACnD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,OAAO;YACV,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC/B,KAAK,UAAU;YACb,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,KAAK,KAAK,CAAC;QACX,KAAK,UAAU;YACb,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QACxC;YACE,OAAO,EAAE,CAAC;IACd,CAAC;AACH,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,kBAAkB,CAAC,UAAkC;IACnE,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,8BAA8B,CAAC;QACxC,KAAK,QAAQ;YACX,OAAO,sDAAsD,CAAC;QAChE,KAAK,SAAS;YACZ,OAAO,0CAA0C,CAAC;QACpD;YACE,OAAO,UAAU,CAAC;IACtB,CAAC;AACH,CAAC;AA+BD,MAAM,UAAU,SAAS,CAAsB,GAAkB;IAC/D,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,185 @@
1
+ import type { AnySchema } from "./schema/schema.js";
2
+ /**
3
+ * ARRANGEMENT IS A CAPABILITY OF THE DECLARATION, not of a view.
4
+ *
5
+ * Every surface that lists things arranges them, and each did it its own
6
+ * way or not at all: the list page grouped by an edge through a URL key of
7
+ * its own, the districts sorted by id, the board and the calendar took no
8
+ * sort, filter or group whatever. What a kind CAN be arranged by is already
9
+ * written down — its fields have types, its edges have far ends, its
10
+ * lifecycle names the past, the rules name what is flagged — so the offers
11
+ * are derived here once, headless, and the same string carries the chosen
12
+ * arrangement in a stop's fragment (`in.sort`, `in.filter`, `in.group`) and
13
+ * in a page's search, so an arranged picture is a link.
14
+ */
15
+ export type SortDirection = "asc" | "desc";
16
+ export interface Sort {
17
+ /** `label`, a field name, or an edge kind (by the far end's label). */
18
+ readonly by: string;
19
+ readonly direction: SortDirection;
20
+ }
21
+ /**
22
+ * One condition; a filter is the conjunction of several.
23
+ *
24
+ * `key` is a field name, an edge kind, or `is`. The value's grammar depends
25
+ * on the key: a boolean or enum field takes one of its values; a date field
26
+ * takes `before:<date>`, `after:<date>` or `on:<date>`; an edge takes a
27
+ * node id, `*` (tied to anything) or `none`; `is` takes `current`, `past`,
28
+ * `any`, `flagged` or `clear`. Anything else is dropped, not thrown.
29
+ */
30
+ export interface Condition {
31
+ readonly key: string;
32
+ readonly value: string;
33
+ }
34
+ /** How wide a date group is. A year and a decade are what a catalogue of thirty years reads by. */
35
+ export type DateBucket = "day" | "week" | "month" | "year" | "decade";
36
+ export interface Grouping {
37
+ /** A field name or an edge kind. */
38
+ readonly by: string;
39
+ /** For a date field: how wide a group is. Day when unsaid. */
40
+ readonly bucket?: DateBucket;
41
+ }
42
+ export interface Arrangement {
43
+ readonly sort?: Sort;
44
+ readonly filter?: readonly Condition[];
45
+ readonly group?: Grouping;
46
+ /**
47
+ * Words to look for: a node stays when its label or any scalar field
48
+ * contains them, case aside. The narrowing a person types, beside the
49
+ * conditions a person picks — and the same matcher a search would use.
50
+ */
51
+ readonly query?: string;
52
+ }
53
+ export declare const NO_ARRANGEMENT: Arrangement;
54
+ /** What a lens says to decline arrangement, wholly or a part at a time. */
55
+ export type ArrangeOption = boolean | {
56
+ readonly sort?: boolean;
57
+ readonly filter?: boolean;
58
+ readonly group?: boolean;
59
+ };
60
+ /** Whether a lens offers a part, given what it declared. Everything is on unless declined. */
61
+ export declare function arrangeAllows(option: ArrangeOption | undefined, part: "sort" | "filter" | "group"): boolean;
62
+ export type OfferType = "text" | "number" | "date" | "boolean" | "choice";
63
+ /** One thing a kind can be sorted, filtered or grouped by, in the declaration's own words. */
64
+ export interface ArrangeOffer {
65
+ readonly key: string;
66
+ /** The words for it: the field's reading, the edge kind humanised, or the reserved word's sentence. */
67
+ readonly label: string;
68
+ readonly about: "label" | "field" | "edge" | "is";
69
+ readonly type?: OfferType;
70
+ /** For a choice field, its options; for `is`, its words; for an edge, nothing — the far ends are the graph's. */
71
+ readonly options?: readonly string[];
72
+ /** For a date field, how it may be bucketed when grouped. */
73
+ readonly buckets?: readonly DateBucket[];
74
+ /** For an edge: the kinds at the far end, and how it reads from this kind. */
75
+ readonly far?: readonly string[];
76
+ }
77
+ export interface Arrangeable {
78
+ readonly kind: string;
79
+ readonly sorts: readonly ArrangeOffer[];
80
+ readonly filters: readonly ArrangeOffer[];
81
+ readonly groups: readonly ArrangeOffer[];
82
+ /** The kind's natural order, when `fieldRoles.order` names one. */
83
+ readonly natural?: Sort;
84
+ }
85
+ /** The edges this kind takes part in, from either end, with how each reads from here. */
86
+ export declare function edgesOf(schema: AnySchema, kind: string): readonly ArrangeOffer[];
87
+ /**
88
+ * Whether a condition names one of a kind's RETIRED states — `status:demo`
89
+ * where demos are behind the horizon — which is asking for the past by
90
+ * name. The search box and the list page both left the past out for it and
91
+ * found nothing.
92
+ */
93
+ export declare function asksForThePast(definition: {
94
+ readonly lifecycle?: {
95
+ readonly field: string;
96
+ readonly retired: readonly unknown[] | "date";
97
+ };
98
+ } | undefined, conditions: readonly {
99
+ readonly key: string;
100
+ readonly value: string;
101
+ }[]): boolean;
102
+ /**
103
+ * What a kind can be arranged by, derived from its declaration alone.
104
+ *
105
+ * Sorts: the label, every field with a scalar type, every edge (by the far
106
+ * end's label). Filters: boolean and choice fields by value, date fields by
107
+ * before/after/on, every edge by a node or by having one at all, and `is`
108
+ * for the lifecycle and the standing. Groups: boolean and choice fields,
109
+ * date fields by day, week or month, and every edge by its far end. A field
110
+ * the declaration hides is not offered — an ordering key is not a thing a
111
+ * person groups by.
112
+ */
113
+ export declare function arrangeable(schema: AnySchema, kind: string): Arrangeable;
114
+ export interface ArrangementWords {
115
+ readonly sort?: string;
116
+ readonly filter?: string;
117
+ readonly group?: string;
118
+ readonly q?: string;
119
+ }
120
+ export declare function parseArrangement(words: ArrangementWords): Arrangement;
121
+ export declare function formatArrangement(arrangement: Arrangement): ArrangementWords;
122
+ /**
123
+ * Keeps only the parts a kind can actually be arranged by, and says which
124
+ * were dropped — a stale link names a field that was renamed, and the
125
+ * honest thing is to show the rest arranged and say what was ignored.
126
+ */
127
+ export declare function admitArrangement(arrangement: Arrangement, offers: Arrangeable): {
128
+ readonly arrangement: Arrangement;
129
+ readonly dropped: readonly string[];
130
+ };
131
+ /** What arranging needs of a node: its identity. Fields are read off it by name. */
132
+ export type ArrangeNode = {
133
+ readonly id: string;
134
+ readonly kind: string;
135
+ };
136
+ /**
137
+ * The little of a graph arranging needs, said structurally so a `Graph<S>`
138
+ * over any concrete schema fits — `GraphReader`'s generic `nodesOfKind`
139
+ * does not, once the kinds are literal.
140
+ */
141
+ export interface ArrangeGraph {
142
+ getNode(id: string): ArrangeNode | undefined;
143
+ allNodes(): readonly ArrangeNode[];
144
+ out(id: string, kind?: string): readonly ArrangeNode[];
145
+ in(id: string, kind?: string): readonly ArrangeNode[];
146
+ }
147
+ export interface ArrangeContext {
148
+ readonly schema: AnySchema;
149
+ readonly graph: ArrangeGraph;
150
+ /** Node ids the rules currently implicate, for `is:flagged` and `is:clear`. */
151
+ readonly flagged?: ReadonlySet<string>;
152
+ /** For the lifecycle: today, as YYYY-MM-DD. */
153
+ readonly today?: string;
154
+ }
155
+ export interface ArrangedGroup<N extends ArrangeNode = ArrangeNode> {
156
+ /** Stable, sortable: the value, the date bucket's first day, the far end's id, or `` for none. */
157
+ readonly key: string;
158
+ /** The words for the group: a value as it reads, a date, a far end's label, or "No <reading>". */
159
+ readonly label: string;
160
+ readonly nodes: readonly N[];
161
+ }
162
+ export interface Arranged<N extends ArrangeNode = ArrangeNode> {
163
+ /** The nodes that passed the filter, in order. */
164
+ readonly nodes: readonly N[];
165
+ /** The same nodes, grouped when a grouping was asked; one unnamed group otherwise. */
166
+ readonly groups: readonly ArrangedGroup<N>[];
167
+ readonly grouped: boolean;
168
+ }
169
+ /** The first day of the bucket a date falls in, as YYYY-MM-DD; weeks start on Monday, in UTC. */
170
+ export declare function bucketStart(date: string, bucket: DateBucket): string | undefined;
171
+ /** Whether a node meets one condition of a filter. Search judges its `key:value` tokens with this too. */
172
+ export declare function conditionHolds(ctx: ArrangeContext, node: ArrangeNode, condition: Condition): boolean;
173
+ /**
174
+ * Whether the words find the node — search's own matcher, so a list's `q`
175
+ * and the Find box never disagree: every word the start of a word in the
176
+ * label or a readable field, case, diacritics and punctuation aside.
177
+ */
178
+ export declare function matches(ctx: ArrangeContext, node: ArrangeNode, query: string): boolean;
179
+ /**
180
+ * Filters, sorts and groups. The filter is a conjunction; the sort is
181
+ * stable; a grouping puts the group with nothing to say last. Nodes whose
182
+ * kind the context cannot describe are kept and sort by what they carry.
183
+ */
184
+ export declare function arrange<N extends ArrangeNode>(nodes: readonly N[], arrangement: Arrangement, ctx: ArrangeContext): Arranged<N>;
185
+ //# sourceMappingURL=arrange.d.ts.map