types-mediawiki-response 1.1.1 → 1.2.0
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.
- package/README.md +4 -4
- package/README.zh.md +4 -4
- package/dist/extensions/readinglists.d.ts +210 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# types-mediawiki-response
|
|
2
2
|
|
|
3
|
-
English | [简体中文](https://github.com/BearBin1215/types-mediawiki-response/blob/main/README.zh.md) | [Document](https://
|
|
3
|
+
English | [简体中文](https://github.com/BearBin1215/types-mediawiki-response/blob/main/README.zh.md) | [Document](https://types-mediawiki-response.pages.dev/)
|
|
4
4
|
|
|
5
5
|
Reusable typings for MediaWiki Action API responses.
|
|
6
6
|
|
|
@@ -30,9 +30,9 @@ const res = (await api.get({
|
|
|
30
30
|
})) as ApiQueryResponse;
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
Wrap with `ApiResponseWith<T>` to get the full error response type — see the [envelope and error handling guide](https://
|
|
33
|
+
Wrap with `ApiResponseWith<T>` to get the full error response type — see the [envelope and error handling guide](https://types-mediawiki-response.pages.dev/guide/errors).
|
|
34
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://
|
|
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://types-mediawiki-response.pages.dev/guide/query).
|
|
36
36
|
|
|
37
37
|
## Extensions
|
|
38
38
|
|
|
@@ -54,4 +54,4 @@ import type { ApiThankResponse } from "types-mediawiki-response/ext/thanks";
|
|
|
54
54
|
const res = (await api.post({ action: "thank", rev })) as ApiThankResponse;
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
Bundled packs are listed in the [extension packs guide](https://
|
|
57
|
+
Bundled packs are listed in the [extension packs guide](https://types-mediawiki-response.pages.dev/guide/ext-packs). 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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# types-mediawiki-response
|
|
2
2
|
|
|
3
|
-
[English](https://github.com/BearBin1215/types-mediawiki-response/blob/main/README.md) | 简体中文 | [在线文档](https://
|
|
3
|
+
[English](https://github.com/BearBin1215/types-mediawiki-response/blob/main/README.md) | 简体中文 | [在线文档](https://types-mediawiki-response.pages.dev/zh/)
|
|
4
4
|
|
|
5
5
|
为 MediaWiki Action API 响应提供可复用类型。
|
|
6
6
|
|
|
@@ -30,9 +30,9 @@ const res = (await api.get({
|
|
|
30
30
|
})) as ApiQueryResponse;
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
可用 `ApiResponseWith<T>` 包装以获得含错误结果的响应类型,见文档[信封与错误处理指南](https://
|
|
33
|
+
可用 `ApiResponseWith<T>` 包装以获得含错误结果的响应类型,见文档[信封与错误处理指南](https://types-mediawiki-response.pages.dev/zh/guide/errors)。
|
|
34
34
|
|
|
35
|
-
使用 `ApiQueryResponse` 的情况下,响应里的 `query.pages[]` 类型是所有已覆盖 `prop=` 字段的并集,可用 `QueryPage<K>` 收窄到本次请求的 prop,见文档[query 响应指南](https://
|
|
35
|
+
使用 `ApiQueryResponse` 的情况下,响应里的 `query.pages[]` 类型是所有已覆盖 `prop=` 字段的并集,可用 `QueryPage<K>` 收窄到本次请求的 prop,见文档[query 响应指南](https://types-mediawiki-response.pages.dev/zh/guide/query)。
|
|
36
36
|
|
|
37
37
|
## 扩展
|
|
38
38
|
|
|
@@ -54,4 +54,4 @@ import type { ApiThankResponse } from "types-mediawiki-response/ext/thanks";
|
|
|
54
54
|
const res = (await api.post({ action: "thank", rev })) as ApiThankResponse;
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
内置包清单见文档站的[扩展包指南](https://
|
|
57
|
+
内置包清单见文档站的[扩展包指南](https://types-mediawiki-response.pages.dev/zh/guide/ext-packs)。本包未覆盖的扩展,手写 `declare module 'types-mediawiki-response' { … }` 走同一接缝增广。
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in extension pack: **ReadingLists** (`meta=readinglists`,
|
|
3
|
+
* `list=readinglistentries`, `action=readinglists`).
|
|
4
|
+
*
|
|
5
|
+
* Not in the default export. Two shapes live here:
|
|
6
|
+
*
|
|
7
|
+
* - `meta=readinglists` / `list=readinglistentries` merge their result arrays
|
|
8
|
+
* into `ApiQueryResult` automatically — importing anything from this file
|
|
9
|
+
* activates the augmentation shipped at the bottom:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* import type {} from 'types-mediawiki-response/ext/readinglists';
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* - `action=readinglists` writes a root-level key named after the `command`
|
|
16
|
+
* submodule (`create`, `update`, `setup`, …); import the matching response
|
|
17
|
+
* type directly:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* import type { ApiReadingListsCreateResponse } from 'types-mediawiki-response/ext/readinglists';
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Both modules require a logged-in user: the reads check the
|
|
24
|
+
* `viewmyprivateinfo` right and the writes `editmyprivateinfo`, so an anonymous
|
|
25
|
+
* request gets a top-level `notloggedin` error and lists are always the current
|
|
26
|
+
* user's own. The extension marks its API internal (`isInternal()`), so the
|
|
27
|
+
* modules are omitted from public listings but still callable.
|
|
28
|
+
*
|
|
29
|
+
* fv2 notes: an id is a `number` inside a list/entry record but a *string* at
|
|
30
|
+
* the root of a write response (`id` / `ids`) — those carry the raw database
|
|
31
|
+
* value, uncoupled from the cast record. `duplicate` appears only while a
|
|
32
|
+
* write's repository row is merge-flagged (the create commands), never on a
|
|
33
|
+
* plain read. `deleted` (`true`) appears only in `changedsince` mode; a deleted
|
|
34
|
+
* list is reported under a `deleted-<hash>` name. The read continuation cursor
|
|
35
|
+
* (`rlcontinue`) is the extension's own and is not merged into
|
|
36
|
+
* `ApiQueryContinue`.
|
|
37
|
+
*
|
|
38
|
+
* @see https://www.mediawiki.org/wiki/Extension:ReadingLists
|
|
39
|
+
*/
|
|
40
|
+
import type { Timestamp } from "../common";
|
|
41
|
+
import type { ApiEnvelope } from "../envelope";
|
|
42
|
+
/**
|
|
43
|
+
* One reading list (`meta=readinglists`, and the `list`/`lists` payload of the
|
|
44
|
+
* `create` / `update` / `setup` commands).
|
|
45
|
+
*/
|
|
46
|
+
export interface ApiReadingListItem {
|
|
47
|
+
/** List id. */
|
|
48
|
+
id: number;
|
|
49
|
+
/** List title as set by the owner. */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Whether this is the user's catch-all default list. */
|
|
52
|
+
default: boolean;
|
|
53
|
+
/** Free-text description; `""` when none was set. */
|
|
54
|
+
description: string;
|
|
55
|
+
/** Creation time (ISO 8601). */
|
|
56
|
+
created: Timestamp;
|
|
57
|
+
/** Last update time (ISO 8601). */
|
|
58
|
+
updated: Timestamp;
|
|
59
|
+
/**
|
|
60
|
+
* Whether a list with the same name already existed, carried by the `create`
|
|
61
|
+
* command; absent on plain reads.
|
|
62
|
+
*/
|
|
63
|
+
duplicate?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* `true` for a list soft-deleted within the retention window; appears only in
|
|
66
|
+
* `changedsince` mode, where the list is reported under a `deleted-<hash>`
|
|
67
|
+
* `name`.
|
|
68
|
+
*/
|
|
69
|
+
deleted?: true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One page saved in a reading list (`list=readinglistentries`, and the
|
|
73
|
+
* `entry`/`entries` payload of the `createentry` command).
|
|
74
|
+
*/
|
|
75
|
+
export interface ApiReadingListEntry {
|
|
76
|
+
/** Entry id. */
|
|
77
|
+
id: number;
|
|
78
|
+
/** Id of the list this entry belongs to. */
|
|
79
|
+
listId: number;
|
|
80
|
+
/**
|
|
81
|
+
* Canonical base URL of the wiki the entry points to (port omitted, e.g.
|
|
82
|
+
* `https://www.mediawiki.org`). Entries are cross-wiki; the `@local` project
|
|
83
|
+
* value resolves to the serving wiki's own URL here.
|
|
84
|
+
*/
|
|
85
|
+
project: string;
|
|
86
|
+
/** Page title on {@link project}. */
|
|
87
|
+
title: string;
|
|
88
|
+
/** Creation time (ISO 8601). */
|
|
89
|
+
created: Timestamp;
|
|
90
|
+
/** Last update time (ISO 8601). */
|
|
91
|
+
updated: Timestamp;
|
|
92
|
+
/** Merge-detection flag of the `createentry` command; absent on plain reads. */
|
|
93
|
+
duplicate?: boolean;
|
|
94
|
+
/** `true` for an entry soft-deleted within the retention window; changes mode only. */
|
|
95
|
+
deleted?: true;
|
|
96
|
+
}
|
|
97
|
+
/** Response of `action=readinglists&command=setup` (no arguments). */
|
|
98
|
+
export interface ApiReadingListsSetupResponse extends ApiEnvelope {
|
|
99
|
+
/** Result of the `setup` command. */
|
|
100
|
+
setup: {
|
|
101
|
+
/** The user's default list, created for them. */
|
|
102
|
+
list: ApiReadingListItem;
|
|
103
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
104
|
+
result: "Success";
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Response of `action=readinglists&command=create`. A single `name` returns
|
|
109
|
+
* `id` + `list`; a `batch` returns `ids` + `lists`.
|
|
110
|
+
*/
|
|
111
|
+
export interface ApiReadingListsCreateResponse extends ApiEnvelope {
|
|
112
|
+
/** Result of the `create` command. */
|
|
113
|
+
create: {
|
|
114
|
+
/** New list id (raw database value) for a single create. */
|
|
115
|
+
id?: string;
|
|
116
|
+
/** New list for a single create. */
|
|
117
|
+
list?: ApiReadingListItem;
|
|
118
|
+
/** New list ids for a batch create. */
|
|
119
|
+
ids?: string[];
|
|
120
|
+
/** New lists for a batch create. */
|
|
121
|
+
lists?: ApiReadingListItem[];
|
|
122
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
123
|
+
result: "Success";
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Response of `action=readinglists&command=update`. A single `list` returns
|
|
128
|
+
* `id` + `list`; a `batch` returns `ids` + `lists`.
|
|
129
|
+
*/
|
|
130
|
+
export interface ApiReadingListsUpdateResponse extends ApiEnvelope {
|
|
131
|
+
/** Result of the `update` command. */
|
|
132
|
+
update: {
|
|
133
|
+
/** Updated list id (raw database value) for a single update. */
|
|
134
|
+
id?: string;
|
|
135
|
+
/** Updated list for a single update. */
|
|
136
|
+
list?: ApiReadingListItem;
|
|
137
|
+
/** Updated list ids for a batch update. */
|
|
138
|
+
ids?: string[];
|
|
139
|
+
/** Updated lists for a batch update. */
|
|
140
|
+
lists?: ApiReadingListItem[];
|
|
141
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
142
|
+
result: "Success";
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/** Response of `action=readinglists&command=delete` (single `list` or `batch`). */
|
|
146
|
+
export interface ApiReadingListsDeleteResponse extends ApiEnvelope {
|
|
147
|
+
/** Result of the `delete` command — a bare success sentinel. */
|
|
148
|
+
delete: {
|
|
149
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
150
|
+
result: "Success";
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Response of `action=readinglists&command=createentry`. A single `project` +
|
|
155
|
+
* `title` returns `id` + `entry`; a `batch` returns `ids` + `entries`.
|
|
156
|
+
*/
|
|
157
|
+
export interface ApiReadingListsCreateEntryResponse extends ApiEnvelope {
|
|
158
|
+
/** Result of the `createentry` command. */
|
|
159
|
+
createentry: {
|
|
160
|
+
/** New entry id (raw database value) for a single create. */
|
|
161
|
+
id?: string;
|
|
162
|
+
/** New entry for a single create. */
|
|
163
|
+
entry?: ApiReadingListEntry;
|
|
164
|
+
/** New entry ids for a batch create. */
|
|
165
|
+
ids?: string[];
|
|
166
|
+
/** New entries for a batch create. */
|
|
167
|
+
entries?: ApiReadingListEntry[];
|
|
168
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
169
|
+
result: "Success";
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Response of `action=readinglists&command=deleteentry` (single `entry` or
|
|
174
|
+
* `batch`).
|
|
175
|
+
*/
|
|
176
|
+
export interface ApiReadingListsDeleteEntryResponse extends ApiEnvelope {
|
|
177
|
+
/** Result of the `deleteentry` command — a bare success sentinel. */
|
|
178
|
+
deleteentry: {
|
|
179
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
180
|
+
result: "Success";
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/** Response of `action=readinglists&command=teardown` (no arguments). */
|
|
184
|
+
export interface ApiReadingListsTeardownResponse extends ApiEnvelope {
|
|
185
|
+
/** Result of the `teardown` command — a bare success sentinel. */
|
|
186
|
+
teardown: {
|
|
187
|
+
/** Always `Success` on the success branch; failures are top-level errors. */
|
|
188
|
+
result: "Success";
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
declare module "types-mediawiki-response" {
|
|
192
|
+
interface ApiQueryResult {
|
|
193
|
+
/**
|
|
194
|
+
* The current user's reading lists. `meta=readinglists`.
|
|
195
|
+
*/
|
|
196
|
+
readinglists?: ApiReadingListItem[];
|
|
197
|
+
/**
|
|
198
|
+
* A sync watermark: querying with this timestamp as `changedsince`
|
|
199
|
+
* guarantees no intervening change is skipped. Sibling of {@link readinglists},
|
|
200
|
+
* `meta=readinglists`; omitted on continuation requests.
|
|
201
|
+
*/
|
|
202
|
+
"readinglists-synctimestamp"?: Timestamp;
|
|
203
|
+
/**
|
|
204
|
+
* Pages saved in the requested list(s). `list=readinglistentries` (or
|
|
205
|
+
* `generator=readinglistentries`, where the entries feed `pages` and this
|
|
206
|
+
* array comes back empty).
|
|
207
|
+
*/
|
|
208
|
+
readinglistentries?: ApiReadingListEntry[];
|
|
209
|
+
}
|
|
210
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "types-mediawiki-response",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "TypeScript type definitions for MediaWiki Action API responses",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"action-api",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"typescript",
|
|
11
11
|
"wiki"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://types-mediawiki-response.pages.dev/",
|
|
14
14
|
"bugs": {
|
|
15
15
|
"url": "https://github.com/BearBin1215/types-mediawiki-response/issues"
|
|
16
16
|
},
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"@types/node": "^26.6.3",
|
|
66
66
|
"bumpp": "^12.3.0",
|
|
67
67
|
"expect-type": "1.4.0",
|
|
68
|
-
"oxfmt": "0.
|
|
69
|
-
"oxlint": "1.
|
|
68
|
+
"oxfmt": "0.72.0",
|
|
69
|
+
"oxlint": "1.87.0",
|
|
70
70
|
"tsx": "^4.23.13",
|
|
71
71
|
"typescript": "^7.0.2"
|
|
72
72
|
},
|