@typicalday/firegraph 0.8.0 → 0.10.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-73p5Blx7.d.cts +97 -0
- package/dist/backend-BrqFkbid.d.ts +97 -0
- package/dist/backend.cjs +222 -0
- package/dist/backend.cjs.map +1 -0
- package/dist/backend.d.cts +122 -0
- package/dist/backend.d.ts +122 -0
- package/dist/backend.js +136 -0
- package/dist/backend.js.map +1 -0
- package/dist/{chunk-6OQW5OKO.js → chunk-5753Y42M.js} +12 -4
- package/dist/chunk-5753Y42M.js.map +1 -0
- package/dist/{chunk-YUXOALMR.js → chunk-LZOIQHYN.js} +69 -92
- package/dist/chunk-LZOIQHYN.js.map +1 -0
- package/dist/chunk-R7CRGYY4.js +94 -0
- package/dist/chunk-R7CRGYY4.js.map +1 -0
- package/dist/{chunk-KFA7G37W.js → chunk-SU4FNLC3.js} +32 -30
- package/dist/chunk-SU4FNLC3.js.map +1 -0
- package/dist/chunk-TYYPRVIE.js +57 -0
- package/dist/chunk-TYYPRVIE.js.map +1 -0
- package/dist/{do-sqlite.cjs → cloudflare/index.cjs} +1538 -1420
- package/dist/cloudflare/index.cjs.map +1 -0
- package/dist/cloudflare/index.d.cts +454 -0
- package/dist/cloudflare/index.d.ts +454 -0
- package/dist/cloudflare/index.js +822 -0
- package/dist/cloudflare/index.js.map +1 -0
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/editor/client/assets/index-Bq2bfzeY.js +411 -0
- package/dist/editor/client/index.html +1 -1
- package/dist/editor/server/index.mjs +6481 -6327
- package/dist/index.cjs +165 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -138
- package/dist/index.d.ts +14 -138
- package/dist/index.js +31 -22
- package/dist/index.js.map +1 -1
- package/dist/query-client/index.cjs +30 -28
- package/dist/query-client/index.cjs.map +1 -1
- package/dist/query-client/index.d.cts +2 -2
- package/dist/query-client/index.d.ts +2 -2
- package/dist/query-client/index.js +1 -1
- package/dist/react.cjs +0 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +0 -1
- package/dist/react.js.map +1 -1
- package/dist/scope-path-B1G3YiA7.d.cts +139 -0
- package/dist/scope-path-B1G3YiA7.d.ts +139 -0
- package/dist/{serialization-C6JNNOCS.js → serialization-ZZ7RSDRX.js} +2 -2
- package/dist/svelte.cjs +0 -2
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.js +0 -2
- package/dist/svelte.js.map +1 -1
- package/dist/{types-BVtx9zLv.d.cts → types-DOemdlVA.d.cts} +20 -2
- package/dist/{types-BVtx9zLv.d.ts → types-DOemdlVA.d.ts} +20 -2
- package/package.json +39 -40
- package/dist/chunk-6OQW5OKO.js.map +0 -1
- package/dist/chunk-KFA7G37W.js.map +0 -1
- package/dist/chunk-WOAJRVHD.js +0 -699
- package/dist/chunk-WOAJRVHD.js.map +0 -1
- package/dist/chunk-YUXOALMR.js.map +0 -1
- package/dist/d1.cjs +0 -2416
- package/dist/d1.cjs.map +0 -1
- package/dist/d1.d.cts +0 -54
- package/dist/d1.d.ts +0 -54
- package/dist/d1.js +0 -75
- package/dist/d1.js.map +0 -1
- package/dist/do-sqlite.cjs.map +0 -1
- package/dist/do-sqlite.d.cts +0 -41
- package/dist/do-sqlite.d.ts +0 -41
- package/dist/do-sqlite.js +0 -78
- package/dist/do-sqlite.js.map +0 -1
- package/dist/editor/client/assets/index-tyFcX6qG.js +0 -411
- /package/dist/{serialization-C6JNNOCS.js.map → serialization-ZZ7RSDRX.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,110 +1,20 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
|
|
1
|
+
import { S as StorageBackend } from './backend-73p5Blx7.cjs';
|
|
2
|
+
import { G as GraphClientOptions, a as GraphClient, D as DynamicGraphClient, b as DiscoveryResult, R as RegistryEntry, c as GraphRegistry, d as GraphReader, M as MigrationExecutor, e as DynamicRegistryConfig, S as StoredGraphRecord, f as MigrationWriteBack, g as MigrationStep, F as FindEdgesParams, Q as QueryPlan, h as FindNodesParams, i as QueryFilter, j as GraphRecord, k as MigrationFn, l as StoredMigrationStep, T as TraversalBuilder } from './types-DOemdlVA.cjs';
|
|
3
|
+
export { B as BulkBatchError, m as BulkOptions, n as BulkProgress, o as BulkResult, C as CascadeResult, p as DefineTypeOptions, q as DiscoveredEntity, E as EdgeTopology, r as EdgeTypeData, s as FiregraphConfig, t as GraphBatch, u as GraphTransaction, v as GraphWriter, H as HopDefinition, w as HopResult, N as NodeTypeData, x as QueryMode, y as QueryOptions, z as ScanProtection, A as TraversalOptions, I as TraversalResult, V as ViewContext, J as ViewDefaultsConfig, K as ViewResolverConfig, W as WhereClause, L as defineConfig, O as resolveView } from './types-DOemdlVA.cjs';
|
|
3
4
|
export { CodegenOptions, generateTypes } from './codegen/index.cjs';
|
|
5
|
+
import { F as FiregraphError } from './scope-path-B1G3YiA7.cjs';
|
|
6
|
+
export { C as CrossBackendTransactionError, D as DynamicRegistryError, E as EdgeNotFoundError, I as InvalidQueryError, M as MigrationError, N as NodeNotFoundError, Q as QuerySafetyError, R as RegistryScopeError, b as RegistryViolationError, S as StorageScopeSegment, T as TraversalError, V as ValidationError, a as appendStorageScope, i as isAncestorScopeUid, p as parseStorageScope, r as resolveAncestorScope } from './scope-path-B1G3YiA7.cjs';
|
|
4
7
|
import { Firestore } from '@google-cloud/firestore';
|
|
5
8
|
export { Q as QueryClient, a as QueryClientError, b as QueryClientErrorCode, c as QueryClientOptions } from './client-Bk2Cm6xv.cjs';
|
|
6
9
|
export { E as EntityViewConfig, a as EntityViewMeta, V as ViewComponentClass, b as ViewMeta, c as ViewRegistry, d as ViewRegistryInput, e as defineViews } from './views-DL60k0cf.cjs';
|
|
7
10
|
|
|
8
|
-
/**
|
|
9
|
-
* Backend abstraction for firegraph.
|
|
10
|
-
*
|
|
11
|
-
* `StorageBackend` is the single interface every storage driver implements.
|
|
12
|
-
* The Firestore backend wraps `@google-cloud/firestore`; the SQLite backend
|
|
13
|
-
* (shared by D1 and Durable Object SQLite) uses a parameterized SQL executor.
|
|
14
|
-
*
|
|
15
|
-
* `GraphClientImpl` and friends depend only on this interface — they have
|
|
16
|
-
* no direct knowledge of Firestore or SQLite.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Per-record write payload — backend-agnostic. Timestamps are not present;
|
|
21
|
-
* the backend supplies them via `serverTimestamp()` placeholders that it
|
|
22
|
-
* itself resolves at commit time.
|
|
23
|
-
*/
|
|
24
|
-
interface WritableRecord {
|
|
25
|
-
aType: string;
|
|
26
|
-
aUid: string;
|
|
27
|
-
axbType: string;
|
|
28
|
-
bType: string;
|
|
29
|
-
bUid: string;
|
|
30
|
-
data: Record<string, unknown>;
|
|
31
|
-
/** Schema version (set by the writer when registry has migrations). */
|
|
32
|
-
v?: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Patch shape for `updateDoc`. Captures the two patterns that exist today:
|
|
36
|
-
* - `dataFields`: shallow merge under `data` (used by `updateNode`)
|
|
37
|
-
* - `replaceData`: full data replacement (used by migration write-back)
|
|
38
|
-
* - `v`: optional schema-version stamp
|
|
39
|
-
*
|
|
40
|
-
* `updatedAt` is always set by the backend.
|
|
41
|
-
*/
|
|
42
|
-
interface UpdatePayload {
|
|
43
|
-
dataFields?: Record<string, unknown>;
|
|
44
|
-
replaceData?: Record<string, unknown>;
|
|
45
|
-
v?: number;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Read/write transaction adapter. Mirrors Firestore's transaction semantics:
|
|
49
|
-
* reads are snapshot-consistent; writes are issued inside the transaction
|
|
50
|
-
* and a rejection from any write aborts the surrounding `runTransaction`.
|
|
51
|
-
*
|
|
52
|
-
* Writes return `Promise<void>` so SQL drivers can surface row-level errors
|
|
53
|
-
* (constraint violations, malformed JSON paths) rather than swallowing them.
|
|
54
|
-
* Firestore implementations can resolve synchronously since the underlying
|
|
55
|
-
* `Transaction.set/update/delete` calls are themselves synchronous buffers.
|
|
56
|
-
*/
|
|
57
|
-
interface TransactionBackend {
|
|
58
|
-
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
59
|
-
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
60
|
-
setDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
61
|
-
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
62
|
-
deleteDoc(docId: string): Promise<void>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Atomic multi-write batch.
|
|
66
|
-
*/
|
|
67
|
-
interface BatchBackend {
|
|
68
|
-
setDoc(docId: string, record: WritableRecord): void;
|
|
69
|
-
updateDoc(docId: string, update: UpdatePayload): void;
|
|
70
|
-
deleteDoc(docId: string): void;
|
|
71
|
-
commit(): Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The single storage abstraction.
|
|
75
|
-
*
|
|
76
|
-
* Each backend instance is scoped to a "graph location" — for Firestore
|
|
77
|
-
* that's a collection path; for SQLite it's a (table, scopePath) pair.
|
|
78
|
-
* `subgraph()` returns a child backend bound to a nested location.
|
|
79
|
-
*/
|
|
80
|
-
interface StorageBackend {
|
|
81
|
-
/** Backend-internal location identifier (collection path or table name). */
|
|
82
|
-
readonly collectionPath: string;
|
|
83
|
-
/** Subgraph scope (empty string for root). */
|
|
84
|
-
readonly scopePath: string;
|
|
85
|
-
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
86
|
-
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
87
|
-
setDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
88
|
-
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
89
|
-
deleteDoc(docId: string): Promise<void>;
|
|
90
|
-
runTransaction<T>(fn: (tx: TransactionBackend) => Promise<T>): Promise<T>;
|
|
91
|
-
createBatch(): BatchBackend;
|
|
92
|
-
subgraph(parentNodeUid: string, name: string): StorageBackend;
|
|
93
|
-
removeNodeCascade(uid: string, reader: GraphReader, options?: BulkOptions): Promise<CascadeResult>;
|
|
94
|
-
bulkRemoveEdges(params: FindEdgesParams, reader: GraphReader, options?: BulkOptions): Promise<BulkResult>;
|
|
95
|
-
/**
|
|
96
|
-
* Find edges across all subgraphs sharing a given collection name.
|
|
97
|
-
* Optional — backends that can't support this should throw a clear error.
|
|
98
|
-
*/
|
|
99
|
-
findEdgesGlobal?(params: FindEdgesParams, collectionName?: string): Promise<StoredGraphRecord[]>;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
11
|
/**
|
|
103
12
|
* Create a `GraphClient` backed by an arbitrary `StorageBackend`.
|
|
104
13
|
*
|
|
105
|
-
* Used by backend-specific factories (
|
|
106
|
-
* should use the higher-level
|
|
107
|
-
*
|
|
14
|
+
* Used by backend-specific factories (e.g. `createDOClient` in
|
|
15
|
+
* `firegraph/cloudflare`) — most callers should use the higher-level
|
|
16
|
+
* `createGraphClient(firestore, ...)` overload below for Firestore, or the
|
|
17
|
+
* Cloudflare factory for DO-backed graphs.
|
|
108
18
|
*/
|
|
109
19
|
declare function createGraphClientFromBackend(backend: StorageBackend, options?: GraphClientOptions, metaBackend?: StorageBackend): GraphClient | DynamicGraphClient;
|
|
110
20
|
|
|
@@ -154,42 +64,6 @@ declare function resolveAncestorCollection(collectionPath: string, uid: string):
|
|
|
154
64
|
*/
|
|
155
65
|
declare function isAncestorUid(collectionPath: string, uid: string): boolean;
|
|
156
66
|
|
|
157
|
-
declare class FiregraphError extends Error {
|
|
158
|
-
readonly code: string;
|
|
159
|
-
constructor(message: string, code: string);
|
|
160
|
-
}
|
|
161
|
-
declare class NodeNotFoundError extends FiregraphError {
|
|
162
|
-
constructor(uid: string);
|
|
163
|
-
}
|
|
164
|
-
declare class EdgeNotFoundError extends FiregraphError {
|
|
165
|
-
constructor(aUid: string, axbType: string, bUid: string);
|
|
166
|
-
}
|
|
167
|
-
declare class ValidationError extends FiregraphError {
|
|
168
|
-
readonly details?: unknown | undefined;
|
|
169
|
-
constructor(message: string, details?: unknown | undefined);
|
|
170
|
-
}
|
|
171
|
-
declare class RegistryViolationError extends FiregraphError {
|
|
172
|
-
constructor(aType: string, axbType: string, bType: string);
|
|
173
|
-
}
|
|
174
|
-
declare class InvalidQueryError extends FiregraphError {
|
|
175
|
-
constructor(message: string);
|
|
176
|
-
}
|
|
177
|
-
declare class TraversalError extends FiregraphError {
|
|
178
|
-
constructor(message: string);
|
|
179
|
-
}
|
|
180
|
-
declare class DynamicRegistryError extends FiregraphError {
|
|
181
|
-
constructor(message: string);
|
|
182
|
-
}
|
|
183
|
-
declare class QuerySafetyError extends FiregraphError {
|
|
184
|
-
constructor(message: string);
|
|
185
|
-
}
|
|
186
|
-
declare class RegistryScopeError extends FiregraphError {
|
|
187
|
-
constructor(aType: string, axbType: string, bType: string, scopePath: string, allowedIn: string[]);
|
|
188
|
-
}
|
|
189
|
-
declare class MigrationError extends FiregraphError {
|
|
190
|
-
constructor(message: string);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
67
|
/**
|
|
194
68
|
* Entity Discovery — convention-based auto-discovery of entities from
|
|
195
69
|
* a per-entity folder structure.
|
|
@@ -281,8 +155,10 @@ declare function createRegistryFromGraph(reader: GraphReader, executor?: Migrati
|
|
|
281
155
|
* Firestore-specific client factory.
|
|
282
156
|
*
|
|
283
157
|
* Kept in its own module so that bundlers don't pull
|
|
284
|
-
* `@google-cloud/firestore` into
|
|
285
|
-
* (`firegraph/
|
|
158
|
+
* `@google-cloud/firestore` into non-Firestore entry points — most
|
|
159
|
+
* importantly the Cloudflare DO backend (`firegraph/cloudflare`) and the
|
|
160
|
+
* routing primitive (`firegraph/backend`), both of which must load cleanly
|
|
161
|
+
* in a Workers environment where the Node Firestore SDK is unavailable.
|
|
286
162
|
*/
|
|
287
163
|
|
|
288
164
|
declare function createGraphClient(db: Firestore, collectionPath: string, options: GraphClientOptions & {
|
|
@@ -619,4 +495,4 @@ declare function deserializeFirestoreTypes(data: Record<string, unknown>, db?: F
|
|
|
619
495
|
*/
|
|
620
496
|
declare function createTraversal(reader: GraphClient | GraphReader, startUid: string, registry?: GraphRegistry): TraversalBuilder;
|
|
621
497
|
|
|
622
|
-
export { BOOTSTRAP_ENTRIES,
|
|
498
|
+
export { BOOTSTRAP_ENTRIES, DEFAULT_QUERY_LIMIT, type DiscoverResult, DiscoveryError, DiscoveryResult, type DiscoveryWarning, DynamicGraphClient, DynamicRegistryConfig, EDGE_TYPE_SCHEMA, type FieldMeta, FindEdgesParams, FindNodesParams, FiregraphError, type FirestoreIndex, type FirestoreIndexConfig, type FirestoreIndexField, GraphClient, GraphClientOptions, GraphReader, GraphRecord, GraphRegistry, META_EDGE_TYPE, META_NODE_TYPE, MigrationExecutor, MigrationFn, type MigrationResult, MigrationStep, MigrationWriteBack, NODE_TYPE_SCHEMA, QueryFilter, QueryPlan, type QuerySafetyResult, RegistryEntry, SERIALIZATION_TAG, StoredGraphRecord, StoredMigrationStep, TraversalBuilder, analyzeQuerySafety, applyMigrationChain, buildEdgeQueryPlan, buildEdgeRecord, buildNodeQueryPlan, buildNodeRecord, compileMigrationFn, compileMigrations, compileSchema, computeEdgeDocId, computeNodeDocId, createBootstrapRegistry, createGraphClient, createGraphClientFromBackend, createMergedRegistry, createRegistry, createRegistryFromGraph, createTraversal, defaultExecutor, deserializeFirestoreTypes, destroySandboxWorker, discoverEntities, generateDeterministicUid, generateId, generateIndexConfig, isAncestorUid, isTaggedValue, jsonSchemaToFieldMeta, matchScope, matchScopeAny, migrateRecord, migrateRecords, precompileSource, resolveAncestorCollection, serializeFirestoreTypes, validateMigrationChain };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,110 +1,20 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
|
|
1
|
+
import { S as StorageBackend } from './backend-BrqFkbid.js';
|
|
2
|
+
import { G as GraphClientOptions, a as GraphClient, D as DynamicGraphClient, b as DiscoveryResult, R as RegistryEntry, c as GraphRegistry, d as GraphReader, M as MigrationExecutor, e as DynamicRegistryConfig, S as StoredGraphRecord, f as MigrationWriteBack, g as MigrationStep, F as FindEdgesParams, Q as QueryPlan, h as FindNodesParams, i as QueryFilter, j as GraphRecord, k as MigrationFn, l as StoredMigrationStep, T as TraversalBuilder } from './types-DOemdlVA.js';
|
|
3
|
+
export { B as BulkBatchError, m as BulkOptions, n as BulkProgress, o as BulkResult, C as CascadeResult, p as DefineTypeOptions, q as DiscoveredEntity, E as EdgeTopology, r as EdgeTypeData, s as FiregraphConfig, t as GraphBatch, u as GraphTransaction, v as GraphWriter, H as HopDefinition, w as HopResult, N as NodeTypeData, x as QueryMode, y as QueryOptions, z as ScanProtection, A as TraversalOptions, I as TraversalResult, V as ViewContext, J as ViewDefaultsConfig, K as ViewResolverConfig, W as WhereClause, L as defineConfig, O as resolveView } from './types-DOemdlVA.js';
|
|
3
4
|
export { CodegenOptions, generateTypes } from './codegen/index.js';
|
|
5
|
+
import { F as FiregraphError } from './scope-path-B1G3YiA7.js';
|
|
6
|
+
export { C as CrossBackendTransactionError, D as DynamicRegistryError, E as EdgeNotFoundError, I as InvalidQueryError, M as MigrationError, N as NodeNotFoundError, Q as QuerySafetyError, R as RegistryScopeError, b as RegistryViolationError, S as StorageScopeSegment, T as TraversalError, V as ValidationError, a as appendStorageScope, i as isAncestorScopeUid, p as parseStorageScope, r as resolveAncestorScope } from './scope-path-B1G3YiA7.js';
|
|
4
7
|
import { Firestore } from '@google-cloud/firestore';
|
|
5
8
|
export { Q as QueryClient, a as QueryClientError, b as QueryClientErrorCode, c as QueryClientOptions } from './client-Bk2Cm6xv.js';
|
|
6
9
|
export { E as EntityViewConfig, a as EntityViewMeta, V as ViewComponentClass, b as ViewMeta, c as ViewRegistry, d as ViewRegistryInput, e as defineViews } from './views-DL60k0cf.js';
|
|
7
10
|
|
|
8
|
-
/**
|
|
9
|
-
* Backend abstraction for firegraph.
|
|
10
|
-
*
|
|
11
|
-
* `StorageBackend` is the single interface every storage driver implements.
|
|
12
|
-
* The Firestore backend wraps `@google-cloud/firestore`; the SQLite backend
|
|
13
|
-
* (shared by D1 and Durable Object SQLite) uses a parameterized SQL executor.
|
|
14
|
-
*
|
|
15
|
-
* `GraphClientImpl` and friends depend only on this interface — they have
|
|
16
|
-
* no direct knowledge of Firestore or SQLite.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Per-record write payload — backend-agnostic. Timestamps are not present;
|
|
21
|
-
* the backend supplies them via `serverTimestamp()` placeholders that it
|
|
22
|
-
* itself resolves at commit time.
|
|
23
|
-
*/
|
|
24
|
-
interface WritableRecord {
|
|
25
|
-
aType: string;
|
|
26
|
-
aUid: string;
|
|
27
|
-
axbType: string;
|
|
28
|
-
bType: string;
|
|
29
|
-
bUid: string;
|
|
30
|
-
data: Record<string, unknown>;
|
|
31
|
-
/** Schema version (set by the writer when registry has migrations). */
|
|
32
|
-
v?: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Patch shape for `updateDoc`. Captures the two patterns that exist today:
|
|
36
|
-
* - `dataFields`: shallow merge under `data` (used by `updateNode`)
|
|
37
|
-
* - `replaceData`: full data replacement (used by migration write-back)
|
|
38
|
-
* - `v`: optional schema-version stamp
|
|
39
|
-
*
|
|
40
|
-
* `updatedAt` is always set by the backend.
|
|
41
|
-
*/
|
|
42
|
-
interface UpdatePayload {
|
|
43
|
-
dataFields?: Record<string, unknown>;
|
|
44
|
-
replaceData?: Record<string, unknown>;
|
|
45
|
-
v?: number;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Read/write transaction adapter. Mirrors Firestore's transaction semantics:
|
|
49
|
-
* reads are snapshot-consistent; writes are issued inside the transaction
|
|
50
|
-
* and a rejection from any write aborts the surrounding `runTransaction`.
|
|
51
|
-
*
|
|
52
|
-
* Writes return `Promise<void>` so SQL drivers can surface row-level errors
|
|
53
|
-
* (constraint violations, malformed JSON paths) rather than swallowing them.
|
|
54
|
-
* Firestore implementations can resolve synchronously since the underlying
|
|
55
|
-
* `Transaction.set/update/delete` calls are themselves synchronous buffers.
|
|
56
|
-
*/
|
|
57
|
-
interface TransactionBackend {
|
|
58
|
-
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
59
|
-
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
60
|
-
setDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
61
|
-
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
62
|
-
deleteDoc(docId: string): Promise<void>;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Atomic multi-write batch.
|
|
66
|
-
*/
|
|
67
|
-
interface BatchBackend {
|
|
68
|
-
setDoc(docId: string, record: WritableRecord): void;
|
|
69
|
-
updateDoc(docId: string, update: UpdatePayload): void;
|
|
70
|
-
deleteDoc(docId: string): void;
|
|
71
|
-
commit(): Promise<void>;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* The single storage abstraction.
|
|
75
|
-
*
|
|
76
|
-
* Each backend instance is scoped to a "graph location" — for Firestore
|
|
77
|
-
* that's a collection path; for SQLite it's a (table, scopePath) pair.
|
|
78
|
-
* `subgraph()` returns a child backend bound to a nested location.
|
|
79
|
-
*/
|
|
80
|
-
interface StorageBackend {
|
|
81
|
-
/** Backend-internal location identifier (collection path or table name). */
|
|
82
|
-
readonly collectionPath: string;
|
|
83
|
-
/** Subgraph scope (empty string for root). */
|
|
84
|
-
readonly scopePath: string;
|
|
85
|
-
getDoc(docId: string): Promise<StoredGraphRecord | null>;
|
|
86
|
-
query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
|
|
87
|
-
setDoc(docId: string, record: WritableRecord): Promise<void>;
|
|
88
|
-
updateDoc(docId: string, update: UpdatePayload): Promise<void>;
|
|
89
|
-
deleteDoc(docId: string): Promise<void>;
|
|
90
|
-
runTransaction<T>(fn: (tx: TransactionBackend) => Promise<T>): Promise<T>;
|
|
91
|
-
createBatch(): BatchBackend;
|
|
92
|
-
subgraph(parentNodeUid: string, name: string): StorageBackend;
|
|
93
|
-
removeNodeCascade(uid: string, reader: GraphReader, options?: BulkOptions): Promise<CascadeResult>;
|
|
94
|
-
bulkRemoveEdges(params: FindEdgesParams, reader: GraphReader, options?: BulkOptions): Promise<BulkResult>;
|
|
95
|
-
/**
|
|
96
|
-
* Find edges across all subgraphs sharing a given collection name.
|
|
97
|
-
* Optional — backends that can't support this should throw a clear error.
|
|
98
|
-
*/
|
|
99
|
-
findEdgesGlobal?(params: FindEdgesParams, collectionName?: string): Promise<StoredGraphRecord[]>;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
11
|
/**
|
|
103
12
|
* Create a `GraphClient` backed by an arbitrary `StorageBackend`.
|
|
104
13
|
*
|
|
105
|
-
* Used by backend-specific factories (
|
|
106
|
-
* should use the higher-level
|
|
107
|
-
*
|
|
14
|
+
* Used by backend-specific factories (e.g. `createDOClient` in
|
|
15
|
+
* `firegraph/cloudflare`) — most callers should use the higher-level
|
|
16
|
+
* `createGraphClient(firestore, ...)` overload below for Firestore, or the
|
|
17
|
+
* Cloudflare factory for DO-backed graphs.
|
|
108
18
|
*/
|
|
109
19
|
declare function createGraphClientFromBackend(backend: StorageBackend, options?: GraphClientOptions, metaBackend?: StorageBackend): GraphClient | DynamicGraphClient;
|
|
110
20
|
|
|
@@ -154,42 +64,6 @@ declare function resolveAncestorCollection(collectionPath: string, uid: string):
|
|
|
154
64
|
*/
|
|
155
65
|
declare function isAncestorUid(collectionPath: string, uid: string): boolean;
|
|
156
66
|
|
|
157
|
-
declare class FiregraphError extends Error {
|
|
158
|
-
readonly code: string;
|
|
159
|
-
constructor(message: string, code: string);
|
|
160
|
-
}
|
|
161
|
-
declare class NodeNotFoundError extends FiregraphError {
|
|
162
|
-
constructor(uid: string);
|
|
163
|
-
}
|
|
164
|
-
declare class EdgeNotFoundError extends FiregraphError {
|
|
165
|
-
constructor(aUid: string, axbType: string, bUid: string);
|
|
166
|
-
}
|
|
167
|
-
declare class ValidationError extends FiregraphError {
|
|
168
|
-
readonly details?: unknown | undefined;
|
|
169
|
-
constructor(message: string, details?: unknown | undefined);
|
|
170
|
-
}
|
|
171
|
-
declare class RegistryViolationError extends FiregraphError {
|
|
172
|
-
constructor(aType: string, axbType: string, bType: string);
|
|
173
|
-
}
|
|
174
|
-
declare class InvalidQueryError extends FiregraphError {
|
|
175
|
-
constructor(message: string);
|
|
176
|
-
}
|
|
177
|
-
declare class TraversalError extends FiregraphError {
|
|
178
|
-
constructor(message: string);
|
|
179
|
-
}
|
|
180
|
-
declare class DynamicRegistryError extends FiregraphError {
|
|
181
|
-
constructor(message: string);
|
|
182
|
-
}
|
|
183
|
-
declare class QuerySafetyError extends FiregraphError {
|
|
184
|
-
constructor(message: string);
|
|
185
|
-
}
|
|
186
|
-
declare class RegistryScopeError extends FiregraphError {
|
|
187
|
-
constructor(aType: string, axbType: string, bType: string, scopePath: string, allowedIn: string[]);
|
|
188
|
-
}
|
|
189
|
-
declare class MigrationError extends FiregraphError {
|
|
190
|
-
constructor(message: string);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
67
|
/**
|
|
194
68
|
* Entity Discovery — convention-based auto-discovery of entities from
|
|
195
69
|
* a per-entity folder structure.
|
|
@@ -281,8 +155,10 @@ declare function createRegistryFromGraph(reader: GraphReader, executor?: Migrati
|
|
|
281
155
|
* Firestore-specific client factory.
|
|
282
156
|
*
|
|
283
157
|
* Kept in its own module so that bundlers don't pull
|
|
284
|
-
* `@google-cloud/firestore` into
|
|
285
|
-
* (`firegraph/
|
|
158
|
+
* `@google-cloud/firestore` into non-Firestore entry points — most
|
|
159
|
+
* importantly the Cloudflare DO backend (`firegraph/cloudflare`) and the
|
|
160
|
+
* routing primitive (`firegraph/backend`), both of which must load cleanly
|
|
161
|
+
* in a Workers environment where the Node Firestore SDK is unavailable.
|
|
286
162
|
*/
|
|
287
163
|
|
|
288
164
|
declare function createGraphClient(db: Firestore, collectionPath: string, options: GraphClientOptions & {
|
|
@@ -619,4 +495,4 @@ declare function deserializeFirestoreTypes(data: Record<string, unknown>, db?: F
|
|
|
619
495
|
*/
|
|
620
496
|
declare function createTraversal(reader: GraphClient | GraphReader, startUid: string, registry?: GraphRegistry): TraversalBuilder;
|
|
621
497
|
|
|
622
|
-
export { BOOTSTRAP_ENTRIES,
|
|
498
|
+
export { BOOTSTRAP_ENTRIES, DEFAULT_QUERY_LIMIT, type DiscoverResult, DiscoveryError, DiscoveryResult, type DiscoveryWarning, DynamicGraphClient, DynamicRegistryConfig, EDGE_TYPE_SCHEMA, type FieldMeta, FindEdgesParams, FindNodesParams, FiregraphError, type FirestoreIndex, type FirestoreIndexConfig, type FirestoreIndexField, GraphClient, GraphClientOptions, GraphReader, GraphRecord, GraphRegistry, META_EDGE_TYPE, META_NODE_TYPE, MigrationExecutor, MigrationFn, type MigrationResult, MigrationStep, MigrationWriteBack, NODE_TYPE_SCHEMA, QueryFilter, QueryPlan, type QuerySafetyResult, RegistryEntry, SERIALIZATION_TAG, StoredGraphRecord, StoredMigrationStep, TraversalBuilder, analyzeQuerySafety, applyMigrationChain, buildEdgeQueryPlan, buildEdgeRecord, buildNodeQueryPlan, buildNodeRecord, compileMigrationFn, compileMigrations, compileSchema, computeEdgeDocId, computeNodeDocId, createBootstrapRegistry, createGraphClient, createGraphClientFromBackend, createMergedRegistry, createRegistry, createRegistryFromGraph, createTraversal, defaultExecutor, deserializeFirestoreTypes, destroySandboxWorker, discoverEntities, generateDeterministicUid, generateId, generateIndexConfig, isAncestorUid, isTaggedValue, jsonSchemaToFieldMeta, matchScope, matchScopeAny, migrateRecord, migrateRecords, precompileSource, resolveAncestorCollection, serializeFirestoreTypes, validateMigrationChain };
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendStorageScope,
|
|
3
|
+
isAncestorScopeUid,
|
|
4
|
+
parseStorageScope,
|
|
5
|
+
resolveAncestorScope
|
|
6
|
+
} from "./chunk-TYYPRVIE.js";
|
|
1
7
|
import {
|
|
2
8
|
BOOTSTRAP_ENTRIES,
|
|
3
9
|
DEFAULT_QUERY_LIMIT,
|
|
4
|
-
DynamicRegistryError,
|
|
5
10
|
EDGE_TYPE_SCHEMA,
|
|
6
|
-
EdgeNotFoundError,
|
|
7
|
-
FiregraphError,
|
|
8
11
|
GraphClientImpl,
|
|
9
|
-
InvalidQueryError,
|
|
10
12
|
META_EDGE_TYPE,
|
|
11
13
|
META_NODE_TYPE,
|
|
12
|
-
MigrationError,
|
|
13
14
|
NODE_RELATION,
|
|
14
15
|
NODE_TYPE_SCHEMA,
|
|
15
|
-
NodeNotFoundError,
|
|
16
|
-
QuerySafetyError,
|
|
17
|
-
RegistryScopeError,
|
|
18
|
-
RegistryViolationError,
|
|
19
|
-
TraversalError,
|
|
20
|
-
ValidationError,
|
|
21
16
|
analyzeQuerySafety,
|
|
22
17
|
applyMigrationChain,
|
|
23
18
|
buildEdgeQueryPlan,
|
|
@@ -42,20 +37,34 @@ import {
|
|
|
42
37
|
migrateRecords,
|
|
43
38
|
precompileSource,
|
|
44
39
|
validateMigrationChain
|
|
45
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-LZOIQHYN.js";
|
|
41
|
+
import {
|
|
42
|
+
CrossBackendTransactionError,
|
|
43
|
+
DynamicRegistryError,
|
|
44
|
+
EdgeNotFoundError,
|
|
45
|
+
FiregraphError,
|
|
46
|
+
InvalidQueryError,
|
|
47
|
+
MigrationError,
|
|
48
|
+
NodeNotFoundError,
|
|
49
|
+
QuerySafetyError,
|
|
50
|
+
RegistryScopeError,
|
|
51
|
+
RegistryViolationError,
|
|
52
|
+
TraversalError,
|
|
53
|
+
ValidationError
|
|
54
|
+
} from "./chunk-R7CRGYY4.js";
|
|
46
55
|
import {
|
|
47
56
|
generateTypes
|
|
48
57
|
} from "./chunk-YLGXLEUE.js";
|
|
49
58
|
import {
|
|
50
59
|
QueryClient,
|
|
51
60
|
QueryClientError
|
|
52
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-SU4FNLC3.js";
|
|
53
62
|
import {
|
|
54
63
|
SERIALIZATION_TAG,
|
|
55
64
|
deserializeFirestoreTypes,
|
|
56
65
|
isTaggedValue,
|
|
57
66
|
serializeFirestoreTypes
|
|
58
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-5753Y42M.js";
|
|
59
68
|
|
|
60
69
|
// src/config.ts
|
|
61
70
|
function defineConfig(config) {
|
|
@@ -91,7 +100,7 @@ function isAncestorUid(collectionPath, uid) {
|
|
|
91
100
|
}
|
|
92
101
|
|
|
93
102
|
// src/discover.ts
|
|
94
|
-
import {
|
|
103
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
95
104
|
import { createRequire } from "module";
|
|
96
105
|
import { join, resolve } from "path";
|
|
97
106
|
var DiscoveryError = class extends FiregraphError {
|
|
@@ -223,14 +232,10 @@ function loadEdgeEntity(dir, name) {
|
|
|
223
232
|
}
|
|
224
233
|
const topology = readJson(edgePath);
|
|
225
234
|
if (!topology.from) {
|
|
226
|
-
throw new DiscoveryError(
|
|
227
|
-
`edge.json for "${name}" is missing required "from" field`
|
|
228
|
-
);
|
|
235
|
+
throw new DiscoveryError(`edge.json for "${name}" is missing required "from" field`);
|
|
229
236
|
}
|
|
230
237
|
if (!topology.to) {
|
|
231
|
-
throw new DiscoveryError(
|
|
232
|
-
`edge.json for "${name}" is missing required "to" field`
|
|
233
|
-
);
|
|
238
|
+
throw new DiscoveryError(`edge.json for "${name}" is missing required "to" field`);
|
|
234
239
|
}
|
|
235
240
|
const meta = readJsonIfExists(join(dir, "meta.json"));
|
|
236
241
|
const sampleData = readJsonIfExists(join(dir, "sample.json"));
|
|
@@ -1134,7 +1139,6 @@ function getCustomElements() {
|
|
|
1134
1139
|
function resilientView(ViewClass, tagName) {
|
|
1135
1140
|
const g = globalThis;
|
|
1136
1141
|
if (!g.HTMLElement) return ViewClass;
|
|
1137
|
-
const Base = g.HTMLElement;
|
|
1138
1142
|
const Wrapped = class extends ViewClass {
|
|
1139
1143
|
connectedCallback() {
|
|
1140
1144
|
try {
|
|
@@ -1221,6 +1225,7 @@ function defineViews(input) {
|
|
|
1221
1225
|
}
|
|
1222
1226
|
export {
|
|
1223
1227
|
BOOTSTRAP_ENTRIES,
|
|
1228
|
+
CrossBackendTransactionError,
|
|
1224
1229
|
DEFAULT_QUERY_LIMIT,
|
|
1225
1230
|
DiscoveryError,
|
|
1226
1231
|
DynamicRegistryError,
|
|
@@ -1242,6 +1247,7 @@ export {
|
|
|
1242
1247
|
TraversalError,
|
|
1243
1248
|
ValidationError,
|
|
1244
1249
|
analyzeQuerySafety,
|
|
1250
|
+
appendStorageScope,
|
|
1245
1251
|
applyMigrationChain,
|
|
1246
1252
|
buildEdgeQueryPlan,
|
|
1247
1253
|
buildEdgeRecord,
|
|
@@ -1269,6 +1275,7 @@ export {
|
|
|
1269
1275
|
generateId,
|
|
1270
1276
|
generateIndexConfig,
|
|
1271
1277
|
generateTypes,
|
|
1278
|
+
isAncestorScopeUid,
|
|
1272
1279
|
isAncestorUid,
|
|
1273
1280
|
isTaggedValue,
|
|
1274
1281
|
jsonSchemaToFieldMeta,
|
|
@@ -1276,8 +1283,10 @@ export {
|
|
|
1276
1283
|
matchScopeAny,
|
|
1277
1284
|
migrateRecord,
|
|
1278
1285
|
migrateRecords,
|
|
1286
|
+
parseStorageScope,
|
|
1279
1287
|
precompileSource,
|
|
1280
1288
|
resolveAncestorCollection,
|
|
1289
|
+
resolveAncestorScope,
|
|
1281
1290
|
resolveView,
|
|
1282
1291
|
serializeFirestoreTypes,
|
|
1283
1292
|
validateMigrationChain
|