@typicalday/firegraph 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +317 -73
  2. package/dist/backend-DuvHGgK1.d.cts +1897 -0
  3. package/dist/backend-DuvHGgK1.d.ts +1897 -0
  4. package/dist/backend.cjs +222 -3
  5. package/dist/backend.cjs.map +1 -1
  6. package/dist/backend.d.cts +25 -5
  7. package/dist/backend.d.ts +25 -5
  8. package/dist/backend.js +197 -4
  9. package/dist/backend.js.map +1 -1
  10. package/dist/chunk-2DHMNTV6.js +16 -0
  11. package/dist/chunk-2DHMNTV6.js.map +1 -0
  12. package/dist/chunk-4MMQ5W74.js +288 -0
  13. package/dist/chunk-4MMQ5W74.js.map +1 -0
  14. package/dist/chunk-D4J7Z4FE.js +67 -0
  15. package/dist/chunk-D4J7Z4FE.js.map +1 -0
  16. package/dist/chunk-N5HFDWQX.js +23 -0
  17. package/dist/chunk-N5HFDWQX.js.map +1 -0
  18. package/dist/chunk-PAD7WFFU.js +573 -0
  19. package/dist/chunk-PAD7WFFU.js.map +1 -0
  20. package/dist/{chunk-AWW4MUJ5.js → chunk-TK64DNVK.js} +12 -1
  21. package/dist/chunk-TK64DNVK.js.map +1 -0
  22. package/dist/{chunk-HONQY4HF.js → chunk-WRTFC5NG.js} +362 -17
  23. package/dist/chunk-WRTFC5NG.js.map +1 -0
  24. package/dist/client-BKi3vk0Q.d.ts +34 -0
  25. package/dist/client-BrsaXtDV.d.cts +34 -0
  26. package/dist/cloudflare/index.cjs +930 -3
  27. package/dist/cloudflare/index.cjs.map +1 -1
  28. package/dist/cloudflare/index.d.cts +213 -12
  29. package/dist/cloudflare/index.d.ts +213 -12
  30. package/dist/cloudflare/index.js +562 -281
  31. package/dist/cloudflare/index.js.map +1 -1
  32. package/dist/codegen/index.d.cts +1 -1
  33. package/dist/codegen/index.d.ts +1 -1
  34. package/dist/errors-BRc3I_eH.d.cts +73 -0
  35. package/dist/errors-BRc3I_eH.d.ts +73 -0
  36. package/dist/firestore-enterprise/index.cjs +3877 -0
  37. package/dist/firestore-enterprise/index.cjs.map +1 -0
  38. package/dist/firestore-enterprise/index.d.cts +141 -0
  39. package/dist/firestore-enterprise/index.d.ts +141 -0
  40. package/dist/firestore-enterprise/index.js +985 -0
  41. package/dist/firestore-enterprise/index.js.map +1 -0
  42. package/dist/firestore-standard/index.cjs +3117 -0
  43. package/dist/firestore-standard/index.cjs.map +1 -0
  44. package/dist/firestore-standard/index.d.cts +49 -0
  45. package/dist/firestore-standard/index.d.ts +49 -0
  46. package/dist/firestore-standard/index.js +283 -0
  47. package/dist/firestore-standard/index.js.map +1 -0
  48. package/dist/index.cjs +590 -550
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +9 -37
  51. package/dist/index.d.ts +9 -37
  52. package/dist/index.js +178 -555
  53. package/dist/index.js.map +1 -1
  54. package/dist/{registry-Fi074zVa.d.ts → registry-Bc7h6WTM.d.cts} +1 -1
  55. package/dist/{registry-B1qsVL0E.d.cts → registry-C2KUPVZj.d.ts} +1 -1
  56. package/dist/{scope-path-B1G3YiA7.d.cts → scope-path-CROFZGr9.d.cts} +1 -56
  57. package/dist/{scope-path-B1G3YiA7.d.ts → scope-path-CROFZGr9.d.ts} +1 -56
  58. package/dist/sqlite/index.cjs +3631 -0
  59. package/dist/sqlite/index.cjs.map +1 -0
  60. package/dist/sqlite/index.d.cts +111 -0
  61. package/dist/sqlite/index.d.ts +111 -0
  62. package/dist/sqlite/index.js +1164 -0
  63. package/dist/sqlite/index.js.map +1 -0
  64. package/package.json +33 -3
  65. package/dist/backend-BsR0lnFL.d.ts +0 -200
  66. package/dist/backend-Ct-fLlkG.d.cts +0 -200
  67. package/dist/chunk-AWW4MUJ5.js.map +0 -1
  68. package/dist/chunk-HONQY4HF.js.map +0 -1
  69. package/dist/types-DxYLy8Ol.d.cts +0 -770
  70. package/dist/types-DxYLy8Ol.d.ts +0 -770
