@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
@@ -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";
@@ -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";
@@ -19,18 +19,18 @@ import { framer } from "@/framer";
19
19
  import { type Frame } from "@/framer/frame";
20
20
  import { rack } from "@/hardware/rack";
21
21
  import {
22
- NewTask,
22
+ type NewTask,
23
23
  newTaskZ,
24
- Payload,
25
- State,
26
- StateObservable,
24
+ type Payload,
25
+ type State,
26
+ type StateObservable,
27
27
  stateZ,
28
- TaskKey,
28
+ type TaskKey,
29
29
  taskKeyZ,
30
30
  taskZ,
31
31
  } from "@/hardware/task/payload";
32
32
  import { ontology } from "@/ontology";
33
- import { ranger } from "@/ranger";
33
+ import { type ranger } from "@/ranger";
34
34
  import { signals } from "@/signals";
35
35
  import { analyzeParams, checkForMultipleOrNoResults } from "@/util/retrieve";
36
36
  import { nullableArrayZ } from "@/util/zod";
@@ -123,9 +123,7 @@ export class Task<
123
123
  if (parsed.success) {
124
124
  res = parsed.data as State<D>;
125
125
  if (res.key === cmdKey) break;
126
- } else {
127
- console.error(parsed.error);
128
- }
126
+ } else console.error(parsed.error);
129
127
  }
130
128
  streamer.close();
131
129
  return res;
@@ -316,10 +314,14 @@ export class Client implements AsyncTermSearcher<string, TaskKey, Payload> {
316
314
  return this.sugar([res.task])[0];
317
315
  }
318
316
 
