@mx-space/api-client 0.3.3 → 0.3.7

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.
Files changed (117) hide show
  1. package/build/index.cjs.js +59 -9
  2. package/build/index.cjs.js.map +1 -1
  3. package/build/index.cjs.min.js +1 -1
  4. package/build/index.cjs.min.js.map +1 -1
  5. package/build/index.d.ts +217 -128
  6. package/build/index.esm.js +59 -9
  7. package/build/index.esm.js.map +1 -1
  8. package/build/index.esm.min.js +1 -1
  9. package/build/index.esm.min.js.map +1 -1
  10. package/build/index.umd.js +59 -9
  11. package/build/index.umd.js.map +1 -1
  12. package/build/index.umd.min.js +1 -1
  13. package/build/index.umd.min.js.map +1 -1
  14. package/esm/adaptors/axios.d.ts +3 -0
  15. package/esm/adaptors/axios.js +46 -0
  16. package/esm/adaptors/axios.js.map +1 -0
  17. package/esm/adaptors/umi-request.d.ts +3 -0
  18. package/esm/adaptors/umi-request.js +27 -0
  19. package/esm/adaptors/umi-request.js.map +1 -0
  20. package/esm/core/client.d.ts +1 -1
  21. package/esm/core/controllers/aggregate.d.ts +5 -7
  22. package/esm/core/controllers/aggregate.js +2 -0
  23. package/esm/core/controllers/aggregate.js.map +1 -1
  24. package/esm/core/controllers/base.d.ts +5 -7
  25. package/esm/core/controllers/base.js +2 -0
  26. package/esm/core/controllers/base.js.map +1 -1
  27. package/esm/core/controllers/category.d.ts +6 -16
  28. package/esm/core/controllers/category.js +4 -2
  29. package/esm/core/controllers/category.js.map +1 -1
  30. package/esm/core/controllers/comment.d.ts +6 -8
  31. package/esm/core/controllers/comment.js +2 -0
  32. package/esm/core/controllers/comment.js.map +1 -1
  33. package/esm/core/controllers/link.js +2 -0
  34. package/esm/core/controllers/link.js.map +1 -1
  35. package/esm/core/controllers/note.d.ts +8 -10
  36. package/esm/core/controllers/note.js +2 -0
  37. package/esm/core/controllers/note.js.map +1 -1
  38. package/esm/core/controllers/page.js +2 -0
  39. package/esm/core/controllers/page.js.map +1 -1
  40. package/esm/core/controllers/post.js +2 -0
  41. package/esm/core/controllers/post.js.map +1 -1
  42. package/esm/core/controllers/project.js +2 -0
  43. package/esm/core/controllers/project.js.map +1 -1
  44. package/esm/core/controllers/recently.js +2 -0
  45. package/esm/core/controllers/recently.js.map +1 -1
  46. package/esm/core/controllers/say.js +2 -0
  47. package/esm/core/controllers/say.js.map +1 -1
  48. package/esm/core/controllers/search.d.ts +6 -6
  49. package/esm/core/controllers/search.js +2 -0
  50. package/esm/core/controllers/search.js.map +1 -1
  51. package/esm/core/controllers/snippet.js +2 -0
  52. package/esm/core/controllers/snippet.js.map +1 -1
  53. package/esm/core/controllers/user.js +2 -0
  54. package/esm/core/controllers/user.js.map +1 -1
  55. package/esm/interfaces/instance.d.ts +11 -6
  56. package/esm/models/aggregate.d.ts +2 -1
  57. package/esm/models/aggregate.js.map +1 -1
  58. package/esm/models/post.d.ts +1 -9
  59. package/esm/utils/auto-bind.d.ts +4 -0
  60. package/esm/utils/auto-bind.js +36 -0
  61. package/esm/utils/auto-bind.js.map +1 -0
  62. package/lib/adaptors/axios.d.ts +3 -0
  63. package/lib/adaptors/axios.js +52 -0
  64. package/lib/adaptors/axios.js.map +1 -0
  65. package/lib/adaptors/umi-request.d.ts +3 -0
  66. package/lib/adaptors/umi-request.js +30 -0
  67. package/lib/adaptors/umi-request.js.map +1 -0
  68. package/lib/core/client.d.ts +1 -1
  69. package/lib/core/controllers/aggregate.d.ts +5 -7
  70. package/lib/core/controllers/aggregate.js +2 -0
  71. package/lib/core/controllers/aggregate.js.map +1 -1
  72. package/lib/core/controllers/base.d.ts +5 -7
  73. package/lib/core/controllers/base.js +2 -0
  74. package/lib/core/controllers/base.js.map +1 -1
  75. package/lib/core/controllers/category.d.ts +6 -16
  76. package/lib/core/controllers/category.js +5 -3
  77. package/lib/core/controllers/category.js.map +1 -1
  78. package/lib/core/controllers/comment.d.ts +6 -8
  79. package/lib/core/controllers/comment.js +2 -0
  80. package/lib/core/controllers/comment.js.map +1 -1
  81. package/lib/core/controllers/link.js +2 -0
  82. package/lib/core/controllers/link.js.map +1 -1
  83. package/lib/core/controllers/note.d.ts +8 -10
  84. package/lib/core/controllers/note.js +2 -0
  85. package/lib/core/controllers/note.js.map +1 -1
  86. package/lib/core/controllers/page.js +2 -0
  87. package/lib/core/controllers/page.js.map +1 -1
  88. package/lib/core/controllers/post.js +2 -0
  89. package/lib/core/controllers/post.js.map +1 -1
  90. package/lib/core/controllers/project.js +2 -0
  91. package/lib/core/controllers/project.js.map +1 -1
  92. package/lib/core/controllers/recently.js +2 -0
  93. package/lib/core/controllers/recently.js.map +1 -1
  94. package/lib/core/controllers/say.js +2 -0
  95. package/lib/core/controllers/say.js.map +1 -1
  96. package/lib/core/controllers/search.d.ts +6 -6
  97. package/lib/core/controllers/search.js +2 -0
  98. package/lib/core/controllers/search.js.map +1 -1
  99. package/lib/core/controllers/snippet.js +2 -0
  100. package/lib/core/controllers/snippet.js.map +1 -1
  101. package/lib/core/controllers/user.js +2 -0
  102. package/lib/core/controllers/user.js.map +1 -1
  103. package/lib/interfaces/instance.d.ts +11 -6
  104. package/lib/models/aggregate.d.ts +2 -1
  105. package/lib/models/aggregate.js.map +1 -1
  106. package/lib/models/post.d.ts +1 -9
  107. package/lib/utils/auto-bind.d.ts +4 -0
  108. package/lib/utils/auto-bind.js +40 -0
  109. package/lib/utils/auto-bind.js.map +1 -0
  110. package/package.json +21 -17
  111. package/readme.md +77 -57
  112. package/esm/types/helper.d.ts +0 -2
  113. package/esm/types/helper.js +0 -2
  114. package/esm/types/helper.js.map +0 -1
  115. package/lib/types/helper.d.ts +0 -2
  116. package/lib/types/helper.js +0 -3
  117. package/lib/types/helper.js.map +0 -1
