@synnaxlabs/client 0.32.0 → 0.34.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 (109) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/dist/access/policy/payload.d.ts +40 -40
  3. package/dist/access/policy/retriever.d.ts +5 -5
  4. package/dist/auth/auth.d.ts.map +1 -1
  5. package/dist/channel/client.d.ts +1 -1
  6. package/dist/channel/writer.d.ts.map +1 -1
  7. package/dist/client.cjs +34 -34
  8. package/dist/client.d.ts.map +1 -1
  9. package/dist/client.js +2999 -2557
  10. package/dist/control/client.d.ts.map +1 -1
  11. package/dist/control/state.d.ts.map +1 -1
  12. package/dist/errors.d.ts +3 -3
  13. package/dist/errors.d.ts.map +1 -1
  14. package/dist/framer/adapter.d.ts.map +1 -1
  15. package/dist/framer/client.d.ts.map +1 -1
  16. package/dist/framer/deleter.d.ts.map +1 -1
  17. package/dist/framer/frame.d.ts.map +1 -1
  18. package/dist/framer/writer.d.ts.map +1 -1
  19. package/dist/hardware/device/client.d.ts.map +1 -1
  20. package/dist/hardware/device/payload.d.ts.map +1 -1
  21. package/dist/hardware/rack/client.d.ts.map +1 -1
  22. package/dist/hardware/task/client.d.ts +1 -1
  23. package/dist/hardware/task/client.d.ts.map +1 -1
  24. package/dist/hardware/task/ni/types.d.ts +13 -13
  25. package/dist/hardware/task/ni/types.d.ts.map +1 -1
  26. package/dist/hardware/task/payload.d.ts.map +1 -1
  27. package/dist/index.d.ts +3 -2
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/label/client.d.ts.map +1 -1
  30. package/dist/label/writer.d.ts +5 -5
  31. package/dist/ontology/client.d.ts +9 -9
  32. package/dist/ontology/client.d.ts.map +1 -1
  33. package/dist/ontology/payload.d.ts +43 -43
  34. package/dist/ontology/payload.d.ts.map +1 -1
  35. package/dist/ranger/alias.d.ts.map +1 -1
  36. package/dist/ranger/client.d.ts.map +1 -1
  37. package/dist/ranger/kv.d.ts.map +1 -1
  38. package/dist/ranger/payload.d.ts.map +1 -1
  39. package/dist/ranger/writer.d.ts +5 -5
  40. package/dist/ranger/writer.d.ts.map +1 -1
  41. package/dist/util/telem.d.ts.map +1 -1
  42. package/dist/workspace/client.d.ts +2 -0
  43. package/dist/workspace/client.d.ts.map +1 -1
  44. package/dist/workspace/lineplot/payload.d.ts.map +1 -1
  45. package/dist/workspace/log/client.d.ts +16 -0
  46. package/dist/workspace/log/client.d.ts.map +1 -0
  47. package/dist/workspace/log/external.d.ts +3 -0
  48. package/dist/workspace/log/external.d.ts.map +1 -0
  49. package/dist/workspace/log/index.d.ts +2 -0
  50. package/dist/workspace/log/index.d.ts.map +1 -0
  51. package/dist/workspace/log/log.spec.d.ts +2 -0
  52. package/dist/workspace/log/log.spec.d.ts.map +1 -0
  53. package/dist/workspace/log/payload.d.ts +36 -0
  54. package/dist/workspace/log/payload.d.ts.map +1 -0
  55. package/dist/workspace/log/retriever.d.ts +9 -0
  56. package/dist/workspace/log/retriever.d.ts.map +1 -0
  57. package/dist/workspace/log/writer.d.ts +35 -0
  58. package/dist/workspace/log/writer.d.ts.map +1 -0
  59. package/dist/workspace/payload.d.ts.map +1 -1
  60. package/dist/workspace/schematic/payload.d.ts.map +1 -1
  61. package/eslint.config.js +1 -1
  62. package/package.json +15 -16
  63. package/src/access/policy/policy.spec.ts +8 -10
  64. package/src/auth/auth.spec.ts +1 -1
  65. package/src/auth/auth.ts +17 -18
  66. package/src/channel/client.ts +1 -1
  67. package/src/channel/writer.ts +2 -2
  68. package/src/connection/checker.ts +1 -1
  69. package/src/control/client.ts +1 -1
  70. package/src/control/state.ts +2 -2
  71. package/src/errors.spec.ts +20 -1
  72. package/src/errors.ts +14 -15
  73. package/src/framer/adapter.ts +5 -6
  74. package/src/framer/client.ts +9 -4
  75. package/src/framer/deleter.ts +1 -1
  76. package/src/framer/frame.ts +9 -11
  77. package/src/framer/iterator.spec.ts +2 -3
  78. package/src/framer/writer.ts +1 -1
  79. package/src/hardware/device/client.ts +3 -3
  80. package/src/hardware/device/payload.ts +1 -1
  81. package/src/hardware/rack/client.ts +3 -3
  82. package/src/hardware/task/client.ts +13 -11
  83. package/src/hardware/task/ni/types.ts +14 -14
  84. package/src/hardware/task/payload.ts +1 -1
  85. package/src/hardware/task/task.spec.ts +1 -1
  86. package/src/index.ts +2 -2
  87. package/src/label/client.ts +1 -1
  88. package/src/ontology/client.ts +2 -4
  89. package/src/ontology/group/payload.ts +2 -2
  90. package/src/ontology/payload.ts +2 -1
  91. package/src/ranger/alias.ts +2 -3
  92. package/src/ranger/client.ts +7 -9
  93. package/src/ranger/kv.ts +2 -2
  94. package/src/ranger/payload.ts +2 -2
  95. package/src/ranger/ranger.spec.ts +2 -2
  96. package/src/user/user.spec.ts +1 -2
  97. package/src/util/telem.ts +1 -3
  98. package/src/workspace/client.ts +3 -0
  99. package/src/workspace/lineplot/payload.ts +1 -1
  100. package/src/workspace/log/client.ts +51 -0
  101. package/src/workspace/log/external.ts +11 -0
  102. package/src/workspace/log/index.ts +10 -0
  103. package/src/workspace/log/log.spec.ts +78 -0
  104. package/src/workspace/log/payload.ts +36 -0
  105. package/src/workspace/log/retriever.ts +38 -0
  106. package/src/workspace/log/writer.ts +116 -0
  107. package/src/workspace/payload.ts +1 -1
  108. package/src/workspace/schematic/payload.ts +1 -1
  109. package/src/workspace/schematic/writer.ts +1 -1
