@milaboratories/pf-driver 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.
Files changed (66) hide show
  1. package/dist/data_info_helpers.cjs +1 -1
  2. package/dist/data_info_helpers.cjs.map +1 -1
  3. package/dist/data_info_helpers.d.ts +1 -1
  4. package/dist/data_info_helpers.d.ts.map +1 -1
  5. package/dist/data_info_helpers.js +1 -1
  6. package/dist/data_info_helpers.js.map +1 -1
  7. package/dist/driver_decl.d.ts +2 -2
  8. package/dist/driver_decl.d.ts.map +1 -1
  9. package/dist/driver_double.cjs +1 -1
  10. package/dist/driver_double.cjs.map +1 -1
  11. package/dist/driver_double.d.ts +6 -6
  12. package/dist/driver_double.d.ts.map +1 -1
  13. package/dist/driver_double.js +1 -1
  14. package/dist/driver_double.js.map +1 -1
  15. package/dist/driver_impl.cjs +35 -32
  16. package/dist/driver_impl.cjs.map +1 -1
  17. package/dist/driver_impl.d.ts +7 -7
  18. package/dist/driver_impl.d.ts.map +1 -1
  19. package/dist/driver_impl.js +35 -32
  20. package/dist/driver_impl.js.map +1 -1
  21. package/dist/index.d.ts +4 -4
  22. package/dist/pframe_pool.cjs +21 -19
  23. package/dist/pframe_pool.cjs.map +1 -1
  24. package/dist/pframe_pool.d.ts +4 -4
  25. package/dist/pframe_pool.d.ts.map +1 -1
  26. package/dist/pframe_pool.js +21 -19
  27. package/dist/pframe_pool.js.map +1 -1
  28. package/dist/ptable_cache_per_frame.cjs +6 -6
  29. package/dist/ptable_cache_per_frame.cjs.map +1 -1
  30. package/dist/ptable_cache_per_frame.d.ts +4 -4
  31. package/dist/ptable_cache_per_frame.d.ts.map +1 -1
  32. package/dist/ptable_cache_per_frame.js +6 -6
  33. package/dist/ptable_cache_per_frame.js.map +1 -1
  34. package/dist/ptable_cache_plain.cjs +5 -5
  35. package/dist/ptable_cache_plain.cjs.map +1 -1
  36. package/dist/ptable_cache_plain.d.ts +4 -4
  37. package/dist/ptable_cache_plain.d.ts.map +1 -1
  38. package/dist/ptable_cache_plain.js +5 -5
  39. package/dist/ptable_cache_plain.js.map +1 -1
  40. package/dist/ptable_def_pool.cjs +2 -2
  41. package/dist/ptable_def_pool.cjs.map +1 -1
  42. package/dist/ptable_def_pool.d.ts +4 -4
  43. package/dist/ptable_def_pool.js +2 -2
  44. package/dist/ptable_def_pool.js.map +1 -1
  45. package/dist/ptable_pool.cjs +30 -26
  46. package/dist/ptable_pool.cjs.map +1 -1
  47. package/dist/ptable_pool.d.ts +6 -6
  48. package/dist/ptable_pool.d.ts.map +1 -1
  49. package/dist/ptable_pool.js +30 -26
  50. package/dist/ptable_pool.js.map +1 -1
  51. package/dist/ptable_shared.cjs.map +1 -1
  52. package/dist/ptable_shared.d.ts +1 -1
  53. package/dist/ptable_shared.js.map +1 -1
  54. package/package.json +29 -29
  55. package/src/data_info_helpers.ts +6 -7
  56. package/src/driver_decl.ts +8 -16
  57. package/src/driver_double.test.ts +89 -83
  58. package/src/driver_double.ts +23 -19
  59. package/src/driver_impl.ts +115 -80
  60. package/src/index.ts +4 -4
  61. package/src/pframe_pool.ts +42 -37
  62. package/src/ptable_cache_per_frame.ts +16 -13
  63. package/src/ptable_cache_plain.ts +16 -12
  64. package/src/ptable_def_pool.ts +7 -7
  65. package/src/ptable_pool.ts +62 -45
  66. package/src/ptable_shared.ts +2 -2
