moderator-toolbox-nxg-for-reddit / util/wiki/wikiMigration

util/wiki/wikiMigration

Functions

bootstrapFreshSub()

bootstrapFreshSub(subreddit): Promise<WikiMigrationResult>

Defined in: extension/data/util/wiki/wikiMigration.ts:457

Creates the toolbox-nxg config page for a subreddit with no toolbox data at all: the default config plus compatibilityWrites: false. The usernotes manifest and notes index stay lazily created on their first save - one wiki edit is all a fresh sub costs. Mod-gated like migrateSubredditToNxg.

Recursion invariant: runs from inside doResolveWikiLayout while the in-flight resolution promise is held; nothing here may call resolveWikiLayout or helpers that do.

Parameters

subreddit

string

The subreddit to bootstrap.

Returns

Promise<WikiMigrationResult>

A per-page outcome report; a non-empty failed list means nothing was created and the layout cache was left untouched.


copyNxgToLegacy()

copyNxgToLegacy(subreddit): Promise<WikiMigrationResult>

Defined in: extension/data/util/wiki/wikiMigration.ts:500

Reverse copy: NXG pages -> legacy pages. Used when 6.x compatibility is turned back on after a period of NXG-only writes, so 6.x mods resume with current data. The NXG pages are never modified.

Parameters

subreddit

string

The subreddit to copy.

Returns

Promise<WikiMigrationResult>

A per-page outcome report; a non-empty failed list means the run aborted.


migrateSubredditToNxg()

migrateSubredditToNxg(subreddit, compatibilityWrites?): Promise<WikiMigrationResult>

Defined in: extension/data/util/wiki/wikiMigration.ts:241

Migrates a subreddit’s toolbox data from the legacy paths to toolbox-nxg/*. The legacy pages are never modified, so this is also safe to re-run at any time to fold in 6.x edits or repair deleted NXG pages. Idempotent: existing NXG pages are reconcile-merged (config, usernotes) or overwritten from legacy data.

Recursion invariant: this runs from inside doResolveWikiLayout while the subreddit’s in-flight resolution promise is held. Nothing in this call graph may call resolveWikiLayout, getWikiReadPath, getConfig, or any other layout-resolving helper for the same subreddit - it would await its own resolution and deadlock. All wiki access here uses explicit OLD_/NEW_WIKI_PATHS.

Parameters

subreddit

string

The subreddit to migrate.

compatibilityWrites?

The compat flag to embed in the NXG config and record in the layout cache. Defaults to true (6.x compat on).

compatibilityWrites?

boolean = true

Returns

Promise<WikiMigrationResult>

A per-page outcome report; a non-empty failed list means the run aborted and the layout cache was left untouched.


setCompatibilityMode()

setCompatibilityMode(subreddit, enabled): Promise<WikiMigrationResult>

Defined in: extension/data/util/wiki/wikiMigration.ts:652

Toggles 6.x compatibility mode for a subreddit. The NXG pages are always canonical; the flag only controls whether the legacy mirror is maintained. Sequencing keeps both sides intact:

  • Turning on: copy NXG -> legacy first (so 6.x mods resume with current data, and any tombstone is replaced with a real config), then record the flag.

  • Turning off: run one final reconcile-merge from the legacy pages (folding in any outstanding 6.x edits before the mirror is abandoned), then tombstone the legacy toolbox page so 6.x users see the sub has moved.

Clears the toolbox cache on success so all reads re-resolve.

Parameters

subreddit

string

The subreddit to toggle.

enabled

boolean

The new compatibility state.

Returns

Promise<WikiMigrationResult>

The outcome report of the underlying copy; a non-empty failed list means nothing was toggled.


summarizeMigrationResult()

summarizeMigrationResult(result): string

Defined in: extension/data/util/wiki/wikiMigration.ts:65

Turns a migration result into a short human-readable summary line for display in settings UIs.

Parameters

result

WikiMigrationResult

The migration result to summarize.

Returns

string

Type Aliases

WikiMigrationResult

WikiMigrationResult = object

Defined in: extension/data/util/wiki/wikiMigration.ts:51

Per-page outcome report for a migration or reverse-copy run.

Properties

copied

copied: string[]

Defined in: extension/data/util/wiki/wikiMigration.ts:53

Pages successfully written to the destination side.

failed

failed: object[]

Defined in: extension/data/util/wiki/wikiMigration.ts:57

Pages that failed, with the reason. A non-empty list means the run aborted.

page

page: string

reason

reason: string

skipped

skipped: string[]

Defined in: extension/data/util/wiki/wikiMigration.ts:55

Source pages skipped because they don’t exist (no_page).