@pgxsinkit/client 0.1.32 → 0.1.36
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 +11 -0
- package/dist/convergence.d.ts +76 -0
- package/dist/convergence.d.ts.map +1 -0
- package/dist/debug.d.ts +34 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/index.d.ts +421 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7214 -2234
- package/dist/index.js.map +74 -44
- package/dist/lazy-guard.d.ts +58 -0
- package/dist/lazy-guard.d.ts.map +1 -0
- package/dist/local-store.d.ts +56 -0
- package/dist/local-store.d.ts.map +1 -0
- package/dist/local-tables.d.ts +707 -0
- package/dist/local-tables.d.ts.map +1 -0
- package/dist/mutation-state.d.ts +62 -0
- package/dist/mutation-state.d.ts.map +1 -0
- package/dist/mutation.d.ts +117 -4
- package/dist/mutation.d.ts.map +1 -1
- package/dist/schema.d.ts +49 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/shape-sync.d.ts +180 -0
- package/dist/shape-sync.d.ts.map +1 -0
- package/dist/sync/apply.d.ts +51 -0
- package/dist/sync/apply.d.ts.map +1 -0
- package/dist/sync/copy.d.ts +43 -0
- package/dist/sync/copy.d.ts.map +1 -0
- package/dist/sync/drizzle-executor.d.ts +5 -0
- package/dist/sync/drizzle-executor.d.ts.map +1 -0
- package/dist/sync/index.d.ts +32 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/metadata-tables.d.ts +131 -0
- package/dist/sync/metadata-tables.d.ts.map +1 -0
- package/dist/sync/nudge.d.ts +49 -0
- package/dist/sync/nudge.d.ts.map +1 -0
- package/dist/sync/shape-inbox.d.ts +215 -0
- package/dist/sync/shape-inbox.d.ts.map +1 -0
- package/dist/sync/subscription-state.d.ts +39 -0
- package/dist/sync/subscription-state.d.ts.map +1 -0
- package/dist/sync/tags.d.ts +130 -0
- package/dist/sync/tags.d.ts.map +1 -0
- package/dist/sync/types.d.ts +118 -0
- package/dist/sync/types.d.ts.map +1 -0
- package/dist/sync-auth.d.ts +53 -0
- package/dist/sync-auth.d.ts.map +1 -0
- package/dist/worker/attach-sync-client.d.ts +75 -0
- package/dist/worker/attach-sync-client.d.ts.map +1 -0
- package/dist/worker/define-sync-worker.d.ts +75 -0
- package/dist/worker/define-sync-worker.d.ts.map +1 -0
- package/dist/worker/live-diff.d.ts +44 -0
- package/dist/worker/live-diff.d.ts.map +1 -0
- package/dist/worker/protocol.d.ts +260 -0
- package/dist/worker/protocol.d.ts.map +1 -0
- package/dist/worker/token-cache.d.ts +26 -0
- package/dist/worker/token-cache.d.ts.map +1 -0
- package/oxlint-plugin.js +143 -0
- package/package.json +15 -7
- package/skills/core/SKILL.md +197 -0
- package/skills/operating/SKILL.md +243 -0
- package/src/convergence.ts +197 -0
- package/src/debug.ts +151 -0
- package/src/index.ts +1104 -44
- package/src/lazy-guard.ts +121 -0
- package/src/local-store.ts +193 -0
- package/src/local-tables.ts +546 -0
- package/src/mutation-state.ts +90 -0
- package/src/mutation.ts +1868 -562
- package/src/schema.ts +352 -27
- package/src/shape-sync.ts +477 -0
- package/src/sync/apply.ts +530 -0
- package/src/sync/copy.ts +206 -0
- package/src/sync/drizzle-executor.ts +48 -0
- package/src/sync/index.ts +1076 -0
- package/src/sync/metadata-tables.ts +67 -0
- package/src/sync/nudge.ts +110 -0
- package/src/sync/shape-inbox.ts +566 -0
- package/src/sync/subscription-state.ts +135 -0
- package/src/sync/tags.ts +365 -0
- package/src/sync/types.ts +132 -0
- package/src/sync-auth.ts +117 -0
- package/src/worker/attach-sync-client.ts +558 -0
- package/src/worker/define-sync-worker.ts +596 -0
- package/src/worker/live-diff.ts +140 -0
- package/src/worker/protocol.ts +325 -0
- package/src/worker/token-cache.ts +84 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { getTableConfig, getViewConfig } from "drizzle-orm/pg-core";
|
|
2
|
+
|
|
3
|
+
import type { SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Lazy-relation safety (ADR-0021).
|
|
7
|
+
*
|
|
8
|
+
* A `lazy` relation is held out of the eager boot and only subscribed on first reference. The hazard is
|
|
9
|
+
* a query reading it *before* it is hydrated — which silently returns empty/stale rows. This pure,
|
|
10
|
+
* React-free core detects which lazy relations a query reads by scanning its **compiled** SQL, so the
|
|
11
|
+
* caller can activate them (and hydrate-then-run) before the query executes.
|
|
12
|
+
*
|
|
13
|
+
* Why a single SQL scan is sufficient (and why there is no Proxy / builder-AST walk): Drizzle compiles
|
|
14
|
+
* a query to parameterised SQL — values are bound (`$1`, `$2`), never inlined — and emits every relation
|
|
15
|
+
* as a **quoted** identifier (`"name"`, or `"schema"."name"` when it carries a schema). So the compiled
|
|
16
|
+
* SQL is ground truth: a relation the query reads must appear there by name, and the only things in the
|
|
17
|
+
* text are quoted identifiers, keywords and `$n` placeholders. The index is built from the *same* Drizzle
|
|
18
|
+
* objects that emit the SQL (`getTableConfig`/`getViewConfig`), so a token matches emission by
|
|
19
|
+
* construction — schema and all. See "Known limitations" in ADR-0021 for the residual edges.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/** Static index of a registry's lazy relations and the exact quoted tokens their reads compile to. */
|
|
23
|
+
export interface LazyGuardIndex {
|
|
24
|
+
/** Registry keys whose subscription timing is `lazy`. */
|
|
25
|
+
readonly lazyKeys: ReadonlySet<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Per lazy key, the exact quoted reference token(s) the compiled SQL emits when reading it: the synced
|
|
28
|
+
* table (and, for readwrite, its read-model view) as `"name"` or `"schema"."name"`. Schema-qualified
|
|
29
|
+
* when the Drizzle object carries a schema — which makes the token collision-proof against bare
|
|
30
|
+
* aliases/CTEs.
|
|
31
|
+
*/
|
|
32
|
+
readonly lazyTokens: ReadonlyMap<string, readonly string[]>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Build the {@link LazyGuardIndex} for a registry. Cheap and pure — cache it per client. */
|
|
36
|
+
export function buildLazyGuardIndex(registry: SyncTableRegistry): LazyGuardIndex {
|
|
37
|
+
const lazyKeys = new Set<string>();
|
|
38
|
+
const lazyTokens = new Map<string, readonly string[]>();
|
|
39
|
+
|
|
40
|
+
for (const [key, entry] of Object.entries(registry)) {
|
|
41
|
+
if (entry.subscription !== "lazy") continue;
|
|
42
|
+
lazyKeys.add(key);
|
|
43
|
+
|
|
44
|
+
const tokens: string[] = [];
|
|
45
|
+
const table = getTableConfig(entry.table);
|
|
46
|
+
tokens.push(quotedRef(table.name, table.schema));
|
|
47
|
+
if (entry.view != null) {
|
|
48
|
+
const view = getViewConfig(entry.view);
|
|
49
|
+
tokens.push(quotedRef(view.name, view.schema));
|
|
50
|
+
}
|
|
51
|
+
lazyTokens.set(key, tokens);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return { lazyKeys, lazyTokens };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The quoted identifier Drizzle emits for a relation: `"schema"."name"` when schema-qualified, else `"name"`. */
|
|
58
|
+
function quotedRef(name: string, schema: string | undefined): string {
|
|
59
|
+
return schema != null && schema.length > 0 ? `"${schema}"."${name}"` : `"${name}"`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* The compiled-SQL scan: the lazy registry keys whose quoted reference token appears in `sql`. Because
|
|
64
|
+
* the token is fully quoted it is self-delimiting (`"a"` cannot match inside `"ab"`), so a substring test
|
|
65
|
+
* is exact. A *bare* token sitting in alias position (`… as "name"`, which Drizzle emits for `.as("name")`)
|
|
66
|
+
* is excluded — the one realistic collision for a schema-less relation; a schema-qualified token cannot be
|
|
67
|
+
* aliased and so needs no such guard.
|
|
68
|
+
*/
|
|
69
|
+
export function findReferencedLazyKeysInSql(sql: string, index: LazyGuardIndex): Set<string> {
|
|
70
|
+
const found = new Set<string>();
|
|
71
|
+
for (const [key, tokens] of index.lazyTokens) {
|
|
72
|
+
if (tokens.some((token) => sqlReferencesToken(sql, token))) found.add(key);
|
|
73
|
+
}
|
|
74
|
+
return found;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function sqlReferencesToken(sql: string, token: string): boolean {
|
|
78
|
+
for (let from = 0; ; ) {
|
|
79
|
+
const at = sql.indexOf(token, from);
|
|
80
|
+
if (at === -1) return false;
|
|
81
|
+
// Exclude an alias occurrence: `<expr> as "token"`. Only a bare token can be an alias, so this never
|
|
82
|
+
// rejects a real (schema-qualified or FROM/JOIN) reference. Window comfortably covers Drizzle's ` as `.
|
|
83
|
+
if (!/\bas\s+$/i.test(sql.slice(Math.max(0, at - 16), at))) return true;
|
|
84
|
+
from = at + token.length;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The activation backstop (ADR-0021): throw if a query references a lazy relation that is still not
|
|
90
|
+
* active. Called *after* the referenced lazy relations have been activated, so in the normal path every
|
|
91
|
+
* scanned relation is now active and this passes. It fires only when activation could not make a
|
|
92
|
+
* referenced relation active (a start that failed, or a lazy relation with no consistency group) —
|
|
93
|
+
* converting a would-be silent empty/stale read into a loud error.
|
|
94
|
+
*/
|
|
95
|
+
export function assertLazyRefsActivated(args: {
|
|
96
|
+
sql: string;
|
|
97
|
+
index: LazyGuardIndex;
|
|
98
|
+
isActive: (key: string) => boolean;
|
|
99
|
+
}): void {
|
|
100
|
+
const referenced = findReferencedLazyKeysInSql(args.sql, args.index);
|
|
101
|
+
const missing = [...referenced].filter((key) => !args.isActive(key));
|
|
102
|
+
if (missing.length > 0) throw new LazyRelationNotActivatedError(missing);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Thrown by the backstop ({@link assertLazyRefsActivated}) when a referenced lazy relation could not be activated. */
|
|
106
|
+
export class LazyRelationNotActivatedError extends Error {
|
|
107
|
+
/** The lazy registry keys that were referenced but could not be activated. */
|
|
108
|
+
readonly relations: readonly string[];
|
|
109
|
+
|
|
110
|
+
constructor(relations: readonly string[]) {
|
|
111
|
+
const quoted = relations.map((r) => `"${r}"`).join(", ");
|
|
112
|
+
super(
|
|
113
|
+
`[pgxsinkit] query references lazy-synced relation(s) ${quoted} that could not be activated (ADR-0021), ` +
|
|
114
|
+
`so it would read empty/stale data. This is usually a failed initial sync or a lazy relation with no ` +
|
|
115
|
+
`consistency group. Activate it explicitly — client.ensureSynced([${quoted}]) — or check the sync ` +
|
|
116
|
+
`status. See "Known limitations" in ADR-0021.`,
|
|
117
|
+
);
|
|
118
|
+
this.name = "LazyRelationNotActivatedError";
|
|
119
|
+
this.relations = relations;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { eq, like } from "drizzle-orm";
|
|
2
|
+
import { drizzle } from "drizzle-orm/pglite";
|
|
3
|
+
|
|
4
|
+
import { type MutationDiagnostics, type SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
5
|
+
|
|
6
|
+
import { getLocalMetaTable } from "./local-tables";
|
|
7
|
+
import type { MutationDb } from "./mutation";
|
|
8
|
+
import { buildWipeLocalStoreSql, generateLocalSchemaSql, REGISTRY_FINGERPRINT_KEY } from "./schema";
|
|
9
|
+
|
|
10
|
+
// Statements are AUTHORED as Drizzle builders over the meta-table object (rename-safe, typed,
|
|
11
|
+
// schema-qualification handled by the table object) and rendered to text+params here, because they
|
|
12
|
+
// EXECUTE through the caller's raw `MutationDb` seam — the one connection the mutation runtime and
|
|
13
|
+
// its tests own (and mock).
|
|
14
|
+
const metaQueryBuilder = drizzle.mock();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The fingerprint-keyed local store (ADR-0006). The registry fingerprint the local PGlite
|
|
18
|
+
* database was provisioned under is recorded in the local-meta table; comparing it to the
|
|
19
|
+
* current fingerprint on boot is how a registry change is *detected* (rather than a
|
|
20
|
+
* hand-bumped `idb://…-vN` suffix), which drives the drain-then-drop read-cache rebuild.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** A boot-time registry-version reconciliation outcome (ADR-0006 drain-then-drop). */
|
|
24
|
+
export interface LocalStoreVersionEvent {
|
|
25
|
+
status: "rebuilt" | "deferred";
|
|
26
|
+
previousFingerprint: string;
|
|
27
|
+
nextFingerprint: string;
|
|
28
|
+
/** Mutations still owed to the server (pending + sending + failed + quarantined). */
|
|
29
|
+
owedMutations: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The minimal mutation-runtime surface the version reconciliation needs. */
|
|
33
|
+
interface VersionReconcileRuntime {
|
|
34
|
+
registryVersion: string;
|
|
35
|
+
readMutationStats: () => Promise<MutationDiagnostics>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The registry fingerprint the local store was last provisioned under, or null if unstamped. */
|
|
39
|
+
export async function readStoredRegistryFingerprint(
|
|
40
|
+
db: MutationDb,
|
|
41
|
+
registry: SyncTableRegistry,
|
|
42
|
+
): Promise<string | null> {
|
|
43
|
+
const meta = getLocalMetaTable(registry);
|
|
44
|
+
const query = metaQueryBuilder
|
|
45
|
+
.select({ value: meta.value })
|
|
46
|
+
.from(meta)
|
|
47
|
+
.where(eq(meta.key, REGISTRY_FINGERPRINT_KEY))
|
|
48
|
+
.limit(1)
|
|
49
|
+
.toSQL();
|
|
50
|
+
const result = await db.query<{ value: string }>(query.sql, query.params as unknown[]);
|
|
51
|
+
|
|
52
|
+
return result.rows[0]?.value ?? null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Meta-key prefix for a persisted `lazy + persistent` group activation (ADR-0021 §2). */
|
|
56
|
+
const LAZY_ACTIVATION_PREFIX = "lazy_active:";
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The consistency-group keys of `lazy + persistent` groups that were activated on a previous boot
|
|
60
|
+
* (ADR-0021 §2). On boot these are promoted into the eager subscription set, so a once-activated durable
|
|
61
|
+
* lazy group resumes permanently with no per-session re-evaluation. (`ephemeral` activation is never
|
|
62
|
+
* persisted, so it never appears here.)
|
|
63
|
+
*/
|
|
64
|
+
export async function readActivatedLazyGroups(db: MutationDb, registry: SyncTableRegistry): Promise<Set<string>> {
|
|
65
|
+
const meta = getLocalMetaTable(registry);
|
|
66
|
+
const query = metaQueryBuilder
|
|
67
|
+
.select({ key: meta.key })
|
|
68
|
+
.from(meta)
|
|
69
|
+
.where(like(meta.key, `${LAZY_ACTIVATION_PREFIX}%`))
|
|
70
|
+
.toSQL();
|
|
71
|
+
const result = await db.query<{ key: string }>(query.sql, query.params as unknown[]);
|
|
72
|
+
return new Set(result.rows.map((row) => row.key.slice(LAZY_ACTIVATION_PREFIX.length)));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Upsert one meta key — the shared write shape for activations and the fingerprint stamp. */
|
|
76
|
+
async function upsertMetaValue(db: MutationDb, registry: SyncTableRegistry, key: string, value: string): Promise<void> {
|
|
77
|
+
const meta = getLocalMetaTable(registry);
|
|
78
|
+
const query = metaQueryBuilder
|
|
79
|
+
.insert(meta)
|
|
80
|
+
.values({ key, value })
|
|
81
|
+
.onConflictDoUpdate({ target: meta.key, set: { value } })
|
|
82
|
+
.toSQL();
|
|
83
|
+
await db.query(query.sql, query.params as unknown[]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Persist a `lazy + persistent` group's activation, so the next boot promotes it to eager (ADR-0021 §2). */
|
|
87
|
+
export async function writeLazyGroupActivation(
|
|
88
|
+
db: MutationDb,
|
|
89
|
+
registry: SyncTableRegistry,
|
|
90
|
+
groupKey: string,
|
|
91
|
+
): Promise<void> {
|
|
92
|
+
await upsertMetaValue(db, registry, `${LAZY_ACTIVATION_PREFIX}${groupKey}`, "1");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Clear a persisted lazy activation — an explicit `desync` reverts the group to dormant next boot (ADR-0021 §2). */
|
|
96
|
+
export async function clearLazyGroupActivation(
|
|
97
|
+
db: MutationDb,
|
|
98
|
+
registry: SyncTableRegistry,
|
|
99
|
+
groupKey: string,
|
|
100
|
+
): Promise<void> {
|
|
101
|
+
const meta = getLocalMetaTable(registry);
|
|
102
|
+
const query = metaQueryBuilder
|
|
103
|
+
.delete(meta)
|
|
104
|
+
.where(eq(meta.key, `${LAZY_ACTIVATION_PREFIX}${groupKey}`))
|
|
105
|
+
.toSQL();
|
|
106
|
+
await db.query(query.sql, query.params as unknown[]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Stamp the local store with the fingerprint it is now provisioned under. */
|
|
110
|
+
export async function writeStoredRegistryFingerprint(
|
|
111
|
+
db: MutationDb,
|
|
112
|
+
registry: SyncTableRegistry,
|
|
113
|
+
fingerprint: string,
|
|
114
|
+
): Promise<void> {
|
|
115
|
+
await upsertMetaValue(db, registry, REGISTRY_FINGERPRINT_KEY, fingerprint);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Reconcile the local store against the current registry fingerprint (ADR-0006). A fresh
|
|
120
|
+
* (unstamped) store is stamped; an unchanged fingerprint is a no-op. On a change, the read
|
|
121
|
+
* cache is dropped and rebuilt at the new shape **only when nothing is owed locally** —
|
|
122
|
+
* otherwise the rebuild is deferred (and retried on a later boot) so un-flushed/quarantined
|
|
123
|
+
* writes are never silently dropped. The drain happens across sessions: pending writes flush
|
|
124
|
+
* and reconcile during normal use, and the rebuild completes once the journal is clear.
|
|
125
|
+
*
|
|
126
|
+
* An unstamped store is always treated as brand-new. There is no pre-fingerprint-store path:
|
|
127
|
+
* the fingerprint mechanism shipped before launch, so every store in existence was
|
|
128
|
+
* provisioned with it (and a stamped store's journal therefore always has `registry_version`).
|
|
129
|
+
*/
|
|
130
|
+
export async function reconcileLocalStoreVersion<TRegistry extends SyncTableRegistry>(args: {
|
|
131
|
+
db: MutationDb;
|
|
132
|
+
registry: TRegistry;
|
|
133
|
+
runtime: VersionReconcileRuntime;
|
|
134
|
+
onSchemaChange?: (event: LocalStoreVersionEvent) => void | Promise<void>;
|
|
135
|
+
}): Promise<LocalStoreVersionEvent | null> {
|
|
136
|
+
const { db, registry, runtime } = args;
|
|
137
|
+
const stored = await readStoredRegistryFingerprint(db, registry);
|
|
138
|
+
const current = runtime.registryVersion;
|
|
139
|
+
|
|
140
|
+
if (stored === current) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (stored === null) {
|
|
145
|
+
await writeStoredRegistryFingerprint(db, registry, current);
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return rebuildReadCacheOrDefer(args, stored);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The drain-then-drop core (ADR-0006): rebuild the read cache at the current shape when
|
|
154
|
+
* nothing is owed locally, otherwise defer so un-flushed/quarantined writes are never
|
|
155
|
+
* dropped (the drain completes on a later boot).
|
|
156
|
+
*/
|
|
157
|
+
async function rebuildReadCacheOrDefer<TRegistry extends SyncTableRegistry>(
|
|
158
|
+
args: {
|
|
159
|
+
db: MutationDb;
|
|
160
|
+
registry: TRegistry;
|
|
161
|
+
runtime: VersionReconcileRuntime;
|
|
162
|
+
onSchemaChange?: (event: LocalStoreVersionEvent) => void | Promise<void>;
|
|
163
|
+
},
|
|
164
|
+
previousFingerprint: string,
|
|
165
|
+
): Promise<LocalStoreVersionEvent> {
|
|
166
|
+
const { db, registry, runtime, onSchemaChange } = args;
|
|
167
|
+
const current = runtime.registryVersion;
|
|
168
|
+
const stats = await runtime.readMutationStats();
|
|
169
|
+
const owedMutations = stats.pendingCount + stats.sendingCount + stats.failedCount + stats.quarantinedCount;
|
|
170
|
+
|
|
171
|
+
if (owedMutations > 0) {
|
|
172
|
+
const event: LocalStoreVersionEvent = {
|
|
173
|
+
status: "deferred",
|
|
174
|
+
previousFingerprint,
|
|
175
|
+
nextFingerprint: current,
|
|
176
|
+
owedMutations,
|
|
177
|
+
};
|
|
178
|
+
await onSchemaChange?.(event);
|
|
179
|
+
return event;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
await db.exec(buildWipeLocalStoreSql(registry));
|
|
183
|
+
await db.exec(generateLocalSchemaSql(registry));
|
|
184
|
+
await writeStoredRegistryFingerprint(db, registry, current);
|
|
185
|
+
const event: LocalStoreVersionEvent = {
|
|
186
|
+
status: "rebuilt",
|
|
187
|
+
previousFingerprint,
|
|
188
|
+
nextFingerprint: current,
|
|
189
|
+
owedMutations: 0,
|
|
190
|
+
};
|
|
191
|
+
await onSchemaChange?.(event);
|
|
192
|
+
return event;
|
|
193
|
+
}
|