package/build/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- // Generated by dts-bundle-generator v5.9.0
1
+ // Generated by dts-bundle-generator v6.2.0
2
2
 
3
- export declare type Class<T> = new (...args: any[]) => T;
4
- export declare type SelectFields<T extends string> = `${"+" | "-" | ""}${T}`[];
3
+ export type Class<T> = new (...args: any[]) => T;
4
+ export type SelectFields<T extends string> = `${"+" | "-" | ""}${T}`[];
5
5
  export interface IController {
6
6
  base: string;
7
7
  name: string;
@@ -16,12 +16,16 @@ export interface RequestOptions {
16
16
  headers?: Record<string, string>;
17
17
  [key: string]: any;
18
18
  }
19
- export interface IRequestAdapter {
20
- get<P = unknown>(url: string, options?: RequestOptions): Promise<P>;
21
- post<P = unknown>(url: string, options?: RequestOptions): Promise<P>;
22
- patch<P = unknown>(url: string, options?: RequestOptions): Promise<P>;
23
- delete<P = unknown>(url: string, options?: RequestOptions): Promise<P>;
24
- put<P = unknown>(url: string, options?: RequestOptions): Promise<P>;
19
+ export declare type RequestResponseType<P> = Promise<Record<string, any> & {
20
+ data: P;
21
+ }>;
22
+ export interface IRequestAdapter<T = any> {
23
+ default: T;
24
+ get<P = unknown>(url: string, options?: RequestOptions): RequestResponseType<P>;
25
+ post<P = unknown>(url: string, options?: RequestOptions): RequestResponseType<P>;
26
+ patch<P = unknown>(url: string, options?: RequestOptions): RequestResponseType<P>;
27
+ delete<P = unknown>(url: string, options?: RequestOptions): RequestResponseType<P>;
28
+ put<P = unknown>(url: string, options?: RequestOptions): RequestResponseType<P>;
25
29
  }
26
30
  export declare type NoStringIndex<T> = {
27
31
  [K in keyof T as string extends K ? never : K]: T[K];
@@ -48,6 +52,70 @@ export declare type ResponseProxyExtraRaw<T, R = any> = T & {
48
52
  };
49
53
  };
50
54
  export declare type SortOrder = "asc" | "desc";
55
+ export interface Count {
56
+ read: number;
57
+ like: number;
58
+ }
59
+ export interface Image {
60
+ height: number;
61
+ width: number;
62
+ type: string;
63
+ accent?: string;
64
+ src: string;
65
+ }
66
+ export interface Pager {
67
+ total: number;
68
+ size: number;
69
+ currentPage: number;
70
+ totalPage: number;
71
+ hasPrevPage: boolean;
72
+ hasNextPage: boolean;
73
+ }
74
+ export interface PaginateResult<T> {
75
+ data: T[];
76
+ pagination: Pager;
77
+ }
78
+ declare class BaseModel {
79
+ created?: Date;
80
+ id?: string;
81
+ }
82
+ export interface PostModel {
83
+ commentsIndex: number;
84
+ allowComment: boolean;
85
+ hide: boolean;
86
+ copyright: boolean;
87
+ tags: string[];
88
+ count: Count;
89
+ id: string;
90
+ text: string;
91
+ title: string;
92
+ slug: string;
93
+ categoryId: string;
94
+ images: Image[];
95
+ modified: string;
96
+ created: string;
97
+ category: CategoryModel;
98
+ }
99
+ declare enum CategoryType {
100
+ Category = 0,
101
+ Tag = 1
102
+ }
103
+ export interface CategoryModel {
104
+ type: CategoryType;
105
+ count: number;
106
+ id: string;
107
+ created: string;
108
+ slug: string;
109
+ name: string;
110
+ modified: string;
111
+ }
112
+ export declare type CategoryWithChildrenModel = CategoryModel & {
113
+ children: Pick<PostModel, "id" | "title" | "slug" | "modified" | "created">[];
114
+ };
115
+ export interface TagModel {
116
+ count: number;
117
+ name: string;
118
+ }
51
119
  export interface NoteModel {
52
120
  id: string;
53
121
  hide: boolean;
@@ -106,59 +174,6 @@ export interface PageModel {
106
174
  /** Other Options */
107
175
  options?: object;
108
176
  }
109
- export interface Count {
110
- read: number;
111
- like: number;
112
- }
113
- export interface Image {
114
- height: number;
115
- width: number;
116
- type: string;
117
- accent?: string;
118
- src: string;
119
- }
120
- export interface Pager {
121
- total: number;
122
- size: number;
123
- currentPage: number;
124
- totalPage: number;
125
- hasPrevPage: boolean;
126
- hasNextPage: boolean;
127
- }
128
- export interface PaginateResult<T> {
129
- data: T[];
130
- pagination: Pager;
131
- }
132
- declare class BaseModel {
133
- created?: Date;
134
- id?: string;
135
- }
136
- export interface PostModel {
137
- commentsIndex: number;
138
- allowComment: boolean;
139
- hide: boolean;
140
- copyright: boolean;
141
- tags: string[];
142
- count: Count;
143
- id: string;
144
- text: string;
145
- title: string;
146
- slug: string;
147
- categoryId: string;
148
- images: Image[];
149
- modified: string;
150
- created: string;
151
- category: CategoryModel;
152
- }
153
- export interface CategoryModel {
154
- type: number;
155
- count: number;
156
- id: string;
157
- name: string;
158
- slug: string;
159
- created: Date;
160
- categoryId: string;
161
- }
162
177
  export interface SayModel {
163
178
  id?: string;
164
179
  text: string;
@@ -249,40 +264,33 @@ export declare class AggregateController implements IController {
249
264
  /**
250
265
  * 获取聚合数据
251
266
  */
252
- getAggregateData(): RequestProxyResult;
267
+ getAggregateData(): RequestProxyResult<AggregateRoot>;
253
268
  /**
254
269
  * 获取最新发布的内容
255
270
  */
256
- getTop(size?: number): RequestProxyResult;
271
+ getTop(size?: number): RequestProxyResult<AggregateTop, {
272
+ [key: string]: any;
273
+ data: AggregateTop;
274
+ }>;
257
275
  getTimeline(options?: {
258
276
  sort?: SortOrder;
259
277
  type?: TimelineType;
260
278
  year?: number;
261
- }): RequestProxyResult;
279
+ }): RequestProxyResult<{
280
+ data: TimelineData;
281
+ }, {
282
+ [key: string]: any;
283
+ data: {
284
+ data: TimelineData;
285
+ };
286
+ }>;
262
287
  /**
263
288
  * 获取聚合数据统计
264
289
  */
265
- getStat(): RequestProxyResult;
266
- }
267
- declare enum CategoryType {
268
- Category = 0,
269
- Tag = 1
270
- }
271
- export interface CategoryModel {
272
- type: CategoryType;
273
- count: number;
274
- id: string;
275
- created: string;
276
- slug: string;
277
- name: string;
278
- modified: string;
279
- }
280
- export declare type CategoryWithChildrenModel = CategoryModel & {
281
- children: Pick<PostModel, "id" | "title" | "slug" | "modified" | "created">[];
282
- };
283
- export interface TagModel {
284
- count: number;
285
- name: string;
290
+ getStat(): RequestProxyResult<AggregateStat, {
291
+ [key: string]: any;
292
+ data: AggregateStat;
293
+ }>;
286
294
  }
287
295
  export declare class CategoryController implements IController {
288
296
  private client;
@@ -290,21 +298,11 @@ export declare class CategoryController implements IController {
290
298
  base: string;
291
299
  constructor(client: HTTPClient);
292
300
  private get proxy();
293
- getAllCategories(): import("~/interfaces/request").RequestProxyResult<{
301
+ getAllCategories(): RequestProxyResult<{
294
302
  data: CategoryModel[];
295
- }, {
296
- [key: string]: any;
297
- data: {
298
- data: CategoryModel[];
299
- };
300
303
  }>;
301
- getAllTags(): import("~/interfaces/request").RequestProxyResult<{
304
+ getAllTags(): RequestProxyResult<{
302
305
  data: TagModel[];
303
- }, {
304
- [key: string]: any;
305
- data: {
306
- data: TagModel[];
307
- };
308
306
  }>;
309
307
  getCategoryDetail(id: string): Promise<ResponseProxyExtraRaw<CategoryWithChildrenModel>>;
310
308
  getCategoryDetail(ids: string[]): Promise<ResponseProxyExtraRaw<Map<string, CategoryWithChildrenModel>>>;
@@ -360,20 +358,29 @@ export declare class CommentController implements IController {
360
358
  /**
361
359
  * 根据 comment id 获取评论, 包括子评论
362
360
  */
363
- getById(id: string): RequestProxyResult;
361
+ getById(id: string): RequestProxyResult<CommentModel>;
364
362
  /**
365
363
  * 获取文章的评论列表
366
364
  * @param refId 文章 Id
367
365
  */
368
- getByRefId(refId: string, pagination?: PaginationParams): RequestProxyResult;
366
+ getByRefId(refId: string, pagination?: PaginationParams): RequestProxyResult<PaginateResult<CommentModel>, {
367
+ [key: string]: any;
368
+ data: PaginateResult<CommentModel>;
369
+ }>;
369
370
  /**
370
371
  * 评论
371
372
  */
372
- comment(refId: string, data: CommentDto): RequestProxyResult;
373
+ comment(refId: string, data: CommentDto): RequestProxyResult<CommentModel, {
374
+ [key: string]: any;
375
+ data: CommentModel;
376
+ }>;
373
377
  /**
374
378
  * 回复评论
375
379
  */
376
- reply(commentId: string, data: CommentDto): RequestProxyResult;
380
+ reply(commentId: string, data: CommentDto): RequestProxyResult<CommentModel, {
381
+ [key: string]: any;
382
+ data: CommentModel;
383
+ }>;
377
384
  }
378
385
  declare enum LinkType {
379
386
  Friend = 0,
@@ -397,14 +404,24 @@ declare abstract class BaseCrudController<T> {
397
404
  base: string;
398
405
  constructor(client: HTTPClient);
399
406
  protected get proxy(): IRequestHandler;
400
- getById(id: string): RequestProxyResult;
401
- getAll(): RequestProxyResult;
407
+ getById(id: string): RequestProxyResult<T>;
408
+ getAll(): RequestProxyResult<{
409
+ data: T[];
410
+ }, {
411
+ [key: string]: any;
412
+ data: {
413
+ data: T[];
414
+ };
415
+ }>;
402
416
  /**
403
417
  * 带分页的查询
404
418
  * @param page
405
419
  * @param perPage
406
420
  */
407
- getAllPaginated(page?: number, perPage?: number): RequestProxyResult;
421
+ getAllPaginated(page?: number, perPage?: number): RequestProxyResult<PaginateResult<T>, {
422
+ [key: string]: any;
423
+ data: PaginateResult<T>;
424
+ }>;
408
425
  }
409
426
  export declare class LinkController extends BaseCrudController<LinkModel> {
410
427
  protected readonly client: HTTPClient;
@@ -427,25 +444,43 @@ export declare class NoteController implements IController {
427
444
  /**
428
445
  * 最新日记
429
446
  */
430
- getLatest(): RequestProxyResult;
447
+ getLatest(): RequestProxyResult<NoteWrappedPayload>;
431
448
  /**
432
449
  * 获取一篇日记
433
450
  * @param id id | nid
434
451
  * @param password 访问密码
435
452
  */
436
- getNoteById(id: string | number, password?: string): RequestProxyResult;
453
+ getNoteById(id: string | number, password?: string): RequestProxyResult<NoteWrappedPayload, {
454
+ [key: string]: any;
455
+ data: NoteWrappedPayload;
456
+ }>;
437
457
  /**
438
458
  * 日记列表分页
439
459
  */
440
- getList(page?: number, perPage?: number, options?: NoteListOptions): RequestProxyResult;
460
+ getList(page?: number, perPage?: number, options?: NoteListOptions): RequestProxyResult<PaginateResult<NoteModel>, {
461
+ [key: string]: any;
462
+ data: PaginateResult<NoteModel>;
463
+ }>;
441
464
  /**
442
465
  * 获取当前日记的上下各 n / 2 篇日记
443
466
  */
444
- getMiddleList(id: string, size?: number): RequestProxyResult;
467
+ getMiddleList(id: string, size?: number): RequestProxyResult<{
468
+ data: Pick<NoteModel, "id" | "title" | "nid" | "created">[];
469
+ size: number;
470
+ }, {
471
+ [key: string]: any;
472
+ data: {
473
+ data: Pick<NoteModel, "id" | "title" | "nid" | "created">[];
474
+ size: number;
475
+ };
476
+ }>;
445
477
  /**
446
478
  * 喜欢这篇日记
447
479
  */
448
- likeIt(id: string): RequestProxyResult;
480
+ likeIt(id: string): RequestProxyResult<never, {
481
+ [key: string]: any;
482
+ data: never;
483
+ }>;
449
484
  }
450
485
  export declare type PageListOptions = {
451
486
  select?: SelectFields<keyof PageModel>;
@@ -461,17 +496,26 @@ export declare class PageController implements IController {
461
496
  /**
462
497
  * 页面列表
463
498
  */
464
- getList(page?: number, perPage?: number, options?: PageListOptions): RequestProxyResult;
499
+ getList(page?: number, perPage?: number, options?: PageListOptions): RequestProxyResult<PaginateResult<PageModel>, {
500
+ [key: string]: any;
501
+ data: PaginateResult<PageModel>;
502
+ }>;
465
503
  /**
466
504
  * 页面详情
467
505
  */
468
- getById(id: string): RequestProxyResult;
506
+ getById(id: string): RequestProxyResult<PageModel, {
507
+ [key: string]: any;
508
+ data: PageModel;
509
+ }>;
469
510
  /**
470
511
  * 根据路径获取页面
471
512
  * @param slug 路径
472
513
  * @returns
473
514
  */
474
- getBySlug(slug: string): RequestProxyResult;
515
+ getBySlug(slug: string): RequestProxyResult<PageModel, {
516
+ [key: string]: any;
517
+ data: PageModel;
518
+ }>;
475
519
  }
476
520
  export declare type PostListOptions = {
477
521
  select?: SelectFields<keyof PostModel>;
@@ -552,9 +596,26 @@ export declare class RecentlyController implements IController {
552
596
  /**
553
597
  * 获取最新一条
554
598
  */
555
- getLatestOne(): RequestProxyResult;
556
- getAll(): RequestProxyResult;
557
- getList(before?: string | undefined, after?: string | undefined, size?: number | number): RequestProxyResult;
599
+ getLatestOne(): RequestProxyResult<RecentlyModel, {
600
+ [key: string]: any;
601
+ data: RecentlyModel;
602
+ }>;
603
+ getAll(): RequestProxyResult<{
604
+ data: RecentlyModel[];
605
+ }, {
606
+ [key: string]: any;
607
+ data: {
608
+ data: RecentlyModel[];
609
+ };
610
+ }>;
611
+ getList(before?: string | undefined, after?: string | undefined, size?: number | number): RequestProxyResult<{
612
+ data: RecentlyModel[];
613
+ }, {
614
+ [key: string]: any;
615
+ data: {
616
+ data: RecentlyModel[];
617
+ };
618
+ }>;
558
619
  }
559
620
  export declare class SayController extends BaseCrudController<SayModel> implements IController {
560
621
  protected client: HTTPClient;
@@ -565,7 +626,14 @@ export declare class SayController extends BaseCrudController<SayModel> implemen
565
626
  /**
566
627
  * 获取随机一条
567
628
  */
568
- getRandom(): RequestProxyResult;
629
+ getRandom(): RequestProxyResult<{
630
+ data: SayModel | null;
631
+ }, {
632
+ [key: string]: any;
633
+ data: {
634
+ data: SayModel | null;
635
+ };
636
+ }>;
569
637
  }
570
638
  export declare type SearchOption = {
571
639
  orderBy?: string;
@@ -577,7 +645,7 @@ export declare class SearchController implements IController {
577
645
  base: string;
578
646
  name: string;
579
647
  constructor(client: HTTPClient);
580
- get proxy(): import("~/interfaces/request").IRequestHandler;
648
+ get proxy(): IRequestHandler;
581
649
  search(type: "note", keyword: string, options?: Omit<SearchOption, "rawAlgolia">): Promise<RequestProxyResult<PaginateResult<Pick<NoteModel, "modified" | "id" | "title" | "created" | "nid">>>>;
582
650
  search(type: "post", keyword: string, options?: Omit<SearchOption, "rawAlgolia">): Promise<RequestProxyResult<PaginateResult<Pick<PostModel, "modified" | "id" | "title" | "created" | "slug" | "category">>>>;
583
651
  /**
@@ -587,14 +655,14 @@ export declare class SearchController implements IController {
587
655
  * @param options
588
656
  * @returns
589
657
  */
590
- searchByAlgolia(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<Pick<PostModel, "created" | "id" | "modified" | "title" | "slug" | "category">> & {
658
+ searchByAlgolia(keyword: string, options?: SearchOption): RequestProxyResult<RequestProxyResult<PaginateResult<Pick<PostModel, "id" | "title" | "slug" | "modified" | "created" | "category">> & {
591
659
  /**
592
660
  * @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
593
661
  */
594
662
  raw?: any;
595
663
  }, {
596
664
  [key: string]: any;
597
- data: PaginateResult<Pick<PostModel, "created" | "id" | "modified" | "title" | "slug" | "category">> & {
665
+ data: PaginateResult<Pick<PostModel, "id" | "title" | "slug" | "modified" | "created" | "category">> & {
598
666
  /**
599
667
  * @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
600
668
  */
@@ -602,14 +670,14 @@ export declare class SearchController implements IController {
602
670
  };
603
671
  }>, {
604
672
  [key: string]: any;
605
- data: RequestProxyResult<PaginateResult<Pick<PostModel, "created" | "id" | "modified" | "title" | "slug" | "category">> & {
673
+ data: RequestProxyResult<PaginateResult<Pick<PostModel, "id" | "title" | "slug" | "modified" | "created" | "category">> & {
606
674
  /**
607
675
  * @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
608
676
  */
609
677
  raw?: any;
610
678
  }, {
611
679
  [key: string]: any;
612
- data: PaginateResult<Pick<PostModel, "created" | "id" | "modified" | "title" | "slug" | "category">> & {
680
+ data: PaginateResult<Pick<PostModel, "id" | "title" | "slug" | "modified" | "created" | "category">> & {
613
681
  /**
614
682
  * @see: algoliasearch <https://www.algolia.com/doc/api-reference/api-methods/search/>
615
683
  */
@@ -637,8 +705,14 @@ export declare class SnippetController implements IController {
637
705
  name: string;
638
706
  constructor(client: HTTPClient);
639
707
  get proxy(): IRequestHandler;
640
- getById(id: string): RequestProxyResult;
641
- getByReferenceAndName(reference: string, name: string): RequestProxyResult;
708
+ getById(id: string): RequestProxyResult<SnippetModel, {
709
+ [key: string]: any;
710
+ data: SnippetModel;
711
+ }>;
712
+ getByReferenceAndName(reference: string, name: string): RequestProxyResult<SnippetModel, {
713
+ [key: string]: any;
714
+ data: SnippetModel;
715
+ }>;
642
716
  }
643
717
  export declare class UserController implements IController {
644
718
  private readonly client;
@@ -646,9 +720,24 @@ export declare class UserController implements IController {
646
720
  base: string;
647
721
  name: string;
648
722
  protected get proxy(): IRequestHandler;
649
- getMasterInfo(): RequestProxyResult;
650
- login(username: string, password: string): RequestProxyResult;
651
- checkTokenValid(token: string): RequestProxyResult;
723
+ getMasterInfo(): RequestProxyResult<UserModel, {
724
+ [key: string]: any;
725
+ data: UserModel;
726
+ }>;
727
+ login(username: string, password: string): RequestProxyResult<TLogin, {
728
+ [key: string]: any;
729
+ data: TLogin;
730
+ }>;
731
+ checkTokenValid(token: string): RequestProxyResult<{
732
+ ok: number;
733
+ isGuest: boolean;
734
+ }, {
735
+ [key: string]: any;
736
+ data: {
737
+ ok: number;
738
+ isGuest: boolean;
739
+ };
740
+ }>;
652
741
  }
653
742
  export 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 SnippetController | typeof UserController)[];
654
743
  export declare const allContollerNames: string[];
@@ -679,7 +768,7 @@ export declare class HTTPClient extends HTTPControllerDefine {
679
768
  injectControllers(...Controller: Class<IController>[]): void;
680
769
  injectControllers(Controller: Class<IController>[]): void;
681
770
  get endpoint(): string;
682
- get instance(): IRequestAdapter;
771
+ get instance(): IRequestAdapter<any>;
683
772
  request(options: {
684
773
  url: string;
685
774
  method?: string;
@@ -433,11 +433,48 @@ function handleSearchParams(obj) {
433
433
  return search.toString();
434
434
  }
435
435
 
436
+ // @ts-nocheck
437
+ // @copy: https://github.com/sindresorhus/auto-bind/blob/main/index.js
438
+ // Gets all non-builtin properties up the prototype chain.
439
+ const getAllProperties = (object) => {
440
+ const properties = new Set();
441
+ do {
442
+ for (const key of Reflect.ownKeys(object)) {
443
+ properties.add([object, key]);
444
+ }
445
+ } while ((object = Reflect.getPrototypeOf(object)) &&
446
+ object !== Object.prototype);
447
+ return properties;
448
+ };
449
+ function autoBind(self, { include, exclude } = {}) {
450
+ const filter = (key) => {
451
+ const match = (pattern) => typeof pattern === 'string' ? key === pattern : pattern.test(key);
452
+ if (include) {
453
+ return include.some(match);
454
+ }
455
+ if (exclude) {
456
+ return !exclude.some(match);
457
+ }
458
+ return true;
459
+ };
460
+ for (const [object, key] of getAllProperties(self.constructor.prototype)) {
461
+ if (key === 'constructor' || !filter(key)) {
462
+ continue;
463
+ }
464
+ const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
465
+ if (descriptor && typeof descriptor.value === 'function') {
466
+ self[key] = self[key].bind(self);
467
+ }
468
+ }
469
+ return self;
470
+ }
471
+
436
472
  class AggregateController {
437
473
  constructor(client) {
438
474
  this.client = client;
439
475
  this.base = 'aggregate';
440
476
  this.name = 'aggregate';
477
+ autoBind(this);
441
478
  }
442
479
  get proxy() {
443
480
  return this.client.proxy(this.base);
@@ -478,11 +515,21 @@ var CategoryType;
478
515
  CategoryType[CategoryType["Tag"] = 1] = "Tag";
479
516
  })(CategoryType || (CategoryType = {}));
480
517
 
518
+ class RequestError extends Error {
519
+ constructor(message, status, path, raw) {
520
+ super(message);
521
+ this.status = status;
522
+ this.path = path;
523
+ this.raw = raw;
524
+ }
525
+ }
526
+
481
527
  class CategoryController {
482
528
  constructor(client) {
483
529
  this.client = client;
484
530
  this.name = 'category';
485
531
  this.base = 'categories';
532
+ autoBind(this);
486
533
  }
487
534
  get proxy() {
488
535
  return this.client.proxy(this.base);
@@ -546,6 +593,7 @@ class CommentController {
546
593
  this.client = client;
547
594
  this.base = 'comments';
548
595
  this.name = 'comment';
596
+ autoBind(this);
549
597
  }
550
598
  get proxy() {
551
599
  return this.client.proxy(this.base);
@@ -587,6 +635,7 @@ class CommentController {
587
635
  class BaseCrudController {
588
636
  constructor(client) {
589
637
  this.client = client;
638
+ autoBind(this);
590
639
  }
591
640
  get proxy() {
592
641
  return this.client.proxy(this.base);
@@ -615,6 +664,7 @@ class LinkController extends BaseCrudController {
615
664
  this.client = client;
616
665
  this.name = 'link';
617
666
  this.base = 'links';
667
+ autoBind(this);
618
668
  }
619
669
  }
620
670
 
@@ -623,6 +673,7 @@ class NoteController {
623
673
  this.client = client;
624
674
  this.base = 'notes';
625
675
  this.name = 'note';
676
+ autoBind(this);
626
677
  }
627
678
  get proxy() {
628
679
  return this.client.proxy(this.base);
@@ -685,6 +736,7 @@ class PageController {
685
736
  this.client = client;
686
737
  this.base = 'pages';
687
738
  this.name = 'page';
739
+ autoBind(this);
688
740
  }
689
741
  get proxy() {
690
742
  return this.client.proxy(this.base);
@@ -725,6 +777,7 @@ class PostController {
725
777
  this.client = client;
726
778
  this.base = 'posts';
727
779
  this.name = 'post';
780
+ autoBind(this);
728
781
  }
729
782
  get proxy() {
730
783
  return this.client.proxy(this.base);
@@ -776,6 +829,7 @@ class ProjectController extends BaseCrudController {
776
829
  this.client = client;
777
830
  this.base = 'projects';
778
831
  this.name = 'project';
832
+ autoBind(this);
779
833
  }
780
834
  }
781
835
 
@@ -784,6 +838,7 @@ class RecentlyController {
784
838
  this.client = client;
785
839
  this.base = 'recently';
786
840
  this.name = 'recently';
841
+ autoBind(this);
787
842
  }
788
843
  get proxy() {
789
844
  return this.client.proxy(this.base);
@@ -817,6 +872,7 @@ class SayController extends BaseCrudController {
817
872
  this.client = client;
818
873
  this.base = 'says';
819
874
  this.name = 'say';
875
+ autoBind(this);
820
876
  }
821
877
  get proxy() {
822
878
  return this.client.proxy(this.base);
@@ -834,6 +890,7 @@ class SearchController {
834
890
  this.client = client;
835
891
  this.base = 'search';
836
892
  this.name = 'search';
893
+ autoBind(this);
837
894
  }
838
895
  get proxy() {
839
896
  return this.client.proxy(this.base);
@@ -860,6 +917,7 @@ class SnippetController {
860
917
  this.client = client;
861
918
  this.base = 'snippets';
862
919
  this.name = 'snippet';
920
+ autoBind(this);
863
921
  }
864
922
  get proxy() {
865
923
  return this.client.proxy(this.base);
@@ -877,6 +935,7 @@ class UserController {
877
935
  this.client = client;
878
936
  this.base = 'master';
879
937
  this.name = 'user';
938
+ autoBind(this);
880
939
  }
881
940
  get proxy() {
882
941
  return this.client.proxy(this.base);
@@ -944,15 +1003,6 @@ class HTTPControllerDefine {
944
1003
  }
945
1004
  }
946
1005
 
947
- class RequestError extends Error {
948
- constructor(message, status, path, raw) {
949
- super(message);
950
- this.status = status;
951
- this.path = path;
952
- this.raw = raw;
953
- }
954
- }
955
-
956
1006
  class HTTPClient extends HTTPControllerDefine {
957
1007
  // define all clients
958
1008
  constructor(_endpoint, _instance) {