@mx-space/api-client 1.4.1 → 1.4.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/controllers/aggregate.ts +9 -3
- package/dist/adaptors/axios.d.cts +6 -0
- package/dist/adaptors/axios.global.js +25 -3
- package/dist/adaptors/fetch.d.cts +5 -0
- package/dist/adaptors/ky.d.cts +26 -0
- package/dist/adaptors/ky.global.js +2 -2
- package/dist/adaptors/umi-request.d.cts +6 -0
- package/dist/adaptors/umi-request.global.js +9 -1
- package/dist/index.cjs +6 -8
- package/dist/index.d.cts +1473 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.global.js +6 -6
- package/dist/index.js +6 -7
- package/dtos/comment.ts +7 -4
- package/models/aggregate.ts +8 -0
- package/models/comment.ts +3 -0
- package/package.json +4 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1473 @@
|
|
|
1
|
+
import { R as RequestOptions, I as IRequestAdapter, a as IAdaptorRequestResponseType } from './adapter-be44aa1e.js';
|
|
2
|
+
|
|
3
|
+
interface IController {
|
|
4
|
+
base: string;
|
|
5
|
+
name: string | string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type Class<T> = new (...args: any[]) => T;
|
|
9
|
+
type SelectFields<T extends string> = `${'+' | '-' | ''}${T}`[];
|
|
10
|
+
|
|
11
|
+
interface IClientOptions {
|
|
12
|
+
controllers: Class<IController>[];
|
|
13
|
+
getCodeMessageFromException: <T = Error>(error: T) => {
|
|
14
|
+
message?: string | undefined | null;
|
|
15
|
+
code?: number | undefined | null;
|
|
16
|
+
};
|
|
17
|
+
customThrowResponseError: <T extends Error = Error>(err: any) => T;
|
|
18
|
+
transformResponse: <T = any>(data: any) => T;
|
|
19
|
+
}
|
|
20
|
+
type ClientOptions = Partial<IClientOptions>;
|
|
21
|
+
|
|
22
|
+
type NoStringIndex<T> = {
|
|
23
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
24
|
+
};
|
|
25
|
+
interface IRequestHandler<ResponseWrapper> {
|
|
26
|
+
(path?: string | number): IRequestHandler<ResponseWrapper>;
|
|
27
|
+
get<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>): RequestProxyResult<P, ResponseWrapper>;
|
|
28
|
+
post<P = unknown>(options?: RequestOptions): RequestProxyResult<P, ResponseWrapper>;
|
|
29
|
+
patch<P = unknown>(options?: RequestOptions): RequestProxyResult<P, ResponseWrapper>;
|
|
30
|
+
delete<P = unknown>(options?: Omit<NoStringIndex<RequestOptions>, 'data'>): RequestProxyResult<P, ResponseWrapper>;
|
|
31
|
+
put<P = unknown>(options?: RequestOptions): RequestProxyResult<P, ResponseWrapper>;
|
|
32
|
+
toString(withBase?: boolean): string;
|
|
33
|
+
valueOf(withBase?: boolean): string;
|
|
34
|
+
[key: string]: IRequestHandler<ResponseWrapper>;
|
|
35
|
+
}
|
|
36
|
+
type RequestProxyResult<T, ResponseWrapper, R = ResponseWrapper extends unknown ? {
|
|
37
|
+
data: T;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
} : ResponseWrapper extends {
|
|
40
|
+
data: T;
|
|
41
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, 'data'> & {
|
|
42
|
+
data: T;
|
|
43
|
+
}> = Promise<ResponseProxyExtraRaw<T, R, ResponseWrapper>>;
|
|
44
|
+
type CamelToSnake<T extends string, P extends string = ''> = string extends T ? string : T extends `${infer C0}${infer R}` ? CamelToSnake<R, `${P}${C0 extends Lowercase<C0> ? '' : '_'}${Lowercase<C0>}`> : P;
|
|
45
|
+
type CamelKeysToSnake<T> = {
|
|
46
|
+
[K in keyof T as CamelToSnake<Extract<K, string>>]: T[K];
|
|
47
|
+
};
|
|
48
|
+
type ResponseWrapperType<Response, RawData, T> = {
|
|
49
|
+
$raw: Response extends {
|
|
50
|
+
data: infer T;
|
|
51
|
+
} ? Response : Response extends unknown ? {
|
|
52
|
+
[i: string]: any;
|
|
53
|
+
data: RawData extends unknown ? CamelKeysToSnake<T> : RawData;
|
|
54
|
+
} : Response;
|
|
55
|
+
$request: {
|
|
56
|
+
path: string;
|
|
57
|
+
method: string;
|
|
58
|
+
[k: string]: string;
|
|
59
|
+
};
|
|
60
|
+
$serialized: T;
|
|
61
|
+
};
|
|
62
|
+
type ResponseProxyExtraRaw<T, RawData = unknown, Response = unknown> = T extends object ? T & ResponseWrapperType<Response, RawData, T> : T extends unknown ? T & ResponseWrapperType<Response, RawData, T> : unknown;
|
|
63
|
+
|
|
64
|
+
declare class HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
65
|
+
private readonly _endpoint;
|
|
66
|
+
private _adaptor;
|
|
67
|
+
private options;
|
|
68
|
+
private readonly _proxy;
|
|
69
|
+
constructor(_endpoint: string, _adaptor: T, options?: Omit<ClientOptions, 'controllers'>);
|
|
70
|
+
private initGetClient;
|
|
71
|
+
injectControllers(...Controller: Class<IController>[]): void;
|
|
72
|
+
injectControllers(Controller: Class<IController>[]): void;
|
|
73
|
+
get endpoint(): string;
|
|
74
|
+
get instance(): T;
|
|
75
|
+
request(options: {
|
|
76
|
+
url: string;
|
|
77
|
+
method?: string;
|
|
78
|
+
data?: any;
|
|
79
|
+
params?: any;
|
|
80
|
+
}): Promise<IAdaptorRequestResponseType<any>>;
|
|
81
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
82
|
+
private buildRoute;
|
|
83
|
+
}
|
|
84
|
+
declare function createClient<T extends IRequestAdapter>(adapter: T): <ResponseWrapper = T extends {
|
|
85
|
+
responseWrapper: infer Type;
|
|
86
|
+
} ? Type extends undefined ? unknown : Type : unknown>(endpoint: string, options?: ClientOptions) => HTTPClient<T, ResponseWrapper>;
|
|
87
|
+
|
|
88
|
+
declare class RequestError extends Error {
|
|
89
|
+
status: number;
|
|
90
|
+
path: string;
|
|
91
|
+
raw: any;
|
|
92
|
+
constructor(message: string, status: number, path: string, raw: any);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type SortOrder = 'asc' | 'desc';
|
|
96
|
+
|
|
97
|
+
interface Count {
|
|
98
|
+
read: number;
|
|
99
|
+
like: number;
|
|
100
|
+
}
|
|
101
|
+
interface Image {
|
|
102
|
+
height: number;
|
|
103
|
+
width: number;
|
|
104
|
+
type: string;
|
|
105
|
+
accent?: string;
|
|
106
|
+
src: string;
|
|
107
|
+
}
|
|
108
|
+
interface Pager {
|
|
109
|
+
total: number;
|
|
110
|
+
size: number;
|
|
111
|
+
currentPage: number;
|
|
112
|
+
totalPage: number;
|
|
113
|
+
hasPrevPage: boolean;
|
|
114
|
+
hasNextPage: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface PaginateResult<T> {
|
|
117
|
+
data: T[];
|
|
118
|
+
pagination: Pager;
|
|
119
|
+
}
|
|
120
|
+
interface BaseModel {
|
|
121
|
+
created: string;
|
|
122
|
+
id: string;
|
|
123
|
+
}
|
|
124
|
+
interface BaseCommentIndexModel extends BaseModel {
|
|
125
|
+
commentsIndex?: number;
|
|
126
|
+
allowComment: boolean;
|
|
127
|
+
}
|
|
128
|
+
interface TextBaseModel extends BaseCommentIndexModel {
|
|
129
|
+
title: string;
|
|
130
|
+
text: string;
|
|
131
|
+
images?: Image[];
|
|
132
|
+
modified: string | null;
|
|
133
|
+
}
|
|
134
|
+
type ModelWithLiked<T> = T & {
|
|
135
|
+
liked: boolean;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
interface PostModel extends TextBaseModel {
|
|
139
|
+
summary?: string;
|
|
140
|
+
copyright: boolean;
|
|
141
|
+
tags: string[];
|
|
142
|
+
count: Count;
|
|
143
|
+
text: string;
|
|
144
|
+
title: string;
|
|
145
|
+
slug: string;
|
|
146
|
+
categoryId: string;
|
|
147
|
+
images: Image[];
|
|
148
|
+
category: CategoryModel;
|
|
149
|
+
pin?: string | null;
|
|
150
|
+
pinOrder?: number;
|
|
151
|
+
related?: Pick<PostModel, 'id' | 'category' | 'categoryId' | 'created' | 'modified' | 'title' | 'slug' | 'summary'>[];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
declare enum CategoryType {
|
|
155
|
+
Category = 0,
|
|
156
|
+
Tag = 1
|
|
157
|
+
}
|
|
158
|
+
interface CategoryModel extends BaseModel {
|
|
159
|
+
type: CategoryType;
|
|
160
|
+
count: number;
|
|
161
|
+
slug: string;
|
|
162
|
+
name: string;
|
|
163
|
+
}
|
|
164
|
+
type CategoryWithChildrenModel = CategoryModel & {
|
|
165
|
+
children: Pick<PostModel, 'id' | 'title' | 'slug' | 'modified' | 'created'>[];
|
|
166
|
+
};
|
|
167
|
+
type CategoryEntries = {
|
|
168
|
+
entries: Record<string, CategoryWithChildrenModel>;
|
|
169
|
+
};
|
|
170
|
+
interface TagModel {
|
|
171
|
+
count: number;
|
|
172
|
+
name: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
interface TopicModel extends BaseModel {
|
|
176
|
+
description?: string;
|
|
177
|
+
introduce: string;
|
|
178
|
+
name: string;
|
|
179
|
+
slug: string;
|
|
180
|
+
icon?: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface NoteModel extends TextBaseModel {
|
|
184
|
+
hide: boolean;
|
|
185
|
+
count: {
|
|
186
|
+
read: number;
|
|
187
|
+
like: number;
|
|
188
|
+
};
|
|
189
|
+
mood?: string;
|
|
190
|
+
weather?: string;
|
|
191
|
+
hasMemory?: boolean;
|
|
192
|
+
secret?: Date;
|
|
193
|
+
password?: string | null;
|
|
194
|
+
nid: number;
|
|
195
|
+
music?: NoteMusicRecord[];
|
|
196
|
+
location?: string;
|
|
197
|
+
coordinates?: Coordinate;
|
|
198
|
+
topic?: TopicModel;
|
|
199
|
+
topicId?: string;
|
|
200
|
+
}
|
|
201
|
+
interface NoteMusicRecord {
|
|
202
|
+
type: string;
|
|
203
|
+
id: string;
|
|
204
|
+
}
|
|
205
|
+
interface Coordinate {
|
|
206
|
+
latitude: number;
|
|
207
|
+
longitude: number;
|
|
208
|
+
}
|
|
209
|
+
interface NoteWrappedPayload {
|
|
210
|
+
data: NoteModel;
|
|
211
|
+
next?: Partial<NoteModel>;
|
|
212
|
+
prev?: Partial<NoteModel>;
|
|
213
|
+
}
|
|
214
|
+
interface NoteWrappedWithLikedPayload {
|
|
215
|
+
data: ModelWithLiked<NoteModel>;
|
|
216
|
+
next?: Partial<NoteModel>;
|
|
217
|
+
prev?: Partial<NoteModel>;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare enum EnumPageType {
|
|
221
|
+
'md' = "md",
|
|
222
|
+
'html' = "html",
|
|
223
|
+
'frame' = "frame"
|
|
224
|
+
}
|
|
225
|
+
interface PageModel extends TextBaseModel {
|
|
226
|
+
created: string;
|
|
227
|
+
slug: string;
|
|
228
|
+
subtitle?: string;
|
|
229
|
+
order?: number;
|
|
230
|
+
type?: EnumPageType;
|
|
231
|
+
options?: object;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
interface SayModel extends BaseModel {
|
|
235
|
+
text: string;
|
|
236
|
+
source?: string;
|
|
237
|
+
author?: string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
declare class SeoOptionModel {
|
|
241
|
+
title: string;
|
|
242
|
+
description: string;
|
|
243
|
+
icon?: string;
|
|
244
|
+
keywords?: string[];
|
|
245
|
+
}
|
|
246
|
+
declare class UrlOptionModel {
|
|
247
|
+
webUrl: string;
|
|
248
|
+
adminUrl: string;
|
|
249
|
+
serverUrl: string;
|
|
250
|
+
wsUrl: string;
|
|
251
|
+
}
|
|
252
|
+
declare class MailOptionModel {
|
|
253
|
+
port: number;
|
|
254
|
+
host: string;
|
|
255
|
+
}
|
|
256
|
+
declare class MailOptionsModel {
|
|
257
|
+
enable: boolean;
|
|
258
|
+
user: string;
|
|
259
|
+
pass: string;
|
|
260
|
+
options?: MailOptionModel;
|
|
261
|
+
}
|
|
262
|
+
declare class CommentOptionsModel {
|
|
263
|
+
antiSpam: boolean;
|
|
264
|
+
spamKeywords?: string[];
|
|
265
|
+
blockIps?: string[];
|
|
266
|
+
disableNoChinese?: boolean;
|
|
267
|
+
}
|
|
268
|
+
declare class BackupOptionsModel {
|
|
269
|
+
enable: boolean;
|
|
270
|
+
secretId?: string;
|
|
271
|
+
secretKey?: string;
|
|
272
|
+
bucket?: string;
|
|
273
|
+
region: string;
|
|
274
|
+
}
|
|
275
|
+
declare class BaiduSearchOptionsModel {
|
|
276
|
+
enable: boolean;
|
|
277
|
+
token?: string;
|
|
278
|
+
}
|
|
279
|
+
declare class AlgoliaSearchOptionsModel {
|
|
280
|
+
enable: boolean;
|
|
281
|
+
apiKey?: string;
|
|
282
|
+
appId?: string;
|
|
283
|
+
indexName?: string;
|
|
284
|
+
}
|
|
285
|
+
declare class AdminExtraModel {
|
|
286
|
+
background?: string;
|
|
287
|
+
gaodemapKey?: string;
|
|
288
|
+
title?: string;
|
|
289
|
+
/**
|
|
290
|
+
* 是否开启后台反代访问
|
|
291
|
+
*/
|
|
292
|
+
enableAdminProxy?: boolean;
|
|
293
|
+
}
|
|
294
|
+
interface IConfig {
|
|
295
|
+
seo: SeoOptionModel;
|
|
296
|
+
url: UrlOptionModel;
|
|
297
|
+
mailOptions: MailOptionsModel;
|
|
298
|
+
commentOptions: CommentOptionsModel;
|
|
299
|
+
backupOptions: BackupOptionsModel;
|
|
300
|
+
baiduSearchOptions: BaiduSearchOptionsModel;
|
|
301
|
+
algoliaSearchOptions: AlgoliaSearchOptionsModel;
|
|
302
|
+
adminExtra: AdminExtraModel;
|
|
303
|
+
}
|
|
304
|
+
declare type IConfigKeys = keyof IConfig;
|
|
305
|
+
|
|
306
|
+
interface UserModel extends BaseModel {
|
|
307
|
+
introduce: string;
|
|
308
|
+
mail: string;
|
|
309
|
+
url: string;
|
|
310
|
+
name: string;
|
|
311
|
+
socialIds: Record<string, string>;
|
|
312
|
+
username: string;
|
|
313
|
+
modified: string;
|
|
314
|
+
v: number;
|
|
315
|
+
lastLoginTime: string;
|
|
316
|
+
lastLoginIp?: string;
|
|
317
|
+
avatar: string;
|
|
318
|
+
postID: string;
|
|
319
|
+
}
|
|
320
|
+
type TLogin = {
|
|
321
|
+
token: string;
|
|
322
|
+
expiresIn: number;
|
|
323
|
+
lastLoginTime: null | string;
|
|
324
|
+
lastLoginIp?: null | string;
|
|
325
|
+
} & Pick<UserModel, 'name' | 'username' | 'created' | 'url' | 'mail' | 'avatar' | 'id'>;
|
|
326
|
+
|
|
327
|
+
interface AggregateRoot {
|
|
328
|
+
user: UserModel;
|
|
329
|
+
seo: SeoOptionModel;
|
|
330
|
+
url: Url;
|
|
331
|
+
categories: CategoryModel[];
|
|
332
|
+
pageMeta: Pick<PageModel, 'title' | 'id' | 'slug' | 'order'>[] | null;
|
|
333
|
+
/**
|
|
334
|
+
* @available 4.2.2
|
|
335
|
+
*/
|
|
336
|
+
latestNoteId: {
|
|
337
|
+
id: string;
|
|
338
|
+
nid: number;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
interface AggregateRootWithTheme<Theme = unknown> extends AggregateRoot {
|
|
342
|
+
theme?: Theme;
|
|
343
|
+
}
|
|
344
|
+
interface Url {
|
|
345
|
+
wsUrl: string;
|
|
346
|
+
serverUrl: string;
|
|
347
|
+
webUrl: string;
|
|
348
|
+
}
|
|
349
|
+
interface AggregateTopNote extends Pick<NoteModel, 'id' | 'title' | 'created' | 'nid' | 'images'> {
|
|
350
|
+
}
|
|
351
|
+
interface AggregateTopPost extends Pick<PostModel, 'id' | 'slug' | 'created' | 'title' | 'category' | 'images'> {
|
|
352
|
+
}
|
|
353
|
+
interface AggregateTop {
|
|
354
|
+
notes: AggregateTopNote[];
|
|
355
|
+
posts: AggregateTopPost[];
|
|
356
|
+
says: SayModel[];
|
|
357
|
+
}
|
|
358
|
+
declare enum TimelineType {
|
|
359
|
+
Post = 0,
|
|
360
|
+
Note = 1
|
|
361
|
+
}
|
|
362
|
+
interface TimelineData {
|
|
363
|
+
notes?: Pick<NoteModel, 'id' | 'nid' | 'title' | 'weather' | 'mood' | 'created' | 'modified' | 'hasMemory'>[];
|
|
364
|
+
posts?: (Pick<PostModel, 'id' | 'title' | 'slug' | 'created' | 'modified' | 'category'> & {
|
|
365
|
+
url: string;
|
|
366
|
+
})[];
|
|
367
|
+
}
|
|
368
|
+
interface AggregateStat {
|
|
369
|
+
allComments: number;
|
|
370
|
+
categories: number;
|
|
371
|
+
comments: number;
|
|
372
|
+
linkApply: number;
|
|
373
|
+
links: number;
|
|
374
|
+
notes: number;
|
|
375
|
+
pages: number;
|
|
376
|
+
posts: number;
|
|
377
|
+
says: number;
|
|
378
|
+
recently: number;
|
|
379
|
+
unreadComments: number;
|
|
380
|
+
online: number;
|
|
381
|
+
todayMaxOnline: string;
|
|
382
|
+
todayOnlineTotal: string;
|
|
383
|
+
callTime: number;
|
|
384
|
+
uv: number;
|
|
385
|
+
todayIpAccessCount: number;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare module '../core/client' {
|
|
389
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
390
|
+
aggregate: AggregateController<ResponseWrapper>;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
declare class AggregateController<ResponseWrapper> implements IController {
|
|
394
|
+
private client;
|
|
395
|
+
base: string;
|
|
396
|
+
name: string;
|
|
397
|
+
constructor(client: HTTPClient);
|
|
398
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
399
|
+
/**
|
|
400
|
+
* 获取聚合数据
|
|
401
|
+
*/
|
|
402
|
+
getAggregateData<Theme>(theme?: string): RequestProxyResult<AggregateRootWithTheme<Theme>, ResponseWrapper>;
|
|
403
|
+
/**
|
|
404
|
+
* 获取最新发布的内容
|
|
405
|
+
*/
|
|
406
|
+
getTop(size?: number): RequestProxyResult<AggregateTop, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
407
|
+
[key: string]: any;
|
|
408
|
+
data: AggregateTop;
|
|
409
|
+
} : ResponseWrapper extends {
|
|
410
|
+
data: AggregateTop;
|
|
411
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
412
|
+
data: AggregateTop;
|
|
413
|
+
}>;
|
|
414
|
+
getTimeline(options?: {
|
|
415
|
+
sort?: SortOrder;
|
|
416
|
+
type?: TimelineType;
|
|
417
|
+
year?: number;
|
|
418
|
+
}): RequestProxyResult<{
|
|
419
|
+
data: TimelineData;
|
|
420
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
421
|
+
[key: string]: any;
|
|
422
|
+
data: {
|
|
423
|
+
data: TimelineData;
|
|
424
|
+
};
|
|
425
|
+
} : ResponseWrapper extends {
|
|
426
|
+
data: {
|
|
427
|
+
data: TimelineData;
|
|
428
|
+
};
|
|
429
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
430
|
+
data: {
|
|
431
|
+
data: TimelineData;
|
|
432
|
+
};
|
|
433
|
+
}>;
|
|
434
|
+
/**
|
|
435
|
+
* 获取聚合数据统计
|
|
436
|
+
*/
|
|
437
|
+
getStat(): RequestProxyResult<AggregateStat, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
438
|
+
[key: string]: any;
|
|
439
|
+
data: AggregateStat;
|
|
440
|
+
} : ResponseWrapper extends {
|
|
441
|
+
data: AggregateStat;
|
|
442
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
443
|
+
data: AggregateStat;
|
|
444
|
+
}>;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
declare module '../core/client' {
|
|
448
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
449
|
+
category: CategoryController<ResponseWrapper>;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
declare class CategoryController<ResponseWrapper> implements IController {
|
|
453
|
+
private client;
|
|
454
|
+
name: string;
|
|
455
|
+
base: string;
|
|
456
|
+
constructor(client: HTTPClient);
|
|
457
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
458
|
+
getAllCategories(): RequestProxyResult<{
|
|
459
|
+
data: CategoryModel[];
|
|
460
|
+
}, ResponseWrapper>;
|
|
461
|
+
getAllTags(): RequestProxyResult<{
|
|
462
|
+
data: TagModel[];
|
|
463
|
+
}, ResponseWrapper>;
|
|
464
|
+
getCategoryDetail(id: string): Promise<ResponseProxyExtraRaw<CategoryWithChildrenModel>>;
|
|
465
|
+
getCategoryDetail(ids: string[]): Promise<ResponseProxyExtraRaw<Map<string, CategoryWithChildrenModel>>>;
|
|
466
|
+
getCategoryByIdOrSlug(idOrSlug: string): Promise<CategoryModel & {
|
|
467
|
+
children: Pick<PostModel, "id" | "created" | "modified" | "title" | "slug">[];
|
|
468
|
+
} & {
|
|
469
|
+
$raw: ResponseWrapper extends {
|
|
470
|
+
data: infer T;
|
|
471
|
+
} ? ResponseWrapper : ResponseWrapper extends unknown ? {
|
|
472
|
+
[i: string]: any;
|
|
473
|
+
data: (ResponseWrapper extends unknown ? {
|
|
474
|
+
[key: string]: any;
|
|
475
|
+
data: CategoryWithChildrenModel;
|
|
476
|
+
} : ResponseWrapper extends {
|
|
477
|
+
data: CategoryWithChildrenModel;
|
|
478
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
479
|
+
data: CategoryWithChildrenModel;
|
|
480
|
+
}) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
|
|
481
|
+
[key: string]: any;
|
|
482
|
+
data: CategoryWithChildrenModel;
|
|
483
|
+
} : ResponseWrapper extends {
|
|
484
|
+
data: CategoryWithChildrenModel;
|
|
485
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
486
|
+
data: CategoryWithChildrenModel;
|
|
487
|
+
}) ? T_1 extends unknown ? {
|
|
488
|
+
type: CategoryType;
|
|
489
|
+
count: number;
|
|
490
|
+
slug: string;
|
|
491
|
+
name: string;
|
|
492
|
+
created: string;
|
|
493
|
+
id: string;
|
|
494
|
+
children: Pick<PostModel, "id" | "created" | "modified" | "title" | "slug">[];
|
|
495
|
+
} : T_1 : never : never;
|
|
496
|
+
} : ResponseWrapper;
|
|
497
|
+
$request: {
|
|
498
|
+
[k: string]: string;
|
|
499
|
+
path: string;
|
|
500
|
+
method: string;
|
|
501
|
+
};
|
|
502
|
+
$serialized: CategoryWithChildrenModel;
|
|
503
|
+
}>;
|
|
504
|
+
getTagByName(name: string): Promise<{
|
|
505
|
+
tag: string;
|
|
506
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
507
|
+
} & {
|
|
508
|
+
$raw: ResponseWrapper extends {
|
|
509
|
+
data: infer T;
|
|
510
|
+
} ? ResponseWrapper : ResponseWrapper extends unknown ? {
|
|
511
|
+
[i: string]: any;
|
|
512
|
+
data: (ResponseWrapper extends unknown ? {
|
|
513
|
+
[key: string]: any;
|
|
514
|
+
data: {
|
|
515
|
+
tag: string;
|
|
516
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
517
|
+
};
|
|
518
|
+
} : ResponseWrapper extends {
|
|
519
|
+
data: {
|
|
520
|
+
tag: string;
|
|
521
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
522
|
+
};
|
|
523
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
524
|
+
data: {
|
|
525
|
+
tag: string;
|
|
526
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
527
|
+
};
|
|
528
|
+
}) extends infer T_1 ? T_1 extends (ResponseWrapper extends unknown ? {
|
|
529
|
+
[key: string]: any;
|
|
530
|
+
data: {
|
|
531
|
+
tag: string;
|
|
532
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
533
|
+
};
|
|
534
|
+
} : ResponseWrapper extends {
|
|
535
|
+
data: {
|
|
536
|
+
tag: string;
|
|
537
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
538
|
+
};
|
|
539
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
540
|
+
data: {
|
|
541
|
+
tag: string;
|
|
542
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
543
|
+
};
|
|
544
|
+
}) ? T_1 extends unknown ? {
|
|
545
|
+
tag: string;
|
|
546
|
+
data: Pick<PostModel, "id" | "category" | "created" | "title" | "slug">[];
|
|
547
|
+
} : T_1 : never : never;
|
|
548
|
+
} : ResponseWrapper;
|
|
549
|
+
$request: {
|
|
550
|
+
[k: string]: string;
|
|
551
|
+
path: string;
|
|
552
|
+
method: string;
|
|
553
|
+
};
|
|
554
|
+
$serialized: {
|
|
555
|
+
tag: string;
|
|
556
|
+
data: Pick<PostModel, 'id' | 'title' | 'slug' | 'category' | 'created'>[];
|
|
557
|
+
};
|
|
558
|
+
}>;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
interface PaginationParams {
|
|
562
|
+
size?: number;
|
|
563
|
+
page?: number;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
declare enum RefType {
|
|
567
|
+
Page = "Page",
|
|
568
|
+
Post = "Post",
|
|
569
|
+
Note = "Note"
|
|
570
|
+
}
|
|
571
|
+
interface CommentModel extends BaseModel {
|
|
572
|
+
refType: RefType;
|
|
573
|
+
ref: string;
|
|
574
|
+
state: number;
|
|
575
|
+
commentsIndex: number;
|
|
576
|
+
author: string;
|
|
577
|
+
text: string;
|
|
578
|
+
mail?: string;
|
|
579
|
+
url?: string;
|
|
580
|
+
ip?: string;
|
|
581
|
+
agent?: string;
|
|
582
|
+
key: string;
|
|
583
|
+
pin?: boolean;
|
|
584
|
+
avatar: string;
|
|
585
|
+
parent?: CommentModel | string;
|
|
586
|
+
children: CommentModel[];
|
|
587
|
+
isWhispers?: boolean;
|
|
588
|
+
location?: string;
|
|
589
|
+
source?: string;
|
|
590
|
+
}
|
|
591
|
+
interface CommentRef {
|
|
592
|
+
id: string;
|
|
593
|
+
categoryId?: string;
|
|
594
|
+
slug: string;
|
|
595
|
+
title: string;
|
|
596
|
+
category?: CategoryModel;
|
|
597
|
+
}
|
|
598
|
+
declare enum CommentState {
|
|
599
|
+
Unread = 0,
|
|
600
|
+
Read = 1,
|
|
601
|
+
Junk = 2
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
interface CommentDto {
|
|
605
|
+
author: string;
|
|
606
|
+
text: string;
|
|
607
|
+
mail: string;
|
|
608
|
+
url?: string;
|
|
609
|
+
source?: 'github' | 'google';
|
|
610
|
+
avatar?: string;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
declare module '../core/client' {
|
|
614
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
615
|
+
comment: CommentController<ResponseWrapper>;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
declare class CommentController<ResponseWrapper> implements IController {
|
|
619
|
+
private readonly client;
|
|
620
|
+
base: string;
|
|
621
|
+
name: string;
|
|
622
|
+
constructor(client: HTTPClient);
|
|
623
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
624
|
+
/**
|
|
625
|
+
* 根据 comment id 获取评论, 包括子评论
|
|
626
|
+
*/
|
|
627
|
+
getById(id: string): RequestProxyResult<CommentModel & {
|
|
628
|
+
ref: string;
|
|
629
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
630
|
+
[key: string]: any;
|
|
631
|
+
data: CommentModel & {
|
|
632
|
+
ref: string;
|
|
633
|
+
};
|
|
634
|
+
} : ResponseWrapper extends {
|
|
635
|
+
data: CommentModel & {
|
|
636
|
+
ref: string;
|
|
637
|
+
};
|
|
638
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
639
|
+
data: CommentModel & {
|
|
640
|
+
ref: string;
|
|
641
|
+
};
|
|
642
|
+
}>;
|
|
643
|
+
/**
|
|
644
|
+
* 获取文章的评论列表
|
|
645
|
+
* @param refId 文章 Id
|
|
646
|
+
*/
|
|
647
|
+
getByRefId(refId: string, pagination?: PaginationParams): RequestProxyResult<PaginateResult<CommentModel & {
|
|
648
|
+
ref: string;
|
|
649
|
+
}>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
650
|
+
[key: string]: any;
|
|
651
|
+
data: PaginateResult<CommentModel & {
|
|
652
|
+
ref: string;
|
|
653
|
+
}>;
|
|
654
|
+
} : ResponseWrapper extends {
|
|
655
|
+
data: PaginateResult<CommentModel & {
|
|
656
|
+
ref: string;
|
|
657
|
+
}>;
|
|
658
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
659
|
+
data: PaginateResult<CommentModel & {
|
|
660
|
+
ref: string;
|
|
661
|
+
}>;
|
|
662
|
+
}>;
|
|
663
|
+
/**
|
|
664
|
+
* 评论
|
|
665
|
+
*/
|
|
666
|
+
comment(refId: string, data: CommentDto): RequestProxyResult<CommentModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
667
|
+
[key: string]: any;
|
|
668
|
+
data: CommentModel;
|
|
669
|
+
} : ResponseWrapper extends {
|
|
670
|
+
data: CommentModel;
|
|
671
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
672
|
+
data: CommentModel;
|
|
673
|
+
}>;
|
|
674
|
+
/**
|
|
675
|
+
* 回复评论
|
|
676
|
+
*/
|
|
677
|
+
reply(commentId: string, data: CommentDto): RequestProxyResult<CommentModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
678
|
+
[key: string]: any;
|
|
679
|
+
data: CommentModel;
|
|
680
|
+
} : ResponseWrapper extends {
|
|
681
|
+
data: CommentModel;
|
|
682
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
683
|
+
data: CommentModel;
|
|
684
|
+
}>;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
declare enum LinkType {
|
|
688
|
+
Friend = 0,
|
|
689
|
+
Collection = 1
|
|
690
|
+
}
|
|
691
|
+
declare enum LinkState {
|
|
692
|
+
Pass = 0,
|
|
693
|
+
Audit = 1,
|
|
694
|
+
Outdate = 2,
|
|
695
|
+
Banned = 3,
|
|
696
|
+
Reject = 4
|
|
697
|
+
}
|
|
698
|
+
interface LinkModel extends BaseModel {
|
|
699
|
+
name: string;
|
|
700
|
+
url: string;
|
|
701
|
+
avatar: string;
|
|
702
|
+
description?: string;
|
|
703
|
+
type: LinkType;
|
|
704
|
+
state: LinkState;
|
|
705
|
+
hide: boolean;
|
|
706
|
+
email: string;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
type SortOptions = {
|
|
710
|
+
sortBy?: string;
|
|
711
|
+
sortOrder?: 1 | -1 | 'asc' | 'desc';
|
|
712
|
+
};
|
|
713
|
+
declare abstract class BaseCrudController<T, ResponseWrapper> {
|
|
714
|
+
protected client: HTTPClient;
|
|
715
|
+
base: string;
|
|
716
|
+
constructor(client: HTTPClient);
|
|
717
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
718
|
+
getById(id: string): RequestProxyResult<T, ResponseWrapper>;
|
|
719
|
+
getAll(): RequestProxyResult<{
|
|
720
|
+
data: T[];
|
|
721
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
722
|
+
[key: string]: any;
|
|
723
|
+
data: {
|
|
724
|
+
data: T[];
|
|
725
|
+
};
|
|
726
|
+
} : ResponseWrapper extends {
|
|
727
|
+
data: {
|
|
728
|
+
data: T[];
|
|
729
|
+
};
|
|
730
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
731
|
+
data: {
|
|
732
|
+
data: T[];
|
|
733
|
+
};
|
|
734
|
+
}>;
|
|
735
|
+
/**
|
|
736
|
+
* 带分页的查询
|
|
737
|
+
* @param page
|
|
738
|
+
* @param perPage
|
|
739
|
+
*/
|
|
740
|
+
getAllPaginated(page?: number, perPage?: number, sortOption?: SortOptions): RequestProxyResult<PaginateResult<T>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
741
|
+
[key: string]: any;
|
|
742
|
+
data: PaginateResult<T>;
|
|
743
|
+
} : ResponseWrapper extends {
|
|
744
|
+
data: PaginateResult<T>;
|
|
745
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
746
|
+
data: PaginateResult<T>;
|
|
747
|
+
}>;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
declare module '../core/client' {
|
|
751
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
752
|
+
link: LinkController<ResponseWrapper>;
|
|
753
|
+
friend: LinkController<ResponseWrapper>;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
declare class LinkController<ResponseWrapper> extends BaseCrudController<LinkModel, ResponseWrapper> {
|
|
757
|
+
protected readonly client: HTTPClient;
|
|
758
|
+
constructor(client: HTTPClient);
|
|
759
|
+
canApplyLink(): Promise<boolean>;
|
|
760
|
+
applyLink(data: Pick<LinkModel, 'avatar' | 'name' | 'description' | 'url' | 'email'> & {
|
|
761
|
+
author: string;
|
|
762
|
+
}): Promise<never>;
|
|
763
|
+
name: string[];
|
|
764
|
+
base: string;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
declare module '../core/client' {
|
|
768
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
769
|
+
note: NoteController<ResponseWrapper>;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
type NoteListOptions = {
|
|
773
|
+
select?: SelectFields<keyof NoteModel>;
|
|
774
|
+
year?: number;
|
|
775
|
+
sortBy?: 'weather' | 'mood' | 'title' | 'created' | 'modified';
|
|
776
|
+
sortOrder?: 1 | -1;
|
|
777
|
+
};
|
|
778
|
+
declare class NoteController<ResponseWrapper> implements IController {
|
|
779
|
+
private client;
|
|
780
|
+
base: string;
|
|
781
|
+
name: string;
|
|
782
|
+
constructor(client: HTTPClient);
|
|
783
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
784
|
+
/**
|
|
785
|
+
* 最新日记
|
|
786
|
+
*/
|
|
787
|
+
getLatest(): RequestProxyResult<NoteWrappedWithLikedPayload, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
788
|
+
[key: string]: any;
|
|
789
|
+
data: NoteWrappedWithLikedPayload;
|
|
790
|
+
} : ResponseWrapper extends {
|
|
791
|
+
data: NoteWrappedWithLikedPayload;
|
|
792
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
793
|
+
data: NoteWrappedWithLikedPayload;
|
|
794
|
+
}>;
|
|
795
|
+
/**
|
|
796
|
+
* 获取一篇日记,根据 Id 查询需要鉴权
|
|
797
|
+
* @param id id | nid
|
|
798
|
+
* @param password 访问密码
|
|
799
|
+
*/
|
|
800
|
+
getNoteById(id: string): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
801
|
+
getNoteById(id: number): Promise<NoteWrappedPayload>;
|
|
802
|
+
getNoteById(id: number, password: string): Promise<NoteWrappedPayload>;
|
|
803
|
+
getNoteById(id: number, password: undefined, singleResult: true): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
804
|
+
getNoteById(id: number, password: string, singleResult: true): Promise<RequestProxyResult<NoteModel, ResponseWrapper>>;
|
|
805
|
+
/**
|
|
806
|
+
* 日记列表分页
|
|
807
|
+
*/
|
|
808
|
+
getList(page?: number, perPage?: number, options?: NoteListOptions): RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
809
|
+
[key: string]: any;
|
|
810
|
+
data: PaginateResult<NoteModel>;
|
|
811
|
+
} : ResponseWrapper extends {
|
|
812
|
+
data: PaginateResult<NoteModel>;
|
|
813
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
814
|
+
data: PaginateResult<NoteModel>;
|
|
815
|
+
}>;
|
|
816
|
+
/**
|
|
817
|
+
* 获取当前日记的上下各 n / 2 篇日记
|
|
818
|
+
*/
|
|
819
|
+
getMiddleList(id: string, size?: number): RequestProxyResult<{
|
|
820
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
821
|
+
size: number;
|
|
822
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
823
|
+
[key: string]: any;
|
|
824
|
+
data: {
|
|
825
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
826
|
+
size: number;
|
|
827
|
+
};
|
|
828
|
+
} : ResponseWrapper extends {
|
|
829
|
+
data: {
|
|
830
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
831
|
+
size: number;
|
|
832
|
+
};
|
|
833
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
834
|
+
data: {
|
|
835
|
+
data: Pick<NoteModel, 'id' | 'title' | 'nid' | 'created'>[];
|
|
836
|
+
size: number;
|
|
837
|
+
};
|
|
838
|
+
}>;
|
|
839
|
+
/**
|
|
840
|
+
* 喜欢这篇日记
|
|
841
|
+
*/
|
|
842
|
+
likeIt(id: string | number): RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
843
|
+
[key: string]: any;
|
|
844
|
+
data: never;
|
|
845
|
+
} : ResponseWrapper extends {
|
|
846
|
+
data: never;
|
|
847
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
848
|
+
data: never;
|
|
849
|
+
}>;
|
|
850
|
+
/**
|
|
851
|
+
* 获取专栏内的所有日记
|
|
852
|
+
*/
|
|
853
|
+
getNoteByTopicId(topicId: string, page?: number, size?: number, sortOptions?: SortOptions): RequestProxyResult<PaginateResult<NoteModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
854
|
+
[key: string]: any;
|
|
855
|
+
data: PaginateResult<NoteModel>;
|
|
856
|
+
} : ResponseWrapper extends {
|
|
857
|
+
data: PaginateResult<NoteModel>;
|
|
858
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
859
|
+
data: PaginateResult<NoteModel>;
|
|
860
|
+
}>;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
declare module '../core/client' {
|
|
864
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
865
|
+
page: PageController<ResponseWrapper>;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
type PageListOptions = {
|
|
869
|
+
select?: SelectFields<keyof PageModel>;
|
|
870
|
+
sortBy?: 'order' | 'subtitle' | 'title' | 'created' | 'modified';
|
|
871
|
+
sortOrder?: 1 | -1;
|
|
872
|
+
};
|
|
873
|
+
declare class PageController<ResponseWrapper> implements IController {
|
|
874
|
+
private readonly client;
|
|
875
|
+
constructor(client: HTTPClient);
|
|
876
|
+
base: string;
|
|
877
|
+
name: string;
|
|
878
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
879
|
+
/**
|
|
880
|
+
* 页面列表
|
|
881
|
+
*/
|
|
882
|
+
getList(page?: number, perPage?: number, options?: PageListOptions): RequestProxyResult<PaginateResult<PageModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
883
|
+
[key: string]: any;
|
|
884
|
+
data: PaginateResult<PageModel>;
|
|
885
|
+
} : ResponseWrapper extends {
|
|
886
|
+
data: PaginateResult<PageModel>;
|
|
887
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
888
|
+
data: PaginateResult<PageModel>;
|
|
889
|
+
}>;
|
|
890
|
+
/**
|
|
891
|
+
* 页面详情
|
|
892
|
+
*/
|
|
893
|
+
getById(id: string): RequestProxyResult<PageModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
894
|
+
[key: string]: any;
|
|
895
|
+
data: PageModel;
|
|
896
|
+
} : ResponseWrapper extends {
|
|
897
|
+
data: PageModel;
|
|
898
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
899
|
+
data: PageModel;
|
|
900
|
+
}>;
|
|
901
|
+
/**
|
|
902
|
+
* 根据路径获取页面
|
|
903
|
+
* @param slug 路径
|
|
904
|
+
* @returns
|
|
905
|
+
*/
|
|
906
|
+
getBySlug(slug: string): RequestProxyResult<PageModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
907
|
+
[key: string]: any;
|
|
908
|
+
data: PageModel;
|
|
909
|
+
} : ResponseWrapper extends {
|
|
910
|
+
data: PageModel;
|
|
911
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
912
|
+
data: PageModel;
|
|
913
|
+
}>;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
declare module '../core/client' {
|
|
917
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
918
|
+
post: PostController<ResponseWrapper>;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
type PostListOptions = {
|
|
922
|
+
select?: SelectFields<keyof PostModel>;
|
|
923
|
+
year?: number;
|
|
924
|
+
sortBy?: 'categoryId' | 'title' | 'created' | 'modified';
|
|
925
|
+
sortOrder?: 1 | -1;
|
|
926
|
+
};
|
|
927
|
+
declare class PostController<ResponseWrapper> implements IController {
|
|
928
|
+
private client;
|
|
929
|
+
constructor(client: HTTPClient);
|
|
930
|
+
base: string;
|
|
931
|
+
name: string;
|
|
932
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
933
|
+
/**
|
|
934
|
+
* 获取文章列表分页
|
|
935
|
+
* @param page
|
|
936
|
+
* @param perPage
|
|
937
|
+
* @returns
|
|
938
|
+
*/
|
|
939
|
+
getList(page?: number, perPage?: number, options?: PostListOptions): RequestProxyResult<PaginateResult<PostModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
940
|
+
[key: string]: any;
|
|
941
|
+
data: PaginateResult<PostModel>;
|
|
942
|
+
} : ResponseWrapper extends {
|
|
943
|
+
data: PaginateResult<PostModel>;
|
|
944
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
945
|
+
data: PaginateResult<PostModel>;
|
|
946
|
+
}>;
|
|
947
|
+
/**
|
|
948
|
+
* 根据分类和路径查找文章
|
|
949
|
+
* @param categoryName
|
|
950
|
+
* @param slug
|
|
951
|
+
*/
|
|
952
|
+
getPost(categoryName: string, slug: string): RequestProxyResult<ModelWithLiked<PostModel>, ResponseWrapper>;
|
|
953
|
+
/**
|
|
954
|
+
* 根据 ID 查找文章
|
|
955
|
+
* @param id
|
|
956
|
+
*/
|
|
957
|
+
getPost(id: string): RequestProxyResult<PostModel, ResponseWrapper>;
|
|
958
|
+
/**
|
|
959
|
+
* 获取最新的文章
|
|
960
|
+
*/
|
|
961
|
+
getLatest(): RequestProxyResult<ModelWithLiked<PostModel>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
962
|
+
[key: string]: any;
|
|
963
|
+
data: ModelWithLiked<PostModel>;
|
|
964
|
+
} : ResponseWrapper extends {
|
|
965
|
+
data: ModelWithLiked<PostModel>;
|
|
966
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
967
|
+
data: ModelWithLiked<PostModel>;
|
|
968
|
+
}>;
|
|
969
|
+
/**
|
|
970
|
+
* 点赞
|
|
971
|
+
*/
|
|
972
|
+
thumbsUp(id: string): RequestProxyResult<void, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
973
|
+
[key: string]: any;
|
|
974
|
+
data: void;
|
|
975
|
+
} : ResponseWrapper extends {
|
|
976
|
+
data: void;
|
|
977
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
978
|
+
data: void;
|
|
979
|
+
}>;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
interface ProjectModel extends BaseModel {
|
|
983
|
+
name: string;
|
|
984
|
+
previewUrl?: string;
|
|
985
|
+
docUrl?: string;
|
|
986
|
+
projectUrl?: string;
|
|
987
|
+
images?: string[];
|
|
988
|
+
description: string;
|
|
989
|
+
avatar?: string;
|
|
990
|
+
text: string;
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
declare module '../core/client' {
|
|
994
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
995
|
+
project: ProjectController<ResponseWrapper>;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
declare class ProjectController<ResponseWrapper> extends BaseCrudController<ProjectModel, ResponseWrapper> {
|
|
999
|
+
protected readonly client: HTTPClient;
|
|
1000
|
+
constructor(client: HTTPClient);
|
|
1001
|
+
base: string;
|
|
1002
|
+
name: string;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
declare enum RecentlyRefTypes {
|
|
1006
|
+
Post = "Post",
|
|
1007
|
+
Note = "Note",
|
|
1008
|
+
Page = "Page"
|
|
1009
|
+
}
|
|
1010
|
+
type RecentlyRefType = {
|
|
1011
|
+
title: string;
|
|
1012
|
+
url: string;
|
|
1013
|
+
};
|
|
1014
|
+
interface RecentlyModel extends BaseCommentIndexModel {
|
|
1015
|
+
content: string;
|
|
1016
|
+
ref?: RecentlyRefType & {
|
|
1017
|
+
[key: string]: any;
|
|
1018
|
+
};
|
|
1019
|
+
refId?: string;
|
|
1020
|
+
refType?: RecentlyRefTypes;
|
|
1021
|
+
up: number;
|
|
1022
|
+
down: number;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
declare module '../core/client' {
|
|
1026
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1027
|
+
recently: RecentlyController<ResponseWrapper>;
|
|
1028
|
+
shorthand: RecentlyController<ResponseWrapper>;
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
declare enum RecentlyAttitudeResultEnum {
|
|
1032
|
+
Inc = 1,
|
|
1033
|
+
Dec = -1
|
|
1034
|
+
}
|
|
1035
|
+
declare enum RecentlyAttitudeEnum {
|
|
1036
|
+
Up = 0,
|
|
1037
|
+
Down = 1
|
|
1038
|
+
}
|
|
1039
|
+
declare class RecentlyController<ResponseWrapper> implements IController {
|
|
1040
|
+
private readonly client;
|
|
1041
|
+
base: string;
|
|
1042
|
+
name: string[];
|
|
1043
|
+
constructor(client: HTTPClient);
|
|
1044
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1045
|
+
/**
|
|
1046
|
+
* 获取最新一条
|
|
1047
|
+
*/
|
|
1048
|
+
getLatestOne(): RequestProxyResult<RecentlyModel & {
|
|
1049
|
+
comments: number;
|
|
1050
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1051
|
+
[key: string]: any;
|
|
1052
|
+
data: RecentlyModel & {
|
|
1053
|
+
comments: number;
|
|
1054
|
+
};
|
|
1055
|
+
} : ResponseWrapper extends {
|
|
1056
|
+
data: RecentlyModel & {
|
|
1057
|
+
comments: number;
|
|
1058
|
+
};
|
|
1059
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1060
|
+
data: RecentlyModel & {
|
|
1061
|
+
comments: number;
|
|
1062
|
+
};
|
|
1063
|
+
}>;
|
|
1064
|
+
getAll(): RequestProxyResult<{
|
|
1065
|
+
data: RecentlyModel[] & {
|
|
1066
|
+
comments: number;
|
|
1067
|
+
};
|
|
1068
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1069
|
+
[key: string]: any;
|
|
1070
|
+
data: {
|
|
1071
|
+
data: RecentlyModel[] & {
|
|
1072
|
+
comments: number;
|
|
1073
|
+
};
|
|
1074
|
+
};
|
|
1075
|
+
} : ResponseWrapper extends {
|
|
1076
|
+
data: {
|
|
1077
|
+
data: RecentlyModel[] & {
|
|
1078
|
+
comments: number;
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1082
|
+
data: {
|
|
1083
|
+
data: RecentlyModel[] & {
|
|
1084
|
+
comments: number;
|
|
1085
|
+
};
|
|
1086
|
+
};
|
|
1087
|
+
}>;
|
|
1088
|
+
getList(before?: string | undefined, after?: string | undefined, size?: number | number): RequestProxyResult<{
|
|
1089
|
+
data: RecentlyModel[] & {
|
|
1090
|
+
comments: number;
|
|
1091
|
+
};
|
|
1092
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1093
|
+
[key: string]: any;
|
|
1094
|
+
data: {
|
|
1095
|
+
data: RecentlyModel[] & {
|
|
1096
|
+
comments: number;
|
|
1097
|
+
};
|
|
1098
|
+
};
|
|
1099
|
+
} : ResponseWrapper extends {
|
|
1100
|
+
data: {
|
|
1101
|
+
data: RecentlyModel[] & {
|
|
1102
|
+
comments: number;
|
|
1103
|
+
};
|
|
1104
|
+
};
|
|
1105
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1106
|
+
data: {
|
|
1107
|
+
data: RecentlyModel[] & {
|
|
1108
|
+
comments: number;
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
}>;
|
|
1112
|
+
/** 表态:点赞,点踩 */
|
|
1113
|
+
attitude(id: string, attitude: RecentlyAttitudeEnum): RequestProxyResult<{
|
|
1114
|
+
code: RecentlyAttitudeResultEnum;
|
|
1115
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1116
|
+
[key: string]: any;
|
|
1117
|
+
data: {
|
|
1118
|
+
code: RecentlyAttitudeResultEnum;
|
|
1119
|
+
};
|
|
1120
|
+
} : ResponseWrapper extends {
|
|
1121
|
+
data: {
|
|
1122
|
+
code: RecentlyAttitudeResultEnum;
|
|
1123
|
+
};
|
|
1124
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1125
|
+
data: {
|
|
1126
|
+
code: RecentlyAttitudeResultEnum;
|
|
1127
|
+
};
|
|
1128
|
+
}>;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
declare module '../core/client' {
|
|
1132
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1133
|
+
say: SayController<ResponseWrapper>;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
declare class SayController<ResponseWrapper> extends BaseCrudController<SayModel, ResponseWrapper> implements IController {
|
|
1137
|
+
protected client: HTTPClient;
|
|
1138
|
+
base: string;
|
|
1139
|
+
name: string;
|
|
1140
|
+
constructor(client: HTTPClient);
|
|
1141
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1142
|
+
/**
|
|
1143
|
+
* 获取随机一条
|
|
1144
|
+
*/
|
|
1145
|
+
getRandom(): RequestProxyResult<{
|
|
1146
|
+
data: SayModel | null;
|
|
1147
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1148
|
+
[key: string]: any;
|
|
1149
|
+
data: {
|
|
1150
|
+
data: SayModel | null;
|
|
1151
|
+
};
|
|
1152
|
+
} : ResponseWrapper extends {
|
|
1153
|
+
data: {
|
|
1154
|
+
data: SayModel | null;
|
|
1155
|
+
};
|
|
1156
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1157
|
+
data: {
|
|
1158
|
+
data: SayModel | null;
|
|
1159
|
+
};
|
|
1160
|
+
}>;
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
declare module '../core/client' {
|
|
1164
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1165
|
+
search: SearchController<ResponseWrapper>;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
type SearchOption = {
|
|
1169
|
+
orderBy?: string;
|
|
1170
|
+
order?: number;
|
|
1171
|
+
rawAlgolia?: boolean;
|
|
1172
|
+
};
|
|
1173
|
+
declare class SearchController<ResponseWrapper> implements IController {
|
|
1174
|
+
private readonly client;
|
|
1175
|
+
base: string;
|
|
1176
|
+
name: string;
|
|
1177
|
+
constructor(client: HTTPClient);
|
|
1178
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1179
|
+
search(type: 'note', keyword: string, options?: Omit<SearchOption, 'rawAlgolia'>): Promise<RequestProxyResult<PaginateResult<Pick<NoteModel, 'modified' | 'id' | 'title' | 'created' | 'nid'>>, ResponseWrapper>>;
|
|
1180
|
+
search(type: 'post', keyword: string, options?: Omit<SearchOption, 'rawAlgolia'>): Promise<RequestProxyResult<PaginateResult<Pick<PostModel, 'modified' | 'id' | 'title' | 'created' | 'slug' | 'category'>>, ResponseWrapper>>;
|
|
1181
|
+
/**
|
|
1182
|
+
* 从 algolya 搜索
|
|
1183
|
+
* https://www.algolia.com/doc/api-reference/api-methods/search/
|
|
1184
|
+
* @param keyword
|
|
1185
|
+
* @param options
|
|
1186
|
+
* @returns
|
|
1187
|
+
*/
|
|
1188
|
+
searchByAlgolia(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<(Pick<PostModel, "id" | "category" | "created" | "modified" | "title" | "slug"> & {
|
|
1189
|
+
type: 'post';
|
|
1190
|
+
}) | (Pick<NoteModel, "id" | "created" | "modified" | "title" | "nid"> & {
|
|
1191
|
+
type: 'note';
|
|
1192
|
+
}) | (Pick<PageModel, "id" | "created" | "modified" | "title" | "slug"> & {
|
|
1193
|
+
type: 'page';
|
|
1194
|
+
})> & {
|
|
1195
|
+
/**
|
|
1196
|
+
* @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
|
|
1197
|
+
*/
|
|
1198
|
+
raw?: any;
|
|
1199
|
+
}, ResponseWrapper>, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1200
|
+
[key: string]: any;
|
|
1201
|
+
data: RequestProxyResult<PaginateResult<(Pick<PostModel, "id" | "category" | "created" | "modified" | "title" | "slug"> & {
|
|
1202
|
+
type: 'post';
|
|
1203
|
+
}) | (Pick<NoteModel, "id" | "created" | "modified" | "title" | "nid"> & {
|
|
1204
|
+
type: 'note';
|
|
1205
|
+
}) | (Pick<PageModel, "id" | "created" | "modified" | "title" | "slug"> & {
|
|
1206
|
+
type: 'page';
|
|
1207
|
+
})> & {
|
|
1208
|
+
/**
|
|
1209
|
+
* @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
|
|
1210
|
+
*/
|
|
1211
|
+
raw?: any;
|
|
1212
|
+
}, ResponseWrapper>;
|
|
1213
|
+
} : ResponseWrapper extends {
|
|
1214
|
+
data: RequestProxyResult<PaginateResult<(Pick<PostModel, "id" | "category" | "created" | "modified" | "title" | "slug"> & {
|
|
1215
|
+
type: 'post';
|
|
1216
|
+
}) | (Pick<NoteModel, "id" | "created" | "modified" | "title" | "nid"> & {
|
|
1217
|
+
type: 'note';
|
|
1218
|
+
}) | (Pick<PageModel, "id" | "created" | "modified" | "title" | "slug"> & {
|
|
1219
|
+
type: 'page';
|
|
1220
|
+
})> & {
|
|
1221
|
+
/**
|
|
1222
|
+
* @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
|
|
1223
|
+
*/
|
|
1224
|
+
raw?: any;
|
|
1225
|
+
}, ResponseWrapper>;
|
|
1226
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1227
|
+
data: RequestProxyResult<PaginateResult<(Pick<PostModel, "id" | "category" | "created" | "modified" | "title" | "slug"> & {
|
|
1228
|
+
type: 'post';
|
|
1229
|
+
}) | (Pick<NoteModel, "id" | "created" | "modified" | "title" | "nid"> & {
|
|
1230
|
+
type: 'note';
|
|
1231
|
+
}) | (Pick<PageModel, "id" | "created" | "modified" | "title" | "slug"> & {
|
|
1232
|
+
type: 'page';
|
|
1233
|
+
})> & {
|
|
1234
|
+
/**
|
|
1235
|
+
* @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
|
|
1236
|
+
*/
|
|
1237
|
+
raw?: any;
|
|
1238
|
+
}, ResponseWrapper>;
|
|
1239
|
+
}>;
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
declare module '../core/client' {
|
|
1243
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1244
|
+
serverless: ServerlessController<ResponseWrapper>;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
declare class ServerlessController<ResponseWrapper> implements IController {
|
|
1248
|
+
protected client: HTTPClient;
|
|
1249
|
+
base: string;
|
|
1250
|
+
name: string;
|
|
1251
|
+
constructor(client: HTTPClient);
|
|
1252
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1253
|
+
getByReferenceAndName<T = unknown>(reference: string, name: string): RequestProxyResult<T, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1254
|
+
[key: string]: any;
|
|
1255
|
+
data: T;
|
|
1256
|
+
} : ResponseWrapper extends {
|
|
1257
|
+
data: T;
|
|
1258
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1259
|
+
data: T;
|
|
1260
|
+
}>;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
declare module '../core/client' {
|
|
1264
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1265
|
+
snippet: SnippetController<ResponseWrapper>;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
declare class SnippetController<ResponseWrapper> implements IController {
|
|
1269
|
+
protected client: HTTPClient;
|
|
1270
|
+
base: string;
|
|
1271
|
+
name: string;
|
|
1272
|
+
constructor(client: HTTPClient);
|
|
1273
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1274
|
+
getByReferenceAndName<T = unknown>(reference: string, name: string): RequestProxyResult<T, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1275
|
+
[key: string]: any;
|
|
1276
|
+
data: T;
|
|
1277
|
+
} : ResponseWrapper extends {
|
|
1278
|
+
data: T;
|
|
1279
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1280
|
+
data: T;
|
|
1281
|
+
}>;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
declare const SubscribePostCreateBit: number;
|
|
1285
|
+
declare const SubscribeNoteCreateBit: number;
|
|
1286
|
+
declare const SubscribeSayCreateBit: number;
|
|
1287
|
+
declare const SubscribeRecentCreateBit: number;
|
|
1288
|
+
declare const SubscribeAllBit: number;
|
|
1289
|
+
declare const SubscribeTypeToBitMap: {
|
|
1290
|
+
post_c: number;
|
|
1291
|
+
note_c: number;
|
|
1292
|
+
say_c: number;
|
|
1293
|
+
recently_c: number;
|
|
1294
|
+
all: number;
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
type SubscribeType = keyof typeof SubscribeTypeToBitMap;
|
|
1298
|
+
|
|
1299
|
+
declare module '../core/client' {
|
|
1300
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1301
|
+
subscribe: SubscribeController<ResponseWrapper>;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
declare class SubscribeController<ResponseWrapper> implements IController {
|
|
1305
|
+
protected client: HTTPClient;
|
|
1306
|
+
base: string;
|
|
1307
|
+
name: string;
|
|
1308
|
+
constructor(client: HTTPClient);
|
|
1309
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1310
|
+
/**
|
|
1311
|
+
* 检查开启状态
|
|
1312
|
+
*/
|
|
1313
|
+
check(): RequestProxyResult<{
|
|
1314
|
+
enable: boolean;
|
|
1315
|
+
bitMap: Record<SubscribeType, number>;
|
|
1316
|
+
allowBits: number[];
|
|
1317
|
+
allowTypes: SubscribeType[];
|
|
1318
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1319
|
+
[key: string]: any;
|
|
1320
|
+
data: {
|
|
1321
|
+
enable: boolean;
|
|
1322
|
+
bitMap: Record<SubscribeType, number>;
|
|
1323
|
+
allowBits: number[];
|
|
1324
|
+
allowTypes: SubscribeType[];
|
|
1325
|
+
};
|
|
1326
|
+
} : ResponseWrapper extends {
|
|
1327
|
+
data: {
|
|
1328
|
+
enable: boolean;
|
|
1329
|
+
bitMap: Record<SubscribeType, number>;
|
|
1330
|
+
allowBits: number[];
|
|
1331
|
+
allowTypes: SubscribeType[];
|
|
1332
|
+
};
|
|
1333
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1334
|
+
data: {
|
|
1335
|
+
enable: boolean;
|
|
1336
|
+
bitMap: Record<SubscribeType, number>;
|
|
1337
|
+
allowBits: number[];
|
|
1338
|
+
allowTypes: SubscribeType[];
|
|
1339
|
+
};
|
|
1340
|
+
}>;
|
|
1341
|
+
subscribe(email: string, types: SubscribeType[]): RequestProxyResult<never, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1342
|
+
[key: string]: any;
|
|
1343
|
+
data: never;
|
|
1344
|
+
} : ResponseWrapper extends {
|
|
1345
|
+
data: never;
|
|
1346
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1347
|
+
data: never;
|
|
1348
|
+
}>;
|
|
1349
|
+
unsubscribe(email: string, cancelToken: string): RequestProxyResult<string, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1350
|
+
[key: string]: any;
|
|
1351
|
+
data: string;
|
|
1352
|
+
} : ResponseWrapper extends {
|
|
1353
|
+
data: string;
|
|
1354
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1355
|
+
data: string;
|
|
1356
|
+
}>;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
declare module '../core/client' {
|
|
1360
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1361
|
+
topic: TopicController<ResponseWrapper>;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
declare class TopicController<ResponseWrapper> extends BaseCrudController<TopicModel, ResponseWrapper> implements IController {
|
|
1365
|
+
protected client: HTTPClient;
|
|
1366
|
+
base: string;
|
|
1367
|
+
name: string;
|
|
1368
|
+
constructor(client: HTTPClient);
|
|
1369
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1370
|
+
getTopicBySlug(slug: string): RequestProxyResult<TopicModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1371
|
+
[key: string]: any;
|
|
1372
|
+
data: TopicModel;
|
|
1373
|
+
} : ResponseWrapper extends {
|
|
1374
|
+
data: TopicModel;
|
|
1375
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1376
|
+
data: TopicModel;
|
|
1377
|
+
}>;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
declare module '../core/client' {
|
|
1381
|
+
interface HTTPClient<T extends IRequestAdapter = IRequestAdapter, ResponseWrapper = unknown> {
|
|
1382
|
+
user: UserController<ResponseWrapper>;
|
|
1383
|
+
master: UserController<ResponseWrapper>;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
declare class UserController<ResponseWrapper> implements IController {
|
|
1387
|
+
private readonly client;
|
|
1388
|
+
constructor(client: HTTPClient);
|
|
1389
|
+
base: string;
|
|
1390
|
+
name: string[];
|
|
1391
|
+
get proxy(): IRequestHandler<ResponseWrapper>;
|
|
1392
|
+
getMasterInfo(): RequestProxyResult<UserModel, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1393
|
+
[key: string]: any;
|
|
1394
|
+
data: UserModel;
|
|
1395
|
+
} : ResponseWrapper extends {
|
|
1396
|
+
data: UserModel;
|
|
1397
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1398
|
+
data: UserModel;
|
|
1399
|
+
}>;
|
|
1400
|
+
login(username: string, password: string): RequestProxyResult<TLogin, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1401
|
+
[key: string]: any;
|
|
1402
|
+
data: TLogin;
|
|
1403
|
+
} : ResponseWrapper extends {
|
|
1404
|
+
data: TLogin;
|
|
1405
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1406
|
+
data: TLogin;
|
|
1407
|
+
}>;
|
|
1408
|
+
loginWithToken(token?: string): RequestProxyResult<{
|
|
1409
|
+
token: string;
|
|
1410
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1411
|
+
[key: string]: any;
|
|
1412
|
+
data: {
|
|
1413
|
+
token: string;
|
|
1414
|
+
};
|
|
1415
|
+
} : ResponseWrapper extends {
|
|
1416
|
+
data: {
|
|
1417
|
+
token: string;
|
|
1418
|
+
};
|
|
1419
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1420
|
+
data: {
|
|
1421
|
+
token: string;
|
|
1422
|
+
};
|
|
1423
|
+
}>;
|
|
1424
|
+
checkTokenValid(token: string): RequestProxyResult<{
|
|
1425
|
+
ok: number;
|
|
1426
|
+
isGuest: boolean;
|
|
1427
|
+
}, ResponseWrapper, ResponseWrapper extends unknown ? {
|
|
1428
|
+
[key: string]: any;
|
|
1429
|
+
data: {
|
|
1430
|
+
ok: number;
|
|
1431
|
+
isGuest: boolean;
|
|
1432
|
+
};
|
|
1433
|
+
} : ResponseWrapper extends {
|
|
1434
|
+
data: {
|
|
1435
|
+
ok: number;
|
|
1436
|
+
isGuest: boolean;
|
|
1437
|
+
};
|
|
1438
|
+
} ? ResponseWrapper : Omit<ResponseWrapper, "data"> & {
|
|
1439
|
+
data: {
|
|
1440
|
+
ok: number;
|
|
1441
|
+
isGuest: boolean;
|
|
1442
|
+
};
|
|
1443
|
+
}>;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
declare const allControllers: (typeof AggregateController | typeof CategoryController | typeof CommentController | typeof LinkController | typeof NoteController | typeof PageController | typeof PostController | typeof ProjectController | typeof RecentlyController | typeof SayController | typeof SearchController | typeof ServerlessController | typeof SnippetController | typeof SubscribeController | typeof TopicController | typeof UserController)[];
|
|
1447
|
+
declare const allContollerNames: readonly ["aggregate", "category", "comment", "link", "note", "page", "post", "project", "topic", "recently", "say", "search", "snippet", "serverless", "subscribe", "user", "friend", "master", "shorthand"];
|
|
1448
|
+
|
|
1449
|
+
declare enum SnippetType {
|
|
1450
|
+
JSON = "json",
|
|
1451
|
+
Function = "function",
|
|
1452
|
+
Text = "text",
|
|
1453
|
+
YAML = "yaml"
|
|
1454
|
+
}
|
|
1455
|
+
interface SnippetModel<T = unknown> extends BaseModel {
|
|
1456
|
+
type: SnippetType;
|
|
1457
|
+
private: boolean;
|
|
1458
|
+
raw: string;
|
|
1459
|
+
name: string;
|
|
1460
|
+
reference: string;
|
|
1461
|
+
comment?: string;
|
|
1462
|
+
metatype?: string;
|
|
1463
|
+
schema?: string;
|
|
1464
|
+
data: T;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* A simple camelCase function that only handles strings, but not handling symbol, date, or other complex case.
|
|
1469
|
+
* If you need to handle more complex cases, please use camelcase-keys package.
|
|
1470
|
+
*/
|
|
1471
|
+
declare const camelcaseKeys: <T = any>(obj: any) => T;
|
|
1472
|
+
|
|
1473
|
+
export { AdminExtraModel, AggregateController, AggregateRoot, AggregateRootWithTheme, AggregateStat, AggregateTop, AggregateTopNote, AggregateTopPost, AlgoliaSearchOptionsModel, BackupOptionsModel, BaiduSearchOptionsModel, BaseCommentIndexModel, BaseModel, CategoryController, CategoryEntries, CategoryModel, CategoryType, CategoryWithChildrenModel, CommentController, CommentDto, CommentModel, CommentOptionsModel, CommentRef, CommentState, Coordinate, Count, EnumPageType, HTTPClient, IConfig, IConfigKeys, Image, LinkController, LinkModel, LinkState, LinkType, MailOptionsModel, ModelWithLiked, NoteController, NoteModel, NoteMusicRecord, NoteWrappedPayload, NoteWrappedWithLikedPayload, PageController, PageModel, Pager, PaginateResult, PostController, PostModel, ProjectController, ProjectModel, RecentlyAttitudeEnum, RecentlyAttitudeResultEnum, RecentlyController, RecentlyModel, RecentlyRefType, RecentlyRefTypes, RefType, RequestError, SayController, SayModel, SearchController, SeoOptionModel, ServerlessController, SnippetController, SnippetModel, SnippetType, SubscribeAllBit, SubscribeController, SubscribeNoteCreateBit, SubscribePostCreateBit, SubscribeRecentCreateBit, SubscribeSayCreateBit, SubscribeType, SubscribeTypeToBitMap, TLogin, TagModel, TextBaseModel, TimelineData, TimelineType, TopicController, TopicModel, Url, UrlOptionModel, UserController, UserModel, allContollerNames, allControllers, createClient, createClient as default, camelcaseKeys as simpleCamelcaseKeys };
|