@synnaxlabs/client 0.2.1 → 0.13.6
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/.eslintrc.cjs +18 -0
- package/.pytest_cache/README.md +8 -0
- package/.turbo/turbo-build.log +16 -0
- package/LICENSE +4 -21
- package/{build/module/lib → dist/auth}/auth.d.ts +16 -19
- package/dist/auth/index.d.ts +1 -0
- package/dist/cdc/external.d.ts +1 -0
- package/dist/cdc/index.d.ts +1 -0
- package/dist/cdc/observable.d.ts +17 -0
- package/dist/channel/client.d.ts +58 -0
- package/dist/channel/creator.d.ts +8 -0
- package/dist/channel/external.d.ts +4 -0
- package/dist/channel/index.d.ts +1 -0
- package/dist/channel/payload.d.ts +63 -0
- package/dist/channel/retriever.d.ts +49 -0
- package/dist/client.cjs.js +23050 -0
- package/dist/client.cjs.js.map +1 -0
- package/dist/client.d.ts +73 -0
- package/dist/client.es.js +23050 -0
- package/dist/client.es.js.map +1 -0
- package/dist/connection/checker.d.ts +66 -0
- package/dist/connection/index.d.ts +1 -0
- package/dist/control/authority.d.ts +6 -0
- package/dist/control/external.d.ts +2 -0
- package/dist/control/index.d.ts +1 -0
- package/dist/control/state.d.ts +81 -0
- package/{build/main/lib → dist}/errors.d.ts +6 -3
- package/dist/framer/adapter.d.ts +21 -0
- package/dist/framer/client.d.ts +44 -0
- package/dist/framer/external.d.ts +5 -0
- package/dist/framer/frame.d.ts +251 -0
- package/dist/framer/index.d.ts +1 -0
- package/{build/module/lib/segment → dist/framer}/iterator.d.ts +32 -64
- package/dist/framer/streamProxy.d.ts +12 -0
- package/dist/framer/streamer.d.ts +17 -0
- package/dist/framer/writer.d.ts +257 -0
- package/dist/index.d.ts +16 -0
- package/dist/label/client.d.ts +25 -0
- package/dist/label/external.d.ts +4 -0
- package/dist/label/index.d.ts +1 -0
- package/dist/label/payload.d.ts +20 -0
- package/dist/label/retriever.d.ts +13 -0
- package/dist/label/writer.d.ts +26 -0
- package/dist/ontology/cdc.d.ts +25 -0
- package/dist/ontology/client.d.ts +25 -0
- package/dist/ontology/external.d.ts +3 -0
- package/dist/ontology/group/client.d.ts +11 -0
- package/dist/ontology/group/external.d.ts +2 -0
- package/dist/ontology/group/group.d.ts +7 -0
- package/dist/ontology/group/index.d.ts +1 -0
- package/dist/ontology/group/payload.d.ts +40 -0
- package/dist/ontology/group/writer.d.ts +13 -0
- package/dist/ontology/index.d.ts +1 -0
- package/dist/ontology/ontology.spec.d.ts +1 -0
- package/dist/ontology/payload.d.ts +235 -0
- package/dist/ontology/retriever.d.ts +12 -0
- package/dist/ontology/signals.d.ts +25 -0
- package/dist/ontology/writer.d.ts +9 -0
- package/dist/ranger/active.d.ts +9 -0
- package/dist/ranger/alias.d.ts +32 -0
- package/dist/ranger/client.d.ts +31 -0
- package/dist/ranger/external.d.ts +6 -0
- package/dist/ranger/index.d.ts +1 -0
- package/dist/ranger/kv.d.ts +50 -0
- package/dist/ranger/payload.d.ts +94 -0
- package/dist/ranger/range.d.ts +29 -0
- package/dist/ranger/ranger.spec.d.ts +1 -0
- package/dist/ranger/retriever.d.ts +10 -0
- package/dist/ranger/writer.d.ts +9 -0
- package/{build/main → dist}/setupspecs.d.ts +2 -2
- package/dist/signals/external.d.ts +1 -0
- package/dist/signals/index.d.ts +1 -0
- package/dist/signals/observable.d.ts +17 -0
- package/dist/transport.d.ts +10 -0
- package/dist/user/index.d.ts +1 -0
- package/{build/main/lib → dist}/user/payload.d.ts +3 -3
- package/dist/util/telem.d.ts +2 -0
- package/dist/workspace/client.d.ts +22 -0
- package/dist/workspace/external.d.ts +2 -0
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/lineplot/client.d.ts +15 -0
- package/dist/workspace/lineplot/external.d.ts +2 -0
- package/dist/workspace/lineplot/index.d.ts +1 -0
- package/dist/workspace/lineplot/linePlot.spec.d.ts +1 -0
- package/dist/workspace/lineplot/payload.d.ts +31 -0
- package/dist/workspace/lineplot/retriever.d.ts +9 -0
- package/dist/workspace/lineplot/writer.d.ts +39 -0
- package/dist/workspace/payload.d.ts +31 -0
- package/dist/workspace/pid/client.d.ts +16 -0
- package/dist/workspace/pid/external.d.ts +2 -0
- package/dist/workspace/pid/index.d.ts +1 -0
- package/dist/workspace/pid/payload.d.ts +37 -0
- package/dist/workspace/pid/pid.spec.d.ts +1 -0
- package/dist/workspace/pid/retriever.d.ts +9 -0
- package/dist/workspace/pid/writer.d.ts +46 -0
- package/dist/workspace/retriever.d.ts +12 -0
- package/dist/workspace/workspace.spec.d.ts +1 -0
- package/dist/workspace/writer.d.ts +55 -0
- package/package.json +27 -98
- package/src/auth/auth.spec.ts +46 -0
- package/src/auth/auth.ts +83 -0
- package/src/auth/index.ts +10 -0
- package/src/channel/channel.spec.ts +82 -0
- package/src/channel/client.ts +209 -0
- package/src/channel/creator.ts +43 -0
- package/src/channel/external.ts +13 -0
- package/src/channel/index.ts +10 -0
- package/src/channel/payload.ts +52 -0
- package/src/channel/retriever.ts +160 -0
- package/src/client.ts +116 -0
- package/src/connection/checker.ts +104 -0
- package/src/connection/connection.spec.ts +35 -0
- package/src/connection/index.ts +10 -0
- package/src/control/authority.ts +26 -0
- package/src/control/external.ts +11 -0
- package/src/control/index.ts +10 -0
- package/src/control/state.spec.ts +24 -0
- package/src/control/state.ts +133 -0
- package/src/errors.ts +163 -0
- package/src/framer/adapter.ts +116 -0
- package/src/framer/client.ts +116 -0
- package/src/framer/external.ts +14 -0
- package/src/framer/frame.spec.ts +317 -0
- package/src/framer/frame.ts +412 -0
- package/src/framer/index.ts +10 -0
- package/src/framer/iterator.spec.ts +62 -0
- package/src/framer/iterator.ts +240 -0
- package/src/framer/streamProxy.ts +59 -0
- package/src/framer/streamer.spec.ts +42 -0
- package/src/framer/streamer.ts +86 -0
- package/src/framer/writer.spec.ts +52 -0
- package/src/framer/writer.ts +236 -0
- package/src/index.ts +53 -0
- package/src/label/client.ts +103 -0
- package/src/label/external.ts +13 -0
- package/src/label/index.ts +10 -0
- package/src/label/label.spec.ts +51 -0
- package/src/label/payload.ts +29 -0
- package/src/label/retriever.ts +65 -0
- package/src/label/writer.ts +90 -0
- package/src/ontology/client.ts +104 -0
- package/src/ontology/external.ts +12 -0
- package/src/ontology/group/client.ts +40 -0
- package/src/ontology/group/external.ts +11 -0
- package/src/ontology/group/group.spec.ts +46 -0
- package/src/ontology/group/group.ts +27 -0
- package/src/ontology/group/index.ts +10 -0
- package/src/ontology/group/payload.ts +65 -0
- package/src/ontology/group/writer.ts +48 -0
- package/src/ontology/index.ts +10 -0
- package/src/ontology/ontology.spec.ts +114 -0
- package/src/ontology/payload.ts +118 -0
- package/src/ontology/retriever.ts +91 -0
- package/src/ontology/signals.ts +135 -0
- package/src/ontology/writer.ts +49 -0
- package/src/ranger/active.ts +56 -0
- package/src/ranger/alias.ts +183 -0
- package/src/ranger/client.ts +129 -0
- package/src/ranger/external.ts +15 -0
- package/src/ranger/index.ts +10 -0
- package/src/ranger/kv.ts +91 -0
- package/src/ranger/payload.ts +70 -0
- package/src/ranger/range.ts +95 -0
- package/src/ranger/ranger.spec.ts +201 -0
- package/src/ranger/retriever.ts +50 -0
- package/src/ranger/writer.ts +80 -0
- package/src/setupspecs.ts +25 -0
- package/src/signals/external.ts +10 -0
- package/src/signals/index.ts +10 -0
- package/src/signals/observable.ts +80 -0
- package/src/transport.ts +39 -0
- package/src/user/index.ts +10 -0
- package/src/user/payload.ts +17 -0
- package/src/util/telem.ts +19 -0
- package/src/vite-env.d.ts +11 -0
- package/src/workspace/client.ts +75 -0
- package/src/workspace/external.ts +11 -0
- package/src/workspace/index.ts +10 -0
- package/src/workspace/lineplot/client.ts +51 -0
- package/src/workspace/lineplot/external.ts +11 -0
- package/src/workspace/lineplot/index.ts +10 -0
- package/src/workspace/lineplot/linePlot.spec.ts +78 -0
- package/src/workspace/lineplot/payload.ts +29 -0
- package/src/workspace/lineplot/retriever.ts +49 -0
- package/src/workspace/lineplot/writer.ts +109 -0
- package/src/workspace/payload.ts +29 -0
- package/src/workspace/pid/client.ts +55 -0
- package/src/workspace/pid/external.ts +11 -0
- package/src/workspace/pid/index.ts +10 -0
- package/src/workspace/pid/payload.ts +31 -0
- package/src/workspace/pid/pid.spec.ts +111 -0
- package/src/workspace/pid/retriever.ts +45 -0
- package/src/workspace/pid/writer.ts +130 -0
- package/src/workspace/retriever.ts +66 -0
- package/src/workspace/workspace.spec.ts +62 -0
- package/src/workspace/writer.ts +103 -0
- package/tsconfig.json +7 -0
- package/tsconfig.vite.json +4 -0
- package/vite.config.ts +25 -0
- package/CHANGELOG.md +0 -5
- package/build/main/index.d.ts +0 -4
- package/build/main/index.js +0 -35
- package/build/main/lib/auth.d.ts +0 -54
- package/build/main/lib/auth.js +0 -62
- package/build/main/lib/auth.spec.js +0 -39
- package/build/main/lib/channel/channel.spec.js +0 -49
- package/build/main/lib/channel/client.d.ts +0 -94
- package/build/main/lib/channel/client.js +0 -134
- package/build/main/lib/channel/creator.d.ts +0 -19
- package/build/main/lib/channel/creator.js +0 -44
- package/build/main/lib/channel/payload.d.ts +0 -25
- package/build/main/lib/channel/payload.js +0 -18
- package/build/main/lib/channel/registry.d.ts +0 -9
- package/build/main/lib/channel/registry.js +0 -37
- package/build/main/lib/channel/retriever.d.ts +0 -11
- package/build/main/lib/channel/retriever.js +0 -39
- package/build/main/lib/client.d.ts +0 -30
- package/build/main/lib/client.js +0 -46
- package/build/main/lib/errors.js +0 -122
- package/build/main/lib/segment/client.d.ts +0 -62
- package/build/main/lib/segment/client.js +0 -95
- package/build/main/lib/segment/iterator.d.ts +0 -134
- package/build/main/lib/segment/iterator.js +0 -253
- package/build/main/lib/segment/iterator.spec.js +0 -73
- package/build/main/lib/segment/payload.d.ts +0 -16
- package/build/main/lib/segment/payload.js +0 -13
- package/build/main/lib/segment/splitter.d.ts +0 -7
- package/build/main/lib/segment/splitter.js +0 -25
- package/build/main/lib/segment/typed.d.ts +0 -15
- package/build/main/lib/segment/typed.js +0 -49
- package/build/main/lib/segment/validator.d.ts +0 -22
- package/build/main/lib/segment/validator.js +0 -64
- package/build/main/lib/segment/writer.d.ts +0 -98
- package/build/main/lib/segment/writer.js +0 -183
- package/build/main/lib/segment/writer.spec.js +0 -90
- package/build/main/lib/telem.d.ts +0 -395
- package/build/main/lib/telem.js +0 -553
- package/build/main/lib/telem.spec.js +0 -152
- package/build/main/lib/transport.d.ts +0 -10
- package/build/main/lib/transport.js +0 -22
- package/build/main/lib/user/payload.js +0 -9
- package/build/main/lib/util/telem.d.ts +0 -2
- package/build/main/lib/util/telem.js +0 -13
- package/build/main/setupspecs.js +0 -17
- package/build/module/index.d.ts +0 -4
- package/build/module/index.js +0 -5
- package/build/module/lib/auth.js +0 -63
- package/build/module/lib/auth.spec.js +0 -34
- package/build/module/lib/channel/channel.spec.js +0 -44
- package/build/module/lib/channel/client.d.ts +0 -94
- package/build/module/lib/channel/client.js +0 -134
- package/build/module/lib/channel/creator.d.ts +0 -19
- package/build/module/lib/channel/creator.js +0 -42
- package/build/module/lib/channel/payload.d.ts +0 -25
- package/build/module/lib/channel/payload.js +0 -15
- package/build/module/lib/channel/registry.d.ts +0 -9
- package/build/module/lib/channel/registry.js +0 -36
- package/build/module/lib/channel/retriever.d.ts +0 -11
- package/build/module/lib/channel/retriever.js +0 -37
- package/build/module/lib/client.d.ts +0 -30
- package/build/module/lib/client.js +0 -44
- package/build/module/lib/errors.d.ts +0 -53
- package/build/module/lib/errors.js +0 -113
- package/build/module/lib/segment/client.d.ts +0 -62
- package/build/module/lib/segment/client.js +0 -94
- package/build/module/lib/segment/iterator.js +0 -248
- package/build/module/lib/segment/iterator.spec.js +0 -68
- package/build/module/lib/segment/payload.d.ts +0 -16
- package/build/module/lib/segment/payload.js +0 -10
- package/build/module/lib/segment/splitter.d.ts +0 -7
- package/build/module/lib/segment/splitter.js +0 -26
- package/build/module/lib/segment/typed.d.ts +0 -15
- package/build/module/lib/segment/typed.js +0 -49
- package/build/module/lib/segment/validator.d.ts +0 -22
- package/build/module/lib/segment/validator.js +0 -60
- package/build/module/lib/segment/writer.d.ts +0 -98
- package/build/module/lib/segment/writer.js +0 -183
- package/build/module/lib/segment/writer.spec.js +0 -85
- package/build/module/lib/telem.d.ts +0 -395
- package/build/module/lib/telem.js +0 -545
- package/build/module/lib/telem.spec.js +0 -147
- package/build/module/lib/transport.d.ts +0 -10
- package/build/module/lib/transport.js +0 -22
- package/build/module/lib/user/payload.d.ts +0 -12
- package/build/module/lib/user/payload.js +0 -6
- package/build/module/lib/util/telem.d.ts +0 -2
- package/build/module/lib/util/telem.js +0 -9
- package/build/module/setupspecs.d.ts +0 -4
- package/build/module/setupspecs.js +0 -16
- /package/{build/main/lib → dist/auth}/auth.spec.d.ts +0 -0
- /package/{build/main/lib → dist}/channel/channel.spec.d.ts +0 -0
- /package/{build/main/lib/segment/iterator.spec.d.ts → dist/connection/connection.spec.d.ts} +0 -0
- /package/{build/main/lib/segment/writer.spec.d.ts → dist/control/state.spec.d.ts} +0 -0
- /package/{build/main/lib/telem.spec.d.ts → dist/framer/frame.spec.d.ts} +0 -0
- /package/{build/module/lib/segment → dist/framer}/iterator.spec.d.ts +0 -0
- /package/{build/module/lib/auth.spec.d.ts → dist/framer/streamer.spec.d.ts} +0 -0
- /package/{build/module/lib/segment → dist/framer}/writer.spec.d.ts +0 -0
- /package/{build/module/lib/channel/channel.spec.d.ts → dist/label/label.spec.d.ts} +0 -0
- /package/{build/module/lib/telem.spec.d.ts → dist/ontology/group/group.spec.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Synnax, { SynnaxProps } from './
|
|
1
|
+
import Synnax, { type SynnaxProps } from './client';
|
|
2
2
|
export declare const HOST = "localhost";
|
|
3
|
-
export declare const PORT =
|
|
3
|
+
export declare const PORT = 9090;
|
|
4
4
|
export declare const newClient: (...props: SynnaxProps[]) => Synnax;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../signals/observable';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as signals from '../signals/external';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { observe, type Destructor, type change, type Series } from "@synnaxlabs/x";
|
|
2
|
+
import { type channel } from '../channel';
|
|
3
|
+
import { type framer } from '../framer';
|
|
4
|
+
export type Decoder<K, V> = (variant: change.Variant, data: Series) => Array<change.Change<K, V>>;
|
|
5
|
+
export declare class Observable<K, V> implements observe.Observable<Array<change.Change<K, V>>> {
|
|
6
|
+
private readonly streamer;
|
|
7
|
+
private readonly decoder;
|
|
8
|
+
private readonly base;
|
|
9
|
+
private readonly closePromise;
|
|
10
|
+
private readonly deleteChannel?;
|
|
11
|
+
private readonly setChannel?;
|
|
12
|
+
private constructor();
|
|
13
|
+
onChange(handler: observe.Handler<Array<change.Change<K, V>>>): Destructor;
|
|
14
|
+
close(): Promise<void>;
|
|
15
|
+
stream(): Promise<void>;
|
|
16
|
+
static open<K, V>(client: framer.Client, setChannel: channel.Key | channel.Name, deleteChannel: channel.Key | channel.Name, ecd: Decoder<K, V>): Promise<Observable<K, V>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Middleware, type StreamClient, type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type URL } from "@synnaxlabs/x";
|
|
3
|
+
export declare class Transport {
|
|
4
|
+
readonly url: URL;
|
|
5
|
+
readonly unary: UnaryClient;
|
|
6
|
+
readonly stream: StreamClient;
|
|
7
|
+
readonly secure: boolean;
|
|
8
|
+
constructor(url: URL, secure?: boolean);
|
|
9
|
+
use(...middleware: Middleware[]): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as user from '../user/payload';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
export declare const
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const payloadZ: z.ZodObject<{
|
|
3
3
|
key: z.ZodString;
|
|
4
4
|
username: z.ZodString;
|
|
5
5
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -9,4 +9,4 @@ export declare const UserPayloadSchema: z.ZodObject<{
|
|
|
9
9
|
key: string;
|
|
10
10
|
username: string;
|
|
11
11
|
}>;
|
|
12
|
-
export
|
|
12
|
+
export type Payload = z.infer<typeof payloadZ>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type UnknownRecord, type AsyncTermSearcher } from "@synnaxlabs/x";
|
|
3
|
+
import { linePlot } from '../workspace/lineplot';
|
|
4
|
+
import { type Key, type Workspace } from '../workspace/payload';
|
|
5
|
+
import { pid } from '../workspace/pid';
|
|
6
|
+
import { type CrudeWorkspace } from '../workspace/writer';
|
|
7
|
+
export declare class Client implements AsyncTermSearcher<string, Key, Workspace> {
|
|
8
|
+
readonly pid: pid.Client;
|
|
9
|
+
readonly linePlot: linePlot.Client;
|
|
10
|
+
private readonly retriever;
|
|
11
|
+
private readonly writer;
|
|
12
|
+
constructor(client: UnaryClient);
|
|
13
|
+
search(term: string): Promise<Workspace[]>;
|
|
14
|
+
retrieveByAuthor(author: string): Promise<Workspace[]>;
|
|
15
|
+
retrieve(key: Key): Promise<Workspace>;
|
|
16
|
+
retrieve(keys: Key[]): Promise<Workspace[]>;
|
|
17
|
+
page(offset: number, limit: number): Promise<Workspace[]>;
|
|
18
|
+
create(workspace: CrudeWorkspace): Promise<Workspace>;
|
|
19
|
+
rename(key: Key, name: string): Promise<void>;
|
|
20
|
+
setLayout(key: Key, layout: UnknownRecord): Promise<void>;
|
|
21
|
+
delete(...keys: Key[]): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as workspace from '../workspace/external';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type UnknownRecord } from "@synnaxlabs/x";
|
|
3
|
+
import { type LinePlot, type Key, type Params } from '../../workspace/lineplot/payload';
|
|
4
|
+
import { type CrudeLinePlot } from '../../workspace/lineplot/writer';
|
|
5
|
+
export declare class Client {
|
|
6
|
+
private readonly writer;
|
|
7
|
+
private readonly retriever;
|
|
8
|
+
constructor(client: UnaryClient);
|
|
9
|
+
create(workspace: string, pid: CrudeLinePlot): Promise<LinePlot>;
|
|
10
|
+
rename(key: Key, name: string): Promise<void>;
|
|
11
|
+
setData(key: Key, data: UnknownRecord): Promise<void>;
|
|
12
|
+
retrieve(key: Key): Promise<LinePlot>;
|
|
13
|
+
retrieve(keys: Key[]): Promise<LinePlot[]>;
|
|
14
|
+
delete(keys: Params): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as linePlot from '../../workspace/lineplot/external';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const keyZ: z.ZodString;
|
|
3
|
+
export type Key = z.infer<typeof keyZ>;
|
|
4
|
+
export type Params = Key | Key[];
|
|
5
|
+
export declare const linePlotZ: z.ZodObject<{
|
|
6
|
+
key: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
data: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
key: string;
|
|
12
|
+
data: Record<string | number | symbol, unknown>;
|
|
13
|
+
}, {
|
|
14
|
+
name: string;
|
|
15
|
+
key: string;
|
|
16
|
+
data: Record<string | number | symbol, unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const linePlotRemoteZ: z.ZodObject<{
|
|
19
|
+
key: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
data: z.ZodEffects<z.ZodString, Partial<Record<import("@synnaxlabs/x").Key, unknown>>, string>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
name: string;
|
|
24
|
+
key: string;
|
|
25
|
+
data: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
26
|
+
}, {
|
|
27
|
+
name: string;
|
|
28
|
+
key: string;
|
|
29
|
+
data: string;
|
|
30
|
+
}>;
|
|
31
|
+
export type LinePlot = z.infer<typeof linePlotZ>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type LinePlot, type Params } from '../../workspace/lineplot/payload';
|
|
3
|
+
export declare class Retriever {
|
|
4
|
+
private readonly ENDPOINT;
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: UnaryClient);
|
|
7
|
+
retrieve(params: Params): Promise<LinePlot[]>;
|
|
8
|
+
private execute;
|
|
9
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type UnknownRecord } from "@synnaxlabs/x";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { type LinePlot, type Params, type Key } from '../../workspace/lineplot/payload';
|
|
5
|
+
export declare const crudeLinePlotZ: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
key: z.ZodOptional<z.ZodString>;
|
|
8
|
+
data: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
data: Record<string | number | symbol, unknown>;
|
|
12
|
+
key?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
name: string;
|
|
15
|
+
data: Record<string | number | symbol, unknown>;
|
|
16
|
+
key?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const linePlotWriteZ: z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
key: z.ZodOptional<z.ZodString>;
|
|
21
|
+
data: z.ZodEffects<z.ZodString, Partial<Record<import("@synnaxlabs/x").Key, unknown>>, string>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
name: string;
|
|
24
|
+
data: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
25
|
+
key?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
name: string;
|
|
28
|
+
data: string;
|
|
29
|
+
key?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type CrudeLinePlot = z.infer<typeof crudeLinePlotZ>;
|
|
32
|
+
export declare class Writer {
|
|
33
|
+
private readonly client;
|
|
34
|
+
constructor(client: UnaryClient);
|
|
35
|
+
create(workspace: string, plot: CrudeLinePlot): Promise<LinePlot>;
|
|
36
|
+
delete(params: Params): Promise<void>;
|
|
37
|
+
rename(pid: Key, name: string): Promise<void>;
|
|
38
|
+
setData(pid: Key, data: UnknownRecord): Promise<void>;
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const keyZ: z.ZodString;
|
|
3
|
+
export type Key = z.infer<typeof keyZ>;
|
|
4
|
+
export type Params = Key | Key[];
|
|
5
|
+
export declare const workspaceZ: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
key: z.ZodString;
|
|
8
|
+
layout: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
key: string;
|
|
12
|
+
layout: Record<string | number | symbol, unknown>;
|
|
13
|
+
}, {
|
|
14
|
+
name: string;
|
|
15
|
+
key: string;
|
|
16
|
+
layout: Record<string | number | symbol, unknown>;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const workspaceRemoteZ: z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
key: z.ZodString;
|
|
21
|
+
layout: z.ZodEffects<z.ZodString, Partial<Record<import("@synnaxlabs/x").Key, unknown>>, string>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
name: string;
|
|
24
|
+
key: string;
|
|
25
|
+
layout: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
26
|
+
}, {
|
|
27
|
+
name: string;
|
|
28
|
+
key: string;
|
|
29
|
+
layout: string;
|
|
30
|
+
}>;
|
|
31
|
+
export type Workspace = z.infer<typeof workspaceZ>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type UnknownRecord } from "@synnaxlabs/x";
|
|
3
|
+
import { type Key, type Params, type PID } from '../../workspace/pid/payload';
|
|
4
|
+
import { type UncreatedPID } from '../../workspace/pid/writer';
|
|
5
|
+
export declare class Client {
|
|
6
|
+
private readonly writer;
|
|
7
|
+
private readonly retriever;
|
|
8
|
+
constructor(client: UnaryClient);
|
|
9
|
+
create(workspace: string, pid: UncreatedPID): Promise<PID>;
|
|
10
|
+
rename(key: Key, name: string): Promise<void>;
|
|
11
|
+
setData(key: Key, data: UnknownRecord): Promise<void>;
|
|
12
|
+
retrieve(key: Key): Promise<PID>;
|
|
13
|
+
retrieve(keys: Key[]): Promise<PID[]>;
|
|
14
|
+
delete(keys: Params): Promise<void>;
|
|
15
|
+
copy(key: Key, name: string, snapshot: boolean): Promise<PID>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as pid from '../../workspace/pid/external';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const keyZ: z.ZodString;
|
|
3
|
+
export type Key = z.infer<typeof keyZ>;
|
|
4
|
+
export type Params = Key | Key[];
|
|
5
|
+
export declare const pidZ: z.ZodObject<{
|
|
6
|
+
key: z.ZodString;
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
data: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
9
|
+
snapshot: z.ZodBoolean;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
name: string;
|
|
12
|
+
key: string;
|
|
13
|
+
data: Record<string | number | symbol, unknown>;
|
|
14
|
+
snapshot: boolean;
|
|
15
|
+
}, {
|
|
16
|
+
name: string;
|
|
17
|
+
key: string;
|
|
18
|
+
data: Record<string | number | symbol, unknown>;
|
|
19
|
+
snapshot: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const pidRemoteZ: z.ZodObject<{
|
|
22
|
+
key: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
snapshot: z.ZodBoolean;
|
|
25
|
+
data: z.ZodEffects<z.ZodString, Partial<Record<import("@synnaxlabs/x").Key, unknown>>, string>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
name: string;
|
|
28
|
+
key: string;
|
|
29
|
+
data: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
30
|
+
snapshot: boolean;
|
|
31
|
+
}, {
|
|
32
|
+
name: string;
|
|
33
|
+
key: string;
|
|
34
|
+
data: string;
|
|
35
|
+
snapshot: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
export type PID = z.infer<typeof pidZ>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type PID, type Params } from "./payload";
|
|
3
|
+
export declare class Retriever {
|
|
4
|
+
private readonly ENDPOINT;
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: UnaryClient);
|
|
7
|
+
retrieve(params: Params): Promise<PID[]>;
|
|
8
|
+
private execute;
|
|
9
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type UnknownRecord } from "@synnaxlabs/x";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { type PID, type Params, type Key } from '../../workspace/pid/payload';
|
|
5
|
+
export declare const crudePIDz: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
key: z.ZodOptional<z.ZodString>;
|
|
8
|
+
data: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
9
|
+
snapshot: z.ZodBoolean;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
name: string;
|
|
12
|
+
data: Record<string | number | symbol, unknown>;
|
|
13
|
+
snapshot: boolean;
|
|
14
|
+
key?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
name: string;
|
|
17
|
+
data: Record<string | number | symbol, unknown>;
|
|
18
|
+
snapshot: boolean;
|
|
19
|
+
key?: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const pidWriteZ: z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
key: z.ZodOptional<z.ZodString>;
|
|
24
|
+
data: z.ZodEffects<z.ZodString, Partial<Record<import("@synnaxlabs/x").Key, unknown>>, string>;
|
|
25
|
+
snapshot: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
name: string;
|
|
28
|
+
data: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
29
|
+
key?: string | undefined;
|
|
30
|
+
snapshot?: boolean | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
name: string;
|
|
33
|
+
data: string;
|
|
34
|
+
key?: string | undefined;
|
|
35
|
+
snapshot?: boolean | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export type UncreatedPID = z.infer<typeof pidWriteZ>;
|
|
38
|
+
export declare class Writer {
|
|
39
|
+
private readonly client;
|
|
40
|
+
constructor(client: UnaryClient);
|
|
41
|
+
create(workspace: string, pid: UncreatedPID): Promise<PID>;
|
|
42
|
+
copy(key: Key, name: string, snapshot: boolean): Promise<PID>;
|
|
43
|
+
delete(params: Params): Promise<void>;
|
|
44
|
+
rename(pid: Key, name: string): Promise<void>;
|
|
45
|
+
setData(pid: Key, data: UnknownRecord): Promise<void>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type Params, type Workspace } from '../workspace/payload';
|
|
3
|
+
export declare class Retriever {
|
|
4
|
+
private static readonly ENDPOINT;
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: UnaryClient);
|
|
7
|
+
retrieve(params: Params): Promise<Workspace[]>;
|
|
8
|
+
retrieveByAuthor(author: string): Promise<Workspace[]>;
|
|
9
|
+
search(term: string): Promise<Workspace[]>;
|
|
10
|
+
page(offset: number, limit: number): Promise<Workspace[]>;
|
|
11
|
+
private execute;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type UnaryClient } from "@synnaxlabs/freighter";
|
|
2
|
+
import { type UnknownRecord } from "@synnaxlabs/x";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { type Workspace } from "./payload";
|
|
5
|
+
declare const crudeWorkspaceZ: z.ZodObject<{
|
|
6
|
+
name: z.ZodString;
|
|
7
|
+
key: z.ZodOptional<z.ZodString>;
|
|
8
|
+
layout: z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
name: string;
|
|
11
|
+
layout: Record<string | number | symbol, unknown>;
|
|
12
|
+
key?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
name: string;
|
|
15
|
+
layout: Record<string | number | symbol, unknown>;
|
|
16
|
+
key?: string | undefined;
|
|
17
|
+
}>;
|
|
18
|
+
export type CrudeWorkspace = z.infer<typeof crudeWorkspaceZ>;
|
|
19
|
+
declare const createResZ: z.ZodObject<{
|
|
20
|
+
workspaces: z.ZodArray<z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
key: z.ZodString;
|
|
23
|
+
layout: z.ZodEffects<z.ZodString, Partial<Record<import("@synnaxlabs/x").Key, unknown>>, string>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
name: string;
|
|
26
|
+
key: string;
|
|
27
|
+
layout: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
28
|
+
}, {
|
|
29
|
+
name: string;
|
|
30
|
+
key: string;
|
|
31
|
+
layout: string;
|
|
32
|
+
}>, "many">;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
workspaces: {
|
|
35
|
+
name: string;
|
|
36
|
+
key: string;
|
|
37
|
+
layout: Partial<Record<import("@synnaxlabs/x").Key, unknown>>;
|
|
38
|
+
}[];
|
|
39
|
+
}, {
|
|
40
|
+
workspaces: {
|
|
41
|
+
name: string;
|
|
42
|
+
key: string;
|
|
43
|
+
layout: string;
|
|
44
|
+
}[];
|
|
45
|
+
}>;
|
|
46
|
+
export type CreateResponse = z.infer<typeof createResZ>;
|
|
47
|
+
export declare class Writer {
|
|
48
|
+
private readonly client;
|
|
49
|
+
constructor(client: UnaryClient);
|
|
50
|
+
create(workspaces: CrudeWorkspace | CrudeWorkspace[]): Promise<Workspace[]>;
|
|
51
|
+
delete(keys: string | string[]): Promise<void>;
|
|
52
|
+
rename(key: string, name: string): Promise<void>;
|
|
53
|
+
setLayout(key: string, layout: UnknownRecord): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/client",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"repository": "https://github.com/synnaxlabs/synnax",
|
|
9
|
-
"license": "MIT",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.13.6",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "The Client Library for Synnax",
|
|
7
|
+
"repository": "https://github.com/synnaxlabs/synnax/tree/main/client/ts",
|
|
10
8
|
"keywords": [
|
|
11
9
|
"synnax",
|
|
12
10
|
"grpc",
|
|
@@ -17,99 +15,30 @@
|
|
|
17
15
|
"telemetry",
|
|
18
16
|
"control systems"
|
|
19
17
|
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "run-p build:*",
|
|
22
|
-
"build:main": "tsc -p tsconfig.json",
|
|
23
|
-
"build:module": "tsc -p tsconfig.module.json",
|
|
24
|
-
"fix": "run-s fix:*",
|
|
25
|
-
"fix:prettier": "prettier \"src/**/*.ts\" --write",
|
|
26
|
-
"fix:lint": "eslint src --ext .ts --fix",
|
|
27
|
-
"test": "run-s build test:*",
|
|
28
|
-
"test:lint": "eslint src --ext .ts",
|
|
29
|
-
"test:prettier": "prettier \"src/**/*.ts\" --list-different",
|
|
30
|
-
"test:unit": "nyc --silent ava",
|
|
31
|
-
"check-cli": "run-s test diff-integration-tests check-integration-tests",
|
|
32
|
-
"check-integration-tests": "run-s check-integration-test:*",
|
|
33
|
-
"diff-integration-tests": "mkdir -p diff && rm -rf diff/test && cp -r test diff/test && rm -rf diff/test/test-*/.git && cd diff && git init --quiet && git add -A && git commit --quiet --no-verify --allow-empty -m 'WIP' && echo '\\n\\nCommitted most recent integration test output in the \"diff\" directory. Review the changes with \"cd diff && git diff HEAD\" or your preferred git diff viewer.'",
|
|
34
|
-
"watch:build": "tsc -p tsconfig.json -w",
|
|
35
|
-
"watch:test": "nyc --silent ava --watch",
|
|
36
|
-
"cov": "run-s build test:unit cov:html cov:lcov",
|
|
37
|
-
"cov:html": "nyc report --reporter=html",
|
|
38
|
-
"cov:lcov": "nyc report --reporter=lcov",
|
|
39
|
-
"cov:send": "run-s cov:lcov && codecov",
|
|
40
|
-
"cov:check": "nyc report && nyc check-coverage --lines 100 --functions 100 --branches 100",
|
|
41
|
-
"doc": "run-s doc:html && open-cli build/docs/index.html",
|
|
42
|
-
"doc:html": "typedoc src/ --exclude **/*.spec.ts --target ES6 --mode file --out build/docs",
|
|
43
|
-
"doc:json": "typedoc src/ --exclude **/*.spec.ts --target ES6 --mode file --json build/docs/typedoc.json",
|
|
44
|
-
"doc:publish": "gh-pages -m \"[ci skip] Updates\" -d build/docs",
|
|
45
|
-
"version": "standard-version",
|
|
46
|
-
"reset-hard": "git clean -dfx && git reset --hard && yarn",
|
|
47
|
-
"prepare-release": "run-s reset-hard test cov:check doc:html version doc:publish"
|
|
48
|
-
},
|
|
49
|
-
"engines": {
|
|
50
|
-
"node": ">=10"
|
|
51
|
-
},
|
|
52
18
|
"dependencies": {
|
|
53
|
-
"
|
|
54
|
-
"
|
|
19
|
+
"zod": "3.22.4",
|
|
20
|
+
"@synnaxlabs/freighter": "0.4.1",
|
|
21
|
+
"@synnaxlabs/x": "0.8.0"
|
|
55
22
|
},
|
|
56
23
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"eslint": "^7.8.0",
|
|
66
|
-
"eslint-config-prettier": "^6.11.0",
|
|
67
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
68
|
-
"eslint-plugin-functional": "^3.0.2",
|
|
69
|
-
"eslint-plugin-import": "^2.22.0",
|
|
70
|
-
"gh-pages": "^3.1.0",
|
|
71
|
-
"npm-run-all": "^4.1.5",
|
|
72
|
-
"nyc": "^15.1.0",
|
|
73
|
-
"open-cli": "^6.0.1",
|
|
74
|
-
"prettier": "^2.1.1",
|
|
75
|
-
"standard-version": "^9.0.0",
|
|
76
|
-
"ts-node": "^9.0.0",
|
|
77
|
-
"typedoc": "^0.19.0",
|
|
78
|
-
"typescript": "^4.0.2"
|
|
79
|
-
},
|
|
80
|
-
"files": [
|
|
81
|
-
"build/main",
|
|
82
|
-
"build/module",
|
|
83
|
-
"!**/*.spec.*",
|
|
84
|
-
"!**/*.json",
|
|
85
|
-
"CHANGELOG.md",
|
|
86
|
-
"LICENSE",
|
|
87
|
-
"README.md"
|
|
88
|
-
],
|
|
89
|
-
"ava": {
|
|
90
|
-
"failFast": true,
|
|
91
|
-
"timeout": "60s",
|
|
92
|
-
"typescript": {
|
|
93
|
-
"rewritePaths": {
|
|
94
|
-
"src/": "build/main/"
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
"files": [
|
|
98
|
-
"!build/module/**"
|
|
99
|
-
]
|
|
100
|
-
},
|
|
101
|
-
"config": {
|
|
102
|
-
"commitizen": {
|
|
103
|
-
"path": "cz-conventional-changelog"
|
|
104
|
-
}
|
|
24
|
+
"@types/node": "^20.10.5",
|
|
25
|
+
"@vitest/coverage-v8": "^1.1.0",
|
|
26
|
+
"typescript": "^5.3.3",
|
|
27
|
+
"vite": "^5.0.10",
|
|
28
|
+
"vitest": "^1.1.0",
|
|
29
|
+
"@synnaxlabs/vite-plugin": "0.0.1",
|
|
30
|
+
"@synnaxlabs/tsconfig": "0.0.1",
|
|
31
|
+
"eslint-config-synnaxlabs": "0.0.0"
|
|
105
32
|
},
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
|
|
33
|
+
"main": "dist/client.cjs.js",
|
|
34
|
+
"module": "dist/client.es.js",
|
|
35
|
+
"types": "dist/index.d.ts",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc --noEmit && vite build",
|
|
38
|
+
"watch": "tsc --noEmit && vite build --watch",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"cov": "vitest --coverage",
|
|
41
|
+
"lint": "eslint \"src/**/*.ts*\"",
|
|
42
|
+
"fix": "eslint \"src/**/*.ts*\" --fix"
|
|
114
43
|
}
|
|
115
|
-
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright 2023 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 { URL } from "@synnaxlabs/x";
|
|
11
|
+
import { describe, expect, test } from "vitest";
|
|
12
|
+
|
|
13
|
+
import { auth } from "@/auth";
|
|
14
|
+
import { AuthError } from "@/errors";
|
|
15
|
+
import { HOST, PORT } from "@/setupspecs";
|
|
16
|
+
import { Transport } from "@/transport";
|
|
17
|
+
|
|
18
|
+
describe("auth", () => {
|
|
19
|
+
test("valid credentials", async () => {
|
|
20
|
+
const transport = new Transport(new URL({ host: HOST, port: PORT }));
|
|
21
|
+
const client = new auth.Client(transport.unary, {
|
|
22
|
+
username: "synnax",
|
|
23
|
+
password: "seldon",
|
|
24
|
+
});
|
|
25
|
+
await client.authenticating;
|
|
26
|
+
expect(client.authenticated).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("invalid credentials", async () => {
|
|
30
|
+
const transport = new Transport(new URL({ host: HOST, port: PORT }));
|
|
31
|
+
const client = new auth.Client(transport.unary, {
|
|
32
|
+
username: "synnax",
|
|
33
|
+
password: "wrong",
|
|
34
|
+
});
|
|
35
|
+
try {
|
|
36
|
+
await client.authenticating;
|
|
37
|
+
expect(client.authenticated).toBeFalsy();
|
|
38
|
+
} catch (e) {
|
|
39
|
+
expect(client.authenticated).toBeFalsy();
|
|
40
|
+
expect(e).toBeInstanceOf(AuthError);
|
|
41
|
+
if (e instanceof AuthError) {
|
|
42
|
+
expect(e.message).toEqual("Invalid authentication credentials");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|