@nicia-ai/typegraph 0.31.0 → 0.32.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.
Files changed (125) hide show
  1. package/dist/backend/postgres/index.cjs +16 -16
  2. package/dist/backend/postgres/index.d.cts +5 -5
  3. package/dist/backend/postgres/index.d.ts +5 -5
  4. package/dist/backend/postgres/index.js +6 -6
  5. package/dist/backend/postgres/pglite.cjs +9 -9
  6. package/dist/backend/postgres/pglite.d.cts +2 -2
  7. package/dist/backend/postgres/pglite.d.ts +2 -2
  8. package/dist/backend/postgres/pglite.js +6 -6
  9. package/dist/backend/sqlite/index.cjs +14 -14
  10. package/dist/backend/sqlite/index.d.cts +6 -6
  11. package/dist/backend/sqlite/index.d.ts +6 -6
  12. package/dist/backend/sqlite/index.js +5 -5
  13. package/dist/backend/sqlite/libsql.cjs +10 -10
  14. package/dist/backend/sqlite/libsql.d.cts +2 -2
  15. package/dist/backend/sqlite/libsql.d.ts +2 -2
  16. package/dist/backend/sqlite/libsql.js +6 -6
  17. package/dist/backend/sqlite/local.cjs +10 -10
  18. package/dist/backend/sqlite/local.d.cts +2 -2
  19. package/dist/backend/sqlite/local.d.ts +2 -2
  20. package/dist/backend/sqlite/local.js +6 -6
  21. package/dist/{chunk-XKJQQQVR.js → chunk-2BVHPOIG.js} +3 -3
  22. package/dist/{chunk-XKJQQQVR.js.map → chunk-2BVHPOIG.js.map} +1 -1
  23. package/dist/{chunk-RZ4DH4E7.cjs → chunk-2LAT5BIK.cjs} +662 -217
  24. package/dist/chunk-2LAT5BIK.cjs.map +1 -0
  25. package/dist/{chunk-CIINW6PS.cjs → chunk-3HQDMOBK.cjs} +64 -64
  26. package/dist/{chunk-CIINW6PS.cjs.map → chunk-3HQDMOBK.cjs.map} +1 -1
  27. package/dist/{chunk-6SA7UIQJ.cjs → chunk-3QRBXYT5.cjs} +6 -6
  28. package/dist/{chunk-6SA7UIQJ.cjs.map → chunk-3QRBXYT5.cjs.map} +1 -1
  29. package/dist/{chunk-4A4GUZTQ.js → chunk-7WW3WL6E.js} +5 -5
  30. package/dist/{chunk-4A4GUZTQ.js.map → chunk-7WW3WL6E.js.map} +1 -1
  31. package/dist/{chunk-2HZGWCB4.js → chunk-C4C4Q7A6.js} +3 -3
  32. package/dist/chunk-C4C4Q7A6.js.map +1 -0
  33. package/dist/{chunk-SFFJ2IKN.cjs → chunk-CAMMC3E4.cjs} +58 -58
  34. package/dist/{chunk-SFFJ2IKN.cjs.map → chunk-CAMMC3E4.cjs.map} +1 -1
  35. package/dist/{chunk-O4VUR6SI.js → chunk-CEF2QOTO.js} +3 -3
  36. package/dist/{chunk-O4VUR6SI.js.map → chunk-CEF2QOTO.js.map} +1 -1
  37. package/dist/{chunk-V4IQYOQ4.cjs → chunk-CFNT3ITG.cjs} +3 -3
  38. package/dist/chunk-CFNT3ITG.cjs.map +1 -0
  39. package/dist/{chunk-LJLMDDCW.js → chunk-CWFPJ3RC.js} +3 -3
  40. package/dist/{chunk-LJLMDDCW.js.map → chunk-CWFPJ3RC.js.map} +1 -1
  41. package/dist/{chunk-7JGLPAFV.cjs → chunk-EEYV6UOE.cjs} +16 -16
  42. package/dist/chunk-EEYV6UOE.cjs.map +1 -0
  43. package/dist/{chunk-ASYQDPPU.cjs → chunk-FDN43KXV.cjs} +19 -19
  44. package/dist/{chunk-ASYQDPPU.cjs.map → chunk-FDN43KXV.cjs.map} +1 -1
  45. package/dist/{chunk-THX25XW6.js → chunk-HFBRAOF7.js} +27 -7
  46. package/dist/chunk-HFBRAOF7.js.map +1 -0
  47. package/dist/{chunk-54JVNOAQ.cjs → chunk-JKRKIEVA.cjs} +5 -5
  48. package/dist/{chunk-54JVNOAQ.cjs.map → chunk-JKRKIEVA.cjs.map} +1 -1
  49. package/dist/{chunk-5DTPBFX5.cjs → chunk-LAZGHOZW.cjs} +10 -10
  50. package/dist/{chunk-5DTPBFX5.cjs.map → chunk-LAZGHOZW.cjs.map} +1 -1
  51. package/dist/{chunk-N2MBPTAF.cjs → chunk-LM2IC4ZJ.cjs} +14 -14
  52. package/dist/{chunk-N2MBPTAF.cjs.map → chunk-LM2IC4ZJ.cjs.map} +1 -1
  53. package/dist/{chunk-STP7QVUB.js → chunk-NDM5PXEH.js} +5 -5
  54. package/dist/{chunk-STP7QVUB.js.map → chunk-NDM5PXEH.js.map} +1 -1
  55. package/dist/{chunk-2ZY4K43M.js → chunk-PIHXFF73.js} +3 -3
  56. package/dist/{chunk-2ZY4K43M.js.map → chunk-PIHXFF73.js.map} +1 -1
  57. package/dist/{chunk-ATTXBMAX.js → chunk-PRMKPFN5.js} +3 -3
  58. package/dist/{chunk-ATTXBMAX.js.map → chunk-PRMKPFN5.js.map} +1 -1
  59. package/dist/{chunk-3JBJEYWE.cjs → chunk-SB65GJNY.cjs} +32 -12
  60. package/dist/chunk-SB65GJNY.cjs.map +1 -0
  61. package/dist/{chunk-VZX2KSY3.js → chunk-TUA3MEJJ.js} +5 -5
  62. package/dist/{chunk-VZX2KSY3.js.map → chunk-TUA3MEJJ.js.map} +1 -1
  63. package/dist/{chunk-MAQJYNJR.js → chunk-W4ZX2GCP.js} +14 -16
  64. package/dist/chunk-W4ZX2GCP.js.map +1 -0
  65. package/dist/{chunk-UIFEEPME.js → chunk-WNORITK6.js} +593 -149
  66. package/dist/chunk-WNORITK6.js.map +1 -0
  67. package/dist/{chunk-VMEWZU2N.cjs → chunk-WWVV44DY.cjs} +11 -11
  68. package/dist/{chunk-VMEWZU2N.cjs.map → chunk-WWVV44DY.cjs.map} +1 -1
  69. package/dist/{chunk-UJ4V3YUQ.js → chunk-XKNAK27R.js} +3 -3
  70. package/dist/{chunk-UJ4V3YUQ.js.map → chunk-XKNAK27R.js.map} +1 -1
  71. package/dist/{chunk-GKFWM3DS.js → chunk-XQFAJVYW.js} +3 -3
  72. package/dist/{chunk-GKFWM3DS.js.map → chunk-XQFAJVYW.js.map} +1 -1
  73. package/dist/{chunk-FLOI7QOT.cjs → chunk-YL4F3CMD.cjs} +59 -59
  74. package/dist/{chunk-FLOI7QOT.cjs.map → chunk-YL4F3CMD.cjs.map} +1 -1
  75. package/dist/{chunk-5CN7B4CZ.cjs → chunk-YW7GHMF4.cjs} +17 -17
  76. package/dist/{chunk-5CN7B4CZ.cjs.map → chunk-YW7GHMF4.cjs.map} +1 -1
  77. package/dist/{ddl-BJcPrB4L.d.ts → ddl-C8e8zDAE.d.ts} +3 -3
  78. package/dist/{ddl-CPZ7mB7X.d.cts → ddl-CwyG4HoQ.d.cts} +3 -3
  79. package/dist/graph-merge/index.cjs +193 -49
  80. package/dist/graph-merge/index.cjs.map +1 -1
  81. package/dist/graph-merge/index.d.cts +3 -3
  82. package/dist/graph-merge/index.d.ts +3 -3
  83. package/dist/graph-merge/index.js +180 -36
  84. package/dist/graph-merge/index.js.map +1 -1
  85. package/dist/index.cjs +89 -85
  86. package/dist/index.d.cts +7 -7
  87. package/dist/index.d.ts +7 -7
  88. package/dist/index.js +12 -12
  89. package/dist/indexes/index.cjs +10 -10
  90. package/dist/indexes/index.d.cts +4 -4
  91. package/dist/indexes/index.d.ts +4 -4
  92. package/dist/indexes/index.js +3 -3
  93. package/dist/interchange/index.cjs +15 -15
  94. package/dist/interchange/index.d.cts +7 -7
  95. package/dist/interchange/index.d.ts +7 -7
  96. package/dist/interchange/index.js +2 -2
  97. package/dist/{manager-By-WEd8M.d.ts → manager-8htmuGr-.d.ts} +1 -1
  98. package/dist/{manager-Np7VVSlE.d.cts → manager-aVgxbGt-.d.cts} +1 -1
  99. package/dist/{postgres-BdIb7tS_.d.ts → postgres-Dhom7iiX.d.ts} +1 -1
  100. package/dist/{postgres-4J2tmauh.d.cts → postgres-jgXmD45C.d.cts} +1 -1
  101. package/dist/profiler/index.d.cts +5 -5
  102. package/dist/profiler/index.d.ts +5 -5
  103. package/dist/schema/index.cjs +26 -26
  104. package/dist/schema/index.d.cts +4 -4
  105. package/dist/schema/index.d.ts +4 -4
  106. package/dist/schema/index.js +3 -3
  107. package/dist/{sqlite-aM_PAz-O.d.ts → sqlite-BfLsCEqO.d.ts} +1 -1
  108. package/dist/{sqlite-Gatk_iw_.d.cts → sqlite-DcQ_BCUW.d.cts} +1 -1
  109. package/dist/{store-DuCbdqsh.d.cts → store-view-lTcb_cnp.d.cts} +639 -311
  110. package/dist/{store-MloRPwb9.d.ts → store-view-pBOUrQte.d.ts} +639 -311
  111. package/dist/{types-DoByHGyU.d.cts → types-5RQwzWXx.d.cts} +1 -1
  112. package/dist/{types-K3vpaJAL.d.ts → types-DGDiXAYc.d.ts} +1 -1
  113. package/dist/{types-BKQljXom.d.ts → types-Dk8r09KY.d.ts} +1 -1
  114. package/dist/{types-C1CYxWrL.d.cts → types-Dvmn-eal.d.cts} +1 -1
  115. package/dist/{where-Dt49bvo6.d.ts → where-CHZFELX0.d.ts} +1 -1
  116. package/dist/{where-DydZjGOb.d.cts → where-Cx_glEEB.d.cts} +1 -1
  117. package/package.json +2 -2
  118. package/dist/chunk-2HZGWCB4.js.map +0 -1
  119. package/dist/chunk-3JBJEYWE.cjs.map +0 -1
  120. package/dist/chunk-7JGLPAFV.cjs.map +0 -1
  121. package/dist/chunk-MAQJYNJR.js.map +0 -1
  122. package/dist/chunk-RZ4DH4E7.cjs.map +0 -1
  123. package/dist/chunk-THX25XW6.js.map +0 -1
  124. package/dist/chunk-UIFEEPME.js.map +0 -1
  125. package/dist/chunk-V4IQYOQ4.cjs.map +0 -1