@@ -0,0 +1,111 @@
1
+ export { c as createGraphClient } from '../client-BrsaXtDV.cjs';
2
+ export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-Bc7h6WTM.cjs';
3
+ import { S as StorageBackend } from '../backend-DuvHGgK1.cjs';
4
+ import '@google-cloud/firestore';
5
+
6
+ /**
7
+ * Driver-level SQLite abstraction.
8
+ *
9
+ * The `SqliteBackend` only depends on this interface, not on any particular
10
+ * SQLite driver. Callers wire up whichever driver suits their runtime —
11
+ * `better-sqlite3` in Node tests, D1 in Workers, DO SQLite inside a Durable
12
+ * Object, etc. — and `createSqliteBackend` composes the rest.
13
+ *
14
+ * Some drivers are fully async with native atomic batches (e.g. D1); others
15
+ * are synchronous and wrap `run`/`all` in immediately-resolved promises while
16
+ * providing interactive transactions via a sync primitive (e.g. DO SQLite's
17
+ * `transactionSync`). Both shapes fit behind this interface.
18
+ */
19
+ interface SqliteExecutor {
20
+ /** Run a query and return all rows. */
21
+ all(sql: string, params: unknown[]): Promise<Record<string, unknown>[]>;
22
+ /** Run a write statement. */
23
+ run(sql: string, params: unknown[]): Promise<void>;
24
+ /**
25
+ * Execute a list of write statements atomically. Drivers that lack
26
+ * native batch support (e.g., a wrapped synchronous SQLite) should still
27
+ * implement this so `BatchBackend.commit()` works.
28
+ */
29
+ batch(statements: ReadonlyArray<{
30
+ sql: string;
31
+ params: unknown[];
32
+ }>): Promise<void>;
33
+ /**
34
+ * Run an interactive transaction. Optional — if absent, the SqliteBackend
35
+ * throws on `runTransaction()`. D1 has no interactive transactions.
36
+ */
37
+ transaction?<T>(fn: (tx: SqliteTxExecutor) => Promise<T>): Promise<T>;
38
+ /**
39
+ * Maximum statements the driver will accept in a single `batch()` call.
40
+ * The backend uses this to chunk large bulk operations (cascade delete,
41
+ * bulkRemoveEdges) so a hub node with thousands of edges doesn't trip the
42
+ * driver's hard limit. D1 caps at ~100 statements per batch; DO SQLite has
43
+ * no documented cap (a single `transactionSync` over many statements is
44
+ * fine). When `undefined`, the backend submits all statements in one batch
45
+ * (preserving cross-batch atomicity for drivers that support it).
46
+ */
47
+ readonly maxBatchSize?: number;
48
+ /**
49
+ * Maximum total bound parameters the driver will accept across one
50
+ * `batch()` call. D1 caps at ~1000 bound parameters per batch — separate
51
+ * from `maxBatchSize`. Most cascade/bulk batches consist of 2-param
52
+ * `DELETE` statements so this rarely triggers, but driver authors should
53
+ * declare it for safety. When `undefined`, the backend doesn't split on
54
+ * parameter count.
55
+ */
56
+ readonly maxBatchParams?: number;
57
+ }
58
+ interface SqliteTxExecutor {
59
+ all(sql: string, params: unknown[]): Promise<Record<string, unknown>[]>;
60
+ run(sql: string, params: unknown[]): Promise<void>;
61
+ }
62
+
63
+ /**
64
+ * SQLite implementation of `StorageBackend`.
65
+ *
66
+ * Uses a single table keyed by `(scope, doc_id)`. Subgraphs are encoded in
67
+ * the `scope` column as a materialized path of interleaved parent UIDs and
68
+ * subgraph names — `''` at the root, `'<uid>/<name>'` one level down,
69
+ * `'<uid1>/<name1>/<uid2>/<name2>'` two levels down, and so on. Cascade
70
+ * delete uses a single `DELETE … WHERE scope LIKE 'prefix/%'` instead of
71
+ * walking subcollections.
72
+ */
73
+
74
+ interface SqliteBackendOptions {
75
+ /** Logical scope path (chained subgraph names) — used for `allowedIn` matching. */
76
+ scopePath?: string;
77
+ /** Internal storage scope (interleaved parent-uid/name path). */
78
+ storageScope?: string;
79
+ }
80
+ /**
81
+ * Capability union declared by the SQLite-backed `StorageBackend`.
82
+ *
83
+ * `core.transactions` is part of the static union because `runTransaction`
84
+ * is always present as a method on the class. The runtime cap-set determines
85
+ * whether that method is *functional*: D1 leaves `executor.transaction`
86
+ * undefined and the call throws `UNSUPPORTED_OPERATION`; DO SQLite and
87
+ * better-sqlite3 wire the executor and the call works. The static type
88
+ * therefore promises only that the method exists — callers that care about
89
+ * portability check `client.capabilities.has('core.transactions')` before
90
+ * opening a tx, and code that runs against an unknown driver can rely on the
91
+ * runtime guard inside `runTransaction`.
92
+ *
93
+ * The `query.*` extension capabilities follow the same conservative
94
+ * declaration rule as the cap descriptor itself — only land in the union
95
+ * when the corresponding method is actually wired up. Today that's
96
+ * `query.aggregate` (Phase 4), `query.dml` (Phase 5), `query.join`
97
+ * (Phase 6 — fan-out via `IN (…)` in one statement), and `query.select`
98
+ * (Phase 7 — server-side projection via `json_extract`).
99
+ */
100
+ type SqliteCapability = 'core.read' | 'core.write' | 'core.transactions' | 'core.batch' | 'core.subgraph' | 'query.aggregate' | 'query.dml' | 'query.join' | 'query.select' | 'raw.sql';
101
+ /**
102
+ * Create a SQLite-backed `StorageBackend`.
103
+ *
104
+ * `tableName` is the single table that holds every triple. The driver must
105
+ * have already created the table and indexes via `buildSchemaStatements()`
106
+ * before any reads/writes arrive — callers that ship their own SQLite
107
+ * driver are responsible for wiring that up.
108
+ */
109
+ declare function createSqliteBackend(executor: SqliteExecutor, tableName: string, options?: SqliteBackendOptions): StorageBackend<SqliteCapability>;
110
+
111
+ export { type SqliteBackendOptions, type SqliteCapability, createSqliteBackend };
@@ -0,0 +1,111 @@
1
+ export { c as createGraphClient } from '../client-BKi3vk0Q.js';
2
+ export { M as META_EDGE_TYPE, a as META_NODE_TYPE, b as createMergedRegistry, d as createRegistry, f as generateId } from '../registry-C2KUPVZj.js';
3
+ import { S as StorageBackend } from '../backend-DuvHGgK1.js';
4
+ import '@google-cloud/firestore';
5
+
6
+ /**
7
+ * Driver-level SQLite abstraction.
8
+ *
9
+ * The `SqliteBackend` only depends on this interface, not on any particular
10
+ * SQLite driver. Callers wire up whichever driver suits their runtime —
11
+ * `better-sqlite3` in Node tests, D1 in Workers, DO SQLite inside a Durable
12
+ * Object, etc. — and `createSqliteBackend` composes the rest.
13
+ *
14
+ * Some drivers are fully async with native atomic batches (e.g. D1); others
15
+ * are synchronous and wrap `run`/`all` in immediately-resolved promises while
16
+ * providing interactive transactions via a sync primitive (e.g. DO SQLite's
17
+ * `transactionSync`). Both shapes fit behind this interface.
18
+ */
19
+ interface SqliteExecutor {
20
+ /** Run a query and return all rows. */
21
+ all(sql: string, params: unknown[]): Promise<Record<string, unknown>[]>;
22
+ /** Run a write statement. */
23
+ run(sql: string, params: unknown[]): Promise<void>;
24
+ /**
25
+ * Execute a list of write statements atomically. Drivers that lack
26
+ * native batch support (e.g., a wrapped synchronous SQLite) should still
27
+ * implement this so `BatchBackend.commit()` works.
28
+ */
29
+ batch(statements: ReadonlyArray<{
30
+ sql: string;
31
+ params: unknown[];
32
+ }>): Promise<void>;
33
+ /**
34
+ * Run an interactive transaction. Optional — if absent, the SqliteBackend
35
+ * throws on `runTransaction()`. D1 has no interactive transactions.
36
+ */
37
+ transaction?<T>(fn: (tx: SqliteTxExecutor) => Promise<T>): Promise<T>;
38
+ /**
39
+ * Maximum statements the driver will accept in a single `batch()` call.
40
+ * The backend uses this to chunk large bulk operations (cascade delete,
41
+ * bulkRemoveEdges) so a hub node with thousands of edges doesn't trip the
42
+ * driver's hard limit. D1 caps at ~100 statements per batch; DO SQLite has
43
+ * no documented cap (a single `transactionSync` over many statements is
44
+ * fine). When `undefined`, the backend submits all statements in one batch
45
+ * (preserving cross-batch atomicity for drivers that support it).
46
+ */
47
+ readonly maxBatchSize?: number;
48
+ /**
49
+ * Maximum total bound parameters the driver will accept across one
50
+ * `batch()` call. D1 caps at ~1000 bound parameters per batch — separate
51
+ * from `maxBatchSize`. Most cascade/bulk batches consist of 2-param
52
+ * `DELETE` statements so this rarely triggers, but driver authors should
53
+ * declare it for safety. When `undefined`, the backend doesn't split on
54
+ * parameter count.
55
+ */
56
+ readonly maxBatchParams?: number;
57
+ }
58
+ interface SqliteTxExecutor {
59
+ all(sql: string, params: unknown[]): Promise<Record<string, unknown>[]>;
60
+ run(sql: string, params: unknown[]): Promise<void>;
61
+ }
62
+
63
+ /**
64
+ * SQLite implementation of `StorageBackend`.
65
+ *
66
+ * Uses a single table keyed by `(scope, doc_id)`. Subgraphs are encoded in
67
+ * the `scope` column as a materialized path of interleaved parent UIDs and
68
+ * subgraph names — `''` at the root, `'<uid>/<name>'` one level down,
69
+ * `'<uid1>/<name1>/<uid2>/<name2>'` two levels down, and so on. Cascade
70
+ * delete uses a single `DELETE … WHERE scope LIKE 'prefix/%'` instead of
71
+ * walking subcollections.
72
+ */
73
+
74
+ interface SqliteBackendOptions {
75
+ /** Logical scope path (chained subgraph names) — used for `allowedIn` matching. */
76
+ scopePath?: string;
77
+ /** Internal storage scope (interleaved parent-uid/name path). */
78
+ storageScope?: string;
79
+ }
80
+ /**
81
+ * Capability union declared by the SQLite-backed `StorageBackend`.
82
+ *
83
+ * `core.transactions` is part of the static union because `runTransaction`
84
+ * is always present as a method on the class. The runtime cap-set determines
85
+ * whether that method is *functional*: D1 leaves `executor.transaction`
86
+ * undefined and the call throws `UNSUPPORTED_OPERATION`; DO SQLite and
87
+ * better-sqlite3 wire the executor and the call works. The static type
88
+ * therefore promises only that the method exists — callers that care about
89
+ * portability check `client.capabilities.has('core.transactions')` before
90
+ * opening a tx, and code that runs against an unknown driver can rely on the
91
+ * runtime guard inside `runTransaction`.
92
+ *
93
+ * The `query.*` extension capabilities follow the same conservative
94
+ * declaration rule as the cap descriptor itself — only land in the union
95
+ * when the corresponding method is actually wired up. Today that's
96
+ * `query.aggregate` (Phase 4), `query.dml` (Phase 5), `query.join`
97
+ * (Phase 6 — fan-out via `IN (…)` in one statement), and `query.select`
98
+ * (Phase 7 — server-side projection via `json_extract`).
99
+ */
100
+ type SqliteCapability = 'core.read' | 'core.write' | 'core.transactions' | 'core.batch' | 'core.subgraph' | 'query.aggregate' | 'query.dml' | 'query.join' | 'query.select' | 'raw.sql';
101
+ /**
102
+ * Create a SQLite-backed `StorageBackend`.
103
+ *
104
+ * `tableName` is the single table that holds every triple. The driver must
105
+ * have already created the table and indexes via `buildSchemaStatements()`
106
+ * before any reads/writes arrive — callers that ship their own SQLite
107
+ * driver are responsible for wiring that up.
108
+ */
109
+ declare function createSqliteBackend(executor: SqliteExecutor, tableName: string, options?: SqliteBackendOptions): StorageBackend<SqliteCapability>;
110
+
111
+ export { type SqliteBackendOptions, type SqliteCapability, createSqliteBackend };