@synnaxlabs/client 0.33.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 (107) 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/writer.d.ts.map +1 -1
  6. package/dist/client.cjs +29 -29
  7. package/dist/client.js +1880 -1686
  8. package/dist/control/client.d.ts.map +1 -1
  9. package/dist/control/state.d.ts.map +1 -1
  10. package/dist/errors.d.ts +3 -3
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/framer/adapter.d.ts.map +1 -1
  13. package/dist/framer/client.d.ts.map +1 -1
  14. package/dist/framer/deleter.d.ts.map +1 -1
  15. package/dist/framer/frame.d.ts.map +1 -1
  16. package/dist/framer/writer.d.ts.map +1 -1
  17. package/dist/hardware/device/client.d.ts +2 -2
  18. package/dist/hardware/device/client.d.ts.map +1 -1
  19. package/dist/hardware/device/payload.d.ts.map +1 -1
  20. package/dist/hardware/rack/client.d.ts.map +1 -1
  21. package/dist/hardware/task/client.d.ts +5 -3
  22. package/dist/hardware/task/client.d.ts.map +1 -1
  23. package/dist/hardware/task/ni/types.d.ts.map +1 -1
  24. package/dist/hardware/task/payload.d.ts +7 -3
  25. package/dist/hardware/task/payload.d.ts.map +1 -1
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/label/client.d.ts.map +1 -1
  29. package/dist/label/writer.d.ts +5 -5
  30. package/dist/ontology/client.d.ts +8 -8
  31. package/dist/ontology/client.d.ts.map +1 -1
  32. package/dist/ontology/payload.d.ts +43 -43
  33. package/dist/ontology/payload.d.ts.map +1 -1
  34. package/dist/ranger/alias.d.ts.map +1 -1
  35. package/dist/ranger/client.d.ts.map +1 -1
  36. package/dist/ranger/kv.d.ts.map +1 -1
  37. package/dist/ranger/payload.d.ts.map +1 -1
  38. package/dist/ranger/writer.d.ts +5 -5
  39. package/dist/util/telem.d.ts.map +1 -1
  40. package/dist/workspace/client.d.ts +2 -0
  41. package/dist/workspace/client.d.ts.map +1 -1
  42. package/dist/workspace/lineplot/payload.d.ts.map +1 -1
  43. package/dist/workspace/log/payload.d.ts.map +1 -1
  44. package/dist/workspace/payload.d.ts.map +1 -1
  45. package/dist/workspace/schematic/payload.d.ts.map +1 -1
  46. package/dist/workspace/table/client.d.ts +16 -0
  47. package/dist/workspace/table/client.d.ts.map +1 -0
  48. package/dist/workspace/table/external.d.ts +3 -0
  49. package/dist/workspace/table/external.d.ts.map +1 -0
  50. package/dist/workspace/table/index.d.ts +2 -0
  51. package/dist/workspace/table/index.d.ts.map +1 -0
  52. package/dist/workspace/table/payload.d.ts +36 -0
  53. package/dist/workspace/table/payload.d.ts.map +1 -0
  54. package/dist/workspace/table/retriever.d.ts +8 -0
  55. package/dist/workspace/table/retriever.d.ts.map +1 -0
  56. package/dist/workspace/table/table.spec.d.ts +2 -0
  57. package/dist/workspace/table/table.spec.d.ts.map +1 -0
  58. package/dist/workspace/table/writer.d.ts +35 -0
  59. package/dist/workspace/table/writer.d.ts.map +1 -0
  60. package/eslint.config.js +1 -1
  61. package/package.json +12 -12
  62. package/src/access/policy/policy.spec.ts +2 -4
  63. package/src/auth/auth.spec.ts +1 -1
  64. package/src/auth/auth.ts +17 -18
  65. package/src/channel/writer.ts +2 -2
  66. package/src/connection/checker.ts +1 -1
  67. package/src/control/client.ts +1 -1
  68. package/src/control/state.ts +1 -1
  69. package/src/errors.spec.ts +1 -1
  70. package/src/errors.ts +14 -15
  71. package/src/framer/adapter.ts +5 -6
  72. package/src/framer/client.ts +9 -4
  73. package/src/framer/deleter.ts +1 -1
  74. package/src/framer/frame.ts +9 -11
  75. package/src/framer/iterator.spec.ts +2 -3
  76. package/src/framer/writer.ts +1 -1
  77. package/src/hardware/device/client.ts +13 -7
  78. package/src/hardware/device/payload.ts +1 -1
  79. package/src/hardware/rack/client.ts +3 -3
  80. package/src/hardware/task/client.ts +64 -14
  81. package/src/hardware/task/ni/types.ts +1 -1
  82. package/src/hardware/task/payload.ts +22 -7
  83. package/src/hardware/task/task.spec.ts +1 -1
  84. package/src/index.ts +1 -0
  85. package/src/label/client.ts +1 -1
  86. package/src/ontology/client.ts +1 -3
  87. package/src/ontology/group/payload.ts +2 -2
  88. package/src/ontology/payload.ts +2 -1
  89. package/src/ranger/alias.ts +2 -3
  90. package/src/ranger/client.ts +7 -9
  91. package/src/ranger/kv.ts +2 -2
  92. package/src/ranger/payload.ts +2 -2
  93. package/src/ranger/ranger.spec.ts +2 -2
  94. package/src/user/user.spec.ts +1 -2
  95. package/src/util/telem.ts +1 -3
  96. package/src/workspace/client.ts +3 -0
  97. package/src/workspace/lineplot/payload.ts +1 -1
  98. package/src/workspace/log/payload.ts +1 -1
  99. package/src/workspace/payload.ts +1 -1
  100. package/src/workspace/schematic/payload.ts +1 -1
  101. package/src/workspace/table/client.ts +51 -0
  102. package/src/workspace/table/external.ts +11 -0
  103. package/src/workspace/table/index.ts +10 -0
  104. package/src/workspace/table/payload.ts +36 -0
  105. package/src/workspace/table/retriever.ts +33 -0
  106. package/src/workspace/table/table.spec.ts +65 -0
  107. package/src/workspace/table/writer.ts +102 -0
