moderator-toolbox-nxg-for-reddit / util/wiki/schemas/usernotes/reconcile
util/wiki/schemas/usernotes/reconcile¶
Functions¶
applyLegacyDiff()¶
applyLegacyDiff(
users,ops):boolean
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:104
Applies 6.x edit ops to a user map, mutating it in place: archives the
matching active notes under the [6.x] sentinel and merges in the added
notes with fresh indexes. Notes the dataset no longer contains (or already
has) are skipped, so applying ops to a dataset that has since changed is
safe.
Parameters¶
users¶
Record<string, UsernotesUser>
ops¶
Returns¶
boolean
Whether anything changed.
computeLegacyDiff()¶
computeLegacyDiff(
storedUsers,legacyUsers):LegacyDiffOps
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:58
Computes the 6.x edit ops by diffing the legacy page’s users against the NXG users as stored. Pure; mutates nothing.
Parameters¶
storedUsers¶
Record<string, UsernotesUser>
The canonical users as currently stored in the shards.
legacyUsers¶
Record<string, UsernotesUser>
The users decoded from the legacy usernotes page.
Returns¶
diffLegacyNotes()¶
diffLegacyNotes(
nxgUsers,legacyUsers):object
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:157
Folds 6.x edits from the legacy page’s user map into a copy of the canonical NXG user map. Pure.
Parameters¶
nxgUsers¶
Record<string, UsernotesUser>
legacyUsers¶
Record<string, UsernotesUser>
Returns¶
object
The reconciled user map (a fresh object; inputs are not mutated) and whether anything changed.
changed¶
changed:
boolean
users¶
users:
Record<string,UsernotesUser>
readLegacyUsersForDiff()¶
readLegacyUsersForDiff(
subreddit):Promise<Record<string,UsernotesUser> |null>
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:172
Reads and decodes the legacy usernotes page.
Parameters¶
subreddit¶
string
Returns¶
Promise<Record<string, UsernotesUser> | null>
The decoded users, or null when the page does not exist.
Throws¶
When the page exists but cannot be read or decoded - callers abort rather than risk clobbering unseen 6.x edits.
reconcileFromLegacy()¶
reconcileFromLegacy(
subreddit,nxgNotes):Promise<{changed:boolean;notes:UserNotesData; }>
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:204
Reads the legacy usernotes page and folds any 6.x edits into a copy of
the given canonical dataset.
Parameters¶
subreddit¶
string
The subreddit to reconcile.
nxgNotes¶
The canonical dataset as read from the NXG shards.
Returns¶
Promise<{ changed: boolean; notes: UserNotesData; }>
The reconciled dataset (the same object when nothing changed) and whether anything changed. A missing legacy page is a no-op.
Throws¶
When the legacy page exists but cannot be read or decoded.
Interfaces¶
LegacyDiffOps¶
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:45
The 6.x edits found by diffing the legacy page against the stored NXG state.
Properties¶
adds¶
adds:
object[]
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:47
Notes that exist only on the legacy page (6.x-created), per storage key.
note¶
note:
UserNoteEntry
username¶
username:
string
archivedKeys¶
archivedKeys:
Set<string>
Defined in: extension/data/util/wiki/schemas/usernotes/reconcile.ts:49
Identity keys of active NXG notes missing from the legacy mirror (6.x-deleted).