@synnaxlabs/client 0.54.2 → 0.56.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 (222) hide show
  1. package/.turbo/turbo-build.log +10 -13
  2. package/dist/client.cjs +60 -42
  3. package/dist/client.js +8037 -6265
  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/arc.spec.d.ts +2 -0
  19. package/dist/src/arc/arc.spec.d.ts.map +1 -0
  20. package/dist/src/arc/client.d.ts.map +1 -1
  21. package/dist/src/arc/compiler/types.gen.d.ts +1 -1
  22. package/dist/src/arc/compiler/types.gen.d.ts.map +1 -1
  23. package/dist/src/arc/graph/types.gen.d.ts +40 -40
  24. package/dist/src/arc/graph/types.gen.d.ts.map +1 -1
  25. package/dist/src/arc/ir/types.gen.d.ts +202 -233
  26. package/dist/src/arc/ir/types.gen.d.ts.map +1 -1
  27. package/dist/src/arc/module/types.gen.d.ts +63 -82
  28. package/dist/src/arc/module/types.gen.d.ts.map +1 -1
  29. package/dist/src/arc/program/types.gen.d.ts +63 -82
  30. package/dist/src/arc/program/types.gen.d.ts.map +1 -1
  31. package/dist/src/arc/types/types.gen.d.ts +11 -11
  32. package/dist/src/arc/types/types.gen.d.ts.map +1 -1
  33. package/dist/src/arc/types.gen.d.ts +139 -158
  34. package/dist/src/arc/types.gen.d.ts.map +1 -1
  35. package/dist/src/auth/auth.d.ts +3 -3
  36. package/dist/src/auth/auth.d.ts.map +1 -1
  37. package/dist/src/channel/client.d.ts +2 -2
  38. package/dist/src/channel/client.d.ts.map +1 -1
  39. package/dist/src/channel/retriever.d.ts +5 -8
  40. package/dist/src/channel/retriever.d.ts.map +1 -1
  41. package/dist/src/channel/types.gen.d.ts +3 -3
  42. package/dist/src/channel/types.gen.d.ts.map +1 -1
  43. package/dist/src/channel/writer.d.ts.map +1 -1
  44. package/dist/src/client.d.ts +5 -0
  45. package/dist/src/client.d.ts.map +1 -1
  46. package/dist/src/connection/checker.d.ts +17 -2
  47. package/dist/src/connection/checker.d.ts.map +1 -1
  48. package/dist/src/control/state.d.ts.map +1 -1
  49. package/dist/src/device/client.d.ts.map +1 -1
  50. package/dist/src/device/types.gen.d.ts +6 -8
  51. package/dist/src/device/types.gen.d.ts.map +1 -1
  52. package/dist/src/errors.d.ts +2 -0
  53. package/dist/src/errors.d.ts.map +1 -1
  54. package/dist/src/framer/adapter.d.ts.map +1 -1
  55. package/dist/src/framer/client.d.ts +2 -2
  56. package/dist/src/framer/client.d.ts.map +1 -1
  57. package/dist/src/framer/codec.d.ts +9 -1
  58. package/dist/src/framer/codec.d.ts.map +1 -1
  59. package/dist/src/framer/deleter.d.ts.map +1 -1
  60. package/dist/src/framer/frame.d.ts +1 -1
  61. package/dist/src/framer/iterator.d.ts +84 -3
  62. package/dist/src/framer/iterator.d.ts.map +1 -1
  63. package/dist/src/framer/streamProxy.d.ts.map +1 -1
  64. package/dist/src/framer/streamer.d.ts +1 -3
  65. package/dist/src/framer/streamer.d.ts.map +1 -1
  66. package/dist/src/framer/types.gen.d.ts +18 -0
  67. package/dist/src/framer/types.gen.d.ts.map +1 -1
  68. package/dist/src/framer/writer.d.ts +8 -8
  69. package/dist/src/framer/writer.d.ts.map +1 -1
  70. package/dist/src/group/client.d.ts +1 -2
  71. package/dist/src/group/client.d.ts.map +1 -1
  72. package/dist/src/group/types.gen.d.ts +2 -2
  73. package/dist/src/index.d.ts +2 -1
  74. package/dist/src/index.d.ts.map +1 -1
  75. package/dist/src/label/client.d.ts +5 -8
  76. package/dist/src/label/client.d.ts.map +1 -1
  77. package/dist/src/lineplot/client.d.ts.map +1 -1
  78. package/dist/src/lineplot/types.gen.d.ts +2 -2
  79. package/dist/src/log/client.d.ts.map +1 -1
  80. package/dist/src/log/types.gen.d.ts +2 -2
  81. package/dist/src/ontology/client.d.ts +1 -3
  82. package/dist/src/ontology/client.d.ts.map +1 -1
  83. package/dist/src/ontology/payload.d.ts +12 -16
  84. package/dist/src/ontology/payload.d.ts.map +1 -1
  85. package/dist/src/ontology/types.gen.d.ts +1 -2
  86. package/dist/src/ontology/types.gen.d.ts.map +1 -1
  87. package/dist/src/ontology/writer.d.ts +5 -10
  88. package/dist/src/ontology/writer.d.ts.map +1 -1
  89. package/dist/src/rack/client.d.ts.map +1 -1
  90. package/dist/src/rack/types.gen.d.ts +3 -3
  91. package/dist/src/ranger/alias/client.d.ts.map +1 -1
  92. package/dist/src/ranger/client.d.ts.map +1 -1
  93. package/dist/src/ranger/kv/client.d.ts.map +1 -1
  94. package/dist/src/ranger/types.gen.d.ts +6 -6
  95. package/dist/src/ranger/types.gen.d.ts.map +1 -1
  96. package/dist/src/ranger/writer.d.ts +2 -3
  97. package/dist/src/ranger/writer.d.ts.map +1 -1
  98. package/dist/src/schematic/actions.d.ts +147 -0
  99. package/dist/src/schematic/actions.d.ts.map +1 -0
  100. package/dist/src/schematic/actions.gen.d.ts +484 -0
  101. package/dist/src/schematic/actions.gen.d.ts.map +1 -0
  102. package/dist/src/schematic/actions.spec.d.ts +2 -0
  103. package/dist/src/schematic/actions.spec.d.ts.map +1 -0
  104. package/dist/src/schematic/client.d.ts +53 -2
  105. package/dist/src/schematic/client.d.ts.map +1 -1
  106. package/dist/src/schematic/external.d.ts +2 -0
  107. package/dist/src/schematic/external.d.ts.map +1 -1
  108. package/dist/src/schematic/symbol/client.d.ts.map +1 -1
  109. package/dist/src/schematic/symbol/types.gen.d.ts +48 -58
  110. package/dist/src/schematic/symbol/types.gen.d.ts.map +1 -1
  111. package/dist/src/schematic/types.gen.d.ts +131 -5
  112. package/dist/src/schematic/types.gen.d.ts.map +1 -1
  113. package/dist/src/status/client.d.ts.map +1 -1
  114. package/dist/src/status/payload.d.ts +3 -3
  115. package/dist/src/table/actions.d.ts +156 -0
  116. package/dist/src/table/actions.d.ts.map +1 -0
  117. package/dist/src/table/actions.gen.d.ts +587 -0
  118. package/dist/src/table/actions.gen.d.ts.map +1 -0
  119. package/dist/src/table/client.d.ts +28 -2
  120. package/dist/src/table/client.d.ts.map +1 -1
  121. package/dist/src/table/external.d.ts +2 -0
  122. package/dist/src/table/external.d.ts.map +1 -1
  123. package/dist/src/table/types.gen.d.ts +71 -4
  124. package/dist/src/table/types.gen.d.ts.map +1 -1
  125. package/dist/src/task/client.d.ts.map +1 -1
  126. package/dist/src/task/types.gen.d.ts +7 -7
  127. package/dist/src/task/types.gen.d.ts.map +1 -1
  128. package/dist/src/user/client.d.ts +2 -2
  129. package/dist/src/user/client.d.ts.map +1 -1
  130. package/dist/src/user/types.gen.d.ts +2 -2
  131. package/dist/src/view/client.d.ts.map +1 -1
  132. package/dist/src/view/types.gen.d.ts +2 -2
  133. package/dist/src/workspace/client.d.ts.map +1 -1
  134. package/dist/src/workspace/types.gen.d.ts +3 -3
  135. package/dist/src/workspace/types.gen.d.ts.map +1 -1
  136. package/package.json +12 -11
  137. package/src/access/policy/client.ts +4 -7
  138. package/src/access/role/client.ts +6 -26
  139. package/src/actions/actions.spec.ts +229 -0
  140. package/src/actions/actions.ts +104 -0
  141. package/src/actions/external.ts +10 -0
  142. package/src/actions/index.ts +10 -0
  143. package/src/arc/arc.spec.ts +44 -0
  144. package/src/arc/client.ts +3 -7
  145. package/src/arc/compiler/types.gen.ts +2 -1
  146. package/src/arc/ir/types.gen.ts +102 -48
  147. package/src/arc/lsp.spec.ts +3 -7
  148. package/src/arc/types/types.gen.ts +3 -3
  149. package/src/auth/auth.spec.ts +12 -13
  150. package/src/auth/auth.ts +48 -34
  151. package/src/channel/batchRetriever.spec.ts +13 -4
  152. package/src/channel/channel.spec.ts +13 -0
  153. package/src/channel/client.ts +8 -6
  154. package/src/channel/retriever.ts +7 -16
  155. package/src/channel/types.gen.ts +1 -2
  156. package/src/channel/writer.ts +4 -20
  157. package/src/client.ts +3 -0
  158. package/src/connection/checker.ts +48 -10
  159. package/src/connection/connection.spec.ts +64 -2
  160. package/src/control/state.ts +5 -4
  161. package/src/device/client.ts +5 -8
  162. package/src/device/device.spec.ts +7 -5
  163. package/src/device/types.gen.ts +4 -4
  164. package/src/errors.ts +8 -9
  165. package/src/framer/adapter.ts +2 -4
  166. package/src/framer/client.ts +12 -0
  167. package/src/framer/codec.spec.ts +53 -3
  168. package/src/framer/codec.ts +58 -25
  169. package/src/framer/deleter.ts +2 -8
  170. package/src/framer/iterator.ts +42 -39
  171. package/src/framer/streamProxy.ts +11 -12
  172. package/src/framer/streamer.spec.ts +1 -1
  173. package/src/framer/streamer.ts +2 -7
  174. package/src/framer/types.gen.ts +20 -0
  175. package/src/framer/writer.spec.ts +221 -1
  176. package/src/framer/writer.ts +53 -28
  177. package/src/group/client.ts +4 -7
  178. package/src/index.ts +3 -2
  179. package/src/label/client.ts +6 -16
  180. package/src/label/label.spec.ts +12 -0
  181. package/src/lineplot/client.ts +6 -21
  182. package/src/log/client.ts +6 -21
  183. package/src/ontology/client.ts +2 -3
  184. package/src/ontology/ontology.spec.ts +10 -0
  185. package/src/ontology/types.gen.ts +0 -1
  186. package/src/ontology/writer.ts +4 -7
  187. package/src/rack/client.ts +4 -7
  188. package/src/rack/rack.spec.ts +12 -1
  189. package/src/ranger/alias/client.ts +6 -11
  190. package/src/ranger/client.ts +2 -3
  191. package/src/ranger/kv/client.ts +4 -7
  192. package/src/ranger/ranger.spec.ts +12 -0
  193. package/src/ranger/writer.ts +4 -17
  194. package/src/schematic/access.spec.ts +6 -6
  195. package/src/schematic/actions.gen.ts +200 -0
  196. package/src/schematic/actions.spec.ts +699 -0
  197. package/src/schematic/actions.ts +168 -0
  198. package/src/schematic/client.ts +34 -30
  199. package/src/schematic/external.ts +2 -0
  200. package/src/schematic/schematic.spec.ts +233 -69
  201. package/src/schematic/symbol/client.spec.ts +33 -9
  202. package/src/schematic/symbol/client.ts +6 -11
  203. package/src/schematic/symbol/types.gen.ts +1 -10
  204. package/src/schematic/types.gen.ts +55 -6
  205. package/src/status/client.ts +4 -10
  206. package/src/status/status.spec.ts +7 -6
  207. package/src/table/access.spec.ts +0 -6
  208. package/src/table/actions.gen.ts +243 -0
  209. package/src/table/actions.ts +255 -0
  210. package/src/table/client.ts +21 -25
  211. package/src/table/external.ts +2 -0
  212. package/src/table/table.spec.ts +588 -43
  213. package/src/table/types.gen.ts +58 -5
  214. package/src/task/client.ts +14 -20
  215. package/src/task/task.spec.ts +15 -1
  216. package/src/task/types.gen.ts +8 -6
  217. package/src/user/client.ts +6 -11
  218. package/src/view/client.ts +4 -7
  219. package/src/view/view.spec.ts +9 -5
  220. package/src/workspace/client.ts +6 -16
  221. package/src/workspace/types.gen.ts +2 -1
  222. package/src/workspace/workspace.spec.ts +14 -1