@@ -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/log/external.ts"],"names":[],"mappings":"AASA,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * as log from './external';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/workspace/log/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,GAAG,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=log.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.spec.d.ts","sourceRoot":"","sources":["../../../src/workspace/log/log.spec.ts"],"names":[],"mappings":""}
@@ -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 logZ: 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 logRemoteZ: 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 Log = z.infer<typeof logZ>;
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/log/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,IAAI;;;;;;;;;;;;EAIf,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;EAIrB,CAAC;AAEH,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;AAEvC,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,YAAoB,CAAC;AAE1D,eAAO,MAAM,UAAU,QAAS,GAAG,KAAG,QAAQ,CAAC,EACA,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { UnaryClient } from '@synnaxlabs/freighter';
2
+ import { Log, Params } from './payload';
3
+ export declare class Retriever {
4
+ private readonly ENDPOINT;
5
+ private readonly client;
6
+ constructor(client: UnaryClient);
7
+ retrieve(logs: Params): Promise<Log[]>;
8
+ }
9
+ //# sourceMappingURL=retriever.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retriever.d.ts","sourceRoot":"","sources":["../../../src/workspace/log/retriever.ts"],"names":[],"mappings":"AASA,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIvE,OAAO,EAAE,KAAK,GAAG,EAAc,KAAK,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAK5E,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IACtD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAIzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;CAW7C"}
@@ -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, Log, Params } from './payload';
5
+ export declare const newLogZ: 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 NewLog = z.input<typeof newLogZ>;
27
+ export declare class Writer {
28
+ private readonly client;
29
+ constructor(client: UnaryClient);
30
+ create(workspace: string, log: NewLog): Promise<Log>;
31
+ delete(logs: Params): Promise<void>;
32
+ rename(log: Key, name: string): Promise<void>;
33
+ setData(log: 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/log/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;AAExB,OAAO,EACL,KAAK,GAAG,EAER,KAAK,GAAG,EAGR,KAAK,MAAM,EACZ,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;EAGjB,CAAC;AAEJ,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,OAAO,CAAC,CAAC;AAoC7C,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,WAAW;IAIzB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAapD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWnC,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU7C,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAS5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/workspace/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;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;;;;;;;;;;;;EAIrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAE3B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,YAA0B,CAAC;AAEhE,eAAO,MAAM,UAAU,QAAS,GAAG,KAAG,QAAQ,CAAC,EACK,CAAC"}
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/workspace/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;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;;;;;;;;;;;;EAIrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAE3B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,YAA0B,CAAC;AAEhE,eAAO,MAAM,UAAU,QAAS,GAAG,KAAG,QAAQ,CAAC,EACA,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/workspace/schematic/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,UAAU;;;;;;;;;;;;;;;EAKrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,YAA0B,CAAC;AAEhE,eAAO,MAAM,UAAU,QAAS,GAAG,KAAG,QAAQ,CAAC,EACK,CAAC"}
1
+ {"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../../src/workspace/schematic/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,UAAU;;;;;;;;;;;;;;;EAKrB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,YAA0B,CAAC;AAEhE,eAAO,MAAM,UAAU,QAAS,GAAG,KAAG,QAAQ,CAAC,EACA,CAAC"}
package/eslint.config.js CHANGED
@@ -9,4 +9,4 @@
9
9
 
10
10
  import synnaxConfig from "eslint-config-synnaxlabs";
11
11
 
12
- export default synnaxConfig;
12
+ export default [...synnaxConfig, { ignores: ["examples"] }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/client",
3
- "version": "0.32.0",
3
+ "version": "0.34.0",
4
4
  "description": "The Synnax Client Library",
5
5
  "keywords": [
6
6
  "synnax",
@@ -25,24 +25,23 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "async-mutex": "^0.5.0",
28
- "zod": "3.23.8",
29
- "@synnaxlabs/freighter": "0.32.0",
30
- "@synnaxlabs/x": "0.32.0"
28
+ "zod": "^3.23.8",
29
+ "@synnaxlabs/freighter": "0.34.0",
30
+ "@synnaxlabs/x": "0.34.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "^22.5.4",
34
- "@vitest/coverage-v8": "^2.1.0",
35
- "eslint": "^9.10.0",
36
- "typescript": "^5.6.2",
37
- "vite": "5.4.4",
38
- "vitest": "^2.1.0",
39
- "@synnaxlabs/tsconfig": "0.0.2",
33
+ "@types/node": "^22.7.5",
34
+ "@types/uuid": "^10.0.0",
35
+ "@vitest/coverage-v8": "^2.1.4",
36
+ "eslint": "^9.14.0",
37
+ "typescript": "^5.6.3",
38
+ "uuid": "^10.0.0",
39
+ "vite": "^5.4.10",
40
+ "vitest": "^2.1.4",
40
41
  "@synnaxlabs/vite-plugin": "0.0.1",
42
+ "@synnaxlabs/tsconfig": "0.0.2",
41
43
  "eslint-config-synnaxlabs": "0.0.1"
42
44
  },
43
- "peerDependencies": {
44
- "zod": "3.23.8"
45
- },
46
45
  "type": "module",
47
46
  "types": "dist/index.d.ts",
48
47
  "module": "dist/client.js",
@@ -51,8 +50,8 @@
51
50
  "watch": "tsc --noEmit && vite build --watch",
52
51
  "test": "vitest",
53
52
  "cov": "vitest --coverage",
54
- "lint": "eslint \"src/**/*.ts*\"",
55
- "fix": "eslint \"src/**/*.ts*\" --fix",
53
+ "lint": "eslint --cache",
54
+ "fix": "eslint --cache --fix",
56
55
  "genApi": "tsc --noEmit && vite build && npx api-extractor run --local",
57
56
  "checkApi": "tsc --noEmit && vite build && npx api-extractor run"
58
57
  }
@@ -10,7 +10,7 @@
10
10
  import { id } from "@synnaxlabs/x";
11
11
  import { describe, expect, test } from "vitest";
12
12
 
13
- import { policy } from "@/access/policy";
13
+ import { type policy } from "@/access/policy";
14
14
  import { channel } from "@/channel";
15
15
  import Synnax from "@/client";
16
16
  import { AuthError } from "@/errors";
@@ -30,7 +30,7 @@ describe("Policy", () => {
30
30
  objects: [user.ONTOLOGY_TYPE, channel.ONTOLOGY_TYPE],
31
31
  actions: "delete",
32
32
  });
33
- expect(policy.key).exist;
33
+ expect(policy.key).toBeDefined();
34
34
  expect(policy.subjects.length).toEqual(1);
35
35
  expect(policy.subjects[0].key).toEqual("");
36
36
  expect(policy.subjects[0].type).toEqual(user.ONTOLOGY_TYPE);
@@ -48,7 +48,7 @@ describe("Policy", () => {
48
48
  objects: [],
49
49
  actions: [],
50
50
  });
51
- expect(policy.key).exist;
51
+ expect(policy.key).toBeDefined();
52
52
  expect(policy.subjects).toHaveLength(0);
53
53
  expect(policy.objects).toHaveLength(0);
54
54
  expect(policy.actions).toHaveLength(0);
@@ -61,7 +61,7 @@ describe("Policy", () => {
61
61
  objects: [],
62
62
  actions: [],
63
63
  });
64
- expect(policy.key).exist;
64
+ expect(policy.key).toBeDefined();
65
65
  expect(policy.subjects.length).toEqual(1);
66
66
  expect(policy.subjects[0].key).toEqual("1");
67
67
  expect(policy.subjects[0].type).toEqual(user.ONTOLOGY_TYPE);
@@ -79,7 +79,7 @@ describe("Policy", () => {
79
79
  objects: { type: channel.ONTOLOGY_TYPE, key: "3" },
80
80
  actions: ["delete", "retrieve"],
81
81
  });
82
- expect(policy.key).exist;
82
+ expect(policy.key).toBeDefined();
83
83
  expect(policy.subjects.length).toEqual(2);
84
84
  expect(policy.subjects[0].key).toEqual("1");
85
85
  expect(policy.subjects[0].type).toEqual(user.ONTOLOGY_TYPE);
@@ -134,7 +134,7 @@ describe("Policy", () => {
134
134
  },
135
135
  ]);
136
136
  expect(policies.length).toEqual(2);
137
- expect(policies[0].key).exist;
137
+ expect(policies[0].key).toBeDefined();
138
138
  expect(policies[0].subjects.length).toEqual(1);
139
139
  expect(policies[0].subjects[0].key).toEqual("");
140
140
  expect(policies[0].subjects[0].type).toEqual(user.ONTOLOGY_TYPE);
@@ -144,7 +144,7 @@ describe("Policy", () => {
144
144
  expect(policies[0].objects[0].type).toEqual(user.ONTOLOGY_TYPE);
145
145
  expect(policies[0].objects[1].type).toEqual(schematic.ONTOLOGY_TYPE);
146
146
  expect(policies[0].actions).toEqual(["retrieve"]);
147
- expect(policies[1].key).exist;
147
+ expect(policies[1].key).toBeDefined();
148
148
  expect(policies[1].subjects.length).toEqual(2);
149
149
  expect(policies[1].subjects[0].key).toEqual("");
150
150
  expect(policies[1].subjects[1].key).toEqual("");
@@ -209,9 +209,7 @@ describe("Policy", () => {
209
209
  },
210
210
  ]);
211
211
  const received = await client.access.policy.retrieveFor(user.ontologyID(key2));
212
- const newReceived = received.filter((p) => {
213
- return created.some((c) => c.key === p.key);
214
- });
212
+ const newReceived = received.filter((p) => created.some((c) => c.key === p.key));
215
213
  expect(created[0]).toMatchObject(newReceived[0]);
216
214
  await client.access.policy.delete([created[0].key, created[1].key]);
217
215
  });
