@mx-space/api-client 0.0.5 → 0.3.1

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 (170) hide show
  1. package/build/index.cjs.js +411 -53
  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 +463 -108
  6. package/build/index.esm.js +411 -53
  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 +411 -53
  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/core/attachRequest.js +4 -0
  15. package/esm/core/attachRequest.js.map +1 -1
  16. package/esm/core/client.d.ts +2 -9
  17. package/esm/core/client.js +16 -2
  18. package/esm/core/client.js.map +1 -1
  19. package/esm/core/controllers/aggregate.d.ts +44 -0
  20. package/esm/core/controllers/aggregate.js +40 -0
  21. package/esm/core/controllers/aggregate.js.map +1 -0
  22. package/esm/core/controllers/all.d.ts +13 -2
  23. package/esm/core/controllers/all.js +38 -9
  24. package/esm/core/controllers/all.js.map +1 -1
  25. package/esm/core/controllers/base.d.ts +29 -0
  26. package/esm/core/controllers/base.js +25 -0
  27. package/esm/core/controllers/base.js.map +1 -0
  28. package/esm/core/controllers/category.d.ts +44 -0
  29. package/esm/core/controllers/category.js +66 -0
  30. package/esm/core/controllers/category.js.map +1 -0
  31. package/esm/core/controllers/index.d.ts +0 -2
  32. package/esm/core/controllers/index.js +0 -3
  33. package/esm/core/controllers/index.js.map +1 -1
  34. package/esm/core/controllers/link.d.ts +9 -0
  35. package/esm/core/controllers/link.js +10 -0
  36. package/esm/core/controllers/link.js.map +1 -0
  37. package/esm/core/controllers/project.d.ts +9 -0
  38. package/esm/core/controllers/project.js +10 -0
  39. package/esm/core/controllers/project.js.map +1 -0
  40. package/esm/core/controllers/recently.d.ts +33 -0
  41. package/esm/core/controllers/recently.js +32 -0
  42. package/esm/core/controllers/recently.js.map +1 -0
  43. package/esm/core/controllers/say.d.ts +22 -0
  44. package/esm/core/controllers/say.js +19 -0
  45. package/esm/core/controllers/say.js.map +1 -0
  46. package/esm/core/controllers/search.d.ts +58 -0
  47. package/esm/core/controllers/search.js +26 -0
  48. package/esm/core/controllers/search.js.map +1 -0
  49. package/esm/core/controllers/snippet.d.ts +18 -0
  50. package/esm/core/controllers/snippet.js +17 -0
  51. package/esm/core/controllers/snippet.js.map +1 -0
  52. package/esm/core/controllers/user.d.ts +28 -0
  53. package/esm/core/controllers/user.js +29 -0
  54. package/esm/core/controllers/user.js.map +1 -0
  55. package/esm/core/define.d.ts +19 -0
  56. package/esm/core/define.js +12 -0
  57. package/esm/core/define.js.map +1 -0
  58. package/esm/interfaces/options.d.ts +1 -0
  59. package/esm/interfaces/options.js +2 -0
  60. package/esm/interfaces/options.js.map +1 -0
  61. package/esm/interfaces/request.d.ts +9 -3
  62. package/esm/models/aggregate.d.ts +47 -0
  63. package/esm/models/aggregate.js +6 -0
  64. package/esm/models/aggregate.js.map +1 -0
  65. package/esm/models/category.d.ts +24 -0
  66. package/esm/models/category.js +6 -0
  67. package/esm/models/category.js.map +1 -0
  68. package/esm/models/link.d.ts +17 -0
  69. package/esm/models/link.js +11 -0
  70. package/esm/models/link.js.map +1 -0
  71. package/esm/models/project.d.ts +16 -0
  72. package/esm/models/project.js +2 -0
  73. package/esm/models/project.js.map +1 -0
  74. package/esm/models/recently.d.ts +5 -0
  75. package/esm/models/recently.js +2 -0
  76. package/esm/models/recently.js.map +1 -0
  77. package/esm/models/say.d.ts +6 -0
  78. package/esm/models/say.js +2 -0
  79. package/esm/models/say.js.map +1 -0
  80. package/esm/models/setting.d.ts +66 -0
  81. package/esm/models/setting.js +2 -0
  82. package/esm/models/setting.js.map +1 -0
  83. package/esm/models/snippet.d.ts +14 -0
  84. package/esm/models/snippet.js +7 -0
  85. package/esm/models/snippet.js.map +1 -0
  86. package/esm/models/user.d.ts +29 -0
  87. package/esm/models/user.js +2 -0
  88. package/esm/models/user.js.map +1 -0
  89. package/esm/utils/index.d.ts +4 -0
  90. package/esm/utils/index.js +38 -0
  91. package/esm/utils/index.js.map +1 -1
  92. package/lib/core/attachRequest.js +4 -0
  93. package/lib/core/attachRequest.js.map +1 -1
  94. package/lib/core/client.d.ts +2 -9
  95. package/lib/core/client.js +16 -2
  96. package/lib/core/client.js.map +1 -1
  97. package/lib/core/controllers/aggregate.d.ts +44 -0
  98. package/lib/core/controllers/aggregate.js +44 -0
  99. package/lib/core/controllers/aggregate.js.map +1 -0
  100. package/lib/core/controllers/all.d.ts +13 -2
  101. package/lib/core/controllers/all.js +52 -11
  102. package/lib/core/controllers/all.js.map +1 -1
  103. package/lib/core/controllers/base.d.ts +29 -0
  104. package/lib/core/controllers/base.js +29 -0
  105. package/lib/core/controllers/base.js.map +1 -0
  106. package/lib/core/controllers/category.d.ts +44 -0
  107. package/lib/core/controllers/category.js +70 -0
  108. package/lib/core/controllers/category.js.map +1 -0
  109. package/lib/core/controllers/index.d.ts +0 -2
  110. package/lib/core/controllers/index.js +0 -3
  111. package/lib/core/controllers/index.js.map +1 -1
  112. package/lib/core/controllers/link.d.ts +9 -0
  113. package/lib/core/controllers/link.js +14 -0
  114. package/lib/core/controllers/link.js.map +1 -0
  115. package/lib/core/controllers/project.d.ts +9 -0
  116. package/lib/core/controllers/project.js +14 -0
  117. package/lib/core/controllers/project.js.map +1 -0
  118. package/lib/core/controllers/recently.d.ts +33 -0
  119. package/lib/core/controllers/recently.js +36 -0
  120. package/lib/core/controllers/recently.js.map +1 -0
  121. package/lib/core/controllers/say.d.ts +22 -0
  122. package/lib/core/controllers/say.js +23 -0
  123. package/lib/core/controllers/say.js.map +1 -0
  124. package/lib/core/controllers/search.d.ts +58 -0
  125. package/lib/core/controllers/search.js +30 -0
  126. package/lib/core/controllers/search.js.map +1 -0
  127. package/lib/core/controllers/snippet.d.ts +18 -0
  128. package/lib/core/controllers/snippet.js +21 -0
  129. package/lib/core/controllers/snippet.js.map +1 -0
  130. package/lib/core/controllers/user.d.ts +28 -0
  131. package/lib/core/controllers/user.js +33 -0
  132. package/lib/core/controllers/user.js.map +1 -0
  133. package/lib/core/define.d.ts +19 -0
  134. package/lib/core/define.js +16 -0
  135. package/lib/core/define.js.map +1 -0
  136. package/lib/interfaces/options.d.ts +1 -0
  137. package/lib/interfaces/options.js +3 -0
  138. package/lib/interfaces/options.js.map +1 -0
  139. package/lib/interfaces/request.d.ts +9 -3
  140. package/lib/models/aggregate.d.ts +47 -0
  141. package/lib/models/aggregate.js +9 -0
  142. package/lib/models/aggregate.js.map +1 -0
  143. package/lib/models/category.d.ts +24 -0
  144. package/lib/models/category.js +9 -0
  145. package/lib/models/category.js.map +1 -0
  146. package/lib/models/link.d.ts +17 -0
  147. package/lib/models/link.js +14 -0
  148. package/lib/models/link.js.map +1 -0
  149. package/lib/models/project.d.ts +16 -0
  150. package/lib/models/project.js +3 -0
  151. package/lib/models/project.js.map +1 -0
  152. package/lib/models/recently.d.ts +5 -0
  153. package/lib/models/recently.js +3 -0
  154. package/lib/models/recently.js.map +1 -0
  155. package/lib/models/say.d.ts +6 -0
  156. package/lib/models/say.js +3 -0
  157. package/lib/models/say.js.map +1 -0
  158. package/lib/models/setting.d.ts +66 -0
  159. package/lib/models/setting.js +3 -0
  160. package/lib/models/setting.js.map +1 -0
  161. package/lib/models/snippet.d.ts +14 -0
  162. package/lib/models/snippet.js +10 -0
  163. package/lib/models/snippet.js.map +1 -0
  164. package/lib/models/user.d.ts +29 -0
  165. package/lib/models/user.js +3 -0
  166. package/lib/models/user.js.map +1 -0
  167. package/lib/utils/index.d.ts +4 -0
  168. package/lib/utils/index.js +42 -1
  169. package/lib/utils/index.js.map +1 -1
  170. package/package.json +11 -11