319
- async retrieveByName(name: string, rack?: number): Promise<Task> {
317
+ async retrieveByName<
318
+ C extends UnknownRecord = UnknownRecord,
319
+ D extends {} = UnknownRecord,
320
+ T extends string = string,
321
+ >(name: string, rack?: number): Promise<Task<C, D, T>> {
320
322
  const tasks = await this.execRetrieve({ names: [name], rack });
321
323
  checkForMultipleOrNoResults("Task", name, tasks, true);
322
- return this.sugar(tasks)[0];
324
+ return this.sugar(tasks)[0] as Task<C, D, T>;
323
325
  }
324
326
 
325
327
  private async execRetrieve(req: RetrieveRequest): Promise<Payload[]> {
@@ -10,7 +10,7 @@
10
10
  import { z } from "zod";
11
11
 
12
12
  import { device } from "@/hardware/device";
13
- import { task } from "@/hardware/task";
13
+ import { type task } from "@/hardware/task";
14
14
 
15
15
  export const unitsVoltsZ = z.literal("Volts");
16
16
  export type UnitsVolts = z.infer<typeof unitsVoltsZ>;
@@ -259,7 +259,7 @@ export const ZERO_AI_ACCEL_CHAN: AIAccelChan = {
259
259
  };
260
260
 
261
261
  // 2 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaiaccel4wiredcvoltagechan.html
262
- const aiAccel4WireDCVoltageChanZ = baseAiAccelChanZ.extend({
262
+ export const aiAccel4WireDCVoltageChanZ = baseAiAccelChanZ.extend({
263
263
  type: z.literal("ai_accel_4_wire_dc_voltage"),
264
264
  units: accelerationUnitsZ,
265
265
  voltageExcitSource: excitSourceZ,
@@ -290,7 +290,7 @@ export const ZERO_AI_ACCEL_4WIRE_DC_VOLTAGE_CHAN: AIAccel4WireDCVoltageChan = {
290
290
  };
291
291
 
292
292
  // 3 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaiaccelchargechan.html
293
- const aiAccelChargeChanZ = baseAiAccelChanZ.extend({
293
+ export const aiAccelChargeChanZ = baseAiAccelChanZ.extend({
294
294
  type: z.literal("ai_accel_charge"),
295
295
  units: accelerationUnitsZ,
296
296
  customScale: scaleZ,
@@ -354,7 +354,7 @@ export const ZERO_AI_BRIDGE_CHAN: AIBridgeChan = {
354
354
  };
355
355
 
356
356
  // 5 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaichargechan.html
357
- const aiChargeChan = baseAIChanZ.extend({
357
+ export const aiChargeChan = baseAIChanZ.extend({
358
358
  type: z.literal("ai_charge"),
359
359
  terminalConfig: terminalConfigZ,
360
360
  minVal: z.number(),
@@ -420,7 +420,7 @@ export const ZERO_AI_CURRENT_CHAN: AICurrentChan = {
420
420
  };
421
421
 
422
422
  // 7 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaicurrentrmschan.html
423
- const aiCurrentRMSChanZ = baseAIChanZ.extend({
423
+ export const aiCurrentRMSChanZ = baseAIChanZ.extend({
424
424
  type: z.literal("ai_current_rms"),
425
425
  terminalConfig: terminalConfigZ,
426
426
  minVal: z.number(),
@@ -450,7 +450,7 @@ export const ZERO_AI_CURRENT_RMS_CHAN: AICurrentRMSChan = {
450
450
  };
451
451
 
452
452
  // 8 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaiforcebridgepolynomialchan.html
453
- const aiForceBridgePolynomialChanZ = baseAIChanZ.extend({
453
+ export const aiForceBridgePolynomialChanZ = baseAIChanZ.extend({
454
454
  type: z.literal("ai_force_bridge_polynomial"),
455
455
  terminalConfig: terminalConfigZ,
456
456
  minVal: z.number(),
@@ -612,7 +612,7 @@ export const ZERO_AI_FORCE_IEPE_CHAN: AIForceEPEChan = {
612
612
  };
613
613
 
614
614
  // 12 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaifreqvoltagechan.html
615
- const aiFreqVoltageChanZ = baseAIChanZ.extend({
615
+ export const aiFreqVoltageChanZ = baseAIChanZ.extend({
616
616
  type: z.literal("ai_freq_voltage"),
617
617
  minVal: z.number(),
618
618
  maxVal: z.number(),
@@ -673,7 +673,7 @@ export const pressureUnitsZ = z.enum(["PoundsPerSquareInch", "Pascals", "Bar"]);
673
673
  export type PressureUnits = z.infer<typeof pressureUnitsZ>;
674
674
 
675
675
  // 14 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaipressurebridgepolynomialchan.html
676
- const aiPressureBridgePolynomialChanZ = baseAIChanZ.extend({
676
+ export const aiPressureBridgePolynomialChanZ = baseAIChanZ.extend({
677
677
  type: z.literal("ai_pressure_bridge_polynomial"),
678
678
  minVal: z.number(),
679
679
  maxVal: z.number(),
@@ -839,7 +839,7 @@ export const ZERO_AI_RESISTANCE_CHAN: AIResistanceChan = {
839
839
  };
840
840
 
841
841
  // 18 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateairosettestraingagechan.html
842
- const aiRosetteStrainGageChanZ = baseAIChanZ.extend({
842
+ export const aiRosetteStrainGageChanZ = baseAIChanZ.extend({
843
843
  type: z.literal("ai_rosette_strain_gage"),
844
844
  terminalConfig: terminalConfigZ,
845
845
  minVal: z.number(),
@@ -1065,7 +1065,7 @@ export const ZERO_AI_THERMOCOUPLE_CHAN: AIThermocoupleChan = {
1065
1065
  };
1066
1066
 
1067
1067
  // 23 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaithrmstrchaniex.html
1068
- const aiThermistorChanIex = baseAIChanZ.extend({
1068
+ export const aiThermistorChanIex = baseAIChanZ.extend({
1069
1069
  key: z.string(),
1070
1070
  type: z.literal("ai_thermistor_iex"),
1071
1071
  minVal: z.number(),
@@ -1100,7 +1100,7 @@ export const ZERO_AI_THERMISTOR_CHAN_IEX: AIThermistorChanIex = {
1100
1100
  };
1101
1101
 
1102
1102
  // 24 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaitorquebridgepolynomialchan.html
1103
- const aiThermistorChanVex = baseAIChanZ.extend({
1103
+ export const aiThermistorChanVex = baseAIChanZ.extend({
1104
1104
  key: z.string(),
1105
1105
  type: z.literal("ai_thermistor_vex"),
1106
1106
  minVal: z.number(),
@@ -1140,7 +1140,7 @@ export const torqueUnitsZ = z.enum(["NewtonMeters", "InchOunces", "FootPounds"])
1140
1140
  export type TorqueUnits = z.infer<typeof torqueUnitsZ>;
1141
1141
 
1142
1142
  // 25 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaitorquebridgepolynomialchan.html
1143
- const aiTorqueBridgePolynomialChanZ = baseAIChanZ.extend({
1143
+ export const aiTorqueBridgePolynomialChanZ = baseAIChanZ.extend({
1144
1144
  key: z.string(),
1145
1145
  type: z.literal("ai_torque_bridge_polynomial"),
1146
1146
  minVal: z.number(),
@@ -1345,7 +1345,7 @@ export const ZERO_AI_VOLTAGE_CHAN: AIVoltageChan = {
1345
1345
  };
1346
1346
 
1347
1347
  // 30 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaivoltagermschan.html
1348
- const aiVoltageRMSChanZ = baseAIChanZ.extend({
1348
+ export const aiVoltageRMSChanZ = baseAIChanZ.extend({
1349
1349
  key: z.string(),
1350
1350
  type: z.literal("ai_voltage_rms"),
1351
1351
  terminalConfig: terminalConfigZ,
@@ -1372,7 +1372,7 @@ export const ZERO_AI_VOLTAGE_RMS_CHAN: AIVoltageRMSChan = {
1372
1372
  };
1373
1373
 
1374
1374
  // 31 - https://www.ni.com/docs/en-US/bundle/ni-daqmx-c-api-ref/page/daqmxcfunc/daqmxcreateaivoltagechanwithexcit.html
1375
- const aiVoltageChanWithExcitZ = baseAIChanZ.extend({
1375
+ export const aiVoltageChanWithExcitZ = baseAIChanZ.extend({
1376
1376
  type: z.literal("ai_voltage_with_excit"),
1377
1377
  terminalConfig: terminalConfigZ,
1378
1378
  minVal: z.number(),
@@ -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, observe, UnknownRecord } from "@synnaxlabs/x";
10
+ import { binary, type observe, type UnknownRecord } from "@synnaxlabs/x";
11
11
  import { z } from "zod";
12
12
 
13
13
  import { ontology } from "@/ontology";
@@ -10,7 +10,7 @@
10
10
  import { id } from "@synnaxlabs/x";
11
11
  import { describe, expect, it } from "vitest";
12
12
 
13
- import { task } from "@/hardware/task";
13
+ import { type task } from "@/hardware/task";
14
14
  import { newClient } from "@/setupspecs";
15
15
 
16
16
  const client = newClient();
package/src/index.ts CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  export { access } from "@/access";
11
11
  export { policy } from "@/access/policy";
12
- export * from "@/channel";
12
+ export { channel } from "@/channel";
13
13
  export { Channel } from "@/channel/client";
14
14
  export { default as Synnax, type SynnaxProps, synnaxPropsZ } from "@/client";
15
15
  export * from "@/connection";
@@ -37,6 +37,7 @@ export { signals } from "@/signals";
37
37
  export { user } from "@/user";
38
38
  export { workspace } from "@/workspace";
39
39
  export { linePlot } from "@/workspace/lineplot";
40
+ export { log } from "@/workspace/log";
40
41
  export { schematic } from "@/workspace/schematic";
41
42
  export {
42
43
  type CrudeDataType,
@@ -48,7 +49,6 @@ export {
48
49
  DataType,
49
50
  Density,
50
51
  MultiSeries,
51
- type NumericTelemValue,
52
52
  Rate,
53
53
  Series,
54
54
  type TelemValue,
@@ -14,7 +14,7 @@ import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
14
14
  import { type framer } from "@/framer";
15
15
  import { type Key, type Label, labelZ } from "@/label/payload";
16
16
  import { Retriever } from "@/label/retriever";
17
- import { type NewLabelPayload, SetOptions, Writer } from "@/label/writer";
17
+ import { type NewLabelPayload, type SetOptions, Writer } from "@/label/writer";
18
18
  import { ontology } from "@/ontology";
19
19
  import { signals } from "@/signals";
20
20
 
@@ -214,7 +214,7 @@ export class Client implements AsyncTermSearcher<string, string, Resource> {
214
214
  /**
215
215
  * Opens an observable that can be used to subscribe to changes in both the ontology's
216
216
  * resources and relationships.
217
- * @see ChangeTracker for more information.
217
+ * @link ChangeTracker for more information.
218
218
  * @returns An observable that emits changes to the ontology's resources and relationships.
219
219
  */
220
220
  async openChangeTracker(): Promise<ChangeTracker> {
@@ -290,9 +290,7 @@ export class ChangeTracker {
290
290
  }
291
291
 
292
292
  private async start(): Promise<void> {
293
- for await (const frame of this.streamer) {
294
- await this.update(frame);
295
- }
293
+ for await (const frame of this.streamer) await this.update(frame);
296
294
  }
297
295
 
298
296
  private async update(frame: framer.Frame): Promise<void> {
@@ -52,9 +52,9 @@ export type ParamAnalysisResult =
52
52
 
53
53
  export const analyzeParams = (groups: Params): ParamAnalysisResult => {
54
54
  const normal = toArray(groups) as Keys | Names;
55
- if (normal.length === 0) {
55
+ if (normal.length === 0)
56
56
  throw new Error("No groups specified");
57
- }
57
+
58
58
  const isKey = keyZ.safeParse(normal[0]).success;
59
59
  return {
60
60
  single: !Array.isArray(groups),
@@ -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 { change, UnknownRecord } from "@synnaxlabs/x";
10
+ import { type change, type UnknownRecord } from "@synnaxlabs/x";
11
11
  import { z } from "zod";
12
12
 
13
13
  export type ResourceChange = change.Change<ID, Resource>;
@@ -19,6 +19,7 @@ export type RelationshipDelete = change.Delete<Relationship, undefined>;
19
19
 
20
20
  export const resourceTypeZ = z.union([
21
21
  z.literal("label"),
22
+ z.literal("log"),
22
23
  z.literal("allow_all"),
23
24
  z.literal("builtin"),
24
25
  z.literal("cluster"),
@@ -12,7 +12,7 @@ import { type change } from "@synnaxlabs/x/change";
12
12
  import { z } from "zod";
13
13
 
14
14
  import { type channel } from "@/channel";
15
- import { type Key as ChannelKey,keyZ as channelKeyZ } from "@/channel/payload";
15
+ import { type Key as ChannelKey, keyZ as channelKeyZ } from "@/channel/payload";
16
16
  import { type Client as FrameClient } from "@/framer/client";
17
17
  import { type Key, keyZ } from "@/ranger/payload";
18
18
  import { signals } from "@/signals";
@@ -161,7 +161,7 @@ const aliasSeparator = "---";
161
161
  const decodeAliasChanges =
162
162
  (rangeKey: Key): signals.Decoder<string, Alias> =>
163
163
  (variant, data) => {
164
- if (variant === "delete") {
164
+ if (variant === "delete")
165
165
  return data
166
166
  .toStrings()
167
167
  .filter((k) => k.split(aliasSeparator)[0] === rangeKey)
@@ -170,7 +170,6 @@ const decodeAliasChanges =
170
170
  key: alias,
171
171
  value: undefined,
172
172
  }));
173
- }
174
173
  return data.parseJSON(aliasZ).map((alias) => ({
175
174
  variant,
176
175
  key: alias.alias,
@@ -8,21 +8,20 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
11
- import { CrudeTimeRange, observe, TimeRange } from "@synnaxlabs/x";
11
+ import { type CrudeTimeRange, observe, TimeRange } from "@synnaxlabs/x";
12
12
  import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
13
13
  import { type Series } from "@synnaxlabs/x/telem";
14
14
  import { toArray } from "@synnaxlabs/x/toArray";
15
15
  import { z } from "zod";
16
16
 
17
- import { Key as ChannelKey } from "@/channel/payload";
17
+ import { type Key as ChannelKey } from "@/channel/payload";
18
18
  import { type Retriever as ChannelRetriever } from "@/channel/retriever";
19
- import { MultipleFoundError, NotFoundError } from "@/errors";
20
- import { QueryError } from "@/errors";
19
+ import { MultipleFoundError, NotFoundError, QueryError } from "@/errors";
21
20
  import { type framer } from "@/framer";
22
21
  import { type label } from "@/label";
23
22
  import { type Label } from "@/label/payload";
24
23
  import { ontology } from "@/ontology";
25
- import { Resource } from "@/ontology/payload";
24
+ import { type Resource } from "@/ontology/payload";
26
25
  import { type Alias, Aliaser } from "@/ranger/alias";
27
26
  import { KV } from "@/ranger/kv";
28
27
  import {
@@ -37,7 +36,7 @@ import {
37
36
  type Payload,
38
37
  payloadZ,
39
38
  } from "@/ranger/payload";
40
- import { CreateOptions, type Writer } from "@/ranger/writer";
39
+ import { type CreateOptions, type Writer } from "@/ranger/writer";
41
40
  import { signals } from "@/signals";
42
41
  import { nullableArrayZ } from "@/util/zod";
43
42
 
@@ -98,9 +97,8 @@ export class Range {
98
97
 
99
98
  async setAlias(channel: ChannelKey | Name, alias: string): Promise<void> {
100
99
  const ch = await this.channels.retrieve(channel);
101
- if (ch.length === 0) {
102
- throw new QueryError(`Channel ${channel} does not exist`);
103
- }
100
+ if (ch.length === 0) throw new QueryError(`Channel ${channel} does not exist`);
101
+
104
102
  await this.aliaser.set({ [ch[0].key]: alias });
105
103
  }
106
104
 
package/src/ranger/kv.ts CHANGED
@@ -12,7 +12,7 @@ import { isObject } from "@synnaxlabs/x/identity";
12
12
  import { toArray } from "@synnaxlabs/x/toArray";
13
13
  import { z } from "zod";
14
14
 
15
- import { framer } from "@/framer";
15
+ import { type framer } from "@/framer";
16
16
  import { type Key, keyZ } from "@/ranger/payload";
17
17
  import { signals } from "@/signals";
18
18
  import { nullableArrayZ } from "@/util/zod";
@@ -96,7 +96,7 @@ export class KV {
96
96
  key: k,
97
97
  value: v,
98
98
  }));
99
- else pairs = [{ range: this.rangeKey, key: key, value: value }];
99
+ else pairs = [{ range: this.rangeKey, key, value }];
100
100
  await sendRequired(
101
101
  this.client,
102
102
  KV.SET_ENDPOINT,
@@ -79,7 +79,7 @@ export const ONTOLOGY_TYPE: ontology.ResourceType = "range";
79
79
  export const ALIAS_ONTOLOGY_TYPE: ontology.ResourceType = "range-alias";
80
80
 
81
81
  export const rangeOntologyID = (key: Key): ontology.ID =>
82
- new ontology.ID({ type: ONTOLOGY_TYPE, key: key });
82
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
83
83
 
84
84
  export const rangeAliasOntologyID = (key: Key): ontology.ID =>
85
- new ontology.ID({ type: ALIAS_ONTOLOGY_TYPE, key: key });
85
+ new ontology.ID({ type: ALIAS_ONTOLOGY_TYPE, key });
@@ -7,12 +7,12 @@
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 { change } from "@synnaxlabs/x";
10
+ import { type change } from "@synnaxlabs/x";
11
11
  import { DataType, Rate, TimeSpan, TimeStamp } from "@synnaxlabs/x/telem";
12
12
  import { describe, expect, it } from "vitest";
13
13
 
14
14
  import { QueryError } from "@/errors";
15
- import { ranger } from "@/ranger";
15
+ import { type ranger } from "@/ranger";
16
16
  import { type NewPayload } from "@/ranger/payload";
17
17
  import { newClient } from "@/setupspecs";
18
18
 
@@ -183,9 +183,8 @@ describe("User", () => {
183
183
  });
184
184
  });
185
185
  test("not found", async () => {
186
- for (const u of userArray) {
186
+ for (const u of userArray)
187
187
  await expect(client.user.delete(u.key as string)).resolves.toBeUndefined();
188
- }
189
188
  await expect(
190
189
  client.user.retrieve(userArray.map((u) => u.key as string)),
191
190
  ).rejects.toThrow(NotFoundError);
package/src/util/telem.ts CHANGED
@@ -12,8 +12,6 @@ import { type DataType, type TypedArray } from "@synnaxlabs/x/telem";
12
12
  export const randomSeries = (length: number, dataType: DataType): TypedArray => {
13
13
  // generate random bytes of the correct length
14
14
  const bytes = new Uint8Array(length * dataType.density.valueOf());
15
- for (let i = 0; i < bytes.byteLength; i++) {
16
- bytes[i] = Math.floor(Math.random() * 256);
17
- }
15
+ for (let i = 0; i < bytes.byteLength; i++) bytes[i] = Math.floor(Math.random() * 256);
18
16
  return new dataType.Array(bytes.buffer);
19
17
  };
@@ -12,6 +12,7 @@ import { type UnknownRecord } from "@synnaxlabs/x/record";
12
12
  import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
13
13
 
14
14
  import { linePlot } from "@/workspace/lineplot";
15
+ import { log } from "@/workspace/log";
15
16
  import { type Key, type Workspace } from "@/workspace/payload";
16
17
  import { Retriever } from "@/workspace/retriever";
17
18
  import { schematic } from "@/workspace/schematic";
@@ -21,6 +22,7 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
21
22
  readonly type = "workspace";
22
23
  readonly schematic: schematic.Client;
23
24
  readonly linePlot: linePlot.Client;
25
+ readonly log: log.Client;
24
26
  private readonly retriever: Retriever;
25
27
  private readonly writer: Writer;
26
28
 
@@ -28,6 +30,7 @@ export class Client implements AsyncTermSearcher<string, Key, Workspace> {
28
30
  this.schematic = new schematic.Client(client);
29
31
  this.linePlot = new linePlot.Client(client);
30
32
  this.retriever = new Retriever(client);
33
+ this.log = new log.Client(client);
31
34
  this.writer = new Writer(client);
32
35
  }
33
36
 
@@ -27,4 +27,4 @@ export type LinePlot = z.infer<typeof linePlotZ>;
27
27
  export const ONTOLOGY_TYPE: ontology.ResourceType = "lineplot";
28
28
 
29
29
  export const ontologyID = (key: Key): ontology.ID =>
30
- new ontology.ID({ type: ONTOLOGY_TYPE, key: key });
30
+ new ontology.ID({ type: ONTOLOGY_TYPE, key });
@@ -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 Log, type Params } from "@/workspace/log/payload";
14
+ import { Retriever } from "@/workspace/log/retriever";
15
+ import { type NewLog, Writer } from "@/workspace/log/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, log: NewLog): Promise<Log> {
27
+ return await this.writer.create(workspace, log);
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<Log>;
39
+
40
+ async retrieve(keys: Key[]): Promise<Log[]>;
41
+
42
+ async retrieve(keys: Params): Promise<Log | Log[]> {
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/log/client";
11
+ export * from "@/workspace/log/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 log from "@/workspace/log/external";