@typicalday/firegraph 0.11.1 → 0.12.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 +40 -15
- package/dist/backend-BsR0lnFL.d.ts +200 -0
- package/dist/backend-Ct-fLlkG.d.cts +200 -0
- package/dist/backend.cjs +143 -2
- package/dist/backend.cjs.map +1 -1
- package/dist/backend.d.cts +3 -3
- package/dist/backend.d.ts +3 -3
- package/dist/backend.js +13 -4
- package/dist/backend.js.map +1 -1
- package/dist/chunk-AWW4MUJ5.js +245 -0
- package/dist/chunk-AWW4MUJ5.js.map +1 -0
- package/dist/{chunk-5753Y42M.js → chunk-C2QMD7RY.js} +6 -10
- package/dist/chunk-C2QMD7RY.js.map +1 -0
- package/dist/chunk-EQJUUVFG.js +14 -0
- package/dist/chunk-EQJUUVFG.js.map +1 -0
- package/dist/{chunk-6SB34IPQ.js → chunk-HONQY4HF.js} +100 -28
- package/dist/chunk-HONQY4HF.js.map +1 -0
- package/dist/cloudflare/index.cjs +509 -102
- package/dist/cloudflare/index.cjs.map +1 -1
- package/dist/cloudflare/index.d.cts +45 -17
- package/dist/cloudflare/index.d.ts +45 -17
- package/dist/cloudflare/index.js +265 -74
- 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/index.cjs +291 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -77
- package/dist/index.d.ts +59 -77
- package/dist/index.js +58 -28
- package/dist/index.js.map +1 -1
- package/dist/registry-B1qsVL0E.d.cts +64 -0
- package/dist/registry-Fi074zVa.d.ts +64 -0
- package/dist/{serialization-ZZ7RSDRX.js → serialization-OE2PFZMY.js} +6 -4
- package/dist/{types-BGWxcpI_.d.cts → types-DxYLy8Ol.d.cts} +36 -2
- package/dist/{types-BGWxcpI_.d.ts → types-DxYLy8Ol.d.ts} +36 -2
- package/package.json +8 -3
- package/dist/backend-U-MLShlg.d.ts +0 -97
- package/dist/backend-np4gEVhB.d.cts +0 -97
- package/dist/chunk-5753Y42M.js.map +0 -1
- package/dist/chunk-6SB34IPQ.js.map +0 -1
- package/dist/chunk-R7CRGYY4.js +0 -94
- package/dist/chunk-R7CRGYY4.js.map +0 -1
- /package/dist/{serialization-ZZ7RSDRX.js.map → serialization-OE2PFZMY.js.map} +0 -0
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { W as WritableRecord, U as UpdatePayload, S as StorageBackend, T as TransactionBackend, B as BatchBackend } from '../backend-
|
|
2
|
-
|
|
1
|
+
import { W as WritableRecord, b as WriteMode, U as UpdatePayload, S as StorageBackend, T as TransactionBackend, B as BatchBackend } from '../backend-Ct-fLlkG.cjs';
|
|
2
|
+
export { d as deleteField } from '../backend-Ct-fLlkG.cjs';
|
|
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';
|
|
4
|
+
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-B1qsVL0E.cjs';
|
|
3
6
|
import '@google-cloud/firestore';
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -79,14 +82,26 @@ interface DORecordWire {
|
|
|
79
82
|
* }
|
|
80
83
|
* ```
|
|
81
84
|
*
|
|
82
|
-
* ## Why
|
|
85
|
+
* ## Why `extends DurableObject`?
|
|
83
86
|
*
|
|
84
|
-
* Cloudflare
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* Cloudflare's modern Durable Objects RPC dispatcher only accepts arbitrary
|
|
88
|
+
* method invocations on stubs whose backing class extends the special
|
|
89
|
+
* `DurableObject` base from `cloudflare:workers`. Plain classes with the
|
|
90
|
+
* `(state, env)` constructor shape still load and serve `fetch()`, but a
|
|
91
|
+
* stub method call (`stub._fgGetDoc(...)`) on a plain-class DO throws:
|
|
92
|
+
*
|
|
93
|
+
* The receiving Durable Object does not support RPC, because its class
|
|
94
|
+
* was not declared with `extends DurableObject`.
|
|
95
|
+
*
|
|
96
|
+
* `DORPCBackend` calls every operation as a stub method (see
|
|
97
|
+
* `src/cloudflare/backend.ts`), so extending `DurableObject` is mandatory
|
|
98
|
+
* for this library's design to work on production Workers.
|
|
99
|
+
*
|
|
100
|
+
* The `cloudflare:workers` import is virtual — only the workerd runtime
|
|
101
|
+
* resolves it. For Node tests we route the import through a vitest alias
|
|
102
|
+
* to a tiny stub class (`tests/__shims__/cloudflare-workers.ts`) that just
|
|
103
|
+
* captures `ctx`/`env`. Tests instantiating `FiregraphDO` directly still
|
|
104
|
+
* work; they just go through the stub instead of the real base class.
|
|
90
105
|
*/
|
|
91
106
|
|
|
92
107
|
interface DOSqlCursor<T> {
|
|
@@ -111,6 +126,7 @@ type BatchOp = {
|
|
|
111
126
|
kind: 'set';
|
|
112
127
|
docId: string;
|
|
113
128
|
record: WritableRecord;
|
|
129
|
+
mode: WriteMode;
|
|
114
130
|
} | {
|
|
115
131
|
kind: 'update';
|
|
116
132
|
docId: string;
|
|
@@ -146,11 +162,23 @@ interface FiregraphDOOptions {
|
|
|
146
162
|
*/
|
|
147
163
|
coreIndexes?: IndexSpec[];
|
|
148
164
|
}
|
|
149
|
-
declare class FiregraphDO {
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
165
|
+
declare class FiregraphDO extends DurableObject<unknown> {
|
|
166
|
+
/**
|
|
167
|
+
* @internal — locally-narrowed alias for `this.ctx`, used only by
|
|
168
|
+
* FiregraphDO's own SQL helpers. Same runtime object as the inherited
|
|
169
|
+
* `this.ctx`, but typed as `DurableObjectStateLike` (just `storage.sql`
|
|
170
|
+
* / `transactionSync` / `blockConcurrencyWhile`) so internal calls
|
|
171
|
+
* don't trip over workers-types' stricter
|
|
172
|
+
* `SqlStorage.exec<T extends Record<string, SqlStorageValue>>`
|
|
173
|
+
* constraint vs the `Record<string, unknown>` rows firegraph passes.
|
|
174
|
+
*
|
|
175
|
+
* **Subclasses should use `this.ctx`, not `this.state`.** `this.state`
|
|
176
|
+
* deliberately exposes only the slice FiregraphDO needs internally;
|
|
177
|
+
* subclasses that want `id`, `acceptWebSocket`, `setAlarm`, `getAlarm`,
|
|
178
|
+
* `waitUntil`, `props`, etc. must reach for the inherited `this.ctx`
|
|
179
|
+
* (the full workers-types `DurableObjectState`).
|
|
180
|
+
*/
|
|
181
|
+
protected readonly state: DurableObjectStateLike;
|
|
154
182
|
/** @internal — table name used by every compiled statement. */
|
|
155
183
|
protected readonly table: string;
|
|
156
184
|
/** @internal — registry consulted by `runSchema` for per-entry indexes. */
|
|
@@ -160,7 +188,7 @@ declare class FiregraphDO {
|
|
|
160
188
|
constructor(ctx: DurableObjectStateLike, env: unknown, options?: FiregraphDOOptions);
|
|
161
189
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
162
190
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
163
|
-
_fgSetDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
191
|
+
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
164
192
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
165
193
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
166
194
|
/**
|
|
@@ -232,7 +260,7 @@ interface DurableObjectIdLike {
|
|
|
232
260
|
interface FiregraphStub {
|
|
233
261
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
234
262
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
235
|
-
_fgSetDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
263
|
+
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
236
264
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
237
265
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
238
266
|
_fgBatch(ops: BatchOp[]): Promise<void>;
|
|
@@ -295,7 +323,7 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
295
323
|
private get stub();
|
|
296
324
|
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
297
325
|
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
298
|
-
setDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
326
|
+
setDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
299
327
|
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
300
328
|
deleteDoc(docId: string): Promise<void>;
|
|
301
329
|
runTransaction<T>(_fn: (tx: TransactionBackend) => Promise<T>): Promise<T>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { W as WritableRecord, U as UpdatePayload, S as StorageBackend, T as TransactionBackend, B as BatchBackend } from '../backend-
|
|
2
|
-
|
|
1
|
+
import { W as WritableRecord, b as WriteMode, U as UpdatePayload, S as StorageBackend, T as TransactionBackend, B as BatchBackend } from '../backend-BsR0lnFL.js';
|
|
2
|
+
export { d as deleteField } from '../backend-BsR0lnFL.js';
|
|
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';
|
|
4
|
+
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-Fi074zVa.js';
|
|
3
6
|
import '@google-cloud/firestore';
|
|
4
7
|
|
|
5
8
|
/**
|
|
@@ -79,14 +82,26 @@ interface DORecordWire {
|
|
|
79
82
|
* }
|
|
80
83
|
* ```
|
|
81
84
|
*
|
|
82
|
-
* ## Why
|
|
85
|
+
* ## Why `extends DurableObject`?
|
|
83
86
|
*
|
|
84
|
-
* Cloudflare
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* Cloudflare's modern Durable Objects RPC dispatcher only accepts arbitrary
|
|
88
|
+
* method invocations on stubs whose backing class extends the special
|
|
89
|
+
* `DurableObject` base from `cloudflare:workers`. Plain classes with the
|
|
90
|
+
* `(state, env)` constructor shape still load and serve `fetch()`, but a
|
|
91
|
+
* stub method call (`stub._fgGetDoc(...)`) on a plain-class DO throws:
|
|
92
|
+
*
|
|
93
|
+
* The receiving Durable Object does not support RPC, because its class
|
|
94
|
+
* was not declared with `extends DurableObject`.
|
|
95
|
+
*
|
|
96
|
+
* `DORPCBackend` calls every operation as a stub method (see
|
|
97
|
+
* `src/cloudflare/backend.ts`), so extending `DurableObject` is mandatory
|
|
98
|
+
* for this library's design to work on production Workers.
|
|
99
|
+
*
|
|
100
|
+
* The `cloudflare:workers` import is virtual — only the workerd runtime
|
|
101
|
+
* resolves it. For Node tests we route the import through a vitest alias
|
|
102
|
+
* to a tiny stub class (`tests/__shims__/cloudflare-workers.ts`) that just
|
|
103
|
+
* captures `ctx`/`env`. Tests instantiating `FiregraphDO` directly still
|
|
104
|
+
* work; they just go through the stub instead of the real base class.
|
|
90
105
|
*/
|
|
91
106
|
|
|
92
107
|
interface DOSqlCursor<T> {
|
|
@@ -111,6 +126,7 @@ type BatchOp = {
|
|
|
111
126
|
kind: 'set';
|
|
112
127
|
docId: string;
|
|
113
128
|
record: WritableRecord;
|
|
129
|
+
mode: WriteMode;
|
|
114
130
|
} | {
|
|
115
131
|
kind: 'update';
|
|
116
132
|
docId: string;
|
|
@@ -146,11 +162,23 @@ interface FiregraphDOOptions {
|
|
|
146
162
|
*/
|
|
147
163
|
coreIndexes?: IndexSpec[];
|
|
148
164
|
}
|
|
149
|
-
declare class FiregraphDO {
|
|
150
|
-
/**
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
165
|
+
declare class FiregraphDO extends DurableObject<unknown> {
|
|
166
|
+
/**
|
|
167
|
+
* @internal — locally-narrowed alias for `this.ctx`, used only by
|
|
168
|
+
* FiregraphDO's own SQL helpers. Same runtime object as the inherited
|
|
169
|
+
* `this.ctx`, but typed as `DurableObjectStateLike` (just `storage.sql`
|
|
170
|
+
* / `transactionSync` / `blockConcurrencyWhile`) so internal calls
|
|
171
|
+
* don't trip over workers-types' stricter
|
|
172
|
+
* `SqlStorage.exec<T extends Record<string, SqlStorageValue>>`
|
|
173
|
+
* constraint vs the `Record<string, unknown>` rows firegraph passes.
|
|
174
|
+
*
|
|
175
|
+
* **Subclasses should use `this.ctx`, not `this.state`.** `this.state`
|
|
176
|
+
* deliberately exposes only the slice FiregraphDO needs internally;
|
|
177
|
+
* subclasses that want `id`, `acceptWebSocket`, `setAlarm`, `getAlarm`,
|
|
178
|
+
* `waitUntil`, `props`, etc. must reach for the inherited `this.ctx`
|
|
179
|
+
* (the full workers-types `DurableObjectState`).
|
|
180
|
+
*/
|
|
181
|
+
protected readonly state: DurableObjectStateLike;
|
|
154
182
|
/** @internal — table name used by every compiled statement. */
|
|
155
183
|
protected readonly table: string;
|
|
156
184
|
/** @internal — registry consulted by `runSchema` for per-entry indexes. */
|
|
@@ -160,7 +188,7 @@ declare class FiregraphDO {
|
|
|
160
188
|
constructor(ctx: DurableObjectStateLike, env: unknown, options?: FiregraphDOOptions);
|
|
161
189
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
162
190
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
163
|
-
_fgSetDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
191
|
+
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
164
192
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
165
193
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
166
194
|
/**
|
|
@@ -232,7 +260,7 @@ interface DurableObjectIdLike {
|
|
|
232
260
|
interface FiregraphStub {
|
|
233
261
|
_fgGetDoc(docId: string): Promise<DORecordWire | null>;
|
|
234
262
|
_fgQuery(filters: QueryFilter[], options?: QueryOptions): Promise<DORecordWire[]>;
|
|
235
|
-
_fgSetDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
263
|
+
_fgSetDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
236
264
|
_fgUpdateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
237
265
|
_fgDeleteDoc(docId: string): Promise<void>;
|
|
238
266
|
_fgBatch(ops: BatchOp[]): Promise<void>;
|
|
@@ -295,7 +323,7 @@ declare class DORPCBackend implements StorageBackend {
|
|
|
295
323
|
private get stub();
|
|
296
324
|
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
297
325
|
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
298
|
-
setDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
326
|
+
setDoc(docId: string, record: WritableRecord, mode: WriteMode): Promise<void>;
|
|
299
327
|
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
300
328
|
deleteDoc(docId: string): Promise<void>;
|
|
301
329
|
runTransaction<T>(_fn: (tx: TransactionBackend) => Promise<T>): Promise<T>;
|