@typicalday/firegraph 0.14.1 → 0.15.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 (64) hide show
  1. package/README.md +23 -3
  2. package/dist/{backend-DuvHGgK1.d.cts → backend-BpYLdwCW.d.cts} +1 -1
  3. package/dist/{backend-DuvHGgK1.d.ts → backend-BpYLdwCW.d.ts} +1 -1
  4. package/dist/backend-CvImIwTY.d.cts +137 -0
  5. package/dist/backend-YH5HtawN.d.ts +137 -0
  6. package/dist/backend.d.cts +2 -2
  7. package/dist/backend.d.ts +2 -2
  8. package/dist/{chunk-3AHHXMWX.js → chunk-5HIRYV2S.js} +12 -35
  9. package/dist/chunk-5HIRYV2S.js.map +1 -0
  10. package/dist/{chunk-DJI3VXXA.js → chunk-7IEZ6IYY.js} +2 -2
  11. package/dist/chunk-7IEZ6IYY.js.map +1 -0
  12. package/dist/chunk-FODIMIWY.js +721 -0
  13. package/dist/chunk-FODIMIWY.js.map +1 -0
  14. package/dist/chunk-NGAJCALM.js +34 -0
  15. package/dist/chunk-NGAJCALM.js.map +1 -0
  16. package/dist/chunk-ULRDQ6HZ.js +862 -0
  17. package/dist/chunk-ULRDQ6HZ.js.map +1 -0
  18. package/dist/{client-BKi3vk0Q.d.ts → client-B5o39X79.d.ts} +1 -1
  19. package/dist/{client-BrsaXtDV.d.cts → client-BGHwxwPg.d.cts} +1 -1
  20. package/dist/{client-Bk2Cm6xv.d.cts → client-DoyEdJ5w.d.cts} +1 -1
  21. package/dist/{client-Bk2Cm6xv.d.ts → client-DoyEdJ5w.d.ts} +1 -1
  22. package/dist/cloudflare/index.cjs +148 -158
  23. package/dist/cloudflare/index.cjs.map +1 -1
  24. package/dist/cloudflare/index.d.cts +73 -70
  25. package/dist/cloudflare/index.d.ts +73 -70
  26. package/dist/cloudflare/index.js +53 -588
  27. package/dist/cloudflare/index.js.map +1 -1
  28. package/dist/codegen/index.d.cts +1 -1
  29. package/dist/codegen/index.d.ts +1 -1
  30. package/dist/firestore-enterprise/index.cjs.map +1 -1
  31. package/dist/firestore-enterprise/index.d.cts +3 -3
  32. package/dist/firestore-enterprise/index.d.ts +3 -3
  33. package/dist/firestore-enterprise/index.js +5 -3
  34. package/dist/firestore-enterprise/index.js.map +1 -1
  35. package/dist/firestore-standard/index.cjs.map +1 -1
  36. package/dist/firestore-standard/index.d.cts +3 -3
  37. package/dist/firestore-standard/index.d.ts +3 -3
  38. package/dist/firestore-standard/index.js +3 -2
  39. package/dist/firestore-standard/index.js.map +1 -1
  40. package/dist/index.d.cts +5 -5
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +6 -4
  43. package/dist/index.js.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/{registry-Bc7h6WTM.d.cts → registry-BGh7Jqpb.d.cts} +2 -2
  47. package/dist/{registry-C2KUPVZj.d.ts → registry-tKTb5Kx1.d.ts} +2 -2
  48. package/dist/sqlite/index.cjs +578 -371
  49. package/dist/sqlite/index.cjs.map +1 -1
  50. package/dist/sqlite/index.d.cts +4 -110
  51. package/dist/sqlite/index.d.ts +4 -110
  52. package/dist/sqlite/index.js +7 -1144
  53. package/dist/sqlite/index.js.map +1 -1
  54. package/dist/sqlite/local.cjs +1835 -0
  55. package/dist/sqlite/local.cjs.map +1 -0
  56. package/dist/sqlite/local.d.cts +83 -0
  57. package/dist/sqlite/local.d.ts +83 -0
  58. package/dist/sqlite/local.js +121 -0
  59. package/dist/sqlite/local.js.map +1 -0
  60. package/package.json +15 -1
  61. package/dist/chunk-3AHHXMWX.js.map +0 -1
  62. package/dist/chunk-DJI3VXXA.js.map +0 -1
  63. package/dist/chunk-NNBSUOOF.js +0 -289
  64. package/dist/chunk-NNBSUOOF.js.map +0 -1
