@algomotion/spec 0.0.0-stage → 1.0.0-alpha.1

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 (97) hide show
  1. package/LICENSE +675 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/common.d.ts +136 -0
  4. package/dist/common.d.ts.map +1 -0
  5. package/dist/common.js +181 -0
  6. package/dist/common.js.map +1 -0
  7. package/dist/errors.d.ts +71 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +43 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +10 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +10 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/json-schema.d.ts +3 -0
  16. package/dist/json-schema.d.ts.map +1 -0
  17. package/dist/json-schema.js +16 -0
  18. package/dist/json-schema.js.map +1 -0
  19. package/dist/kinds/array.d.ts +171 -0
  20. package/dist/kinds/array.d.ts.map +1 -0
  21. package/dist/kinds/array.js +179 -0
  22. package/dist/kinds/array.js.map +1 -0
  23. package/dist/kinds/btree.d.ts +190 -0
  24. package/dist/kinds/btree.d.ts.map +1 -0
  25. package/dist/kinds/btree.js +274 -0
  26. package/dist/kinds/btree.js.map +1 -0
  27. package/dist/kinds/graph.d.ts +227 -0
  28. package/dist/kinds/graph.d.ts.map +1 -0
  29. package/dist/kinds/graph.js +229 -0
  30. package/dist/kinds/graph.js.map +1 -0
  31. package/dist/kinds/hash-table.d.ts +108 -0
  32. package/dist/kinds/hash-table.d.ts.map +1 -0
  33. package/dist/kinds/hash-table.js +133 -0
  34. package/dist/kinds/hash-table.js.map +1 -0
  35. package/dist/kinds/index.d.ts +98 -0
  36. package/dist/kinds/index.d.ts.map +1 -0
  37. package/dist/kinds/index.js +53 -0
  38. package/dist/kinds/index.js.map +1 -0
  39. package/dist/kinds/kind.d.ts +73 -0
  40. package/dist/kinds/kind.d.ts.map +1 -0
  41. package/dist/kinds/kind.js +4 -0
  42. package/dist/kinds/kind.js.map +1 -0
  43. package/dist/kinds/linear.d.ts +24 -0
  44. package/dist/kinds/linear.d.ts.map +1 -0
  45. package/dist/kinds/linear.js +26 -0
  46. package/dist/kinds/linear.js.map +1 -0
  47. package/dist/kinds/linked-list.d.ts +132 -0
  48. package/dist/kinds/linked-list.d.ts.map +1 -0
  49. package/dist/kinds/linked-list.js +95 -0
  50. package/dist/kinds/linked-list.js.map +1 -0
  51. package/dist/kinds/plane.d.ts +190 -0
  52. package/dist/kinds/plane.d.ts.map +1 -0
  53. package/dist/kinds/plane.js +206 -0
  54. package/dist/kinds/plane.js.map +1 -0
  55. package/dist/kinds/priority-queue.d.ts +120 -0
  56. package/dist/kinds/priority-queue.d.ts.map +1 -0
  57. package/dist/kinds/priority-queue.js +108 -0
  58. package/dist/kinds/priority-queue.js.map +1 -0
  59. package/dist/kinds/queue.d.ts +94 -0
  60. package/dist/kinds/queue.d.ts.map +1 -0
  61. package/dist/kinds/queue.js +59 -0
  62. package/dist/kinds/queue.js.map +1 -0
  63. package/dist/kinds/stack.d.ts +70 -0
  64. package/dist/kinds/stack.d.ts.map +1 -0
  65. package/dist/kinds/stack.js +50 -0
  66. package/dist/kinds/stack.js.map +1 -0
  67. package/dist/kinds/table.d.ts +65 -0
  68. package/dist/kinds/table.d.ts.map +1 -0
  69. package/dist/kinds/table.js +116 -0
  70. package/dist/kinds/table.js.map +1 -0
  71. package/dist/kinds/tree.d.ts +272 -0
  72. package/dist/kinds/tree.d.ts.map +1 -0
  73. package/dist/kinds/tree.js +380 -0
  74. package/dist/kinds/tree.js.map +1 -0
  75. package/dist/parse.d.ts +26 -0
  76. package/dist/parse.d.ts.map +1 -0
  77. package/dist/parse.js +380 -0
  78. package/dist/parse.js.map +1 -0
  79. package/dist/result.d.ts +16 -0
  80. package/dist/result.d.ts.map +1 -0
  81. package/dist/result.js +3 -0
  82. package/dist/result.js.map +1 -0
  83. package/dist/share.d.ts +68 -0
  84. package/dist/share.d.ts.map +1 -0
  85. package/dist/share.js +319 -0
  86. package/dist/share.js.map +1 -0
  87. package/dist/version.d.ts +108 -0
  88. package/dist/version.d.ts.map +1 -0
  89. package/dist/version.js +167 -0
  90. package/dist/version.js.map +1 -0
  91. package/dist/visualization.d.ts +3591 -0
  92. package/dist/visualization.d.ts.map +1 -0
  93. package/dist/visualization.js +131 -0
  94. package/dist/visualization.js.map +1 -0
  95. package/package.json +45 -4
  96. package/schema/visualization.schema.json +5717 -0
  97. package/README.md +0 -3
