Class: ParsoidConfig

config/ParsoidConfig~ParsoidConfig(localSettings, options)

new ParsoidConfig(localSettings, options)

Global Parsoid configuration object.

Global Parsoid configuration object. Will hold things like debug/trace options, mw api map, and local settings like fetchTemplates.

Parameters:
Name Type Description
localSettings Object

The localSettings object, probably from a localsettings.js file.

Properties
Name Type Description
setup function

The local settings setup function, which sets up our local configuration.

Properties
Name Type Description
opts ParsoidConfig

The setup function is passed the object under construction so it can extend the config directly.

options Object

Any options we want to set over the defaults. See the class properties for more information.

Source:

Members

addHTMLTemplateParameters

...
Properties:
Name Type Description
addHTMLTemplateParameters boolean

When processing template parameters, parse them to HTML and add it to the template parameters data.

Source:

allowCORS

...
Properties:
Name Type Description
allowCORS string

Permissive CORS headers as Parsoid is full idempotent currently

Source:

batchConcurrency

The maximum number of concurrent requests that the API request batcher will allow to be active at any given time.

The maximum number of concurrent requests that the API request batcher will allow to be active at any given time. Before this limit is reached, requests will be dispatched more aggressively, giving smaller batches on average. After the limit is reached, batches will be stored in a queue with APIBatchSize items in each batch.

Source:

batchSize

The batch size for parse/preprocess requests

.

The batch size for parse/preprocess requests

Source:

debug

...
Properties:
Name Type Description
debug boolean

Whether to print debugging information.

Source:

debugFlags

...
Properties:
Name Type Description
debugFlags Set

Flags that tell us which debugging information to print.

Source:

defaultAPIProxyURI

The default api proxy, overridden by apiConf.proxy entries.

The default api proxy, overridden by apiConf.proxy entries.

Source:

defaultWiki

...
Properties:
Name Type Description
defaultWiki string

