@milaboratories/pframes-rs-node 1.0.57 → 1.0.63

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 (40) hide show
  1. package/README.md +17 -5
  2. package/export/addon-def.ts +0 -1
  3. package/export/dump.ts +13 -14
  4. package/export/export.ts +10 -10
  5. package/export/index.ts +2 -1
  6. package/export/wrapper.ts +143 -132
  7. package/export_dist/addon-def.d.ts +1 -1
  8. package/export_dist/addon-def.d.ts.map +1 -1
  9. package/export_dist/addon.cjs +24 -0
  10. package/export_dist/addon.cjs.map +1 -0
  11. package/export_dist/addon.d.ts +1 -1
  12. package/export_dist/addon.js +21 -0
  13. package/export_dist/addon.js.map +1 -0
  14. package/export_dist/dump.cjs +133 -0
  15. package/export_dist/dump.cjs.map +1 -0
  16. package/export_dist/dump.d.ts +1 -1
  17. package/export_dist/dump.d.ts.map +1 -1
  18. package/export_dist/dump.js +125 -0
  19. package/export_dist/dump.js.map +1 -0
  20. package/export_dist/export.cjs +15 -0
  21. package/export_dist/export.cjs.map +1 -0
  22. package/export_dist/export.d.ts +2 -6
  23. package/export_dist/export.d.ts.map +1 -1
  24. package/export_dist/export.js +13 -0
  25. package/export_dist/export.js.map +1 -0
  26. package/export_dist/index.cjs +13 -0
  27. package/export_dist/index.cjs.map +1 -0
  28. package/export_dist/index.d.ts +2 -1
  29. package/export_dist/index.d.ts.map +1 -1
  30. package/export_dist/index.js +2 -21
  31. package/export_dist/index.js.map +1 -1
  32. package/export_dist/wrapper.cjs +511 -0
  33. package/export_dist/wrapper.cjs.map +1 -0
  34. package/export_dist/wrapper.d.ts +32 -10
  35. package/export_dist/wrapper.d.ts.map +1 -1
  36. package/export_dist/wrapper.js +508 -0
  37. package/export_dist/wrapper.js.map +1 -0
  38. package/package.json +34 -33
  39. package/export_dist/index.mjs +0 -765
  40. package/export_dist/index.mjs.map +0 -1
package/README.md CHANGED
@@ -1,35 +1,46 @@
1
1
  # PFrames Node.js native addon
2
+
2
3
  ## Usage
4
+ >
3
5
  > [!TIP]
4
- > Install using `npm install @milaboratory/pframes-rs-node` command.
6
+ > Install using `pnpm install @milaboratories/pframes-rs-node` command.
5
7
  > Check [tests](tests/pframes.test.ts) for usage examples.
8
+ >
6
9
  ## Build instructions
10
+
7
11
  ### Build steps
12
+
8
13
  ```sh
9
- npm run build
14
+ pnpm run build
10
15
  ```
11
16
 
12
17
  ### Artifacts
18
+
13
19
  NodeJS Native Addon is places in `dist` folder.
14
- Use `npm run pack` to prepare an archive (last output line is its path) and upload it to AWS S3.
20
+ Use `pnpm run pack` to prepare an archive (last output line is its path) and upload it to AWS S3.
15
21
 
16
22
  Export wrapper is placed in `export_dist` folder.
17
- Use `npm publish` to publish NodeJS package.
23
+ Use `pnpm publish` to publish NodeJS package.
18
24
 
19
25
  ## Debugging
26
+
20
27
  ### Prerequisites
28
+
21
29
  Debugging is only supported using VSCode with the following extencions installed (check `@recommended` section in VScode for more suggestions):
30
+
22
31
  - [C/C++](vscode:extension/ms-vscode.cpptools)
23
32
  - [CodeLLDB](vscode:extension/vadimcn.vscode-lldb)
24
33
  - [rust-analyzer](vscode:extension/rust-lang.rust-analyzer)
25
34
 
26
35
  ### Launching debug session
36
+
27
37
  1. Clone and build the latest `platforma-desktop-v2` (`git clean -dffx && npm i && npm run build`)
28
38
  2. Set the correct RELATIVE path to `platforma-desktop-v2` in `.vscode/settings.json` variable `platformaDesktopPath` (default is `../platforma-desktop-v2`)
