@milaboratories/pframes-rs-node 1.1.2 → 1.1.4

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 (47) hide show
  1. package/README.md +3 -3
  2. package/export/addon-def.ts +27 -39
  3. package/export/addon.ts +6 -8
  4. package/export/dump.ts +37 -48
  5. package/export/export.ts +4 -6
  6. package/export/index.ts +2 -2
  7. package/export/node-pre-gyp.d.ts +1 -1
  8. package/export/tests/pframes.test.ts +279 -333
  9. package/export/tests/setup.ts +6 -15
  10. package/export/wrapper.ts +149 -221
  11. package/package.json +45 -43
  12. package/export_dist/addon-def.d.ts +0 -43
  13. package/export_dist/addon-def.d.ts.map +0 -1
  14. package/export_dist/addon.cjs +0 -24
  15. package/export_dist/addon.cjs.map +0 -1
  16. package/export_dist/addon.d.ts +0 -4
  17. package/export_dist/addon.d.ts.map +0 -1
  18. package/export_dist/addon.js +0 -21
  19. package/export_dist/addon.js.map +0 -1
  20. package/export_dist/dump.cjs +0 -115
  21. package/export_dist/dump.cjs.map +0 -1
  22. package/export_dist/dump.d.ts +0 -12
  23. package/export_dist/dump.d.ts.map +0 -1
  24. package/export_dist/dump.js +0 -107
  25. package/export_dist/dump.js.map +0 -1
  26. package/export_dist/export.cjs +0 -15
  27. package/export_dist/export.cjs.map +0 -1
  28. package/export_dist/export.d.ts +0 -3
  29. package/export_dist/export.d.ts.map +0 -1
  30. package/export_dist/export.js +0 -13
  31. package/export_dist/export.js.map +0 -1
  32. package/export_dist/index.cjs +0 -13
  33. package/export_dist/index.cjs.map +0 -1
  34. package/export_dist/index.d.ts +0 -3
  35. package/export_dist/index.d.ts.map +0 -1
  36. package/export_dist/index.js +0 -3
  37. package/export_dist/index.js.map +0 -1
  38. package/export_dist/tests/pframes.test.d.ts +0 -2
  39. package/export_dist/tests/pframes.test.d.ts.map +0 -1
  40. package/export_dist/tests/setup.d.ts +0 -2
  41. package/export_dist/tests/setup.d.ts.map +0 -1
  42. package/export_dist/wrapper.cjs +0 -542
  43. package/export_dist/wrapper.cjs.map +0 -1
  44. package/export_dist/wrapper.d.ts +0 -54
  45. package/export_dist/wrapper.d.ts.map +0 -1
  46. package/export_dist/wrapper.js +0 -539
  47. package/export_dist/wrapper.js.map +0 -1
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # PFrames Node.js native addon
2
2
 
3
3
  ## Usage
4
- >
4
+
5
5
  > [!TIP]
6
6
  > Install using `pnpm install @milaboratories/pframes-rs-node` command.
7
7
  > Check [tests](tests/pframes.test.ts) for usage examples.
8
- >
8
+
9
9
  ## Build instructions
10
10
 
11
11
  ### Build steps
@@ -47,7 +47,7 @@ Debugging is only supported using VSCode with the following extencions installed
47
47
  4. Launch VSCode task (Cmd+Shift+P -> Tasks: Run Task -> Perf-profile platforma-desktop) for profiling
48
48
  5. Execute the test scenario and quite platforma-desktop
49
49
  6. Firefox profiler with recorded performance profile would automatically open in you browser of choice
50
- (Warning! Firefox profiler does not work in Safari and with AdBlock enabled)
50
+ (Warning! Firefox profiler does not work in Safari and with AdBlock enabled)
51
51
 
52
52
  ### Dump pframes requests
53
53
 
@@ -12,110 +12,98 @@ import type {
12
12
  UniqueValuesRequest,
13
13
  UniqueValuesResponse,
14
14
  QueryData,
15
- AxisId,
16
- PColumnIdAndSpec
17
- } from '@milaboratories/pl-model-common';
18
- import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
15
+ } from "@milaboratories/pl-model-common";
16
+ import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
19
17
 