@@ -1,22 +1,57 @@
1
- import { W as WritableRecord, f as WriteMode, U as UpdatePayload, G as GraphRegistry, I as IndexSpec, p as QueryFilter, ai as QueryOptions, z as AggregateSpec, O as CascadeResult, F as FindEdgesParams, H as BulkOptions, L as BulkResult, b as BulkUpdatePatch, E as ExpandParams, S as StorageBackend, B as BackendCapabilities, t as GraphClient, Z as DynamicGraphClient, m as StoredGraphRecord, T as TransactionBackend, a as BatchBackend, u as GraphReader, e as ExpandResult, a8 as GraphClientOptions, $ as DynamicRegistryConfig } from '../backend-DuvHGgK1.cjs';
2
- export { A as AggregateExtension, w as AggregateField, x as AggregateOp, y as AggregateResult, N as Capability, d as DmlExtension, J as JoinExtension, g as createCapabilities, h as deleteField, j as intersectCapabilities } from '../backend-DuvHGgK1.cjs';
1
+ import { W as WritableRecord, f as WriteMode, U as UpdatePayload, p as GraphRegistry, I as IndexSpec, Q as QueryFilter, r as QueryOptions, A as AggregateSpec, s as CascadeResult, F as FindEdgesParams, t as BulkOptions, u as BulkResult, b as BulkUpdatePatch, E as ExpandParams, S as StorageBackend, B as BackendCapabilities, o as GraphClient, n as DynamicGraphClient, v as StoredGraphRecord, T as TransactionBackend, a as BatchBackend, q as GraphReader, e as ExpandResult, G as GraphClientOptions, m as DynamicRegistryConfig } from '../backend-BpYLdwCW.cjs';
2
+ export { w as AggregateExtension, x as AggregateField, y as AggregateOp, z as AggregateResult, C as Capability, d as DmlExtension, J as JoinExtension, g as createCapabilities, h as deleteField, j as intersectCapabilities } from '../backend-BpYLdwCW.cjs';
3
3
  import { DurableObject } from 'cloudflare:workers';
4
- export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-Bc7h6WTM.cjs';
4
+ export { M as META_EDGE_TYPE, a as META_NODE_TYPE, c as createMergedRegistry, b as createRegistry, g as generateId } from '../registry-BGh7Jqpb.cjs';
5
5
  export { C as CapabilityNotSupportedError } from '../errors-BRc3I_eH.cjs';
6
6
  import '@google-cloud/firestore';
7
7
 
