@milaboratories/pl-model-middle-layer 1.8.37 → 1.8.39
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/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/json.cjs +24 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.ts +9 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +20 -0
- package/dist/json.js.map +1 -0
- package/dist/pframe/internal_api/api_factory.cjs +10 -0
- package/dist/pframe/internal_api/api_factory.cjs.map +1 -0
- package/dist/pframe/internal_api/api_factory.d.ts +6 -2
- package/dist/pframe/internal_api/api_factory.d.ts.map +1 -1
- package/dist/pframe/internal_api/api_factory.js +7 -0
- package/dist/pframe/internal_api/api_factory.js.map +1 -0
- package/dist/pframe/internal_api/index.cjs +3 -0
- package/dist/pframe/internal_api/index.cjs.map +1 -1
- package/dist/pframe/internal_api/index.js +1 -0
- package/dist/pframe/internal_api/index.js.map +1 -1
- package/package.json +4 -3
- package/src/index.ts +1 -0
- package/src/json.ts +31 -0
- package/src/pframe/internal_api/api_factory.ts +8 -2
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,7 @@ var block_pack_spec = require('./block_registry/block_pack_spec.cjs');
|
|
|
13
13
|
var overview = require('./block_registry/overview.cjs');
|
|
14
14
|
var registry_spec = require('./block_registry/registry_spec.cjs');
|
|
15
15
|
var index = require('./pframe/internal_api/index.cjs');
|
|
16
|
+
var json = require('./json.cjs');
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -93,4 +94,7 @@ exports.RegistrySpec = registry_spec.RegistrySpec;
|
|
|
93
94
|
exports.RemoteRegistryV1Spec = registry_spec.RemoteRegistryV1Spec;
|
|
94
95
|
exports.RemoteRegistryV2Spec = registry_spec.RemoteRegistryV2Spec;
|
|
95
96
|
exports.PFrameInternal = index;
|
|
97
|
+
exports.hashJson = json.hashJson;
|
|
98
|
+
exports.readJson = json.readJson;
|
|
99
|
+
exports.readJsonSync = json.readJsonSync;
|
|
96
100
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAE9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12,4 +12,5 @@ export { AnyChannel, BlockPackListing, BlockPackOverview, BlockPackOverviewLegac
|
|
|
12
12
|
export { LocalDevFolder, RegistryEntry, RegistryList, RegistrySpec, RemoteRegistryV1Spec, RemoteRegistryV2Spec } from './block_registry/registry_spec.js';
|
|
13
13
|
import * as index from './pframe/internal_api/index.js';
|
|
14
14
|
export { index as PFrameInternal };
|
|
15
|
+
export { hashJson, readJson, readJsonSync } from './json.js';
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;"}
|
package/dist/json.cjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var plModelCommon = require('@milaboratories/pl-model-common');
|
|
4
|
+
var node_crypto = require('node:crypto');
|
|
5
|
+
var fs = require('node:fs');
|
|
6
|
+
|
|
7
|
+
function hashJson(value) {
|
|
8
|
+
const hash = node_crypto.createHash('sha256');
|
|
9
|
+
hash.update(plModelCommon.canonicalizeJson(value));
|
|
10
|
+
return hash.digest().toString('hex');
|
|
11
|
+
}
|
|
12
|
+
async function readJson(filePath, signal) {
|
|
13
|
+
const content = await fs.promises.readFile(filePath, { encoding: 'utf8', signal });
|
|
14
|
+
return plModelCommon.parseJson(content);
|
|
15
|
+
}
|
|
16
|
+
function readJsonSync(filePath) {
|
|
17
|
+
const content = fs.readFileSync(filePath, { encoding: 'utf8' });
|
|
18
|
+
return plModelCommon.parseJson(content);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.hashJson = hashJson;
|
|
22
|
+
exports.readJson = readJson;
|
|
23
|
+
exports.readJsonSync = readJsonSync;
|
|
24
|
+
//# sourceMappingURL=json.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.cjs","sources":["../src/json.ts"],"sourcesContent":["import {\n canonicalizeJson,\n parseJson,\n type JsonCompatible,\n type JsonSerializable,\n type StringifiedJson,\n} from '@milaboratories/pl-model-common';\nimport { createHash } from 'node:crypto';\nimport fs from 'node:fs';\n\nexport type HashedJson<T = unknown> = JsonCompatible<T> extends never ? never : string & {\n __json_hashed: T;\n};\n\nexport function hashJson<T>(value: JsonCompatible<T>): HashedJson<T>;\nexport function hashJson<T extends JsonSerializable>(value: T): string;\nexport function hashJson(value: unknown): string {\n const hash = createHash('sha256');\n hash.update(canonicalizeJson(value));\n return hash.digest().toString('hex');\n}\n\nexport async function readJson<T extends JsonSerializable>(filePath: string, signal?: AbortSignal): Promise<T> {\n const content = await fs.promises.readFile(filePath, { encoding: 'utf8', signal });\n return parseJson(content as StringifiedJson<T>);\n}\n\nexport function readJsonSync<T extends JsonSerializable>(filePath: string): T {\n const content = fs.readFileSync(filePath, { encoding: 'utf8' });\n return parseJson(content as StringifiedJson<T>);\n}\n"],"names":["createHash","canonicalizeJson","parseJson"],"mappings":";;;;;;AAgBM,SAAU,QAAQ,CAAC,KAAc,EAAA;AACrC,IAAA,MAAM,IAAI,GAAGA,sBAAU,CAAC,QAAQ,CAAC;IACjC,IAAI,CAAC,MAAM,CAACC,8BAAgB,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;AACtC;AAEO,eAAe,QAAQ,CAA6B,QAAgB,EAAE,MAAoB,EAAA;AAC/F,IAAA,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAClF,IAAA,OAAOC,uBAAS,CAAC,OAA6B,CAAC;AACjD;AAEM,SAAU,YAAY,CAA6B,QAAgB,EAAA;AACvE,IAAA,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC/D,IAAA,OAAOA,uBAAS,CAAC,OAA6B,CAAC;AACjD;;;;;;"}
|
package/dist/json.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type JsonCompatible, type JsonSerializable } from '@milaboratories/pl-model-common';
|
|
2
|
+
export type HashedJson<T = unknown> = JsonCompatible<T> extends never ? never : string & {
|
|
3
|
+
__json_hashed: T;
|
|
4
|
+
};
|
|
5
|
+
export declare function hashJson<T>(value: JsonCompatible<T>): HashedJson<T>;
|
|
6
|
+
export declare function hashJson<T extends JsonSerializable>(value: T): string;
|
|
7
|
+
export declare function readJson<T extends JsonSerializable>(filePath: string, signal?: AbortSignal): Promise<T>;
|
|
8
|
+
export declare function readJsonSync<T extends JsonSerializable>(filePath: string): T;
|
|
9
|
+
//# sourceMappingURL=json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../src/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAEtB,MAAM,iCAAiC,CAAC;AAIzC,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI,cAAc,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG;IACvF,aAAa,EAAE,CAAC,CAAC;CAClB,CAAC;AAEF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AACrE,wBAAgB,QAAQ,CAAC,CAAC,SAAS,gBAAgB,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC;AAOvE,wBAAsB,QAAQ,CAAC,CAAC,SAAS,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAG7G;AAED,wBAAgB,YAAY,CAAC,CAAC,SAAS,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAG5E"}
|
package/dist/json.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { canonicalizeJson, parseJson } from '@milaboratories/pl-model-common';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
|
|
5
|
+
function hashJson(value) {
|
|
6
|
+
const hash = createHash('sha256');
|
|
7
|
+
hash.update(canonicalizeJson(value));
|
|
8
|
+
return hash.digest().toString('hex');
|
|
9
|
+
}
|
|
10
|
+
async function readJson(filePath, signal) {
|
|
11
|
+
const content = await fs.promises.readFile(filePath, { encoding: 'utf8', signal });
|
|
12
|
+
return parseJson(content);
|
|
13
|
+
}
|
|
14
|
+
function readJsonSync(filePath) {
|
|
15
|
+
const content = fs.readFileSync(filePath, { encoding: 'utf8' });
|
|
16
|
+
return parseJson(content);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { hashJson, readJson, readJsonSync };
|
|
20
|
+
//# sourceMappingURL=json.js.map
|
package/dist/json.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.js","sources":["../src/json.ts"],"sourcesContent":["import {\n canonicalizeJson,\n parseJson,\n type JsonCompatible,\n type JsonSerializable,\n type StringifiedJson,\n} from '@milaboratories/pl-model-common';\nimport { createHash } from 'node:crypto';\nimport fs from 'node:fs';\n\nexport type HashedJson<T = unknown> = JsonCompatible<T> extends never ? never : string & {\n __json_hashed: T;\n};\n\nexport function hashJson<T>(value: JsonCompatible<T>): HashedJson<T>;\nexport function hashJson<T extends JsonSerializable>(value: T): string;\nexport function hashJson(value: unknown): string {\n const hash = createHash('sha256');\n hash.update(canonicalizeJson(value));\n return hash.digest().toString('hex');\n}\n\nexport async function readJson<T extends JsonSerializable>(filePath: string, signal?: AbortSignal): Promise<T> {\n const content = await fs.promises.readFile(filePath, { encoding: 'utf8', signal });\n return parseJson(content as StringifiedJson<T>);\n}\n\nexport function readJsonSync<T extends JsonSerializable>(filePath: string): T {\n const content = fs.readFileSync(filePath, { encoding: 'utf8' });\n return parseJson(content as StringifiedJson<T>);\n}\n"],"names":[],"mappings":";;;;AAgBM,SAAU,QAAQ,CAAC,KAAc,EAAA;AACrC,IAAA,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC;IACjC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;AACtC;AAEO,eAAe,QAAQ,CAA6B,QAAgB,EAAE,MAAoB,EAAA;AAC/F,IAAA,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAClF,IAAA,OAAO,SAAS,CAAC,OAA6B,CAAC;AACjD;AAEM,SAAU,YAAY,CAA6B,QAAgB,EAAA;AACvE,IAAA,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;AAC/D,IAAA,OAAO,SAAS,CAAC,OAA6B,CAAC;AACjD;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/** PColumn spec file extension */
|
|
4
|
+
const SpecExtension = '.spec';
|
|
5
|
+
/** PColumn data info file extension */
|
|
6
|
+
const DataInfoExtension = '.datainfo';
|
|
7
|
+
|
|
8
|
+
exports.DataInfoExtension = DataInfoExtension;
|
|
9
|
+
exports.SpecExtension = SpecExtension;
|
|
10
|
+
//# sourceMappingURL=api_factory.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_factory.cjs","sources":["../../../src/pframe/internal_api/api_factory.ts"],"sourcesContent":["import {\n BinaryPartitionedDataInfo,\n Branded,\n JsonDataInfo,\n JsonPartitionedDataInfo,\n ParquetChunk,\n ParquetPartitionedDataInfo,\n PColumnSpec,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n HttpHelpers,\n HttpServerInfo,\n} from './http_helpers';\n\n/** PColumn spec file extension */\nexport const SpecExtension = '.spec' as const;\n\n/** PColumn data info file extension */\nexport const DataInfoExtension = '.datainfo' as const;\n\n/** Abstract identifier of a data blob that can be requested from the storage backend */\nexport type PFrameBlobId = Branded<string, 'PFrameInternal.PFrameBlobId'>;\n\n/** Path of the file containing requested data (blob). This path is returned by\n * {@link BlobPathResolver} as soon as blob materialized in the file system. */\nexport type FilePath = string;\n\n/** Data source allows PFrame to retrieve the data blobs for columns with assigned data info. */\nexport interface PFrameDataSourceV2 {\n /**\n * PFrame may notify storage backend about its plans to use particular blobs in the future.\n * Storage backend will do its best to preload specified blob so the subsequent\n * {@link resolveBlob} will quickly return preloaded file path.\n */\n preloadBlob(blobIds: PFrameBlobId[]): Promise<void>;\n\n /** Returns raw blob data given the blob id from {@link DataInfo}. */\n resolveBlobContent(blobId: PFrameBlobId): Promise<Uint8Array>;\n\n /**\n * Parquet HTTP(S) server connection settings, {@link HttpHelpers.createHttpServer}\n * When not provided, parquet BlobIds would be treated as local file paths.\n */\n parquetServer?: HttpServerInfo;\n}\n\n/**\n * Union type representing all possible data storage formats for PColumn data.\n * The specific format used depends on data size, access patterns, and performance requirements.\n *\n * @template Blob - Type parameter representing the storage reference type (could be ResourceInfo, PFrameBlobId, etc.)\n */\nexport type DataInfo<Blob> =\n | JsonDataInfo\n | JsonPartitionedDataInfo<Blob>\n | BinaryPartitionedDataInfo<Blob>\n | ParquetPartitionedDataInfo<ParquetChunk<Blob>>;\n\n/** API exposed by PFrames library allowing to create and provide data for\n * PFrame objects */\nexport interface PFrameFactoryAPIV4 extends Disposable {\n /** Associates data source with this PFrame */\n setDataSource(dataSource: PFrameDataSourceV2): void;\n\n /** Adds PColumn without data info */\n addColumnSpec(columnId: PObjectId, columnSpec: PColumnSpec): void;\n\n /**\n * Assign data info to the specified PColumn.\n * For parquet data info, schema resolution via network is performed during this call.\n */\n setColumnData(\n columnId: PObjectId,\n dataInfo: DataInfo<PFrameBlobId>,\n options?: {\n signal?: AbortSignal,\n }\n ): Promise<void>;\n\n /** Releases all the data previously added to PFrame using methods above,\n * any interactions with disposed PFrame will result in exception */\n dispose(): void;\n}\n"],"names":[],"mappings":";;AAeA;AACO,MAAM,aAAa,GAAG;AAE7B;AACO,MAAM,iBAAiB,GAAG;;;;;"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import { BinaryPartitionedDataInfo, JsonDataInfo, JsonPartitionedDataInfo, ParquetChunk, ParquetPartitionedDataInfo, PColumnSpec, PObjectId } from '@milaboratories/pl-model-common';
|
|
1
|
+
import { BinaryPartitionedDataInfo, Branded, JsonDataInfo, JsonPartitionedDataInfo, ParquetChunk, ParquetPartitionedDataInfo, PColumnSpec, PObjectId } from '@milaboratories/pl-model-common';
|
|
2
2
|
import { HttpServerInfo } from './http_helpers';
|
|
3
|
+
/** PColumn spec file extension */
|
|
4
|
+
export declare const SpecExtension: ".spec";
|
|
5
|
+
/** PColumn data info file extension */
|
|
6
|
+
export declare const DataInfoExtension: ".datainfo";
|
|
3
7
|
/** Abstract identifier of a data blob that can be requested from the storage backend */
|
|
4
|
-
export type PFrameBlobId = string
|
|
8
|
+
export type PFrameBlobId = Branded<string, 'PFrameInternal.PFrameBlobId'>;
|
|
5
9
|
/** Path of the file containing requested data (blob). This path is returned by
|
|
6
10
|
* {@link BlobPathResolver} as soon as blob materialized in the file system. */
|
|
7
11
|
export type FilePath = string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api_factory.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/api_factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,0BAA0B,EAC1B,WAAW,EACX,SAAS,EACV,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,wFAAwF;AACxF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"api_factory.d.ts","sourceRoot":"","sources":["../../../src/pframe/internal_api/api_factory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,OAAO,EACP,YAAY,EACZ,uBAAuB,EACvB,YAAY,EACZ,0BAA0B,EAC1B,WAAW,EACX,SAAS,EACV,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEL,cAAc,EACf,MAAM,gBAAgB,CAAC;AAExB,kCAAkC;AAClC,eAAO,MAAM,aAAa,SAAmB,CAAC;AAE9C,uCAAuC;AACvC,eAAO,MAAM,iBAAiB,aAAuB,CAAC;AAEtD,wFAAwF;AACxF,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;AAE1E;+EAC+E;AAC/E,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,gGAAgG;AAChG,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpD,qEAAqE;IACrE,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9D;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,CAAC,IAAI,IACrB,YAAY,GACZ,uBAAuB,CAAC,IAAI,CAAC,GAC7B,yBAAyB,CAAC,IAAI,CAAC,GAC/B,0BAA0B,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAEnD;oBACoB;AACpB,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,8CAA8C;IAC9C,aAAa,CAAC,UAAU,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAEpD,qCAAqC;IACrC,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAElE;;;OAGG;IACH,aAAa,CACX,QAAQ,EAAE,SAAS,EACnB,QAAQ,EAAE,QAAQ,CAAC,YAAY,CAAC,EAChC,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,WAAW,CAAC;KACtB,GACA,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;wEACoE;IACpE,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api_factory.js","sources":["../../../src/pframe/internal_api/api_factory.ts"],"sourcesContent":["import {\n BinaryPartitionedDataInfo,\n Branded,\n JsonDataInfo,\n JsonPartitionedDataInfo,\n ParquetChunk,\n ParquetPartitionedDataInfo,\n PColumnSpec,\n PObjectId,\n} from '@milaboratories/pl-model-common';\nimport {\n HttpHelpers,\n HttpServerInfo,\n} from './http_helpers';\n\n/** PColumn spec file extension */\nexport const SpecExtension = '.spec' as const;\n\n/** PColumn data info file extension */\nexport const DataInfoExtension = '.datainfo' as const;\n\n/** Abstract identifier of a data blob that can be requested from the storage backend */\nexport type PFrameBlobId = Branded<string, 'PFrameInternal.PFrameBlobId'>;\n\n/** Path of the file containing requested data (blob). This path is returned by\n * {@link BlobPathResolver} as soon as blob materialized in the file system. */\nexport type FilePath = string;\n\n/** Data source allows PFrame to retrieve the data blobs for columns with assigned data info. */\nexport interface PFrameDataSourceV2 {\n /**\n * PFrame may notify storage backend about its plans to use particular blobs in the future.\n * Storage backend will do its best to preload specified blob so the subsequent\n * {@link resolveBlob} will quickly return preloaded file path.\n */\n preloadBlob(blobIds: PFrameBlobId[]): Promise<void>;\n\n /** Returns raw blob data given the blob id from {@link DataInfo}. */\n resolveBlobContent(blobId: PFrameBlobId): Promise<Uint8Array>;\n\n /**\n * Parquet HTTP(S) server connection settings, {@link HttpHelpers.createHttpServer}\n * When not provided, parquet BlobIds would be treated as local file paths.\n */\n parquetServer?: HttpServerInfo;\n}\n\n/**\n * Union type representing all possible data storage formats for PColumn data.\n * The specific format used depends on data size, access patterns, and performance requirements.\n *\n * @template Blob - Type parameter representing the storage reference type (could be ResourceInfo, PFrameBlobId, etc.)\n */\nexport type DataInfo<Blob> =\n | JsonDataInfo\n | JsonPartitionedDataInfo<Blob>\n | BinaryPartitionedDataInfo<Blob>\n | ParquetPartitionedDataInfo<ParquetChunk<Blob>>;\n\n/** API exposed by PFrames library allowing to create and provide data for\n * PFrame objects */\nexport interface PFrameFactoryAPIV4 extends Disposable {\n /** Associates data source with this PFrame */\n setDataSource(dataSource: PFrameDataSourceV2): void;\n\n /** Adds PColumn without data info */\n addColumnSpec(columnId: PObjectId, columnSpec: PColumnSpec): void;\n\n /**\n * Assign data info to the specified PColumn.\n * For parquet data info, schema resolution via network is performed during this call.\n */\n setColumnData(\n columnId: PObjectId,\n dataInfo: DataInfo<PFrameBlobId>,\n options?: {\n signal?: AbortSignal,\n }\n ): Promise<void>;\n\n /** Releases all the data previously added to PFrame using methods above,\n * any interactions with disposed PFrame will result in exception */\n dispose(): void;\n}\n"],"names":[],"mappings":"AAeA;AACO,MAAM,aAAa,GAAG;AAE7B;AACO,MAAM,iBAAiB,GAAG;;;;"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var api_factory = require('./api_factory.cjs');
|
|
3
4
|
var http_helpers = require('./http_helpers.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
exports.DataInfoExtension = api_factory.DataInfoExtension;
|
|
9
|
+
exports.SpecExtension = api_factory.SpecExtension;
|
|
7
10
|
exports.BaseObjectStore = http_helpers.BaseObjectStore;
|
|
8
11
|
exports.ParquetExtension = http_helpers.ParquetExtension;
|
|
9
12
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milaboratories/pl-model-middle-layer",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.39",
|
|
4
4
|
"description": "Common model between middle layer and non-block UI code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -24,9 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"typescript": "~5.6.3",
|
|
27
|
+
"@types/node": "~24.5.2",
|
|
28
|
+
"@milaboratories/build-configs": "1.0.8",
|
|
27
29
|
"@milaboratories/ts-builder": "1.0.5",
|
|
28
|
-
"@milaboratories/ts-configs": "1.0.6"
|
|
29
|
-
"@milaboratories/build-configs": "1.0.8"
|
|
30
|
+
"@milaboratories/ts-configs": "1.0.6"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
33
|
"type-check": "ts-builder types --target node",
|
package/src/index.ts
CHANGED
package/src/json.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicalizeJson,
|
|
3
|
+
parseJson,
|
|
4
|
+
type JsonCompatible,
|
|
5
|
+
type JsonSerializable,
|
|
6
|
+
type StringifiedJson,
|
|
7
|
+
} from '@milaboratories/pl-model-common';
|
|
8
|
+
import { createHash } from 'node:crypto';
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
|
|
11
|
+
export type HashedJson<T = unknown> = JsonCompatible<T> extends never ? never : string & {
|
|
12
|
+
__json_hashed: T;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function hashJson<T>(value: JsonCompatible<T>): HashedJson<T>;
|
|
16
|
+
export function hashJson<T extends JsonSerializable>(value: T): string;
|
|
17
|
+
export function hashJson(value: unknown): string {
|
|
18
|
+
const hash = createHash('sha256');
|
|
19
|
+
hash.update(canonicalizeJson(value));
|
|
20
|
+
return hash.digest().toString('hex');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function readJson<T extends JsonSerializable>(filePath: string, signal?: AbortSignal): Promise<T> {
|
|
24
|
+
const content = await fs.promises.readFile(filePath, { encoding: 'utf8', signal });
|
|
25
|
+
return parseJson(content as StringifiedJson<T>);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function readJsonSync<T extends JsonSerializable>(filePath: string): T {
|
|
29
|
+
const content = fs.readFileSync(filePath, { encoding: 'utf8' });
|
|
30
|
+
return parseJson(content as StringifiedJson<T>);
|
|
31
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BinaryPartitionedDataInfo,
|
|
3
|
+
Branded,
|
|
3
4
|
JsonDataInfo,
|
|
4
5
|
JsonPartitionedDataInfo,
|
|
5
6
|
ParquetChunk,
|
|
@@ -12,9 +13,14 @@ import {
|
|
|
12
13
|
HttpServerInfo,
|
|
13
14
|
} from './http_helpers';
|
|
14
15
|
|
|
15
|
-
/**
|
|
16
|
-
export
|
|
16
|
+
/** PColumn spec file extension */
|
|
17
|
+
export const SpecExtension = '.spec' as const;
|
|
18
|
+
|
|
19
|
+
/** PColumn data info file extension */
|
|
20
|
+
export const DataInfoExtension = '.datainfo' as const;
|
|
17
21
|
|
|
22
|
+
/** Abstract identifier of a data blob that can be requested from the storage backend */
|
|
23
|
+
export type PFrameBlobId = Branded<string, 'PFrameInternal.PFrameBlobId'>;
|
|
18
24
|
|
|
19
25
|
/** Path of the file containing requested data (blob). This path is returned by
|
|
20
26
|
* {@link BlobPathResolver} as soon as blob materialized in the file system. */
|