@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/dist/index.cjs CHANGED
@@ -173,9 +173,15 @@ var AggregateController = class {
173
173
  get proxy() {
174
174
  return this.client.proxy(this.base);
175
175
  }
176
+ /**
177
+ * 获取聚合数据
178
+ */
176
179
  getAggregateData() {
177
180
  return this.proxy.get();
178
181
  }
182
+ /**
183
+ * 获取最新发布的内容
184
+ */
179
185
  getTop(size = 5) {
180
186
  return this.proxy.top.get({ params: { size } });
181
187
  }
@@ -189,6 +195,9 @@ var AggregateController = class {
189
195
  }
190
196
  });
191
197
  }
198
+ /**
199
+ * 获取聚合数据统计
200
+ */
192
201
  getStat() {
193
202
  return this.proxy.stat.get();
194
203
  }
@@ -293,20 +302,33 @@ var CommentController = class {
293
302
  get proxy() {
294
303
  return this.client.proxy(this.base);
295
304
  }
305
+ /**
306
+ * 根据 comment id 获取评论, 包括子评论
307
+ */
296
308
  getById(id) {
297
309
  return this.proxy(id).get();
298
310
  }
311
+ /**
312
+ * 获取文章的评论列表
313
+ * @param refId 文章 Id
314
+ */
299
315
  getByRefId(refId, pagination = {}) {
300
316
  const { page, size } = pagination;
301
317
  return this.proxy.ref(refId).get({
302
318
  params: { page: page || 1, size: size || 10 }
303
319
  });
304
320
  }
321
+ /**
322
+ * 评论
323
+ */
305
324
  comment(refId, data) {
306
325
  return this.proxy(refId).post({
307
326
  data
308
327
  });
309
328
  }
329
+ /**
330
+ * 回复评论
331
+ */
310
332
  reply(commentId, data) {
311
333
  return this.proxy.reply(commentId).post({
312
334
  data
@@ -329,6 +351,11 @@ var BaseCrudController = class {
329
351
  getAll() {
330
352
  return this.proxy.all.get();
331
353
  }
354
+ /**
355
+ * 带分页的查询
356
+ * @param page
357
+ * @param perPage
358
+ */
332
359
  getAllPaginated(page, perPage, sortOption) {
333
360
  return this.proxy.get({
334
361
  params: { page, size: perPage, ...sortOption }
@@ -345,10 +372,12 @@ var LinkController = class extends BaseCrudController {
345
372
  this.base = "links";
346
373
  autoBind(this);
347
374
  }
375
+ // 是否可以申请友链
348
376
  async canApplyLink() {
349
377
  const { can } = await this.proxy.audit.get();
350
378
  return can;
351
379
  }
380
+ // 申请友链
352
381
  async applyLink(data) {
353
382
  return await this.proxy.audit.post({ data });
354
383
  }
@@ -365,6 +394,9 @@ var NoteController = class {
365
394
  get proxy() {
366
395
  return this.client.proxy(this.base);
367
396
  }
397
+ /**
398
+ * 最新日记
399
+ */
368
400
  getLatest() {
369
401
  return this.proxy.latest.get();
370
402
  }
@@ -378,6 +410,9 @@ var NoteController = class {
378
410
  return this.proxy(id).get();
379
411
  }
380
412
  }
413
+ /**
414
+ * 日记列表分页
415
+ */
381
416
  getList(page = 1, perPage = 10, options = {}) {
382
417
  const { select, sortBy, sortOrder, year } = options;
383
418
  return this.proxy.get({
@@ -391,14 +426,23 @@ var NoteController = class {
391
426
  }
392
427
  });
393
428
  }
429
+ /**
430
+ * 获取当前日记的上下各 n / 2 篇日记
431
+ */
394
432
  getMiddleList(id, size = 5) {
395
433
  return this.proxy.list(id).get({
396
434
  params: { size }
397
435
  });
398
436
  }
437
+ /**
438
+ * 喜欢这篇日记
439
+ */
399
440
  likeIt(id) {
400
441
  return this.proxy.like(id).get();
401
442
  }
443
+ /**
444
+ * 获取专栏内的所有日记
445
+ */
402
446
  getNoteByTopicId(topicId, page = 1, size = 10, sortOptions = {}) {
403
447
  return this.proxy.topics(topicId).get({
404
448
  params: { page, size, ...sortOptions }
@@ -417,6 +461,9 @@ var PageController = class {
417
461
  get proxy() {
418
462
  return this.client.proxy(this.base);
419
463
  }
464
+ /**
465
+ * 页面列表
466
+ */
420
467
  getList(page = 1, perPage = 10, options = {}) {
421
468
  const { select, sortBy, sortOrder } = options;
422
469
  return this.proxy.get({
@@ -429,9 +476,17 @@ var PageController = class {
429
476
  }
430
477
  });
431
478
  }
479
+ /**
480
+ * 页面详情
481
+ */
432
482
  getById(id) {
433
483
  return this.proxy(id).get();
434
484
  }
485
+ /**
486
+ * 根据路径获取页面
487
+ * @param slug 路径
488
+ * @returns
489
+ */
435
490
  getBySlug(slug) {
436
491
  return this.proxy.slug(slug).get({});
437
492
  }
@@ -448,6 +503,12 @@ var PostController = class {
448
503
  get proxy() {
449
504
  return this.client.proxy(this.base);
450
505
  }
506
+ /**
507
+ * 获取文章列表分页
508
+ * @param page
509
+ * @param perPage
510
+ * @returns
511
+ */
451
512
  getList(page = 1, perPage = 10, options = {}) {
452
513
  const { select, sortBy, sortOrder, year } = options;
453
514
  return this.proxy.get({
@@ -468,9 +529,15 @@ var PostController = class {
468
529
  return this.proxy(idOrCategoryName)(slug).get();
469
530
  }
470
531
  }
532
+ /**
533
+ * 获取最新的文章
534
+ */
471
535
  getLatest() {
472
536
  return this.proxy.latest.get();
473
537
  }
538
+ /**
539
+ * 点赞
540
+ */
474
541
  thumbsUp(id) {
475
542
  return this.proxy("_thumbs-up").get({ params: { id } });
476
543
  }
@@ -508,6 +575,9 @@ var RecentlyController = class {
508
575
  get proxy() {
509
576
  return this.client.proxy(this.base);
510
577
  }
578
+ /**
579
+ * 获取最新一条
580
+ */
511
581
  getLatestOne() {
512
582
  return this.proxy.latest.get();
513
583
  }
@@ -523,6 +593,7 @@ var RecentlyController = class {
523
593
  }
524
594
  });
525
595
  }
596
+ /** 表态:点赞,点踩 */
526
597
  attitude(id, attitude) {
527
598
  return this.proxy.attitude(id).get({
528
599
  params: {
@@ -544,6 +615,9 @@ var SayController = class extends BaseCrudController {
544
615
  get proxy() {
545
616
  return this.client.proxy(this.base);
546
617
  }
618
+ /**
619
+ * 获取随机一条
620
+ */
547
621
  getRandom() {
548
622
  return this.proxy.random.get();
549
623
  }
@@ -565,6 +639,13 @@ var SearchController = class {
565
639
  params: { keyword, ...options }
566
640
  });
567
641
  }
642
+ /**
643
+ * 从 algolya 搜索
644
+ * https://www.algolia.com/doc/api-reference/api-methods/search/
645
+ * @param keyword
646
+ * @param options
647
+ * @returns
648
+ */
568
649
  searchByAlgolia(keyword, options) {
569
650
  return this.proxy("algolia").get({ params: { keyword, ...options } });
570
651
  }
@@ -597,6 +678,9 @@ var SnippetController = class {
597
678
  get proxy() {
598
679
  return this.client.proxy(this.base);
599
680
  }
681
+ // getById(id: string) {
682
+ // return this.proxy(id).get<Omit<SnippetModel, 'data'>>()
683
+ // }
600
684
  getByReferenceAndName(reference, name) {
601
685
  return this.proxy(reference)(name).get();
602
686
  }
@@ -613,12 +697,15 @@ var SubscribeController = class {
613
697
  get proxy() {
614
698
  return this.client.proxy(this.base);
615
699
  }
700
+ /**
701
+ * 检查开启状态
702
+ */
616
703
  check() {
617
704
  return this.proxy.status.get();
618
705
  }
619
706
  subscribe(email, types) {
620
707
  return this.proxy.post({
621
- params: {
708
+ data: {
622
709
  email,
623
710
  types
624
711
  }
@@ -725,6 +812,7 @@ var allContollerNames = [
725
812
  "serverless",
726
813
  "subscribe",
727
814
  "user",
815
+ // alias,
728
816
  "friend",
729
817
  "master",
730
818
  "shorthand"
@@ -910,6 +998,7 @@ var HTTPClient = class {
910
998
  route.push(name);
911
999
  return new Proxy(noop, handler);
912
1000
  },
1001
+ // @ts-ignore
913
1002
  apply(target, _, args) {
914
1003
  route.push(...args.filter((x) => x !== null));
915
1004
  return new Proxy(noop, handler);
package/dist/index.d.ts CHANGED
@@ -566,6 +566,7 @@ interface CommentModel extends BaseModel {
566
566
  parent?: CommentModel | string;
567
567
  children: CommentModel[];
568
568
  isWhispers?: boolean;
569
+ location?: string;
569
570
  }
570
571
  interface CommentRef {
571
572
  id: string;
@@ -110,9 +110,15 @@
110
110
  get proxy() {
111
111
  return this.client.proxy(this.base);
112
112
  }
113
+ /**
114
+ * 获取聚合数据
115
+ */
113
116
  getAggregateData() {
114
117
  return this.proxy.get();
115
118
  }
119
+ /**
120
+ * 获取最新发布的内容
121
+ */
116
122
  getTop(size = 5) {
117
123
  return this.proxy.top.get({ params: { size } });
118
124
  }
@@ -126,6 +132,9 @@
126
132
  }
127
133
  });
128
134
  }
135
+ /**
136
+ * 获取聚合数据统计
137
+ */
129
138
  getStat() {
130
139
  return this.proxy.stat.get();
131
140
  }
@@ -230,20 +239,33 @@
230
239
  get proxy() {
231
240
  return this.client.proxy(this.base);
232
241
  }
242
+ /**
243
+ * 根据 comment id 获取评论, 包括子评论
244
+ */
233
245
  getById(id) {
234
246
  return this.proxy(id).get();
235
247
  }
248
+ /**
249
+ * 获取文章的评论列表
250
+ * @param refId 文章 Id
251
+ */
236
252
  getByRefId(refId, pagination = {}) {
237
253
  const { page, size } = pagination;
238
254
  return this.proxy.ref(refId).get({
239
255
  params: { page: page || 1, size: size || 10 }
240
256
  });
241
257
  }
258
+ /**
259
+ * 评论
260
+ */
242
261
  comment(refId, data) {
243
262
  return this.proxy(refId).post({
244
263
  data
245
264
  });
246
265
  }
266
+ /**
267
+ * 回复评论
268
+ */
247
269
  reply(commentId, data) {
248
270
  return this.proxy.reply(commentId).post({
249
271
  data
@@ -266,6 +288,11 @@
266
288
  getAll() {
267
289
  return this.proxy.all.get();
268
290
  }
291
+ /**
292
+ * 带分页的查询
293
+ * @param page
294
+ * @param perPage
295
+ */
269
296
  getAllPaginated(page, perPage, sortOption) {
270
297
  return this.proxy.get({
271
298
  params: { page, size: perPage, ...sortOption }
@@ -282,10 +309,12 @@
282
309
  this.base = "links";
283
310
  autoBind(this);
284
311
  }
312
+ // 是否可以申请友链
285
313
  async canApplyLink() {
286
314
  const { can } = await this.proxy.audit.get();
287
315
  return can;
288
316
  }
317
+ // 申请友链
289
318
  async applyLink(data) {
290
319
  return await this.proxy.audit.post({ data });
291
320
  }
@@ -302,6 +331,9 @@
302
331
  get proxy() {
303
332
  return this.client.proxy(this.base);
304
333
  }
334
+ /**
335
+ * 最新日记
336
+ */
305
337
  getLatest() {
306
338
  return this.proxy.latest.get();
307
339
  }
@@ -315,6 +347,9 @@
315
347
  return this.proxy(id).get();
316
348
  }
317
349
  }
350
+ /**
351
+ * 日记列表分页
352
+ */
318
353
  getList(page = 1, perPage = 10, options = {}) {
319
354
  const { select, sortBy, sortOrder, year } = options;
320
355
  return this.proxy.get({
@@ -328,14 +363,23 @@
328
363
  }
329
364
  });
330
365
  }
366
+ /**
367
+ * 获取当前日记的上下各 n / 2 篇日记
368
+ */
331
369
  getMiddleList(id, size = 5) {
332
370
  return this.proxy.list(id).get({
333
371
  params: { size }
334
372
  });
335
373
  }
374
+ /**
375
+ * 喜欢这篇日记
376
+ */
336
377
  likeIt(id) {
337
378
  return this.proxy.like(id).get();
338
379
  }
380
+ /**
381
+ * 获取专栏内的所有日记
382
+ */
339
383
  getNoteByTopicId(topicId, page = 1, size = 10, sortOptions = {}) {
340
384
  return this.proxy.topics(topicId).get({
341
385
  params: { page, size, ...sortOptions }
@@ -354,6 +398,9 @@
354
398
  get proxy() {
355
399
  return this.client.proxy(this.base);
356
400
  }
401
+ /**
402
+ * 页面列表
403
+ */
357
404
  getList(page = 1, perPage = 10, options = {}) {
358
405
  const { select, sortBy, sortOrder } = options;
359
406
  return this.proxy.get({
@@ -366,9 +413,17 @@
366
413
  }
367
414
  });
368
415
  }
416
+ /**
417
+ * 页面详情
418
+ */
369
419
  getById(id) {
370
420
  return this.proxy(id).get();
371
421
  }
422
+ /**
423
+ * 根据路径获取页面
424
+ * @param slug 路径
425
+ * @returns
426
+ */
372
427
  getBySlug(slug) {
373
428
  return this.proxy.slug(slug).get({});
374
429
  }
@@ -385,6 +440,12 @@
385
440
  get proxy() {
386
441
  return this.client.proxy(this.base);
387
442
  }
443
+ /**
444
+ * 获取文章列表分页
445
+ * @param page
446
+ * @param perPage
447
+ * @returns
448
+ */
388
449
  getList(page = 1, perPage = 10, options = {}) {
389
450
  const { select, sortBy, sortOrder, year } = options;
390
451
  return this.proxy.get({
@@ -405,9 +466,15 @@
405
466
  return this.proxy(idOrCategoryName)(slug).get();
406
467
  }
407
468
  }
469
+ /**
470
+ * 获取最新的文章
471
+ */
408
472
  getLatest() {
409
473
  return this.proxy.latest.get();
410
474
  }
475
+ /**
476
+ * 点赞
477
+ */
411
478
  thumbsUp(id) {
412
479
  return this.proxy("_thumbs-up").get({ params: { id } });
413
480
  }
@@ -445,6 +512,9 @@
445
512
  get proxy() {
446
513
  return this.client.proxy(this.base);
447
514
  }
515
+ /**
516
+ * 获取最新一条
517
+ */
448
518
  getLatestOne() {
449
519
  return this.proxy.latest.get();
450
520
  }
@@ -460,6 +530,7 @@
460
530
  }
461
531
  });
462
532
  }
533
+ /** 表态:点赞,点踩 */
463
534
  attitude(id, attitude) {
464
535
  return this.proxy.attitude(id).get({
465
536
  params: {
@@ -481,6 +552,9 @@
481
552
  get proxy() {
482
553
  return this.client.proxy(this.base);
483
554
  }
555
+ /**
556
+ * 获取随机一条
557
+ */
484
558
  getRandom() {
485
559
  return this.proxy.random.get();
486
560
  }
@@ -502,6 +576,13 @@
502
576
  params: { keyword, ...options }
503
577
  });
504
578
  }
579
+ /**
580
+ * 从 algolya 搜索
581
+ * https://www.algolia.com/doc/api-reference/api-methods/search/
582
+ * @param keyword
583
+ * @param options
584
+ * @returns
585
+ */
505
586
  searchByAlgolia(keyword, options) {
506
587
  return this.proxy("algolia").get({ params: { keyword, ...options } });
507
588
  }
@@ -534,6 +615,9 @@
534
615
  get proxy() {
535
616
  return this.client.proxy(this.base);
536
617
  }
618
+ // getById(id: string) {
619
+ // return this.proxy(id).get<Omit<SnippetModel, 'data'>>()
620
+ // }
537
621
  getByReferenceAndName(reference, name) {
538
622
  return this.proxy(reference)(name).get();
539
623
  }
@@ -550,12 +634,15 @@
550
634
  get proxy() {
551
635
  return this.client.proxy(this.base);
552
636
  }
637
+ /**
638
+ * 检查开启状态
639
+ */
553
640
  check() {
554
641
  return this.proxy.status.get();
555
642
  }
556
643
  subscribe(email, types) {
557
644
  return this.proxy.post({
558
- params: {
645
+ data: {
559
646
  email,
560
647
  types
561
648
  }
@@ -662,6 +749,7 @@
662
749
  "serverless",
663
750
  "subscribe",
664
751
  "user",
752
+ // alias,
665
753
  "friend",
666
754
  "master",
667
755
  "shorthand"
@@ -847,6 +935,7 @@
847
935
  route.push(name);
848
936
  return new Proxy(noop, handler);
849
937
  },
938
+ // @ts-ignore
850
939
  apply(target, _, args) {
851
940
  route.push(...args.filter((x) => x !== null));
852
941
  return new Proxy(noop, handler);