8
8
  /**
9
- * SQL compilation for the DO SQLite backend.
10
- *
11
- * Every `FiregraphDO` instance owns one SQLite database holding exactly one
12
- * subgraph's triples there is no `scope` column and no scope discriminator
13
- * on any statement. Contrast with `src/internal/sqlite-sql.ts`, which
14
- * carries a scope prefix on every read and write for the legacy shared-table
15
- * D1/DO SQLite backend.
16
- *
17
- * Filter compilation, JSON-path validation, and value binding mirror the
18
- * legacy module so the query planner (`src/query.ts`) emits the same
19
- * `QueryFilter[]` shape regardless of backend.
9
+ * SQL compilation for SQLite-shaped firegraph backends.
10
+ *
11
+ * One table holds exactly one graph's triples there is no `scope` column
12
+ * and no scope discriminator on any statement. Subgraph isolation is
13
+ * physical: the shared SQLite backend (`src/sqlite/`) maps each graph to
14
+ * its own table, and the Cloudflare DO backend (`src/cloudflare/`) maps
15
+ * each graph to its own Durable Object. Every compiler in this module is
16
+ * parameterized by the target table name.
17
+ *
18
+ * Filter compilation, JSON-path validation, and value binding are shared so
19
+ * the query planner (`src/query.ts`) emits the same `QueryFilter[]` shape
20
+ * regardless of backend.
21
+ */
22
+
23
+ /**
24
+ * Discriminator for one projected column. The decoder uses this to recover
25
+ * the JS-shape of the requested field.
26
+ */
27
+ type ProjectedColumnKind = 'builtin-text' | 'builtin-int' | 'builtin-timestamp' | 'data' | 'json';
28
+ /** Per-column metadata returned alongside the compiled projection statement. */
29
+ interface ProjectedColumnSpec {
30
+ /** Original caller-supplied field name. Used as the alias in the SQL
31
+ * projection list AND as the key in the returned JS row. */
32
+ field: string;
33
+ /** Kind discriminator — see `ProjectedColumnKind`. */
34
+ kind: ProjectedColumnKind;
35
+ /**
36
+ * For `kind === 'json'` only: alias of the paired `json_type` companion
37
+ * column. Uses a positional sentinel (`__fg_t_<idx>`) keyed by the
38
+ * field's position in the unique projection list rather than the
39
+ * historical `<field>__t` suffix, which would collide if the caller
40
+ * projected both `'foo'` and `'foo__t'` (both legal user input).
41
+ */
42
+ typeAlias?: string;
43
+ }
44
+
45
+ /**
46
+ * DO RPC wire helpers for the Cloudflare backend.
47
+ *
48
+ * SQL compilation lives in the shared scope-free compiler
49
+ * (`src/internal/sqlite-sql.ts`) — every `FiregraphDO` owns one SQLite
50
+ * database holding exactly one subgraph's triples, the same one-table /
51
+ * one-graph shape the shared SQLite edition uses, so the compilers are
52
+ * identical. This module keeps only what is specific to crossing the DO
53
+ * RPC boundary: the structured-clone-safe record shape and its
54
+ * serialize / hydrate pair.
20
55
  */
21
56
 
22
57
  /**
@@ -42,30 +77,6 @@ interface DORecordWire {
42
77
  createdAtMs: number;
43
78
  updatedAtMs: number;
44
79
  }
45
- /**
46
- * Discriminator for one projected column on the DO backend. The decoder
47
- * uses this to recover the JS-shape of the requested field. Mirrors the
48
- * shared-SQLite `ProjectedColumnKind` — same kinds, same decode rules. The
49
- * two share no module so the symbol is duplicated; the contract is locked
50
- * by the cross-backend test in `tests/unit/cloudflare-sql.test.ts`.
51
- */
52
- type DOProjectedColumnKind = 'builtin-text' | 'builtin-int' | 'builtin-timestamp' | 'data' | 'json';
53
- /** Per-column metadata returned alongside the compiled projection statement. */
54
- interface DOProjectedColumnSpec {
55
- /** Original caller-supplied field name. Used as the alias in the SQL
56
- * projection list AND as the key in the returned JS row. */
57
- field: string;
58
- /** Kind discriminator — see `DOProjectedColumnKind`. */
59
- kind: DOProjectedColumnKind;
60
- /**
61
- * For `kind === 'json'` only: alias of the paired `json_type` companion
62
- * column. Uses a positional sentinel (`__fg_t_<idx>`) keyed by the
63
- * field's position in the unique projection list rather than the
64
- * historical `<field>__t` suffix, which would collide if the caller
65
- * projected both `'foo'` and `'foo__t'` (both legal user input).
66
- */
67
- typeAlias?: string;
68
- }
69
80
 
