moderator-toolbox-nxg-for-reddit / util/wiki/schemas/config/reconcile

util/wiki/schemas/config/reconcile

Functions

adoptLegacyConfigFields()

adoptLegacyConfigFields(nxg, legacy): ToolboxConfig

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:143

Returns a copy of the NXG config with the 6.x-owned fields replaced by the legacy config’s values. Stable ids on removal reasons and macros are preserved by content-matching against the NXG entries (the legacy mirror carries no ids); genuinely new entries get fresh ids. NXG-only keys (ver, layout metadata, anything outside the owned fields) are untouched.

Parameters

nxg

ToolboxConfig

The canonical normalized NXG config.

legacy

ToolboxConfig

The normalized legacy config to adopt 6.x edits from.

Returns

ToolboxConfig


legacyMirrorMatchesConfig()

legacyMirrorMatchesConfig(subreddit, nxgConfig): Promise<boolean | undefined>

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:246

Whether the legacy mirror on the wiki carries the same 6.x-owned content the given canonical config would produce - i.e. whether it holds no 6.x edit and is not lagging behind an NXG edit. Runs the same content comparison as the reconcile’s first guard, so the two can never disagree about what “in sync” means.

Only the 6.x-owned fields participate; domain tags and usernote colors are injected into the mirror from their own NXG pages and are dropped on read, so they cannot be compared here.

Parameters

subreddit

string

The subreddit whose mirror to inspect.

nxgConfig

ToolboxConfig

The canonical normalized NXG config.

Returns

Promise<boolean | undefined>

true/false, or undefined when the mirror could not be read.


legacyOwnedFieldsEqual()

legacyOwnedFieldsEqual(nxg, legacy): boolean

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:103

Returns true when the 6.x-owned fields of two normalized configs agree, ignoring stable ids (which the legacy round-trip strips) and reasons synced from Reddit (which the mirror never carries).

Parameters

nxg

ToolboxConfig

legacy

ToolboxConfig

Returns

boolean


mirrorViewOfConfig()

mirrorViewOfConfig(config): ToolboxConfig

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:191

Returns the config as the legacy mirror would carry it: down-converted to the classic v1 wire shape and read back through the same normalization every legacy read runs. Comparing this against the mirror on the wiki - rather than comparing the NXG config directly - makes an unedited mirror equal by construction, so a lossy v1 round trip can never be mistaken for a 6.x edit.

Domain tags and usernote colors are deliberately not passed to the down-convert: they live on their own NXG pages, and normalizeConfig deletes both fields on read, so they can never participate in the comparison.

Parameters

config

ToolboxConfig

The canonical normalized NXG config.

Returns

ToolboxConfig


reconcileConfigFromLegacy()

reconcileConfigFromLegacy(subreddit, nxgConfig, options?): Promise<{ changed: boolean; config: ToolboxConfig; outcome: ReconcileOutcome; }>

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:289

Reads the legacy toolbox page and folds any 6.x edits into the given NXG config in memory, subject to the content and recency guards described at the top of this file. The wiki is not written here - callers cache the merged result and the next save persists it. Missing pages, tombstones, and read/parse failures are all no-ops: a flaky mirror must never break config reads, nor overwrite canonical data.

Parameters

subreddit

string

The subreddit whose legacy page to check.

nxgConfig

ToolboxConfig

The canonical normalized NXG config.

options?

ReconcileConfigOptions = {}

Arbitration inputs (see ReconcileConfigOptions).

Returns

Promise<{ changed: boolean; config: ToolboxConfig; outcome: ReconcileOutcome; }>

The (possibly merged) config, whether anything was adopted, and why.

Interfaces

ReconcileConfigOptions

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:268

Options for reconcileConfigFromLegacy.

Properties

nxgRevisionTimestamp?

optional nxgRevisionTimestamp?: number

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:274

Unix timestamp (seconds) of the canonical page revision nxgConfig was read from, used to arbitrate against the mirror’s newest revision. Omitted when the caller could not determine it, which keeps the canonical config unchanged.

Type Aliases

ReconcileOutcome

ReconcileOutcome = "equal" | "adopted" | "keptCanonical" | "unarbitrable"

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:257

What a reconcile decided, for callers that log or surface the reason.

Variables

LEGACY_OWNED_FIELDS

const LEGACY_OWNED_FIELDS: readonly ["removalReasons", "modMacros", "banMacros"]

Defined in: extension/data/util/wiki/schemas/config/reconcile.ts:48

The config fields 6.x owns and may edit on the legacy page. Everything else (ver, the NXG metadata keys, stable ids) is NXG-only and never adopted from the mirror.