moderator-toolbox-nxg-for-reddit / util/wiki/schemas/config/codec
util/wiki/schemas/config/codec¶
Functions¶
encodeClassicConfig()¶
encodeClassicConfig(
config,domainTags?,usernoteColors?):LegacyConfig
Defined in: extension/data/util/wiki/schemas/config/codec.ts:52
Down-converts a v2 (NXG) config object to the classic v1 wire shape for the
legacy toolbox page. The input is not modified.
Domain tags and usernote colors live on their own NXG pages, so the caller passes them in; they are written back onto the legacy config as the minimal v1 shapes 6.x expects (NXG-only subfields are dropped). Omitting them - or passing empty arrays - leaves the corresponding field off the output.
Parameters¶
config¶
The normalized v2 config.
usernoteColors?¶
The subreddit’s usernote color types from the manifest.
Returns¶
A plain object safe to serialize onto the legacy page.
Variables¶
configCodec¶
constconfigCodec:WikiPageCodec<ToolboxConfig>
Defined in: extension/data/util/wiki/schemas/config/codec.ts:133
The WikiPageCodec for the canonical NXG config page, used by the versioned
transport so a config save can detect a concurrent edit (it conditions the write on
the revision the edit was based on). serialize is the only part exercised on the
write path; parse is lenient because config’s read path (getConfig) already
validates and rejects unsupported schema versions, and a conditional write’s 409 is
surfaced as a conflict without inspecting the parsed body.