@typicalday/firegraph 0.15.0 → 0.16.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/README.md +39 -17
- package/dist/{backend-CvImIwTY.d.cts → backend-CE3pM9-T.d.ts} +32 -2
- package/dist/{backend-BpYLdwCW.d.cts → backend-DNzv8KSR.d.cts} +33 -19
- package/dist/{backend-BpYLdwCW.d.ts → backend-DNzv8KSR.d.ts} +33 -19
- package/dist/{backend-YH5HtawN.d.ts → backend-EjFfw9yO.d.cts} +32 -2
- package/dist/backend.cjs.map +1 -1
- package/dist/backend.d.cts +2 -2
- package/dist/backend.d.ts +2 -2
- package/dist/backend.js +1 -1
- package/dist/{chunk-FODIMIWY.js → chunk-5JBNLH5W.js} +17 -6
- package/dist/chunk-5JBNLH5W.js.map +1 -0
- package/dist/{chunk-5HIRYV2S.js → chunk-6IO74NKD.js} +12 -10
- package/dist/{chunk-5HIRYV2S.js.map → chunk-6IO74NKD.js.map} +1 -1
- package/dist/{chunk-ULRDQ6HZ.js → chunk-NZVSLWNY.js} +6 -1
- package/dist/chunk-NZVSLWNY.js.map +1 -0
- package/dist/{chunk-N5HFDWQX.js → chunk-PWIO46RT.js} +1 -1
- package/dist/{chunk-N5HFDWQX.js.map → chunk-PWIO46RT.js.map} +1 -1
- package/dist/{client-B5o39X79.d.ts → client-CNAwJayO.d.ts} +1 -1
- package/dist/{client-BGHwxwPg.d.cts → client-CaXH5D5C.d.cts} +1 -1
- package/dist/cloudflare/index.cjs +11 -9
- package/dist/cloudflare/index.cjs.map +1 -1
- package/dist/cloudflare/index.d.cts +3 -3
- package/dist/cloudflare/index.d.ts +3 -3
- package/dist/cloudflare/index.js +3 -3
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/firestore-enterprise/index.cjs +11 -9
- package/dist/firestore-enterprise/index.cjs.map +1 -1
- package/dist/firestore-enterprise/index.d.cts +3 -3
- package/dist/firestore-enterprise/index.d.ts +3 -3
- package/dist/firestore-enterprise/index.js +2 -2
- package/dist/firestore-standard/index.cjs +11 -9
- package/dist/firestore-standard/index.cjs.map +1 -1
- package/dist/firestore-standard/index.d.cts +3 -3
- package/dist/firestore-standard/index.d.ts +3 -3
- package/dist/firestore-standard/index.js +2 -2
- package/dist/index.cjs +11 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/{registry-tKTb5Kx1.d.ts → registry-By1i-zge.d.ts} +1 -1
- package/dist/{registry-BGh7Jqpb.d.cts → registry-CNToyEra.d.cts} +1 -1
- package/dist/sqlite/index.cjs +24 -12
- package/dist/sqlite/index.cjs.map +1 -1
- package/dist/sqlite/index.d.cts +4 -4
- package/dist/sqlite/index.d.ts +4 -4
- package/dist/sqlite/index.js +4 -4
- package/dist/sqlite/local.cjs +474 -47
- package/dist/sqlite/local.cjs.map +1 -1
- package/dist/sqlite/local.d.cts +31 -5
- package/dist/sqlite/local.d.ts +31 -5
- package/dist/sqlite/local.js +429 -4
- package/dist/sqlite/local.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-FODIMIWY.js.map +0 -1
- package/dist/chunk-ULRDQ6HZ.js.map +0 -1
package/README.md
CHANGED
|
@@ -129,21 +129,21 @@ if (client.capabilities.has('query.join')) {
|
|
|
129
129
|
|
|
130
130
|
**Capability values:**
|
|
131
131
|
|
|
132
|
-
| Capability | Methods unlocked | Backends
|
|
133
|
-
| ----------------------------------------------------------- | ---------------------------------------------------------------- |
|
|
134
|
-
| `core.read` / `core.write` / `core.batch` / `core.subgraph` | `getNode`, `putNode`, `findEdges`, `batch()`, `subgraph()`, etc. | All
|
|
135
|
-
| `core.transactions` | `runTransaction(fn)` | Firestore (both), SQLite (`better-sqlite3` only; absent on D1); **absent on Cloudflare DO**
|
|
136
|
-
| `query.aggregate` | `aggregate(spec)` | All; `min`/`max` only on SQLite + DO (both Firestore editions reject `min`/`max` — classic `Query.aggregate` exposes only count/sum/avg)
|
|
137
|
-
| `query.select` | `findEdgesProjected(params)` | All
|
|
138
|
-
| `query.join` | `expand(params)` | All
|
|
139
|
-
| `query.dml` | `bulkDelete(params)`, `bulkUpdate(params)` | Enterprise (requires `previewDml: true`), SQLite, DO
|
|
140
|
-
| `traversal.serverSide` | `runEngineTraversal(params)` | Enterprise
|
|
141
|
-
| `search.vector` | `findNearest(params)` | Firestore (both)
|
|
142
|
-
| `search.fullText` | `fullTextSearch(params)` | Enterprise. **Note:** the `fields` option is not yet supported — passing a non-empty `fields` array throws `INVALID_QUERY`.
|
|
143
|
-
| `search.geo` | `geoSearch(params)` | Enterprise
|
|
144
|
-
| `raw.firestore` | _(reserved — no methods yet)_ | Firestore (both)
|
|
145
|
-
| `raw.sql` | _(reserved — no methods yet)_ | SQLite
|
|
146
|
-
| `realtime.listen` | _(reserved — no methods yet)_ | _(none currently)_
|
|
132
|
+
| Capability | Methods unlocked | Backends |
|
|
133
|
+
| ----------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| `core.read` / `core.write` / `core.batch` / `core.subgraph` | `getNode`, `putNode`, `findEdges`, `batch()`, `subgraph()`, etc. | All |
|
|
135
|
+
| `core.transactions` | `runTransaction(fn)` | Firestore (both), SQLite (`better-sqlite3` only; absent on D1); **absent on Cloudflare DO** |
|
|
136
|
+
| `query.aggregate` | `aggregate(spec)` | All; `min`/`max` only on SQLite + DO (both Firestore editions reject `min`/`max` — classic `Query.aggregate` exposes only count/sum/avg) |
|
|
137
|
+
| `query.select` | `findEdgesProjected(params)` | All |
|
|
138
|
+
| `query.join` | `expand(params)` | All |
|
|
139
|
+
| `query.dml` | `bulkDelete(params)`, `bulkUpdate(params)` | Enterprise (requires `previewDml: true`), SQLite, DO |
|
|
140
|
+
| `traversal.serverSide` | `runEngineTraversal(params)` | Enterprise |
|
|
141
|
+
| `search.vector` | `findNearest(params)` | Firestore (both), local SQLite (`firegraph/sqlite-local` — exact brute-force scan via a SQL distance function) |
|
|
142
|
+
| `search.fullText` | `fullTextSearch(params)` | Enterprise, local SQLite (`firegraph/sqlite-local` — FTS5, bm25-ranked). **Note:** the `fields` option is not yet supported — passing a non-empty `fields` array throws `INVALID_QUERY`. |
|
|
143
|
+
| `search.geo` | `geoSearch(params)` | Enterprise |
|
|
144
|
+
| `raw.firestore` | _(reserved — no methods yet)_ | Firestore (both) |
|
|
145
|
+
| `raw.sql` | _(reserved — no methods yet)_ | SQLite |
|
|
146
|
+
| `realtime.listen` | _(reserved — no methods yet)_ | _(none currently)_ |
|
|
147
147
|
|
|
148
148
|
### Extension Methods
|
|
149
149
|
|
|
@@ -200,7 +200,7 @@ const tree = await (client as TraversalExtension).runEngineTraversal({
|
|
|
200
200
|
hops: [{ axbType: 'hasDeparture', bType: 'departure', limitPerSource: 10 }],
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
-
// search.vector —
|
|
203
|
+
// search.vector — nearest-neighbour (Firestore both editions; local SQLite via firegraph/sqlite-local)
|
|
204
204
|
const similar = await (client as VectorExtension).findNearest({
|
|
205
205
|
aType: 'tour',
|
|
206
206
|
axbType: 'is',
|
|
@@ -210,7 +210,7 @@ const similar = await (client as VectorExtension).findNearest({
|
|
|
210
210
|
limit: 5,
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
-
// search.fullText — full-text search (Enterprise; `fields` throws INVALID_QUERY if non-empty)
|
|
213
|
+
// search.fullText — full-text search (Enterprise + firegraph/sqlite-local; `fields` throws INVALID_QUERY if non-empty)
|
|
214
214
|
const results = await (client as FullTextExtension).fullTextSearch({
|
|
215
215
|
aType: 'tour',
|
|
216
216
|
axbType: 'is',
|
|
@@ -1172,6 +1172,28 @@ close();
|
|
|
1172
1172
|
|
|
1173
1173
|
`createLocalSqliteBackend` also accepts an already-open better-sqlite3 `Database` (in which case `close()` is a no-op — the caller owns the lifecycle), `':memory:'` for ephemeral graphs, a `pragmas` map for extra tuning, and `fileMustExist: true` to refuse creating new files. `createBetterSqliteExecutor(db)` is exported separately for wiring `createSqliteBackend` directly.
|
|
1174
1174
|
|
|
1175
|
+
On top of the shared SQLite capability set, the local factory declares `search.fullText` and `search.vector`:
|
|
1176
|
+
|
|
1177
|
+
- **`fullTextSearch(params)`** — every graph table gets a contentless FTS5 index kept in sync by pure-SQL triggers (`json_tree` extracts all string leaves from `data`, so nested fields are searchable). Results are ranked by bm25. FTS5 query syntax (`AND` / `OR` / `NOT`, `"phrase"` quoting, `prefix*`) passes through; malformed queries throw `INVALID_QUERY`. The `fields` option is not supported (the index is one combined text column) — a non-empty `fields` array throws `INVALID_QUERY`, matching Firestore Enterprise. Because the triggers are plain SQL, writes from _any_ connection or process stay indexed, and rows written before the index existed are backfilled on bootstrap.
|
|
1178
|
+
- **`findNearest(params)`** — exact (not approximate) nearest-neighbour via a brute-force scan scored by a connection-local SQL distance function. Supports `EUCLIDEAN`, `COSINE`, and `DOT_PRODUCT`, plus `distanceThreshold` and `distanceResultField`, mirroring Firestore semantics (rows with a missing field, wrong dimension, or non-finite values are silently skipped). Vector queries must run through the factory-created backend — the distance function is registered per connection.
|
|
1179
|
+
|
|
1180
|
+
```typescript
|
|
1181
|
+
const hits = await g.fullTextSearch({
|
|
1182
|
+
aType: 'tour',
|
|
1183
|
+
axbType: 'is',
|
|
1184
|
+
bType: 'tour',
|
|
1185
|
+
query: 'dolomites OR alps',
|
|
1186
|
+
});
|
|
1187
|
+
const similar = await g.findNearest({
|
|
1188
|
+
aType: 'tour',
|
|
1189
|
+
axbType: 'is',
|
|
1190
|
+
bType: 'tour',
|
|
1191
|
+
queryVector: [0.1, 0.2, 0.3],
|
|
1192
|
+
vectorField: 'embedding',
|
|
1193
|
+
limit: 5,
|
|
1194
|
+
});
|
|
1195
|
+
```
|
|
1196
|
+
|
|
1175
1197
|
### Cloudflare Durable Object Backend (`firegraph/cloudflare`)
|
|
1176
1198
|
|
|
1177
1199
|
Runs inside a Durable Object via `state.storage.sql`. Same capability set as SQLite minus `core.transactions` (the DO's single-threaded executor cannot block on transaction callbacks) and `raw.sql` (the DO SQL surface is hidden behind RPC).
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as GraphRegistry, I as IndexSpec, S as StorageBackend } from './backend-
|
|
1
|
+
import { p as GraphRegistry, I as IndexSpec, S as StorageBackend } from './backend-DNzv8KSR.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Driver-level SQLite abstraction.
|
|
@@ -101,6 +101,36 @@ interface SqliteBackendOptions {
|
|
|
101
101
|
* Pass `[]` to disable core indexes entirely.
|
|
102
102
|
*/
|
|
103
103
|
coreIndexes?: IndexSpec[];
|
|
104
|
+
/**
|
|
105
|
+
* Extra DDL statements appended to every graph table's lazy bootstrap.
|
|
106
|
+
* Called with the physical table name; the returned statements run after
|
|
107
|
+
* the core table/index DDL inside the same chunked batch. Statements MUST
|
|
108
|
+
* be idempotent (`IF NOT EXISTS` / `INSERT OR IGNORE` / re-runnable DML)
|
|
109
|
+
* — the bootstrap re-runs after self-heal and once per backend instance,
|
|
110
|
+
* including every lazily created subgraph table.
|
|
111
|
+
*
|
|
112
|
+
* @internal Used by `firegraph/sqlite-local` to install FTS5 index
|
|
113
|
+
* tables, sync triggers, and backfill statements. Propagated to subgraph
|
|
114
|
+
* backends derived via `subgraph()`.
|
|
115
|
+
*/
|
|
116
|
+
extraTableDDL?: (tableName: string) => string[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The shape `createSqliteBackend` actually returns: `StorageBackend` plus
|
|
120
|
+
* internal hooks the `firegraph/sqlite-local` search wrapper needs.
|
|
121
|
+
*/
|
|
122
|
+
interface SqliteStorageBackend extends StorageBackend<SqliteCapability> {
|
|
123
|
+
/**
|
|
124
|
+
* Force the lazy schema bootstrap (table + indexes + catalog + any
|
|
125
|
+
* `extraTableDDL` artifacts). Pass `force: true` to reset the bootstrap
|
|
126
|
+
* cache first — mirrors the self-heal path in `withSchema` for callers
|
|
127
|
+
* that issue their own SQL against this graph's table and hit a
|
|
128
|
+
* "no such table" error after a parent cascade dropped it.
|
|
129
|
+
*
|
|
130
|
+
* @internal Used by the `firegraph/sqlite-local` search wrapper.
|
|
131
|
+
*/
|
|
132
|
+
ensureReady(force?: boolean): Promise<void>;
|
|
133
|
+
subgraph(parentNodeUid: string, name: string): SqliteStorageBackend;
|
|
104
134
|
}
|
|
105
135
|
/**
|
|
106
136
|
* Capability union declared by the SQLite-backed `StorageBackend`.
|
|
@@ -132,6 +162,6 @@ type SqliteCapability = 'core.read' | 'core.write' | 'core.transactions' | 'core
|
|
|
132
162
|
* Pass `options.registry` so per-entry `indexes` declarations land in
|
|
133
163
|
* every lazily created table.
|
|
134
164
|
*/
|
|
135
|
-
declare function createSqliteBackend(executor: SqliteExecutor, tableName: string, options?: SqliteBackendOptions):
|
|
165
|
+
declare function createSqliteBackend(executor: SqliteExecutor, tableName: string, options?: SqliteBackendOptions): SqliteStorageBackend;
|
|
136
166
|
|
|
137
167
|
export { type SqliteBackendOptions as S, type SqliteCapability as a, type SqliteExecutor as b, createSqliteBackend as c };
|
|
@@ -1095,9 +1095,14 @@ interface FullTextSearchParams {
|
|
|
1095
1095
|
* Enterprise product feature, not a free-tier feature).
|
|
1096
1096
|
* - **Firestore Standard** — not supported. FTS is an Enterprise-only
|
|
1097
1097
|
* product feature; this row will never become "✓".
|
|
1098
|
-
* - **SQLite /
|
|
1099
|
-
*
|
|
1100
|
-
*
|
|
1098
|
+
* - **Local SQLite (`firegraph/sqlite-local`)** ✓ — backed by one FTS5
|
|
1099
|
+
* table per graph table, kept in sync by pure-SQL triggers and ranked
|
|
1100
|
+
* by `bm25()`. The whole `data` payload is indexed as one combined
|
|
1101
|
+
* text column, so a non-empty `fields` list is rejected with
|
|
1102
|
+
* `INVALID_QUERY`.
|
|
1103
|
+
* - **Shared SQLite (D1) / Cloudflare DO** — not supported. No FTS5
|
|
1104
|
+
* trigger infrastructure on those runtimes; emulating FTS over
|
|
1105
|
+
* `json_extract` is not viable for any realistic dataset.
|
|
1101
1106
|
*
|
|
1102
1107
|
* Migrations are NOT applied to the result. The search index walked
|
|
1103
1108
|
* the raw stored shape; rehydrating each row through the migration
|
|
@@ -1311,12 +1316,15 @@ interface FindNearestParams {
|
|
|
1311
1316
|
* Native vector / nearest-neighbour search.
|
|
1312
1317
|
*
|
|
1313
1318
|
* Backends declaring `search.vector` translate the call into a single
|
|
1314
|
-
* server-side `findNearest` query.
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1319
|
+
* server-side `findNearest` query. Firestore Standard and Enterprise
|
|
1320
|
+
* both implement it via the classic `Query.findNearest(...)` API; the
|
|
1321
|
+
* pipeline `findNearest` stage is a future optimisation. The local
|
|
1322
|
+
* better-sqlite3 backend (`firegraph/sqlite-local`) implements it as a
|
|
1323
|
+
* brute-force scan scored by a deterministic SQL UDF — exact rather
|
|
1324
|
+
* than approximate, fine for local files at local-file scale. The D1
|
|
1325
|
+
* and Cloudflare DO editions do not declare the capability: those
|
|
1326
|
+
* runtimes expose no UDF registration surface, and emulating ANN on top
|
|
1327
|
+
* of `json_extract` alone is a non-starter for any realistic dataset.
|
|
1320
1328
|
*
|
|
1321
1329
|
* Migrations are NOT applied to the result. The vector query selects
|
|
1322
1330
|
* documents by similarity, not by query plan — applying migrations
|
|
@@ -1827,11 +1835,14 @@ interface StorageBackend<C extends Capability = Capability> {
|
|
|
1827
1835
|
findEdgesProjected?(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<Array<Record<string, unknown>>>;
|
|
1828
1836
|
/**
|
|
1829
1837
|
* Run a vector / nearest-neighbour query. Present only on backends that
|
|
1830
|
-
* declare `search.vector`. There is no client-side fallback —
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
1838
|
+
* declare `search.vector`. There is no client-side fallback — backends
|
|
1839
|
+
* without the cap throw `UNSUPPORTED_OPERATION` from the client wrapper.
|
|
1840
|
+
* In-tree: both Firestore editions (native ANN via `Query.findNearest`)
|
|
1841
|
+
* and the local better-sqlite3 backend (`firegraph/sqlite-local`, a
|
|
1842
|
+
* brute-force UDF-scored scan — exact, not approximate). The D1 and
|
|
1843
|
+
* Cloudflare DO editions stay without the cap: no UDF registration
|
|
1844
|
+
* surface, and a JS-side k-NN sweep over `findEdges()` would scale
|
|
1845
|
+
* catastrophically.
|
|
1835
1846
|
*
|
|
1836
1847
|
* `params` carries the user-facing shape (vector field path, query
|
|
1837
1848
|
* vector, distance metric, optional threshold and result-field). The
|
|
@@ -1859,11 +1870,14 @@ interface StorageBackend<C extends Capability = Capability> {
|
|
|
1859
1870
|
findNearest?(params: FindNearestParams): Promise<StoredGraphRecord[]>;
|
|
1860
1871
|
/**
|
|
1861
1872
|
* Run a full-text search query. Present only on backends that declare
|
|
1862
|
-
* `search.fullText`. There is no client-side fallback —
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1873
|
+
* `search.fullText`. There is no client-side fallback — backends
|
|
1874
|
+
* without the cap throw `UNSUPPORTED_OPERATION` from the client
|
|
1875
|
+
* wrapper. In-tree: Firestore Enterprise (via Pipeline
|
|
1876
|
+
* `search({ query: documentMatches(...) })`) and the local
|
|
1877
|
+
* better-sqlite3 backend (`firegraph/sqlite-local`, via a
|
|
1878
|
+
* trigger-synced FTS5 index ranked by `bm25()`). Firestore Standard
|
|
1879
|
+
* never gets it (Enterprise-only product feature); D1 and the
|
|
1880
|
+
* Cloudflare DO edition don't ship FTS5 trigger infrastructure.
|
|
1867
1881
|
*
|
|
1868
1882
|
* The backend is responsible for path normalisation (rewriting
|
|
1869
1883
|
* bare `fields` entries to `data.<name>`, rejecting envelope fields
|
|
@@ -1095,9 +1095,14 @@ interface FullTextSearchParams {
|
|
|
1095
1095
|
* Enterprise product feature, not a free-tier feature).
|
|
1096
1096
|
* - **Firestore Standard** — not supported. FTS is an Enterprise-only
|
|
1097
1097
|
* product feature; this row will never become "✓".
|
|
1098
|
-
* - **SQLite /
|
|
1099
|
-
*
|
|
1100
|
-
*
|
|
1098
|
+
* - **Local SQLite (`firegraph/sqlite-local`)** ✓ — backed by one FTS5
|
|
1099
|
+
* table per graph table, kept in sync by pure-SQL triggers and ranked
|
|
1100
|
+
* by `bm25()`. The whole `data` payload is indexed as one combined
|
|
1101
|
+
* text column, so a non-empty `fields` list is rejected with
|
|
1102
|
+
* `INVALID_QUERY`.
|
|
1103
|
+
* - **Shared SQLite (D1) / Cloudflare DO** — not supported. No FTS5
|
|
1104
|
+
* trigger infrastructure on those runtimes; emulating FTS over
|
|
1105
|
+
* `json_extract` is not viable for any realistic dataset.
|
|
1101
1106
|
*
|
|
1102
1107
|
* Migrations are NOT applied to the result. The search index walked
|
|
1103
1108
|
* the raw stored shape; rehydrating each row through the migration
|
|
@@ -1311,12 +1316,15 @@ interface FindNearestParams {
|
|
|
1311
1316
|
* Native vector / nearest-neighbour search.
|
|
1312
1317
|
*
|
|
1313
1318
|
* Backends declaring `search.vector` translate the call into a single
|
|
1314
|
-
* server-side `findNearest` query.
|
|
1315
|
-
*
|
|
1316
|
-
*
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1319
|
+
* server-side `findNearest` query. Firestore Standard and Enterprise
|
|
1320
|
+
* both implement it via the classic `Query.findNearest(...)` API; the
|
|
1321
|
+
* pipeline `findNearest` stage is a future optimisation. The local
|
|
1322
|
+
* better-sqlite3 backend (`firegraph/sqlite-local`) implements it as a
|
|
1323
|
+
* brute-force scan scored by a deterministic SQL UDF — exact rather
|
|
1324
|
+
* than approximate, fine for local files at local-file scale. The D1
|
|
1325
|
+
* and Cloudflare DO editions do not declare the capability: those
|
|
1326
|
+
* runtimes expose no UDF registration surface, and emulating ANN on top
|
|
1327
|
+
* of `json_extract` alone is a non-starter for any realistic dataset.
|
|
1320
1328
|
*
|
|
1321
1329
|
* Migrations are NOT applied to the result. The vector query selects
|
|
1322
1330
|
* documents by similarity, not by query plan — applying migrations
|
|
@@ -1827,11 +1835,14 @@ interface StorageBackend<C extends Capability = Capability> {
|
|
|
1827
1835
|
findEdgesProjected?(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<Array<Record<string, unknown>>>;
|
|
1828
1836
|
/**
|
|
1829
1837
|
* Run a vector / nearest-neighbour query. Present only on backends that
|
|
1830
|
-
* declare `search.vector`. There is no client-side fallback —
|
|
1831
|
-
*
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1834
|
-
*
|
|
1838
|
+
* declare `search.vector`. There is no client-side fallback — backends
|
|
1839
|
+
* without the cap throw `UNSUPPORTED_OPERATION` from the client wrapper.
|
|
1840
|
+
* In-tree: both Firestore editions (native ANN via `Query.findNearest`)
|
|
1841
|
+
* and the local better-sqlite3 backend (`firegraph/sqlite-local`, a
|
|
1842
|
+
* brute-force UDF-scored scan — exact, not approximate). The D1 and
|
|
1843
|
+
* Cloudflare DO editions stay without the cap: no UDF registration
|
|
1844
|
+
* surface, and a JS-side k-NN sweep over `findEdges()` would scale
|
|
1845
|
+
* catastrophically.
|
|
1835
1846
|
*
|
|
1836
1847
|
* `params` carries the user-facing shape (vector field path, query
|
|
1837
1848
|
* vector, distance metric, optional threshold and result-field). The
|
|
@@ -1859,11 +1870,14 @@ interface StorageBackend<C extends Capability = Capability> {
|
|
|
1859
1870
|
findNearest?(params: FindNearestParams): Promise<StoredGraphRecord[]>;
|
|
1860
1871
|
/**
|
|
1861
1872
|
* Run a full-text search query. Present only on backends that declare
|
|
1862
|
-
* `search.fullText`. There is no client-side fallback —
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1865
|
-
*
|
|
1866
|
-
*
|
|
1873
|
+
* `search.fullText`. There is no client-side fallback — backends
|
|
1874
|
+
* without the cap throw `UNSUPPORTED_OPERATION` from the client
|
|
1875
|
+
* wrapper. In-tree: Firestore Enterprise (via Pipeline
|
|
1876
|
+
* `search({ query: documentMatches(...) })`) and the local
|
|
1877
|
+
* better-sqlite3 backend (`firegraph/sqlite-local`, via a
|
|
1878
|
+
* trigger-synced FTS5 index ranked by `bm25()`). Firestore Standard
|
|
1879
|
+
* never gets it (Enterprise-only product feature); D1 and the
|
|
1880
|
+
* Cloudflare DO edition don't ship FTS5 trigger infrastructure.
|
|
1867
1881
|
*
|
|
1868
1882
|
* The backend is responsible for path normalisation (rewriting
|
|
1869
1883
|
* bare `fields` entries to `data.<name>`, rejecting envelope fields
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as GraphRegistry, I as IndexSpec, S as StorageBackend } from './backend-
|
|
1
|
+
import { p as GraphRegistry, I as IndexSpec, S as StorageBackend } from './backend-DNzv8KSR.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Driver-level SQLite abstraction.
|
|
@@ -101,6 +101,36 @@ interface SqliteBackendOptions {
|
|
|
101
101
|
* Pass `[]` to disable core indexes entirely.
|
|
102
102
|
*/
|
|
103
103
|
coreIndexes?: IndexSpec[];
|
|
104
|
+
/**
|
|
105
|
+
* Extra DDL statements appended to every graph table's lazy bootstrap.
|
|
106
|
+
* Called with the physical table name; the returned statements run after
|
|
107
|
+
* the core table/index DDL inside the same chunked batch. Statements MUST
|
|
108
|
+
* be idempotent (`IF NOT EXISTS` / `INSERT OR IGNORE` / re-runnable DML)
|
|
109
|
+
* — the bootstrap re-runs after self-heal and once per backend instance,
|
|
110
|
+
* including every lazily created subgraph table.
|
|
111
|
+
*
|
|
112
|
+
* @internal Used by `firegraph/sqlite-local` to install FTS5 index
|
|
113
|
+
* tables, sync triggers, and backfill statements. Propagated to subgraph
|
|
114
|
+
* backends derived via `subgraph()`.
|
|
115
|
+
*/
|
|
116
|
+
extraTableDDL?: (tableName: string) => string[];
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The shape `createSqliteBackend` actually returns: `StorageBackend` plus
|
|
120
|
+
* internal hooks the `firegraph/sqlite-local` search wrapper needs.
|
|
121
|
+
*/
|
|
122
|
+
interface SqliteStorageBackend extends StorageBackend<SqliteCapability> {
|
|
123
|
+
/**
|
|
124
|
+
* Force the lazy schema bootstrap (table + indexes + catalog + any
|
|
125
|
+
* `extraTableDDL` artifacts). Pass `force: true` to reset the bootstrap
|
|
126
|
+
* cache first — mirrors the self-heal path in `withSchema` for callers
|
|
127
|
+
* that issue their own SQL against this graph's table and hit a
|
|
128
|
+
* "no such table" error after a parent cascade dropped it.
|
|
129
|
+
*
|
|
130
|
+
* @internal Used by the `firegraph/sqlite-local` search wrapper.
|
|
131
|
+
*/
|
|
132
|
+
ensureReady(force?: boolean): Promise<void>;
|
|
133
|
+
subgraph(parentNodeUid: string, name: string): SqliteStorageBackend;
|
|
104
134
|
}
|
|
105
135
|
/**
|
|
106
136
|
* Capability union declared by the SQLite-backed `StorageBackend`.
|
|
@@ -132,6 +162,6 @@ type SqliteCapability = 'core.read' | 'core.write' | 'core.transactions' | 'core
|
|
|
132
162
|
* Pass `options.registry` so per-entry `indexes` declarations land in
|
|
133
163
|
* every lazily created table.
|
|
134
164
|
*/
|
|
135
|
-
declare function createSqliteBackend(executor: SqliteExecutor, tableName: string, options?: SqliteBackendOptions):
|
|
165
|
+
declare function createSqliteBackend(executor: SqliteExecutor, tableName: string, options?: SqliteBackendOptions): SqliteStorageBackend;
|
|
136
166
|
|
|
137
167
|
export { type SqliteBackendOptions as S, type SqliteCapability as a, type SqliteExecutor as b, createSqliteBackend as c };
|