@@ -366,6 +366,44 @@
366
366
 
367
367
  const isPlainObject = (obj) => typeof obj === 'object' &&
368
368
  Object.prototype.toString.call(obj) === '[object Object]';
369
+ const sortOrderToNumber = (order) => {
370
+ return ({
371
+ asc: 1,
372
+ desc: -1,
373
+ }[order] || 1);
374
+ };
375
+ const destructureData = (payload) => {
376
+ if (typeof payload !== 'object') {
377
+ return payload;
378
+ }
379
+ if (payload === null) {
380
+ return payload;
381
+ }
382
+ const data = payload.data;
383
+ const dataIsPlainObject = Object.prototype.toString.call(data) === '[object Object]';
384
+ if (dataIsPlainObject && Object.keys(payload).length === 1) {
385
+ const d = Object.assign({}, data);
386
+ // attach raw onto new data
387
+ attachRawFromOneToAnthor(payload, d);
388
+ return d;
389
+ }
390
+ return payload;
391
+ };
392
+ const attachRawFromOneToAnthor = (from, to) => {
393
+ if (!from) {
394
+ return;
395
+ }
396
+ from.$raw &&
397
+ Object.defineProperty(to, '$raw', {
398
+ value: Object.assign({}, from.$raw),
399
+ enumerable: false,
400
+ });
401
+ from.$request &&
402
+ Object.defineProperty(to, '$request', {
403
+ value: Object.assign({}, from.$request),
404
+ enumerable: false,
405
+ });
406
+ };
369
407
 
