@nicia-ai/typegraph 0.73.0 → 0.73.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/backend/postgres/pglite-store.cjs +1 -1
  3. package/dist/backend/postgres/pglite-store.js +1 -1
  4. package/dist/backend/postgres/working-copy.cjs +85 -85
  5. package/dist/backend/postgres/working-copy.js +4 -4
  6. package/dist/backend/sqlite/local-store.cjs +1 -1
  7. package/dist/backend/sqlite/local-store.js +1 -1
  8. package/dist/{chunk-7QQ3ICAZ.cjs → chunk-BZ5EXHZX.cjs} +11 -11
  9. package/dist/{chunk-7QQ3ICAZ.cjs.map → chunk-BZ5EXHZX.cjs.map} +1 -1
  10. package/dist/{chunk-ZN24TFVZ.cjs → chunk-GLDGT3L3.cjs} +6 -3
  11. package/dist/chunk-GLDGT3L3.cjs.map +1 -0
  12. package/dist/{chunk-ORTKLAAU.js → chunk-LJG2TYCN.js} +3 -3
  13. package/dist/{chunk-ORTKLAAU.js.map → chunk-LJG2TYCN.js.map} +1 -1
  14. package/dist/{chunk-VKMLQTXP.cjs → chunk-MPCF5XBW.cjs} +159 -159
  15. package/dist/{chunk-VKMLQTXP.cjs.map → chunk-MPCF5XBW.cjs.map} +1 -1
  16. package/dist/{chunk-5RTWCMBC.js → chunk-OA4PF2QI.js} +6 -3
  17. package/dist/chunk-OA4PF2QI.js.map +1 -0
  18. package/dist/{chunk-XGYVKBI5.cjs → chunk-P52FOZSI.cjs} +8 -8
  19. package/dist/{chunk-XGYVKBI5.cjs.map → chunk-P52FOZSI.cjs.map} +1 -1
  20. package/dist/{chunk-KI7VMCOG.cjs → chunk-QJGQ3FN2.cjs} +16 -16
  21. package/dist/{chunk-KI7VMCOG.cjs.map → chunk-QJGQ3FN2.cjs.map} +1 -1
  22. package/dist/{chunk-MSUUUG5B.js → chunk-TI2O2U4G.js} +4 -4
  23. package/dist/{chunk-MSUUUG5B.js.map → chunk-TI2O2U4G.js.map} +1 -1
  24. package/dist/{chunk-FC7INRDS.js → chunk-WX7BQELV.js} +4 -4
  25. package/dist/{chunk-FC7INRDS.js.map → chunk-WX7BQELV.js.map} +1 -1
  26. package/dist/{chunk-NMLLXBGF.js → chunk-XIFBU27X.js} +3 -3
  27. package/dist/{chunk-NMLLXBGF.js.map → chunk-XIFBU27X.js.map} +1 -1
  28. package/dist/graph-merge/index.cjs +531 -531
  29. package/dist/graph-merge/index.js +6 -6
  30. package/dist/index.cjs +43 -43
  31. package/dist/index.js +2 -2
  32. package/dist/interchange/index.cjs +26 -26
  33. package/dist/interchange/index.js +3 -3
  34. package/dist/{local-store-impl-ALYCG7CX.js → local-store-impl-HPNBERU4.js} +4 -4
  35. package/dist/{local-store-impl-ALYCG7CX.js.map → local-store-impl-HPNBERU4.js.map} +1 -1
  36. package/dist/{local-store-impl-2HTGPM6A.cjs → local-store-impl-WIVQ5HDM.cjs} +5 -5
  37. package/dist/{local-store-impl-2HTGPM6A.cjs.map → local-store-impl-WIVQ5HDM.cjs.map} +1 -1
  38. package/dist/{pglite-store-impl-F2WHYIM7.cjs → pglite-store-impl-IXKIXLH6.cjs} +5 -5
  39. package/dist/{pglite-store-impl-F2WHYIM7.cjs.map → pglite-store-impl-IXKIXLH6.cjs.map} +1 -1
  40. package/dist/{pglite-store-impl-3UUTJLGP.js → pglite-store-impl-U3TW3Z4C.js} +4 -4
  41. package/dist/{pglite-store-impl-3UUTJLGP.js.map → pglite-store-impl-U3TW3Z4C.js.map} +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-5RTWCMBC.js.map +0 -1
  44. package/dist/chunk-ZN24TFVZ.cjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { exportStreamBackend, serializedStreamRefusal, withImportStreamLease } from './chunk-ORTKLAAU.js';
2
- import { resolveEdgeMatchIdentityStorage } from './chunk-5RTWCMBC.js';
1
+ import { exportStreamBackend, serializedStreamRefusal, withImportStreamLease } from './chunk-LJG2TYCN.js';
2
+ import { resolveEdgeMatchIdentityStorage } from './chunk-OA4PF2QI.js';
3
3
  import { assertEdgeMatchIdentityBackendSupport } from './chunk-XD54DLIG.js';
4
4
  import { storeBackend, storeCaptureEnabled } from './chunk-EUHKGM2J.js';
5
5
  import { snapshotExportContention } from './chunk-JVRZ23QG.js';
@@ -324,5 +324,5 @@ function trustedImportGraph(store, data) {
324
324
  }
325
325
 
326
326
  export { trustedImportGraph, trustedImportGraphStream };