The wiki we should use for template, page, and configuration requests. We set this as a default because a configuration file (e.g. the API service's config.yaml) might set this, but we will still use the appropriate wiki when requests come in for a different prefix.

Source:

devAPI

...
Properties:
Name Type Description
Expose boolean

development routes in the HTTP API.

Source:

dumpFlags

...
Properties:
Name Type Description
dumpFlags Set

Flags that tell us what state to dump.

Source:

dynamicConfig

...
Properties:
Name Type Description
Allow function | null

dynamic configuration of unknown domains.

See T100841.

Source:

expandExtensions

...
Properties:
Name Type Description
expandExtensions boolean

Whether we should request extension tag expansions from a wiki.

Source:

fetchConfig

...
Properties:
Name Type Description
fetchConfig boolean

Whether to fetch the wiki config from the server or use our local copy.

Source:

fetchImageInfo

...
Properties:
Name Type Description
fetchImageInfo boolean

Whether to fetch image info via the API or else treat all images as missing.

Source:

fetchTemplates

...
Properties:
Name Type Description
fetchTemplates boolean

Whether we should request templates from a wiki, or just use cached versions.

Source:

heapUsageSampleInterval

...
Properties:
Name Type Description
How number

often should we emit a heap sample? Time in ms.

Only relevant if performance timing is enabled

Source:

linting

...
Properties:
Name Type Description
linting boolean | Array

Whether to enable linter Backend. Or an array of enabled lint types

Source:

loadWMF

Load WMF sites in the interwikiMap from the cached wmf.sitematrix.json

.

Load WMF sites in the interwikiMap from the cached wmf.sitematrix.json

Source:

loggerBackend

...
Properties:
Name Type Description
loggerBackend function

The logger output function. By default, use stderr to output logs.

Source:

loggerSampling

...
Properties:
Name Type Description
loggerSampling Array | null

An array of arrays of log types and sample rates, in percent. Omissions imply 100. For example, parsoidConfig.loggerSampling = [ ['warn/dsr/inconsistent', 1], ];

Source:

logMwApiWarnings

Log warnings from the Mediawiki Api.

Log warnings from the Mediawiki Api.

Source:

maxDepth

...
Properties:
Name Type Description
maxDepth number

The maximum depth to which we should expand templates. Only applies if we would fetch templates anyway, and if we're actually expanding templates. So #fetchTemplates must be true and #usePHPPreProcessor must be false.

Source:

maxFormSize

...
Properties:
Name Type Description
Form number

size limit in bytes (default is 2M in express)

Source:

maxListeners

...
Properties:
Name Type Description
Number number

of outstanding event listeners waiting on Mediawiki API responses

Source:

metrics

...
Properties:
Name Type Description
Statistics Object | null

aggregator, for counting and timing.

Source:

modulesLoadURI

The server from which to load style modules.

The server from which to load style modules.

Source:

mwApiServer

Server to connect to for MediaWiki API requests.

Server to connect to for MediaWiki API requests.

Source:

rtTestMode

...
Properties:
Name Type Description
rtTestMode boolean

Test in rt test mode (changes some parse & serialization strategies)

Source:

scrubBidiChars

If enabled, bidi chars adjacent to category links will be stripped in the html -> wt serialization pass.

If enabled, bidi chars adjacent to category links will be stripped in the html -> wt serialization pass.

Source:

strictSSL

...
Properties:
Name Type Description
strictSSL boolean

By default require SSL certificates to be valid Set to false when using self-signed SSL certificates

Source:

suppressMwApiWarnings

Suppress some warnings by default.

Suppress some warnings by default.

Source:

traceFlags

...
Properties:
Name Type Description
traceFlags Set

Flags that tell us which tracing information to print.

Source:

tracerBackend

...
Properties:
Name Type Description
tracerBackend function

The tracer output function. By default, use stderr to output traces.

Source:

useBatchAPI

Set to true to use the Parsoid-specific batch API from the ParsoidBatchAPI extension (action=parsoid-batch).

Set to true to use the Parsoid-specific batch API from the ParsoidBatchAPI extension (action=parsoid-batch).

Source:

usePHPPreProcessor

...
Properties:
Name Type Description
usePHPPreProcessor boolean

Whether we should use the PHP Preprocessor to expand templates, extension content, and the like. See #PHPPreProcessorRequest in lib/mediawiki.ApiRequest.js

Source:

userAgent

...
Properties:
Name Type Description
Default string

user agent used for making Mediawiki API requests

Source:

useSelser

...
Properties:
Name Type Description
useSelser boolean

Whether to use selective serialization when serializing a DOM to Wikitext. This amounts to not serializing bits of the page that aren't marked as having changed, and requires some way of getting the original text of the page. See #SelectiveSerializer in lib/mediawiki.SelectiveSerializer.js

Source:

Methods

getAPIProxy(prefix) → {Object}

Figure out the proxy to use for API requests for a given wiki.

Figure out the proxy to use for API requests for a given wiki.

Parameters:
Name Type Description
prefix string
Source:
Returns:
Type
Object

getPrefixFor(domain) → {string}

Return the internal prefix used to index configuration information for the given domain string.

Return the internal prefix used to index configuration information for the given domain string. If the prefix is not present, attempts dynamic configuration using the dynamicConfig hook before returning.

XXX: We should eventually move the dynamic configuration to lookups on the mwApiMap, once we remove prefix from our codebase: T206764.

Parameters:
Name Type Description
domain string
Source:
Returns:

Internal prefix

Type
string

loadWMFApiMap()

Initialize the mwApiMap and friends.

Initialize the mwApiMap and friends.

Source:

removeMwApi(apiConf)

Remove an wiki configuration.

Remove an wiki configuration.

Parameters:
Name Type Description
apiConf Object

A wiki configuration object. The value of apiConf.domain, or if that is missing apiConf.prefix, will be used to locate the configuration to remove. Deprecated: if a string is passed, it is used as the prefix to remove.

Source:

setMwApi(apiConf)

Set up a wiki configuration.

Set up a wiki configuration.

For backward compatibility, if there are two arguments the first is taken as a prefix and the second as the configuration, and if the configuration is a string it is used as the uri property in a new empty configuration object. This usage is deprecated; we recommend users pass a configuration object as documented below.

Parameters:
Name Type Description
apiConf Object

The wiki configuration object.

Properties
Name Type Attributes Description
uri string

The URL to the wiki's Action API (api.php). This is the only mandatory argument.

domain string <optional>

The "domain" used to identify this wiki when using the Parsoid v2/v3 API. It defaults to the hostname portion of apiConf.uri.

prefix string <optional>

An arbitrary unique identifier for this wiki. If none is provided a unique string will be generated.

proxy Object <optional>

A proxy configuration object.

Properties
Name Type Attributes Description
uri string | null <optional>

The URL of a proxy to use for API requests, or null to explicitly disable API request proxying for this wiki. Will fall back to ParsoidConfig#defaultAPIProxyURI if undefined (default value).

headers Object <optional>

Headers to add when proxying.

extensions Array <optional>

A list of native extension constructors. Otherwise, registers cite by default.

strictSSL boolean <optional>
Source: