@mx-space/api-client 1.3.3 → 1.3.5
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/.eslintcache +1 -1
- package/controllers/subscribe.ts +1 -1
- package/dist/adaptors/axios.cjs +4 -0
- package/dist/adaptors/axios.global.js +188 -85
- package/dist/adaptors/ky.cjs +4 -0
- package/dist/adaptors/ky.global.js +11 -1
- package/dist/adaptors/umi-request.global.js +165 -74
- package/dist/index.cjs +90 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.global.js +90 -1
- package/dist/index.js +90 -1
- package/models/comment.ts +1 -0
- package/package.json +3 -4
package/dist/index.js
CHANGED
|
@@ -108,9 +108,15 @@ var AggregateController = class {
|
|
|
108
108
|
get proxy() {
|
|
109
109
|
return this.client.proxy(this.base);
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* 获取聚合数据
|
|
113
|
+
*/
|
|
111
114
|
getAggregateData() {
|
|
112
115
|
return this.proxy.get();
|
|
113
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* 获取最新发布的内容
|
|
119
|
+
*/
|
|
114
120
|
getTop(size = 5) {
|
|
115
121
|
return this.proxy.top.get({ params: { size } });
|
|
116
122
|
}
|
|
@@ -124,6 +130,9 @@ var AggregateController = class {
|
|
|
124
130
|
}
|
|
125
131
|
});
|
|
126
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* 获取聚合数据统计
|
|
135
|
+
*/
|
|
127
136
|
getStat() {
|
|
128
137
|
return this.proxy.stat.get();
|
|
129
138
|
}
|
|
@@ -228,20 +237,33 @@ var CommentController = class {
|
|
|
228
237
|
get proxy() {
|
|
229
238
|
return this.client.proxy(this.base);
|
|
230
239
|
}
|
|
240
|
+
/**
|
|
241
|
+
* 根据 comment id 获取评论, 包括子评论
|
|
242
|
+
*/
|
|
231
243
|
getById(id) {
|
|
232
244
|
return this.proxy(id).get();
|
|
233
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* 获取文章的评论列表
|
|
248
|
+
* @param refId 文章 Id
|
|
249
|
+
*/
|
|
234
250
|
getByRefId(refId, pagination = {}) {
|
|
235
251
|
const { page, size } = pagination;
|
|
236
252
|
return this.proxy.ref(refId).get({
|
|
237
253
|
params: { page: page || 1, size: size || 10 }
|
|
238
254
|
});
|
|
239
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* 评论
|
|
258
|
+
*/
|
|
240
259
|
comment(refId, data) {
|
|
241
260
|
return this.proxy(refId).post({
|
|
242
261
|
data
|
|
243
262
|
});
|
|
244
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* 回复评论
|
|
266
|
+
*/
|
|
245
267
|
reply(commentId, data) {
|
|
246
268
|
return this.proxy.reply(commentId).post({
|
|
247
269
|
data
|
|
@@ -264,6 +286,11 @@ var BaseCrudController = class {
|
|
|
264
286
|
getAll() {
|
|
265
287
|
return this.proxy.all.get();
|
|
266
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* 带分页的查询
|
|
291
|
+
* @param page
|
|
292
|
+
* @param perPage
|
|
293
|
+
*/
|
|
267
294
|
getAllPaginated(page, perPage, sortOption) {
|
|
268
295
|
return this.proxy.get({
|
|
269
296
|
params: { page, size: perPage, ...sortOption }
|
|
@@ -280,10 +307,12 @@ var LinkController = class extends BaseCrudController {
|
|
|
280
307
|
this.base = "links";
|
|
281
308
|
autoBind(this);
|
|
282
309
|
}
|
|
310
|
+
// 是否可以申请友链
|
|
283
311
|
async canApplyLink() {
|
|
284
312
|
const { can } = await this.proxy.audit.get();
|
|
285
313
|
return can;
|
|
286
314
|
}
|
|
315
|
+
// 申请友链
|
|
287
316
|
async applyLink(data) {
|
|
288
317
|
return await this.proxy.audit.post({ data });
|
|
289
318
|
}
|
|
@@ -300,6 +329,9 @@ var NoteController = class {
|
|
|
300
329
|
get proxy() {
|
|
301
330
|
return this.client.proxy(this.base);
|
|
302
331
|
}
|
|
332
|
+
/**
|
|
333
|
+
* 最新日记
|
|
334
|
+
*/
|
|
303
335
|
getLatest() {
|
|
304
336
|
return this.proxy.latest.get();
|
|
305
337
|
}
|
|
@@ -313,6 +345,9 @@ var NoteController = class {
|
|
|
313
345
|
return this.proxy(id).get();
|
|
314
346
|
}
|
|
315
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* 日记列表分页
|
|
350
|
+
*/
|
|
316
351
|
getList(page = 1, perPage = 10, options = {}) {
|
|
317
352
|
const { select, sortBy, sortOrder, year } = options;
|
|
318
353
|
return this.proxy.get({
|
|
@@ -326,14 +361,23 @@ var NoteController = class {
|
|
|
326
361
|
}
|
|
327
362
|
});
|
|
328
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* 获取当前日记的上下各 n / 2 篇日记
|
|
366
|
+
*/
|
|
329
367
|
getMiddleList(id, size = 5) {
|
|
330
368
|
return this.proxy.list(id).get({
|
|
331
369
|
params: { size }
|
|
332
370
|
});
|
|
333
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* 喜欢这篇日记
|
|
374
|
+
*/
|
|
334
375
|
likeIt(id) {
|
|
335
376
|
return this.proxy.like(id).get();
|
|
336
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* 获取专栏内的所有日记
|
|
380
|
+
*/
|
|
337
381
|
getNoteByTopicId(topicId, page = 1, size = 10, sortOptions = {}) {
|
|
338
382
|
return this.proxy.topics(topicId).get({
|
|
339
383
|
params: { page, size, ...sortOptions }
|
|
@@ -352,6 +396,9 @@ var PageController = class {
|
|
|
352
396
|
get proxy() {
|
|
353
397
|
return this.client.proxy(this.base);
|
|
354
398
|
}
|
|
399
|
+
/**
|
|
400
|
+
* 页面列表
|
|
401
|
+
*/
|
|
355
402
|
getList(page = 1, perPage = 10, options = {}) {
|
|
356
403
|
const { select, sortBy, sortOrder } = options;
|
|
357
404
|
return this.proxy.get({
|
|
@@ -364,9 +411,17 @@ var PageController = class {
|
|
|
364
411
|
}
|
|
365
412
|
});
|
|
366
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* 页面详情
|
|
416
|
+
*/
|
|
367
417
|
getById(id) {
|
|
368
418
|
return this.proxy(id).get();
|
|
369
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* 根据路径获取页面
|
|
422
|
+
* @param slug 路径
|
|
423
|
+
* @returns
|
|
424
|
+
*/
|
|
370
425
|
getBySlug(slug) {
|
|
371
426
|
return this.proxy.slug(slug).get({});
|
|
372
427
|
}
|
|
@@ -383,6 +438,12 @@ var PostController = class {
|
|
|
383
438
|
get proxy() {
|
|
384
439
|
return this.client.proxy(this.base);
|
|
385
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* 获取文章列表分页
|
|
443
|
+
* @param page
|
|
444
|
+
* @param perPage
|
|
445
|
+
* @returns
|
|
446
|
+
*/
|
|
386
447
|
getList(page = 1, perPage = 10, options = {}) {
|
|
387
448
|
const { select, sortBy, sortOrder, year } = options;
|
|
388
449
|
return this.proxy.get({
|
|
@@ -403,9 +464,15 @@ var PostController = class {
|
|
|
403
464
|
return this.proxy(idOrCategoryName)(slug).get();
|
|
404
465
|
}
|
|
405
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* 获取最新的文章
|
|
469
|
+
*/
|
|
406
470
|
getLatest() {
|
|
407
471
|
return this.proxy.latest.get();
|
|
408
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* 点赞
|
|
475
|
+
*/
|
|
409
476
|
thumbsUp(id) {
|
|
410
477
|
return this.proxy("_thumbs-up").get({ params: { id } });
|
|
411
478
|
}
|
|
@@ -443,6 +510,9 @@ var RecentlyController = class {
|
|
|
443
510
|
get proxy() {
|
|
444
511
|
return this.client.proxy(this.base);
|
|
445
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* 获取最新一条
|
|
515
|
+
*/
|
|
446
516
|
getLatestOne() {
|
|
447
517
|
return this.proxy.latest.get();
|
|
448
518
|
}
|
|
@@ -458,6 +528,7 @@ var RecentlyController = class {
|
|
|
458
528
|
}
|
|
459
529
|
});
|
|
460
530
|
}
|
|
531
|
+
/** 表态:点赞,点踩 */
|
|
461
532
|
attitude(id, attitude) {
|
|
462
533
|
return this.proxy.attitude(id).get({
|
|
463
534
|
params: {
|
|
@@ -479,6 +550,9 @@ var SayController = class extends BaseCrudController {
|
|
|
479
550
|
get proxy() {
|
|
480
551
|
return this.client.proxy(this.base);
|
|
481
552
|
}
|
|
553
|
+
/**
|
|
554
|
+
* 获取随机一条
|
|
555
|
+
*/
|
|
482
556
|
getRandom() {
|
|
483
557
|
return this.proxy.random.get();
|
|
484
558
|
}
|
|
@@ -500,6 +574,13 @@ var SearchController = class {
|
|
|
500
574
|
params: { keyword, ...options }
|
|
501
575
|
});
|
|
502
576
|
}
|
|
577
|
+
/**
|
|
578
|
+
* 从 algolya 搜索
|
|
579
|
+
* https://www.algolia.com/doc/api-reference/api-methods/search/
|
|
580
|
+
* @param keyword
|
|
581
|
+
* @param options
|
|
582
|
+
* @returns
|
|
583
|
+
*/
|
|
503
584
|
searchByAlgolia(keyword, options) {
|
|
504
585
|
return this.proxy("algolia").get({ params: { keyword, ...options } });
|
|
505
586
|
}
|
|
@@ -532,6 +613,9 @@ var SnippetController = class {
|
|
|
532
613
|
get proxy() {
|
|
533
614
|
return this.client.proxy(this.base);
|
|
534
615
|
}
|
|
616
|
+
// getById(id: string) {
|
|
617
|
+
// return this.proxy(id).get<Omit<SnippetModel, 'data'>>()
|
|
618
|
+
// }
|
|
535
619
|
getByReferenceAndName(reference, name) {
|
|
536
620
|
return this.proxy(reference)(name).get();
|
|
537
621
|
}
|
|
@@ -548,12 +632,15 @@ var SubscribeController = class {
|
|
|
548
632
|
get proxy() {
|
|
549
633
|
return this.client.proxy(this.base);
|
|
550
634
|
}
|
|
635
|
+
/**
|
|
636
|
+
* 检查开启状态
|
|
637
|
+
*/
|
|
551
638
|
check() {
|
|
552
639
|
return this.proxy.status.get();
|
|
553
640
|
}
|
|
554
641
|
subscribe(email, types) {
|
|
555
642
|
return this.proxy.post({
|
|
556
|
-
|
|
643
|
+
data: {
|
|
557
644
|
email,
|
|
558
645
|
types
|
|
559
646
|
}
|
|
@@ -660,6 +747,7 @@ var allContollerNames = [
|
|
|
660
747
|
"serverless",
|
|
661
748
|
"subscribe",
|
|
662
749
|
"user",
|
|
750
|
+
// alias,
|
|
663
751
|
"friend",
|
|
664
752
|
"master",
|
|
665
753
|
"shorthand"
|
|
@@ -845,6 +933,7 @@ var HTTPClient = class {
|
|
|
845
933
|
route.push(name);
|
|
846
934
|
return new Proxy(noop, handler);
|
|
847
935
|
},
|
|
936
|
+
// @ts-ignore
|
|
848
937
|
apply(target, _, args) {
|
|
849
938
|
route.push(...args.filter((x) => x !== null));
|
|
850
939
|
return new Proxy(noop, handler);
|
package/models/comment.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mx-space/api-client",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A api client for mx-space server@next",
|
|
6
6
|
"author": "Innei",
|
|
@@ -59,19 +59,18 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/cors": "2.8.13",
|
|
62
|
-
"@types/express": "4.17.
|
|
62
|
+
"@types/express": "4.17.17",
|
|
63
63
|
"@types/lodash": "4.14.191",
|
|
64
64
|
"abort-controller": "3.0.0",
|
|
65
65
|
"axios": "^1.3.1",
|
|
66
66
|
"camelcase-keys": "*",
|
|
67
67
|
"cors": "2.8.5",
|
|
68
68
|
"express": "4.18.2",
|
|
69
|
-
"isomorphic-unfetch": "3.1.0",
|
|
70
69
|
"ky": "0.33.2",
|
|
71
70
|
"lodash": "4.17.21",
|
|
72
71
|
"node-fetch": "3.3.0",
|
|
73
72
|
"tsc-alias": "1.8.2",
|
|
74
|
-
"tsup": "6.
|
|
73
|
+
"tsup": "6.6.3",
|
|
75
74
|
"umi-request": "1.4.0"
|
|
76
75
|
}
|
|
77
76
|
}
|