@synnaxlabs/client 0.43.1 → 0.44.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 +7 -7
- package/dist/access/payload.d.ts +1 -1
- package/dist/access/payload.d.ts.map +1 -1
- package/dist/access/policy/client.d.ts +263 -6
- package/dist/access/policy/client.d.ts.map +1 -1
- package/dist/access/policy/external.d.ts +0 -1
- package/dist/access/policy/external.d.ts.map +1 -1
- package/dist/access/policy/payload.d.ts +105 -93
- package/dist/access/policy/payload.d.ts.map +1 -1
- package/dist/auth/auth.d.ts +1 -1
- package/dist/auth/auth.d.ts.map +1 -1
- package/dist/channel/client.d.ts +12 -13
- package/dist/channel/client.d.ts.map +1 -1
- package/dist/channel/payload.d.ts +77 -19
- package/dist/channel/payload.d.ts.map +1 -1
- package/dist/channel/retriever.d.ts +9 -16
- package/dist/channel/retriever.d.ts.map +1 -1
- package/dist/channel/writer.d.ts +1 -1
- package/dist/channel/writer.d.ts.map +1 -1
- package/dist/client.cjs +27 -135
- package/dist/client.d.ts +3 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8612 -28957
- package/dist/connection/checker.d.ts +1 -1
- package/dist/connection/checker.d.ts.map +1 -1
- package/dist/control/client.d.ts +1 -0
- package/dist/control/client.d.ts.map +1 -1
- package/dist/control/state.d.ts +6 -6
- package/dist/control/state.d.ts.map +1 -1
- package/dist/errors.d.ts +18 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/framer/adapter.d.ts +3 -3
- package/dist/framer/adapter.d.ts.map +1 -1
- package/dist/framer/client.d.ts +4 -13
- package/dist/framer/client.d.ts.map +1 -1
- package/dist/framer/codec.d.ts +1 -1
- package/dist/framer/codec.d.ts.map +1 -1
- package/dist/framer/deleter.d.ts +5 -5
- package/dist/framer/deleter.d.ts.map +1 -1
- package/dist/framer/frame.d.ts +5 -7
- package/dist/framer/frame.d.ts.map +1 -1
- package/dist/framer/streamProxy.d.ts +1 -1
- package/dist/framer/streamProxy.d.ts.map +1 -1
- package/dist/framer/streamer.d.ts +139 -20
- package/dist/framer/streamer.d.ts.map +1 -1
- package/dist/framer/writer.d.ts +222 -33
- package/dist/framer/writer.d.ts.map +1 -1
- package/dist/hardware/device/client.d.ts +49 -28
- package/dist/hardware/device/client.d.ts.map +1 -1
- package/dist/hardware/device/payload.d.ts +126 -46
- package/dist/hardware/device/payload.d.ts.map +1 -1
- package/dist/hardware/rack/client.d.ts +78 -22
- package/dist/hardware/rack/client.d.ts.map +1 -1
- package/dist/hardware/rack/payload.d.ts +99 -56
- package/dist/hardware/rack/payload.d.ts.map +1 -1
- package/dist/hardware/task/client.d.ts +100 -41
- package/dist/hardware/task/client.d.ts.map +1 -1
- package/dist/hardware/task/payload.d.ts +83 -61
- package/dist/hardware/task/payload.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/label/client.d.ts +138 -20
- package/dist/label/client.d.ts.map +1 -1
- package/dist/label/external.d.ts +0 -2
- package/dist/label/external.d.ts.map +1 -1
- package/dist/label/payload.d.ts +4 -5
- package/dist/label/payload.d.ts.map +1 -1
- package/dist/ontology/client.d.ts +45 -135
- package/dist/ontology/client.d.ts.map +1 -1
- package/dist/ontology/group/group.d.ts +3 -3
- package/dist/ontology/group/group.d.ts.map +1 -1
- package/dist/ontology/group/payload.d.ts +3 -27
- package/dist/ontology/group/payload.d.ts.map +1 -1
- package/dist/ontology/payload.d.ts +113 -243
- package/dist/ontology/payload.d.ts.map +1 -1
- package/dist/ontology/writer.d.ts +4 -4
- package/dist/ontology/writer.d.ts.map +1 -1
- package/dist/ranger/alias.d.ts +11 -5
- package/dist/ranger/alias.d.ts.map +1 -1
- package/dist/ranger/client.d.ts +87 -30
- 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 +10 -12
- package/dist/ranger/kv.d.ts.map +1 -1
- package/dist/ranger/payload.d.ts +23 -44
- package/dist/ranger/payload.d.ts.map +1 -1
- package/dist/ranger/writer.d.ts +22 -19
- package/dist/ranger/writer.d.ts.map +1 -1
- package/dist/testutil/client.d.ts +4 -0
- package/dist/testutil/client.d.ts.map +1 -0
- package/dist/user/client.d.ts +59 -6
- package/dist/user/client.d.ts.map +1 -1
- package/dist/user/payload.d.ts +4 -6
- package/dist/user/payload.d.ts.map +1 -1
- package/dist/user/retriever.d.ts +2 -2
- package/dist/user/retriever.d.ts.map +1 -1
- package/dist/util/decodeJSONString.d.ts +2 -2
- package/dist/util/decodeJSONString.d.ts.map +1 -1
- package/dist/util/parseWithoutKeyConversion.d.ts +2 -2
- package/dist/util/parseWithoutKeyConversion.d.ts.map +1 -1
- package/dist/util/retrieve.d.ts +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 +17 -6
- package/dist/workspace/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/client.d.ts +2 -2
- package/dist/workspace/lineplot/client.d.ts.map +1 -1
- package/dist/workspace/lineplot/payload.d.ts +8 -9
- package/dist/workspace/lineplot/payload.d.ts.map +1 -1
- package/dist/workspace/log/client.d.ts +2 -2
- package/dist/workspace/log/client.d.ts.map +1 -1
- package/dist/workspace/log/payload.d.ts +8 -9
- package/dist/workspace/log/payload.d.ts.map +1 -1
- package/dist/workspace/payload.d.ts +10 -11
- package/dist/workspace/payload.d.ts.map +1 -1
- package/dist/workspace/schematic/client.d.ts +2 -2
- package/dist/workspace/schematic/client.d.ts.map +1 -1
- package/dist/workspace/schematic/payload.d.ts +10 -11
- package/dist/workspace/schematic/payload.d.ts.map +1 -1
- package/dist/workspace/table/client.d.ts +2 -2
- package/dist/workspace/table/client.d.ts.map +1 -1
- package/dist/workspace/table/payload.d.ts +10 -11
- package/dist/workspace/table/payload.d.ts.map +1 -1
- package/examples/node/package-lock.json +47 -39
- package/examples/node/package.json +2 -1
- package/examples/node/streamWrite.js +5 -11
- package/package.json +14 -13
- package/src/access/payload.ts +1 -1
- package/src/access/policy/client.ts +87 -32
- package/src/access/policy/external.ts +0 -1
- package/src/access/policy/payload.ts +4 -4
- package/src/access/policy/policy.spec.ts +86 -83
- package/src/auth/auth.spec.ts +29 -18
- package/src/auth/auth.ts +1 -1
- package/src/channel/batchRetriever.spec.ts +4 -9
- package/src/channel/channel.spec.ts +24 -6
- package/src/channel/client.ts +31 -46
- package/src/channel/payload.ts +13 -14
- package/src/channel/retriever.ts +26 -41
- package/src/channel/writer.ts +3 -3
- package/src/client.ts +4 -4
- package/src/connection/checker.ts +1 -1
- package/src/connection/connection.spec.ts +31 -23
- package/src/control/client.ts +2 -2
- package/src/control/state.spec.ts +3 -3
- package/src/control/state.ts +1 -1
- package/src/errors.spec.ts +9 -5
- package/src/errors.ts +28 -15
- package/src/framer/adapter.spec.ts +118 -9
- package/src/framer/adapter.ts +24 -11
- package/src/framer/client.spec.ts +125 -2
- package/src/framer/client.ts +41 -47
- package/src/framer/codec.ts +1 -1
- package/src/framer/deleter.spec.ts +2 -2
- package/src/framer/deleter.ts +1 -1
- package/src/framer/frame.ts +1 -4
- package/src/framer/iterator.spec.ts +8 -8
- package/src/framer/iterator.ts +1 -1
- package/src/framer/streamProxy.ts +1 -1
- package/src/framer/streamer.spec.ts +185 -36
- package/src/framer/streamer.ts +28 -36
- package/src/framer/writer.spec.ts +6 -6
- package/src/framer/writer.ts +97 -111
- package/src/hardware/device/client.ts +45 -131
- package/src/hardware/device/device.spec.ts +163 -52
- package/src/hardware/device/payload.ts +10 -21
- package/src/hardware/rack/client.ts +87 -105
- package/src/hardware/rack/payload.ts +4 -13
- package/src/hardware/rack/rack.spec.ts +28 -35
- package/src/hardware/task/client.ts +335 -291
- package/src/hardware/task/payload.ts +86 -62
- package/src/hardware/task/task.spec.ts +208 -32
- package/src/index.ts +2 -1
- package/src/label/client.ts +100 -95
- package/src/label/external.ts +0 -2
- package/src/label/label.spec.ts +8 -6
- package/src/label/payload.ts +3 -4
- package/src/ontology/client.ts +41 -324
- package/src/ontology/group/group.spec.ts +2 -2
- package/src/ontology/group/group.ts +4 -5
- package/src/ontology/group/payload.ts +2 -25
- package/src/ontology/group/writer.ts +1 -1
- package/src/ontology/ontology.spec.ts +355 -41
- package/src/ontology/payload.ts +74 -112
- package/src/ontology/writer.ts +8 -17
- package/src/ranger/alias.ts +19 -37
- package/src/ranger/client.ts +118 -150
- package/src/ranger/external.ts +9 -1
- package/src/ranger/kv.ts +6 -27
- package/src/ranger/payload.ts +21 -37
- package/src/ranger/ranger.spec.ts +37 -56
- package/src/ranger/writer.ts +1 -1
- package/src/{signals/index.ts → testutil/client.ts} +11 -1
- package/src/user/client.ts +122 -47
- package/src/user/payload.ts +2 -5
- package/src/user/retriever.ts +1 -1
- package/src/user/user.spec.ts +31 -31
- package/src/user/writer.ts +1 -1
- package/src/util/decodeJSONString.ts +3 -3
- package/src/util/parseWithoutKeyConversion.ts +2 -2
- package/src/util/retrieve.ts +1 -1
- package/src/util/zod.ts +1 -1
- package/src/workspace/client.ts +20 -36
- package/src/workspace/lineplot/client.ts +5 -7
- package/src/workspace/lineplot/lineplot.spec.ts +2 -2
- package/src/workspace/lineplot/payload.ts +4 -7
- package/src/workspace/log/client.ts +5 -7
- package/src/workspace/log/log.spec.ts +2 -2
- package/src/workspace/log/payload.ts +4 -7
- package/src/workspace/payload.ts +4 -7
- package/src/workspace/schematic/client.ts +5 -7
- package/src/workspace/schematic/payload.ts +4 -7
- package/src/workspace/schematic/schematic.spec.ts +2 -2
- package/src/workspace/table/client.ts +5 -7
- package/src/workspace/table/payload.ts +4 -7
- package/src/workspace/table/table.spec.ts +2 -2
- package/src/workspace/workspace.spec.ts +2 -2
- package/dist/access/policy/ontology.d.ts +0 -5
- package/dist/access/policy/ontology.d.ts.map +0 -1
- package/dist/access/policy/retriever.d.ts +0 -40
- package/dist/access/policy/retriever.d.ts.map +0 -1
- package/dist/access/policy/writer.d.ts +0 -9
- package/dist/access/policy/writer.d.ts.map +0 -1
- package/dist/label/retriever.d.ts +0 -14
- package/dist/label/retriever.d.ts.map +0 -1
- package/dist/label/writer.d.ts +0 -54
- package/dist/label/writer.d.ts.map +0 -1
- package/dist/setupspecs.d.ts +0 -5
- package/dist/setupspecs.d.ts.map +0 -1
- package/dist/signals/external.d.ts +0 -2
- package/dist/signals/external.d.ts.map +0 -1
- package/dist/signals/index.d.ts +0 -2
- package/dist/signals/index.d.ts.map +0 -1
- package/dist/signals/observable.d.ts +0 -12
- package/dist/signals/observable.d.ts.map +0 -1
- package/src/access/policy/ontology.ts +0 -17
- package/src/access/policy/retriever.ts +0 -44
- package/src/access/policy/writer.ts +0 -65
- package/src/label/retriever.ts +0 -63
- package/src/label/writer.ts +0 -95
- package/src/setupspecs.ts +0 -27
- package/src/signals/external.ts +0 -10
- package/src/signals/observable.ts +0 -42
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/signals/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { change } from '@synnaxlabs/x/change';
|
|
2
|
-
import { observe } from '@synnaxlabs/x/observe';
|
|
3
|
-
import { Series } from '@synnaxlabs/x/telem';
|
|
4
|
-
import { channel } from '../channel';
|
|
5
|
-
import { framer } from '../framer';
|
|
6
|
-
export interface Decoder<K, V> {
|
|
7
|
-
(variant: change.Variant, data: Series): Array<change.Change<K, V>>;
|
|
8
|
-
}
|
|
9
|
-
export interface Observable<K, V> extends observe.ObservableAsyncCloseable<Array<change.Change<K, V>>> {
|
|
10
|
-
}
|
|
11
|
-
export declare const openObservable: <K, V>(client: framer.Client, setChannel: channel.Key | channel.Name, deleteChannel: channel.Key | channel.Name, codec: Decoder<K, V>) => Promise<Observable<K, V>>;
|
|
12
|
-
//# sourceMappingURL=observable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observable.d.ts","sourceRoot":"","sources":["../../src/signals/observable.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,WAAW,OAAO,CAAC,CAAC,EAAE,CAAC;IAC3B,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACrE;AAED,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,CAAC,CAC9B,SAAQ,OAAO,CAAC,wBAAwB,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAAG;AAEzE,eAAO,MAAM,cAAc,GAAU,CAAC,EAAE,CAAC,EACvC,QAAQ,MAAM,CAAC,MAAM,EACrB,YAAY,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,EACtC,eAAe,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,IAAI,EACzC,OAAO,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,KACnB,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAa1B,CAAC"}
|
|
@@ -1,17 +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
|
-
// This needs to be a separate file because these types are imported by the ontology
|
|
11
|
-
// module, but the policy module need to import the ID schema from the ontology module.
|
|
12
|
-
|
|
13
|
-
export const ONTOLOGY_TYPE = "policy";
|
|
14
|
-
export type OntologyType = typeof ONTOLOGY_TYPE;
|
|
15
|
-
|
|
16
|
-
export const ALLOW_ALL_ONTOLOGY_TYPE = "allow_all";
|
|
17
|
-
export type AllowAllOntologyType = typeof ALLOW_ALL_ONTOLOGY_TYPE;
|
|
@@ -1,44 +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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { z } from "zod/v4";
|
|
12
|
-
|
|
13
|
-
import { keyZ, type Policy, policyZ } from "@/access/policy/payload";
|
|
14
|
-
import { ontology } from "@/ontology";
|
|
15
|
-
import { nullableArrayZ } from "@/util/zod";
|
|
16
|
-
|
|
17
|
-
const reqZ = z.object({
|
|
18
|
-
keys: keyZ.array().optional(),
|
|
19
|
-
subjects: ontology.idZ.array().optional(),
|
|
20
|
-
});
|
|
21
|
-
interface Request extends z.infer<typeof reqZ> {}
|
|
22
|
-
|
|
23
|
-
const resZ = z.object({ policies: nullableArrayZ(policyZ) });
|
|
24
|
-
|
|
25
|
-
const ENDPOINT = "/access/policy/retrieve";
|
|
26
|
-
|
|
27
|
-
export class Retriever {
|
|
28
|
-
private readonly client: UnaryClient;
|
|
29
|
-
|
|
30
|
-
constructor(client: UnaryClient) {
|
|
31
|
-
this.client = client;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async retrieve(req: Request): Promise<Policy[]> {
|
|
35
|
-
const res = await sendRequired<typeof reqZ, typeof resZ>(
|
|
36
|
-
this.client,
|
|
37
|
-
ENDPOINT,
|
|
38
|
-
req,
|
|
39
|
-
reqZ,
|
|
40
|
-
resZ,
|
|
41
|
-
);
|
|
42
|
-
return res.policies;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,65 +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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { array } from "@synnaxlabs/x";
|
|
12
|
-
import { z } from "zod/v4";
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
type Key,
|
|
16
|
-
keyZ,
|
|
17
|
-
type New,
|
|
18
|
-
newZ,
|
|
19
|
-
type Policy,
|
|
20
|
-
policyZ,
|
|
21
|
-
} from "@/access/policy/payload";
|
|
22
|
-
|
|
23
|
-
const createReqZ = z.object({ policies: policyZ.partial({ key: true }).array() });
|
|
24
|
-
const createResZ = z.object({ policies: policyZ.array() });
|
|
25
|
-
|
|
26
|
-
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
27
|
-
const deleteResZ = z.object({});
|
|
28
|
-
|
|
29
|
-
const CREATE_ENDPOINT = "/access/policy/create";
|
|
30
|
-
const DELETE_ENDPOINT = "/access/policy/delete";
|
|
31
|
-
|
|
32
|
-
export class Writer {
|
|
33
|
-
private readonly client: UnaryClient;
|
|
34
|
-
|
|
35
|
-
constructor(client: UnaryClient) {
|
|
36
|
-
this.client = client;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async create(policies: New | New[]): Promise<Policy[]> {
|
|
40
|
-
const parsedPolicies = newZ.array().parse(array.toArray(policies));
|
|
41
|
-
const req = parsedPolicies.map((policy) => ({
|
|
42
|
-
objects: array.toArray(policy.objects),
|
|
43
|
-
actions: array.toArray(policy.actions),
|
|
44
|
-
subjects: array.toArray(policy.subjects),
|
|
45
|
-
}));
|
|
46
|
-
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
47
|
-
this.client,
|
|
48
|
-
CREATE_ENDPOINT,
|
|
49
|
-
{ policies: req },
|
|
50
|
-
createReqZ,
|
|
51
|
-
createResZ,
|
|
52
|
-
);
|
|
53
|
-
return res.policies;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
async delete(keys: Key | Key[]): Promise<void> {
|
|
57
|
-
await sendRequired<typeof deleteReqZ, typeof deleteResZ>(
|
|
58
|
-
this.client,
|
|
59
|
-
DELETE_ENDPOINT,
|
|
60
|
-
{ keys: array.toArray(keys) },
|
|
61
|
-
deleteReqZ,
|
|
62
|
-
deleteResZ,
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}
|
package/src/label/retriever.ts
DELETED
|
@@ -1,63 +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 { array } from "@synnaxlabs/x/array";
|
|
12
|
-
import { z } from "zod/v4";
|
|
13
|
-
|
|
14
|
-
import { keyZ, type Label, labelZ, type Params } from "@/label/payload";
|
|
15
|
-
import { ontology } from "@/ontology";
|
|
16
|
-
import { nullableArrayZ } from "@/util/zod";
|
|
17
|
-
|
|
18
|
-
const reqZ = z.object({
|
|
19
|
-
keys: keyZ.array().optional(),
|
|
20
|
-
for: ontology.idZ.optional(),
|
|
21
|
-
search: z.string().optional(),
|
|
22
|
-
offset: z.number().optional(),
|
|
23
|
-
limit: z.number().optional(),
|
|
24
|
-
});
|
|
25
|
-
interface Request extends z.infer<typeof reqZ> {}
|
|
26
|
-
|
|
27
|
-
const resZ = z.object({ labels: nullableArrayZ(labelZ) });
|
|
28
|
-
|
|
29
|
-
export class Retriever {
|
|
30
|
-
private static readonly ENDPOINT = "/label/retrieve";
|
|
31
|
-
private readonly client: UnaryClient;
|
|
32
|
-
|
|
33
|
-
constructor(client: UnaryClient) {
|
|
34
|
-
this.client = client;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async retrieve(labels: Params): Promise<Label[]> {
|
|
38
|
-
return await this.execute({ keys: array.toArray(labels) });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async retrieveFor(id: ontology.ID): Promise<Label[]> {
|
|
42
|
-
return await this.execute({ for: id });
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async search(term: string): Promise<Label[]> {
|
|
46
|
-
return await this.execute({ search: term });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async page(offset: number, limit: number): Promise<Label[]> {
|
|
50
|
-
return await this.execute({ offset, limit });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private async execute(req: Request): Promise<Label[]> {
|
|
54
|
-
const [res, err] = await this.client.send<typeof reqZ, typeof resZ>(
|
|
55
|
-
Retriever.ENDPOINT,
|
|
56
|
-
req,
|
|
57
|
-
reqZ,
|
|
58
|
-
resZ,
|
|
59
|
-
);
|
|
60
|
-
if (err != null) throw err;
|
|
61
|
-
return res.labels;
|
|
62
|
-
}
|
|
63
|
-
}
|
package/src/label/writer.ts
DELETED
|
@@ -1,95 +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 { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
|
|
11
|
-
import { array } from "@synnaxlabs/x/array";
|
|
12
|
-
import { z } from "zod/v4";
|
|
13
|
-
|
|
14
|
-
import { type Key, keyZ, type Label, labelZ } from "@/label/payload";
|
|
15
|
-
import { ontology } from "@/ontology";
|
|
16
|
-
|
|
17
|
-
export const newZ = labelZ.extend({ key: keyZ.optional() });
|
|
18
|
-
export interface New extends z.infer<typeof newZ> {}
|
|
19
|
-
|
|
20
|
-
const createReqZ = z.object({ labels: newZ.array() });
|
|
21
|
-
|
|
22
|
-
const createResZ = z.object({ labels: labelZ.array() });
|
|
23
|
-
|
|
24
|
-
const deleteReqZ = z.object({ keys: keyZ.array() });
|
|
25
|
-
|
|
26
|
-
const setReqZ = z.object({
|
|
27
|
-
id: ontology.idZ,
|
|
28
|
-
labels: keyZ.array(),
|
|
29
|
-
replace: z.boolean().optional(),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
interface SetReq extends z.infer<typeof setReqZ> {}
|
|
33
|
-
export interface SetOptions extends Pick<SetReq, "replace"> {}
|
|
34
|
-
|
|
35
|
-
const removeReqZ = setReqZ.omit({ replace: true });
|
|
36
|
-
|
|
37
|
-
const emptyResZ = z.object({});
|
|
38
|
-
|
|
39
|
-
const CREATE_ENDPOINT = "/label/create";
|
|
40
|
-
const DELETE_ENDPOINT = "/label/delete";
|
|
41
|
-
const SET_ENDPOINT = "/label/set";
|
|
42
|
-
const REMOVE_ENDPOINT = "/label/remove";
|
|
43
|
-
|
|
44
|
-
export class Writer {
|
|
45
|
-
private readonly client: UnaryClient;
|
|
46
|
-
|
|
47
|
-
constructor(client: UnaryClient) {
|
|
48
|
-
this.client = client;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async create(labels: New | New[]): Promise<Label[]> {
|
|
52
|
-
const res = await sendRequired<typeof createReqZ, typeof createResZ>(
|
|
53
|
-
this.client,
|
|
54
|
-
CREATE_ENDPOINT,
|
|
55
|
-
{ labels: array.toArray(labels) },
|
|
56
|
-
createReqZ,
|
|
57
|
-
createResZ,
|
|
58
|
-
);
|
|
59
|
-
return res.labels;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async delete(keys: Key | Key[]): Promise<void> {
|
|
63
|
-
await sendRequired<typeof deleteReqZ, typeof emptyResZ>(
|
|
64
|
-
this.client,
|
|
65
|
-
DELETE_ENDPOINT,
|
|
66
|
-
{ keys: array.toArray(keys) },
|
|
67
|
-
deleteReqZ,
|
|
68
|
-
emptyResZ,
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async set(
|
|
73
|
-
id: ontology.ID,
|
|
74
|
-
labels: Key[],
|
|
75
|
-
{ replace }: SetOptions = {},
|
|
76
|
-
): Promise<void> {
|
|
77
|
-
await sendRequired<typeof setReqZ, typeof emptyResZ>(
|
|
78
|
-
this.client,
|
|
79
|
-
SET_ENDPOINT,
|
|
80
|
-
{ id, labels, replace },
|
|
81
|
-
setReqZ,
|
|
82
|
-
emptyResZ,
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
async remove(id: ontology.ID, labels: Key[]): Promise<void> {
|
|
87
|
-
await sendRequired<typeof removeReqZ, typeof emptyResZ>(
|
|
88
|
-
this.client,
|
|
89
|
-
REMOVE_ENDPOINT,
|
|
90
|
-
{ id, labels },
|
|
91
|
-
removeReqZ,
|
|
92
|
-
emptyResZ,
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
}
|
package/src/setupspecs.ts
DELETED
|
@@ -1,27 +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 Synnax, { type SynnaxProps } from "@/client";
|
|
11
|
-
|
|
12
|
-
export const HOST = "localhost";
|
|
13
|
-
export const PORT = 9090;
|
|
14
|
-
const USERNAME = "synnax";
|
|
15
|
-
const PASSWORD = "seldon";
|
|
16
|
-
|
|
17
|
-
export const newClient = (...props: SynnaxProps[]): Synnax => {
|
|
18
|
-
let _props = {};
|
|
19
|
-
if (props.length > 0) _props = props[0];
|
|
20
|
-
return new Synnax({
|
|
21
|
-
host: HOST,
|
|
22
|
-
port: PORT,
|
|
23
|
-
username: USERNAME,
|
|
24
|
-
password: PASSWORD,
|
|
25
|
-
..._props,
|
|
26
|
-
});
|
|
27
|
-
};
|
package/src/signals/external.ts
DELETED
|
@@ -1,10 +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
|
-
export * from "@/signals/observable";
|
|
@@ -1,42 +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 change } from "@synnaxlabs/x/change";
|
|
11
|
-
import { type observe } from "@synnaxlabs/x/observe";
|
|
12
|
-
import { type Series } from "@synnaxlabs/x/telem";
|
|
13
|
-
|
|
14
|
-
import { type channel } from "@/channel";
|
|
15
|
-
import { framer } from "@/framer";
|
|
16
|
-
|
|
17
|
-
export interface Decoder<K, V> {
|
|
18
|
-
(variant: change.Variant, data: Series): Array<change.Change<K, V>>;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface Observable<K, V>
|
|
22
|
-
extends observe.ObservableAsyncCloseable<Array<change.Change<K, V>>> {}
|
|
23
|
-
|
|
24
|
-
export const openObservable = async <K, V>(
|
|
25
|
-
client: framer.Client,
|
|
26
|
-
setChannel: channel.Key | channel.Name,
|
|
27
|
-
deleteChannel: channel.Key | channel.Name,
|
|
28
|
-
codec: Decoder<K, V>,
|
|
29
|
-
): Promise<Observable<K, V>> => {
|
|
30
|
-
const stream = await client.openStreamer([setChannel, deleteChannel] as channel.Keys);
|
|
31
|
-
const transform = (frame: framer.Frame): [Array<change.Change<K, V>>, boolean] => {
|
|
32
|
-
const changes: Array<change.Change<K, V>> = [];
|
|
33
|
-
if (deleteChannel != null)
|
|
34
|
-
changes.push(
|
|
35
|
-
...frame.get(deleteChannel).series.flatMap((s) => codec("delete", s)),
|
|
36
|
-
);
|
|
37
|
-
if (setChannel != null)
|
|
38
|
-
changes.push(...frame.get(setChannel).series.flatMap((s) => codec("set", s)));
|
|
39
|
-
return [changes, changes.length > 0];
|
|
40
|
-
};
|
|
41
|
-
return new framer.ObservableStreamer<Array<change.Change<K, V>>>(stream, transform);
|
|
42
|
-
};
|