@synnaxlabs/client 0.37.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/dist/access/policy/payload.d.ts +10 -10
  3. package/dist/channel/client.d.ts +13 -1
  4. package/dist/channel/client.d.ts.map +1 -1
  5. package/dist/channel/payload.d.ts +14 -0
  6. package/dist/channel/payload.d.ts.map +1 -1
  7. package/dist/client.cjs +30 -30
  8. package/dist/client.js +2149 -2092
  9. package/dist/framer/frame.d.ts.map +1 -1
  10. package/dist/hardware/device/payload.d.ts +2 -2
  11. package/dist/hardware/device/payload.d.ts.map +1 -1
  12. package/dist/hardware/task/client.d.ts.map +1 -1
  13. package/dist/hardware/task/payload.d.ts +4 -4
  14. package/dist/hardware/task/payload.d.ts.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/label/client.d.ts.map +1 -1
  18. package/dist/ontology/group/group.d.ts.map +1 -1
  19. package/dist/ontology/payload.d.ts.map +1 -1
  20. package/dist/ranger/client.d.ts.map +1 -1
  21. package/dist/ranger/payload.d.ts +2 -2
  22. package/dist/ranger/payload.d.ts.map +1 -1
  23. package/dist/util/retrieve.d.ts.map +1 -1
  24. package/dist/util/zod.d.ts +1 -1
  25. package/dist/util/zod.d.ts.map +1 -1
  26. package/examples/node/package-lock.json +56 -5509
  27. package/examples/node/package.json +1 -1
  28. package/package.json +10 -14
  29. package/src/access/policy/policy.spec.ts +1 -4
  30. package/src/channel/batchRetriever.spec.ts +4 -0
  31. package/src/channel/channel.spec.ts +108 -37
  32. package/src/channel/client.ts +45 -2
  33. package/src/channel/payload.ts +5 -0
  34. package/src/framer/frame.ts +3 -4
  35. package/src/framer/streamer.spec.ts +178 -0
  36. package/src/hardware/task/client.ts +3 -2
  37. package/src/index.ts +1 -1
  38. package/src/label/client.ts +2 -2
  39. package/src/ontology/group/group.ts +3 -5
  40. package/src/ontology/payload.ts +1 -1
  41. package/src/ranger/client.ts +6 -11
  42. package/src/ranger/payload.ts +2 -2
  43. package/src/util/retrieve.ts +2 -2
  44. package/src/util/zod.ts +4 -1
  45. package/vite.config.ts +5 -12
  46. package/api/client.api.md +0 -3473
  47. package/api-extractor.json +0 -7
  48. package/dist/hardware/task/ni/types.d.ts +0 -14495
  49. package/dist/hardware/task/ni/types.d.ts.map +0 -1
  50. package/dist/workspace/lineplot/payload.d.ts +0 -23
  51. package/dist/workspace/lineplot/payload.d.ts.map +0 -1
  52. package/src/hardware/task/ni/types.ts +0 -1716
  53. package/src/workspace/lineplot/payload.ts +0 -30
@@ -7,7 +7,8 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
- import { ontology } from "@/ontology";
10
+ import { type ontology } from "@/ontology";
11
+ import { ontologyID as payloadOntologyID } from "@/ontology/group/payload";
11
12
 
12
13
  export class Group {
13
14
  key: string;
@@ -19,9 +20,6 @@ export class Group {
19
20
  }
20
21
 
21
22
  get ontologyID(): ontology.ID {
22
- return new ontology.ID({
23
- type: "group",
24
- key: this.key,
25
- });
23
+ return payloadOntologyID(this.key);
26
24
  }
27
25
  }
@@ -95,7 +95,7 @@ export class ID {
95
95
  static readonly z = z.union([z.instanceof(ID), crudeIDZ.transform((v) => new ID(v))]);
96
96
  }
97
97
 
98
- export const Root = new ID({ type: "builtin", key: "root" });
98
+ export const Root = new ID({ type: BUILTIN_TYPE, key: "root" });
99
99
 
100
100
  export const schemaFieldZ = z.object({ type: z.number() });
101
101
 
@@ -20,7 +20,7 @@ import { MultipleFoundError, NotFoundError, QueryError } from "@/errors";
20
20
  import { type framer } from "@/framer";
21
21
  import { type label } from "@/label";
22
22
  import { type Label } from "@/label/payload";
23
- import { ontology } from "@/ontology";
23
+ import { type ontology } from "@/ontology";
24
24
  import { type Resource } from "@/ontology/payload";
25
25
  import { type Alias, Aliaser } from "@/ranger/alias";
26
26
  import { KV } from "@/ranger/kv";
