@synnaxlabs/client 0.28.0 → 0.30.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 (53) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/CONTRIBUTING.md +47 -0
  3. package/README.md +17 -32
  4. package/api/client.api.md +5 -7
  5. package/dist/channel/client.d.ts +10 -8
  6. package/dist/channel/client.d.ts.map +1 -1
  7. package/dist/channel/retriever.d.ts +1 -1
  8. package/dist/channel/retriever.d.ts.map +1 -1
  9. package/dist/client.cjs +18 -18
  10. package/dist/client.d.ts.map +1 -1
  11. package/dist/client.js +1456 -1456
  12. package/dist/control/state.d.ts.map +1 -1
  13. package/dist/framer/deleter.d.ts.map +1 -1
  14. package/dist/framer/frame.d.ts.map +1 -1
  15. package/dist/framer/streamer.d.ts +2 -4
  16. package/dist/framer/streamer.d.ts.map +1 -1
  17. package/dist/framer/writer.d.ts.map +1 -1
  18. package/dist/label/retriever.d.ts +1 -1
  19. package/dist/ontology/group/payload.d.ts +1 -1
  20. package/dist/ranger/client.d.ts.map +1 -1
  21. package/dist/ranger/payload.d.ts +25 -25
  22. package/dist/ranger/payload.d.ts.map +1 -1
  23. package/dist/ranger/writer.d.ts.map +1 -1
  24. package/dist/workspace/lineplot/client.d.ts +1 -1
  25. package/dist/workspace/lineplot/client.d.ts.map +1 -1
  26. package/dist/workspace/lineplot/retriever.d.ts +1 -1
  27. package/dist/workspace/lineplot/retriever.d.ts.map +1 -1
  28. package/dist/workspace/lineplot/writer.d.ts +3 -3
  29. package/dist/workspace/lineplot/writer.d.ts.map +1 -1
  30. package/dist/workspace/retriever.d.ts +1 -1
  31. package/dist/workspace/retriever.d.ts.map +1 -1
  32. package/dist/workspace/schematic/retriever.d.ts +1 -1
  33. package/dist/workspace/schematic/retriever.d.ts.map +1 -1
  34. package/dist/workspace/schematic/writer.d.ts +1 -1
  35. package/dist/workspace/schematic/writer.d.ts.map +1 -1
  36. package/package.json +26 -18
  37. package/src/channel/client.ts +10 -8
  38. package/src/channel/retriever.ts +2 -2
  39. package/src/framer/client.ts +2 -2
  40. package/src/framer/streamer.spec.ts +5 -7
  41. package/src/framer/streamer.ts +7 -10
  42. package/src/hardware/rack/client.ts +3 -4
  43. package/src/label/retriever.ts +2 -2
  44. package/src/ontology/group/payload.ts +4 -4
  45. package/src/ranger/client.ts +9 -9
  46. package/src/ranger/payload.ts +4 -4
  47. package/src/workspace/lineplot/client.ts +2 -2
  48. package/src/workspace/lineplot/linePlot.spec.ts +12 -12
  49. package/src/workspace/lineplot/retriever.ts +2 -2
  50. package/src/workspace/lineplot/writer.ts +8 -8
  51. package/src/workspace/retriever.ts +2 -2
  52. package/src/workspace/schematic/retriever.ts +2 -2
  53. package/src/workspace/schematic/writer.ts +8 -6