@@ -9,14 +9,56 @@
9
9
 
10
10
  // Code generated by Oracle. DO NOT EDIT.
11
11
 
12
- import { caseconv, record } from "@synnaxlabs/x";
12
+ import { array, caseconv, record } from "@synnaxlabs/x";
13
13
  import { z } from "zod";
14
14
 
15
15
  import { ontology } from "@/ontology";
16
16
 
17
+ /** Cell is a single cell in a table, identified by key and variant. */
18
+ export const cellZ = z.object({
19
+ /** key is the unique identifier for this cell within the table. */
20
+ key: z.string(),
21
+ /**
22
+ * variant is the cell variant identifier (e.g. "text", "value"). The variant
23
+ * determines the shape of props and which Pluto cell component renders
24
+ * the cell.
25
+ */
26
+ variant: z.string(),
27
+ /**
28
+ * props is the variant-specific cell configuration. The shape is determined
29
+ * by the variant; the wire format intentionally stores it as an
30
+ * opaque record so new variants can be added without a schema
31
+ * migration.
32
+ */
33
+ props: caseconv.preserveCase(record.nullishToEmpty()),
34
+ });
35
+ export interface Cell extends z.infer<typeof cellZ> {}
36
+
37
+ /** Row is a single row in a table, with height and ordered cell keys. */
38
+ export const rowZ = z.object({
39
+ /** size is the height of the row in pixels. */
40
+ size: z.number(),
41
+ /**
42
+ * cells is the ordered list of cell keys in this row from left to right.
43
+ * Each key points at an entry in the table's cells map.
44
+ */
45
+ cells: array.nullishToEmpty(z.string()),
46
+ });
47
+ export interface Row extends z.infer<typeof rowZ> {}
48
+
49
+ /** Column is a single column in a table, with width. */
50
+ export const columnZ = z.object({
51
+ /** size is the width of the column in pixels. */
52
+ size: z.number(),
53
+ });
54
+ export interface Column extends z.infer<typeof columnZ> {}
55
+
17
56
  export const keyZ = z.uuid();
