@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.
- package/.turbo/turbo-build.log +7 -7
- package/CONTRIBUTING.md +47 -0
- package/README.md +17 -32
- package/api/client.api.md +5 -7
- package/dist/channel/client.d.ts +10 -8
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +1 -1
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/client.cjs +18 -18
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +1456 -1456
- package/dist/control/state.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts +2 -4
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/label/retriever.d.ts +1 -1
- package/dist/ontology/group/payload.d.ts +1 -1
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +25 -25
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +1 -1
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/retriever.d.ts +1 -1
- package/dist/workspace/lineplot/retriever.d.ts.map +1 -1
- package/dist/workspace/lineplot/writer.d.ts +3 -3
- package/dist/workspace/lineplot/writer.d.ts.map +1 -1
- package/dist/workspace/retriever.d.ts +1 -1
- package/dist/workspace/retriever.d.ts.map +1 -1
- package/dist/workspace/schematic/retriever.d.ts +1 -1
- package/dist/workspace/schematic/retriever.d.ts.map +1 -1
- package/dist/workspace/schematic/writer.d.ts +1 -1
- package/dist/workspace/schematic/writer.d.ts.map +1 -1
- package/package.json +26 -18
- package/src/channel/client.ts +10 -8
- package/src/channel/retriever.ts +2 -2
- package/src/framer/client.ts +2 -2
- package/src/framer/streamer.spec.ts +5 -7
- package/src/framer/streamer.ts +7 -10
- package/src/hardware/rack/client.ts +3 -4
- package/src/label/retriever.ts +2 -2
- package/src/ontology/group/payload.ts +4 -4
- package/src/ranger/client.ts +9 -9
- package/src/ranger/payload.ts +4 -4
- package/src/workspace/lineplot/client.ts +2 -2
- package/src/workspace/lineplot/linePlot.spec.ts +12 -12
- package/src/workspace/lineplot/retriever.ts +2 -2
- package/src/workspace/lineplot/writer.ts +8 -8
- package/src/workspace/retriever.ts +2 -2
- package/src/workspace/schematic/retriever.ts +2 -2
- 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
|
-
|
|
130
|
+
racks: string | RackKey | string[] | RackKey[],
|
|
131
131
|
): Promise<Rack | Rack[]> {
|
|
132
|
-
const { variant, normalized, single } = analyzeParams(
|
|
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",
|
|
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
|
-
|
package/src/label/retriever.ts
CHANGED
|
@@ -37,8 +37,8 @@ export class Retriever {
|
|
|
37
37
|
this.client = client;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
async retrieve(
|
|
41
|
-
const normalized = toArray(
|
|
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 = (
|
|
54
|
-
const normal = toArray(
|
|
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(
|
|
60
|
+
single: !Array.isArray(groups),
|
|
61
61
|
variant: isKey ? "keys" : "names",
|
|
62
62
|
normalized: normal,
|
|
63
|
-
actual:
|
|
63
|
+
actual: groups,
|
|
64
64
|
} as const as ParamAnalysisResult;
|
|
65
65
|
};
|
package/src/ranger/client.ts
CHANGED
|
@@ -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(
|
|
275
|
-
if (typeof
|
|
276
|
-
return await this.execRetrieve({ overlapsWith: new TimeRange(
|
|
277
|
-
const { single, actual, variant, normalized, empty } = analyzeParams(
|
|
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
|
|
280
|
-
if (!single) return
|
|
281
|
-
if (
|
|
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 (
|
|
283
|
+
if (retrieved.length > 1)
|
|
284
284
|
throw new MultipleFoundError(`multiple ranges matching ${actual} found`);
|
|
285
|
-
return
|
|
285
|
+
return retrieved[0];
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
getKV(range: Key): KV {
|
package/src/ranger/payload.ts
CHANGED
|
@@ -63,16 +63,16 @@ export type ParamAnalysisResult =
|
|
|
63
63
|
empty: boolean;
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
-
export const analyzeParams = (
|
|
67
|
-
const normal = toArray(
|
|
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(
|
|
72
|
+
single: !Array.isArray(ranges),
|
|
73
73
|
variant: isKey ? "keys" : "names",
|
|
74
74
|
normalized: normal,
|
|
75
|
-
actual:
|
|
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,
|
|
27
|
-
return await this.writer.create(workspace,
|
|
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: "
|
|
22
|
+
name: "Line Plot",
|
|
23
23
|
layout: { one: 1 },
|
|
24
24
|
});
|
|
25
25
|
const linePlot = await client.workspaces.linePlot.create(ws.key, {
|
|
26
|
-
name: "
|
|
26
|
+
name: "Line Plot",
|
|
27
27
|
data: { one: 1 },
|
|
28
28
|
});
|
|
29
|
-
expect(linePlot.name).toEqual("
|
|
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: "
|
|
37
|
+
name: "Line Plot",
|
|
38
38
|
layout: { one: 1 },
|
|
39
39
|
});
|
|
40
40
|
const linePlot = await client.workspaces.linePlot.create(ws.key, {
|
|
41
|
-
name: "
|
|
41
|
+
name: "Line Plot",
|
|
42
42
|
data: { one: 1 },
|
|
43
43
|
});
|
|
44
|
-
await client.workspaces.linePlot.rename(linePlot.key, "
|
|
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("
|
|
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: "
|
|
52
|
+
name: "Line Plot",
|
|
53
53
|
layout: { one: 1 },
|
|
54
54
|
});
|
|
55
55
|
const linePlot = await client.workspaces.linePlot.create(ws.key, {
|
|
56
|
-
name: "
|
|
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: "
|
|
67
|
+
name: "Line Plot",
|
|
68
68
|
layout: { one: 1 },
|
|
69
69
|
});
|
|
70
70
|
const linePlot = await client.workspaces.linePlot.create(ws.key, {
|
|
71
|
-
name: "
|
|
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(
|
|
29
|
-
const normalized = toArray(
|
|
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
|
|
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: [
|
|
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(
|
|
86
|
-
const normalized = toArray(
|
|
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(
|
|
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:
|
|
100
|
+
{ key: plot, name },
|
|
101
101
|
renameReqZ,
|
|
102
102
|
renameResZ,
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
async setData(
|
|
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:
|
|
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(
|
|
44
|
-
const normalized = toArray(
|
|
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(
|
|
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(
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
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(
|
|
109
|
-
const normalized = toArray(
|
|
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,
|