@optimystic/db-p2p-storage-ns 1.15.0 → 1.16.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 +78 -20
- package/dist/src/db.d.ts +45 -7
- package/dist/src/db.d.ts.map +1 -1
- package/dist/src/db.js +71 -5
- package/dist/src/db.js.map +1 -1
- package/dist/src/identity.d.ts +3 -1
- package/dist/src/identity.d.ts.map +1 -1
- package/dist/src/identity.js +5 -1
- package/dist/src/identity.js.map +1 -1
- package/dist/src/index.d.ts +4 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ns-opener.d.ts.map +1 -1
- package/dist/src/ns-opener.js +16 -31
- package/dist/src/ns-opener.js.map +1 -1
- package/dist/src/sqlite-kv-store.d.ts +15 -1
- package/dist/src/sqlite-kv-store.d.ts.map +1 -1
- package/dist/src/sqlite-kv-store.js +38 -0
- package/dist/src/sqlite-kv-store.js.map +1 -1
- package/dist/src/sqlite-storage.d.ts +126 -45
- package/dist/src/sqlite-storage.d.ts.map +1 -1
- package/dist/src/sqlite-storage.js +246 -129
- package/dist/src/sqlite-storage.js.map +1 -1
- package/dist/src/sqlite-sync.d.ts +17 -0
- package/dist/src/sqlite-sync.d.ts.map +1 -0
- package/dist/src/sqlite-sync.js +21 -0
- package/dist/src/sqlite-sync.js.map +1 -0
- package/package.json +3 -3
- package/src/db.ts +96 -6
- package/src/identity.ts +5 -1
- package/src/index.ts +4 -2
- package/src/ns-opener.ts +20 -29
- package/src/sqlite-kv-store.ts +36 -2
- package/src/sqlite-storage.ts +291 -164
- package/src/sqlite-sync.ts +24 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StoreFailedError } from '@optimystic/db-p2p';
|
|
2
|
+
import { syncSqliteDb } from './sqlite-sync.js';
|
|
1
3
|
/**
|
|
2
4
|
* SQLite-backed `IKVStore` adapter for NativeScript peers.
|
|
3
5
|
*
|
|
@@ -9,11 +11,23 @@
|
|
|
9
11
|
*
|
|
10
12
|
* Only the `s_val` column is read or written here; the `b_val` column is
|
|
11
13
|
* reserved for binary identity material.
|
|
14
|
+
*
|
|
15
|
+
* Writes are autocommit statements: each is visible, and survives a crash of this process, once it
|
|
16
|
+
* resolves, and the write-ahead log keeps them in order. `flush()` makes them survive a power cut:
|
|
17
|
+
* when anything was written since the last flush it runs `syncSqliteDb`, one synced commit that
|
|
18
|
+
* syncs the shared log and with it every earlier write on the connection; otherwise it resolves at
|
|
19
|
+
* once. A failed sync latches the store, after which every write and flush throws
|
|
20
|
+
* `StoreFailedError` (rule 5 of the flush contract on `RawStoreDriver.flush`); reads keep working.
|
|
12
21
|
*/
|
|
13
22
|
export class SqliteKVStore {
|
|
23
|
+
db;
|
|
14
24
|
stmts;
|
|
15
25
|
prefix;
|
|
26
|
+
/** Set once a write has resolved, cleared by the flush that syncs it. */
|
|
27
|
+
dirty = false;
|
|
28
|
+
fault;
|
|
16
29
|
constructor(db, prefix = 'optimystic:txn:') {
|
|
30
|
+
this.db = db;
|
|
17
31
|
this.prefix = prefix;
|
|
18
32
|
this.stmts = {
|
|
19
33
|
get: db.prepare('SELECT s_val FROM kv WHERE key = ?'),
|
|
@@ -30,10 +44,14 @@ export class SqliteKVStore {
|
|
|
30
44
|
return typeof value === 'string' ? value : undefined;
|
|
31
45
|
}
|
|
32
46
|
async set(key, value) {
|
|
47
|
+
this.throwIfFailed();
|
|
33
48
|
await this.stmts.set.run(this.prefix + key, value);
|
|
49
|
+
this.dirty = true;
|
|
34
50
|
}
|
|
35
51
|
async delete(key) {
|
|
52
|
+
this.throwIfFailed();
|
|
36
53
|
await this.stmts.delete.run(this.prefix + key);
|
|
54
|
+
this.dirty = true;
|
|
37
55
|
}
|
|
38
56
|
async list(prefix) {
|
|
39
57
|
const fullPrefix = this.prefix + prefix;
|
|
@@ -46,5 +64,25 @@ export class SqliteKVStore {
|
|
|
46
64
|
const rows = await this.stmts.list.all(fullPrefix, upper);
|
|
47
65
|
return rows.map(row => row.key.slice(this.prefix.length));
|
|
48
66
|
}
|
|
67
|
+
/** `IKVStore.flush`: one synced commit when this store wrote since its last flush, otherwise nothing. */
|
|
68
|
+
async flush() {
|
|
69
|
+
this.throwIfFailed();
|
|
70
|
+
if (!this.dirty)
|
|
71
|
+
return;
|
|
72
|
+
// Cleared before the sync, so a write resolving while the sync runs is covered by the next
|
|
73
|
+
// flush whether or not this sync's commit happened to come after it.
|
|
74
|
+
this.dirty = false;
|
|
75
|
+
try {
|
|
76
|
+
await syncSqliteDb(this.db);
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
this.fault ??= { cause: err };
|
|
80
|
+
throw new StoreFailedError(this.fault.cause);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
throwIfFailed() {
|
|
84
|
+
if (this.fault)
|
|
85
|
+
throw new StoreFailedError(this.fault.cause);
|
|
86
|
+
}
|
|
49
87
|
}
|
|
50
88
|
//# sourceMappingURL=sqlite-kv-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-kv-store.js","sourceRoot":"","sources":["../../src/sqlite-kv-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sqlite-kv-store.js","sourceRoot":"","sources":["../../src/sqlite-kv-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAiB,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,OAAO,aAAa;IAYI;IAXZ,KAAK,CAKpB;IACe,MAAM,CAAS;IAChC,yEAAyE;IACjE,KAAK,GAAG,KAAK,CAAC;IACd,KAAK,CAAiC;IAE9C,YAA6B,EAAY,EAAE,SAAiB,iBAAiB;QAAhD,OAAE,GAAF,EAAE,CAAU;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAA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9E,0EAA0E;QAC1E,2EAA2E;QAC3E,4EAA4E;QAC5E,+EAA+E;QAC/E,MAAM,KAAK,GAAG,UAAU,GAAG,YAAY,CAAC;QACxC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAE,GAAG,CAAC,GAAc,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,yGAAyG;IACzG,KAAK,CAAC,KAAK;QACV,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO;QACxB,2FAA2F;QAC3F,qEAAqE;QACrE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC;YACJ,MAAM,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACd,IAAI,CAAC,KAAK,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;YAC9B,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;IACF,CAAC;IAEO,aAAa;QACpB,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;CACD"}
|
|
@@ -1,65 +1,146 @@
|
|
|
1
1
|
import type { ActionId, BlockId } from '@optimystic/db-core';
|
|
2
|
-
import { KvRawStorage, type
|
|
2
|
+
import { KvRawStorage, type BatchBackend, type BatchEntry, type CommittedBatch, type SetTimer, type SinkCommitOptions, type StoreDurability, type StoreIdentity, type StoreKey, type WriteGroupOptions } from '@optimystic/db-p2p';
|
|
3
3
|
import type { SqliteDb } from './db.js';
|
|
4
|
+
/** What a {@link SqliteBatchBackend} is built with: the test-only `setTimer` that arms its deadline timer. */
|
|
5
|
+
export interface SqliteBatchBackendOptions {
|
|
6
|
+
readonly setTimer?: SetTimer;
|
|
7
|
+
}
|
|
4
8
|
/**
|
|
5
|
-
* SQLite {@link
|
|
6
|
-
*
|
|
7
|
-
*
|
|
9
|
+
* SQLite {@link BatchBackend}: the six logical block-storage stores mapped to the six relational
|
|
10
|
+
* tables (`metadata`, `revisions`, `pending`, `transactions`, `proofs`, `materialized`) with their
|
|
11
|
+
* original columns and keys, every batch applied as ONE SQLite transaction. The reads are the
|
|
12
|
+
* former per-write driver's statements unchanged, so the on-disk format did not change with the
|
|
13
|
+
* move to batches.
|
|
14
|
+
*
|
|
15
|
+
* `KvRawStorage` owns all JSON serialization, so this backend only ever reads/writes `Uint8Array`
|
|
16
|
+
* values: the value columns are BLOB and SQLite binds a `Uint8Array` as a BLOB and returns it as a
|
|
17
|
+
* `Uint8Array`, so no codec lives here (a TEXT column would risk UTF-8 coercion corrupting non-ASCII
|
|
18
|
+
* JSON bytes).
|
|
19
|
+
*
|
|
20
|
+
* ### Why a committed batch survives a power cut, and in order
|
|
21
|
+
*
|
|
22
|
+
* `applySchema` (`db.ts`) opens every database in write-ahead-log (WAL) mode under
|
|
23
|
+
* `synchronous = NORMAL`. A commit appends the batch's frames to the one WAL file, each frame
|
|
24
|
+
* checksummed over the frames before it, and recovery stops at the first bad frame; before every
|
|
25
|
+
* checkpoint SQLite syncs the WAL, so the database file never holds later content ahead of earlier
|
|
26
|
+
* content. What a power cut leaves is therefore a prefix of the committed transactions, in commit
|
|
27
|
+
* order — rule 3 of the flush contract on `RawStoreDriver.flush` — and a batch is one transaction,
|
|
28
|
+
* so it survives whole or not at all. A commit under `synchronous = FULL`
|
|
29
|
+
* (`SqliteTransactionOptions.synced`) syncs the WAL at that commit, and the WAL being one
|
|
30
|
+
* append-only file, that sync covers every earlier commit on the database, the key-value store's
|
|
31
|
+
* and the identity helper's included, since all three share one connection. So the sync of a batch
|
|
32
|
+
* is one `FULL` commit — this batch's own when it must be synced at once, a later batch's, or the
|
|
33
|
+
* `durability_mark` bump the deadline timer commits — which is what `durability: 'power-loss'`
|
|
34
|
+
* states.
|
|
8
35
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
36
|
+
* ### How a commit decides
|
|
37
|
+
*
|
|
38
|
+
* The deadlines, the timer and the backpressure test are the rules of `SyncDeadlines` from
|
|
39
|
+
* `@optimystic/db-p2p`, shared with the file backend. `commit` takes the batch's deadline as it is
|
|
40
|
+
* called and decides whether the transaction is synced BEFORE taking the connection mutex, since
|
|
41
|
+
* the pragma is set as the transaction starts; the bookkeeping — `defer` of a deferred batch,
|
|
42
|
+
* `take` of the cover a synced one settles — runs INSIDE the transaction body, under the mutex, so
|
|
43
|
+
* it is ordered against every other commit and sync: a cover taken there is exactly the batches
|
|
44
|
+
* whose transactions committed earlier, every one of which this `FULL` commit syncs. A deadline
|
|
45
|
+
* that passes between the decision and the mutex only delays that commit's backpressure to the
|
|
46
|
+
* timer, which is due anyway.
|
|
47
|
+
*
|
|
48
|
+
* A read sees a batch as soon as its transaction commits, before it is synced, which `BatchBackend`
|
|
49
|
+
* allows; the overlay above serves the batch until it is durable. The handle is shared with
|
|
50
|
+
* `SqliteKVStore` and `loadOrCreateNSPeerKey`, so `close()` never closes it. Every write of a batch
|
|
51
|
+
* goes through `tx.prepare`, never a class-level statement, which would re-take the mutex the
|
|
52
|
+
* transaction holds and deadlock (see `SqliteDb.transaction`).
|
|
20
53
|
*/
|
|
21
|
-
export declare class
|
|
54
|
+
export declare class SqliteBatchBackend implements BatchBackend {
|
|
22
55
|
private readonly db;
|
|
23
|
-
|
|
56
|
+
readonly durability: StoreDurability;
|
|
24
57
|
private readonly identity;
|
|
25
|
-
|
|
58
|
+
/** One point read per store. Reads run off the mutex, so a class-level statement is right here. */
|
|
59
|
+
private readonly reads;
|
|
60
|
+
private readonly stmts;
|
|
61
|
+
/**
|
|
62
|
+
* Batches committed and not yet synced, in order, each with the `durable` the next sync settles;
|
|
63
|
+
* the earliest deadline among them, with a timer armed for it; and the `window-overrun` episode.
|
|
64
|
+
* A batch's payload is nothing: its transaction has already applied it.
|
|
65
|
+
*/
|
|
66
|
+
private readonly deadlines;
|
|
67
|
+
private fault;
|
|
68
|
+
constructor(db: SqliteDb, options?: SqliteBatchBackendOptions);
|
|
69
|
+
/** True once a transaction or a sync failed; every later `commit` and `sync` then throws {@link StoreFailedError}. */
|
|
70
|
+
get failed(): boolean;
|
|
26
71
|
storeIdentity(): StoreIdentity;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
putRevision(blockId: BlockId, rev: number, value: Uint8Array): Promise<void>;
|
|
31
|
-
rangeRevisions(blockId: BlockId, lo: number, hi: number, reverse: boolean): AsyncIterable<[number, Uint8Array]>;
|
|
32
|
-
getPending(blockId: BlockId, actionId: ActionId): Promise<Uint8Array | undefined>;
|
|
33
|
-
putPending(blockId: BlockId, actionId: ActionId, value: Uint8Array): Promise<void>;
|
|
34
|
-
deletePending(blockId: BlockId, actionId: ActionId): Promise<void>;
|
|
35
|
-
listPendingActionIds(blockId: BlockId): AsyncIterable<ActionId>;
|
|
36
|
-
getTransaction(blockId: BlockId, actionId: ActionId): Promise<Uint8Array | undefined>;
|
|
37
|
-
putTransaction(blockId: BlockId, actionId: ActionId, value: Uint8Array): Promise<void>;
|
|
38
|
-
getProof(blockId: BlockId, rev: number): Promise<Uint8Array | undefined>;
|
|
39
|
-
putProof(blockId: BlockId, rev: number, value: Uint8Array): Promise<void>;
|
|
40
|
-
getMaterialized(blockId: BlockId, actionId: ActionId): Promise<Uint8Array | undefined>;
|
|
41
|
-
putMaterialized(blockId: BlockId, actionId: ActionId, value: Uint8Array): Promise<void>;
|
|
42
|
-
deleteMaterialized(blockId: BlockId, actionId: ActionId): Promise<void>;
|
|
43
|
-
promote(blockId: BlockId, actionId: ActionId): Promise<void>;
|
|
72
|
+
get(key: StoreKey): Promise<Uint8Array | undefined>;
|
|
73
|
+
rangeRevisions(blockId: BlockId, lo: number, hi: number): Promise<[number, Uint8Array][]>;
|
|
74
|
+
listPendingActionIds(blockId: BlockId): Promise<ActionId[]>;
|
|
44
75
|
listBlockIds(): AsyncIterable<BlockId>;
|
|
45
76
|
approximateBytesUsed(): Promise<number>;
|
|
77
|
+
/**
|
|
78
|
+
* Apply the batch as one transaction and resolve with its `durable`. `WriteGroupSink.commit`'s
|
|
79
|
+
* contract: with `syncWithinMs` 0, or a deadline already passed (`SyncDeadlines.mustSyncNow`),
|
|
80
|
+
* the transaction commits under `synchronous = FULL`, which syncs this batch and every one held,
|
|
81
|
+
* and `durable` is already settled; otherwise it commits under `NORMAL` and `durable` settles at
|
|
82
|
+
* the next sync, which the timer makes by the earliest deadline held. A rejection has latched the
|
|
83
|
+
* backend.
|
|
84
|
+
*/
|
|
85
|
+
commit(entries: readonly BatchEntry[], { syncWithinMs }: SinkCommitOptions): Promise<CommittedBatch>;
|
|
86
|
+
/** Hasten: one synced commit covering every batch held when it runs; with nothing held, nothing is synced. `WriteGroupSink.sync`'s contract. */
|
|
87
|
+
sync(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* The handle is shared, so it is not closed here: only the deadline timer must not outlive the
|
|
90
|
+
* backend. `WriteGroupDriver.close` flushes strictly first, which took and settled everything
|
|
91
|
+
* held and so disarmed the timer; a caller that did not flush gets the same here. After a latch
|
|
92
|
+
* nothing is held, since the latch took and rejected it.
|
|
93
|
+
*/
|
|
94
|
+
close(): Promise<void>;
|
|
95
|
+
private commitDeferred;
|
|
96
|
+
private commitSynced;
|
|
97
|
+
/**
|
|
98
|
+
* The sync step: one synced transaction whose body runs `write`, if given, then takes the cover
|
|
99
|
+
* of every batch held — under the mutex, so the cover is exactly the batches whose transactions
|
|
100
|
+
* committed before this one — and, when there is a cover to settle and nothing of its own was
|
|
101
|
+
* written, bumps `durability_mark` so the commit has a frame to sync. The cover settles once the
|
|
102
|
+
* commit has resolved. A failure anywhere latches the backend and rejects every covered
|
|
103
|
+
* `durable`, so no flush waits for a sync the store will not make.
|
|
104
|
+
*
|
|
105
|
+
* `owedSince` is the moment the timer fired, when the timer's task runs this: `SyncDeadlines.take`
|
|
106
|
+
* counts the sync's lateness from it rather than from a deadline the timer's own slop missed.
|
|
107
|
+
*/
|
|
108
|
+
private syncHeld;
|
|
109
|
+
/** The timer fired: run the sync step. Its failure has latched the backend, so it is only logged here. */
|
|
110
|
+
private syncInBackground;
|
|
111
|
+
/**
|
|
112
|
+
* Every entry in order — a put as `INSERT OR REPLACE`, a delete as `DELETE` — each statement
|
|
113
|
+
* prepared once per batch against the open transaction. Returns how many were applied.
|
|
114
|
+
*/
|
|
115
|
+
private applyEntries;
|
|
116
|
+
private throwIfFailed;
|
|
117
|
+
/**
|
|
118
|
+
* Latch the backend failed on its first fault and reject every batch waiting for a sync that will
|
|
119
|
+
* now never be made, so no caller waits on a `durable` for ever. Returns the error to throw.
|
|
120
|
+
*/
|
|
121
|
+
private latch;
|
|
46
122
|
}
|
|
123
|
+
/** The write group's options (`WriteGroupOptions`); the test-only `setTimer` arms both the group's idle flush and the backend's deadline timer. */
|
|
124
|
+
export type SqliteRawStorageOptions = WriteGroupOptions;
|
|
47
125
|
/**
|
|
48
|
-
* SQLite-backed {@link IRawStorage} for NativeScript peers
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
126
|
+
* SQLite-backed {@link IRawStorage} for NativeScript peers: the shared {@link KvRawStorage} kernel
|
|
127
|
+
* over a {@link WriteGroupDriver} over a {@link SqliteBatchBackend}. Every write resolves into the
|
|
128
|
+
* driver's in-memory overlay; `flush()` hands the group to the backend as one batch, which applies
|
|
129
|
+
* it as one SQLite transaction, synced before the flush resolves or within the window the flush
|
|
130
|
+
* allows. The public name/constructor (`new SqliteRawStorage(db)`) is unchanged so existing imports
|
|
131
|
+
* keep resolving.
|
|
53
132
|
*
|
|
54
|
-
* `listBlockIds`/`getApproximateBytesUsed` are re-declared here as
|
|
55
|
-
* (the
|
|
56
|
-
*
|
|
57
|
-
* them.
|
|
133
|
+
* `listBlockIds`/`getApproximateBytesUsed`/`getStoreIdentity`/`close` are re-declared here as
|
|
134
|
+
* always-present (the backend always implements the first three, so the driver and kernel always
|
|
135
|
+
* wire them, and the driver always has a `close`) — the base declares them optional, but every NS
|
|
136
|
+
* consumer relies on them. `close()` flushes what is still held, syncs it, and disarms the timers;
|
|
137
|
+
* it does not close the shared handle, which the host closes afterwards.
|
|
58
138
|
*/
|
|
59
139
|
export declare class SqliteRawStorage extends KvRawStorage {
|
|
60
140
|
listBlockIds: () => AsyncIterable<BlockId>;
|
|
61
141
|
getApproximateBytesUsed: () => Promise<number>;
|
|
62
142
|
getStoreIdentity: () => StoreIdentity;
|
|
63
|
-
|
|
143
|
+
close: () => Promise<void>;
|
|
144
|
+
constructor(db: SqliteDb, options?: SqliteRawStorageOptions);
|
|
64
145
|
}
|
|
65
146
|
//# sourceMappingURL=sqlite-storage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-storage.d.ts","sourceRoot":"","sources":["../../src/sqlite-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,
|
|
1
|
+
{"version":3,"file":"sqlite-storage.d.ts","sourceRoot":"","sources":["../../src/sqlite-storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACN,YAAY,EAKZ,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,Q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