@@ -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 { Context } from "@synnaxlabs/freighter";
10
+ import { type Context } from "@synnaxlabs/freighter";
11
11
  import { URL } from "@synnaxlabs/x/url";
12
12
  import { describe, expect, it, test } from "vitest";
13
13
 
package/src/auth/auth.ts CHANGED
@@ -72,24 +72,23 @@ export class Client {
72
72
  middleware(): Middleware {
73
73
  const mw: Middleware = async (reqCtx, next) => {
74
74
  if (!this.authenticated && !reqCtx.target.endsWith(LOGIN_ENDPOINT)) {
75
- if (this.authenticating == null)
76
- this.authenticating = new Promise((resolve, reject) => {
77
- this.client
78
- .send(
79
- LOGIN_ENDPOINT,
80
- this.credentials,
81
- insecureCredentialsZ,
82
- tokenResponseZ,
83
- )
84
- .then(([res, err]) => {
85
- if (err != null) return resolve(err);
86
- this.token = res?.token;
87
- this.user = res?.user;
88
- this.authenticated = true;
89
- resolve(null);
90
- })
91
- .catch(reject);
92
- });
75
+ this.authenticating ??= new Promise((resolve, reject) => {
76
+ this.client
77
+ .send(
78
+ LOGIN_ENDPOINT,
79
+ this.credentials,
80
+ insecureCredentialsZ,
81
+ tokenResponseZ,
82
+ )
83
+ .then(([res, err]) => {
84
+ if (err != null) return resolve(err);
85
+ this.token = res?.token;
86
+ this.user = res?.user;
87
+ this.authenticated = true;
88
+ resolve(null);
89
+ })
90
+ .catch(reject);
91
+ });
93
92
  const err = await this.authenticating;
94
93
  if (err != null) return [reqCtx, err];
95
94
  }
@@ -237,7 +237,7 @@ export class Client implements AsyncTermSearcher<string, Key, Channel> {
237
237
  * channel. If this value is specified, the 'rate' parameter will be ignored.
238
238
  * @param isIndex - Set to true if the channel is an index channel, and false
239
239
  * otherwise. Index channels must have a data type of `DataType.TIMESTAMP`.
240
- * @returns the created channel. {@see Channel}
240
+ * @returns the created channel. {@link Channel}
241
241
  * @throws {ValidationError} if any of the parameters for creating the channel are
242
242
  * invalid.
243
243
  *
@@ -11,14 +11,14 @@ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { z } from "zod";
12
12
 
13
13
  import {
14
- Key,
14
+ type Key,
15
15
  keyZ,
16
16
  type NewPayload,
17
17
  newPayload,
18
18
  type Payload,
19
19
  payload,
20
20
  } from "@/channel/payload";
21
- import { CacheRetriever } from "@/channel/retriever";
21
+ import { type CacheRetriever } from "@/channel/retriever";
22
22
 
23
23
  const createReqZ = z.object({ channels: newPayload.array() });
24
24
  const createResZ = z.object({ channels: payload.array() });
@@ -48,7 +48,7 @@ const generateWarning = (
48
48
  clientIsNewer: boolean,
49
49
  ): string => {
50
50
  const toUpgrade = clientIsNewer ? "cluster" : "client";
51
- return `Synnax cluster node version ${nodeVersion != null ? nodeVersion + " " : ""}is too ${clientIsNewer ? "old" : "new"} for client version ${clientVersion}.
51
+ return `Synnax cluster node version ${nodeVersion != null ? `${nodeVersion} ` : ""}is too ${clientIsNewer ? "old" : "new"} for client version ${clientVersion}.
52
52
  This may cause compatibility issues. We recommend updating the ${toUpgrade}. For more information, see
53
53
  https://docs.synnaxlabs.com/reference/typescript-client/troubleshooting#old-${toUpgrade}-version`;
54
54
  };
@@ -8,7 +8,7 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  import { StateTracker } from "@/control/state";
11
- import { framer } from "@/framer";
11
+ import { type framer } from "@/framer";
12
12
 
13
13
  const CONTROL_STATE_KEY = "sy_node_1_control";
14
14
 
@@ -9,7 +9,7 @@
9
9
 
10
10
  import { control } from "@synnaxlabs/x";
11
11
  import { binary } from "@synnaxlabs/x/binary";
12
- import { observe } from "@synnaxlabs/x/observe";
12
+ import { type observe } from "@synnaxlabs/x/observe";
13
13
  import { z } from "zod";
14
14
 
15
15
  import { type Key as ChannelKey } from "@/channel/payload";
@@ -47,7 +47,7 @@ export class StateTracker
47
47
 
48
48
  constructor(streamer: FrameStreamer) {
49
49
  super(streamer, (frame) => {
50
- const update: Update = this.codec.decode(frame.series[0].buffer);
50
+ const update: Update = this.codec.decode(frame.series[0].data);
51
51
  this.merge(update);
52
52
  return [update.transfers, true];
53
53
  });
@@ -7,7 +7,9 @@
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 { MatchableErrorType } from "@synnaxlabs/freighter/src/errors";
10
+ import { type MatchableErrorType } from "@synnaxlabs/freighter/src/errors";
11
+ import { id } from "@synnaxlabs/x";
12
+ import { v4 as uuid } from "uuid";
11
13
  import { describe, expect, test } from "vitest";
12
14
 
13
15
  import {
@@ -24,6 +26,7 @@ import {
24
26
  UnexpectedError,
25
27
  ValidationError,
26
28
  } from "@/errors";
29
+ import { newClient } from "@/setupspecs";
27
30
 
28
31
  describe("error", () => {
29
32
  describe("type matching", () => {
@@ -46,3 +49,19 @@ describe("error", () => {
46
49
  );
47
50
  });
48
51
  });
52
+
53
+ const client = newClient();
54
+
55
+ test("client", async () => {
56
+ expect.assertions(2);
57
+ try {
58
+ await client.channels.retrieve(id.id());
59
+ } catch (e) {
60
+ expect(NotFoundError.matches(e)).toBe(true);
61
+ }
62
+ try {
63
+ await client.workspaces.schematic.retrieve(uuid());
64
+ } catch (e) {
65
+ expect(NotFoundError.matches(e)).toBe(true);
66
+ }
67
+ });
package/src/errors.ts CHANGED
@@ -27,20 +27,20 @@ export interface Field {
27
27
  * Raised when a validation error occurs.
28
28
  */
29
29
  export class ValidationError extends BaseTypedError {
30
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "validation";
30
+ static readonly TYPE: string = `${_FREIGHTER_EXCEPTION_PREFIX}validation`;
31
31
  type = ValidationError.TYPE;
32
32
  static readonly matches = errorMatcher(ValidationError.TYPE);
33
33
  }
34
34
 
35
35
  export class FieldError extends ValidationError {
36
- static readonly TYPE = ValidationError.TYPE + ".field";
36
+ static readonly TYPE = `${ValidationError.TYPE}.field`;
37
37
  type = FieldError.TYPE;
38
38
  static readonly matches = errorMatcher(FieldError.TYPE);
39
39
  readonly field: string;
40
40
  readonly message: string;
41
41
 
42
42
  constructor(field: string, message: string) {
43
- super(field + ": " + message);
43
+ super(`${field}: ${message}`);
44
44
  this.field = field;
45
45
  this.message = message;
46
46
  }
@@ -50,7 +50,7 @@ export class FieldError extends ValidationError {
50
50
  * AuthError is raised when an authentication error occurs.
51
51
  */
52
52
  export class AuthError extends BaseTypedError {
53
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "auth";
53
+ static readonly TYPE: string = `${_FREIGHTER_EXCEPTION_PREFIX}auth`;
54
54
  type = AuthError.TYPE;
55
55
  static readonly matches = errorMatcher(AuthError.TYPE);
56
56
  }
@@ -59,7 +59,7 @@ export class AuthError extends BaseTypedError {
59
59
  * InvalidTokenError is raised when an authentication token is invalid.
60
60
  */
61
61
  export class InvalidTokenError extends AuthError {
62
- static readonly TYPE = AuthError.TYPE + ".invalid-token";
62
+ static readonly TYPE = `${AuthError.TYPE}.invalid-token`;
63
63
  type = InvalidTokenError.TYPE;
64
64
  static readonly matches = errorMatcher(InvalidTokenError.TYPE);
65
65
  }
@@ -68,7 +68,7 @@ export class InvalidTokenError extends AuthError {
68
68
  * UnexpectedError is raised when an unexpected error occurs.
69
69
  */
70
70
  export class UnexpectedError extends BaseTypedError {
71
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "unexpected";
71
+ static readonly TYPE = `${_FREIGHTER_EXCEPTION_PREFIX}unexpected`;
72
72
  type = UnexpectedError.TYPE;
73
73
  static readonly matches = errorMatcher(UnexpectedError.TYPE);
74
74
 
@@ -87,19 +87,19 @@ export class UnexpectedError extends BaseTypedError {
87
87
  * QueryError is raised when a query error occurs.
88
88
  */
89
89
  export class QueryError extends BaseTypedError {
90
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "query";
90
+ static readonly TYPE: string = `${_FREIGHTER_EXCEPTION_PREFIX}query`;
91
91
  type = QueryError.TYPE;
92
92
  static readonly matches = errorMatcher(QueryError.TYPE);
93
93
  }
94
94
 
95
95
  export class NotFoundError extends QueryError {
96
- static readonly TYPE = QueryError.TYPE + ".not_found";
96
+ static readonly TYPE = `${QueryError.TYPE}.not_found`;
97
97
  type = NotFoundError.TYPE;
98
98
  static readonly matches = errorMatcher(NotFoundError.TYPE);
99
99
  }
100
100
 
101
101
  export class MultipleFoundError extends QueryError {
102
- static readonly TYPE = QueryError.TYPE + ".multiple_results";
102
+ static readonly TYPE = `${QueryError.TYPE}.multiple_results`;
103
103
  type = MultipleFoundError.TYPE;
104
104
  static readonly matches = errorMatcher(MultipleFoundError.TYPE);
105
105
  }
@@ -108,7 +108,7 @@ export class MultipleFoundError extends QueryError {
108
108
  * RouteError is raised when a routing error occurs.
109
109
  */
110
110
  export class RouteError extends BaseTypedError {
111
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "route";
111
+ static readonly TYPE = `${_FREIGHTER_EXCEPTION_PREFIX}route`;
112
112
  type = RouteError.TYPE;
113
113
  static readonly matches = errorMatcher(RouteError.TYPE);
114
114
  path: string;
@@ -120,13 +120,13 @@ export class RouteError extends BaseTypedError {
120
120
  }
121
121
 
122
122
  export class ControlError extends BaseTypedError {
123
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "control";
123
+ static readonly TYPE: string = `${_FREIGHTER_EXCEPTION_PREFIX}control`;
124
124
  type = ControlError.TYPE;
125
125
  static readonly matches = errorMatcher(ControlError.TYPE);
126
126
  }
127
127
 
128
128
  export class UnauthorizedError extends ControlError {
129
- static readonly TYPE = ControlError.TYPE + ".unauthorized";
129
+ static readonly TYPE = `${ControlError.TYPE}.unauthorized`;
130
130
  type = UnauthorizedError.TYPE;
131
131
  static readonly matches = errorMatcher(UnauthorizedError.TYPE);
132
132
  }
@@ -135,7 +135,7 @@ export class UnauthorizedError extends ControlError {
135
135
  * Raised when time-series data is not contiguous.
136
136
  */
137
137
  export class ContiguityError extends BaseTypedError {
138
- static readonly TYPE = _FREIGHTER_EXCEPTION_PREFIX + "contiguity";
138
+ static readonly TYPE = `${_FREIGHTER_EXCEPTION_PREFIX}contiguity`;
139
139
  type = ContiguityError.TYPE;
140
140
  static readonly matches = errorMatcher(ContiguityError.TYPE);
141
141
  }
@@ -157,9 +157,8 @@ const decode = (payload: ErrorPayload): Error | null => {
157
157
  return new AuthError(payload.data);
158
158
  }
159
159
 
160
- if (payload.type.startsWith(UnexpectedError.TYPE)) {
160
+ if (payload.type.startsWith(UnexpectedError.TYPE))
161
161
  return new UnexpectedError(payload.data);
162
- }
163
162
 
164
163
  if (payload.type.startsWith(QueryError.TYPE)) {
165
164
  if (payload.type.startsWith(NotFoundError.TYPE))
@@ -127,11 +127,11 @@ export class WriteFrameAdapter {
127
127
  Received a single channel name or key but no series.
128
128
  `);
129
129
  if (Array.isArray(series)) {
130
- if (series.some((s) => s instanceof Series || Array.isArray(s))) {
130
+ if (series.some((s) => s instanceof Series || Array.isArray(s)))
131
131
  throw new ValidationError(`
132
132
  Received a single channel name or key but multiple series.
133
133
  `);
134
- }
134
+
135
135
  series = series as CrudeSeries;
136
136
  }
137
137
  const pld = await this.fetchChannel(columnsOrData);
@@ -152,11 +152,11 @@ export class WriteFrameAdapter {
152
152
  const data = [];
153
153
  for (let i = 0; i < columnsOrData.length; i++) {
154
154
  const pld = await this.fetchChannel(columnsOrData[i]);
155
- if (i >= series.length) {
155
+ if (i >= series.length)
156
156
  throw new ValidationError(`
157
157
  Received an array of channel names or keys but not enough series.
158
158
  `);
159
- }
159
+
160
160
  const s = new Series({
161
161
  data: series[i] as CrudeSeries,
162
162
  dataType: pld.dataType,
@@ -170,8 +170,7 @@ export class WriteFrameAdapter {
170
170
  if (columnsOrData instanceof Frame || columnsOrData instanceof Map) {
171
171
  const fr = new Frame(columnsOrData);
172
172
  if (this.adapter == null) return fr;
173
- let cols: Key[] = [];
174
- cols = fr.columns.map((col_) => {
173
+ const cols = fr.columns.map((col_) => {
175
174
  const col = typeof col_ === "string" ? this.adapter?.get(col_) : col_;
176
175
  if (col == null)
177
176
  throw new ValidationError(`
@@ -7,21 +7,26 @@
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 StreamClient, UnaryClient } from "@synnaxlabs/freighter";
10
+ import { type StreamClient, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import {
12
12
  type CrudeSeries,
13
13
  type CrudeTimeRange,
14
14
  type CrudeTimeStamp,
15
15
  type MultiSeries,
16
- TimeRange,
16
+ type TimeRange,
17
17
  TimeSpan,
18
18
  } from "@synnaxlabs/x";
19
19
 
20
- import { type Key, type KeyOrName, KeysOrNames, type Params } from "@/channel/payload";
20
+ import {
21
+ type Key,
22
+ type KeyOrName,
23
+ type KeysOrNames,
24
+ type Params,
25
+ } from "@/channel/payload";
21
26
  import { analyzeChannelParams, type Retriever } from "@/channel/retriever";
22
27
  import { Deleter } from "@/framer/deleter";
23
28
  import { Frame } from "@/framer/frame";
24
- import { Iterator, IteratorConfig } from "@/framer/iterator";
29
+ import { Iterator, type IteratorConfig } from "@/framer/iterator";
25
30
  import { Streamer, type StreamerConfig } from "@/framer/streamer";
26
31
  import { Writer, type WriterConfig, WriterMode } from "@/framer/writer";
27
32
  import { ontology } from "@/ontology";
@@ -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 { sendRequired, UnaryClient } from "@synnaxlabs/freighter";
10
+ import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
11
  import { TimeRange } from "@synnaxlabs/x";
12
12
  import { z } from "zod";
13
13