20
- export interface NodeFrameSymbol extends Symbol {}
18
+ export interface NodeFrameSymbol
19
+ // oxlint-disable-next-line
20
+ extends Symbol {}
21
21
 
22
- export interface NodeTableSymbol extends Symbol {}
22
+ export interface NodeTableSymbol
23
+ // oxlint-disable-next-line
24
+ extends Symbol {}
23
25
 
24
26
  interface HeapProfiler {
25
27
  pprofDump: () => Promise<Uint8Array>;
26
28
  }
27
29
 
28
30
  interface NodeFrame {
29
- pFrameCreate: (
30
- spillPath: string,
31
- logger: PFrameInternal.Logger | undefined
32
- ) => NodeFrameSymbol;
31
+ pFrameCreate: (spillPath: string, logger: PFrameInternal.Logger | undefined) => NodeFrameSymbol;
33
32
  pFrameAddColumnSpec: (
34
33
  pFrame: NodeFrameSymbol,
35
34
  columnId: PObjectId,
36
- columnSpec: PColumnSpec
35
+ columnSpec: PColumnSpec,
37
36
  ) => void;
38
37
  pFrameSetDataSource: (
39
38
  pFrame: NodeFrameSymbol,
40
- dataSource: PFrameInternal.PFrameDataSourceV2
39
+ dataSource: PFrameInternal.PFrameDataSourceV2,
41
40
  ) => void;
42
41
  pFrameSetColumnData: (
43
42
  pFrame: NodeFrameSymbol,
44
43
  columnId: PObjectId,
45
44
  dataInfo: PFrameInternal.DataInfo<PFrameInternal.PFrameBlobId>,
46
- signal: AbortSignal | undefined
45
+ signal: AbortSignal | undefined,
47
46
  ) => Promise<void>;
48
47
  pFrameDispose: (pFrame: NodeFrameSymbol) => void;
49
48
  pFrameFindColumns: (
50
49
  pFrame: NodeFrameSymbol,
51
- request: PFrameInternal.FindColumnsRequest
50
+ request: PFrameInternal.FindColumnsRequest,
52
51
  ) => Promise<PFrameInternal.FindColumnsResponse>;
53
52
  pFrameDeleteColumn: (
54
53
  pFrame: NodeFrameSymbol,
55
- request: PFrameInternal.DeleteColumnFromColumnsRequest
54
+ request: PFrameInternal.DeleteColumnFromColumnsRequest,
56
55
  ) => Promise<PFrameInternal.DeleteColumnFromColumnsResponse>;
57
56
  pFrameGetColumnSpec: (
58
57
  pFrame: NodeFrameSymbol,
59
- columnId: PObjectId
58
+ columnId: PObjectId,
60
59
  ) => Promise<PColumnSpec | null>;
61
60
  pFrameListColumns: (pFrame: NodeFrameSymbol) => Promise<PColumnInfo[]>;
62
61
  pFrameCreateTable: (
63
62
  pFrame: NodeFrameSymbol,
64
63
  id: PFrameInternal.PTableId,
65
- request: PFrameInternal.CreateTableRequestV4
64
+ request: PFrameInternal.CreateTableRequestV4,
66
65
  ) => NodeTableSymbol;
67
- pFrameCreateTableByDataQuery: (
66
+ pFrameCreateTableV2: (
68
67
  pFrame: NodeFrameSymbol,
69
68
  id: PFrameInternal.PTableId,
70
69
  request: {
71
- tableSpec: {
72
- axes: AxisId[];
73
- columns: PColumnIdAndSpec[];
74
- };
70
+ tableSpec: PTableColumnSpec[];
75
71
  dataQuery: QueryData;
76
- }
72
+ },
77
73
  ) => NodeTableSymbol;
78
74
  pFrameGetUniqueValues: (
79
75
  pFrame: NodeFrameSymbol,
80
76
  id: PFrameInternal.PTableId,
81
77
  request: UniqueValuesRequest,
82
- signal: AbortSignal | undefined
78
+ signal: AbortSignal | undefined,
83
79
  ) => Promise<UniqueValuesResponse>;
84
80
  }
