@synnaxlabs/client 0.34.0 → 0.35.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 (48) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/dist/access/policy/payload.d.ts +40 -40
  3. package/dist/access/policy/retriever.d.ts +5 -5
  4. package/dist/client.cjs +19 -19
  5. package/dist/client.js +1758 -1609
  6. package/dist/hardware/device/client.d.ts +2 -2
  7. package/dist/hardware/device/client.d.ts.map +1 -1
  8. package/dist/hardware/task/client.d.ts +4 -2
  9. package/dist/hardware/task/client.d.ts.map +1 -1
  10. package/dist/hardware/task/payload.d.ts +7 -3
  11. package/dist/hardware/task/payload.d.ts.map +1 -1
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/label/writer.d.ts +5 -5
  15. package/dist/ontology/client.d.ts +8 -8
  16. package/dist/ontology/payload.d.ts +43 -43
  17. package/dist/ontology/payload.d.ts.map +1 -1
  18. package/dist/ranger/writer.d.ts +5 -5
  19. package/dist/workspace/client.d.ts +2 -0
  20. package/dist/workspace/client.d.ts.map +1 -1
  21. package/dist/workspace/table/client.d.ts +16 -0
  22. package/dist/workspace/table/client.d.ts.map +1 -0
  23. package/dist/workspace/table/external.d.ts +3 -0
  24. package/dist/workspace/table/external.d.ts.map +1 -0
  25. package/dist/workspace/table/index.d.ts +2 -0
  26. package/dist/workspace/table/index.d.ts.map +1 -0
  27. package/dist/workspace/table/payload.d.ts +36 -0
  28. package/dist/workspace/table/payload.d.ts.map +1 -0
  29. package/dist/workspace/table/retriever.d.ts +8 -0
  30. package/dist/workspace/table/retriever.d.ts.map +1 -0
  31. package/dist/workspace/table/table.spec.d.ts +2 -0
  32. package/dist/workspace/table/table.spec.d.ts.map +1 -0
  33. package/dist/workspace/table/writer.d.ts +35 -0
  34. package/dist/workspace/table/writer.d.ts.map +1 -0
  35. package/package.json +5 -5
  36. package/src/hardware/device/client.ts +10 -4
  37. package/src/hardware/task/client.ts +51 -3
  38. package/src/hardware/task/payload.ts +21 -6
  39. package/src/index.ts +1 -0
  40. package/src/ontology/payload.ts +1 -0
  41. package/src/workspace/client.ts +3 -0
  42. package/src/workspace/table/client.ts +51 -0
  43. package/src/workspace/table/external.ts +11 -0
  44. package/src/workspace/table/index.ts +10 -0
  45. package/src/workspace/table/payload.ts +36 -0
  46. package/src/workspace/table/retriever.ts +33 -0
  47. package/src/workspace/table/table.spec.ts +65 -0
  48. package/src/workspace/table/writer.ts +102 -0
@@ -3,13 +3,13 @@ import { z } from 'zod';
3
3
  import { NewPayload, Payload } from './payload';
