@synnaxlabs/client 0.36.0 → 0.38.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/dist/access/policy/payload.d.ts +10 -10
- package/dist/channel/client.d.ts +13 -1
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +14 -0
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/client.cjs +30 -30
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2226 -2157
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +2 -2
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +4 -4
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/label/client.d.ts.map +1 -1
- package/dist/ontology/group/group.d.ts.map +1 -1
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +2 -2
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/util/retrieve.d.ts.map +1 -1
- package/dist/util/zod.d.ts +1 -1
- package/dist/util/zod.d.ts.map +1 -1
- package/dist/workspace/client.d.ts +2 -2
- package/dist/workspace/client.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/log/client.d.ts +1 -1
- package/dist/workspace/log/client.d.ts.map +1 -1
- package/dist/workspace/schematic/client.d.ts +1 -1
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/table/client.d.ts +1 -1
- package/dist/workspace/table/client.d.ts.map +1 -1
- package/examples/node/package-lock.json +56 -5509
- package/examples/node/package.json +1 -1
- package/package.json +11 -15
- package/src/access/policy/policy.spec.ts +1 -4
- package/src/channel/batchRetriever.spec.ts +4 -0
- package/src/channel/channel.spec.ts +108 -37
- package/src/channel/client.ts +45 -2
- package/src/channel/payload.ts +5 -0
- package/src/client.ts +1 -1
- package/src/framer/frame.spec.ts +0 -1
- package/src/framer/frame.ts +4 -5
- package/src/framer/streamer.spec.ts +193 -6
- package/src/hardware/task/client.ts +3 -2
- package/src/index.ts +1 -1
- package/src/label/client.ts +2 -2
- package/src/ontology/group/group.ts +3 -5
- package/src/ontology/group/payload.ts +1 -0
- package/src/ontology/payload.ts +1 -1
- package/src/ranger/client.ts +6 -11
- package/src/ranger/payload.ts +2 -2
- package/src/transport.ts +4 -4
- package/src/util/retrieve.ts +2 -2
- package/src/util/zod.ts +4 -1
- package/src/workspace/client.ts +6 -5
- package/src/workspace/lineplot/client.ts +5 -4
- package/src/workspace/log/client.ts +4 -3
- package/src/workspace/schematic/client.ts +5 -4
- package/src/workspace/table/client.ts +4 -3
- package/vite.config.ts +5 -12
- package/api/client.api.md +0 -3473
- package/api-extractor.json +0 -7
- package/dist/hardware/task/ni/types.d.ts +0 -14495
- package/dist/hardware/task/ni/types.d.ts.map +0 -1
- package/dist/workspace/lineplot/payload.d.ts +0 -23
- package/dist/workspace/lineplot/payload.d.ts.map +0 -1
- package/src/hardware/task/ni/types.ts +0 -1716
- package/src/workspace/lineplot/payload.ts +0 -30
|
@@ -52,7 +52,10 @@ describe("Streamer", () => {
|
|
|
52
52
|
});
|
|
53
53
|
test("downsample factor of 1", async () => {
|
|
54
54
|
const ch = await newChannel();
|
|
55
|
-
const streamer = await client.openStreamer({
|
|
55
|
+
const streamer = await client.openStreamer({
|
|
56
|
+
channels: ch.key,
|
|
57
|
+
downsampleFactor: 1,
|
|
58
|
+
});
|
|
56
59
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
57
60
|
const writer = await client.openWriter({
|
|
58
61
|
start: TimeStamp.now(),
|
|
@@ -66,9 +69,12 @@ describe("Streamer", () => {
|
|
|
66
69
|
const d = await streamer.read();
|
|
67
70
|
expect(Array.from(d.get(ch.key))).toEqual([1, 2, 3, 4, 5]);
|
|
68
71
|
});
|
|
69
|
-
test("downsample factor of 2", async () => {
|
|
72
|
+
test("downsample factor of 2", async () => {
|
|
70
73
|
const ch = await newChannel();
|
|
71
|
-
const streamer = await client.openStreamer({
|
|
74
|
+
const streamer = await client.openStreamer({
|
|
75
|
+
channels: ch.key,
|
|
76
|
+
downsampleFactor: 2,
|
|
77
|
+
});
|
|
72
78
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
73
79
|
const writer = await client.openWriter({
|
|
74
80
|
start: TimeStamp.now(),
|
|
@@ -82,16 +88,19 @@ test("downsample factor of 2", async () => {
|
|
|
82
88
|
const d = await streamer.read();
|
|
83
89
|
expect(Array.from(d.get(ch.key))).toEqual([1, 3, 5, 7, 9]);
|
|
84
90
|
});
|
|
85
|
-
test("downsample factor of 10", async () => {
|
|
91
|
+
test("downsample factor of 10", async () => {
|
|
86
92
|
const ch = await newChannel();
|
|
87
|
-
const streamer = await client.openStreamer({
|
|
93
|
+
const streamer = await client.openStreamer({
|
|
94
|
+
channels: ch.key,
|
|
95
|
+
downsampleFactor: 10,
|
|
96
|
+
});
|
|
88
97
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
89
98
|
const writer = await client.openWriter({
|
|
90
99
|
start: TimeStamp.now(),
|
|
91
100
|
channels: ch.key,
|
|
92
101
|
});
|
|
93
102
|
try {
|
|
94
|
-
await writer.write(ch.key, new Float64Array([1, 2, 3, 4, 5, 6,7,8,9,10]));
|
|
103
|
+
await writer.write(ch.key, new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]));
|
|
95
104
|
} finally {
|
|
96
105
|
await writer.close();
|
|
97
106
|
}
|
|
@@ -99,3 +108,181 @@ test("downsample factor of 10", async () => {
|
|
|
99
108
|
expect(Array.from(d.get(ch.key))).toEqual([1]);
|
|
100
109
|
});
|
|
101
110
|
});
|
|
111
|
+
|
|
112
|
+
describe("Streamer - Calculated Channels", () => {
|
|
113
|
+
test("basic calculated channel streaming", async () => {
|
|
114
|
+
// Create a timestamp index channel
|
|
115
|
+
const timeChannel = await client.channels.create({
|
|
116
|
+
name: "calc_test_time",
|
|
117
|
+
isIndex: true,
|
|
118
|
+
dataType: DataType.TIMESTAMP,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
// Create source channels with the timestamp index
|
|
122
|
+
const [channelA, channelB] = await client.channels.create([
|
|
123
|
+
{
|
|
124
|
+
name: "test_a",
|
|
125
|
+
dataType: DataType.FLOAT64,
|
|
126
|
+
index: timeChannel.key,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "test_b",
|
|
130
|
+
dataType: DataType.FLOAT64,
|
|
131
|
+
index: timeChannel.key,
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
|
|
135
|
+
// Create calculated channel that adds the two source channels
|
|
136
|
+
const calcChannel = await client.channels.create({
|
|
137
|
+
name: "test_calc",
|
|
138
|
+
dataType: DataType.FLOAT64,
|
|
139
|
+
index: timeChannel.key,
|
|
140
|
+
virtual: true,
|
|
141
|
+
expression: "return test_a + test_b",
|
|
142
|
+
requires: [channelA.key, channelB.key],
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Set up streamer to listen for calculated results
|
|
146
|
+
const streamer = await client.openStreamer(calcChannel.key);
|
|
147
|
+
|
|
148
|
+
// Give streamer time to initialize
|
|
149
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
150
|
+
|
|
151
|
+
// Write test data
|
|
152
|
+
const startTime = TimeStamp.now();
|
|
153
|
+
const writer = await client.openWriter({
|
|
154
|
+
start: startTime,
|
|
155
|
+
channels: [timeChannel.key, channelA.key, channelB.key],
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
try {
|
|
159
|
+
// Write test values - each source gets 2.5 so sum should be 5.0
|
|
160
|
+
await writer.write({
|
|
161
|
+
[timeChannel.key]: [startTime],
|
|
162
|
+
[channelA.key]: new Float64Array([2.5]),
|
|
163
|
+
[channelB.key]: new Float64Array([2.5]),
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Read from streamer
|
|
167
|
+
const frame = await streamer.read();
|
|
168
|
+
|
|
169
|
+
// Verify calculated results
|
|
170
|
+
const calcData = Array.from(frame.get(calcChannel.key));
|
|
171
|
+
expect(calcData).toEqual([5.0]);
|
|
172
|
+
} finally {
|
|
173
|
+
await writer.close();
|
|
174
|
+
streamer.close();
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
test("calculated channel with constant", async () => {
|
|
178
|
+
// Create an index channel for timestamps
|
|
179
|
+
const timeChannel = await client.channels.create({
|
|
180
|
+
name: "calc_const_time",
|
|
181
|
+
isIndex: true,
|
|
182
|
+
dataType: DataType.TIMESTAMP,
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Create base channel with index
|
|
186
|
+
const baseChannel = await client.channels.create({
|
|
187
|
+
name: "base_channel",
|
|
188
|
+
dataType: DataType.FLOAT64,
|
|
189
|
+
index: timeChannel.key,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// Create calculated channel that adds 5
|
|
193
|
+
const calcChannel = await client.channels.create({
|
|
194
|
+
name: "calc_const_channel",
|
|
195
|
+
dataType: DataType.FLOAT64,
|
|
196
|
+
index: timeChannel.key,
|
|
197
|
+
virtual: true,
|
|
198
|
+
expression: `return ${baseChannel.name} + 5`,
|
|
199
|
+
requires: [baseChannel.key],
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const streamer = await client.openStreamer(calcChannel.key);
|
|
203
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
204
|
+
|
|
205
|
+
const startTime = TimeStamp.now();
|
|
206
|
+
const writer = await client.openWriter({
|
|
207
|
+
start: startTime,
|
|
208
|
+
channels: [timeChannel.key, baseChannel.key],
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
const timestamps = [
|
|
213
|
+
startTime,
|
|
214
|
+
new TimeStamp(startTime.valueOf() + BigInt(1000000000)),
|
|
215
|
+
new TimeStamp(startTime.valueOf() + BigInt(2000000000)),
|
|
216
|
+
];
|
|
217
|
+
|
|
218
|
+
await writer.write({
|
|
219
|
+
[timeChannel.key]: timestamps,
|
|
220
|
+
[baseChannel.key]: new Float64Array([1, 2, 3]),
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
const frame = await streamer.read();
|
|
224
|
+
const calcData = Array.from(frame.get(calcChannel.key));
|
|
225
|
+
expect(calcData).toEqual([6, 7, 8]); // Original values + 5
|
|
226
|
+
} finally {
|
|
227
|
+
await writer.close();
|
|
228
|
+
streamer.close();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
test("calculated channel with multiple operations", async () => {
|
|
233
|
+
// Create timestamp channel
|
|
234
|
+
const timeChannel = await client.channels.create({
|
|
235
|
+
name: "calc_multi_time",
|
|
236
|
+
isIndex: true,
|
|
237
|
+
dataType: DataType.TIMESTAMP,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Create source channels
|
|
241
|
+
const [channelA, channelB] = await client.channels.create([
|
|
242
|
+
{
|
|
243
|
+
name: "multi_test_a",
|
|
244
|
+
dataType: DataType.FLOAT64,
|
|
245
|
+
index: timeChannel.key,
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: "multi_test_b",
|
|
249
|
+
dataType: DataType.FLOAT64,
|
|
250
|
+
index: timeChannel.key,
|
|
251
|
+
},
|
|
252
|
+
]);
|
|
253
|
+
|
|
254
|
+
// Create calculated channel with multiple operations
|
|
255
|
+
const calcChannel = await client.channels.create({
|
|
256
|
+
name: "multi_calc",
|
|
257
|
+
dataType: DataType.FLOAT64,
|
|
258
|
+
index: timeChannel.key,
|
|
259
|
+
virtual: true,
|
|
260
|
+
expression: "return (multi_test_a * 2) + (multi_test_b / 2)",
|
|
261
|
+
requires: [channelA.key, channelB.key],
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
const streamer = await client.openStreamer(calcChannel.key);
|
|
265
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
266
|
+
|
|
267
|
+
const startTime = TimeStamp.now();
|
|
268
|
+
const writer = await client.openWriter({
|
|
269
|
+
start: startTime,
|
|
270
|
+
channels: [timeChannel.key, channelA.key, channelB.key],
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
await writer.write({
|
|
275
|
+
[timeChannel.key]: [startTime],
|
|
276
|
+
[channelA.key]: new Float64Array([2.0]), // Will be multiplied by 2 = 4.0
|
|
277
|
+
[channelB.key]: new Float64Array([4.0]), // Will be divided by 2 = 2.0
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const frame = await streamer.read();
|
|
281
|
+
const calcData = Array.from(frame.get(calcChannel.key));
|
|
282
|
+
expect(calcData).toEqual([6.0]); // (2.0 * 2) + (4.0 / 2) = 4.0 + 2.0 = 6.0
|
|
283
|
+
} finally {
|
|
284
|
+
await writer.close();
|
|
285
|
+
streamer.close();
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
commandZ,
|
|
25
25
|
type NewTask,
|
|
26
26
|
newTaskZ,
|
|
27
|
+
ontologyID as payloadOntologyID,
|
|
27
28
|
type Payload,
|
|
28
29
|
type State,
|
|
29
30
|
type StateObservable,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
taskKeyZ,
|
|
33
34
|
taskZ,
|
|
34
35
|
} from "@/hardware/task/payload";
|
|
35
|
-
import { ontology } from "@/ontology";
|
|
36
|
+
import { type ontology } from "@/ontology";
|
|
36
37
|
import { type ranger } from "@/ranger";
|
|
37
38
|
import { signals } from "@/signals";
|
|
38
39
|
import { analyzeParams, checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
@@ -95,7 +96,7 @@ export class Task<
|
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
get ontologyID(): ontology.ID {
|
|
98
|
-
return
|
|
99
|
+
return payloadOntologyID(this.key);
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
async executeCommand(type: string, args?: UnknownRecord): Promise<string> {
|
package/src/index.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
export { access } from "@/access";
|
|
11
11
|
export { policy } from "@/access/policy";
|
|
12
12
|
export { channel } from "@/channel";
|
|
13
|
-
export { Channel } from "@/channel/client";
|
|
13
|
+
export { Channel, isCalculated } from "@/channel/client";
|
|
14
14
|
export { default as Synnax, type SynnaxProps, synnaxPropsZ } from "@/client";
|
|
15
15
|
export * from "@/connection";
|
|
16
16
|
export { control } from "@/control";
|
package/src/label/client.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { observe } from "@synnaxlabs/x";
|
|
|
12
12
|
import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
|
|
13
13
|
|
|
14
14
|
import { type framer } from "@/framer";
|
|
15
|
-
import { type Key, type Label, labelZ } from "@/label/payload";
|
|
15
|
+
import { type Key, type Label, labelZ, ontologyID } from "@/label/payload";
|
|
16
16
|
import { Retriever } from "@/label/retriever";
|
|
17
17
|
import { type NewLabelPayload, type SetOptions, Writer } from "@/label/writer";
|
|
18
18
|
import { ontology } from "@/ontology";
|
|
@@ -105,7 +105,7 @@ export class Client implements AsyncTermSearcher<string, Key, Label> {
|
|
|
105
105
|
): Promise<observe.ObservableAsyncCloseable<Label[]>> {
|
|
106
106
|
const wrapper = new observe.Observer<Label[]>();
|
|
107
107
|
const initial = (await this.retrieveFor(id)).map((l) => ({
|
|
108
|
-
id:
|
|
108
|
+
id: ontologyID(l.key),
|
|
109
109
|
key: l.key,
|
|
110
110
|
name: l.name,
|
|
111
111
|
data: l,
|
|
@@ -7,7 +7,8 @@
|
|
|
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 { ontology } from "@/ontology";
|
|
10
|
+
import { type ontology } from "@/ontology";
|
|
11
|
+
import { ontologyID as payloadOntologyID } from "@/ontology/group/payload";
|
|
11
12
|
|
|
12
13
|
export class Group {
|
|
13
14
|
key: string;
|
|
@@ -19,9 +20,6 @@ export class Group {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
get ontologyID(): ontology.ID {
|
|
22
|
-
return
|
|
23
|
-
type: "group",
|
|
24
|
-
key: this.key,
|
|
25
|
-
});
|
|
23
|
+
return payloadOntologyID(this.key);
|
|
26
24
|
}
|
|
27
25
|
}
|
package/src/ontology/payload.ts
CHANGED
|
@@ -95,7 +95,7 @@ export class ID {
|
|
|
95
95
|
static readonly z = z.union([z.instanceof(ID), crudeIDZ.transform((v) => new ID(v))]);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
export const Root = new ID({ type:
|
|
98
|
+
export const Root = new ID({ type: BUILTIN_TYPE, key: "root" });
|
|
99
99
|
|
|
100
100
|
export const schemaFieldZ = z.object({ type: z.number() });
|
|
101
101
|
|
package/src/ranger/client.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { MultipleFoundError, NotFoundError, QueryError } from "@/errors";
|
|
|
20
20
|
import { type framer } from "@/framer";
|
|
21
21
|
import { type label } from "@/label";
|
|
22
22
|
import { type Label } from "@/label/payload";
|
|
23
|
-
import { ontology } from "@/ontology";
|
|
23
|
+
import { type ontology } from "@/ontology";
|
|
24
24
|
import { type Resource } from "@/ontology/payload";
|
|
25
25
|
import { type Alias, Aliaser } from "@/ranger/alias";
|
|
26
26
|
import { KV } from "@/ranger/kv";
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
type Name,
|
|
33
33
|
type Names,
|
|
34
34
|
type NewPayload,
|
|
35
|
+
ontologyID,
|
|
35
36
|
type Params,
|
|
36
37
|
type Payload,
|
|
37
38
|
payloadZ,
|
|
@@ -40,9 +41,6 @@ import { type CreateOptions, type Writer } from "@/ranger/writer";
|
|
|
40
41
|
import { signals } from "@/signals";
|
|
41
42
|
import { nullableArrayZ } from "@/util/zod";
|
|
42
43
|
|
|
43
|
-
const ontologyID = (key: string): ontology.ID =>
|
|
44
|
-
new ontology.ID({ type: "range", key });
|
|
45
|
-
|
|
46
44
|
export class Range {
|
|
47
45
|
key: string;
|
|
48
46
|
name: string;
|
|
@@ -83,7 +81,7 @@ export class Range {
|
|
|
83
81
|
}
|
|
84
82
|
|
|
85
83
|
get ontologyID(): ontology.ID {
|
|
86
|
-
return
|
|
84
|
+
return ontologyID(this.key);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
get payload(): Payload {
|
|
@@ -155,7 +153,7 @@ export class Range {
|
|
|
155
153
|
async openChildRangeTracker(): Promise<observe.ObservableAsyncCloseable<Range[]>> {
|
|
156
154
|
const wrapper = new observe.Observer<Range[]>();
|
|
157
155
|
const initial: ontology.Resource[] = (await this.retrieveChildren()).map((r) => {
|
|
158
|
-
const id =
|
|
156
|
+
const id = ontologyID(r.key);
|
|
159
157
|
return { id, key: id.toString(), name: r.name, data: r.payload };
|
|
160
158
|
});
|
|
161
159
|
const base = await this.ontologyClient.openDependentTracker({
|
|
@@ -174,7 +172,7 @@ export class Range {
|
|
|
174
172
|
const wrapper = new observe.Observer<Range>();
|
|
175
173
|
const p = await this.retrieveParent();
|
|
176
174
|
if (p == null) return null;
|
|
177
|
-
const id =
|
|
175
|
+
const id = ontologyID(p.key);
|
|
178
176
|
const resourceP = { id, key: id.toString(), name: p.name, data: p.payload };
|
|
179
177
|
const base = await this.ontologyClient.openDependentTracker({
|
|
180
178
|
target: this.ontologyID,
|
|
@@ -302,10 +300,7 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
|
|
|
302
300
|
}
|
|
303
301
|
|
|
304
302
|
async retrieveParent(range: Key): Promise<Range | null> {
|
|
305
|
-
const res = await this.ontologyClient.retrieveParents(
|
|
306
|
-
key: range,
|
|
307
|
-
type: "range",
|
|
308
|
-
});
|
|
303
|
+
const res = await this.ontologyClient.retrieveParents(ontologyID(range));
|
|
309
304
|
if (res.length === 0) return null;
|
|
310
305
|
const first = res[0];
|
|
311
306
|
if (first.id.type !== "range") return null;
|
package/src/ranger/payload.ts
CHANGED
|
@@ -78,8 +78,8 @@ export const analyzeParams = (ranges: Params): ParamAnalysisResult => {
|
|
|
78
78
|
export const ONTOLOGY_TYPE: ontology.ResourceType = "range";
|
|
79
79
|
export const ALIAS_ONTOLOGY_TYPE: ontology.ResourceType = "range-alias";
|
|
80
80
|
|
|
81
|
-
export const
|
|
81
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
82
82
|
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
83
83
|
|
|
84
|
-
export const
|
|
84
|
+
export const aliasOntologyID = (key: Key): ontology.ID =>
|
|
85
85
|
new ontology.ID({ type: ALIAS_ONTOLOGY_TYPE, key });
|
package/src/transport.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
unaryWithBreaker,
|
|
16
16
|
WebSocketClient,
|
|
17
17
|
} from "@synnaxlabs/freighter";
|
|
18
|
-
import { breaker } from "@synnaxlabs/x";
|
|
18
|
+
import { type breaker } from "@synnaxlabs/x";
|
|
19
19
|
import { binary } from "@synnaxlabs/x/binary";
|
|
20
20
|
import { type URL } from "@synnaxlabs/x/url";
|
|
21
21
|
|
|
@@ -31,11 +31,11 @@ export class Transport {
|
|
|
31
31
|
this.secure = secure;
|
|
32
32
|
this.url = url.child(baseAPIEndpoint);
|
|
33
33
|
const codec = new binary.JSONCodec();
|
|
34
|
-
|
|
34
|
+
this.unary = unaryWithBreaker(
|
|
35
35
|
new HTTPClient(this.url, codec, this.secure),
|
|
36
36
|
breakerCfg,
|
|
37
|
-
)
|
|
38
|
-
|
|
37
|
+
);
|
|
38
|
+
this.stream = new WebSocketClient(this.url, codec, this.secure);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
use(...middleware: Middleware[]): void {
|
package/src/util/retrieve.ts
CHANGED
|
@@ -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 Primitive,toArray } from "@synnaxlabs/x";
|
|
10
|
+
import { type Primitive, toArray } from "@synnaxlabs/x";
|
|
11
11
|
|
|
12
12
|
import { MultipleFoundError, NotFoundError } from "@/errors";
|
|
13
13
|
|
|
@@ -84,7 +84,7 @@ export const analyzeParams = <
|
|
|
84
84
|
variant,
|
|
85
85
|
normalized: normal,
|
|
86
86
|
actual: args,
|
|
87
|
-
} as
|
|
87
|
+
} as ParamAnalysisResult<T, K>;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
90
|
export const checkForMultipleOrNoResults = <T, R>(
|
package/src/util/zod.ts
CHANGED
|
@@ -10,4 +10,7 @@
|
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
|
|
12
12
|
export const nullableArrayZ = <Z extends z.ZodTypeAny>(item: Z) =>
|
|
13
|
-
z.union([
|
|
13
|
+
z.union([
|
|
14
|
+
z.union([z.null(), z.undefined()]).transform(() => [] as z.output<Z>[]),
|
|
15
|
+
item.array(),
|
|
16
|
+
]);
|
package/src/workspace/client.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { toArray, UnknownRecord } from "@synnaxlabs/x";
|
|
1
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
4
3
|
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
4
|
+
import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import { ontology } from "@/ontology";
|
|
8
|
+
import { nullableArrayZ } from "@/util/zod";
|
|
7
9
|
import { linePlot } from "@/workspace/lineplot";
|
|
8
10
|
import { log } from "@/workspace/log";
|
|
9
11
|
import { schematic } from "@/workspace/schematic";
|
|
10
12
|
import { table } from "@/workspace/table";
|
|
11
|
-
import { nullableArrayZ } from "@/util/zod";
|
|
12
13
|
|
|
13
14
|
export const keyZ = z.string().uuid();
|
|
14
15
|
export type Key = z.infer<typeof keyZ>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { sendRequired, UnaryClient } from "@synnaxlabs/freighter";
|
|
4
|
-
import { breaker, TimeSpan, toArray, UnknownRecord } from "@synnaxlabs/x";
|
|
1
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
5
3
|
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
6
4
|
import { z } from "zod";
|
|
7
5
|
|
|
6
|
+
import { ontology } from "@/ontology";
|
|
7
|
+
import { nullableArrayZ } from "@/util/zod";
|
|
8
|
+
|
|
8
9
|
export const keyZ = z.string().uuid();
|
|
9
10
|
export type Key = z.infer<typeof keyZ>;
|
|
10
11
|
export type Params = Key | Key[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { toArray, UnknownRecord } from "@synnaxlabs/x";
|
|
1
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
4
3
|
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
|
|
6
|
+
import { ontology } from "@/ontology";
|
|
7
|
+
|
|
7
8
|
export const keyZ = z.string().uuid();
|
|
8
9
|
export type Key = z.infer<typeof keyZ>;
|
|
9
10
|
export type Params = Key | Key[];
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { sendRequired, UnaryClient } from "@synnaxlabs/freighter";
|
|
4
|
-
import { toArray, UnknownRecord } from "@synnaxlabs/x";
|
|
1
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
5
3
|
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
6
4
|
import { z } from "zod";
|
|
7
5
|
|
|
6
|
+
import { ontology } from "@/ontology";
|
|
7
|
+
import { nullableArrayZ } from "@/util/zod";
|
|
8
|
+
|
|
8
9
|
export const keyZ = z.string().uuid();
|
|
9
10
|
export type Key = z.infer<typeof keyZ>;
|
|
10
11
|
export type Params = Key | Key[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { toArray, UnknownRecord } from "@synnaxlabs/x";
|
|
1
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
4
3
|
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
|
|
6
|
+
import { ontology } from "@/ontology";
|
|
7
|
+
|
|
7
8
|
export const keyZ = z.string().uuid();
|
|
8
9
|
export type Key = z.infer<typeof keyZ>;
|
|
9
10
|
export type Params = Key | Key[];
|
package/vite.config.ts
CHANGED
|
@@ -7,23 +7,16 @@
|
|
|
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
|
+
/// <reference types="vitest/config" />
|
|
11
|
+
|
|
10
12
|
import { lib } from "@synnaxlabs/vite-plugin";
|
|
11
13
|
import { defineConfig } from "vite";
|
|
12
14
|
|
|
13
15
|
import packageJSON from "./package.json";
|
|
14
16
|
|
|
15
17
|
export default defineConfig({
|
|
16
|
-
define: {
|
|
17
|
-
__VERSION__: JSON.stringify(packageJSON.version),
|
|
18
|
-
},
|
|
18
|
+
define: { __VERSION__: JSON.stringify(packageJSON.version) },
|
|
19
19
|
plugins: [lib({ name: "client" })],
|
|
20
|
-
build: {
|
|
21
|
-
|
|
22
|
-
external: ["zod"],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
test: {
|
|
26
|
-
globals: true,
|
|
27
|
-
environment: "jsdom",
|
|
28
|
-
},
|
|
20
|
+
build: { rollupOptions: { external: ["zod"] } },
|
|
21
|
+
test: { globals: true, environment: "jsdom" },
|
|
29
22
|
});
|