@@ -32,6 +32,7 @@ import {
32
32
  type Name,
33
33
  type Names,
34
34
  type NewPayload,
35
+ ontologyID,
35
36
  type Params,
36
37
  type Payload,
37
38
  payloadZ,
@@ -40,9 +41,6 @@ import { type CreateOptions, type Writer } from "@/ranger/writer";
40
41
  import { signals } from "@/signals";
41
42
  import { nullableArrayZ } from "@/util/zod";
42
43
 
43
- const ontologyID = (key: string): ontology.ID =>
44
- new ontology.ID({ type: "range", key });
45
-
46
44
  export class Range {
47
45
  key: string;
48
46
  name: string;
@@ -83,7 +81,7 @@ export class Range {
83
81
  }
84
82
 
85
83
  get ontologyID(): ontology.ID {
86
- return new ontology.ID({ key: this.key, type: "range" });
84
+ return ontologyID(this.key);
87
85
  }
88
86
 
89
87
  get payload(): Payload {
@@ -155,7 +153,7 @@ export class Range {
155
153
  async openChildRangeTracker(): Promise<observe.ObservableAsyncCloseable<Range[]>> {
156
154
  const wrapper = new observe.Observer<Range[]>();
157
155
  const initial: ontology.Resource[] = (await this.retrieveChildren()).map((r) => {
158
- const id = new ontology.ID({ key: r.key, type: "range" });
156
+ const id = ontologyID(r.key);
159
157
  return { id, key: id.toString(), name: r.name, data: r.payload };
160
158
  });
161
159
  const base = await this.ontologyClient.openDependentTracker({
@@ -174,7 +172,7 @@ export class Range {
174
172
  const wrapper = new observe.Observer<Range>();
175
173
  const p = await this.retrieveParent();
176
174
  if (p == null) return null;
177
- const id = new ontology.ID({ key: p.key, type: "range" });
175
+ const id = ontologyID(p.key);
178
176
  const resourceP = { id, key: id.toString(), name: p.name, data: p.payload };
179
177
  const base = await this.ontologyClient.openDependentTracker({
180
178
  target: this.ontologyID,
@@ -302,10 +300,7 @@ export class Client implements AsyncTermSearcher<string, Key, Range> {
302
300
  }
303
301
 
304
302
  async retrieveParent(range: Key): Promise<Range | null> {
305
- const res = await this.ontologyClient.retrieveParents({
306
- key: range,
307
- type: "range",
308
- });
303
+ const res = await this.ontologyClient.retrieveParents(ontologyID(range));
309
304
  if (res.length === 0) return null;
310
305
  const first = res[0];
311
306
  if (first.id.type !== "range") return null;
@@ -78,8 +78,8 @@ export const analyzeParams = (ranges: Params): ParamAnalysisResult => {
78
78
  export const ONTOLOGY_TYPE: ontology.ResourceType = "range";
79
79
  export const ALIAS_ONTOLOGY_TYPE: ontology.ResourceType = "range-alias";
80
80
 
81
- export const rangeOntologyID = (key: Key): ontology.ID =>
81
+ export const ontologyID = (key: Key): ontology.ID =>
82
82
  new ontology.ID({ type: ONTOLOGY_TYPE, key });
83
83
 
84
- export const rangeAliasOntologyID = (key: Key): ontology.ID =>
84
+ export const aliasOntologyID = (key: Key): ontology.ID =>
85
85
  new ontology.ID({ type: ALIAS_ONTOLOGY_TYPE, key });
@@ -7,7 +7,7 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
- import { type Primitive,toArray } from "@synnaxlabs/x";
10
+ import { type Primitive, toArray } from "@synnaxlabs/x";
11
11
 
12
12
  import { MultipleFoundError, NotFoundError } from "@/errors";
13
13
 
@@ -84,7 +84,7 @@ export const analyzeParams = <
84
84
  variant,
85
85
  normalized: normal,
86
86
  actual: args,
87
- } as unknown as ParamAnalysisResult<T, K>;
87
+ } as ParamAnalysisResult<T, K>;
88
88
  };
89
89
 
90
90
  export const checkForMultipleOrNoResults = <T, R>(
package/src/util/zod.ts CHANGED
@@ -10,4 +10,7 @@
10
10
  import { z } from "zod";
11
11
 
12
12
  export const nullableArrayZ = <Z extends z.ZodTypeAny>(item: Z) =>
13
- z.union([z.null().transform(() => [] as z.output<Z>[]), item.array()]);
13
+ z.union([
14
+ z.union([z.null(), z.undefined()]).transform(() => [] as z.output<Z>[]),
15
+ item.array(),
16
+ ]);
package/vite.config.ts CHANGED
@@ -7,23 +7,16 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
+ /// <reference types="vitest/config" />
11
+
10
12
  import { lib } from "@synnaxlabs/vite-plugin";
11
13
  import { defineConfig } from "vite";
12
14
 
13
15
  import packageJSON from "./package.json";
14
16
 
15
17
  export default defineConfig({
16
- define: {
17
- __VERSION__: JSON.stringify(packageJSON.version),
18
- },
18
+ define: { __VERSION__: JSON.stringify(packageJSON.version) },
19
19
  plugins: [lib({ name: "client" })],
20
- build: {
21
- rollupOptions: {
22
- external: ["zod"],
23
- },
24
- },
25
- test: {
26
- globals: true,
27
- environment: "jsdom",
28
- },
20
+ build: { rollupOptions: { external: ["zod"] } },
21
+ test: { globals: true, environment: "jsdom" },
29
22
  });