370
408
  function attachRequestMethod(target) {
371
409
  Object.defineProperty(target, '$$get', {
@@ -392,11 +430,200 @@
392
430
  }
393
431
  const search = new URLSearchParams();
394
432
  Object.entries(obj).forEach(([k, v]) => {
433
+ if (typeof v === 'undefined' ||
434
+ Object.prototype.toString.call(v) === '[object Null]') {
435
+ return;
436
+ }
395
437
  search.set(k, v);
396
438
  });
397
439
  return search.toString();
398
440
  }
399
441
 
442
+ class AggregateController {
443
+ constructor(client) {
444
+ this.client = client;
445
+ this.base = 'aggregate';
446
+ this.name = 'aggregate';
447
+ }
448
+ get proxy() {
449
+ return this.client.proxy(this.base);
450
+ }
451
+ /**
452
+ * 获取聚合数据
453
+ */
454
+ getAggregateData() {
455
+ return this.proxy.get();
456
+ }
457
+ /**
458
+ * 获取最新发布的内容
459
+ */
460
+ getTop(size = 5) {
461
+ return this.proxy.top.get({ params: { size } });
462
+ }
463
+ getTimeline(options) {
464
+ const { sort, type, year } = options || {};
465
+ return this.proxy.timeline.get({
466
+ params: {
467
+ sort: sort && sortOrderToNumber(sort),
468
+ type,
469
+ year,
470
+ },
471
+ });
472
+ }
473
+ /**
474
+ * 获取聚合数据统计
475
+ */
476
+ getStat() {
477
+ return this.proxy.stat.get();
478
+ }
479
+ }
480
+
481
+ var CategoryType;
482
+ (function (CategoryType) {
483
+ CategoryType[CategoryType["Category"] = 0] = "Category";
484
+ CategoryType[CategoryType["Tag"] = 1] = "Tag";
485
+ })(CategoryType || (CategoryType = {}));
486
+
487
+ class CategoryController {
488
+ constructor(client) {
489
+ this.client = client;
490
+ this.name = 'category';
491
+ this.base = 'categories';
492
+ }
493
+ get proxy() {
494
+ return this.client.proxy(this.base);
495
+ }
496
+ getAllCategories() {
497
+ return this.proxy.get({
498
+ params: {
499
+ type: CategoryType.Category,
500
+ },
501
+ });
502
+ }
503
+ getAllTags() {
504
+ return this.proxy.get({
505
+ params: {
506
+ type: CategoryType.Tag,
507
+ },
508
+ });
509
+ }
510
+ async getCategoryDetail(ids) {
511
+ if (typeof ids === 'string') {
512
+ const data = await this.proxy.get({
513
+ params: {
514
+ ids: ids,
515
+ },
516
+ });
517
+ const result = Object.values(data.entries)[0];
518
+ attachRawFromOneToAnthor(data, result);
519
+ return result;
520
+ }
521
+ else if (Array.isArray(ids)) {
522
+ const data = await this.proxy.get({
523
+ params: {
524
+ ids: ids.join(','),
525
+ },
526
+ });
527
+ const entries = data === null || data === void 0 ? void 0 : data.entries;
528
+ if (!entries) {
529
+ throw new RequestError('data structure error', 500, data.$request.path, data);
530
+ }
531
+ const map = new Map(Object.entries(entries).map(([id, value]) => [id.toLowerCase(), value]));
532
+ attachRawFromOneToAnthor(data, map);
533
+ return map;
534
+ }
535
+ }
536
+ async getCategoryByIdOrSlug(idOrSlug) {
537
+ const res = await this.proxy(idOrSlug).get();
538
+ return destructureData(res);
539
+ }
540
+ async getTagByName(name) {
541
+ const res = await this.proxy(name).get({
542
+ params: {
543
+ tag: 1,
544
+ },
545
+ });
546
+ return res;
547
+ }
548
+ }
549
+
550
+ class CommentController {
551
+ constructor(client) {
552
+ this.client = client;
553
+ this.base = 'comments';
554
+ this.name = 'comment';
555
+ }
556
+ get proxy() {
557
+ return this.client.proxy(this.base);
558
+ }
559
+ /**
560
+ * 根据 comment id 获取评论, 包括子评论
561
+ */
562
+ getById(id) {
563
+ return this.proxy(id).get();
564
+ }
565
+ /**
566
+ * 获取文章的评论列表
567
+ * @param refId 文章 Id
568
+ */
569
+ getByRefId(refId, pagination = {}) {
570
+ const { page, size } = pagination;
571
+ return this.proxy.ref(refId).get({
572
+ params: { page: page || 1, size: size || 10 },
573
+ });
574
+ }
575
+ /**
576
+ * 评论
577
+ */
578
+ comment(refId, data) {
579
+ return this.proxy(refId).post({
580
+ data,
581
+ });
582
+ }
583
+ /**
584
+ * 回复评论
585
+ */
586
+ reply(commentId, data) {
587
+ return this.proxy.reply(commentId).post({
588
+ data,
589
+ });
590
+ }
591
+ }
592
+
593
+ class BaseCrudController {
594
+ constructor(client) {
595
+ this.client = client;
596
+ }
597
+ get proxy() {
598
+ return this.client.proxy(this.base);
599
+ }
600
+ getById(id) {
601
+ return this.proxy(id).get();
602
+ }
603
+ getAll() {
604
+ return this.proxy.all.get();
605
+ }
606
+ /**
607
+ * 带分页的查询
608
+ * @param page
609
+ * @param perPage
610
+ */
611
+ getAllPaginated(page, perPage) {
612
+ return this.proxy.get({
613
+ params: { page, size: perPage },
614
+ });
615
+ }
616
+ }
617
+
618
+ class LinkController extends BaseCrudController {
619
+ constructor(client) {
620
+ super(client);
621
+ this.client = client;
622
+ this.name = 'link';
623
+ this.base = 'links';
624
+ }
625
+ }
626
+
400
627
  class NoteController {
401
628
  constructor(client) {
402
629
  this.client = client;
@@ -451,6 +678,39 @@
451
678
  }
452
679
  }
453
680
 
681
+ class PageController {
682
+ constructor(client) {
683
+ this.client = client;
684
+ this.base = 'pages';
685
+ this.name = 'page';
686
+ }
687
+ get proxy() {
688
+ return this.client.proxy(this.base);
689
+ }
690
+ /**
691
+ * 页面列表
692
+ */
693
+ getList(page = 1, perPage = 10) {
694
+ return this.proxy.get({
695
+ params: { page, size: perPage },
696
+ });
697
+ }
698
+ /**
699
+ * 页面详情
700
+ */
701
+ getById(id) {
702
+ return this.proxy(id).get();
703
+ }
704
+ /**
705
+ * 根据路径获取页面
706
+ * @param slug 路径
707
+ * @returns
708
+ */
709
+ getBySlug(slug) {
710
+ return this.proxy.slug(slug).get({});
711
+ }
712
+ }
713
+
454
714
  class PostController {
455
715
  constructor(client) {
456
716
  this.client = client;
@@ -493,94 +753,179 @@
493
753
  }
494
754
  }
495
755
 
496
- class CommentController {
756
+ class ProjectController extends BaseCrudController {
497
757
  constructor(client) {
758
+ super(client);
498
759
  this.client = client;
499
- this.base = 'comments';
500
- this.name = 'comment';
760
+ this.base = 'projects';
761
+ this.name = 'project';
762
+ }
763
+ }
764
+
765
+ class RecentlyController {
766
+ constructor(client) {
767
+ this.client = client;
768
+ this.base = 'recently';
769
+ this.name = 'recently';
501
770
  }
502
771
  get proxy() {
503
772
  return this.client.proxy(this.base);
504
773
  }
505
774
  /**
506
- * 根据 comment id 获取评论, 包括子评论
775
+ * 获取最新一条
507
776
  */
508
- getById(id) {
509
- return this.proxy(id).get();
777
+ getLatestOne() {
778
+ return this.proxy.latest.get();
510
779
  }
511
- /**
512
- * 获取文章的评论列表
513
- * @param refId 文章 Id
514
- */
515
- getByRefId(refId, pagination = {}) {
516
- const { page, size } = pagination;
517
- return this.proxy.ref(refId).get({
518
- params: { page: page || 1, size: size || 10 },
519
- });
780
+ getAll() {
781
+ return this.proxy.all.get();
520
782
  }
521
- /**
522
- * 评论
523
- */
524
- comment(refId, data) {
525
- return this.proxy(refId).post({
526
- data,
783
+ getList(before, after, size) {
784
+ if (!before && !after) {
785
+ throw new Error('you can only choose `before` or `after`');
786
+ }
787
+ return this.proxy.get({
788
+ params: {
789
+ before,
790
+ after,
791
+ size,
792
+ },
527
793
  });
528
794
  }
795
+ }
796
+
797
+ class SayController extends BaseCrudController {
798
+ constructor(client) {
799
+ super(client);
800
+ this.client = client;
801
+ this.base = 'says';
802
+ this.name = 'say';
803
+ }
804
+ get proxy() {
805
+ return this.client.proxy(this.base);
806
+ }
529
807
  /**
530
- * 回复评论
808
+ * 获取随机一条
531
809
  */
532
- reply(commentId, data) {
533
- return this.proxy.reply(commentId).post({
534
- data,
535
- });
810
+ getRandom() {
811
+ return this.proxy.random.get();
536
812
  }
537
813
  }
538
814
 
539
- class PageController {
815
+ class SearchController {
540
816
  constructor(client) {
541
817
  this.client = client;
542
- this.base = 'pages';
543
- this.name = 'page';
818
+ this.base = 'search';
819
+ this.name = 'search';
544
820
  }
545
821
  get proxy() {
546
822
  return this.client.proxy(this.base);
547
823
  }
548
- /**
549
- * 页面列表
550
- */
551
- getList(page = 1, perPage = 10) {
552
- return this.proxy.get({
553
- params: { page, size: perPage },
824
+ search(type, keyword, options = {}) {
825
+ return this.proxy(type).get({
826
+ params: Object.assign({ keyword }, options),
554
827
  });
555
828
  }
556
829
  /**
557
- * 页面详情
830
+ * 从 algolya 搜索
831
+ * https://www.algolia.com/doc/api-reference/api-methods/search/
832
+ * @param keyword
833
+ * @param options
834
+ * @returns
558
835
  */
836
+ searchByAlgolia(keyword, options) {
837
+ return this.proxy('algolia').get({ params: Object.assign({ keyword }, options) });
838
+ }
839
+ }
840
+
841
+ class SnippetController {
842
+ constructor(client) {
843
+ this.client = client;
844
+ this.base = 'snippets';
845
+ this.name = 'snippet';
846
+ }
847
+ get proxy() {
848
+ return this.client.proxy(this.base);
849
+ }
559
850
  getById(id) {
560
851
  return this.proxy(id).get();
561
852
  }
562
- /**
563
- * 根据路径获取页面
564
- * @param slug 路径
565
- * @returns
566
- */
567
- getBySlug(slug) {
568
- return this.proxy.slug(slug).get({});
853
+ getByReferenceAndName(reference, name) {
854
+ return this.proxy(reference)(name).get();
855
+ }
856
+ }
857
+
858
+ class UserController {
859
+ constructor(client) {
860
+ this.client = client;
861
+ this.base = 'master';
862
+ this.name = 'user';
863
+ }
864
+ get proxy() {
865
+ return this.client.proxy(this.base);
866
+ }
867
+ getMasterInfo() {
868
+ return this.proxy.get();
869
+ }
870
+ login(username, password) {
871
+ return this.proxy.login.post({
872
+ data: {
873
+ username,
874
+ password,
875
+ },
876
+ });
877
+ }
878
+ checkTokenValid(token) {
879
+ return this.proxy.check_logged.get({
880
+ params: {
881
+ token,
882
+ },
883
+ });
569
884
  }
570
885
  }
571
886
 
572
887
  const allControllers = [
888
+ AggregateController,
889
+ CategoryController,
890
+ CommentController,
891
+ LinkController,
573
892
  NoteController,
574
- PostController,
575
893
  PageController,
576
- CommentController,
894
+ PostController,
895
+ ProjectController,
896
+ RecentlyController,
897
+ SayController,
898
+ SearchController,
899
+ SnippetController,
900
+ UserController,
901
+ ];
902
+ const allContollerNames = [
903
+ 'aggregate',
904
+ 'category',
905
+ 'comment',
906
+ 'link',
907
+ 'note',
908
+ 'page',
909
+ 'post',
910
+ 'project',
911
+ 'recently',
912
+ 'say',
913
+ 'search',
914
+ 'snippet',
915
+ 'user',
577
916
  ];
578
- // export const allClientName = allClients.map((c) =>
579
- // c.name.replace('Client', '').toLowerCase(),
580
- // )
581
- // Why not code like before
582
- // In order to tree shake unnecessary client
583
- const allContollerNames = ['note', 'post', 'page', 'comment'];
917
+
918
+ class HTTPControllerDefine {
919
+ get master() {
920
+ return this.user;
921
+ }
922
+ get friend() {
923
+ return this.link;
924
+ }
925
+ get shorthand() {
926
+ return this.recently;
927
+ }
928
+ }
584
929
 
585
930
  class RequestError extends Error {
586
931
  constructor(message, status, path, raw) {
@@ -591,8 +936,10 @@
591
936
  }
592
937
  }
593
938
 
594
- class HTTPClient {
939
+ class HTTPClient extends HTTPControllerDefine {
940
+ // define all clients
595
941
  constructor(_endpoint, _instance) {
942
+ super();
596
943
  this._endpoint = _endpoint;
597
944
  this._instance = _instance;
598
945
  this._endpoint = _endpoint
@@ -694,13 +1041,24 @@
694
1041
  const transform = Array.isArray(data) || isPlainObject(data)
695
1042
  ? camelcaseKeys(data, { deep: true })
696
1043
  : data;
697
- Object.defineProperty(transform, 'raw', {
1044
+ Object.defineProperty(transform, '$raw', {
698
1045
  get() {
699
1046
  return res;
700
1047
  },
701
1048
  enumerable: false,
702
1049
  configurable: false,
703
1050
  });
1051
+ // attach request config onto response
1052
+ Object.defineProperty(transform, '$request', {
1053
+ get() {
1054
+ return {
1055
+ url,
1056
+ method: name,
1057
+ options,
1058
+ };
1059
+ },
1060
+ enumerable: false,
1061
+ });
704
1062
  return transform;
705
1063
  };
706
1064
  }