327
- //# sourceMappingURL=chunk-MSUUUG5B.js.map
328
- //# sourceMappingURL=chunk-MSUUUG5B.js.map
327
+ //# sourceMappingURL=chunk-TI2O2U4G.js.map
328
+ //# sourceMappingURL=chunk-TI2O2U4G.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interchange/trusted-import.ts"],"names":[],"mappings":";;;;;;;;;;AAgCA,SAAS,+BACP,KAAA,EACM;AACN,EAAA,MAAM,OAAA,GAAU,aAAa,KAAK,CAAA;AAClC,EAAA,KAAA,MAAW,CAAC,MAAM,YAAY,CAAA,IAAK,OAAO,OAAA,CAAQ,KAAA,CAAM,KAAA,CAAM,KAAK,CAAA,EAAG;AACpE,IAAA,qCAAA;AAAA,MACE,YAAA,CAAa,aAAA;AAAA,MACb,OAAA,CAAQ,YAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAO9B,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,gEAAA;AAAA,MACA,qBAAA;AAAA,MACA,EAAE,OAAA,EAAS,KAAA,CAAM,OAAA;AAAQ,KAC3B;AAAA,EACF;AACA,EAAA,IAAI,MAAM,uBAAA,EAAyB;AACjC,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,oDAAA;AAAA,MACA,+BAAA;AAAA,MACA,EAAE,OAAA,EAAS,KAAA,CAAM,OAAA;AAAQ,KAC3B;AAAA,EACF;AACA,EAAA,IAAI,KAAA,CAAM,KAAA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,MAAA,GACvB;AAAA,MACE,GAAG,MAAA;AAAA,MACH,UAAU,EAAE,OAAA,EAAS,SAAS,OAAA,EAAS,IAAA,EAAM,SAAS,IAAA;AAAK;AAC7D,GAEN;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAM;AAC7B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAM;AAC7B,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,UAAA,EAAY,SAAS,UAAA,EAAW;AAAA,EAC5D;AACF;AAGO,SAAS,kBAAA,CACd,OACA,IAAA,EAC8B;AAC9B,EAAA,OAAO,wBAAA,CAAyB,KAAA,EAAO,eAAA,CAAgB,IAAI,CAAC,CAAA;AAC9D","file":"chunk-MSUUUG5B.js","sourcesContent":["import { assertEdgeMatchIdentityBackendSupport } from \"../backend/edge-match-identity\";\nimport { snapshotExportContention } from \"../backend/transaction-resource\";\nimport type {\n InsertEdgeParams,\n InsertNodeParams,\n TrustedImportOptions,\n TrustedImportSession,\n} from \"../backend/types\";\nimport type { GraphDef } from \"../core/define-graph\";\nimport { resolveGraphVectorSlots } from \"../core/embedding\";\nimport { getSearchableFields } from \"../core/searchable\";\nimport type { EdgeRegistration } from \"../core/types\";\nimport { TrustedImportError } from \"../errors\";\nimport { resolveEdgeMatchIdentityStorage } from \"../store/edge-match-key\";\nimport { storeBackend, storeCaptureEnabled } from \"../store/runtime-port\";\nimport type { Store } from \"../store/store\";\nimport { isCanonicalIsoDate, isInvertedValidityWindow } from \"../utils/date\";\nimport { serializedStreamRefusal, withImportStreamLease } from \"./import\";\nimport { exportStreamBackend } from \"./stream-source\";\nimport type {\n GraphData,\n GraphInterchangeChunk,\n InterchangeEdge,\n InterchangeNode,\n} from \"./types\";\n\n/** Counts committed by a trusted initial import. */\nexport type TrustedImportResult = Readonly<{\n nodes: number;\n edges: number;\n}>;\n\nfunction rejectUnsupportedStoreFeatures<G extends GraphDef>(\n store: Store<G>,\n): void {\n const backend = storeBackend(store);\n for (const [kind, registration] of Object.entries(store.graph.edges)) {\n assertEdgeMatchIdentityBackendSupport(\n registration.matchIdentity,\n backend.capabilities,\n kind,\n );\n }\n if (storeCaptureEnabled(store)) {\n // Trusted import writes rows directly, bypassing the node/edge-\n // operations layer that TypeGraph's own capture uses to populate the\n // recorded relations — a check against `storeCaptureEnabled`, not the\n // public `historyEnabled` getter, so an engine-native `history: true`\n // store (whose engine versions every write to the live table itself,\n // regardless of which code path produced it) is unaffected.\n throw new TrustedImportError(\n \"Trusted import does not support recorded-time history capture.\",\n \"history_unsupported\",\n { graphId: store.graphId },\n );\n }\n if (store.revisionTrackingEnabled) {\n throw new TrustedImportError(\n \"Trusted import does not support revision tracking.\",\n \"revision_tracking_unsupported\",\n { graphId: store.graphId },\n );\n }\n if (store.graph.identity !== undefined) {\n throw new TrustedImportError(\n \"Trusted import does not maintain Operational Identity assertions or closure.\",\n \"identity_unsupported\",\n { graphId: store.graphId },\n );\n }\n\n const uniqueKinds = Object.values(store.graph.nodes)\n .filter((registration) => (registration.unique?.length ?? 0) > 0)\n .map((registration) => registration.type.kind);\n if (uniqueKinds.length > 0) {\n throw new TrustedImportError(\n \"Trusted import does not maintain node uniqueness sidecars.\",\n \"uniqueness_unsupported\",\n { graphId: store.graphId, nodeKinds: uniqueKinds },\n );\n }\n\n const searchableKinds = Object.values(store.graph.nodes)\n .filter(\n (registration) =>\n getSearchableFields(registration.type.schema).length > 0,\n )\n .map((registration) => registration.type.kind);\n if (searchableKinds.length > 0) {\n throw new TrustedImportError(\n \"Trusted import does not maintain fulltext sidecars.\",\n \"fulltext_unsupported\",\n { graphId: store.graphId, nodeKinds: searchableKinds },\n );\n }\n\n const vectorSlots = resolveGraphVectorSlots(store.graph);\n if (vectorSlots.length > 0) {\n throw new TrustedImportError(\n \"Trusted import does not maintain vector sidecars.\",\n \"vector_unsupported\",\n {\n graphId: store.graphId,\n fields: vectorSlots.map((slot) => `${slot.nodeKind}.${slot.fieldPath}`),\n },\n );\n }\n}\n\nfunction invalidStream(message: string): TrustedImportError {\n return new TrustedImportError(message, \"invalid_stream\");\n}\n\n/** The stated validity window of a streamed node or edge. */\ntype StatedValidityWindow = Readonly<{\n validFrom?: string | null | undefined;\n validTo?: string | undefined;\n}>;\n\ntype ValidityWindowField = \"validFrom\" | \"validTo\";\n\n/** A stated window field that is not canonical, with the offending value. */\ntype NonCanonicalWindow = Readonly<{\n field: ValidityWindowField;\n value: string;\n}>;\n\n/**\n * The first window field of `entity` stating a timestamp that is not canonical\n * fixed-width UTC ISO 8601 — with the offending value — or `undefined` when\n * every stated one is canonical.\n *\n * A trusted stream is never re-parsed, so this is the only place its timestamps\n * are held to the format the rest of the system assumes. It is deliberately\n * format-ONLY — the same {@link isCanonicalIsoDate} decision the untrusted\n * path's schema and the store's own write validation make, and nothing more —\n * because a non-canonical instant is not merely ugly: every temporal filter\n * compares these values AS TEXT against an `asOf` coordinate, so a variable-width\n * one (`...:00.1Z`, an offset, date-only) mis-sorts and silently includes or\n * excludes the wrong rows once stored, and it would mis-decide the negative-width\n * check below on the way in. Two field tests per row costs about a microsecond\n * against the ~4µs an in-memory SQLite row already costs — the price of the\n * stream's ordering claims meaning anything.\n *\n * An absent field states nothing, and a `null` validFrom is a confirmed\n * open-left window (see {@link nodeParams}) — neither is a timestamp to check.\n */\nfunction nonCanonicalWindowOf(\n entity: StatedValidityWindow,\n): NonCanonicalWindow | undefined {\n const { validFrom, validTo } = entity;\n if (typeof validFrom === \"string\" && !isCanonicalIsoDate(validFrom)) {\n return { field: \"validFrom\", value: validFrom };\n }\n if (typeof validTo === \"string\" && !isCanonicalIsoDate(validTo)) {\n return { field: \"validTo\", value: validTo };\n }\n return undefined;\n}\n\n/**\n * The first entity in `entities` stating a non-canonical window timestamp, with\n * the offending field and value. Allocates only on the failing path, so a clean\n * chunk pays one predicate per stated timestamp and nothing else.\n */\nfunction findNonCanonicalWindow<Entity extends StatedValidityWindow>(\n entities: readonly Entity[],\n): (NonCanonicalWindow & Readonly<{ entity: Entity }>) | undefined {\n for (const entity of entities) {\n const nonCanonical = nonCanonicalWindowOf(entity);\n if (nonCanonical !== undefined) return { entity, ...nonCanonical };\n }\n return undefined;\n}\n\n/** The refusal message for a non-canonical window timestamp on `subject`. */\nfunction nonCanonicalWindowMessage(\n subject: string,\n field: ValidityWindowField,\n value: string,\n): string {\n return (\n `Non-canonical ${field} in trusted import: ${subject} states \"${value}\". ` +\n `Expected canonical fixed-width UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ), ` +\n `which is what makes a stored timestamp sort chronologically against an asOf ` +\n `coordinate. Convert with new Date(value).toISOString().`\n );\n}\n\n/**\n * An entity whose stated window has negative width. Trusted import writes\n * straight to SQL and skips schema validation for throughput, but a row that\n * stopped being true before it started is a stream SHAPE fault rather than a\n * policy check: it is unobservable at every `asOf` coordinate, and no later\n * write repairs it. `null` validFrom is a confirmed open-left window, so there\n * is no lower bound to invert against; zero width is legal (see\n * {@link isInvertedValidityWindow}).\n *\n * Only ever reached for a chunk whose timestamps {@link findNonCanonicalWindow}\n * has already accepted, which is what makes the lexicographic compare inside a\n * chronological one.\n */\nfunction hasInvertedWindow(entity: StatedValidityWindow): boolean {\n return isInvertedValidityWindow(\n entity.validFrom ?? undefined,\n entity.validTo,\n );\n}\n\nfunction nodeParams(graphId: string, node: InterchangeNode): InsertNodeParams {\n return {\n graphId,\n kind: node.kind,\n id: node.id,\n props: node.properties,\n ...(node.validFrom === undefined ? {} : { validFrom: node.validFrom }),\n ...(node.validTo === undefined ? {} : { validTo: node.validTo }),\n };\n}\n\nfunction edgeParams(\n graphId: string,\n edge: InterchangeEdge,\n registration: EdgeRegistration,\n): InsertEdgeParams {\n const matchIdentity = resolveEdgeMatchIdentityStorage(\n registration.matchIdentity,\n {\n fromKind: edge.from.kind,\n fromId: edge.from.id,\n toKind: edge.to.kind,\n toId: edge.to.id,\n props: edge.properties,\n },\n { graphId, edgeKind: edge.kind },\n );\n return {\n graphId,\n id: edge.id,\n kind: edge.kind,\n fromKind: edge.from.kind,\n fromId: edge.from.id,\n toKind: edge.to.kind,\n toId: edge.to.id,\n props: edge.properties,\n ...(matchIdentity === undefined ? {} : { matchIdentity }),\n ...(edge.validFrom === undefined ? {} : { validFrom: edge.validFrom }),\n ...(edge.validTo === undefined ? {} : { validTo: edge.validTo }),\n };\n}\n\nasync function consumeTrustedChunks<G extends GraphDef>(\n store: Store<G>,\n session: TrustedImportSession,\n chunks:\n AsyncIterable<GraphInterchangeChunk> | Iterable<GraphInterchangeChunk>,\n): Promise<TrustedImportResult> {\n const nodeKinds = new Set(\n Object.values(store.graph.nodes).map(\n (registration) => registration.type.kind,\n ),\n );\n const edgeKinds = new Set(\n Object.values(store.graph.edges).map(\n (registration) => registration.type.kind,\n ),\n );\n let receivedHeader = false;\n let receivedEdges = false;\n let nodeCount = 0;\n let edgeCount = 0;\n\n for await (const chunk of chunks) {\n switch (chunk.type) {\n case \"header\": {\n if (receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream emitted more than one header.\",\n );\n }\n if (chunk.header.identity !== undefined) {\n throw invalidStream(\n \"Trusted graph interchange import does not support identity data. \" +\n \"Use importGraphStream() for an identity export.\",\n );\n }\n receivedHeader = true;\n break;\n }\n case \"nodes\": {\n if (!receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream must start with a header.\",\n );\n }\n if (receivedEdges) {\n throw invalidStream(\n \"Trusted graph interchange stream cannot emit nodes after edges.\",\n );\n }\n const unknownKind = chunk.nodes.find(\n (node) => !nodeKinds.has(node.kind),\n )?.kind;\n if (unknownKind !== undefined) {\n throw invalidStream(\n `Unknown node kind in trusted import: ${unknownKind}`,\n );\n }\n const nonCanonicalNode = findNonCanonicalWindow(chunk.nodes);\n if (nonCanonicalNode !== undefined) {\n const { entity, field, value } = nonCanonicalNode;\n throw invalidStream(\n nonCanonicalWindowMessage(\n `${entity.kind} \"${entity.id}\"`,\n field,\n value,\n ),\n );\n }\n const invertedNode = chunk.nodes.find((node) =>\n hasInvertedWindow(node),\n );\n if (invertedNode !== undefined) {\n throw invalidStream(\n `Inverted validity window in trusted import: ${invertedNode.kind} \"${invertedNode.id}\" ends at ` +\n `\"${String(invertedNode.validTo)}\", before its validFrom \"${String(invertedNode.validFrom)}\".`,\n );\n }\n await session.insertNodes(\n chunk.nodes.map((node) => nodeParams(store.graphId, node)),\n );\n nodeCount += chunk.nodes.length;\n break;\n }\n case \"edges\": {\n if (!receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream must start with a header.\",\n );\n }\n receivedEdges = true;\n const invalidEdge = chunk.edges.find(\n (edge) =>\n !edgeKinds.has(edge.kind) ||\n !nodeKinds.has(edge.from.kind) ||\n !nodeKinds.has(edge.to.kind),\n );\n if (invalidEdge !== undefined) {\n throw invalidStream(\n `Unknown edge or endpoint kind in trusted import: ${invalidEdge.kind}`,\n );\n }\n const nonCanonicalEdge = findNonCanonicalWindow(chunk.edges);\n if (nonCanonicalEdge !== undefined) {\n const { entity, field, value } = nonCanonicalEdge;\n throw invalidStream(\n nonCanonicalWindowMessage(\n `${entity.kind} edge \"${entity.id}\"`,\n field,\n value,\n ),\n );\n }\n const invertedEdge = chunk.edges.find((edge) =>\n hasInvertedWindow(edge),\n );\n if (invertedEdge !== undefined) {\n throw invalidStream(\n `Inverted validity window in trusted import: ${invertedEdge.kind} edge \"${invertedEdge.id}\" ends at ` +\n `\"${String(invertedEdge.validTo)}\", before its validFrom \"${String(invertedEdge.validFrom)}\".`,\n );\n }\n await session.insertEdges(\n chunk.edges.map((edge) =>\n edgeParams(\n store.graphId,\n edge,\n store.graph.edges[edge.kind] as EdgeRegistration,\n ),\n ),\n );\n edgeCount += chunk.edges.length;\n break;\n }\n case \"identity\": {\n // The trusted session writes only the node and edge relations, so it\n // has no way to persist assertions or materialize the derived closure.\n // Refuse rather than drop identity truth from an identity-enabled\n // export: `importGraph` / `importGraphStream` carry it correctly.\n throw invalidStream(\n \"Trusted graph interchange import does not support identity assertions. \" +\n \"Use importGraphStream() for an export that carries identity truth.\",\n );\n }\n }\n }\n\n if (!receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream ended before emitting a header.\",\n );\n }\n return { nodes: nodeCount, edges: edgeCount };\n}\n\n/**\n * Atomically imports a header-first stream into a fresh, dedicated database.\n *\n * This is an intentionally trusted path. It checks stream ordering and kind\n * names, but it does not validate properties, references, cardinality, or\n * conflicts. The caller must guarantee those invariants. Use\n * {@link importGraphStream} for untrusted data.\n *\n * Trusted of the DATA, not of the connection: this holds ONE write transaction\n * open for the entire stream, which makes it a long-lived import holder exactly\n * like {@link importGraphStream}, and it is guarded the same way — the source\n * stream's own backend is checked against the target before the first chunk, and\n * the target connection's exclusive stream lease is held for the whole import.\n * `trustedImportGraphStream(target, exportGraphStream(source))` over one\n * serialized connection is therefore refused with the shared typed\n * {@link ConfigurationError} (codes and `details.heldBy` / `details.requested`\n * as documented on `importGraphStream`) rather than reaching the driver as a\n * nested BEGIN.\n */\nexport async function trustedImportGraphStream<G extends GraphDef>(\n store: Store<G>,\n chunks:\n AsyncIterable<GraphInterchangeChunk> | Iterable<GraphInterchangeChunk>,\n): Promise<TrustedImportResult> {\n rejectUnsupportedStoreFeatures(store);\n const backend = storeBackend(store);\n const trustedImport = backend.trustedImport;\n if (trustedImport === undefined) {\n throw new TrustedImportError(\n `The ${backend.dialect} backend does not support trusted import.`,\n \"backend_unsupported\",\n { dialect: backend.dialect },\n );\n }\n // The same pre-flight `importGraphStream` runs, through the same owner of\n // \"would this export hold the connection that write needs\": a synchronous\n // iterable was materialized by its producer and holds nothing, so only an\n // async stream can name a source backend.\n const sourceBackend =\n Symbol.asyncIterator in chunks ? exportStreamBackend(chunks) : undefined;\n const contention =\n sourceBackend === undefined ? undefined : (\n snapshotExportContention(sourceBackend, backend)\n );\n if (contention !== undefined) {\n throw serializedStreamRefusal({\n graphId: store.graphId,\n requested: \"import-stream\",\n heldBy: \"export-snapshot\",\n detector: contention,\n });\n }\n const schemaVersion = store.introspect().schemaVersion;\n const options: TrustedImportOptions | undefined =\n schemaVersion === undefined ? undefined : (\n {\n schemaWrite: {\n graphId: store.graphId,\n expectedVersion: schemaVersion,\n },\n }\n );\n return withImportStreamLease(store, () =>\n trustedImport(\n (session) => consumeTrustedChunks(store, session, chunks),\n options,\n ),\n );\n}\n\nfunction* graphDataChunks(data: GraphData): Iterable<GraphInterchangeChunk> {\n const { nodes, edges, identity, ...header } = data;\n yield {\n type: \"header\",\n header:\n identity === undefined ? header : (\n {\n ...header,\n identity: { profile: identity.profile, mode: identity.mode },\n }\n ),\n };\n yield { type: \"nodes\", nodes };\n yield { type: \"edges\", edges };\n if (identity !== undefined) {\n yield { type: \"identity\", assertions: identity.assertions };\n }\n}\n\n/** In-memory convenience wrapper around {@link trustedImportGraphStream}. */\nexport function trustedImportGraph<G extends GraphDef>(\n store: Store<G>,\n data: GraphData,\n): Promise<TrustedImportResult> {\n return trustedImportGraphStream(store, graphDataChunks(data));\n}\n"]}
1
+ {"version":3,"sources":["../src/interchange/trusted-import.ts"],"names":[],"mappings":";;;;;;;;;;AAgCA,SAAS,+BACP,KAAA,EACM;AACN,EAAA,MAAM,OAAA,GAAU,aAAa,KAAK,CAAA;AAClC,EAAA,KAAA,MAAW,CAAC,MAAM,YAAY,CAAA,IAAK,OAAO,OAAA,CAAQ,KAAA,CAAM,KAAA,CAAM,KAAK,CAAA,EAAG;AACpE,IAAA,qCAAA;AAAA,MACE,YAAA,CAAa,aAAA;AAAA,MACb,OAAA,CAAQ,YAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,IAAI,mBAAA,CAAoB,KAAK,CAAA,EAAG;AAO9B,IAAA,MAAM,IAAI,kBAAA;AAAA,MACR,gEAAA;AAAA,MACA,qBAAA;AAAA,MACA,EAAE,OAAA,EAAS,KAAA,CAAM,OAAA;AAAQ,KAC3B;AAAA,EACF;AACA,EAAA,IAAI,MAAM,uB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AAkD;AAC1E,EAAA,MAAM,EAAE,KAAA,EAAO,KAAA,EAAO,QAAA,EAAU,GAAG,QAAO,GAAI,IAAA;AAC9C,EAAA,MAAM;AAAA,IACJ,IAAA,EAAM,QAAA;AAAA,IACN,MAAA,EACE,QAAA,KAAa,MAAA,GAAY,MAAA,GACvB;AAAA,MACE,GAAG,MAAA;AAAA,MACH,UAAU,EAAE,OAAA,EAAS,SAAS,OAAA,EAAS,IAAA,EAAM,SAAS,IAAA;AAAK;AAC7D,GAEN;AACA,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAM;AAC7B,EAAA,MAAM,EAAE,IAAA,EAAM,OAAA,EAAS,KAAA,EAAM;AAC7B,EAAA,IAAI,aAAa,MAAA,EAAW;AAC1B,IAAA,MAAM,EAAE,IAAA,EAAM,UAAA,EAAY,UAAA,EAAY,SAAS,UAAA,EAAW;AAAA,EAC5D;AACF;AAGO,SAAS,kBAAA,CACd,OACA,IAAA,EAC8B;AAC9B,EAAA,OAAO,wBAAA,CAAyB,KAAA,EAAO,eAAA,CAAgB,IAAI,CAAC,CAAA;AAC9D","file":"chunk-TI2O2U4G.js","sourcesContent":["import { assertEdgeMatchIdentityBackendSupport } from \"../backend/edge-match-identity\";\nimport { snapshotExportContention } from \"../backend/transaction-resource\";\nimport type {\n InsertEdgeParams,\n InsertNodeParams,\n TrustedImportOptions,\n TrustedImportSession,\n} from \"../backend/types\";\nimport type { GraphDef } from \"../core/define-graph\";\nimport { resolveGraphVectorSlots } from \"../core/embedding\";\nimport { getSearchableFields } from \"../core/searchable\";\nimport type { EdgeRegistration } from \"../core/types\";\nimport { TrustedImportError } from \"../errors\";\nimport { resolveEdgeMatchIdentityStorage } from \"../store/edge-match-key\";\nimport { storeBackend, storeCaptureEnabled } from \"../store/runtime-port\";\nimport type { Store } from \"../store/store\";\nimport { isCanonicalIsoDate, isInvertedValidityWindow } from \"../utils/date\";\nimport { serializedStreamRefusal, withImportStreamLease } from \"./import\";\nimport { exportStreamBackend } from \"./stream-source\";\nimport type {\n GraphData,\n GraphInterchangeChunk,\n InterchangeEdge,\n InterchangeNode,\n} from \"./types\";\n\n/** Counts committed by a trusted initial import. */\nexport type TrustedImportResult = Readonly<{\n nodes: number;\n edges: number;\n}>;\n\nfunction rejectUnsupportedStoreFeatures<G extends GraphDef>(\n store: Store<G>,\n): void {\n const backend = storeBackend(store);\n for (const [kind, registration] of Object.entries(store.graph.edges)) {\n assertEdgeMatchIdentityBackendSupport(\n registration.matchIdentity,\n backend.capabilities,\n kind,\n );\n }\n if (storeCaptureEnabled(store)) {\n // Trusted import writes rows directly, bypassing the node/edge-\n // operations layer that TypeGraph's own capture uses to populate the\n // recorded relations — a check against `storeCaptureEnabled`, not the\n // public `historyEnabled` getter, so an engine-native `history: true`\n // store (whose engine versions every write to the live table itself,\n // regardless of which code path produced it) is unaffected.\n throw new TrustedImportError(\n \"Trusted import does not support recorded-time history capture.\",\n \"history_unsupported\",\n { graphId: store.graphId },\n );\n }\n if (store.revisionTrackingEnabled) {\n throw new TrustedImportError(\n \"Trusted import does not support revision tracking.\",\n \"revision_tracking_unsupported\",\n { graphId: store.graphId },\n );\n }\n if (store.graph.identity !== undefined) {\n throw new TrustedImportError(\n \"Trusted import does not maintain Operational Identity assertions or closure.\",\n \"identity_unsupported\",\n { graphId: store.graphId },\n );\n }\n\n const uniqueKinds = Object.values(store.graph.nodes)\n .filter((registration) => (registration.unique?.length ?? 0) > 0)\n .map((registration) => registration.type.kind);\n if (uniqueKinds.length > 0) {\n throw new TrustedImportError(\n \"Trusted import does not maintain node uniqueness sidecars.\",\n \"uniqueness_unsupported\",\n { graphId: store.graphId, nodeKinds: uniqueKinds },\n );\n }\n\n const searchableKinds = Object.values(store.graph.nodes)\n .filter(\n (registration) =>\n getSearchableFields(registration.type.schema).length > 0,\n )\n .map((registration) => registration.type.kind);\n if (searchableKinds.length > 0) {\n throw new TrustedImportError(\n \"Trusted import does not maintain fulltext sidecars.\",\n \"fulltext_unsupported\",\n { graphId: store.graphId, nodeKinds: searchableKinds },\n );\n }\n\n const vectorSlots = resolveGraphVectorSlots(store.graph);\n if (vectorSlots.length > 0) {\n throw new TrustedImportError(\n \"Trusted import does not maintain vector sidecars.\",\n \"vector_unsupported\",\n {\n graphId: store.graphId,\n fields: vectorSlots.map((slot) => `${slot.nodeKind}.${slot.fieldPath}`),\n },\n );\n }\n}\n\nfunction invalidStream(message: string): TrustedImportError {\n return new TrustedImportError(message, \"invalid_stream\");\n}\n\n/** The stated validity window of a streamed node or edge. */\ntype StatedValidityWindow = Readonly<{\n validFrom?: string | null | undefined;\n validTo?: string | undefined;\n}>;\n\ntype ValidityWindowField = \"validFrom\" | \"validTo\";\n\n/** A stated window field that is not canonical, with the offending value. */\ntype NonCanonicalWindow = Readonly<{\n field: ValidityWindowField;\n value: string;\n}>;\n\n/**\n * The first window field of `entity` stating a timestamp that is not canonical\n * fixed-width UTC ISO 8601 — with the offending value — or `undefined` when\n * every stated one is canonical.\n *\n * A trusted stream is never re-parsed, so this is the only place its timestamps\n * are held to the format the rest of the system assumes. It is deliberately\n * format-ONLY — the same {@link isCanonicalIsoDate} decision the untrusted\n * path's schema and the store's own write validation make, and nothing more —\n * because a non-canonical instant is not merely ugly: every temporal filter\n * compares these values AS TEXT against an `asOf` coordinate, so a variable-width\n * one (`...:00.1Z`, an offset, date-only) mis-sorts and silently includes or\n * excludes the wrong rows once stored, and it would mis-decide the negative-width\n * check below on the way in. Two field tests per row costs about a microsecond\n * against the ~4µs an in-memory SQLite row already costs — the price of the\n * stream's ordering claims meaning anything.\n *\n * An absent field states nothing, and a `null` validFrom is a confirmed\n * open-left window (see {@link nodeParams}) — neither is a timestamp to check.\n */\nfunction nonCanonicalWindowOf(\n entity: StatedValidityWindow,\n): NonCanonicalWindow | undefined {\n const { validFrom, validTo } = entity;\n if (typeof validFrom === \"string\" && !isCanonicalIsoDate(validFrom)) {\n return { field: \"validFrom\", value: validFrom };\n }\n if (typeof validTo === \"string\" && !isCanonicalIsoDate(validTo)) {\n return { field: \"validTo\", value: validTo };\n }\n return undefined;\n}\n\n/**\n * The first entity in `entities` stating a non-canonical window timestamp, with\n * the offending field and value. Allocates only on the failing path, so a clean\n * chunk pays one predicate per stated timestamp and nothing else.\n */\nfunction findNonCanonicalWindow<Entity extends StatedValidityWindow>(\n entities: readonly Entity[],\n): (NonCanonicalWindow & Readonly<{ entity: Entity }>) | undefined {\n for (const entity of entities) {\n const nonCanonical = nonCanonicalWindowOf(entity);\n if (nonCanonical !== undefined) return { entity, ...nonCanonical };\n }\n return undefined;\n}\n\n/** The refusal message for a non-canonical window timestamp on `subject`. */\nfunction nonCanonicalWindowMessage(\n subject: string,\n field: ValidityWindowField,\n value: string,\n): string {\n return (\n `Non-canonical ${field} in trusted import: ${subject} states \"${value}\". ` +\n `Expected canonical fixed-width UTC ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ), ` +\n `which is what makes a stored timestamp sort chronologically against an asOf ` +\n `coordinate. Convert with new Date(value).toISOString().`\n );\n}\n\n/**\n * An entity whose stated window has negative width. Trusted import writes\n * straight to SQL and skips schema validation for throughput, but a row that\n * stopped being true before it started is a stream SHAPE fault rather than a\n * policy check: it is unobservable at every `asOf` coordinate, and no later\n * write repairs it. `null` validFrom is a confirmed open-left window, so there\n * is no lower bound to invert against; zero width is legal (see\n * {@link isInvertedValidityWindow}).\n *\n * Only ever reached for a chunk whose timestamps {@link findNonCanonicalWindow}\n * has already accepted, which is what makes the lexicographic compare inside a\n * chronological one.\n */\nfunction hasInvertedWindow(entity: StatedValidityWindow): boolean {\n return isInvertedValidityWindow(\n entity.validFrom ?? undefined,\n entity.validTo,\n );\n}\n\nfunction nodeParams(graphId: string, node: InterchangeNode): InsertNodeParams {\n return {\n graphId,\n kind: node.kind,\n id: node.id,\n props: node.properties,\n ...(node.validFrom === undefined ? {} : { validFrom: node.validFrom }),\n ...(node.validTo === undefined ? {} : { validTo: node.validTo }),\n };\n}\n\nfunction edgeParams(\n graphId: string,\n edge: InterchangeEdge,\n registration: EdgeRegistration,\n): InsertEdgeParams {\n const matchIdentity = resolveEdgeMatchIdentityStorage(\n registration.matchIdentity,\n {\n fromKind: edge.from.kind,\n fromId: edge.from.id,\n toKind: edge.to.kind,\n toId: edge.to.id,\n props: edge.properties,\n },\n { graphId, edgeKind: edge.kind },\n );\n return {\n graphId,\n id: edge.id,\n kind: edge.kind,\n fromKind: edge.from.kind,\n fromId: edge.from.id,\n toKind: edge.to.kind,\n toId: edge.to.id,\n props: edge.properties,\n ...(matchIdentity === undefined ? {} : { matchIdentity }),\n ...(edge.validFrom === undefined ? {} : { validFrom: edge.validFrom }),\n ...(edge.validTo === undefined ? {} : { validTo: edge.validTo }),\n };\n}\n\nasync function consumeTrustedChunks<G extends GraphDef>(\n store: Store<G>,\n session: TrustedImportSession,\n chunks:\n AsyncIterable<GraphInterchangeChunk> | Iterable<GraphInterchangeChunk>,\n): Promise<TrustedImportResult> {\n const nodeKinds = new Set(\n Object.values(store.graph.nodes).map(\n (registration) => registration.type.kind,\n ),\n );\n const edgeKinds = new Set(\n Object.values(store.graph.edges).map(\n (registration) => registration.type.kind,\n ),\n );\n let receivedHeader = false;\n let receivedEdges = false;\n let nodeCount = 0;\n let edgeCount = 0;\n\n for await (const chunk of chunks) {\n switch (chunk.type) {\n case \"header\": {\n if (receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream emitted more than one header.\",\n );\n }\n if (chunk.header.identity !== undefined) {\n throw invalidStream(\n \"Trusted graph interchange import does not support identity data. \" +\n \"Use importGraphStream() for an identity export.\",\n );\n }\n receivedHeader = true;\n break;\n }\n case \"nodes\": {\n if (!receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream must start with a header.\",\n );\n }\n if (receivedEdges) {\n throw invalidStream(\n \"Trusted graph interchange stream cannot emit nodes after edges.\",\n );\n }\n const unknownKind = chunk.nodes.find(\n (node) => !nodeKinds.has(node.kind),\n )?.kind;\n if (unknownKind !== undefined) {\n throw invalidStream(\n `Unknown node kind in trusted import: ${unknownKind}`,\n );\n }\n const nonCanonicalNode = findNonCanonicalWindow(chunk.nodes);\n if (nonCanonicalNode !== undefined) {\n const { entity, field, value } = nonCanonicalNode;\n throw invalidStream(\n nonCanonicalWindowMessage(\n `${entity.kind} \"${entity.id}\"`,\n field,\n value,\n ),\n );\n }\n const invertedNode = chunk.nodes.find((node) =>\n hasInvertedWindow(node),\n );\n if (invertedNode !== undefined) {\n throw invalidStream(\n `Inverted validity window in trusted import: ${invertedNode.kind} \"${invertedNode.id}\" ends at ` +\n `\"${String(invertedNode.validTo)}\", before its validFrom \"${String(invertedNode.validFrom)}\".`,\n );\n }\n await session.insertNodes(\n chunk.nodes.map((node) => nodeParams(store.graphId, node)),\n );\n nodeCount += chunk.nodes.length;\n break;\n }\n case \"edges\": {\n if (!receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream must start with a header.\",\n );\n }\n receivedEdges = true;\n const invalidEdge = chunk.edges.find(\n (edge) =>\n !edgeKinds.has(edge.kind) ||\n !nodeKinds.has(edge.from.kind) ||\n !nodeKinds.has(edge.to.kind),\n );\n if (invalidEdge !== undefined) {\n throw invalidStream(\n `Unknown edge or endpoint kind in trusted import: ${invalidEdge.kind}`,\n );\n }\n const nonCanonicalEdge = findNonCanonicalWindow(chunk.edges);\n if (nonCanonicalEdge !== undefined) {\n const { entity, field, value } = nonCanonicalEdge;\n throw invalidStream(\n nonCanonicalWindowMessage(\n `${entity.kind} edge \"${entity.id}\"`,\n field,\n value,\n ),\n );\n }\n const invertedEdge = chunk.edges.find((edge) =>\n hasInvertedWindow(edge),\n );\n if (invertedEdge !== undefined) {\n throw invalidStream(\n `Inverted validity window in trusted import: ${invertedEdge.kind} edge \"${invertedEdge.id}\" ends at ` +\n `\"${String(invertedEdge.validTo)}\", before its validFrom \"${String(invertedEdge.validFrom)}\".`,\n );\n }\n await session.insertEdges(\n chunk.edges.map((edge) =>\n edgeParams(\n store.graphId,\n edge,\n store.graph.edges[edge.kind] as EdgeRegistration,\n ),\n ),\n );\n edgeCount += chunk.edges.length;\n break;\n }\n case \"identity\": {\n // The trusted session writes only the node and edge relations, so it\n // has no way to persist assertions or materialize the derived closure.\n // Refuse rather than drop identity truth from an identity-enabled\n // export: `importGraph` / `importGraphStream` carry it correctly.\n throw invalidStream(\n \"Trusted graph interchange import does not support identity assertions. \" +\n \"Use importGraphStream() for an export that carries identity truth.\",\n );\n }\n }\n }\n\n if (!receivedHeader) {\n throw invalidStream(\n \"Trusted graph interchange stream ended before emitting a header.\",\n );\n }\n return { nodes: nodeCount, edges: edgeCount };\n}\n\n/**\n * Atomically imports a header-first stream into a fresh, dedicated database.\n *\n * This is an intentionally trusted path. It checks stream ordering and kind\n * names, but it does not validate properties, references, cardinality, or\n * conflicts. The caller must guarantee those invariants. Use\n * {@link importGraphStream} for untrusted data.\n *\n * Trusted of the DATA, not of the connection: this holds ONE write transaction\n * open for the entire stream, which makes it a long-lived import holder exactly\n * like {@link importGraphStream}, and it is guarded the same way — the source\n * stream's own backend is checked against the target before the first chunk, and\n * the target connection's exclusive stream lease is held for the whole import.\n * `trustedImportGraphStream(target, exportGraphStream(source))` over one\n * serialized connection is therefore refused with the shared typed\n * {@link ConfigurationError} (codes and `details.heldBy` / `details.requested`\n * as documented on `importGraphStream`) rather than reaching the driver as a\n * nested BEGIN.\n */\nexport async function trustedImportGraphStream<G extends GraphDef>(\n store: Store<G>,\n chunks:\n AsyncIterable<GraphInterchangeChunk> | Iterable<GraphInterchangeChunk>,\n): Promise<TrustedImportResult> {\n rejectUnsupportedStoreFeatures(store);\n const backend = storeBackend(store);\n const trustedImport = backend.trustedImport;\n if (trustedImport === undefined) {\n throw new TrustedImportError(\n `The ${backend.dialect} backend does not support trusted import.`,\n \"backend_unsupported\",\n { dialect: backend.dialect },\n );\n }\n // The same pre-flight `importGraphStream` runs, through the same owner of\n // \"would this export hold the connection that write needs\": a synchronous\n // iterable was materialized by its producer and holds nothing, so only an\n // async stream can name a source backend.\n const sourceBackend =\n Symbol.asyncIterator in chunks ? exportStreamBackend(chunks) : undefined;\n const contention =\n sourceBackend === undefined ? undefined : (\n snapshotExportContention(sourceBackend, backend)\n );\n if (contention !== undefined) {\n throw serializedStreamRefusal({\n graphId: store.graphId,\n requested: \"import-stream\",\n heldBy: \"export-snapshot\",\n detector: contention,\n });\n }\n const schemaVersion = store.introspect().schemaVersion;\n const options: TrustedImportOptions | undefined =\n schemaVersion === undefined ? undefined : (\n {\n schemaWrite: {\n graphId: store.graphId,\n expectedVersion: schemaVersion,\n },\n }\n );\n return withImportStreamLease(store, () =>\n trustedImport(\n (session) => consumeTrustedChunks(store, session, chunks),\n options,\n ),\n );\n}\n\nfunction* graphDataChunks(data: GraphData): Iterable<GraphInterchangeChunk> {\n const { nodes, edges, identity, ...header } = data;\n yield {\n type: \"header\",\n header:\n identity === undefined ? header : (\n {\n ...header,\n identity: { profile: identity.profile, mode: identity.mode },\n }\n ),\n };\n yield { type: \"nodes\", nodes };\n yield { type: \"edges\", edges };\n if (identity !== undefined) {\n yield { type: \"identity\", assertions: identity.assertions };\n }\n}\n\n/** In-memory convenience wrapper around {@link trustedImportGraphStream}. */\nexport function trustedImportGraph<G extends GraphDef>(\n store: Store<G>,\n data: GraphData,\n): Promise<TrustedImportResult> {\n return trustedImportGraphStream(store, graphDataChunks(data));\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { createStoreWithSchema, createStore } from './chunk-NMLLXBGF.js';
2
- import { importGraphStream, exportGraphStream, importGraph, exportGraph, summarizeImportErrors } from './chunk-ORTKLAAU.js';
1
+ import { createStoreWithSchema, createStore } from './chunk-XIFBU27X.js';
2
+ import { importGraphStream, exportGraphStream, importGraph, exportGraph, summarizeImportErrors } from './chunk-LJG2TYCN.js';
3
3
  import { normalizeIdentityPair, identityReferenceKey, identityValidityWindowsOverlap, identityAssertionSemanticKey } from './chunk-XD54DLIG.js';
4
4
  import { storeBackend, storeRuntime, hasScopedIdentityReads, mintsOriginNamespacedAnchor, storeCaptureEnabled, readRevisionOrigin, recordedRelationsLineage, encodeRecordedLineageRevision, generateId, resolveLineage, getNodeRowsByIds, getEdgeRowsByIds, readRecordedClock, ensureRevisionOriginRow, ensureRevisionOrigin } from './chunk-EUHKGM2J.js';
5
5
  import { recordedRevisionOriginsVerdict, batchPointReadVerdict } from './chunk-SASYH2V4.js';
@@ -3015,5 +3015,5 @@ async function closeDurableQuietly(store, access) {
3015
3015
  }
3016
3016
 
3017
3017
  export { BaseVersionMismatchError, BranchError, CandidateSourceError, CandidateWriteSetError, DurableEvidenceUndeliveredError, DurableOperationConflictError, DurableOperationError, DurableOperationEvidenceError, DurableOperationRequestError, DurableOperationUnsupportedError, IdentityMergeConflictError, InvalidMergeOptionsError, InvalidMergePlanError, LEGACY_BASE_VERSION_REFUSAL, MERGE_ERROR_CODES, MatchEvidenceError, MergeConflictError, MergeConstraintConflictError, MergeError, MergePlanCapabilityError, MergePlanDigestMismatchError, MergePlanOriginMismatchError, MergePlanSchemaMismatchError, MergePlanTargetMismatchError, MergePlanningStaleError, MergeReviewError, NO_STORED_ASSERTIONS, RETRACTION_DELETION_OVERRULED_DROP_REASON, SimilarityUnavailableError, StaleMergePlanError, UnsupportedMergePlanVersionError, VALIDITY_END_TARGET_PRECEDENCE, asBaseVersion, asBranchId, assertGraphMatchesAttestedOrigin, assertIdentityEndpointsNotDeleted, assertIdentityPeersStable, assertMergedIdentityClassesConsistent, assertNoContradictoryIdentityClosure, assertOneIdOneTruth, assertPlannedIdentityIdsFresh, branch, branchDurable, buildIdentityPeerProbe, canonicalValueKey, canonicalizeProps, cloneIngestionWorkingCopyStrategy, cloneWorkingCopyStrategy, coalescedWorkingCopyClose, compareBaseVersionAtTarget, compareMergeKeys, computeBaseVersion, computeBaseVersionAtTarget, computeSchemaComponent, createGraphEdgeKindReader, createGraphNodeKindReader, describeCause, destroyDurableBranch, diffAgainstBase, durableDescriptorRefusal, durableOriginOfDescriptor, durableOriginsEqual, edgeStateSignature, engineAnchorOf, forkedWorkingCopyStrategy, graphWithoutNodeUniqueness, hasRevisionAnchor, idOf, isLegacyBaseVersion, kindOf, lineageDeltaSinceAnchor, mergeKey, mergeKeyOf, parseRowProps, planIdentityChanges, readActiveSchemaVersion, remapIdentityAssertionEndpoints, reopenDurableBranch, revisionAnchorOf, revisionOriginOf, schemaActiveVersionOf, schemaComponentOf, translateIdentityCommitError, translateMergeCommitError };
3018
- //# sourceMappingURL=chunk-FC7INRDS.js.map
3019
- //# sourceMappingURL=chunk-FC7INRDS.js.map
3018
+ //# sourceMappingURL=chunk-WX7BQELV.js.map
3019
+ //# sourceMappingURL=chunk-WX7BQELV.js.map