@synnaxlabs/client 0.55.0 → 0.56.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 (197) hide show
  1. package/.turbo/turbo-build.log +10 -13
  2. package/dist/client.cjs +60 -36
  3. package/dist/client.js +6435 -4786
  4. package/dist/src/access/policy/client.d.ts +70 -80
  5. package/dist/src/access/policy/client.d.ts.map +1 -1
  6. package/dist/src/access/policy/types.gen.d.ts +18 -20
  7. package/dist/src/access/policy/types.gen.d.ts.map +1 -1
  8. package/dist/src/access/role/client.d.ts.map +1 -1
  9. package/dist/src/access/role/types.gen.d.ts +2 -2
  10. package/dist/src/actions/actions.d.ts +68 -0
  11. package/dist/src/actions/actions.d.ts.map +1 -0
  12. package/dist/src/actions/actions.spec.d.ts +2 -0
  13. package/dist/src/actions/actions.spec.d.ts.map +1 -0
  14. package/dist/src/actions/external.d.ts +2 -0
  15. package/dist/src/actions/external.d.ts.map +1 -0
  16. package/dist/src/actions/index.d.ts +2 -0
  17. package/dist/src/actions/index.d.ts.map +1 -0
  18. package/dist/src/arc/client.d.ts.map +1 -1
  19. package/dist/src/arc/compiler/types.gen.d.ts +1 -1
  20. package/dist/src/arc/compiler/types.gen.d.ts.map +1 -1
  21. package/dist/src/arc/graph/types.gen.d.ts +29 -29
  22. package/dist/src/arc/graph/types.gen.d.ts.map +1 -1
  23. package/dist/src/arc/ir/types.gen.d.ts +123 -123
  24. package/dist/src/arc/ir/types.gen.d.ts.map +1 -1
  25. package/dist/src/arc/module/types.gen.d.ts +45 -45
  26. package/dist/src/arc/program/types.gen.d.ts +45 -45
  27. package/dist/src/arc/types/types.gen.d.ts +11 -11
  28. package/dist/src/arc/types/types.gen.d.ts.map +1 -1
  29. package/dist/src/arc/types.gen.d.ts +99 -99
  30. package/dist/src/auth/auth.d.ts +3 -3
  31. package/dist/src/auth/auth.d.ts.map +1 -1
  32. package/dist/src/channel/client.d.ts +2 -2
  33. package/dist/src/channel/client.d.ts.map +1 -1
  34. package/dist/src/channel/retriever.d.ts +5 -8
  35. package/dist/src/channel/retriever.d.ts.map +1 -1
  36. package/dist/src/channel/types.gen.d.ts +3 -3
  37. package/dist/src/channel/writer.d.ts.map +1 -1
  38. package/dist/src/connection/checker.d.ts +1 -1
  39. package/dist/src/connection/checker.d.ts.map +1 -1
  40. package/dist/src/device/client.d.ts.map +1 -1
  41. package/dist/src/device/types.gen.d.ts +6 -8
  42. package/dist/src/device/types.gen.d.ts.map +1 -1
  43. package/dist/src/errors.d.ts +2 -0
  44. package/dist/src/errors.d.ts.map +1 -1
  45. package/dist/src/framer/adapter.d.ts.map +1 -1
  46. package/dist/src/framer/client.d.ts +2 -2
  47. package/dist/src/framer/codec.d.ts +9 -1
  48. package/dist/src/framer/codec.d.ts.map +1 -1
  49. package/dist/src/framer/deleter.d.ts.map +1 -1
  50. package/dist/src/framer/frame.d.ts +1 -1
  51. package/dist/src/framer/iterator.d.ts +84 -3
  52. package/dist/src/framer/iterator.d.ts.map +1 -1
  53. package/dist/src/framer/streamProxy.d.ts.map +1 -1
  54. package/dist/src/framer/streamer.d.ts +1 -3
  55. package/dist/src/framer/streamer.d.ts.map +1 -1
  56. package/dist/src/framer/types.gen.d.ts +18 -0
  57. package/dist/src/framer/types.gen.d.ts.map +1 -1
  58. package/dist/src/framer/writer.d.ts +8 -8
  59. package/dist/src/framer/writer.d.ts.map +1 -1
  60. package/dist/src/group/client.d.ts +1 -2
  61. package/dist/src/group/client.d.ts.map +1 -1
  62. package/dist/src/group/types.gen.d.ts +2 -2
  63. package/dist/src/index.d.ts +2 -1
  64. package/dist/src/index.d.ts.map +1 -1
  65. package/dist/src/label/client.d.ts +5 -8
  66. package/dist/src/label/client.d.ts.map +1 -1
  67. package/dist/src/lineplot/client.d.ts.map +1 -1
  68. package/dist/src/lineplot/types.gen.d.ts +2 -2
  69. package/dist/src/log/client.d.ts.map +1 -1
  70. package/dist/src/log/types.gen.d.ts +2 -2
  71. package/dist/src/ontology/client.d.ts +1 -3
  72. package/dist/src/ontology/client.d.ts.map +1 -1
  73. package/dist/src/ontology/payload.d.ts +12 -16
  74. package/dist/src/ontology/payload.d.ts.map +1 -1
  75. package/dist/src/ontology/types.gen.d.ts +1 -2
  76. package/dist/src/ontology/types.gen.d.ts.map +1 -1
  77. package/dist/src/ontology/writer.d.ts +5 -10
  78. package/dist/src/ontology/writer.d.ts.map +1 -1
  79. package/dist/src/rack/client.d.ts.map +1 -1
  80. package/dist/src/rack/types.gen.d.ts +3 -3
  81. package/dist/src/ranger/alias/client.d.ts.map +1 -1
  82. package/dist/src/ranger/client.d.ts.map +1 -1
  83. package/dist/src/ranger/kv/client.d.ts.map +1 -1
  84. package/dist/src/ranger/types.gen.d.ts +6 -6
  85. package/dist/src/ranger/types.gen.d.ts.map +1 -1
  86. package/dist/src/ranger/writer.d.ts +2 -3
  87. package/dist/src/ranger/writer.d.ts.map +1 -1
  88. package/dist/src/schematic/actions.d.ts +147 -0
  89. package/dist/src/schematic/actions.d.ts.map +1 -0
  90. package/dist/src/schematic/actions.gen.d.ts +484 -0
  91. package/dist/src/schematic/actions.gen.d.ts.map +1 -0
  92. package/dist/src/schematic/actions.spec.d.ts +2 -0
  93. package/dist/src/schematic/actions.spec.d.ts.map +1 -0
  94. package/dist/src/schematic/client.d.ts +53 -2
  95. package/dist/src/schematic/client.d.ts.map +1 -1
  96. package/dist/src/schematic/external.d.ts +2 -0
  97. package/dist/src/schematic/external.d.ts.map +1 -1
  98. package/dist/src/schematic/symbol/client.d.ts.map +1 -1
  99. package/dist/src/schematic/symbol/types.gen.d.ts +48 -58
  100. package/dist/src/schematic/symbol/types.gen.d.ts.map +1 -1
  101. package/dist/src/schematic/types.gen.d.ts +131 -5
  102. package/dist/src/schematic/types.gen.d.ts.map +1 -1
  103. package/dist/src/status/client.d.ts.map +1 -1
  104. package/dist/src/status/payload.d.ts +3 -3
  105. package/dist/src/table/actions.d.ts +156 -0
  106. package/dist/src/table/actions.d.ts.map +1 -0
  107. package/dist/src/table/actions.gen.d.ts +587 -0
  108. package/dist/src/table/actions.gen.d.ts.map +1 -0
  109. package/dist/src/table/client.d.ts +28 -2
  110. package/dist/src/table/client.d.ts.map +1 -1
  111. package/dist/src/table/external.d.ts +2 -0
  112. package/dist/src/table/external.d.ts.map +1 -1
  113. package/dist/src/table/types.gen.d.ts +71 -4
  114. package/dist/src/table/types.gen.d.ts.map +1 -1
  115. package/dist/src/task/client.d.ts.map +1 -1
  116. package/dist/src/task/types.gen.d.ts +7 -7
  117. package/dist/src/task/types.gen.d.ts.map +1 -1
  118. package/dist/src/user/client.d.ts +2 -2
  119. package/dist/src/user/client.d.ts.map +1 -1
  120. package/dist/src/user/types.gen.d.ts +2 -2
  121. package/dist/src/view/client.d.ts.map +1 -1
  122. package/dist/src/view/types.gen.d.ts +2 -2
  123. package/dist/src/workspace/client.d.ts.map +1 -1
  124. package/dist/src/workspace/types.gen.d.ts +3 -3
  125. package/dist/src/workspace/types.gen.d.ts.map +1 -1
  126. package/package.json +12 -11
  127. package/src/access/policy/client.ts +4 -7
  128. package/src/access/role/client.ts +6 -26
  129. package/src/actions/actions.spec.ts +229 -0
  130. package/src/actions/actions.ts +104 -0
  131. package/src/actions/external.ts +10 -0
  132. package/src/actions/index.ts +10 -0
  133. package/src/arc/client.ts +3 -7
  134. package/src/arc/compiler/types.gen.ts +2 -1
  135. package/src/arc/ir/types.gen.ts +2 -2
  136. package/src/arc/lsp.spec.ts +3 -7
  137. package/src/arc/types/types.gen.ts +3 -3
  138. package/src/auth/auth.spec.ts +12 -13
  139. package/src/auth/auth.ts +36 -34
  140. package/src/channel/batchRetriever.spec.ts +13 -4
  141. package/src/channel/client.ts +8 -6
  142. package/src/channel/retriever.ts +7 -16
  143. package/src/channel/writer.ts +4 -20
  144. package/src/connection/checker.ts +6 -6
  145. package/src/connection/connection.spec.ts +5 -8
  146. package/src/device/client.ts +5 -8
  147. package/src/device/types.gen.ts +4 -4
  148. package/src/errors.ts +9 -9
  149. package/src/framer/adapter.ts +2 -4
  150. package/src/framer/client.ts +1 -1
  151. package/src/framer/codec.spec.ts +53 -3
  152. package/src/framer/codec.ts +58 -25
  153. package/src/framer/deleter.ts +2 -8
  154. package/src/framer/iterator.ts +43 -40
  155. package/src/framer/streamProxy.ts +13 -13
  156. package/src/framer/streamer.spec.ts +12 -3
  157. package/src/framer/streamer.ts +7 -12
  158. package/src/framer/types.gen.ts +20 -0
  159. package/src/framer/writer.spec.ts +77 -0
  160. package/src/framer/writer.ts +51 -28
  161. package/src/group/client.ts +4 -7
  162. package/src/index.ts +3 -2
  163. package/src/label/client.ts +6 -16
  164. package/src/lineplot/client.ts +6 -21
  165. package/src/log/client.ts +6 -21
  166. package/src/ontology/client.ts +3 -4
  167. package/src/ontology/types.gen.ts +0 -1
  168. package/src/ontology/writer.ts +4 -7
  169. package/src/rack/client.ts +4 -7
  170. package/src/ranger/alias/client.ts +6 -11
  171. package/src/ranger/client.ts +3 -4
  172. package/src/ranger/kv/client.ts +5 -8
  173. package/src/ranger/writer.ts +4 -17
  174. package/src/schematic/access.spec.ts +6 -6
  175. package/src/schematic/actions.gen.ts +200 -0
  176. package/src/schematic/actions.spec.ts +699 -0
  177. package/src/schematic/actions.ts +168 -0
  178. package/src/schematic/client.ts +34 -30
  179. package/src/schematic/external.ts +2 -0
  180. package/src/schematic/schematic.spec.ts +233 -69
  181. package/src/schematic/symbol/client.ts +6 -11
  182. package/src/schematic/symbol/types.gen.ts +1 -10
  183. package/src/schematic/types.gen.ts +55 -6
  184. package/src/status/client.ts +4 -10
  185. package/src/table/access.spec.ts +0 -6
  186. package/src/table/actions.gen.ts +243 -0
  187. package/src/table/actions.ts +255 -0
  188. package/src/table/client.ts +21 -25
  189. package/src/table/external.ts +2 -0
  190. package/src/table/table.spec.ts +588 -43
  191. package/src/table/types.gen.ts +58 -5
  192. package/src/task/client.ts +7 -11
  193. package/src/task/types.gen.ts +8 -6
  194. package/src/user/client.ts +6 -11
  195. package/src/view/client.ts +4 -7
  196. package/src/workspace/client.ts +6 -16
  197. package/src/workspace/types.gen.ts +2 -1
