@synnaxlabs/client 0.15.2 → 0.16.3
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/.pytest_cache/README.md +8 -0
- package/.turbo/turbo-build.log +10 -10
- package/README.md +11 -2
- package/dist/channel/batchRetriever.spec.d.ts +1 -0
- package/dist/channel/client.d.ts +149 -14
- package/dist/channel/retriever.d.ts +15 -0
- package/dist/client.cjs +21 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.ts +1 -1
- package/dist/{client.es.js → client.js} +5076 -4731
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +4 -0
- package/dist/ontology/payload.d.ts +38 -38
- package/examples/index.js +1 -0
- package/examples/package.json +16 -0
- package/package.json +6 -5
- package/src/channel/batchRetriever.spec.ts +95 -0
- package/src/channel/channel.spec.ts +19 -2
- package/src/channel/client.ts +177 -33
- package/src/channel/payload.ts +2 -2
- package/src/channel/retriever.ts +62 -2
- package/src/client.ts +10 -6
- package/src/errors.ts +4 -0
- package/src/framer/streamer.spec.ts +1 -0
- package/src/hardware/task/retriever.ts +1 -1
- package/dist/client.cjs.js +0 -21
- package/dist/client.cjs.js.map +0 -1
- package/dist/client.es.js.map +0 -1
package/dist/errors.d.ts
CHANGED
|
@@ -39,6 +39,10 @@ export declare class UnexpectedError extends BaseError {
|
|
|
39
39
|
*/
|
|
40
40
|
export declare class QueryError extends BaseError {
|
|
41
41
|
}
|
|
42
|
+
export declare class NoResultsError extends QueryError {
|
|
43
|
+
}
|
|
44
|
+
export declare class MultipleResultsError extends QueryError {
|
|
45
|
+
}
|
|
42
46
|
/**
|
|
43
47
|
* RouteError is raised when a routing error occurs.
|
|
44
48
|
*/
|
|
@@ -6,27 +6,27 @@ export declare const idZ: z.ZodObject<{
|
|
|
6
6
|
key: z.ZodString;
|
|
7
7
|
}, "strip", z.ZodTypeAny, {
|
|
8
8
|
key: string;
|
|
9
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
9
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
10
10
|
}, {
|
|
11
11
|
key: string;
|
|
12
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
12
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
13
13
|
}>;
|
|
14
14
|
export declare const stringIDZ: z.ZodEffects<z.ZodString, {
|
|
15
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
15
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
16
16
|
key: string;
|
|
17
17
|
}, string>;
|
|
18
18
|
export declare const crudeIDZ: z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
19
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
19
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
20
20
|
key: string;
|
|
21
21
|
}, string>, z.ZodObject<{
|
|
22
22
|
type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"pid">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">]>;
|
|
23
23
|
key: z.ZodString;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
25
|
key: string;
|
|
26
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
26
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
27
27
|
}, {
|
|
28
28
|
key: string;
|
|
29
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
29
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
30
30
|
}>]>;
|
|
31
31
|
export declare class ID {
|
|
32
32
|
type: ResourceType;
|
|
@@ -35,20 +35,20 @@ export declare class ID {
|
|
|
35
35
|
toString(): string;
|
|
36
36
|
get payload(): z.infer<typeof idZ>;
|
|
37
37
|
static readonly z: z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
38
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
38
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
39
39
|
key: string;
|
|
40
40
|
}, string>, z.ZodObject<{
|
|
41
41
|
type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"pid">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">]>;
|
|
42
42
|
key: z.ZodString;
|
|
43
43
|
}, "strip", z.ZodTypeAny, {
|
|
44
44
|
key: string;
|
|
45
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
45
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
46
46
|
}, {
|
|
47
47
|
key: string;
|
|
48
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
48
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
49
49
|
}>]>, z.ZodType<ID, z.ZodTypeDef, ID>]>, ID, string | ID | {
|
|
50
50
|
key: string;
|
|
51
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
51
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
52
52
|
}>;
|
|
53
53
|
}
|
|
54
54
|
export declare const Root: ID;
|
|
@@ -70,12 +70,12 @@ export declare const schemaZ: z.ZodObject<{
|
|
|
70
70
|
type: number;
|
|
71
71
|
}>>;
|
|
72
72
|
}, "strip", z.ZodTypeAny, {
|
|
73
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
73
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
74
74
|
fields: Record<string, {
|
|
75
75
|
type: number;
|
|
76
76
|
}>;
|
|
77
77
|
}, {
|
|
78
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
78
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
79
79
|
fields: Record<string, {
|
|
80
80
|
type: number;
|
|
81
81
|
}>;
|
|
@@ -83,20 +83,20 @@ export declare const schemaZ: z.ZodObject<{
|
|
|
83
83
|
export type Schema = z.infer<typeof schemaZ>;
|
|
84
84
|
export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
85
85
|
id: z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
86
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
86
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
87
87
|
key: string;
|
|
88
88
|
}, string>, z.ZodObject<{
|
|
89
89
|
type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"pid">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">]>;
|
|
90
90
|
key: z.ZodString;
|
|
91
91
|
}, "strip", z.ZodTypeAny, {
|
|
92
92
|
key: string;
|
|
93
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
93
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
94
94
|
}, {
|
|
95
95
|
key: string;
|
|
96
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
96
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
97
97
|
}>]>, z.ZodType<ID, z.ZodTypeDef, ID>]>, ID, string | ID | {
|
|
98
98
|
key: string;
|
|
99
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
99
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
100
100
|
}>;
|
|
101
101
|
name: z.ZodString;
|
|
102
102
|
schema: z.ZodOptional<z.ZodObject<{
|
|
@@ -109,12 +109,12 @@ export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
|
109
109
|
type: number;
|
|
110
110
|
}>>;
|
|
111
111
|
}, "strip", z.ZodTypeAny, {
|
|
112
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
112
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
113
113
|
fields: Record<string, {
|
|
114
114
|
type: number;
|
|
115
115
|
}>;
|
|
116
116
|
}, {
|
|
117
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
117
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
118
118
|
fields: Record<string, {
|
|
119
119
|
type: number;
|
|
120
120
|
}>;
|
|
@@ -124,7 +124,7 @@ export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
|
124
124
|
name: string;
|
|
125
125
|
id: ID;
|
|
126
126
|
schema?: {
|
|
127
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
127
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
128
128
|
fields: Record<string, {
|
|
129
129
|
type: number;
|
|
130
130
|
}>;
|
|
@@ -134,13 +134,13 @@ export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
|
134
134
|
name: string;
|
|
135
135
|
id: (string | ID | {
|
|
136
136
|
key: string;
|
|
137
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
137
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
138
138
|
}) & (string | ID | {
|
|
139
139
|
key: string;
|
|
140
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
140
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
141
141
|
} | undefined);
|
|
142
142
|
schema?: {
|
|
143
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
143
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
144
144
|
fields: Record<string, {
|
|
145
145
|
type: number;
|
|
146
146
|
}>;
|
|
@@ -150,7 +150,7 @@ export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
|
150
150
|
name: string;
|
|
151
151
|
id: ID;
|
|
152
152
|
schema?: {
|
|
153
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
153
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
154
154
|
fields: Record<string, {
|
|
155
155
|
type: number;
|
|
156
156
|
}>;
|
|
@@ -161,13 +161,13 @@ export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
|
161
161
|
name: string;
|
|
162
162
|
id: (string | ID | {
|
|
163
163
|
key: string;
|
|
164
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
164
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
165
165
|
}) & (string | ID | {
|
|
166
166
|
key: string;
|
|
167
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
167
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
168
168
|
} | undefined);
|
|
169
169
|
schema?: {
|
|
170
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
170
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
171
171
|
fields: Record<string, {
|
|
172
172
|
type: number;
|
|
173
173
|
}>;
|
|
@@ -177,37 +177,37 @@ export declare const resourceSchemaZ: z.ZodEffects<z.ZodObject<{
|
|
|
177
177
|
export type Resource = z.infer<typeof resourceSchemaZ>;
|
|
178
178
|
export declare const relationshipSchemaZ: z.ZodObject<{
|
|
179
179
|
from: z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
180
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
180
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
181
181
|
key: string;
|
|
182
182
|
}, string>, z.ZodObject<{
|
|
183
183
|
type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"pid">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">]>;
|
|
184
184
|
key: z.ZodString;
|
|
185
185
|
}, "strip", z.ZodTypeAny, {
|
|
186
186
|
key: string;
|
|
187
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
187
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
188
188
|
}, {
|
|
189
189
|
key: string;
|
|
190
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
190
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
191
191
|
}>]>, z.ZodType<ID, z.ZodTypeDef, ID>]>, ID, string | ID | {
|
|
192
192
|
key: string;
|
|
193
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
193
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
194
194
|
}>;
|
|
195
195
|
type: z.ZodString;
|
|
196
196
|
to: z.ZodEffects<z.ZodUnion<[z.ZodUnion<[z.ZodEffects<z.ZodString, {
|
|
197
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
197
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
198
198
|
key: string;
|
|
199
199
|
}, string>, z.ZodObject<{
|
|
200
200
|
type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"pid">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">]>;
|
|
201
201
|
key: z.ZodString;
|
|
202
202
|
}, "strip", z.ZodTypeAny, {
|
|
203
203
|
key: string;
|
|
204
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
204
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
205
205
|
}, {
|
|
206
206
|
key: string;
|
|
207
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
207
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
208
208
|
}>]>, z.ZodType<ID, z.ZodTypeDef, ID>]>, ID, string | ID | {
|
|
209
209
|
key: string;
|
|
210
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
210
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
211
211
|
}>;
|
|
212
212
|
}, "strip", z.ZodTypeAny, {
|
|
213
213
|
type: string;
|
|
@@ -217,17 +217,17 @@ export declare const relationshipSchemaZ: z.ZodObject<{
|
|
|
217
217
|
type: string;
|
|
218
218
|
from: (string | ID | {
|
|
219
219
|
key: string;
|
|
220
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
220
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
221
221
|
}) & (string | ID | {
|
|
222
222
|
key: string;
|
|
223
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
223
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
224
224
|
} | undefined);
|
|
225
225
|
to: (string | ID | {
|
|
226
226
|
key: string;
|
|
227
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
227
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
228
228
|
}) & (string | ID | {
|
|
229
229
|
key: string;
|
|
230
|
-
type: "user" | "cluster" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot"
|
|
230
|
+
type: "user" | "cluster" | "rack" | "label" | "builtin" | "channel" | "node" | "group" | "range" | "range-alias" | "workspace" | "pid" | "lineplot";
|
|
231
231
|
} | undefined);
|
|
232
232
|
}>;
|
|
233
233
|
export type Relationship = z.infer<typeof relationshipSchemaZ>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {Synnax} from "@synnaxlabs/client";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "examples",
|
|
3
|
+
"type":"module",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"main": "node index.js"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@synnaxlabs/client": "workspace:*"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC"
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.3",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The Client Library for Synnax",
|
|
7
7
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/client/ts",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"control systems"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"async-mutex": "^0.4.0",
|
|
19
20
|
"zod": "3.22.4",
|
|
20
21
|
"@synnaxlabs/freighter": "0.7.1",
|
|
21
22
|
"@synnaxlabs/x": "0.12.0"
|
|
@@ -26,12 +27,12 @@
|
|
|
26
27
|
"typescript": "^5.3.3",
|
|
27
28
|
"vite": "^5.1.2",
|
|
28
29
|
"vitest": "^1.2.2",
|
|
30
|
+
"@synnaxlabs/tsconfig": "0.0.2",
|
|
29
31
|
"@synnaxlabs/vite-plugin": "0.0.1",
|
|
30
|
-
"eslint-config-synnaxlabs": "0.0.1"
|
|
31
|
-
"@synnaxlabs/tsconfig": "0.0.2"
|
|
32
|
+
"eslint-config-synnaxlabs": "0.0.1"
|
|
32
33
|
},
|
|
33
|
-
"main": "dist/client.cjs
|
|
34
|
-
"module": "dist/client.
|
|
34
|
+
"main": "dist/client.cjs",
|
|
35
|
+
"module": "dist/client.js",
|
|
35
36
|
"types": "dist/index.d.ts",
|
|
36
37
|
"scripts": {
|
|
37
38
|
"build": "tsc --noEmit && vite build",
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { newClient } from "@/setupspecs";
|
|
3
|
+
import { DebouncedBatchRetriever, Retriever, analyzeParams } from "@/channel/retriever";
|
|
4
|
+
import { Params, Payload } from "@/channel/payload";
|
|
5
|
+
import { DataType, Rate } from "@synnaxlabs/x";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MockRetriever implements Retriever {
|
|
10
|
+
func: (channels: Params, rangeKey?: string) => Promise<Payload[]>;
|
|
11
|
+
|
|
12
|
+
constructor(func: (channels: Params, rangeKey?: string) => Promise<Payload[]>) {
|
|
13
|
+
this.func = func;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async search(term: string, rangeKey?: string): Promise<Payload[]> {
|
|
17
|
+
throw new Error("Method not implemented.");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async page(offset: number, limit: number, rangeKey?: string): Promise<Payload[]> {
|
|
21
|
+
throw new Error("Method not implemented.");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async retrieve(channels: Params, rangeKey?: string): Promise<Payload[]> {
|
|
25
|
+
return this.func(channels, rangeKey);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
describe("channelRetriever", () => {
|
|
32
|
+
it("should batch multiple retrieve requests", async () => {
|
|
33
|
+
const called = vi.fn();
|
|
34
|
+
const base = new MockRetriever(async (batch): Promise<Payload[]> => {
|
|
35
|
+
called(batch);
|
|
36
|
+
const {normalized} = analyzeParams(batch);
|
|
37
|
+
return normalized.map(
|
|
38
|
+
(key) =>
|
|
39
|
+
({
|
|
40
|
+
key: key as number,
|
|
41
|
+
name: `channel-${key}`,
|
|
42
|
+
dataType: DataType.FLOAT32,
|
|
43
|
+
isIndex: false,
|
|
44
|
+
rate: Rate.hz(1),
|
|
45
|
+
leaseholder: 1,
|
|
46
|
+
index:0
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
});
|
|
50
|
+
const retriever = new DebouncedBatchRetriever(base, 10);
|
|
51
|
+
const res = await Promise.all([
|
|
52
|
+
retriever.retrieve([1]),
|
|
53
|
+
retriever.retrieve([2]),
|
|
54
|
+
retriever.retrieve([3, 4]),
|
|
55
|
+
]);
|
|
56
|
+
expect(called).toHaveBeenCalledTimes(1);
|
|
57
|
+
expect(called).toHaveBeenCalledWith([1, 2, 3, 4]);
|
|
58
|
+
expect(res.map((r) => r.map((c) => c.key))).toEqual([[1], [2], [3, 4]]);
|
|
59
|
+
});
|
|
60
|
+
it("should only fetch duplicate keys once", async () => {
|
|
61
|
+
const called = vi.fn();
|
|
62
|
+
const base = new MockRetriever(async (batch): Promise<Payload[]> => {
|
|
63
|
+
called(batch);
|
|
64
|
+
const {normalized} = analyzeParams(batch);
|
|
65
|
+
return normalized.map(
|
|
66
|
+
(key) =>
|
|
67
|
+
({
|
|
68
|
+
key: key as number,
|
|
69
|
+
name: `channel-${key}`,
|
|
70
|
+
dataType: DataType.FLOAT32,
|
|
71
|
+
isIndex: false,
|
|
72
|
+
rate: Rate.hz(1),
|
|
73
|
+
leaseholder: 1,
|
|
74
|
+
index:0
|
|
75
|
+
}),
|
|
76
|
+
);
|
|
77
|
+
})
|
|
78
|
+
const retriever = new DebouncedBatchRetriever(base, 10);
|
|
79
|
+
const res = await Promise.all([
|
|
80
|
+
retriever.retrieve([1]),
|
|
81
|
+
retriever.retrieve([2]),
|
|
82
|
+
retriever.retrieve([1, 2]),
|
|
83
|
+
]);
|
|
84
|
+
expect(called).toHaveBeenCalledTimes(1);
|
|
85
|
+
expect(called).toHaveBeenCalledWith([1, 2]);
|
|
86
|
+
expect(res.map((r) => r.map((c) => c.key))).toEqual([[1], [2], [1, 2]]);
|
|
87
|
+
});
|
|
88
|
+
it("should throw an error if the fetch fails", async () => {
|
|
89
|
+
const base = new MockRetriever(async (batch): Promise<Payload[]> => {
|
|
90
|
+
throw new Error("failed to fetch");
|
|
91
|
+
});
|
|
92
|
+
const retriever = new DebouncedBatchRetriever(base, 10);
|
|
93
|
+
await expect(retriever.retrieve([1])).rejects.toThrow("failed to fetch");
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -43,6 +43,25 @@ describe("Channel", () => {
|
|
|
43
43
|
});
|
|
44
44
|
expect(two.key).not.toEqual(0);
|
|
45
45
|
});
|
|
46
|
+
test("create many", async () => {
|
|
47
|
+
const channels = await client.channels.create([
|
|
48
|
+
{
|
|
49
|
+
name: "test1",
|
|
50
|
+
leaseholder: 1,
|
|
51
|
+
rate: Rate.hz(1),
|
|
52
|
+
dataType: DataType.FLOAT32,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: "test2",
|
|
56
|
+
leaseholder: 1,
|
|
57
|
+
rate: Rate.hz(1),
|
|
58
|
+
dataType: DataType.FLOAT32,
|
|
59
|
+
},
|
|
60
|
+
]);
|
|
61
|
+
expect(channels.length).toEqual(2);
|
|
62
|
+
expect(channels[0].name).toEqual("test1");
|
|
63
|
+
expect(channels[1].name).toEqual("test2");
|
|
64
|
+
});
|
|
46
65
|
});
|
|
47
66
|
test("retrieve by key", async () => {
|
|
48
67
|
const channel = await client.channels.create({
|
|
@@ -62,7 +81,6 @@ describe("Channel", () => {
|
|
|
62
81
|
QueryError,
|
|
63
82
|
);
|
|
64
83
|
});
|
|
65
|
-
|
|
66
84
|
test("retrieve by name", async () => {
|
|
67
85
|
const retrieved = await client.channels.retrieve(["test"]);
|
|
68
86
|
expect(retrieved.length).toBeGreaterThan(0);
|
|
@@ -73,7 +91,6 @@ describe("Channel", () => {
|
|
|
73
91
|
QueryError,
|
|
74
92
|
);
|
|
75
93
|
});
|
|
76
|
-
|
|
77
94
|
test("retrieve by name", async () => {
|
|
78
95
|
const retrieved = await client.channels.retrieve(["test"]);
|
|
79
96
|
expect(retrieved.length).toBeGreaterThan(0);
|