@typicalday/firegraph 0.11.2 → 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.
- package/README.md +355 -78
- package/dist/backend-DuvHGgK1.d.cts +1897 -0
- package/dist/backend-DuvHGgK1.d.ts +1897 -0
- package/dist/backend.cjs +365 -5
- package/dist/backend.cjs.map +1 -1
- package/dist/backend.d.cts +25 -5
- package/dist/backend.d.ts +25 -5
- package/dist/backend.js +209 -7
- package/dist/backend.js.map +1 -1
- package/dist/chunk-2DHMNTV6.js +16 -0
- package/dist/chunk-2DHMNTV6.js.map +1 -0
- package/dist/chunk-4MMQ5W74.js +288 -0
- package/dist/chunk-4MMQ5W74.js.map +1 -0
- package/dist/{chunk-5753Y42M.js → chunk-C2QMD7RY.js} +6 -10
- package/dist/chunk-C2QMD7RY.js.map +1 -0
- package/dist/chunk-D4J7Z4FE.js +67 -0
- package/dist/chunk-D4J7Z4FE.js.map +1 -0
- package/dist/chunk-EQJUUVFG.js +14 -0
- package/dist/chunk-EQJUUVFG.js.map +1 -0
- package/dist/chunk-N5HFDWQX.js +23 -0
- package/dist/chunk-N5HFDWQX.js.map +1 -0
- package/dist/chunk-PAD7WFFU.js +573 -0
- package/dist/chunk-PAD7WFFU.js.map +1 -0
- package/dist/chunk-TK64DNVK.js +256 -0
- package/dist/chunk-TK64DNVK.js.map +1 -0
- package/dist/{chunk-NJSOD64C.js → chunk-WRTFC5NG.js} +438 -30
- package/dist/chunk-WRTFC5NG.js.map +1 -0
- package/dist/client-BKi3vk0Q.d.ts +34 -0
- package/dist/client-BrsaXtDV.d.cts +34 -0
- package/dist/cloudflare/index.cjs +1386 -74
- package/dist/cloudflare/index.cjs.map +1 -1
- package/dist/cloudflare/index.d.cts +217 -13
- package/dist/cloudflare/index.d.ts +217 -13
- package/dist/cloudflare/index.js +639 -180
- package/dist/cloudflare/index.js.map +1 -1
- package/dist/codegen/index.d.cts +1 -1
- package/dist/codegen/index.d.ts +1 -1
- package/dist/errors-BRc3I_eH.d.cts +73 -0
- package/dist/errors-BRc3I_eH.d.ts +73 -0
- package/dist/firestore-enterprise/index.cjs +3877 -0
- package/dist/firestore-enterprise/index.cjs.map +1 -0
- package/dist/firestore-enterprise/index.d.cts +141 -0
- package/dist/firestore-enterprise/index.d.ts +141 -0
- package/dist/firestore-enterprise/index.js +985 -0
- package/dist/firestore-enterprise/index.js.map +1 -0
- package/dist/firestore-standard/index.cjs +3117 -0
- package/dist/firestore-standard/index.cjs.map +1 -0
- package/dist/firestore-standard/index.d.cts +49 -0
- package/dist/firestore-standard/index.d.ts +49 -0
- package/dist/firestore-standard/index.js +283 -0
- package/dist/firestore-standard/index.js.map +1 -0
- package/dist/index.cjs +809 -534
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -100
- package/dist/index.d.ts +24 -100
- package/dist/index.js +184 -531
- package/dist/index.js.map +1 -1
- package/dist/registry-Bc7h6WTM.d.cts +64 -0
- package/dist/registry-C2KUPVZj.d.ts +64 -0
- package/dist/{scope-path-B1G3YiA7.d.ts → scope-path-CROFZGr9.d.cts} +1 -56
- package/dist/{scope-path-B1G3YiA7.d.cts → scope-path-CROFZGr9.d.ts} +1 -56
- package/dist/{serialization-ZZ7RSDRX.js → serialization-OE2PFZMY.js} +6 -4
- package/dist/sqlite/index.cjs +3631 -0
- package/dist/sqlite/index.cjs.map +1 -0
- package/dist/sqlite/index.d.cts +111 -0
- package/dist/sqlite/index.d.ts +111 -0
- package/dist/sqlite/index.js +1164 -0
- package/dist/sqlite/index.js.map +1 -0
- package/package.json +33 -3
- package/dist/backend-U-MLShlg.d.ts +0 -97
- package/dist/backend-np4gEVhB.d.cts +0 -97
- package/dist/chunk-5753Y42M.js.map +0 -1
- package/dist/chunk-NJSOD64C.js.map +0 -1
- package/dist/chunk-R7CRGYY4.js +0 -94
- package/dist/chunk-R7CRGYY4.js.map +0 -1
- package/dist/types-BGWxcpI_.d.cts +0 -736
- package/dist/types-BGWxcpI_.d.ts +0 -736
- /package/dist/{serialization-ZZ7RSDRX.js.map → serialization-OE2PFZMY.js.map} +0 -0
|
@@ -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 };
|