@@ -1,7 +1,7 @@
1
+ import { K as KindRegistry, G as GraphDef, w as EdgeKinds, t as NodeKinds, v as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-8htmuGr-.js';
2
+ import { T as TemporalMode, A as AnyEdgeType, N as NodeType, g as EdgeType, E as EdgeRegistration, e as EdgeId, d as NodeId, b as NodeRegistration, K as KindEntity, m as Cardinality, n as EndpointExistence, f as KindAnnotations, U as UniquenessScope, C as Collation, G as GraphExtension } from './extension-types-D1k0inWU.js';
1
3
  import { z } from 'zod';
2
- import { aA as ValueType, aB as PredicateExpression, aC as VectorMetricType, a1 as FulltextQueryMode, Q as QueryAst, J as JsonPointer, P as FieldRef, ad as ParameterRef, G as GraphBackend, am as TransactionBackend, a6 as JsonPointerInput, an as TraversalExpansion, p as SqlDialect, ai as SqlSchema, aD as Traversal, aE as NodePredicate, aF as ProjectedField, ac as OrderSpec, aG as GroupBySpec, a4 as HybridFusionOptions, aH as RecursiveCyclePolicy, aI as TraversalDirection$1, aJ as EdgeRow, aK as NodeRow, W as AdoptedTransaction, L as AggregateExpr, F as FulltextStrategy, V as VectorStrategy, aL as VectorSlotMap, aM as SelectiveField, aN as ComposableQuery, aO as SetOperationType, aP as SetOperation, ah as SortDirection, m as JsonSchema, aQ as VectorMetric } from './types-BKQljXom.js';
3
- import { K as KindRegistry, G as GraphDef, w as EdgeKinds, t as NodeKinds, v as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-By-WEd8M.js';
4
- import { A as AnyEdgeType, N as NodeType, T as TemporalMode, g as EdgeType, E as EdgeRegistration, e as EdgeId, d as NodeId, b as NodeRegistration, K as KindEntity, m as Cardinality, n as EndpointExistence, f as KindAnnotations, U as UniquenessScope, C as Collation, G as GraphExtension } from './extension-types-D1k0inWU.js';
4
+ import { aA as ValueType, aB as PredicateExpression, aC as VectorMetricType, a1 as FulltextQueryMode, Q as QueryAst, J as JsonPointer, P as FieldRef, ad as ParameterRef, G as GraphBackend, am as TransactionBackend, a6 as JsonPointerInput, an as TraversalExpansion, p as SqlDialect, ai as SqlSchema, aD as Traversal, aE as NodePredicate, aF as ProjectedField, ac as OrderSpec, aG as GroupBySpec, a4 as HybridFusionOptions, aH as RecursiveCyclePolicy, aI as TraversalDirection$1, aJ as EdgeRow, aK as NodeRow, W as AdoptedTransaction, L as AggregateExpr, F as FulltextStrategy, V as VectorStrategy, aL as VectorSlotMap, aM as SelectiveField, aN as ComposableQuery, aO as SetOperationType, aP as SetOperation, ah as SortDirection, aQ as VectorMetric, m as JsonSchema, aR as TransactionOptions } from './types-Dk8r09KY.js';
5
5
  import { SQL } from 'drizzle-orm';
6
6
  import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-CAGhqPHQ.js';
7
7
 
@@ -216,6 +216,25 @@ declare function searchable(options?: SearchableOptions): SearchableSchema;
216
216
  declare function isSearchableSchema(value: unknown): value is SearchableSchema;
217
217
  declare function getSearchableMetadata(schema: z.ZodType): SearchableMetadata | undefined;
218
218
 
219
+ /**
220
+ * The single opaque temporal coordinate every pinned read is resolved
221
+ * against. Today it carries only the valid-time axis; Unit 2 adds a sibling
222
+ * `recorded` axis here, and because every surface injects the coordinate
223
+ * through one helper ({@link withCoordinate}), a new axis lands on all
224
+ * surfaces at once instead of splitting by surface.
225
+ */
226
+ type ReadCoordinate = Readonly<{
227
+ /**
228
+ * The valid-time axis: a resolved temporal mode and (only for `"asOf"`) the
229
+ * instant it is pinned to.
230
+ */
231
+ valid: Readonly<{
232
+ mode: TemporalMode;
233
+ /** Defined only when `mode` is `"asOf"`. */
234
+ asOf?: string;
235
+ }>;
236
+ }>;
237
+
219
238
  type FieldTypeInfo = Readonly<{
220
239
  valueType: ValueType;
221
240
  elementType?: ValueType | undefined;
@@ -843,6 +862,12 @@ type QueryBuilderConfig = Readonly<{
843
862
  dialect?: SqlDialect;
844
863
  /** SQL schema configuration for custom table names. */
845
864
  schema?: SqlSchema;
865
+ /**
866
+ * When set, the builder is pinned to a {@link StoreView}'s coordinate and
867
+ * its temporal axis is sealed: `.temporal(...)` throws. Threaded verbatim
868
+ * through every builder clone, so the seal survives the whole fluent chain.
869
+ */
870
+ sealedCoordinate?: ReadCoordinate;
846
871
  }>;
847
872
  /**
848
873
  * Internal state of the query builder.
@@ -885,6 +910,12 @@ type CreateQueryBuilderOptions = Readonly<{
885
910
  schema?: SqlSchema;
886
911
  /** Default traversal ontology expansion mode (default: "inverse"). */
887
912
  defaultTraversalExpansion?: TraversalExpansion;
913
+ /**
914
+ * Pin the builder to a {@link StoreView} coordinate and seal its temporal
915
+ * axis. Seeds the initial `temporalMode` / `asOf` and makes `.temporal(...)`
916
+ * throw. Used by `store.view(...).query()`.
917
+ */
918
+ sealedCoordinate?: ReadCoordinate;
888
919
  }>;
889
920
 
890
921
  /**
@@ -1174,7 +1205,7 @@ type EdgeGetOrCreateByEndpointsResult<E extends AnyEdgeType, From extends NodeTy
1174
1205
  type EdgeFindByEndpointsOptions<E extends AnyEdgeType> = Readonly<{
1175
1206
  /**
1176
1207
  * Edge property fields to include in the match alongside the (from, to) endpoints.
1177
- * When omitted, matches on endpoints only (returns first live edge).
1208
+ * When omitted, matches on endpoints only (returns the first edge at the read coordinate).
1178
1209
  */
1179
1210
  matchOn?: readonly (keyof z.input<E["schema"]>)[];
1180
1211
  /** Property values to match against when matchOn is specified. */
@@ -1232,15 +1263,13 @@ type NodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
1232
1263
  * Supports predicate filtering via the `where` option for SQL-level filtering.
1233
1264
  * For simple queries. Use store.query() for complex traversals.
1234
1265
  */
1235
- find: (options?: Readonly<{
1266
+ find: (filter?: Readonly<{
1236
1267
  where?: (accessor: NodeAccessor<N>) => Predicate;
1237
1268
  limit?: number;
1238
1269
  offset?: number;
1239
- temporalMode?: TemporalMode;
1240
- asOf?: string;
1241
- }>) => Promise<Node<N>[]>;
1270
+ }>, temporal?: QueryOptions) => Promise<Node<N>[]>;
1242
1271
  /** Count nodes matching criteria */
1243
- count: (options?: QueryOptions) => Promise<number>;
1272
+ count: (temporal?: QueryOptions) => Promise<number>;
1244
1273
  /**
1245
1274
  * Create a node from untyped data, relying on runtime Zod validation.
1246
1275
  *
@@ -1451,29 +1480,43 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
1451
1480
  update: (id: EdgeId<E>, props: Partial<z.input<E["schema"]>>, options?: Readonly<{
1452
1481
  validTo?: string;
1453
1482
  }>) => Promise<Edge<E, From, To>>;
1454
- /** Find edges from a specific node */
1455
- findFrom: (from: NodeRef<From>) => Promise<Edge<E, From, To>[]>;
1456
- /** Find edges to a specific node */
1457
- findTo: (to: NodeRef<To>) => Promise<Edge<E, From, To>[]>;
1483
+ /**
1484
+ * Find edges from a specific node.
1485
+ *
1486
+ * Honors the same temporal model as `getById` / `find`: with no
1487
+ * `options`, the graph's default `temporalMode` applies (excluding
1488
+ * soft-deleted edges and, in `current` / `asOf` modes, edges outside
1489
+ * their validity window). Pass `temporalMode` / `asOf` to read the
1490
+ * endpoint's edges at another temporal coordinate.
1491
+ */
1492
+ findFrom: (from: NodeRef<From>, options?: QueryOptions) => Promise<Edge<E, From, To>[]>;
1493
+ /**
1494
+ * Find edges to a specific node.
1495
+ *
1496
+ * Temporal semantics mirror {@link EdgeCollection.findFrom}.
1497
+ */
1498
+ findTo: (to: NodeRef<To>, options?: QueryOptions) => Promise<Edge<E, From, To>[]>;
1458
1499
  /**
1459
1500
  * Deferred variant of `findFrom` for use with `store.batch()`.
1460
1501
  *
1461
- * Returns a `BatchableQuery` instead of executing immediately.
1502
+ * Returns a `BatchableQuery` instead of executing immediately. Accepts
1503
+ * the same temporal `options` as {@link EdgeCollection.findFrom}.
1462
1504
  */
1463
- batchFindFrom: (from: NodeRef<From>) => BatchableQuery<Edge<E, From, To>>;
1505
+ batchFindFrom: (from: NodeRef<From>, options?: QueryOptions) => BatchableQuery<Edge<E, From, To>>;
1464
1506
  /**
1465
1507
  * Deferred variant of `findTo` for use with `store.batch()`.
1466
1508
  *
1467
- * Returns a `BatchableQuery` instead of executing immediately.
1509
+ * Returns a `BatchableQuery` instead of executing immediately. Accepts
1510
+ * the same temporal `options` as {@link EdgeCollection.findTo}.
1468
1511
  */
1469
- batchFindTo: (to: NodeRef<To>) => BatchableQuery<Edge<E, From, To>>;
1512
+ batchFindTo: (to: NodeRef<To>, options?: QueryOptions) => BatchableQuery<Edge<E, From, To>>;
1470
1513
  /**
1471
1514
  * Deferred variant of `findByEndpoints` for use with `store.batch()`.
1472
1515
  *
1473
1516
  * Returns a `BatchableQuery` that yields a 0-or-1 element array
1474
1517
  * (matching `findByEndpoints`' at-most-one semantics).
1475
1518
  */
1476
- batchFindByEndpoints: (from: NodeRef<From>, to: NodeRef<To>, options?: EdgeFindByEndpointsOptions<E>) => BatchableQuery<Edge<E, From, To>>;
1519
+ batchFindByEndpoints: (from: NodeRef<From>, to: NodeRef<To>, options?: EdgeFindByEndpointsOptions<E>, temporal?: QueryOptions) => BatchableQuery<Edge<E, From, To>>;
1477
1520
  /** Delete an edge (soft delete - sets deletedAt timestamp) */
1478
1521
  delete: (id: EdgeId<E>) => Promise<void>;
1479
1522
  /**
@@ -1487,21 +1530,17 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
1487
1530
  */
1488
1531
  hardDelete: (id: EdgeId<E>) => Promise<void>;
1489
1532
  /** Find edges matching endpoint and pagination criteria */
1490
- find: (options?: Readonly<{
1533
+ find: (filter?: Readonly<{
1491
1534
  from?: NodeRef<From>;
1492
1535
  to?: NodeRef<To>;
1493
1536
  limit?: number;
1494
1537
  offset?: number;
1495
- temporalMode?: TemporalMode;
1496
- asOf?: string;
1497
- }>) => Promise<Edge<E, From, To>[]>;
1538
+ }>, temporal?: QueryOptions) => Promise<Edge<E, From, To>[]>;
1498
1539
  /** Count edges matching criteria */
1499
- count: (options?: Readonly<{
1540
+ count: (filter?: Readonly<{
1500
1541
  from?: NodeRef<From>;
1501
1542
  to?: NodeRef<To>;
1502
- temporalMode?: TemporalMode;
1503
- asOf?: string;
1504
- }>) => Promise<number>;
1543
+ }>, temporal?: QueryOptions) => Promise<number>;
1505
1544
  /**
1506
1545
  * Create multiple edges in a batch.
1507
1546
  *
@@ -1553,16 +1592,22 @@ type EdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To
1553
1592
  */
1554
1593
  bulkDelete: (ids: readonly EdgeId<E>[]) => Promise<void>;
1555
1594
  /**
1556
- * Find a live edge by endpoints and optional property fields.
1595
+ * Find an edge by endpoints and optional property fields.
1557
1596
  *
1558
- * Returns the first matching live edge, or undefined.
1559
- * Soft-deleted edges are excluded.
1597
+ * Returns the first matching edge at the read coordinate, or undefined.
1598
+ * Honors the temporal model like `findFrom` / `findTo`: by default
1599
+ * (`current` mode) soft-deleted and out-of-window edges are excluded; under
1600
+ * `includeTombstones` a soft-deleted edge can be returned.
1560
1601
  *
1561
1602
  * @param from - Source node
1562
1603
  * @param to - Target node
1563
1604
  * @param options - Match criteria (matchOn fields and property values)
1605
+ * @param temporal - Temporal coordinate. With no `temporal`, the graph's
1606
+ * default `temporalMode` applies (so under the default `"current"` mode,
1607
+ * edges outside their validity window are excluded). Pass
1608
+ * `temporalMode` / `asOf` to read the edge as of another coordinate.
1564
1609
  */
1565
- findByEndpoints: (from: NodeRef<From>, to: NodeRef<To>, options?: EdgeFindByEndpointsOptions<E>) => Promise<Edge<E, From, To> | undefined>;
1610
+ findByEndpoints: (from: NodeRef<From>, to: NodeRef<To>, options?: EdgeFindByEndpointsOptions<E>, temporal?: QueryOptions) => Promise<Edge<E, From, To> | undefined>;
1566
1611
  /**
1567
1612
  * Get an existing edge by endpoints and optional property fields, or create a new one.
1568
1613
  *
@@ -1619,6 +1664,104 @@ type GraphNodeCollections<G extends GraphDef> = {
1619
1664
  type GraphEdgeCollections<G extends GraphDef> = {
1620
1665
  [K in keyof G["edges"] & string]-?: TypedEdgeCollection<G["edges"][K]>;
1621
1666
  };
1667
+ /** Temporal-aware node reads — a {@link StoreView} pins these. */
1668
+ type NodeTemporalReads<N extends NodeType, CN extends string = string> = Pick<NodeCollection<N, CN>, "getById" | "getByIds" | "find" | "count">;
1669
+ /**
1670
+ * The method names of the current-state-only node reads (constraint / index
1671
+ * lookups). Single source of truth: {@link NodeCurrentReads} (the type) and the
1672
+ * `StoreView`'s runtime routing Set are both derived from this array, so adding
1673
+ * a current-only read here updates both at once — a new read cannot pass the
1674
+ * type partition yet be misrouted at runtime (refused as a write).
1675
+ */
1676
+ declare const CURRENT_ONLY_READ_NAMES: readonly ["findByConstraint", "bulkFindByConstraint", "bulkFindByIndex"];
1677
+ /**
1678
+ * Current-state-only node reads (constraint / index lookups). No temporal
1679
+ * axis, so a {@link StoreView} delegates them on a `current` pin and refuses
1680
+ * them on a temporal pin.
1681
+ */
1682
+ type NodeCurrentReads<N extends NodeType, CN extends string = string> = Pick<NodeCollection<N, CN>, (typeof CURRENT_ONLY_READ_NAMES)[number]>;
1683
+ /** Node writes — never available on a read-only {@link StoreView}. */
1684
+ type NodeWrites<N extends NodeType, CN extends string = string> = Pick<NodeCollection<N, CN>, "create" | "createFromRecord" | "update" | "delete" | "hardDelete" | "upsertById" | "upsertByIdFromRecord" | "bulkCreate" | "bulkUpsertById" | "bulkInsert" | "bulkDelete" | "getOrCreateByConstraint" | "bulkGetOrCreateByConstraint">;
1685
+ /**
1686
+ * Temporal-aware edge reads — a {@link StoreView} pins these. Unlike the node
1687
+ * collection, edges have no current-state-only reads: `findByEndpoints` honors
1688
+ * the temporal coordinate like `findFrom` / `findTo`, so every edge read is
1689
+ * pinnable.
1690
+ */
1691
+ type EdgeTemporalReads<E extends AnyEdgeType, From extends NodeType = NodeType, To extends NodeType = NodeType> = Pick<EdgeCollection<E, From, To>, "getById" | "getByIds" | "find" | "count" | "findFrom" | "findTo" | "findByEndpoints">;
1692
+ /**
1693
+ * Deferred edge reads for `store.batch()` — absent from a {@link StoreView},
1694
+ * which has no batch context.
1695
+ */
1696
+ type EdgeBatchReads<E extends AnyEdgeType, From extends NodeType = NodeType, To extends NodeType = NodeType> = Pick<EdgeCollection<E, From, To>, "batchFindFrom" | "batchFindTo" | "batchFindByEndpoints">;
1697
+ /** Edge writes — never available on a read-only {@link StoreView}. */
1698
+ type EdgeWrites<E extends AnyEdgeType, From extends NodeType = NodeType, To extends NodeType = NodeType> = Pick<EdgeCollection<E, From, To>, "create" | "update" | "delete" | "hardDelete" | "bulkCreate" | "bulkUpsertById" | "bulkInsert" | "bulkDelete" | "getOrCreateByEndpoints" | "bulkGetOrCreateByEndpoints">;
1699
+ /**
1700
+ * The read-only node surface a {@link StoreView} exposes for one node kind.
1701
+ * The temporal reads drop the per-call temporal argument — the pin owns the
1702
+ * axis; the current reads ({@link NodeCurrentReads}) are exposed as-is
1703
+ * (delegated on a `current` view, refused on a temporal pin). Writes live on
1704
+ * the live `Store`. The conformance test asserts the temporal part equals the
1705
+ * pinned form of {@link NodeTemporalReads}.
1706
+ */
1707
+ type StoreViewNodeCollection<N extends NodeType, CN extends string = string> = Readonly<{
1708
+ /** Get a node by ID at the view's pinned coordinate. */
1709
+ getById: (id: NodeId<N>) => Promise<Node<N> | undefined>;
1710
+ /** Get multiple nodes by ID, preserving input order (undefined for missing). */
1711
+ getByIds: (ids: readonly NodeId<N>[]) => Promise<readonly (Node<N> | undefined)[]>;
1712
+ /** Find nodes matching criteria at the view's pinned coordinate. */
1713
+ find: (filter?: Readonly<{
1714
+ where?: (accessor: NodeAccessor<N>) => Predicate;
1715
+ limit?: number;
1716
+ offset?: number;
1717
+ }>) => Promise<Node<N>[]>;
1718
+ /** Count nodes at the view's pinned coordinate. */
1719
+ count: () => Promise<number>;
1720
+ }> & NodeCurrentReads<N, CN>;
1721
+ /**
1722
+ * The read-only edge surface a {@link StoreView} exposes for one edge
1723
+ * kind, mirroring {@link StoreViewNodeCollection}. Every edge read —
1724
+ * including `findByEndpoints` — honors the pin via the same temporal model,
1725
+ * so (unlike nodes) there are no current-state-only edge reads.
1726
+ */
1727
+ type StoreViewEdgeCollection<E extends AnyEdgeType, From extends NodeType = NodeType, To extends NodeType = NodeType> = Readonly<{
1728
+ /** Get an edge by ID at the view's pinned coordinate. */
1729
+ getById: (id: EdgeId<E>) => Promise<Edge<E, From, To> | undefined>;
1730
+ /** Get multiple edges by ID, preserving input order (undefined for missing). */
1731
+ getByIds: (ids: readonly EdgeId<E>[]) => Promise<readonly (Edge<E, From, To> | undefined)[]>;
1732
+ /** Find edges matching endpoint and pagination criteria. */
1733
+ find: (filter?: Readonly<{
1734
+ from?: NodeRef<From>;
1735
+ to?: NodeRef<To>;
1736
+ limit?: number;
1737
+ offset?: number;
1738
+ }>) => Promise<Edge<E, From, To>[]>;
1739
+ /** Count edges matching criteria at the view's pinned coordinate. */
1740
+ count: (filter?: Readonly<{
1741
+ from?: NodeRef<From>;
1742
+ to?: NodeRef<To>;
1743
+ }>) => Promise<number>;
1744
+ /** Find edges from a specific node at the view's pinned coordinate. */
1745
+ findFrom: (from: NodeRef<From>) => Promise<Edge<E, From, To>[]>;
1746
+ /** Find edges to a specific node at the view's pinned coordinate. */
1747
+ findTo: (to: NodeRef<To>) => Promise<Edge<E, From, To>[]>;
1748
+ /** Find the edge between two endpoints at the view's pinned coordinate. */
1749
+ findByEndpoints: (from: NodeRef<From>, to: NodeRef<To>, options?: EdgeFindByEndpointsOptions<E>) => Promise<Edge<E, From, To> | undefined>;
1750
+ }>;
1751
+ /**
1752
+ * Read-only view edge collection derived from an `EdgeRegistration`,
1753
+ * extracting the edge type and from/to node types — the read-only
1754
+ * counterpart of {@link TypedEdgeCollection}.
1755
+ */
1756
+ type TypedStoreViewEdgeCollection<R extends EdgeRegistration> = StoreViewEdgeCollection<R["type"], EdgeFromTypes<R> extends NodeType ? EdgeFromTypes<R> : NodeType, EdgeToTypes<R> extends NodeType ? EdgeToTypes<R> : NodeType>;
1757
+ /** Mapped type of all read-only view node collections for a graph. */
1758
+ type StoreViewNodeCollections<G extends GraphDef> = {
1759
+ [K in keyof G["nodes"] & string]-?: StoreViewNodeCollection<G["nodes"][K]["type"]>;
1760
+ };
1761
+ /** Mapped type of all read-only view edge collections for a graph. */
1762
+ type StoreViewEdgeCollections<G extends GraphDef> = {
1763
+ [K in keyof G["edges"] & string]-?: TypedStoreViewEdgeCollection<G["edges"][K]>;
1764
+ };
1622
1765
  /**
1623
1766
  * A typed transaction context with collection API.
1624
1767
  *
@@ -1673,6 +1816,13 @@ type TransactionContext<G extends GraphDef> = Readonly<{
1673
1816
  nodes: GraphNodeCollections<G>;
1674
1817
  edges: GraphEdgeCollections<G>;
1675
1818
  sql?: AdoptedTransaction;
1819
+ /**
1820
+ * The transaction-scoped backend the collections are bound to, for advanced
1821
+ * raw reads that must observe the transaction's snapshot (e.g. graph-merge's
1822
+ * in-transaction base@V re-validation). On the non-transactional fallback it
1823
+ * is the store's plain backend — reads work, but there is no snapshot.
1824
+ */
1825
+ backend: TransactionBackend;
1676
1826
  }>;
1677
1827
  /**
1678
1828
  * Replace branded `NodeId` / `EdgeId` with plain `string` in each
@@ -1757,204 +1907,6 @@ type StoreProjection<G extends GraphDef, N extends keyof G["nodes"] & string = n
1757
1907
  edges: Pick<GraphEdgeCollections<G>, E>;
1758
1908
  }>;
1759
1909
 
1760
- /**
1761
- * Discriminated union of all Node runtime types in a graph.
1762
- *
1763
- * Unlike `AllNodeTypes<G>` which gives the union of *type definitions*,
1764
- * `AnyNode<G>` gives the union of *runtime node instances*.
1765
- */
1766
- type AnyNode<G extends GraphDef> = {
1767
- [K in NodeKinds<G>]: Node<G["nodes"][K]["type"]>;
1768
- }[NodeKinds<G>];
1769
- /**
1770
- * Discriminated union of all Edge runtime types in a graph.
1771
- */
1772
- type AnyEdge<G extends GraphDef> = {
1773
- [K in EdgeKinds<G>]: Edge<G["edges"][K]["type"]>;
1774
- }[EdgeKinds<G>];
1775
- /**
1776
- * Discriminated union of Node runtime types narrowed to a subset of kinds.
1777
- */
1778
- type SubsetNode<G extends GraphDef, K extends NodeKinds<G>> = {
1779
- [Kind in K]: Node<G["nodes"][Kind]["type"]>;
1780
- }[K];
1781
- /**
1782
- * Discriminated union of Edge runtime types narrowed to a subset of kinds.
1783
- */
1784
- type SubsetEdge<G extends GraphDef, K extends EdgeKinds<G>> = {
1785
- [Kind in K]: Edge<G["edges"][Kind]["type"]>;
1786
- }[K];
1787
- type EmptyShape = Readonly<Record<never, never>>;
1788
- type NodeProjectionPropertyKey<N extends NodeType> = Exclude<keyof Node<N>, "id" | "kind" | "meta"> & string;
1789
- type EdgeProjectionPropertyKey<E extends AnyEdgeType> = Exclude<keyof Edge<E>, "id" | "kind" | "fromKind" | "fromId" | "toKind" | "toId" | "meta"> & string;
1790
- type SubgraphNodeProjectionField<N extends NodeType = NodeType> = NodeProjectionPropertyKey<N> | "meta";
1791
- type SubgraphEdgeProjectionField<E extends AnyEdgeType = AnyEdgeType> = EdgeProjectionPropertyKey<E> | "meta";
1792
- type SubgraphNodeProjectionMap<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>> = Readonly<{
1793
- [K in NodeKinds<G>]?: K extends NK ? readonly SubgraphNodeProjectionField<G["nodes"][K]["type"]>[] : never;
1794
- }>;
1795
- type SubgraphEdgeProjectionMap<G extends GraphDef, EK extends EdgeKinds<G> = EdgeKinds<G>> = Readonly<{
1796
- [K in EdgeKinds<G>]?: K extends EK ? readonly SubgraphEdgeProjectionField<G["edges"][K]["type"]>[] : never;
1797
- }>;
1798
- type SubgraphProject<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>, EK extends EdgeKinds<G> = EdgeKinds<G>> = Readonly<{
1799
- /**
1800
- * Node fields to keep per kind.
1801
- *
1802
- * Projected nodes always retain `kind` and `id`.
1803
- * Use `"meta"` to include the full metadata object; omit it to exclude metadata entirely.
1804
- * Only kinds present in `includeKinds` (or all node kinds when omitted) are valid keys.
1805
- */
1806
- nodes?: SubgraphNodeProjectionMap<G, NK>;
1807
- /**
1808
- * Edge fields to keep per kind.
1809
- *
1810
- * Projected edges always retain `id`, `kind`, `fromKind`, `fromId`,
1811
- * `toKind`, and `toId`.
1812
- * Use `"meta"` to include the full metadata object; omit it to exclude metadata entirely.
1813
- * Only edge kinds listed in `edges` are valid keys.
1814
- */
1815
- edges?: SubgraphEdgeProjectionMap<G, EK>;
1816
- }>;
1817
- /**
1818
- * Identity function that preserves literal types for reusable projection configs.
1819
- *
1820
- * Without this helper, storing a projection in a typed variable widens the
1821
- * field arrays to `string[]`, defeating compile-time narrowing on results.
1822
- *
1823
- * @example
1824
- * ```ts
1825
- * const project = defineSubgraphProject(graph)({
1826
- * nodes: { Task: ["title", "meta"] },
1827
- * edges: { uses_skill: [] },
1828
- * });
1829
- * const result = await store.subgraph(rootId, { edges: ["uses_skill"], project });
1830
- * // result.nodes narrowed correctly — task.status is a type error
1831
- * ```
1832
- */
1833
- declare function defineSubgraphProject<G extends GraphDef>(_graph: G): <const P extends SubgraphProject<G>>(project: P) => P;
1834
- type HasMeta<Selection extends readonly string[] | undefined> = Selection extends readonly string[] ? "meta" extends Selection[number] ? true : false : false;
1835
- type SelectedNodeProps<N extends NodeType, Selection extends readonly string[] | undefined> = Selection extends readonly string[] ? Pick<Node<N>, Extract<Selection[number], NodeProjectionPropertyKey<N>>> : EmptyShape;
1836
- type SelectedEdgeProps<E extends AnyEdgeType, Selection extends readonly string[] | undefined> = Selection extends readonly string[] ? Pick<Edge<E>, Extract<Selection[number], EdgeProjectionPropertyKey<E>>> : EmptyShape;
1837
- type ProjectedNodeResult<N extends NodeType, Selection extends readonly string[] | undefined> = Readonly<Pick<Node<N>, "id" | "kind">> & Readonly<SelectedNodeProps<N, Selection>> & (HasMeta<Selection> extends true ? Readonly<{
1838
- meta: NodeMeta;
1839
- }> : EmptyShape);
1840
- type ProjectedEdgeResult<E extends AnyEdgeType, Selection extends readonly string[] | undefined> = Readonly<Pick<Edge<E>, "id" | "kind" | "fromKind" | "fromId" | "toKind" | "toId">> & Readonly<SelectedEdgeProps<E, Selection>> & (HasMeta<Selection> extends true ? Readonly<{
1841
- meta: EdgeMeta;
1842
- }> : EmptyShape);
1843
- type ProjectionSelection<P, Key extends "nodes" | "edges", Kind extends string> = P extends Readonly<{
1844
- [K in Key]?: infer Map;
1845
- }> ? Map extends Readonly<Record<string, readonly string[] | undefined>> ? Kind extends keyof Map ? Map[Kind] : undefined : undefined : undefined;
1846
- type SubgraphNodeResultForKind<G extends GraphDef, Kind extends NodeKinds<G>, P> = ProjectionSelection<P, "nodes", Kind> extends readonly string[] ? ProjectedNodeResult<G["nodes"][Kind]["type"], ProjectionSelection<P, "nodes", Kind>> : Node<G["nodes"][Kind]["type"]>;
1847
- type SubgraphEdgeResultForKind<G extends GraphDef, Kind extends EdgeKinds<G>, P> = ProjectionSelection<P, "edges", Kind> extends readonly string[] ? ProjectedEdgeResult<G["edges"][Kind]["type"], ProjectionSelection<P, "edges", Kind>> : Edge<G["edges"][Kind]["type"]>;
1848
- type SubgraphOptions<G extends GraphDef, EK extends EdgeKinds<G>, NK extends NodeKinds<G>, P extends SubgraphProject<G, NK, EK> | undefined = undefined> = Readonly<{
1849
- /** Edge kinds to follow during traversal. Edges not listed are not traversed. */
1850
- edges: readonly EK[];
1851
- /** Maximum traversal depth from root (default: 10). */
1852
- maxDepth?: number;
1853
- /**
1854
- * Node kinds to include in the result. Nodes of other kinds are still
1855
- * traversed through but omitted from the output. When omitted, all
1856
- * reachable node kinds are included.
1857
- */
1858
- includeKinds?: readonly NK[];
1859
- /** Exclude the root node from the result (default: false). */
1860
- excludeRoot?: boolean;
1861
- /**
1862
- * Edge direction policy (default: "out").
1863
- * - "out": follow edges in their defined direction only
1864
- * - "both": follow edges in both directions (undirected traversal)
1865
- */
1866
- direction?: "out" | "both";
1867
- /** Cycle policy — reuse RecursiveCyclePolicy (default: "prevent"). */
1868
- cyclePolicy?: RecursiveCyclePolicy;
1869
- /**
1870
- * Temporal mode applied to both nodes and edges along the traversal and in
1871
- * the hydrated result. Defaults to `graph.defaults.temporalMode`.
1872
- */
1873
- temporalMode?: TemporalMode;
1874
- /** ISO-8601 timestamp used when `temporalMode === "asOf"`. */
1875
- asOf?: string;
1876
- /**
1877
- * Optional field-level projection per node/edge kind.
1878
- *
1879
- * Projected nodes keep `kind` and `id`; projected edges keep their structural
1880
- * endpoint fields. Kinds omitted from `project` remain fully hydrated.
1881
- * Projection applies to every returned entity, including the root node.
1882
- *
1883
- * Only kinds present in `includeKinds` (nodes) or `edges` (edges) are valid
1884
- * projection keys. Specifying a kind outside those sets is a compile-time error.
1885
- */
1886
- project?: P;
1887
- }>;
1888
- /**
1889
- * Union of all node result types in a subgraph, respecting projection.
1890
- */
1891
- type SubgraphNodeResult<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>, P = undefined> = {
1892
- [Kind in NK]: SubgraphNodeResultForKind<G, Kind, P>;
1893
- }[NK];
1894
- /**
1895
- * Union of all edge result types in a subgraph, respecting projection.
1896
- */
1897
- type SubgraphEdgeResult<G extends GraphDef, EK extends EdgeKinds<G> = EdgeKinds<G>, P = undefined> = {
1898
- [Kind in EK]: SubgraphEdgeResultForKind<G, Kind, P>;
1899
- }[EK];
1900
- type SubgraphResult<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>, EK extends EdgeKinds<G> = EdgeKinds<G>, P extends SubgraphProject<G, NK, EK> | undefined = undefined> = Readonly<{
1901
- /** The root node, or undefined if the root was not found or excluded. */
1902
- root: SubgraphNodeResult<G, NK, P> | undefined;
1903
- nodes: ReadonlyMap<string, SubgraphNodeResult<G, NK, P>>;
1904
- /** Forward adjacency: fromId → edgeKind → edges to targets. */
1905
- adjacency: ReadonlyMap<string, ReadonlyMap<EK, readonly SubgraphEdgeResult<G, EK, P>[]>>;
1906
- /** Reverse adjacency: toId → edgeKind → edges from sources. */
1907
- reverseAdjacency: ReadonlyMap<string, ReadonlyMap<EK, readonly SubgraphEdgeResult<G, EK, P>[]>>;
1908
- }>;
1909
-
1910
- /**
1911
- * Data-cleanup phase for `store.removeKinds()`.
1912
- *
1913
- * The removeKinds verb commits the new schema atomically (millisecond
1914
- * budget); the data deletion happens here, scoped per-deployment via
1915
- * the `typegraph_kind_removals` status table. Splitting the verbs
1916
- * mirrors how `materializeIndexes` complements `evolve`: schema
1917
- * commits are atomic and fast, data work is bounded by row count and
1918
- * deferrable / parallelizable.
1919
- */
1920
-
1921
- type MaterializeRemovalsOptions = Readonly<{
1922
- /** Restrict to specific kind names. */
1923
- kinds?: readonly string[];
1924
- /** Halt on first failure. Default: false (best-effort). */
1925
- stopOnError?: boolean;
1926
- }>;
1927
- type MaterializeRemovalsEntry = Readonly<{
1928
- kind: string;
1929
- entity: KindEntity;
1930
- status: "removed" | "failed";
1931
- error?: Error;
1932
- }>;
1933
- /**
1934
- * Outcome of reclaiming one per-`(graphId, kind, field)` vector table that
1935
- * was orphaned when its embedding field was dropped from a *surviving*
1936
- * kind's schema. Distinct from {@link MaterializeRemovalsEntry} (whole
1937
- * kinds) because the unit is a single embedding field, not a kind.
1938
- */
1939
- type ReclaimedVectorFieldEntry = Readonly<{
1940
- kind: string;
1941
- fieldPath: string;
1942
- status: "reclaimed" | "failed";
1943
- error?: Error;
1944
- }>;
1945
- type MaterializeRemovalsResult = Readonly<{
1946
- results: readonly MaterializeRemovalsEntry[];
1947
- /**
1948
- * Embedding fields removed from a *surviving* kind whose per-field vector
1949
- * table this pass dropped (or confirmed already absent). Empty when the
1950
- * backend has no vector strategy or no embedding field has ever been
1951
- * dropped. Re-derived from immutable schema history each call, so it lists
1952
- * the same removed fields on repeat passes — the underlying drop is
1953
- * idempotent (`DROP ... IF EXISTS`). See {@link reclaimRemovedVectorFieldTables}.
1954
- */
1955
- reclaimedVectorFields: readonly ReclaimedVectorFieldEntry[];
1956
- }>;
1957
-
1958
1910
  /**
1959
1911
  * ExecutableAggregateQuery - A query with aggregate functions that can be executed.
1960
1912
  */
@@ -2543,8 +2495,12 @@ declare class QueryBuilder<G extends GraphDef, Aliases extends AliasMap = {}, Ed
2543
2495
  * Sets temporal mode.
2544
2496
  *
2545
2497
  * @param mode - The temporal mode to use
2546
- * @param asOf - Required timestamp for "asOf" mode (ISO 8601 string)
2547
- * @throws ValidationError if mode is "asOf" but no timestamp is provided
2498
+ * @param asOf - Required timestamp for "asOf" mode (ISO 8601 string).
2499
+ * Rejected for every other mode — pinning an instant is only meaningful
2500
+ * in "asOf" mode, so `temporal("current", t)` is a caller error, not a
2501
+ * silently-dropped argument.
2502
+ * @throws ValidationError if mode is "asOf" but no timestamp is provided, or
2503
+ * if an asOf is supplied with a non-"asOf" mode.
2548
2504
  */
2549
2505
  temporal(mode: TemporalMode, asOf?: string): QueryBuilder<G, Aliases, EdgeAliases, RecursiveAliases>;
2550
2506
  /**
@@ -2652,15 +2608,16 @@ type AlgorithmCyclePolicy = RecursiveCyclePolicy;
2652
2608
  *
2653
2609
  * Algorithms honor the same temporal model as the rest of the store: both
2654
2610
  * nodes and edges are filtered according to the resolved mode. `asOf` is
2655
- * only consulted when the resolved mode is `"asOf"`. If neither option is
2656
- * supplied, the algorithm falls back to `graph.defaults.temporalMode`.
2611
+ * required when the resolved mode is `"asOf"` and rejected for every other
2612
+ * mode. If neither option is supplied, the algorithm falls back to
2613
+ * `graph.defaults.temporalMode`.
2657
2614
  */
2658
2615
  type TemporalAlgorithmOptions = Readonly<{
2659
2616
  /** Temporal mode. Defaults to the graph's configured default. */
2660
2617
  temporalMode?: TemporalMode;
2661
2618
  /**
2662
- * ISO-8601 timestamp used when `temporalMode` is `"asOf"`. Required in that
2663
- * mode; ignored in all others.
2619
+ * ISO-8601 timestamp pinning the read. Required when `temporalMode` is
2620
+ * `"asOf"`; rejected (throws `ValidationError`) for every other mode.
2664
2621
  */
2665
2622
  asOf?: string;
2666
2623
  }>;
@@ -2813,81 +2770,6 @@ type GraphAlgorithms<G extends GraphDef> = Readonly<{
2813
2770
  degree: (node: NodeIdentifier, options?: DegreeOptions<G>) => Promise<number>;
2814
2771
  }>;
2815
2772
 
2816
- /**
2817
- * `store.introspect()` — unified read of the merged schema.
2818
- *
2819
- * Returns a coherent snapshot of "what does my schema look like right
2820
- * now" suitable for schema-management UIs, codegen, and IDE plugins.
2821
- * The previous surface was fragmented across `registry.hasNodeType`,
2822
- * `store.deprecatedKinds`, and direct graph poking; `introspect()`
2823
- * unifies them with explicit `origin` markers distinguishing
2824
- * compile-time from runtime declarations.
2825
- *
2826
- * Pure read — no I/O. Built from the in-memory `GraphDef` and the
2827
- * persisted-but-already-merged `extension`. `schemaVersion` /
2828
- * `schemaHash` are populated when the loader cached them at
2829
- * construction time and `undefined` otherwise; consumers needing a
2830
- * fresh read should call `backend.getActiveSchema(graphId)` directly.
2831
- */
2832
-
2833
- type SchemaIntrospection = Readonly<{
2834
- graphId: string;
2835
- /** Active schema version on the backend, when known to the caller. */
2836
- schemaVersion: number | undefined;
2837
- /** Hash of the active schema document, when known to the caller. */
2838
- schemaHash: string | undefined;
2839
- kinds: readonly KindIntrospection[];
2840
- edges: readonly EdgeIntrospection[];
2841
- ontology: readonly OntologyIntrospection[];
2842
- deprecatedKinds: ReadonlySet<string>;
2843
- /**
2844
- * The persisted graph extension, or `undefined` when the store has
2845
- * no extensions. Round-trips: passing this value to
2846
- * `defineGraphExtension` and `evolve` against an empty graph yields
2847
- * a graph with the same extension kinds.
2848
- */
2849
- extension: GraphExtension | undefined;
2850
- }>;
2851
- type KindIntrospection = Readonly<{
2852
- name: string;
2853
- origin: "compile-time" | "runtime";
2854
- description: string | undefined;
2855
- annotations: KindAnnotations | undefined;
2856
- deprecated: boolean;
2857
- /**
2858
- * JSON-Schema view of the kind's properties. For extension kinds the
2859
- * lower-level `ExtensionPropertyType` shape (with first-class
2860
- * `searchable` / `embedding` modifiers) is reachable via
2861
- * `introspection.extension.nodes[name].properties`.
2862
- */
2863
- properties: JsonSchema;
2864
- unique: readonly UniqueIntrospection[];
2865
- }>;
2866
- type EdgeIntrospection = Readonly<{
2867
- name: string;
2868
- origin: "compile-time" | "runtime";
2869
- description: string | undefined;
2870
- from: readonly string[];
2871
- to: readonly string[];
2872
- cardinality: Cardinality;
2873
- endpointExistence: EndpointExistence;
2874
- properties: JsonSchema;
2875
- annotations: KindAnnotations | undefined;
2876
- deprecated: boolean;
2877
- }>;
2878
- type OntologyIntrospection = Readonly<{
2879
- metaEdge: string;
2880
- from: string;
2881
- to: string;
2882
- origin: "compile-time" | "runtime";
2883
- }>;
2884
- type UniqueIntrospection = Readonly<{
2885
- name: string;
2886
- fields: readonly string[];
2887
- scope: UniquenessScope;
2888
- collation: Collation;
2889
- }>;
2890
-
2891
2773
  type RebuildFulltextOptions = Readonly<{
2892
2774
  /** Page size. Must be a positive integer. Default: 500. */
2893
2775
  pageSize?: number;
@@ -3174,6 +3056,279 @@ declare class StoreSearch<G extends GraphDef> {
3174
3056
  rebuildFulltext<K extends string>(nodeKind?: K, options?: RebuildFulltextOptions): Promise<RebuildFulltextResult>;
3175
3057
  }
3176
3058
 
3059
+ /**
3060
+ * `store.introspect()` — unified read of the merged schema.
3061
+ *
3062
+ * Returns a coherent snapshot of "what does my schema look like right
3063
+ * now" suitable for schema-management UIs, codegen, and IDE plugins.
3064
+ * The previous surface was fragmented across `registry.hasNodeType`,
3065
+ * `store.deprecatedKinds`, and direct graph poking; `introspect()`
3066
+ * unifies them with explicit `origin` markers distinguishing
3067
+ * compile-time from runtime declarations.
3068
+ *
3069
+ * Pure read — no I/O. Built from the in-memory `GraphDef` and the
3070
+ * persisted-but-already-merged `extension`. `schemaVersion` /
3071
+ * `schemaHash` are populated when the loader cached them at
3072
+ * construction time and `undefined` otherwise; consumers needing a
3073
+ * fresh read should call `backend.getActiveSchema(graphId)` directly.
3074
+ */
3075
+
3076
+ type SchemaIntrospection = Readonly<{
3077
+ graphId: string;
3078
+ /** Active schema version on the backend, when known to the caller. */
3079
+ schemaVersion: number | undefined;
3080
+ /** Hash of the active schema document, when known to the caller. */
3081
+ schemaHash: string | undefined;
3082
+ kinds: readonly KindIntrospection[];
3083
+ edges: readonly EdgeIntrospection[];
3084
+ ontology: readonly OntologyIntrospection[];
3085
+ deprecatedKinds: ReadonlySet<string>;
3086
+ /**
3087
+ * The persisted graph extension, or `undefined` when the store has
3088
+ * no extensions. Round-trips: passing this value to
3089
+ * `defineGraphExtension` and `evolve` against an empty graph yields
3090
+ * a graph with the same extension kinds.
3091
+ */
3092
+ extension: GraphExtension | undefined;
3093
+ }>;
3094
+ type KindIntrospection = Readonly<{
3095
+ name: string;
3096
+ origin: "compile-time" | "runtime";
3097
+ description: string | undefined;
3098
+ annotations: KindAnnotations | undefined;
3099
+ deprecated: boolean;
3100
+ /**
3101
+ * JSON-Schema view of the kind's properties. For extension kinds the
3102
+ * lower-level `ExtensionPropertyType` shape (with first-class
3103
+ * `searchable` / `embedding` modifiers) is reachable via
3104
+ * `introspection.extension.nodes[name].properties`.
3105
+ */
3106
+ properties: JsonSchema;
3107
+ unique: readonly UniqueIntrospection[];
3108
+ }>;
3109
+ type EdgeIntrospection = Readonly<{
3110
+ name: string;
3111
+ origin: "compile-time" | "runtime";
3112
+ description: string | undefined;
3113
+ from: readonly string[];
3114
+ to: readonly string[];
3115
+ cardinality: Cardinality;
3116
+ endpointExistence: EndpointExistence;
3117
+ properties: JsonSchema;
3118
+ annotations: KindAnnotations | undefined;
3119
+ deprecated: boolean;
3120
+ }>;
3121
+ type OntologyIntrospection = Readonly<{
3122
+ metaEdge: string;
3123
+ from: string;
3124
+ to: string;
3125
+ origin: "compile-time" | "runtime";
3126
+ }>;
3127
+ type UniqueIntrospection = Readonly<{
3128
+ name: string;
3129
+ fields: readonly string[];
3130
+ scope: UniquenessScope;
3131
+ collation: Collation;
3132
+ }>;
3133
+
3134
+ /**
3135
+ * Data-cleanup phase for `store.removeKinds()`.
3136
+ *
3137
+ * The removeKinds verb commits the new schema atomically (millisecond
3138
+ * budget); the data deletion happens here, scoped per-deployment via
3139
+ * the `typegraph_kind_removals` status table. Splitting the verbs
3140
+ * mirrors how `materializeIndexes` complements `evolve`: schema
3141
+ * commits are atomic and fast, data work is bounded by row count and
3142
+ * deferrable / parallelizable.
3143
+ */
3144
+
3145
+ type MaterializeRemovalsOptions = Readonly<{
3146
+ /** Restrict to specific kind names. */
3147
+ kinds?: readonly string[];
3148
+ /** Halt on first failure. Default: false (best-effort). */
3149
+ stopOnError?: boolean;
3150
+ }>;
3151
+ type MaterializeRemovalsEntry = Readonly<{
3152
+ kind: string;
3153
+ entity: KindEntity;
3154
+ status: "removed" | "failed";
3155
+ error?: Error;
3156
+ }>;
3157
+ /**
3158
+ * Outcome of reclaiming one per-`(graphId, kind, field)` vector table that
3159
+ * was orphaned when its embedding field was dropped from a *surviving*
3160
+ * kind's schema. Distinct from {@link MaterializeRemovalsEntry} (whole
3161
+ * kinds) because the unit is a single embedding field, not a kind.
3162
+ */
3163
+ type ReclaimedVectorFieldEntry = Readonly<{
3164
+ kind: string;
3165
+ fieldPath: string;
3166
+ status: "reclaimed" | "failed";
3167
+ error?: Error;
3168
+ }>;
3169
+ type MaterializeRemovalsResult = Readonly<{
3170
+ results: readonly MaterializeRemovalsEntry[];
3171
+ /**
3172
+ * Embedding fields removed from a *surviving* kind whose per-field vector
3173
+ * table this pass dropped (or confirmed already absent). Empty when the
3174
+ * backend has no vector strategy or no embedding field has ever been
3175
+ * dropped. Re-derived from immutable schema history each call, so it lists
3176
+ * the same removed fields on repeat passes — the underlying drop is
3177
+ * idempotent (`DROP ... IF EXISTS`). See {@link reclaimRemovedVectorFieldTables}.
3178
+ */
3179
+ reclaimedVectorFields: readonly ReclaimedVectorFieldEntry[];
3180
+ }>;
3181
+
3182
+ /**
3183
+ * Discriminated union of all Node runtime types in a graph.
3184
+ *
3185
+ * Unlike `AllNodeTypes<G>` which gives the union of *type definitions*,
3186
+ * `AnyNode<G>` gives the union of *runtime node instances*.
3187
+ */
3188
+ type AnyNode<G extends GraphDef> = {
3189
+ [K in NodeKinds<G>]: Node<G["nodes"][K]["type"]>;
3190
+ }[NodeKinds<G>];
3191
+ /**
3192
+ * Discriminated union of all Edge runtime types in a graph.
3193
+ */
3194
+ type AnyEdge<G extends GraphDef> = {
3195
+ [K in EdgeKinds<G>]: Edge<G["edges"][K]["type"]>;
3196
+ }[EdgeKinds<G>];
3197
+ /**
3198
+ * Discriminated union of Node runtime types narrowed to a subset of kinds.
3199
+ */
3200
+ type SubsetNode<G extends GraphDef, K extends NodeKinds<G>> = {
3201
+ [Kind in K]: Node<G["nodes"][Kind]["type"]>;
3202
+ }[K];
3203
+ /**
3204
+ * Discriminated union of Edge runtime types narrowed to a subset of kinds.
3205
+ */
3206
+ type SubsetEdge<G extends GraphDef, K extends EdgeKinds<G>> = {
3207
+ [Kind in K]: Edge<G["edges"][Kind]["type"]>;
3208
+ }[K];
3209
+ type EmptyShape = Readonly<Record<never, never>>;
3210
+ type NodeProjectionPropertyKey<N extends NodeType> = Exclude<keyof Node<N>, "id" | "kind" | "meta"> & string;
3211
+ type EdgeProjectionPropertyKey<E extends AnyEdgeType> = Exclude<keyof Edge<E>, "id" | "kind" | "fromKind" | "fromId" | "toKind" | "toId" | "meta"> & string;
3212
+ type SubgraphNodeProjectionField<N extends NodeType = NodeType> = NodeProjectionPropertyKey<N> | "meta";
3213
+ type SubgraphEdgeProjectionField<E extends AnyEdgeType = AnyEdgeType> = EdgeProjectionPropertyKey<E> | "meta";
3214
+ type SubgraphNodeProjectionMap<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>> = Readonly<{
3215
+ [K in NodeKinds<G>]?: K extends NK ? readonly SubgraphNodeProjectionField<G["nodes"][K]["type"]>[] : never;
3216
+ }>;
3217
+ type SubgraphEdgeProjectionMap<G extends GraphDef, EK extends EdgeKinds<G> = EdgeKinds<G>> = Readonly<{
3218
+ [K in EdgeKinds<G>]?: K extends EK ? readonly SubgraphEdgeProjectionField<G["edges"][K]["type"]>[] : never;
3219
+ }>;
3220
+ type SubgraphProject<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>, EK extends EdgeKinds<G> = EdgeKinds<G>> = Readonly<{
3221
+ /**
3222
+ * Node fields to keep per kind.
3223
+ *
3224
+ * Projected nodes always retain `kind` and `id`.
3225
+ * Use `"meta"` to include the full metadata object; omit it to exclude metadata entirely.
3226
+ * Only kinds present in `includeKinds` (or all node kinds when omitted) are valid keys.
3227
+ */
3228
+ nodes?: SubgraphNodeProjectionMap<G, NK>;
3229
+ /**
3230
+ * Edge fields to keep per kind.
3231
+ *
3232
+ * Projected edges always retain `id`, `kind`, `fromKind`, `fromId`,
3233
+ * `toKind`, and `toId`.
3234
+ * Use `"meta"` to include the full metadata object; omit it to exclude metadata entirely.
3235
+ * Only edge kinds listed in `edges` are valid keys.
3236
+ */
3237
+ edges?: SubgraphEdgeProjectionMap<G, EK>;
3238
+ }>;
3239
+ /**
3240
+ * Identity function that preserves literal types for reusable projection configs.
3241
+ *
3242
+ * Without this helper, storing a projection in a typed variable widens the
3243
+ * field arrays to `string[]`, defeating compile-time narrowing on results.
3244
+ *
3245
+ * @example
3246
+ * ```ts
3247
+ * const project = defineSubgraphProject(graph)({
3248
+ * nodes: { Task: ["title", "meta"] },
3249
+ * edges: { uses_skill: [] },
3250
+ * });
3251
+ * const result = await store.subgraph(rootId, { edges: ["uses_skill"], project });
3252
+ * // result.nodes narrowed correctly — task.status is a type error
3253
+ * ```
3254
+ */
3255
+ declare function defineSubgraphProject<G extends GraphDef>(_graph: G): <const P extends SubgraphProject<G>>(project: P) => P;
3256
+ type HasMeta<Selection extends readonly string[] | undefined> = Selection extends readonly string[] ? "meta" extends Selection[number] ? true : false : false;
3257
+ type SelectedNodeProps<N extends NodeType, Selection extends readonly string[] | undefined> = Selection extends readonly string[] ? Pick<Node<N>, Extract<Selection[number], NodeProjectionPropertyKey<N>>> : EmptyShape;
3258
+ type SelectedEdgeProps<E extends AnyEdgeType, Selection extends readonly string[] | undefined> = Selection extends readonly string[] ? Pick<Edge<E>, Extract<Selection[number], EdgeProjectionPropertyKey<E>>> : EmptyShape;
3259
+ type ProjectedNodeResult<N extends NodeType, Selection extends readonly string[] | undefined> = Readonly<Pick<Node<N>, "id" | "kind">> & Readonly<SelectedNodeProps<N, Selection>> & (HasMeta<Selection> extends true ? Readonly<{
3260
+ meta: NodeMeta;
3261
+ }> : EmptyShape);
3262
+ type ProjectedEdgeResult<E extends AnyEdgeType, Selection extends readonly string[] | undefined> = Readonly<Pick<Edge<E>, "id" | "kind" | "fromKind" | "fromId" | "toKind" | "toId">> & Readonly<SelectedEdgeProps<E, Selection>> & (HasMeta<Selection> extends true ? Readonly<{
3263
+ meta: EdgeMeta;
3264
+ }> : EmptyShape);
3265
+ type ProjectionSelection<P, Key extends "nodes" | "edges", Kind extends string> = P extends Readonly<{
3266
+ [K in Key]?: infer Map;
3267
+ }> ? Map extends Readonly<Record<string, readonly string[] | undefined>> ? Kind extends keyof Map ? Map[Kind] : undefined : undefined : undefined;
3268
+ type SubgraphNodeResultForKind<G extends GraphDef, Kind extends NodeKinds<G>, P> = ProjectionSelection<P, "nodes", Kind> extends readonly string[] ? ProjectedNodeResult<G["nodes"][Kind]["type"], ProjectionSelection<P, "nodes", Kind>> : Node<G["nodes"][Kind]["type"]>;
3269
+ type SubgraphEdgeResultForKind<G extends GraphDef, Kind extends EdgeKinds<G>, P> = ProjectionSelection<P, "edges", Kind> extends readonly string[] ? ProjectedEdgeResult<G["edges"][Kind]["type"], ProjectionSelection<P, "edges", Kind>> : Edge<G["edges"][Kind]["type"]>;
3270
+ type SubgraphOptions<G extends GraphDef, EK extends EdgeKinds<G>, NK extends NodeKinds<G>, P extends SubgraphProject<G, NK, EK> | undefined = undefined> = Readonly<{
3271
+ /** Edge kinds to follow during traversal. Edges not listed are not traversed. */
3272
+ edges: readonly EK[];
3273
+ /** Maximum traversal depth from root (default: 10). */
3274
+ maxDepth?: number;
3275
+ /**
3276
+ * Node kinds to include in the result. Nodes of other kinds are still
3277
+ * traversed through but omitted from the output. When omitted, all
3278
+ * reachable node kinds are included.
3279
+ */
3280
+ includeKinds?: readonly NK[];
3281
+ /** Exclude the root node from the result (default: false). */
3282
+ excludeRoot?: boolean;
3283
+ /**
3284
+ * Edge direction policy (default: "out").
3285
+ * - "out": follow edges in their defined direction only
3286
+ * - "both": follow edges in both directions (undirected traversal)
3287
+ */
3288
+ direction?: "out" | "both";
3289
+ /** Cycle policy — reuse RecursiveCyclePolicy (default: "prevent"). */
3290
+ cyclePolicy?: RecursiveCyclePolicy;
3291
+ /**
3292
+ * Temporal mode applied to both nodes and edges along the traversal and in
3293
+ * the hydrated result. Defaults to `graph.defaults.temporalMode`.
3294
+ */
3295
+ temporalMode?: TemporalMode;
3296
+ /** ISO-8601 timestamp used when `temporalMode === "asOf"`. */
3297
+ asOf?: string;
3298
+ /**
3299
+ * Optional field-level projection per node/edge kind.
3300
+ *
3301
+ * Projected nodes keep `kind` and `id`; projected edges keep their structural
3302
+ * endpoint fields. Kinds omitted from `project` remain fully hydrated.
3303
+ * Projection applies to every returned entity, including the root node.
3304
+ *
3305
+ * Only kinds present in `includeKinds` (nodes) or `edges` (edges) are valid
3306
+ * projection keys. Specifying a kind outside those sets is a compile-time error.
3307
+ */
3308
+ project?: P;
3309
+ }>;
3310
+ /**
3311
+ * Union of all node result types in a subgraph, respecting projection.
3312
+ */
3313
+ type SubgraphNodeResult<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>, P = undefined> = {
3314
+ [Kind in NK]: SubgraphNodeResultForKind<G, Kind, P>;
3315
+ }[NK];
3316
+ /**
3317
+ * Union of all edge result types in a subgraph, respecting projection.
3318
+ */
3319
+ type SubgraphEdgeResult<G extends GraphDef, EK extends EdgeKinds<G> = EdgeKinds<G>, P = undefined> = {
3320
+ [Kind in EK]: SubgraphEdgeResultForKind<G, Kind, P>;
3321
+ }[EK];
3322
+ type SubgraphResult<G extends GraphDef, NK extends NodeKinds<G> = NodeKinds<G>, EK extends EdgeKinds<G> = EdgeKinds<G>, P extends SubgraphProject<G, NK, EK> | undefined = undefined> = Readonly<{
3323
+ /** The root node, or undefined if the root was not found or excluded. */
3324
+ root: SubgraphNodeResult<G, NK, P> | undefined;
3325
+ nodes: ReadonlyMap<string, SubgraphNodeResult<G, NK, P>>;
3326
+ /** Forward adjacency: fromId → edgeKind → edges to targets. */
3327
+ adjacency: ReadonlyMap<string, ReadonlyMap<EK, readonly SubgraphEdgeResult<G, EK, P>[]>>;
3328
+ /** Reverse adjacency: toId → edgeKind → edges from sources. */
3329
+ reverseAdjacency: ReadonlyMap<string, ReadonlyMap<EK, readonly SubgraphEdgeResult<G, EK, P>[]>>;
3330
+ }>;
3331
+
3177
3332
  /**
3178
3333
  * Main Store implementation for TypeGraph.
3179
3334
  *
@@ -3400,6 +3555,69 @@ declare class Store<G extends GraphDef> {
3400
3555
  * ```
3401
3556
  */
3402
3557
  query(): QueryBuilder<G>;
3558
+ /**
3559
+ * Internal seam for {@link StoreView.query}: a query builder pinned to a
3560
+ * view's {@link ReadCoordinate} with its temporal axis sealed
3561
+ * (`.temporal()` throws). Not part of the stable public API — construct a
3562
+ * view via {@link Store.view} / {@link Store.asOf} and call `.query()`.
3563
+ */
3564
+ sealedQuery(coordinate: ReadCoordinate): QueryBuilder<G>;
3565
+ /**
3566
+ * Returns a read-only {@link StoreView} pinned to a valid-time instant.
3567
+ *
3568
+ * The view routes every supported read — `nodes` / `edges` collections,
3569
+ * `query()`, `subgraph()`, and the graph algorithms — through the
3570
+ * `asOf` coordinate, so they observe the graph as it was valid at `T`.
3571
+ * Writes stay on the live `Store`. Mirrors Datomic's `(d/as-of db t)`.
3572
+ *
3573
+ * @example
3574
+ * ```typescript
3575
+ * const past = store.asOf("2026-01-01T00:00:00.000Z");
3576
+ * const alice = await past.nodes.Person.getById(aliceId);
3577
+ * const names = await past
3578
+ * .query()
3579
+ * .from("Person", "p")
3580
+ * .whereNode("p", (p) => p.name.eq("Alice"))
3581
+ * .select((ctx) => ctx.p.name)
3582
+ * .execute();
3583
+ * ```
3584
+ *
3585
+ * @param asOf - ISO-8601 timestamp to pin the valid-time coordinate to.
3586
+ */
3587
+ asOf(asOf: string): StoreView<G>;
3588
+ /**
3589
+ * Returns a read-only {@link StoreView} pinned to an arbitrary public
3590
+ * temporal mode. Use {@link Store.asOf} for the common valid-time case;
3591
+ * reach for `view` to pin `"current"`, `"includeEnded"`, or
3592
+ * `"includeTombstones"`.
3593
+ *
3594
+ * @example
3595
+ * ```typescript
3596
+ * const withTombstones = store.view({ mode: "includeTombstones" });
3597
+ * const everyEverVersion = await withTombstones.nodes.Person.find();
3598
+ * ```
3599
+ *
3600
+ * @param coordinate - The `(mode, asOf)` coordinate to pin. `asOf` is
3601
+ * required when `mode` is `"asOf"` and rejected for every other mode.
3602
+ */
3603
+ view(coordinate: StoreViewCoordinate): StoreView<G>;
3604
+ /**
3605
+ * Returns a read-only {@link StoreView} pinned to the current instant,
3606
+ * captured once at construction — a stable point-in-time snapshot. Unlike
3607
+ * `store.view({ mode: "current" })` (which tracks "now" live and can read
3608
+ * different surfaces against slightly different clocks), a snapshot pins one
3609
+ * `asOf` timestamp, so every surface observes the same instant. Sugar for
3610
+ * `store.asOf(new Date().toISOString())`; mirrors Datomic's `(d/db conn)`.
3611
+ *
3612
+ * @example
3613
+ * ```typescript
3614
+ * const snap = store.snapshot();
3615
+ * // Every read on `snap` sees the graph as of one fixed instant.
3616
+ * const a = await snap.nodes.Person.find();
3617
+ * const r = await snap.reachable(rootId, { edges: ["knows"] });
3618
+ * ```
3619
+ */
3620
+ snapshot(): StoreView<G>;
3403
3621
  /**
3404
3622
  * Search-related operations (fulltext, hybrid, and rebuild).
3405
3623
  *
@@ -3546,8 +3764,14 @@ declare class Store<G extends GraphDef> {
3546
3764
  * // sequential, non-atomic — handle partial-failure recovery yourself
3547
3765
  * }
3548
3766
  * ```
3767
+ *
3768
+ * @param fn The callback run inside the transaction boundary.
3769
+ * @param options Optional {@link TransactionOptions} forwarded to the
3770
+ * backend (e.g. `isolationLevel: "serializable"` on Postgres). Backends
3771
+ * without isolation-level support ignore it; the non-transactional
3772
+ * fallback ignores it entirely.
3549
3773
  */
3550
- transaction<T>(fn: (tx: TransactionContext<G>) => Promise<T>): Promise<T>;
3774
+ transaction<T>(fn: (tx: TransactionContext<G>) => Promise<T>, options?: TransactionOptions): Promise<T>;
3551
3775
  /**
3552
3776
  * Adopts a caller-owned, already-open Drizzle transaction so the graph
3553
3777
  * store and the caller's relational writes commit or roll back as one
@@ -3952,4 +4176,108 @@ declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: Gr
3952
4176
  */
3953
4177
  declare function createVerifiedStore<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions): Promise<[Store<G>, SchemaValidationResult]>;
3954
4178
 
3955
- export { type HybridVectorOptions as $, type AliasMap as A, type BaseTraversalOptions as B, type CreateQueryBuilderOptions as C, DEFAULT_SEARCHABLE_LANGUAGE as D, type EmbeddingMetric as E, type EdgeGetOrCreateByEndpointsResult as F, type EdgeIntrospection as G, type EmbeddingSchema as H, type EmbeddingValue as I, ExecutableAggregateQuery as J, ExecutableQuery as K, type FieldAccessor as L, type FulltextSearchHit as M, type Node as N, type FulltextSearchOptions as O, type GetOrCreateAction as P, QueryBuilder as Q, type GraphAlgorithms as R, Store as S, TraversalBuilder as T, type UniqueIntrospection as U, type GraphEdgeCollections as V, type GraphNodeCollections as W, type HookContext as X, type HybridFulltextOptions as Y, type HybridSearchHit as Z, type HybridSearchOptions as _, type EmbeddingIndexType as a, createStore as a$, type IfExistsMode as a0, type KindIntrospection as a1, type MaterializeRemovalsEntry as a2, type MaterializeRemovalsOptions as a3, type MaterializeRemovalsResult as a4, type NeighborsOptions as a5, type NodeAccessor as a6, type NodeAlias as a7, type NodeBulkFindByIndexOptions as a8, type NodeCollection as a9, type SearchableSchema as aA, type SelectContext as aB, type SelectableEdge as aC, type SelectableNode as aD, type ShortestPathOptions as aE, type ShortestPathResult as aF, type StoreHooks as aG, type StoreOptions as aH, type StoreProjection as aI, type StoreRef as aJ, StoreSearch as aK, type StreamOptions as aL, type SubgraphEdgeResult as aM, type SubgraphNodeResult as aN, type SubgraphOptions as aO, type SubgraphResult as aP, type SubsetEdge as aQ, type SubsetNode as aR, type TemporalAlgorithmOptions as aS, type TransactionContext as aT, type TraversalDirection as aU, type TypedEdgeCollection as aV, UnionableQuery as aW, type UpdateEdgeInput as aX, type UpdateNodeInput as aY, type VectorSearchHit as aZ, type VectorSearchOptions as a_, type NodeGetOrCreateByConstraintOptions as aa, type NodeGetOrCreateByConstraintResult as ab, type NodeIdentifier as ac, type NodeRef as ad, type OntologyIntrospection as ae, type OperationHookContext as af, type PaginateOptions as ag, type PaginatedResult as ah, type PathNode as ai, type Predicate as aj, PreparedQuery as ak, type PropsAccessor as al, type QueryHookContext as am, type QueryOptions as an, type ReachableNode as ao, type ReachableOptions as ap, type RebuildFulltextOptions as aq, type RebuildFulltextResult as ar, type ReclaimedVectorFieldEntry as as, type RecursiveTraversalOptions as at, type ReembedFunction as au, type ReembedVectorFieldOptions as av, type ReembedVectorFieldResult as aw, type SchemaIntrospection as ax, type SearchableMetadata as ay, type SearchableOptions as az, type EdgeAliasMap as b, createStoreWithSchema as b0, createVerifiedStore as b1, defineSubgraphProject as b2, embedding as b3, exists as b4, fieldRef as b5, getEmbeddingDimensions as b6, getSearchableMetadata as b7, inSubquery as b8, isEmbeddingSchema as b9, isParameterRef as ba, isSearchableSchema as bb, notExists as bc, notInSubquery as bd, param as be, searchable as bf, type AggregateResult as c, type AlgorithmCyclePolicy as d, type AnyEdge as e, type AnyNode as f, type BatchResults as g, type BatchableQuery as h, type ConstraintNames as i, type CreateEdgeInput as j, type CreateNodeInput as k, type DegreeOptions as l, type DynamicEdgeAccessor as m, type DynamicEdgeCollection as n, type DynamicEdgeType as o, type DynamicFieldBuilder as p, type DynamicNodeAccessor as q, type DynamicNodeCollection as r, type DynamicNodeType as s, type DynamicSelectableEdge as t, type DynamicSelectableNode as u, type Edge as v, type EdgeAccessor as w, type EdgeCollection as x, type EdgeFindByEndpointsOptions as y, type EdgeGetOrCreateByEndpointsOptions as z };
4179
+ /**
4180
+ * StoreView — a read-only `(mode, asOf)` lens over a {@link Store}.
4181
+ *
4182
+ * A `StoreView` pins a temporal coordinate and routes every supported
4183
+ * read through it, mirroring Datomic's `(d/as-of db t)` database value
4184
+ * and SQL:2011 `FOR SYSTEM_TIME AS OF`. It is *read-only by
4185
+ * construction*: mutating "the graph as of last Tuesday" is incoherent,
4186
+ * so writes stay on the live `Store`.
4187
+ *
4188
+ * The view is an explicit read context, not a single default flip — the
4189
+ * temporal seam is not uniform across surfaces (the query builder
4190
+ * hardcodes `"current"`, `subgraph` reads `graph.defaults` directly,
4191
+ * collections apply a per-call default). The view therefore injects its
4192
+ * pinned {@link ReadCoordinate} into each surface it hands out through one
4193
+ * helper ({@link withCoordinate}), so a future temporal axis (recorded
4194
+ * time) lands on every surface at once instead of splitting by surface.
4195
+ *
4196
+ * Built on the public `Store` surface (plus one internal sealed-query
4197
+ * seam), so it composes the same reads `branch()` / `merge()` consume.
4198
+ */
4199
+
4200
+ /**
4201
+ * The temporal coordinate a {@link StoreView} pins. A discriminated union on
4202
+ * `mode`: `asOf` is *required* for `"asOf"` and *rejected* (`never`) for every
4203
+ * other mode, so the type mirrors the runtime contract. `view({ mode: "asOf" })`
4204
+ * (missing timestamp) and `view({ mode: "current", asOf })` (pinning an instant
4205
+ * outside `"asOf"`) are both compile errors, not merely runtime
4206
+ * `ValidationError`s.
4207
+ */
4208
+ type StoreViewCoordinate = Readonly<{
4209
+ mode: "asOf";
4210
+ asOf: string;
4211
+ }> | Readonly<{
4212
+ mode: Exclude<TemporalMode, "asOf">;
4213
+ asOf?: never;
4214
+ }>;
4215
+ /**
4216
+ * {@link Store.subgraph} options with the temporal axis removed — the
4217
+ * view's pinned coordinate supplies it.
4218
+ */
4219
+ type StoreViewSubgraphOptions<G extends GraphDef, EK extends EdgeKinds<G>, NK extends NodeKinds<G>, P extends SubgraphProject<G, NK, EK> | undefined = undefined> = Omit<SubgraphOptions<G, EK, NK, P>, "temporalMode" | "asOf">;
4220
+ /** `reachable` options with the temporal axis removed (the pin supplies it). */
4221
+ type StoreViewReachableOptions<G extends GraphDef> = Omit<ReachableOptions<G>, keyof TemporalAlgorithmOptions>;
4222
+ /** `shortestPath` options with the temporal axis removed (the pin supplies it). */
4223
+ type StoreViewShortestPathOptions<G extends GraphDef> = Omit<ShortestPathOptions<G>, keyof TemporalAlgorithmOptions>;
4224
+ /** `canReach` options with the temporal axis removed (the pin supplies it). */
4225
+ type StoreViewCanReachOptions<G extends GraphDef> = Omit<BaseTraversalOptions<G>, keyof TemporalAlgorithmOptions>;
4226
+ /** `neighbors` options with the temporal axis removed (the pin supplies it). */
4227
+ type StoreViewNeighborsOptions<G extends GraphDef> = Omit<NeighborsOptions<G>, keyof TemporalAlgorithmOptions>;
4228
+ /** `degree` options with the temporal axis removed (the pin supplies it). */
4229
+ type StoreViewDegreeOptions<G extends GraphDef> = Omit<DegreeOptions<G>, keyof TemporalAlgorithmOptions>;
4230
+ /**
4231
+ * A read-only `(mode, asOf)` lens over a {@link Store}. Construct one via
4232
+ * {@link Store.asOf} (valid-time) or {@link Store.view} (any public
4233
+ * mode), never directly.
4234
+ *
4235
+ * @example
4236
+ * ```typescript
4237
+ * const past = store.asOf("2026-01-01T00:00:00.000Z");
4238
+ * const alice = await past.nodes.Person.getById(aliceId);
4239
+ * const jobs = await past.edges.worksAt.findFrom(alice!);
4240
+ * const reach = await past.reachable(alice!, { edges: ["knows"] });
4241
+ * ```
4242
+ */
4243
+ declare class StoreView<G extends GraphDef> {
4244
+ #private;
4245
+ constructor(store: Store<G>, coordinate: StoreViewCoordinate);
4246
+ /** The temporal mode this view reads in. */
4247
+ get mode(): TemporalMode;
4248
+ /** The pinned `asOf` timestamp, or `undefined` for non-`asOf` modes. */
4249
+ get asOf(): string | undefined;
4250
+ /** Read-only node collections pinned to this view's coordinate. */
4251
+ get nodes(): StoreViewNodeCollections<G>;
4252
+ /** Read-only edge collections pinned to this view's coordinate. */
4253
+ get edges(): StoreViewEdgeCollections<G>;
4254
+ /**
4255
+ * A query builder pinned to this view's coordinate. The temporal axis is
4256
+ * sealed: calling `.temporal(...)` on the returned builder throws, so the
4257
+ * view's coordinate cannot be overridden on a per-query basis.
4258
+ */
4259
+ query(): QueryBuilder<G>;
4260
+ /** Extracts a subgraph at this view's pinned coordinate. */
4261
+ subgraph<const EK extends EdgeKinds<G>, const NK extends NodeKinds<G> = NodeKinds<G>, const P extends SubgraphProject<G, NK, EK> | undefined = undefined>(rootId: NodeId<AllNodeTypes<G>>, options: StoreViewSubgraphOptions<G, EK, NK, P>): Promise<SubgraphResult<G, NK, EK, P>>;
4262
+ /** Shortest path between two nodes at this view's pinned coordinate. */
4263
+ shortestPath(from: NodeIdentifier, to: NodeIdentifier, options: StoreViewShortestPathOptions<G>): Promise<ShortestPathResult | undefined>;
4264
+ /** Nodes reachable from `from` at this view's pinned coordinate. */
4265
+ reachable(from: NodeIdentifier, options: StoreViewReachableOptions<G>): Promise<readonly ReachableNode[]>;
4266
+ /** Whether `to` is reachable from `from` at this view's pinned coordinate. */
4267
+ canReach(from: NodeIdentifier, to: NodeIdentifier, options: StoreViewCanReachOptions<G>): Promise<boolean>;
4268
+ /** The k-hop neighborhood of `node` at this view's pinned coordinate. */
4269
+ neighbors(node: NodeIdentifier, options: StoreViewNeighborsOptions<G>): Promise<readonly ReachableNode[]>;
4270
+ /** Counts active edges incident to `node` at this view's pinned coordinate. */
4271
+ degree(node: NodeIdentifier, options?: StoreViewDegreeOptions<G>): Promise<number>;
4272
+ /**
4273
+ * Read-only search facade. On a `current` view the read methods
4274
+ * (`fulltext` / `vector` / `hybrid`) delegate to the live `store.search`,
4275
+ * while the mutating `rebuildFulltext` is refused — the view is read-only.
4276
+ * On any non-`current` pin every search method refuses: the fulltext /
4277
+ * vector index reflects current state only, so historical relevance is
4278
+ * out of scope.
4279
+ */
4280
+ get search(): StoreSearch<G>;
4281
+ }
4282
+
4283
+ export { type HybridFulltextOptions as $, type AliasMap as A, type BaseTraversalOptions as B, type CreateQueryBuilderOptions as C, DEFAULT_SEARCHABLE_LANGUAGE as D, type EmbeddingMetric as E, type EdgeGetOrCreateByEndpointsOptions as F, type EdgeGetOrCreateByEndpointsResult as G, type EdgeIntrospection as H, type EdgeTemporalReads as I, type EdgeWrites as J, type EmbeddingSchema as K, type EmbeddingValue as L, ExecutableAggregateQuery as M, type Node as N, ExecutableQuery as O, type FieldAccessor as P, QueryBuilder as Q, type FulltextSearchHit as R, Store as S, TraversalBuilder as T, type UniqueIntrospection as U, type FulltextSearchOptions as V, type GetOrCreateAction as W, type GraphAlgorithms as X, type GraphEdgeCollections as Y, type GraphNodeCollections as Z, type HookContext as _, type EmbeddingIndexType as a, type StoreViewShortestPathOptions as a$, type HybridSearchHit as a0, type HybridSearchOptions as a1, type HybridVectorOptions as a2, type IfExistsMode as a3, type KindIntrospection as a4, type MaterializeRemovalsEntry as a5, type MaterializeRemovalsOptions as a6, type MaterializeRemovalsResult as a7, type NeighborsOptions as a8, type NodeAccessor as a9, type ReembedFunction as aA, type ReembedVectorFieldOptions as aB, type ReembedVectorFieldResult as aC, type SchemaIntrospection as aD, type SearchableMetadata as aE, type SearchableOptions as aF, type SearchableSchema as aG, type SelectContext as aH, type SelectableEdge as aI, type SelectableNode as aJ, type ShortestPathOptions as aK, type ShortestPathResult as aL, type StoreHooks as aM, type StoreOptions as aN, type StoreProjection as aO, type StoreRef as aP, StoreSearch as aQ, StoreView as aR, type StoreViewCanReachOptions as aS, type StoreViewCoordinate as aT, type StoreViewDegreeOptions as aU, type StoreViewEdgeCollection as aV, type StoreViewEdgeCollections as aW, type StoreViewNeighborsOptions as aX, type StoreViewNodeCollection as aY, type StoreViewNodeCollections as aZ, type StoreViewReachableOptions as a_, type NodeAlias as aa, type NodeBulkFindByIndexOptions as ab, type NodeCollection as ac, type NodeCurrentReads as ad, type NodeGetOrCreateByConstraintOptions as ae, type NodeGetOrCreateByConstraintResult as af, type NodeIdentifier as ag, type NodeRef as ah, type NodeTemporalReads as ai, type NodeWrites as aj, type OntologyIntrospection as ak, type OperationHookContext as al, type PaginateOptions as am, type PaginatedResult as an, type PathNode as ao, type Predicate as ap, PreparedQuery as aq, type PropsAccessor as ar, type QueryHookContext as as, type QueryOptions as at, type ReachableNode as au, type ReachableOptions as av, type RebuildFulltextOptions as aw, type RebuildFulltextResult as ax, type ReclaimedVectorFieldEntry as ay, type RecursiveTraversalOptions as az, type EdgeAliasMap as b, type StoreViewSubgraphOptions as b0, type StreamOptions as b1, type SubgraphEdgeResult as b2, type SubgraphNodeResult as b3, type SubgraphOptions as b4, type SubgraphResult as b5, type SubsetEdge as b6, type SubsetNode as b7, type TemporalAlgorithmOptions as b8, type TransactionContext as b9, type TraversalDirection as ba, type TypedEdgeCollection as bb, type TypedStoreViewEdgeCollection as bc, UnionableQuery as bd, type UpdateEdgeInput as be, type UpdateNodeInput as bf, type VectorSearchHit as bg, type VectorSearchOptions as bh, createStore as bi, createStoreWithSchema as bj, createVerifiedStore as bk, defineSubgraphProject as bl, embedding as bm, exists as bn, fieldRef as bo, getEmbeddingDimensions as bp, getSearchableMetadata as bq, inSubquery as br, isEmbeddingSchema as bs, isParameterRef as bt, isSearchableSchema as bu, notExists as bv, notInSubquery as bw, param as bx, searchable as by, type AggregateResult as c, type AlgorithmCyclePolicy as d, type AnyEdge as e, type AnyNode as f, type BatchResults as g, type BatchableQuery as h, type ConstraintNames as i, type CreateEdgeInput as j, type CreateNodeInput as k, type DegreeOptions as l, type DynamicEdgeAccessor as m, type DynamicEdgeCollection as n, type DynamicEdgeType as o, type DynamicFieldBuilder as p, type DynamicNodeAccessor as q, type DynamicNodeCollection as r, type DynamicNodeType as s, type DynamicSelectableEdge as t, type DynamicSelectableNode as u, type Edge as v, type EdgeAccessor as w, type EdgeBatchReads as x, type EdgeCollection as y, type EdgeFindByEndpointsOptions as z };