@typicalday/firegraph 0.8.0 → 0.9.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.
Files changed (65) hide show
  1. package/dist/backend.cjs +222 -0
  2. package/dist/backend.cjs.map +1 -0
  3. package/dist/backend.d.cts +121 -0
  4. package/dist/backend.d.ts +121 -0
  5. package/dist/backend.js +136 -0
  6. package/dist/backend.js.map +1 -0
  7. package/dist/{chunk-6OQW5OKO.js → chunk-5753Y42M.js} +12 -4
  8. package/dist/chunk-5753Y42M.js.map +1 -0
  9. package/dist/{chunk-YUXOALMR.js → chunk-EVUM6ORB.js} +14 -92
  10. package/dist/chunk-EVUM6ORB.js.map +1 -0
  11. package/dist/chunk-GLOVWKQH.js +94 -0
  12. package/dist/chunk-GLOVWKQH.js.map +1 -0
  13. package/dist/{chunk-KFA7G37W.js → chunk-SU4FNLC3.js} +32 -30
  14. package/dist/chunk-SU4FNLC3.js.map +1 -0
  15. package/dist/{chunk-WOAJRVHD.js → chunk-SZ6W4VAS.js} +5 -3
  16. package/dist/{chunk-WOAJRVHD.js.map → chunk-SZ6W4VAS.js.map} +1 -1
  17. package/dist/chunk-TYYPRVIE.js +57 -0
  18. package/dist/chunk-TYYPRVIE.js.map +1 -0
  19. package/dist/codegen/index.d.cts +1 -1
  20. package/dist/codegen/index.d.ts +1 -1
  21. package/dist/d1.cjs +11 -6
  22. package/dist/d1.cjs.map +1 -1
  23. package/dist/d1.d.cts +1 -1
  24. package/dist/d1.d.ts +1 -1
  25. package/dist/d1.js +3 -2
  26. package/dist/d1.js.map +1 -1
  27. package/dist/do-sqlite.cjs +11 -6
  28. package/dist/do-sqlite.cjs.map +1 -1
  29. package/dist/do-sqlite.d.cts +1 -1
  30. package/dist/do-sqlite.d.ts +1 -1
  31. package/dist/do-sqlite.js +3 -2
  32. package/dist/do-sqlite.js.map +1 -1
  33. package/dist/editor/client/assets/index-Bq2bfzeY.js +411 -0
  34. package/dist/editor/client/index.html +1 -1
  35. package/dist/editor/server/index.mjs +6432 -6333
  36. package/dist/index.cjs +110 -44
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +5 -133
  39. package/dist/index.d.ts +5 -133
  40. package/dist/index.js +36 -27
  41. package/dist/index.js.map +1 -1
  42. package/dist/query-client/index.cjs +30 -28
  43. package/dist/query-client/index.cjs.map +1 -1
  44. package/dist/query-client/index.d.cts +2 -2
  45. package/dist/query-client/index.d.ts +2 -2
  46. package/dist/query-client/index.js +1 -1
  47. package/dist/react.cjs +0 -1
  48. package/dist/react.cjs.map +1 -1
  49. package/dist/react.js +0 -1
  50. package/dist/react.js.map +1 -1
  51. package/dist/scope-path-BtajqNK5.d.ts +234 -0
  52. package/dist/scope-path-D2mNENJ-.d.cts +234 -0
  53. package/dist/{serialization-C6JNNOCS.js → serialization-ZZ7RSDRX.js} +2 -2
  54. package/dist/svelte.cjs +0 -2
  55. package/dist/svelte.cjs.map +1 -1
  56. package/dist/svelte.js +0 -2
  57. package/dist/svelte.js.map +1 -1
  58. package/dist/{types-BVtx9zLv.d.cts → types-DfWVTsMn.d.cts} +3 -2
  59. package/dist/{types-BVtx9zLv.d.ts → types-DfWVTsMn.d.ts} +3 -2
  60. package/package.json +12 -1
  61. package/dist/chunk-6OQW5OKO.js.map +0 -1
  62. package/dist/chunk-KFA7G37W.js.map +0 -1
  63. package/dist/chunk-YUXOALMR.js.map +0 -1
  64. package/dist/editor/client/assets/index-tyFcX6qG.js +0 -411
  65. /package/dist/{serialization-C6JNNOCS.js.map → serialization-ZZ7RSDRX.js.map} +0 -0