4
4
  declare const createReqZ: z.ZodObject<{
5
5
  parent: z.ZodOptional<z.ZodObject<{
6
- type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"log">, z.ZodLiteral<"allow_all">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"framer">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"schematic">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">, z.ZodLiteral<"device">, z.ZodLiteral<"task">, z.ZodLiteral<"policy">]>;
6
+ type: z.ZodUnion<[z.ZodLiteral<"label">, z.ZodLiteral<"log">, z.ZodLiteral<"allow_all">, z.ZodLiteral<"builtin">, z.ZodLiteral<"cluster">, z.ZodLiteral<"channel">, z.ZodLiteral<"node">, z.ZodLiteral<"group">, z.ZodLiteral<"range">, z.ZodLiteral<"framer">, z.ZodLiteral<"range-alias">, z.ZodLiteral<"user">, z.ZodLiteral<"workspace">, z.ZodLiteral<"schematic">, z.ZodLiteral<"lineplot">, z.ZodLiteral<"rack">, z.ZodLiteral<"device">, z.ZodLiteral<"task">, z.ZodLiteral<"policy">, z.ZodLiteral<"table">]>;
7
7
  key: z.ZodString;
8
8
  }, "strip", z.ZodTypeAny, {
9
- type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy";
9
+ type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy" | "table";
10
10
  key: string;
11
11
  }, {
12
- type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy";
12
+ type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy" | "table";
13
13
  key: string;
14
14
  }>>;
15
15
  ranges: z.ZodArray<z.ZodObject<z.objectUtil.extendShape<{
@@ -81,7 +81,7 @@ declare const createReqZ: z.ZodObject<{
81
81
  color?: string | undefined;
82
82
  }[];
83
83
  parent?: {
84
- type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy";
84
+ type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy" | "table";
85
85
  key: string;
86
86
  } | undefined;
87
87
  }, {
@@ -99,7 +99,7 @@ declare const createReqZ: z.ZodObject<{
99
99
  color?: string | undefined;
100
100
  }[];
101
101
  parent?: {
102
- type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy";
102
+ type: "label" | "log" | "allow_all" | "builtin" | "cluster" | "channel" | "node" | "group" | "range" | "framer" | "range-alias" | "user" | "workspace" | "schematic" | "lineplot" | "rack" | "device" | "task" | "policy" | "table";
103
103
  key: string;
104
104
  } | undefined;
105
105
  }>;
@@ -5,12 +5,14 @@ import { linePlot } from './lineplot';
5
5
  import { log } from './log';
6
6
  import { Key, Workspace } from './payload';
7
7
  import { schematic } from './schematic';
8
+ import { table } from './table';
8
9
  import { NewWorkspace } from './writer';
9
10
  export declare class Client implements AsyncTermSearcher<string, Key, Workspace> {
10
11
  readonly type = "workspace";
11
12
  readonly schematic: schematic.Client;
12
13
  readonly linePlot: linePlot.Client;
13
14
  readonly log: log.Client;
15
+ readonly table: table.Client;
14
16
  private readonly retriever;
15
17
  private readonly writer;
16
18
  constructor(client: UnaryClient);
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/workspace/client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,oBAAoB,CAAC;AAE/D,qBAAa,MAAO,YAAW,iBAAiB,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,CAAC;IACtE,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,C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E,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzD,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5C"}
@@ -0,0 +1,16 @@
1
+ import { UnaryClient } from '@synnaxlabs/freighter';
2
+ import { UnknownRecord } from '@synnaxlabs/x/record';
3
+ import { Key, Params, Table } from './payload';
4
+ import { NewTable } from './writer';
5
+ export declare class Client {
6
+ private readonly writer;
7
+ private readonly retriever;
8
+ constructor(client: UnaryClient);
9
+ create(workspace: string, table: NewTable): Promise<Table>;
10
+ rename(key: Key, name: string): Promise<void>;
11
+ setData(key: Key, data: UnknownRecord): Promise<void>;
12
+ retrieve(key: Key): Promise<Table>;
13
+ retrieve(keys: Key[]): Promise<Table[]>;
14
+ delete(keys: Params): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAE9E,OAAO,EAAE,KAAK,QAAQ,EAAU,MAAM,0BAA0B,CAAC;AAEjE,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,MAAM,EAAE,WAAW;IAKzB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAI1D,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrD,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC;IAElC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAQvC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG1C"}
@@ -0,0 +1,3 @@
1
+ export * from './client';
2
+ export * from './payload';
3
+ //# sourceMappingURL=external.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/external.ts"],"names":[],"mappings":"AASA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * as table from './external';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { UnknownRecord } from '@synnaxlabs/x/record';
2
+ import { z } from 'zod';
3
+ import { ontology } from '../../ontology';
4
+ export declare const keyZ: z.ZodString;
5
+ export type Key = z.infer<typeof keyZ>;
6
+ export type Params = Key | Key[];
7
+ export declare const tableZ: z.ZodObject<{
8
+ key: z.ZodString;
9
+ name: z.ZodString;
10
+ data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, UnknownRecord, string>]>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ name: string;
13
+ key: string;
14
+ data: UnknownRecord | Record<string | number | symbol, unknown>;
15
+ }, {
16
+ name: string;
17
+ key: string;
18
+ data: string | Record<string | number | symbol, unknown>;
19
+ }>;
20
+ export declare const tableRemoteZ: z.ZodObject<{
21
+ key: z.ZodString;
22
+ name: z.ZodString;
23
+ data: z.ZodEffects<z.ZodString, UnknownRecord, string>;
24
+ }, "strip", z.ZodTypeAny, {
25
+ name: string;
26
+ key: string;
27
+ data: UnknownRecord;
28
+ }, {
29
+ name: string;
30
+ key: string;
31
+ data: string;
32
+ }>;
33
+ export type Table = z.infer<typeof tableZ>;
34
+ export declare const ONTOLOGY_TYPE: ontology.ResourceType;
35
+ export declare const ontologyID: (key: Key) => ontology.ID;
36
+ //# sourceMappingURL=payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/payload.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,eAAO,MAAM,IAAI,aAAoB,CAAC;AACtC,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;AAEjC,eAAO,MAAM,MAAM;;;;;;;;;;;;EAIjB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;EAIvB,CAAC;AAEH,MAAM,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,CAAC;AAE3C,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,YAAsB,CAAC;AAE5D,eAAO,MAAM,UAAU,QAAS,GAAG,KAAG,QAAQ,CAAC,EACA,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { UnaryClient } from '@synnaxlabs/freighter';
2
+ import { Params, Table } from './payload';
3
+ export declare class Retriever {
4
+ private readonly client;
5
+ constructor(client: UnaryClient);
6
+ retrieve(tables: Params): Promise<Table[]>;
7
+ }
8
+ //# sourceMappingURL=retriever.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retriever.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/retriever.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIvE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAgB,MAAM,2BAA2B,CAAC;AAOlF,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAIzB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;CAKjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=table.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.spec.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/table.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { UnaryClient } from '@synnaxlabs/freighter';
2
+ import { UnknownRecord } from '@synnaxlabs/x/record';
3
+ import { z } from 'zod';
4
+ import { Key, Params, Table } from './payload';
5
+ export declare const newTableZ: z.ZodEffects<z.ZodObject<{
6
+ name: z.ZodString;
7
+ key: z.ZodOptional<z.ZodString>;
8
+ data: z.ZodUnion<[z.ZodRecord<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodSymbol]>, z.ZodUnknown>, z.ZodEffects<z.ZodString, UnknownRecord, string>]>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ name: string;
11
+ data: UnknownRecord | Record<string | number | symbol, unknown>;
12
+ key?: string | undefined;
13
+ }, {
14
+ name: string;
15
+ data: string | Record<string | number | symbol, unknown>;
16
+ key?: string | undefined;
17
+ }>, {
18
+ data: string;
19
+ name: string;
20
+ key?: string | undefined;
21
+ }, {
22
+ name: string;
23
+ data: string | Record<string | number | symbol, unknown>;
24
+ key?: string | undefined;
25
+ }>;
26
+ export type NewTable = z.input<typeof newTableZ>;
27
+ export declare class Writer {
28
+ private readonly client;
29
+ constructor(client: UnaryClient);
30
+ create(workspace: string, table: NewTable): Promise<Table>;
31
+ delete(tables: Params): Promise<void>;
32
+ rename(table: Key, name: string): Promise<void>;
33
+ setData(table: Key, data: UnknownRecord): Promise<void>;
34
+ }
35
+ //# sourceMappingURL=writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../../src/workspace/table/writer.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EACL,KAAK,GAAG,EAER,KAAK,MAAM,EACX,KAAK,KAAK,EAGX,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;EAEuC,CAAC;AAE9D,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAuBjD,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAIzB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAa1D,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU/C,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAS9D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/client",
3
- "version": "0.34.0",
3
+ "version": "0.35.0",
4
4
  "description": "The Synnax Client Library",
5
5
  "keywords": [
6
6
  "synnax",
@@ -26,8 +26,8 @@
26
26
  "dependencies": {
27
27
  "async-mutex": "^0.5.0",
28
28
  "zod": "^3.23.8",
29
- "@synnaxlabs/freighter": "0.34.0",
30
- "@synnaxlabs/x": "0.34.0"
29
+ "@synnaxlabs/x": "0.35.0",
30
+ "@synnaxlabs/freighter": "0.35.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/node": "^22.7.5",
@@ -38,9 +38,9 @@
38
38
  "uuid": "^10.0.0",
39
39
  "vite": "^5.4.10",
40
40
  "vitest": "^2.1.4",
41
- "@synnaxlabs/vite-plugin": "0.0.1",
41
+ "eslint-config-synnaxlabs": "0.0.1",
42
42
  "@synnaxlabs/tsconfig": "0.0.2",
43
- "eslint-config-synnaxlabs": "0.0.1"
43
+ "@synnaxlabs/vite-plugin": "0.0.1"
44
44
  },
45
45
  "type": "module",
46
46
  "types": "dist/index.d.ts",
@@ -117,11 +117,17 @@ export class Client implements AsyncTermSearcher<string, DeviceKey, Device> {
117
117
  ).devices;
118
118
  }
119
119
 
120
- async create(device: NewDevice): Promise<Device>;
120
+ async create<P extends UnknownRecord = UnknownRecord>(
121
+ device: NewDevice<P>,
122
+ ): Promise<Device<P>>;
121
123
 
122
- async create(devices: NewDevice[]): Promise<Device[]>;
124
+ async create<P extends UnknownRecord = UnknownRecord>(
125
+ devices: NewDevice<P>[],
126
+ ): Promise<Device<P>[]>;
123
127
 
124
- async create(devices: NewDevice | NewDevice[]): Promise<Device | Device[]> {
128
+ async create<P extends UnknownRecord = UnknownRecord>(
129
+ devices: NewDevice<P> | NewDevice<P>[],
130
+ ): Promise<Device<P> | Device<P>[]> {
125
131
  const isSingle = !Array.isArray(devices);
126
132
  const res = await sendRequired(
127
133
  this.client,
@@ -130,7 +136,7 @@ export class Client implements AsyncTermSearcher<string, DeviceKey, Device> {
130
136
  createReqZ,
131
137
  createResZ,
132
138
  );
133
- return isSingle ? res.devices[0] : res.devices;
139
+ return isSingle ? (res.devices[0] as Device<P>) : (res.devices as Device<P>[]);
134
140
  }
135
141
 
136
142
  async delete(keys: string | string[]): Promise<void> {
@@ -19,6 +19,9 @@ import { framer } from "@/framer";
19
19
  import { type Frame } from "@/framer/frame";
20
20
  import { rack } from "@/hardware/rack";
21
21
  import {
22
+ type Command,
23
+ type CommandObservable,
24
+ commandZ,
22
25
  type NewTask,
23
26
  newTaskZ,
24
27
  type Payload,
@@ -46,7 +49,7 @@ export class Task<
46
49
  T extends string = string,
47
50
  > {
48
51
  readonly key: TaskKey;
49
- readonly name: string;
52
+ name: string;
50
53
  readonly internal: boolean;
51
54
  readonly type: T;
52
55
  config: C;
@@ -139,7 +142,10 @@ export class Task<
139
142
  const s = frame.get(TASK_STATE_CHANNEL);
140
143
  if (s.length === 0) return [null, false];
141
144
  const parse = stateZ.safeParse(s.at(-1));
142
- if (!parse.success) return [null, false];
145
+ if (!parse.success) {
146
+ console.error(parse.error);
147
+ return [null, false];
148
+ }
143
149
  const state = parse.data as State<D>;
144
150
  if (state.task !== this.key) return [null, false];
145
151
  return [state, true];
@@ -147,6 +153,27 @@ export class Task<
147
153
  );
148
154
  }
149
155
 
156
+ async openCommandObserver<A extends UnknownRecord = UnknownRecord>(): Promise<
157
+ CommandObservable<A>
158
+ > {
159
+ if (this.frameClient == null) throw TASK_NOT_CREATED;
160
+ return new framer.ObservableStreamer<Command<A>>(
161
+ await this.frameClient.openStreamer(TASK_CMD_CHANNEL),
162
+ (frame) => {
163
+ const s = frame.get(TASK_CMD_CHANNEL);
164
+ if (s.length === 0) return [null, false];
165
+ const parse = commandZ.safeParse(s.at(-1));
166
+ if (!parse.success) {
167
+ console.error(parse.error);
168
+ return [null, false];
169
+ }
170
+ const cmd = parse.data as Command<A>;
171
+ if (cmd.task !== this.key) return [null, false];
172
+ return [cmd, true];
173
+ },
174
+ );
175
+ }
176
+
150
177
  async snapshottedTo(): Promise<ontology.Resource | null> {
151
178
  if (this.ontologyClient == null || this.rangeClient == null) throw TASK_NOT_CREATED;
152
179
  if (!this.snapshot) return null;
@@ -376,9 +403,30 @@ export class Client implements AsyncTermSearcher<string, TaskKey, Payload> {
376
403
  const s = frame.get(TASK_STATE_CHANNEL);
377
404
  if (s.length === 0) return [null, false];
378
405
  const parse = stateZ.safeParse(s.at(-1));
379
- if (!parse.success) return [null, false];
406
+ if (!parse.success) {
407
+ console.error(parse.error);
408
+ return [null, false];
409
+ }
380
410
  return [parse.data as State<D>, true];
381
411
  },
382
412
  );
383
413
  }
414
+
415
+ async openCommandObserver<A extends UnknownRecord = UnknownRecord>(): Promise<
416
+ CommandObservable<A>
417
+ > {
418
+ return new framer.ObservableStreamer<Command<A>>(
419
+ await this.frameClient.openStreamer(TASK_CMD_CHANNEL),
420
+ (frame) => {
421
+ const s = frame.get(TASK_CMD_CHANNEL);
422
+ if (s.length === 0) return [null, false];
423
+ const parse = commandZ.safeParse(s.at(-1));
424
+ if (!parse.success) {
425
+ console.error(parse.error);
426
+ return [null, false];
427
+ }
428
+ return [parse.data as Command<A>, true];
429
+ },
430
+ );
431
+ }
384
432
  }
@@ -85,17 +85,32 @@ export const commandZ = z.object({
85
85
  task: taskKeyZ,
86
86
  type: z.string(),
87
87
  key: z.string(),
88
- args: z.record(z.unknown()).or(
89
- z.string().transform((c) => {
90
- if (c === "") return {};
91
- return JSON.parse(c);
92
- }),
93
- ) as z.ZodType<UnknownRecord>,
88
+ args: z
89
+ .record(z.unknown())
90
+ .or(
91
+ z.string().transform((c) => {
92
+ if (c === "") return {};
93
+ return JSON.parse(c);
94
+ }),
95
+ )
96
+ .or(z.array(z.unknown()))
97
+ .or(z.null())
98
+ .optional() as z.ZodOptional<z.ZodType<UnknownRecord>>,
94
99
  });
95
100
 
101
+ export type Command<A extends {} = UnknownRecord> = Omit<
102
+ z.infer<typeof commandZ>,
103
+ "args"
104
+ > & {
105
+ args?: A;
106
+ };
107
+
96
108
  export type StateObservable<D extends UnknownRecord = UnknownRecord> =
97
109
  observe.ObservableAsyncCloseable<State<D>>;
98
110
 
111
+ export type CommandObservable<A extends UnknownRecord = UnknownRecord> =
112
+ observe.ObservableAsyncCloseable<Command<A>>;
113
+
99
114
  export const ONTOLOGY_TYPE: ontology.ResourceType = "task";
100
115
 
101
116
  export const ontologyID = (key: TaskKey): ontology.ID =>
package/src/index.ts CHANGED
@@ -39,6 +39,7 @@ export { workspace } from "@/workspace";
39
39
  export { linePlot } from "@/workspace/lineplot";
40
40
  export { log } from "@/workspace/log";
41
41
  export { schematic } from "@/workspace/schematic";
42
+ export { table } from "@/workspace/table";
42
43
  export {
43
44
  type CrudeDataType,
44
45
  type CrudeDensity,
@@ -37,6 +37,7 @@ export const resourceTypeZ = z.union([
37
37
  z.literal("device"),
38
38
  z.literal("task"),
39
39
  z.literal("policy"),
40
+ z.literal("table"),
40
41
  ]);
41
42
  export type ResourceType = z.infer<typeof resourceTypeZ>;
42
43
 
@@ -16,6 +16,7 @@ import { log } from "@/workspace/log";
16
16
  import { type Key, type Workspace } from "@/workspace/payload";
17
17
  import { Retriever } from "@/workspace/retriever";
18
18
  import { schematic } from "@/workspace/schematic";
19
+ import { table } from "@/workspace/table";
19
20
  import { type NewWorkspace, Writer } from "@/workspace/writer";
20
21
 
21
22
  export class Client implements AsyncTermSearcher<string, Key, Workspace> {
@@ -23,6 +24,7 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
23
24
  readonly schematic: schematic.Client;
24
25
  readonly linePlot: linePlot.Client;
25
26
  readonly log: log.Client;
27
+ readonly table: table.Client;
26
28
  private readonly retriever: Retriever;
27
29
  private readonly writer: Writer;
28
30
 
@@ -32,6 +34,7 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
32
34
  this.retriever = new Retriever(client);
33
35
  this.log = new log.Client(client);
34
36
  this.writer = new Writer(client);
37
+ this.table = new table.Client(client);
35
38
  }
36
39
 
37
40
  async search(term: string): Promise<Workspace[]> {
@@ -0,0 +1,51 @@
1
+ // Copyright 2024 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 { type UnknownRecord } from "@synnaxlabs/x/record";
12
+
13
+ import { type Key, type Params, type Table } from "@/workspace/table/payload";
14
+ import { Retriever } from "@/workspace/table/retriever";
15
+ import { type NewTable, Writer } from "@/workspace/table/writer";
16
+
17
+ export class Client {
18
+ private readonly writer: Writer;
19
+ private readonly retriever: Retriever;
20
+
21
+ constructor(client: UnaryClient) {
22
+ this.writer = new Writer(client);
23
+ this.retriever = new Retriever(client);
24
+ }
25
+
26
+ async create(workspace: string, table: NewTable): Promise<Table> {
27
+ return await this.writer.create(workspace, table);
28
+ }
29
+
30
+ async rename(key: Key, name: string): Promise<void> {
31
+ await this.writer.rename(key, name);
32
+ }
33
+
34
+ async setData(key: Key, data: UnknownRecord): Promise<void> {
35
+ await this.writer.setData(key, data);
36
+ }
37
+
38
+ async retrieve(key: Key): Promise<Table>;
39
+
40
+ async retrieve(keys: Key[]): Promise<Table[]>;
41
+
42
+ async retrieve(keys: Params): Promise<Table | Table[]> {
43
+ const isMany = Array.isArray(keys);
44
+ const res = await this.retriever.retrieve(keys);
45
+ return isMany ? res : res[0];
46
+ }
47
+
48
+ async delete(keys: Params): Promise<void> {
49
+ await this.writer.delete(keys);
50
+ }
51
+ }
@@ -0,0 +1,11 @@
1
+ // Copyright 2024 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 "@/workspace/table/client";
11
+ export * from "@/workspace/table/payload";
@@ -0,0 +1,10 @@
1
+ // Copyright 2024 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 * as table from "@/workspace/table/external";
@@ -0,0 +1,36 @@
1
+ // Copyright 2024 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 UnknownRecord, unknownRecordZ } from "@synnaxlabs/x/record";
11
+ import { z } from "zod";
12
+
13
+ import { ontology } from "@/ontology";
14
+
15
+ export const keyZ = z.string().uuid();
16
+ export type Key = z.infer<typeof keyZ>;
17
+ export type Params = Key | Key[];
18
+
19
+ export const tableZ = z.object({
20
+ key: z.string(),
21
+ name: z.string(),
22
+ data: unknownRecordZ.or(z.string().transform((s) => JSON.parse(s) as UnknownRecord)),
23
+ });
24
+
25
+ export const tableRemoteZ = z.object({
26
+ key: z.string(),
27
+ name: z.string(),
28
+ data: z.string().transform((s) => JSON.parse(s) as UnknownRecord),
29
+ });
30
+
31
+ export type Table = z.infer<typeof tableZ>;
32
+
33
+ export const ONTOLOGY_TYPE: ontology.ResourceType = "table";
34
+
35
+ export const ontologyID = (key: Key): ontology.ID =>
36
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
@@ -0,0 +1,33 @@
1
+ // Copyright 2024 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 { toArray } from "@synnaxlabs/x/toArray";
12
+ import { z } from "zod";
13
+
14
+ import { type Params, type Table, tableRemoteZ } from "@/workspace/table/payload";
15
+
16
+ const reqZ = z.object({ keys: z.string().array() });
17
+ const resZ = z.object({ tables: tableRemoteZ.array() });
18
+
19
+ const ENDPOINT = "/workspace/table/retrieve";
20
+
21
+ export class Retriever {
22
+ private readonly client: UnaryClient;
23
+
24
+ constructor(client: UnaryClient) {
25
+ this.client = client;
26
+ }
27
+
28
+ async retrieve(tables: Params): Promise<Table[]> {
29
+ return (
30
+ await sendRequired(this.client, ENDPOINT, { keys: toArray(tables) }, reqZ, resZ)
31
+ ).tables;
32
+ }
33
+ }