@rotorsoft/act-sqlite 1.22.3 → 1.22.5
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 +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/@types/sqlite-store.d.ts +11 -55
- package/dist/@types/sqlite-store.d.ts.map +1 -1
- package/dist/index.cjs +180 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +183 -186
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -102,11 +102,14 @@ export declare function streamPatternToGlob(input: string): string;
|
|
|
102
102
|
* Provides persistent event storage using SQLite via `@libsql/client`.
|
|
103
103
|
* All write operations use transactions for ACID guarantees.
|
|
104
104
|
*
|
|
105
|
-
* SQLite is a single-writer store
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
105
|
+
* SQLite is a single-writer store. The store runs its statements and
|
|
106
|
+
* transactions one at a time on its one connection, so concurrent calls
|
|
107
|
+
* from one process wait their turn. A second connection to the same file
|
|
108
|
+
* (another process, another `SqliteStore`) still fails with `SQLITE_BUSY`,
|
|
109
|
+
* so it does not support competing consumers the way PostgreSQL's
|
|
110
|
+
* `FOR UPDATE SKIP LOCKED` does (the TCK leaves `concurrent_claim` off for
|
|
111
|
+
* this reason). The intended model is one store, and one drain worker, per
|
|
112
|
+
* database file.
|
|
110
113
|
*
|
|
111
114
|
* **`Store.notify` is intentionally not implemented.** The notify hook is
|
|
112
115
|
* a cross-process wake-up signal that lets a horizontally-scaled Act
|
|
@@ -126,37 +129,15 @@ export declare function streamPatternToGlob(input: string): string;
|
|
|
126
129
|
*/
|
|
127
130
|
export declare class SqliteStore implements Store {
|
|
128
131
|
private client;
|
|
129
|
-
/**
|
|
130
|
-
* Memoized key resolver for the optional `pii_encryption` envelope.
|
|
131
|
-
* Initialized in the constructor when encryption is configured;
|
|
132
|
-
* `undefined` otherwise. The resolver caches the operator's key on
|
|
133
|
-
* first use — rotation means restarting the store with a fresh
|
|
134
|
-
* provider.
|
|
135
|
-
*/
|
|
136
132
|
private readonly _resolve_pii_key;
|
|
137
133
|
constructor(config: SqliteConfig);
|
|
138
|
-
/**
|
|
139
|
-
* Write-side pii encoder: encrypts when `pii_encryption` is configured,
|
|
140
|
-
* stringifies for the TEXT column either way. `null` passes through so
|
|
141
|
-
* `forget_pii` semantics survive intact (the row format skips the
|
|
142
|
-
* column entirely on a `NULL` write).
|
|
143
|
-
*
|
|
144
|
-
* @internal
|
|
145
|
-
*/
|
|
146
134
|
private _stringify_pii_for_write;
|
|
147
|
-
/**
|
|
148
|
-
* Read-side pii decoder: parses the TEXT column, and when
|
|
149
|
-
* `pii_encryption` is configured, transparently decrypts any value
|
|
150
|
-
* that came back as a JSON string. Plaintext writes deserialize to
|
|
151
|
-
* objects and pass through — which is what makes mixed-data
|
|
152
|
-
* rollouts (some pre-encryption rows, some post-) read cleanly.
|
|
153
|
-
*
|
|
154
|
-
* @internal
|
|
155
|
-
*/
|
|
156
135
|
private _parse_pii_from_read;
|
|
157
136
|
seed(): Promise<void>;
|
|
158
137
|
drop(): Promise<void>;
|
|
159
|
-
|
|
138
|
+
private _turn;
|
|
139
|
+
private _serial;
|
|
140
|
+
private _exec;
|
|
160
141
|
private _tx;
|
|
161
142
|
dispose(): Promise<void>;
|
|
162
143
|
commit<E extends Schemas>(stream: string, msgs: Message<E, keyof E>[], meta: EventMeta, expectedVersion?: number): Promise<Committed<E, keyof E>[]>;
|
|
@@ -170,23 +151,7 @@ export declare class SqliteStore implements Store {
|
|
|
170
151
|
ack(leases: Lease[]): Promise<Lease[]>;
|
|
171
152
|
block(leases: BlockedLease[]): Promise<BlockedLease[]>;
|
|
172
153
|
defer(input: string[] | StreamFilter, deferred_at: number): Promise<number>;
|
|
173
|
-
/**
|
|
174
|
-
* Runs `UPDATE streams <set>` on the streams named by `input`, in one
|
|
175
|
-
* write transaction (`_tx`) that rolls back on failure. An explicit list is
|
|
176
|
-
* de-duplicated, so a repeated name counts once (matching PG's set-based
|
|
177
|
-
* `stream = ANY(...)`), and updated one name per statement, so a long list
|
|
178
|
-
* never meets SQLite's bound-parameter limit. `set` and `where` bind
|
|
179
|
-
* `params` in order; libSQL `?` placeholders are positional and can't be
|
|
180
|
-
* reused, so a value used twice is passed twice.
|
|
181
|
-
*
|
|
182
|
-
* @returns Count of rows updated.
|
|
183
|
-
*/
|
|
184
154
|
private _update;
|
|
185
|
-
/**
|
|
186
|
-
* Translate a {@link StreamFilter} to a SQLite `WHERE` clause fragment
|
|
187
|
-
* plus positional args. Returns `"1"` (always true) when empty so
|
|
188
|
-
* callers can compose it unconditionally.
|
|
189
|
-
*/
|
|
190
155
|
private _filter_clause;
|
|
191
156
|
reset(input: string[] | StreamFilter): Promise<number>;
|
|
192
157
|
unblock(input: string[] | StreamFilter): Promise<number>;
|
|
@@ -216,16 +181,7 @@ export declare class SqliteStore implements Store {
|
|
|
216
181
|
* since SQLite has no native array type.
|
|
217
182
|
*/
|
|
218
183
|
query_stats<E extends Schemas>(input: string[] | Pick<StreamFilter, "stream" | "stream_exact">, options?: QueryStatsOptions<E>): Promise<Map<string, StreamStats<E>>>;
|
|
219
|
-
/**
|
|
220
|
-
* Cheap path — head (and optional tail) via ROW_NUMBER() over the
|
|
221
|
-
* `(stream, version)` unique index. Parallel queries when tail set.
|
|
222
|
-
*/
|
|
223
184
|
private _query_stats_heads_only;
|
|
224
|
-
/**
|
|
225
|
-
* Full-scan path — one CTE-based query with per-stream `COUNT(*)` and
|
|
226
|
-
* `json_group_object(name, n)`. Heads (and optional tails) ride free
|
|
227
|
-
* on the same scan.
|
|
228
|
-
*/
|
|
229
185
|
private _query_stats_full_scan;
|
|
230
186
|
prioritize(filter: StreamFilter, priority: number): Promise<number>;
|
|
231
187
|
truncate(targets: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-store.d.ts","sourceRoot":"","sources":["../../src/sqlite-store.ts"],"names":[],"mappings":"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