@@ -0,0 +1,274 @@
1
+ /**
2
+ * The `btree` kind (ADR 0035): multiway search trees whose nodes hold
3
+ * several keys in order, such as B-trees and 2-3-4 trees. A node has no
4
+ * children (a leaf) or one more than its keys; child `i` hangs from the
5
+ * gap left of key `i`. Keys are elements: they keep their ids when they
6
+ * move between nodes, so a drawing can follow them.
7
+ *
8
+ * A tree always has a root: an empty tree is a root leaf with no keys, as
9
+ * CLRS's B-TREE-CREATE makes it. The kind enforces no minimum degree, no
10
+ * key order and no level leaves: recipes keep those rules. Every action
11
+ * keeps the shape valid.
12
+ *
13
+ * Marks: `highlight` lasts one step; `settle`, `pointer` and `annotate`
14
+ * persist.
15
+ */
16
+ import { z } from 'zod';
17
+ import { Element, ElementId, ElementInput, isElement, LIMITS, Place, PointerName, Scalar, } from "../common.js";
18
+ import { typesOf } from "./kind.js";
19
+ /** Most keys one node holds. */
20
+ export const MAX_NODE_KEYS = 32;
21
+ const Children = z
22
+ .array(ElementId)
23
+ .max(MAX_NODE_KEYS + 1)
24
+ .describe('Child node ids, one more than the keys; none for a leaf.');
25
+ export const BTreeNode = z
26
+ .strictObject({
27
+ id: ElementId,
28
+ keys: z.array(Element).max(MAX_NODE_KEYS),
29
+ children: Children.optional(),
30
+ })
31
+ .describe('A node: its keys in order and its children.');
32
+ const BTreeNodeInput = z
33
+ .strictObject({
34
+ id: ElementId,
35
+ keys: z
36
+ .array(ElementInput)
37
+ .max(MAX_NODE_KEYS)
38
+ .describe('Keys in order: values like ["G", "M"] (ids "k0", "k1", … are generated through the tree) or elements { "id", "value" }.'),
39
+ children: Children.optional(),
40
+ })
41
+ .describe('A node: its keys in order and its children.');
42
+ const label = z.string().max(LIMITS.textLength).optional();
43
+ /** Canonical declaration. */
44
+ export const BTreeDecl = z
45
+ .strictObject({
46
+ kind: z.literal('btree'),
47
+ label,
48
+ place: Place.optional(),
49
+ nodes: z.array(BTreeNode).min(1).max(LIMITS.elementsPerStructure),
50
+ root: ElementId.describe('The root node.'),
51
+ })
52
+ .describe('A multiway search tree, such as a B-tree.');
53
+ export const BTreeDeclInput = z
54
+ .strictObject({
55
+ kind: z.literal('btree'),
56
+ label,
57
+ place: Place.optional(),
58
+ nodes: z
59
+ .array(BTreeNodeInput)
60
+ .min(1)
61
+ .max(LIMITS.elementsPerStructure)
62
+ .optional()
63
+ .describe('The nodes; by default one empty root with the id "root".'),
64
+ root: ElementId.optional().describe('The root node; by default the node that is nobody’s child.'),
65
+ })
66
+ .describe('A multiway search tree, such as a B-tree.');
67
+ /** An empty root id, which no element id can be: validation reports it. */
68
+ const NO_ROOT = '';
69
+ function normalizeBTreeDecl(input) {
70
+ const { nodes: given = [{ id: 'root', keys: [] }], root, ...rest } = input;
71
+ // Generated key ids skip the ids the author wrote.
72
+ const taken = new Set([
73
+ ...given.map((n) => n.id),
74
+ ...given.flatMap((n) => n.keys.filter(isElement).map((k) => k.id)),
75
+ ]);
76
+ let next = 0;
77
+ const fresh = () => {
78
+ while (taken.has(`k${next}`))
79
+ next++;
80
+ return `k${next++}`;
81
+ };
82
+ const nodes = given.map((n) => ({
83
+ id: n.id,
84
+ keys: n.keys.map((k) => (isElement(k) ? k : { id: fresh(), value: k })),
85
+ ...(n.children === undefined ? {} : { children: n.children }),
86
+ }));
87
+ if (root !== undefined)
88
+ return { ...rest, nodes, root };
89
+ const children = new Set(nodes.flatMap((n) => n.children ?? []));
90
+ const parentless = nodes.filter((n) => !children.has(n.id));
91
+ return {
92
+ ...rest,
93
+ nodes,
94
+ root: parentless.length === 1 ? parentless[0].id : NO_ROOT,
95
+ };
96
+ }
97
+ /** Shape rules: size, child counts, one parent each, one root, no cycles. */
98
+ export function validateBTreeDecl(decl) {
99
+ const issues = [];
100
+ const total = decl.nodes.reduce((n, node) => n + 1 + node.keys.length, 0);
101
+ if (total > LIMITS.elementsPerStructure)
102
+ issues.push({
103
+ path: ['nodes'],
104
+ message: `The tree holds ${total} elements, nodes and keys together; at most ${LIMITS.elementsPerStructure} are allowed`,
105
+ });
106
+ const index = new Map(decl.nodes.map((n, k) => [n.id, k]));
107
+ const parent = new Map();
108
+ decl.nodes.forEach((node, k) => {
109
+ const children = node.children ?? [];
110
+ if (children.length !== 0 && children.length !== node.keys.length + 1)
111
+ issues.push({
112
+ path: ['nodes', k, 'children'],
113
+ message: `Node "${node.id}" has ${node.keys.length} keys and ${children.length} children; a node has no children or one more than its keys`,
114
+ });
115
+ children.forEach((child, c) => {
116
+ const path = ['nodes', k, 'children', c];
117
+ if (!index.has(child))
118
+ issues.push({
119
+ path,
120
+ message: `Child "${child}" is not a node of this tree`,
121
+ });
122
+ else if (parent.has(child))
123
+ issues.push({
124
+ path,
125
+ message: parent.get(child) === node.id
126
+ ? `Node "${node.id}" lists "${child}" as a child twice`
127
+ : `Node "${child}" has two parents ("${parent.get(child)}" and "${node.id}")`,
128
+ });
129
+ else
130
+ parent.set(child, node.id);
131
+ });
132
+ });
133
+ if (decl.root === NO_ROOT) {
134
+ issues.push({
135
+ path: ['root'],
136
+ message: 'No node, or more than one, is nobody’s child',
137
+ hint: 'Say which node is the root with `root`.',
138
+ });
139
+ return issues;
140
+ }
141
+ if (!index.has(decl.root)) {
142
+ issues.push({
143
+ path: ['root'],
144
+ message: `Root "${decl.root}" is not a node of this tree`,
145
+ });
146
+ return issues;
147
+ }
148
+ if (parent.has(decl.root))
149
+ issues.push({
150
+ path: ['root'],
151
+ message: `Root "${decl.root}" is also the child of "${parent.get(decl.root)}"`,
152
+ });
153
+ const seen = new Set();
154
+ const stack = [decl.root];
155
+ while (stack.length > 0) {
156
+ const id = stack.pop();
157
+ if (seen.has(id))
158
+ continue;
159
+ seen.add(id);
160
+ for (const c of decl.nodes[index.get(id)].children ?? [])
161
+ if (index.has(c))
162
+ stack.push(c);
163
+ }
164
+ decl.nodes.forEach((node, k) => {
165
+ if (!seen.has(node.id))
166
+ issues.push({
167
+ path: ['nodes', k],
168
+ message: `Node "${node.id}" is not reachable from the root`,
169
+ hint: 'Every node but the root is the child of one node.',
170
+ });
171
+ });
172
+ return issues;
173
+ }
174
+ const NodeRef = ElementId.describe('A node id.');
175
+ const KeyRef = ElementId.describe('A key id.');
176
+ const Index = z.int().min(0).max(MAX_NODE_KEYS);
177
+ const actions = (key) => z.discriminatedUnion('type', [
178
+ z
179
+ .strictObject({
180
+ type: z.literal('insertKey'),
181
+ node: NodeRef,
182
+ index: Index,
183
+ key,
184
+ })
185
+ .describe('Insert a key into a leaf at position `index`, from 0 to its number of keys.'),
186
+ z
187
+ .strictObject({ type: z.literal('removeKey'), key: KeyRef })
188
+ .describe('Remove a key from the leaf that holds it.'),
189
+ z
190
+ .strictObject({ type: z.literal('setKey'), key: KeyRef, value: Scalar })
191
+ .describe('Change a key’s value: a relabelling that keeps its cell and marks.'),
192
+ z
193
+ .strictObject({ type: z.literal('lift'), key: KeyRef, over: KeyRef })
194
+ .describe('The key `key`, in a leaf, leaves it and takes the place of the key `over` in an inner node, which is removed: a predecessor or successor rising in a deletion.'),
195
+ z
196
+ .strictObject({
197
+ type: z.literal('split'),
198
+ node: NodeRef,
199
+ index: Index,
200
+ newNode: ElementId,
201
+ })
202
+ .describe('Split child `index` of `node` around its middle key, at ⌊(k − 1)/2⌋ of its k keys: the middle key rises into `node` at `index`, the keys and children right of it go to the new node `newNode`, child `index + 1`. The child needs at least 3 keys.'),
203
+ z
204
+ .strictObject({ type: z.literal('grow'), newRoot: ElementId })
205
+ .describe('Put a new root with no keys above the root, with the old root as its one child; a split of that child follows.'),
206
+ z
207
+ .strictObject({ type: z.literal('merge'), node: NodeRef, index: Index })
208
+ .describe('Merge child `index` of `node`, its key `index` and child `index + 1` into child `index`; child `index + 1` goes. Both children are leaves, or both have children.'),
209
+ z
210
+ .strictObject({ type: z.literal('shrink') })
211
+ .describe('The root has no keys and one child: the child becomes the root.'),
212
+ z
213
+ .strictObject({
214
+ type: z.literal('borrow'),
215
+ node: NodeRef,
216
+ child: Index,
217
+ from: z.enum(['left', 'right']),
218
+ })
219
+ .describe('Child `child` of `node` takes a key from its sibling on the side `from`, through `node`. From "right": `node`’s key `child` falls to the end of the child, the right sibling’s first key rises in its place, and the sibling’s first child moves to the end of the child. From "left" it mirrors: key `child − 1` falls to the front, the left sibling’s last key rises, its last child moves to the front.'),
220
+ z
221
+ .strictObject({
222
+ type: z.literal('highlight'),
223
+ keys: z.array(KeyRef).max(LIMITS.elementsPerStructure).optional(),
224
+ nodes: z.array(NodeRef).max(LIMITS.elementsPerStructure).optional(),
225
+ })
226
+ .describe('Highlight keys and nodes (this step only).'),
227
+ z
228
+ .strictObject({ type: z.literal('settle'), key: KeyRef })
229
+ .describe('Mark a key as found (persists).'),
230
+ z
231
+ .strictObject({
232
+ type: z.literal('pointer'),
233
+ name: PointerName,
234
+ node: NodeRef.nullable(),
235
+ })
236
+ .describe('Point a named pointer at a node; null removes it.'),
237
+ z
238
+ .strictObject({
239
+ type: z.literal('annotate'),
240
+ node: NodeRef,
241
+ text: z.string().max(32).nullable(),
242
+ })
243
+ .describe('Show a short note beside a node; null removes it.'),
244
+ ]);
245
+ export const BTreeAction = actions(Element);
246
+ export const BTreeActionInput = actions(ElementInput);
247
+ export const btreeSpec = {
248
+ kind: 'btree',
249
+ decl: BTreeDecl,
250
+ declInput: BTreeDeclInput,
251
+ action: BTreeAction,
252
+ actionInput: BTreeActionInput,
253
+ actionTypes: typesOf(BTreeAction),
254
+ normalizeDecl: normalizeBTreeDecl,
255
+ declIds: (decl) => decl.nodes.flatMap((n, k) => [
256
+ { id: n.id, path: ['nodes', k, 'id'] },
257
+ ...n.keys.map((key, j) => ({
258
+ id: key.id,
259
+ path: ['nodes', k, 'keys', j, 'id'],
260
+ })),
261
+ ]),
262
+ validateDecl: validateBTreeDecl,
263
+ normalizeAction: (input, ctx) => input.type === 'insertKey' && !isElement(input.key)
264
+ ? { ...input, key: { id: ctx.allocateId('k'), value: input.key } }
265
+ : input,
266
+ introducedIds: (action) => action.type === 'insertKey'
267
+ ? [{ id: action.key.id, path: ['key', 'id'] }]
268
+ : action.type === 'split'
269
+ ? [{ id: action.newNode, path: ['newNode'] }]
270
+ : action.type === 'grow'
271
+ ? [{ id: action.newRoot, path: ['newRoot'] }]
272
+ : [],
273
+ };
274
+ //# sourceMappingURL=btree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"btree.js","sourceRoot":"","sources":["../../src/kinds/btree.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,OAAO,EACP,SAAS,EACT,YAAY,EACZ,SAAS,EACT,MAAM,EACN,KAAK,EACL,WAAW,EACX,MAAM,GACP,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAA6C,MAAM,WAAW,CAAC;AAE/E,gCAAgC;AAChC,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC;AAEhC,MAAM,QAAQ,GAAG,CAAC;KACf,KAAK,CAAC,SAAS,CAAC;KAChB,GAAG,CAAC,aAAa,GAAG,CAAC,CAAC;KACtB,QAAQ,CAAC,0DAA0D,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC;KACvB,YAAY,CAAC;IACZ,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;IACzC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE;CAC9B,CAAC;KACD,QAA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,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;QAC9C,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO;YACvB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM;gBACtB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC7C,CAAC,CAAC,EAAE;CACb,CAAC"}
@@ -0,0 +1,227 @@
1
+ /**
2
+ * The `graph` kind: directed or undirected graphs with optional edge
3
+ * weights, for traversals, shortest paths, spanning trees, topological
4
+ * sorting and flows.
5
+ *
6
+ * Node ids double as names: the shorthand `"nodes": ["A", "B"]` declares
7
+ * nodes A and B, and the edge `["A", "B", 4]` gets the id `A-B`.
8
+ *
9
+ * Marks: `highlight` lasts one step; `visit`, `settle`, `group`, `pointer`,
10
+ * `annotate` and `markEdge` persist until changed or `resetMarks`.
11
+ */
12
+ import { z } from 'zod';
13
+ import { type DeclIssue, type KindSpec } from './kind.ts';
14
+ export declare const GraphNode: z.ZodObject<{
15
+ id: z.ZodString;
16
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
17
+ x: z.ZodOptional<z.ZodNumber>;
18
+ y: z.ZodOptional<z.ZodNumber>;
19
+ }, z.core.$strict>;
20
+ export type GraphNode = z.infer<typeof GraphNode>;
21
+ export declare const GraphEdge: z.ZodObject<{
22
+ id: z.ZodString;
23
+ from: z.ZodString;
24
+ to: z.ZodString;
25
+ weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
26
+ }, z.core.$strict>;
27
+ export type GraphEdge = z.infer<typeof GraphEdge>;
28
+ export declare const GraphLayout: z.ZodEnum<{
29
+ auto: "auto";
30
+ circle: "circle";
31
+ layered: "layered";
32
+ grid: "grid";
33
+ manual: "manual";
34
+ }>;
35
+ export type GraphLayout = z.infer<typeof GraphLayout>;
36
+ export declare const GraphDecl: z.ZodObject<{
37
+ kind: z.ZodLiteral<"graph">;
38
+ label: z.ZodOptional<z.ZodString>;
39
+ place: z.ZodOptional<z.ZodEnum<{
40
+ main: "main";
41
+ side: "side";
42
+ }>>;
43
+ directed: z.ZodBoolean;
44
+ layout: z.ZodEnum<{
45
+ auto: "auto";
46
+ circle: "circle";
47
+ layered: "layered";
48
+ grid: "grid";
49
+ manual: "manual";
50
+ }>;
51
+ nodes: z.ZodArray<z.ZodObject<{
52
+ id: z.ZodString;
53
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
54
+ x: z.ZodOptional<z.ZodNumber>;
55
+ y: z.ZodOptional<z.ZodNumber>;
56
+ }, z.core.$strict>>;
57
+ edges: z.ZodArray<z.ZodObject<{
58
+ id: z.ZodString;
59
+ from: z.ZodString;
60
+ to: z.ZodString;
61
+ weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
62
+ }, z.core.$strict>>;
63
+ }, z.core.$strict>;
64
+ export type GraphDecl = z.infer<typeof GraphDecl>;
65
+ export declare const GraphDeclInput: z.ZodObject<{
66
+ kind: z.ZodLiteral<"graph">;
67
+ label: z.ZodOptional<z.ZodString>;
68
+ place: z.ZodOptional<z.ZodEnum<{
69
+ main: "main";
70
+ side: "side";
71
+ }>>;
72
+ directed: z.ZodOptional<z.ZodBoolean>;
73
+ layout: z.ZodOptional<z.ZodEnum<{
74
+ auto: "auto";
75
+ circle: "circle";
76
+ layered: "layered";
77
+ grid: "grid";
78
+ manual: "manual";
79
+ }>>;
80
+ nodes: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
81
+ id: z.ZodString;
82
+ x: z.ZodOptional<z.ZodNumber>;
83
+ y: z.ZodOptional<z.ZodNumber>;
84
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
85
+ }, z.core.$strict>, z.ZodString, z.ZodNumber]>>>;
86
+ edges: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
87
+ from: z.ZodString;
88
+ to: z.ZodString;
89
+ weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
90
+ id: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strict>, z.ZodTuple<[z.ZodString, z.ZodString], null>, z.ZodTuple<[z.ZodString, z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>], null>]>>>;
92
+ }, z.core.$strict>;
93
+ export type GraphDeclInput = z.infer<typeof GraphDeclInput>;
94
+ export declare function validateGraphDecl(decl: GraphDecl): DeclIssue[];
95
+ export declare const GraphAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
96
+ type: z.ZodLiteral<"addNode">;
97
+ node: z.ZodObject<{
98
+ id: z.ZodString;
99
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
100
+ x: z.ZodOptional<z.ZodNumber>;
101
+ y: z.ZodOptional<z.ZodNumber>;
102
+ }, z.core.$strict>;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ type: z.ZodLiteral<"removeNode">;
105
+ node: z.ZodString;
106
+ }, z.core.$strict>, z.ZodObject<{
107
+ type: z.ZodLiteral<"setValue">;
108
+ node: z.ZodString;
109
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ type: z.ZodLiteral<"addEdge">;
112
+ edge: z.ZodObject<{
113
+ id: z.ZodString;
114
+ from: z.ZodString;
115
+ to: z.ZodString;
116
+ weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
117
+ }, z.core.$strict>;
118
+ }, z.core.$strict>, z.ZodObject<{
119
+ type: z.ZodLiteral<"removeEdge">;
120
+ edge: z.ZodString;
121
+ }, z.core.$strict>, z.ZodObject<{
122
+ type: z.ZodLiteral<"setWeight">;
123
+ edge: z.ZodString;
124
+ weight: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
125
+ }, z.core.$strict>, z.ZodObject<{
126
+ type: z.ZodLiteral<"highlight">;
127
+ nodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
128
+ edges: z.ZodOptional<z.ZodArray<z.ZodString>>;
129
+ }, z.core.$strict>, z.ZodObject<{
130
+ type: z.ZodLiteral<"visit">;
131
+ node: z.ZodString;
132
+ }, z.core.$strict>, z.ZodObject<{
133
+ type: z.ZodLiteral<"settle">;
134
+ node: z.ZodString;
135
+ }, z.core.$strict>, z.ZodObject<{
136
+ type: z.ZodLiteral<"group">;
137
+ node: z.ZodString;
138
+ group: z.ZodNullable<z.ZodLiteral<0 | 1 | 4 | 2 | 3 | 5>>;
139
+ }, z.core.$strict>, z.ZodObject<{
140
+ type: z.ZodLiteral<"pointer">;
141
+ name: z.ZodString;
142
+ node: z.ZodNullable<z.ZodString>;
143
+ }, z.core.$strict>, z.ZodObject<{
144
+ type: z.ZodLiteral<"annotate">;
145
+ node: z.ZodString;
146
+ text: z.ZodNullable<z.ZodString>;
147
+ }, z.core.$strict>, z.ZodObject<{
148
+ type: z.ZodLiteral<"markEdge">;
149
+ edge: z.ZodString;
150
+ mark: z.ZodNullable<z.ZodEnum<{
151
+ selected: "selected";
152
+ rejected: "rejected";
153
+ }>>;
154
+ }, z.core.$strict>, z.ZodObject<{
155
+ type: z.ZodLiteral<"resetMarks">;
156
+ }, z.core.$strict>], "type">;
157
+ export type GraphAction = z.infer<typeof GraphAction>;
158
+ export declare const GraphActionInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
159
+ type: z.ZodLiteral<"addNode">;
160
+ node: z.ZodUnion<readonly [z.ZodObject<{
161
+ id: z.ZodString;
162
+ x: z.ZodOptional<z.ZodNumber>;
163
+ y: z.ZodOptional<z.ZodNumber>;
164
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
165
+ }, z.core.$strict>, z.ZodString, z.ZodNumber]>;
166
+ }, z.core.$strict>, z.ZodObject<{
167
+ type: z.ZodLiteral<"removeNode">;
168
+ node: z.ZodString;
169
+ }, z.core.$strict>, z.ZodObject<{
170
+ type: z.ZodLiteral<"setValue">;
171
+ node: z.ZodString;
172
+ value: z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>;
173
+ }, z.core.$strict>, z.ZodObject<{
174
+ type: z.ZodLiteral<"addEdge">;
175
+ edge: z.ZodUnion<readonly [z.ZodObject<{
176
+ from: z.ZodString;
177
+ to: z.ZodString;
178
+ weight: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
179
+ id: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strict>, z.ZodTuple<[z.ZodString, z.ZodString], null>, z.ZodTuple<[z.ZodString, z.ZodString, z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>], null>]>;
181
+ }, z.core.$strict>, z.ZodObject<{
182
+ type: z.ZodLiteral<"removeEdge">;
183
+ edge: z.ZodString;
184
+ }, z.core.$strict>, z.ZodObject<{
185
+ type: z.ZodLiteral<"setWeight">;
186
+ edge: z.ZodString;
187
+ weight: z.ZodNullable<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>>;
188
+ }, z.core.$strict>, z.ZodObject<{
189
+ type: z.ZodLiteral<"highlight">;
190
+ nodes: z.ZodOptional<z.ZodArray<z.ZodString>>;
191
+ edges: z.ZodOptional<z.ZodArray<z.ZodString>>;
192
+ }, z.core.$strict>, z.ZodObject<{
193
+ type: z.ZodLiteral<"visit">;
194
+ node: z.ZodString;
195
+ }, z.core.$strict>, z.ZodObject<{
196
+ type: z.ZodLiteral<"settle">;
197
+ node: z.ZodString;
198
+ }, z.core.$strict>, z.ZodObject<{
199
+ type: z.ZodLiteral<"group">;
200
+ node: z.ZodString;
201
+ group: z.ZodNullable<z.ZodLiteral<0 | 1 | 4 | 2 | 3 | 5>>;
202
+ }, z.core.$strict>, z.ZodObject<{
203
+ type: z.ZodLiteral<"pointer">;
204
+ name: z.ZodString;
205
+ node: z.ZodNullable<z.ZodString>;
206
+ }, z.core.$strict>, z.ZodObject<{
207
+ type: z.ZodLiteral<"annotate">;
208
+ node: z.ZodString;
209
+ text: z.ZodNullable<z.ZodString>;
210
+ }, z.core.$strict>, z.ZodObject<{
211
+ type: z.ZodLiteral<"markEdge">;
212
+ edge: z.ZodString;
213
+ mark: z.ZodNullable<z.ZodEnum<{
214
+ selected: "selected";
215
+ rejected: "rejected";
216
+ }>>;
217
+ }, z.core.$strict>, z.ZodObject<{
218
+ type: z.ZodLiteral<"resetMarks">;
219
+ }, z.core.$strict>], "type">;
220
+ export type GraphActionInput = z.infer<typeof GraphActionInput>;
221
+ export declare const graphSpec: KindSpec<{
222
+ decl: GraphDecl;
223
+ declInput: GraphDeclInput;
224
+ action: GraphAction;
225
+ actionInput: GraphActionInput;
226
+ }>;
227
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/kinds/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,OAAO,EAAW,KAAK,SAAS,EAAc,KAAK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