@@ -3,40 +3,38 @@ import {
3
3
  type CalculateTableDataResponse,
4
4
  type PFrameDriver,
5
5
  type PObjectId,
6
- } from '@platforma-sdk/model';
7
- import {
8
- readJson,
9
- PFrameInternal,
10
- } from '@milaboratories/pl-model-middle-layer';
11
- import { test } from 'vitest';
12
- import { join } from 'node:path';
13
- import {
14
- createPFrameDriverDouble,
15
- makeFolderPath,
16
- } from './driver_double';
6
+ } from "@platforma-sdk/model";
7
+ import { readJson, PFrameInternal } from "@milaboratories/pl-model-middle-layer";
8
+ import { test } from "vitest";
9
+ import { join } from "node:path";
10
+ import { createPFrameDriverDouble, makeFolderPath } from "./driver_double";
17
11
 
18
- test('inline column support', async ({ expect }) => {
12
+ test("inline column support", async ({ expect }) => {
19
13
  // Model context
20
14
 
21
15
  await using driver = await createPFrameDriverDouble({});
22
- using pFrame = driver.createPFrame([{
23
- id: 'column1' as PObjectId,
24
- spec: {
25
- kind: 'PColumn',
26
- axesSpec: [{
27
- name: 'axis1',
28
- type: 'String',
29
- }],
30
- name: 'column1',
31
- valueType: 'Int',
32
- },
33
- data: [
34
- {
35
- key: ['axis1'],
36
- val: 1,
16
+ using pFrame = driver.createPFrame([
17
+ {
18
+ id: "column1" as PObjectId,
19
+ spec: {
20
+ kind: "PColumn",
21
+ axesSpec: [
22
+ {
23
+ name: "axis1",
24
+ type: "String",
25
+ },
26
+ ],
27
+ name: "column1",
28
+ valueType: "Int",
37
29
  },
38
- ],
39
- }]);
30
+ data: [
31
+ {
32
+ key: ["axis1"],
33
+ val: 1,
34
+ },
35
+ ],
36
+ },
37
+ ]);
40
38
 
41
39
  // UI context
42
40
 
@@ -45,8 +43,8 @@ test('inline column support', async ({ expect }) => {
45
43
 
46
44
  const data = await uiDriver.calculateTableData(pFrameHandle, {
47
45
  src: {
48
- type: 'column',
49
- column: 'column1' as PObjectId,
46
+ type: "column",
47
+ column: "column1" as PObjectId,
50
48
  },
51
49
  filters: [],
52
50
  sorting: [],
@@ -55,39 +53,41 @@ test('inline column support', async ({ expect }) => {
55
53
  expect(data).toEqual([
56
54
  {
57
55
  spec: {
58
- type: 'axis',
56
+ type: "axis",
59
57
  id: {
60
- name: 'axis1',
61
- type: 'String',
58
+ name: "axis1",
59
+ type: "String",
62
60
  },
63
61
  spec: {
64
- name: 'axis1',
65
- type: 'String',
62
+ name: "axis1",
63
+ type: "String",
66
64
  },
67
65
  },
68
66
  data: {
69
- type: 'String',
70
- data: ['axis1'],
67
+ type: "String",
68
+ data: ["axis1"],
71
69
  isNA: new Uint8Array(),
72
70
  absent: new Uint8Array(),
73
71
  },
74
72
  },
75
73
  {
76
74
  spec: {
77
- type: 'column',
78
- id: 'column1' as PObjectId,
75
+ type: "column",
76
+ id: "column1" as PObjectId,
79
77
  spec: {
80
- kind: 'PColumn',
81
- axesSpec: [{
82
- name: 'axis1',
83
- type: 'String',
84
- }],
85
- name: 'column1',
86
- valueType: 'Int',
78
+ kind: "PColumn",
79
+ axesSpec: [
80
+ {
81
+ name: "axis1",
82
+ type: "String",
83
+ },
84
+ ],
85
+ name: "column1",
86
+ valueType: "Int",
87
87
  },
88
88
  },
89
89
  data: {
90
- type: 'Int',
90
+ type: "Int",
91
91
  data: new Int32Array([1]),
92
92
  isNA: new Uint8Array(),
93
93
  absent: new Uint8Array(),
@@ -96,43 +96,49 @@ test('inline column support', async ({ expect }) => {
96
96
  ] satisfies CalculateTableDataResponse);
97
97
  });
98
98
 
99
- test.for([
100
- { testCase: '01_json' },
101
- { testCase: '02_binary' },
102
- { testCase: '03_parquet' },
103
- ])(`stored column support - $testCase`, async ({ testCase }, { expect }) => {
104
- const dataFolder = makeFolderPath(join(__dirname, '..', 'assets', testCase));
99
+ test.for([{ testCase: "01_json" }, { testCase: "02_binary" }, { testCase: "03_parquet" }])(
100
+ `stored column support - $testCase`,
101
+ async ({ testCase }, { expect }) => {
102
+ const dataFolder = makeFolderPath(join(__dirname, "..", "assets", testCase));
105
103
 
106
- // Model context
104
+ // Model context
107
105
 
108
- await using driver = await createPFrameDriverDouble({ dataFolder });
109
- const pFrame = driver.createPFrame([{
110
- id: 'column' as PObjectId,
111
- spec: await readJson(join(dataFolder, `column${PFrameInternal.SpecExtension}`)),
112
- data: await readJson(join(dataFolder, `column${PFrameInternal.DataInfoExtension}`)),
113
- }]);
106
+ await using driver = await createPFrameDriverDouble({ dataFolder });
107
+ const pFrame = driver.createPFrame([
108
+ {
109
+ id: "column" as PObjectId,
110
+ spec: await readJson(join(dataFolder, `column${PFrameInternal.SpecExtension}`)),
111
+ data: await readJson(join(dataFolder, `column${PFrameInternal.DataInfoExtension}`)),
112
+ },
113
+ ]);
114
114
 
115
- // UI context
115
+ // UI context
116
116
 
117
- const uiDriver: PFrameDriver = driver;
118
- const pFrameHandle = pFrame.key;
117
+ const uiDriver: PFrameDriver = driver;
118
+ const pFrameHandle = pFrame.key;
119
119
 
120
- const data = await uiDriver.calculateTableData(pFrameHandle, {
121
- src: {
122
- type: 'column',
123
- column: 'column' as PObjectId,
124
- },
125
- filters: [],
126
- sorting: [],
127
- });
128
- const result = {
129
- spec: data.map((d) => d.spec),
130
- data: data.map((d) => d.data)
131
- .map((d) => [...d.data.keys()].map((i) => pTableValue(d, i, {
132
- absent: '|~|',
133
- na: null,
134
- }))),
135
- };
136
- const expected = await readJson(join(dataFolder, 'response.json'));
137
- expect(result).toEqual(expected);
138
- });
120
+ const data = await uiDriver.calculateTableData(pFrameHandle, {
121
+ src: {
122
+ type: "column",
123
+ column: "column" as PObjectId,
124
+ },
125
+ filters: [],
126
+ sorting: [],
127
+ });
128
+ const result = {
129
+ spec: data.map((d) => d.spec),
130
+ data: data
131
+ .map((d) => d.data)
132
+ .map((d) =>
133
+ [...d.data.keys()].map((i) =>
134
+ pTableValue(d, i, {
135
+ absent: "|~|",
136
+ na: null,
137
+ }),
138
+ ),
139
+ ),
140
+ };
141
+ const expected = await readJson(join(dataFolder, "response.json"));
142
+ expect(result).toEqual(expected);
143
+ },
144
+ );
@@ -4,24 +4,24 @@ import {
4
4
  type Branded,
5
5
  type PColumnSpec,
6
6
  type PColumnValues,
7
- } from '@platforma-sdk/model';
8
- import { PFrameInternal } from '@milaboratories/pl-model-middle-layer';
9
- import { RefCountPoolBase, type PoolEntry } from '@milaboratories/ts-helpers';
10
- import { HttpHelpers } from '@milaboratories/pframes-rs-node';
11
- import fs from 'node:fs';
12
- import path from 'node:path';
13
- import { tmpdir } from 'node:os';
14
- import type { AbstractInternalPFrameDriver } from './driver_decl';
7
+ } from "@platforma-sdk/model";
8
+ import { PFrameInternal } from "@milaboratories/pl-model-middle-layer";
9
+ import { RefCountPoolBase, type PoolEntry } from "@milaboratories/ts-helpers";
10
+ import { HttpHelpers } from "@milaboratories/pframes-rs-node";
11
+ import fs from "node:fs";
12
+ import path from "node:path";
13
+ import { tmpdir } from "node:os";
14
+ import type { AbstractInternalPFrameDriver } from "./driver_decl";
15
15
  import {
16
16
  AbstractPFrameDriver,
17
17
  type LocalBlobProvider,
18
18
  type RemoteBlobProvider,
19
- } from './driver_impl';
20
- import { makeJsonDataInfo } from './data_info_helpers';
19
+ } from "./driver_impl";
20
+ import { makeJsonDataInfo } from "./data_info_helpers";
21
21
 
22
- export type FileName = Branded<string, 'FileName'>;
23
- export type FilePath = Branded<string, 'FilePath'>;
24
- export type FolderPath = Branded<string, 'FolderPath'>;
22
+ export type FileName = Branded<string, "FileName">;
23
+ export type FilePath = Branded<string, "FilePath">;
24
+ export type FolderPath = Branded<string, "FolderPath">;
25
25
 
26
26
  export function makeFolderPath(dataFolder: string): FolderPath {
27
27
  if (!fs.statSync(dataFolder, { throwIfNoEntry: false })?.isDirectory()) {
@@ -38,7 +38,8 @@ function makeBlobId(res: FileName): PFrameInternal.PFrameBlobId {
38
38
 
39
39
  class LocalBlobProviderImpl
40
40
  extends RefCountPoolBase<FileName, PFrameInternal.PFrameBlobId, FilePath>
41
- implements LocalBlobProvider<FileName> {
41
+ implements LocalBlobProvider<FileName>
42
+ {
42
43
  constructor(private readonly dataFolder: FolderPath) {
43
44
  super();
44
45
  }
@@ -67,7 +68,9 @@ class LocalBlobProviderImpl
67
68
  return resource;
68
69
  }
69
70
 
70
- public makeDataSource(signal: AbortSignal): Omit<PFrameInternal.PFrameDataSourceV2, 'parquetServer'> {
71
+ public makeDataSource(
72
+ signal: AbortSignal,
73
+ ): Omit<PFrameInternal.PFrameDataSourceV2, "parquetServer"> {
71
74
  return {
72
75
  preloadBlob: async (_blobIds: PFrameInternal.PFrameBlobId[]) => {},
73
76
  resolveBlobContent: async (blobId: PFrameInternal.PFrameBlobId) => {
@@ -87,7 +90,7 @@ class RemoteBlobProviderImpl implements RemoteBlobProvider<FileName> {
87
90
  public static async init(
88
91
  dataFolder: FolderPath,
89
92
  logger: PFrameInternal.Logger,
90
- serverOptions: Omit<PFrameInternal.HttpServerOptions, 'handler'>,
93
+ serverOptions: Omit<PFrameInternal.HttpServerOptions, "handler">,
91
94
  ): Promise<RemoteBlobProviderImpl> {
92
95
  const pool = new LocalBlobProviderImpl(dataFolder);
93
96
 
@@ -118,8 +121,9 @@ class RemoteBlobProviderImpl implements RemoteBlobProvider<FileName> {
118
121
  }
119
122
  }
120
123
 
121
- export type InternalPFrameDriverDouble =
122
- AbstractInternalPFrameDriver<PFrameInternal.DataInfo<FileName> | PColumnValues>;
124
+ export type InternalPFrameDriverDouble = AbstractInternalPFrameDriver<
125
+ PFrameInternal.DataInfo<FileName> | PColumnValues
126
+ >;
123
127
 
124
128
  export async function createPFrameDriverDouble({
125
129
  dataFolder = tmpdir() as FolderPath,
@@ -134,7 +138,7 @@ export async function createPFrameDriverDouble({
134
138
  const resolveDataInfo = (
135
139
  spec: PColumnSpec,
136
140
  data: PFrameInternal.DataInfo<FileName> | PColumnValues,
137
- ) => isDataInfo(data) ? data : makeJsonDataInfo(spec, data);
141
+ ) => (isDataInfo(data) ? data : makeJsonDataInfo(spec, data));
138
142
 
139
143
  return new AbstractPFrameDriver({
140
144
  logger,