types-mediawiki-response 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -0
  3. package/README.zh.md +57 -0
  4. package/dist/common/index.d.ts +87 -0
  5. package/dist/core/acquiretempusername.d.ts +17 -0
  6. package/dist/core/block.d.ts +98 -0
  7. package/dist/core/changeauthenticationdata.d.ts +18 -0
  8. package/dist/core/changecontentmodel.d.ts +27 -0
  9. package/dist/core/checktoken.d.ts +28 -0
  10. package/dist/core/clearhasmsg.d.ts +15 -0
  11. package/dist/core/clientlogin.d.ts +48 -0
  12. package/dist/core/compare.d.ts +92 -0
  13. package/dist/core/createaccount.d.ts +41 -0
  14. package/dist/core/delete.d.ts +45 -0
  15. package/dist/core/edit.d.ts +66 -0
  16. package/dist/core/emailuser.d.ts +27 -0
  17. package/dist/core/expandtemplates.d.ts +66 -0
  18. package/dist/core/filerevert.d.ts +20 -0
  19. package/dist/core/imagerotate.d.ts +51 -0
  20. package/dist/core/import.d.ts +29 -0
  21. package/dist/core/index.d.ts +40 -0
  22. package/dist/core/languagesearch.d.ts +24 -0
  23. package/dist/core/login.d.ts +30 -0
  24. package/dist/core/logout.d.ts +16 -0
  25. package/dist/core/managetags.d.ts +28 -0
  26. package/dist/core/mergehistory.d.ts +26 -0
  27. package/dist/core/move.d.ts +62 -0
  28. package/dist/core/options.d.ts +16 -0
  29. package/dist/core/parse.d.ts +324 -0
  30. package/dist/core/patrol.d.ts +21 -0
  31. package/dist/core/protect.d.ts +43 -0
  32. package/dist/core/purge.d.ts +61 -0
  33. package/dist/core/query/allcategories.d.ts +30 -0
  34. package/dist/core/query/alldeletedrevisions.d.ts +29 -0
  35. package/dist/core/query/allfileusages.d.ts +15 -0
  36. package/dist/core/query/allimages.d.ts +25 -0
  37. package/dist/core/query/alllinks.d.ts +34 -0
  38. package/dist/core/query/allmessages.d.ts +43 -0
  39. package/dist/core/query/allpages.d.ts +23 -0
  40. package/dist/core/query/allredirects.d.ts +23 -0
  41. package/dist/core/query/allrevisions.d.ts +30 -0
  42. package/dist/core/query/alltransclusions.d.ts +14 -0
  43. package/dist/core/query/allusers.d.ts +37 -0
  44. package/dist/core/query/authmanagerinfo.d.ts +96 -0
  45. package/dist/core/query/backlinks.d.ts +34 -0
  46. package/dist/core/query/blocks.d.ts +104 -0
  47. package/dist/core/query/categories.d.ts +28 -0
  48. package/dist/core/query/categoryinfo.d.ts +25 -0
  49. package/dist/core/query/categorymembers.d.ts +38 -0
  50. package/dist/core/query/codexicons.d.ts +40 -0
  51. package/dist/core/query/contributors.d.ts +23 -0
  52. package/dist/core/query/deletedrevisions.d.ts +21 -0
  53. package/dist/core/query/deletedrevs.d.ts +84 -0
  54. package/dist/core/query/duplicatefiles.d.ts +30 -0
  55. package/dist/core/query/embeddedin.d.ts +28 -0
  56. package/dist/core/query/extlinks.d.ts +17 -0
  57. package/dist/core/query/exturlusage.d.ts +30 -0
  58. package/dist/core/query/filearchive.d.ts +91 -0
  59. package/dist/core/query/filerepoinfo.d.ts +51 -0
  60. package/dist/core/query/fileusage.d.ts +26 -0
  61. package/dist/core/query/imageinfo.d.ts +214 -0
  62. package/dist/core/query/images.d.ts +20 -0
  63. package/dist/core/query/imageusage.d.ts +36 -0
  64. package/dist/core/query/index.d.ts +489 -0
  65. package/dist/core/query/info.d.ts +208 -0
  66. package/dist/core/query/iwbacklinks.d.ts +28 -0
  67. package/dist/core/query/iwlinks.d.ts +21 -0
  68. package/dist/core/query/langbacklinks.d.ts +28 -0
  69. package/dist/core/query/langlinks.d.ts +32 -0
  70. package/dist/core/query/languageinfo.d.ts +70 -0
  71. package/dist/core/query/links.d.ts +22 -0
  72. package/dist/core/query/linkshere.d.ts +25 -0
  73. package/dist/core/query/logevents.d.ts +77 -0
  74. package/dist/core/query/mystashedfiles.d.ts +39 -0
  75. package/dist/core/query/pagepropnames.d.ts +18 -0
  76. package/dist/core/query/pageprops.d.ts +19 -0
  77. package/dist/core/query/pageswithprop.d.ts +28 -0
  78. package/dist/core/query/prefixsearch.d.ts +27 -0
  79. package/dist/core/query/protectedtitles.d.ts +43 -0
  80. package/dist/core/query/querypage.d.ts +59 -0
  81. package/dist/core/query/random.d.ts +30 -0
  82. package/dist/core/query/recentchanges.d.ts +103 -0
  83. package/dist/core/query/redirects.d.ts +27 -0
  84. package/dist/core/query/revisions.d.ts +176 -0
  85. package/dist/core/query/search.d.ts +141 -0
  86. package/dist/core/query/siteinfo.d.ts +731 -0
  87. package/dist/core/query/stashimageinfo.d.ts +101 -0
  88. package/dist/core/query/tags.d.ts +34 -0
  89. package/dist/core/query/templates.d.ts +20 -0
  90. package/dist/core/query/tokens.d.ts +34 -0
  91. package/dist/core/query/trackingcategories.d.ts +25 -0
  92. package/dist/core/query/transcludedin.d.ts +25 -0
  93. package/dist/core/query/usercontribs.d.ts +72 -0
  94. package/dist/core/query/userinfo.d.ts +141 -0
  95. package/dist/core/query/users.d.ts +164 -0
  96. package/dist/core/query/watchlist.d.ts +109 -0
  97. package/dist/core/query/watchlistraw.d.ts +42 -0
  98. package/dist/core/removeauthenticationdata.d.ts +18 -0
  99. package/dist/core/resetpassword.d.ts +16 -0
  100. package/dist/core/revisiondelete.d.ts +83 -0
  101. package/dist/core/rollback.d.ts +27 -0
  102. package/dist/core/setnotificationtimestamp.d.ts +47 -0
  103. package/dist/core/setpagelanguage.d.ts +24 -0
  104. package/dist/core/stashedit.d.ts +25 -0
  105. package/dist/core/tag.d.ts +49 -0
  106. package/dist/core/upload.d.ts +106 -0
  107. package/dist/core/userrights.d.ts +41 -0
  108. package/dist/core/validatepassword.d.ts +28 -0
  109. package/dist/core/watch.d.ts +45 -0
  110. package/dist/envelope/index.d.ts +122 -0
  111. package/dist/extensions/abusefilters.d.ts +207 -0
  112. package/dist/extensions/babel.d.ts +32 -0
  113. package/dist/extensions/categorytree.d.ts +78 -0
  114. package/dist/extensions/checkuser.d.ts +148 -0
  115. package/dist/extensions/description.d.ts +22 -0
  116. package/dist/extensions/discussiontools.d.ts +273 -0
  117. package/dist/extensions/echo.d.ts +306 -0
  118. package/dist/extensions/extracts.d.ts +24 -0
  119. package/dist/extensions/flaggedrevs.d.ts +192 -0
  120. package/dist/extensions/gadgets.d.ts +148 -0
  121. package/dist/extensions/globalblocks.d.ts +115 -0
  122. package/dist/extensions/globalpreferences.d.ts +62 -0
  123. package/dist/extensions/globalusage.d.ts +41 -0
  124. package/dist/extensions/globaluserinfo.d.ts +95 -0
  125. package/dist/extensions/linter.d.ts +83 -0
  126. package/dist/extensions/massmessage.d.ts +108 -0
  127. package/dist/extensions/oathauth.d.ts +86 -0
  128. package/dist/extensions/pageimages.d.ts +33 -0
  129. package/dist/extensions/pageviews.d.ts +63 -0
  130. package/dist/extensions/scribunto.d.ts +61 -0
  131. package/dist/extensions/sitematrix.d.ts +109 -0
  132. package/dist/extensions/spamblacklist.d.ts +25 -0
  133. package/dist/extensions/templatedata.d.ts +130 -0
  134. package/dist/extensions/thanks.d.ts +29 -0
  135. package/dist/extensions/timedmediahandler.d.ts +121 -0
  136. package/dist/extensions/titleblacklist.d.ts +29 -0
  137. package/dist/extensions/urlshortener.d.ts +42 -0
  138. package/dist/extensions/visualeditor.d.ts +204 -0
  139. package/dist/extensions/wikibase.d.ts +100 -0
  140. package/dist/extensions/wikilove.d.ts +38 -0
  141. package/dist/index.d.ts +3 -0
  142. package/package.json +76 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BearBin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # types-mediawiki-response
