@synnaxlabs/client 0.16.3 → 0.17.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 (71) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/dist/auth/auth.d.ts +2 -2
  3. package/dist/client.cjs +11 -11
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.ts +14 -4
  6. package/dist/client.js +5442 -5437
  7. package/dist/client.js.map +1 -1
  8. package/dist/framer/frame.d.ts +280 -24
  9. package/dist/framer/writer.d.ts +203 -15
  10. package/dist/hardware/rack/client.d.ts +1 -1
  11. package/dist/hardware/task/payload.d.ts +5 -5
  12. package/dist/ontology/retriever.d.ts +1 -1
  13. package/dist/ranger/active.d.ts +1 -1
  14. package/dist/ranger/payload.d.ts +308 -20
  15. package/dist/workspace/client.d.ts +2 -2
  16. package/dist/workspace/lineplot/client.d.ts +2 -2
  17. package/dist/workspace/lineplot/payload.d.ts +3 -16
  18. package/dist/workspace/lineplot/retriever.d.ts +0 -1
  19. package/dist/workspace/lineplot/writer.d.ts +9 -14
  20. package/dist/workspace/payload.d.ts +3 -3
  21. package/dist/workspace/pid/client.d.ts +2 -2
  22. package/dist/workspace/pid/payload.d.ts +3 -3
  23. package/dist/workspace/pid/retriever.d.ts +0 -1
  24. package/dist/workspace/pid/writer.d.ts +12 -18
  25. package/dist/workspace/writer.d.ts +14 -6
  26. package/examples/node/basicReadWriter.js +66 -0
  27. package/examples/node/package-lock.json +4961 -0
  28. package/examples/{package.json → node/package.json} +5 -5
  29. package/package.json +5 -5
  30. package/src/auth/auth.ts +5 -4
  31. package/src/channel/client.ts +0 -1
  32. package/src/channel/creator.ts +1 -0
  33. package/src/channel/retriever.ts +2 -2
  34. package/src/client.ts +2 -2
  35. package/src/connection/checker.ts +6 -2
  36. package/src/framer/client.ts +7 -3
  37. package/src/framer/frame.ts +4 -4
  38. package/src/hardware/device/retriever.ts +3 -3
  39. package/src/hardware/device/writer.ts +3 -1
  40. package/src/hardware/rack/client.ts +3 -4
  41. package/src/hardware/rack/retriever.ts +3 -0
  42. package/src/hardware/rack/writer.ts +2 -0
  43. package/src/hardware/task/payload.ts +5 -4
  44. package/src/hardware/task/retriever.ts +10 -7
  45. package/src/hardware/task/writer.ts +3 -1
  46. package/src/label/retriever.ts +1 -0
  47. package/src/label/writer.ts +4 -0
  48. package/src/ontology/group/writer.ts +18 -5
  49. package/src/ontology/retriever.ts +9 -9
  50. package/src/ontology/writer.ts +25 -11
  51. package/src/ranger/active.ts +26 -8
  52. package/src/ranger/alias.ts +9 -13
  53. package/src/ranger/client.ts +0 -1
  54. package/src/ranger/kv.ts +4 -1
  55. package/src/ranger/retriever.ts +1 -1
  56. package/src/ranger/writer.ts +3 -0
  57. package/src/workspace/client.ts +3 -3
  58. package/src/workspace/lineplot/client.ts +2 -2
  59. package/src/workspace/lineplot/payload.ts +1 -7
  60. package/src/workspace/lineplot/retriever.ts +10 -11
  61. package/src/workspace/lineplot/writer.ts +13 -8
  62. package/src/workspace/payload.ts +1 -1
  63. package/src/workspace/pid/client.ts +2 -2
  64. package/src/workspace/pid/payload.ts +1 -1
  65. package/src/workspace/pid/retriever.ts +8 -10
  66. package/src/workspace/pid/writer.ts +12 -5
  67. package/src/workspace/retriever.ts +2 -4
  68. package/src/workspace/workspace.spec.ts +4 -4
  69. package/src/workspace/writer.ts +12 -10
  70. package/.pytest_cache/README.md +0 -8
  71. package/examples/index.js +0 -1