@@ -127,9 +127,9 @@ export class Client implements AsyncTermSearcher<string, RackKey, Rack> {
127
127
  async retrieve(keys: number[] | RackKey[]): Promise<Rack[]>;
128
128
 
129
129
  async retrieve(
130
- params: string | RackKey | string[] | RackKey[],
130
+ racks: string | RackKey | string[] | RackKey[],
131
131
  ): Promise<Rack | Rack[]> {
132
- const { variant, normalized, single } = analyzeParams(params, {
132
+ const { variant, normalized, single } = analyzeParams(racks, {
133
133
  string: "names",
134
134
  number: "keys",
135
135
  });
@@ -141,7 +141,7 @@ export class Client implements AsyncTermSearcher<string, RackKey, Rack> {
141
141
  retrieveRackResZ,
142
142
  );
143
143
  const sugared = this.sugar(res.racks);
144
- checkForMultipleOrNoResults("Rack", params, sugared, single);
144
+ checkForMultipleOrNoResults("Rack", racks, sugared, single);
145
145
  return single ? sugared[0] : sugared;
146
146
  }
147
147
 
@@ -186,4 +186,3 @@ export class Rack {
186
186
  }
187
187
  }
188
188
  export { rackKeyZ };
189
-
@@ -37,8 +37,8 @@ export class Retriever {
37
37
  this.client = client;
38
38
  }
39
39
 
40
- async retrieve(params: Params): Promise<Label[]> {
41
- const normalized = toArray(params);
40
+ async retrieve(labels: Params): Promise<Label[]> {
41
+ const normalized = toArray(labels);
42
42
  return await this.execute({ keys: normalized });
43
43
  }
44
44
 
@@ -50,16 +50,16 @@ export type ParamAnalysisResult =
50
50
  actual: Names;
51
51
  };
52
52
 
53
- export const analyzeParams = (params: Params): ParamAnalysisResult => {
54
- const normal = toArray(params) as Keys | Names;
53
+ export const analyzeParams = (groups: Params): ParamAnalysisResult => {
54
+ const normal = toArray(groups) as Keys | Names;
55
55
  if (normal.length === 0) {
56
56
  throw new Error("No groups specified");
57
57
  }
58
58
  const isKey = keyZ.safeParse(normal[0]).success;
59
59
  return {
60
- single: !Array.isArray(params),
60
+ single: !Array.isArray(groups),
61
61
  variant: isKey ? "keys" : "names",
62
62
  normalized: normal,
63
- actual: params,
63
+ actual: groups,
64
64
  } as const as ParamAnalysisResult;
65
65
  };
@@ -271,18 +271,18 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
271
271
 
272
272
  async retrieve(range: Keys | Names): Promise<Range[]>;
273
273
 
274
- async retrieve(params: Params | CrudeTimeRange): Promise<Range | Range[]> {
275
- if (typeof params === "object" && "start" in params)
276
- return await this.execRetrieve({ overlapsWith: new TimeRange(params) });
277
- const { single, actual, variant, normalized, empty } = analyzeParams(params);
274
+ async retrieve(ranges: Params | CrudeTimeRange): Promise<Range | Range[]> {
275
+ if (typeof ranges === "object" && "start" in ranges)
276
+ return await this.execRetrieve({ overlapsWith: new TimeRange(ranges) });
277
+ const { single, actual, variant, normalized, empty } = analyzeParams(ranges);
278
278
  if (empty) return [];
279
- const ranges = await this.execRetrieve({ [variant]: normalized });
280
- if (!single) return ranges;
281
- if (ranges.length === 0)
279
+ const retrieved = await this.execRetrieve({ [variant]: normalized });
280
+ if (!single) return retrieved;
281
+ if (retrieved.length === 0)
282
282
  throw new NotFoundError(`range matching ${actual} not found`);
283
- if (ranges.length > 1)
283
+ if (retrieved.length > 1)
284
284
  throw new MultipleFoundError(`multiple ranges matching ${actual} found`);
285
- return ranges[0];
285
+ return retrieved[0];
286
286
  }
287
287
 
288
288
  getKV(range: Key): KV {
@@ -63,16 +63,16 @@ export type ParamAnalysisResult =
63
63
  empty: boolean;
64
64
  };
65
65
 
66
- export const analyzeParams = (params: Params): ParamAnalysisResult => {
67
- const normal = toArray(params) as Keys | Names;
66
+ export const analyzeParams = (ranges: Params): ParamAnalysisResult => {
67
+ const normal = toArray(ranges) as Keys | Names;
68
68
  const empty = normal.length === 0;
69
69
  let isKey = false;
70
70
  if (!empty) isKey = keyZ.safeParse(normal[0]).success;
71
71
  return {
72
- single: !Array.isArray(params),
72
+ single: !Array.isArray(ranges),
73
73
  variant: isKey ? "keys" : "names",
74
74
  normalized: normal,
75
- actual: params,
75
+ actual: ranges,
76
76
  empty,
77
77
  } as const as ParamAnalysisResult;
78
78
  };
@@ -23,8 +23,8 @@ export class Client {
23
23
  this.retriever = new Retriever(client);
24
24
  }
25
25
 
26
- async create(workspace: string, schematic: NewLinePlot): Promise<LinePlot> {
27
- return await this.writer.create(workspace, schematic);
26
+ async create(workspace: string, linePlot: NewLinePlot): Promise<LinePlot> {
27
+ return await this.writer.create(workspace, linePlot);
28
28
  }
29
29
 
30
30
  async rename(key: Key, name: string): Promise<void> {
@@ -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 { describe, expect,test } from "vitest";
10
+ import { describe, expect, test } from "vitest";
11
11
 
12
12
  import { newClient } from "@/setupspecs";
13
13
 
@@ -19,14 +19,14 @@ describe("LinePlot", () => {
19
19
  describe("create", () => {
20
20
  test("create one", async () => {
21
21
  const ws = await client.workspaces.create({
22
- name: "Schematic",
22
+ name: "Line Plot",
23
23
  layout: { one: 1 },
24
24
  });
25
25
  const linePlot = await client.workspaces.linePlot.create(ws.key, {
26
- name: "Schematic",
26
+ name: "Line Plot",
27
27
  data: { one: 1 },
28
28
  });
29
- expect(linePlot.name).toEqual("Schematic");
29
+ expect(linePlot.name).toEqual("Line Plot");
30
30
  expect(linePlot.key).not.toEqual(ZERO_UUID);
31
31
  expect(linePlot.data.one).toEqual(1);
32
32
  });
@@ -34,26 +34,26 @@ describe("LinePlot", () => {
34
34
  describe("rename", () => {
35
35
  test("rename one", async () => {
36
36
  const ws = await client.workspaces.create({
37
- name: "Schematic",
37
+ name: "Line Plot",
38
38
  layout: { one: 1 },
39
39
  });
40
40
  const linePlot = await client.workspaces.linePlot.create(ws.key, {
41
- name: "Schematic",
41
+ name: "Line Plot",
42
42
  data: { one: 1 },
43
43
  });
44
- await client.workspaces.linePlot.rename(linePlot.key, "Schematic2");
44
+ await client.workspaces.linePlot.rename(linePlot.key, "Line Plot2");
45
45
  const res = await client.workspaces.linePlot.retrieve(linePlot.key);
46
- expect(res.name).toEqual("Schematic2");
46
+ expect(res.name).toEqual("Line Plot2");
47
47
  });
48
48
  });
49
49
  describe("setData", () => {
50
50
  test("set data", async () => {
51
51
  const ws = await client.workspaces.create({
52
- name: "Schematic",
52
+ name: "Line Plot",
53
53
  layout: { one: 1 },
54
54
  });
55
55
  const linePlot = await client.workspaces.linePlot.create(ws.key, {
56
- name: "Schematic",
56
+ name: "Line Plot",
57
57
  data: { one: 1 },
58
58
  });
59
59
  await client.workspaces.linePlot.setData(linePlot.key, { two: 2 });
@@ -64,11 +64,11 @@ describe("LinePlot", () => {
64
64
  describe("delete", () => {
65
65
  test("delete one", async () => {
66
66
  const ws = await client.workspaces.create({
67
- name: "Schematic",
67
+ name: "Line Plot",
68
68
  layout: { one: 1 },
69
69
  });
70
70
  const linePlot = await client.workspaces.linePlot.create(ws.key, {
71
- name: "Schematic",
71
+ name: "Line Plot",
72
72
  data: { one: 1 },
73
73
  });
74
74
  await client.workspaces.linePlot.delete(linePlot.key);
@@ -25,8 +25,8 @@ export class Retriever {
25
25
  this.client = client;
26
26
  }
27
27
 
28
- async retrieve(params: Params): Promise<LinePlot[]> {
29
- const normalized = toArray(params);
28
+ async retrieve(linePlots: Params): Promise<LinePlot[]> {
29
+ const normalized = toArray(linePlots);
30
30
  return (
31
31
  await sendRequired(this.client, this.ENDPOINT, { keys: normalized }, reqZ, resZ)
32
32
  ).linePlots;
@@ -70,11 +70,11 @@ export class Writer {
70
70
  }
71
71
 
72
72
  async create(workspace: string, plot: NewLinePlot): Promise<LinePlot> {
73
- const schematic_ = { ...plot, data: JSON.stringify(plot.data) };
73
+ const linePlot = { ...plot, data: JSON.stringify(plot.data) };
74
74
  const res = await sendRequired<typeof createReqZ, typeof createResZ>(
75
75
  this.client,
76
76
  CREATE_ENDPOINT,
77
- { workspace, linePlots: [schematic_] },
77
+ { workspace, linePlots: [linePlot] },
78
78
  createReqZ,
79
79
  createResZ,
80
80
  );
@@ -82,8 +82,8 @@ export class Writer {
82
82
  return res.linePlots[0];
83
83
  }
84
84
 
85
- async delete(params: Params): Promise<void> {
86
- const normalized = toArray(params);
85
+ async delete(workspaces: Params): Promise<void> {
86
+ const normalized = toArray(workspaces);
87
87
  await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
88
88
  this.client,
89
89
  DELETE_ENDPOINT,
@@ -93,21 +93,21 @@ export class Writer {
93
93
  );
94
94
  }
95
95
 
96
- async rename(schematic: Key, name: string): Promise<void> {
96
+ async rename(plot: Key, name: string): Promise<void> {
97
97
  await sendRequired<typeof renameReqZ, typeof renameResZ>(
98
98
  this.client,
99
99
  RENAME_ENDPOINT,
100
- { key: schematic, name },
100
+ { key: plot, name },
101
101
  renameReqZ,
102
102
  renameResZ,
103
103
  );
104
104
  }
105
105
 
106
- async setData(schematic: Key, data: UnknownRecord): Promise<void> {
106
+ async setData(plot: Key, data: UnknownRecord): Promise<void> {
107
107
  await sendRequired<typeof setDataReqZ, typeof setDataResZ>(
108
108
  this.client,
109
109
  SET_DATA_ENDPOINT,
110
- { key: schematic, data: JSON.stringify(data) },
110
+ { key: plot, data: JSON.stringify(data) },
111
111
  setDataReqZ,
112
112
  setDataResZ,
113
113
  );
@@ -40,8 +40,8 @@ export class Retriever {
40
40
  this.client = client;
41
41
  }
42
42
 
43
- async retrieve(params: Params): Promise<Workspace[]> {
44
- const normalized = toArray(params);
43
+ async retrieve(workspaces: Params): Promise<Workspace[]> {
44
+ const normalized = toArray(workspaces);
45
45
  return await this.execute({ keys: normalized });
46
46
  }
47
47
 
@@ -28,12 +28,12 @@ export class Retriever {
28
28
  this.client = client;
29
29
  }
30
30
 
31
- async retrieve(params: Params): Promise<Schematic[]> {
31
+ async retrieve(schematics: Params): Promise<Schematic[]> {
32
32
  return (
33
33
  await sendRequired(
34
34
  this.client,
35
35
  this.ENDPOINT,
36
- { keys: toArray(params) },
36
+ { keys: toArray(schematics) },
37
37
  reqZ,
38
38
  resZ,
39
39
  )
@@ -22,10 +22,12 @@ import {
22
22
  schematicZ,
23
23
  } from "@/workspace/schematic/payload";
24
24
 
25
- export const newSchematicZ = schematicZ.partial({ key: true, snapshot: true }).transform((p) => ({
26
- ...p,
27
- data: JSON.stringify(p.data),
28
- }));
25
+ export const newSchematicZ = schematicZ
26
+ .partial({ key: true, snapshot: true })
27
+ .transform((p) => ({
28
+ ...p,
29
+ data: JSON.stringify(p.data),
30
+ }));
29
31
 
30
32
  export type NewSchematic = z.input<typeof newSchematicZ>;
31
33
 
@@ -105,8 +107,8 @@ export class Writer {
105
107
  return res.schematic;
106
108
  }
107
109
 
108
- async delete(params: Params): Promise<void> {
109
- const normalized = toArray(params);
110
+ async delete(schematics: Params): Promise<void> {
111
+ const normalized = toArray(schematics);
110
112
  await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
111
113
  this.client,
112
114
  DELETE_ENDPOINT,