18
57
  export type Key = z.infer<typeof keyZ>;
19
58
 
59
+ export const cellTemplateZ = cellZ.omit({ key: true });
60
+ export interface CellTemplate extends z.infer<typeof cellTemplateZ> {}
61
+
20
62
  /**
21
63
  * Table is a tabular data display component for viewing structured telemetry
22
64
  * data. Tables support multiple columns, channel data sources, and
@@ -27,15 +69,26 @@ export const tableZ = z.object({
27
69
  key: keyZ,
28
70
  /** name is a human-readable name for the table. */
29
71
  name: z.string(),
72
+ /** rows are the table rows in display order, top to bottom. */
73
+ rows: array.nullishToEmpty(rowZ),
74
+ /** columns are the table columns in display order, left to right. */
75
+ columns: array.nullishToEmpty(columnZ),
30
76
  /**
31
- * data is the table configuration including column definitions, channel
32
- * references, and formatting options.
77
+ * cells contains all cells in the table, keyed by cell key. Cell positions
78
+ * are derived from rows[*].cells[*] references; cells not referenced
79
+ * by any row are orphaned and will be pruned on the next structural
80
+ * edit.
33
81
  */
34
- data: caseconv.preserveCase(record.nullishToEmpty()),
82
+ cells: caseconv.preserveCase(record.nullishToEmpty(z.string(), cellZ)),
35
83
  });