85
81
 
86
82
  interface NodeTable {
87
83
  pTableGetSpec: (boxed: NodeTableSymbol) => PTableColumnSpec[];
88
- pTableGetColumnIndices: (
89
- boxed: NodeTableSymbol,
90
- columnIds: PTableColumnId[]
91
- ) => number[];
92
- pTableGetFootprint: (
93
- boxed: NodeTableSymbol,
94
- signal: AbortSignal | undefined
95
- ) => Promise<number>;
96
- pTableGetShape: (
97
- boxed: NodeTableSymbol,
98
- signal: AbortSignal | undefined
99
- ) => Promise<PTableShape>;
84
+ pTableGetColumnIndices: (boxed: NodeTableSymbol, columnIds: PTableColumnId[]) => number[];
85
+ pTableGetFootprint: (boxed: NodeTableSymbol, signal: AbortSignal | undefined) => Promise<number>;
86
+ pTableGetShape: (boxed: NodeTableSymbol, signal: AbortSignal | undefined) => Promise<PTableShape>;
100
87
  pTableGetData: (
101
88
  boxed: NodeTableSymbol,
102
89
  id: PFrameInternal.PTableId,
103
90
  columnIndices: number[],
104
91
  range: TableRange | undefined,
105
- signal: AbortSignal | undefined
92
+ signal: AbortSignal | undefined,
106
93
  ) => Promise<PTableVector[]>;
107
94
  pTableFilter: (
108
95
  boxed: NodeTableSymbol,
109
96
  id: PFrameInternal.PTableId,
110
- request: PTableRecordFilter[]
97
+ request: PTableRecordFilter[],
111
98
  ) => NodeTableSymbol;
112
99
  pTableSort: (
113
100
  boxed: NodeTableSymbol,
114
101
  id: PFrameInternal.PTableId,
115
- request: PTableSorting[]
102
+ request: PTableSorting[],
116
103
  ) => NodeTableSymbol;
117
104
  pTableDispose: (boxed: NodeTableSymbol) => void;
118
105
  }
119
106
 
120
107
  export interface AddonSymbol
108
+ // oxlint-disable-next-line
121
109
  extends Symbol, HeapProfiler, NodeFrame, NodeTable {}
package/export/addon.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { createRequire } from 'node:module';
2
- import { dirname, resolve } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import gyp from '@mapbox/node-pre-gyp';
5
- import type { AddonSymbol } from './addon-def';
1
+ import { createRequire } from "node:module";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import gyp from "@mapbox/node-pre-gyp";
5
+ import type { AddonSymbol } from "./addon-def";
6
6
 
7
7
  const nodeFileUrl = import.meta.url;
8
8
  const nodeDirname = dirname(fileURLToPath(nodeFileUrl));
@@ -18,8 +18,6 @@ const { find: findAddon } = gyp;
18
18
  // https://github.com/search?q=repo%3Anodejs%2Fnode%20NAPI_MODULE_INITIALIZER&type=code
19
19
  // And neon exports napi_register_module_v1 from #[neon::main]
20
20
  // https://github.com/neon-bindings/neon/blob/b1728fa21e968ccde9611ac9955cf6d638be16e6/crates/neon/src/context/internal.rs#L76
21
- const AddonSymbol = nodeRequire(
22
- findAddon(resolve(nodeDirname, '../package.json'))
23
- ) as AddonSymbol;
21
+ const AddonSymbol = nodeRequire(findAddon(resolve(nodeDirname, "../package.json"))) as AddonSymbol;
24
22
 
25
23
  export { AddonSymbol };
package/export/dump.ts CHANGED
@@ -1,97 +1,91 @@
1
- import { createHash } from 'node:crypto';
2
- import { promises as fs } from 'node:fs';
3
- import { join } from 'node:path';
4
- import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
1
+ import { createHash } from "node:crypto";
2
+ import { promises as fs } from "node:fs";
3
+ import { join } from "node:path";
4
+ import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
5
5
  import type {
6
6
  PObjectId,
7
7
  PTableColumnId,
8
8
  PTableRecordFilter,
9
9
  PTableSorting,
10
- UniqueValuesRequest
11
- } from '@milaboratories/pl-model-common';
10
+ UniqueValuesRequest,
11
+ } from "@milaboratories/pl-model-common";
12
12
 