@@ -0,0 +1,255 @@
1
+ // Copyright 2026 Synnax Labs, Inc.
2
+ //
3
+ // Use of this software is governed by the Business Source License included in the file
4
+ // licenses/BSL.txt.
5
+ //
6
+ // As of the Change Date specified in that file, in accordance with the Business Source
7
+ // License, use of this software will be governed by the Apache License, Version 2.0,
8
+ // included in the file licenses/APL.txt.
9
+
10
+ import { NO_OP_RESULT as NO_OP, snapshotDraft as snapshot } from "@/actions/actions";
11
+ import {
12
+ type Action,
13
+ addCol,
14
+ addRow,
15
+ createReduceAll,
16
+ type Handlers,
17
+ removeCol,
18
+ removeRow,
19
+ rename,
20
+ resizeCol,
21
+ resizeRow,
22
+ setCell,
23
+ } from "@/table/actions.gen";
24
+ import { type Cell } from "@/table/types.gen";
25
+
26
+ // MIN_CELL_DIM is the floor enforced on row and column sizes.
27
+ const MIN_CELL_DIM = 32;
28
+ // BASE_ROW_DIM and BASE_COL_DIM are the defaults used when an action
29
+ // bootstraps the opposing axis on an empty table.
30
+ const BASE_ROW_DIM = 36;
31
+ const BASE_COL_DIM = 72;
32
+
33
+ // deriveCellKey returns the key for the index-th replica of template. Both
34
+ // reducers run the same scheme so optimistic client state agrees with the
35
+ // server.
36
+ const deriveCellKey = (templateKey: string, index: number): string => {
37
+ const suffix = index.toString(16).padStart(4, "0");
38
+ if (templateKey.length < 36) return `${templateKey}-${suffix}`;
39
+ return templateKey.slice(0, 32) + suffix;
40
+ };
41
+
42
+ // expandTemplate returns count replicas of template with keys derived via
43
+ // deriveCellKey.
44
+ const expandTemplate = (template: Cell, count: number): Cell[] =>
45
+ Array.from({ length: count }, (_, i) => ({
46
+ key: deriveCellKey(template.key, i),
47
+ variant: template.variant,
48
+ props: template.props,
49
+ }));
50
+
51
+ const handlers: Handlers = {
52
+ rename: (state, payload) => {
53
+ const oldName = state.name;
54
+ state.name = payload.name;
55
+ return {
56
+ inverse: [rename({ name: oldName })],
57
+ targets: [state.key],
58
+ };
59
+ },
60
+
61
+ addRow: (state, payload) => {
62
+ const cells = payload.cellTemplate
63
+ ? expandTemplate(
64
+ payload.cellTemplate,
65
+ state.columns.length === 0 && state.rows.length === 0
66
+ ? 1
67
+ : state.columns.length,
68
+ )
69
+ : payload.cells;
70
+ if (state.columns.length === 0 && cells.length > 0)
71
+ for (let i = 0; i < cells.length; i++) state.columns.push({ size: BASE_COL_DIM });
72
+ const idx = Math.min(payload.index, state.rows.length);
73
+ const keys = cells.map((c) => c.key);
74
+ state.rows.splice(idx, 0, {
75
+ size: Math.max(payload.size, MIN_CELL_DIM),
76
+ cells: keys,
77
+ });
78
+ for (const c of cells) state.cells[c.key] = c;
79
+ return {
80
+ inverse: [removeRow({ index: idx })],
81
+ targets: keys,
82
+ };
83
+ },
84
+
85
+ removeRow: (state, payload) => {
86
+ if (payload.index >= state.rows.length) return NO_OP;
87
+ const removed = snapshot(state.rows[payload.index]);
88
+ const cells: Cell[] = [];
89
+ for (const k of removed.cells) {
90
+ const c = state.cells[k];
91
+ if (c != null) cells.push(snapshot(c));
92
+ }
93
+ state.rows.splice(payload.index, 1);
94
+ for (const k of removed.cells) delete state.cells[k];
95
+ return {
96
+ inverse: [addRow({ index: payload.index, size: removed.size, cells })],
97
+ targets: removed.cells,
98
+ };
99
+ },
100
+
101
+ addCol: (state, payload) => {
102
+ const cells = payload.cellTemplate
103
+ ? expandTemplate(
104
+ payload.cellTemplate,
105
+ state.rows.length === 0 && state.columns.length === 0 ? 1 : state.rows.length,
106
+ )
107
+ : payload.cells;
108
+ if (state.rows.length === 0 && cells.length > 0)
109
+ for (let i = 0; i < cells.length; i++)
110
+ state.rows.push({ size: BASE_ROW_DIM, cells: [] });
111
+ const idx = Math.min(payload.index, state.columns.length);
112
+ state.columns.splice(idx, 0, { size: Math.max(payload.size, MIN_CELL_DIM) });
113
+ for (let i = 0; i < state.rows.length; i++) {
114
+ if (i >= cells.length) break;
115
+ const rowIdx = Math.min(idx, state.rows[i].cells.length);
116
+ state.rows[i].cells.splice(rowIdx, 0, cells[i].key);
117
+ }
118
+ for (const c of cells) state.cells[c.key] = c;
119
+ return {
120
+ inverse: [removeCol({ index: idx })],
121
+ targets: cells.map((c) => c.key),
122
+ };
123
+ },
124
+
125
+ removeCol: (state, payload) => {
126
+ if (payload.index >= state.columns.length) return NO_OP;
127
+ const oldSize = state.columns[payload.index].size;
128
+ const removedCells: Cell[] = [];
129
+ state.columns.splice(payload.index, 1);
130
+ // Rows missing a cell at this column are skipped, not padded. Go AddCol
131
+ // short-circuits when len(cells) < len(rows), so the inverse repopulates
132
+ // only the rows we captured.
133
+ for (let i = 0; i < state.rows.length; i++) {
134
+ if (payload.index >= state.rows[i].cells.length) continue;
135
+ const k = state.rows[i].cells[payload.index];
136
+ const c = state.cells[k];
137
+ if (c != null) removedCells.push(snapshot(c));
138
+ delete state.cells[k];
139
+ state.rows[i].cells.splice(payload.index, 1);
140
+ }
141
+ return {
142
+ inverse: [addCol({ index: payload.index, size: oldSize, cells: removedCells })],
143
+ targets: removedCells.map((c) => c.key),
144
+ };
145
+ },
146
+
147
+ resizeRow: (state, payload) => {
148
+ if (payload.index >= state.rows.length) return NO_OP;
149
+ const oldSize = state.rows[payload.index].size;
150
+ state.rows[payload.index].size = Math.max(payload.size, MIN_CELL_DIM);
151
+ return {
152
+ inverse: [resizeRow({ index: payload.index, size: oldSize })],
153
+ targets: [...state.rows[payload.index].cells],
154
+ };
155
+ },
156
+
157
+ resizeCol: (state, payload) => {
158
+ if (payload.index >= state.columns.length) return NO_OP;
159
+ const oldSize = state.columns[payload.index].size;
160
+ state.columns[payload.index].size = Math.max(payload.size, MIN_CELL_DIM);
161
+ const targets = state.rows
162
+ .map((r) => r.cells[payload.index])
163
+ .filter((k): k is string => k != null);
164
+ return {
165
+ inverse: [resizeCol({ index: payload.index, size: oldSize })],
166
+ targets,
167
+ };
168
+ },
169
+
170
+ setCell: (state, payload) => {
171
+ const existing = state.cells[payload.cell.key];
172
+ if (existing == null) return NO_OP;
173
+ const oldCell = snapshot(existing);
174
+ state.cells[payload.cell.key] = payload.cell;
175
+ return {
176
+ inverse: [setCell({ cell: oldCell })],
177
+ targets: [payload.cell.key],
178
+ };
179
+ },
180
+
181
+ eraseCells: (state, payload) => {
182
+ if (payload.cells.length === 0) return NO_OP;
183
+ const selected = new Set(payload.cells);
184
+ const rowPosOf = new Map<string, { row: number; col: number }>();
185
+ for (let r = 0; r < state.rows.length; r++) {
186
+ const cells = state.rows[r].cells;
187
+ for (let c = 0; c < cells.length; c++) rowPosOf.set(cells[c], { row: r, col: c });
188
+ }
189
+ const rowTally = new Map<number, number>();
190
+ const colTally = new Map<number, number>();
191
+ for (const k of selected) {
192
+ const pos = rowPosOf.get(k);
193
+ if (pos == null) continue;
194
+ rowTally.set(pos.row, (rowTally.get(pos.row) ?? 0) + 1);
195
+ colTally.set(pos.col, (colTally.get(pos.col) ?? 0) + 1);
196
+ }
197
+ const fullRowIdx: number[] = [];
198
+ for (const [rowIdx, tally] of rowTally)
199
+ if (tally > 0 && tally === state.rows[rowIdx].cells.length)
200
+ fullRowIdx.push(rowIdx);
201
+ fullRowIdx.sort((a, b) => a - b);
202
+ const fullColIdx: number[] = [];
203
+ for (const [colIdx, tally] of colTally)
204
+ if (tally === state.rows.length) fullColIdx.push(colIdx);
205
+ fullColIdx.sort((a, b) => a - b);
206
+ const inverse: Action[] = [];
207
+ const targets: string[] = [];
208
+ // Iterate highest-first so earlier removals don't shift later indices;
209
+ // unshift the inverse so undo replays it in ascending order.
210
+ for (let i = fullRowIdx.length - 1; i >= 0; i--) {
211
+ const idx = fullRowIdx[i];
212
+ const removed = snapshot(state.rows[idx]);
213
+ const cells: Cell[] = [];
214
+ for (const k of removed.cells) {
215
+ const c = state.cells[k];
216
+ if (c != null) cells.push(snapshot(c));
217
+ }
218
+ state.rows.splice(idx, 1);
219
+ for (const k of removed.cells) delete state.cells[k];
220
+ inverse.unshift(addRow({ index: idx, size: removed.size, cells }));
221
+ targets.push(...removed.cells);
222
+ }
223
+ for (let i = fullColIdx.length - 1; i >= 0; i--) {
224
+ const idx = fullColIdx[i];
225
+ const oldSize = state.columns[idx].size;
226
+ const removedCells: Cell[] = [];
227
+ state.columns.splice(idx, 1);
228
+ for (let r = 0; r < state.rows.length; r++) {
229
+ if (idx >= state.rows[r].cells.length) continue;
230
+ const k = state.rows[r].cells[idx];
231
+ const c = state.cells[k];
232
+ if (c != null) removedCells.push(snapshot(c));
233
+ delete state.cells[k];
234
+ state.rows[r].cells.splice(idx, 1);
235
+ }
236
+ inverse.unshift(addCol({ index: idx, size: oldSize, cells: removedCells }));
237
+ targets.push(...removedCells.map((c) => c.key));
238
+ }
239
+ for (const k of selected) {
240
+ const existing = state.cells[k];
241
+ if (existing == null) continue;
242
+ const oldCell = snapshot(existing);
243
+ state.cells[k] = {
244
+ key: k,
245
+ variant: payload.template.variant,
246
+ props: payload.template.props,
247
+ };
248
+ inverse.push(setCell({ cell: oldCell }));
249
+ targets.push(k);
250
+ }
251
+ return { inverse, targets };
252
+ },
253
+ };
254
+
255
+ export const reduceAll = createReduceAll(handlers);
@@ -7,20 +7,22 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
- import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
- import { array, caseconv, record } from "@synnaxlabs/x";
10
+ import { type UnaryClient } from "@synnaxlabs/freighter";
11
+ import { array } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
14
+ import { type Action, dispatchReqZ } from "@/table/actions.gen";
14
15
  import { type Key, keyZ, type New, newZ, type Table, tableZ } from "@/table/types.gen";
