@synnaxlabs/client 0.49.2 → 0.49.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.
- package/.turbo/turbo-build.log +5 -5
- package/dist/client.cjs +27 -27
- package/dist/client.js +3439 -3444
- package/dist/src/framer/external.d.ts +1 -0
- package/dist/src/framer/external.d.ts.map +1 -1
- package/dist/src/framer/iterator.d.ts +5 -0
- package/dist/src/framer/iterator.d.ts.map +1 -1
- package/dist/src/framer/reader.d.ts +3 -1
- package/dist/src/framer/reader.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/framer/external.ts +1 -0
- package/src/framer/iterator.spec.ts +67 -0
- package/src/framer/iterator.ts +7 -0
- package/src/framer/reader.spec.ts +212 -83
- package/src/framer/reader.ts +13 -6
package/src/framer/reader.ts
CHANGED
|
@@ -13,13 +13,14 @@ import { type CrudeTimeRange, csv, runtime } from "@synnaxlabs/x";
|
|
|
13
13
|
import { type channel } from "@/channel";
|
|
14
14
|
import { UnexpectedError } from "@/errors";
|
|
15
15
|
import { type Frame } from "@/framer/frame";
|
|
16
|
-
import { Iterator } from "@/framer/iterator";
|
|
16
|
+
import { Iterator, type IteratorConfig } from "@/framer/iterator";
|
|
17
17
|
|
|
18
18
|
export interface ReadRequest {
|
|
19
19
|
channels: channel.Params;
|
|
20
20
|
timeRange: CrudeTimeRange;
|
|
21
|
-
channelNames?:
|
|
21
|
+
channelNames?: Record<channel.KeyOrName, string>;
|
|
22
22
|
responseType: "csv";
|
|
23
|
+
iteratorConfig?: IteratorConfig;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export class Reader {
|
|
@@ -32,7 +33,12 @@ export class Reader {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
async read(request: ReadRequest): Promise<ReadableStream<Uint8Array>> {
|
|
35
|
-
const {
|
|
36
|
+
const {
|
|
37
|
+
channels: channelParams,
|
|
38
|
+
timeRange,
|
|
39
|
+
channelNames,
|
|
40
|
+
iteratorConfig,
|
|
41
|
+
} = request;
|
|
36
42
|
const channelPayloads = await this.retriever.retrieve(channelParams);
|
|
37
43
|
const allKeys = new Set<channel.Key>();
|
|
38
44
|
channelPayloads.forEach((ch) => {
|
|
@@ -51,6 +57,7 @@ export class Reader {
|
|
|
51
57
|
Array.from(allKeys),
|
|
52
58
|
this.retriever,
|
|
53
59
|
this.streamClient,
|
|
60
|
+
iteratorConfig,
|
|
54
61
|
);
|
|
55
62
|
return createCSVReadableStream({
|
|
56
63
|
iterator,
|
|
@@ -63,7 +70,7 @@ export class Reader {
|
|
|
63
70
|
interface CreateCSVExportStreamParams {
|
|
64
71
|
iterator: Iterator;
|
|
65
72
|
channelPayloads: channel.Payload[];
|
|
66
|
-
headers?:
|
|
73
|
+
headers?: Record<channel.KeyOrName, string>;
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
const createCSVReadableStream = ({
|
|
@@ -219,7 +226,7 @@ interface ColumnMetaResult {
|
|
|
219
226
|
const buildColumnMeta = (
|
|
220
227
|
channels: channel.Payload[],
|
|
221
228
|
groups: Map<channel.Key, channel.Keys>,
|
|
222
|
-
headers?:
|
|
229
|
+
headers?: Record<channel.KeyOrName, string>,
|
|
223
230
|
): ColumnMetaResult => {
|
|
224
231
|
const channelMap = new Map(channels.map((ch) => [ch.key, ch]));
|
|
225
232
|
const columns: ColumnMeta[] = [];
|
|
@@ -233,7 +240,7 @@ const buildColumnMeta = (
|
|
|
233
240
|
if (ch == null) throw new UnexpectedError(`Channel ${key} not found`);
|
|
234
241
|
const meta: ColumnMeta = {
|
|
235
242
|
key,
|
|
236
|
-
header: headers?.
|
|
243
|
+
header: headers?.[key] ?? headers?.[ch.name] ?? ch.name,
|
|
237
244
|
};
|
|
238
245
|
columns.push(meta);
|
|
239
246
|
groupColumns.push(meta);
|