@bitcobblers/wod-wiki-storage 0.39.2142 → 0.40.2144
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/dist/chunk-IFLOX2TK.mjs +874 -0
- package/dist/chunk-IFLOX2TK.mjs.map +1 -0
- package/dist/{chunk-NUJEAUAK.mjs → chunk-IMNG2HY5.mjs} +4 -131
- package/dist/chunk-IMNG2HY5.mjs.map +1 -0
- package/dist/chunk-JFVXIJJI.mjs +134 -0
- package/dist/chunk-JFVXIJJI.mjs.map +1 -0
- package/dist/chunk-MOGQICXM.mjs +43 -0
- package/dist/chunk-MOGQICXM.mjs.map +1 -0
- package/dist/idb/index.cjs +1462 -0
- package/dist/idb/index.cjs.map +1 -0
- package/dist/idb/index.d.cts +156 -0
- package/dist/idb/index.d.ts +156 -0
- package/dist/idb/index.mjs +1079 -0
- package/dist/idb/index.mjs.map +1 -0
- package/dist/index.cjs +47 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +5 -2
- package/dist/index.mjs.map +1 -1
- package/dist/policy-CPscN81J.d.ts +49 -0
- package/dist/policy-DRYF6Y8i.d.cts +49 -0
- package/dist/sql/index.cjs +241 -38
- package/dist/sql/index.cjs.map +1 -1
- package/dist/sql/index.d.cts +64 -132
- package/dist/sql/index.d.ts +64 -132
- package/dist/sql/index.mjs +188 -852
- package/dist/sql/index.mjs.map +1 -1
- package/dist/sync-Bjj_c1ea.d.ts +141 -0
- package/dist/sync-DG4Z-szj.d.cts +141 -0
- package/dist/{wire-CKJDK_Nq.d.cts → wire-DGYxXt3I.d.cts} +2 -2
- package/dist/{wire-CKJDK_Nq.d.ts → wire-DGYxXt3I.d.ts} +2 -2
- package/package.json +14 -7
- package/dist/chunk-NUJEAUAK.mjs.map +0 -1
package/dist/sql/index.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { S as SqlConnection, D as Database } from '../connection-DxuCLpRc.cjs';
|
|
2
2
|
export { L as LibsqlClient, a as SqlRow, b as SqlStatement, c as SqlValue, l as libsqlDatabase } from '../connection-DxuCLpRc.cjs';
|
|
3
|
-
import {
|
|
3
|
+
import { e as StoreDef, R as RangeDTO, K as KeyDTO, f as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, d as IStorageTransaction } from '../wire-DGYxXt3I.cjs';
|
|
4
|
+
import { b as StoredSyncOp, S as SyncMutation } from '../sync-DG4Z-szj.cjs';
|
|
5
|
+
export { A as ApplySyncBatchOptions, R as RawSyncOp, c as SYNC_OPS_TABLE, d as SYNC_STATE_TABLE, a as SyncEntry, e as SyncTargetKind, f as applySyncBatch, g as fetchSyncOps, i as initSyncTarget, p as probeSyncTarget, r as readLegacyRows, h as readRawSyncOps } from '../sync-DG4Z-szj.cjs';
|
|
4
6
|
import '@libsql/client';
|
|
5
7
|
import '@bitcobblers/wod-wiki-core';
|
|
6
8
|
import '@bitcobblers/wod-wiki-lang';
|
|
@@ -157,148 +159,78 @@ declare class BrowserTursoStorage extends SqlStorage {
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* Turso target is a backup/sync destination, never the read/write provider.
|
|
162
|
+
* Native-copy verification + migration finalize — the pure-SQL seam the CLI
|
|
163
|
+
* `wod db backup/restore/migrate` commands run over any libsql Database.
|
|
163
164
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* and
|
|
170
|
-
*
|
|
171
|
-
*
|
|
165
|
+
* - databaseFingerprint: canonical sha-256 over EVERY user table (schema
|
|
166
|
+
* SQL + sorted typed-cell rows + the sync state row), so a Turso native
|
|
167
|
+
* seed-copy can be proven row- and binary-identical (BLOB bytes are hex
|
|
168
|
+
* encoded — JSON.stringify(ArrayBuffer) would collapse to {}) before any
|
|
169
|
+
* credential is minted or paired. Rows are encoded as typed cells inside
|
|
170
|
+
* JSON arrays and SORTED, so framing is unambiguous and rowid/physical
|
|
171
|
+
* order differences after a native copy cannot produce a false mismatch.
|
|
172
|
+
* - assertDatabaseCopyMatches: interrupted-copy AND concurrent-source
|
|
173
|
+
* refusal — the source must be unchanged since the copy started and the
|
|
174
|
+
* copy must match that exact snapshot.
|
|
175
|
+
* - finalizeMigrationTarget: CAS that flips a migration target from the
|
|
176
|
+
* non-legitimate "constructing" marker (state schema 0, unpairable by
|
|
177
|
+
* engine refusal and by `wod db pair`) to the live schema in ONE
|
|
178
|
+
* transaction, only after full replay/pin/binary validation passed.
|
|
172
179
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* a group (one pathologically large group can exceed the nominal row bound;
|
|
177
|
-
* that is the unavoidable atomicity ceiling).
|
|
178
|
-
*
|
|
179
|
-
* ponytail: op-log replay pulls — a fresh browser replays the whole log
|
|
180
|
-
* (O(history)) instead of reading per-store current-state tables. Upgrade
|
|
181
|
-
* path: add per-store state tables rev-indexed by primary key and collapse
|
|
182
|
-
* the log into them periodically; the wire format (op_id, rev, mutation)
|
|
183
|
-
* stays unchanged.
|
|
184
|
-
*
|
|
185
|
-
* Never-downgrade rule: the state row's `schema` is the managing client's
|
|
186
|
-
* DB_VERSION at init time. Uploads verify `schema` INSIDE the write
|
|
187
|
-
* transaction (a stale probe must not append current payloads to an old or
|
|
188
|
-
* newer remote); an older remote log is migrated forward by the caller
|
|
189
|
-
* (transform payloads, never just rewrite the marker), a newer remote is
|
|
190
|
-
* never rewritten — the client refuses and keeps working locally.
|
|
180
|
+
* No source is ever mutated by these helpers (reads + one guarded state-row
|
|
181
|
+
* UPDATE on the target). Fingerprint reads run inside one transaction so the
|
|
182
|
+
* enumeration and the rows come from one consistent snapshot.
|
|
191
183
|
*/
|
|
192
184
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
value: unknown;
|
|
204
|
-
} | {
|
|
205
|
-
op: 'delete';
|
|
206
|
-
store: StoreName;
|
|
207
|
-
key: KeyDTO;
|
|
208
|
-
} | {
|
|
209
|
-
op: 'clear';
|
|
210
|
-
store: StoreName;
|
|
211
|
-
} | {
|
|
212
|
-
op: 'wipe';
|
|
213
|
-
};
|
|
214
|
-
interface SyncEntry {
|
|
215
|
-
/** Idempotency key — one uuid per committed local transaction group. */
|
|
216
|
-
id: string;
|
|
217
|
-
at: number;
|
|
218
|
-
ops: SyncMutation[];
|
|
219
|
-
}
|
|
220
|
-
interface StoredSyncOp {
|
|
221
|
-
opId: string;
|
|
222
|
-
rev: number;
|
|
223
|
-
idx: number;
|
|
224
|
-
at: number;
|
|
225
|
-
mutation: SyncMutation;
|
|
226
|
-
}
|
|
227
|
-
type SyncTargetKind =
|
|
228
|
-
/** No tables at all (beyond libsql internals): fresh database. */
|
|
229
|
-
'empty'
|
|
230
|
-
/** Tables exist but neither sync state nor a legacy schema guard — not
|
|
231
|
-
* ours; initializing over unknown data is refused by the caller. */
|
|
232
|
-
| {
|
|
233
|
-
kind: 'unknown';
|
|
234
|
-
}
|
|
235
|
-
/** Legacy direct-Turso SqlStorage layout (`_wodwiki_schema` guard). */
|
|
236
|
-
| {
|
|
237
|
-
kind: 'legacy';
|
|
238
|
-
schemaVersion: number;
|
|
239
|
-
}
|
|
240
|
-
/** This sync protocol's layout; payload = state row. */
|
|
241
|
-
| {
|
|
242
|
-
kind: 'current';
|
|
243
|
-
schemaVersion: number;
|
|
244
|
-
rev: number;
|
|
245
|
-
};
|
|
246
|
-
/** Classify the sync target WITHOUT mutating it. */
|
|
247
|
-
declare function probeSyncTarget(db: Database): Promise<SyncTargetKind>;
|
|
248
|
-
/** Create the sync tables + state row. Only for empty targets; existing
|
|
249
|
-
* state (current, legacy or unknown) is never overwritten by init. */
|
|
250
|
-
declare function initSyncTarget(db: Database, schemaVersion: number): Promise<void>;
|
|
251
|
-
interface ApplySyncBatchOptions {
|
|
252
|
-
/** Schema the caller verified at probe time — rechecked INSIDE the write
|
|
253
|
-
* transaction so a schema change between probe and append aborts. */
|
|
254
|
-
expectSchema?: number;
|
|
255
|
-
/** Bump the state schema version in the SAME transaction (remote-schema
|
|
256
|
-
* migrations append converted payloads + move the marker atomically). */
|
|
257
|
-
toSchemaVersion?: number;
|
|
185
|
+
interface DatabaseFingerprint {
|
|
186
|
+
tables: number;
|
|
187
|
+
rows: number;
|
|
188
|
+
/** sha-256 hex over the canonical whole-database rendering. */
|
|
189
|
+
digest: string;
|
|
190
|
+
/** The sync protocol state row when this database carries that layout. */
|
|
191
|
+
sync: {
|
|
192
|
+
schema: number;
|
|
193
|
+
rev: number;
|
|
194
|
+
} | undefined;
|
|
258
195
|
}
|
|
259
196
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* uploader's watermark.
|
|
197
|
+
* Canonical fingerprint of every user table (sqlite_% / libsql_% internal
|
|
198
|
+
* tables excluded): per table the CREATE statement text plus its rows as
|
|
199
|
+
* typed-cell JSON arrays, SORTED so physical row order cannot influence the
|
|
200
|
+
* digest. Reads run inside one transaction for a consistent snapshot.
|
|
265
201
|
*/
|
|
266
|
-
declare function
|
|
202
|
+
declare function databaseFingerprint(db: Database): Promise<DatabaseFingerprint>;
|
|
267
203
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* group larger than `limit` is returned whole — the atomicity ceiling.
|
|
204
|
+
* Prove a native copy: the copy must equal the exact source snapshot the
|
|
205
|
+
* caller fingerprinted BEFORE starting the copy (`before`), and the source
|
|
206
|
+
* must not have advanced meanwhile (writers were supposed to be retired).
|
|
207
|
+
* Returns the re-read source fingerprint.
|
|
273
208
|
*/
|
|
274
|
-
declare function
|
|
209
|
+
declare function assertDatabaseCopyMatches(source: Database, copy: Database, before: DatabaseFingerprint): Promise<DatabaseFingerprint>;
|
|
275
210
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
* replay converted payloads only, so pulls never touch legacy row shapes.
|
|
211
|
+
* CAS-finalize a migration target constructed at the non-legitimate marker
|
|
212
|
+
* schema 0: requires the state row to be exactly {schema: 0, rev:
|
|
213
|
+
* expectRev}, then publishes the live schema in the same transaction. A
|
|
214
|
+
* target that never reaches this call stays schema 0 — probes report
|
|
215
|
+
* current/0, which no client accepts and `wod db pair` refuses.
|
|
282
216
|
*/
|
|
283
|
-
declare function
|
|
284
|
-
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
declare function readRawSyncOps(db: Database): Promise<RawSyncOp[]>;
|
|
217
|
+
declare function finalizeMigrationTarget(db: Database, toSchema: number, expectRev: number): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Policy snapshot validation shared by `wod db migrate` (pre-write) and
|
|
220
|
+
* `wod db pair` (over the full replayed remote log): a user-scope snapshot
|
|
221
|
+
* is policy-compliant PUTS ONLY — any delete/clear/wipe means non-user
|
|
222
|
+
* policy operations leaked into the copy — and every session pin and note
|
|
223
|
+
* block pin must have its immutable block_revisions row present (missing
|
|
224
|
+
* pins fail the copy, they are never silently dropped).
|
|
225
|
+
*/
|
|
226
|
+
declare function assertPolicySnapshot(ops: readonly SyncMutation[]): void;
|
|
295
227
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
228
|
+
* Pin closure over a LIVE op log (pair verification): unlike a conversion
|
|
229
|
+
* snapshot, an operational log legitimately contains delete/clear/wipe
|
|
230
|
+
* tombstones, so the CURRENT row set is replayed first and only live
|
|
231
|
+
* sessions/notes must find their immutable revisions. Anything deleted is
|
|
232
|
+
* not required to have one.
|
|
301
233
|
*/
|
|
302
|
-
declare function
|
|
234
|
+
declare function assertLogPinClosure(ops: readonly StoredSyncOp[]): void;
|
|
303
235
|
|
|
304
|
-
export {
|
|
236
|
+
export { BrowserTursoStorage, Database, type DatabaseFingerprint, MAX_BODY, SCHEMA_TABLE, SqlConnection, SqlStorage, type SqlStorageOptions, StorageError, StoredSyncOp, SyncMutation, type TursoSettings, assertDatabaseCopyMatches, assertLogPinClosure, assertPolicySnapshot, clearRows, countRows, databaseFingerprint, decodeRowJson, deleteRows, encodeRowJson, finalizeMigrationTarget, getRow, getRows, handleDomainQuery, initializeDomain, initializeStore, listRows, listRowsFromIndexMany, putRow, putRows, rebuildProjections, refreshDomain, storeDefinition, validateTursoUrl, verifyReadiness, wipeDomain, wipeRows };
|
package/dist/sql/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { S as SqlConnection, D as Database } from '../connection-DxuCLpRc.js';
|
|
2
2
|
export { L as LibsqlClient, a as SqlRow, b as SqlStatement, c as SqlValue, l as libsqlDatabase } from '../connection-DxuCLpRc.js';
|
|
3
|
-
import {
|
|
3
|
+
import { e as StoreDef, R as RangeDTO, K as KeyDTO, f as DomainQueryResult, T as TxOp, I as IStorage, S as StoreName, a as IReadOnlyStore, b as StoreType, c as IReadWriteStore, D as DomainQuery, d as IStorageTransaction } from '../wire-DGYxXt3I.js';
|
|
4
|
+
import { b as StoredSyncOp, S as SyncMutation } from '../sync-Bjj_c1ea.js';
|
|
5
|
+
export { A as ApplySyncBatchOptions, R as RawSyncOp, c as SYNC_OPS_TABLE, d as SYNC_STATE_TABLE, a as SyncEntry, e as SyncTargetKind, f as applySyncBatch, g as fetchSyncOps, i as initSyncTarget, p as probeSyncTarget, r as readLegacyRows, h as readRawSyncOps } from '../sync-Bjj_c1ea.js';
|
|
4
6
|
import '@libsql/client';
|
|
5
7
|
import '@bitcobblers/wod-wiki-core';
|
|
6
8
|
import '@bitcobblers/wod-wiki-lang';
|
|
@@ -157,148 +159,78 @@ declare class BrowserTursoStorage extends SqlStorage {
|
|
|
157
159
|
}
|
|
158
160
|
|
|
159
161
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* Turso target is a backup/sync destination, never the read/write provider.
|
|
162
|
+
* Native-copy verification + migration finalize — the pure-SQL seam the CLI
|
|
163
|
+
* `wod db backup/restore/migrate` commands run over any libsql Database.
|
|
163
164
|
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* and
|
|
170
|
-
*
|
|
171
|
-
*
|
|
165
|
+
* - databaseFingerprint: canonical sha-256 over EVERY user table (schema
|
|
166
|
+
* SQL + sorted typed-cell rows + the sync state row), so a Turso native
|
|
167
|
+
* seed-copy can be proven row- and binary-identical (BLOB bytes are hex
|
|
168
|
+
* encoded — JSON.stringify(ArrayBuffer) would collapse to {}) before any
|
|
169
|
+
* credential is minted or paired. Rows are encoded as typed cells inside
|
|
170
|
+
* JSON arrays and SORTED, so framing is unambiguous and rowid/physical
|
|
171
|
+
* order differences after a native copy cannot produce a false mismatch.
|
|
172
|
+
* - assertDatabaseCopyMatches: interrupted-copy AND concurrent-source
|
|
173
|
+
* refusal — the source must be unchanged since the copy started and the
|
|
174
|
+
* copy must match that exact snapshot.
|
|
175
|
+
* - finalizeMigrationTarget: CAS that flips a migration target from the
|
|
176
|
+
* non-legitimate "constructing" marker (state schema 0, unpairable by
|
|
177
|
+
* engine refusal and by `wod db pair`) to the live schema in ONE
|
|
178
|
+
* transaction, only after full replay/pin/binary validation passed.
|
|
172
179
|
*
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
* a group (one pathologically large group can exceed the nominal row bound;
|
|
177
|
-
* that is the unavoidable atomicity ceiling).
|
|
178
|
-
*
|
|
179
|
-
* ponytail: op-log replay pulls — a fresh browser replays the whole log
|
|
180
|
-
* (O(history)) instead of reading per-store current-state tables. Upgrade
|
|
181
|
-
* path: add per-store state tables rev-indexed by primary key and collapse
|
|
182
|
-
* the log into them periodically; the wire format (op_id, rev, mutation)
|
|
183
|
-
* stays unchanged.
|
|
184
|
-
*
|
|
185
|
-
* Never-downgrade rule: the state row's `schema` is the managing client's
|
|
186
|
-
* DB_VERSION at init time. Uploads verify `schema` INSIDE the write
|
|
187
|
-
* transaction (a stale probe must not append current payloads to an old or
|
|
188
|
-
* newer remote); an older remote log is migrated forward by the caller
|
|
189
|
-
* (transform payloads, never just rewrite the marker), a newer remote is
|
|
190
|
-
* never rewritten — the client refuses and keeps working locally.
|
|
180
|
+
* No source is ever mutated by these helpers (reads + one guarded state-row
|
|
181
|
+
* UPDATE on the target). Fingerprint reads run inside one transaction so the
|
|
182
|
+
* enumeration and the rows come from one consistent snapshot.
|
|
191
183
|
*/
|
|
192
184
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
value: unknown;
|
|
204
|
-
} | {
|
|
205
|
-
op: 'delete';
|
|
206
|
-
store: StoreName;
|
|
207
|
-
key: KeyDTO;
|
|
208
|
-
} | {
|
|
209
|
-
op: 'clear';
|
|
210
|
-
store: StoreName;
|
|
211
|
-
} | {
|
|
212
|
-
op: 'wipe';
|
|
213
|
-
};
|
|
214
|
-
interface SyncEntry {
|
|
215
|
-
/** Idempotency key — one uuid per committed local transaction group. */
|
|
216
|
-
id: string;
|
|
217
|
-
at: number;
|
|
218
|
-
ops: SyncMutation[];
|
|
219
|
-
}
|
|
220
|
-
interface StoredSyncOp {
|
|
221
|
-
opId: string;
|
|
222
|
-
rev: number;
|
|
223
|
-
idx: number;
|
|
224
|
-
at: number;
|
|
225
|
-
mutation: SyncMutation;
|
|
226
|
-
}
|
|
227
|
-
type SyncTargetKind =
|
|
228
|
-
/** No tables at all (beyond libsql internals): fresh database. */
|
|
229
|
-
'empty'
|
|
230
|
-
/** Tables exist but neither sync state nor a legacy schema guard — not
|
|
231
|
-
* ours; initializing over unknown data is refused by the caller. */
|
|
232
|
-
| {
|
|
233
|
-
kind: 'unknown';
|
|
234
|
-
}
|
|
235
|
-
/** Legacy direct-Turso SqlStorage layout (`_wodwiki_schema` guard). */
|
|
236
|
-
| {
|
|
237
|
-
kind: 'legacy';
|
|
238
|
-
schemaVersion: number;
|
|
239
|
-
}
|
|
240
|
-
/** This sync protocol's layout; payload = state row. */
|
|
241
|
-
| {
|
|
242
|
-
kind: 'current';
|
|
243
|
-
schemaVersion: number;
|
|
244
|
-
rev: number;
|
|
245
|
-
};
|
|
246
|
-
/** Classify the sync target WITHOUT mutating it. */
|
|
247
|
-
declare function probeSyncTarget(db: Database): Promise<SyncTargetKind>;
|
|
248
|
-
/** Create the sync tables + state row. Only for empty targets; existing
|
|
249
|
-
* state (current, legacy or unknown) is never overwritten by init. */
|
|
250
|
-
declare function initSyncTarget(db: Database, schemaVersion: number): Promise<void>;
|
|
251
|
-
interface ApplySyncBatchOptions {
|
|
252
|
-
/** Schema the caller verified at probe time — rechecked INSIDE the write
|
|
253
|
-
* transaction so a schema change between probe and append aborts. */
|
|
254
|
-
expectSchema?: number;
|
|
255
|
-
/** Bump the state schema version in the SAME transaction (remote-schema
|
|
256
|
-
* migrations append converted payloads + move the marker atomically). */
|
|
257
|
-
toSchemaVersion?: number;
|
|
185
|
+
interface DatabaseFingerprint {
|
|
186
|
+
tables: number;
|
|
187
|
+
rows: number;
|
|
188
|
+
/** sha-256 hex over the canonical whole-database rendering. */
|
|
189
|
+
digest: string;
|
|
190
|
+
/** The sync protocol state row when this database carries that layout. */
|
|
191
|
+
sync: {
|
|
192
|
+
schema: number;
|
|
193
|
+
rev: number;
|
|
194
|
+
} | undefined;
|
|
258
195
|
}
|
|
259
196
|
/**
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* uploader's watermark.
|
|
197
|
+
* Canonical fingerprint of every user table (sqlite_% / libsql_% internal
|
|
198
|
+
* tables excluded): per table the CREATE statement text plus its rows as
|
|
199
|
+
* typed-cell JSON arrays, SORTED so physical row order cannot influence the
|
|
200
|
+
* digest. Reads run inside one transaction for a consistent snapshot.
|
|
265
201
|
*/
|
|
266
|
-
declare function
|
|
202
|
+
declare function databaseFingerprint(db: Database): Promise<DatabaseFingerprint>;
|
|
267
203
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* group larger than `limit` is returned whole — the atomicity ceiling.
|
|
204
|
+
* Prove a native copy: the copy must equal the exact source snapshot the
|
|
205
|
+
* caller fingerprinted BEFORE starting the copy (`before`), and the source
|
|
206
|
+
* must not have advanced meanwhile (writers were supposed to be retired).
|
|
207
|
+
* Returns the re-read source fingerprint.
|
|
273
208
|
*/
|
|
274
|
-
declare function
|
|
209
|
+
declare function assertDatabaseCopyMatches(source: Database, copy: Database, before: DatabaseFingerprint): Promise<DatabaseFingerprint>;
|
|
275
210
|
/**
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
281
|
-
* replay converted payloads only, so pulls never touch legacy row shapes.
|
|
211
|
+
* CAS-finalize a migration target constructed at the non-legitimate marker
|
|
212
|
+
* schema 0: requires the state row to be exactly {schema: 0, rev:
|
|
213
|
+
* expectRev}, then publishes the live schema in the same transaction. A
|
|
214
|
+
* target that never reaches this call stays schema 0 — probes report
|
|
215
|
+
* current/0, which no client accepts and `wod db pair` refuses.
|
|
282
216
|
*/
|
|
283
|
-
declare function
|
|
284
|
-
/**
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
*
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
declare function readRawSyncOps(db: Database): Promise<RawSyncOp[]>;
|
|
217
|
+
declare function finalizeMigrationTarget(db: Database, toSchema: number, expectRev: number): Promise<void>;
|
|
218
|
+
/**
|
|
219
|
+
* Policy snapshot validation shared by `wod db migrate` (pre-write) and
|
|
220
|
+
* `wod db pair` (over the full replayed remote log): a user-scope snapshot
|
|
221
|
+
* is policy-compliant PUTS ONLY — any delete/clear/wipe means non-user
|
|
222
|
+
* policy operations leaked into the copy — and every session pin and note
|
|
223
|
+
* block pin must have its immutable block_revisions row present (missing
|
|
224
|
+
* pins fail the copy, they are never silently dropped).
|
|
225
|
+
*/
|
|
226
|
+
declare function assertPolicySnapshot(ops: readonly SyncMutation[]): void;
|
|
295
227
|
/**
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
228
|
+
* Pin closure over a LIVE op log (pair verification): unlike a conversion
|
|
229
|
+
* snapshot, an operational log legitimately contains delete/clear/wipe
|
|
230
|
+
* tombstones, so the CURRENT row set is replayed first and only live
|
|
231
|
+
* sessions/notes must find their immutable revisions. Anything deleted is
|
|
232
|
+
* not required to have one.
|
|
301
233
|
*/
|
|
302
|
-
declare function
|
|
234
|
+
declare function assertLogPinClosure(ops: readonly StoredSyncOp[]): void;
|
|
303
235
|
|
|
304
|
-
export {
|
|
236
|
+
export { BrowserTursoStorage, Database, type DatabaseFingerprint, MAX_BODY, SCHEMA_TABLE, SqlConnection, SqlStorage, type SqlStorageOptions, StorageError, StoredSyncOp, SyncMutation, type TursoSettings, assertDatabaseCopyMatches, assertLogPinClosure, assertPolicySnapshot, clearRows, countRows, databaseFingerprint, decodeRowJson, deleteRows, encodeRowJson, finalizeMigrationTarget, getRow, getRows, handleDomainQuery, initializeDomain, initializeStore, listRows, listRowsFromIndexMany, putRow, putRows, rebuildProjections, refreshDomain, storeDefinition, validateTursoUrl, verifyReadiness, wipeDomain, wipeRows };
|