Skip to content

Releases: lucaswerkmeister/m3api

v0.6.0

27 Mar 14:44
Compare
Choose a tag to compare
  • BREAKING CHANGE: Warnings are now always logged to the console by default. Previously, the Node.js backend only did this if NODE_ENV = “development” was set. If you use m3api for an interactive CLI application on Node.js, you may want to configure a custom warn handler (using the second constructor argument, next to the userAgent option), so that warnings are not shown to end users. You should make sure that the warnings still reach the developers, though.
  • BREAKING CHANGE: It is no longer possible to modify continuation by modifying the contents of a response’s continue member; continuation now always proceeds according to the original continue contents. The fact that this previously worked was not intended, and if any code actually behaves differently due to this change, it is assumed that the previous behavior was a bug rather than intended. If you really want to modify continuation, implement it yourself instead of using requestAndContinue.
  • A new function, requestAndContinueReducingBatch, is available to work with continuation. It is useful in cases where data for a batch
    of pages is spread across multiple responses, i.e. in cases where not every response is marked batchcomplete. (An example is
    generator=search with prop=revisions: the generator can yield up to 500 results per response, but revisions are limited to 50, so ten
    requests are required to get the revisions of the whole batch, after which the next batch of 500 search results can commence.) It is
    expected to be mainly used in libraries, such as the upcoming m3api-query.
  • The Node.js backend (specifically axios.js) now requests gzip compression of the response from the server, which should reduce
    network traffic somewhat.
  • Fixed a bug in handling warnings for combined requests.
  • The “modern” requirements of m3api, i.e. compatibility with different platforms, are documented in the README now.
  • Updated dependencies.

v0.5.0

04 Dec 20:38
Compare
Choose a tag to compare

Abbreviate api.php URL as domain, warn on requests without user agent.

  • BREAKING CHANGE (internal): The Session constructor now requires the default request options to include warn, which must be a function. The fetch.js and axios.js backends already add a default for this option, so this is only relevant for you if you wrote a custom network implementation; if you just import browser.js or node.js, it doesn’t matter.

  • The first constructor argument can now be a domain name instead of a full api.php URL, e.g. en.wikipedia.org instead of
    https://en.wikipedia.org/w/api.php.

  • Requests that do not specify a user agent will now trigger a warning, limited to once per session. If you see this warning, you should add a
    user agent to your requests – see the User-Agent policy. Usually you would add it to the default options at construction time:

    const session = new Session( 'en.wikipedia.org', {
        formatversion: 2,
        // other default params...
    }, {
        userAgent: 'my-cool-tool',
        // other default options...
    } );

    But it can also be specified for an individual request:

    const response = await session.request( {
        action: 'query',
        // other params...
    }, {
        userAgent: 'my-cool-tool',
        // other options...
    } );

    Recall that the default warning handler is console.warn in the browser, and also in Node.js if NODE_ENV = “development” is set, but otherwise the Node.js backend ignores warnings.

v0.4.0

13 Nov 20:52
Compare
Choose a tag to compare

More consistent constructor signature, support for API warnings.

  • BREAKING CHANGE: The third constructor parameter is now an object with default request options, and the user agent string is just one option, under the userAgent key. Convert constructor calls like new Session( ..., {}, 'user-agent' ) to new Session( ..., {}, { userAgent: 'user-agent' } ) instead.
  • BREAKING CHANGE (internal): The internalGet and internalPost methods now receive an additional parameter, the user agent string,
    which should be used instead of the constructor option. This is only relevant for you if you wrote a custom network implementation; if you
    just import browser.js or node.js, it doesn’t matter.
  • Thanks to the constructor change mentioned above, the userAgent request option can now specified for an individual request if you want to, and conversely other options like maxRetries can be defaulted in the constructor.
  • Added the warn request option, which can be used to handle warnings from a request. In the browser, and with NODE_ENV = “development” in Node.js, warnings are sent to the console by default. If you use the Node.js backend, but not for a CLI application, consider logging warnings regardless of environment by adding warn: console.warn to the default request options (or use a custom warning handler).
  • Added the responseBoolean utility function, to get a boolean out of a response value regardless of formatversion.
  • Updated dependencies.

v0.3.0

10 Oct 16:42
Compare
Choose a tag to compare
  • m3api now automatically combines concurrent compatible API requests. To make use of this feature, import the set() helper as a named
    import, and then use set( ... ) instead of [ ... ] for list-like parameters where additional values from other requests can be safely added, such as action=query’s prop, list and meta parameters. For more information, see the updated README, especially the new “automatically combining requests” section.
  • Updated dependencies.

v0.2.1

09 Oct 21:04
Compare
Choose a tag to compare

Security update.

  • Updated axios, avoiding CVE-2021-3749. The potential impact of this security vulnerability should have been fairly low: when using
    the axios backend (but not the fetch backend), a malicious API server could have provoked long processing times, by sending response headers with long sequences of interior whitespace. This would likely have required custom server software, since common servers like Apache and nginx limit the maximum header length, and the performance impact appears to be negligible at 8K characters.
  • Updated other dependencies.

v0.2.0

09 Sep 10:58
Compare
Choose a tag to compare

First proper update over a previous release.

  • BREAKING CHANGE (internal): The internalGet and internalPost methods now return additional data. This is only relevant for you if you wrote a custom network implementation; if you just import browser.js or node.js, it doesn’t matter.
  • Automatically retry requests when encountering a Retry-After response header. By default, retry once; adjust or disable with the maxRetries request option.
  • A non-200 HTTP response status is now detected and throws an error.
  • Improved the default user agent.
  • Added package metadata.

v0.1.2

19 Aug 19:50
Compare
Choose a tag to compare

No change from v0.1.1 apart from the version number.

v0.1.1

17 Aug 21:50
Compare
Choose a tag to compare

This is the initial release of the library, as presented at the 2021 Wikimania Hackathon Showcase. It supports basic API requests, continuation, error detection, cookie jars in axios, and more.