@nicia-ai/typegraph 0.25.1 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +161 -113
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +6 -8
- package/dist/backend/postgres/index.d.ts +6 -8
- package/dist/backend/postgres/index.js +116 -68
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +16 -15
- package/dist/backend/sqlite/index.d.cts +11 -26
- package/dist/backend/sqlite/index.d.ts +11 -26
- package/dist/backend/sqlite/index.js +6 -5
- package/dist/backend/sqlite/libsql.cjs +9 -8
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +4 -3
- package/dist/backend/sqlite/libsql.d.ts +4 -3
- package/dist/backend/sqlite/libsql.js +6 -5
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +11 -10
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +4 -3
- package/dist/backend/sqlite/local.d.ts +4 -3
- package/dist/backend/sqlite/local.js +6 -5
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-4FJVSF3K.cjs +12 -0
- package/dist/{chunk-D2GO3RBL.cjs.map → chunk-4FJVSF3K.cjs.map} +1 -1
- package/dist/chunk-5H3BAMTB.js +32 -0
- package/dist/chunk-5H3BAMTB.js.map +1 -0
- package/dist/{chunk-CLEUFN2K.js → chunk-DDVA4QBA.js} +174 -78
- package/dist/chunk-DDVA4QBA.js.map +1 -0
- package/dist/{chunk-OECDVACY.cjs → chunk-DN4RUDF3.cjs} +2 -2
- package/dist/chunk-DN4RUDF3.cjs.map +1 -0
- package/dist/{chunk-NHQWXSTS.js → chunk-E5ROA3MN.js} +3 -3
- package/dist/{chunk-NHQWXSTS.js.map → chunk-E5ROA3MN.js.map} +1 -1
- package/dist/{chunk-CPFR3O7L.js → chunk-ENXJLDRK.js} +2 -2
- package/dist/chunk-ENXJLDRK.js.map +1 -0
- package/dist/chunk-IUIWCFG3.cjs +36 -0
- package/dist/chunk-IUIWCFG3.cjs.map +1 -0
- package/dist/{chunk-EG6TJ3I5.js → chunk-OYLF3IC7.js} +3 -3
- package/dist/{chunk-EG6TJ3I5.js.map → chunk-OYLF3IC7.js.map} +1 -1
- package/dist/{chunk-JTI5WT4P.cjs → chunk-PN37HVAV.cjs} +32 -10
- package/dist/chunk-PN37HVAV.cjs.map +1 -0
- package/dist/{chunk-RCAJZG67.cjs → chunk-PYJOBZR3.cjs} +10 -10
- package/dist/{chunk-RCAJZG67.cjs.map → chunk-PYJOBZR3.cjs.map} +1 -1
- package/dist/{chunk-PSKUWVCB.js → chunk-RF5EUQWS.js} +336 -36
- package/dist/chunk-RF5EUQWS.js.map +1 -0
- package/dist/{chunk-CLGC7AQ2.cjs → chunk-RVT2N4RF.cjs} +206 -110
- package/dist/chunk-RVT2N4RF.cjs.map +1 -0
- package/dist/{chunk-4BOWVUGQ.js → chunk-TSGBRPNE.js} +3 -3
- package/dist/{chunk-4BOWVUGQ.js.map → chunk-TSGBRPNE.js.map} +1 -1
- package/dist/{chunk-CQVNGKU7.cjs → chunk-TVUARC7S.cjs} +410 -100
- package/dist/chunk-TVUARC7S.cjs.map +1 -0
- package/dist/{chunk-DOTEN2FG.js → chunk-U5ROKVRF.js} +26 -3
- package/dist/chunk-U5ROKVRF.js.map +1 -0
- package/dist/{chunk-E5JZSEGJ.cjs → chunk-WFUN6DCM.cjs} +8 -8
- package/dist/{chunk-E5JZSEGJ.cjs.map → chunk-WFUN6DCM.cjs.map} +1 -1
- package/dist/{chunk-AAA2CR3P.js → chunk-X53YKGHR.js} +78 -37
- package/dist/chunk-X53YKGHR.js.map +1 -0
- package/dist/{chunk-W5MTHMTE.cjs → chunk-YEDQLNVE.cjs} +26 -2
- package/dist/chunk-YEDQLNVE.cjs.map +1 -0
- package/dist/{chunk-QMQYK3IF.cjs → chunk-ZGEMI7MJ.cjs} +163 -122
- package/dist/chunk-ZGEMI7MJ.cjs.map +1 -0
- package/dist/{chunk-YZZBDCLV.js → chunk-ZTREJOGB.js} +32 -11
- package/dist/chunk-ZTREJOGB.js.map +1 -0
- package/dist/{ddl-BqMmpNor.d.ts → ddl-9kw8UADK.d.ts} +298 -12
- package/dist/{ddl-Bwjh8Hff.d.cts → ddl-Cw82BPM4.d.cts} +298 -12
- package/dist/{extension-types-D07e_NTw.d.cts → extension-types-B78CZfA5.d.cts} +1 -1
- package/dist/{extension-types-D07e_NTw.d.ts → extension-types-B78CZfA5.d.ts} +1 -1
- package/dist/graph-extension/index.cjs +18 -18
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +3 -3
- package/dist/{index-CT6nvtxL.d.cts → index-Bilw0pYm.d.cts} +34 -3
- package/dist/{index-DQheiVQV.d.ts → index-CWdBFWbI.d.ts} +34 -3
- package/dist/index.cjs +482 -361
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +153 -37
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +13 -13
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +1 -1
- package/dist/interchange/index.cjs +7 -7
- package/dist/interchange/index.d.cts +7 -5
- package/dist/interchange/index.d.ts +7 -5
- package/dist/interchange/index.js +2 -2
- package/dist/{manager-Cy3dhwYO.d.cts → manager-CWa9cgwb.d.cts} +36 -9
- package/dist/{manager-sZkU2VPC.d.ts → manager-Cfcb2sJL.d.ts} +36 -9
- package/dist/{materialize-indexes-BB9N5uQl.d.cts → materialize-indexes-BQfaAZKA.d.cts} +1 -1
- package/dist/{materialize-indexes-BYpU2RKh.d.ts → materialize-indexes-DFavFQah.d.ts} +1 -1
- package/dist/profiler/index.d.cts +9 -7
- package/dist/profiler/index.d.ts +9 -7
- package/dist/schema/index.cjs +32 -27
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +9 -7
- package/dist/schema/index.d.ts +9 -7
- package/dist/schema/index.js +6 -5
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-h6dta1IJ.d.ts → sqlite-BvSEbybu.d.cts} +320 -1
- package/dist/{sqlite-BhFswiAR.d.cts → sqlite-GKvcDPVn.d.ts} +320 -1
- package/dist/{store-BS_hehiz.d.ts → store-C57kdvAa.d.ts} +155 -5
- package/dist/{store-CkCvqRUf.d.cts → store-Ojf0NOKk.d.cts} +155 -5
- package/dist/{types-BpgACExN.d.cts → types-CF7nDH3q.d.cts} +2 -2
- package/dist/{types-Bz-Pi681.d.ts → types-Cars4JZ1.d.ts} +2 -2
- package/dist/{types-DptZHe-l.d.ts → types-DZPBXZOK.d.cts} +272 -14
- package/dist/{types-WF5ItKQu.d.cts → types-Dzkr0Eqi.d.ts} +272 -14
- package/dist/{where-DZYMiXVq.d.cts → where-BmtjfWuS.d.cts} +2 -2
- package/dist/{where-C40InMIp.d.ts → where-kk1Zz2En.d.ts} +2 -2
- package/package.json +3 -1
- package/dist/chunk-AAA2CR3P.js.map +0 -1
- package/dist/chunk-CLEUFN2K.js.map +0 -1
- package/dist/chunk-CLGC7AQ2.cjs.map +0 -1
- package/dist/chunk-CPFR3O7L.js.map +0 -1
- package/dist/chunk-CQVNGKU7.cjs.map +0 -1
- package/dist/chunk-D2GO3RBL.cjs +0 -12
- package/dist/chunk-DOTEN2FG.js.map +0 -1
- package/dist/chunk-JTI5WT4P.cjs.map +0 -1
- package/dist/chunk-OECDVACY.cjs.map +0 -1
- package/dist/chunk-PSKUWVCB.js.map +0 -1
- package/dist/chunk-QMQYK3IF.cjs.map +0 -1
- package/dist/chunk-W5MTHMTE.cjs.map +0 -1
- package/dist/chunk-YZZBDCLV.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import { K as KindRegistry, G as GraphDef,
|
|
4
|
-
import { A as AnyEdgeType, N as NodeType, T as TemporalMode,
|
|
2
|
+
import { p as SqlDialect, ah as SqlSchema, F as FulltextStrategy, ax as ValueType, ay as PredicateExpression, az as VectorMetricType, a0 as FulltextQueryMode, Q as QueryAst, J as JsonPointer, L as FieldRef, ac as ParameterRef, G as GraphBackend, al as TransactionBackend, a5 as JsonPointerInput, am as TraversalExpansion, aA as Traversal, aB as NodePredicate, aC as ProjectedField, ab as OrderSpec, aD as GroupBySpec, a3 as HybridFusionOptions, aE as RecursiveCyclePolicy, aF as TraversalDirection$1, aG as EdgeRow, aH as NodeRow, U as AdoptedTransaction, K as AggregateExpr, aI as SelectiveField, aJ as ComposableQuery, aK as SetOperationType, aL as SetOperation, ag as SortDirection, m as JsonSchema, aM as VectorMetric } from './types-DZPBXZOK.cjs';
|
|
3
|
+
import { K as KindRegistry, G as GraphDef, u as EdgeKinds, x as NodeKinds, t as AllNodeTypes, c as SchemaManagerOptions, d as SchemaValidationResult } from './manager-CWa9cgwb.cjs';
|
|
4
|
+
import { A as AnyEdgeType, N as NodeType, T as TemporalMode, e as EdgeType, E as EdgeRegistration, h as EdgeId, m as NodeId, b as NodeRegistration, K as KindEntity, f as Cardinality, k as EndpointExistence, d as KindAnnotations, o as UniquenessScope, g as Collation, G as GraphExtension } from './extension-types-B78CZfA5.cjs';
|
|
5
5
|
import { SQL } from 'drizzle-orm';
|
|
6
|
-
import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-
|
|
6
|
+
import { b as MaterializeIndexesOptions, M as MaterializeIndexesResult } from './materialize-indexes-BQfaAZKA.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Embedding type for vector search.
|
|
@@ -1615,6 +1615,41 @@ type GraphEdgeCollections<G extends GraphDef> = {
|
|
|
1615
1615
|
* Provides the same `tx.nodes.*` and `tx.edges.*` API as the Store,
|
|
1616
1616
|
* but operations are executed within the transaction scope.
|
|
1617
1617
|
*
|
|
1618
|
+
* `tx.sql` is the raw Drizzle handle **bound to this same
|
|
1619
|
+
* transaction** — use it to write the caller's own relational tables
|
|
1620
|
+
* inside the graph-owned transaction so both layers commit or roll
|
|
1621
|
+
* back together (the graph-owned counterpart of
|
|
1622
|
+
* {@link Store.withTransaction}, where the caller owns the boundary):
|
|
1623
|
+
*
|
|
1624
|
+
* ```typescript
|
|
1625
|
+
* await store.transaction(async (tx) => {
|
|
1626
|
+
* await tx.nodes.Document.update(documentId, props);
|
|
1627
|
+
* // `tx.sql` is the `AdoptedTransaction` union — cast to your
|
|
1628
|
+
* // concrete Drizzle database type at the call site.
|
|
1629
|
+
* const sqlTx = tx.sql as NodePgDatabase;
|
|
1630
|
+
* await sqlTx.insert(documentVersions).values(versionRow);
|
|
1631
|
+
* await sqlTx.insert(changeEvents).values(eventRow);
|
|
1632
|
+
* });
|
|
1633
|
+
* ```
|
|
1634
|
+
*
|
|
1635
|
+
* Per-backend semantics:
|
|
1636
|
+
* - **Postgres / libsql** (async drivers): `tx.sql` is the Drizzle
|
|
1637
|
+
* transaction handle. Using the outer `db` instead would write on a
|
|
1638
|
+
* *different* connection and silently escape the transaction — so
|
|
1639
|
+
* `tx.sql` is a correctness requirement there.
|
|
1640
|
+
* - **better-sqlite3**: the single connection, framed by TypeGraph's
|
|
1641
|
+
* `BEGIN`/`COMMIT`/`ROLLBACK`.
|
|
1642
|
+
* - **Durable Objects (`do-sqlite`)**: the bound Drizzle handle; the
|
|
1643
|
+
* storage transaction is ambient, so writing the outer `db` also
|
|
1644
|
+
* enlists — `tx.sql` is the explicit, portable form.
|
|
1645
|
+
*
|
|
1646
|
+
* It is `undefined` only on the non-transactional fallback
|
|
1647
|
+
* (`backend.capabilities.transactions === false` — e.g. Cloudflare
|
|
1648
|
+
* D1, `drizzle-orm/neon-http`), where `store.transaction()` runs the
|
|
1649
|
+
* callback with no atomicity and there is no transaction to enlist.
|
|
1650
|
+
* Its type is the `AdoptedTransaction` union; cast to your concrete
|
|
1651
|
+
* Drizzle database type at the call site.
|
|
1652
|
+
*
|
|
1618
1653
|
* @example
|
|
1619
1654
|
* ```typescript
|
|
1620
1655
|
* await store.transaction(async (tx) => {
|
|
@@ -1627,6 +1662,7 @@ type GraphEdgeCollections<G extends GraphDef> = {
|
|
|
1627
1662
|
type TransactionContext<G extends GraphDef> = Readonly<{
|
|
1628
1663
|
nodes: GraphNodeCollections<G>;
|
|
1629
1664
|
edges: GraphEdgeCollections<G>;
|
|
1665
|
+
sql?: AdoptedTransaction;
|
|
1630
1666
|
}>;
|
|
1631
1667
|
/**
|
|
1632
1668
|
* Replace branded `NodeId` / `EdgeId` with plain `string` in each
|
|
@@ -3341,6 +3377,12 @@ declare class Store<G extends GraphDef> {
|
|
|
3341
3377
|
* The transaction context provides the same collection API as the Store:
|
|
3342
3378
|
* - `tx.nodes.Person.create(...)` - Create a node
|
|
3343
3379
|
* - `tx.edges.worksAt.create(...)` - Create an edge
|
|
3380
|
+
* - `tx.sql` - the raw Drizzle handle **bound to this same
|
|
3381
|
+
* transaction**, for writing the caller's own relational tables in
|
|
3382
|
+
* the same atomic boundary (the graph-owned counterpart of
|
|
3383
|
+
* {@link Store.withTransaction}). See {@link TransactionContext}
|
|
3384
|
+
* for per-backend semantics; it is `undefined` only on the
|
|
3385
|
+
* non-transactional fallback.
|
|
3344
3386
|
*
|
|
3345
3387
|
* @example
|
|
3346
3388
|
* ```typescript
|
|
@@ -3355,6 +3397,16 @@ declare class Store<G extends GraphDef> {
|
|
|
3355
3397
|
* });
|
|
3356
3398
|
* ```
|
|
3357
3399
|
*
|
|
3400
|
+
* @example Cross-store write via `tx.sql` (graph-owned boundary):
|
|
3401
|
+
* ```typescript
|
|
3402
|
+
* await store.transaction(async (tx) => {
|
|
3403
|
+
* await tx.nodes.Document.update(documentId, props);
|
|
3404
|
+
* // cast `tx.sql` to your concrete Drizzle database type
|
|
3405
|
+
* const sqlTx = tx.sql as NodePgDatabase;
|
|
3406
|
+
* await sqlTx.insert(documentVersions).values(versionRow);
|
|
3407
|
+
* });
|
|
3408
|
+
* ```
|
|
3409
|
+
*
|
|
3358
3410
|
* **Backends without transactions.** When `backend.capabilities.transactions`
|
|
3359
3411
|
* is `false` (Cloudflare D1, `drizzle-orm/neon-http`), this method runs the
|
|
3360
3412
|
* callback against the same backend used outside `transaction()` — writes
|
|
@@ -3371,6 +3423,62 @@ declare class Store<G extends GraphDef> {
|
|
|
3371
3423
|
* ```
|
|
3372
3424
|
*/
|
|
3373
3425
|
transaction<T>(fn: (tx: TransactionContext<G>) => Promise<T>): Promise<T>;
|
|
3426
|
+
/**
|
|
3427
|
+
* Adopts a caller-owned, already-open Drizzle transaction so the graph
|
|
3428
|
+
* store and the caller's relational writes commit or roll back as one
|
|
3429
|
+
* Postgres/SQLite transaction (#134).
|
|
3430
|
+
*
|
|
3431
|
+
* Use this when the **relational layer owns the transaction**: the
|
|
3432
|
+
* caller has opened a transaction and needs TypeGraph writes enlisted
|
|
3433
|
+
* on the *same* connection. Unlike {@link transaction}, this opens no
|
|
3434
|
+
* transaction — the caller's transaction is the single commit/rollback
|
|
3435
|
+
* boundary.
|
|
3436
|
+
*
|
|
3437
|
+
* `withTransaction` is driver-agnostic; how the caller opens the
|
|
3438
|
+
* transaction is not. **Async drivers** (node-postgres,
|
|
3439
|
+
* `neon-serverless` Pool, libsql) use `db.transaction(async …)`.
|
|
3440
|
+
* **Synchronous `better-sqlite3`** cannot — its driver rejects an
|
|
3441
|
+
* `async` transaction callback (`Transaction function cannot return a
|
|
3442
|
+
* promise`) and the async continuation would run outside the
|
|
3443
|
+
* rolled-back transaction — so the caller opens the transaction with
|
|
3444
|
+
* explicit `BEGIN`/`COMMIT`/`ROLLBACK` on the single connection
|
|
3445
|
+
* instead. See the "Cross-Store Transactions" recipe for both shapes.
|
|
3446
|
+
*
|
|
3447
|
+
* The returned context reuses this store's already-resolved
|
|
3448
|
+
* schema/registry: it runs **no** schema bootstrap, `evolve`, or
|
|
3449
|
+
* migration, and emits **no DDL** inside the caller's transaction.
|
|
3450
|
+
* Fulltext operations assert the durable materialization marker (a
|
|
3451
|
+
* cached SELECT) and throw {@link StoreNotInitializedError} on a
|
|
3452
|
+
* missing/stale/failed marker rather than migrating mid-transaction —
|
|
3453
|
+
* so boot the parent store via `createStoreWithSchema` once at
|
|
3454
|
+
* startup.
|
|
3455
|
+
*
|
|
3456
|
+
* @example
|
|
3457
|
+
* ```typescript
|
|
3458
|
+
* // Async driver (Postgres / libsql):
|
|
3459
|
+
* await db.transaction(async (sqlTx) => {
|
|
3460
|
+
* const connector = await createConnectorRow(sqlTx, input); // Drizzle
|
|
3461
|
+
* const txStore = store.withTransaction(sqlTx);
|
|
3462
|
+
* await txStore.nodes.ArtifactSource.create({ // TypeGraph
|
|
3463
|
+
* connectorId: connector.id,
|
|
3464
|
+
* });
|
|
3465
|
+
* }); // one COMMIT / ROLLBACK across both layers
|
|
3466
|
+
* ```
|
|
3467
|
+
*
|
|
3468
|
+
* @throws {ConfigurationError} when the backend cannot adopt an
|
|
3469
|
+
* external transaction — either it is not a Drizzle Postgres/SQLite
|
|
3470
|
+
* backend, or `backend.capabilities.transactions` is `false`
|
|
3471
|
+
* (`drizzle-orm/neon-http`, Cloudflare D1, SQLite
|
|
3472
|
+
* `transactionMode: "none"`). A non-atomic fallback is deliberately
|
|
3473
|
+
* not offered here: the caller's relational write *would* still
|
|
3474
|
+
* commit, defeating the purpose of cross-store atomicity.
|
|
3475
|
+
* @throws {StoreNotInitializedError} at point of use, when a fulltext
|
|
3476
|
+
* operation on the returned context observes a missing/stale/failed
|
|
3477
|
+
* durable materialization marker (parent store not booted via
|
|
3478
|
+
* `createStoreWithSchema`). Rolls back the caller's transaction
|
|
3479
|
+
* without emitting any DDL.
|
|
3480
|
+
*/
|
|
3481
|
+
withTransaction(externalTx: AdoptedTransaction): TransactionContext<G>;
|
|
3374
3482
|
/**
|
|
3375
3483
|
* Hard-deletes all data for this graph from the database.
|
|
3376
3484
|
*
|
|
@@ -3658,5 +3766,47 @@ declare function createStore<G extends GraphDef>(graph: G, backend: GraphBackend
|
|
|
3658
3766
|
* ```
|
|
3659
3767
|
*/
|
|
3660
3768
|
declare function createStoreWithSchema<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions & SchemaManagerOptions): Promise<[Store<G>, SchemaValidationResult]>;
|
|
3769
|
+
/**
|
|
3770
|
+
* Creates a Store after **verifying** that the database is at the same
|
|
3771
|
+
* schema version as the code graph — without running any DDL, bootstrap,
|
|
3772
|
+
* or marker writes. The runtime counterpart of `createStoreWithSchema`
|
|
3773
|
+
* for the deployment model in "Database roles & least privilege":
|
|
3774
|
+
*
|
|
3775
|
+
* - **`createStoreWithSchema(graph, backend)`** runs DDL (bootstrap,
|
|
3776
|
+
* safe auto-migrations, durable contribution materialization). Run it
|
|
3777
|
+
* once at startup under a privileged role that holds `CREATE` / DDL.
|
|
3778
|
+
* - **`createVerifiedStore(graph, backend)`** is the zero-DDL runtime
|
|
3779
|
+
* attach with a verification gate. Throws `MigrationError` when the
|
|
3780
|
+
* persisted schema is behind the code graph (any pending change, safe
|
|
3781
|
+
* or breaking), `ConfigurationError` when no schema has been
|
|
3782
|
+
* initialized, or `StoreNotInitializedError` when the schema is
|
|
3783
|
+
* current but the runtime-contribution markers are missing/stale.
|
|
3784
|
+
* The runtime can use a least-privilege, DML-only database role.
|
|
3785
|
+
* - **`createStore(graph, backend)`** is the same zero-DDL attach
|
|
3786
|
+
* *without* the verification gate — fastest, but schema drift goes
|
|
3787
|
+
* undetected until a hot-path operation trips.
|
|
3788
|
+
*
|
|
3789
|
+
* Folds any persisted graph-extension document into the supplied graph
|
|
3790
|
+
* before building the Store, just like `createStoreWithSchema`.
|
|
3791
|
+
*
|
|
3792
|
+
* @param graph - The graph definition
|
|
3793
|
+
* @param backend - The database backend
|
|
3794
|
+
* @param options - Optional store configuration
|
|
3795
|
+
* @returns A tuple of [store, validationResult] — `result.status` is
|
|
3796
|
+
* always `"unchanged"` on success
|
|
3797
|
+
*
|
|
3798
|
+
* @example
|
|
3799
|
+
* ```typescript
|
|
3800
|
+
* // Runtime — least-privilege, DML-only role. Zero DDL.
|
|
3801
|
+
* const [store, result] = await createVerifiedStore(graph, backend);
|
|
3802
|
+
* // result.status === "unchanged" — the privileged migrator is current.
|
|
3803
|
+
* ```
|
|
3804
|
+
*
|
|
3805
|
+
* @throws ConfigurationError if no schema has been initialized.
|
|
3806
|
+
* @throws MigrationError if the persisted schema is behind the code graph.
|
|
3807
|
+
* @throws StoreNotInitializedError if runtime-contribution markers are
|
|
3808
|
+
* missing/stale/failed for this graph on this connection.
|
|
3809
|
+
*/
|
|
3810
|
+
declare function createVerifiedStore<G extends GraphDef>(graph: G, backend: GraphBackend, options?: StoreOptions): Promise<[Store<G>, SchemaValidationResult]>;
|
|
3661
3811
|
|
|
3662
|
-
export { type MaterializeRemovalsOptions as $, type AliasMap as A, type BaseTraversalOptions as B, type CreateQueryBuilderOptions as C, DEFAULT_SEARCHABLE_LANGUAGE as D, type EdgeAliasMap as E, type EmbeddingSchema as F, type EmbeddingValue as G, ExecutableAggregateQuery as H, ExecutableQuery as I, type FieldAccessor as J, type FulltextSearchHit as K, type FulltextSearchOptions as L, type GetOrCreateAction as M, type GraphAlgorithms as N, type GraphEdgeCollections as O, type GraphNodeCollections as P, QueryBuilder as Q, type HookContext as R, Store as S, TraversalBuilder as T, type HybridFulltextOptions as U, type HybridSearchHit as V, type HybridSearchOptions as W, type HybridVectorOptions as X, type IfExistsMode as Y, type KindIntrospection as Z, type MaterializeRemovalsEntry as _, type AggregateResult as a,
|
|
3812
|
+
export { type MaterializeRemovalsOptions as $, type AliasMap as A, type BaseTraversalOptions as B, type CreateQueryBuilderOptions as C, DEFAULT_SEARCHABLE_LANGUAGE as D, type EdgeAliasMap as E, type EmbeddingSchema as F, type EmbeddingValue as G, ExecutableAggregateQuery as H, ExecutableQuery as I, type FieldAccessor as J, type FulltextSearchHit as K, type FulltextSearchOptions as L, type GetOrCreateAction as M, type GraphAlgorithms as N, type GraphEdgeCollections as O, type GraphNodeCollections as P, QueryBuilder as Q, type HookContext as R, Store as S, TraversalBuilder as T, type HybridFulltextOptions as U, type HybridSearchHit as V, type HybridSearchOptions as W, type HybridVectorOptions as X, type IfExistsMode as Y, type KindIntrospection as Z, type MaterializeRemovalsEntry as _, type AggregateResult as a, getEmbeddingDimensions as a$, type MaterializeRemovalsResult as a0, type NeighborsOptions as a1, type Node as a2, type NodeAccessor as a3, type NodeAlias as a4, type NodeCollection as a5, type NodeGetOrCreateByConstraintOptions as a6, type NodeGetOrCreateByConstraintResult as a7, type NodeIdentifier as a8, type NodeRef as a9, type StoreProjection as aA, type StoreRef as aB, StoreSearch as aC, type StreamOptions as aD, type SubgraphEdgeResult as aE, type SubgraphNodeResult as aF, type SubgraphOptions as aG, type SubgraphResult as aH, type SubsetEdge as aI, type SubsetNode as aJ, type TemporalAlgorithmOptions as aK, type TransactionContext as aL, type TraversalDirection as aM, type TypedEdgeCollection as aN, UnionableQuery as aO, type UniqueIntrospection as aP, type UpdateEdgeInput as aQ, type UpdateNodeInput as aR, type VectorSearchHit as aS, type VectorSearchOptions as aT, createStore as aU, createStoreWithSchema as aV, createVerifiedStore as aW, defineSubgraphProject as aX, embedding as aY, exists as aZ, fieldRef as a_, type OntologyIntrospection as aa, type OperationHookContext as ab, type PaginateOptions as ac, type PaginatedResult as ad, type PathNode as ae, type Predicate as af, PreparedQuery as ag, type PropsAccessor as ah, type QueryHookContext as ai, type QueryOptions as aj, type ReachableNode as ak, type ReachableOptions as al, type RebuildFulltextOptions as am, type RebuildFulltextResult as an, type RecursiveTraversalOptions as ao, type SchemaIntrospection as ap, type SearchableMetadata as aq, type SearchableOptions as ar, type SearchableSchema as as, type SelectContext as at, type SelectableEdge as au, type SelectableNode as av, type ShortestPathOptions as aw, type ShortestPathResult as ax, type StoreHooks as ay, type StoreOptions as az, type AlgorithmCyclePolicy as b, getSearchableMetadata as b0, inSubquery as b1, isEmbeddingSchema as b2, isParameterRef as b3, isSearchableSchema as b4, notExists as b5, notInSubquery as b6, param as b7, searchable as b8, type AnyEdge as c, type AnyNode as d, type BatchResults as e, type BatchableQuery as f, type ConstraintNames as g, type CreateEdgeInput as h, type CreateNodeInput as i, type DegreeOptions as j, type DynamicEdgeAccessor as k, type DynamicEdgeCollection as l, type DynamicEdgeType as m, type DynamicFieldBuilder as n, type DynamicNodeAccessor as o, type DynamicNodeCollection as p, type DynamicNodeType as q, type DynamicSelectableEdge as r, type DynamicSelectableNode as s, type Edge as t, type EdgeAccessor as u, type EdgeCollection as v, type EdgeFindByEndpointsOptions as w, type EdgeGetOrCreateByEndpointsOptions as x, type EdgeGetOrCreateByEndpointsResult as y, type EdgeIntrospection as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as KindEntity } from './extension-types-
|
|
2
|
-
import { J as JsonPointer } from './types-
|
|
1
|
+
import { K as KindEntity } from './extension-types-B78CZfA5.cjs';
|
|
2
|
+
import { J as JsonPointer } from './types-DZPBXZOK.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* QueryProfiler types.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { K as KindEntity } from './extension-types-
|
|
2
|
-
import { J as JsonPointer } from './types-
|
|
1
|
+
import { K as KindEntity } from './extension-types-B78CZfA5.js';
|
|
2
|
+
import { J as JsonPointer } from './types-Dzkr0Eqi.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* QueryProfiler types.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { N as NodeType,
|
|
2
|
+
import { N as NodeType, e as EdgeType, o as UniquenessScope, g as Collation, D as DeleteBehavior, d as KindAnnotations, f as Cardinality, k as EndpointExistence, T as TemporalMode, G as GraphExtension, I as IndexEntity, K as KindEntity, a as NullCheckOp, A as AnyEdgeType } from './extension-types-B78CZfA5.cjs';
|
|
3
3
|
import { SQL } from 'drizzle-orm';
|
|
4
|
+
import { PgDatabase, PgQueryResultHKT } from 'drizzle-orm/pg-core';
|
|
5
|
+
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
4
6
|
|
|
5
7
|
/** Brand key for MetaEdge */
|
|
6
8
|
declare const META_EDGE_BRAND: "__metaEdge";
|
|
@@ -170,6 +172,64 @@ declare function createSqlSchema(names?: Partial<SqlTableNames>): SqlSchema;
|
|
|
170
172
|
*/
|
|
171
173
|
declare const DEFAULT_SQL_SCHEMA: SqlSchema;
|
|
172
174
|
|
|
175
|
+
/**
|
|
176
|
+
* A single table TypeGraph owns.
|
|
177
|
+
*/
|
|
178
|
+
type TableContribution = Readonly<{
|
|
179
|
+
/**
|
|
180
|
+
* Stable, graph- and deployment-independent identity for the logical
|
|
181
|
+
* slot this contribution fills (e.g. `"fulltext"`). NOT the physical
|
|
182
|
+
* table name. Stable across table-name overrides and across strategy
|
|
183
|
+
* swaps of the *same* logical slot, so #135's durable marker can
|
|
184
|
+
* survive both.
|
|
185
|
+
*/
|
|
186
|
+
logicalName: string;
|
|
187
|
+
/**
|
|
188
|
+
* Identifies the producer of this contribution (e.g. a strategy id
|
|
189
|
+
* like `"tsvector"` / `"fts5"`, or `"base"` for core schema tables).
|
|
190
|
+
* Part of the #135 materialization identity and an input to the
|
|
191
|
+
* drift signature — a strategy swap on the same `logicalName` is a
|
|
192
|
+
* legitimate, detectable drift, not a silent reuse.
|
|
193
|
+
*/
|
|
194
|
+
owner: string;
|
|
195
|
+
/**
|
|
196
|
+
* Resolved physical table name after any per-deployment name
|
|
197
|
+
* override. Part of the #135 materialization identity (custom names
|
|
198
|
+
* must be distinguishable) and used by diagnostics / the focused
|
|
199
|
+
* bootstrap ensure.
|
|
200
|
+
*/
|
|
201
|
+
tableName: string;
|
|
202
|
+
/**
|
|
203
|
+
* Idempotent (`CREATE ... IF NOT EXISTS`) statements that
|
|
204
|
+
* materialize this contribution's table **and its supporting
|
|
205
|
+
* indexes**. Running the full list is how the runtime ensure
|
|
206
|
+
* self-heals partial states (table present, index missing) — it is
|
|
207
|
+
* not a probe-and-skip. Deterministic for a given resolved
|
|
208
|
+
* configuration: the canonical normalized input to #135's drift
|
|
209
|
+
* signature.
|
|
210
|
+
*/
|
|
211
|
+
createDdl: readonly string[];
|
|
212
|
+
/**
|
|
213
|
+
* When `true`, the post-schema-load focused ensure
|
|
214
|
+
* (`loadActiveSchemaWithBootstrap`) materializes this contribution
|
|
215
|
+
* on every successful schema load.
|
|
216
|
+
*
|
|
217
|
+
* **Invariant: only strategy-declared contributions may set this.**
|
|
218
|
+
* Core/base tables are always `false` — they are created by
|
|
219
|
+
* drizzle-kit / `bootstrapTables`. This is what lets the boot path
|
|
220
|
+
* derive runtime contributions straight from the strategy
|
|
221
|
+
* (`fulltextStrategy.ownedTables`) without walking — and generating
|
|
222
|
+
* DDL for — every base table.
|
|
223
|
+
*/
|
|
224
|
+
runtimeEnsure: boolean;
|
|
225
|
+
}>;
|
|
226
|
+
/**
|
|
227
|
+
* A table a {@link FulltextStrategy} declares it owns. An alias, not a
|
|
228
|
+
* distinct shape: a strategy's declaration is already authoritative
|
|
229
|
+
* (no resolution step). The name documents the producer role.
|
|
230
|
+
*/
|
|
231
|
+
type StrategyTableContribution = TableContribution;
|
|
232
|
+
|
|
173
233
|
/**
|
|
174
234
|
* Fulltext Strategy — pluggable DDL + SQL generation for a dialect's
|
|
175
235
|
* fulltext stack. A strategy owns every SQL statement that touches its
|
|
@@ -245,11 +305,20 @@ interface FulltextStrategy {
|
|
|
245
305
|
*/
|
|
246
306
|
snippetExpression(tableName: string, query: string, mode: FulltextQueryMode, language?: string): SQL;
|
|
247
307
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
* `
|
|
308
|
+
* The tables this strategy owns, as Drizzle-free, already
|
|
309
|
+
* authoritative `TableContribution`s (`logicalName`, `owner`,
|
|
310
|
+
* resolved `tableName`, idempotent `createDdl` for the table **and
|
|
311
|
+
* its supporting indexes**, `runtimeEnsure`). A strategy never
|
|
312
|
+
* constructs a Drizzle table itself; drizzle-kit visibility, when
|
|
313
|
+
* applicable, is the schema barrel's responsibility (the default
|
|
314
|
+
* Postgres strategy's `schema/postgres.ts` exports a matching
|
|
315
|
+
* `tables.fulltext` — a non-default strategy must export its own).
|
|
316
|
+
*
|
|
317
|
+
* Replaces the former `generateDdl(tableName)`: DDL is now one field
|
|
318
|
+
* of a contribution rather than the strategy's whole storage
|
|
319
|
+
* surface. (Public API change — see #129.)
|
|
251
320
|
*/
|
|
252
|
-
|
|
321
|
+
ownedTables(primaryTableName: string): readonly StrategyTableContribution[];
|
|
253
322
|
/**
|
|
254
323
|
* Emits the statements that upsert a single fulltext row. Returns one
|
|
255
324
|
* or more statements — some backends (SQLite FTS5) cannot emulate
|
|
@@ -445,6 +514,33 @@ type SerializedSchema = Readonly<{
|
|
|
445
514
|
*/
|
|
446
515
|
type SchemaHash = string;
|
|
447
516
|
|
|
517
|
+
type AnyPgDatabase = PgDatabase<PgQueryResultHKT, Record<string, unknown>>;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Controls how the backend manages SQLite transactions.
|
|
521
|
+
*
|
|
522
|
+
* - `"sql"`: TypeGraph issues BEGIN / COMMIT / ROLLBACK SQL directly.
|
|
523
|
+
* Default for sync drivers (better-sqlite3, bun:sqlite).
|
|
524
|
+
* - `"drizzle"`: Delegates to Drizzle's `db.transaction()` method.
|
|
525
|
+
* Default for async drivers (libsql, sql.js).
|
|
526
|
+
* - `"do-sqlite"`: Delegates to the Cloudflare Durable Objects async
|
|
527
|
+
* storage transaction runner (`db.$client.transaction`,
|
|
528
|
+
* i.e. `ctx.storage.transaction(async ...)`). Drizzle's
|
|
529
|
+
* own `db.transaction()` on DO is
|
|
530
|
+
* `ctx.storage.transactionSync` and cannot span `await`,
|
|
531
|
+
* so it is deliberately not used. Auto-detected for
|
|
532
|
+
* `drizzle(ctx.storage)` (#140).
|
|
533
|
+
* - `"none"`: Transactions disabled. Default for Cloudflare D1
|
|
534
|
+
* (`D1Database.batch` is transactional but not an
|
|
535
|
+
* interactive runner — tracked separately).
|
|
536
|
+
*/
|
|
537
|
+
type SqliteTransactionMode = "sql" | "drizzle" | "none" | "do-sqlite";
|
|
538
|
+
type SqliteExecutionProfileHints = Readonly<{
|
|
539
|
+
isSync?: boolean;
|
|
540
|
+
transactionMode?: SqliteTransactionMode;
|
|
541
|
+
}>;
|
|
542
|
+
type AnySqliteDatabase = BaseSQLiteDatabase<"sync" | "async", unknown>;
|
|
543
|
+
|
|
448
544
|
/**
|
|
449
545
|
* SQL Dialect Abstraction Layer
|
|
450
546
|
*
|
|
@@ -914,6 +1010,63 @@ type RecordIndexMaterializationParams = Readonly<{
|
|
|
914
1010
|
/** Error message on failure; undefined on success (clears existing). */
|
|
915
1011
|
error: string | undefined;
|
|
916
1012
|
}>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Durable identity of a strategy-owned table contribution (#129),
|
|
1015
|
+
* scoped to a graph. This is the primary key of
|
|
1016
|
+
* `typegraph_contribution_materializations`.
|
|
1017
|
+
*
|
|
1018
|
+
* `logicalName` is the stable slot ("fulltext"); `owner` is the
|
|
1019
|
+
* producing strategy ("tsvector" / "fts5"); `tableName` is the resolved
|
|
1020
|
+
* physical name (custom per-deployment names must be distinguishable).
|
|
1021
|
+
* `graphId` is part of identity here — unlike the index status table
|
|
1022
|
+
* where the physical index name is database-global, two graphs can each
|
|
1023
|
+
* own a logically-identical fulltext contribution.
|
|
1024
|
+
*/
|
|
1025
|
+
type ContributionMaterializationIdentity = Readonly<{
|
|
1026
|
+
graphId: string;
|
|
1027
|
+
logicalName: string;
|
|
1028
|
+
owner: string;
|
|
1029
|
+
tableName: string;
|
|
1030
|
+
}>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Per-deployment record that a strategy-owned contribution has been
|
|
1033
|
+
* durably materialized against this database.
|
|
1034
|
+
*
|
|
1035
|
+
* `signature` is intentionally NOT part of the identity: a row with the
|
|
1036
|
+
* same identity but a different signature means "materialized artifact
|
|
1037
|
+
* is stale/drifted" — a loud error on the hot path, never a silent
|
|
1038
|
+
* re-materialize. `materializedAt` is undefined until the first
|
|
1039
|
+
* successful materialization; `lastAttemptedAt` is always set.
|
|
1040
|
+
*/
|
|
1041
|
+
type ContributionMaterializationRow = Readonly<{
|
|
1042
|
+
graphId: string;
|
|
1043
|
+
logicalName: string;
|
|
1044
|
+
owner: string;
|
|
1045
|
+
tableName: string;
|
|
1046
|
+
signature: string;
|
|
1047
|
+
materializedAt: string | undefined;
|
|
1048
|
+
lastAttemptedAt: string;
|
|
1049
|
+
lastError: string | undefined;
|
|
1050
|
+
}>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Parameters for upserting a contribution-materialization attempt.
|
|
1053
|
+
* Same success/failure contract as
|
|
1054
|
+
* {@link RecordIndexMaterializationParams}: on failure pass undefined
|
|
1055
|
+
* `materializedAt` so a prior successful timestamp is preserved via
|
|
1056
|
+
* COALESCE, and the error message.
|
|
1057
|
+
*/
|
|
1058
|
+
type RecordContributionMaterializationParams = Readonly<{
|
|
1059
|
+
graphId: string;
|
|
1060
|
+
logicalName: string;
|
|
1061
|
+
owner: string;
|
|
1062
|
+
tableName: string;
|
|
1063
|
+
signature: string;
|
|
1064
|
+
attemptedAt: string;
|
|
1065
|
+
/** ISO timestamp on success; undefined on failure (preserves existing). */
|
|
1066
|
+
materializedAt: string | undefined;
|
|
1067
|
+
/** Error message on failure; undefined on success (clears existing). */
|
|
1068
|
+
error: string | undefined;
|
|
1069
|
+
}>;
|
|
917
1070
|
/**
|
|
918
1071
|
* One row of the per-deployment `typegraph_kind_removals` table:
|
|
919
1072
|
* a graph-extension kind that has been removed from the schema and whose
|
|
@@ -955,6 +1108,21 @@ type TransactionOptions = Readonly<{
|
|
|
955
1108
|
/** Transaction isolation level (if supported) */
|
|
956
1109
|
isolationLevel?: "read_uncommitted" | "read_committed" | "repeatable_read" | "serializable";
|
|
957
1110
|
}>;
|
|
1111
|
+
/**
|
|
1112
|
+
* A caller-owned, already-open Drizzle transaction handle that a
|
|
1113
|
+
* TypeGraph store can adopt so both layers commit/rollback together.
|
|
1114
|
+
*
|
|
1115
|
+
* The literal client the caller's transaction runs on — a `PgDatabase`
|
|
1116
|
+
* transaction (node-postgres / `neon-serverless` Pool) or a
|
|
1117
|
+
* `BaseSQLiteDatabase` connection. Async drivers obtain it from
|
|
1118
|
+
* `db.transaction(async (tx) => …)`; synchronous `better-sqlite3` (whose
|
|
1119
|
+
* driver rejects an `async` transaction callback) passes the connection
|
|
1120
|
+
* itself under an explicit `BEGIN`/`COMMIT`/`ROLLBACK`. Passing it to
|
|
1121
|
+
* {@link GraphBackend.adoptTransaction} threads that *literal* client
|
|
1122
|
+
* through TypeGraph's SQL, so graph writes and the caller's own
|
|
1123
|
+
* relational writes share one Postgres/SQLite transaction (#134).
|
|
1124
|
+
*/
|
|
1125
|
+
type AdoptedTransaction = AnyPgDatabase | AnySqliteDatabase;
|
|
958
1126
|
/**
|
|
959
1127
|
* Transaction backend — a backend scoped to a transaction.
|
|
960
1128
|
*
|
|
@@ -968,7 +1136,7 @@ type TransactionOptions = Readonly<{
|
|
|
968
1136
|
* exists to eliminate. Schema commits go through the top-level backend
|
|
969
1137
|
* methods only.
|
|
970
1138
|
*/
|
|
971
|
-
type TransactionBackend = Omit<GraphBackend, "transaction" | "close" | "refreshStatistics" | "commitSchemaVersion" | "setActiveVersion">;
|
|
1139
|
+
type TransactionBackend = Omit<GraphBackend, "transaction" | "adoptTransaction" | "close" | "refreshStatistics" | "commitSchemaVersion" | "setActiveVersion">;
|
|
972
1140
|
/**
|
|
973
1141
|
* The GraphBackend interface abstracts database operations.
|
|
974
1142
|
*
|
|
@@ -1107,6 +1275,40 @@ type GraphBackend = Readonly<{
|
|
|
1107
1275
|
* timestamp survives across error windows.
|
|
1108
1276
|
*/
|
|
1109
1277
|
recordIndexMaterialization?: (params: RecordIndexMaterializationParams) => Promise<void>;
|
|
1278
|
+
/**
|
|
1279
|
+
* Idempotently ensure ONLY the
|
|
1280
|
+
* `typegraph_contribution_materializations` table exists. Same
|
|
1281
|
+
* focused-bootstrap rationale as `ensureIndexMaterializationsTable`:
|
|
1282
|
+
* a single `CREATE TABLE IF NOT EXISTS` is concurrency-safe under
|
|
1283
|
+
* replica startup, where the full `bootstrapTables` set risks a
|
|
1284
|
+
* Postgres SHARE-lock deadlock.
|
|
1285
|
+
*/
|
|
1286
|
+
ensureContributionMaterializationsTable?: () => Promise<void>;
|
|
1287
|
+
/**
|
|
1288
|
+
* Look up the durable materialization marker for one strategy-owned
|
|
1289
|
+
* contribution identity. Returns `undefined` when no row exists
|
|
1290
|
+
* ("never initialized").
|
|
1291
|
+
*/
|
|
1292
|
+
getContributionMaterialization?: (identity: ContributionMaterializationIdentity) => Promise<ContributionMaterializationRow | undefined>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Upsert a contribution-materialization attempt — success or failure.
|
|
1295
|
+
* Failure rows preserve any prior `materializedAt` via COALESCE so a
|
|
1296
|
+
* later failed re-attempt doesn't erase the historical success.
|
|
1297
|
+
*/
|
|
1298
|
+
recordContributionMaterialization?: (params: RecordContributionMaterializationParams) => Promise<void>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Resolve (once per backend instance, cached) and assert the durable
|
|
1301
|
+
* materialization markers for every `runtimeEnsure` contribution this
|
|
1302
|
+
* backend's strategy declares, for `graphId`. Throws
|
|
1303
|
+
* `StoreNotInitializedError` when a marker is missing, stale
|
|
1304
|
+
* (signature drift), or recorded a failed last attempt.
|
|
1305
|
+
*
|
|
1306
|
+
* This is the single read-side gate the fulltext hot-path wrappers
|
|
1307
|
+
* and `store.transaction()` consult. It performs ZERO DDL and ZERO
|
|
1308
|
+
* marker writes — initialization is the exclusive job of the async
|
|
1309
|
+
* boot path (`createStoreWithSchema` → `ensureRuntimeContributions`).
|
|
1310
|
+
*/
|
|
1311
|
+
assertRuntimeContributionsInitialized?: (graphId: string) => Promise<void>;
|
|
1110
1312
|
/**
|
|
1111
1313
|
* Bootstraps the per-deployment `typegraph_kind_removals` table so
|
|
1112
1314
|
* `store.removeKinds()` and `store.materializeRemovals()` can persist
|
|
@@ -1149,15 +1351,32 @@ type GraphBackend = Readonly<{
|
|
|
1149
1351
|
* deadlock under concurrent replica startup.
|
|
1150
1352
|
*/
|
|
1151
1353
|
ensureReconciliationMarkersTable?: () => Promise<void>;
|
|
1354
|
+
/**
|
|
1355
|
+
* Materializes every contribution flagged `runtimeEnsure` — the
|
|
1356
|
+
* strategy-owned runtime tables (fulltext today) that drizzle-kit-
|
|
1357
|
+
* managed setups don't create. Called once after a successful schema
|
|
1358
|
+
* load. Deliberately scoped: base/drizzle-visible tables are
|
|
1359
|
+
* `runtimeEnsure: false`, so this does not regress startup into
|
|
1360
|
+
* broad DDL/probing across every table.
|
|
1361
|
+
*
|
|
1362
|
+
* The canonical durable-marker writer (#135): for each runtime
|
|
1363
|
+
* contribution it short-circuits when the marker already records a
|
|
1364
|
+
* matching signature, otherwise runs the idempotent `createDdl` and
|
|
1365
|
+
* records the marker (success or failure) keyed by `graphId`.
|
|
1366
|
+
*/
|
|
1367
|
+
ensureRuntimeContributions?: (graphId: string) => Promise<void>;
|
|
1152
1368
|
/**
|
|
1153
1369
|
* Bootstraps the fulltext storage table the active `FulltextStrategy`
|
|
1154
|
-
* owns
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1370
|
+
* owns. Same focused-bootstrap rationale as the other `ensure*Table`
|
|
1371
|
+
* methods: idempotent and concurrency-safe under replica startup.
|
|
1372
|
+
*
|
|
1373
|
+
* Superseded by `ensureRuntimeContributions()` (#129); retained as
|
|
1374
|
+
* a thin back-compat wrapper for backends/callers predating #129. Not
|
|
1375
|
+
* machine-`@deprecated` because the manager still calls it as the
|
|
1376
|
+
* pre-#129 fallback. #135 removed the remaining hot-path callers and
|
|
1377
|
+
* routed this through the durable-marker writer.
|
|
1159
1378
|
*/
|
|
1160
|
-
ensureFulltextTable?: () => Promise<void>;
|
|
1379
|
+
ensureFulltextTable?: (graphId: string) => Promise<void>;
|
|
1161
1380
|
/**
|
|
1162
1381
|
* Read the high-water mark schema version for which
|
|
1163
1382
|
* `materializeRemovals` reconciliation has already verified history
|
|
@@ -1225,7 +1444,46 @@ type GraphBackend = Readonly<{
|
|
|
1225
1444
|
* statement outside `transaction(...)`.
|
|
1226
1445
|
*/
|
|
1227
1446
|
executeDdl?: (ddl: string) => Promise<void>;
|
|
1228
|
-
|
|
1447
|
+
/**
|
|
1448
|
+
* `fn` receives the tx-scoped backend and the raw Drizzle handle
|
|
1449
|
+
* **bound to that same transaction** (`AdoptedTransaction`). The
|
|
1450
|
+
* store surfaces the second argument as `TransactionContext.sql` so
|
|
1451
|
+
* callers can write their own relational tables inside the
|
|
1452
|
+
* graph-owned transaction. Implementations MUST pass the *exact*
|
|
1453
|
+
* handle the tx-scoped backend writes through (the Postgres/libsql
|
|
1454
|
+
* tx handle; for better-sqlite3 / do-sqlite the bound connection),
|
|
1455
|
+
* never a fresh one.
|
|
1456
|
+
*/
|
|
1457
|
+
transaction: <T>(fn: (tx: TransactionBackend, sql: AdoptedTransaction) => Promise<T>, options?: TransactionOptions) => Promise<T>;
|
|
1458
|
+
/**
|
|
1459
|
+
* Adopt a caller-owned, already-open transaction (#134).
|
|
1460
|
+
*
|
|
1461
|
+
* Returns a transaction-scoped backend bound to the *exact*
|
|
1462
|
+
* `externalTx` client, reusing this backend's already-resolved
|
|
1463
|
+
* schema/strategy config — no `createStoreWithSchema` / `evolve` /
|
|
1464
|
+
* `migrateSchema`, and **no DDL inside the caller's business
|
|
1465
|
+
* transaction**. The caller owns `BEGIN`/`COMMIT`/`ROLLBACK`; this
|
|
1466
|
+
* method neither opens nor closes a transaction. Async drivers
|
|
1467
|
+
* (node-postgres, `neon-serverless` Pool, libsql) wrap with
|
|
1468
|
+
* `db.transaction(async …)`; synchronous `better-sqlite3` must instead
|
|
1469
|
+
* issue explicit `BEGIN`/`COMMIT`/`ROLLBACK` (its driver rejects an
|
|
1470
|
+
* `async` transaction callback).
|
|
1471
|
+
*
|
|
1472
|
+
* Optional and presence-detected like the other capability-scoped
|
|
1473
|
+
* members: only the Drizzle Postgres/SQLite backends provide it.
|
|
1474
|
+
* Implementations MUST throw (not silently degrade) when
|
|
1475
|
+
* `capabilities.transactions` is `false` — a non-atomic fallback is
|
|
1476
|
+
* safe for graph-only writes but dangerous for cross-store flows,
|
|
1477
|
+
* where the caller's relational write *would* still commit.
|
|
1478
|
+
*
|
|
1479
|
+
* Fulltext stays safe by construction: the returned backend's
|
|
1480
|
+
* fulltext methods assert the durable materialization marker (a
|
|
1481
|
+
* cached SELECT, never DDL) at point of use and throw
|
|
1482
|
+
* `StoreNotInitializedError` on a missing/stale/failed marker rather
|
|
1483
|
+
* than migrating mid-transaction. Prefer booting the parent store via
|
|
1484
|
+
* `createStoreWithSchema` so that assertion is a warm-cache no-op.
|
|
1485
|
+
*/
|
|
1486
|
+
adoptTransaction?: (externalTx: AdoptedTransaction) => TransactionBackend;
|
|
1229
1487
|
close: () => Promise<void>;
|
|
1230
1488
|
}>;
|
|
1231
1489
|
/**
|
|
@@ -2129,4 +2387,4 @@ type RelationalIndexDeclaration = NodeIndexDeclaration | EdgeIndexDeclaration;
|
|
|
2129
2387
|
type IndexDeclaration = RelationalIndexDeclaration | VectorIndexDeclaration;
|
|
2130
2388
|
type SystemColumnName = "graph_id" | "kind" | "id" | "from_kind" | "from_id" | "to_kind" | "to_id" | "deleted_at" | "valid_from" | "valid_to" | "created_at" | "updated_at" | "version";
|
|
2131
2389
|
|
|
2132
|
-
export { type
|
|
2390
|
+
export { type FulltextCapabilities as $, type AnySqliteDatabase as A, type BackendCapabilities as B, type VectorIndexParams as C, type SchemaVersionRow as D, type EdgeIndexConfig as E, type FulltextStrategy as F, type GraphBackend as G, type InferenceType as H, type IndexDeclaration as I, type JsonPointer as J, type AggregateExpr as K, type FieldRef as L, type MetaEdge as M, type NodeIndexConfig as N, type OntologyRelation as O, type ComparisonOp as P, type QueryAst as Q, type RelationalIndexDeclaration as R, type SqliteExecutionProfileHints as S, type AggregateComparisonPredicate as T, type AdoptedTransaction as U, type VectorIndexDeclaration as V, type CommitSchemaVersionExpected as W, type CommitSchemaVersionParams as X, DEFAULT_SQL_SCHEMA as Y, type DeleteFulltextBatchParams as Z, type FulltextBatchRow as _, type SqliteTransactionMode as a, type FulltextQueryMode as a0, type FulltextSearchParams as a1, type FulltextSearchResult as a2, type HybridFusionOptions as a3, type JsonPointerFor as a4, type JsonPointerInput as a5, type JsonPointerSegment as a6, type JsonPointerSegments as a7, type JsonPointerSegmentsFor as a8, MAX_JSON_POINTER_DEPTH as a9, type Traversal as aA, type NodePredicate as aB, type ProjectedField as aC, type GroupBySpec as aD, type RecursiveCyclePolicy as aE, type TraversalDirection as aF, type EdgeRow as aG, type NodeRow as aH, type SelectiveField as aI, type ComposableQuery as aJ, type SetOperationType as aK, type SetOperation as aL, type VectorMetric as aM, type MetaEdgeProperties as aa, type OrderSpec as ab, type ParameterRef as ac, type ResolveJsonPointer as ad, type ResolveJsonPointerSegments as ae, type SetActiveVersionParams as af, type SortDirection as ag, type SqlSchema as ah, type SqlTableNames as ai, type StrategyTableContribution as aj, type TableContribution as ak, type TransactionBackend as al, type TraversalExpansion as am, type UpsertFulltextBatchParams as an, type VectorCapabilities as ao, createSqlSchema as ap, fts5Strategy as aq, isMetaEdge as ar, joinJsonPointers as as, jsonPointer as at, normalizeJsonPointer as au, parseJsonPointer as av, tsvectorStrategy as aw, type ValueType as ax, type PredicateExpression as ay, type VectorMetricType as az, type AnyPgDatabase as b, type EdgeIndexDeclaration as c, type NodeIndexDeclaration as d, type IndexWhereExpression as e, type SerializedNodeDef as f, type SerializedEdgeDef as g, type SerializedMetaEdge as h, type SerializedOntologyRelation as i, type SerializedClosures as j, type SerializedSchema as k, type SchemaHash as l, type JsonSchema as m, type SerializedOntology as n, type SerializedUniqueConstraint as o, type SqlDialect as p, type EdgeIndexDirection as q, type EdgeIndexWhereBuilder as r, type IndexOrigin as s, type IndexScope as t, type IndexWhereFieldBuilder as u, type IndexWhereInput as v, type NodeIndexWhereBuilder as w, type SystemColumnName as x, type VectorIndexImplementation as y, type VectorIndexMetric as z };
|