@modernrelay/orbit-data 0.2.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.
@@ -0,0 +1 @@
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,CAAA,IAAK,MAAA;AAAA,EAClC;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,OAAO,GAAA,GAAM,KAAA,CAAM,GAAA,CAAI,CAAC,CAAA,KAAM,aAAA,CAAc,CAAC,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,GAAI,GAAA;AAAA,EAC9D;AACA,EAAA,MAAM,MAAA,GAAS,KAAA;AACf,EAAA,MAAM,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,MAAM,CAAA,CAC5B,MAAA,CAAO,CAAC,CAAA,KAAM,MAAA,CAAO,CAAC,CAAA,KAAM,MAAS,EACrC,IAAA,EAAK;AACR,EAAA,OACE,MAAM,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,KAAM,IAAA,CAAK,UAAU,CAAC,CAAA,GAAI,GAAA,GAAM,aAAA,CAAc,OAAO,CAAC,CAAC,CAAC,CAAA,CAAE,IAAA,CAAK,GAAG,CAAA,GAAI,GAAA;AAE1F;AAEA,IAAM,UAAA,GAAa,mBAAA;AACnB,IAAM,SAAA,GAAY,cAAA;AAClB,IAAM,OAAA,GAAU,mBAAA;AAGT,SAAS,WAAW,IAAA,EAAsB;AAC/C,EAAA,MAAM,KAAA,GAAQ,IAAI,WAAA,EAAY,CAAE,OAAO,IAAI,CAAA;AAC3C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,CAAA;AAChC,EAAA,IAAI,MAAA,GAAS,CAAA;AACb,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,GAAA,CAAI,GAAA,CAAI,OAAO,MAAM,CAAA;AACrB,IAAA,MAAA,IAAU,KAAA,CAAM,UAAA;AAAA,EAClB;AACA,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,SAAA,CACd,QACA,MAAA,EACwB;AACxB,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG;AACzB,IAAA,MAAM,IAAA,GAAO,MAAA;AACb,IAAA,OAAA,CAAQ,mBAAmB;AACzB,MAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,IAAA,CAAK,QAAQ,CAAA,EAAA,EAAK;AACpC,QAAA,IAAA,CAAK,CAAA,GAAI,GAAA,MAAS,CAAA,EAAG,cAAA,CAAe,MAAM,CAAA;AAC1C,QAAA,MAAM,KAAK,CAAC,CAAA;AAAA,MACd;AAAA,IACF,CAAA,GAAG;AAAA,EACL;AACA,EAAA,IAAI,eAAA,CAAgB,MAAM,CAAA,EAAG;AAC3B,IAAA,OAAA,CAAQ,mBAAmB;AACzB,MAAA,WAAA,MAAiB,OAAO,MAAA,EAAQ;AAC9B,QAAA,cAAA,CAAe,MAAM,CAAA;AACrB,QAAA,MAAM,GAAA;AAAA,MACR;AAAA,IACF,CAAA,GAAG;AAAA,EACL;AACA,EAAA,MAAM,IAAI,SAAA;AAAA,IACR;AAAA,GACF;AACF","file":"chunk-H22YHC2C.js","sourcesContent":["/**\n * Mapping fingerprint (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 out[name] = acc.finalize(this.rows);\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 (attrs ??= {})[key] = value;\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 (attrs ??= {})[key] = value;\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. */\nexport async function peekAsyncIterable(\n source: AsyncIterable<unknown>,\n): Promise<{ first: unknown | undefined; rest: AsyncIterable<unknown> }> {\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 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 }\n return { first, rest: replay() };\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"]}
@@ -0,0 +1,93 @@
1
+ import { c as GraphPrepareInput, a as GraphColumnMapping, b as GraphPrepareOptions, P as PreparedGraph, d as PreparedGraphSummaries, e as GraphPrepareFormat } from './types-Bf3sle3D.js';
2
+ export { C as ColumnSummary, G as GraphByteSource, f as GraphRowSource, g as GraphTabularSource } from './types-Bf3sle3D.js';
3
+ import { GraphSnapshot } from '@modernrelay/orbit-core';
4
+
5
+ /**
6
+ * `prepareGraphData` (T01/T02/T03) — the root-entry preparation pipeline for
7
+ * the built-in lanes: row objects, streaming CSV, and JSON documents.
8
+ *
9
+ * Arrow/Parquet live behind the `./arrow` and `./parquet` format entries
10
+ * (spec §5.2/§18 bundle isolation): passing `format: 'arrow' | 'parquet'`
11
+ * here throws with a pointer to the right entry instead of dragging optional
12
+ * parsers into the root bundle.
13
+ *
14
+ * Format inference when `format` is omitted:
15
+ * - `{document}` input → 'json';
16
+ * - arrays → 'rows'; Blob/ArrayBuffer → 'csv';
17
+ * - an AsyncIterable is ambiguous: the first element is peeked — Uint8Array
18
+ * chunks mean 'csv' bytes, anything else means row objects (sources.ts).
19
+ * The resolved label used in the fingerprint is `options.format` when given,
20
+ * else 'csv' if any lane parsed CSV, else 'rows' (or 'json' for documents).
21
+ */
22
+
23
+ declare function prepareGraphData<N = Record<string, unknown>, E = Record<string, unknown>>(input: GraphPrepareInput, mapping: GraphColumnMapping, options: GraphPrepareOptions): Promise<PreparedGraph<N, E>>;
24
+
25
+ /**
26
+ * Prepared-artifact round-trip (T05): a versioned JSON envelope so repeated
27
+ * loads skip reparsing (spec §5.2 "prepare once, upload prepared files").
28
+ *
29
+ * v1 envelope: `{ formatVersion: 1, datasetKey, sourceRevision,
30
+ * mappingFingerprint, snapshot, summaries }`. The version field is how the
31
+ * S13 columnar upgrade slots in: a future v2 carries a ColumnarGraphSnapshot
32
+ * while v1 artifacts keep loading through this object lane.
33
+ *
34
+ * Revalidation contract:
35
+ * - `loadPrepared(bytes, { expectedMappingFingerprint })` with a MATCHING
36
+ * fingerprint skips structural revalidation entirely (the fast path — the
37
+ * artifact was produced by `serializePrepared` under the same mapping);
38
+ * - a MISMATCH throws, quoting both fingerprints;
39
+ * - no expected fingerprint → full structural revalidation via
40
+ * `validatePreparedEnvelope`.
41
+ *
42
+ * JSON transport caveat (documented): snapshot attrs must be JSON-safe —
43
+ * `bigint` throws (native JSON.stringify behavior) and `Date` flattens to an
44
+ * ISO string. Prepared lanes that normalize values (arrow.ts/parquet.ts)
45
+ * already produce JSON-safe attrs.
46
+ */
47
+
48
+ declare const PREPARED_ARTIFACT_FORMAT_VERSION = 1;
49
+ interface PreparedArtifactEnvelopeV1 {
50
+ formatVersion: 1;
51
+ datasetKey: string;
52
+ sourceRevision: string | number;
53
+ mappingFingerprint: string;
54
+ snapshot: GraphSnapshot;
55
+ summaries: PreparedGraphSummaries;
56
+ }
57
+ declare function serializePrepared(prepared: PreparedGraph<unknown, unknown>): Uint8Array;
58
+ declare function loadPrepared<N = Record<string, unknown>, E = Record<string, unknown>>(bytes: Uint8Array, options?: {
59
+ expectedMappingFingerprint?: string;
60
+ }): PreparedGraph<N, E>;
61
+ /**
62
+ * Structural revalidation of a parsed v1 envelope. O(rows); throws TypeError
63
+ * on the first violation. Full semantic validation (duplicate ids, dangling
64
+ * endpoints, …) stays core's §5.1 job at ingestion.
65
+ */
66
+ declare function validatePreparedEnvelope(envelope: Partial<PreparedArtifactEnvelopeV1>): void;
67
+
68
+ /**
69
+ * Mapping fingerprint (spec §5.2: "mapping/schema fingerprints").
70
+ *
71
+ * `mappingFingerprint = fnv1a64Hex(canonicalJson(mapping) + '\n' + format +
72
+ * '\n' + canonicalJson(columns))` where `columns` is, per role, the ADMITTED
73
+ * attr-field union (invariant I4, semantic fingerprint completeness): the
74
+ * seeded schema columns (CSV header / Arrow-Parquet schema / first-row keys,
75
+ * minus identity, filtered by `includeFields`) UNIONED with every field any
76
+ * row actually materialized into attrs — collected by builder.ts during the
77
+ * single materialization pass. The lists are sorted here, so field discovery
78
+ * order never moves the fingerprint; canonical JSON sorts object keys
79
+ * recursively so key-order-insensitive equal mappings fingerprint
80
+ * identically.
81
+ */
82
+
83
+ /** Recursively key-sorted JSON. Only JSON-safe values are expected (mappings
84
+ * and column lists are plain strings/arrays/objects). */
85
+ declare function canonicalJson(value: unknown): string;
86
+ /** FNV-1a 64-bit over the UTF-8 bytes of `text`, as a 16-char lowercase hex string. */
87
+ declare function fnv1a64Hex(text: string): string;
88
+ declare function computeMappingFingerprint(mapping: GraphColumnMapping, format: GraphPrepareFormat, columns: {
89
+ nodes: readonly string[];
90
+ edges: readonly string[];
91
+ }): string;
92
+
93
+ export { GraphColumnMapping, GraphPrepareFormat, GraphPrepareInput, GraphPrepareOptions, PREPARED_ARTIFACT_FORMAT_VERSION, PreparedGraph, PreparedGraphSummaries, canonicalJson, computeMappingFingerprint, fnv1a64Hex, loadPrepared, prepareGraphData, serializePrepared, validatePreparedEnvelope };
package/dist/index.js ADDED
@@ -0,0 +1,450 @@
1
+ import { buildPrepared, isBlob, isAsyncIterable, peekAsyncIterable, EMPTY_ROW_TABLE, collectBytes, isPlainRowObject, rowStream, byteChunks, throwIfAborted } from './chunk-H22YHC2C.js';
2
+ export { canonicalJson, computeMappingFingerprint, fnv1a64Hex } from './chunk-H22YHC2C.js';
3
+ import { coerceNumeric } from '@modernrelay/orbit-core';
4
+
5
+ var SAMPLE_ROWS = 1e3;
6
+ async function* csvRecords(chunks) {
7
+ const decoder = new TextDecoder("utf-8");
8
+ let field = "";
9
+ let record = [];
10
+ let inQuotes = false;
11
+ let afterQuote = false;
12
+ let sawCR = false;
13
+ let recordHadQuote = false;
14
+ const pending = [];
15
+ const endField = () => {
16
+ record.push(field);
17
+ field = "";
18
+ };
19
+ const endRecord = () => {
20
+ endField();
21
+ const blankLine = record.length === 1 && record[0] === "" && !recordHadQuote;
22
+ if (!blankLine) pending.push(record);
23
+ record = [];
24
+ recordHadQuote = false;
25
+ };
26
+ const feed = (text) => {
27
+ for (const ch of text) {
28
+ const prevCR = sawCR;
29
+ sawCR = false;
30
+ if (afterQuote) {
31
+ afterQuote = false;
32
+ if (ch === '"') {
33
+ field += '"';
34
+ continue;
35
+ }
36
+ inQuotes = false;
37
+ }
38
+ if (inQuotes) {
39
+ if (ch === '"') afterQuote = true;
40
+ else field += ch;
41
+ continue;
42
+ }
43
+ if (ch === "\n") {
44
+ if (!prevCR) endRecord();
45
+ continue;
46
+ }
47
+ if (ch === "\r") {
48
+ endRecord();
49
+ sawCR = true;
50
+ continue;
51
+ }
52
+ if (ch === ",") {
53
+ endField();
54
+ continue;
55
+ }
56
+ if (ch === '"') {
57
+ if (field === "") {
58
+ inQuotes = true;
59
+ recordHadQuote = true;
60
+ continue;
61
+ }
62
+ field += ch;
63
+ continue;
64
+ }
65
+ field += ch;
66
+ }
67
+ };
68
+ for await (const chunk of chunks) {
69
+ feed(decoder.decode(chunk, { stream: true }));
70
+ if (pending.length > 0) {
71
+ yield* pending.splice(0, pending.length);
72
+ }
73
+ }
74
+ feed(decoder.decode());
75
+ if (inQuotes && !afterQuote) {
76
+ throw new TypeError("prepareGraphData: CSV ended inside an unterminated quoted field");
77
+ }
78
+ if (afterQuote) inQuotes = false;
79
+ if (field !== "" || record.length > 0 || recordHadQuote) {
80
+ endRecord();
81
+ }
82
+ yield* pending.splice(0, pending.length);
83
+ }
84
+ async function csvTable(source, signal, identityColumns) {
85
+ const records = csvRecords(byteChunks(source, signal));
86
+ const iterator = records[Symbol.asyncIterator]();
87
+ const head = await iterator.next();
88
+ if (head.done) return EMPTY_ROW_TABLE;
89
+ const columns = [...head.value];
90
+ const rows = (async function* () {
91
+ const sample = [];
92
+ let sampleDone = false;
93
+ while (sample.length < SAMPLE_ROWS) {
94
+ const next = await iterator.next();
95
+ if (next.done) {
96
+ sampleDone = true;
97
+ break;
98
+ }
99
+ sample.push(next.value);
100
+ }
101
+ const numeric = columns.map((name, index) => {
102
+ if (identityColumns.has(name)) return false;
103
+ let nonEmpty = 0;
104
+ for (const record of sample) {
105
+ const cell = record[index];
106
+ if (cell === void 0 || cell === "") continue;
107
+ nonEmpty++;
108
+ if (coerceNumeric(cell) === null) return false;
109
+ }
110
+ return nonEmpty > 0;
111
+ });
112
+ const toRow = (record) => {
113
+ const row = {};
114
+ for (let i = 0; i < columns.length; i++) {
115
+ const cell = record[i];
116
+ if (cell === void 0 || cell === "") continue;
117
+ const name = columns[i];
118
+ if (numeric[i]) {
119
+ const value = coerceNumeric(cell);
120
+ if (value === null) continue;
121
+ row[name] = value;
122
+ } else {
123
+ row[name] = cell;
124
+ }
125
+ }
126
+ return row;
127
+ };
128
+ for (const record of sample) {
129
+ yield toRow(record);
130
+ }
131
+ if (!sampleDone) {
132
+ while (true) {
133
+ throwIfAborted(signal);
134
+ const next = await iterator.next();
135
+ if (next.done) break;
136
+ yield toRow(next.value);
137
+ }
138
+ }
139
+ })();
140
+ return { columns, rows };
141
+ }
142
+
143
+ // src/document.ts
144
+ async function documentTables(source, mapping, signal) {
145
+ const paths = mapping.documentPaths;
146
+ if (paths === void 0) {
147
+ throw new TypeError(
148
+ "prepareGraphData: document input requires mapping.documentPaths ({ nodes, edges } dot-paths into the parsed object)"
149
+ );
150
+ }
151
+ const bytes = await collectBytes(source, signal);
152
+ let parsed;
153
+ try {
154
+ parsed = JSON.parse(new TextDecoder().decode(bytes));
155
+ } catch (cause) {
156
+ throw new TypeError(
157
+ `prepareGraphData: document input is not valid JSON (${cause.message})`
158
+ );
159
+ }
160
+ if (!isPlainRowObject(parsed)) {
161
+ throw new TypeError(
162
+ "prepareGraphData: document input must parse to a single JSON object"
163
+ );
164
+ }
165
+ return {
166
+ nodes: arrayAtPath(parsed, paths.nodes, "nodes"),
167
+ edges: arrayAtPath(parsed, paths.edges, "edges")
168
+ };
169
+ }
170
+ function arrayAtPath(document, path, role) {
171
+ let cursor = document;
172
+ for (const segment of path.split(".")) {
173
+ if (!isPlainRowObject(cursor)) {
174
+ throw new TypeError(
175
+ `prepareGraphData: documentPaths.${role} ${JSON.stringify(path)} does not resolve to an array (stopped at segment ${JSON.stringify(segment)})`
176
+ );
177
+ }
178
+ cursor = cursor[segment];
179
+ }
180
+ if (!Array.isArray(cursor)) {
181
+ throw new TypeError(
182
+ `prepareGraphData: documentPaths.${role} ${JSON.stringify(path)} must resolve to an array`
183
+ );
184
+ }
185
+ const rows = cursor;
186
+ if (rows.length === 0) return EMPTY_ROW_TABLE;
187
+ const first = rows[0];
188
+ if (!isPlainRowObject(first)) {
189
+ throw new TypeError(
190
+ `prepareGraphData: documentPaths.${role} array elements must be plain row objects`
191
+ );
192
+ }
193
+ return {
194
+ columns: Object.keys(first),
195
+ rows: (async function* () {
196
+ for (let i = 0; i < rows.length; i++) {
197
+ const row = rows[i];
198
+ if (!isPlainRowObject(row)) {
199
+ throw new TypeError(
200
+ `prepareGraphData: documentPaths.${role} element ${i} is not a plain row object`
201
+ );
202
+ }
203
+ yield row;
204
+ }
205
+ })()
206
+ };
207
+ }
208
+
209
+ // src/rows.ts
210
+ async function rowsTable(source, signal, role) {
211
+ const stream = rowStream(source, signal);
212
+ const { first, rest } = await peekAsyncIterable(stream);
213
+ if (first === void 0) return EMPTY_ROW_TABLE;
214
+ if (!isPlainRowObject(first)) {
215
+ throw new TypeError(
216
+ `prepareGraphData: ${role} row sources must yield plain row objects (got ${first === null ? "null" : typeof first})`
217
+ );
218
+ }
219
+ const columns = Object.keys(first);
220
+ return {
221
+ columns,
222
+ rows: (async function* () {
223
+ let index = 0;
224
+ for await (const row of rest) {
225
+ if (!isPlainRowObject(row)) {
226
+ throw new TypeError(
227
+ `prepareGraphData: ${role} row ${index} is not a plain row object`
228
+ );
229
+ }
230
+ yield row;
231
+ index++;
232
+ }
233
+ })()
234
+ };
235
+ }
236
+
237
+ // src/prepare.ts
238
+ async function prepareGraphData(input, mapping, options) {
239
+ const { format, signal } = options;
240
+ if (format === "arrow" || format === "parquet") {
241
+ throw new TypeError(
242
+ `prepareGraphData: format '${format}' is served by the '@modernrelay/orbit-data/${format}' entry (prepare${format === "arrow" ? "Arrow" : "Parquet"}GraphData) \u2014 the root entry never bundles optional format parsers`
243
+ );
244
+ }
245
+ if ("document" in input) {
246
+ if (format !== void 0 && format !== "json") {
247
+ throw new TypeError(
248
+ `prepareGraphData: a document input is valid only for JSON (got format '${format}')`
249
+ );
250
+ }
251
+ const tables = await documentTables(input.document, mapping, signal);
252
+ return await buildPrepared({
253
+ nodeTable: tables.nodes,
254
+ edgeTable: tables.edges,
255
+ mapping,
256
+ format: "json",
257
+ options
258
+ });
259
+ }
260
+ if (format === "json") {
261
+ throw new TypeError(
262
+ "prepareGraphData: format 'json' requires the { document } input variant with mapping.documentPaths"
263
+ );
264
+ }
265
+ const deriveNodes = "deriveNodes" in input && input.deriveNodes === true;
266
+ const edgeIdentity = new Set(
267
+ [mapping.edges.id, mapping.edges.source, mapping.edges.target].filter(
268
+ (c) => c !== void 0
269
+ )
270
+ );
271
+ const lanes = { csv: false, rows: false };
272
+ const edgeTable = await resolveTabular(input.edges, options, edgeIdentity, "edge", lanes);
273
+ let nodeTable = null;
274
+ if (!deriveNodes) {
275
+ if (!("nodes" in input) || input.nodes === void 0) {
276
+ throw new TypeError(
277
+ "prepareGraphData: input must supply nodes, set deriveNodes: true, or use a document"
278
+ );
279
+ }
280
+ const nodeIdentity = new Set(mapping.nodes === void 0 ? [] : [mapping.nodes.id]);
281
+ nodeTable = await resolveTabular(input.nodes, options, nodeIdentity, "node", lanes);
282
+ }
283
+ const resolvedFormat = format ?? (lanes.csv ? "csv" : "rows");
284
+ return await buildPrepared({
285
+ nodeTable,
286
+ edgeTable,
287
+ mapping,
288
+ format: resolvedFormat,
289
+ options
290
+ });
291
+ }
292
+ async function resolveTabular(source, options, identityColumns, role, lanes) {
293
+ const { format, signal } = options;
294
+ if (Array.isArray(source)) {
295
+ if (format === "csv") {
296
+ throw new TypeError(
297
+ `prepareGraphData: format 'csv' needs a byte source for the ${role} lane, got an array of rows`
298
+ );
299
+ }
300
+ lanes.rows = true;
301
+ return rowsTable(source, signal, role);
302
+ }
303
+ if (source instanceof ArrayBuffer || isBlob(source)) {
304
+ if (format === "rows") {
305
+ throw new TypeError(
306
+ `prepareGraphData: format 'rows' needs row objects for the ${role} lane, got bytes`
307
+ );
308
+ }
309
+ lanes.csv = true;
310
+ return csvTable(source, signal, identityColumns);
311
+ }
312
+ if (isAsyncIterable(source)) {
313
+ if (format === "csv") {
314
+ lanes.csv = true;
315
+ return csvTable(source, signal, identityColumns);
316
+ }
317
+ if (format === "rows") {
318
+ lanes.rows = true;
319
+ return rowsTable(source, signal, role);
320
+ }
321
+ const { first, rest } = await peekAsyncIterable(source);
322
+ if (first === void 0) return EMPTY_ROW_TABLE;
323
+ if (first instanceof Uint8Array) {
324
+ lanes.csv = true;
325
+ return csvTable(rest, signal, identityColumns);
326
+ }
327
+ lanes.rows = true;
328
+ return rowsTable(rest, signal, role);
329
+ }
330
+ throw new TypeError(
331
+ `prepareGraphData: unsupported ${role} source \u2014 expected rows (array/AsyncIterable) or bytes (Blob/ArrayBuffer/AsyncIterable<Uint8Array>)`
332
+ );
333
+ }
334
+
335
+ // src/artifact.ts
336
+ var PREPARED_ARTIFACT_FORMAT_VERSION = 1;
337
+ function serializePrepared(prepared) {
338
+ const snapshot = prepared.snapshot;
339
+ const envelope = {
340
+ formatVersion: PREPARED_ARTIFACT_FORMAT_VERSION,
341
+ datasetKey: snapshot.datasetKey,
342
+ sourceRevision: snapshot.sourceRevision,
343
+ mappingFingerprint: prepared.mappingFingerprint,
344
+ snapshot,
345
+ summaries: prepared.summaries
346
+ };
347
+ return new TextEncoder().encode(JSON.stringify(envelope));
348
+ }
349
+ function loadPrepared(bytes, options) {
350
+ let parsed;
351
+ try {
352
+ parsed = JSON.parse(new TextDecoder().decode(bytes));
353
+ } catch (cause) {
354
+ throw new TypeError(
355
+ `loadPrepared: artifact is not valid JSON (${cause.message})`
356
+ );
357
+ }
358
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
359
+ throw new TypeError("loadPrepared: artifact must be a JSON object envelope");
360
+ }
361
+ const envelope = parsed;
362
+ if (envelope.formatVersion !== PREPARED_ARTIFACT_FORMAT_VERSION) {
363
+ throw new TypeError(
364
+ `loadPrepared: unsupported artifact formatVersion ${JSON.stringify(envelope.formatVersion)} (this build reads v${PREPARED_ARTIFACT_FORMAT_VERSION})`
365
+ );
366
+ }
367
+ if (typeof envelope.mappingFingerprint !== "string") {
368
+ throw new TypeError("loadPrepared: artifact is missing its mappingFingerprint");
369
+ }
370
+ const expected = options?.expectedMappingFingerprint;
371
+ if (expected !== void 0) {
372
+ if (expected !== envelope.mappingFingerprint) {
373
+ throw new Error(
374
+ `loadPrepared: mapping fingerprint mismatch \u2014 expected ${expected}, artifact has ${envelope.mappingFingerprint}; the artifact was prepared under a different mapping/format/schema`
375
+ );
376
+ }
377
+ } else {
378
+ _internals.validate(envelope);
379
+ }
380
+ const valid = envelope;
381
+ return {
382
+ snapshot: valid.snapshot,
383
+ summaries: valid.summaries,
384
+ mappingFingerprint: valid.mappingFingerprint
385
+ };
386
+ }
387
+ function validatePreparedEnvelope(envelope) {
388
+ const snapshot = envelope.snapshot;
389
+ if (typeof snapshot !== "object" || snapshot === null) {
390
+ throw new TypeError("loadPrepared: artifact snapshot is missing");
391
+ }
392
+ if (typeof snapshot.datasetKey !== "string" || snapshot.datasetKey === "") {
393
+ throw new TypeError("loadPrepared: snapshot.datasetKey must be a non-empty string");
394
+ }
395
+ if (typeof snapshot.sourceRevision !== "string" && typeof snapshot.sourceRevision !== "number") {
396
+ throw new TypeError("loadPrepared: snapshot.sourceRevision must be a string or number");
397
+ }
398
+ if (envelope.datasetKey !== snapshot.datasetKey) {
399
+ throw new TypeError("loadPrepared: envelope datasetKey disagrees with its snapshot");
400
+ }
401
+ if (envelope.sourceRevision !== snapshot.sourceRevision) {
402
+ throw new TypeError("loadPrepared: envelope sourceRevision disagrees with its snapshot");
403
+ }
404
+ if (!Array.isArray(snapshot.nodes) || !Array.isArray(snapshot.edges)) {
405
+ throw new TypeError("loadPrepared: snapshot nodes/edges must be arrays");
406
+ }
407
+ for (let i = 0; i < snapshot.nodes.length; i++) {
408
+ const node = snapshot.nodes[i];
409
+ if (node === null || typeof node !== "object" || typeof node.id !== "string" || node.id === "") {
410
+ throw new TypeError(`loadPrepared: snapshot node ${i} lacks a string id`);
411
+ }
412
+ if (node.attrs !== void 0 && (typeof node.attrs !== "object" || node.attrs === null)) {
413
+ throw new TypeError(`loadPrepared: snapshot node ${i} attrs must be an object`);
414
+ }
415
+ }
416
+ for (let i = 0; i < snapshot.edges.length; i++) {
417
+ const edge = snapshot.edges[i];
418
+ if (edge === null || typeof edge !== "object" || typeof edge.source !== "string" || edge.source === "" || typeof edge.target !== "string" || edge.target === "") {
419
+ throw new TypeError(`loadPrepared: snapshot edge ${i} lacks string endpoints`);
420
+ }
421
+ if (edge.id !== void 0 && (typeof edge.id !== "string" || edge.id === "")) {
422
+ throw new TypeError(`loadPrepared: snapshot edge ${i} id must be a non-empty string`);
423
+ }
424
+ if (edge.attrs !== void 0 && (typeof edge.attrs !== "object" || edge.attrs === null)) {
425
+ throw new TypeError(`loadPrepared: snapshot edge ${i} attrs must be an object`);
426
+ }
427
+ }
428
+ const summaries = envelope.summaries;
429
+ if (typeof summaries !== "object" || summaries === null) {
430
+ throw new TypeError("loadPrepared: artifact summaries are missing");
431
+ }
432
+ for (const side of ["nodes", "edges"]) {
433
+ const table = summaries[side];
434
+ if (typeof table !== "object" || table === null || Array.isArray(table)) {
435
+ throw new TypeError(`loadPrepared: summaries.${side} must be a record`);
436
+ }
437
+ for (const [column, summary] of Object.entries(table)) {
438
+ if (typeof summary !== "object" || summary === null || typeof summary.count !== "number" || typeof summary.nullCount !== "number") {
439
+ throw new TypeError(
440
+ `loadPrepared: summaries.${side}[${JSON.stringify(column)}] lacks numeric count/nullCount`
441
+ );
442
+ }
443
+ }
444
+ }
445
+ }
446
+ var _internals = { validate: validatePreparedEnvelope };
447
+
448
+ export { PREPARED_ARTIFACT_FORMAT_VERSION, loadPrepared, prepareGraphData, serializePrepared, validatePreparedEnvelope };
449
+ //# sourceMappingURL=index.js.map
450
+ //# sourceMappingURL=index.js.map