@@ -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/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.33.0",
3
+ "version": "0.35.0",
4
4
  "description": "The Synnax Client Library",
5
5
  "keywords": [
6
6
  "synnax",
@@ -26,21 +26,21 @@
26
26
  "dependencies": {
27
27
  "async-mutex": "^0.5.0",
28
28
  "zod": "^3.23.8",
29
- "@synnaxlabs/freighter": "0.33.0",
30
- "@synnaxlabs/x": "0.33.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",
34
- "@vitest/coverage-v8": "^2.1.2",
35
- "eslint": "^9.12.0",
36
- "uuid": "^10.0.0",
37
34
  "@types/uuid": "^10.0.0",
35
+ "@vitest/coverage-v8": "^2.1.4",
36
+ "eslint": "^9.14.0",
38
37
  "typescript": "^5.6.3",
39
- "vite": "^5.4.8",
40
- "vitest": "^2.1.2",
38
+ "uuid": "^10.0.0",
39
+ "vite": "^5.4.10",
40
+ "vitest": "^2.1.4",
41
+ "eslint-config-synnaxlabs": "0.0.1",
41
42
  "@synnaxlabs/tsconfig": "0.0.2",
42
- "@synnaxlabs/vite-plugin": "0.0.1",
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",
@@ -50,8 +50,8 @@
50
50
  "watch": "tsc --noEmit && vite build --watch",
51
51
  "test": "vitest",
52
52
  "cov": "vitest --coverage",
53
- "lint": "eslint \"src/**/*.ts*\"",
54
- "fix": "eslint \"src/**/*.ts*\" --fix",
53
+ "lint": "eslint --cache",
54
+ "fix": "eslint --cache --fix",
55
55
  "genApi": "tsc --noEmit && vite build && npx api-extractor run --local",
56
56
  "checkApi": "tsc --noEmit && vite build && npx api-extractor run"
57
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";
@@ -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
  }
@@ -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";
@@ -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 { MatchableErrorType } from "@synnaxlabs/freighter/src/errors";
10
+ import { type MatchableErrorType } from "@synnaxlabs/freighter/src/errors";
11
11
  import { id } from "@synnaxlabs/x";
12
12
  import { v4 as uuid } from "uuid";
13
13
  import { describe, expect, test } from "vitest";
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
 
@@ -10,7 +10,7 @@
10
10
  import {
11
11
  MultiSeries,
12
12
  Series,
13
- SeriesPayload,
13
+ type SeriesPayload,
14
14
  Size,
15
15
  type TelemValue,
16
16
  TimeRange,
@@ -126,7 +126,7 @@ export class Frame {
126
126
  Object.entries(columnsOrData).forEach(([k, v]) => {
127
127
  const key = parseInt(k);
128
128
  if (!isNaN(key)) return this.push(key, ...toArray(v));
129
- else this.push(k, ...toArray(v));
129
+ this.push(k, ...toArray(v));
130
130
  });
131
131
  return;
132
132
  }
@@ -334,7 +334,7 @@ export class Frame {
334
334
  */
335
335
  has(channel: KeyOrName): boolean {
336
336
  if (typeof channel === "string" && this.colType === "key") return false;
337
- else if (typeof channel === "number" && this.colType === "name") return false;
337
+ if (typeof channel === "number" && this.colType === "name") return false;
338
338
  return (this.columns as Keys).includes(channel as Key);
339
339
  }
340
340
 
@@ -418,11 +418,9 @@ export const seriesFromPayload = (series: SeriesPayload): Series => {
418
418
  return new Series({ data, dataType, timeRange, glBufferUsage: "static", alignment });
419
419
  };
420
420
 
421
- export const seriesToPayload = (series: Series): SeriesPayload => {
422
- return {
423
- timeRange: series._timeRange,
424
- dataType: series.dataType,
425
- data: new Uint8Array(series.data.buffer),
426
- alignment: series.alignment,
427
- };
428
- };
421
+ export const seriesToPayload = (series: Series): SeriesPayload => ({
422
+ timeRange: series._timeRange,
423
+ dataType: series.dataType,
424
+ data: new Uint8Array(series.data.buffer),
425
+ alignment: series.alignment,
426
+ });
@@ -17,14 +17,13 @@ import { randomSeries } from "@/util/telem";
17
17
 
18
18
  const client = newClient();
19
19
 
20
- const newChannel = async (): Promise<channel.Channel> => {
21
- return await client.channels.create({
20
+ const newChannel = async (): Promise<channel.Channel> =>
21
+ await client.channels.create({
22
22
  name: "test",
23
23
  leaseholder: 1,
24
24
  rate: Rate.hz(25),
25
25
  dataType: DataType.FLOAT64,
26
26
  });
27
- };
28
27
 
29
28
  describe("Iterator", () => {
30
29
  test("happy path", async () => {
@@ -245,7 +245,7 @@ export class Writer {
245
245
  value: Record<KeyOrName, control.Authority> | KeyOrName | number,
246
246
  authority?: control.Authority,
247
247
  ): Promise<boolean> {
248
- let config: Config = { keys: [], authorities: [] };
248
+ let config: Config;
249
249
  if (typeof value === "number" && authority == null)
250
250
  config = { keys: [], authorities: [value] };
251
251
  else {
@@ -14,11 +14,11 @@ import { z } from "zod";
14
14
 
15
15
  import { type framer } from "@/framer";
16
16
  import {
17
- Device,
18
- DeviceKey,
17
+ type Device,
18
+ type DeviceKey,
19
19
  deviceKeyZ,
20
20
  deviceZ,
21
- NewDevice,
21
+ type NewDevice,
22
22
  newDeviceZ,
23
23
  } from "@/hardware/device/payload";
24
24
  import { signals } from "@/signals";
@@ -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> {
@@ -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 { binary, UnknownRecord } from "@synnaxlabs/x";
10
+ import { binary, type UnknownRecord } from "@synnaxlabs/x";
11
11
  import { z } from "zod";
12
12
 
13
13
  import { rackKeyZ } from "@/hardware/rack/payload";
@@ -15,11 +15,11 @@ import { z } from "zod";
15
15
 
16
16
  import { type framer } from "@/framer";
17
17
  import {
18
- NewRack,
18
+ type NewRack,
19
19
  newRackZ,
20
- RackKey,
20
+ type RackKey,
21
21
  rackKeyZ,
22
- RackPayload,
22
+ type RackPayload,
23
23
  rackZ,
24
24
  } from "@/hardware/rack/payload";
25
25
  import { type task } from "@/hardware/task";