@synnaxlabs/client 0.38.1 → 0.39.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/payload.d.ts +6 -6
- package/dist/access/payload.d.ts.map +1 -1
- package/dist/access/policy/client.d.ts +5 -3
- package/dist/access/policy/client.d.ts.map +1 -1
- package/dist/access/policy/external.d.ts +1 -0
- package/dist/access/policy/external.d.ts.map +1 -1
- package/dist/access/policy/ontology.d.ts +5 -0
- package/dist/access/policy/ontology.d.ts.map +1 -0
- package/dist/access/policy/payload.d.ts +86 -89
- package/dist/access/policy/payload.d.ts.map +1 -1
- package/dist/access/policy/retriever.d.ts +7 -6
- package/dist/access/policy/retriever.d.ts.map +1 -1
- package/dist/access/policy/writer.d.ts +2 -2
- package/dist/access/policy/writer.d.ts.map +1 -1
- package/dist/auth/auth.d.ts +2 -1
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/client.d.ts +6 -5
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +13 -11
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +9 -6
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/channel/writer.d.ts +6 -4
- package/dist/channel/writer.d.ts.map +1 -1
- package/dist/client.cjs +30 -30
- package/dist/client.d.ts +4 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +3376 -3423
- package/dist/connection/checker.d.ts +5 -4
- package/dist/connection/checker.d.ts.map +1 -1
- package/dist/control/state.d.ts +10 -8
- package/dist/control/state.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +14 -15
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts +13 -15
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts +3 -2
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts +31 -27
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/iterator.d.ts +4 -5
- package/dist/framer/iterator.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts +5 -6
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +42 -39
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +17 -12
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +19 -16
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/rack/client.d.ts +15 -15
- package/dist/hardware/rack/client.d.ts.map +1 -1
- package/dist/hardware/rack/payload.d.ts +9 -8
- package/dist/hardware/rack/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +38 -29
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +58 -53
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/label/client.d.ts +4 -3
- package/dist/label/client.d.ts.map +1 -1
- package/dist/label/payload.d.ts +4 -4
- package/dist/label/payload.d.ts.map +1 -1
- package/dist/label/retriever.d.ts.map +1 -1
- package/dist/label/writer.d.ts +13 -10
- package/dist/label/writer.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +12 -10
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/group/client.d.ts +5 -4
- package/dist/ontology/group/client.d.ts.map +1 -1
- package/dist/ontology/group/group.d.ts +7 -5
- package/dist/ontology/group/group.d.ts.map +1 -1
- package/dist/ontology/group/payload.d.ts +6 -5
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/group/writer.d.ts +8 -8
- package/dist/ontology/group/writer.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +72 -62
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ontology/writer.d.ts.map +1 -1
- package/dist/ranger/alias.d.ts +9 -10
- package/dist/ranger/alias.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +18 -18
- package/dist/ranger/client.d.ts.map +1 -1
- package/dist/ranger/external.d.ts +1 -1
- package/dist/ranger/external.d.ts.map +1 -1
- package/dist/ranger/kv.d.ts +18 -14
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +13 -13
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +14 -14
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/setupspecs.d.ts.map +1 -1
- package/dist/signals/observable.d.ts +3 -1
- package/dist/signals/observable.d.ts.map +1 -1
- package/dist/user/client.d.ts +5 -3
- package/dist/user/client.d.ts.map +1 -1
- package/dist/user/payload.d.ts +7 -6
- package/dist/user/payload.d.ts.map +1 -1
- package/dist/user/retriever.d.ts +2 -1
- package/dist/user/retriever.d.ts.map +1 -1
- package/dist/user/writer.d.ts +2 -2
- package/dist/user/writer.d.ts.map +1 -1
- package/dist/util/decodeJSONString.d.ts +3 -0
- package/dist/util/decodeJSONString.d.ts.map +1 -0
- package/dist/util/parseWithoutKeyConversion.d.ts +3 -0
- package/dist/util/parseWithoutKeyConversion.d.ts.map +1 -0
- package/dist/util/retrieve.d.ts +1 -1
- package/dist/util/retrieve.d.ts.map +1 -1
- package/dist/util/telem.d.ts.map +1 -1
- package/dist/util/zod.d.ts.map +1 -1
- package/dist/workspace/client.d.ts +6 -60
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/external.d.ts +3 -0
- package/dist/workspace/external.d.ts.map +1 -0
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +5 -44
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/external.d.ts +3 -0
- package/dist/workspace/lineplot/external.d.ts.map +1 -0
- package/dist/workspace/lineplot/index.d.ts +1 -1
- package/dist/workspace/lineplot/index.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +45 -0
- package/dist/workspace/lineplot/payload.d.ts.map +1 -0
- package/dist/workspace/log/client.d.ts +5 -44
- package/dist/workspace/log/client.d.ts.map +1 -1
- package/dist/workspace/log/external.d.ts +3 -0
- package/dist/workspace/log/external.d.ts.map +1 -0
- package/dist/workspace/log/index.d.ts +1 -1
- package/dist/workspace/log/index.d.ts.map +1 -1
- package/dist/workspace/log/payload.d.ts +45 -0
- package/dist/workspace/log/payload.d.ts.map +1 -0
- package/dist/workspace/payload.d.ts +60 -0
- package/dist/workspace/payload.d.ts.map +1 -0
- package/dist/workspace/schematic/client.d.ts +5 -68
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/schematic/external.d.ts +3 -0
- package/dist/workspace/schematic/external.d.ts.map +1 -0
- package/dist/workspace/schematic/index.d.ts +1 -1
- package/dist/workspace/schematic/index.d.ts.map +1 -1
- package/dist/workspace/schematic/payload.d.ts +71 -0
- package/dist/workspace/schematic/payload.d.ts.map +1 -0
- package/dist/workspace/table/client.d.ts +5 -57
- package/dist/workspace/table/client.d.ts.map +1 -1
- package/dist/workspace/table/external.d.ts +3 -0
- package/dist/workspace/table/external.d.ts.map +1 -0
- package/dist/workspace/table/index.d.ts +1 -1
- package/dist/workspace/table/index.d.ts.map +1 -1
- package/dist/workspace/table/payload.d.ts +60 -0
- package/dist/workspace/table/payload.d.ts.map +1 -0
- package/examples/node/basicReadWrite.js +26 -26
- package/examples/node/liveStream.js +15 -15
- package/examples/node/seriesAndFrames.js +38 -38
- package/examples/node/streamWrite.js +47 -45
- package/package.json +15 -13
- package/src/access/payload.ts +12 -12
- package/src/access/policy/client.ts +13 -12
- package/src/access/policy/external.ts +1 -0
- package/src/access/policy/ontology.ts +17 -0
- package/src/access/policy/payload.ts +7 -19
- package/src/access/policy/policy.spec.ts +16 -16
- package/src/access/policy/retriever.ts +2 -1
- package/src/access/policy/writer.ts +4 -4
- package/src/auth/auth.spec.ts +27 -23
- package/src/auth/auth.ts +7 -11
- package/src/channel/batchRetriever.spec.ts +25 -22
- package/src/channel/client.ts +19 -21
- package/src/channel/payload.ts +16 -20
- package/src/channel/retriever.ts +20 -21
- package/src/channel/writer.ts +11 -13
- package/src/client.ts +6 -16
- package/src/connection/checker.ts +9 -11
- package/src/connection/connection.spec.ts +17 -5
- package/src/control/state.ts +8 -9
- package/src/errors.spec.ts +1 -1
- package/src/errors.ts +8 -0
- package/src/framer/adapter.spec.ts +28 -23
- package/src/framer/adapter.ts +37 -41
- package/src/framer/client.spec.ts +5 -11
- package/src/framer/client.ts +34 -38
- package/src/framer/deleter.ts +5 -6
- package/src/framer/frame.ts +62 -50
- package/src/framer/iterator.ts +11 -16
- package/src/framer/streamer.spec.ts +2 -10
- package/src/framer/streamer.ts +15 -19
- package/src/framer/writer.spec.ts +48 -7
- package/src/framer/writer.ts +39 -31
- package/src/hardware/device/client.ts +64 -39
- package/src/hardware/device/device.spec.ts +49 -33
- package/src/hardware/device/payload.ts +29 -29
- package/src/hardware/rack/client.ts +52 -65
- package/src/hardware/rack/payload.ts +9 -18
- package/src/hardware/rack/rack.spec.ts +12 -0
- package/src/hardware/task/client.ts +160 -131
- package/src/hardware/task/payload.ts +49 -68
- package/src/hardware/task/task.spec.ts +98 -81
- package/src/label/client.ts +12 -15
- package/src/label/payload.ts +3 -9
- package/src/label/retriever.ts +3 -7
- package/src/label/writer.ts +8 -15
- package/src/ontology/client.ts +17 -22
- package/src/ontology/group/client.ts +5 -5
- package/src/ontology/group/group.spec.ts +4 -4
- package/src/ontology/group/group.ts +10 -7
- package/src/ontology/group/payload.ts +11 -35
- package/src/ontology/group/writer.ts +22 -26
- package/src/ontology/ontology.spec.ts +15 -15
- package/src/ontology/payload.ts +67 -43
- package/src/ontology/writer.ts +16 -23
- package/src/ranger/alias.ts +25 -42
- package/src/ranger/client.ts +29 -38
- package/src/ranger/external.ts +1 -1
- package/src/ranger/kv.ts +9 -32
- package/src/ranger/payload.ts +14 -36
- package/src/ranger/ranger.spec.ts +1 -2
- package/src/ranger/writer.ts +8 -26
- package/src/signals/observable.ts +3 -4
- package/src/user/client.ts +8 -4
- package/src/user/payload.ts +5 -9
- package/src/user/retriever.ts +1 -1
- package/src/user/user.spec.ts +17 -15
- package/src/user/writer.ts +3 -10
- package/src/util/decodeJSONString.ts +13 -0
- package/src/util/parseWithoutKeyConversion.ts +19 -0
- package/src/util/retrieve.spec.ts +3 -13
- package/src/util/retrieve.ts +2 -12
- package/src/util/telem.ts +1 -1
- package/src/vite-env.d.ts +1 -0
- package/src/workspace/client.ts +30 -57
- package/src/workspace/external.ts +11 -0
- package/src/workspace/index.ts +1 -1
- package/src/workspace/lineplot/client.ts +22 -36
- package/src/workspace/lineplot/external.ts +11 -0
- package/src/workspace/lineplot/index.ts +1 -1
- package/src/workspace/lineplot/linePlot.spec.ts +1 -2
- package/src/workspace/lineplot/payload.ts +32 -0
- package/src/workspace/log/client.ts +25 -39
- package/src/workspace/log/external.ts +11 -0
- package/src/workspace/log/index.ts +1 -1
- package/src/workspace/log/log.spec.ts +5 -18
- package/src/workspace/log/payload.ts +32 -0
- package/src/workspace/payload.ts +36 -0
- package/src/workspace/schematic/client.ts +30 -56
- package/src/workspace/schematic/external.ts +11 -0
- package/src/workspace/schematic/index.ts +1 -1
- package/src/workspace/schematic/payload.ts +37 -0
- package/src/workspace/schematic/schematic.spec.ts +15 -6
- package/src/workspace/table/client.ts +27 -50
- package/src/workspace/table/external.ts +11 -0
- package/src/workspace/table/index.ts +1 -1
- package/src/workspace/table/payload.ts +36 -0
- package/src/workspace/workspace.spec.ts +1 -2
- package/dist/channel/creator.d.ts +0 -9
- package/dist/channel/creator.d.ts.map +0 -1
- package/src/channel/creator.ts +0 -37
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright 2025 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 { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
import { parseWithoutKeyConversion } from "@/util/parseWithoutKeyConversion";
|
|
14
|
+
|
|
15
|
+
export const keyZ = z.string().uuid();
|
|
16
|
+
export type Key = z.infer<typeof keyZ>;
|
|
17
|
+
export type Params = Key | Key[];
|
|
18
|
+
|
|
19
|
+
export const workspaceZ = z.object({
|
|
20
|
+
key: keyZ,
|
|
21
|
+
name: z.string(),
|
|
22
|
+
layout: unknownRecordZ.or(z.string().transform(parseWithoutKeyConversion)),
|
|
23
|
+
});
|
|
24
|
+
export interface Workspace extends z.infer<typeof workspaceZ> {}
|
|
25
|
+
|
|
26
|
+
export const ONTOLOGY_TYPE = "workspace";
|
|
27
|
+
export type OntologyType = typeof ONTOLOGY_TYPE;
|
|
28
|
+
|
|
29
|
+
export const newZ = workspaceZ
|
|
30
|
+
.partial({ key: true })
|
|
31
|
+
.transform((p) => ({ ...p, layout: JSON.stringify(p.layout) }));
|
|
32
|
+
export interface New extends z.input<typeof newZ> {}
|
|
33
|
+
|
|
34
|
+
export const remoteZ = workspaceZ
|
|
35
|
+
.omit({ layout: true })
|
|
36
|
+
.extend({ layout: z.string().transform(parseWithoutKeyConversion) });
|
|
@@ -9,36 +9,22 @@
|
|
|
9
9
|
|
|
10
10
|
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
12
|
-
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
13
12
|
import { z } from "zod";
|
|
14
13
|
|
|
15
14
|
import { ontology } from "@/ontology";
|
|
16
15
|
import { nullableArrayZ } from "@/util/zod";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export const schematicRemoteZ = z.object({
|
|
30
|
-
key: z.string(),
|
|
31
|
-
name: z.string(),
|
|
32
|
-
snapshot: z.boolean(),
|
|
33
|
-
data: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
export type Schematic = z.infer<typeof schematicZ>;
|
|
37
|
-
|
|
38
|
-
export const ONTOLOGY_TYPE: ontology.ResourceType = "schematic";
|
|
39
|
-
|
|
40
|
-
export const ontologyID = (key: Key): ontology.ID =>
|
|
41
|
-
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
16
|
+
import { type Key as WorkspaceKey, keyZ as workspaceKeyZ } from "@/workspace/payload";
|
|
17
|
+
import {
|
|
18
|
+
type Key,
|
|
19
|
+
keyZ,
|
|
20
|
+
type New,
|
|
21
|
+
newZ,
|
|
22
|
+
ONTOLOGY_TYPE,
|
|
23
|
+
type Params,
|
|
24
|
+
remoteZ,
|
|
25
|
+
type Schematic,
|
|
26
|
+
schematicZ,
|
|
27
|
+
} from "@/workspace/schematic/payload";
|
|
42
28
|
|
|
43
29
|
const RETRIEVE_ENDPOINT = "/workspace/schematic/retrieve";
|
|
44
30
|
const CREATE_ENDPOINT = "/workspace/schematic/create";
|
|
@@ -47,27 +33,15 @@ const SET_DATA_ENDPOINT = "/workspace/schematic/set-data";
|
|
|
47
33
|
const DELETE_ENDPOINT = "/workspace/schematic/delete";
|
|
48
34
|
const COPY_ENDPOINT = "/workspace/schematic/copy";
|
|
49
35
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export type NewSchematic = z.input<typeof newSchematicZ>;
|
|
58
|
-
|
|
59
|
-
const retrieveReqZ = z.object({ keys: z.string().array() });
|
|
60
|
-
const createReqZ = z.object({
|
|
61
|
-
workspace: z.string(),
|
|
62
|
-
schematics: newSchematicZ.array(),
|
|
63
|
-
});
|
|
64
|
-
const renameReqZ = z.object({ key: z.string(), name: z.string() });
|
|
65
|
-
const setDataReqZ = z.object({ key: z.string(), data: z.string() });
|
|
66
|
-
const deleteReqZ = z.object({ keys: z.string().array() });
|
|
67
|
-
const copyReqZ = z.object({ key: z.string(), name: z.string(), snapshot: z.boolean() });
|
|
36
|
+
const retrieveReqZ = z.object({ keys: keyZ.array() });
|
|
37
|
+
const createReqZ = z.object({ workspace: workspaceKeyZ, schematics: newZ.array() });
|
|
38
|
+
const renameReqZ = z.object({ key: keyZ, name: z.string() });
|
|
39
|
+
const setDataReqZ = z.object({ key: keyZ, data: z.string() });
|
|
40
|
+
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
41
|
+
const copyReqZ = z.object({ key: keyZ, name: z.string(), snapshot: z.boolean() });
|
|
68
42
|
|
|
69
|
-
const retrieveResZ = z.object({ schematics: nullableArrayZ(
|
|
70
|
-
const createResZ = z.object({ schematics:
|
|
43
|
+
const retrieveResZ = z.object({ schematics: nullableArrayZ(remoteZ) });
|
|
44
|
+
const createResZ = z.object({ schematics: remoteZ.array() });
|
|
71
45
|
const copyResZ = z.object({ schematic: schematicZ });
|
|
72
46
|
const emptyResZ = z.object({});
|
|
73
47
|
|
|
@@ -78,18 +52,17 @@ export class Client {
|
|
|
78
52
|
this.client = client;
|
|
79
53
|
}
|
|
80
54
|
|
|
81
|
-
async create(workspace:
|
|
82
|
-
async create(workspace:
|
|
55
|
+
async create(workspace: WorkspaceKey, schematic: New): Promise<Schematic>;
|
|
56
|
+
async create(workspace: WorkspaceKey, schematics: New[]): Promise<Schematic[]>;
|
|
83
57
|
async create(
|
|
84
|
-
workspace:
|
|
85
|
-
schematics:
|
|
58
|
+
workspace: WorkspaceKey,
|
|
59
|
+
schematics: New | New[],
|
|
86
60
|
): Promise<Schematic | Schematic[]> {
|
|
87
61
|
const isMany = Array.isArray(schematics);
|
|
88
|
-
const normalized = toArray(schematics);
|
|
89
62
|
const res = await sendRequired(
|
|
90
63
|
this.client,
|
|
91
64
|
CREATE_ENDPOINT,
|
|
92
|
-
{ workspace, schematics:
|
|
65
|
+
{ workspace, schematics: toArray(schematics) },
|
|
93
66
|
createReqZ,
|
|
94
67
|
createResZ,
|
|
95
68
|
);
|
|
@@ -120,11 +93,10 @@ export class Client {
|
|
|
120
93
|
async retrieve(keys: Key[]): Promise<Schematic[]>;
|
|
121
94
|
async retrieve(keys: Params): Promise<Schematic | Schematic[]> {
|
|
122
95
|
const isMany = Array.isArray(keys);
|
|
123
|
-
const normalized = toArray(keys);
|
|
124
96
|
const res = await sendRequired(
|
|
125
97
|
this.client,
|
|
126
98
|
RETRIEVE_ENDPOINT,
|
|
127
|
-
{ keys:
|
|
99
|
+
{ keys: toArray(keys) },
|
|
128
100
|
retrieveReqZ,
|
|
129
101
|
retrieveResZ,
|
|
130
102
|
);
|
|
@@ -134,11 +106,10 @@ export class Client {
|
|
|
134
106
|
async delete(key: Key): Promise<void>;
|
|
135
107
|
async delete(keys: Key[]): Promise<void>;
|
|
136
108
|
async delete(keys: Params): Promise<void> {
|
|
137
|
-
const normalized = toArray(keys);
|
|
138
109
|
await sendRequired(
|
|
139
110
|
this.client,
|
|
140
111
|
DELETE_ENDPOINT,
|
|
141
|
-
{ keys:
|
|
112
|
+
{ keys: toArray(keys) },
|
|
142
113
|
deleteReqZ,
|
|
143
114
|
emptyResZ,
|
|
144
115
|
);
|
|
@@ -155,3 +126,6 @@ export class Client {
|
|
|
155
126
|
return res.schematic;
|
|
156
127
|
}
|
|
157
128
|
}
|
|
129
|
+
|
|
130
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
131
|
+
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2025 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 "@/workspace/schematic/client";
|
|
11
|
+
export * from "@/workspace/schematic/payload";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright 2025 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 { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
import { parseWithoutKeyConversion } from "@/util/parseWithoutKeyConversion";
|
|
14
|
+
|
|
15
|
+
export const keyZ = z.string().uuid();
|
|
16
|
+
export type Key = z.infer<typeof keyZ>;
|
|
17
|
+
export type Params = Key | Key[];
|
|
18
|
+
|
|
19
|
+
export const schematicZ = z.object({
|
|
20
|
+
key: keyZ,
|
|
21
|
+
name: z.string(),
|
|
22
|
+
data: unknownRecordZ.or(z.string().transform(parseWithoutKeyConversion)),
|
|
23
|
+
snapshot: z.boolean(),
|
|
24
|
+
});
|
|
25
|
+
export interface Schematic extends z.infer<typeof schematicZ> {}
|
|
26
|
+
|
|
27
|
+
export const newZ = schematicZ
|
|
28
|
+
.partial({ key: true, snapshot: true })
|
|
29
|
+
.transform((p) => ({ ...p, data: JSON.stringify(p.data) }));
|
|
30
|
+
export interface New extends z.input<typeof newZ> {}
|
|
31
|
+
|
|
32
|
+
export const remoteZ = schematicZ.extend({
|
|
33
|
+
data: z.string().transform(parseWithoutKeyConversion),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const ONTOLOGY_TYPE = "schematic";
|
|
37
|
+
export type OntologyType = typeof ONTOLOGY_TYPE;
|
|
@@ -7,15 +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 {
|
|
10
|
+
import { NIL as ZERO_UUID } from "uuid";
|
|
11
|
+
import { describe, expect, it, test } from "vitest";
|
|
11
12
|
|
|
12
13
|
import { ValidationError } from "@/errors";
|
|
13
14
|
import { newClient } from "@/setupspecs";
|
|
14
15
|
|
|
15
16
|
const client = newClient();
|
|
16
17
|
|
|
17
|
-
const ZERO_UUID = "00000000-0000-0000-0000-000000000000";
|
|
18
|
-
|
|
19
18
|
describe("Schematic", () => {
|
|
20
19
|
describe("create", () => {
|
|
21
20
|
test("create one", async () => {
|
|
@@ -73,7 +72,9 @@ describe("Schematic", () => {
|
|
|
73
72
|
data: { one: 1 },
|
|
74
73
|
});
|
|
75
74
|
await client.workspaces.schematic.delete(schematic.key);
|
|
76
|
-
await expect(
|
|
75
|
+
await expect(
|
|
76
|
+
client.workspaces.schematic.retrieve(schematic.key),
|
|
77
|
+
).rejects.toThrow();
|
|
77
78
|
});
|
|
78
79
|
});
|
|
79
80
|
describe("copy", () => {
|
|
@@ -86,7 +87,11 @@ describe("Schematic", () => {
|
|
|
86
87
|
name: "Schematic",
|
|
87
88
|
data: { one: 1 },
|
|
88
89
|
});
|
|
89
|
-
const schematic2 = await client.workspaces.schematic.copy(
|
|
90
|
+
const schematic2 = await client.workspaces.schematic.copy(
|
|
91
|
+
schematic.key,
|
|
92
|
+
"Schematic2",
|
|
93
|
+
false,
|
|
94
|
+
);
|
|
90
95
|
expect(schematic2.name).toEqual("Schematic2");
|
|
91
96
|
expect(schematic2.key).not.toEqual(ZERO_UUID);
|
|
92
97
|
expect(schematic2.data.one).toEqual(1);
|
|
@@ -101,7 +106,11 @@ describe("Schematic", () => {
|
|
|
101
106
|
name: "Schematic",
|
|
102
107
|
data: { one: 1 },
|
|
103
108
|
});
|
|
104
|
-
const schematic2 = await client.workspaces.schematic.copy(
|
|
109
|
+
const schematic2 = await client.workspaces.schematic.copy(
|
|
110
|
+
schematic.key,
|
|
111
|
+
"Schematic2",
|
|
112
|
+
true,
|
|
113
|
+
);
|
|
105
114
|
await expect(
|
|
106
115
|
client.workspaces.schematic.setData(schematic2.key, { two: 2 }),
|
|
107
116
|
).rejects.toThrow(ValidationError);
|
|
@@ -9,27 +9,20 @@
|
|
|
9
9
|
|
|
10
10
|
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
11
|
import { toArray, type UnknownRecord } from "@synnaxlabs/x";
|
|
12
|
-
import { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
13
12
|
import { z } from "zod";
|
|
14
13
|
|
|
15
14
|
import { ontology } from "@/ontology";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export type Table = z.infer<typeof tableZ>;
|
|
28
|
-
|
|
29
|
-
export const ONTOLOGY_TYPE: ontology.ResourceType = "table";
|
|
30
|
-
|
|
31
|
-
export const ontologyID = (key: Key): ontology.ID =>
|
|
32
|
-
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
15
|
+
import { type Key as WorkspaceKey, keyZ as workspaceKeyZ } from "@/workspace/payload";
|
|
16
|
+
import {
|
|
17
|
+
type Key,
|
|
18
|
+
keyZ,
|
|
19
|
+
type New,
|
|
20
|
+
newZ,
|
|
21
|
+
ONTOLOGY_TYPE,
|
|
22
|
+
type Params,
|
|
23
|
+
remoteZ,
|
|
24
|
+
type Table,
|
|
25
|
+
} from "@/workspace/table/payload";
|
|
33
26
|
|
|
34
27
|
const RETRIEVE_ENDPOINT = "/workspace/table/retrieve";
|
|
35
28
|
const CREATE_ENDPOINT = "/workspace/table/create";
|
|
@@ -37,27 +30,14 @@ const RENAME_ENDPOINT = "/workspace/table/rename";
|
|
|
37
30
|
const SET_DATA_ENDPOINT = "/workspace/table/set-data";
|
|
38
31
|
const DELETE_ENDPOINT = "/workspace/table/delete";
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
33
|
+
const retrieveReqZ = z.object({ keys: keyZ.array() });
|
|
34
|
+
const createReqZ = z.object({ workspace: workspaceKeyZ, tables: newZ.array() });
|
|
35
|
+
const renameReqZ = z.object({ key: keyZ, name: z.string() });
|
|
36
|
+
const setDataReqZ = z.object({ key: keyZ, data: z.string() });
|
|
37
|
+
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
44
38
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export const tableRemoteZ = z.object({
|
|
48
|
-
key: z.string(),
|
|
49
|
-
name: z.string(),
|
|
50
|
-
data: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const retrieveReqZ = z.object({ keys: z.string().array() });
|
|
54
|
-
const createReqZ = z.object({ workspace: z.string(), tables: newTableZ.array() });
|
|
55
|
-
const renameReqZ = z.object({ key: z.string(), name: z.string() });
|
|
56
|
-
const setDataReqZ = z.object({ key: z.string(), data: z.string() });
|
|
57
|
-
const deleteReqZ = z.object({ keys: z.string().array() });
|
|
58
|
-
|
|
59
|
-
const retrieveResZ = z.object({ tables: tableRemoteZ.array() });
|
|
60
|
-
const createResZ = z.object({ tables: tableRemoteZ.array() });
|
|
39
|
+
const retrieveResZ = z.object({ tables: remoteZ.array() });
|
|
40
|
+
const createResZ = z.object({ tables: remoteZ.array() });
|
|
61
41
|
const emptyResZ = z.object({});
|
|
62
42
|
|
|
63
43
|
export class Client {
|
|
@@ -67,18 +47,14 @@ export class Client {
|
|
|
67
47
|
this.client = client;
|
|
68
48
|
}
|
|
69
49
|
|
|
70
|
-
async create(workspace:
|
|
71
|
-
async create(workspace:
|
|
72
|
-
async create(
|
|
73
|
-
workspace: string,
|
|
74
|
-
tables: NewTable | NewTable[],
|
|
75
|
-
): Promise<Table | Table[]> {
|
|
50
|
+
async create(workspace: WorkspaceKey, table: New): Promise<Table>;
|
|
51
|
+
async create(workspace: WorkspaceKey, tables: New[]): Promise<Table[]>;
|
|
52
|
+
async create(workspace: WorkspaceKey, tables: New | New[]): Promise<Table | Table[]> {
|
|
76
53
|
const isMany = Array.isArray(tables);
|
|
77
|
-
const normalized = toArray(tables);
|
|
78
54
|
const res = await sendRequired(
|
|
79
55
|
this.client,
|
|
80
56
|
CREATE_ENDPOINT,
|
|
81
|
-
{ workspace, tables:
|
|
57
|
+
{ workspace, tables: toArray(tables) },
|
|
82
58
|
createReqZ,
|
|
83
59
|
createResZ,
|
|
84
60
|
);
|
|
@@ -109,11 +85,10 @@ export class Client {
|
|
|
109
85
|
async retrieve(keys: Key[]): Promise<Table[]>;
|
|
110
86
|
async retrieve(keys: Params): Promise<Table | Table[]> {
|
|
111
87
|
const isMany = Array.isArray(keys);
|
|
112
|
-
const normalized = toArray(keys);
|
|
113
88
|
const res = await sendRequired(
|
|
114
89
|
this.client,
|
|
115
90
|
RETRIEVE_ENDPOINT,
|
|
116
|
-
{ keys:
|
|
91
|
+
{ keys: toArray(keys) },
|
|
117
92
|
retrieveReqZ,
|
|
118
93
|
retrieveResZ,
|
|
119
94
|
);
|
|
@@ -123,13 +98,15 @@ export class Client {
|
|
|
123
98
|
async delete(key: Key): Promise<void>;
|
|
124
99
|
async delete(keys: Key[]): Promise<void>;
|
|
125
100
|
async delete(keys: Params): Promise<void> {
|
|
126
|
-
const normalized = toArray(keys);
|
|
127
101
|
await sendRequired(
|
|
128
102
|
this.client,
|
|
129
103
|
DELETE_ENDPOINT,
|
|
130
|
-
{ keys:
|
|
104
|
+
{ keys: toArray(keys) },
|
|
131
105
|
deleteReqZ,
|
|
132
106
|
emptyResZ,
|
|
133
107
|
);
|
|
134
108
|
}
|
|
135
109
|
}
|
|
110
|
+
|
|
111
|
+
export const ontologyID = (key: Key): ontology.ID =>
|
|
112
|
+
new ontology.ID({ type: ONTOLOGY_TYPE, key });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2025 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 "@/workspace/table/client";
|
|
11
|
+
export * from "@/workspace/table/payload";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright 2025 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 { unknownRecordZ } from "@synnaxlabs/x/record";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
|
|
13
|
+
import { parseWithoutKeyConversion } from "@/util/parseWithoutKeyConversion";
|
|
14
|
+
|
|
15
|
+
export const keyZ = z.string().uuid();
|
|
16
|
+
export type Key = z.infer<typeof keyZ>;
|
|
17
|
+
export type Params = Key | Key[];
|
|
18
|
+
|
|
19
|
+
export const tableZ = z.object({
|
|
20
|
+
key: keyZ,
|
|
21
|
+
name: z.string(),
|
|
22
|
+
data: unknownRecordZ.or(z.string().transform(parseWithoutKeyConversion)),
|
|
23
|
+
});
|
|
24
|
+
export interface Table extends z.infer<typeof tableZ> {}
|
|
25
|
+
|
|
26
|
+
export const newZ = tableZ
|
|
27
|
+
.partial({ key: true })
|
|
28
|
+
.transform((p) => ({ ...p, data: JSON.stringify(p.data) }));
|
|
29
|
+
export interface New extends z.input<typeof newZ> {}
|
|
30
|
+
|
|
31
|
+
export const remoteZ = tableZ.extend({
|
|
32
|
+
data: z.string().transform(parseWithoutKeyConversion),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const ONTOLOGY_TYPE = "table";
|
|
36
|
+
export type OntologyType = typeof ONTOLOGY_TYPE;
|
|
@@ -7,14 +7,13 @@
|
|
|
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 { NIL as ZERO_UUID } from "uuid";
|
|
10
11
|
import { describe, expect, test } from "vitest";
|
|
11
12
|
|
|
12
13
|
import { newClient } from "@/setupspecs";
|
|
13
14
|
|
|
14
15
|
const client = newClient();
|
|
15
16
|
|
|
16
|
-
const ZERO_UUID = "00000000-0000-0000-0000-000000000000";
|
|
17
|
-
|
|
18
17
|
describe("Workspace", () => {
|
|
19
18
|
describe("create", () => {
|
|
20
19
|
test("create one", async () => {
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { UnaryClient } from '@synnaxlabs/freighter';
|
|
2
|
-
import { NewPayload, Payload } from './payload';
|
|
3
|
-
export declare class Creator {
|
|
4
|
-
private static readonly ENDPOINT;
|
|
5
|
-
private readonly client;
|
|
6
|
-
constructor(client: UnaryClient);
|
|
7
|
-
create(channels: NewPayload[]): Promise<Payload[]>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=creator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"creator.d.ts","sourceRoot":"","sources":["../../src/channel/creator.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,KAAK,UAAU,EAAa,KAAK,OAAO,EAAW,MAAM,mBAAmB,CAAC;AAMtF,qBAAa,OAAO;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAIzB,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAUzD"}
|
package/src/channel/creator.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 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 type { UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
|
|
13
|
-
import { type NewPayload,newPayload, type Payload, payload } from "@/channel/payload";
|
|
14
|
-
|
|
15
|
-
const reqZ = z.object({ channels: newPayload.array() });
|
|
16
|
-
|
|
17
|
-
const resZ = z.object({ channels: payload.array() });
|
|
18
|
-
|
|
19
|
-
export class Creator {
|
|
20
|
-
private static readonly ENDPOINT = "/channel/create";
|
|
21
|
-
private readonly client: UnaryClient;
|
|
22
|
-
|
|
23
|
-
constructor(client: UnaryClient) {
|
|
24
|
-
this.client = client;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async create(channels: NewPayload[]): Promise<Payload[]> {
|
|
28
|
-
const [res, err] = await this.client.send<typeof reqZ, typeof resZ>(
|
|
29
|
-
Creator.ENDPOINT,
|
|
30
|
-
{ channels },
|
|
31
|
-
reqZ,
|
|
32
|
-
resZ,
|
|
33
|
-
);
|
|
34
|
-
if (err != null) throw err;
|
|
35
|
-
return res.channels;
|
|
36
|
-
}
|
|
37
|
-
}
|