@synnaxlabs/client 0.25.0 → 0.26.1
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 +6 -6
- package/dist/access/access.spec.d.ts +2 -0
- package/dist/access/access.spec.d.ts.map +1 -0
- package/dist/access/client.d.ts +13 -0
- package/dist/access/client.d.ts.map +1 -0
- package/dist/access/external.d.ts +3 -0
- package/dist/access/external.d.ts.map +1 -0
- package/dist/access/index.d.ts +2 -0
- package/dist/access/index.d.ts.map +1 -0
- package/dist/access/payload.d.ts +105 -0
- package/dist/access/payload.d.ts.map +1 -0
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +17 -14
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +7 -7
- package/dist/client.cjs +18 -18
- package/dist/client.d.ts +4 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2223 -2126
- package/dist/control/state.d.ts +1 -1
- package/dist/control/state.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +2 -0
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts +1 -1
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +9 -6
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +1 -66
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/external.d.ts +1 -0
- package/dist/hardware/device/external.d.ts.map +1 -1
- package/dist/hardware/device/index.d.ts +1 -1
- package/dist/hardware/device/index.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +73 -0
- package/dist/hardware/device/payload.d.ts.map +1 -0
- package/dist/hardware/rack/client.d.ts +2 -25
- package/dist/hardware/rack/client.d.ts.map +1 -1
- package/dist/hardware/rack/external.d.ts +1 -0
- package/dist/hardware/rack/external.d.ts.map +1 -1
- package/dist/hardware/rack/payload.d.ts +30 -0
- package/dist/hardware/rack/payload.d.ts.map +1 -0
- package/dist/hardware/task/client.d.ts +1 -145
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/external.d.ts +3 -0
- package/dist/hardware/task/external.d.ts.map +1 -0
- package/dist/hardware/task/index.d.ts +1 -1
- package/dist/hardware/task/index.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +151 -0
- package/dist/hardware/task/payload.d.ts.map +1 -0
- package/dist/label/payload.d.ts +1 -0
- package/dist/label/payload.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +5 -5
- package/dist/ontology/payload.d.ts +40 -37
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +5 -0
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/setupspecs.d.ts.map +1 -1
- package/dist/signals/observable.d.ts +1 -1
- package/dist/signals/observable.d.ts.map +1 -1
- package/dist/user/client.d.ts +9 -0
- package/dist/user/client.d.ts.map +1 -0
- package/dist/user/external.d.ts +3 -0
- package/dist/user/external.d.ts.map +1 -0
- package/dist/user/index.d.ts +1 -1
- package/dist/user/index.d.ts.map +1 -1
- package/dist/user/payload.d.ts +5 -0
- package/dist/user/payload.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +3 -0
- package/dist/workspace/lineplot/payload.d.ts.map +1 -1
- package/dist/workspace/payload.d.ts +3 -0
- package/dist/workspace/payload.d.ts.map +1 -1
- package/dist/workspace/schematic/payload.d.ts +3 -0
- package/dist/workspace/schematic/payload.d.ts.map +1 -1
- package/examples/node/basicReadWrite.js +28 -18
- package/examples/node/liveStream.js +7 -8
- package/examples/node/package-lock.json +2165 -2365
- package/examples/node/package.json +1 -1
- package/examples/node/seriesAndFrames.js +48 -47
- package/examples/node/streamWrite.js +34 -33
- package/package.json +5 -5
- package/src/access/access.spec.ts +276 -0
- package/src/access/client.ts +86 -0
- package/src/access/external.ts +11 -0
- package/src/access/index.ts +10 -0
- package/src/access/payload.ts +35 -0
- package/src/auth/auth.ts +1 -1
- package/src/channel/payload.ts +7 -0
- package/src/client.ts +7 -1
- package/src/control/state.ts +3 -3
- package/src/framer/adapter.spec.ts +9 -0
- package/src/framer/adapter.ts +12 -0
- package/src/framer/client.ts +3 -2
- package/src/framer/deleter.ts +2 -4
- package/src/framer/writer.spec.ts +99 -14
- package/src/framer/writer.ts +56 -23
- package/src/hardware/device/client.ts +8 -36
- package/src/hardware/device/external.ts +1 -0
- package/src/hardware/device/index.ts +1 -1
- package/src/hardware/device/payload.ts +44 -0
- package/src/hardware/rack/client.ts +10 -15
- package/src/hardware/rack/external.ts +1 -0
- package/src/hardware/rack/payload.ts +23 -0
- package/src/hardware/task/client.ts +1 -84
- package/src/hardware/task/external.ts +11 -0
- package/src/hardware/task/index.ts +1 -1
- package/src/hardware/task/payload.ts +92 -0
- package/src/label/payload.ts +3 -1
- package/src/ontology/payload.ts +6 -1
- package/src/ranger/payload.ts +11 -0
- package/src/setupspecs.ts +4 -2
- package/src/signals/observable.ts +5 -3
- package/src/transport.ts +3 -3
- package/src/user/client.ts +37 -0
- package/src/user/external.ts +11 -0
- package/src/user/index.ts +1 -1
- package/src/user/payload.ts +11 -0
- package/src/workspace/lineplot/payload.ts +7 -0
- package/src/workspace/payload.ts +7 -0
- package/src/workspace/schematic/payload.ts +7 -0
- package/tsconfig.json +4 -2
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
import { ontology } from "@/ontology";
|
|
4
|
+
|
|
5
|
+
export const rackKeyZ = z.number();
|
|
6
|
+
|
|
7
|
+
export type RackKey = z.infer<typeof rackKeyZ>;
|
|
8
|
+
|
|
9
|
+
export const rackZ = z.object({
|
|
10
|
+
key: rackKeyZ,
|
|
11
|
+
name: z.string(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export type RackPayload = z.infer<typeof rackZ>;
|
|
15
|
+
|
|
16
|
+
export const newRackZ = rackZ.partial({ key: true });
|
|
17
|
+
|
|
18
|
+
export type NewRack = z.input<typeof newRackZ>;
|
|
19
|
+
|
|
20
|
+
export const RackOntologyType = "rack" as ontology.ResourceType;
|
|
21
|
+
|
|
22
|
+
export const ontologyID = (key: RackKey): ontology.ID =>
|
|
23
|
+
new ontology.ID({ type: RackOntologyType, key: key.toString() });
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
// included in the file licenses/APL.txt.
|
|
9
9
|
|
|
10
10
|
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { binary, type observe } from "@synnaxlabs/x";
|
|
12
11
|
import { id } from "@synnaxlabs/x";
|
|
13
12
|
import { type UnknownRecord } from "@synnaxlabs/x/record";
|
|
14
13
|
import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
|
|
@@ -19,6 +18,7 @@ import { z } from "zod";
|
|
|
19
18
|
import { framer } from "@/framer";
|
|
20
19
|
import { type Frame } from "@/framer/frame";
|
|
21
20
|
import { rack } from "@/hardware/rack";
|
|
21
|
+
import { NewTask, newTaskZ, Payload, State, StateObservable, stateZ, TaskKey, taskKeyZ, taskZ } from "@/hardware/task/payload";
|
|
22
22
|
import { signals } from "@/signals";
|
|
23
23
|
import { analyzeParams, checkForMultipleOrNoResults } from "@/util/retrieve";
|
|
24
24
|
import { nullableArrayZ } from "@/util/zod";
|
|
@@ -26,89 +26,6 @@ import { nullableArrayZ } from "@/util/zod";
|
|
|
26
26
|
const TASK_STATE_CHANNEL = "sy_task_state";
|
|
27
27
|
const TASK_CMD_CHANNEL = "sy_task_cmd";
|
|
28
28
|
|
|
29
|
-
export const taskKeyZ = z.union([
|
|
30
|
-
z.string(),
|
|
31
|
-
z.bigint().transform((k) => k.toString()),
|
|
32
|
-
z.number().transform((k) => k.toString()),
|
|
33
|
-
]);
|
|
34
|
-
|
|
35
|
-
export type TaskKey = z.infer<typeof taskKeyZ>;
|
|
36
|
-
|
|
37
|
-
export const stateZ = z.object({
|
|
38
|
-
task: taskKeyZ,
|
|
39
|
-
variant: z.string(),
|
|
40
|
-
key: z.string().optional(),
|
|
41
|
-
details: z
|
|
42
|
-
.record(z.unknown())
|
|
43
|
-
.or(
|
|
44
|
-
z.string().transform((c) => {
|
|
45
|
-
if (c === "") return {};
|
|
46
|
-
return JSON.parse(c);
|
|
47
|
-
}),
|
|
48
|
-
)
|
|
49
|
-
.or(z.array(z.unknown()))
|
|
50
|
-
.or(z.null()),
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
export type State<D extends {} = UnknownRecord> = Omit<
|
|
54
|
-
z.infer<typeof stateZ>,
|
|
55
|
-
"details"
|
|
56
|
-
> & {
|
|
57
|
-
details?: D;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export const taskZ = z.object({
|
|
61
|
-
key: taskKeyZ,
|
|
62
|
-
name: z.string(),
|
|
63
|
-
type: z.string(),
|
|
64
|
-
internal: z.boolean().optional(),
|
|
65
|
-
config: z.record(z.unknown()).or(
|
|
66
|
-
z.string().transform((c) => {
|
|
67
|
-
if (c === "") return {};
|
|
68
|
-
return binary.JSON_ECD.decodeString(c);
|
|
69
|
-
}),
|
|
70
|
-
) as z.ZodType<UnknownRecord>,
|
|
71
|
-
state: stateZ.optional().nullable(),
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
export const newTaskZ = taskZ.omit({ key: true }).extend({
|
|
75
|
-
key: taskKeyZ.transform((k) => k.toString()).optional(),
|
|
76
|
-
config: z.unknown().transform((c) => binary.JSON_ECD.encodeString(c)),
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export type NewTask<
|
|
80
|
-
C extends UnknownRecord = UnknownRecord,
|
|
81
|
-
T extends string = string,
|
|
82
|
-
> = Omit<z.input<typeof newTaskZ>, "config" | "state"> & {
|
|
83
|
-
type: T;
|
|
84
|
-
config: C;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export type Payload<
|
|
88
|
-
C extends UnknownRecord = UnknownRecord,
|
|
89
|
-
D extends {} = UnknownRecord,
|
|
90
|
-
T extends string = string,
|
|
91
|
-
> = Omit<z.output<typeof taskZ>, "config" | "type" | "state"> & {
|
|
92
|
-
type: T;
|
|
93
|
-
config: C;
|
|
94
|
-
state?: State<D> | null;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const commandZ = z.object({
|
|
98
|
-
task: taskKeyZ,
|
|
99
|
-
type: z.string(),
|
|
100
|
-
key: z.string(),
|
|
101
|
-
args: z.record(z.unknown()).or(
|
|
102
|
-
z.string().transform((c) => {
|
|
103
|
-
if (c === "") return {};
|
|
104
|
-
return JSON.parse(c);
|
|
105
|
-
}),
|
|
106
|
-
) as z.ZodType<UnknownRecord>,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
export type StateObservable<D extends UnknownRecord = UnknownRecord> =
|
|
110
|
-
observe.ObservableAsyncCloseable<State<D>>;
|
|
111
|
-
|
|
112
29
|
export class Task<
|
|
113
30
|
C extends UnknownRecord = UnknownRecord,
|
|
114
31
|
D extends {} = UnknownRecord,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * from "@/hardware/task/client";
|
|
11
|
+
export * from "@/hardware/task/payload";
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { binary, observe, UnknownRecord } from "@synnaxlabs/x";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
import { ontology } from "@/ontology";
|
|
5
|
+
|
|
6
|
+
export const taskKeyZ = z.union([
|
|
7
|
+
z.string(),
|
|
8
|
+
z.bigint().transform((k) => k.toString()),
|
|
9
|
+
z.number().transform((k) => k.toString()),
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
export type TaskKey = z.infer<typeof taskKeyZ>;
|
|
13
|
+
|
|
14
|
+
export const stateZ = z.object({
|
|
15
|
+
task: taskKeyZ,
|
|
16
|
+
variant: z.string(),
|
|
17
|
+
key: z.string().optional(),
|
|
18
|
+
details: z
|
|
19
|
+
.record(z.unknown())
|
|
20
|
+
.or(
|
|
21
|
+
z.string().transform((c) => {
|
|
22
|
+
if (c === "") return {};
|
|
23
|
+
return JSON.parse(c);
|
|
24
|
+
}),
|
|
25
|
+
)
|
|
26
|
+
.or(z.array(z.unknown()))
|
|
27
|
+
.or(z.null()),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type State<D extends {} = UnknownRecord> = Omit<
|
|
31
|
+
z.infer<typeof stateZ>,
|
|
32
|
+
"details"
|
|
33
|
+
> & {
|
|
34
|
+
details?: D;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const taskZ = z.object({
|
|
38
|
+
key: taskKeyZ,
|
|
39
|
+
name: z.string(),
|
|
40
|
+
type: z.string(),
|
|
41
|
+
internal: z.boolean().optional(),
|
|
42
|
+
config: z.record(z.unknown()).or(
|
|
43
|
+
z.string().transform((c) => {
|
|
44
|
+
if (c === "") return {};
|
|
45
|
+
return binary.JSON_CODEC.decodeString(c);
|
|
46
|
+
}),
|
|
47
|
+
) as z.ZodType<UnknownRecord>,
|
|
48
|
+
state: stateZ.optional().nullable(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export const newTaskZ = taskZ.omit({ key: true }).extend({
|
|
52
|
+
key: taskKeyZ.transform((k) => k.toString()).optional(),
|
|
53
|
+
config: z.unknown().transform((c) => binary.JSON_CODEC.encodeString(c)),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export type NewTask<
|
|
57
|
+
C extends UnknownRecord = UnknownRecord,
|
|
58
|
+
T extends string = string,
|
|
59
|
+
> = Omit<z.input<typeof newTaskZ>, "config" | "state"> & {
|
|
60
|
+
type: T;
|
|
61
|
+
config: C;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type Payload<
|
|
65
|
+
C extends UnknownRecord = UnknownRecord,
|
|
66
|
+
D extends {} = UnknownRecord,
|
|
67
|
+
T extends string = string,
|
|
68
|
+
> = Omit<z.output<typeof taskZ>, "config" | "type" | "state"> & {
|
|
69
|
+
type: T;
|
|
70
|
+
config: C;
|
|
71
|
+
state?: State<D> | null;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const commandZ = z.object({
|
|
75
|
+
task: taskKeyZ,
|
|
76
|
+
type: z.string(),
|
|
77
|
+
key: z.string(),
|
|
78
|
+
args: z.record(z.unknown()).or(
|
|
79
|
+
z.string().transform((c) => {
|
|
80
|
+
if (c === "") return {};
|
|
81
|
+
return JSON.parse(c);
|
|
82
|
+
}),
|
|
83
|
+
) as z.ZodType<UnknownRecord>,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
export type StateObservable<D extends UnknownRecord = UnknownRecord> =
|
|
87
|
+
observe.ObservableAsyncCloseable<State<D>>;
|
|
88
|
+
|
|
89
|
+
export const DeviceOntologyType = "task" as ontology.ResourceType;
|
|
90
|
+
|
|
91
|
+
export const ontologyID = (key: TaskKey): ontology.ID =>
|
|
92
|
+
new ontology.ID({ type: DeviceOntologyType, key: key.toString() });
|
package/src/label/payload.ts
CHANGED
|
@@ -25,5 +25,7 @@ export const labelZ = z.object({
|
|
|
25
25
|
|
|
26
26
|
export type Label = z.infer<typeof labelZ>;
|
|
27
27
|
|
|
28
|
+
export const LabelOntologyType = "label" as ontology.ResourceType;
|
|
29
|
+
|
|
28
30
|
export const ontologyID = (key: Key): ontology.ID =>
|
|
29
|
-
new ontology.ID({ type:
|
|
31
|
+
new ontology.ID({ type: LabelOntologyType, key });
|
package/src/ontology/payload.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 { change,UnknownRecord } from "@synnaxlabs/x";
|
|
10
|
+
import { change, UnknownRecord } from "@synnaxlabs/x";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
13
|
export type ResourceChange = change.Change<ID, Resource>;
|
|
@@ -33,10 +33,15 @@ const resourceTypeZ = z.union([
|
|
|
33
33
|
z.literal("rack"),
|
|
34
34
|
z.literal("device"),
|
|
35
35
|
z.literal("task"),
|
|
36
|
+
z.literal("policy"),
|
|
36
37
|
]);
|
|
37
38
|
|
|
38
39
|
export type ResourceType = z.infer<typeof resourceTypeZ>;
|
|
39
40
|
|
|
41
|
+
export const BuiltinOntologyType = "builtin" as ResourceType;
|
|
42
|
+
export const ClusterOntologyType = "cluster" as ResourceType;
|
|
43
|
+
export const NodeOntologyType = "node" as ResourceType;
|
|
44
|
+
|
|
40
45
|
export const idZ = z.object({ type: resourceTypeZ, key: z.string() });
|
|
41
46
|
|
|
42
47
|
export type IDPayload = z.infer<typeof idZ>;
|
package/src/ranger/payload.ts
CHANGED
|
@@ -11,6 +11,8 @@ import { TimeRange } from "@synnaxlabs/x/telem";
|
|
|
11
11
|
import { toArray } from "@synnaxlabs/x/toArray";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
|
|
14
|
+
import { ontology } from "@/ontology";
|
|
15
|
+
|
|
14
16
|
export const keyZ = z.string().uuid();
|
|
15
17
|
export type Key = z.infer<typeof keyZ>;
|
|
16
18
|
export type Name = string;
|
|
@@ -70,3 +72,12 @@ export const analyzeParams = (params: Params): ParamAnalysisResult => {
|
|
|
70
72
|
actual: params,
|
|
71
73
|
} as const as ParamAnalysisResult;
|
|
72
74
|
};
|
|
75
|
+
|
|
76
|
+
export const RangeOntologyType = "range" as ontology.ResourceType;
|
|
77
|
+
export const RangeAliasOntologyType = "range-alias" as ontology.ResourceType;
|
|
78
|
+
|
|
79
|
+
export const rangeOntologyID = (key: Key): ontology.ID =>
|
|
80
|
+
new ontology.ID({ type: RangeOntologyType, key: key });
|
|
81
|
+
|
|
82
|
+
export const rangeAliasOntologyID = (key: Key): ontology.ID =>
|
|
83
|
+
new ontology.ID({ type: RangeAliasOntologyType, key: key });
|
package/src/setupspecs.ts
CHANGED
|
@@ -11,6 +11,8 @@ import Synnax, { type SynnaxProps } from "@/client";
|
|
|
11
11
|
|
|
12
12
|
export const HOST = "localhost";
|
|
13
13
|
export const PORT = 9090;
|
|
14
|
+
const USERNAME = "synnax"
|
|
15
|
+
const PASSWORD = "seldon"
|
|
14
16
|
|
|
15
17
|
export const newClient = (...props: SynnaxProps[]): Synnax => {
|
|
16
18
|
let _props = {};
|
|
@@ -18,8 +20,8 @@ export const newClient = (...props: SynnaxProps[]): Synnax => {
|
|
|
18
20
|
return new Synnax({
|
|
19
21
|
host: HOST,
|
|
20
22
|
port: PORT,
|
|
21
|
-
username:
|
|
22
|
-
password:
|
|
23
|
+
username: USERNAME,
|
|
24
|
+
password: PASSWORD,
|
|
23
25
|
..._props,
|
|
24
26
|
});
|
|
25
27
|
};
|
|
@@ -26,15 +26,17 @@ export const openObservable = async <K, V>(
|
|
|
26
26
|
client: framer.Client,
|
|
27
27
|
setChannel: channel.Key | channel.Name,
|
|
28
28
|
deleteChannel: channel.Key | channel.Name,
|
|
29
|
-
|
|
29
|
+
codec: Decoder<K, V>,
|
|
30
30
|
): Promise<Observable<K, V>> => {
|
|
31
31
|
const stream = await client.openStreamer([setChannel, deleteChannel] as channel.Keys);
|
|
32
32
|
const transform = (frame: framer.Frame): [Array<change.Change<K, V>>, boolean] => {
|
|
33
33
|
const changes: Array<change.Change<K, V>> = [];
|
|
34
34
|
if (deleteChannel != null)
|
|
35
|
-
changes.push(
|
|
35
|
+
changes.push(
|
|
36
|
+
...frame.get(deleteChannel).series.flatMap((s) => codec("delete", s)),
|
|
37
|
+
);
|
|
36
38
|
if (setChannel != null)
|
|
37
|
-
changes.push(...frame.get(setChannel).series.flatMap((s) =>
|
|
39
|
+
changes.push(...frame.get(setChannel).series.flatMap((s) => codec("set", s)));
|
|
38
40
|
return [changes, changes.length > 0];
|
|
39
41
|
};
|
|
40
42
|
return new framer.ObservableStreamer<Array<change.Change<K, V>>>(stream, transform);
|
package/src/transport.ts
CHANGED
|
@@ -28,9 +28,9 @@ export class Transport {
|
|
|
28
28
|
constructor(url: URL, secure: boolean = false) {
|
|
29
29
|
this.secure = secure;
|
|
30
30
|
this.url = url.child(baseAPIEndpoint);
|
|
31
|
-
const
|
|
32
|
-
this.unary = new HTTPClient(this.url,
|
|
33
|
-
this.stream = new WebSocketClient(this.url,
|
|
31
|
+
const codec = new binary.JSONCodec();
|
|
32
|
+
this.unary = new HTTPClient(this.url, codec, this.secure);
|
|
33
|
+
this.stream = new WebSocketClient(this.url, codec, this.secure);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
use(...middleware: Middleware[]): void {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
+
|
|
12
|
+
import { insecureCredentialsZ, tokenResponseZ } from "@/auth/auth";
|
|
13
|
+
import { Payload } from "@/user/payload";
|
|
14
|
+
|
|
15
|
+
const REGISTER_ENDPOINT = "/user/register";
|
|
16
|
+
|
|
17
|
+
export class Client {
|
|
18
|
+
private readonly client: UnaryClient;
|
|
19
|
+
|
|
20
|
+
constructor(client: UnaryClient) {
|
|
21
|
+
this.client = client;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async register(username: string, password: string): Promise<Payload> {
|
|
25
|
+
const { user } = await sendRequired<
|
|
26
|
+
typeof insecureCredentialsZ,
|
|
27
|
+
typeof tokenResponseZ
|
|
28
|
+
>(
|
|
29
|
+
this.client,
|
|
30
|
+
REGISTER_ENDPOINT,
|
|
31
|
+
{ username: username, password: password },
|
|
32
|
+
insecureCredentialsZ,
|
|
33
|
+
tokenResponseZ,
|
|
34
|
+
);
|
|
35
|
+
return user;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2024 Synnax Labs, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Use of this software is governed by the Business Source License included in the file
|
|
4
|
+
// licenses/BSL.txt.
|
|
5
|
+
//
|
|
6
|
+
// As of the Change Date specified in that file, in accordance with the Business Source
|
|
7
|
+
// License, use of this software will be governed by the Apache License, Version 2.0,
|
|
8
|
+
// included in the file licenses/APL.txt.
|
|
9
|
+
|
|
10
|
+
export * from "@/user/client";
|
|
11
|
+
export * from "@/user/payload";
|
package/src/user/index.ts
CHANGED
package/src/user/payload.ts
CHANGED
|
@@ -9,9 +9,20 @@
|
|
|
9
9
|
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
|
|
12
|
+
import { ontology } from "@/ontology";
|
|
13
|
+
|
|
14
|
+
export const keyZ = z.string().uuid();
|
|
15
|
+
|
|
16
|
+
export type Key = z.infer<typeof keyZ>;
|
|
17
|
+
|
|
12
18
|
export const payloadZ = z.object({
|
|
13
19
|
key: z.string(),
|
|
14
20
|
username: z.string(),
|
|
15
21
|
});
|
|
16
22
|
|
|
17
23
|
export type Payload = z.infer<typeof payloadZ>;
|
|
24
|
+
|
|
25
|
+
export const UserOntologyType = "user" as ontology.ResourceType;
|
|
26
|
+
|
|
27
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
28
|
+
new ontology.ID({ type: UserOntologyType, key });
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
import { type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
+
import { ontology } from "@/ontology";
|
|
14
|
+
|
|
13
15
|
export const keyZ = z.string().uuid();
|
|
14
16
|
export type Key = z.infer<typeof keyZ>;
|
|
15
17
|
export type Params = Key | Key[];
|
|
@@ -21,3 +23,8 @@ export const linePlotZ = z.object({
|
|
|
21
23
|
});
|
|
22
24
|
|
|
23
25
|
export type LinePlot = z.infer<typeof linePlotZ>;
|
|
26
|
+
|
|
27
|
+
export const LineplotOntologyType = "lineplot" as ontology.ResourceType;
|
|
28
|
+
|
|
29
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
30
|
+
new ontology.ID({ type: LineplotOntologyType, key: key });
|
package/src/workspace/payload.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
import { type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
+
import { ontology } from "@/ontology";
|
|
14
|
+
|
|
13
15
|
export const keyZ = z.string().uuid();
|
|
14
16
|
|
|
15
17
|
export type Key = z.infer<typeof keyZ>;
|
|
@@ -35,3 +37,8 @@ export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
|
|
|
35
37
|
});
|
|
36
38
|
|
|
37
39
|
export type Workspace = z.infer<typeof workspaceZ>;
|
|
40
|
+
|
|
41
|
+
export const WorkspaceOntologyType = "workspace" as ontology.ResourceType;
|
|
42
|
+
|
|
43
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
44
|
+
new ontology.ID({ type: WorkspaceOntologyType, key: key });
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
import { type UnknownRecord, unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
+
import { ontology } from "@/ontology";
|
|
14
|
+
|
|
13
15
|
export const keyZ = z.string().uuid();
|
|
14
16
|
export type Key = z.infer<typeof keyZ>;
|
|
15
17
|
export type Params = Key | Key[];
|
|
@@ -29,3 +31,8 @@ export const schematicRemoteZ = z.object({
|
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
export type Schematic = z.infer<typeof schematicZ>;
|
|
34
|
+
|
|
35
|
+
export const SchematicOntologyType = "schematic" as ontology.ResourceType;
|
|
36
|
+
|
|
37
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
38
|
+
new ontology.ID({ type: SchematicOntologyType, key: key });
|