@milaboratories/pframes-rs-node 1.0.39 → 1.0.41
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/export/dump.ts +101 -1
- package/export/wrapper.ts +52 -21
- package/export_dist/dump.d.ts +7 -0
- package/export_dist/dump.d.ts.map +1 -1
- package/export_dist/index.js +19 -19
- package/export_dist/index.js.map +1 -1
- package/export_dist/index.mjs +318 -220
- package/export_dist/index.mjs.map +1 -1
- package/export_dist/wrapper.d.ts.map +1 -1
- package/package.json +7 -5
package/export/dump.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { Readable, Writable } from 'node:stream';
|
|
4
5
|
import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
6
|
+
import {
|
|
7
|
+
PObjectId,
|
|
8
|
+
PTableColumnId,
|
|
9
|
+
PTableRecordFilter,
|
|
10
|
+
PTableSorting,
|
|
11
|
+
UniqueValuesRequest
|
|
12
|
+
} from '@milaboratories/pl-model-common';
|
|
5
13
|
|
|
6
14
|
async function fileExists(path: string): Promise<boolean> {
|
|
7
15
|
try {
|
|
@@ -35,6 +43,98 @@ async function writeFile(
|
|
|
35
43
|
await fs.promises.rename(tempPath, filePath);
|
|
36
44
|
}
|
|
37
45
|
|
|
46
|
+
export function hashColumnId(columnId: PObjectId): PObjectId {
|
|
47
|
+
return createHash('sha256').update(columnId).digest('hex') as PObjectId;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function hashTableColumnId(tableId: PTableColumnId): PTableColumnId {
|
|
51
|
+
if (tableId.type === 'column') {
|
|
52
|
+
return {
|
|
53
|
+
...tableId,
|
|
54
|
+
id: hashColumnId(tableId.id)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return tableId;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function hashFilterColumnId(
|
|
61
|
+
filter: PTableRecordFilter
|
|
62
|
+
): PTableRecordFilter {
|
|
63
|
+
return {
|
|
64
|
+
...filter,
|
|
65
|
+
column: hashTableColumnId(filter.column)
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function hashUniqueValuesRequestColumnId(
|
|
70
|
+
request: UniqueValuesRequest
|
|
71
|
+
): UniqueValuesRequest {
|
|
72
|
+
return {
|
|
73
|
+
...request,
|
|
74
|
+
columnId: hashColumnId(request.columnId),
|
|
75
|
+
filters: request.filters.map(hashFilterColumnId)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function hashSortingColumnId(sorting: PTableSorting): PTableSorting {
|
|
80
|
+
return {
|
|
81
|
+
...sorting,
|
|
82
|
+
column: hashTableColumnId(sorting.column)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function hashJoinEntryColumnId(
|
|
87
|
+
entry: PFrameInternal.JoinEntryV3
|
|
88
|
+
): PFrameInternal.JoinEntryV3 {
|
|
89
|
+
const type = entry.type;
|
|
90
|
+
switch (type) {
|
|
91
|
+
case 'column':
|
|
92
|
+
return {
|
|
93
|
+
...entry,
|
|
94
|
+
columnId: hashColumnId(entry.columnId)
|
|
95
|
+
};
|
|
96
|
+
case 'slicedColumn':
|
|
97
|
+
return {
|
|
98
|
+
...entry,
|
|
99
|
+
columnId: hashColumnId(entry.columnId),
|
|
100
|
+
newId: hashColumnId(entry.newId)
|
|
101
|
+
};
|
|
102
|
+
case 'inlineColumn':
|
|
103
|
+
return {
|
|
104
|
+
...entry,
|
|
105
|
+
newId: hashColumnId(entry.newId)
|
|
106
|
+
};
|
|
107
|
+
case 'inner':
|
|
108
|
+
return {
|
|
109
|
+
...entry,
|
|
110
|
+
entries: entry.entries.map(hashJoinEntryColumnId)
|
|
111
|
+
};
|
|
112
|
+
case 'full':
|
|
113
|
+
return {
|
|
114
|
+
...entry,
|
|
115
|
+
entries: entry.entries.map(hashJoinEntryColumnId)
|
|
116
|
+
};
|
|
117
|
+
case 'outer':
|
|
118
|
+
return {
|
|
119
|
+
...entry,
|
|
120
|
+
primary: hashJoinEntryColumnId(entry.primary),
|
|
121
|
+
secondary: entry.secondary.map(hashJoinEntryColumnId)
|
|
122
|
+
};
|
|
123
|
+
default:
|
|
124
|
+
throw new Error(`Unsupported join entry type: ${type}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function hashCreateTableRequestColumnId(
|
|
129
|
+
request: PFrameInternal.CreateTableRequestV3
|
|
130
|
+
): PFrameInternal.CreateTableRequestV3 {
|
|
131
|
+
return {
|
|
132
|
+
...request,
|
|
133
|
+
src: hashJoinEntryColumnId(request.src),
|
|
134
|
+
filters: request.filters.map(hashFilterColumnId)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
38
138
|
export async function dump(
|
|
39
139
|
relativePath: string[],
|
|
40
140
|
data: { [key: string]: Object } | Uint8Array,
|
|
@@ -52,7 +152,7 @@ export async function dump(
|
|
|
52
152
|
const filePath = path.join(process.env.MI_DUMP_PFRAMES_RS, ...relativeUri);
|
|
53
153
|
const fileData = ArrayBuffer.isView(data)
|
|
54
154
|
? (data as Uint8Array)
|
|
55
|
-
: JSON.stringify(data);
|
|
155
|
+
: JSON.stringify(data, null, 2);
|
|
56
156
|
await writeFile(filePath, fileData);
|
|
57
157
|
} catch (error: unknown) {
|
|
58
158
|
logger?.('warn', `error while dumping PFrames data: ${error}`);
|
package/export/wrapper.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import humanizeDuration from 'humanize-duration';
|
|
1
2
|
import { ulid } from 'ulid';
|
|
2
3
|
import {
|
|
3
4
|
DataInfo,
|
|
@@ -17,7 +18,15 @@ import {
|
|
|
17
18
|
import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
18
19
|
import type { NodeFrameSymbol, NodeTableSymbol } from './addon-def';
|
|
19
20
|
import { AddonSymbol } from './addon';
|
|
20
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
hashColumnId,
|
|
23
|
+
dump,
|
|
24
|
+
hashTableColumnId,
|
|
25
|
+
hashFilterColumnId,
|
|
26
|
+
hashUniqueValuesRequestColumnId,
|
|
27
|
+
hashSortingColumnId,
|
|
28
|
+
hashCreateTableRequestColumnId
|
|
29
|
+
} from './dump';
|
|
21
30
|
|
|
22
31
|
export class PFrame implements PFrameInternal.PFrameV6 {
|
|
23
32
|
public readonly id: string = ulid();
|
|
@@ -61,7 +70,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
61
70
|
timeStamp: Date.now(),
|
|
62
71
|
requestType: 'addColumnSpec',
|
|
63
72
|
requestData: {
|
|
64
|
-
columnId,
|
|
73
|
+
columnId: hashColumnId(columnId),
|
|
65
74
|
columnSpec
|
|
66
75
|
}
|
|
67
76
|
},
|
|
@@ -69,7 +78,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
69
78
|
);
|
|
70
79
|
|
|
71
80
|
dump(
|
|
72
|
-
[`${this.id}`, `data`, `${columnId}.spec`],
|
|
81
|
+
[`${this.id}`, `data`, `${hashColumnId(columnId)}.spec`],
|
|
73
82
|
{
|
|
74
83
|
...columnSpec
|
|
75
84
|
},
|
|
@@ -124,7 +133,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
124
133
|
const t1 = performance.now();
|
|
125
134
|
this.logger?.(
|
|
126
135
|
'info',
|
|
127
|
-
`PFrame ${this.id} preloaded ${blobIds.length} blobs ${JSON.stringify(blobIds)}, took ${Math.round(t1 - t0)}
|
|
136
|
+
`PFrame ${this.id} preloaded ${blobIds.length} blobs ${JSON.stringify(blobIds)}, took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
128
137
|
);
|
|
129
138
|
}
|
|
130
139
|
},
|
|
@@ -175,7 +184,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
175
184
|
timeStamp: Date.now(),
|
|
176
185
|
requestType: 'setColumnData',
|
|
177
186
|
requestData: {
|
|
178
|
-
columnId,
|
|
187
|
+
columnId: hashColumnId(columnId),
|
|
179
188
|
dataInfo
|
|
180
189
|
}
|
|
181
190
|
},
|
|
@@ -183,7 +192,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
183
192
|
);
|
|
184
193
|
|
|
185
194
|
dump(
|
|
186
|
-
[`${this.id}`, `data`, `${columnId}.datainfo`],
|
|
195
|
+
[`${this.id}`, `data`, `${hashColumnId(columnId)}.datainfo`],
|
|
187
196
|
{
|
|
188
197
|
...dataInfo
|
|
189
198
|
},
|
|
@@ -258,7 +267,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
258
267
|
const t1 = performance.now();
|
|
259
268
|
this.logger?.(
|
|
260
269
|
'info',
|
|
261
|
-
`PFrame ${this.id} findColumns request ${requestId} took ${Math.round(t1 - t0)}
|
|
270
|
+
`PFrame ${this.id} findColumns request ${requestId} took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
262
271
|
);
|
|
263
272
|
}
|
|
264
273
|
}
|
|
@@ -291,7 +300,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
291
300
|
const t1 = performance.now();
|
|
292
301
|
this.logger?.(
|
|
293
302
|
'info',
|
|
294
|
-
`PFrame ${this.id} deleteColumn request ${requestId} took ${Math.round(t1 - t0)}
|
|
303
|
+
`PFrame ${this.id} deleteColumn request ${requestId} took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
295
304
|
);
|
|
296
305
|
}
|
|
297
306
|
}
|
|
@@ -304,7 +313,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
304
313
|
timeStamp: Date.now(),
|
|
305
314
|
requestType: 'getColumnSpec',
|
|
306
315
|
requestData: {
|
|
307
|
-
columnId
|
|
316
|
+
columnId: hashColumnId(columnId)
|
|
308
317
|
}
|
|
309
318
|
},
|
|
310
319
|
this.logger
|
|
@@ -324,7 +333,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
324
333
|
const t1 = performance.now();
|
|
325
334
|
this.logger?.(
|
|
326
335
|
'info',
|
|
327
|
-
`PFrame ${this.id} getColumnSpec request ${requestId} took ${Math.round(t1 - t0)}
|
|
336
|
+
`PFrame ${this.id} getColumnSpec request ${requestId} took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
328
337
|
);
|
|
329
338
|
}
|
|
330
339
|
}
|
|
@@ -353,7 +362,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
353
362
|
const t1 = performance.now();
|
|
354
363
|
this.logger?.(
|
|
355
364
|
'info',
|
|
356
|
-
`PFrame ${this.id} listColumns request ${requestId} took ${Math.round(t1 - t0)}
|
|
365
|
+
`PFrame ${this.id} listColumns request ${requestId} took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
357
366
|
);
|
|
358
367
|
}
|
|
359
368
|
}
|
|
@@ -366,7 +375,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
366
375
|
const dumpData = {
|
|
367
376
|
timeStamp: Date.now(),
|
|
368
377
|
requestType: 'createTable',
|
|
369
|
-
requestData: request
|
|
378
|
+
requestData: hashCreateTableRequestColumnId(request)
|
|
370
379
|
};
|
|
371
380
|
dump([`${this.id}`, `${requestId}.json`], dumpData, this.logger);
|
|
372
381
|
dump(
|
|
@@ -375,6 +384,10 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
375
384
|
this.logger
|
|
376
385
|
);
|
|
377
386
|
|
|
387
|
+
this.logger?.(
|
|
388
|
+
'info',
|
|
389
|
+
`PFrame ${this.id} createTable request ${requestId} started`
|
|
390
|
+
);
|
|
378
391
|
const t0 = performance.now();
|
|
379
392
|
try {
|
|
380
393
|
signal?.throwIfAborted();
|
|
@@ -396,7 +409,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
396
409
|
const t1 = performance.now();
|
|
397
410
|
this.logger?.(
|
|
398
411
|
'info',
|
|
399
|
-
`PFrame ${this.id} createTable request ${requestId} took ${Math.round(t1 - t0)}
|
|
412
|
+
`PFrame ${this.id} createTable request ${requestId} finished, took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
400
413
|
);
|
|
401
414
|
}
|
|
402
415
|
}
|
|
@@ -411,11 +424,15 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
411
424
|
{
|
|
412
425
|
timeStamp: Date.now(),
|
|
413
426
|
requestType: 'getUniqueValues',
|
|
414
|
-
requestData: request
|
|
427
|
+
requestData: hashUniqueValuesRequestColumnId(request)
|
|
415
428
|
},
|
|
416
429
|
this.logger
|
|
417
430
|
);
|
|
418
431
|
|
|
432
|
+
this.logger?.(
|
|
433
|
+
'info',
|
|
434
|
+
`PFrame ${this.id} getUniqueValues request ${requestId} started`
|
|
435
|
+
);
|
|
419
436
|
const t0 = performance.now();
|
|
420
437
|
try {
|
|
421
438
|
signal?.throwIfAborted();
|
|
@@ -436,7 +453,7 @@ export class PFrame implements PFrameInternal.PFrameV6 {
|
|
|
436
453
|
const t1 = performance.now();
|
|
437
454
|
this.logger?.(
|
|
438
455
|
'info',
|
|
439
|
-
`PFrame ${this.id} getUniqueValues request ${requestId} took ${Math.round(t1 - t0)}
|
|
456
|
+
`PFrame ${this.id} getUniqueValues request ${requestId} finished, took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
440
457
|
);
|
|
441
458
|
}
|
|
442
459
|
}
|
|
@@ -503,7 +520,7 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
503
520
|
timeStamp: Date.now(),
|
|
504
521
|
requestType: 'getColumnIndices',
|
|
505
522
|
requestData: {
|
|
506
|
-
columnIds
|
|
523
|
+
columnIds: columnIds.map(hashTableColumnId)
|
|
507
524
|
}
|
|
508
525
|
},
|
|
509
526
|
this.frame.logger
|
|
@@ -540,6 +557,10 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
540
557
|
this.frame.logger
|
|
541
558
|
);
|
|
542
559
|
|
|
560
|
+
this.frame.logger?.(
|
|
561
|
+
'info',
|
|
562
|
+
`PTable ${this.id} getData request ${requestId} started`
|
|
563
|
+
);
|
|
543
564
|
const t0 = performance.now();
|
|
544
565
|
try {
|
|
545
566
|
signal?.throwIfAborted();
|
|
@@ -562,7 +583,7 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
562
583
|
const t1 = performance.now();
|
|
563
584
|
this.frame.logger?.(
|
|
564
585
|
'info',
|
|
565
|
-
`PTable ${this.id} getData request ${requestId} took ${Math.round(t1 - t0)}
|
|
586
|
+
`PTable ${this.id} getData request ${requestId} finished, took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
566
587
|
);
|
|
567
588
|
}
|
|
568
589
|
}
|
|
@@ -576,7 +597,9 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
576
597
|
timeStamp: Date.now(),
|
|
577
598
|
table: this.id,
|
|
578
599
|
requestType: 'filter',
|
|
579
|
-
requestData:
|
|
600
|
+
requestData: {
|
|
601
|
+
filters: request.map(hashFilterColumnId)
|
|
602
|
+
}
|
|
580
603
|
};
|
|
581
604
|
dump(
|
|
582
605
|
[`${this.frame.id}`, `${requestId}.json`],
|
|
@@ -589,6 +612,10 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
589
612
|
this.frame.logger
|
|
590
613
|
);
|
|
591
614
|
|
|
615
|
+
this.frame.logger?.(
|
|
616
|
+
'info',
|
|
617
|
+
`PTable ${this.id} filter request ${requestId} started`
|
|
618
|
+
);
|
|
592
619
|
const t0 = performance.now();
|
|
593
620
|
try {
|
|
594
621
|
signal?.throwIfAborted();
|
|
@@ -610,7 +637,7 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
610
637
|
const t1 = performance.now();
|
|
611
638
|
this.frame.logger?.(
|
|
612
639
|
'info',
|
|
613
|
-
`PTable ${this.id} filter request ${requestId} took ${Math.round(t1 - t0)}
|
|
640
|
+
`PTable ${this.id} filter request ${requestId} finished, took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
614
641
|
);
|
|
615
642
|
}
|
|
616
643
|
}
|
|
@@ -624,7 +651,7 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
624
651
|
timeStamp: Date.now(),
|
|
625
652
|
table: this.id,
|
|
626
653
|
requestType: 'sort',
|
|
627
|
-
requestData: request
|
|
654
|
+
requestData: request.map(hashSortingColumnId)
|
|
628
655
|
};
|
|
629
656
|
dump(
|
|
630
657
|
[`${this.frame.id}`, `${requestId}.json`],
|
|
@@ -637,6 +664,10 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
637
664
|
this.frame.logger
|
|
638
665
|
);
|
|
639
666
|
|
|
667
|
+
this.frame.logger?.(
|
|
668
|
+
'info',
|
|
669
|
+
`PTable ${this.id} sort request ${requestId} started`
|
|
670
|
+
);
|
|
640
671
|
const t0 = performance.now();
|
|
641
672
|
try {
|
|
642
673
|
signal?.throwIfAborted();
|
|
@@ -658,7 +689,7 @@ class PTable implements PFrameInternal.PTableV4 {
|
|
|
658
689
|
const t1 = performance.now();
|
|
659
690
|
this.frame.logger?.(
|
|
660
691
|
'info',
|
|
661
|
-
`PTable ${this.id} sort request ${requestId} took ${Math.round(t1 - t0)}
|
|
692
|
+
`PTable ${this.id} sort request ${requestId} finished, took ${humanizeDuration(Math.round(t1 - t0))}`
|
|
662
693
|
);
|
|
663
694
|
}
|
|
664
695
|
}
|
package/export_dist/dump.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
|
|
2
|
+
import { PObjectId, PTableColumnId, PTableRecordFilter, PTableSorting, UniqueValuesRequest } from '@milaboratories/pl-model-common';
|
|
3
|
+
export declare function hashColumnId(columnId: PObjectId): PObjectId;
|
|
4
|
+
export declare function hashTableColumnId(tableId: PTableColumnId): PTableColumnId;
|
|
5
|
+
export declare function hashFilterColumnId(filter: PTableRecordFilter): PTableRecordFilter;
|
|
6
|
+
export declare function hashUniqueValuesRequestColumnId(request: UniqueValuesRequest): UniqueValuesRequest;
|
|
7
|
+
export declare function hashSortingColumnId(sorting: PTableSorting): PTableSorting;
|
|
8
|
+
export declare function hashCreateTableRequestColumnId(request: PFrameInternal.CreateTableRequestV3): PFrameInternal.CreateTableRequestV3;
|
|
2
9
|
export declare function dump(relativePath: string[], data: {
|
|
3
10
|
[key: string]: Object;
|
|
4
11
|
} | Uint8Array, logger?: PFrameInternal.Logger): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../export/dump.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../export/dump.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EACL,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAkCzC,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,CAE3D;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAQzE;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,kBAAkB,GACzB,kBAAkB,CAKpB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,mBAAmB,GAC3B,mBAAmB,CAMrB;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,CAKzE;AA4CD,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,cAAc,CAAC,oBAAoB,GAC3C,cAAc,CAAC,oBAAoB,CAMrC;AAED,wBAAsB,IAAI,CACxB,YAAY,EAAE,MAAM,EAAE,EACtB,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,UAAU,EAC5C,MAAM,CAAC,EAAE,cAAc,CAAC,MAAM,GAC7B,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
package/export_dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
${i.toString()}`)}}static async pprofDump(){return
|
|
3
|
-
${i.toString()}`)}}setDataSource(
|
|
4
|
-
${i.toString()}`)}}setColumnData(t
|
|
5
|
-
${i.toString()}`)}}dispose(){var
|
|
6
|
-
${r.toString()}`)}}[Symbol.dispose](){this.dispose()}async findColumns(
|
|
7
|
-
${
|
|
8
|
-
${
|
|
9
|
-
${
|
|
10
|
-
${i.toString()}`)}finally{const i=performance.now();(r=this.logger)==null||r.call(this,"info",`PFrame ${this.id} listColumns request ${
|
|
11
|
-
${
|
|
12
|
-
${a.toString()}`)}finally{const a=performance.now();(
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${r.toString()}`)}}async getData(t,
|
|
16
|
-
${
|
|
17
|
-
${
|
|
18
|
-
${
|
|
19
|
-
${i.toString()}`)}}[Symbol.dispose](){this.dispose()}}const
|
|
1
|
+
"use strict";var F=Object.defineProperty;var I=(o,e,t)=>e in o?F(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var S=(o,e,t)=>I(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("humanize-duration"),d=require("ulid"),j=require("node:module"),w=require("node:path"),E=require("node:url"),M=require("@mapbox/node-pre-gyp"),U=require("node:crypto"),g=require("node:fs"),y=require("node:stream");var D=typeof document<"u"?document.currentScript:null;const P=typeof document>"u"?require("url").pathToFileURL(__filename).href:D&&D.tagName.toUpperCase()==="SCRIPT"&&D.src||new URL("index.js",document.baseURI).href,R=w.dirname(E.fileURLToPath(P)),J=j.createRequire(P),{find:N}=M,c=J(N(w.resolve(R,"../package.json")));async function C(o){try{return await g.promises.access(o),!0}catch{return!1}}async function O(o){await C(o)||await g.promises.mkdir(o,{recursive:!0})}async function v(o,e){const t=`${o}.tmp`;await C(t)&&await g.promises.rm(t,{recursive:!0});const r=typeof e=="string"?Buffer.from(e,"utf8"):e,i=y.Readable.from(r),s=g.createWriteStream(t,{flags:"wx"});await y.Readable.toWeb(i).pipeTo(y.Writable.toWeb(s)),await g.promises.rename(t,o)}function m(o){return U.createHash("sha256").update(o).digest("hex")}function b(o){return o.type==="column"?{...o,id:m(o.id)}:o}function T(o){return{...o,column:b(o.column)}}function _(o){return{...o,columnId:m(o.columnId),filters:o.filters.map(T)}}function k(o){return{...o,column:b(o.column)}}function p(o){const e=o.type;switch(e){case"column":return{...o,columnId:m(o.columnId)};case"slicedColumn":return{...o,columnId:m(o.columnId),newId:m(o.newId)};case"inlineColumn":return{...o,newId:m(o.newId)};case"inner":return{...o,entries:o.entries.map(p)};case"full":return{...o,entries:o.entries.map(p)};case"outer":return{...o,primary:p(o.primary),secondary:o.secondary.map(p)};default:throw new Error(`Unsupported join entry type: ${e}`)}}function A(o){return{...o,src:p(o.src),filters:o.filters.map(T)}}async function n(o,e,t){if(process.env.MI_DUMP_PFRAMES_RS)try{const r=o.map(a=>encodeURIComponent(a)),i=w.join(process.env.MI_DUMP_PFRAMES_RS,...r.slice(0,-1));await O(i);const s=w.join(process.env.MI_DUMP_PFRAMES_RS,...r),u=ArrayBuffer.isView(e)?e:JSON.stringify(e,null,2);await v(s,u)}catch(r){t==null||t("warn",`error while dumping PFrames data: ${r}`)}}let x=class{constructor(e,t){S(this,"id",d.ulid());S(this,"frame");var r;this.logger=t,n([`${this.id}`,`${this.id}.json`],{timeStamp:Date.now(),requestType:"create"},this.logger);try{this.frame=c.pFrameCreate(e,t),(r=this.logger)==null||r.call(this,"info",`PFrame ${this.id} created`)}catch(i){throw new Error(`PFrame ${this.id} creation failed, logger: ${t==null?void 0:t.toString()}, error:
|
|
2
|
+
${i.toString()}`)}}static async pprofDump(){return c.pprofDump()}addColumnSpec(e,t){const r=d.ulid();n([`${this.id}`,`${r}.json`],{timeStamp:Date.now(),requestType:"addColumnSpec",requestData:{columnId:m(e),columnSpec:t}},this.logger),n([`${this.id}`,"data",`${m(e)}.spec`],{...t},this.logger);try{return c.pFrameAddColumnSpec(this.frame,e,t)}catch(i){throw new Error(`PFrame ${this.id} addColumnSpec request ${r} failed, columnId: ${JSON.stringify(e)}, columnSpec: ${JSON.stringify(t)}, error:
|
|
3
|
+
${i.toString()}`)}}setDataSource(e){const t=d.ulid();n([`${this.id}`,`${t}.json`],{timeStamp:Date.now(),requestType:"setDataSource"},this.logger);let r={preloadBlob:async i=>{var a;const s=d.ulid();n([`${this.id}`,`${s}.json`],{timeStamp:Date.now(),requestType:"preloadBlob",requestData:{blobIds:i}},this.logger);const u=performance.now();try{return e.preloadBlob(i)}finally{const h=performance.now();(a=this.logger)==null||a.call(this,"info",`PFrame ${this.id} preloaded ${i.length} blobs ${JSON.stringify(i)}, took ${f(Math.round(h-u))}`)}},resolveBlobContent:async i=>{var a;const s=d.ulid();n([`${this.id}`,`${s}.json`],{timeStamp:Date.now(),requestType:"resolveBlobContent",requestData:{blobId:i}},this.logger);const u=await e.resolveBlobContent(i);return(a=this.logger)==null||a.call(this,"info",`PFrame ${this.id} resolved blob ${i}`),n([`${this.id}`,"data",`${i}`],u,this.logger),u}};try{return c.pFrameSetDataSource(this.frame,r)}catch(i){throw new Error(`PFrame ${this.id} setDataSource request ${t} failed, dataSource: ${e.toString()}, error:
|
|
4
|
+
${i.toString()}`)}}setColumnData(e,t){const r=d.ulid();n([`${this.id}`,`${r}.json`],{timeStamp:Date.now(),requestType:"setColumnData",requestData:{columnId:m(e),dataInfo:t}},this.logger),n([`${this.id}`,"data",`${m(e)}.datainfo`],{...t},this.logger);try{return c.pFrameSetColumnData(this.frame,e,t)}catch(i){throw new Error(`PFrame ${this.id} setColumnData request ${r} failed, columnId: ${JSON.stringify(e)}, dataInfo: ${JSON.stringify(t)}, error:
|
|
5
|
+
${i.toString()}`)}}dispose(){var t;const e=d.ulid();n([`${this.id}`,`${e}.json`],{timeStamp:Date.now(),requestType:"dispose"},this.logger);try{c.pFrameDispose(this.frame),(t=this.logger)==null||t.call(this,"info",`PFrame ${this.id} disposed`)}catch(r){throw new Error(`PFrame ${this.id} dispose request ${e} failed, error:
|
|
6
|
+
${r.toString()}`)}}[Symbol.dispose](){this.dispose()}async findColumns(e){var i;const t=d.ulid();n([`${this.id}`,`${t}.json`],{timeStamp:Date.now(),requestType:"findColumns",requestData:e},this.logger);const r=performance.now();try{return await c.pFrameFindColumns(this.frame,e)}catch(s){throw new Error(`PFrame ${this.id} findColumns request ${t} failed, request: ${JSON.stringify(e)}, error:
|
|
7
|
+
${s.toString()}`)}finally{const s=performance.now();(i=this.logger)==null||i.call(this,"info",`PFrame ${this.id} findColumns request ${t} took ${f(Math.round(s-r))}`)}}async deleteColumn(e){var i;const t=d.ulid();n([`${this.id}`,`${t}.json`],{timeStamp:Date.now(),requestType:"deleteColumn",requestData:e},this.logger);const r=performance.now();try{return await c.pFrameDeleteColumn(this.frame,e)}catch(s){throw new Error(`PFrame ${this.id} deleteColumn request ${t} failed, request: ${JSON.stringify(e)}, error:
|
|
8
|
+
${s.toString()}`)}finally{const s=performance.now();(i=this.logger)==null||i.call(this,"info",`PFrame ${this.id} deleteColumn request ${t} took ${f(Math.round(s-r))}`)}}async getColumnSpec(e){var i;const t=d.ulid();n([`${this.id}`,`${t}.json`],{timeStamp:Date.now(),requestType:"getColumnSpec",requestData:{columnId:m(e)}},this.logger);const r=performance.now();try{return await c.pFrameGetColumnSpec(this.frame,e)}catch(s){throw new Error(`PFrame ${this.id} getColumnSpec request ${t} failed, columnId: ${JSON.stringify(e)}, error:
|
|
9
|
+
${s.toString()}`)}finally{const s=performance.now();(i=this.logger)==null||i.call(this,"info",`PFrame ${this.id} getColumnSpec request ${t} took ${f(Math.round(s-r))}`)}}async listColumns(){var r;const e=d.ulid();n([`${this.id}`,`${e}.json`],{timeStamp:Date.now(),requestType:"listColumns"},this.logger);const t=performance.now();try{return await c.pFrameListColumns(this.frame)}catch(i){throw new Error(`PFrame ${this.id} listColumns request ${e} failed, error:
|
|
10
|
+
${i.toString()}`)}finally{const i=performance.now();(r=this.logger)==null||r.call(this,"info",`PFrame ${this.id} listColumns request ${e} took ${f(Math.round(i-t))}`)}}async createTable(e,t){var u,a;const r=d.ulid(),i={timeStamp:Date.now(),requestType:"createTable",requestData:A(e)};n([`${this.id}`,`${r}.json`],i,this.logger),n([`${this.id}`,`${r}`,`${r}.json`],i,this.logger),(u=this.logger)==null||u.call(this,"info",`PFrame ${this.id} createTable request ${r} started`);const s=performance.now();try{t==null||t.throwIfAborted();const h=await c.pFrameCreateTable(this.frame,r,e,t);return new q(this,r,h)}catch(h){throw new Error(`PFrame ${this.id} createTable request ${r} failed, request: ${JSON.stringify(e)}, error:
|
|
11
|
+
${h.toString()}`)}finally{const h=performance.now();(a=this.logger)==null||a.call(this,"info",`PFrame ${this.id} createTable request ${r} finished, took ${f(Math.round(h-s))}`)}}async getUniqueValues(e,t){var s,u;const r=d.ulid();n([`${this.id}`,`${r}.json`],{timeStamp:Date.now(),requestType:"getUniqueValues",requestData:_(e)},this.logger),(s=this.logger)==null||s.call(this,"info",`PFrame ${this.id} getUniqueValues request ${r} started`);const i=performance.now();try{return t==null||t.throwIfAborted(),await c.pFrameGetUniqueValues(this.frame,r,e,t)}catch(a){throw new Error(`PFrame ${this.id} getUniqueValues request ${r} failed, request: ${JSON.stringify(e)}, error:
|
|
12
|
+
${a.toString()}`)}finally{const a=performance.now();(u=this.logger)==null||u.call(this,"info",`PFrame ${this.id} getUniqueValues request ${r} finished, took ${f(Math.round(a-i))}`)}}};class q{constructor(e,t,r){var i,s;this.frame=e,this.id=t,this.table=r,(s=(i=this.frame).logger)==null||s.call(i,"info",`PTable ${this.id} created`)}getShape(){const e=d.ulid();n([`${this.frame.id}`,`${this.id}`,`${e}.json`],{timeStamp:Date.now(),requestType:"getShape"},this.frame.logger);try{return c.pTableGetShape(this.table)}catch(t){throw new Error(`PTable ${this.id} getShape request ${e} failed, error:
|
|
13
|
+
${t.toString()}`)}}getSpec(){const e=d.ulid();n([`${this.frame.id}`,`${this.id}`,`${e}.json`],{timeStamp:Date.now(),requestType:"getSpec"},this.frame.logger);try{return c.pTableGetSpec(this.table)}catch(t){throw new Error(`PTable ${this.id} getSpec request ${e} failed, error:
|
|
14
|
+
${t.toString()}`)}}getColumnIndices(e){const t=d.ulid();n([`${this.frame.id}`,`${this.id}`,`${t}.json`],{timeStamp:Date.now(),requestType:"getColumnIndices",requestData:{columnIds:e.map(b)}},this.frame.logger);try{return c.pTableGetColumnIndices(this.table,e)}catch(r){throw new Error(`PTable ${this.id} getColumnIndices request ${t} failed, columnIds: ${JSON.stringify(e)}, error:
|
|
15
|
+
${r.toString()}`)}}async getData(e,t,r){var u,a,h,$;const i=d.ulid();n([`${this.frame.id}`,`${this.id}`,`${i}.json`],{timeStamp:Date.now(),requestType:"getData",requestData:{columnIndices:e,range:t??null}},this.frame.logger),(a=(u=this.frame).logger)==null||a.call(u,"info",`PTable ${this.id} getData request ${i} started`);const s=performance.now();try{return r==null||r.throwIfAborted(),await c.pTableGetData(this.table,i,e,t,r)}catch(l){throw new Error(`PTable ${this.id} getData request ${i} failed, columnIndices: ${JSON.stringify(e)}, range: ${t?JSON.stringify(t):void 0}, error:
|
|
16
|
+
${l.toString()}`)}finally{const l=performance.now();($=(h=this.frame).logger)==null||$.call(h,"info",`PTable ${this.id} getData request ${i} finished, took ${f(Math.round(l-s))}`)}}async filter(e,t){var u,a,h,$;const r=d.ulid(),i={timeStamp:Date.now(),table:this.id,requestType:"filter",requestData:{filters:e.map(T)}};n([`${this.frame.id}`,`${r}.json`],i,this.frame.logger),n([`${this.frame.id}`,`${r}`,`${r}.json`],i,this.frame.logger),(a=(u=this.frame).logger)==null||a.call(u,"info",`PTable ${this.id} filter request ${r} started`);const s=performance.now();try{t==null||t.throwIfAborted();const l=await c.pTableFilter(this.table,r,e,t);return new q(this.frame,r,l)}catch(l){throw new Error(`PTable ${this.id} filter request ${r} failed, request: ${JSON.stringify(e)}, error:
|
|
17
|
+
${l.toString()}`)}finally{const l=performance.now();($=(h=this.frame).logger)==null||$.call(h,"info",`PTable ${this.id} filter request ${r} finished, took ${f(Math.round(l-s))}`)}}async sort(e,t){var u,a,h,$;const r=d.ulid(),i={timeStamp:Date.now(),table:this.id,requestType:"sort",requestData:e.map(k)};n([`${this.frame.id}`,`${r}.json`],i,this.frame.logger),n([`${this.frame.id}`,`${r}`,`${r}.json`],i,this.frame.logger),(a=(u=this.frame).logger)==null||a.call(u,"info",`PTable ${this.id} sort request ${r} started`);const s=performance.now();try{t==null||t.throwIfAborted();const l=await c.pTableSort(this.table,r,e,t);return new q(this.frame,r,l)}catch(l){throw new Error(`PTable ${this.id} sort request ${r} failed, request: ${JSON.stringify(e)}, error:
|
|
18
|
+
${l.toString()}`)}finally{const l=performance.now();($=(h=this.frame).logger)==null||$.call(h,"info",`PTable ${this.id} sort request ${r} finished, took ${f(Math.round(l-s))}`)}}dispose(){var t,r;const e=d.ulid();n([`${this.frame.id}`,`${this.id}`,`${e}.json`],{timeStamp:Date.now(),requestType:"dispose"},this.frame.logger);try{c.pTableDispose(this.table),(r=(t=this.frame).logger)==null||r.call(t,"info",`PTable ${this.id} disposed`)}catch(i){throw new Error(`PTable ${this.id} dispose request ${e} failed, error:
|
|
19
|
+
${i.toString()}`)}}[Symbol.dispose](){this.dispose()}}const B=x;exports.PFrame=B;
|
|
20
20
|
//# sourceMappingURL=index.js.map
|