@typicalday/firegraph 0.12.0 → 0.13.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 +317 -73
- package/dist/backend-DuvHGgK1.d.cts +1897 -0
- package/dist/backend-DuvHGgK1.d.ts +1897 -0
- package/dist/backend.cjs +222 -3
- package/dist/backend.cjs.map +1 -1
- package/dist/backend.d.cts +25 -5
- package/dist/backend.d.ts +25 -5
- package/dist/backend.js +197 -4
- package/dist/backend.js.map +1 -1
- package/dist/chunk-2DHMNTV6.js +16 -0
- package/dist/chunk-2DHMNTV6.js.map +1 -0
- package/dist/chunk-4MMQ5W74.js +288 -0
- package/dist/chunk-4MMQ5W74.js.map +1 -0
- package/dist/chunk-D4J7Z4FE.js +67 -0
- package/dist/chunk-D4J7Z4FE.js.map +1 -0
- package/dist/chunk-N5HFDWQX.js +23 -0
- package/dist/chunk-N5HFDWQX.js.map +1 -0
- package/dist/chunk-PAD7WFFU.js +573 -0
- package/dist/chunk-PAD7WFFU.js.map +1 -0
- package/dist/{chunk-AWW4MUJ5.js → chunk-TK64DNVK.js} +12 -1
- package/dist/chunk-TK64DNVK.js.map +1 -0
- package/dist/{chunk-HONQY4HF.js → chunk-WRTFC5NG.js} +362 -17
- package/dist/chunk-WRTFC5NG.js.map +1 -0
- package/dist/client-BKi3vk0Q.d.ts +34 -0
- package/dist/client-BrsaXtDV.d.cts +34 -0
- package/dist/cloudflare/index.cjs +930 -3
- package/dist/cloudflare/index.cjs.map +1 -1
- package/dist/cloudflare/index.d.cts +213 -12
- package/dist/cloudflare/index.d.ts +213 -12
- package/dist/cloudflare/index.js +562 -281
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/errors-BRc3I_eH.d.cts +73 -0
- package/dist/errors-BRc3I_eH.d.ts +73 -0
- package/dist/firestore-enterprise/index.cjs +3877 -0
- package/dist/firestore-enterprise/index.cjs.map +1 -0
- package/dist/firestore-enterprise/index.d.cts +141 -0
- package/dist/firestore-enterprise/index.d.ts +141 -0
- package/dist/firestore-enterprise/index.js +985 -0
- package/dist/firestore-enterprise/index.js.map +1 -0
- package/dist/firestore-standard/index.cjs +3117 -0
- package/dist/firestore-standard/index.cjs.map +1 -0
- package/dist/firestore-standard/index.d.cts +49 -0
- package/dist/firestore-standard/index.d.ts +49 -0
- package/dist/firestore-standard/index.js +283 -0
- package/dist/firestore-standard/index.js.map +1 -0
- package/dist/index.cjs +590 -550
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -37
- package/dist/index.d.ts +9 -37
- package/dist/index.js +178 -555
- package/dist/index.js.map +1 -1
- package/dist/{registry-Fi074zVa.d.ts → registry-Bc7h6WTM.d.cts} +1 -1
- package/dist/{registry-B1qsVL0E.d.cts → registry-C2KUPVZj.d.ts} +1 -1
- package/dist/{scope-path-B1G3YiA7.d.cts → scope-path-CROFZGr9.d.cts} +1 -56
- package/dist/{scope-path-B1G3YiA7.d.ts → scope-path-CROFZGr9.d.ts} +1 -56
- package/dist/sqlite/index.cjs +3631 -0
- package/dist/sqlite/index.cjs.map +1 -0
- package/dist/sqlite/index.d.cts +111 -0
- package/dist/sqlite/index.d.ts +111 -0
- package/dist/sqlite/index.js +1164 -0
- package/dist/sqlite/index.js.map +1 -0
- package/package.json +33 -3
- package/dist/backend-BsR0lnFL.d.ts +0 -200
- package/dist/backend-Ct-fLlkG.d.cts +0 -200
- package/dist/chunk-AWW4MUJ5.js.map +0 -1
- package/dist/chunk-HONQY4HF.js.map +0 -1
- package/dist/types-DxYLy8Ol.d.cts +0 -770
- package/dist/types-DxYLy8Ol.d.ts +0 -770
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { W as WritableRecord,
|
|
2
|
-
export { d as deleteField } from '../backend-
|
|
3
|
-
import { e as GraphRegistry, I as IndexSpec, g as QueryFilter, z as QueryOptions, C as CascadeResult, F as FindEdgesParams, m as BulkOptions, o as BulkResult, a as GraphClient, D as DynamicGraphClient, S as StoredGraphRecord, l as GraphReader, G as GraphClientOptions, c as DynamicRegistryConfig } from '../types-DxYLy8Ol.cjs';
|
|
1
|
+
import { W as WritableRecord, f as WriteMode, U as UpdatePayload, G as GraphRegistry, I as IndexSpec, p as QueryFilter, ai as QueryOptions, z as AggregateSpec, O as CascadeResult, F as FindEdgesParams, H as BulkOptions, L as BulkResult, b as BulkUpdatePatch, E as ExpandParams, S as StorageBackend, B as BackendCapabilities, t as GraphClient, Z as DynamicGraphClient, m as StoredGraphRecord, T as TransactionBackend, a as BatchBackend, u as GraphReader, e as ExpandResult, a8 as GraphClientOptions, $ as DynamicRegistryConfig } from '../backend-DuvHGgK1.cjs';
|
|
2
|
+
export { A as AggregateExtension, w as AggregateField, x as AggregateOp, y as AggregateResult, N as Capability, d as DmlExtension, J as JoinExtension, g as createCapabilities, h as deleteField, j as intersectCapabilities } from '../backend-DuvHGgK1.cjs';
|
|
4
3
|
import { DurableObject } from 'cloudflare:workers';
|
|
5
|
-
export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-
|
|
4
|
+
export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-Bc7h6WTM.cjs';
|
|
5
|
+
export { C as CapabilityNotSupportedError } from '../errors-BRc3I_eH.cjs';
|
|
6
6
|
import '@google-cloud/firestore';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -42,6 +42,30 @@ interface DORecordWire {
|
|
|
42
42
|
createdAtMs: number;
|
|
43
43
|
updatedAtMs: number;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Discriminator for one projected column on the DO backend. The decoder
|
|
47
|
+
* uses this to recover the JS-shape of the requested field. Mirrors the
|
|
48
|
+
* shared-SQLite `ProjectedColumnKind` — same kinds, same decode rules. The
|
|
49
|
+
* two share no module so the symbol is duplicated; the contract is locked
|
|
50
|
+
* by the cross-backend test in `tests/unit/cloudflare-sql.test.ts`.
|
|
51
|
+
*/
|
|
52
|
+
type DOProjectedColumnKind = 'builtin-text' | 'builtin-int' | 'builtin-timestamp' | 'data' | 'json';
|
|
53
|
+
/** Per-column metadata returned alongside the compiled projection statement. */
|
|
54
|
+
interface DOProjectedColumnSpec {
|
|
55
|
+
/** Original caller-supplied field name. Used as the alias in the SQL
|
|
56
|
+
* projection list AND as the key in the returned JS row. */
|
|
57
|
+
field: string;
|
|
58
|
+
/** Kind discriminator — see `DOProjectedColumnKind`. */
|
|
59
|
+
kind: DOProjectedColumnKind;
|
|
60
|
+
/**
|
|
61
|
+
* For `kind === 'json'` only: alias of the paired `json_type` companion
|
|
62
|
+
* column. Uses a positional sentinel (`__fg_t_<idx>`) keyed by the
|
|
63
|
+
* field's position in the unique projection list rather than the
|
|
64
|
+
* historical `<field>__t` suffix, which would collide if the caller
|
|
65
|
+
* projected both `'foo'` and `'foo__t'` (both legal user input).
|
|
66
|
+
*/
|
|
67
|
+
typeAlias?: string;
|
|
68
|
+
}
|
|
45
69
|
|
|
46
70
|
/**
|
|
47
71
|
* `FiregraphDO` — the Durable Object class that holds a single subgraph's
|
|
@@ -188,6 +212,14 @@ declare class FiregraphDO extends DurableObject<unknown> {
|
|
|
188
212
|
constructor(ctx: DurableObjectStateLike, env: unknown, options?: FiregraphDOOptions);
|
|
189
213
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
190
214
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
215
|
+
/**
|
|
216
|
+
* Aggregate query (capability `query.aggregate`). Compiles a single
|
|
217
|
+
* `SELECT` projecting one column per alias; SQLite handles count, sum,
|
|
218
|
+
* avg, min, max natively. Empty-set fix-ups (NULL → 0 for sum/min/max,
|
|
219
|
+
* NaN for avg) happen on the client side in `DORPCBackend.aggregate` so
|
|
220
|
+
* the wire payload stays a plain row of (alias → number | null).
|
|
221
|
+
*/
|
|
222
|
+
_fgAggregate(spec: AggregateSpec, filters: QueryFilter[]): Promise<Record<string, number | null>>;
|
|
191
223
|
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
192
224
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
193
225
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
@@ -200,6 +232,21 @@ declare class FiregraphDO extends DurableObject<unknown> {
|
|
|
200
232
|
_fgBatch(ops: BatchOp[]): Promise<void>;
|
|
201
233
|
_fgRemoveNodeCascade(uid: string): Promise<CascadeResult>;
|
|
202
234
|
_fgBulkRemoveEdges(params: FindEdgesParams, _options?: BulkOptions): Promise<BulkResult>;
|
|
235
|
+
_fgBulkDelete(filters: QueryFilter[], _options?: BulkOptions): Promise<BulkResult>;
|
|
236
|
+
_fgBulkUpdate(filters: QueryFilter[], patch: BulkUpdatePatch, _options?: BulkOptions): Promise<BulkResult>;
|
|
237
|
+
_fgExpand(params: ExpandParams): Promise<ExpandResultWire>;
|
|
238
|
+
_fgFindEdgesProjected(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
|
|
239
|
+
rows: Array<Record<string, unknown>>;
|
|
240
|
+
columns: DOProjectedColumnSpec[];
|
|
241
|
+
}>;
|
|
242
|
+
/**
|
|
243
|
+
* Run a DML statement with `RETURNING "doc_id"` so the affected-row count
|
|
244
|
+
* comes back authoritatively. Errors are caught and surfaced via the
|
|
245
|
+
* `BulkResult.errors` array (single batch, batchIndex 0) so the wire
|
|
246
|
+
* payload stays a regular `BulkResult` and the client doesn't have to
|
|
247
|
+
* differentiate "RPC threw" from "single-statement failure."
|
|
248
|
+
*/
|
|
249
|
+
private execDmlWithReturning;
|
|
203
250
|
/**
|
|
204
251
|
* Wipe every row. Called by the client when tearing down a subgraph DO as
|
|
205
252
|
* part of cascade — the DO itself can't be destroyed (DO IDs persist
|
|
@@ -260,14 +307,80 @@ interface DurableObjectIdLike {
|
|
|
260
307
|
interface FiregraphStub {
|
|
261
308
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
262
309
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
310
|
+
/**
|
|
311
|
+
* Optional — added in Phase 4 (`query.aggregate`). Marked optional so
|
|
312
|
+
* external worker code that hand-rolls a stub wrapper around a real DO
|
|
313
|
+
* stub (e.g. for testing or for layering structured-clone shims) keeps
|
|
314
|
+
* compiling without modification. `FiregraphDO` always implements this
|
|
315
|
+
* method, but callers of `DORPCBackend.aggregate` must either assert the
|
|
316
|
+
* stub supports it or be prepared for `UNSUPPORTED_OPERATION` at runtime.
|
|
317
|
+
*/
|
|
318
|
+
_fgAggregate?(spec: AggregateSpec, filters: QueryFilter[]): Promise<Record<string, number | null>>;
|
|
263
319
|
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
264
320
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
265
321
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
266
322
|
_fgBatch(ops: BatchOp[]): Promise<void>;
|
|
267
323
|
_fgRemoveNodeCascade(uid: string): Promise<CascadeResult>;
|
|
268
324
|
_fgBulkRemoveEdges(params: FindEdgesParams, options?: BulkOptions): Promise<BulkResult>;
|
|
325
|
+
/**
|
|
326
|
+
* Optional — added in Phase 5 (`query.dml`). Same back-compat rationale as
|
|
327
|
+
* `_fgAggregate`: external worker code that hand-rolls a stub wrapper keeps
|
|
328
|
+
* compiling without modification. `FiregraphDO` always implements this
|
|
329
|
+
* method; callers of `DORPCBackend.bulkDelete` either assert support or
|
|
330
|
+
* accept `UNSUPPORTED_OPERATION` at runtime.
|
|
331
|
+
*/
|
|
332
|
+
_fgBulkDelete?(filters: QueryFilter[], options?: BulkOptions): Promise<BulkResult>;
|
|
333
|
+
/**
|
|
334
|
+
* Optional — added in Phase 5 (`query.dml`). See `_fgBulkDelete`.
|
|
335
|
+
*/
|
|
336
|
+
_fgBulkUpdate?(filters: QueryFilter[], patch: BulkUpdatePatch, options?: BulkOptions): Promise<BulkResult>;
|
|
337
|
+
/**
|
|
338
|
+
* Optional — added in Phase 6 (`query.join`). Same back-compat rationale as
|
|
339
|
+
* `_fgAggregate` / `_fgBulkDelete`: external worker code that hand-rolls a
|
|
340
|
+
* stub wrapper keeps compiling without modification. `FiregraphDO` always
|
|
341
|
+
* implements this method; callers of `DORPCBackend.expand` either assert
|
|
342
|
+
* the stub supports it or accept `UNSUPPORTED_OPERATION` at runtime.
|
|
343
|
+
*
|
|
344
|
+
* The wire shape uses `ExpandResultWire` so `StoredGraphRecord` instances
|
|
345
|
+
* (which carry `Timestamp` wrappers) survive the structured-clone hop —
|
|
346
|
+
* they're rehydrated on this side via `hydrateDORecord`, just like the
|
|
347
|
+
* `query()` and `_fgBulkRemoveEdges` paths.
|
|
348
|
+
*/
|
|
349
|
+
_fgExpand?(params: ExpandParams): Promise<ExpandResultWire>;
|
|
350
|
+
/**
|
|
351
|
+
* Optional — added in Phase 7 (`query.select`). Same back-compat rationale
|
|
352
|
+
* as `_fgAggregate` / `_fgBulkDelete` / `_fgExpand`: external worker code
|
|
353
|
+
* that hand-rolls a stub wrapper keeps compiling without modification.
|
|
354
|
+
* `FiregraphDO` always implements this method; callers of
|
|
355
|
+
* `DORPCBackend.findEdgesProjected` either assert the stub supports it or
|
|
356
|
+
* accept `UNSUPPORTED_OPERATION` at runtime.
|
|
357
|
+
*
|
|
358
|
+
* The wire shape returns `{ rows, columns }` — raw row objects from the
|
|
359
|
+
* SQLite executor plus the per-column metadata produced by
|
|
360
|
+
* `compileDOFindEdgesProjected`. Decoding (BigInt → number, timestamp
|
|
361
|
+
* rehydration, paired `__t` resolution for `data.*` paths) happens on
|
|
362
|
+
* the client side via `decodeDOProjectedRow`. We deliberately do NOT
|
|
363
|
+
* decode inside the DO because `GraphTimestampImpl` instances do not
|
|
364
|
+
* survive workerd's structured-clone boundary as class instances —
|
|
365
|
+
* decoding must happen on the side that owns the prototype.
|
|
366
|
+
*/
|
|
367
|
+
_fgFindEdgesProjected?(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
|
|
368
|
+
rows: Array<Record<string, unknown>>;
|
|
369
|
+
columns: DOProjectedColumnSpec[];
|
|
370
|
+
}>;
|
|
269
371
|
_fgDestroy(): Promise<void>;
|
|
270
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Wire shape for `_fgExpand`. The DO returns rows as `DORecordWire` (the
|
|
375
|
+
* SQLite row layout) and the backend re-hydrates them on this side, so
|
|
376
|
+
* `Timestamp` wrappers are reconstructed locally and never round-trip
|
|
377
|
+
* through workerd's structured-clone boundary as plain objects.
|
|
378
|
+
*/
|
|
379
|
+
interface ExpandResultWire {
|
|
380
|
+
edges: DORecordWire[];
|
|
381
|
+
/** Aligned with `edges`; absent when the caller didn't request hydration. */
|
|
382
|
+
targets?: Array<DORecordWire | null>;
|
|
383
|
+
}
|
|
271
384
|
interface FiregraphNamespace {
|
|
272
385
|
idFromName(name: string): DurableObjectIdLike;
|
|
273
386
|
get(id: DurableObjectIdLike): FiregraphStub;
|
|
@@ -306,9 +419,26 @@ interface DORPCBackendOptions {
|
|
|
306
419
|
* own overload signatures.
|
|
307
420
|
* @internal
|
|
308
421
|
*/
|
|
309
|
-
makeSiblingClient?: (siblingStorageKey: string) => GraphClient | DynamicGraphClient
|
|
422
|
+
makeSiblingClient?: (siblingStorageKey: string) => GraphClient<CloudflareCapability> | DynamicGraphClient<CloudflareCapability>;
|
|
310
423
|
}
|
|
311
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Capability union declared by the DO RPC backend.
|
|
426
|
+
*
|
|
427
|
+
* Note the absence of `core.transactions`: `runTransaction` throws
|
|
428
|
+
* `UNSUPPORTED_OPERATION` because holding a synchronous SQLite transaction
|
|
429
|
+
* across async RPC calls would block the DO's single-threaded executor (see
|
|
430
|
+
* `transactionsUnsupported` above). `raw.sql` is also intentionally absent —
|
|
431
|
+
* the SQL surface lives inside the DO and isn't exposed across the RPC
|
|
432
|
+
* boundary.
|
|
433
|
+
*
|
|
434
|
+
* Conservative declaration matters: the type-level capability gate (Phase 3)
|
|
435
|
+
* relies on the union and the runtime cap-set agreeing. Adding a cap here
|
|
436
|
+
* without a corresponding runtime method would let callers reach a method
|
|
437
|
+
* that doesn't exist.
|
|
438
|
+
*/
|
|
439
|
+
type CloudflareCapability = 'core.read' | 'core.write' | 'core.batch' | 'core.subgraph' | 'query.aggregate' | 'query.dml' | 'query.join' | 'query.select';
|
|
440
|
+
declare class DORPCBackend implements StorageBackend<CloudflareCapability> {
|
|
441
|
+
readonly capabilities: BackendCapabilities<CloudflareCapability>;
|
|
312
442
|
readonly collectionPath = "firegraph";
|
|
313
443
|
readonly scopePath: string;
|
|
314
444
|
/** @internal */
|
|
@@ -317,12 +447,20 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
317
447
|
readonly namespace: FiregraphNamespace;
|
|
318
448
|
private readonly registryAccessor?;
|
|
319
449
|
/** @internal — see `DORPCBackendOptions.makeSiblingClient` for the union-type rationale. */
|
|
320
|
-
readonly makeSiblingClient?: (siblingStorageKey: string) => GraphClient | DynamicGraphClient
|
|
450
|
+
readonly makeSiblingClient?: (siblingStorageKey: string) => GraphClient<CloudflareCapability> | DynamicGraphClient<CloudflareCapability>;
|
|
321
451
|
private cachedStub;
|
|
322
452
|
constructor(namespace: FiregraphNamespace, options: DORPCBackendOptions);
|
|
323
453
|
private get stub();
|
|
324
454
|
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
325
455
|
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
456
|
+
/**
|
|
457
|
+
* Run an aggregate query inside the backing DO. The DO returns a row of
|
|
458
|
+
* `{ alias: number | null }` (null = SQLite NULL for SUM/MIN/MAX over an
|
|
459
|
+
* empty set, or the count being literally 0); this method resolves NULL
|
|
460
|
+
* to 0 for SUM/MIN/MAX and to NaN for AVG, matching the SQLite backend
|
|
461
|
+
* and the Firestore Standard helper.
|
|
462
|
+
*/
|
|
463
|
+
aggregate(spec: AggregateSpec, filters: QueryFilter[]): Promise<Record<string, number>>;
|
|
326
464
|
setDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
327
465
|
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
328
466
|
deleteDoc(docId: string): Promise<void>;
|
|
@@ -331,6 +469,57 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
331
469
|
subgraph(parentNodeUid: string, name: string): StorageBackend;
|
|
332
470
|
removeNodeCascade(uid: string, reader: GraphReader, options?: BulkOptions): Promise<CascadeResult>;
|
|
333
471
|
bulkRemoveEdges(params: FindEdgesParams, _reader: GraphReader, options?: BulkOptions): Promise<BulkResult>;
|
|
472
|
+
/**
|
|
473
|
+
* Single-statement bulk DELETE inside the backing DO. The DO compiles
|
|
474
|
+
* the filter list to one `DELETE … WHERE …` statement and returns a
|
|
475
|
+
* `BulkResult` whose `deleted` is the affected-row count.
|
|
476
|
+
*
|
|
477
|
+
* Defensive `_fgBulkDelete` presence check mirrors `aggregate()`: the
|
|
478
|
+
* RPC method is optional on `FiregraphStub` so external worker code with
|
|
479
|
+
* a hand-rolled stub wrapper still type-checks. Surface a clear
|
|
480
|
+
* `UNSUPPORTED_OPERATION` rather than `TypeError: stub._fgBulkDelete is
|
|
481
|
+
* not a function` when the wrapper hasn't forwarded the method.
|
|
482
|
+
*/
|
|
483
|
+
bulkDelete(filters: QueryFilter[], options?: BulkOptions): Promise<BulkResult>;
|
|
484
|
+
/**
|
|
485
|
+
* Single-statement bulk UPDATE inside the backing DO. Same contract as
|
|
486
|
+
* `bulkDelete` for the missing-method case; the DO compiles the patch to
|
|
487
|
+
* one `UPDATE … SET data = json_patch(...) WHERE …` statement.
|
|
488
|
+
*/
|
|
489
|
+
bulkUpdate(filters: QueryFilter[], patch: BulkUpdatePatch, options?: BulkOptions): Promise<BulkResult>;
|
|
490
|
+
/**
|
|
491
|
+
* Multi-source fan-out — `query.join` capability. Routes the call through
|
|
492
|
+
* the DO's `_fgExpand` RPC, which compiles to one `SELECT … WHERE
|
|
493
|
+
* "aUid" IN (?, …)` statement (plus, when `params.hydrate === true`, a
|
|
494
|
+
* second IN-clause statement against the node rows).
|
|
495
|
+
*
|
|
496
|
+
* Defensive `_fgExpand` presence check matches the bulk-DML pattern: the
|
|
497
|
+
* RPC method is optional on `FiregraphStub` so external worker code with
|
|
498
|
+
* a hand-rolled stub wrapper still type-checks. We surface a clear
|
|
499
|
+
* `UNSUPPORTED_OPERATION` rather than `TypeError: stub._fgExpand is not a
|
|
500
|
+
* function` if the wrapper hasn't forwarded the method.
|
|
501
|
+
*/
|
|
502
|
+
expand(params: ExpandParams): Promise<ExpandResult>;
|
|
503
|
+
/**
|
|
504
|
+
* Server-side projection — `query.select` capability. Forwards the call to
|
|
505
|
+
* the DO's `_fgFindEdgesProjected` RPC, which compiles to a single
|
|
506
|
+
* `SELECT json_extract(...) AS …, json_type(...) AS …__t FROM <table>
|
|
507
|
+
* WHERE …` statement. The DO returns raw rows + per-column metadata; this
|
|
508
|
+
* method decodes each row locally via `decodeDOProjectedRow`.
|
|
509
|
+
*
|
|
510
|
+
* Decoding lives on this side (not inside the DO) because
|
|
511
|
+
* `GraphTimestampImpl` is a class — its prototype does not survive
|
|
512
|
+
* workerd's structured-clone boundary — so timestamp rehydration must
|
|
513
|
+
* happen wherever the rows are consumed by the GraphClient.
|
|
514
|
+
*
|
|
515
|
+
* Defensive `_fgFindEdgesProjected` presence check matches the `expand` /
|
|
516
|
+
* bulk-DML / aggregate pattern: the RPC method is optional on
|
|
517
|
+
* `FiregraphStub` so external worker code with a hand-rolled stub wrapper
|
|
518
|
+
* still type-checks. Surface a clear `UNSUPPORTED_OPERATION` rather than
|
|
519
|
+
* `TypeError: stub._fgFindEdgesProjected is not a function` if the
|
|
520
|
+
* wrapper hasn't forwarded the method.
|
|
521
|
+
*/
|
|
522
|
+
findEdgesProjected(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<Array<Record<string, unknown>>>;
|
|
334
523
|
/**
|
|
335
524
|
* Wipe this DO's storage. The DO itself can't be deleted — its ID
|
|
336
525
|
* persists forever — but its rows can be emptied, which is what the
|
|
@@ -443,6 +632,18 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
443
632
|
* ```
|
|
444
633
|
*/
|
|
445
634
|
|
|
635
|
+
/**
|
|
636
|
+
* The DO declares a strict subset of `Capability` (no `search.*`,
|
|
637
|
+
* `realtime.listen`, or `raw.*`). Local variables and helper closures
|
|
638
|
+
* that round-trip the client need to use the narrower form so that a
|
|
639
|
+
* `GraphClient<CloudflareCapability>` (which doesn't promise, e.g.,
|
|
640
|
+
* `findNearest`) is assignable. Using the unparameterized
|
|
641
|
+
* `GraphClient` here would require the DO to implement every
|
|
642
|
+
* extension method, which would defeat the whole point of the
|
|
643
|
+
* capability gate.
|
|
644
|
+
*/
|
|
645
|
+
type DOGraphClient = GraphClient<CloudflareCapability>;
|
|
646
|
+
type DODynamicGraphClient = DynamicGraphClient<CloudflareCapability>;
|
|
446
647
|
/**
|
|
447
648
|
* Options for `createDOClient`. Same shape as `GraphClientOptions`; the DO
|
|
448
649
|
* backend does not expose a table label of its own — the DO owns its SQLite
|
|
@@ -464,8 +665,8 @@ type DOClientOptions = GraphClientOptions;
|
|
|
464
665
|
*/
|
|
465
666
|
declare function createDOClient(namespace: FiregraphNamespace, rootKey: string, options: DOClientOptions & {
|
|
466
667
|
registryMode: DynamicRegistryConfig;
|
|
467
|
-
}):
|
|
468
|
-
declare function createDOClient(namespace: FiregraphNamespace, rootKey: string, options?: DOClientOptions):
|
|
668
|
+
}): DODynamicGraphClient;
|
|
669
|
+
declare function createDOClient(namespace: FiregraphNamespace, rootKey: string, options?: DOClientOptions): DOGraphClient;
|
|
469
670
|
/**
|
|
470
671
|
* Construct a peer `GraphClient` that shares `client`'s DO namespace and
|
|
471
672
|
* construction options but targets a different root DO (i.e. a different
|
|
@@ -498,8 +699,8 @@ declare function createDOClient(namespace: FiregraphNamespace, rootKey: string,
|
|
|
498
699
|
* as `createDOClient`'s `rootKey`: non-empty,
|
|
499
700
|
* no `/`.
|
|
500
701
|
*/
|
|
501
|
-
declare function createSiblingClient(client:
|
|
502
|
-
declare function createSiblingClient(client:
|
|
702
|
+
declare function createSiblingClient(client: DOGraphClient, siblingRootKey: string): DOGraphClient;
|
|
703
|
+
declare function createSiblingClient(client: DODynamicGraphClient, siblingRootKey: string): DODynamicGraphClient;
|
|
503
704
|
|
|
504
705
|
/**
|
|
505
706
|
* Flat SQLite schema for a single firegraph DO.
|
|
@@ -554,4 +755,4 @@ interface BuildDOSchemaOptions {
|
|
|
554
755
|
*/
|
|
555
756
|
declare function buildDOSchemaStatements(table: string, options?: BuildDOSchemaOptions): string[];
|
|
556
757
|
|
|
557
|
-
export { type BatchOp, type BuildDOSchemaOptions, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildDOSchemaStatements, createDOClient, createSiblingClient };
|
|
758
|
+
export { AggregateSpec, BackendCapabilities, type BatchOp, type BuildDOSchemaOptions, BulkUpdatePatch, type CloudflareCapability, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, ExpandParams, ExpandResult, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildDOSchemaStatements, createDOClient, createSiblingClient };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { W as WritableRecord,
|
|
2
|
-
export { d as deleteField } from '../backend-
|
|
3
|
-
import { e as GraphRegistry, I as IndexSpec, g as QueryFilter, z as QueryOptions, C as CascadeResult, F as FindEdgesParams, m as BulkOptions, o as BulkResult, a as GraphClient, D as DynamicGraphClient, S as StoredGraphRecord, l as GraphReader, G as GraphClientOptions, c as DynamicRegistryConfig } from '../types-DxYLy8Ol.js';
|
|
1
|
+
import { W as WritableRecord, f as WriteMode, U as UpdatePayload, G as GraphRegistry, I as IndexSpec, p as QueryFilter, ai as QueryOptions, z as AggregateSpec, O as CascadeResult, F as FindEdgesParams, H as BulkOptions, L as BulkResult, b as BulkUpdatePatch, E as ExpandParams, S as StorageBackend, B as BackendCapabilities, t as GraphClient, Z as DynamicGraphClient, m as StoredGraphRecord, T as TransactionBackend, a as BatchBackend, u as GraphReader, e as ExpandResult, a8 as GraphClientOptions, $ as DynamicRegistryConfig } from '../backend-DuvHGgK1.js';
|
|
2
|
+
export { A as AggregateExtension, w as AggregateField, x as AggregateOp, y as AggregateResult, N as Capability, d as DmlExtension, J as JoinExtension, g as createCapabilities, h as deleteField, j as intersectCapabilities } from '../backend-DuvHGgK1.js';
|
|
4
3
|
import { DurableObject } from 'cloudflare:workers';
|
|
5
|
-
export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-
|
|
4
|
+
export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-C2KUPVZj.js';
|
|
5
|
+
export { C as CapabilityNotSupportedError } from '../errors-BRc3I_eH.js';
|
|
6
6
|
import '@google-cloud/firestore';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -42,6 +42,30 @@ interface DORecordWire {
|
|
|
42
42
|
createdAtMs: number;
|
|
43
43
|
updatedAtMs: number;
|
|
44
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Discriminator for one projected column on the DO backend. The decoder
|
|
47
|
+
* uses this to recover the JS-shape of the requested field. Mirrors the
|
|
48
|
+
* shared-SQLite `ProjectedColumnKind` — same kinds, same decode rules. The
|
|
49
|
+
* two share no module so the symbol is duplicated; the contract is locked
|
|
50
|
+
* by the cross-backend test in `tests/unit/cloudflare-sql.test.ts`.
|
|
51
|
+
*/
|
|
52
|
+
type DOProjectedColumnKind = 'builtin-text' | 'builtin-int' | 'builtin-timestamp' | 'data' | 'json';
|
|
53
|
+
/** Per-column metadata returned alongside the compiled projection statement. */
|
|
54
|
+
interface DOProjectedColumnSpec {
|
|
55
|
+
/** Original caller-supplied field name. Used as the alias in the SQL
|
|
56
|
+
* projection list AND as the key in the returned JS row. */
|
|
57
|
+
field: string;
|
|
58
|
+
/** Kind discriminator — see `DOProjectedColumnKind`. */
|
|
59
|
+
kind: DOProjectedColumnKind;
|
|
60
|
+
/**
|
|
61
|
+
* For `kind === 'json'` only: alias of the paired `json_type` companion
|
|
62
|
+
* column. Uses a positional sentinel (`__fg_t_<idx>`) keyed by the
|
|
63
|
+
* field's position in the unique projection list rather than the
|
|
64
|
+
* historical `<field>__t` suffix, which would collide if the caller
|
|
65
|
+
* projected both `'foo'` and `'foo__t'` (both legal user input).
|
|
66
|
+
*/
|
|
67
|
+
typeAlias?: string;
|
|
68
|
+
}
|
|
45
69
|
|
|
46
70
|
/**
|
|
47
71
|
* `FiregraphDO` — the Durable Object class that holds a single subgraph's
|
|
@@ -188,6 +212,14 @@ declare class FiregraphDO extends DurableObject<unknown> {
|
|
|
188
212
|
constructor(ctx: DurableObjectStateLike, env: unknown, options?: FiregraphDOOptions);
|
|
189
213
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
190
214
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
215
|
+
/**
|
|
216
|
+
* Aggregate query (capability `query.aggregate`). Compiles a single
|
|
217
|
+
* `SELECT` projecting one column per alias; SQLite handles count, sum,
|
|
218
|
+
* avg, min, max natively. Empty-set fix-ups (NULL → 0 for sum/min/max,
|
|
219
|
+
* NaN for avg) happen on the client side in `DORPCBackend.aggregate` so
|
|
220
|
+
* the wire payload stays a plain row of (alias → number | null).
|
|
221
|
+
*/
|
|
222
|
+
_fgAggregate(spec: AggregateSpec, filters: QueryFilter[]): Promise<Record<string, number | null>>;
|
|
191
223
|
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
192
224
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
193
225
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
@@ -200,6 +232,21 @@ declare class FiregraphDO extends DurableObject<unknown> {
|
|
|
200
232
|
_fgBatch(ops: BatchOp[]): Promise<void>;
|
|
201
233
|
_fgRemoveNodeCascade(uid: string): Promise<CascadeResult>;
|
|
202
234
|
_fgBulkRemoveEdges(params: FindEdgesParams, _options?: BulkOptions): Promise<BulkResult>;
|
|
235
|
+
_fgBulkDelete(filters: QueryFilter[], _options?: BulkOptions): Promise<BulkResult>;
|
|
236
|
+
_fgBulkUpdate(filters: QueryFilter[], patch: BulkUpdatePatch, _options?: BulkOptions): Promise<BulkResult>;
|
|
237
|
+
_fgExpand(params: ExpandParams): Promise<ExpandResultWire>;
|
|
238
|
+
_fgFindEdgesProjected(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
|
|
239
|
+
rows: Array<Record<string, unknown>>;
|
|
240
|
+
columns: DOProjectedColumnSpec[];
|
|
241
|
+
}>;
|
|
242
|
+
/**
|
|
243
|
+
* Run a DML statement with `RETURNING "doc_id"` so the affected-row count
|
|
244
|
+
* comes back authoritatively. Errors are caught and surfaced via the
|
|
245
|
+
* `BulkResult.errors` array (single batch, batchIndex 0) so the wire
|
|
246
|
+
* payload stays a regular `BulkResult` and the client doesn't have to
|
|
247
|
+
* differentiate "RPC threw" from "single-statement failure."
|
|
248
|
+
*/
|
|
249
|
+
private execDmlWithReturning;
|
|
203
250
|
/**
|
|
204
251
|
* Wipe every row. Called by the client when tearing down a subgraph DO as
|
|
205
252
|
* part of cascade — the DO itself can't be destroyed (DO IDs persist
|
|
@@ -260,14 +307,80 @@ interface DurableObjectIdLike {
|
|
|
260
307
|
interface FiregraphStub {
|
|
261
308
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
262
309
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
310
|
+
/**
|
|
311
|
+
* Optional — added in Phase 4 (`query.aggregate`). Marked optional so
|
|
312
|
+
* external worker code that hand-rolls a stub wrapper around a real DO
|
|
313
|
+
* stub (e.g. for testing or for layering structured-clone shims) keeps
|
|
314
|
+
* compiling without modification. `FiregraphDO` always implements this
|
|
315
|
+
* method, but callers of `DORPCBackend.aggregate` must either assert the
|
|
316
|
+
* stub supports it or be prepared for `UNSUPPORTED_OPERATION` at runtime.
|
|
317
|
+
*/
|
|
318
|
+
_fgAggregate?(spec: AggregateSpec, filters: QueryFilter[]): Promise<Record<string, number | null>>;
|
|
263
319
|
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
264
320
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
265
321
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
266
322
|
_fgBatch(ops: BatchOp[]): Promise<void>;
|
|
267
323
|
_fgRemoveNodeCascade(uid: string): Promise<CascadeResult>;
|
|
268
324
|
_fgBulkRemoveEdges(params: FindEdgesParams, options?: BulkOptions): Promise<BulkResult>;
|
|
325
|
+
/**
|
|
326
|
+
* Optional — added in Phase 5 (`query.dml`). Same back-compat rationale as
|
|
327
|
+
* `_fgAggregate`: external worker code that hand-rolls a stub wrapper keeps
|
|
328
|
+
* compiling without modification. `FiregraphDO` always implements this
|
|
329
|
+
* method; callers of `DORPCBackend.bulkDelete` either assert support or
|
|
330
|
+
* accept `UNSUPPORTED_OPERATION` at runtime.
|
|
331
|
+
*/
|
|
332
|
+
_fgBulkDelete?(filters: QueryFilter[], options?: BulkOptions): Promise<BulkResult>;
|
|
333
|
+
/**
|
|
334
|
+
* Optional — added in Phase 5 (`query.dml`). See `_fgBulkDelete`.
|
|
335
|
+
*/
|
|
336
|
+
_fgBulkUpdate?(filters: QueryFilter[], patch: BulkUpdatePatch, options?: BulkOptions): Promise<BulkResult>;
|
|
337
|
+
/**
|
|
338
|
+
* Optional — added in Phase 6 (`query.join`). Same back-compat rationale as
|
|
339
|
+
* `_fgAggregate` / `_fgBulkDelete`: external worker code that hand-rolls a
|
|
340
|
+
* stub wrapper keeps compiling without modification. `FiregraphDO` always
|
|
341
|
+
* implements this method; callers of `DORPCBackend.expand` either assert
|
|
342
|
+
* the stub supports it or accept `UNSUPPORTED_OPERATION` at runtime.
|
|
343
|
+
*
|
|
344
|
+
* The wire shape uses `ExpandResultWire` so `StoredGraphRecord` instances
|
|
345
|
+
* (which carry `Timestamp` wrappers) survive the structured-clone hop —
|
|
346
|
+
* they're rehydrated on this side via `hydrateDORecord`, just like the
|
|
347
|
+
* `query()` and `_fgBulkRemoveEdges` paths.
|
|
348
|
+
*/
|
|
349
|
+
_fgExpand?(params: ExpandParams): Promise<ExpandResultWire>;
|
|
350
|
+
/**
|
|
351
|
+
* Optional — added in Phase 7 (`query.select`). Same back-compat rationale
|
|
352
|
+
* as `_fgAggregate` / `_fgBulkDelete` / `_fgExpand`: external worker code
|
|
353
|
+
* that hand-rolls a stub wrapper keeps compiling without modification.
|
|
354
|
+
* `FiregraphDO` always implements this method; callers of
|
|
355
|
+
* `DORPCBackend.findEdgesProjected` either assert the stub supports it or
|
|
356
|
+
* accept `UNSUPPORTED_OPERATION` at runtime.
|
|
357
|
+
*
|
|
358
|
+
* The wire shape returns `{ rows, columns }` — raw row objects from the
|
|
359
|
+
* SQLite executor plus the per-column metadata produced by
|
|
360
|
+
* `compileDOFindEdgesProjected`. Decoding (BigInt → number, timestamp
|
|
361
|
+
* rehydration, paired `__t` resolution for `data.*` paths) happens on
|
|
362
|
+
* the client side via `decodeDOProjectedRow`. We deliberately do NOT
|
|
363
|
+
* decode inside the DO because `GraphTimestampImpl` instances do not
|
|
364
|
+
* survive workerd's structured-clone boundary as class instances —
|
|
365
|
+
* decoding must happen on the side that owns the prototype.
|
|
366
|
+
*/
|
|
367
|
+
_fgFindEdgesProjected?(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
|
|
368
|
+
rows: Array<Record<string, unknown>>;
|
|
369
|
+
columns: DOProjectedColumnSpec[];
|
|
370
|
+
}>;
|
|
269
371
|
_fgDestroy(): Promise<void>;
|
|
270
372
|
}
|
|
373
|
+
/**
|
|
374
|
+
* Wire shape for `_fgExpand`. The DO returns rows as `DORecordWire` (the
|
|
375
|
+
* SQLite row layout) and the backend re-hydrates them on this side, so
|
|
376
|
+
* `Timestamp` wrappers are reconstructed locally and never round-trip
|
|
377
|
+
* through workerd's structured-clone boundary as plain objects.
|
|
378
|
+
*/
|
|
379
|
+
interface ExpandResultWire {
|
|
380
|
+
edges: DORecordWire[];
|
|
381
|
+
/** Aligned with `edges`; absent when the caller didn't request hydration. */
|
|
382
|
+
targets?: Array<DORecordWire | null>;
|
|
383
|
+
}
|
|
271
384
|
interface FiregraphNamespace {
|
|
272
385
|
idFromName(name: string): DurableObjectIdLike;
|
|
273
386
|
get(id: DurableObjectIdLike): FiregraphStub;
|
|
@@ -306,9 +419,26 @@ interface DORPCBackendOptions {
|
|
|
306
419
|
* own overload signatures.
|
|
307
420
|
* @internal
|
|
308
421
|
*/
|
|
309
|
-
makeSiblingClient?: (siblingStorageKey: string) => GraphClient | DynamicGraphClient
|
|
422
|
+
makeSiblingClient?: (siblingStorageKey: string) => GraphClient<CloudflareCapability> | DynamicGraphClient<CloudflareCapability>;
|
|
310
423
|
}
|
|
311
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Capability union declared by the DO RPC backend.
|
|
426
|
+
*
|
|
427
|
+
* Note the absence of `core.transactions`: `runTransaction` throws
|
|
428
|
+
* `UNSUPPORTED_OPERATION` because holding a synchronous SQLite transaction
|
|
429
|
+
* across async RPC calls would block the DO's single-threaded executor (see
|
|
430
|
+
* `transactionsUnsupported` above). `raw.sql` is also intentionally absent —
|
|
431
|
+
* the SQL surface lives inside the DO and isn't exposed across the RPC
|
|
432
|
+
* boundary.
|
|
433
|
+
*
|
|
434
|
+
* Conservative declaration matters: the type-level capability gate (Phase 3)
|
|
435
|
+
* relies on the union and the runtime cap-set agreeing. Adding a cap here
|
|
436
|
+
* without a corresponding runtime method would let callers reach a method
|
|
437
|
+
* that doesn't exist.
|
|
438
|
+
*/
|
|
439
|
+
type CloudflareCapability = 'core.read' | 'core.write' | 'core.batch' | 'core.subgraph' | 'query.aggregate' | 'query.dml' | 'query.join' | 'query.select';
|
|
440
|
+
declare class DORPCBackend implements StorageBackend<CloudflareCapability> {
|
|
441
|
+
readonly capabilities: BackendCapabilities<CloudflareCapability>;
|
|
312
442
|
readonly collectionPath = "firegraph";
|
|
313
443
|
readonly scopePath: string;
|
|
314
444
|
/** @internal */
|
|
@@ -317,12 +447,20 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
317
447
|
readonly namespace: FiregraphNamespace;
|
|
318
448
|
private readonly registryAccessor?;
|
|
319
449
|
/** @internal — see `DORPCBackendOptions.makeSiblingClient` for the union-type rationale. */
|
|
320
|
-
readonly makeSiblingClient?: (siblingStorageKey: string) => GraphClient | DynamicGraphClient
|
|
450
|
+
readonly makeSiblingClient?: (siblingStorageKey: string) => GraphClient<CloudflareCapability> | DynamicGraphClient<CloudflareCapability>;
|
|
321
451
|
private cachedStub;
|
|
322
452
|
constructor(namespace: FiregraphNamespace, options: DORPCBackendOptions);
|
|
323
453
|
private get stub();
|
|
324
454
|
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
325
455
|
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
456
|
+
/**
|
|
457
|
+
* Run an aggregate query inside the backing DO. The DO returns a row of
|
|
458
|
+
* `{ alias: number | null }` (null = SQLite NULL for SUM/MIN/MAX over an
|
|
459
|
+
* empty set, or the count being literally 0); this method resolves NULL
|
|
460
|
+
* to 0 for SUM/MIN/MAX and to NaN for AVG, matching the SQLite backend
|
|
461
|
+
* and the Firestore Standard helper.
|
|
462
|
+
*/
|
|
463
|
+
aggregate(spec: AggregateSpec, filters: QueryFilter[]): Promise<Record<string, number>>;
|
|
326
464
|
setDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
327
465
|
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
328
466
|
deleteDoc(docId: string): Promise<void>;
|
|
@@ -331,6 +469,57 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
331
469
|
subgraph(parentNodeUid: string, name: string): StorageBackend;
|
|
332
470
|
removeNodeCascade(uid: string, reader: GraphReader, options?: BulkOptions): Promise<CascadeResult>;
|
|
333
471
|
bulkRemoveEdges(params: FindEdgesParams, _reader: GraphReader, options?: BulkOptions): Promise<BulkResult>;
|
|
472
|
+
/**
|
|
473
|
+
* Single-statement bulk DELETE inside the backing DO. The DO compiles
|
|
474
|
+
* the filter list to one `DELETE … WHERE …` statement and returns a
|
|
475
|
+
* `BulkResult` whose `deleted` is the affected-row count.
|
|
476
|
+
*
|
|
477
|
+
* Defensive `_fgBulkDelete` presence check mirrors `aggregate()`: the
|
|
478
|
+
* RPC method is optional on `FiregraphStub` so external worker code with
|
|
479
|
+
* a hand-rolled stub wrapper still type-checks. Surface a clear
|
|
480
|
+
* `UNSUPPORTED_OPERATION` rather than `TypeError: stub._fgBulkDelete is
|
|
481
|
+
* not a function` when the wrapper hasn't forwarded the method.
|
|
482
|
+
*/
|
|
483
|
+
bulkDelete(filters: QueryFilter[], options?: BulkOptions): Promise<BulkResult>;
|
|
484
|
+
/**
|
|
485
|
+
* Single-statement bulk UPDATE inside the backing DO. Same contract as
|
|
486
|
+
* `bulkDelete` for the missing-method case; the DO compiles the patch to
|
|
487
|
+
* one `UPDATE … SET data = json_patch(...) WHERE …` statement.
|
|
488
|
+
*/
|
|
489
|
+
bulkUpdate(filters: QueryFilter[], patch: BulkUpdatePatch, options?: BulkOptions): Promise<BulkResult>;
|
|
490
|
+
/**
|
|
491
|
+
* Multi-source fan-out — `query.join` capability. Routes the call through
|
|
492
|
+
* the DO's `_fgExpand` RPC, which compiles to one `SELECT … WHERE
|
|
493
|
+
* "aUid" IN (?, …)` statement (plus, when `params.hydrate === true`, a
|
|
494
|
+
* second IN-clause statement against the node rows).
|
|
495
|
+
*
|
|
496
|
+
* Defensive `_fgExpand` presence check matches the bulk-DML pattern: the
|
|
497
|
+
* RPC method is optional on `FiregraphStub` so external worker code with
|
|
498
|
+
* a hand-rolled stub wrapper still type-checks. We surface a clear
|
|
499
|
+
* `UNSUPPORTED_OPERATION` rather than `TypeError: stub._fgExpand is not a
|
|
500
|
+
* function` if the wrapper hasn't forwarded the method.
|
|
501
|
+
*/
|
|
502
|
+
expand(params: ExpandParams): Promise<ExpandResult>;
|
|
503
|
+
/**
|
|
504
|
+
* Server-side projection — `query.select` capability. Forwards the call to
|
|
505
|
+
* the DO's `_fgFindEdgesProjected` RPC, which compiles to a single
|
|
506
|
+
* `SELECT json_extract(...) AS …, json_type(...) AS …__t FROM <table>
|
|
507
|
+
* WHERE …` statement. The DO returns raw rows + per-column metadata; this
|
|
508
|
+
* method decodes each row locally via `decodeDOProjectedRow`.
|
|
509
|
+
*
|
|
510
|
+
* Decoding lives on this side (not inside the DO) because
|
|
511
|
+
* `GraphTimestampImpl` is a class — its prototype does not survive
|
|
512
|
+
* workerd's structured-clone boundary — so timestamp rehydration must
|
|
513
|
+
* happen wherever the rows are consumed by the GraphClient.
|
|
514
|
+
*
|
|
515
|
+
* Defensive `_fgFindEdgesProjected` presence check matches the `expand` /
|
|
516
|
+
* bulk-DML / aggregate pattern: the RPC method is optional on
|
|
517
|
+
* `FiregraphStub` so external worker code with a hand-rolled stub wrapper
|
|
518
|
+
* still type-checks. Surface a clear `UNSUPPORTED_OPERATION` rather than
|
|
519
|
+
* `TypeError: stub._fgFindEdgesProjected is not a function` if the
|
|
520
|
+
* wrapper hasn't forwarded the method.
|
|
521
|
+
*/
|
|
522
|
+
findEdgesProjected(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<Array<Record<string, unknown>>>;
|
|
334
523
|
/**
|
|
335
524
|
* Wipe this DO's storage. The DO itself can't be deleted — its ID
|
|
336
525
|
* persists forever — but its rows can be emptied, which is what the
|
|
@@ -443,6 +632,18 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
443
632
|
* ```
|
|
444
633
|
*/
|
|
445
634
|
|
|
635
|
+
/**
|
|
636
|
+
* The DO declares a strict subset of `Capability` (no `search.*`,
|
|
637
|
+
* `realtime.listen`, or `raw.*`). Local variables and helper closures
|
|
638
|
+
* that round-trip the client need to use the narrower form so that a
|
|
639
|
+
* `GraphClient<CloudflareCapability>` (which doesn't promise, e.g.,
|
|
640
|
+
* `findNearest`) is assignable. Using the unparameterized
|
|
641
|
+
* `GraphClient` here would require the DO to implement every
|
|
642
|
+
* extension method, which would defeat the whole point of the
|
|
643
|
+
* capability gate.
|
|
644
|
+
*/
|
|
645
|
+
type DOGraphClient = GraphClient<CloudflareCapability>;
|
|
646
|
+
type DODynamicGraphClient = DynamicGraphClient<CloudflareCapability>;
|
|
446
647
|
/**
|
|
447
648
|
* Options for `createDOClient`. Same shape as `GraphClientOptions`; the DO
|
|
448
649
|
* backend does not expose a table label of its own — the DO owns its SQLite
|
|
@@ -464,8 +665,8 @@ type DOClientOptions = GraphClientOptions;
|
|
|
464
665
|
*/
|
|
465
666
|
declare function createDOClient(namespace: FiregraphNamespace, rootKey: string, options: DOClientOptions & {
|
|
466
667
|
registryMode: DynamicRegistryConfig;
|
|
467
|
-
}):
|
|
468
|
-
declare function createDOClient(namespace: FiregraphNamespace, rootKey: string, options?: DOClientOptions):
|
|
668
|
+
}): DODynamicGraphClient;
|
|
669
|
+
declare function createDOClient(namespace: FiregraphNamespace, rootKey: string, options?: DOClientOptions): DOGraphClient;
|
|
469
670
|
/**
|
|
470
671
|
* Construct a peer `GraphClient` that shares `client`'s DO namespace and
|
|
471
672
|
* construction options but targets a different root DO (i.e. a different
|
|
@@ -498,8 +699,8 @@ declare function createDOClient(namespace: FiregraphNamespace, rootKey: string,
|
|
|
498
699
|
* as `createDOClient`'s `rootKey`: non-empty,
|
|
499
700
|
* no `/`.
|
|
500
701
|
*/
|
|
501
|
-
declare function createSiblingClient(client:
|
|
502
|
-
declare function createSiblingClient(client:
|
|
702
|
+
declare function createSiblingClient(client: DOGraphClient, siblingRootKey: string): DOGraphClient;
|
|
703
|
+
declare function createSiblingClient(client: DODynamicGraphClient, siblingRootKey: string): DODynamicGraphClient;
|
|
503
704
|
|
|
504
705
|
/**
|
|
505
706
|
* Flat SQLite schema for a single firegraph DO.
|
|
@@ -554,4 +755,4 @@ interface BuildDOSchemaOptions {
|
|
|
554
755
|
*/
|
|
555
756
|
declare function buildDOSchemaStatements(table: string, options?: BuildDOSchemaOptions): string[];
|
|
556
757
|
|
|
557
|
-
export { type BatchOp, type BuildDOSchemaOptions, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildDOSchemaStatements, createDOClient, createSiblingClient };
|
|
758
|
+
export { AggregateSpec, BackendCapabilities, type BatchOp, type BuildDOSchemaOptions, BulkUpdatePatch, type CloudflareCapability, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, ExpandParams, ExpandResult, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildDOSchemaStatements, createDOClient, createSiblingClient };
|