70
81
  /**
71
82
  * `FiregraphDO` — the Durable Object class that holds a single subgraph's
@@ -237,7 +248,7 @@ declare class FiregraphDO extends DurableObject<unknown> {
237
248
  _fgExpand(params: ExpandParams): Promise<ExpandResultWire>;
238
249
  _fgFindEdgesProjected(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
239
250
  rows: Array<Record<string, unknown>>;
240
- columns: DOProjectedColumnSpec[];
251
+ columns: ProjectedColumnSpec[];
241
252
  }>;
242
253
  /**
243
254
  * Run a DML statement with `RETURNING "doc_id"` so the affected-row count
@@ -366,7 +377,7 @@ interface FiregraphStub {
366
377
  */
367
378
  _fgFindEdgesProjected?(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
368
379
  rows: Array<Record<string, unknown>>;
369
- columns: DOProjectedColumnSpec[];
380
+ columns: ProjectedColumnSpec[];
370
381
  }>;
371
382
  _fgDestroy(): Promise<void>;
372
383
  }
@@ -703,56 +714,48 @@ declare function createSiblingClient(client: DOGraphClient, siblingRootKey: stri
703
714
  declare function createSiblingClient(client: DODynamicGraphClient, siblingRootKey: string): DODynamicGraphClient;
704
715
 
705
716
  /**
706
- * Flat SQLite schema for a single firegraph DO.
707
- *
708
- * Each `FiregraphDO` instance owns its own SQLite database and holds exactly
709
- * one subgraph's triples. Subgraph isolation is physical (one DO per
710
- * subgraph), so there is no `scope` column — every row in this DO belongs to
711
- * the same logical scope. This is the Cloudflare-native design: the scope
712
- * discriminator used by the legacy shared-table SQLite backend
713
- * (`src/internal/sqlite-schema.ts`) does not exist here.
717
+ * SQLite schema for firegraph triples.
714
718
  *
715
- * Document IDs:
716
- * - Nodes: the UID itself
717
- * - Edges: `shard:aUid:axbType:bUid`
719
+ * Single-table design — both nodes (self-loops with `axbType = 'is'`) and
720
+ * edges share one row shape. Each table holds exactly one graph's triples:
721
+ * subgraph isolation is physical (one table per graph, or one Durable
722
+ * Object per graph on Cloudflare), so there is no `scope` discriminator
723
+ * column. The table a row lives in *is* its scope.
718
724
  *
719
- * Indexes come from two sources and are appended to the DDL list:
725
+ * `data` is a JSON string. Built-in fields are projected to typed columns so
726
+ * the query planner can use indexes without going through `json_extract`.
720
727
  *
721
- * 1. The core preset (`DEFAULT_CORE_INDEXES`), overridable per-DO via
722
- * `FiregraphDOOptions.coreIndexes`.
723
- * 2. Per-registry-entry `indexes` declared on `RegistryEntry` (from code or
724
- * `meta.json` via entity discovery).
728
+ * ## Indexes
725
729
  *
726
- * Both sets are deduplicated by canonical fingerprint, so declaring the same
727
- * composite twice (e.g., by preset + registry entry) collapses to one
728
- * `CREATE INDEX`.
730
+ * Index specs come from the core preset (overridable via
731
+ * `BuildSchemaOptions.coreIndexes`) plus per-entry `indexes` declared on
732
+ * registry entries. Specs are deduplicated by canonical fingerprint before
733
+ * emission.
729
734
  */
730
735
 
731
736
  /**
732
- * Options controlling DDL emission for `buildDOSchemaStatements`.
737
+ * Options controlling DDL emission for `buildSchemaStatements`.
733
738
  */
734
- interface BuildDOSchemaOptions {
739
+ interface BuildSchemaOptions {
735
740
  /**
736
741
  * Replaces the built-in core preset. Defaults to `DEFAULT_CORE_INDEXES`.
737
742
  * Pass `[]` to disable core indexes entirely.
738
743
  */
739
744
  coreIndexes?: IndexSpec[];
740
745
  /**
741
- * Registry contributing per-triple `indexes` declarations. Entries with
742
- * no `indexes` field are ignored; the rest are flattened and deduplicated
743
- * against the core preset by canonical fingerprint.
746
+ * Registry contributing per-triple `indexes` declarations.
744
747
  */
745
748
  registry?: GraphRegistry;
746
749
  }
747
750
  /**
748
- * DDL statements that create the firegraph table and its indexes. Returned
749
- * as separate statements because DO SQLite's `exec()` runs one statement per
750
- * call. Run via `FiregraphDO.ensureSchema()` on DO boot.
751
+ * Build the DDL statements that create one graph's triple table and its
752
+ * indexes. Returned as separate statements because some drivers (D1, DO
753
+ * SQLite's `exec()`) require one statement per call.
751
754
  *
752
755
  * The CREATE TABLE statement is always first; index statements follow in
753
756
  * deterministic order. Same specs across runs produce the same statements,
754
- * so `CREATE INDEX IF NOT EXISTS` is idempotent.
757
+ * so `CREATE IF NOT EXISTS` is idempotent.
755
758
  */
756
- declare function buildDOSchemaStatements(table: string, options?: BuildDOSchemaOptions): string[];
759
+ declare function buildSchemaStatements(table: string, options?: BuildSchemaOptions): string[];
757
760
 
758
- export { AggregateSpec, BackendCapabilities, type BatchOp, type BuildDOSchemaOptions, BulkUpdatePatch, type CloudflareCapability, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, ExpandParams, ExpandResult, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildDOSchemaStatements, createDOClient, createSiblingClient };
761
+ export { AggregateSpec, BackendCapabilities, type BatchOp, type BuildSchemaOptions as BuildDOSchemaOptions, BulkUpdatePatch, type CloudflareCapability, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, ExpandParams, ExpandResult, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildSchemaStatements as buildDOSchemaStatements, createDOClient, createSiblingClient };
@@ -1,22 +1,57 @@
1
- import { W as WritableRecord, f as WriteMode, U as UpdatePayload, G as GraphRegistry, I as IndexSpec, p as QueryFilter, ai as QueryOptions, z as AggregateSpec, O as CascadeResult, F as FindEdgesParams, H as BulkOptions, L as BulkResult, b as BulkUpdatePatch, E as ExpandParams, S as StorageBackend, B as BackendCapabilities, t as GraphClient, Z as DynamicGraphClient, m as StoredGraphRecord, T as TransactionBackend, a as BatchBackend, u as GraphReader, e as ExpandResult, a8 as GraphClientOptions, $ as DynamicRegistryConfig } from '../backend-DuvHGgK1.js';
2
- export { A as AggregateExtension, w as AggregateField, x as AggregateOp, y as AggregateResult, N as Capability, d as DmlExtension, J as JoinExtension, g as createCapabilities, h as deleteField, j as intersectCapabilities } from '../backend-DuvHGgK1.js';
1
+ import { W as WritableRecord, f as WriteMode, U as UpdatePayload, p as GraphRegistry, I as IndexSpec, Q as QueryFilter, r as QueryOptions, A as AggregateSpec, s as CascadeResult, F as FindEdgesParams, t as BulkOptions, u as BulkResult, b as BulkUpdatePatch, E as ExpandParams, S as StorageBackend, B as BackendCapabilities, o as GraphClient, n as DynamicGraphClient, v as StoredGraphRecord, T as TransactionBackend, a as BatchBackend, q as GraphReader, e as ExpandResult, G as GraphClientOptions, m as DynamicRegistryConfig } from '../backend-BpYLdwCW.js';
2
+ export { w as AggregateExtension, x as AggregateField, y as AggregateOp, z as AggregateResult, C as Capability, d as DmlExtension, J as JoinExtension, g as createCapabilities, h as deleteField, j as intersectCapabilities } from '../backend-BpYLdwCW.js';
3
3
  import { DurableObject } from 'cloudflare:workers';
4
- export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-C2KUPVZj.js';
4
+ export { M as META_EDGE_TYPE, a as META_NODE_TYPE, c as createMergedRegistry, b as createRegistry, g as generateId } from '../registry-tKTb5Kx1.js';
5
5
  export { C as CapabilityNotSupportedError } from '../errors-BRc3I_eH.js';
6
6
  import '@google-cloud/firestore';
7
7
 
8
8
  /**
9
- * SQL compilation for the DO SQLite backend.
10
- *
11
- * Every `FiregraphDO` instance owns one SQLite database holding exactly one
12
- * subgraph's triples there is no `scope` column and no scope discriminator
13
- * on any statement. Contrast with `src/internal/sqlite-sql.ts`, which
14
- * carries a scope prefix on every read and write for the legacy shared-table
15
- * D1/DO SQLite backend.
16
- *
17
- * Filter compilation, JSON-path validation, and value binding mirror the
18
- * legacy module so the query planner (`src/query.ts`) emits the same
19
- * `QueryFilter[]` shape regardless of backend.
9
+ * SQL compilation for SQLite-shaped firegraph backends.
10
+ *
11
+ * One table holds exactly one graph's triples there is no `scope` column
12
+ * and no scope discriminator on any statement. Subgraph isolation is
13
+ * physical: the shared SQLite backend (`src/sqlite/`) maps each graph to
14
+ * its own table, and the Cloudflare DO backend (`src/cloudflare/`) maps
15
+ * each graph to its own Durable Object. Every compiler in this module is
16
+ * parameterized by the target table name.
17
+ *
18
+ * Filter compilation, JSON-path validation, and value binding are shared so
19
+ * the query planner (`src/query.ts`) emits the same `QueryFilter[]` shape
20
+ * regardless of backend.
21
+ */
22
+
23
+ /**
24
+ * Discriminator for one projected column. The decoder uses this to recover
25
+ * the JS-shape of the requested field.
26
+ */
27
+ type ProjectedColumnKind = 'builtin-text' | 'builtin-int' | 'builtin-timestamp' | 'data' | 'json';
28
+ /** Per-column metadata returned alongside the compiled projection statement. */
29
+ interface ProjectedColumnSpec {
30
+ /** Original caller-supplied field name. Used as the alias in the SQL
31
+ * projection list AND as the key in the returned JS row. */
32
+ field: string;
33
+ /** Kind discriminator — see `ProjectedColumnKind`. */
34
+ kind: ProjectedColumnKind;
35
+ /**
36
+ * For `kind === 'json'` only: alias of the paired `json_type` companion
37
+ * column. Uses a positional sentinel (`__fg_t_<idx>`) keyed by the
38
+ * field's position in the unique projection list rather than the
39
+ * historical `<field>__t` suffix, which would collide if the caller
40
+ * projected both `'foo'` and `'foo__t'` (both legal user input).
41
+ */
42
+ typeAlias?: string;
43
+ }
44
+
45
+ /**
46
+ * DO RPC wire helpers for the Cloudflare backend.
47
+ *
48
+ * SQL compilation lives in the shared scope-free compiler
49
+ * (`src/internal/sqlite-sql.ts`) — every `FiregraphDO` owns one SQLite
50
+ * database holding exactly one subgraph's triples, the same one-table /
51
+ * one-graph shape the shared SQLite edition uses, so the compilers are
52
+ * identical. This module keeps only what is specific to crossing the DO
53
+ * RPC boundary: the structured-clone-safe record shape and its
54
+ * serialize / hydrate pair.
20
55
  */
21
56
 
22
57
  /**
@@ -42,30 +77,6 @@ interface DORecordWire {
42
77
  createdAtMs: number;
43
78
  updatedAtMs: number;
44
79
  }
45
- /**
46
- * Discriminator for one projected column on the DO backend. The decoder
47
- * uses this to recover the JS-shape of the requested field. Mirrors the
48
- * shared-SQLite `ProjectedColumnKind` — same kinds, same decode rules. The
49
- * two share no module so the symbol is duplicated; the contract is locked
50
- * by the cross-backend test in `tests/unit/cloudflare-sql.test.ts`.
51
- */
52
- type DOProjectedColumnKind = 'builtin-text' | 'builtin-int' | 'builtin-timestamp' | 'data' | 'json';
53
- /** Per-column metadata returned alongside the compiled projection statement. */
54
- interface DOProjectedColumnSpec {
55
- /** Original caller-supplied field name. Used as the alias in the SQL
56
- * projection list AND as the key in the returned JS row. */
57
- field: string;
58
- /** Kind discriminator — see `DOProjectedColumnKind`. */
59
- kind: DOProjectedColumnKind;
60
- /**
61
- * For `kind === 'json'` only: alias of the paired `json_type` companion
62
- * column. Uses a positional sentinel (`__fg_t_<idx>`) keyed by the
63
- * field's position in the unique projection list rather than the
64
- * historical `<field>__t` suffix, which would collide if the caller
65
- * projected both `'foo'` and `'foo__t'` (both legal user input).
66
- */
67
- typeAlias?: string;
68
- }
69
80
 
70
81
  /**
71
82
  * `FiregraphDO` — the Durable Object class that holds a single subgraph's
@@ -237,7 +248,7 @@ declare class FiregraphDO extends DurableObject<unknown> {
237
248
  _fgExpand(params: ExpandParams): Promise<ExpandResultWire>;
238
249
  _fgFindEdgesProjected(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
239
250
  rows: Array<Record<string, unknown>>;
240
- columns: DOProjectedColumnSpec[];
251
+ columns: ProjectedColumnSpec[];
241
252
  }>;
242
253
  /**
243
254
  * Run a DML statement with `RETURNING "doc_id"` so the affected-row count
@@ -366,7 +377,7 @@ interface FiregraphStub {
366
377
  */
367
378
  _fgFindEdgesProjected?(select: ReadonlyArray<string>, filters: QueryFilter[], options?: QueryOptions): Promise<{
368
379
  rows: Array<Record<string, unknown>>;
369
- columns: DOProjectedColumnSpec[];
380
+ columns: ProjectedColumnSpec[];
370
381
  }>;
371
382
  _fgDestroy(): Promise<void>;
372
383
  }
@@ -703,56 +714,48 @@ declare function createSiblingClient(client: DOGraphClient, siblingRootKey: stri
703
714
  declare function createSiblingClient(client: DODynamicGraphClient, siblingRootKey: string): DODynamicGraphClient;
704
715
 
705
716
  /**
706
- * Flat SQLite schema for a single firegraph DO.
707
- *
708
- * Each `FiregraphDO` instance owns its own SQLite database and holds exactly
709
- * one subgraph's triples. Subgraph isolation is physical (one DO per
710
- * subgraph), so there is no `scope` column — every row in this DO belongs to
711
- * the same logical scope. This is the Cloudflare-native design: the scope
712
- * discriminator used by the legacy shared-table SQLite backend
713
- * (`src/internal/sqlite-schema.ts`) does not exist here.
717
+ * SQLite schema for firegraph triples.
714
718
  *
715
- * Document IDs:
716
- * - Nodes: the UID itself
717
- * - Edges: `shard:aUid:axbType:bUid`
719
+ * Single-table design — both nodes (self-loops with `axbType = 'is'`) and
720
+ * edges share one row shape. Each table holds exactly one graph's triples:
721
+ * subgraph isolation is physical (one table per graph, or one Durable
722
+ * Object per graph on Cloudflare), so there is no `scope` discriminator
723
+ * column. The table a row lives in *is* its scope.
718
724
  *
719
- * Indexes come from two sources and are appended to the DDL list:
725
+ * `data` is a JSON string. Built-in fields are projected to typed columns so
726
+ * the query planner can use indexes without going through `json_extract`.
720
727
  *
721
- * 1. The core preset (`DEFAULT_CORE_INDEXES`), overridable per-DO via
722
- * `FiregraphDOOptions.coreIndexes`.
723
- * 2. Per-registry-entry `indexes` declared on `RegistryEntry` (from code or
724
- * `meta.json` via entity discovery).
728
+ * ## Indexes
725
729
  *
726
- * Both sets are deduplicated by canonical fingerprint, so declaring the same
727
- * composite twice (e.g., by preset + registry entry) collapses to one
728
- * `CREATE INDEX`.
730
+ * Index specs come from the core preset (overridable via
731
+ * `BuildSchemaOptions.coreIndexes`) plus per-entry `indexes` declared on
732
+ * registry entries. Specs are deduplicated by canonical fingerprint before
733
+ * emission.
729
734
  */
730
735
 
731
736
  /**
732
- * Options controlling DDL emission for `buildDOSchemaStatements`.
737
+ * Options controlling DDL emission for `buildSchemaStatements`.
733
738
  */
734
- interface BuildDOSchemaOptions {
739
+ interface BuildSchemaOptions {
735
740
  /**
736
741
  * Replaces the built-in core preset. Defaults to `DEFAULT_CORE_INDEXES`.
737
742
  * Pass `[]` to disable core indexes entirely.
738
743
  */
739
744
  coreIndexes?: IndexSpec[];
740
745
  /**
741
- * Registry contributing per-triple `indexes` declarations. Entries with
742
- * no `indexes` field are ignored; the rest are flattened and deduplicated
743
- * against the core preset by canonical fingerprint.
746
+ * Registry contributing per-triple `indexes` declarations.
744
747
  */
745
748
  registry?: GraphRegistry;
746
749
  }
747
750
  /**
748
- * DDL statements that create the firegraph table and its indexes. Returned
749
- * as separate statements because DO SQLite's `exec()` runs one statement per
750
- * call. Run via `FiregraphDO.ensureSchema()` on DO boot.
751
+ * Build the DDL statements that create one graph's triple table and its
752
+ * indexes. Returned as separate statements because some drivers (D1, DO
753
+ * SQLite's `exec()`) require one statement per call.
751
754
  *
752
755
  * The CREATE TABLE statement is always first; index statements follow in
753
756
  * deterministic order. Same specs across runs produce the same statements,
754
- * so `CREATE INDEX IF NOT EXISTS` is idempotent.
757
+ * so `CREATE IF NOT EXISTS` is idempotent.
755
758
  */
756
- declare function buildDOSchemaStatements(table: string, options?: BuildDOSchemaOptions): string[];
759
+ declare function buildSchemaStatements(table: string, options?: BuildSchemaOptions): string[];
757
760
 
758
- export { AggregateSpec, BackendCapabilities, type BatchOp, type BuildDOSchemaOptions, BulkUpdatePatch, type CloudflareCapability, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, ExpandParams, ExpandResult, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildDOSchemaStatements, createDOClient, createSiblingClient };
761
+ export { AggregateSpec, BackendCapabilities, type BatchOp, type BuildSchemaOptions as BuildDOSchemaOptions, BulkUpdatePatch, type CloudflareCapability, type DOClientOptions, DORPCBackend, type DORPCBackendOptions, type DOSqlCursor, type DOSqlExecutor, type DOStorage, type DurableObjectIdLike, type DurableObjectStateLike, ExpandParams, ExpandResult, FiregraphDO, type FiregraphDOOptions, type FiregraphNamespace, type FiregraphStub, buildSchemaStatements as buildDOSchemaStatements, createDOClient, createSiblingClient };