moderator-toolbox-nxg-for-reddit / util/wiki/schemas/usernotes/sharded
util/wiki/schemas/usernotes/sharded¶
Functions¶
clearSessionShardState()¶
clearSessionShardState(
subreddit?):void
Defined in: extension/data/util/wiki/schemas/usernotes/sharded.ts:140
Clears the session shard state for a subreddit (or all subreddits). Called after migrations and compat toggles, which rewrite shard pages outside the save path.
Parameters¶
subreddit?¶
string
Returns¶
void
getSessionStorageInfo()¶
getSessionStorageInfo(
subreddit):ShardedStorageInfo|undefined
Defined in: extension/data/util/wiki/schemas/usernotes/sharded.ts:152
Returns storage statistics from the last sharded read or write this
session, or undefined when none happened.
Parameters¶
subreddit¶
string
Returns¶
ShardedStorageInfo | undefined
listRetiredUsernoteShardPages()¶
listRetiredUsernoteShardPages(
subreddit,activeSuffixes):Promise<string[]>
Defined in: extension/data/util/wiki/schemas/usernotes/sharded.ts:58
Lists the suffixes of retired usernote shard pages: pages under the NXG usernotes prefix that exist on the wiki but are no longer referenced by the manifest (tombstoned leftovers from shard splits). Used by the config overlay when the “only show active shards” setting is off.
Parameters¶
subreddit¶
string
The subreddit to list retired shard pages for.
activeSuffixes¶
string[]
The active shard suffixes from the manifest (see listUsernoteShardPages), excluded from the result.
Returns¶
Promise<string[]>
The retired suffixes, sorted; [] when the page listing fails.
listUsernoteShardPages()¶
listUsernoteShardPages(
subreddit):Promise<string[]>
Defined in: extension/data/util/wiki/schemas/usernotes/sharded.ts:88
Lists the shard page suffixes currently referenced by a subreddit’s
usernotes manifest, for UIs that expose the raw shard pages (the config
overlay’s advanced editor tabs). Prefers the session state from the last
sharded read/write; otherwise reads the manifest page. Returns [] when
the subreddit has no manifest (no NXG usernotes page, a legacy-fallback
layout, or unrecognized page content).
Parameters¶
subreddit¶
string
The subreddit to list shard pages for.
Returns¶
Promise<string[]>
readShardedUsernotes()¶
readShardedUsernotes(
subreddit):Promise<ShardedReadResult>
Defined in: extension/data/util/wiki/schemas/usernotes/sharded.ts:230
Reads the NXG usernotes page family for a subreddit: the manifest, then all shard pages in parallel, merged into one dataset. Records session state for dirty-shard detection and the manager UI.
Parameters¶
subreddit¶
string
Returns¶
Promise<ShardedReadResult>
Throws¶
When the manifest is corrupt or any shard is missing/unreadable.
writeShardedUsernotes()¶
writeShardedUsernotes(
subreddit,notes,reason):Promise<{written:string[]; }>
Defined in: extension/data/util/wiki/schemas/usernotes/sharded.ts:322
Writes a complete usernotes dataset to the sharded NXG layout. Only shards whose users changed are re-encoded and written; a shard whose envelope would exceed the soft size limit splits at the median user hash (its halves getting new page names) until everything fits. Shard pages are written sequentially, the manifest last and only when it changed.
Parameters¶
subreddit¶
string
The subreddit to write.
notes¶
The full dataset; notes.types should already be seeded.
reason¶
string
Wiki revision note for all page writes.
Returns¶
Promise<{ written: string[]; }>
The full paths of every page written, in write order.
Throws¶
On write failures, and when a single user’s notes exceed the hard per-page limit (a one-user shard cannot split).