36
84
  export interface Table extends z.infer<typeof tableZ> {}
37
85
 
38
- export const newZ = tableZ.partial({ key: true });
86
+ export const newZ = tableZ.partial({
87
+ key: true,
88
+ rows: true,
89
+ columns: true,
90
+ cells: true,
91
+ });
39
92
  export interface New extends z.input<typeof newZ> {}
40
93
 
41
94
  export const ontologyID = ontology.createIDFactory<Key>("table");
@@ -7,7 +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
- import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import {
12
12
  array,
13
13
  caseconv,
@@ -44,8 +44,6 @@ export const COMMAND_CHANNEL_NAME = "sy_task_cmd";
44
44
  export const SET_CHANNEL_NAME = "sy_task_set";
45
45
  export const DELETE_CHANNEL_NAME = "sy_task_delete";
46
46
 
47
- const NOT_CREATED_ERROR = new Error("Task not created");
48
-
49
47
  export const rackKey = (key: Key): RackKey => Number(BigInt(key) >> 32n);
50
48
 
51
49
  export const newKey = (rackKey: RackKey, taskKey: number = 0): Key =>
@@ -99,17 +97,17 @@ export class Task<S extends Schemas = Schemas> {
99
97
  private readonly rangeClient_?: ranger.Client;
100
98
 
101
99
  get frameClient(): framer.Client {
102
- if (this.frameClient_ == null) throw NOT_CREATED_ERROR;
100
+ if (this.frameClient_ == null) throw new Error("Task not created");
103
101
  return this.frameClient_;
104
102
  }
105
103
 
106
104
  get ontologyClient(): ontology.Client {
107
- if (this.ontologyClient_ == null) throw NOT_CREATED_ERROR;
105
+ if (this.ontologyClient_ == null) throw new Error("Task not created");
108
106
  return this.ontologyClient_;
109
107
  }
110
108
 
111
109
  get rangeClient(): ranger.Client {
112
- if (this.rangeClient_ == null) throw NOT_CREATED_ERROR;
110
+ if (this.rangeClient_ == null) throw new Error("Task not created");
113
111
  return this.rangeClient_;
114
112
  }
115
113
 
@@ -129,7 +127,7 @@ export class Task<S extends Schemas = Schemas> {
129
127
  ({
130
128
  type: z.string(),
131
129
  config: z.unknown(),
132
- statusData: z.unknown(),
130
+ statusData: z.unknown().optional(),
133
131
  } as unknown as S);
134
132
  this.internal = internal;
135
133
  this.snapshot = snapshot;
@@ -193,7 +191,7 @@ export class Task<S extends Schemas = Schemas> {
193
191
 
194
192
  async snapshottedTo(): Promise<ontology.Resource | null> {
195
193
  if (this.ontologyClient == null || this.rangeClient == null)
196
- throw NOT_CREATED_ERROR;
194
+ throw new Error("Task not created");
197
195
  if (!this.snapshot) return null;
198
196
  return await retrieveSnapshottedTo(this.key, this.ontologyClient);
199
197
  }
@@ -281,10 +279,9 @@ export class Client {
281
279
  const isSingle = !Array.isArray(task);
282
280
  const createReq = createReqZ(schemas);
283
281
  const createRes = createResZ(schemas);
284
- const res = await sendRequired(
285
- this.client,
282
+ const res = await this.client.send(
286
283
  "/task/create",
287
- { tasks: array.toArray(task) } as z.infer<typeof createReq>,
284
+ { tasks: array.toArray(task) },
288
285
  createReq,
289
286
  createRes,
290
287
  );
@@ -293,8 +290,7 @@ export class Client {
293
290
  }
294
291
 
295
292
  async delete(keys: Key | Key[]): Promise<void> {
296
- await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
297
- this.client,
293
+ await this.client.send(
298
294
  "/task/delete",
299
295
  { keys: array.toArray(keys) },
300
296
  deleteReqZ,
@@ -315,8 +311,7 @@ export class Client {
315
311
  ...args
316
312
  }: RetrieveArgs & RetrieveSchemas<S>): Promise<Task<S> | Task<S>[]> {
317
313
  const isSingle = singleRetrieveArgsZ.safeParse(args).success;
318
- const res = await sendRequired(
319
- this.client,
314
+ const res = await this.client.send(
320
315
  "/task/retrieve",
321
316
  args,
322
317
  retrieveArgsZ,
@@ -330,8 +325,7 @@ export class Client {
330
325
 
331
326
  async copy(key: Key, name: string, snapshot: boolean): Promise<Task> {
332
327
  const copyRes = copyResZ();
333
- const response = await sendRequired(
334
- this.client,
328
+ const response = await this.client.send(
335
329
  "/task/copy",
336
330
  { key, name, snapshot },
337
331
  copyReqZ,
@@ -347,7 +341,7 @@ export class Client {
347
341
  }
348
342
 
349
343
  async retrieveSnapshottedTo(taskKey: Key): Promise<ontology.Resource | null> {
350
- if (this.ontologyClient == null) throw NOT_CREATED_ERROR;
344
+ if (this.ontologyClient == null) throw new Error("Task not created");
351
345
  return await retrieveSnapshottedTo(taskKey, this.ontologyClient);
352
346
  }
353
347
 
@@ -463,7 +457,7 @@ const executeCommands = async ({
463
457
  frameClient,
464
458
  commands,
465
459
  }: ExecuteCommandsInternalParams): Promise<string[]> => {
466
- if (frameClient == null) throw NOT_CREATED_ERROR;
460
+ if (frameClient == null) throw new Error("Task not created");
467
461
  const w = await frameClient.openWriter(COMMAND_CHANNEL_NAME);
468
462
  const cmds = commands.map((c) => ({ ...c, key: id.create() }));
469
463
  await w.write(COMMAND_CHANNEL_NAME, cmds);
@@ -512,7 +506,7 @@ const executeCommandsSync = async <StatusData extends z.ZodType = z.ZodNever>({
512
506
  statusDataZ,
513
507
  name: taskName,
514
508
  }: ExecuteCommandsSyncInternalParams<StatusData>): Promise<Status<StatusData>[]> => {
515
- if (frameClient == null) throw NOT_CREATED_ERROR;
509
+ if (frameClient == null) throw new Error("Task not created");
516
510
  const streamer = await frameClient.openStreamer(status.SET_CHANNEL_NAME);
517
511
  const cmdKeys = await executeCommands({ frameClient, commands });
518
512
  const parsedTimeout = new TimeSpan(timeout);
@@ -7,7 +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
- import { TimeStamp } from "@synnaxlabs/x";
10
+ import { id, TimeStamp } from "@synnaxlabs/x";
11
11
  import { beforeAll, describe, expect, it } from "vitest";
12
12
  import { z } from "zod";
13
13
 
@@ -114,6 +114,20 @@ describe("Task", async () => {
114
114
  expect(retrieved.key).toBe(m.key);
115
115
  });
116
116
 
117
+ it("should retrieve tasks by search term", async () => {
118
+ const prefix = `searchable-task-${id.create()}`;
119
+ const names = [`${prefix}-1`, `${prefix}-2`];
120
+ await Promise.all(
121
+ names.map((name) => testRack.createTask({ name, config: {}, type: "ni" })),
122
+ );
123
+ await expect
124
+ .poll(async () => {
125
+ const results = await client.tasks.retrieve({ searchTerm: prefix });
126
+ return results.map((t) => t.name).sort();
127
+ })
128
+ .toEqual(names);
129
+ });
130
+
117
131
  describe("status", () => {
118
132
  it("should include task status when requested", async () => {
119
133
  const t = await testRack.createTask({
@@ -23,7 +23,7 @@ export type StatusDetailsZodObject<Data extends z.ZodType = z.ZodNever> = z.ZodO
23
23
  task: typeof keyZ;
24
24
  running: z.ZodBoolean;
25
25
  cmd: z.ZodOptional<z.ZodString>;
26
- data: [Data] extends [z.ZodNever] ? z.ZodOptional<z.ZodUnknown> : Data;
26
+ data: [Data] extends [z.ZodNever] ? z.ZodOptional<z.ZodUnknown> : z.ZodOptional<Data>;
27
27
  }>;
28
28
 
29
29
  export interface StatusDetailsZFunction {
@@ -38,20 +38,22 @@ export const statusDetailsZ: StatusDetailsZFunction = <Data extends z.ZodType>(
38
38
  task: keyZ,
39
39
  running: z.boolean(),
40
40
  cmd: z.string().optional(),
41
- data: data ?? z.unknown().optional(),
41
+ data: (data ?? z.unknown()).optional(),
42
42
  });
43
43
  export type StatusDetails<Data extends z.ZodType = z.ZodNever> = {
44
44
  task: Key;
45
45
  running: boolean;
46
46
  cmd?: string;
47
- } & ([Data] extends [z.ZodNever] ? {} : { data: z.infer<Data> });
47
+ } & ([Data] extends [z.ZodNever] ? {} : { data?: z.infer<Data> });
48
48
 
49
49
  export type NewStatusDetailsZodObject<Data extends z.ZodType = z.ZodNever> =
50
50
  z.ZodObject<{
51
51
  task: z.ZodOptional<typeof keyZ>;
52
52
  running: z.ZodBoolean;
53
53
  cmd: z.ZodOptional<z.ZodString>;
54
- data: [Data] extends [z.ZodNever] ? z.ZodOptional<z.ZodUnknown> : Data;
54
+ data: [Data] extends [z.ZodNever]
55
+ ? z.ZodOptional<z.ZodUnknown>
56
+ : z.ZodOptional<Data>;
55
57
  }>;
56
58
 
57
59
  export interface NewStatusDetailsZFunction {
@@ -66,13 +68,13 @@ export const newStatusDetailsZ: NewStatusDetailsZFunction = <Data extends z.ZodT
66
68
  task: keyZ.optional(),
67
69
  running: z.boolean(),
68
70
  cmd: z.string().optional(),
69
- data: data ?? z.unknown().optional(),
71
+ data: (data ?? z.unknown()).optional(),
70
72
  });
71
73
  export type NewStatusDetails<Data extends z.ZodType = z.ZodNever> = {
72
74
  task?: Key;
73
75
  running: boolean;
74
76
  cmd?: string;
75
- } & ([Data] extends [z.ZodNever] ? {} : { data: z.infer<Data> });
77
+ } & ([Data] extends [z.ZodNever] ? {} : { data?: z.infer<Data> });
76
78
 
77
79
  /** Command is a command to execute on a task in the Driver system. */
78
80
  export const commandZ = z.object({
@@ -7,7 +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
- import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { array } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
@@ -82,8 +82,7 @@ export class Client {
82
82
  async create(users: New[]): Promise<User[]>;
83
83
  async create(users: New | New[]): Promise<User | User[]> {
84
84
  const isMany = Array.isArray(users);
85
- const res = await sendRequired<typeof createReqZ, typeof createResZ>(
86
- this.client,
85
+ const res = await this.client.send(
87
86
  "/user/create",
88
87
  { users: array.toArray(users) },
89
88
  createReqZ,
@@ -93,8 +92,7 @@ export class Client {
93
92
  }
94
93
 
95
94
  async changeUsername(key: Key, newUsername: string): Promise<void> {
96
- await sendRequired<typeof changeUsernameReqZ, typeof changeUsernameResZ>(
97
- this.client,
95
+ await this.client.send(
98
96
  "/user/change-username",
99
97
  { key, username: newUsername },
100
98
  changeUsernameReqZ,
@@ -107,8 +105,7 @@ export class Client {
107
105
  async retrieve(args: RetrieveArgs): Promise<User[]>;
108
106
  async retrieve(args: RetrieveArgs): Promise<User | User[]> {
109
107
  const isSingle = "key" in args || "username" in args;
110
- const res = await sendRequired<typeof retrieveArgsZ, typeof retrieveResZ>(
111
- this.client,
108
+ const res = await this.client.send(
112
109
  "/user/retrieve",
113
110
  args,
114
111
  retrieveArgsZ,
@@ -131,8 +128,7 @@ export class Client {
131
128
  }
132
129
 
133
130
  async rename(key: Key, firstName?: string, lastName?: string): Promise<void> {
134
- await sendRequired<typeof renameReqZ, typeof renameResZ>(
135
- this.client,
131
+ await this.client.send(
136
132
  "/user/rename",
137
133
  { key, firstName, lastName },
138
134
  renameReqZ,
@@ -143,8 +139,7 @@ export class Client {
143
139
  async delete(key: Key): Promise<void>;
144
140
  async delete(keys: Key[]): Promise<void>;
145
141
  async delete(keys: Key | Key[]): Promise<void> {
146
- await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
147
- this.client,
142
+ await this.client.send(
148
143
  "/user/delete",
149
144
  { keys: array.toArray(keys) },
150
145
  deleteReqZ,
@@ -7,7 +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
- import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { array } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
@@ -54,8 +54,7 @@ export class Client {
54
54
  args: RetrieveSingleParams | RetrieveMultipleParams,
55
55
  ): Promise<View | View[]> {
56
56
  const isSingle = "key" in args;
57
- const res = await sendRequired(
58
- this.client,
57
+ const res = await this.client.send(
59
58
  "/view/retrieve",
60
59
  args,
61
60
  retrieveArgsZ,
@@ -69,8 +68,7 @@ export class Client {
69
68
  async create(views: New[]): Promise<View[]>;
70
69
  async create(views: New | New[]): Promise<View | View[]> {
71
70
  const isMany = Array.isArray(views);
72
- const res = await sendRequired<typeof createReqZ, typeof createResZ>(
73
- this.client,
71
+ const res = await this.client.send(
74
72
  "/view/create",
75
73
  { views: array.toArray(views) },
76
74
  createReqZ,
@@ -80,8 +78,7 @@ export class Client {
80
78
  }
81
79
 
82
80
  async delete(keys: Key | Key[]): Promise<void> {
83
- await sendRequired<typeof deleteReqZ, typeof emptyResZ>(
84
- this.client,
81
+ await this.client.send(
85
82
  "/view/delete",
86
83
  { keys: array.toArray(keys) },
87
84
  deleteReqZ,
@@ -113,15 +113,19 @@ describe("View", () => {
113
113
 
114
114
  it("should search for views by name", async () => {
115
115
  const client = createTestClient();
116
+ const prefix = id.create();
117
+ const name = `${prefix} View`;
116
118
  await client.views.create({
117
- name: "Searchable View",
119
+ name,
118
120
  type: "lineplot",
119
121
  query: { channels: ["search"] },
120
122
  });
121
- const results = await client.views.retrieve({ searchTerm: "Searchable" });
122
- expect(results.length).toBeGreaterThan(0);
123
- expect(results[0].name).toContain("Searchable");
124
- expect(results[0].query).toEqual({ channels: ["search"] });
123
+ await expect
124
+ .poll(async () => {
125
+ const results = await client.views.retrieve({ searchTerm: prefix });
126
+ return results.find((v) => v.name === name);
127
+ })
128
+ .toMatchObject({ query: { channels: ["search"] } });
125
129
  });
126
130
  });
127
131
 
@@ -7,7 +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
- import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { array, caseconv, record } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
@@ -57,8 +57,7 @@ export class Client {
57
57
  async create(workspaces: New[]): Promise<Workspace[]>;
58
58
  async create(workspaces: New | New[]): Promise<Workspace | Workspace[]> {
59
59
  const isMany = Array.isArray(workspaces);
60
- const res = await sendRequired(
61
- this.client,
60
+ const res = await this.client.send(
62
61
  "/workspace/create",
63
62
  { workspaces: array.toArray(workspaces) },
64
63
  createReqZ,
@@ -68,18 +67,11 @@ export class Client {
68
67
  }
69
68
 
70
69
  async rename(key: Key, name: string): Promise<void> {
71
- await sendRequired(
72
- this.client,
73
- "/workspace/rename",
74
- { key, name },
75
- renameReqZ,
76
- emptyResZ,
77
- );
70
+ await this.client.send("/workspace/rename", { key, name }, renameReqZ, emptyResZ);
78
71
  }
79
72
 
80
73
  async setLayout(key: Key, layout: record.Unknown): Promise<void> {
81
- await sendRequired(
82
- this.client,
74
+ await this.client.send(
83
75
  "/workspace/set-layout",
84
76
  { key, layout },
85
77
  setLayoutReqZ,
@@ -98,8 +90,7 @@ export class Client {
98
90
  if (typeof keys === "string" || Array.isArray(keys))
99
91
  req = { keys: array.toArray(keys) };
100
92
  else req = keys;
101
- const res = await sendRequired(
102
- this.client,
93
+ const res = await this.client.send(
103
94
  "/workspace/retrieve",
104
95
  req,
105
96
  retrieveReqZ,
@@ -111,8 +102,7 @@ export class Client {
111
102
  async delete(key: Key): Promise<void>;
112
103
  async delete(keys: Key[]): Promise<void>;
113
104
  async delete(keys: Key | Key[]): Promise<void> {
114
- await sendRequired(
115
- this.client,
105
+ await this.client.send(
116
106
  "/workspace/delete",
117
107
  { keys: array.toArray(keys) },
118
108
  deleteReqZ,
@@ -13,6 +13,7 @@ import { caseconv, record } from "@synnaxlabs/x";
13
13
  import { z } from "zod";
14
14
 
15
15
  import { ontology } from "@/ontology";
16
+ import { user } from "@/user";
16
17
 
17
18
  export const keyZ = z.uuid();
18
19
  export type Key = z.infer<typeof keyZ>;
@@ -28,7 +29,7 @@ export const workspaceZ = z.object({
28
29
  /** name is a human-readable name for the workspace. */
29
30
  name: z.string().min(1, "Name is required"),
30
31
  /** author is the UUID of the user who created this workspace. */
31
- author: z.uuid().optional(),
32
+ author: user.keyZ.optional(),
32
33
  /**
33
34
  * layout is the mosaic tree structure that defines how visualizations are
34
35
  * arranged. Contains tab layout, split configurations, and window
@@ -7,7 +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
- import { uuid } from "@synnaxlabs/x";
10
+ import { id, uuid } from "@synnaxlabs/x";
11
11
  import { describe, expect, test } from "vitest";
12
12
 
13
13
  import { createTestClient } from "@/testutil/client";
@@ -58,6 +58,19 @@ describe("Workspace", () => {
58
58
  await expect(client.workspaces.retrieve(ws.key)).rejects.toThrow();
59
59
  });
60
60
  });
61
+ describe("retrieve", () => {
62
+ test("retrieve workspaces by search term", async () => {
63
+ const prefix = `searchable-workspace-${id.create()}`;
64
+ const names = [`${prefix}-1`, `${prefix}-2`];
65
+ await client.workspaces.create(names.map((name) => ({ name, layout: {} })));
66
+ await expect
67
+ .poll(async () => {
68
+ const results = await client.workspaces.retrieve({ searchTerm: prefix });
69
+ return results.map((w) => w.name).sort();
70
+ })
71
+ .toEqual(names);
72
+ });
73
+ });
61
74
  describe("case preservation", () => {
62
75
  test("should preserve key casing in layout field on create/retrieve cycle", async () => {
63
76
  const ws = await client.workspaces.create({