@modernrelay/orbit-data 0.17.0 → 0.19.0
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/arrow.d.ts +5 -3
- package/dist/arrow.js +20 -6
- package/dist/arrow.js.map +1 -1
- package/dist/chunk-VRRKGDQJ.js +32 -0
- package/dist/chunk-VRRKGDQJ.js.map +1 -0
- package/dist/parquet.d.ts +3 -2
- package/dist/parquet.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-JWGHZW7P.js +0 -24
- package/dist/chunk-JWGHZW7P.js.map +0 -1
package/dist/arrow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphByteSource, GraphColumnMapping, GraphPrepareOptions, PreparedGraph } from './index.js';
|
|
2
2
|
import '@modernrelay/orbit-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -16,7 +16,8 @@ import '@modernrelay/orbit-core';
|
|
|
16
16
|
* through `getChild` vectors and feed the shared builder; columns come from
|
|
17
17
|
* the SCHEMA (exact, not sampled). Value normalization for the object lane:
|
|
18
18
|
* arrow nulls → absent keys, bigints → number when safely representable else
|
|
19
|
-
* decimal string
|
|
19
|
+
* decimal string, and LIST/STRUCT values recursively become plain JSON
|
|
20
|
+
* containers. Other values pass through.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
/** Structural subset of an apache-arrow Table (any supported major). */
|
|
@@ -45,4 +46,5 @@ declare const _internals: {
|
|
|
45
46
|
};
|
|
46
47
|
declare function prepareArrowGraphData<N = Record<string, unknown>, E = Record<string, unknown>>(input: ArrowGraphPrepareInput, mapping: GraphColumnMapping, options: Omit<GraphPrepareOptions, 'format'>): Promise<PreparedGraph<N, E>>;
|
|
47
48
|
|
|
48
|
-
export {
|
|
49
|
+
export { _internals, prepareArrowGraphData };
|
|
50
|
+
export type { ArrowGraphPrepareInput, ArrowGraphSource, ArrowTableLike };
|
package/dist/arrow.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { normalizeJsonSafeValue } from './chunk-
|
|
2
|
-
import { buildPrepared, collectBytes, EMPTY_ROW_TABLE } from './chunk-XXC2CUXZ.js';
|
|
1
|
+
import { normalizeJsonSafeValue } from './chunk-VRRKGDQJ.js';
|
|
2
|
+
import { throwIfAborted, buildPrepared, collectBytes, EMPTY_ROW_TABLE } from './chunk-XXC2CUXZ.js';
|
|
3
3
|
|
|
4
4
|
// src/arrow.ts
|
|
5
5
|
var _internals = {
|
|
@@ -21,11 +21,21 @@ async function loadArrowModule() {
|
|
|
21
21
|
"@modernrelay/orbit-data/arrow: the installed 'apache-arrow' does not expose tableFromIPC (unsupported version?)"
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const { Vector, StructRow } = mod;
|
|
25
|
+
return {
|
|
26
|
+
tableFromIPC,
|
|
27
|
+
materialize(value) {
|
|
28
|
+
if (value instanceof Vector) return Array.from(value);
|
|
29
|
+
if (value instanceof StructRow) return Object.fromEntries(value);
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
25
33
|
}
|
|
26
34
|
async function prepareArrowGraphData(input, mapping, options) {
|
|
27
|
-
const arrow = await loadArrowModule();
|
|
28
35
|
const signal = options.signal;
|
|
36
|
+
throwIfAborted(signal);
|
|
37
|
+
const arrow = await loadArrowModule();
|
|
38
|
+
throwIfAborted(signal);
|
|
29
39
|
const deriveNodes = "deriveNodes" in input && input.deriveNodes === true;
|
|
30
40
|
const edgeTable = await arrowRowTable(input.edges, arrow, signal);
|
|
31
41
|
const nodeTable = deriveNodes ? null : await arrowRowTable(input.nodes, arrow, signal);
|
|
@@ -41,7 +51,9 @@ function isArrowTable(source) {
|
|
|
41
51
|
return typeof source === "object" && source !== null && "schema" in source && typeof source.getChild === "function" && Array.isArray(source.schema?.fields);
|
|
42
52
|
}
|
|
43
53
|
async function arrowRowTable(source, arrow, signal) {
|
|
54
|
+
throwIfAborted(signal);
|
|
44
55
|
const table = isArrowTable(source) ? source : arrow.tableFromIPC(await collectBytes(source, signal));
|
|
56
|
+
throwIfAborted(signal);
|
|
45
57
|
const columns = table.schema.fields.map((f) => f.name);
|
|
46
58
|
if (columns.length === 0 && table.numRows === 0) return EMPTY_ROW_TABLE;
|
|
47
59
|
const vectors = columns.map((name) => table.getChild(name));
|
|
@@ -49,23 +61,25 @@ async function arrowRowTable(source, arrow, signal) {
|
|
|
49
61
|
columns,
|
|
50
62
|
rows: (async function* () {
|
|
51
63
|
for (let i = 0; i < table.numRows; i++) {
|
|
64
|
+
throwIfAborted(signal);
|
|
52
65
|
const row = {};
|
|
53
66
|
for (let j = 0; j < columns.length; j++) {
|
|
54
67
|
const value = vectors[j]?.get(i);
|
|
55
68
|
if (value === null || value === void 0) continue;
|
|
56
69
|
Object.defineProperty(row, columns[j], {
|
|
57
|
-
value:
|
|
70
|
+
value: normalizeJsonSafeValue(value, arrow.materialize),
|
|
58
71
|
enumerable: true,
|
|
59
72
|
writable: true,
|
|
60
73
|
configurable: true
|
|
61
74
|
});
|
|
62
75
|
}
|
|
76
|
+
throwIfAborted(signal);
|
|
63
77
|
yield row;
|
|
64
78
|
}
|
|
79
|
+
throwIfAborted(signal);
|
|
65
80
|
})()
|
|
66
81
|
};
|
|
67
82
|
}
|
|
68
|
-
var normalizeArrowValue = normalizeJsonSafeValue;
|
|
69
83
|
|
|
70
84
|
export { _internals, prepareArrowGraphData };
|
|
71
85
|
//# sourceMappingURL=arrow.js.map
|
package/dist/arrow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/arrow.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../src/arrow.ts"],"names":[],"mappings":";;;;AA6CO,IAAM,UAAA,GAAa;AAAA,EACxB,WAAA,EAAa,MAAwB,OAAO,cAAc;AAC5D;AAOA,eAAe,eAAA,GAAwC;AACrD,EAAA,IAAI,GAAA;AACJ,EAAA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A,CAAQ,QAAQ,CAAA,EAAA,EAAK;AACvC,UAAA,MAAM,KAAA,GAAQ,OAAA,CAAQ,CAAC,CAAA,EAAG,IAAI,CAAC,CAAA;AAC/B,UAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAG3C,UAAA,MAAA,CAAO,cAAA,CAAe,GAAA,EAAK,OAAA,CAAQ,CAAC,CAAA,EAAI;AAAA,YACtC,KAAA,EAAO,sBAAA,CAAuB,KAAA,EAAO,KAAA,CAAM,WAAW,CAAA;AAAA,YACtD,UAAA,EAAY,IAAA;AAAA,YACZ,QAAA,EAAU,IAAA;AAAA,YACV,YAAA,EAAc;AAAA,WACf,CAAA;AAAA,QACH;AACA,QAAA,cAAA,CAAe,MAAM,CAAA;AACrB,QAAA,MAAM,GAAA;AAAA,MACR;AACA,MAAA,cAAA,CAAe,MAAM,CAAA;AAAA,IACvB,CAAA;AAAG,GACL;AACF","file":"arrow.js","sourcesContent":["/**\n * Arrow format entry — `@modernrelay/orbit-data/arrow`.\n *\n * NEVER imported by the root entry: the\n * 'apache-arrow' optional peer is loaded with a DYNAMIC import inside the\n * call, so this module is import-safe without it (the clear install-hint\n * error fires only when preparation actually runs), and root-entry bundles\n * carry no arrow code.\n *\n * Sources per role are Arrow IPC bytes (file or stream framing\n * Blob/ArrayBuffer/AsyncIterable<Uint8Array>) or an already-constructed\n * arrow Table (duck-typed via `schema.fields`). Tables become row objects\n * through `getChild` vectors and feed the shared builder; columns come from\n * the SCHEMA (exact, not sampled). Value normalization for the object lane:\n * arrow nulls → absent keys, bigints → number when safely representable else\n * decimal string, and LIST/STRUCT values recursively become plain JSON\n * containers. Other values pass through.\n */\n\nimport { normalizeJsonSafeValue } from './jsonSafe';\n\nimport { buildPrepared } from './builder';\nimport { EMPTY_ROW_TABLE, type RowTable } from './rowTable';\nimport { collectBytes, throwIfAborted } from './sources';\nimport type {\n GraphByteSource,\n GraphColumnMapping,\n GraphPrepareOptions,\n PreparedGraph,\n} from './types';\n\n/** Structural subset of an apache-arrow Table (any supported major). */\nexport interface ArrowTableLike {\n readonly numRows: number;\n readonly schema: { readonly fields: ReadonlyArray<{ readonly name: string }> };\n getChild(name: string): { get(index: number): unknown } | null;\n}\n\nexport type ArrowGraphSource = GraphByteSource | ArrowTableLike;\n\nexport type ArrowGraphPrepareInput =\n | { nodes: ArrowGraphSource; edges: ArrowGraphSource }\n | { edges: ArrowGraphSource; deriveNodes: true };\n\n/** Test seam: lets suites simulate the missing-optional-dependency path. */\nexport const _internals = {\n importArrow: (): Promise<unknown> => import('apache-arrow'),\n};\n\ninterface ArrowModule {\n tableFromIPC(bytes: Uint8Array): ArrowTableLike;\n materialize(value: object): unknown;\n}\n\nasync function loadArrowModule(): Promise<ArrowModule> {\n let mod: unknown;\n try {\n mod = await _internals.importArrow();\n } catch (cause) {\n throw new Error(\n \"@modernrelay/orbit-data/arrow requires the optional peer dependency 'apache-arrow'. \" +\n 'Install it (e.g. `pnpm add apache-arrow`) to use prepareArrowGraphData.',\n { cause },\n );\n }\n const tableFromIPC = (mod as Record<string, unknown>)['tableFromIPC'];\n if (typeof tableFromIPC !== 'function') {\n throw new Error(\n \"@modernrelay/orbit-data/arrow: the installed 'apache-arrow' does not expose tableFromIPC \" +\n '(unsupported version?)',\n );\n }\n const { Vector, StructRow } = mod as typeof import('apache-arrow');\n return {\n tableFromIPC: tableFromIPC as (bytes: Uint8Array) => ArrowTableLike,\n materialize(value) {\n if (value instanceof Vector) return Array.from(value);\n // Iterate entries instead of using toJSON/Object.entries: Arrow's\n // property access and toJSON can shadow or lose fields such as\n // __proto__ and constructor. fromEntries always creates own data.\n if (value instanceof StructRow) return Object.fromEntries(value);\n return value;\n },\n };\n}\n\nexport async function prepareArrowGraphData<\n N = Record<string, unknown>,\n E = Record<string, unknown>,\n>(\n input: ArrowGraphPrepareInput,\n mapping: GraphColumnMapping,\n options: Omit<GraphPrepareOptions, 'format'>,\n): Promise<PreparedGraph<N, E>> {\n const signal = options.signal;\n throwIfAborted(signal);\n const arrow = await loadArrowModule();\n throwIfAborted(signal);\n const deriveNodes = 'deriveNodes' in input && input.deriveNodes === true;\n const edgeTable = await arrowRowTable(input.edges, arrow, signal);\n const nodeTable = deriveNodes\n ? null\n : await arrowRowTable((input as { nodes: ArrowGraphSource }).nodes, arrow, signal);\n return (await buildPrepared({\n nodeTable,\n edgeTable,\n mapping,\n format: 'arrow',\n options: { ...options, format: 'arrow' },\n })) as PreparedGraph<N, E>;\n}\n\nfunction isArrowTable(source: ArrowGraphSource): source is ArrowTableLike {\n return (\n typeof source === 'object' &&\n source !== null &&\n 'schema' in source &&\n typeof (source as ArrowTableLike).getChild === 'function' &&\n Array.isArray((source as ArrowTableLike).schema?.fields)\n );\n}\n\nasync function arrowRowTable(\n source: ArrowGraphSource,\n arrow: ArrowModule,\n signal: AbortSignal | undefined,\n): Promise<RowTable> {\n throwIfAborted(signal);\n const table = isArrowTable(source)\n ? source\n : arrow.tableFromIPC(await collectBytes(source as GraphByteSource, signal));\n throwIfAborted(signal);\n const columns = table.schema.fields.map((f) => f.name);\n if (columns.length === 0 && table.numRows === 0) return EMPTY_ROW_TABLE;\n const vectors = columns.map((name) => table.getChild(name));\n return {\n columns,\n rows: (async function* () {\n for (let i = 0; i < table.numRows; i++) {\n throwIfAborted(signal);\n const row: Record<string, unknown> = {};\n for (let j = 0; j < columns.length; j++) {\n const value = vectors[j]?.get(i);\n if (value === null || value === undefined) continue; // arrow null → absent\n // Arrow schemas may legally contain a `__proto__` column. Plain\n // assignment would invoke the legacy prototype setter and lose it.\n Object.defineProperty(row, columns[j]!, {\n value: normalizeJsonSafeValue(value, arrow.materialize),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n throwIfAborted(signal);\n yield row;\n }\n throwIfAborted(signal);\n })(),\n };\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/jsonSafe.ts
|
|
2
|
+
function normalizeJsonSafeValue(value, materialize) {
|
|
3
|
+
if (typeof value === "bigint") {
|
|
4
|
+
return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString();
|
|
5
|
+
}
|
|
6
|
+
if (value === null || typeof value !== "object") return value;
|
|
7
|
+
if (materialize !== void 0) {
|
|
8
|
+
const plain = materialize(value);
|
|
9
|
+
if (plain !== value) return normalizeJsonSafeValue(plain, materialize);
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
return value.map((item) => normalizeJsonSafeValue(item, materialize));
|
|
13
|
+
}
|
|
14
|
+
const prototype = Object.getPrototypeOf(value);
|
|
15
|
+
if (prototype === Object.prototype || prototype === null) {
|
|
16
|
+
const out = {};
|
|
17
|
+
for (const [k, v] of Object.entries(value)) {
|
|
18
|
+
Object.defineProperty(out, k, {
|
|
19
|
+
value: normalizeJsonSafeValue(v, materialize),
|
|
20
|
+
enumerable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
configurable: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { normalizeJsonSafeValue };
|
|
31
|
+
//# sourceMappingURL=chunk-VRRKGDQJ.js.map
|
|
32
|
+
//# sourceMappingURL=chunk-VRRKGDQJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/jsonSafe.ts"],"names":[],"mappings":";AAQO,SAAS,sBAAA,CACd,OACA,WAAA,EACS;AACT,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,gBAAgB,KAAK,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,gBAAgB,CAAA,GACtF,MAAA,CAAO,KAAK,CAAA,GACZ,MAAM,QAAA,EAAS;AAAA,EACrB;AACA,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,UAAU,OAAO,KAAA;AACxD,EAAA,IAAI,gBAAgB,MAAA,EAAW;AAC7B,IAAA,MAAM,KAAA,GAAQ,YAAY,KAAK,CAAA;AAC/B,IAAA,IAAI,KAAA,KAAU,KAAA,EAAO,OAAO,sBAAA,CAAuB,OAAO,WAAW,CAAA;AAAA,EACvE;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,MAAM,GAAA,CAAI,CAAC,SAAS,sBAAA,CAAuB,IAAA,EAAM,WAAW,CAAC,CAAA;AAAA,EACtE;AACA,EAAA,MAAM,SAAA,GAAY,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA;AAC7C,EAAA,IAAI,SAAA,KAAc,MAAA,CAAO,SAAA,IAAa,SAAA,KAAc,IAAA,EAAM;AACxD,IAAA,MAAM,MAA+B,EAAC;AACtC,IAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC1C,MAAA,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA,EAAG;AAAA,QAC5B,KAAA,EAAO,sBAAA,CAAuB,CAAA,EAAG,WAAW,CAAA;AAAA,QAC5C,UAAA,EAAY,IAAA;AAAA,QACZ,QAAA,EAAU,IAAA;AAAA,QACV,YAAA,EAAc;AAAA,OACf,CAAA;AAAA,IACH;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT","file":"chunk-VRRKGDQJ.js","sourcesContent":["/**\n * Shared JSON-safe value normalization for the optional format parsers:\n * Arrow/Parquet scalar decoding surfaces BigInt, and LIST/\n * STRUCT columns surface arrays/objects whose LEAVES can be BigInt — a\n * shallow pass broke the promised JSON-safe `serializePrepared` path.\n * Safe integers become numbers, the rest become strings, containers\n * recurse; '__proto__' keys land as own properties (never the setter).\n */\nexport function normalizeJsonSafeValue(\n value: unknown,\n materialize?: (value: object) => unknown,\n): unknown {\n if (typeof value === 'bigint') {\n return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)\n ? Number(value)\n : value.toString();\n }\n if (value === null || typeof value !== 'object') return value;\n if (materialize !== undefined) {\n const plain = materialize(value);\n if (plain !== value) return normalizeJsonSafeValue(plain, materialize);\n }\n if (Array.isArray(value)) {\n return value.map((item) => normalizeJsonSafeValue(item, materialize));\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype === Object.prototype || prototype === null) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n Object.defineProperty(out, k, {\n value: normalizeJsonSafeValue(v, materialize),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return out;\n }\n return value;\n}\n"]}
|
package/dist/parquet.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GraphByteSource, GraphColumnMapping, GraphPrepareOptions, PreparedGraph } from './index.js';
|
|
2
2
|
import '@modernrelay/orbit-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -31,4 +31,5 @@ declare const _internals: {
|
|
|
31
31
|
};
|
|
32
32
|
declare function prepareParquetGraphData<N = Record<string, unknown>, E = Record<string, unknown>>(input: ParquetGraphPrepareInput, mapping: GraphColumnMapping, options: Omit<GraphPrepareOptions, 'format'>): Promise<PreparedGraph<N, E>>;
|
|
33
33
|
|
|
34
|
-
export {
|
|
34
|
+
export { _internals, prepareParquetGraphData };
|
|
35
|
+
export type { ParquetGraphPrepareInput };
|
package/dist/parquet.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modernrelay/orbit-data",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Data preparation for Orbit: streaming CSV, JSON paths, Arrow and Parquet into typed graph snapshots.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@modernrelay/orbit-core": "0.
|
|
34
|
+
"@modernrelay/orbit-core": "0.19.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"apache-arrow": ">=17.0.0",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"apache-arrow": "^21.2.0",
|
|
50
|
-
"hyparquet": "^1.
|
|
51
|
-
"typescript": "^
|
|
52
|
-
"vitest": "^
|
|
50
|
+
"hyparquet": "^1.31.5",
|
|
51
|
+
"typescript": "^7.0.2",
|
|
52
|
+
"vitest": "^5.0.5"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"build": "tsup",
|
package/dist/chunk-JWGHZW7P.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/jsonSafe.ts
|
|
2
|
-
function normalizeJsonSafeValue(value) {
|
|
3
|
-
if (typeof value === "bigint") {
|
|
4
|
-
return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString();
|
|
5
|
-
}
|
|
6
|
-
if (Array.isArray(value)) return value.map(normalizeJsonSafeValue);
|
|
7
|
-
if (value !== null && typeof value === "object" && value.constructor === Object) {
|
|
8
|
-
const out = {};
|
|
9
|
-
for (const [k, v] of Object.entries(value)) {
|
|
10
|
-
Object.defineProperty(out, k, {
|
|
11
|
-
value: normalizeJsonSafeValue(v),
|
|
12
|
-
enumerable: true,
|
|
13
|
-
writable: true,
|
|
14
|
-
configurable: true
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return out;
|
|
18
|
-
}
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { normalizeJsonSafeValue };
|
|
23
|
-
//# sourceMappingURL=chunk-JWGHZW7P.js.map
|
|
24
|
-
//# sourceMappingURL=chunk-JWGHZW7P.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jsonSafe.ts"],"names":[],"mappings":";AAQO,SAAS,uBAAuB,KAAA,EAAyB;AAC9D,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,OAAO,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,gBAAgB,KAAK,KAAA,IAAS,MAAA,CAAO,MAAA,CAAO,gBAAgB,CAAA,GACtF,MAAA,CAAO,KAAK,CAAA,GACZ,MAAM,QAAA,EAAS;AAAA,EACrB;AACA,EAAA,IAAI,MAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,KAAA,CAAM,IAAI,sBAAsB,CAAA;AACjE,EAAA,IAAI,UAAU,IAAA,IAAQ,OAAO,UAAU,QAAA,IAAY,KAAA,CAAM,gBAAgB,MAAA,EAAQ;AAC/E,IAAA,MAAM,MAA+B,EAAC;AACtC,IAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAC1C,MAAA,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA,EAAG;AAAA,QAC5B,KAAA,EAAO,uBAAuB,CAAC,CAAA;AAAA,QAC/B,UAAA,EAAY,IAAA;AAAA,QACZ,QAAA,EAAU,IAAA;AAAA,QACV,YAAA,EAAc;AAAA,OACf,CAAA;AAAA,IACH;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT","file":"chunk-JWGHZW7P.js","sourcesContent":["/**\n * Shared JSON-safe value normalization for the optional format parsers:\n * Arrow/Parquet scalar decoding surfaces BigInt, and LIST/\n * STRUCT columns surface arrays/objects whose LEAVES can be BigInt — a\n * shallow pass broke the promised JSON-safe `serializePrepared` path.\n * Safe integers become numbers, the rest become strings, containers\n * recurse; '__proto__' keys land as own properties (never the setter).\n */\nexport function normalizeJsonSafeValue(value: unknown): unknown {\n if (typeof value === 'bigint') {\n return value >= BigInt(Number.MIN_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)\n ? Number(value)\n : value.toString();\n }\n if (Array.isArray(value)) return value.map(normalizeJsonSafeValue);\n if (value !== null && typeof value === 'object' && value.constructor === Object) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n Object.defineProperty(out, k, {\n value: normalizeJsonSafeValue(v),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return out;\n }\n return value;\n}\n"]}
|