2
+
3
+ English | [简体中文](https://github.com/BearBin1215/types-mediawiki-response/blob/main/README.zh.md) | [Document](https://bearbin1215.github.io/types-mediawiki-response/)
4
+
5
+ Reusable typings for MediaWiki Action API responses.
6
+
7
+ - **Pure types**: type declarations only — no impact on your bundle size.
8
+ - **Cross-version**: field union spanning MediaWiki 1.39–1.47.
9
+ - **JSDoc coverage**: every field annotated with its parameter and semantics; hover in your IDE and it is there.
10
+ - **Bundled extensions**: extension fields are opt-in (see [Extensions](#extensions)).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install -D types-mediawiki-response
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Import the response type for the `action` you called:
21
+
22
+ ```ts
23
+ import type { ApiQueryResponse } from "types-mediawiki-response";
24
+
25
+ const res = (await api.get({
26
+ action: "query",
27
+ prop: "revisions",
28
+ titles,
29
+ formatversion: "2",
30
+ })) as ApiQueryResponse;
31
+ ```
32
+
33
+ Wrap with `ApiResponseWith<T>` to get the full error response type — see the [envelope and error handling guide](https://bearbin1215.github.io/types-mediawiki-response/guide/errors.html).
34
+
35
+ When using `ApiQueryResponse`, `query.pages[]` in the response is the union of every covered `prop=` field; project it with `QueryPage<K>` to scope a page to the props you requested — see the [query responses guide](https://bearbin1215.github.io/types-mediawiki-response/guide/query.html).
36
+
37
+ ## Extensions
38
+
39
+ Extension response types ship as opt-in packs under `types-mediawiki-response/ext/*`. The fields a pack adds to query responses are activated by a one-line type import:
40
+
41
+ ```ts
42
+ // mw-extensions.d.ts — declared once per repository, in any file covered by your tsconfig
43
+ import type {} from "types-mediawiki-response/ext/flaggedrevs";
44
+ import type {} from "types-mediawiki-response/ext/globalusage";
45
+ ```
46
+
47
+ The augmentation applies to the whole project, after which field types such as `page.flagged` / `query.notifications` are added where they belong.
48
+
49
+ An extension action (`action=thank`, `action=wikilove`, …) instead exports a standalone response type — import it by name where you call it, like any core action:
50
+
51
+ ```ts
52
+ import type { ApiThankResponse } from "types-mediawiki-response/ext/thanks";
53
+
54
+ const res = (await api.post({ action: "thank", rev })) as ApiThankResponse;
55
+ ```
56
+
57
+ Bundled packs are listed in the [extension packs guide](https://bearbin1215.github.io/types-mediawiki-response/guide/ext-packs.html). Extensions this package does not cover can be augmented the same way with a hand-written `declare module 'types-mediawiki-response' { … }`.
package/README.zh.md ADDED
@@ -0,0 +1,57 @@
1
+ # types-mediawiki-response
2
+
3
+ [English](https://github.com/BearBin1215/types-mediawiki-response/blob/main/README.md) | 简体中文 | [在线文档](https://bearbin1215.github.io/types-mediawiki-response/zh/)
4
+
5
+ 为 MediaWiki Action API 响应提供可复用类型。
6
+
7
+ - **纯类型**:产物仅类型声明,不影响产物体积。
8
+ - **跨版本支持**:覆盖 MediaWiki 1.39–1.47 的字段并集。
9
+ - **JSDoc 覆盖**:逐字段标注参数与语义,IDE 悬停即文档。
10
+ - **内置扩展**:支持按需引入扩展内容(见[扩展](#扩展))。
11
+
12
+ ## 安装
13
+
14
+ ```bash
15
+ npm install -D types-mediawiki-response
16
+ ```
17
+
18
+ ## 用法
19
+
20
+ 按调用的 `action` 导入对应响应类型:
21
+
22
+ ```ts
23
+ import type { ApiQueryResponse } from "types-mediawiki-response";
24
+
25
+ const res = (await api.get({
26
+ action: "query",
27
+ prop: "revisions",
28
+ titles,
29
+ formatversion: "2",
30
+ })) as ApiQueryResponse;
31
+ ```
32
+
33
+ 可用 `ApiResponseWith<T>` 包装以获得含错误结果的响应类型,见文档[信封与错误处理指南](https://bearbin1215.github.io/types-mediawiki-response/zh/guide/errors.html)。
34
+
35
+ 使用 `ApiQueryResponse` 的情况下,响应里的 `query.pages[]` 类型是所有已覆盖 `prop=` 字段的并集,可用 `QueryPage<K>` 收窄到本次请求的 prop,见文档[query 响应指南](https://bearbin1215.github.io/types-mediawiki-response/zh/guide/query.html)。
36
+
37
+ ## 扩展
38
+
39
+ 扩展响应类型以可选包形式放在 `types-mediawiki-response/ext/*`。扩展往 query 响应中加入的字段通过一行类型导入来激活:
40
+
41
+ ```ts
42
+ // mw-extensions.d.ts —— 每个仓库声明一次,放在任意被 tsconfig include 的文件里
43
+ import type {} from "types-mediawiki-response/ext/flaggedrevs";
44
+ import type {} from "types-mediawiki-response/ext/globalusage";
45
+ ```
46
+
47
+ 增广对整个项目生效,此后 `page.flagged` / `query.notifications` 等字段类型就会被添加到对应位置。
48
+
49
+ 扩展的 action(`action=thank`、`action=wikilove` 等)则导出独立响应类型,在调用处按名导入,像核心 action 一样使用:
50
+
51
+ ```ts
52
+ import type { ApiThankResponse } from "types-mediawiki-response/ext/thanks";
53
+
54
+ const res = (await api.post({ action: "thank", rev })) as ApiThankResponse;
55
+ ```
56
+
57
+ 内置包清单见文档站的[扩展包指南](https://bearbin1215.github.io/types-mediawiki-response/zh/guide/ext-packs.html)。本包未覆盖的扩展,手写 `declare module 'types-mediawiki-response' { … }` 走同一接缝增广。
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Shared primitive types used across response modules.
3
+ */
4
+ /**
5
+ * MediaWiki boolean-style flags: present as `true` when set, otherwise absent.
6
+ *
7
+ * @see https://www.mediawiki.org/wiki/API:JSON_version_2
8
+ */
9
+ export type Flag = true;
10
+ /**
11
+ * A MediaWiki timestamp in ISO 8601 format (UTC),
12
+ * e.g. `2024-01-15T08:30:00Z`.
13
+ */
14
+ export type Timestamp = string;
15
+ /**
16
+ * A block of plain text (as opposed to HTML), e.g. a TextExtracts excerpt
17
+ * requested with `explaintext`. Kept distinct from HTML-bearing string fields.
18
+ */
19
+ export type PlainText = string;
20
+ /** Namespace index. Negative indexes are pseudo-namespaces. */
21
+ export type NamespaceIndex = number;
22
+ /**
23
+ * A structured in-band message — a serialized MediaWiki `Message`/`FatalError`
24
+ * spec (`{ message, params, code, type }`) nested inside an action result
25
+ * (e.g. password-policy messages, file-backend errors, AuthManager failures).
26
+ * Distinct from `ApiMessage`, which models the `errorformat`-based envelope.
27
+ */
28
+ export interface ApiSpecMessage {
29
+ /** i18n message key, e.g. `passwordtooshort`. */
30
+ message?: string;
31
+ /** Parameters substituted into the message (may be numbers). */
32
+ params?: unknown[];
33
+ /** Machine-readable code (usually mirrors `message`). */
34
+ code?: string;
35
+ /** Severity, e.g. `error`. Open union. */
36
+ type?: string;
37
+ /** Pre-rendered HTML, when the server supplies it. */
38
+ html?: string;
39
+ }
40
+ /**
41
+ * A watchlist label (`{ id, name }`), as returned by `meta=userinfo`
42
+ * `uiprop=watchlistlabels`, `prop=info` `inprop=watchlistlabels`,
43
+ * `list=watchlist` `wlprop=labels`, and echoed by `action=watch`. Requires
44
+ * `$wgEnableWatchlistLabels`. Emitted as a list; an empty set serializes as `[]`.
45
+ *
46
+ * @since MediaWiki 1.46
47
+ */
48
+ export interface ApiWatchlistLabel {
49
+ /** Stable numeric label id. */
50
+ id?: number;
51
+ /** Label text. */
52
+ name?: string;
53
+ }
54
+ /**
55
+ * Content model of a page. **Open union** — known values are autocomplete
56
+ * sugar only; `(string & {})` accepts any model a response may carry.
57
+ *
58
+ * Coverage policy: MediaWiki core models are listed directly; `Scribunto`
59
+ * is included as the one near-universal extension model; extension packs
60
+ * promote their own models by augmenting {@link ContentModelExtension}
61
+ * (e.g. `MassMessageListContent` from the MassMessage pack); consumers may
62
+ * augment the same interface for site-specific models registered through
63
+ * `$wgContentModels`.
64
+ */
65
+ export type ContentModel = "wikitext" | "javascript" | "css" | "json" | "text" | "Scribunto" | ContentModelExtension[keyof ContentModelExtension] | (string & {});
66
+ /**
67
+ * Augmentation target for content models beyond MediaWiki core: extension
68
+ * packs and consumers merge members here (each mapping the model name to
69
+ * itself) to promote them to first-class known values of
70
+ * {@link ContentModel}.
71
+ *
72
+ * @example
73
+ * // A site-specific model registered through $wgContentModels:
74
+ * declare module "types-mediawiki-response" {
75
+ * interface ContentModelExtension {
76
+ * MyModel: "my-model";
77
+ * }
78
+ * }
79
+ */
80
+ export interface ContentModelExtension {
81
+ }
82
+ /**
83
+ * Serialization format of a revision slot, e.g. `text/x-wiki`. **Open union**:
84
+ * known core formats are listed for autocomplete and `(string & {})` keeps the
85
+ * type forward-compatible with extension-provided formats.
86
+ */
87
+ export type ContentFormat = "text/x-wiki" | "text/plain" | "text/javascript" | "text/css" | "application/json" | (string & {});
@@ -0,0 +1,17 @@
1
+ /**
2
+ * `action=acquiretempusername` response — acquires a temporary account
3
+ * username and stashes it in the current session, so that the name is reused
4
+ * when a later action auto-creates the account (also usable in previews).
5
+ * Write mode: requires a POST, a logged-out session, temporary-account
6
+ * auto-creation enabled on the wiki, and the `createaccount` right. Repeated
7
+ * calls return the same stashed name.
8
+ *
9
+ * @see https://www.mediawiki.org/wiki/Help:Temporary_accounts
10
+ * @since MediaWiki 1.41
11
+ */
12
+ import type { ApiEnvelope } from "../envelope";
13
+ /** Response of `action=acquiretempusername`. */
14
+ export interface ApiAcquireTempUserNameResponse extends ApiEnvelope {
15
+ /** The stashed temporary username (e.g. `~2024-9`). */
16
+ acquiretempusername?: string;
17
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * `action=block` / `action=unblock` responses — (un)blocking a user or IP
3
+ * range, each returned under a top-level object. Requires the `block` right.
4
+ *
5
+ * fv2 note: the block result uses **`userID`** (capital `D`) while the unblock
6
+ * result uses `userid` — a real asymmetry in the API, preserved here. Block
7
+ * flags are real booleans (present as `false`); partial-block restrictions come
8
+ * back as `null` when the block is sitewide.
9
+ *
10
+ * @see https://www.mediawiki.org/wiki/API:Block
11
+ */
12
+ import type { Timestamp } from "../common";
13
+ import type { ApiEnvelope } from "../envelope";
14
+ /** The `block` object of an `action=block` response. */
15
+ export interface ApiBlockResult {
16
+ /** Blocked user name / IP. */
17
+ user: string;
18
+ /** Blocked user id (`0` for IPs / autoblocks). Note the capital `D`. */
19
+ userID: number;
20
+ /** Block id. */
21
+ id: number;
22
+ /** Expiry timestamp, or `infinite` for an indefinite block. */
23
+ expiry: Timestamp | "infinite";
24
+ /** Block reason (echoed back). */
25
+ reason: string;
26
+ /** Block only anonymous users editing from an IP address range. */
27
+ anononly: boolean;
28
+ /** Prevent new account creation from the blocked user or IP range. */
29
+ nocreate: boolean;
30
+ /** Also block the IP addresses this user edits from. */
31
+ autoblock: boolean;
32
+ /** Prevent the user from sending email via `Special:Emailuser`. */
33
+ noemail: boolean;
34
+ /** Hide the username in logs and contributions. */
35
+ hidename: boolean;
36
+ /** Let the blocked user keep editing their own user talk page. */
37
+ allowusertalk: boolean;
38
+ /** Add the blocked user's user and talk pages to the blocker's watchlist. */
39
+ watchuser: boolean;
40
+ /** Restrict the block to specific pages or namespaces instead of sitewide. */
41
+ partial: boolean;
42
+ /** Page restrictions of a partial block; `null` when sitewide. */
43
+ pagerestrictions: unknown;
44
+ /** Namespace restrictions of a partial block; `null` when sitewide. */
45
+ namespacerestrictions: unknown;
46
+ /**
47
+ * Expiry applied to the watched user page, present only when the request
48
+ * passed `watchlistexpiry`; `null` when the page is not actually watched.
49
+ */
50
+ watchlistexpiry?: Timestamp | null;
51
+ /**
52
+ * Restricted actions of a partial action block; only emitted when
53
+ * `$wgEnablePartialActionBlocks` is enabled.
54
+ */
55
+ actionrestrictions?: string[];
56
+ /**
57
+ * When the block was applied, in ISO 8601.
58
+ *
59
+ * @since MediaWiki 1.47
60
+ */
61
+ timestamp?: Timestamp;
62
+ /**
63
+ * Extra statuses set by extensions during a successful block. Always
64
+ * emitted; core never fills it, so it is `[]` unless `$wgEnableMultiBlocks`
65
+ * is on and an extension populates it via the `ApiBlockSucceeded` hook, in
66
+ * which case a PHP map (thus the `unknown[]` empty case).
67
+ *
68
+ * @since MediaWiki 1.46
69
+ */
70
+ additionalBlocksStatuses?: Record<string, unknown> | unknown[];
71
+ }
72
+ /** Response of `action=block`. */
73
+ export interface ApiBlockResponse extends ApiEnvelope {
74
+ block: ApiBlockResult;
75
+ }
76
+ /** The `unblock` object of an `action=unblock` response. */
77
+ export interface ApiUnblockResult {
78
+ /** Removed block id. */
79
+ id: number;
80
+ /** Unblocked user name / IP; empty string when removing an autoblock. */
81
+ user: string;
82
+ /** Unblocked user id (`0` for IPs and autoblocks). Note lowercase, unlike the block result. */
83
+ userid: number;
84
+ /** Unblock reason (echoed back). */
85
+ reason: string;
86
+ /** Whether the unblock added the unblocked user to the unblocker's watchlist. */
87
+ watchuser: boolean;
88
+ /**
89
+ * Expiry applied to the watched user page, present only when the request
90
+ * passed `watchlistexpiry` with `watchuser`; `null` when the page is not
91
+ * actually watched.
92
+ */
93
+ watchlistexpiry?: Timestamp | null;
94
+ }
95
+ /** Response of `action=unblock`. */
96
+ export interface ApiUnblockResponse extends ApiEnvelope {
97
+ unblock: ApiUnblockResult;
98
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * `action=changeauthenticationdata` response — AuthManager flow that changes a
3
+ * logged-in user's authentication data (e.g. email, password); needs a session
4
+ * token, the `editmyprivateinfo` right, and a fully-configured secondary-provider
5
+ * session. On success `ApiChangeAuthenticationData` emits a single field:
6
+ * `changeauthenticationdata.status` = `success`. Any refusal or incomplete flow
7
+ * is a top-level {@link ApiErrorResponse} (dieStatus / badrequest).
8
+ *
9
+ * @see https://www.mediawiki.org/wiki/API:Changeauthenticationdata
10
+ */
11
+ import type { ApiEnvelope } from "../envelope";
12
+ /** Response of `action=changeauthenticationdata`. */
13
+ export interface ApiChangeAuthenticationDataResponse extends ApiEnvelope {
14
+ changeauthenticationdata: {
15
+ /** Flow outcome; `success` when the change was applied. */
16
+ status: "success" | (string & {});
17
+ };
18
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `action=changecontentmodel` response — changes a page's content model (e.g.
3
+ * wikitext → JavaScript); requires CSRF and `edit` + `editcontentmodel` rights
4
+ * (on the page under both the current and the new model). The result keys under
5
+ * `changecontentmodel`.
6
+ *
7
+ * @see https://www.mediawiki.org/wiki/API:Changecontentmodel
8
+ */
9
+ import type { ContentModel } from "../common";
10
+ import type { ApiEnvelope } from "../envelope";
11
+ /** Response of `action=changecontentmodel`. */
12
+ export interface ApiChangeContentModelResponse extends ApiEnvelope {
13
+ changecontentmodel: {
14
+ /** `Success` when the model was changed. */
15
+ result: "Success" | (string & {});
16
+ /** Page title. */
17
+ title: string;
18
+ /** Page id. */
19
+ pageid: number;
20
+ /** The content model now in effect. */
21
+ contentmodel: ContentModel;
22
+ /** New revision id created by the change. */
23
+ revid: number;
24
+ /** Log entry id recorded for the change. */
25
+ logid: number;
26
+ };
27
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * `action=checktoken` response — validates a token the client already holds
3
+ * (e.g. before a write), returning `checktoken.result`. No write side effects.
4
+ *
5
+ * `ApiCheckToken` sets `result` to `valid`, `expired` (a token older than
6
+ * `maxtokenage`), or `invalid`. `generated` is decoded from the submitted
7
+ * token itself (MediaWiki tokens embed their generation time), so it appears
8
+ * whenever the token carries a timestamp — an old token reports its own age.
9
+ * Modeled as an open union for forward compatibility.
10
+ *
11
+ * @see https://www.mediawiki.org/wiki/API:Checktoken
12
+ */
13
+ import type { Timestamp } from "../common";
14
+ import type { ApiEnvelope } from "../envelope";
15
+ /** Result values of {@link ApiCheckTokenResponse}. */
16
+ export type ApiCheckTokenResult = "valid" | "expired" | "invalid" | (string & {});
17
+ /** Response of `action=checktoken`. */
18
+ export interface ApiCheckTokenResponse extends ApiEnvelope {
19
+ checktoken: {
20
+ /** Outcome of the token check. */
21
+ result: ApiCheckTokenResult;
22
+ /**
23
+ * ISO-8601 timestamp when the submitted token was generated; present
24
+ * whenever the token embeds one (including old tokens).
25
+ */
26
+ generated?: Timestamp;
27
+ };
28
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * `action=clearhasmsg` response — clears the "you have new messages" flag on the
3
+ * current (logged-in) user. The payload is a bare status string under the
4
+ * `clearhasmsg` key (a `success` value in 1.43; historically an empty string).
5
+ *
6
+ * Takes no token; passing one draws an `Unrecognized parameter: token` warning.
7
+ *
8
+ * @see https://www.mediawiki.org/wiki/API:Watch#Clearing_the_new_messages_flag
9
+ */
10
+ import type { ApiEnvelope } from "../envelope";
11
+ /** Response of `action=clearhasmsg`. */
12
+ export interface ApiClearHasMsgResponse extends ApiEnvelope {
13
+ /** Status string; `success` on 1.43 (older builds returned an empty string). */
14
+ clearhasmsg: string;
15
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `action=clientlogin` response — the recommended login flow (replaces the
3
+ * deprecated `action=login`), returning a `clientlogin` object.
4
+ *
5
+ * `status` drives the flow: `PASS` (logged in), `FAIL`, `UI` (needs further
6
+ * interaction, e.g. 2FA), `RESTART` (third-party auth succeeded but no local
7
+ * account exists yet), `REDIRECT` (continue at `redirecttarget`). Which other
8
+ * fields appear depends on `status` and the `messageformat` parameter.
9
+ *
10
+ * @see https://www.mediawiki.org/wiki/API:Client_login
11
+ */
12
+ import type { ApiAuthManagerMessage, ApiQueryAuthManagerField, ApiQueryAuthManagerInfoRequest } from "./query/authmanagerinfo";
13
+ import type { ApiEnvelope } from "../envelope";
14
+ /** The `clientlogin` object of an `action=clientlogin` response. */
15
+ export interface ApiClientLogin {
16
+ /** Login outcome. */
17
+ status?: "PASS" | "FAIL" | "UI" | "REDIRECT" | "RESTART" | (string & {});
18
+ /** Authenticated user name; `PASS` only. */
19
+ username?: string;
20
+ /**
21
+ * Failure / interaction message, rendered per the `messageformat` parameter:
22
+ * a string under `wikitext`/`html`, a `{ key, params }` object under `raw`,
23
+ * absent under `none`. `FAIL`/`UI`/`RESTART` only.
24
+ */
25
+ message?: ApiAuthManagerMessage;
26
+ /** Machine-readable message code accompanying `message`; `FAIL`/`UI`/`RESTART` only. */
27
+ messagecode?: string;
28
+ /** URL to continue the flow at. `REDIRECT` only. */
29
+ redirecttarget?: string;
30
+ /**
31
+ * Data for a `REDIRECT` response the client may use to query the remote site
32
+ * via its API instead of following `redirecttarget`.
33
+ */
34
+ redirectdata?: Record<string, unknown>;
35
+ /** AuthManager request descriptors to continue the flow; `UI`/`RESTART`/`REDIRECT` only. */
36
+ requests?: ApiQueryAuthManagerInfoRequest[];
37
+ /**
38
+ * Field descriptors merged across all `requests`, present only when the
39
+ * request passed `mergerequestfields`.
40
+ */
41
+ fields?: Record<string, ApiQueryAuthManagerField>;
42
+ /** Whether the current AuthManager state can be preserved across requests; `FAIL`/`RESTART` only. */
43
+ canpreservestate?: boolean;
44
+ }
45
+ /** Response of `action=clientlogin`. */
46
+ export interface ApiClientLoginResponse extends ApiEnvelope {
47
+ clientlogin: ApiClientLogin;
48
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * `action=compare` response — compares two pages/revisions/texts and returns
3
+ * the result under a top-level `compare` object.
4
+ *
5
+ * The rendered diff HTML is `compare.body`, or `compare.bodies` keyed by slot
6
+ * role when comparing specific slots. Which `from*` / `to*` metadata appear
7
+ * depends on `prop`; the `*hidden` markers do not.
8
+ *
9
+ * @see https://www.mediawiki.org/wiki/API:Compare_pages
10
+ */
11
+ import type { Flag, Timestamp } from "../common";
12
+ import type { ApiEnvelope } from "../envelope";
13
+ /** The `compare` object of a successful `action=compare` response. */
14
+ export interface ApiCompareResult {
15
+ /** Diff HTML. `prop=diff`; only when the diff is not split per slot. */
16
+ body?: string;
17
+ /**
18
+ * Per-slot diff bodies, keyed by slot role. `prop=diff` when comparing
19
+ * specific slots (`fromslots`/`toslots`); takes the place of {@link body}.
20
+ */
21
+ bodies?: Record<string, string>;
22
+ /** Size of the diff HTML in bytes. `prop=diffsize`. */
23
+ diffsize?: number;
24
+ /** Revision id preceding the `from` side. `prop=rel`. */
25
+ prev?: number;
26
+ /** Revision id following the `to` side. `prop=rel`. */
27
+ next?: number;
28
+ /** Page id of the `from` side. `prop=ids`. */
29
+ fromid?: number;
30
+ /** Revision id of the `from` side. `prop=ids`. */
31
+ fromrevid?: number;
32
+ /** Namespace index of the `from` side. `prop=title`. */
33
+ fromns?: number;
34
+ /** Page title of the `from` side. `prop=title`. */
35
+ fromtitle?: string;
36
+ /** Revision size in bytes of the `from` side. `prop=size`. */
37
+ fromsize?: number;
38
+ /** Timestamp of the `from` revision. `prop=timestamp`. */
39
+ fromtimestamp?: Timestamp;
40
+ /** Editor of the `from` revision. `prop=user`. */
41
+ fromuser?: string;
42
+ /** Editor user id of the `from` revision. `prop=user`. */
43
+ fromuserid?: number;
44
+ /** Edit summary of the `from` revision. `prop=comment`. */
45
+ fromcomment?: string;
46
+ /** HTML-rendered summary of the `from` revision. `prop=comment` or `prop=parsedcomment`. */
47
+ fromparsedcomment?: string;
48
+ /** The `from` revision's content is hidden (revision-deleted). A {@link Flag}. */
49
+ fromtexthidden?: Flag;
50
+ /** The `from` revision's author is hidden. A {@link Flag}. */
51
+ fromuserhidden?: Flag;
52
+ /** The `from` revision's summary is hidden. A {@link Flag}. */
53
+ fromcommenthidden?: Flag;
54
+ /** Suppression (oversight) applies to the `from` revision, alongside the `*hidden` flags. A {@link Flag}. */
55
+ fromsuppressed?: Flag;
56
+ /** The `from` revision was read from the archive (deleted since it was referenced). A {@link Flag}. */
57
+ fromarchive?: Flag;
58
+ /** Page id of the `to` side. `prop=ids`. */
59
+ toid?: number;
60
+ /** Revision id of the `to` side. `prop=ids`. */
61
+ torevid?: number;
62
+ /** Namespace index of the `to` side. `prop=title`. */
63
+ tons?: number;
64
+ /** Page title of the `to` side. `prop=title`. */
65
+ totitle?: string;
66
+ /** Revision size in bytes of the `to` side. `prop=size`. */
67
+ tosize?: number;
68
+ /** Timestamp of the `to` revision. `prop=timestamp`. */
69
+ totimestamp?: Timestamp;
70
+ /** Editor of the `to` revision. `prop=user`. */
71
+ touser?: string;
72
+ /** Editor user id of the `to` revision. `prop=user`. */
73
+ touserid?: number;
74
+ /** Edit summary of the `to` revision. `prop=comment`. */
75
+ tocomment?: string;
76
+ /** HTML-rendered summary of the `to` revision. `prop=comment` or `prop=parsedcomment`. */
77
+ toparsedcomment?: string;
78
+ /** The `to` revision's content is hidden (revision-deleted). A {@link Flag}. */
79
+ totexthidden?: Flag;
80
+ /** The `to` revision's author is hidden. A {@link Flag}. */
81
+ touserhidden?: Flag;
82
+ /** The `to` revision's summary is hidden. A {@link Flag}. */
83
+ tocommenthidden?: Flag;
84
+ /** Suppression (oversight) applies to the `to` revision, alongside the `*hidden` flags. A {@link Flag}. */
85
+ tosuppressed?: Flag;
86
+ /** The `to` revision was read from the archive (deleted since it was referenced). A {@link Flag}. */
87
+ toarchive?: Flag;
88
+ }
89
+ /** Response of `action=compare`. */
90
+ export interface ApiCompareResponse extends ApiEnvelope {
91
+ compare: ApiCompareResult;
92
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `action=createaccount` response — AuthManager-driven account creation. The
3
+ * result keys under `createaccount`, produced by `ApiAuthManagerHelper::
4
+ * formatAuthenticationResponse` (the same builder as `clientlogin`): `status`
5
+ * drives the flow (`PASS` on success, plus in-band `FAIL`/`UI`/`RESTART`/
6
+ * `REDIRECT`), and failures carry `message`/`messagecode`.
7
+ *
8
+ * These are **in-band** AuthManager outcomes, not a top-level
9
+ * {@link ApiErrorResponse}. `username` appears on `PASS`; `UI`/`RESTART`/
10
+ * `REDIRECT` outcomes add the `requests` descriptors; `canpreservestate` marks
11
+ * whether state can be kept.
12
+ *
13
+ * @see https://www.mediawiki.org/wiki/API:Createaccount
14
+ */
15
+ import type { ApiAuthManagerMessage, ApiAuthManagerStatus } from "./query/authmanagerinfo";
16
+ import type { ApiEnvelope } from "../envelope";
17
+ /** Response of `action=createaccount`. */
18
+ export interface ApiCreateAccountResponse extends ApiEnvelope {
19
+ createaccount: {
20
+ /** AuthManager outcome of the account-creation flow. */
21
+ status?: ApiAuthManagerStatus;
22
+ /** Created (or attempted) user name; present on `PASS`. */
23
+ username?: string;
24
+ /**
25
+ * Failure / interaction message, rendered per the `messageformat`
26
+ * parameter: a string under `wikitext`/`html`, a `{ key, params }` object
27
+ * under `raw`, absent under `none`. `FAIL`/`UI`/`RESTART` only.
28
+ */
29
+ message?: ApiAuthManagerMessage;
30
+ /** Machine-readable message code (e.g. `invaliduser`). */
31
+ messagecode?: string;
32
+ /** Whether the current AuthManager state can be preserved across requests; `FAIL`/`RESTART` only. */
33
+ canpreservestate?: boolean;
34
+ /** Redirect target for a `REDIRECT` outcome. */
35
+ redirecttarget?: string;
36
+ /** Extra API data accompanying a `REDIRECT` outcome. */
37
+ redirectdata?: Record<string, unknown>;
38
+ /** AuthManager request descriptors for interactive (`UI`/`RESTART`) and `REDIRECT` steps. */
39
+ requests?: Record<string, unknown>[];
40
+ };
41
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * `action=delete` / `action=undelete` responses — page deletion and its undo,
3
+ * each returned under a top-level object. Requires the `delete` right.
4
+ *
5
+ * Under `formatversion=2` a successful delete carries **no `result` key**
6
+ * (older clients branched on `result: "Success"`).
7
+ *
8
+ * @see https://www.mediawiki.org/wiki/API:Delete
9
+ */
10
+ import type { Flag } from "../common";
11
+ import type { ApiEnvelope } from "../envelope";
12
+ /** The `delete` object of an `action=delete` response. */
13
+ export interface ApiDeleteResult {
14
+ /** Deleted page title. */
15
+ title: string;
16
+ /** Deletion reason (echoed back). */
17
+ reason: string;
18
+ /**
19
+ * The deletion was scheduled for asynchronous processing instead of running
20
+ * inline (large pages, above `$wgDeleteRevisionsBatchSize`). Mutually
21
+ * exclusive with {@link logid}: a scheduled deletion has no log entry yet.
22
+ */
23
+ scheduled?: Flag;
24
+ /** Log id of the new deletion log entry. */
25
+ logid?: number;
26
+ }
27
+ /** Response of `action=delete`. */
28
+ export interface ApiDeleteResponse extends ApiEnvelope {
29
+ delete: ApiDeleteResult;
30
+ }
31
+ /** The `undelete` object of an `action=undelete` response. */
32
+ export interface ApiUndeleteResult {
33
+ /** Restored page title. */
34
+ title: string;
35
+ /** Number of revisions restored. */
36
+ revisions: number;
37
+ /** Number of file versions restored. */
38
+ fileversions: number;
39
+ /** Undelete reason (echoed back). */
40
+ reason: string;
41
+ }
42
+ /** Response of `action=undelete`. */
43
+ export interface ApiUndeleteResponse extends ApiEnvelope {
44
+ undelete: ApiUndeleteResult;
45
+ }