@modernrelay/orbit-data 0.13.6 → 0.15.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parquet.ts"],"names":[],"mappings":";;;;AAkCO,IAAM,UAAA,GAAa;AAAA,EACxB,eAAA,EAAiB,MAAwB,OAAO,WAAW;AAC7D;AAMA,eAAe,mBAAA,GAA2E;AACxF,EAAA,IAAI,GAAA;AACJ,EAAA,IAAI;AACF,IAAA,GAAA,GAAM,MAAM,WAAW,eAAA,EAAgB;AAAA,EACzC,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,2JAAA;AAAA,MAEA,EAAE,KAAA;AAAM,KACV;AAAA,EACF;AACA,EAAA,MAAM,kBAAA,GAAsB,IAAgC,oBAAoB,CAAA;AAChF,EAAA,IAAI,OAAO,uBAAuB,UAAA,EAAY;AAC5C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AACA,EAAA,OAAO,EAAE,kBAAA,EAA6D;AACxE;AAEA,eAAsB,uBAAA,CAIpB,KAAA,EACA,OAAA,EACA,OAAA,EAC8B;AAC9B,EAAA,MAAM,SAAA,GAAY,MAAM,mBAAA,EAAoB;AAC5C,EAAA,MAAM,SAAS,OAAA,CAAQ,MAAA;AACvB,EAAA,MAAM,WAAA,GAAc,aAAA,IAAiB,KAAA,IAAS,KAAA,CAAM,WAAA,KAAgB,IAAA;AACpE,EAAA,MAAM,YAAY,MAAM,eAAA,CAAgB,KAAA,CAAM,KAAA,EAAO,WAAW,MAAM,CAAA;AACtE,EAAA,MAAM,SAAA,GAAY,cACd,IAAA,GACA,MAAM,gBAAiB,KAAA,CAAqC,KAAA,EAAO,WAAW,MAAM,CAAA;AACxF,EAAA,OAAQ,MAAM,aAAA,CAAc;AAAA,IAC1B,SAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA,MAAA,EAAQ,SAAA;AAAA,IACR,OAAA,EAAS,EAAE,GAAG,OAAA,EAAS,QAAQ,SAAA;AAAU,GAC1C,CAAA;AACH;AAEA,eAAe,eAAA,CACb,MAAA,EACA,SAAA,EACA,MAAA,EACmB;AACnB,EAAA,MAAM,KAAA,GAAQ,MAAM,YAAA,CAAa,MAAA,EAAQ,MAAM,CAAA;AAG/C,EAAA,MAAM,IAAA,GAAO,MAAM,SAAA,CAAU,kBAAA,CAAmB,EAAE,IAAA,EAAM,KAAA,CAAM,QAAuB,CAAA;AACrF,EAAA,MAAM,KAAA,GAAQ,KAAK,CAAC,CAAA;AACpB,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,eAAA;AAChC,EAAA,IAAI,CAAC,gBAAA,CAAiB,KAAK,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,SAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA;AACjC,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,OAAO,mBAAmB;AACxB,MAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,QAAA,MAAM,MAA+B,EAAC;AACtC,QAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,EAAG;AAClC,UAAA,MAAM,KAAA,GAAQ,IAAI,GAAG,CAAA;AACrB,UAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAC3C,UAAA,GAAA,CAAI,GAAG,CAAA,GAAI,qBAAA,CAAsB,KAAK,CAAA;AAAA,QACxC;AACA,QAAA,MAAM,GAAA;AAAA,MACR;AAAA,IACF,CAAA;AAAG,GACL;AACF;AAEA,IAAM,qBAAA,GAAwB,sBAAA","file":"parquet.js","sourcesContent":["/**\n * Parquet format entry (T04) — `@modernrelay/orbit-data/parquet`.\n *\n * NEVER imported by the root entry (spec §5.2/§18 bundle isolation): the\n * 'hyparquet' optional peer (a pure-JS parquet reader) is loaded with a\n * DYNAMIC import inside the call — this module is import-safe without it and\n * the install-hint error fires only when preparation actually runs.\n *\n * Sources per role are parquet file bytes (Blob/ArrayBuffer/\n * AsyncIterable<Uint8Array>); each role is one parquet file. Rows come from\n * hyparquet's `parquetReadObjects` and feed the shared builder. Columns are\n * taken from the first materialized row (hyparquet emits every schema column\n * as a key on each row object, so first-row keys ARE the schema for flat\n * files). Value normalization mirrors arrow.ts: nulls → absent keys, bigints\n * (INT64) → number when safely representable else decimal string.\n */\n\nimport { normalizeJsonSafeValue } from './jsonSafe';\n\nimport { buildPrepared } from './builder';\nimport { EMPTY_ROW_TABLE, isPlainRowObject, type RowTable } from './rowTable';\nimport { collectBytes } from './sources';\nimport type {\n GraphByteSource,\n GraphColumnMapping,\n GraphPrepareOptions,\n PreparedGraph,\n} from './types';\n\nexport type ParquetGraphPrepareInput =\n | { nodes: GraphByteSource; edges: GraphByteSource }\n | { edges: GraphByteSource; deriveNodes: true };\n\n/** Test seam: lets suites simulate the missing-optional-dependency path. */\nexport const _internals = {\n importHyparquet: (): Promise<unknown> => import('hyparquet'),\n};\n\ntype ParquetReadObjects = (options: {\n file: ArrayBuffer;\n}) => Promise<ReadonlyArray<Record<string, unknown>>>;\n\nasync function loadHyparquetModule(): Promise<{ parquetReadObjects: ParquetReadObjects }> {\n let mod: unknown;\n try {\n mod = await _internals.importHyparquet();\n } catch (cause) {\n throw new Error(\n \"@modernrelay/orbit-data/parquet requires the optional peer dependency 'hyparquet'. \" +\n 'Install it (e.g. `pnpm add hyparquet`) to use prepareParquetGraphData.',\n { cause },\n );\n }\n const parquetReadObjects = (mod as Record<string, unknown>)['parquetReadObjects'];\n if (typeof parquetReadObjects !== 'function') {\n throw new Error(\n \"@modernrelay/orbit-data/parquet: the installed 'hyparquet' does not expose \" +\n 'parquetReadObjects (unsupported version?)',\n );\n }\n return { parquetReadObjects: parquetReadObjects as ParquetReadObjects };\n}\n\nexport async function prepareParquetGraphData<\n N = Record<string, unknown>,\n E = Record<string, unknown>,\n>(\n input: ParquetGraphPrepareInput,\n mapping: GraphColumnMapping,\n options: Omit<GraphPrepareOptions, 'format'>,\n): Promise<PreparedGraph<N, E>> {\n const hyparquet = await loadHyparquetModule();\n const signal = options.signal;\n const deriveNodes = 'deriveNodes' in input && input.deriveNodes === true;\n const edgeTable = await parquetRowTable(input.edges, hyparquet, signal);\n const nodeTable = deriveNodes\n ? null\n : await parquetRowTable((input as { nodes: GraphByteSource }).nodes, hyparquet, signal);\n return (await buildPrepared({\n nodeTable,\n edgeTable,\n mapping,\n format: 'parquet',\n options: { ...options, format: 'parquet' },\n })) as PreparedGraph<N, E>;\n}\n\nasync function parquetRowTable(\n source: GraphByteSource,\n hyparquet: { parquetReadObjects: ParquetReadObjects },\n signal: AbortSignal | undefined,\n): Promise<RowTable> {\n const bytes = await collectBytes(source, signal);\n // collectBytes allocates an exact-size buffer, so `bytes.buffer` is the\n // whole file — the AsyncBuffer shape hyparquet expects.\n const rows = await hyparquet.parquetReadObjects({ file: bytes.buffer as ArrayBuffer });\n const first = rows[0];\n if (first === undefined) return EMPTY_ROW_TABLE;\n if (!isPlainRowObject(first)) {\n throw new TypeError(\n '@modernrelay/orbit-data/parquet: hyparquet returned non-object rows (unsupported file?)',\n );\n }\n const columns = Object.keys(first);\n return {\n columns,\n rows: (async function* () {\n for (const raw of rows) {\n const row: Record<string, unknown> = {};\n for (const key of Object.keys(raw)) {\n const value = raw[key];\n if (value === null || value === undefined) continue; // parquet null → absent\n row[key] = normalizeParquetValue(value);\n }\n yield row;\n }\n })(),\n };\n}\n\nconst normalizeParquetValue = normalizeJsonSafeValue;\n"]}
1
+ {"version":3,"sources":["../src/parquet.ts"],"names":[],"mappings":";;;;AAkCO,IAAM,UAAA,GAAa;AAAA,EACxB,eAAA,EAAiB,MAAwB,OAAO,WAAW;AAC7D;AAMA,eAAe,mBAAA,GAA2E;AACxF,EAAA,IAAI,GAAA;A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,IAAA,EAAM,KAAA,CAAM,QAAuB,CAAA;AACrF,EAAA,MAAM,KAAA,GAAQ,KAAK,CAAC,CAAA;AACpB,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,eAAA;AAChC,EAAA,IAAI,CAAC,gBAAA,CAAiB,KAAK,CAAA,EAAG;AAC5B,IAAA,MAAM,IAAI,SAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,MAAM,OAAA,GAAU,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA;AACjC,EAAA,OAAO;AAAA,IACL,OAAA;AAAA,IACA,OAAO,mBAAmB;AACxB,MAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,QAAA,MAAM,MAA+B,EAAC;AACtC,QAAA,KAAA,MAAW,GAAA,IAAO,MAAA,CAAO,IAAA,CAAK,GAAG,CAAA,EAAG;AAClC,UAAA,MAAM,KAAA,GAAQ,IAAI,GAAG,CAAA;AACrB,UAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,EAAW;AAE3C,UAAA,MAAA,CAAO,cAAA,CAAe,KAAK,GAAA,EAAK;AAAA,YAC9B,KAAA,EAAO,sBAAsB,KAAK,CAAA;AAAA,YAClC,UAAA,EAAY,IAAA;AAAA,YACZ,QAAA,EAAU,IAAA;AAAA,YACV,YAAA,EAAc;AAAA,WACf,CAAA;AAAA,QACH;AACA,QAAA,MAAM,GAAA;AAAA,MACR;AAAA,IACF,CAAA;AAAG,GACL;AACF;AAEA,IAAM,qBAAA,GAAwB,sBAAA","file":"parquet.js","sourcesContent":["/**\n * Parquet format entry — `@modernrelay/orbit-data/parquet`.\n *\n * NEVER imported by the root entry: the\n * 'hyparquet' optional peer (a pure-JS parquet reader) is loaded with a\n * DYNAMIC import inside the call — this module is import-safe without it and\n * the install-hint error fires only when preparation actually runs.\n *\n * Sources per role are parquet file bytes (Blob/ArrayBuffer/\n * AsyncIterable<Uint8Array>); each role is one parquet file. Rows come from\n * hyparquet's `parquetReadObjects` and feed the shared builder. Columns are\n * taken from the first materialized row (hyparquet emits every schema column\n * as a key on each row object, so first-row keys ARE the schema for flat\n * files). Value normalization mirrors arrow.ts: nulls → absent keys, bigints\n * (INT64) → number when safely representable else decimal string.\n */\n\nimport { normalizeJsonSafeValue } from './jsonSafe';\n\nimport { buildPrepared } from './builder';\nimport { EMPTY_ROW_TABLE, isPlainRowObject, type RowTable } from './rowTable';\nimport { collectBytes } from './sources';\nimport type {\n GraphByteSource,\n GraphColumnMapping,\n GraphPrepareOptions,\n PreparedGraph,\n} from './types';\n\nexport type ParquetGraphPrepareInput =\n | { nodes: GraphByteSource; edges: GraphByteSource }\n | { edges: GraphByteSource; deriveNodes: true };\n\n/** Test seam: lets suites simulate the missing-optional-dependency path. */\nexport const _internals = {\n importHyparquet: (): Promise<unknown> => import('hyparquet'),\n};\n\ntype ParquetReadObjects = (options: {\n file: ArrayBuffer;\n}) => Promise<ReadonlyArray<Record<string, unknown>>>;\n\nasync function loadHyparquetModule(): Promise<{ parquetReadObjects: ParquetReadObjects }> {\n let mod: unknown;\n try {\n mod = await _internals.importHyparquet();\n } catch (cause) {\n throw new Error(\n \"@modernrelay/orbit-data/parquet requires the optional peer dependency 'hyparquet'. \" +\n 'Install it (e.g. `pnpm add hyparquet`) to use prepareParquetGraphData.',\n { cause },\n );\n }\n const parquetReadObjects = (mod as Record<string, unknown>)['parquetReadObjects'];\n if (typeof parquetReadObjects !== 'function') {\n throw new Error(\n \"@modernrelay/orbit-data/parquet: the installed 'hyparquet' does not expose \" +\n 'parquetReadObjects (unsupported version?)',\n );\n }\n return { parquetReadObjects: parquetReadObjects as ParquetReadObjects };\n}\n\nexport async function prepareParquetGraphData<\n N = Record<string, unknown>,\n E = Record<string, unknown>,\n>(\n input: ParquetGraphPrepareInput,\n mapping: GraphColumnMapping,\n options: Omit<GraphPrepareOptions, 'format'>,\n): Promise<PreparedGraph<N, E>> {\n const hyparquet = await loadHyparquetModule();\n const signal = options.signal;\n const deriveNodes = 'deriveNodes' in input && input.deriveNodes === true;\n const edgeTable = await parquetRowTable(input.edges, hyparquet, signal);\n const nodeTable = deriveNodes\n ? null\n : await parquetRowTable((input as { nodes: GraphByteSource }).nodes, hyparquet, signal);\n return (await buildPrepared({\n nodeTable,\n edgeTable,\n mapping,\n format: 'parquet',\n options: { ...options, format: 'parquet' },\n })) as PreparedGraph<N, E>;\n}\n\nasync function parquetRowTable(\n source: GraphByteSource,\n hyparquet: { parquetReadObjects: ParquetReadObjects },\n signal: AbortSignal | undefined,\n): Promise<RowTable> {\n const bytes = await collectBytes(source, signal);\n // collectBytes allocates an exact-size buffer, so `bytes.buffer` is the\n // whole file — the AsyncBuffer shape hyparquet expects.\n const rows = await hyparquet.parquetReadObjects({ file: bytes.buffer as ArrayBuffer });\n const first = rows[0];\n if (first === undefined) return EMPTY_ROW_TABLE;\n if (!isPlainRowObject(first)) {\n throw new TypeError(\n '@modernrelay/orbit-data/parquet: hyparquet returned non-object rows (unsupported file?)',\n );\n }\n const columns = Object.keys(first);\n return {\n columns,\n rows: (async function* () {\n for (const raw of rows) {\n const row: Record<string, unknown> = {};\n for (const key of Object.keys(raw)) {\n const value = raw[key];\n if (value === null || value === undefined) continue; // parquet null → absent\n // Preserve a literal `__proto__` schema column as own data.\n Object.defineProperty(row, key, {\n value: normalizeParquetValue(value),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n yield row;\n }\n })(),\n };\n}\n\nconst normalizeParquetValue = normalizeJsonSafeValue;\n"]}
@@ -1,15 +1,15 @@
1
1
  import { GraphSnapshot } from '@modernrelay/orbit-core';
2
2
 
3
3
  /**
4
- * @modernrelay/orbit-data public shapes (spec §5.2).
4
+ * @modernrelay/orbit-data public shapes.
5
5
  *
6
6
  * The prepared-data package turns caller-supplied rows/bytes into reusable
7
7
  * artifacts without adding parsers or networking to core. The package consumes
8
- * supplied bytes/streams and NEVER fetches a URL (spec §18: Node-import-safe,
9
- * no ambient browser globals).
8
+ * supplied bytes/streams, never fetches a URL, and remains Node-import-safe
9
+ * without ambient browser globals.
10
10
  *
11
11
  * v0.9 TRIM (documented): core has no `ColumnarGraphSnapshot` yet — the
12
- * columnar lane is S13 — so the prepared artifact wraps an OBJECT
12
+ * columnar lane remains separate, so the prepared artifact wraps an OBJECT
13
13
  * `GraphSnapshot` plus summaries and fingerprints. The serialized artifact
14
14
  * format is versioned (`formatVersion`, see artifact.ts) so the columnar
15
15
  * upgrade slots in without breaking stored artifacts.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modernrelay/orbit-data",
3
- "version": "0.13.6",
3
+ "version": "0.15.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.13.6"
34
+ "@modernrelay/orbit-core": "0.15.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "apache-arrow": ">=17.0.0",
@@ -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-BMWDY6DA.js","sourcesContent":["/**\n * Shared JSON-safe value normalization for the optional format parsers\n * (review P2): 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"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/fingerprint.ts","../src/summaries.ts","../src/validate.ts","../src/builder.ts","../src/rowTable.ts","../src/sources.ts"],"names":[],"mappings":";;;AAmBO,SAAS,cAAc,KAAA,EAAwB;AACpD,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,QAAA,EAAU;AAC/C,IAAA,OAAO,IAAA,CAAK,SAAA,CAAU,KAAK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int (spec §5.2: \"mapping/schema fingerprints\").\n *\n * `mappingFingerprint = fnv1a64Hex(canonicalJson(mapping) + '\\n' + format +\n * '\\n' + canonicalJson(columns))` where `columns` is, per role, the ADMITTED\n * attr-field union (invariant I4, semantic fingerprint completeness): the\n * seeded schema columns (CSV header / Arrow-Parquet schema / first-row keys,\n * minus identity, filtered by `includeFields`) UNIONED with every field any\n * row actually materialized into attrs — collected by builder.ts during the\n * single materialization pass. The lists are sorted here, so field discovery\n * order never moves the fingerprint; canonical JSON sorts object keys\n * recursively so key-order-insensitive equal mappings fingerprint\n * identically.\n */\n\nimport type { GraphColumnMapping, GraphPrepareFormat } from './types';\n\n/** Recursively key-sorted JSON. Only JSON-safe values are expected (mappings\n * and column lists are plain strings/arrays/objects). */\nexport function canonicalJson(value: unknown): string {\n if (value === null || typeof value !== 'object') {\n return JSON.stringify(value) ?? 'null';\n }\n if (Array.isArray(value)) {\n return '[' + value.map((v) => canonicalJson(v)).join(',') + ']';\n }\n const record = value as Record<string, unknown>;\n const keys = Object.keys(record)\n .filter((k) => record[k] !== undefined)\n .sort();\n return (\n '{' + keys.map((k) => JSON.stringify(k) + ':' + canonicalJson(record[k])).join(',') + '}'\n );\n}\n\nconst FNV_OFFSET = 0xcbf29ce484222325n;\nconst FNV_PRIME = 0x100000001b3n;\nconst MASK_64 = 0xffffffffffffffffn;\n\n/** FNV-1a 64-bit over the UTF-8 bytes of `text`, as a 16-char lowercase hex string. */\nexport function fnv1a64Hex(text: string): string {\n const bytes = new TextEncoder().encode(text);\n let hash = FNV_OFFSET;\n for (const byte of bytes) {\n hash ^= BigInt(byte);\n hash = (hash * FNV_PRIME) & MASK_64;\n }\n return hash.toString(16).padStart(16, '0');\n}\n\nexport function computeMappingFingerprint(\n mapping: GraphColumnMapping,\n format: GraphPrepareFormat,\n columns: { nodes: readonly string[]; edges: readonly string[] },\n): string {\n const columnList = {\n nodes: [...columns.nodes].sort(),\n edges: [...columns.edges].sort(),\n };\n return fnv1a64Hex(\n canonicalJson(mapping) + '\\n' + format + '\\n' + canonicalJson(columnList),\n );\n}\n","/**\n * Streaming per-column summaries for prepared artifacts (spec §5.2 /\n * §16.6-shaped `ColumnSummary`, defined locally in types.ts).\n *\n * Accumulation rules (single pass, bounded memory):\n * - `count` — total rows of the owning table; identical across the\n * table's summaries.\n * - `nullCount` — rows with no usable value for the column: key absent,\n * `null`/`undefined`, or a number that fails core's\n * `coerceNumeric` hygiene (NaN/±Infinity → null; the single\n * coercion layer, spec §8 R-19-10).\n * - numeric lane — finite numbers feed min/max (over ALL values) and\n * quantiles [0.25, 0.5, 0.75] from a retained sample:\n * Algorithm-R reservoir capped at RESERVOIR_CAP = 10 000.\n * While the value count is ≤ the cap the sample is the whole\n * column, so quantiles are EXACT (type-7 linear\n * interpolation, the common statistical default); beyond the\n * cap they are reservoir-approximate (and, because Algorithm\n * R draws from Math.random, nondeterministic — acceptable\n * for a profile, documented here).\n * - categorical lane — strings and booleans feed a value→count map capped at\n * CATEGORY_CAP = 10 000 distinct keys: once full, unseen\n * values stop being tracked (existing keys still count) and\n * the summary is marked truncated. `categories` reports the\n * top TOP_CATEGORIES = 20 by count (ties broken by first\n * occurrence); `categoriesTruncated` is set when the map\n * overflowed OR more than 20 distinct values were tracked.\n * - `approximateUnique` — all primitive values (numbers, strings, booleans;\n * type-tagged so `1` and `'1'` stay distinct) in a Set\n * capped at UNIQUE_CAP = 10 000; once capped the reported\n * value is the cap itself (a lower bound).\n * - other types — objects/arrays/dates/bigints/functions/symbols count as\n * present (not null) but contribute to no value statistic;\n * this profile tier only characterizes primitives.\n */\n\nimport { coerceNumeric } from '@modernrelay/orbit-core';\nimport type { ColumnSummary } from './types';\n\nexport const RESERVOIR_CAP = 10_000;\nexport const UNIQUE_CAP = 10_000;\nexport const CATEGORY_CAP = 10_000;\nexport const TOP_CATEGORIES = 20;\nexport const QUANTILE_PROBS = [0.25, 0.5, 0.75] as const;\n\nclass ColumnAccumulator {\n /** Values with a usable value; `nullCount` falls out as rows − present. */\n presentCount = 0;\n\n numericCount = 0;\n min = Infinity;\n max = -Infinity;\n /** Algorithm-R reservoir of numeric values (exact sample while ≤ cap). */\n reservoir: number[] = [];\n numericSeen = 0;\n\n categories = new Map<string, number>();\n categoriesOverflowed = false;\n hasCategorical = false;\n\n uniques = new Set<string>();\n uniquesOverflowed = false;\n\n add(value: unknown): void {\n if (value === null || value === undefined) {\n return; // counts as null via rows − presentCount\n }\n if (typeof value === 'number') {\n const coerced = coerceNumeric(value);\n if (coerced === null) {\n // NaN/±Infinity: hygiene says no usable value (spec §8).\n return;\n }\n this.presentCount++;\n this.numericCount++;\n if (coerced < this.min) this.min = coerced;\n if (coerced > this.max) this.max = coerced;\n this.numericSeen++;\n if (this.reservoir.length < RESERVOIR_CAP) {\n this.reservoir.push(coerced);\n } else {\n const j = Math.floor(Math.random() * this.numericSeen);\n if (j < RESERVOIR_CAP) this.reservoir[j] = coerced;\n }\n this.addUnique('n:' + coerced);\n return;\n }\n if (typeof value === 'string' || typeof value === 'boolean') {\n this.presentCount++;\n this.hasCategorical = true;\n const key = String(value);\n const existing = this.categories.get(key);\n if (existing !== undefined) {\n this.categories.set(key, existing + 1);\n } else if (this.categories.size < CATEGORY_CAP) {\n this.categories.set(key, 1);\n } else {\n this.categoriesOverflowed = true;\n }\n this.addUnique((typeof value === 'string' ? 's:' : 'b:') + key);\n return;\n }\n // Opaque non-primitive: present, but no value statistics.\n this.presentCount++;\n }\n\n private addUnique(key: string): void {\n if (this.uniques.size < UNIQUE_CAP) {\n this.uniques.add(key);\n } else if (!this.uniques.has(key)) {\n this.uniquesOverflowed = true;\n }\n }\n\n finalize(totalRows: number): ColumnSummary {\n const summary: ColumnSummary = {\n count: totalRows,\n nullCount: totalRows - this.presentCount,\n };\n if (this.numericCount > 0) {\n summary.min = this.min;\n summary.max = this.max;\n summary.quantiles = computeQuantiles(this.reservoir);\n }\n if (this.presentCount > 0 && (this.numericCount > 0 || this.hasCategorical)) {\n summary.approximateUnique = this.uniquesOverflowed ? UNIQUE_CAP : this.uniques.size;\n }\n if (this.hasCategorical) {\n // Top-N by count; ties keep first-occurrence (Map iteration) order via\n // a stable sort over insertion-ordered entries.\n const entries = [...this.categories.entries()];\n entries.sort((a, b) => b[1] - a[1]);\n summary.categories = entries\n .slice(0, TOP_CATEGORIES)\n .map(([value, count]) => ({ value, count }));\n if (this.categoriesOverflowed || this.categories.size > TOP_CATEGORIES) {\n summary.categoriesTruncated = true;\n }\n }\n return summary;\n }\n}\n\n/** Type-7 (linear interpolation between closest ranks) quantiles over a sample. */\nexport function computeQuantiles(sample: readonly number[]): readonly number[] {\n const sorted = [...sample].sort((a, b) => a - b);\n const n = sorted.length;\n return QUANTILE_PROBS.map((p) => {\n if (n === 1) return sorted[0]!;\n const idx = (n - 1) * p;\n const lo = Math.floor(idx);\n const hi = Math.ceil(idx);\n const loV = sorted[lo]!;\n const hiV = sorted[hi]!;\n return lo === hi ? loV : loV + (hiV - loV) * (idx - lo);\n });\n}\n\n/**\n * Summarizes one table's attr columns. Columns known up front (CSV header,\n * Arrow/Parquet schema) are seeded so an all-empty column still reports\n * `{count, nullCount: count}`; row-object lanes discover columns as they\n * appear (rows before a column's first appearance count as null via\n * `count - presentCount`).\n */\nexport class TableSummarizer {\n private readonly columns = new Map<string, ColumnAccumulator>();\n private rows = 0;\n\n seed(columnNames: Iterable<string>): void {\n for (const name of columnNames) {\n if (!this.columns.has(name)) this.columns.set(name, new ColumnAccumulator());\n }\n }\n\n addRow(attrs: Readonly<Record<string, unknown>> | undefined): void {\n this.rows++;\n if (attrs === undefined) return;\n for (const key of Object.keys(attrs)) {\n let acc = this.columns.get(key);\n if (acc === undefined) {\n acc = new ColumnAccumulator();\n this.columns.set(key, acc);\n }\n acc.add(attrs[key]);\n }\n }\n\n finalize(): Readonly<Record<string, ColumnSummary>> {\n const out: Record<string, ColumnSummary> = {};\n for (const [name, acc] of this.columns) {\n // Review P2: a column literally named '__proto__' must land as an own\n // property, not invoke the prototype setter.\n Object.defineProperty(out, name, {\n value: acc.finalize(this.rows),\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return out;\n }\n}\n","/**\n * Mapping validation (spec §5.2) — runs BEFORE any row work.\n *\n * `mapping.nodes.id` and `mapping.edges.source`/`target` must exist in the\n * discovered input columns (see rowTable.ts for how each lane discovers\n * them). Failures throw ONE TypeError listing EVERY missing column at once,\n * so a caller fixes the whole mapping in a single round trip.\n *\n * Deliberately lenient by design:\n * - `mapping.edges.id` and `includeFields` entries are NOT required to exist\n * (optional column; absent fields simply never materialize);\n * - an empty source (`columns === null`) is vacuously valid — there is no\n * schema to check and no rows to mis-map.\n */\n\nimport type { GraphColumnMapping } from './types';\n\nexport interface MappingValidationInput {\n mapping: GraphColumnMapping;\n /** Discovered node columns (null = empty source or derived nodes). */\n nodeColumns: readonly string[] | null;\n /** Discovered edge columns (null = empty source). */\n edgeColumns: readonly string[] | null;\n /** True for the `{edges, deriveNodes: true}` input variant. */\n deriveNodes: boolean;\n}\n\nexport function validateMapping(input: MappingValidationInput): void {\n const { mapping, nodeColumns, edgeColumns, deriveNodes } = input;\n const problems: string[] = [];\n\n if (!deriveNodes) {\n if (mapping.nodes === undefined) {\n problems.push('mapping.nodes is required when a node source is supplied');\n } else if (nodeColumns !== null && !nodeColumns.includes(mapping.nodes.id)) {\n problems.push(\n `node id column ${JSON.stringify(mapping.nodes.id)} not found ` +\n `(available: ${formatColumns(nodeColumns)})`,\n );\n }\n }\n\n if (edgeColumns !== null) {\n const missing: string[] = [];\n if (!edgeColumns.includes(mapping.edges.source)) missing.push('source');\n if (!edgeColumns.includes(mapping.edges.target)) missing.push('target');\n for (const role of missing) {\n const column = role === 'source' ? mapping.edges.source : mapping.edges.target;\n problems.push(\n `edge ${role} column ${JSON.stringify(column)} not found ` +\n `(available: ${formatColumns(edgeColumns)})`,\n );\n }\n }\n\n if (problems.length > 0) {\n throw new TypeError(\n `prepareGraphData: mapping validation failed — ${problems.join('; ')}`,\n );\n }\n}\n\nfunction formatColumns(columns: readonly string[]): string {\n if (columns.length === 0) return 'none';\n return columns.map((c) => JSON.stringify(c)).join(', ');\n}\n","/**\n * Shared prepared-graph builder (T02): every lane (rows/CSV/JSON/Arrow/\n * Parquet) funnels normalized RowTables through here.\n *\n * Order of operations (spec §5.2): mapping validation FIRST (before any row\n * work, against the discovered columns), then a single streaming pass per\n * table building snapshot rows and column summaries, then the fingerprint.\n * The fingerprint is FINALIZED only after materialization (invariant I4,\n * semantic fingerprint completeness): it covers the union of ADMITTED attr\n * fields across ALL rows — seeded columns plus every field a row actually\n * materialized — not the header/first-row projection used for validation.\n * Late-appearing fields flow into attrs and summaries, so they must move the\n * fingerprint too, or artifact revalidation skipping (artifact.ts) could\n * serve stale structure.\n *\n * Attr selection: identity columns (node id; edge id/source/target) are\n * consumed for identity and excluded from attrs — unless `includeFields`\n * names them explicitly. When `includeFields` is present it is the exact\n * attr allowlist; otherwise attrs = all non-identity columns. Rows with no\n * attrs omit the `attrs` key entirely (exactOptionalPropertyTypes-friendly).\n *\n * Identity values must be strings, finite numbers, or bigints (stringified);\n * a row with a missing/unusable id/source/target throws a TypeError with the\n * row ordinal — prepared data must be well-keyed, and silent row drops would\n * corrupt summaries.\n */\n\nimport type { GraphEdge, GraphNode, GraphSnapshot } from '@modernrelay/orbit-core';\nimport { computeMappingFingerprint } from './fingerprint';\nimport type { RowTable } from './rowTable';\nimport { TableSummarizer } from './summaries';\nimport type {\n GraphColumnMapping,\n GraphPrepareFormat,\n GraphPrepareOptions,\n PreparedGraph,\n} from './types';\nimport { validateMapping } from './validate';\n\ntype Row = Readonly<Record<string, unknown>>;\ntype Attrs = Record<string, unknown>;\n\nexport interface BuildArgs {\n /** null = `{edges, deriveNodes: true}` — nodes synthesized from endpoints. */\n nodeTable: RowTable | null;\n edgeTable: RowTable;\n mapping: GraphColumnMapping;\n /** Resolved lane label; part of the fingerprint. */\n format: GraphPrepareFormat;\n options: GraphPrepareOptions;\n}\n\nexport async function buildPrepared(args: BuildArgs): Promise<PreparedGraph> {\n const { nodeTable, edgeTable, mapping, format, options } = args;\n validateOptions(options);\n validateMapping({\n mapping,\n nodeColumns: nodeTable === null ? null : nodeTable.columns,\n edgeColumns: edgeTable.columns,\n deriveNodes: nodeTable === null,\n });\n const nodeSummarizer = new TableSummarizer();\n const edgeSummarizer = new TableSummarizer();\n\n // --- edges (first, so deriveNodes sees endpoint order) ------------------\n const edgeIdentity = new Set<string>(\n [mapping.edges.id, mapping.edges.source, mapping.edges.target].filter(\n (c): c is string => c !== undefined,\n ),\n );\n const edgeAttrPick = attrPicker(edgeTable.columns, edgeIdentity, mapping.edges.includeFields);\n if (edgeTable.columns !== null) {\n edgeSummarizer.seed(edgeAttrPick.seedColumns);\n for (const column of edgeAttrPick.seedColumns) edgeAttrPick.admitted.add(column);\n }\n const edges: GraphEdge[] = [];\n const endpointOrder = new Set<string>();\n let edgeOrdinal = 0;\n for await (const row of edgeTable.rows) {\n const source = identityString(row[mapping.edges.source], 'edge source', edgeOrdinal, mapping.edges.source);\n const target = identityString(row[mapping.edges.target], 'edge target', edgeOrdinal, mapping.edges.target);\n const edge: GraphEdge = { source, target };\n if (mapping.edges.id !== undefined) {\n const raw = row[mapping.edges.id];\n if (raw !== undefined && raw !== null) {\n edge.id = identityString(raw, 'edge id', edgeOrdinal, mapping.edges.id);\n }\n }\n const attrs = edgeAttrPick.pick(row);\n if (attrs !== undefined) edge.attrs = attrs;\n edgeSummarizer.addRow(attrs);\n edges.push(edge);\n if (nodeTable === null) {\n endpointOrder.add(source);\n endpointOrder.add(target);\n }\n edgeOrdinal++;\n }\n\n // --- nodes ---------------------------------------------------------------\n const nodes: GraphNode[] = [];\n let nodeAdmitted: ReadonlySet<string> = new Set<string>();\n if (nodeTable === null) {\n // deriveNodes: ids only, first-occurrence order over edge endpoints.\n for (const id of endpointOrder) nodes.push({ id });\n } else {\n const nodeMapping = mapping.nodes!; // validated above\n const nodeIdentity = new Set<string>([nodeMapping.id]);\n const nodeAttrPick = attrPicker(nodeTable.columns, nodeIdentity, nodeMapping.includeFields);\n nodeAdmitted = nodeAttrPick.admitted;\n if (nodeTable.columns !== null) {\n nodeSummarizer.seed(nodeAttrPick.seedColumns);\n for (const column of nodeAttrPick.seedColumns) nodeAttrPick.admitted.add(column);\n }\n let nodeOrdinal = 0;\n for await (const row of nodeTable.rows) {\n const id = identityString(row[nodeMapping.id], 'node id', nodeOrdinal, nodeMapping.id);\n const node: GraphNode = { id };\n const attrs = nodeAttrPick.pick(row);\n if (attrs !== undefined) node.attrs = attrs;\n nodeSummarizer.addRow(attrs);\n nodes.push(node);\n nodeOrdinal++;\n }\n }\n\n // Fingerprint AFTER materialization (I4): the admitted union is only known\n // once every row has streamed through. computeMappingFingerprint sorts the\n // lists, so field DISCOVERY order can never move the fingerprint.\n const mappingFingerprint = computeMappingFingerprint(mapping, format, {\n nodes: [...nodeAdmitted],\n edges: [...edgeAttrPick.admitted],\n });\n\n const snapshot: GraphSnapshot = {\n datasetKey: options.datasetKey,\n sourceRevision: options.sourceRevision,\n nodes,\n edges,\n };\n return {\n snapshot,\n summaries: { nodes: nodeSummarizer.finalize(), edges: edgeSummarizer.finalize() },\n mappingFingerprint,\n };\n}\n\nfunction validateOptions(options: GraphPrepareOptions): void {\n if (typeof options.datasetKey !== 'string' || options.datasetKey === '') {\n throw new TypeError('prepareGraphData: options.datasetKey must be a non-empty string');\n }\n const rev = options.sourceRevision;\n if (typeof rev !== 'string' && typeof rev !== 'number') {\n throw new TypeError('prepareGraphData: options.sourceRevision must be a string or number');\n }\n}\n\nfunction identityString(\n value: unknown,\n role: string,\n ordinal: number,\n column: string,\n): string {\n if (typeof value === 'string') {\n if (value === '') {\n throw new TypeError(\n `prepareGraphData: ${role} in column ${JSON.stringify(column)} is empty at row ${ordinal}`,\n );\n }\n return value;\n }\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'bigint') return String(value);\n throw new TypeError(\n `prepareGraphData: ${role} in column ${JSON.stringify(column)} is missing or unusable ` +\n `at row ${ordinal} (got ${value === null ? 'null' : typeof value})`,\n );\n}\n\ninterface AttrPicker {\n /** Columns to pre-seed summaries with (known-schema lanes). */\n seedColumns: readonly string[];\n /**\n * Union of admitted attr field names (I4 fingerprint input): every key\n * `pick` materialized into attrs, plus — added by the builder alongside\n * summary seeding — the seeded columns. Mirrors the summary key set\n * exactly; identity columns and allowlist-excluded fields never enter.\n */\n admitted: Set<string>;\n /** Row → attrs object, or undefined when the row has no attr values. */\n pick(row: Row): Attrs | undefined;\n}\n\nfunction attrPicker(\n columns: readonly string[] | null,\n identity: ReadonlySet<string>,\n includeFields: readonly string[] | undefined,\n): AttrPicker {\n const admitted = new Set<string>();\n if (includeFields !== undefined) {\n const allow = new Set(includeFields);\n return {\n seedColumns: columns === null ? [...allow] : columns.filter((c) => allow.has(c)),\n admitted,\n pick: (row) => {\n let attrs: Attrs | undefined;\n for (const key of Object.keys(row)) {\n if (!allow.has(key)) continue;\n const value = row[key];\n if (value === undefined) continue;\n admitted.add(key);\n // Review P2: JSON.parse rows carry '__proto__' as an OWN key —\n // plain assignment would invoke the legacy prototype setter\n // (field lost, prototype swapped). defineProperty writes the own\n // property regardless of the key.\n attrs ??= {};\n Object.defineProperty(attrs, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return attrs;\n },\n };\n }\n return {\n seedColumns: columns === null ? [] : columns.filter((c) => !identity.has(c)),\n admitted,\n pick: (row) => {\n let attrs: Attrs | undefined;\n for (const key of Object.keys(row)) {\n if (identity.has(key)) continue;\n const value = row[key];\n if (value === undefined) continue;\n admitted.add(key);\n // Same review-P2 guard as the includeFields branch above.\n attrs ??= {};\n Object.defineProperty(attrs, key, {\n value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n return attrs;\n },\n };\n}\n","/**\n * Internal adapter contract: every input lane (rows, CSV, JSON document,\n * Arrow, Parquet) normalizes to a `RowTable` — the discovered column list\n * (available BEFORE any row work, so mapping validation can run first) plus a\n * single-pass stream of plain row objects.\n *\n * Column discovery per lane (spec §5.2 mapping-validation rule):\n * - row objects → keys of the FIRST row (sampled; later rows may add keys,\n * which flow into attrs/summaries but not validation);\n * - CSV → the header row;\n * - JSON document → keys of the first element of each resolved path array;\n * - Arrow/Parquet → the file schema (exact, not sampled).\n *\n * `columns: null` means the source was empty — nothing to validate against\n * (vacuously valid) and nothing to stream.\n */\n\nexport interface RowTable {\n /** Discovered columns, or null when the source has no rows at all. */\n readonly columns: readonly string[] | null;\n readonly rows: AsyncIterable<Readonly<Record<string, unknown>>>;\n}\n\nexport const EMPTY_ROW_TABLE: RowTable = {\n columns: null,\n rows: (async function* () {})(),\n};\n\nexport function isPlainRowObject(row: unknown): row is Record<string, unknown> {\n return typeof row === 'object' && row !== null && !Array.isArray(row);\n}\n","/**\n * Source-kind detection and byte/row stream normalization.\n *\n * The package accepts exactly the spec §5.2 source shapes:\n * GraphRowSource = readonly unknown[] | AsyncIterable<unknown>\n * GraphByteSource = Blob | ArrayBuffer | AsyncIterable<Uint8Array>\n *\n * An `AsyncIterable` is ambiguous between the two — when the caller supplies\n * no explicit `format`, the first element is peeked: `Uint8Array` chunks mean\n * bytes (CSV lane), anything else means row objects. The peeked element is\n * pushed back, so adapters observe the full stream.\n */\n\nexport function throwIfAborted(signal: AbortSignal | undefined): void {\n if (signal?.aborted) {\n if (typeof signal.throwIfAborted === 'function') signal.throwIfAborted();\n throw new Error('prepareGraphData: aborted');\n }\n}\n\nexport function isBlob(value: unknown): value is Blob {\n return typeof Blob !== 'undefined' && value instanceof Blob;\n}\n\nexport function isAsyncIterable(value: unknown): value is AsyncIterable<unknown> {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as Record<PropertyKey, unknown>)[Symbol.asyncIterator] === 'function'\n );\n}\n\n/** An async iterable with its first element already consumed and re-yielded.\n * `done` distinguishes a completed source from one whose first YIELD was\n * `undefined` (review P2: conflating them silently discarded the whole\n * source instead of reporting malformed row zero). */\nexport async function peekAsyncIterable(\n source: AsyncIterable<unknown>,\n): Promise<{\n first: unknown | undefined;\n done: boolean;\n rest: AsyncIterable<unknown>;\n /** Close the UNDERLYING iterator directly (review P2): calling return()\n * on the un-started replay generator completes without entering its body,\n * so its finally cannot forward — validation-failure paths close here. */\n close: () => Promise<void>;\n}> {\n const iterator = source[Symbol.asyncIterator]();\n const head = await iterator.next();\n const first = head.done ? undefined : head.value;\n async function* replay(): AsyncGenerator<unknown> {\n try {\n if (!head.done) yield head.value;\n // Delegate to the original iterator (not the iterable) so nothing is lost.\n while (true) {\n const next = await iterator.next();\n if (next.done) return;\n yield next.value;\n }\n } finally {\n // Review P2: early exit or a downstream throw must CLOSE the source —\n // file handles, network bodies, and generator finally-blocks hang off\n // return(). Forwarded unconditionally; a completed iterator no-ops.\n await iterator.return?.();\n }\n }\n return {\n first,\n done: head.done === true,\n rest: replay(),\n close: async () => {\n await iterator.return?.();\n },\n };\n}\n\n/** Normalize any GraphByteSource to an async chunk stream. */\nexport function byteChunks(\n source: Blob | ArrayBuffer | AsyncIterable<Uint8Array>,\n signal: AbortSignal | undefined,\n): AsyncIterable<Uint8Array> {\n if (source instanceof ArrayBuffer) {\n const chunk = new Uint8Array(source);\n return (async function* () {\n throwIfAborted(signal);\n yield chunk;\n })();\n }\n if (isBlob(source)) {\n return (async function* () {\n // Blob.stream() is a web ReadableStream; async-iterable in Node ≥18.\n const stream = source.stream() as unknown as AsyncIterable<Uint8Array>;\n for await (const chunk of stream) {\n throwIfAborted(signal);\n yield chunk;\n }\n })();\n }\n return (async function* () {\n for await (const chunk of source) {\n throwIfAborted(signal);\n if (!(chunk instanceof Uint8Array)) {\n throw new TypeError(\n 'prepareGraphData: byte sources must yield Uint8Array chunks',\n );\n }\n yield chunk;\n }\n })();\n}\n\n/** Collect a full byte source into one Uint8Array (JSON/Arrow/Parquet lanes). */\nexport async function collectBytes(\n source: Blob | ArrayBuffer | AsyncIterable<Uint8Array>,\n signal: AbortSignal | undefined,\n): Promise<Uint8Array> {\n const chunks: Uint8Array[] = [];\n let total = 0;\n for await (const chunk of byteChunks(source, signal)) {\n chunks.push(chunk);\n total += chunk.byteLength;\n }\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out;\n}\n\n/** Normalize a row source (array or async iterable of rows) to a stream. */\nexport function rowStream(\n source: readonly unknown[] | AsyncIterable<unknown>,\n signal: AbortSignal | undefined,\n): AsyncIterable<unknown> {\n if (Array.isArray(source)) {\n const rows = source as readonly unknown[];\n return (async function* () {\n for (let i = 0; i < rows.length; i++) {\n if ((i & 255) === 0) throwIfAborted(signal);\n yield rows[i];\n }\n })();\n }\n if (isAsyncIterable(source)) {\n return (async function* () {\n for await (const row of source) {\n throwIfAborted(signal);\n yield row;\n }\n })();\n }\n throw new TypeError(\n 'prepareGraphData: row sources must be an array or an AsyncIterable of row objects',\n );\n}\n"]}