@milaboratories/pframes-rs-node 1.1.3 → 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 +26 -33
  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 +239 -307
  9. package/export/tests/setup.ts +6 -15
  10. package/export/wrapper.ts +145 -210
  11. package/package.json +43 -41
  12. package/export_dist/addon-def.d.ts +0 -40
  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 -51
  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
 
@@ -11,56 +11,57 @@ import type {
11
11
  TableRange,
12
12
  UniqueValuesRequest,
13
13
  UniqueValuesResponse,
14
- QueryData
15
- } from '@milaboratories/pl-model-common';
16
- import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
14
+ QueryData,
15
+ } from "@milaboratories/pl-model-common";
16
+ import type { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
17
17
 
18
- export interface NodeFrameSymbol extends Symbol {}
18
+ export interface NodeFrameSymbol
19
+ // oxlint-disable-next-line
20
+ extends Symbol {}
19
21
 
20
- export interface NodeTableSymbol extends Symbol {}
22
+ export interface NodeTableSymbol
23
+ // oxlint-disable-next-line
24
+ extends Symbol {}
21
25
 
22
26
  interface HeapProfiler {
23
27
  pprofDump: () => Promise<Uint8Array>;
24
28
  }
25
29
 
26
30
  interface NodeFrame {
27
- pFrameCreate: (
28
- spillPath: string,
29
- logger: PFrameInternal.Logger | undefined
30
- ) => NodeFrameSymbol;
31
+ pFrameCreate: (spillPath: string, logger: PFrameInternal.Logger | undefined) => NodeFrameSymbol;
31
32
  pFrameAddColumnSpec: (
32
33
  pFrame: NodeFrameSymbol,
33
34
  columnId: PObjectId,
34
- columnSpec: PColumnSpec
35
+ columnSpec: PColumnSpec,
35
36
  ) => void;
36
37
  pFrameSetDataSource: (
37
38
  pFrame: NodeFrameSymbol,
38
- dataSource: PFrameInternal.PFrameDataSourceV2
39
+ dataSource: PFrameInternal.PFrameDataSourceV2,
39
40
  ) => void;
40
41
  pFrameSetColumnData: (
41
42
  pFrame: NodeFrameSymbol,
42
43
  columnId: PObjectId,
43
44
  dataInfo: PFrameInternal.DataInfo<PFrameInternal.PFrameBlobId>,
44
- signal: AbortSignal | undefined
45
+ signal: AbortSignal | undefined,
45
46
  ) => Promise<void>;
46
47
  pFrameDispose: (pFrame: NodeFrameSymbol) => void;
47
48
  pFrameFindColumns: (
48
49
  pFrame: NodeFrameSymbol,
49
- request: PFrameInternal.FindColumnsRequest
50
+ request: PFrameInternal.FindColumnsRequest,
50
51
  ) => Promise<PFrameInternal.FindColumnsResponse>;
51
52
  pFrameDeleteColumn: (
52
53
  pFrame: NodeFrameSymbol,
53
- request: PFrameInternal.DeleteColumnFromColumnsRequest
54
+ request: PFrameInternal.DeleteColumnFromColumnsRequest,
54
55
  ) => Promise<PFrameInternal.DeleteColumnFromColumnsResponse>;
55
56
  pFrameGetColumnSpec: (
56
57
  pFrame: NodeFrameSymbol,
57
- columnId: PObjectId
58
+ columnId: PObjectId,
58
59
  ) => Promise<PColumnSpec | null>;
59
60
  pFrameListColumns: (pFrame: NodeFrameSymbol) => Promise<PColumnInfo[]>;
60
61
  pFrameCreateTable: (
61
62
  pFrame: NodeFrameSymbol,
62
63
  id: PFrameInternal.PTableId,
63
- request: PFrameInternal.CreateTableRequestV4
64
+ request: PFrameInternal.CreateTableRequestV4,
64
65
  ) => NodeTableSymbol;
65
66
  pFrameCreateTableV2: (
66
67
  pFrame: NodeFrameSymbol,
@@ -68,49 +69,41 @@ interface NodeFrame {
68
69
  request: {
69
70
  tableSpec: PTableColumnSpec[];
70
71
  dataQuery: QueryData;
71
- }
72
+ },
72
73
  ) => NodeTableSymbol;
73
74
  pFrameGetUniqueValues: (
74
75
  pFrame: NodeFrameSymbol,
75
76
  id: PFrameInternal.PTableId,
76
77
  request: UniqueValuesRequest,
77
- signal: AbortSignal | undefined
78
+ signal: AbortSignal | undefined,
78
79
  ) => Promise<UniqueValuesResponse>;
79
80
  }
80
81
 
81
82
  interface NodeTable {
82
83
  pTableGetSpec: (boxed: NodeTableSymbol) => PTableColumnSpec[];
83
- pTableGetColumnIndices: (
84
- boxed: NodeTableSymbol,
85
- columnIds: PTableColumnId[]
86
- ) => number[];
87
- pTableGetFootprint: (
88
- boxed: NodeTableSymbol,
89
- signal: AbortSignal | undefined
90
- ) => Promise<number>;
91
- pTableGetShape: (
92
- boxed: NodeTableSymbol,
93
- signal: AbortSignal | undefined
94
- ) => 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>;
95
87
  pTableGetData: (
96
88
  boxed: NodeTableSymbol,
97
89
  id: PFrameInternal.PTableId,
98
90
  columnIndices: number[],
99
91
  range: TableRange | undefined,
100
- signal: AbortSignal | undefined
92
+ signal: AbortSignal | undefined,
101
93
  ) => Promise<PTableVector[]>;
102
94
  pTableFilter: (
103
95
  boxed: NodeTableSymbol,
104
96
  id: PFrameInternal.PTableId,
105
- request: PTableRecordFilter[]
97
+ request: PTableRecordFilter[],
106
98
  ) => NodeTableSymbol;
107
99
  pTableSort: (
108
100
  boxed: NodeTableSymbol,
109
101
  id: PFrameInternal.PTableId,
110
- request: PTableSorting[]
102
+ request: PTableSorting[],
111
103
  ) => NodeTableSymbol;
112
104
  pTableDispose: (boxed: NodeTableSymbol) => void;
113
105
  }
114
106
 
115
107
  export interface AddonSymbol
108
+ // oxlint-disable-next-line
116
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
  }