@@ -0,0 +1,234 @@
1
+ import { S as StoredGraphRecord, i as QueryFilter, y as QueryOptions, e as GraphReader, m as BulkOptions, C as CascadeResult, F as FindEdgesParams, o as BulkResult } from './types-DfWVTsMn.cjs';
2
+
3
+ declare class FiregraphError extends Error {
4
+ readonly code: string;
5
+ constructor(message: string, code: string);
6
+ }
7
+ declare class NodeNotFoundError extends FiregraphError {
8
+ constructor(uid: string);
9
+ }
10
+ declare class EdgeNotFoundError extends FiregraphError {
11
+ constructor(aUid: string, axbType: string, bUid: string);
12
+ }
13
+ declare class ValidationError extends FiregraphError {
14
+ readonly details?: unknown | undefined;
15
+ constructor(message: string, details?: unknown | undefined);
16
+ }
17
+ declare class RegistryViolationError extends FiregraphError {
18
+ constructor(aType: string, axbType: string, bType: string);
19
+ }
20
+ declare class InvalidQueryError extends FiregraphError {
21
+ constructor(message: string);
22
+ }
23
+ declare class TraversalError extends FiregraphError {
24
+ constructor(message: string);
25
+ }
26
+ declare class DynamicRegistryError extends FiregraphError {
27
+ constructor(message: string);
28
+ }
29
+ declare class QuerySafetyError extends FiregraphError {
30
+ constructor(message: string);
31
+ }
32
+ declare class RegistryScopeError extends FiregraphError {
33
+ constructor(aType: string, axbType: string, bType: string, scopePath: string, allowedIn: string[]);
34
+ }
35
+ declare class MigrationError extends FiregraphError {
36
+ constructor(message: string);
37
+ }
38
+ /**
39
+ * Thrown when a caller tries to perform an operation that would require
40
+ * atomicity across two physical storage backends — e.g. opening a routed
41
+ * subgraph client from inside a transaction callback. Cross-backend
42
+ * atomicity cannot be honoured by any of the underlying drivers (D1, DO
43
+ * SQLite, Firestore), so firegraph surfaces this as a typed error instead
44
+ * of silently confining the write to the base backend.
45
+ *
46
+ * Normally `TransactionBackend` and `BatchBackend` don't expose `subgraph()`
47
+ * at the type level, so this error is unreachable through well-typed code.
48
+ * It exists as a public catchable type for app code that needs to tolerate
49
+ * this case deliberately (e.g. dynamic code paths that bypass the type
50
+ * system) and as future-proofing if the interface ever grows a way to
51
+ * request a sub-scope inside a transaction.
52
+ */
53
+ declare class CrossBackendTransactionError extends FiregraphError {
54
+ constructor(message: string);
55
+ }
56
+
57
+ /**
58
+ * Backend abstraction for firegraph.
59
+ *
60
+ * `StorageBackend` is the single interface every storage driver implements.
61
+ * The Firestore backend wraps `@google-cloud/firestore`; the SQLite backend
62
+ * (shared by D1 and Durable Object SQLite) uses a parameterized SQL executor.
63
+ *
64
+ * `GraphClientImpl` and friends depend only on this interface — they have
65
+ * no direct knowledge of Firestore or SQLite.
66
+ */
67
+
68
+ /**
69
+ * Per-record write payload — backend-agnostic. Timestamps are not present;
70
+ * the backend supplies them via `serverTimestamp()` placeholders that it
71
+ * itself resolves at commit time.
72
+ */
73
+ interface WritableRecord {
74
+ aType: string;
75
+ aUid: string;
76
+ axbType: string;
77
+ bType: string;
78
+ bUid: string;
79
+ data: Record<string, unknown>;
80
+ /** Schema version (set by the writer when registry has migrations). */
81
+ v?: number;
82
+ }
83
+ /**
84
+ * Patch shape for `updateDoc`. Captures the two patterns that exist today:
85
+ * - `dataFields`: shallow merge under `data` (used by `updateNode`)
86
+ * - `replaceData`: full data replacement (used by migration write-back)
87
+ * - `v`: optional schema-version stamp
88
+ *
89
+ * `updatedAt` is always set by the backend.
90
+ */
91
+ interface UpdatePayload {
92
+ dataFields?: Record<string, unknown>;
93
+ replaceData?: Record<string, unknown>;
94
+ v?: number;
95
+ }
96
+ /**
97
+ * Read/write transaction adapter. Mirrors Firestore's transaction semantics:
98
+ * reads are snapshot-consistent; writes are issued inside the transaction
99
+ * and a rejection from any write aborts the surrounding `runTransaction`.
100
+ *
101
+ * Writes return `Promise<void>` so SQL drivers can surface row-level errors
102
+ * (constraint violations, malformed JSON paths) rather than swallowing them.
103
+ * Firestore implementations can resolve synchronously since the underlying
104
+ * `Transaction.set/update/delete` calls are themselves synchronous buffers.
105
+ */
106
+ interface TransactionBackend {
107
+ getDoc(docId: string): Promise<StoredGraphRecord | null>;
108
+ query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
109
+ setDoc(docId: string, record: WritableRecord): Promise<void>;
110
+ updateDoc(docId: string, update: UpdatePayload): Promise<void>;
111
+ deleteDoc(docId: string): Promise<void>;
112
+ }
113
+ /**
114
+ * Atomic multi-write batch.
115
+ */
116
+ interface BatchBackend {
117
+ setDoc(docId: string, record: WritableRecord): void;
118
+ updateDoc(docId: string, update: UpdatePayload): void;
119
+ deleteDoc(docId: string): void;
120
+ commit(): Promise<void>;
121
+ }
122
+ /**
123
+ * The single storage abstraction.
124
+ *
125
+ * Each backend instance is scoped to a "graph location" — for Firestore
126
+ * that's a collection path; for SQLite it's a (table, scopePath) pair.
127
+ * `subgraph()` returns a child backend bound to a nested location.
128
+ */
129
+ interface StorageBackend {
130
+ /** Backend-internal location identifier (collection path or table name). */
131
+ readonly collectionPath: string;
132
+ /** Subgraph scope (empty string for root). */
133
+ readonly scopePath: string;
134
+ getDoc(docId: string): Promise<StoredGraphRecord | null>;
135
+ query(filters: QueryFilter[], options?: QueryOptions): Promise<StoredGraphRecord[]>;
136
+ setDoc(docId: string, record: WritableRecord): Promise<void>;
137
+ updateDoc(docId: string, update: UpdatePayload): Promise<void>;
138
+ deleteDoc(docId: string): Promise<void>;
139
+ runTransaction<T>(fn: (tx: TransactionBackend) => Promise<T>): Promise<T>;
140
+ createBatch(): BatchBackend;
141
+ subgraph(parentNodeUid: string, name: string): StorageBackend;
142
+ removeNodeCascade(uid: string, reader: GraphReader, options?: BulkOptions): Promise<CascadeResult>;
143
+ bulkRemoveEdges(params: FindEdgesParams, reader: GraphReader, options?: BulkOptions): Promise<BulkResult>;
144
+ /**
145
+ * Find edges across all subgraphs sharing a given collection name.
146
+ * Optional — backends that can't support this should throw a clear error.
147
+ */
148
+ findEdgesGlobal?(params: FindEdgesParams, collectionName?: string): Promise<StoredGraphRecord[]>;
149
+ }
150
+
151
+ /**
152
+ * Storage-scope path utilities — materialized-path parsing helpers for the
153
+ * SQLite backend's `storageScope` string and for any custom backend that
154
+ * adopts the same encoding (e.g. a cross-DO routing layer that uses
155
+ * `storageScope` as a Durable Object name).
156
+ *
157
+ * **Storage-scope** (as produced by `SqliteBackendImpl`) interleaves parent
158
+ * UIDs with subgraph names:
159
+ *
160
+ * ```
161
+ * '' // root
162
+ * 'A/memories' // g.subgraph(A, 'memories')
163
+ * 'A/memories/B/context' // .subgraph(B, 'context') on the above
164
+ * ```
165
+ *
166
+ * The structure is the same as a Firestore collection path with the
167
+ * collection/doc segments reordered: each pair is `<uid>/<name>`, where
168
+ * `<uid>` is a node UID in the parent scope and `<name>` is the subgraph
169
+ * name. Use these helpers to decode that structure when building cross-
170
+ * backend routers (see `createRoutingBackend`).
171
+ *
172
+ * For Firestore paths (which begin with a collection segment), use
173
+ * `resolveAncestorCollection` / `isAncestorUid` from `./cross-graph.js`.
174
+ */
175
+ /**
176
+ * One segment of a materialized-path storage-scope — a `(uid, name)` pair
177
+ * produced by one `subgraph(uid, name)` call.
178
+ */
179
+ interface StorageScopeSegment {
180
+ /** Parent node UID at the enclosing scope. */
181
+ uid: string;
182
+ /** Subgraph name chosen by the caller (e.g. `'memories'`). */
183
+ name: string;
184
+ }
185
+ /**
186
+ * Parse a materialized-path storage-scope into its `(uid, name)` pairs.
187
+ *
188
+ * Returns `[]` for the root (`''`). Throws `Error('INVALID_SCOPE_PATH')`
189
+ * when the string has an odd number of segments (a corrupt path — every
190
+ * level contributes exactly two segments) or when any segment is empty.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * parseStorageScope(''); // []
195
+ * parseStorageScope('A/memories'); // [{ uid: 'A', name: 'memories' }]
196
+ * parseStorageScope('A/memories/B/context'); // [{ uid: 'A', name: 'memories' }, { uid: 'B', name: 'context' }]
197
+ * ```
198
+ */
199
+ declare function parseStorageScope(scope: string): StorageScopeSegment[];
200
+ /**
201
+ * Resolve the ancestor **storage-scope** at which a given UID's node lives,
202
+ * by scanning a materialized-path storage-scope for that UID.
203
+ *
204
+ * Mirrors `resolveAncestorCollection()` from `./cross-graph.js` for
205
+ * Firestore paths, but operates on `storageScope` (no leading collection
206
+ * segment — segments are `<uid>/<name>` pairs).
207
+ *
208
+ * @returns The storage-scope at which the UID's node was added via
209
+ * `subgraph(uid, _)`, or `null` if the UID does not appear at a UID
210
+ * position in the path.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * // Scope: 'A/memories/B/context'
215
+ * resolveAncestorScope('A/memories/B/context', 'A'); // '' (A was added at root)
216
+ * resolveAncestorScope('A/memories/B/context', 'B'); // 'A/memories'
217
+ * resolveAncestorScope('A/memories/B/context', 'X'); // null
218
+ * ```
219
+ */
220
+ declare function resolveAncestorScope(storageScope: string, uid: string): string | null;
221
+ /**
222
+ * Boolean shorthand for `resolveAncestorScope(scope, uid) !== null`.
223
+ */
224
+ declare function isAncestorScopeUid(storageScope: string, uid: string): boolean;
225
+ /**
226
+ * Join a parent storage-scope with a new `(uid, name)` pair, producing the
227
+ * storage-scope that `backend.subgraph(uid, name)` would use internally.
228
+ *
229
+ * This is the inverse of `parseStorageScope`'s per-segment semantics and is
230
+ * useful when computing DO names / shard keys from the router callback.
231
+ */
232
+ declare function appendStorageScope(parentScope: string, uid: string, name: string): string;
233
+
234
+ export { type BatchBackend as B, CrossBackendTransactionError as C, DynamicRegistryError as D, EdgeNotFoundError as E, FiregraphError as F, InvalidQueryError as I, MigrationError as M, NodeNotFoundError as N, QuerySafetyError as Q, RegistryScopeError as R, type StorageBackend as S, type TransactionBackend as T, type UpdatePayload as U, ValidationError as V, type WritableRecord as W, type StorageScopeSegment as a, appendStorageScope as b, RegistryViolationError as c, TraversalError as d, isAncestorScopeUid as i, parseStorageScope as p, resolveAncestorScope as r };
@@ -3,11 +3,11 @@ import {
3
3
  deserializeFirestoreTypes,
4
4
  isTaggedValue,
5
5
  serializeFirestoreTypes
6
- } from "./chunk-6OQW5OKO.js";
6
+ } from "./chunk-5753Y42M.js";
7
7
  export {
8
8
  SERIALIZATION_TAG,
9
9
  deserializeFirestoreTypes,
10
10
  isTaggedValue,
11
11
  serializeFirestoreTypes
12
12
  };