13
13
  export function hashColumnId(columnId: PObjectId): PObjectId {
14
- return createHash('sha256').update(columnId).digest('hex') as PObjectId;
14
+ return createHash("sha256").update(columnId).digest("hex") as PObjectId;
15
15
  }
16
16
 
17
17
  export function hashTableColumnId(tableId: PTableColumnId): PTableColumnId {
18
- if (tableId.type === 'column') {
18
+ if (tableId.type === "column") {
19
19
  return {
20
20
  ...tableId,
21
- id: hashColumnId(tableId.id)
21
+ id: hashColumnId(tableId.id),
22
22
  };
23
23
  }
24
24
  return tableId;
25
25
  }
26
26
 
27
- export function hashFilterColumnId(
28
- filter: PTableRecordFilter
29
- ): PTableRecordFilter {
27
+ export function hashFilterColumnId(filter: PTableRecordFilter): PTableRecordFilter {
30
28
  return {
31
29
  ...filter,
32
- column: hashTableColumnId(filter.column)
30
+ column: hashTableColumnId(filter.column),
33
31
  };
34
32
  }
35
33
 
36
- export function hashUniqueValuesRequestColumnId(
37
- request: UniqueValuesRequest
38
- ): UniqueValuesRequest {
34
+ export function hashUniqueValuesRequestColumnId(request: UniqueValuesRequest): UniqueValuesRequest {
39
35
  return {
40
36
  ...request,
41
37
  columnId: hashColumnId(request.columnId),
42
- filters: request.filters.map(hashFilterColumnId)
38
+ filters: request.filters.map(hashFilterColumnId),
43
39
  };
44
40
  }
45
41
 
46
42
  export function hashSortingColumnId(sorting: PTableSorting): PTableSorting {
47
43
  return {
48
44
  ...sorting,
49
- column: hashTableColumnId(sorting.column)
45
+ column: hashTableColumnId(sorting.column),
50
46
  };
51
47
  }
52
48
 
53
- function hashJoinEntryColumnId(
54
- entry: PFrameInternal.JoinEntryV4
55
- ): PFrameInternal.JoinEntryV4 {
49
+ function hashJoinEntryColumnId(entry: PFrameInternal.JoinEntryV4): PFrameInternal.JoinEntryV4 {
56
50
  const type = entry.type;
57
51
  switch (type) {
58
- case 'column':
52
+ case "column":
59
53
  return {
60
54
  ...entry,
61
- columnId: hashColumnId(entry.columnId)
55
+ columnId: hashColumnId(entry.columnId),
62
56
  };
63
- case 'slicedColumn':
57
+ case "slicedColumn":
64
58
  return {
65
59
  ...entry,
66
60
  columnId: hashColumnId(entry.columnId),
67
- newId: hashColumnId(entry.newId)
61
+ newId: hashColumnId(entry.newId),
68
62
  };
69
- case 'artificialColumn':
63
+ case "artificialColumn":
70
64
  return {
71
65
  ...entry,
72
66
  columnId: hashColumnId(entry.columnId),
73
- newId: hashColumnId(entry.newId)
67
+ newId: hashColumnId(entry.newId),
74
68
  };
75
- case 'inlineColumn':
69
+ case "inlineColumn":
76
70
  return {
77
71
  ...entry,
78
- newId: hashColumnId(entry.newId)
72
+ newId: hashColumnId(entry.newId),
79
73
  };
80
- case 'inner':
74
+ case "inner":
81
75
  return {
82
76
  ...entry,
83
- entries: entry.entries.map(hashJoinEntryColumnId)
77
+ entries: entry.entries.map(hashJoinEntryColumnId),
84
78
  };
85
- case 'full':
79
+ case "full":
86
80
  return {
87
81
  ...entry,
88
- entries: entry.entries.map(hashJoinEntryColumnId)
82
+ entries: entry.entries.map(hashJoinEntryColumnId),
89
83
  };
90
- case 'outer':
84
+ case "outer":
91
85
  return {
92
86
  ...entry,
93
87
  primary: hashJoinEntryColumnId(entry.primary),
94
- secondary: entry.secondary.map(hashJoinEntryColumnId)
88
+ secondary: entry.secondary.map(hashJoinEntryColumnId),
95
89
  };
96
90
  default:
97
91
  throw new Error(`Unsupported join entry type: ${type}`);
@@ -99,35 +93,30 @@ function hashJoinEntryColumnId(
99
93
  }
100
94
 
101
95
  export function hashCreateTableRequestColumnId(
102
- request: PFrameInternal.CreateTableRequestV4
96
+ request: PFrameInternal.CreateTableRequestV4,
103
97
  ): PFrameInternal.CreateTableRequestV4 {
104
98
  return {
105
99
  ...request,
106
100
  src: hashJoinEntryColumnId(request.src),
107
- filters: request.filters.map(hashFilterColumnId)
101
+ filters: request.filters.map(hashFilterColumnId),
108
102
  };
109
103
  }
110
104
 
111
105
  export async function dump(
112
106
  relativePath: string[],
113
- data: { [key: string]: Object } | Uint8Array,
114
- logger?: PFrameInternal.Logger
107
+ data: { [key: string]: string | number | boolean | object } | Uint8Array,
108
+ logger?: PFrameInternal.Logger,
115
109
  ): Promise<void> {
116
110
  if (!process.env.MI_DUMP_PFRAMES_RS) return;
117
111
  try {
118
112
  const relativeUri = relativePath.map((part) => encodeURIComponent(part));
119
- const fileDir = join(
120
- process.env.MI_DUMP_PFRAMES_RS,
121
- ...relativeUri.slice(0, -1)
122
- );
113
+ const fileDir = join(process.env.MI_DUMP_PFRAMES_RS, ...relativeUri.slice(0, -1));
123
114
  await fs.mkdir(fileDir, { recursive: true });
124
115
 
125
116
  const filePath = join(process.env.MI_DUMP_PFRAMES_RS, ...relativeUri);
126
- const fileData = ArrayBuffer.isView(data)
127
- ? data
128
- : JSON.stringify(data, null, 2);
129
- await fs.writeFile(filePath, fileData, { flag: 'wx' });
117
+ const fileData = ArrayBuffer.isView(data) ? data : JSON.stringify(data, null, 2);
118
+ await fs.writeFile(filePath, fileData, { flag: "wx" });
130
119
  } catch (error: unknown) {
131
- logger?.('warn', `error while dumping PFrames data: ${error}`);
120
+ logger?.("warn", `error while dumping PFrames data: ${error}`);
132
121
  }
133
122
  }
package/export/export.ts CHANGED
@@ -1,13 +1,11 @@
1
- import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
2
- import { PFrame, pprofDump } from './wrapper';
1
+ import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
2
+ import { PFrame, pprofDump } from "./wrapper";
3
3
 
4
4
  export const PFrameFactory: PFrameInternal.PFrameFactoryV4 = {
5
- createPFrame: (
6
- options: PFrameInternal.PFrameOptionsV2
7
- ): PFrameInternal.PFrameV13 => {
5
+ createPFrame: (options: PFrameInternal.PFrameOptionsV2): PFrameInternal.PFrameV13 => {
8
6
  return new PFrame(options);
9
7
  },
10
8
  pprofDump: async (): Promise<Uint8Array> => {
11
9
  return await pprofDump();
12
- }
10
+ },
13
11
  };
package/export/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { PFrameFactory } from './export';
2
- export { HttpHelpers } from '@milaboratories/pframes-rs-serv';
1
+ export { PFrameFactory } from "./export";
2
+ export { HttpHelpers } from "@milaboratories/pframes-rs-serv";
@@ -1,3 +1,3 @@
1
- declare module '@mapbox/node-pre-gyp' {
1
+ declare module "@mapbox/node-pre-gyp" {
2
2
  function find(packageRoot: string): string;
3
3
  }