@ukwhatn/wikidot 1.0.10 → 4.0.3
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 +242 -78
- package/dist/errors.cjs +114 -0
- package/dist/errors.d.cts +94 -0
- package/dist/errors.d.ts +94 -0
- package/dist/errors.js +81 -0
- package/dist/index.cjs +4615 -0
- package/dist/index.d.cts +2158 -0
- package/dist/index.d.ts +2158 -1
- package/dist/index.js +4582 -6
- package/package.json +64 -40
- package/.eslintrc.js +0 -23
- package/.github/dependabot.yml +0 -12
- package/.prettierrc +0 -6
- package/Makefile +0 -24
- package/dist/common/exceptions.d.ts +0 -95
- package/dist/common/exceptions.js +0 -146
- package/dist/common/exceptions.js.map +0 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +0 -6
- package/dist/common/index.js.map +0 -1
- package/dist/common/logger.d.ts +0 -2
- package/dist/common/logger.js +0 -19
- package/dist/common/logger.js.map +0 -1
- package/dist/connector/ajax.d.ts +0 -142
- package/dist/connector/ajax.js +0 -260
- package/dist/connector/ajax.js.map +0 -1
- package/dist/connector/api.d.ts +0 -11
- package/dist/connector/api.js +0 -17
- package/dist/connector/api.js.map +0 -1
- package/dist/connector/index.d.ts +0 -0
- package/dist/connector/index.js +0 -2
- package/dist/connector/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/module/auth.d.ts +0 -8
- package/dist/module/auth.js +0 -80
- package/dist/module/auth.js.map +0 -1
- package/dist/module/client.d.ts +0 -39
- package/dist/module/client.js +0 -96
- package/dist/module/client.js.map +0 -1
- package/dist/module/index.d.ts +0 -0
- package/dist/module/index.js +0 -2
- package/dist/module/index.js.map +0 -1
- package/dist/module/page.d.ts +0 -102
- package/dist/module/page.js +0 -402
- package/dist/module/page.js.map +0 -1
- package/dist/module/pageRevision.d.ts +0 -29
- package/dist/module/pageRevision.js +0 -114
- package/dist/module/pageRevision.js.map +0 -1
- package/dist/module/pageSource.d.ts +0 -7
- package/dist/module/pageSource.js +0 -11
- package/dist/module/pageSource.js.map +0 -1
- package/dist/module/pageVote.d.ts +0 -14
- package/dist/module/pageVote.js +0 -20
- package/dist/module/pageVote.js.map +0 -1
- package/dist/module/privateMessage.d.ts +0 -29
- package/dist/module/privateMessage.js +0 -132
- package/dist/module/privateMessage.js.map +0 -1
- package/dist/module/site.d.ts +0 -32
- package/dist/module/site.js +0 -117
- package/dist/module/site.js.map +0 -1
- package/dist/module/siteApplication.d.ts +0 -14
- package/dist/module/siteApplication.js +0 -100
- package/dist/module/siteApplication.js.map +0 -1
- package/dist/module/user.d.ts +0 -56
- package/dist/module/user.js +0 -115
- package/dist/module/user.js.map +0 -1
- package/dist/util/index.d.ts +0 -3
- package/dist/util/index.js +0 -10
- package/dist/util/index.js.map +0 -1
- package/dist/util/parser/index.d.ts +0 -1
- package/dist/util/parser/index.js +0 -18
- package/dist/util/parser/index.js.map +0 -1
- package/dist/util/parser/odate.d.ts +0 -12
- package/dist/util/parser/odate.js +0 -25
- package/dist/util/parser/odate.js.map +0 -1
- package/dist/util/parser/user.d.ts +0 -16
- package/dist/util/parser/user.js +0 -36
- package/dist/util/parser/user.js.map +0 -1
- package/dist/util/quickModule.d.ts +0 -96
- package/dist/util/quickModule.js +0 -137
- package/dist/util/quickModule.js.map +0 -1
- package/dist/util/requestUtil.d.ts +0 -26
- package/dist/util/requestUtil.js +0 -69
- package/dist/util/requestUtil.js.map +0 -1
- package/dist/util/stringUtil.d.ts +0 -21
- package/dist/util/stringUtil.js +0 -64
- package/dist/util/stringUtil.js.map +0 -1
- package/dist/util/table/charTable.d.ts +0 -3
- package/dist/util/table/charTable.js +0 -472
- package/dist/util/table/charTable.js.map +0 -1
- package/dist/util/table/index.d.ts +0 -1
- package/dist/util/table/index.js +0 -18
- package/dist/util/table/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pageRevision.js","sourceRoot":"","sources":["../../src/module/pageRevision.ts"],"names":[],"m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AAC,KAAM,CAAC,CAAA;QAC1F,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAM,CAAC,CAAA;IACvC,CAAC;IAED,IAAI,IAAI,CAAC,KAAa;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACtB,CAAC;CACJ;AAEgC,oCAAY"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageSource = void 0;
|
|
4
|
-
class PageSource {
|
|
5
|
-
constructor(page, wikiText) {
|
|
6
|
-
this.page = page;
|
|
7
|
-
this.wikiText = wikiText;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.PageSource = PageSource;
|
|
11
|
-
//# sourceMappingURL=pageSource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pageSource.js","sourceRoot":"","sources":["../../src/module/pageSource.ts"],"names":[],"mappings":";;;AAEA,MAAM,UAAU;IAIZ,YAAY,IAAU,EAAE,QAAgB;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC5B,CAAC;CACJ;AAEQ,gCAAU"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Page } from './page';
|
|
2
|
-
import { AbstractUser } from './user';
|
|
3
|
-
declare class PageVoteCollection extends Array<PageVote> {
|
|
4
|
-
page: Page;
|
|
5
|
-
votes: PageVote[];
|
|
6
|
-
constructor(page: Page, votes: PageVote[]);
|
|
7
|
-
}
|
|
8
|
-
declare class PageVote {
|
|
9
|
-
page: Page;
|
|
10
|
-
user: AbstractUser;
|
|
11
|
-
value: number;
|
|
12
|
-
constructor(page: Page, user: AbstractUser, value: number);
|
|
13
|
-
}
|
|
14
|
-
export { PageVote, PageVoteCollection };
|
package/dist/module/pageVote.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PageVoteCollection = exports.PageVote = void 0;
|
|
4
|
-
class PageVoteCollection extends Array {
|
|
5
|
-
constructor(page, votes) {
|
|
6
|
-
super(...votes);
|
|
7
|
-
this.page = page;
|
|
8
|
-
this.votes = votes;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.PageVoteCollection = PageVoteCollection;
|
|
12
|
-
class PageVote {
|
|
13
|
-
constructor(page, user, value) {
|
|
14
|
-
this.page = page;
|
|
15
|
-
this.user = user;
|
|
16
|
-
this.value = value;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.PageVote = PageVote;
|
|
20
|
-
//# sourceMappingURL=pageVote.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pageVote.js","sourceRoot":"","sources":["../../src/module/pageVote.ts"],"names":[],"mappings":";;;AAGA,MAAM,kBAAmB,SAAQ,KAAe;IAC5C,YACW,IAAU,EACV,KAAiB;QAExB,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;QAHR,SAAI,GAAJ,IAAI,CAAM;QACV,UAAK,GAAL,KAAK,CAAY;IAG5B,CAAC;CACJ;AAUkB,gDAAkB;AARrC,MAAM,QAAQ;IACV,YACW,IAAU,EACV,IAAkB,EAClB,KAAa;QAFb,SAAI,GAAJ,IAAI,CAAM;QACV,SAAI,GAAJ,IAAI,CAAc;QAClB,UAAK,GAAL,KAAK,CAAQ;IACrB,CAAC;CACP;AAEQ,4BAAQ"}
|
|
@@ -1,29 +0,0 @@
|
|
|
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 };
|
|
@@ -1,132 +0,0 @@
|
|
|
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
|
-
messageIds.push(...html('tr.message')
|
|
75
|
-
// @ts-expect-error href属性が存在することを保証
|
|
76
|
-
.map((_, tr) => Number(html(tr).data('href').split('/').pop()))
|
|
77
|
-
.get());
|
|
78
|
-
}
|
|
79
|
-
return PrivateMessageCollection.fromIds(client, messageIds);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
exports.PrivateMessageCollection = PrivateMessageCollection;
|
|
83
|
-
class PrivateMessageInbox extends PrivateMessageCollection {
|
|
84
|
-
static async fromIds(client, messageIds) {
|
|
85
|
-
return new PrivateMessageInbox(...(await PrivateMessageCollection.fromIds(client, messageIds)));
|
|
86
|
-
}
|
|
87
|
-
static async acquire(client) {
|
|
88
|
-
return new PrivateMessageInbox(...(await PrivateMessageCollection._acquire(client, 'dashboard/messages/DMInboxModule')));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.PrivateMessageInbox = PrivateMessageInbox;
|
|
92
|
-
class PrivateMessageSentBox extends PrivateMessageCollection {
|
|
93
|
-
static async fromIds(client, messageIds) {
|
|
94
|
-
return new PrivateMessageSentBox(...(await PrivateMessageCollection.fromIds(client, messageIds)));
|
|
95
|
-
}
|
|
96
|
-
static async acquire(client) {
|
|
97
|
-
return new PrivateMessageSentBox(...(await PrivateMessageCollection._acquire(client, 'dashboard/messages/DMSentModule')));
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.PrivateMessageSentBox = PrivateMessageSentBox;
|
|
101
|
-
class PrivateMessage {
|
|
102
|
-
constructor(client, id, sender, recipient, subject, body, createdAt) {
|
|
103
|
-
this.client = client;
|
|
104
|
-
this.id = id;
|
|
105
|
-
this.sender = sender;
|
|
106
|
-
this.recipient = recipient;
|
|
107
|
-
this.subject = subject;
|
|
108
|
-
this.body = body;
|
|
109
|
-
this.createdAt = createdAt;
|
|
110
|
-
}
|
|
111
|
-
toString() {
|
|
112
|
-
return `PrivateMessage(id=${this.id}, sender=${this.sender}, recipient=${this.recipient}, subject=${this.subject})`;
|
|
113
|
-
}
|
|
114
|
-
static async fromId(client, messageId) {
|
|
115
|
-
return (await PrivateMessageCollection.fromIds(client, [messageId]))[0];
|
|
116
|
-
}
|
|
117
|
-
static async send(client, recipient, subject, body) {
|
|
118
|
-
client.loginCheck();
|
|
119
|
-
await client.amcClient.request([
|
|
120
|
-
{
|
|
121
|
-
source: body,
|
|
122
|
-
subject: subject,
|
|
123
|
-
to_user_id: recipient.id,
|
|
124
|
-
action: 'DashboardMessageAction',
|
|
125
|
-
event: 'send',
|
|
126
|
-
moduleName: 'Empty',
|
|
127
|
-
},
|
|
128
|
-
]);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.PrivateMessage = PrivateMessage;
|
|
132
|
-
//# sourceMappingURL=privateMessage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"privateMessage.js","sourceRoot":"","sources":["../../src/module/privateMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,qDAAqF;AAGrF,iDAAkC;AAClC,2CAA2C;AAC3C,8CAA+C;AAE/C,MAAM,wBAAyB,SAAQ,KAAqB;IACxD,QAAQ;QACJ,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,YAAY,CAAA;IAC9D,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAc,EAAE,UAAoB;QACrD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,wCAAwC;SACvD,CAAC,CAAC,CAAA;QAEH,MAAM,CAAC,UAAU,EAAE,CAAA;QAEnB,MAAM,SAAS,GAA8B,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QAEzF,MAAM,QAAQ,GAAqB,EAAE,CAAA;QAErC,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,IAAI,QAAQ,YAAY,uCAA0B,EAAE,CAAC;gBACjD,IAAI,QAAQ,CAAC,UAAU,KAAK,YAAY,EAAE,CAAC;oBACvC,MAAM,IAAI,+BAAkB,CAAC,0BAA0B,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;gBAC/E,CAAC;YACL,CAAC;YAED,IAAI,QAAQ,YAAY,KAAK,EAAE,CAAC;gBAC5B,MAAM,QAAQ,CAAA;YAClB,CAAC;YAED,MAAM,I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,CAAC,MAAM,wBAAwB,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAC3E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAc,EAAE,SAAe,EAAE,OAAe,EAAE,IAAY;QAC5E,MAAM,CAAC,UAAU,EAAE,CAAA;QACnB,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;YAC3B;gBACI,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;SACJ,CAAC,CAAA;IACN,CAAC;CACJ;AAE8E,wCAAc"}
|
package/dist/module/site.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 };
|
package/dist/module/site.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
{
|
|
92
|
-
action: 'ManageSiteMembershipAction',
|
|
93
|
-
event: 'inviteMember',
|
|
94
|
-
user_id: user.id,
|
|
95
|
-
text: text,
|
|
96
|
-
moduleName: 'Empty',
|
|
97
|
-
},
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
catch (error) {
|
|
101
|
-
if (error instanceof exceptions_1.WikidotStatusCodeException) {
|
|
102
|
-
if (error.statusCode === 'already_invited') {
|
|
103
|
-
throw new exceptions_1.TargetErrorException(`User is already invited to ${this.unixName}: ${user.name}`);
|
|
104
|
-
}
|
|
105
|
-
else if (error.statusCode === 'already_member') {
|
|
106
|
-
throw new exceptions_1.TargetErrorException(`User is already a member of ${this.unixName}: ${user.name}`);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
getUrl() {
|
|
113
|
-
return `http${this.sslSupported ? 's' : ''}://${this.domain}`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.Site = Site;
|
|
117
|
-
//# sourceMappingURL=site.js.map
|
package/dist/module/site.js.map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,IAAI;oBACV,UAAU,EAAE,OAAO;iBACtB;aACJ,CAAC,CAAA;QACN,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,CAAA;gBAC/F,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,CAAA;gBAChG,CAAC;YACL,CAAC;YACD,MAAM,KAAK,CAAA;QACf,CAAC;IACL,CAAC;IAED,MAAM;QACF,OAAO,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;IACjE,CAAC;CACJ;AAEQ,oBAAI"}
|
|
@@ -1,14 +0,0 @@
|
|
|
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 };
|
|
@@ -1,100 +0,0 @@
|
|
|
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.SiteApplication = void 0;
|
|
27
|
-
const exceptions_1 = require("../common/exceptions");
|
|
28
|
-
const user_1 = require("../util/parser/user");
|
|
29
|
-
const cheerio = __importStar(require("cheerio"));
|
|
30
|
-
class SiteApplication {
|
|
31
|
-
constructor(site, user, text) {
|
|
32
|
-
this.site = site;
|
|
33
|
-
this.user = user;
|
|
34
|
-
this.text = text;
|
|
35
|
-
}
|
|
36
|
-
toString() {
|
|
37
|
-
return `SiteApplication(user=${this.user}, site=${this.site}, text=${this.text})`;
|
|
38
|
-
}
|
|
39
|
-
static async acquireAll(site) {
|
|
40
|
-
site.client.loginCheck();
|
|
41
|
-
const response = (await site.amcRequest([
|
|
42
|
-
{
|
|
43
|
-
moduleName: 'managesite/ManageSiteMembersApplicationsModule',
|
|
44
|
-
},
|
|
45
|
-
]))[0];
|
|
46
|
-
const body = response.data.body;
|
|
47
|
-
if (body.includes('WIKIDOT.page.listeners.loginClick(event)')) {
|
|
48
|
-
throw new exceptions_1.ForbiddenException('You are not allowed to access this page');
|
|
49
|
-
}
|
|
50
|
-
const html = cheerio.load(body);
|
|
51
|
-
const applications = [];
|
|
52
|
-
const userElements = html('h3 span.printuser');
|
|
53
|
-
const textWrapperElements = html('table');
|
|
54
|
-
if (userElements.length !== textWrapperElements.length) {
|
|
55
|
-
throw new exceptions_1.UnexpectedException('Length of userElements and textWrapperElements are different');
|
|
56
|
-
}
|
|
57
|
-
for (let i = 0; i < userElements.length; i++) {
|
|
58
|
-
const userElement = userElements.eq(i);
|
|
59
|
-
const textWrapperElement = textWrapperElements.eq(i);
|
|
60
|
-
const user = (0, user_1.userParse)(site.client, userElement);
|
|
61
|
-
const text = textWrapperElement.find('td').eq(1).text().trim();
|
|
62
|
-
applications.push(new SiteApplication(site, user, text));
|
|
63
|
-
}
|
|
64
|
-
return applications;
|
|
65
|
-
}
|
|
66
|
-
async _process(action) {
|
|
67
|
-
this.site.client.loginCheck();
|
|
68
|
-
if (action !== 'accept' && action !== 'decline') {
|
|
69
|
-
throw new Error(`Invalid action: ${action}`);
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
await this.site.amcRequest([
|
|
73
|
-
{
|
|
74
|
-
action: 'ManageSiteMembershipAction',
|
|
75
|
-
event: 'acceptApplication',
|
|
76
|
-
user_id: this.user.id,
|
|
77
|
-
text: `your application has been ${action}ed`,
|
|
78
|
-
type: action,
|
|
79
|
-
moduleName: 'Empty',
|
|
80
|
-
},
|
|
81
|
-
]);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
if (error instanceof exceptions_1.WikidotStatusCodeException && error.statusCode === 'no_application') {
|
|
85
|
-
throw new exceptions_1.NotFoundException(`Application not found: ${this.user}`);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
throw error;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async accept() {
|
|
93
|
-
await this._process('accept');
|
|
94
|
-
}
|
|
95
|
-
async decline() {
|
|
96
|
-
await this._process('decline');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.SiteApplication = SiteApplication;
|
|
100
|
-
//# sourceMappingURL=siteApplication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"siteApplication.js","sourceRoot":"","sources":["../../src/module/siteApplication.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,qDAK6B;AAC7B,8CAA+C;AAC/C,iDAAkC;AAElC,MAAM,eAAe;IACjB,YACW,IAAU,EACV,IAAkB,EAClB,IAAY;QAFZ,SAAI,GAAJ,IAAI,CAAM;QACV,SAAI,GAAJ,IAAI,CAAc;QAClB,SAAI,GAAJ,IAAI,CAAQ;IACpB,CAAC;IAEJ,QAAQ;QACJ,OAAO,wBAAwB,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,IAAI,GAAG,CAAA;IACrF,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,IAAU;QAC9B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAA;QAExB,MAAM,QAAQ,GAAG,CACb,MAAM,IAAI,CAAC,UAAU,CAAC;YAClB;gBACI,UAAU,EAAE,gDAAgD;aAC/D;SACJ,CAAC,CACL,CAAC,CAAC,CAAC,CAAA;QAEJ,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAA;QAE/B,IAAI,IAAI,CAAC,QAAQ,CAAC,0CAA0C,CAAC,EAAE,CAAC;YAC5D,MAAM,IAAI,+BAAkB,CAAC,yCAAyC,CAAC,CAAA;QAC3E,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAE/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oBACpC,KAAK,EAAE,mBAAmB;oBAC1B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE;oBACrB,IAAI,EAAE,6BAA6B,MAAM,IAAI;oBAC7C,IAAI,EAAE,MAAM;oBACZ,UAAU,EAAE,OAAO;iBACtB;aACJ,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,IAAI,KAAK,YAAY,uCAA0B,IAAI,KAAK,CAAC,UAAU,KAAK,gBAAgB,EAAE,CAAC;gBACvF,MAAM,IAAI,8BAAiB,CAAC,0BAA0B,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;YACtE,CAAC;iBAAM,CAAC;gBACJ,MAAM,KAAK,CAAA;YACf,CAAC;QACL,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM;QACR,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,OAAO;QACT,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IAClC,CAAC;CACJ;AAEQ,0CAAe"}
|
package/dist/module/user.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Client } from './client';
|
|
2
|
-
/**
|
|
3
|
-
* @class UserCollection
|
|
4
|
-
* @extends Array
|
|
5
|
-
* @description ユーザーオブジェクトのリスト
|
|
6
|
-
*/
|
|
7
|
-
declare class UserCollection extends Array<User | null> {
|
|
8
|
-
/**
|
|
9
|
-
* @method fromNames
|
|
10
|
-
* @description ユーザー名のリストからユーザーオブジェクトのリストを取得
|
|
11
|
-
* @param client - クライアント
|
|
12
|
-
* @param names - ユーザー名のリスト
|
|
13
|
-
* @param raiseWhenNotFound - ユーザーが見つからなかった場合に例外を発生させるかどうか(デフォルトは false)
|
|
14
|
-
*/
|
|
15
|
-
static fromNames(client: Client, names: string[], raiseWhenNotFound?: boolean): Promise<UserCollection>;
|
|
16
|
-
}
|
|
17
|
-
declare abstract class AbstractUser {
|
|
18
|
-
client: Client;
|
|
19
|
-
id: number | null;
|
|
20
|
-
name: string | null;
|
|
21
|
-
unixName: string | null;
|
|
22
|
-
avatarUrl: string | null;
|
|
23
|
-
ip: string | null;
|
|
24
|
-
constructor(client: Client, id?: number | null, name?: string | null, unixName?: string | null, avatarUrl?: string | null, ip?: string | null);
|
|
25
|
-
toString(): string;
|
|
26
|
-
}
|
|
27
|
-
declare class User extends AbstractUser {
|
|
28
|
-
ip: null;
|
|
29
|
-
static fromName(client: Client, name: string, raiseWhenNotFound?: boolean): Promise<User | null>;
|
|
30
|
-
}
|
|
31
|
-
declare class DeletedUser extends AbstractUser {
|
|
32
|
-
name: string;
|
|
33
|
-
unixName: string;
|
|
34
|
-
avatarUrl: null;
|
|
35
|
-
ip: null;
|
|
36
|
-
}
|
|
37
|
-
declare class AnonymousUser extends AbstractUser {
|
|
38
|
-
id: null;
|
|
39
|
-
name: string;
|
|
40
|
-
unixName: string;
|
|
41
|
-
avatarUrl: null;
|
|
42
|
-
}
|
|
43
|
-
declare class GuestUser extends AbstractUser {
|
|
44
|
-
id: null;
|
|
45
|
-
unixName: null;
|
|
46
|
-
avatarUrl: null;
|
|
47
|
-
ip: null;
|
|
48
|
-
}
|
|
49
|
-
declare class WikidotUser extends AbstractUser {
|
|
50
|
-
id: null;
|
|
51
|
-
name: string;
|
|
52
|
-
unixName: string;
|
|
53
|
-
avatarUrl: null;
|
|
54
|
-
ip: null;
|
|
55
|
-
}
|
|
56
|
-
export { UserCollection, AbstractUser, User, DeletedUser, AnonymousUser, GuestUser, WikidotUser };
|