@synnaxlabs/client 0.22.0 → 0.22.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 +5 -5
- package/dist/client.cjs +7 -7
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +721 -713
- package/dist/client.js.map +1 -1
- package/dist/framer/client.d.ts +1 -1
- package/dist/framer/client.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/payload.d.ts.map +1 -1
- package/dist/workspace/retriever.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/framer/client.ts +4 -2
- package/src/util/zod.ts +2 -2
- package/src/workspace/payload.ts +10 -2
- package/src/workspace/retriever.ts +12 -2
package/dist/framer/client.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Iterator } from './iterator';
|
|
|
4
4
|
import { Frame } from './frame';
|
|
5
5
|
import { Retriever } from '../channel/retriever';
|
|
6
6
|
import { KeysOrNames, KeyOrName, Params } from '../channel/payload';
|
|
7
|
-
import { CrudeTimeStamp, CrudeSeries, CrudeTimeRange, MultiSeries } from '@synnaxlabs/x
|
|
7
|
+
import { CrudeTimeStamp, CrudeSeries, CrudeTimeRange, MultiSeries } from '@synnaxlabs/x';
|
|
8
8
|
import { StreamClient } from '@synnaxlabs/freighter';
|
|
9
9
|
|
|
10
10
|
export declare class Client {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/framer/client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/framer/client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,Y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c,EACrB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,WAAW,EAAE,GAClB,OAAO,CAAC,IAAI,CAAC;IAEV,KAAK,CACT,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC;IA6CV,IAAI,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAElE,IAAI,CAAC,EAAE,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;YASlD,SAAS;CAUxB"}
|
package/dist/util/zod.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
export declare const nullableArrayZ: <Z extends z.ZodTypeAny>(item: Z) => z.ZodUnion<[z.ZodEffects<z.ZodNull,
|
|
3
|
+
export declare const nullableArrayZ: <Z extends z.ZodTypeAny>(item: Z) => z.ZodUnion<[z.ZodEffects<z.ZodNull, z.output<Z>[], null>, z.ZodArray<Z, "many">]>;
|
|
4
4
|
//# sourceMappingURL=zod.d.ts.map
|
package/dist/util/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/util/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/util/zod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,cAAc,iCAAkC,CAAC,sFACU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/workspace/payload.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,IAAI,aAAoB,CAAC;AAEtC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAEvC,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/workspace/payload.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,IAAI,aAAoB,CAAC;AAEtC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAEvC,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;AAUjC,eAAO,MAAM,UAAU;;;;;;;;;;;;EAMrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAE3B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retriever.d.ts","sourceRoot":"","sources":["../../src/workspace/retriever.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIvE,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"retriever.d.ts","sourceRoot":"","sources":["../../src/workspace/retriever.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIvE,OAAO,EACL,KAAK,MAAM,EACX,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAC;AAmB7B,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAEzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAIzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAK9C,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAItD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAI1C,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;YAIjD,OAAO;CAUtB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/client",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.22.
|
|
4
|
+
"version": "0.22.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "The Client Library for Synnax",
|
|
7
7
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/client/ts",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"async-mutex": "^0.5.0",
|
|
20
20
|
"nanoid": "^5.0.7",
|
|
21
21
|
"zod": "3.22.4",
|
|
22
|
-
"@synnaxlabs/
|
|
23
|
-
"@synnaxlabs/
|
|
22
|
+
"@synnaxlabs/x": "0.16.0",
|
|
23
|
+
"@synnaxlabs/freighter": "0.10.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^20.12.7",
|
package/src/framer/client.ts
CHANGED
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
type CrudeSeries,
|
|
14
14
|
type CrudeTimeRange,
|
|
15
15
|
type MultiSeries,
|
|
16
|
-
|
|
16
|
+
TimeSpan,
|
|
17
|
+
} from "@synnaxlabs/x";
|
|
17
18
|
|
|
18
19
|
import { KeysOrNames, type KeyOrName, type Params } from "@/channel/payload";
|
|
19
20
|
import { type Retriever, analyzeChannelParams } from "@/channel/retriever";
|
|
@@ -135,10 +136,11 @@ export class Client {
|
|
|
135
136
|
start,
|
|
136
137
|
channels: channels as Params,
|
|
137
138
|
mode: WriterMode.PersistOnly,
|
|
139
|
+
enableAutoCommit: true,
|
|
140
|
+
autoIndexPersistInterval: TimeSpan.MAX,
|
|
138
141
|
});
|
|
139
142
|
try {
|
|
140
143
|
await w.write(channels as Params, data);
|
|
141
|
-
await w.commit();
|
|
142
144
|
} finally {
|
|
143
145
|
await w.close();
|
|
144
146
|
}
|
package/src/util/zod.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export const nullableArrayZ = <Z extends z.ZodTypeAny>(item: Z) =>
|
|
4
|
+
z.union([z.null().transform(() => [] as z.output<Z>[]), item.array()]);
|
package/src/workspace/payload.ts
CHANGED
|
@@ -17,16 +17,24 @@ export type Key = z.infer<typeof keyZ>;
|
|
|
17
17
|
|
|
18
18
|
export type Params = Key | Key[];
|
|
19
19
|
|
|
20
|
+
// --- VERY IMPORTANT ---
|
|
21
|
+
// Synnax's encoders (in the binary package inside x) automatically convert the case
|
|
22
|
+
// of keys in objects to snake_case and back to camelCase when encoding and decoding
|
|
23
|
+
// respectively. This is done to ensure that the keys are consistent across all
|
|
24
|
+
// languages and platforms. Sometimes workspaces have keys that are uuids, which have
|
|
25
|
+
// dashes, and those get messed up. So we just use regular JSON for workspaces.
|
|
26
|
+
const parse = (s: string): UnknownRecord => JSON.parse(s) as UnknownRecord;
|
|
27
|
+
|
|
20
28
|
export const workspaceZ = z.object({
|
|
21
29
|
name: z.string(),
|
|
22
30
|
key: keyZ,
|
|
23
31
|
layout: unknownRecordZ.or(
|
|
24
|
-
z.string().transform((s) =>
|
|
32
|
+
z.string().transform((s) => JSON.parse(s) as UnknownRecord),
|
|
25
33
|
),
|
|
26
34
|
});
|
|
27
35
|
|
|
28
36
|
export const workspaceRemoteZ = workspaceZ.omit({ layout: true }).extend({
|
|
29
|
-
layout: z.string().transform((s) =>
|
|
37
|
+
layout: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
|
|
30
38
|
});
|
|
31
39
|
|
|
32
40
|
export type Workspace = z.infer<typeof workspaceZ>;
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
keyZ,
|
|
18
18
|
workspaceRemoteZ,
|
|
19
19
|
} from "@/workspace/payload";
|
|
20
|
+
import { nullableArrayZ } from "@/util/zod";
|
|
20
21
|
|
|
21
22
|
const reqZ = z.object({
|
|
22
23
|
keys: keyZ.array().optional(),
|
|
@@ -29,9 +30,11 @@ const reqZ = z.object({
|
|
|
29
30
|
type Request = z.infer<typeof reqZ>;
|
|
30
31
|
|
|
31
32
|
const resZ = z.object({
|
|
32
|
-
workspaces: workspaceRemoteZ
|
|
33
|
+
workspaces: nullableArrayZ(workspaceRemoteZ),
|
|
33
34
|
});
|
|
34
35
|
|
|
36
|
+
type Response = z.infer<typeof resZ>;
|
|
37
|
+
|
|
35
38
|
export class Retriever {
|
|
36
39
|
private static readonly ENDPOINT = "/workspace/retrieve";
|
|
37
40
|
|
|
@@ -59,6 +62,13 @@ export class Retriever {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
private async execute(request: Request): Promise<Workspace[]> {
|
|
62
|
-
|
|
65
|
+
const res = await sendRequired(
|
|
66
|
+
this.client,
|
|
67
|
+
Retriever.ENDPOINT,
|
|
68
|
+
request,
|
|
69
|
+
reqZ,
|
|
70
|
+
resZ,
|
|
71
|
+
);
|
|
72
|
+
return res.workspaces;
|
|
63
73
|
}
|
|
64
74
|
}
|