29
- 3. Build this package by following the build steps from above (for faster build use `npm run dev-build`)
39
+ 3. Build this package by following the build steps from above (for faster build use `pnpm run dev-build`)
30
40
  4. Use VSCode launch configuration for your platform to start debug session ([VSCode debugging guide](https://code.visualstudio.com/docs/debugtest/debugging))
31
41
 
32
42
  ### Performance profiling
43
+
33
44
  1. Clone and build the latest `platforma-desktop-v2`
34
45
  2. Set the correct RELATIVE path to `platforma-desktop-v2` in `.vscode/settings.json` variable `platformaDesktopPath`
35
46
  3. Build this package by following the build steps from above
@@ -39,5 +50,6 @@ Debugging is only supported using VSCode with the following extencions installed
39
50
  (Warning! Firefox profiler does not work in Safari and with AdBlock enabled)
40
51
 
41
52
  ### Dump pframes requests
53
+
42
54
  1. Run `platforma-desktop-v2` with `MI_DUMP_PFRAMES_RS=/absolute/path/to/dump/requests npm run dev`
43
55
  2. Archive the `/absolute/path/to/dump/requests` folder and pass to the developer
@@ -1,5 +1,4 @@
1
1
  import {
2
- DataInfo,
3
2
  PColumnInfo,
4
3
  PColumnSpec,
5
4
  PObjectId,
package/export/dump.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { createHash } from 'node:crypto';
2
- import fs from 'node:fs';
2
+ import { createWriteStream, promises as fs } from 'node:fs';
3
3
  import path from 'node:path';
4
- import { Readable, Writable } from 'node:stream';
4
+ import { Readable } from 'node:stream';
5
+ import { pipeline } from 'node:stream/promises';
5
6
  import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
6
7
  import {
7
8
  PObjectId,
@@ -11,18 +12,16 @@ import {
11
12
  UniqueValuesRequest
12
13
  } from '@milaboratories/pl-model-common';
13
14
 
14
- async function fileExists(path: string): Promise<boolean> {
15
- try {
16
- await fs.promises.access(path);
17
- return true;
18
- } catch {
19
- return false;
20
- }
15
+ function fileExists(path: string): Promise<boolean> {
16
+ return fs
17
+ .access(path)
18
+ .then(() => true)
19
+ .catch(() => false);
21
20
  }
22
21
 
23
22
  async function ensureDirExists(fileOrDir: string): Promise<void> {
24
23
  if (!(await fileExists(fileOrDir))) {
25
- await fs.promises.mkdir(fileOrDir, { recursive: true });
24
+ await fs.mkdir(fileOrDir, { recursive: true });
26
25
  }
27
26
  }
28
27
 
@@ -32,15 +31,15 @@ async function writeFile(
32
31
  ): Promise<void> {
33
32
  const tempPath = `${filePath}.tmp`;
34
33
  if (await fileExists(tempPath)) {
35
- await fs.promises.rm(tempPath, { recursive: true });
34
+ await fs.rm(tempPath, { recursive: true });
36
35
  }
37
36
 
38
37
  const buffer = typeof data === 'string' ? Buffer.from(data, 'utf8') : data;
39
38
  const source = Readable.from(buffer);
40
- const destination = fs.createWriteStream(tempPath, { flags: 'wx' });
41
- await Readable.toWeb(source).pipeTo(Writable.toWeb(destination));
39
+ const destination = createWriteStream(tempPath, { flags: 'wx' });
40
+ await pipeline(source, destination);
42
41
 
43
- await fs.promises.rename(tempPath, filePath);
42
+ await fs.rename(tempPath, filePath);
44
43
  }
45
44
 
46
45
  export function hashColumnId(columnId: PObjectId): PObjectId {
package/export/export.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import type { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
2
- import { PFrame as PFrameImpl } from './wrapper';
2
+ import { PFrame, pprofDump } from './wrapper';
3
3
 
4
- export type PFrame = {
5
- new (
6
- spillPath: string,
7
- logger?: PFrameInternal.Logger
8
- ): PFrameInternal.PFrameV9;
9
-
10
- pprofDump: () => Promise<Uint8Array>;
4
+ export const PFrameFactory: PFrameInternal.PFrameFactory = {
5
+ createPFrame: (
6
+ options: PFrameInternal.PFrameOptions
7
+ ): PFrameInternal.PFrameV10 => {
8
+ return new PFrame(options);
9
+ },
10
+ pprofDump: async (): Promise<Uint8Array> => {
11
+ return await pprofDump();
12
+ }
11
13
  };
12
-
13
- export const PFrame: PFrame = PFrameImpl;
package/export/index.ts CHANGED
@@ -1 +1,2 @@
1
- export { PFrame } from './export';
1
+ export { PFrameFactory } from './export';
2
+ export { HttpHelpers } from '@milaboratories/pframes-rs-serv';