13
- //# sourceMappingURL=serialization-C6JNNOCS.js.map
13
+ //# sourceMappingURL=serialization-ZZ7RSDRX.js.map
package/dist/svelte.cjs CHANGED
@@ -34,9 +34,7 @@ function wrapSvelte(Component, meta) {
34
34
  static viewName = meta.viewName;
35
35
  static description = meta.description;
36
36
  _data = {};
37
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
37
  _instance = null;
39
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
38
  _props = null;
41
39
  _mounted = false;
42
40
  set data(v) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte 5 adapter for firegraph views.\n *\n * Wraps a Svelte component into a Web Component (HTMLElement) that satisfies\n * the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:\n *\n * @example\n * ```ts\n * import { wrapSvelte } from 'firegraph/svelte';\n * import TaskCard from './TaskCard.svelte';\n *\n * export default [\n * wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),\n * ];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `svelte` at\n * mount time. Svelte is resolved from the project's own `node_modules` —\n * firegraph does not bundle or depend on Svelte itself.\n *\n * The Svelte component should accept a `data` prop:\n * ```svelte\n * <script>\n * let { data } = $props();\n * </script>\n * ```\n *\n * Props are updated by mutating the props object — Svelte 5's reactivity\n * system picks up the changes automatically.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass {\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _instance: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _props: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n if (this._props) {\n // Svelte 5: mutating the props object triggers reactivity\n this._props.data = v;\n } else if (this._mounted) {\n this._mount();\n }\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._mount();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n if (this._instance) {\n // Dynamic import — resolved from project's node_modules at runtime\n (Function('return import(\"svelte\")')() as Promise<{ unmount: Function }>).then(\n ({ unmount }) => {\n if (this._instance) {\n unmount(this._instance);\n this._instance = null;\n this._props = null;\n }\n },\n );\n }\n }\n\n async _mount() {\n // Dynamic import — resolved from project's node_modules at runtime\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const svelte: any = await (Function('return import(\"svelte\")')() as Promise<unknown>);\n if (!this._mounted) return; // disconnected while awaiting\n\n // Clean up previous instance\n if (this._instance) {\n svelte.unmount(this._instance);\n }\n\n // Svelte 5: pass a props object — mutating it later triggers re-renders\n this._props = { data: this._data };\n this._instance = svelte.mount(Component, {\n target: this,\n props: this._props,\n });\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmCA,SAAS,eAAyB;AAEhC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AAoBO,SAAS,WAAW,WAAgB,MAAoC;AAC7E,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA;AAAA,IAElC,YAAiB;AAAA;AAAA,IAEjB,SAAc;AAAA,IACd,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AAEf,aAAK,OAAO,OAAO;AAAA,MACrB,WAAW,KAAK,UAAU;AACxB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,OAAO;AAAA,IACd;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,UAAI,KAAK,WAAW;AAElB,QAAC,SAAS,yBAAyB,EAAE,EAAqC;AAAA,UACxE,CAAC,EAAE,QAAQ,MAAM;AACf,gBAAI,KAAK,WAAW;AAClB,sBAAQ,KAAK,SAAS;AACtB,mBAAK,YAAY;AACjB,mBAAK,SAAS;AAAA,YAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,SAAS;AAGb,YAAM,SAAc,MAAO,SAAS,yBAAyB,EAAE;AAC/D,UAAI,CAAC,KAAK,SAAU;AAGpB,UAAI,KAAK,WAAW;AAClB,eAAO,QAAQ,KAAK,SAAS;AAAA,MAC/B;AAGA,WAAK,SAAS,EAAE,MAAM,KAAK,MAAM;AACjC,WAAK,YAAY,OAAO,MAAM,WAAW;AAAA,QACvC,QAAQ;AAAA,QACR,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte 5 adapter for firegraph views.\n *\n * Wraps a Svelte component into a Web Component (HTMLElement) that satisfies\n * the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:\n *\n * @example\n * ```ts\n * import { wrapSvelte } from 'firegraph/svelte';\n * import TaskCard from './TaskCard.svelte';\n *\n * export default [\n * wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),\n * ];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `svelte` at\n * mount time. Svelte is resolved from the project's own `node_modules` —\n * firegraph does not bundle or depend on Svelte itself.\n *\n * The Svelte component should accept a `data` prop:\n * ```svelte\n * <script>\n * let { data } = $props();\n * </script>\n * ```\n *\n * Props are updated by mutating the props object — Svelte 5's reactivity\n * system picks up the changes automatically.\n */\n\nexport function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass {\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n\n _instance: any = null;\n\n _props: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n if (this._props) {\n // Svelte 5: mutating the props object triggers reactivity\n this._props.data = v;\n } else if (this._mounted) {\n this._mount();\n }\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._mount();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n if (this._instance) {\n // Dynamic import — resolved from project's node_modules at runtime\n (Function('return import(\"svelte\")')() as Promise<{ unmount: Function }>).then(\n ({ unmount }) => {\n if (this._instance) {\n unmount(this._instance);\n this._instance = null;\n this._props = null;\n }\n },\n );\n }\n }\n\n async _mount() {\n // Dynamic import — resolved from project's node_modules at runtime\n\n const svelte: any = await (Function('return import(\"svelte\")')() as Promise<unknown>);\n if (!this._mounted) return; // disconnected while awaiting\n\n // Clean up previous instance\n if (this._instance) {\n svelte.unmount(this._instance);\n }\n\n // Svelte 5: pass a props object — mutating it later triggers re-renders\n this._props = { data: this._data };\n this._instance = svelte.mount(Component, {\n target: this,\n props: this._props,\n });\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCA,SAAS,eAAyB;AAChC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AAoBO,SAAS,WAAW,WAAgB,MAAoC;AAC7E,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA,IAElC,YAAiB;AAAA,IAEjB,SAAc;AAAA,IACd,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AAEf,aAAK,OAAO,OAAO;AAAA,MACrB,WAAW,KAAK,UAAU;AACxB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,OAAO;AAAA,IACd;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,UAAI,KAAK,WAAW;AAElB,QAAC,SAAS,yBAAyB,EAAE,EAAqC;AAAA,UACxE,CAAC,EAAE,QAAQ,MAAM;AACf,gBAAI,KAAK,WAAW;AAClB,sBAAQ,KAAK,SAAS;AACtB,mBAAK,YAAY;AACjB,mBAAK,SAAS;AAAA,YAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,SAAS;AAGb,YAAM,SAAc,MAAO,SAAS,yBAAyB,EAAE;AAC/D,UAAI,CAAC,KAAK,SAAU;AAGpB,UAAI,KAAK,WAAW;AAClB,eAAO,QAAQ,KAAK,SAAS;AAAA,MAC/B;AAGA,WAAK,SAAS,EAAE,MAAM,KAAK,MAAM;AACjC,WAAK,YAAY,OAAO,MAAM,WAAW;AAAA,QACvC,QAAQ;AAAA,QACR,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
package/dist/svelte.js CHANGED
@@ -10,9 +10,7 @@ function wrapSvelte(Component, meta) {
10
10
  static viewName = meta.viewName;
11
11
  static description = meta.description;
12
12
  _data = {};
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
13
  _instance = null;
15
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
14
  _props = null;
17
15
  _mounted = false;
18
16
  set data(v) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte 5 adapter for firegraph views.\n *\n * Wraps a Svelte component into a Web Component (HTMLElement) that satisfies\n * the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:\n *\n * @example\n * ```ts\n * import { wrapSvelte } from 'firegraph/svelte';\n * import TaskCard from './TaskCard.svelte';\n *\n * export default [\n * wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),\n * ];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `svelte` at\n * mount time. Svelte is resolved from the project's own `node_modules` —\n * firegraph does not bundle or depend on Svelte itself.\n *\n * The Svelte component should accept a `data` prop:\n * ```svelte\n * <script>\n * let { data } = $props();\n * </script>\n * ```\n *\n * Props are updated by mutating the props object — Svelte 5's reactivity\n * system picks up the changes automatically.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass {\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _instance: any = null;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _props: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n if (this._props) {\n // Svelte 5: mutating the props object triggers reactivity\n this._props.data = v;\n } else if (this._mounted) {\n this._mount();\n }\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._mount();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n if (this._instance) {\n // Dynamic import — resolved from project's node_modules at runtime\n (Function('return import(\"svelte\")')() as Promise<{ unmount: Function }>).then(\n ({ unmount }) => {\n if (this._instance) {\n unmount(this._instance);\n this._instance = null;\n this._props = null;\n }\n },\n );\n }\n }\n\n async _mount() {\n // Dynamic import — resolved from project's node_modules at runtime\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const svelte: any = await (Function('return import(\"svelte\")')() as Promise<unknown>);\n if (!this._mounted) return; // disconnected while awaiting\n\n // Clean up previous instance\n if (this._instance) {\n svelte.unmount(this._instance);\n }\n\n // Svelte 5: pass a props object — mutating it later triggers re-renders\n this._props = { data: this._data };\n this._instance = svelte.mount(Component, {\n target: this,\n props: this._props,\n });\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";AAmCA,SAAS,eAAyB;AAEhC,QAAM,IAAI;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ources":["../src/svelte.ts"],"sourcesContent":["/**\n * Svelte 5 adapter for firegraph views.\n *\n * Wraps a Svelte component into a Web Component (HTMLElement) that satisfies\n * the firegraph `ViewComponentClass` contract. Import from `firegraph/svelte`:\n *\n * @example\n * ```ts\n * import { wrapSvelte } from 'firegraph/svelte';\n * import TaskCard from './TaskCard.svelte';\n *\n * export default [\n * wrapSvelte(TaskCard, { viewName: 'card', description: 'Compact task card' }),\n * ];\n * ```\n */\n\nimport type { ViewComponentClass } from './views.js';\n\n/** Metadata required for every firegraph view. */\nexport interface ViewMeta {\n /** Short identifier (e.g. 'card', 'detail'). */\n viewName: string;\n /** Optional human-readable description. */\n description?: string;\n}\n\ntype AnyClass = { new (...args: any[]): any };\n\n/**\n * Get HTMLElement from the runtime environment.\n * Returns a base class for view elements — works in both browser and Node.js\n * (where HTMLElement may be shimmed by the editor server).\n */\nfunction getBaseClass(): AnyClass {\n const g = globalThis as any;\n return g.HTMLElement ?? class {};\n}\n\n/**\n * Wrap a Svelte 5 component into a firegraph `ViewComponentClass`.\n *\n * The returned class extends `HTMLElement` and lazily imports `svelte` at\n * mount time. Svelte is resolved from the project's own `node_modules` —\n * firegraph does not bundle or depend on Svelte itself.\n *\n * The Svelte component should accept a `data` prop:\n * ```svelte\n * <script>\n * let { data } = $props();\n * </script>\n * ```\n *\n * Props are updated by mutating the props object — Svelte 5's reactivity\n * system picks up the changes automatically.\n */\n\nexport function wrapSvelte(Component: any, meta: ViewMeta): ViewComponentClass {\n const Base = getBaseClass();\n\n const Cls = class extends Base {\n static viewName = meta.viewName;\n static description = meta.description;\n\n _data: Record<string, unknown> = {};\n\n _instance: any = null;\n\n _props: any = null;\n _mounted = false;\n\n set data(v: Record<string, unknown>) {\n this._data = v;\n if (this._props) {\n // Svelte 5: mutating the props object triggers reactivity\n this._props.data = v;\n } else if (this._mounted) {\n this._mount();\n }\n }\n\n get data() {\n return this._data;\n }\n\n connectedCallback() {\n this._mounted = true;\n this._mount();\n }\n\n disconnectedCallback() {\n this._mounted = false;\n if (this._instance) {\n // Dynamic import — resolved from project's node_modules at runtime\n (Function('return import(\"svelte\")')() as Promise<{ unmount: Function }>).then(\n ({ unmount }) => {\n if (this._instance) {\n unmount(this._instance);\n this._instance = null;\n this._props = null;\n }\n },\n );\n }\n }\n\n async _mount() {\n // Dynamic import — resolved from project's node_modules at runtime\n\n const svelte: any = await (Function('return import(\"svelte\")')() as Promise<unknown>);\n if (!this._mounted) return; // disconnected while awaiting\n\n // Clean up previous instance\n if (this._instance) {\n svelte.unmount(this._instance);\n }\n\n // Svelte 5: pass a props object — mutating it later triggers re-renders\n this._props = { data: this._data };\n this._instance = svelte.mount(Component, {\n target: this,\n props: this._props,\n });\n }\n };\n\n return Cls as unknown as ViewComponentClass;\n}\n"],"mappings":";AAkCA,SAAS,eAAyB;AAChC,QAAM,IAAI;AACV,SAAO,EAAE,eAAe,MAAM;AAAA,EAAC;AACjC;AAoBO,SAAS,WAAW,WAAgB,MAAoC;AAC7E,QAAM,OAAO,aAAa;AAE1B,QAAM,MAAM,cAAc,KAAK;AAAA,IAC7B,OAAO,WAAW,KAAK;AAAA,IACvB,OAAO,cAAc,KAAK;AAAA,IAE1B,QAAiC,CAAC;AAAA,IAElC,YAAiB;AAAA,IAEjB,SAAc;AAAA,IACd,WAAW;AAAA,IAEX,IAAI,KAAK,GAA4B;AACnC,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AAEf,aAAK,OAAO,OAAO;AAAA,MACrB,WAAW,KAAK,UAAU;AACxB,aAAK,OAAO;AAAA,MACd;AAAA,IACF;AAAA,IAEA,IAAI,OAAO;AACT,aAAO,KAAK;AAAA,IACd;AAAA,IAEA,oBAAoB;AAClB,WAAK,WAAW;AAChB,WAAK,OAAO;AAAA,IACd;AAAA,IAEA,uBAAuB;AACrB,WAAK,WAAW;AAChB,UAAI,KAAK,WAAW;AAElB,QAAC,SAAS,yBAAyB,EAAE,EAAqC;AAAA,UACxE,CAAC,EAAE,QAAQ,MAAM;AACf,gBAAI,KAAK,WAAW;AAClB,sBAAQ,KAAK,SAAS;AACtB,mBAAK,YAAY;AACjB,mBAAK,SAAS;AAAA,YAChB;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IAEA,MAAM,SAAS;AAGb,YAAM,SAAc,MAAO,SAAS,yBAAyB,EAAE;AAC/D,UAAI,CAAC,KAAK,SAAU;AAGpB,UAAI,KAAK,WAAW;AAClB,eAAO,QAAQ,KAAK,SAAS;AAAA,MAC/B;AAGA,WAAK,SAAS,EAAE,MAAM,KAAK,MAAM;AACjC,WAAK,YAAY,OAAO,MAAM,WAAW;AAAA,QACvC,QAAQ;AAAA,QACR,OAAO,KAAK;AAAA,MACd,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -1,4 +1,4 @@
1
- import { Timestamp, FieldValue, WhereFilterOp } from '@google-cloud/firestore';
1
+ import { WhereFilterOp, Timestamp, FieldValue } from '@google-cloud/firestore';
2
2
 
3
3
  /**
4
4
  * Firegraph Configuration — project-level config file support.
@@ -16,6 +16,7 @@ import { Timestamp, FieldValue, WhereFilterOp } from '@google-cloud/firestore';
16
16
  * });
17
17
  * ```
18
18
  */
19
+
19
20
  /** Display contexts where views can appear. */
20
21
  type ViewContext = 'listing' | 'detail' | 'inline';
21
22
  /** View resolution configuration for a single entity type. */
@@ -641,4 +642,4 @@ interface CascadeResult extends BulkResult {
641
642
  nodeDeleted: boolean;
642
643
  }
643
644
 
644
- export { type TraversalOptions as A, type BulkOptions as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalResult as I, type ViewDefaultsConfig as J, type ViewResolverConfig as K, defineConfig as L, type MigrationExecutor as M, type NodeTypeData as N, resolveView as O, type QueryFilter as Q, type RegistryEntry as R, type StoredGraphRecord as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type QueryOptions as c, type GraphReader as d, type BulkResult as e, type DiscoveryResult as f, type GraphRegistry as g, type MigrationWriteBack as h, type MigrationStep as i, type QueryPlan as j, type FindNodesParams as k, type GraphRecord as l, type MigrationFn as m, type StoredMigrationStep as n, type BulkBatchError as o, type BulkProgress as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type ScanProtection as z };
645
+ export { type TraversalOptions as A, type BulkBatchError as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalResult as I, type ViewDefaultsConfig as J, type ViewResolverConfig as K, defineConfig as L, type MigrationExecutor as M, type NodeTypeData as N, resolveView as O, type QueryPlan as Q, type RegistryEntry as R, type StoredGraphRecord as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type DiscoveryResult as c, type GraphRegistry as d, type GraphReader as e, type MigrationWriteBack as f, type MigrationStep as g, type FindNodesParams as h, type QueryFilter as i, type GraphRecord as j, type MigrationFn as k, type StoredMigrationStep as l, type BulkOptions as m, type BulkProgress as n, type BulkResult as o, type DefineTypeOptions as p, type DiscoveredEntity as q, type EdgeTypeData as r, type FiregraphConfig as s, type GraphBatch as t, type GraphTransaction as u, type GraphWriter as v, type HopResult as w, type QueryMode as x, type QueryOptions as y, type ScanProtection as z };
@@ -1,4 +1,4 @@
1
- import { Timestamp, FieldValue, WhereFilterOp } from '@google-cloud/firestore';
1
+ import { WhereFilterOp, Timestamp, FieldValue } from '@google-cloud/firestore';
2
2
 
3
3
  /**
4
4
  * Firegraph Configuration — project-level config file support.
@@ -16,6 +16,7 @@ import { Timestamp, FieldValue, WhereFilterOp } from '@google-cloud/firestore';
16
16
  * });
17
17
  * ```
18
18
  */
19
+
19
20
  /** Display contexts where views can appear. */
20
21
  type ViewContext = 'listing' | 'detail' | 'inline';
21
22
  /** View resolution configuration for a single entity type. */
@@ -641,4 +642,4 @@ interface CascadeResult extends BulkResult {
641
642
  nodeDeleted: boolean;
642
643
  }
643
644
 
644
- export { type TraversalOptions as A, type BulkOptions as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalResult as I, type ViewDefaultsConfig as J, type ViewResolverConfig as K, defineConfig as L, type MigrationExecutor as M, type NodeTypeData as N, resolveView as O, type QueryFilter as Q, type RegistryEntry as R, type StoredGraphRecord as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type QueryOptions as c, type GraphReader as d, type BulkResult as e, type DiscoveryResult as f, type GraphRegistry as g, type MigrationWriteBack as h, type MigrationStep as i, type QueryPlan as j, type FindNodesParams as k, type GraphRecord as l, type MigrationFn as m, type StoredMigrationStep as n, type BulkBatchError as o, type BulkProgress as p, type DefineTypeOptions as q, type DiscoveredEntity as r, type EdgeTypeData as s, type FiregraphConfig as t, type GraphBatch as u, type GraphTransaction as v, type GraphWriter as w, type HopResult as x, type QueryMode as y, type ScanProtection as z };
645
+ export { type TraversalOptions as A, type BulkBatchError as B, type CascadeResult as C, type DynamicRegistryConfig as D, type EdgeTopology as E, type FindEdgesParams as F, type GraphClientOptions as G, type HopDefinition as H, type TraversalResult as I, type ViewDefaultsConfig as J, type ViewResolverConfig as K, defineConfig as L, type MigrationExecutor as M, type NodeTypeData as N, resolveView as O, type QueryPlan as Q, type RegistryEntry as R, type StoredGraphRecord as S, type TraversalBuilder as T, type ViewContext as V, type WhereClause as W, type DynamicGraphClient as a, type GraphClient as b, type DiscoveryResult as c, type GraphRegistry as d, type GraphReader as e, type MigrationWriteBack as f, type MigrationStep as g, type FindNodesParams as h, type QueryFilter as i, type GraphRecord as j, type MigrationFn as k, type StoredMigrationStep as l, type BulkOptions as m, type BulkProgress as n, type BulkResult as o, type DefineTypeOptions as p, type DiscoveredEntity as q, type EdgeTypeData as r, type FiregraphConfig as s, type GraphBatch as t, type GraphTransaction as u, type GraphWriter as v, type HopResult as w, type QueryMode as x, type QueryOptions as y, type ScanProtection as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typicalday/firegraph",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Generic Firestore adjacency graph client with smart query planning",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -66,6 +66,16 @@
66
66
  "types": "./dist/do-sqlite.d.cts",
67
67
  "default": "./dist/do-sqlite.cjs"
68
68
  }
69
+ },
70
+ "./backend": {
71
+ "import": {
72
+ "types": "./dist/backend.d.ts",
73
+ "default": "./dist/backend.js"
74
+ },
75
+ "require": {
76
+ "types": "./dist/backend.d.cts",
77
+ "default": "./dist/backend.cjs"
78
+ }
69
79
  }
70
80
  },
71
81
  "bin": {
@@ -139,6 +149,7 @@
139
149
  "better-sqlite3": "^12.9.0",
140
150
  "eslint": "^10.1.0",
141
151
  "eslint-config-prettier": "^10.1.8",
152
+ "eslint-plugin-react-hooks": "^7.1.0",
142
153
  "eslint-plugin-simple-import-sort": "^12.1.1",
143
154
  "husky": "^9.1.7",
144
155
  "json-schema-to-typescript": "^15.0.4",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/serialization.ts"],"sourcesContent":["/**\n * Firestore-aware serialization for the sandbox migration pipeline.\n *\n * Firestore documents can contain special types (Timestamp, GeoPoint,\n * VectorValue, DocumentReference) that don't survive plain JSON\n * round-tripping. This module provides tagged serialization: Firestore\n * types are wrapped in tagged plain objects before JSON marshaling and\n * reconstructed after.\n *\n * Only used by the `defaultExecutor` sandbox path. Static migrations\n * (in-memory functions) receive raw Firestore objects directly.\n */\n\nimport { Timestamp, GeoPoint, FieldValue } from '@google-cloud/firestore';\nimport type { Firestore, DocumentReference } from '@google-cloud/firestore';\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\n/** Sentinel key used to tag serialized Firestore types. */\nexport const SERIALIZATION_TAG = '__firegraph_ser__' as const;\n\n/** Known discriminator values for tagged types. */\nconst KNOWN_TYPES = new Set(['Timestamp', 'GeoPoint', 'VectorValue', 'DocumentReference']);\n\n// One-time warning for DocumentReference deserialization without db\nlet _docRefWarned = false;\n\n// ---------------------------------------------------------------------------\n// Type guard\n// ---------------------------------------------------------------------------\n\n/** Check if a value is a tagged serialized Firestore type. */\nexport function isTaggedValue(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const tag = (value as Record<string, unknown>)[SERIALIZATION_TAG];\n return typeof tag === 'string' && KNOWN_TYPES.has(tag);\n}\n\n// ---------------------------------------------------------------------------\n// Detection helpers\n// ---------------------------------------------------------------------------\n\nfunction isTimestamp(value: unknown): value is Timestamp {\n return value instanceof Timestamp;\n}\n\nfunction isGeoPoint(value: unknown): value is GeoPoint {\n return value instanceof GeoPoint;\n}\n\nfunction isDocumentReference(value: unknown): value is DocumentReference {\n // Duck-type check: DocumentReference has path (string) and firestore properties\n if (value === null || typeof value !== 'object') return false;\n const v = value as Record<string, unknown>;\n return (\n typeof v.path === 'string' &&\n v.firestore !== undefined &&\n typeof v.id === 'string' &&\n v.constructor?.name === 'DocumentReference'\n );\n}\n\nfunction isVectorValue(value: unknown): boolean {\n if (value === null || typeof value !== 'object') return false;\n const v = value as Record<string, unknown>;\n return (\n v.constructor?.name === 'VectorValue' &&\n Array.isArray((v as Record<string, unknown>)._values)\n );\n}\n\n// ---------------------------------------------------------------------------\n// Serialize\n// ---------------------------------------------------------------------------\n\n/**\n * Recursively walk a data object and replace Firestore types with tagged\n * plain objects suitable for JSON serialization.\n *\n * Returns a new object tree — the input is never mutated.\n */\nexport function serializeFirestoreTypes(\n data: Record<string, unknown>,\n): Record<string, unknown> {\n return serializeValue(data) as Record<string, unknown>;\n}\n\nfunction serializeValue(value: unknown): unknown {\n // Primitives\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n // Firestore types (check before generic object/array)\n if (isTimestamp(value)) {\n return { [SERIALIZATION_TAG]: 'Timestamp', seconds: value.seconds, nanoseconds: value.nanoseconds };\n }\n if (isGeoPoint(value)) {\n return { [SERIALIZATION_TAG]: 'GeoPoint', latitude: value.latitude, longitude: value.longitude };\n }\n if (isDocumentReference(value)) {\n return { [SERIALIZATION_TAG]: 'DocumentReference', path: (value as DocumentReference).path };\n }\n if (isVectorValue(value)) {\n // Prefer toArray() (public API) over _values (private internal property)\n const v = value as Record<string, unknown>;\n const values = typeof v.toArray === 'function'\n ? (v.toArray as () => number[])()\n : (v._values as number[]);\n return { [SERIALIZATION_TAG]: 'VectorValue', values: [...values] };\n }\n\n // Arrays\n if (Array.isArray(value)) {\n return value.map(serializeValue);\n }\n\n // Plain objects — recurse\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(value as Record<string, unknown>)) {\n result[key] = serializeValue((value as Record<string, unknown>)[key]);\n }\n return result;\n}\n\n// ---------------------------------------------------------------------------\n// Deserialize\n// ---------------------------------------------------------------------------\n\n/**\n * Recursively walk a data object and reconstruct Firestore types from\n * tagged plain objects.\n *\n * @param data - The data to deserialize (typically from JSON.parse)\n * @param db - Optional Firestore instance for DocumentReference reconstruction.\n * If not provided, tagged DocumentReferences are left as-is with a one-time warning.\n *\n * Returns a new object tree — the input is never mutated.\n */\nexport function deserializeFirestoreTypes(\n data: Record<string, unknown>,\n db?: Firestore,\n): Record<string, unknown> {\n return deserializeValue(data, db) as Record<string, unknown>;\n}\n\nfunction deserializeValue(value: unknown, db?: Firestore): unknown {\n if (value === null || value === undefined) return value;\n if (typeof value !== 'object') return value;\n\n // Short-circuit for values that are already real Firestore types.\n // This makes deserializeFirestoreTypes idempotent — safe to call on data\n // that has already been deserialized (e.g., write-back after defaultExecutor\n // already reconstructed types, or static migrations that return raw types).\n if (isTimestamp(value) || isGeoPoint(value) || isDocumentReference(value) || isVectorValue(value)) {\n return value;\n }\n\n // Arrays\n if (Array.isArray(value)) {\n return value.map((v) => deserializeValue(v, db));\n }\n\n const obj = value as Record<string, unknown>;\n\n // Check for tagged Firestore type\n if (isTaggedValue(obj)) {\n const tag = obj[SERIALIZATION_TAG] as string;\n\n switch (tag) {\n case 'Timestamp':\n // Validate expected fields before reconstruction\n if (typeof obj.seconds !== 'number' || typeof obj.nanoseconds !== 'number') return obj;\n return new Timestamp(obj.seconds, obj.nanoseconds);\n\n case 'GeoPoint':\n if (typeof obj.latitude !== 'number' || typeof obj.longitude !== 'number') return obj;\n return new GeoPoint(obj.latitude, obj.longitude);\n\n case 'VectorValue':\n if (!Array.isArray(obj.values)) return obj;\n return FieldValue.vector(obj.values as number[]);\n\n case 'DocumentReference':\n if (typeof obj.path !== 'string') return obj;\n if (db) {\n return db.doc(obj.path);\n }\n // No db available — leave as tagged object with one-time warning\n if (!_docRefWarned) {\n _docRefWarned = true;\n console.warn(\n '[firegraph] DocumentReference encountered during migration deserialization ' +\n 'but no Firestore instance available. The reference will remain as a tagged ' +\n 'object with its path. Enable write-back for full reconstruction.',\n );\n }\n return obj;\n\n default:\n // Unknown tag — leave as-is (forward compatibility)\n return obj;\n }\n }\n\n // Plain object — recurse\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n result[key] = deserializeValue(obj[key], db);\n }\n return result;\n}\n"],"mappings":";AAaA,SAAS,WAAW,UAAU,kBAAkB;AAQzC,IAAM,oBAAoB;AAGjC,IAAM,cAAc,oBAAI,IAAI,CAAC,aAAa,YAAY,eAAe,mBAAmB,CAAC;AAGzF,IAAI,gBAAgB;AAOb,SAAS,cAAc,OAAyB;AACrD,MAAI,UAAU,QAAQ,OAAO,UAAU,SAAU,QAAO;AACxD,QAAM,MAAO,MAAkC,iBAAiB;AAChE,SAAO,OAAO,QAAQ,YAAY,YAAY,IAAI,GAAG;AACvD;AAMA,SAAS,YAAY,OAAoC;AACvD,SAAO,iBAAiB;AAC1B;AAEA,SAAS,WAAW,OAAmC;AACrD,SAAO,iB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A,EACF;AAGA,QAAM,SAAkC,CAAC;AACzC,aAAW,OAAO,OAAO,KAAK,GAAG,GAAG;AAClC,WAAO,GAAG,IAAI,iBAAiB,IAAI,GAAG,GAAG,EAAE;AAAA,EAC7C;AACA,SAAO;AACT;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/query-client/client.ts","../src/query-client/shaping.ts","../src/query-client/config.ts","../src/query-client/cli.ts"],"sourcesContent":["import http from 'node:http';\nimport type {\n QueryClientOptions,\n SchemaResult,\n GetNodeDetailInput,\n NodeDetailResult,\n GetNodesInput,\n GetNodesResult,\n GetEdgesInput,\n GetEdgesResult,\n TraverseInput,\n TraverseResult,\n TraverseHopResult,\n SearchInput,\n SearchResult,\n SummarizedRecord,\n SummarizedEdge,\n} from './types.js';\nimport { summarizeRecord, summarizeEdge } from './shaping.js';\nimport { readEditorPort } from './config.js';\n\n// --- Error ---\n\nexport type QueryClientErrorCode = 'VALIDATION_ERROR' | 'CONNECTION_FAILED' | 'SERVER_ERROR';\n\nexport class QueryClientError extends Error {\n constructor(\n message: string,\n public readonly code: QueryClientErrorCode,\n ) {\n super(message);\n this.name = 'QueryClientError';\n }\n}\n\n// --- Validation helpers ---\n\nfunction requireString(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string' || value.length === 0) {\n throw new QueryClientError(`${name} must be a non-empty string`, 'VALIDATION_ERROR');\n }\n}\n\nfunction clampInt(value: number | undefined, min: number, max: number, fallback: number): number {\n if (value == null) return fallback;\n if (!Number.isInteger(value)) {\n throw new QueryClientError(`limit must be an integer`, 'VALIDATION_ERROR');\n }\n return Math.max(min, Math.min(max, value));\n}\n\nfunction validateSortDir(dir: string | undefined): void {\n if (dir != null && dir !== 'asc' && dir !== 'desc') {\n throw new QueryClientError(`sortDir must be 'asc' or 'desc'`, 'VALIDATION_ERROR');\n }\n}\n\n// --- HTTP helpers ---\n\nfunction httpGet(url: string): Promise<string> {\n return new Promise((resolve, reject) => {\n http\n .get(url, (res) => {\n let body = '';\n res.on('data', (c: string) => (body += c));\n res.on('end', () => resolve(body));\n })\n .on('error', (err) => {\n reject(new QueryClientError(`Connection failed: ${err.message}`, 'CONNECTION_FAILED'));\n });\n });\n}\n\nfunction httpPost(url: string, payload: string): Promise<string> {\n const parsed = new URL(url);\n return new Promise((resolve, reject) => {\n const req = http.request(\n {\n hostname: parsed.hostname,\n port: parsed.port,\n path: parsed.pathname,\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(payload),\n },\n },\n (res) => {\n let body = '';\n res.on('data', (c: string) => (body += c));\n res.on('end', () => resolve(body));\n },\n );\n req.on('error', (err) => {\n reject(new QueryClientError(`Connection failed: ${err.message}`, 'CONNECTION_FAILED'));\n });\n req.write(payload);\n req.end();\n });\n}\n\nfunction parseTrpcResponse(raw: string, procedure: string): unknown {\n let parsed: Record<string, unknown>;\n try {\n parsed = JSON.parse(raw);\n } catch {\n throw new QueryClientError(\n `Invalid JSON from ${procedure}: ${raw.slice(0, 200)}`,\n 'SERVER_ERROR',\n );\n }\n if (parsed.error) {\n const msg =\n typeof parsed.error === 'object' && parsed.error !== null\n ? (parsed.error as Record<string, unknown>).message ?? JSON.stringify(parsed.error)\n : String(parsed.error);\n throw new QueryClientError(`Server error from ${procedure}: ${msg}`, 'SERVER_ERROR');\n }\n return (parsed.result as Record<string, unknown>)?.data ?? parsed;\n}\n\n// --- Client ---\n\nexport class QueryClient {\n private readonly baseUrl: string;\n\n constructor(options?: QueryClientOptions) {\n const host = options?.host ?? 'localhost';\n const port = options?.port ?? readEditorPort();\n this.baseUrl = `http://${host}:${port}/api/trpc`;\n }\n\n private async query(procedure: string, input?: unknown): Promise<unknown> {\n const qs =\n input != null ? `?input=${encodeURIComponent(JSON.stringify(input))}` : '';\n const url = `${this.baseUrl}/${procedure}${qs}`;\n const raw = await httpGet(url);\n return parseTrpcResponse(raw, procedure);\n }\n\n private async mutate(procedure: string, input: unknown): Promise<unknown> {\n const url = `${this.baseUrl}/${procedure}`;\n const raw = await httpPost(url, JSON.stringify(input));\n return parseTrpcResponse(raw, procedure);\n }\n\n // --- Public API ---\n\n async getSchema(): Promise<SchemaResult> {\n const data = (await this.query('getSchema')) as Record<string, unknown>;\n return {\n nodeTypes: ((data.nodeTypes as unknown[]) ?? []).map(\n (t) => (typeof t === 'object' && t !== null ? (t as Record<string, unknown>).type : t) as string,\n ),\n edgeTypes: ((data.edgeTypes as unknown[]) ?? []).map((t) => {\n const e = t as Record<string, unknown>;\n return {\n relation: e.axbType as string,\n from: e.aType as string,\n to: e.bType as string,\n inverseLabel: (e.inverseLabel as string) ?? null,\n };\n }),\n };\n }\n\n async getNodeDetail(input: GetNodeDetailInput): Promise<NodeDetailResult> {\n requireString(input.uid, 'uid');\n const data = (await this.query('getNodeDetail', { uid: input.uid })) as Record<string, unknown>;\n return {\n node: summarizeRecord(data.node as Record<string, unknown> | null),\n outEdges: ((data.outEdges as Record<string, unknown>[]) ?? []).map(summarizeEdge).filter(Boolean) as SummarizedEdge[],\n inEdges: ((data.inEdges as Record<string, unknown>[]) ?? []).map(summarizeEdge).filter(Boolean) as SummarizedEdge[],\n };\n }\n\n async getNodes(input: GetNodesInput): Promise<GetNodesResult> {\n const limit = clampInt(input.limit, 1, 200, 25);\n validateSortDir(input.sortDir);\n const data = (await this.query('getNodes', {\n type: input.type,\n limit,\n startAfter: input.startAfter,\n sortBy: input.sortBy,\n sortDir: input.sortDir,\n where: input.where,\n })) as Record<string, unknown>;\n return {\n nodes: ((data.nodes as Record<string, unknown>[]) ?? []).map(summarizeRecord).filter(Boolean) as SummarizedRecord[],\n hasMore: (data.hasMore as boolean) ?? false,\n nextCursor: data.nextCursor as string | null | undefined,\n };\n }\n\n async getEdges(input: GetEdgesInput): Promise<GetEdgesResult> {\n const hasFilter = input.aType || input.aUid || input.axbType || input.bType || input.bUid || (input.where && input.where.length > 0);\n if (!hasFilter) {\n throw new QueryClientError(\n 'getEdges requires at least one filter field (aType, aUid, axbType, bType, bUid, or where)',\n 'VALIDATION_ERROR',\n );\n }\n const limit = clampInt(input.limit, 1, 200, 25);\n validateSortDir(input.sortDir);\n const data = (await this.query('getEdges', {\n aType: input.aType,\n aUid: input.aUid,\n axbType: input.axbType,\n bType: input.bType,\n bUid: input.bUid,\n limit,\n startAfter: input.startAfter,\n sortBy: input.sortBy,\n sortDir: input.sortDir,\n where: input.where,\n })) as Record<string, unknown>;\n return {\n edges: ((data.edges as Record<string, unknown>[]) ?? []).map(summarizeEdge).filter(Boolean) as SummarizedEdge[],\n hasMore: (data.hasMore as boolean) ?? false,\n nextCursor: data.nextCursor as string | null | undefined,\n };\n }\n\n async traverse(input: TraverseInput): Promise<TraverseResult> {\n requireString(input.startUid, 'startUid');\n if (!input.hops || input.hops.length === 0) {\n throw new QueryClientError('traverse requires at least one hop', 'VALIDATION_ERROR');\n }\n for (let i = 0; i < input.hops.length; i++) {\n const hop = input.hops[i];\n requireString(hop.axbType, `hops[${i}].axbType`);\n if (hop.direction != null && hop.direction !== 'forward' && hop.direction !== 'reverse') {\n throw new QueryClientError(\n `hops[${i}].direction must be 'forward' or 'reverse'`,\n 'VALIDATION_ERROR',\n );\n }\n if (hop.limit != null && (!Number.isInteger(hop.limit) || hop.limit < 1)) {\n throw new QueryClientError(\n `hops[${i}].limit must be a positive integer`,\n 'VALIDATION_ERROR',\n );\n }\n }\n if (input.maxReads != null && (!Number.isInteger(input.maxReads) || input.maxReads < 1)) {\n throw new QueryClientError('maxReads must be a positive integer', 'VALIDATION_ERROR');\n }\n if (input.concurrency != null && (!Number.isInteger(input.concurrency) || input.concurrency < 1)) {\n throw new QueryClientError('concurrency must be a positive integer', 'VALIDATION_ERROR');\n }\n\n const data = (await this.mutate('traverse', input)) as Record<string, unknown>;\n return {\n hops: ((data.hops as Record<string, unknown>[]) ?? []).map((h): TraverseHopResult => ({\n relation: h.axbType as string,\n direction: h.direction as string,\n depth: h.depth as number,\n edgeCount: ((h.edges as unknown[]) ?? []).length,\n edges: ((h.edges as Record<string, unknown>[]) ?? []).map(summarizeEdge).filter(Boolean) as SummarizedEdge[],\n truncated: (h.truncated as boolean) ?? false,\n })),\n totalReads: (data.totalReads as number) ?? 0,\n truncated: (data.truncated as boolean) ?? false,\n };\n }\n\n async search(input: SearchInput): Promise<SearchResult> {\n requireString(input.q, 'q');\n const limit = clampInt(input.limit, 1, 50, 20);\n const data = (await this.query('search', { q: input.q, limit })) as Record<string, unknown>;\n return {\n results: ((data.results as Record<string, unknown>[]) ?? []).map((r) => {\n const base = summarizeRecord(r);\n if (!base) return null;\n return {\n ...base,\n matchType: (r._matchType as string) ?? null,\n };\n }).filter(Boolean) as (SummarizedRecord & { matchType: string | null })[],\n };\n }\n}\n","import type { SummarizedRecord, SummarizedEdge } from './types.js';\n\nexport function summarizeRecord(r: Record<string, unknown> | null): SummarizedRecord | null {\n if (!r) return null;\n const out: SummarizedRecord = { type: r.aType as string, uid: r.aUid as string };\n const data = r.data as Record<string, unknown> | undefined;\n if (data && typeof data === 'object' && Object.keys(data).length > 0) {\n out.data = data;\n }\n return out;\n}\n\nexport function summarizeEdge(r: Record<string, unknown> | null): SummarizedEdge | null {\n if (!r) return null;\n const out: SummarizedEdge = {\n fromType: r.aType as string,\n fromUid: r.aUid as string,\n relation: r.axbType as string,\n toType: r.bType as string,\n toUid: r.bUid as string,\n };\n const data = r.data as Record<string, unknown> | undefined;\n if (data && typeof data === 'object' && Object.keys(data).length > 0) {\n out.data = data;\n }\n return out;\n}\n","import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nconst CONFIG_FILES = ['firegraph.config.ts', 'firegraph.config.js', 'firegraph.config.mjs'];\nconst DEFAULT_PORT = 3884;\n\n/**\n * Read the editor port from firegraph config files using regex.\n * Zero-dependency — no jiti needed.\n */\nexport function readEditorPort(cwd?: string): number {\n const dir = cwd ?? process.cwd();\n for (const name of CONFIG_FILES) {\n try {\n const content = readFileSync(join(dir, name), 'utf8');\n const editorBlock = content.match(/editor\\s*:\\s*\\{[^}]*\\}/s)?.[0] ?? '';\n const portMatch = editorBlock.match(/port\\s*:\\s*(\\d+)/);\n if (portMatch) return parseInt(portMatch[1], 10);\n } catch {\n continue;\n }\n }\n return DEFAULT_PORT;\n}\n","import { QueryClient, QueryClientError } from './client.js';\nimport type { TraverseInput } from './types.js';\n\n// --- Argument parsing ---\n\ninterface ParsedArgs {\n flags: Record<string, string>;\n positional: string[];\n}\n\nfunction parseFlags(args: string[]): ParsedArgs {\n const flags: Record<string, string> = {};\n const positional: string[] = [];\n for (let i = 0; i < args.length; i++) {\n if (args[i].startsWith('--')) {\n const key = args[i].slice(2);\n const next = args[i + 1];\n if (next && !next.startsWith('--')) {\n flags[key] = next;\n i++;\n } else {\n flags[key] = 'true';\n }\n } else {\n positional.push(args[i]);\n }\n }\n return { flags, positional };\n}\n\n// --- CLI runner ---\n\nexport async function runQueryCli(argv: string[]): Promise<void> {\n const command = argv[0];\n const rest = argv.slice(1);\n const { flags, positional } = parseFlags(rest);\n\n const port = flags.port ? parseInt(flags.port, 10) : undefined;\n const host = flags.host ?? undefined;\n const client = new QueryClient({ port, host });\n\n try {\n let result: unknown;\n\n switch (command) {\n case 'schema':\n result = await client.getSchema();\n break;\n\n case 'get':\n if (!positional[0]) {\n die('Usage: firegraph query get <uid>');\n }\n result = await client.getNodeDetail({ uid: positional[0] });\n break;\n\n case 'find-nodes': {\n if (!positional[0]) {\n die('Usage: firegraph query find-nodes <type> [--limit N]');\n }\n result = await client.getNodes({\n type: positional[0],\n limit: flags.limit ? parseInt(flags.limit, 10) : undefined,\n });\n break;\n }\n\n case 'find-edges': {\n result = await client.getEdges({\n aType: flags.aType,\n aUid: flags.aUid,\n axbType: flags.axbType,\n bType: flags.bType,\n bUid: flags.bUid,\n limit: flags.limit ? parseInt(flags.limit, 10) : undefined,\n });\n break;\n }\n\n case 'traverse': {\n const jsonStr = positional.join(' ');\n if (!jsonStr) {\n die(\n 'Usage: firegraph query traverse \\'<JSON>\\'\\n\\n' +\n 'JSON shape:\\n' +\n '{\\n' +\n ' \"startUid\": \"nodeUid\",\\n' +\n ' \"hops\": [\\n' +\n ' {\\n' +\n ' \"axbType\": \"relationName\",\\n' +\n ' \"direction\": \"forward\" | \"reverse\",\\n' +\n ' \"limit\": 10,\\n' +\n ' \"aType\": \"filterSourceType\",\\n' +\n ' \"bType\": \"filterTargetType\",\\n' +\n ' \"orderBy\": { \"field\": \"data.name\", \"direction\": \"asc\" },\\n' +\n ' \"where\": [{ \"field\": \"data.status\", \"op\": \"==\", \"value\": \"active\" }]\\n' +\n ' }\\n' +\n ' ],\\n' +\n ' \"maxReads\": 100,\\n' +\n ' \"concurrency\": 5\\n' +\n '}',\n );\n }\n let input: TraverseInput;\n try {\n input = JSON.parse(jsonStr) as TraverseInput;\n } catch {\n die(`Invalid JSON: ${jsonStr.slice(0, 200)}`);\n }\n result = await client.traverse(input!);\n break;\n }\n\n case 'search':\n if (!positional[0]) {\n die('Usage: firegraph query search <query>');\n }\n result = await client.search({ q: positional.join(' ') });\n break;\n\n case '--help':\n case '-h':\n case undefined:\n printHelp();\n return;\n\n default:\n die(\n `Unknown query command: ${command}\\n` +\n 'Commands: schema, get, find-nodes, find-edges, traverse, search',\n );\n }\n\n console.log(JSON.stringify(result, null, 2));\n } catch (err) {\n if (err instanceof QueryClientError) {\n console.error(JSON.stringify({ error: err.message, code: err.code }));\n } else {\n console.error(JSON.stringify({ error: (err as Error).message }));\n }\n process.exit(1);\n }\n}\n\nfunction printHelp(): void {\n console.log('');\n console.log(' Usage: firegraph query <command> [options]');\n console.log('');\n console.log(' Commands:');\n console.log(' schema Get graph schema (node types + edge types)');\n console.log(' get <uid> Get node detail with edges');\n console.log(' find-nodes <type> [--limit N] List nodes of a type');\n console.log(' find-edges [filters] List edges matching filters');\n console.log(' traverse \\'<JSON>\\' Multi-hop graph traversal');\n console.log(' search <query> Search nodes by text');\n console.log('');\n console.log(' Global options:');\n console.log(' --port <number> Editor server port (default: auto-detect from config)');\n console.log(' --host <string> Editor server host (default: localhost)');\n console.log('');\n console.log(' find-edges filters:');\n console.log(' --aType <type> Filter by source type');\n console.log(' --aUid <uid> Filter by source UID');\n console.log(' --axbType <rel> Filter by relation type');\n console.log(' --bType <type> Filter by target type');\n console.log(' --bUid <uid> Filter by target UID');\n console.log(' --limit <N> Max results (1-200, default 25)');\n console.log('');\n console.log(' Examples:');\n console.log(' npx firegraph query schema');\n console.log(' npx firegraph query get Kj7vNq2mP9xR4wL1tY8s3');\n console.log(' npx firegraph query find-nodes task --limit 10');\n console.log(' npx firegraph query find-edges --aUid Kj7vNq2mP9xR4wL1tY8s3 --axbType hasTask');\n console.log(' npx firegraph query search \"John Doe\"');\n console.log('');\n}\n\nfunction die(msg: string): never {\n console.error(msg);\n process.exit(1);\n}\n"],"mappings":";AAAA,OAAO,UAAU;;;ACEV,SAAS,gBAAgB,GAA4D;AAC1F,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,MAAwB,EAAE,MAAM,EAAE,OAAiB,KAAK,EAAE,KAAe;AAC/E,QAAM,OAAO,EAAE;AACf,MAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACpE,QAAI,OAAO;AAAA,EACb;AACA,SAAO;AACT;AAEO,SAAS,cAAc,GAA0D;AACtF,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,MAAsB;AAAA,IAC1B,UAAU,EAAE;AAAA,IACZ,SAAS,EAAE;AAAA,IACX,UAAU,EAAE;AAAA,IACZ,QAAQ,EAAE;AAAA,IACV,OAAO,EAAE;AAAA,EACX;AACA,QAAM,OAAO,EAAE;AACf,MAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AACpE,QAAI,OAAO;AAAA,EACb;AACA,SAAO;AACT;;;AC1BA,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AAErB,IAAM,eAAe,CAAC,uBAAuB,uBAAuB,sBAAsB;AAC1F,IAAM,eAAe;AAMd,SAAS,e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