@@ -7,12 +7,11 @@
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 { type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { z } from "zod";
12
12
 
13
- import { QueryError } from "..";
14
-
15
- import { type Payload, payloadZ, type Key } from "./payload";
13
+ import { QueryError } from "@/errors";
14
+ import { type Payload, payloadZ, type Key, keyZ } from "@/ranger/payload";
16
15
 
17
16
  const setActiveResZ = z.object({});
18
17
 
@@ -20,6 +19,14 @@ const retrieveActiveResZ = z.object({
20
19
  range: payloadZ,
21
20
  });
22
21
 
22
+ const setActiveReqZ = z.object({
23
+ range: keyZ,
24
+ });
25
+
26
+ const clearActiveReqZ = z.object({
27
+ range: keyZ,
28
+ });
29
+
23
30
  const clearActiveResZ = z.object({});
24
31
 
25
32
  const SET_ENDPOINT = "/range/set-active";
@@ -34,14 +41,20 @@ export class Active {
34
41
  }
35
42
 
36
43
  async setActive(range: Key): Promise<void> {
37
- const [, err] = await this.client.send(SET_ENDPOINT, { range }, setActiveResZ);
38
- if (err != null) throw err;
44
+ await sendRequired<typeof setActiveReqZ, typeof setActiveResZ>(
45
+ this.client,
46
+ SET_ENDPOINT,
47
+ { range },
48
+ setActiveReqZ,
49
+ setActiveResZ,
50
+ );
39
51
  }
40
52
 
41
53
  async retrieveActive(): Promise<Payload | null> {
42
54
  const [res, err] = await this.client.send(
43
55
  RETRIEVE_ENDPOINT,
44
56
  {},
57
+ z.object({}),
45
58
  retrieveActiveResZ,
46
59
  );
47
60
  if (err instanceof QueryError) return null;
@@ -50,7 +63,12 @@ export class Active {
50
63
  }
51
64
 
52
65
  async clearActive(range: Key): Promise<void> {
53
- const [, err] = await this.client.send(CLEAR_ENDPOINT, { range }, clearActiveResZ);
54
- if (err != null) throw err;
66
+ await sendRequired<typeof clearActiveReqZ, typeof clearActiveResZ>(
67
+ this.client,
68
+ CLEAR_ENDPOINT,
69
+ { range },
70
+ clearActiveReqZ,
71
+ clearActiveResZ,
72
+ );
55
73
  }
56
74
  }
@@ -31,7 +31,7 @@ const resolveResZ = z.object({
31
31
 
32
32
  const setReqZ = z.object({
33
33
  range: keyZ,
34
- aliases: z.record(channelKeyZ, z.string()),
34
+ aliases: z.record(channelKeyZ.or(z.string()), z.string()),
35
35
  });
36
36
 
37
37
  const setResZ = z.unknown();
@@ -93,6 +93,7 @@ export class Aliaser {
93
93
  this.client,
94
94
  Aliaser.RESOLVE_ENDPOINT,
95
95
  { range: this.rangeKey, aliases: toFetch },
96
+ resolveReqZ,
96
97
  resolveResZ,
97
98
  );
98
99
  Object.entries(res.aliases).forEach(([alias, key]) => this.cache.set(alias, key));
@@ -103,11 +104,9 @@ export class Aliaser {
103
104
  await sendRequired<typeof setReqZ, typeof setResZ>(
104
105
  this.client,
105
106
  Aliaser.SET_ENDPOINT,
106
- {
107
- range: this.rangeKey,
108
- aliases,
109
- },
110
- z.unknown(),
107
+ { range: this.rangeKey, aliases },
108
+ setReqZ,
109
+ setResZ,
111
110
  );
112
111
  }
113
112
 
@@ -116,9 +115,8 @@ export class Aliaser {
116
115
  await sendRequired<typeof listReqZ, typeof listResZ>(
117
116
  this.client,
118
117
  Aliaser.LIST_ENDPOINT,
119
- {
120
- range: this.rangeKey,
121
- },
118
+ { range: this.rangeKey },
119
+ listReqZ,
122
120
  listResZ,
123
121
  )
124
122
  ).aliases;
@@ -128,10 +126,8 @@ export class Aliaser {
128
126
  await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
129
127
  this.client,
130
128
  Aliaser.DELETE_ENDPOINT,
131
- {
132
- range: this.rangeKey,
133
- channels: aliases,
134
- },
129
+ { range: this.rangeKey, channels: aliases },
130
+ deleteReqZ,
135
131
  deleteResZ,
136
132
  );
137
133
  }
@@ -14,7 +14,6 @@ import { type Retriever as ChannelRetriever } from "@/channel/retriever";
14
14
  import { QueryError } from "@/errors";
15
15
  import { type framer } from "@/framer";
16
16
  import { type label } from "@/label";
17
- import { type ontology } from "@/ontology";
18
17
  import { Active } from "@/ranger/active";
19
18
  import { Aliaser } from "@/ranger/alias";
20
19
  import { KV } from "@/ranger/kv";
package/src/ranger/kv.ts CHANGED
@@ -58,6 +58,7 @@ export class KV {
58
58
  const [res, err] = await this.client.send(
59
59
  KV.GET_ENDPOINT,
60
60
  { range: this.rangeKey, keys: toArray(keys) },
61
+ getReqZ,
61
62
  getResZ,
62
63
  );
63
64
  if (err != null) throw err;
@@ -68,7 +69,7 @@ export class KV {
68
69
 
69
70
  async set(kv: Record<string, string>): Promise<void>;
70
71
 
71
- async set(key: string | Record<string, string>, value?: string): Promise<void> {
72
+ async set(key: string | Record<string, string>, value: string = ""): Promise<void> {
72
73
  await sendRequired(
73
74
  this.client,
74
75
  KV.SET_ENDPOINT,
@@ -76,6 +77,7 @@ export class KV {
76
77
  range: this.rangeKey,
77
78
  pairs: isObject(key) ? key : { [key]: value },
78
79
  },
80
+ setReqZ,
79
81
  z.unknown(),
80
82
  );
81
83
  }
@@ -85,6 +87,7 @@ export class KV {
85
87
  this.client,
86
88
  KV.DELETE_ENDPOINT,
87
89
  { range: this.rangeKey, keys: toArray(key) },
90
+ deleteReqZ,
88
91
  z.unknown(),
89
92
  );
90
93
  }
@@ -43,7 +43,7 @@ export class Retriever {
43
43
  }
44
44
 
45
45
  private async execute(request: Request): Promise<Payload[]> {
46
- const [res, err] = await this.client.send(this.ENDPOINT, request, resZ);
46
+ const [res, err] = await this.client.send(this.ENDPOINT, request, reqZ, resZ);
47
47
  if (err != null) throw err;
48
48
  return res.ranges;
49
49
  }
@@ -55,6 +55,7 @@ export class Writer {
55
55
  this.client,
56
56
  RENAME_ENDPOINT,
57
57
  { key, name },
58
+ renameReqZ,
58
59
  renameResZ,
59
60
  );
60
61
  }
@@ -64,6 +65,7 @@ export class Writer {
64
65
  this.client,
65
66
  CREATE_ENDPOINT,
66
67
  { ranges },
68
+ createReqZ,
67
69
  createResZ,
68
70
  );
69
71
  return res.ranges;
@@ -74,6 +76,7 @@ export class Writer {
74
76
  this.client,
75
77
  DELETE_ENDPOINT,
76
78
  { keys },
79
+ deleteReqZ,
77
80
  deleteResZ,
78
81
  );
79
82
  }
@@ -14,7 +14,7 @@ import { linePlot } from "@/workspace/lineplot";
14
14
  import { type Key, type Workspace } from "@/workspace/payload";
15
15
  import { pid } from "@/workspace/pid";
16
16
  import { Retriever } from "@/workspace/retriever";
17
- import { type CrudeWorkspace, Writer } from "@/workspace/writer";
17
+ import { type NewWorkspace, Writer } from "@/workspace/writer";
18
18
 
19
19
  export class Client implements AsyncTermSearcher<string, Key, Workspace> {
20
20
  readonly pid: pid.Client;
@@ -51,10 +51,10 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
51
51
  return await this.retriever.page(offset, limit);
52
52
  }
53
53
 
54
- async create(workspace: CrudeWorkspace): Promise<Workspace>;
54
+ async create(workspace: NewWorkspace): Promise<Workspace>;
55
55
 
56
56
  async create(
57
- workspaces: CrudeWorkspace | CrudeWorkspace[],
57
+ workspaces: NewWorkspace | NewWorkspace[],
58
58
  ): Promise<Workspace | Workspace[]> {
59
59
  const isMany = Array.isArray(workspaces);
60
60
  const res = await this.writer.create(workspaces);
@@ -12,7 +12,7 @@ import { type UnknownRecord } from "@synnaxlabs/x";
12
12
 
13
13
  import { type LinePlot, type Key, type Params } from "@/workspace/lineplot/payload";
14
14
  import { Retriever } from "@/workspace/lineplot/retriever";
15
- import { type CrudeLinePlot, Writer } from "@/workspace/lineplot/writer";
15
+ import { type NewLinePlot, Writer } from "@/workspace/lineplot/writer";
16
16
 
17
17
  export class Client {
18
18
  private readonly writer: Writer;
@@ -23,7 +23,7 @@ export class Client {
23
23
  this.retriever = new Retriever(client);
24
24
  }
25
25
 
26
- async create(workspace: string, pid: CrudeLinePlot): Promise<LinePlot> {
26
+ async create(workspace: string, pid: NewLinePlot): Promise<LinePlot> {
27
27
  return await this.writer.create(workspace, pid);
28
28
  }
29
29
 
@@ -17,13 +17,7 @@ export type Params = Key | Key[];
17
17
  export const linePlotZ = z.object({
18
18
  key: z.string(),
19
19
  name: z.string(),
20
- data: unknownRecordZ,
21
- });
22
-
23
- export const linePlotRemoteZ = z.object({
24
- key: z.string(),
25
- name: z.string(),
26
- data: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
20
+ data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
27
21
  });
28
22
 
29
23
  export type LinePlot = z.infer<typeof linePlotZ>;
@@ -7,14 +7,14 @@
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 { type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
14
14
  import {
15
15
  type LinePlot,
16
16
  type Params,
17
- linePlotRemoteZ,
17
+ linePlotZ,
18
18
  } from "@/workspace/lineplot/payload";
19
19
 
20
20
  const reqZ = z.object({
@@ -24,7 +24,7 @@ const reqZ = z.object({
24
24
  type Request = z.infer<typeof reqZ>;
25
25
 
26
26
  const resZ = z.object({
27
- linePlots: linePlotRemoteZ.array(),
27
+ linePlots: linePlotZ.array(),
28
28
  });
29
29
 
30
30
  export class Retriever {
@@ -37,13 +37,12 @@ export class Retriever {
37
37
 
38
38
  async retrieve(params: Params): Promise<LinePlot[]> {
39
39
  const normalized = toArray(params);
40
- const res = await this.execute({ keys: normalized });
41
- return res;
42
- }
43
-
44
- private async execute(request: Request): Promise<LinePlot[]> {
45
- const [res, err] = await this.client.send(this.ENDPOINT, request, resZ);
46
- if (err != null) throw err;
47
- return res.linePlots;
40
+ return (await sendRequired(
41
+ this.client,
42
+ this.ENDPOINT,
43
+ { keys: normalized },
44
+ reqZ,
45
+ resZ
46
+ )).linePlots;
48
47
  }
49
48
  }
@@ -17,22 +17,23 @@ import {
17
17
  type Params,
18
18
  keyZ,
19
19
  type Key,
20
- linePlotRemoteZ,
21
20
  } from "@/workspace/lineplot/payload";
22
21
  import { keyZ as workspaceKeyZ } from "@/workspace/payload";
23
22
 
24
- export const crudeLinePlotZ = linePlotZ.partial({ key: true });
25
- export const linePlotWriteZ = linePlotRemoteZ.partial({ key: true });
23
+ export const newLinePlotZ = linePlotZ.partial({ key: true }).transform((p) => ({
24
+ ...p,
25
+ data: JSON.stringify(p.data),
26
+ }));
26
27
 
27
- export type CrudeLinePlot = z.infer<typeof crudeLinePlotZ>;
28
+ export type NewLinePlot = z.input<typeof newLinePlotZ>;
28
29
 
29
30
  const createReqZ = z.object({
30
31
  workspace: workspaceKeyZ,
31
- linePlots: linePlotWriteZ.array(),
32
+ linePlots: newLinePlotZ.array(),
32
33
  });
33
34
 
34
35
  const createResZ = z.object({
35
- linePlots: linePlotRemoteZ.array(),
36
+ linePlots: linePlotZ.array(),
36
37
  });
37
38
 
38
39
  const deleteReqZ = z.object({
@@ -67,12 +68,13 @@ export class Writer {
67
68
  this.client = client;
68
69
  }
69
70
 
70
- async create(workspace: string, plot: CrudeLinePlot): Promise<LinePlot> {
71
+ async create(workspace: string, plot: NewLinePlot): Promise<LinePlot> {
71
72
  const pid_ = { ...plot, data: JSON.stringify(plot.data) };
72
73
  const res = await sendRequired<typeof createReqZ, typeof createResZ>(
73
74
  this.client,
74
75
  CREATE_ENDPOINT,
75
76
  { workspace, linePlots: [pid_] },
77
+ createReqZ,
76
78
  createResZ,
77
79
  );
78
80
 
@@ -85,6 +87,7 @@ export class Writer {
85
87
  this.client,
86
88
  DELETE_ENDPOINT,
87
89
  { keys: normalized },
90
+ deleteReqZ,
88
91
  deleteResZ,
89
92
  );
90
93
  }
@@ -94,6 +97,7 @@ export class Writer {
94
97
  this.client,
95
98
  RENAME_ENDPOINT,
96
99
  { key: pid, name },
100
+ renameReqZ,
97
101
  renameResZ,
98
102
  );
99
103
  }
@@ -103,7 +107,8 @@ export class Writer {
103
107
  this.client,
104
108
  SET_DATA_ENDPOINT,
105
109
  { key: pid, data: JSON.stringify(data) },
106
- renameResZ,
110
+ setDataReqZ,
111
+ setDataResZ,
107
112
  );
108
113
  }
109
114
  }
@@ -19,7 +19,7 @@ export type Params = Key | Key[];
19
19
  export const workspaceZ = z.object({
20
20
  name: z.string(),
21
21
  key: keyZ,
22
- layout: unknownRecordZ,
22
+ layout: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
23
23
  });
24
24
 
25
25
  export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
@@ -12,7 +12,7 @@ import { type UnknownRecord } from "@synnaxlabs/x";
12
12
 
13
13
  import { type Key, type Params, type PID } from "@/workspace/pid/payload";
14
14
  import { Retriever } from "@/workspace/pid/retriever";
15
- import { Writer, type UncreatedPID } from "@/workspace/pid/writer";
15
+ import { Writer, type NewPID } from "@/workspace/pid/writer";
16
16
 
17
17
  export class Client {
18
18
  private readonly writer: Writer;
@@ -23,7 +23,7 @@ export class Client {
23
23
  this.retriever = new Retriever(client);
24
24
  }
25
25
 
26
- async create(workspace: string, pid: UncreatedPID): Promise<PID> {
26
+ async create(workspace: string, pid: NewPID): Promise<PID> {
27
27
  return await this.writer.create(workspace, pid);
28
28
  }
29
29
 
@@ -17,7 +17,7 @@ export type Params = Key | Key[];
17
17
  export const pidZ = z.object({
18
18
  key: z.string(),
19
19
  name: z.string(),
20
- data: unknownRecordZ,
20
+ data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
21
21
  snapshot: z.boolean(),
22
22
  });
23
23
 
@@ -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 { type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
@@ -32,14 +32,12 @@ export class Retriever {
32
32
  }
33
33
 
34
34
  async retrieve(params: Params): Promise<PID[]> {
35
- const normalized = toArray(params);
36
- const res = await this.execute({ keys: normalized });
37
- return res;
38
- }
39
-
40
- private async execute(request: Request): Promise<PID[]> {
41
- const [res, err] = await this.client.send(this.ENDPOINT, request, resZ);
42
- if (err != null) throw err;
43
- return res.pids;
35
+ return (await sendRequired(
36
+ this.client,
37
+ this.ENDPOINT,
38
+ { keys: toArray(params) },
39
+ reqZ,
40
+ resZ,
41
+ )).pids;
44
42
  }
45
43
  }
@@ -21,14 +21,16 @@ import {
21
21
  pidRemoteZ,
22
22
  } from "@/workspace/pid/payload";
23
23
 
24
- export const crudePIDz = pidZ.partial({ key: true });
25
- export const pidWriteZ = pidRemoteZ.partial({ key: true, snapshot: true });
24
+ export const newPIDZ = pidZ.partial({ key: true, snapshot: true }).transform((p) => ({
25
+ ...p,
26
+ data: JSON.stringify(p.data),
27
+ }));
26
28
 
27
- export type UncreatedPID = z.infer<typeof pidWriteZ>;
29
+ export type NewPID = z.input<typeof newPIDZ>;
28
30
 
29
31
  const createReqZ = z.object({
30
32
  workspace: workspaceKeyZ,
31
- pids: pidWriteZ.array(),
33
+ pids: newPIDZ.array(),
32
34
  });
33
35
 
34
36
  const createResZ = z.object({
@@ -78,12 +80,13 @@ export class Writer {
78
80
  this.client = client;
79
81
  }
80
82
 
81
- async create(workspace: string, pid: UncreatedPID): Promise<PID> {
83
+ async create(workspace: string, pid: NewPID): Promise<PID> {
82
84
  const pid_ = { ...pid, data: JSON.stringify(pid.data) };
83
85
  const res = await sendRequired<typeof createReqZ, typeof createResZ>(
84
86
  this.client,
85
87
  CREATE_ENDPOINT,
86
88
  { workspace, pids: [pid_] },
89
+ createReqZ,
87
90
  createResZ,
88
91
  );
89
92
 
@@ -95,6 +98,7 @@ export class Writer {
95
98
  this.client,
96
99
  COPY_ENDPOINT,
97
100
  { key, name, snapshot },
101
+ copyReqZ,
98
102
  copyResZ,
99
103
  );
100
104
  return res.pid;
@@ -106,6 +110,7 @@ export class Writer {
106
110
  this.client,
107
111
  DELETE_ENDPOINT,
108
112
  { keys: normalized },
113
+ deleteReqZ,
109
114
  deleteResZ,
110
115
  );
111
116
  }
@@ -115,6 +120,7 @@ export class Writer {
115
120
  this.client,
116
121
  RENAME_ENDPOINT,
117
122
  { key: pid, name },
123
+ renameReqZ,
118
124
  renameResZ,
119
125
  );
120
126
  }
@@ -124,6 +130,7 @@ export class Writer {
124
130
  this.client,
125
131
  SET_DATA_ENDPOINT,
126
132
  { key: pid, data: JSON.stringify(data) },
133
+ setDataReqZ,
127
134
  renameResZ,
128
135
  );
129
136
  }
@@ -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 { type UnaryClient } from "@synnaxlabs/freighter";
10
+ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { toArray } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13
 
@@ -59,8 +59,6 @@ export class Retriever {
59
59
  }
60
60
 
61
61
  private async execute(request: Request): Promise<Workspace[]> {
62
- const [res, err] = await this.client.send(Retriever.ENDPOINT, request, resZ);
63
- if (err != null) throw err;
64
- return res.workspaces;
62
+ return (await sendRequired(this.client, Retriever.ENDPOINT, request, reqZ, resZ)).workspaces;
65
63
  }
66
64
  }
@@ -18,13 +18,13 @@ const ZERO_UUID = "00000000-0000-0000-0000-000000000000";
18
18
  describe("Workspace", () => {
19
19
  describe("create", () => {
20
20
  test("create one", async () => {
21
- const pid = await client.workspaces.create({
21
+ const ws = await client.workspaces.create({
22
22
  name: "PID",
23
23
  layout: { one: 1 },
24
24
  });
25
- expect(pid.name).toEqual("PID");
26
- expect(pid.key).not.toEqual(ZERO_UUID);
27
- expect(pid.layout.one).toEqual(1);
25
+ expect(ws.name).toEqual("PID");
26
+ expect(ws.key).not.toEqual(ZERO_UUID);
27
+ expect(ws.layout.one).toEqual(1);
28
28
  });
29
29
  });
30
30
  describe("rename", () => {
@@ -13,13 +13,15 @@ import { z } from "zod";
13
13
 
14
14
  import { type Workspace, workspaceZ, keyZ, workspaceRemoteZ } from "./payload";
15
15
 
16
- const crudeWorkspaceZ = workspaceZ.partial({ key: true });
17
- const workspaceWriteZ = workspaceRemoteZ.partial({ key: true });
16
+ const newWorkspaceZ = workspaceZ.partial({ key: true }).transform((w) => ({
17
+ ...w,
18
+ layout: JSON.stringify(w.layout),
19
+ }));
18
20
 
19
- export type CrudeWorkspace = z.infer<typeof crudeWorkspaceZ>;
21
+ export type NewWorkspace = z.input<typeof newWorkspaceZ>;
20
22
 
21
23
  const createReqZ = z.object({
22
- workspaces: workspaceWriteZ.partial({ key: true }).array(),
24
+ workspaces: newWorkspaceZ.array(),
23
25
  });
24
26
 
25
27
  const createResZ = z.object({
@@ -60,15 +62,12 @@ export class Writer {
60
62
  this.client = client;
61
63
  }
62
64
 
63
- async create(workspaces: CrudeWorkspace | CrudeWorkspace[]): Promise<Workspace[]> {
64
- const ws = toArray(workspaces).map((w) => ({
65
- ...w,
66
- layout: JSON.stringify(w.layout),
67
- }));
65
+ async create(workspaces: NewWorkspace | NewWorkspace[]): Promise<Workspace[]> {
68
66
  const res = await sendRequired<typeof createReqZ, typeof createResZ>(
69
67
  this.client,
70
68
  CREATE_ENDPOINT,
71
- { workspaces: ws },
69
+ { workspaces: toArray(workspaces) },
70
+ createReqZ,
72
71
  createResZ,
73
72
  );
74
73
  return res.workspaces;
@@ -79,6 +78,7 @@ export class Writer {
79
78
  this.client,
80
79
  DELETE_ENDPOINT,
81
80
  { keys: toArray(keys) },
81
+ deleteReqZ,
82
82
  deleteResZ,
83
83
  );
84
84
  }
@@ -88,6 +88,7 @@ export class Writer {
88
88
  this.client,
89
89
  RENAME_ENDPOINT,
90
90
  { key, name },
91
+ renameReqZ,
91
92
  renameResZ,
92
93
  );
93
94
  }
@@ -97,6 +98,7 @@ export class Writer {
97
98
  this.client,
98
99
  SET_LAYOUT_ENDPOINT,
99
100
  { key, layout: JSON.stringify(layout) },
101
+ setLayoutReqZ,
100
102
  setLayoutResZ,
101
103
  );
102
104
  }
@@ -1,8 +0,0 @@
1
- # pytest cache directory #
2
-
3
- This directory contains data from the pytest's cache plugin,
4
- which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
-
6
- **Do not** commit this to version control.
7
-
8
- See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
package/examples/index.js DELETED
@@ -1 +0,0 @@
1
- import {Synnax} from "@synnaxlabs/client";