15
16
  import { checkForMultipleOrNoResults } from "@/util/retrieve";
16
17
  import { workspace } from "@/workspace";
17
18
 
19
+ export const SET_CHANNEL_NAME = "sy_table_set";
20
+
18
21
  const renameReqZ = z.object({ key: keyZ, name: z.string() });
19
22
 
20
- const setDataReqZ = z.object({
21
- key: keyZ,
22
- data: caseconv.preserveCase(record.unknownZ()),
23
- });
23
+ const setDataBodyZ = tableZ.omit({ key: true, name: true });
24
+ export type SetDataBody = z.input<typeof setDataBodyZ>;
25
+ const setDataReqZ = z.object({ key: keyZ, data: setDataBodyZ });
24
26
  const deleteReqZ = z.object({ keys: keyZ.array() });
25
27
 
26
28
  const retrieveReqZ = z.object({ keys: keyZ.array() });
@@ -54,8 +56,7 @@ export class Client {
54
56
  tables: New | New[],
55
57
  ): Promise<Table | Table[]> {
56
58
  const isMany = Array.isArray(tables);
57
- const res = await sendRequired(
58
- this.client,
59
+ const res = await this.client.send(
59
60
  "/table/create",
60
61
  { workspace, tables: array.toArray(tables) },
61
62
  createReqZ,
@@ -65,21 +66,18 @@ export class Client {
65
66
  }
66
67
 
67
68
  async rename(key: Key, name: string): Promise<void> {
68
- await sendRequired(
69
- this.client,
70
- "/table/rename",
71
- { key, name },
72
- renameReqZ,
73
- emptyResZ,
74
- );
69
+ await this.client.send("/table/rename", { key, name }, renameReqZ, emptyResZ);
70
+ }
71
+
72
+ async setData(key: Key, data: SetDataBody): Promise<void> {
73
+ await this.client.send("/table/set-data", { key, data }, setDataReqZ, emptyResZ);
75
74
  }
76
75
 
77
- async setData(key: Key, data: record.Unknown): Promise<void> {
78
- await sendRequired(
79
- this.client,
80
- "/table/set-data",
81
- { key, data },
82
- setDataReqZ,
76
+ async dispatch(key: Key, dispatchKey: string, actions: Action[]): Promise<void> {
77
+ await this.client.send(
78
+ "/table/dispatch",
79
+ { key, dispatchKey, actions },
80
+ dispatchReqZ,
83
81
  emptyResZ,
84
82
  );
85
83
  }
@@ -90,8 +88,7 @@ export class Client {
90
88
  args: RetrieveSingleParams | RetrieveMultipleParams,
91
89
  ): Promise<Table | Table[]> {
92
90
  const isSingle = singleRetrieveArgsZ.safeParse(args).success;
93
- const res = await sendRequired(
94
- this.client,
91
+ const res = await this.client.send(
95
92
  "/table/retrieve",
96
93
  args,
97
94
  retrieveArgsZ,
@@ -102,8 +99,7 @@ export class Client {
102
99
  }
103
100
 
104
101
  async delete(keys: Key | Key[]): Promise<void> {
105
- await sendRequired(
106
- this.client,
102
+ await this.client.send(
107
103
  "/table/delete",
108
104
  { keys: array.toArray(keys) },
109
105
  deleteReqZ,
@@ -7,5 +7,7 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
+ export * from "@/table/actions";
11
+ export * from "@/table/actions.gen";
10
12
  export * from "@/table/client";
11
13
  export * from "@/table/types.gen";