@synnaxlabs/client 0.15.3 → 0.16.3

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.
@@ -0,0 +1,8 @@
1
+ # pytest cache directory #
2
+
3
+ This directory contains data from the pytest's cache plugin,
4
+ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
+
6
+ **Do not** commit this to version control.
7
+
8
+ See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
@@ -1,16 +1,16 @@
1
1
 
2
- > @synnaxlabs/client@0.15.3 build /home/runner/work/synnax/synnax/client/ts
2
+ > @synnaxlabs/client@0.15.3 build /Users/emilianobonilla/Desktop/synnaxlabs/synnax/client/ts
3
3
  > tsc --noEmit && vite build
4
4
 
5
- vite v5.1.2 building for production...
5
+ vite v5.1.2 building for production...
6
6
  transforming...
7
- ✓ 103 modules transformed.
7
+ 103 modules transformed.
8
8
  rendering chunks...
9
- 
10
- [vite:dts] Start generate declaration files...
9
+
10
+ [vite:dts] Start generate declaration files...
11
11
  computing gzip size...
12
- dist/client.es.js 521.17 kB │ gzip: 114.65 kB │ map: 1,285.87 kB
13
- [vite:dts] Declaration files built in 3563ms.
14
- 
15
- dist/client.cjs.js 347.31 kB │ gzip: 91.63 kB │ map: 1,231.44 kB
16
- ✓ built in 5.10s
12
+ dist/client.js 525.34 kB │ gzip: 115.61 kB │ map: 1,305.03 kB
13
+ [vite:dts] Declaration files built in 1356ms.
14
+
15
+ dist/client.cjs 349.33 kB │ gzip: 91.91 kB │ map: 1,250.18 kB
16
+ ✓ built in 2.05s
package/README.md CHANGED
@@ -1,3 +1,12 @@
1
- # synnax
1
+ # Synnax Client
2
+
3
+ A client library for interacting with a Synnax cluster. It supports Typescript and can be used in both node and browser environments.
4
+
5
+ Detailed documentation is available [here](https://docs.synnaxlabs.com/typescript-client/get-started]).
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @synnaxlabs/client
11
+ ```
2
12
 
3
- synnax Client Library
@@ -1,28 +1,68 @@
1
- import { DataType, Rate, type NativeTypedArray, type CrudeDensity, type Series, type TimeRange, type AsyncTermSearcher, type CrudeTimeSpan } from "@synnaxlabs/x";
1
+ import { type UnaryClient } from "@synnaxlabs/freighter";
2
+ import { DataType, Rate, type NativeTypedArray, type CrudeDensity, type Series, type TimeRange, type AsyncTermSearcher, type CrudeTimeStamp } from "@synnaxlabs/x";
2
3
  import { type Creator } from './creator';
3
4
  import { type Key, type KeyOrName, type Params, type Payload, type NewPayload } from './payload';
4
5
  import { type Retriever } from './retriever';
5
6
  import { type framer } from '../framer';
6
- import { UnaryClient } from "@synnaxlabs/freighter";
7
7
  /**
8
- * Represents a Channel in a Synnax database. It should not be instantiated
9
- * directly, but rather created or retrieved from a {@link Client}.
8
+ * Represents a Channel in a Synnax database. Typically, channels should not be
9
+ * instantiated directly, but instead created via the `.channels.create` or retrieved
10
+ * via the `.channels.retrieve` method on a Synnax client.
11
+ *
12
+ * Please refer to the [Synnax documentation](https://docs.synnaxlabs.com) for detailed
13
+ * information on what channels are and how to use them.
10
14
  */
11
15
  export declare class Channel {
12
16
  private readonly _frameClient;
13
- key: Key;
14
- name: string;
15
- rate: Rate;
16
- dataType: DataType;
17
- leaseholder: number;
18
- index: Key;
19
- isIndex: boolean;
20
- alias: string | undefined;
17
+ /**
18
+ * A unique key identifying the channel in the Synnax database. This key is
19
+ * automatically assigned by Synnax.
20
+ */
21
+ readonly key: Key;
22
+ /**
23
+ * A human-readable name for the channel. This name is not guaranteed to be
24
+ * unique.
25
+ */
26
+ readonly name: string;
27
+ /**
28
+ * The rate at which the channel samples telemetry. This only applies to fixed rate
29
+ * channels, and will be 0 if the channel is indexed.
30
+ */
31
+ readonly rate: Rate;
32
+ /**
33
+ * The data type of the channel.
34
+ */
35
+ readonly dataType: DataType;
36
+ /**
37
+ * The key of the node in the Synnax cluster that holds the 'lease' over the channel
38
+ * i.e. it's the only node in the cluster allowed to accept writes to the channel. This
39
+ * property is mostly for internal use.
40
+ */
41
+ readonly leaseholder: number;
42
+ /**
43
+ * The key of the index channel that this channel is associated with i.e. the channel
44
+ * that stores its timestamps.
45
+ */
46
+ readonly index: Key;
47
+ /**
48
+ * This is set to true if the channel is an index channel, and false otherwise.
49
+ */
50
+ readonly isIndex: boolean;
51
+ /**
52
+ * An alias for the channel under a specific range. This parameter is unstable and
53
+ * should not be relied upon in the current version of Synnax.
54
+ */
55
+ readonly alias: string | undefined;
21
56
  constructor({ dataType, rate, name, leaseholder, key, isIndex, index, frameClient, alias, }: NewPayload & {
22
57
  frameClient?: framer.Client;
23
58
  density?: CrudeDensity;
24
59
  });
25
60
  private get framer();
61
+ /**
62
+ * Returns the payload representation of this channel i.e. a pure JS object with
63
+ * all of the channel fields but without any methods. This is used internally for
64
+ * network transportation, but also provided to you as a convenience.
65
+ */
26
66
  get payload(): Payload;
27
67
  /**
28
68
  * Reads telemetry from the channel between the two timestamps.
@@ -38,21 +78,113 @@ export declare class Channel {
38
78
  * @param start - The starting timestamp of the first sample in data.
39
79
  * @param data - THe telemetry to write to the channel.
40
80
  */
41
- write(start: CrudeTimeSpan, data: NativeTypedArray): Promise<void>;
81
+ write(start: CrudeTimeStamp, data: NativeTypedArray): Promise<void>;
42
82
  }
43
83
  /**
44
84
  * The core client class for executing channel operations against a Synnax
45
- * cluster.
85
+ * cluster. This class should not be instantiated directly, and instead should be used
86
+ * through the `channels` property of an {@link Synnax} client.
46
87
  */
47
88
  export declare class Client implements AsyncTermSearcher<string, Key, Channel> {
48
89
  private readonly frameClient;
49
90
  private readonly retriever;
50
91
  private readonly creator;
51
92
  private readonly client;
52
- constructor(segmentClient: framer.Client, retriever: Retriever, client: UnaryClient, creator: Creator);
93
+ constructor(frameClient: framer.Client, retriever: Retriever, client: UnaryClient, creator: Creator);
94
+ /**
95
+ * Creates a single channel with the given properties.
96
+ *
97
+ * @param name - A human-readable name for the channel.
98
+ * @param rate - The rate of the channel. This only applies to fixed rate channels.
99
+ * @param dataType - The data type for the samples stored in the channel.
100
+ * @param index - The key of the index channel that this channel should be associated
101
+ * with. An 'index' channel is a channel that stores timestamps for other channels. Refer
102
+ * to the Synnax documentation (https://docs.synnaxlabs.com) for more information. The
103
+ * index channel must have already been created. This field does not need to be specified
104
+ * if the channel is an index channel, or the channel is a fixed rate channel. If this
105
+ * value is specified, the 'rate' parameter will be ignored.
106
+ * @param isIndex - Set to true if the channel is an index channel, and false otherwise.
107
+ * Index channels must have a data type of `DataType.TIMESTAMP`.
108
+ * @returns the created channel. {@see Channel}
109
+ * @throws {ValidationError} if any of the parameters for creating the channel are
110
+ * invalid.
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const indexChannel = await client.channels.create({
115
+ * name: "time",
116
+ * dataType: DataType.TIMESTAMP,
117
+ * isIndex: true,
118
+ * })
119
+ *
120
+ *
121
+ * const dataChannel = await client.channels.create({
122
+ * name: "temperature",
123
+ * dataType: DataType.FLOAT,
124
+ * index: indexChannel.key,
125
+ * });
126
+ * ```
127
+ */
53
128
  create(channel: NewPayload): Promise<Channel>;
129
+ /**
130
+ * Creates multiple channels with the given properties. The order of the channels
131
+ * returned is guaranteed to match the order of the channels passed in.
132
+ *
133
+ * @param channels - An array of channel properties to create.
134
+ * For each channel, the following properties should be considered:
135
+ *
136
+ * @param name - A human-readable name for the channel.
137
+ * @param rate - The rate of the channel. This only applies to fixed rate channels. If
138
+ * the 'index' parameter is specified or 'isIndex' is set to true, this parameter will
139
+ * be ignored.
140
+ * @param dataType - The data type for the samples stored in the channel.
141
+ * @param index - The key of the index channel that this channel should be associated
142
+ * with. An 'index' channel is a channel that stores timestamps for other channels. Refer
143
+ * to the Synnax documentation (https://docs.synnaxlabs.com) for more information. The
144
+ * index channel must have already been created. This field does not need to be specified
145
+ * if the channel is an index channel, or the channel is a fixed rate channel. If this
146
+ * value is specified, the 'rate' parameter will be ignored.
147
+ * @param isIndex - Set to true if the channel is an index channel, and false otherwise.
148
+ * Index channels must have a data type of `DataType.TIMESTAMP`.
149
+ *
150
+ * @param channels
151
+ */
54
152
  create(channels: NewPayload[]): Promise<Channel[]>;
153
+ /**
154
+ * Retrieves a channel from the database using the given key or name.
155
+ *
156
+ * @param channel - The key or name of the channel to retrieve.
157
+ * @param options - Optional parameters to control the retrieval process.
158
+ * @param options.dataTypes - Limits the query to only channels with the specified data
159
+ * type.
160
+ * @param options.notDataTypes - Limits the query to only channels without the specified
161
+ * data type.
162
+ *
163
+ * @returns The retrieved channel.
164
+ * @throws {NotFoundError} if the channel does not exist in the cluster.
165
+ * @throws {MultipleResultsError} is only thrown if the channel is retrieved by name,
166
+ * and multiple channels with the same name exist in the cluster.
167
+ *
168
+ * @example
169
+ *
170
+ * ```typescript
171
+ * const channel = await client.channels.retrieve("temperature");
172
+ * const channel = await client.channels.retrieve(1);
173
+ * ```
174
+ */
55
175
  retrieve(channel: KeyOrName, rangeKey?: string): Promise<Channel>;
176
+ /**
177
+ * Retrieves multiple channels from the database using the provided keys or the
178
+ * provided names.
179
+ *
180
+ * @param channels - The keys or the names of the channels to retrieve. Note that
181
+ * this method does not support mixing keys and names in the same call.
182
+ * @param options - Optional parameters to control the retrieval process.
183
+ * @param options.dataTypes - Limits the query to only channels with the specified data
184
+ * type.
185
+ * @param options.notDataTypes - Limits the query to only channels without the specified
186
+ *
187
+ */
56
188
  retrieve(channels: Params, rangeKey?: string): Promise<Channel[]>;
57
189
  search(term: string, rangeKey?: string): Promise<Channel[]>;
58
190
  newSearcherUnderRange(rangeKey?: string): AsyncTermSearcher<string, Key, Channel>;