@ukwhatn/wikidot 1.0.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/dist/common/decorators.d.ts +0 -0
- package/dist/common/decorators.js +2 -0
- package/dist/common/decorators.js.map +1 -0
- package/dist/common/exceptions.d.ts +95 -0
- package/dist/common/exceptions.js +146 -0
- package/dist/common/exceptions.js.map +1 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.js +6 -0
- package/dist/common/index.js.map +1 -0
- package/dist/common/logger.d.ts +2 -0
- package/dist/common/logger.js +19 -0
- package/dist/common/logger.js.map +1 -0
- package/dist/connector/ajax.d.ts +142 -0
- package/dist/connector/ajax.js +259 -0
- package/dist/connector/ajax.js.map +1 -0
- package/dist/connector/api.d.ts +11 -0
- package/dist/connector/api.js +17 -0
- package/dist/connector/api.js.map +1 -0
- package/dist/connector/index.d.ts +0 -0
- package/dist/connector/index.js +2 -0
- package/dist/connector/index.js.map +1 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/module/auth.d.ts +8 -0
- package/dist/module/auth.js +77 -0
- package/dist/module/auth.js.map +1 -0
- package/dist/module/client.d.ts +39 -0
- package/dist/module/client.js +97 -0
- package/dist/module/client.js.map +1 -0
- package/dist/module/index.d.ts +0 -0
- package/dist/module/index.js +2 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/page.d.ts +81 -0
- package/dist/module/page.js +267 -0
- package/dist/module/page.js.map +1 -0
- package/dist/module/privateMessage.d.ts +29 -0
- package/dist/module/privateMessage.js +128 -0
- package/dist/module/privateMessage.js.map +1 -0
- package/dist/module/site.d.ts +32 -0
- package/dist/module/site.js +115 -0
- package/dist/module/site.js.map +1 -0
- package/dist/module/siteApplication.d.ts +14 -0
- package/dist/module/siteApplication.js +96 -0
- package/dist/module/siteApplication.js.map +1 -0
- package/dist/module/user.d.ts +56 -0
- package/dist/module/user.js +115 -0
- package/dist/module/user.js.map +1 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/index.js +10 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/parser/index.d.ts +1 -0
- package/dist/util/parser/index.js +18 -0
- package/dist/util/parser/index.js.map +1 -0
- package/dist/util/parser/odate.d.ts +12 -0
- package/dist/util/parser/odate.js +25 -0
- package/dist/util/parser/odate.js.map +1 -0
- package/dist/util/parser/user.d.ts +16 -0
- package/dist/util/parser/user.js +36 -0
- package/dist/util/parser/user.js.map +1 -0
- package/dist/util/quickModule.d.ts +96 -0
- package/dist/util/quickModule.js +137 -0
- package/dist/util/quickModule.js.map +1 -0
- package/dist/util/requestUtil.d.ts +26 -0
- package/dist/util/requestUtil.js +69 -0
- package/dist/util/requestUtil.js.map +1 -0
- package/dist/util/stringUtil.d.ts +20 -0
- package/dist/util/stringUtil.js +47 -0
- package/dist/util/stringUtil.js.map +1 -0
- package/dist/util/table/charTable.d.ts +3 -0
- package/dist/util/table/charTable.js +472 -0
- package/dist/util/table/charTable.js.map +1 -0
- package/dist/util/table/index.d.ts +1 -0
- package/dist/util/table/index.js +18 -0
- package/dist/util/table/index.js.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Page = exports.PageCollection = exports.SearchPagesQuery = void 0;
|
|
27
|
+
const exceptions_1 = require("../common/exceptions");
|
|
28
|
+
const user_1 = require("../util/parser/user");
|
|
29
|
+
const parser_1 = require("../util/parser");
|
|
30
|
+
const util_1 = require("../util");
|
|
31
|
+
const cheerio = __importStar(require("cheerio"));
|
|
32
|
+
const DEFAULT_MODULE_BODY = [
|
|
33
|
+
"fullname",
|
|
34
|
+
"category",
|
|
35
|
+
"name",
|
|
36
|
+
"title",
|
|
37
|
+
"created_at",
|
|
38
|
+
"created_by_linked",
|
|
39
|
+
"updated_at",
|
|
40
|
+
"updated_by_linked",
|
|
41
|
+
"commented_at",
|
|
42
|
+
"commented_by_linked",
|
|
43
|
+
"parent_fullname",
|
|
44
|
+
"comments",
|
|
45
|
+
"size",
|
|
46
|
+
"children",
|
|
47
|
+
"rating_votes",
|
|
48
|
+
"rating",
|
|
49
|
+
"rating_percent",
|
|
50
|
+
"revisions",
|
|
51
|
+
"tags",
|
|
52
|
+
"_tags"
|
|
53
|
+
];
|
|
54
|
+
// noinspection JSUnusedGlobalSymbols
|
|
55
|
+
class SearchPagesQuery {
|
|
56
|
+
constructor(init) {
|
|
57
|
+
this.pagetype = "*";
|
|
58
|
+
this.category = "*";
|
|
59
|
+
this.tags = undefined;
|
|
60
|
+
this.parent = undefined;
|
|
61
|
+
this.linkTo = undefined;
|
|
62
|
+
this.createdAt = undefined;
|
|
63
|
+
this.updatedAt = undefined;
|
|
64
|
+
this.createdBy = undefined;
|
|
65
|
+
this.rating = undefined;
|
|
66
|
+
this.votes = undefined;
|
|
67
|
+
this.name = undefined;
|
|
68
|
+
this.fullname = undefined;
|
|
69
|
+
this.range = undefined;
|
|
70
|
+
this.order = "created_at desc";
|
|
71
|
+
this.offset = 0;
|
|
72
|
+
this.limit = undefined;
|
|
73
|
+
this.perPage = 250;
|
|
74
|
+
this.separate = "no";
|
|
75
|
+
this.wrapper = "no";
|
|
76
|
+
Object.assign(this, init);
|
|
77
|
+
}
|
|
78
|
+
asDict() {
|
|
79
|
+
const res = {};
|
|
80
|
+
for (const [key, value] of Object.entries(this)) {
|
|
81
|
+
if (value !== undefined) {
|
|
82
|
+
res[key] = value;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (res.tags && Array.isArray(res.tags)) {
|
|
86
|
+
res.tags = res.tags.join(" ");
|
|
87
|
+
}
|
|
88
|
+
return res;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.SearchPagesQuery = SearchPagesQuery;
|
|
92
|
+
class PageCollection extends Array {
|
|
93
|
+
static _parse(site, htmlBody) {
|
|
94
|
+
const pages = new PageCollection();
|
|
95
|
+
for (const _pageElement of htmlBody("span.page").toArray()) {
|
|
96
|
+
const pageElement = cheerio.load(_pageElement);
|
|
97
|
+
const pageParams = {};
|
|
98
|
+
const is5starRating = pageElement("span.rating span.page-rate-list-pages-start").length > 0;
|
|
99
|
+
for (const setElement of pageElement("span.set").toArray()) {
|
|
100
|
+
let key = cheerio.load(setElement)("span.name").text().trim();
|
|
101
|
+
const valueElement = cheerio.load(setElement)("span.value");
|
|
102
|
+
let value = undefined;
|
|
103
|
+
if (valueElement.length === 0) {
|
|
104
|
+
value = undefined;
|
|
105
|
+
}
|
|
106
|
+
else if (["created_at", "updated_at", "commented_at"].includes(key)) {
|
|
107
|
+
const odateElement = valueElement.find("span.odate");
|
|
108
|
+
value = odateElement.length > 0 ? (0, parser_1.odateParse)(odateElement) : undefined;
|
|
109
|
+
}
|
|
110
|
+
else if (["created_by_linked", "updated_by_linked", "commented_by_linked"].includes(key)) {
|
|
111
|
+
const printuserElement = valueElement.find("span.printuser");
|
|
112
|
+
value = printuserElement.length > 0 ? (0, user_1.userParse)(site.client, printuserElement) : undefined;
|
|
113
|
+
}
|
|
114
|
+
else if (["tags", "_tags"].includes(key)) {
|
|
115
|
+
value = valueElement.text().split(/\s+/);
|
|
116
|
+
}
|
|
117
|
+
else if (["rating_votes", "comments", "size", "revisions"].includes(key)) {
|
|
118
|
+
value = parseInt(valueElement.text().trim(), 10);
|
|
119
|
+
}
|
|
120
|
+
else if (key === "rating") {
|
|
121
|
+
value = is5starRating ? parseFloat(valueElement.text().trim()) : parseInt(valueElement.text().trim(), 10);
|
|
122
|
+
}
|
|
123
|
+
else if (key === "rating_percent") {
|
|
124
|
+
value = is5starRating ? parseFloat(valueElement.text().trim()) / 100 : undefined;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
value = valueElement.text().trim();
|
|
128
|
+
}
|
|
129
|
+
if (key.endsWith("_linked")) {
|
|
130
|
+
key = key.slice(0, -7);
|
|
131
|
+
}
|
|
132
|
+
else if (["comments", "children"].includes(key)) {
|
|
133
|
+
key = `${key}_count`;
|
|
134
|
+
}
|
|
135
|
+
else if (key === "rating_votes") {
|
|
136
|
+
key = "votes";
|
|
137
|
+
}
|
|
138
|
+
pageParams[key] = value;
|
|
139
|
+
}
|
|
140
|
+
for (const key of ["tags", "_tags"]) {
|
|
141
|
+
if (!pageParams[key]) {
|
|
142
|
+
pageParams[key] = [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
pageParams.tags = [...pageParams.tags, ...pageParams._tags];
|
|
146
|
+
delete pageParams._tags;
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
pages.push(new Page(site, pageParams));
|
|
149
|
+
}
|
|
150
|
+
return pages;
|
|
151
|
+
}
|
|
152
|
+
static async searchPages(site, query = new SearchPagesQuery()) {
|
|
153
|
+
const queryDict = query.asDict();
|
|
154
|
+
queryDict.moduleName = "list/ListPagesModule";
|
|
155
|
+
queryDict.module_body = '[[span class="page"]]' + DEFAULT_MODULE_BODY.map(key => `[[span class="set ${key}"]]` +
|
|
156
|
+
`[[span class="name"]] ${key} [[/span]]` +
|
|
157
|
+
`[[span class="value"]] %%${key}%% [[/span]]` +
|
|
158
|
+
`[[/span]]`).join("") + "[[/span]]";
|
|
159
|
+
let response;
|
|
160
|
+
try {
|
|
161
|
+
response = (await site.amcRequest([queryDict]))[0];
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
if (error instanceof exceptions_1.WikidotStatusCodeException) {
|
|
165
|
+
if (error.statusCode === "not_ok") {
|
|
166
|
+
throw new exceptions_1.ForbiddenException("Failed to get pages, target site may be private");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
const body = response.data.body;
|
|
172
|
+
const firstPageHtmlBody = cheerio.load(body);
|
|
173
|
+
let total = 1;
|
|
174
|
+
const htmlBodies = [firstPageHtmlBody];
|
|
175
|
+
if (firstPageHtmlBody("div.pager").length > 0) {
|
|
176
|
+
total = parseInt(firstPageHtmlBody("div.pager span.target").eq(-2).find("a").text(), 10);
|
|
177
|
+
}
|
|
178
|
+
if (total > 1) {
|
|
179
|
+
const requestBodies = [];
|
|
180
|
+
for (let i = 1; i < total; i++) {
|
|
181
|
+
const _queryDict = { ...queryDict };
|
|
182
|
+
_queryDict.offset = i * query.perPage;
|
|
183
|
+
requestBodies.push(_queryDict);
|
|
184
|
+
}
|
|
185
|
+
const responses = await site.amcRequest(requestBodies);
|
|
186
|
+
htmlBodies.push(...responses.map(response => cheerio.load(response.data.body)));
|
|
187
|
+
}
|
|
188
|
+
const pages = new PageCollection();
|
|
189
|
+
for (const htmlBody of htmlBodies) {
|
|
190
|
+
pages.push(...PageCollection._parse(site, htmlBody));
|
|
191
|
+
}
|
|
192
|
+
return pages;
|
|
193
|
+
}
|
|
194
|
+
static async _acquirePageIds(pages) {
|
|
195
|
+
const targetPages = pages.filter(page => !page.isIdAcquired());
|
|
196
|
+
if (targetPages.length === 0) {
|
|
197
|
+
return pages;
|
|
198
|
+
}
|
|
199
|
+
const responses = await util_1.RequestUtil.request(targetPages[0].site.client, "GET", targetPages.map(page => `${page.getUrl()}/norender/true/noredirect/true`));
|
|
200
|
+
for (const [index, response] of responses.entries()) {
|
|
201
|
+
// @ts-ignore
|
|
202
|
+
const idMatch = response?.data.match(/WIKIREQUEST\.info\.pageId = (\d+);/);
|
|
203
|
+
if (!idMatch) {
|
|
204
|
+
throw new exceptions_1.UnexpectedException(`Cannot find page id: ${targetPages[index].fullname}`);
|
|
205
|
+
}
|
|
206
|
+
targetPages[index].id = parseInt(idMatch[1], 10);
|
|
207
|
+
}
|
|
208
|
+
return pages;
|
|
209
|
+
}
|
|
210
|
+
// noinspection JSUnusedGlobalSymbols
|
|
211
|
+
async getPageIds() {
|
|
212
|
+
return await PageCollection._acquirePageIds(this);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
exports.PageCollection = PageCollection;
|
|
216
|
+
class Page {
|
|
217
|
+
constructor(site, { fullname, name, category, title, children_count, comments_count, size, rating, votes, rating_percent, revisions, parent_fullname, tags, created_by, created_at, updated_by, updated_at, commented_by, commented_at }) {
|
|
218
|
+
this.site = site;
|
|
219
|
+
this.fullname = fullname;
|
|
220
|
+
this.name = name;
|
|
221
|
+
this.category = category;
|
|
222
|
+
this.title = title;
|
|
223
|
+
this.childrenCount = children_count;
|
|
224
|
+
this.commentsCount = comments_count;
|
|
225
|
+
this.size = size;
|
|
226
|
+
this.rating = rating ?? undefined;
|
|
227
|
+
this.votes = votes;
|
|
228
|
+
this.ratingPercent = rating_percent ?? undefined;
|
|
229
|
+
this.revisions = revisions;
|
|
230
|
+
this.parentFullname = parent_fullname ?? undefined;
|
|
231
|
+
this.tags = tags;
|
|
232
|
+
this.createdBy = created_by;
|
|
233
|
+
this.createdAt = created_at;
|
|
234
|
+
this.updatedBy = updated_by ?? undefined;
|
|
235
|
+
this.updatedAt = updated_at ?? undefined;
|
|
236
|
+
this.commentedBy = commented_by ?? undefined;
|
|
237
|
+
this.commentedAt = commented_at ?? undefined;
|
|
238
|
+
}
|
|
239
|
+
getUrl() {
|
|
240
|
+
return `${this.site.getUrl()}/${this.fullname}`;
|
|
241
|
+
}
|
|
242
|
+
get id() {
|
|
243
|
+
if (this._id === undefined) {
|
|
244
|
+
return PageCollection._acquirePageIds([this]).then(() => this._id);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return Promise.resolve(this._id);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
set id(value) {
|
|
251
|
+
this._id = value;
|
|
252
|
+
}
|
|
253
|
+
isIdAcquired() {
|
|
254
|
+
return this._id !== undefined;
|
|
255
|
+
}
|
|
256
|
+
async destroy() {
|
|
257
|
+
this.site.client.loginCheck();
|
|
258
|
+
await this.site.amcRequest([{
|
|
259
|
+
action: "WikiPageAction",
|
|
260
|
+
event: "deletePage",
|
|
261
|
+
page_id: await this.id,
|
|
262
|
+
moduleName: "Empty"
|
|
263
|
+
}]);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.Page = Page;
|
|
267
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/module/page.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAAyG;AACzG,8CAA8C;AAC9C,2CAA0C;AAC1C,kCAAoC;AACpC,iDAAmC;AAEnC,MAAM,mBAAmB,GAAG;IACxB,UAAU;IACV,UAAU;IACV,MAAM;IACN,OAAO;IACP,YAAY;IACZ,mBAAmB;IACnB,YAAY;IACZ,mBAAmB;IACnB,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M,CAAC,UAAU,EAAE,CAAC;QAC9B,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;gBACxB,MAAM,EAAE,gBAAgB;gBACxB,KAAK,EAAE,YAAY;gBACnB,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE;gBACtB,UAAU,EAAE,OAAO;aACtB,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAEyC,oBAAI"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Client } from './client';
|
|
2
|
+
import { AbstractUser, User } from './user';
|
|
3
|
+
declare class PrivateMessageCollection extends Array<PrivateMessage> {
|
|
4
|
+
toString(): string;
|
|
5
|
+
static fromIds(client: Client, messageIds: number[]): Promise<PrivateMessageCollection>;
|
|
6
|
+
protected static _acquire(client: Client, moduleName: string): Promise<PrivateMessageCollection>;
|
|
7
|
+
}
|
|
8
|
+
declare class PrivateMessageInbox extends PrivateMessageCollection {
|
|
9
|
+
static fromIds(client: Client, messageIds: number[]): Promise<PrivateMessageInbox>;
|
|
10
|
+
static acquire(client: Client): Promise<PrivateMessageInbox>;
|
|
11
|
+
}
|
|
12
|
+
declare class PrivateMessageSentBox extends PrivateMessageCollection {
|
|
13
|
+
static fromIds(client: Client, messageIds: number[]): Promise<PrivateMessageSentBox>;
|
|
14
|
+
static acquire(client: Client): Promise<PrivateMessageSentBox>;
|
|
15
|
+
}
|
|
16
|
+
declare class PrivateMessage {
|
|
17
|
+
client: Client;
|
|
18
|
+
id: number;
|
|
19
|
+
sender: AbstractUser;
|
|
20
|
+
recipient: AbstractUser;
|
|
21
|
+
subject: string;
|
|
22
|
+
body: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
constructor(client: Client, id: number, sender: AbstractUser, recipient: AbstractUser, subject: string, body: string, createdAt: Date);
|
|
25
|
+
toString(): string;
|
|
26
|
+
static fromId(client: Client, messageId: number): Promise<PrivateMessage>;
|
|
27
|
+
static send(client: Client, recipient: User, subject: string, body: string): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export { PrivateMessageCollection, PrivateMessageInbox, PrivateMessageSentBox, PrivateMessage };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.PrivateMessage = exports.PrivateMessageSentBox = exports.PrivateMessageInbox = exports.PrivateMessageCollection = void 0;
|
|
27
|
+
const exceptions_1 = require("../common/exceptions");
|
|
28
|
+
const cheerio = __importStar(require("cheerio"));
|
|
29
|
+
const parser_1 = require("../util/parser");
|
|
30
|
+
const user_1 = require("../util/parser/user");
|
|
31
|
+
class PrivateMessageCollection extends Array {
|
|
32
|
+
toString() {
|
|
33
|
+
return `${this.constructor.name}(${this.length} messages)`;
|
|
34
|
+
}
|
|
35
|
+
static async fromIds(client, messageIds) {
|
|
36
|
+
const bodies = messageIds.map(messageId => ({
|
|
37
|
+
item: messageId,
|
|
38
|
+
moduleName: 'dashboard/messages/DMViewMessageModule'
|
|
39
|
+
}));
|
|
40
|
+
client.loginCheck();
|
|
41
|
+
const responses = await client.amcClient.request(bodies, true);
|
|
42
|
+
const messages = [];
|
|
43
|
+
for (const [index, response] of responses.entries()) {
|
|
44
|
+
if (response instanceof exceptions_1.WikidotStatusCodeException) {
|
|
45
|
+
if (response.statusCode === 'no_message') {
|
|
46
|
+
throw new exceptions_1.ForbiddenException(`Failed to get message: ${messageIds[index]}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (response instanceof Error) {
|
|
50
|
+
throw response;
|
|
51
|
+
}
|
|
52
|
+
const html = cheerio.load(response.data.body);
|
|
53
|
+
const [sender, recipient] = html('div.pmessage div.header span.printuser').get();
|
|
54
|
+
messages.push(new PrivateMessage(client, messageIds[index], (0, user_1.userParse)(client, html(sender)), (0, user_1.userParse)(client, html(recipient)), html('div.pmessage div.header span.subject').text(), html('div.pmessage div.body').text(), (0, parser_1.odateParse)(html('div.header span.odate'))));
|
|
55
|
+
}
|
|
56
|
+
return new PrivateMessageCollection(...messages);
|
|
57
|
+
}
|
|
58
|
+
static async _acquire(client, moduleName) {
|
|
59
|
+
client.loginCheck();
|
|
60
|
+
const response = (await client.amcClient.request([{ moduleName }]))[0];
|
|
61
|
+
if (response instanceof Error)
|
|
62
|
+
throw response;
|
|
63
|
+
const html = cheerio.load(response.data.body);
|
|
64
|
+
const pager = html('div.pager span.target');
|
|
65
|
+
const maxPage = pager.length > 2 ? Number(pager.eq(-2).text()) : 1;
|
|
66
|
+
const responses = maxPage > 1
|
|
67
|
+
? await client.amcClient.request(Array.from({ length: maxPage }, (_, i) => ({ page: i + 1, moduleName })), false)
|
|
68
|
+
: [response];
|
|
69
|
+
const messageIds = [];
|
|
70
|
+
for (const response of responses) {
|
|
71
|
+
if (response instanceof Error)
|
|
72
|
+
throw response;
|
|
73
|
+
const html = cheerio.load(response.data.body);
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
messageIds.push(...html('tr.message').map((_, tr) => Number(html(tr).data('href').split('/').pop())).get());
|
|
76
|
+
}
|
|
77
|
+
return PrivateMessageCollection.fromIds(client, messageIds);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.PrivateMessageCollection = PrivateMessageCollection;
|
|
81
|
+
class PrivateMessageInbox extends PrivateMessageCollection {
|
|
82
|
+
static async fromIds(client, messageIds) {
|
|
83
|
+
return new PrivateMessageInbox(...await PrivateMessageCollection.fromIds(client, messageIds));
|
|
84
|
+
}
|
|
85
|
+
static async acquire(client) {
|
|
86
|
+
return new PrivateMessageInbox(...await PrivateMessageCollection._acquire(client, 'dashboard/messages/DMInboxModule'));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.PrivateMessageInbox = PrivateMessageInbox;
|
|
90
|
+
class PrivateMessageSentBox extends PrivateMessageCollection {
|
|
91
|
+
static async fromIds(client, messageIds) {
|
|
92
|
+
return new PrivateMessageSentBox(...await PrivateMessageCollection.fromIds(client, messageIds));
|
|
93
|
+
}
|
|
94
|
+
static async acquire(client) {
|
|
95
|
+
return new PrivateMessageSentBox(...await PrivateMessageCollection._acquire(client, 'dashboard/messages/DMSentModule'));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.PrivateMessageSentBox = PrivateMessageSentBox;
|
|
99
|
+
class PrivateMessage {
|
|
100
|
+
constructor(client, id, sender, recipient, subject, body, createdAt) {
|
|
101
|
+
this.client = client;
|
|
102
|
+
this.id = id;
|
|
103
|
+
this.sender = sender;
|
|
104
|
+
this.recipient = recipient;
|
|
105
|
+
this.subject = subject;
|
|
106
|
+
this.body = body;
|
|
107
|
+
this.createdAt = createdAt;
|
|
108
|
+
}
|
|
109
|
+
toString() {
|
|
110
|
+
return `PrivateMessage(id=${this.id}, sender=${this.sender}, recipient=${this.recipient}, subject=${this.subject})`;
|
|
111
|
+
}
|
|
112
|
+
static async fromId(client, messageId) {
|
|
113
|
+
return (await PrivateMessageCollection.fromIds(client, [messageId]))[0];
|
|
114
|
+
}
|
|
115
|
+
static async send(client, recipient, subject, body) {
|
|
116
|
+
client.loginCheck();
|
|
117
|
+
await client.amcClient.request([{
|
|
118
|
+
source: body,
|
|
119
|
+
subject: subject,
|
|
120
|
+
to_user_id: recipient.id,
|
|
121
|
+
action: 'DashboardMessageAction',
|
|
122
|
+
event: 'send',
|
|
123
|
+
moduleName: 'Empty'
|
|
124
|
+
}]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.PrivateMessage = PrivateMessage;
|
|
128
|
+
//# sourceMappingURL=privateMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privateMessage.js","sourceRoot":"","sources":["../../src/module/privateMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAoF;AAGpF,iDAAmC;AACnC,2CAA0C;AAC1C,8CAA8C;AAE9C,MAAM,wBAAyB,SAAQ,KAAqB;IACxD,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,YAAY,CAAC;IAC/D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,UAAoB;QACrD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YACxC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,wCAAwC;SACvD,CAAC,CAAC,CAAC;QAEJ,MAAM,CAAC,UAAU,EAAE,CAAC;QAEpB,MAAM,SAAS,GAA8B,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAE1F,MAAM,Q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MAAM,CAAc;QACpB,cAAS,GAAT,SAAS,CAAc;QACvB,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAM;IAE1B,CAAC;IAED,QAAQ;QACJ,OAAO,qBAAqB,IAAI,CAAC,EAAE,YAAY,IAAI,CAAC,MAAM,eAAe,IAAI,CAAC,SAAS,aAAa,IAAI,CAAC,OAAO,GAAG,CAAC;IACxH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,SAAiB;QACjD,OAAO,CAAC,MAAM,wBAAwB,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,SAAe,EAAE,OAAe,EAAE,IAAY;QAC5E,MAAM,CAAC,UAAU,EAAE,CAAC;QACpB,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;gBAC5B,MAAM,EAAE,IAAI;gBACZ,OAAO,EAAE,OAAO;gBAChB,UAAU,EAAE,SAAS,CAAC,EAAE;gBACxB,MAAM,EAAE,wBAAwB;gBAChC,KAAK,EAAE,MAAM;gBACb,UAAU,EAAE,OAAO;aACtB,CAAC,CAAC,CAAC;IACR,CAAC;CACJ;AAE6E,wCAAc"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Client } from './client';
|
|
2
|
+
import { User } from './user';
|
|
3
|
+
import { Page, SearchPagesQuery, PageCollection } from './page';
|
|
4
|
+
import { SiteApplication } from './siteApplication';
|
|
5
|
+
declare class SitePagesMethods {
|
|
6
|
+
private site;
|
|
7
|
+
constructor(site: Site);
|
|
8
|
+
search(query: Partial<SearchPagesQuery>): Promise<PageCollection>;
|
|
9
|
+
}
|
|
10
|
+
declare class SitePageMethods {
|
|
11
|
+
private site;
|
|
12
|
+
constructor(site: Site);
|
|
13
|
+
get(fullname: string, raiseWhenNotFound?: boolean): Promise<Page | null>;
|
|
14
|
+
}
|
|
15
|
+
declare class Site {
|
|
16
|
+
client: Client;
|
|
17
|
+
id: number;
|
|
18
|
+
title: string;
|
|
19
|
+
unixName: string;
|
|
20
|
+
domain: string;
|
|
21
|
+
sslSupported: boolean;
|
|
22
|
+
pages: SitePagesMethods;
|
|
23
|
+
page: SitePageMethods;
|
|
24
|
+
constructor(client: Client, id: number, title: string, unixName: string, domain: string, sslSupported: boolean);
|
|
25
|
+
toString(): string;
|
|
26
|
+
static fromUnixName(client: Client, unixName: string): Promise<Site>;
|
|
27
|
+
amcRequest(bodies: object[], returnExceptions?: boolean): Promise<any[]>;
|
|
28
|
+
getApplications(): Promise<SiteApplication[]>;
|
|
29
|
+
inviteUser(user: User, text: string): Promise<void>;
|
|
30
|
+
getUrl(): string;
|
|
31
|
+
}
|
|
32
|
+
export { Site };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Site = void 0;
|
|
7
|
+
const page_1 = require("./page");
|
|
8
|
+
const siteApplication_1 = require("./siteApplication");
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const exceptions_1 = require("../common/exceptions");
|
|
11
|
+
class SitePagesMethods {
|
|
12
|
+
constructor(site) {
|
|
13
|
+
this.site = site;
|
|
14
|
+
}
|
|
15
|
+
async search(query) {
|
|
16
|
+
const _query = new page_1.SearchPagesQuery(query);
|
|
17
|
+
return await page_1.PageCollection.searchPages(this.site, _query);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
class SitePageMethods {
|
|
21
|
+
constructor(site) {
|
|
22
|
+
this.site = site;
|
|
23
|
+
}
|
|
24
|
+
async get(fullname, raiseWhenNotFound = true) {
|
|
25
|
+
const res = await page_1.PageCollection.searchPages(this.site, new page_1.SearchPagesQuery({ fullname }));
|
|
26
|
+
if (res.length === 0) {
|
|
27
|
+
if (raiseWhenNotFound) {
|
|
28
|
+
throw new exceptions_1.NotFoundException(`Page is not found: ${fullname}`);
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return res[0];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
class Site {
|
|
36
|
+
constructor(client, id, title, unixName, domain, sslSupported) {
|
|
37
|
+
this.client = client;
|
|
38
|
+
this.id = id;
|
|
39
|
+
this.title = title;
|
|
40
|
+
this.unixName = unixName;
|
|
41
|
+
this.domain = domain;
|
|
42
|
+
this.sslSupported = sslSupported;
|
|
43
|
+
this.pages = new SitePagesMethods(this);
|
|
44
|
+
this.page = new SitePageMethods(this);
|
|
45
|
+
}
|
|
46
|
+
toString() {
|
|
47
|
+
return `Site(id=${this.id}, title=${this.title}, unixName=${this.unixName})`;
|
|
48
|
+
}
|
|
49
|
+
static async fromUnixName(client, unixName) {
|
|
50
|
+
const response = await axios_1.default.get(`http://${unixName}.wikidot.com`, {
|
|
51
|
+
maxRedirects: 5,
|
|
52
|
+
timeout: client.amcClient.config.requestTimeout * 1000
|
|
53
|
+
});
|
|
54
|
+
if (response.status === 404) {
|
|
55
|
+
throw new exceptions_1.NotFoundException(`Site is not found: ${unixName}.wikidot.com`);
|
|
56
|
+
}
|
|
57
|
+
const source = response.data;
|
|
58
|
+
const idMatch = source.match(/WIKIREQUEST\.info\.siteId = (\d+);/);
|
|
59
|
+
if (!idMatch) {
|
|
60
|
+
throw new exceptions_1.UnexpectedException(`Cannot find site id: ${unixName}.wikidot.com`);
|
|
61
|
+
}
|
|
62
|
+
const siteId = Number(idMatch[1]);
|
|
63
|
+
const titleMatch = source.match(/<title>(.*?)<\/title>/);
|
|
64
|
+
if (!titleMatch) {
|
|
65
|
+
throw new exceptions_1.UnexpectedException(`Cannot find site title: ${unixName}.wikidot.com`);
|
|
66
|
+
}
|
|
67
|
+
const title = titleMatch[1];
|
|
68
|
+
const unixNameMatch = source.match(/WIKIREQUEST\.info\.siteUnixName = "(.*?)";/);
|
|
69
|
+
if (!unixNameMatch) {
|
|
70
|
+
throw new exceptions_1.UnexpectedException(`Cannot find site unixName: ${unixName}.wikidot.com`);
|
|
71
|
+
}
|
|
72
|
+
unixName = unixNameMatch[1];
|
|
73
|
+
const domainMatch = source.match(/WIKIREQUEST\.info\.domain = "(.*?)";/);
|
|
74
|
+
if (!domainMatch) {
|
|
75
|
+
throw new exceptions_1.UnexpectedException(`Cannot find site domain: ${unixName}.wikidot.com`);
|
|
76
|
+
}
|
|
77
|
+
const domain = domainMatch[1];
|
|
78
|
+
const sslSupported = response.request.protocol === 'https:';
|
|
79
|
+
return new Site(client, siteId, title, unixName, domain, sslSupported);
|
|
80
|
+
}
|
|
81
|
+
amcRequest(bodies, returnExceptions = false) {
|
|
82
|
+
return this.client.amcClient.request(bodies, returnExceptions, this.unixName, this.sslSupported);
|
|
83
|
+
}
|
|
84
|
+
async getApplications() {
|
|
85
|
+
return await siteApplication_1.SiteApplication.acquireAll(this);
|
|
86
|
+
}
|
|
87
|
+
async inviteUser(user, text) {
|
|
88
|
+
user.client.loginCheck();
|
|
89
|
+
try {
|
|
90
|
+
await this.amcRequest([{
|
|
91
|
+
action: 'ManageSiteMembershipAction',
|
|
92
|
+
event: 'inviteMember',
|
|
93
|
+
user_id: user.id,
|
|
94
|
+
text: text,
|
|
95
|
+
moduleName: 'Empty'
|
|
96
|
+
}]);
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error instanceof exceptions_1.WikidotStatusCodeException) {
|
|
100
|
+
if (error.statusCode === 'already_invited') {
|
|
101
|
+
throw new exceptions_1.TargetErrorException(`User is already invited to ${this.unixName}: ${user.name}`);
|
|
102
|
+
}
|
|
103
|
+
else if (error.statusCode === 'already_member') {
|
|
104
|
+
throw new exceptions_1.TargetErrorException(`User is already a member of ${this.unixName}: ${user.name}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
getUrl() {
|
|
111
|
+
return `http${this.sslSupported ? 's' : ''}://${this.domain}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.Site = Site;
|
|
115
|
+
//# sourceMappingURL=site.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.js","sourceRoot":"","sources":["../../src/module/site.ts"],"names":[],"mappings":";;;;;;AAEA,iCAA8D;AAC9D,uDAAkD;AAClD,kDAA2C;AAC3C,qDAK8B;AAE9B,MAAM,gBAAgB;IAClB,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,KAAgC;QACzC,MAAM,MAAM,GAAG,IAAI,uBAAgB,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,MAAM,qBAAc,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AAED,MAAM,eAAe;IACjB,YAAoB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAC9B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,oBAA6B,IAAI;QACzD,MAAM,GAAG,GAAG,MAAM,qBAAc,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,uBAAgB,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnB,IAAI,iBAAiB,EAAE,CAAC;gBACpB,MAAM,IAAI,8BAAiB,CAAC,sBAAsB,QAAQ,EAAE,CAAC,CAAC;YAClE,CAAC;YACD,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,GAAG,CAAC,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C;IAED,KAAK,CAAC,UAAU,CAAC,IAAU,EAAE,IAAY;QACrC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACzB,IAAI,CAAC;YACD,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC;oBACnB,MAAM,EAAE,4BAA4B;oBACpC,KAAK,EAAE,cAAc;oBACrB,OAAO,EAAE,IAAI,CAAC,EAAE;oBAChB,IAAI,EAAE,IAAI;oBACV,UAAU,EAAE,OAAO;iBACtB,CAAC,CAAC,CAAC;QACR,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,KAAK,YAAY,uCAA0B,EAAE,CAAC;gBAC9C,IAAI,KAAK,CAAC,UAAU,KAAK,iBAAiB,EAAE,CAAC;oBACzC,MAAM,IAAI,iCAAoB,CAAC,8BAA8B,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBAChG,CAAC;qBAAM,IAAI,KAAK,CAAC,UAAU,KAAK,gBAAgB,EAAE,CAAC;oBAC/C,MAAM,IAAI,iCAAoB,CAAC,+BAA+B,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBACjG,CAAC;YACL,CAAC;YACD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAED,MAAM;QACF,OAAO,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC;IAClE,CAAC;CACJ;AAEO,oBAAI"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Site } from './site';
|
|
2
|
+
import { AbstractUser } from './user';
|
|
3
|
+
declare class SiteApplication {
|
|
4
|
+
site: Site;
|
|
5
|
+
user: AbstractUser;
|
|
6
|
+
text: string;
|
|
7
|
+
constructor(site: Site, user: AbstractUser, text: string);
|
|
8
|
+
toString(): string;
|
|
9
|
+
static acquireAll(site: Site): Promise<SiteApplication[]>;
|
|
10
|
+
private _process;
|
|
11
|
+
accept(): Promise<void>;
|
|
12
|
+
decline(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export { SiteApplication };
|