moderator-toolbox-nxg-for-reddit / util/wiki/schemas/config/schema
util/wiki/schemas/config/schema¶
Functions¶
ensureStableIds()¶
ensureStableIds(
config):void
Defined in: extension/data/util/wiki/schemas/config/schema.ts:185
Ensures every removal reason and mod macro has a unique stable id,
assigning fresh ones where missing or duplicated. Runs on every normalize
(not just the v1->v2 migration) so entries created by older builds, 6.x
saves on the legacy page, or manual wiki edits pick up ids transparently.
Parameters¶
config¶
The config to update in-place.
Returns¶
void
generateConfigId()¶
generateConfigId():
string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:174
Generates a stable id for a config list entry (removal reason or macro):
eight base-36 characters, collision-checked by the caller via ensureStableIds.
Returns¶
string
isConfigValidVersion()¶
isConfigValidVersion(
subreddit,config):boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:46
Checks whether a parsed config object’s ver field is within the supported schema range.
Parameters¶
subreddit¶
string
The subreddit name, used only for error logging.
config¶
The parsed config object to validate.
Returns¶
boolean
True if the version is compatible, false otherwise.
migrateConfig()¶
migrateConfig(
config):void
Defined in: extension/data/util/wiki/schemas/config/schema.ts:310
Applies all pending schema migrations to a config object in ascending version order,
updating config.ver after each step. A no-op when the config is already current.
Parameters¶
config¶
The config to migrate, mutated in-place.
Returns¶
void
normalizeConfig()¶
normalizeConfig(
configInput):asserts configInput is ToolboxConfig
Defined in: extension/data/util/wiki/schemas/config/schema.ts:355
Normalizes a raw (possibly legacy) parsed toolbox config object in-place and asserts that it conforms to ToolboxConfig afterwards. Covers:
For classic (ver < 2) configs only, URL-decodes all string values - 6.1.25 and earlier stored them encoded. v2 configs store plain text, which must not be decoded again (a literal
%20in reason text has to survive).Coerces every array field (
modMacros) from the legacy empty-string representation to[]Ensures
removalReasonsis an object with areasonsarrayRemoves the
bantitlefield fromremovalReasons(written by 6.1.25, never used)Coerces
banMacrostonullwhen it is not a non-array objectApplies any pending schema migrations via migrateConfig
Converts limited-HTML fill-in fields in reason text to brace tokens - for every config, not just v1, so corrupted v2 pages self-heal (see upconvertReasonHtml)
Ensures every removal reason and macro has a stable
id
Parameters¶
configInput¶
unknown
Returns¶
asserts configInput is ToolboxConfig
Interfaces¶
ConfigState¶
Defined in: extension/data/util/wiki/schemas/config/schema.ts:440
Mutable state shared between the config overlay and all tab components for a single open session.
Properties¶
config¶
config:
ToolboxConfig
Defined in: extension/data/util/wiki/schemas/config/schema.ts:442
The live (possibly mutated) config object loaded from the wiki, or the default if no page exists.
postFlairTemplates¶
postFlairTemplates:
any
Defined in: extension/data/util/wiki/schemas/config/schema.ts:449
Cached post flair templates for the current subreddit, or null if not yet loaded.
subreddit¶
subreddit:
string|null|undefined
Defined in: extension/data/util/wiki/schemas/config/schema.ts:444
The subreddit whose config is currently loaded, or null/undefined when no overlay is open.
userFlairTemplates¶
userFlairTemplates:
any
Defined in: extension/data/util/wiki/schemas/config/schema.ts:452
Cached user flair templates for the current subreddit, or null if not yet loaded.
LegacyConfig¶
Defined in: extension/data/util/wiki/schemas/config/schema.ts:151
The classic v1 config shape as stored on the legacy toolbox wiki page that
Toolbox 6.x reads: a ToolboxConfig plus the domainTags and
usernoteColors arrays 6.x keeps inline (NXG moves both to dedicated pages).
This is the wire shape produced by encodeClassicConfig; raw pages read off
the wiki are coerced back to ToolboxConfig by normalizeConfig.
Extends¶
Properties¶
banMacros¶
banMacros:
BanMacros|null
Defined in: extension/data/util/wiki/schemas/config/schema.ts:68
Default ban form values.
null means the subreddit has not configured ban macros.
Inherited from¶
guardedActions?¶
optionalguardedActions?:string[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:121
Which moderation action types are guarded (captured as proposals) for this
subreddit’s trainees. A subreddit-wide set applying to every trainee.
Absent ⇒ every action is guarded (the original all-or-nothing behavior),
so existing configs are unaffected; an explicit empty array guards nothing.
Entries are ProposedActionType discriminants. NXG-only; stripped from
the legacy v1 mirror in encodeClassicConfig.
Inherited from¶
modMacros¶
modMacros:
MacroConfig[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:63
Inherited from¶
proposalRetentionDays?¶
optionalproposalRetentionDays?:number
Defined in: extension/data/util/wiki/schemas/config/schema.ts:127
How many days a resolved proposal is retained before pruning (unless its proposer acknowledges it sooner). Integer in [1, 365]. NXG-only. Defaults to 14.
Inherited from¶
removalReasons¶
removalReasons:
RemovalReasonsConfig
Defined in: extension/data/util/wiki/schemas/config/schema.ts:62
Inherited from¶
requireUsernoteLink?¶
optionalrequireUsernoteLink?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:95
When true, a usernote saved in this subreddit must include a link to the
content it concerns. Combined with each moderator’s personal
requireNoteLink setting per usernoteRequirementOption. Defaults
to false. NXG-only.
Inherited from¶
requireUsernoteText?¶
optionalrequireUsernoteText?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:88
When true, a usernote saved in this subreddit must have body text.
Combined with each moderator’s personal requireNoteText setting per
usernoteRequirementOption. Defaults to true. NXG-only.
Inherited from¶
requireUsernoteType?¶
optionalrequireUsernoteType?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:82
When true, a usernote saved in this subreddit must have a type/tag.
Combined with each moderator’s personal requireNoteType setting per
usernoteRequirementOption; see resolveUsernoteRequirements.
Defaults to false. NXG-only: stripped from the legacy v1 mirror.
Inherited from¶
showRetiredUsernoteShards?¶
optionalshowRetiredUsernoteShards?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:75
When true, retired (tombstoned) usernote shard pages left behind by shard
splits are exposed as raw-editor tabs in the config overlay, alongside the
active shards. Defaults to false (only active shards shown). NXG-only: this
is stripped from the legacy v1 mirror in encodeClassicConfig.
Inherited from¶
trainingMods?¶
optionaltrainingMods?:string[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:112
Usernames of moderators in training mode for this subreddit. Their in-scope
moderation actions are captured as proposals for review instead of being
performed. Compared case-insensitively. NXG-only; stripped from the legacy
v1 mirror in encodeClassicConfig. Defaults to none.
Inherited from¶
usernoteColors?¶
optionalusernoteColors?:LegacyUsernoteColor[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:153
usernoteRequirementOption?¶
optionalusernoteRequirementOption?:string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:105
How the three requireUsernote* flags apply to moderators. Uses the same
token set as removal reasons’ removalOption ('suggest'/'force'/
'leave'): 'suggest' and 'force' both make the subreddit flags a floor
(effective requirement is the more restrictive of the subreddit flag and the
moderator’s personal setting); anything else, including absent/'leave',
defers entirely to each moderator’s personal settings. Resolved by
resolveUsernoteRequirements. NXG-only.
Inherited from¶
ver¶
ver:
number
Defined in: extension/data/util/wiki/schemas/config/schema.ts:61
Schema version; used by migrateConfig to apply pending upgrades.
Inherited from¶
LegacyDomainTag¶
Defined in: extension/data/util/wiki/schemas/config/schema.ts:131
Minimal domain-tag shape stored inline on the legacy toolbox config page (6.x reads it from there).
Properties¶
color¶
color:
string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:133
name¶
name:
string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:132
note?¶
optionalnote?:string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:134
LegacyUsernoteColor¶
Defined in: extension/data/util/wiki/schemas/config/schema.ts:138
Minimal usernote-color shape stored inline on the legacy toolbox config page.
Properties¶
color¶
color:
string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:141
key¶
key:
string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:139
text¶
text:
string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:140
ToolboxConfig¶
Defined in: extension/data/util/wiki/schemas/config/schema.ts:59
The full shape of the toolbox subreddit config as stored in the wiki.
Extended by¶
Properties¶
banMacros¶
banMacros:
BanMacros|null
Defined in: extension/data/util/wiki/schemas/config/schema.ts:68
Default ban form values.
null means the subreddit has not configured ban macros.
guardedActions?¶
optionalguardedActions?:string[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:121
Which moderation action types are guarded (captured as proposals) for this
subreddit’s trainees. A subreddit-wide set applying to every trainee.
Absent ⇒ every action is guarded (the original all-or-nothing behavior),
so existing configs are unaffected; an explicit empty array guards nothing.
Entries are ProposedActionType discriminants. NXG-only; stripped from
the legacy v1 mirror in encodeClassicConfig.
modMacros¶
modMacros:
MacroConfig[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:63
proposalRetentionDays?¶
optionalproposalRetentionDays?:number
Defined in: extension/data/util/wiki/schemas/config/schema.ts:127
How many days a resolved proposal is retained before pruning (unless its proposer acknowledges it sooner). Integer in [1, 365]. NXG-only. Defaults to 14.
removalReasons¶
removalReasons:
RemovalReasonsConfig
Defined in: extension/data/util/wiki/schemas/config/schema.ts:62
requireUsernoteLink?¶
optionalrequireUsernoteLink?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:95
When true, a usernote saved in this subreddit must include a link to the
content it concerns. Combined with each moderator’s personal
requireNoteLink setting per usernoteRequirementOption. Defaults
to false. NXG-only.
requireUsernoteText?¶
optionalrequireUsernoteText?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:88
When true, a usernote saved in this subreddit must have body text.
Combined with each moderator’s personal requireNoteText setting per
usernoteRequirementOption. Defaults to true. NXG-only.
requireUsernoteType?¶
optionalrequireUsernoteType?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:82
When true, a usernote saved in this subreddit must have a type/tag.
Combined with each moderator’s personal requireNoteType setting per
usernoteRequirementOption; see resolveUsernoteRequirements.
Defaults to false. NXG-only: stripped from the legacy v1 mirror.
showRetiredUsernoteShards?¶
optionalshowRetiredUsernoteShards?:boolean
Defined in: extension/data/util/wiki/schemas/config/schema.ts:75
When true, retired (tombstoned) usernote shard pages left behind by shard
splits are exposed as raw-editor tabs in the config overlay, alongside the
active shards. Defaults to false (only active shards shown). NXG-only: this
is stripped from the legacy v1 mirror in encodeClassicConfig.
trainingMods?¶
optionaltrainingMods?:string[]
Defined in: extension/data/util/wiki/schemas/config/schema.ts:112
Usernames of moderators in training mode for this subreddit. Their in-scope
moderation actions are captured as proposals for review instead of being
performed. Compared case-insensitively. NXG-only; stripped from the legacy
v1 mirror in encodeClassicConfig. Defaults to none.
usernoteRequirementOption?¶
optionalusernoteRequirementOption?:string
Defined in: extension/data/util/wiki/schemas/config/schema.ts:105
How the three requireUsernote* flags apply to moderators. Uses the same
token set as removal reasons’ removalOption ('suggest'/'force'/
'leave'): 'suggest' and 'force' both make the subreddit flags a floor
(effective requirement is the more restrictive of the subreddit flag and the
moderator’s personal setting); anything else, including absent/'leave',
defers entirely to each moderator’s personal settings. Resolved by
resolveUsernoteRequirements. NXG-only.
ver¶
ver:
number
Defined in: extension/data/util/wiki/schemas/config/schema.ts:61
Schema version; used by migrateConfig to apply pending upgrades.
Variables¶
config¶
constconfig:ToolboxConfig
Defined in: extension/data/util/wiki/schemas/config/schema.ts:157
Default empty toolbox config used when a subreddit has no existing wiki page.
configMaxSchema¶
constconfigMaxSchema:2=2
Defined in: extension/data/util/wiki/schemas/config/schema.ts:38
The maximum config schema version this build can read.
configMigrations¶
constconfigMigrations:Record<number, (config) =>void> ={}
Defined in: extension/data/util/wiki/schemas/config/schema.ts:303
Registered per-version config migrations, keyed by the version they upgrade FROM.
Add an entry here whenever the schema bumps: configMigrations[1] = config => { ... }.
Each function mutates the config in-place and the caller bumps config.ver afterwards.
The v1 -> v2 upgrade has no entry: its string decode happens early in
normalizeConfig (URI decoding must precede the structural coercions) and
its HTML-to-token text conversion runs unconditionally there as
upconvertReasonHtml, because it doubles as healing for v2 pages.
configMinSchema¶
constconfigMinSchema:1=1
Defined in: extension/data/util/wiki/schemas/config/schema.ts:36
The minimum config schema version this build can read.
configSchema¶
constconfigSchema:2=2
Defined in: extension/data/util/wiki/schemas/config/schema.ts:34
The current toolbox config schema version written to new wiki pages.
v2 (the NXG schema, stored on the toolbox-nxg page):
Every string is stored as plain text - no
escape()/URI encoding anywhere.Removal reason text, header, and footer use brace tokens for interactive fill-in fields (
{input: ...},{textarea: ...}, and a{choice}block followed by a markdown list) instead of the limited-HTML form elements v1 allowed.Removal reasons and mod macros carry a stable
id, so future reordering and cross-references don’t depend on array position.
The classic v1 shape lives on at the legacy toolbox page for 6.x
compatibility; see encodeClassicConfig in ./codec for the down-convert.