@mx-space/api-client 1.3.5 → 1.4.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 (92) hide show
  1. package/.eslintcache +1 -1
  2. package/controllers/aggregate.ts +7 -7
  3. package/controllers/base.ts +4 -4
  4. package/controllers/category.ts +12 -11
  5. package/controllers/comment.ts +9 -9
  6. package/controllers/link.ts +4 -3
  7. package/controllers/note.ts +9 -9
  8. package/controllers/page.ts +8 -8
  9. package/controllers/post.ts +8 -8
  10. package/controllers/project.ts +4 -3
  11. package/controllers/recently.ts +6 -6
  12. package/controllers/say.ts +6 -5
  13. package/controllers/search.ts +9 -9
  14. package/controllers/severless.ts +5 -5
  15. package/controllers/snippet.ts +5 -5
  16. package/controllers/subscribe.ts +6 -6
  17. package/controllers/topic.ts +6 -5
  18. package/controllers/user.ts +6 -6
  19. package/coverage/clover.xml +591 -0
  20. package/coverage/coverage-final.json +5944 -0
  21. package/coverage/lcov-report/adaptors/axios.ts.html +201 -0
  22. package/coverage/lcov-report/adaptors/index.html +196 -0
  23. package/coverage/lcov-report/adaptors/umi-request.ts.html +186 -0
  24. package/coverage/lcov-report/auto-bind.ts.html +228 -0
  25. package/coverage/lcov-report/base.css +354 -0
  26. package/coverage/lcov-report/block-navigation.js +85 -0
  27. package/coverage/lcov-report/controllers/aggregate.ts.html +294 -0
  28. package/coverage/lcov-report/controllers/base.ts.html +183 -0
  29. package/coverage/lcov-report/controllers/category.ts.html +441 -0
  30. package/coverage/lcov-report/controllers/comment.ts.html +291 -0
  31. package/coverage/lcov-report/controllers/index.html +476 -0
  32. package/coverage/lcov-report/controllers/index.ts.html +297 -0
  33. package/coverage/lcov-report/controllers/link.ts.html +216 -0
  34. package/coverage/lcov-report/controllers/note.ts.html +375 -0
  35. package/coverage/lcov-report/controllers/page.ts.html +279 -0
  36. package/coverage/lcov-report/controllers/post.ts.html +369 -0
  37. package/coverage/lcov-report/controllers/project.ts.html +168 -0
  38. package/coverage/lcov-report/controllers/recently.ts.html +246 -0
  39. package/coverage/lcov-report/controllers/say.ts.html +207 -0
  40. package/coverage/lcov-report/controllers/search.ts.html +411 -0
  41. package/coverage/lcov-report/controllers/severless.ts.html +180 -0
  42. package/coverage/lcov-report/controllers/snippet.ts.html +195 -0
  43. package/coverage/lcov-report/controllers/user.ts.html +240 -0
  44. package/coverage/lcov-report/core/attach-request.ts.html +216 -0
  45. package/coverage/lcov-report/core/client.ts.html +786 -0
  46. package/coverage/lcov-report/core/error.ts.html +117 -0
  47. package/coverage/lcov-report/core/index.html +236 -0
  48. package/coverage/lcov-report/core/index.ts.html +93 -0
  49. package/coverage/lcov-report/favicon.png +0 -0
  50. package/coverage/lcov-report/index.html +276 -0
  51. package/coverage/lcov-report/index.ts.html +243 -0
  52. package/coverage/lcov-report/models/aggregate.ts.html +300 -0
  53. package/coverage/lcov-report/models/category.ts.html +162 -0
  54. package/coverage/lcov-report/models/index.html +196 -0
  55. package/coverage/lcov-report/prettify.css +101 -0
  56. package/coverage/lcov-report/prettify.js +1004 -0
  57. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  58. package/coverage/lcov-report/sorter.js +191 -0
  59. package/coverage/lcov-report/utils/auto-bind.ts.html +231 -0
  60. package/coverage/lcov-report/utils/index.html +216 -0
  61. package/coverage/lcov-report/utils/index.ts.html +246 -0
  62. package/coverage/lcov-report/utils/path.ts.html +105 -0
  63. package/coverage/lcov.info +1209 -0
  64. package/dist/adaptors/axios.d.ts +1 -1
  65. package/dist/adaptors/axios.global.js +146 -95
  66. package/dist/adaptors/ky.global.js +13 -12
  67. package/dist/adaptors/umi-request.d.ts +1 -1
  68. package/dist/adaptors/umi-request.global.js +22 -13
  69. package/dist/index.cjs +21 -13
  70. package/dist/index.d.ts +22 -193
  71. package/dist/index.global.js +21 -13
  72. package/dist/index.js +21 -13
  73. package/interfaces/adapter.ts +1 -1
  74. package/interfaces/client.ts +2 -2
  75. package/interfaces/request.ts +3 -1
  76. package/models/aggregate.ts +20 -9
  77. package/models/base.ts +0 -2
  78. package/models/category.ts +2 -2
  79. package/models/comment.ts +2 -2
  80. package/models/link.ts +1 -1
  81. package/models/note.ts +2 -2
  82. package/models/page.ts +1 -1
  83. package/models/post.ts +2 -2
  84. package/models/project.ts +1 -1
  85. package/models/recently.ts +1 -1
  86. package/models/say.ts +1 -1
  87. package/models/snippet.ts +1 -1
  88. package/models/subscribe.ts +1 -1
  89. package/models/topic.ts +1 -1
  90. package/models/user.ts +1 -1
  91. package/package.json +10 -23
  92. package/tsconfig.json +1 -1
@@ -29,13 +29,14 @@
29
29
  if (!from || !isObject(to)) {
30
30
  return;
31
31
  }
32
- from.$raw && Object.defineProperty(to, "$raw", {
33
- value: { ...from.$raw },
34
- enumerable: false
35
- });
36
- from.$request && Object.defineProperty(to, "$request", {
37
- value: { ...from.$request },
38
- enumerable: false
32
+ ;
33
+ ["$raw", "$request", "$serialized"].forEach((key) => {
34
+ from[key] && Object.defineProperty(to, key, {
35
+ get() {
36
+ return from[key];
37
+ },
38
+ enumerable: false
39
+ });
39
40
  });
40
41
  };
41
42
 
@@ -909,16 +910,18 @@
909
910
  if (!data) {
910
911
  return null;
911
912
  }
912
- const transform = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
913
- if (transform && typeof transform === "object") {
914
- Object.defineProperty(transform, "$raw", {
913
+ const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
914
+ let nextObject = cameledObject;
915
+ if (cameledObject && typeof cameledObject === "object") {
916
+ nextObject = { ...cameledObject };
917
+ Object.defineProperty(nextObject, "$raw", {
915
918
  get() {
916
919
  return res;
917
920
  },
918
921
  enumerable: false,
919
922
  configurable: false
920
923
  });
921
- Object.defineProperty(transform, "$request", {
924
+ Object.defineProperty(nextObject, "$request", {
922
925
  get() {
923
926
  return {
924
927
  url,
@@ -928,8 +931,13 @@
928
931
  },
929
932
  enumerable: false
930
933
  });
934
+ Object.defineProperty(nextObject, "$serialized", {
935
+ get() {
936
+ return cameledObject;
937
+ }
938
+ });
931
939
  }
932
- return transform;
940
+ return nextObject;
933
941
  };
934
942
  }
935
943
  route.push(name);
@@ -1021,7 +1029,7 @@
1021
1029
  return SnippetType2;
1022
1030
  })(SnippetType || {});
1023
1031
 
1024
- // ../../src/modules/subscribe/subscribe.constant.ts
1032
+ // ../../apps/core/src/modules/subscribe/subscribe.constant.ts
1025
1033
  var SubscribePostCreateBit = 1 << 0;
1026
1034
  var SubscribeNoteCreateBit = 1 << 1;
1027
1035
  var SubscribeSayCreateBit = 1 << 2;
package/dist/index.js CHANGED
@@ -27,13 +27,14 @@ var attachRawFromOneToAnthor = (from, to) => {
27
27
  if (!from || !isObject(to)) {
28
28
  return;
29
29
  }
30
- from.$raw && Object.defineProperty(to, "$raw", {
31
- value: { ...from.$raw },
32
- enumerable: false
33
- });
34
- from.$request && Object.defineProperty(to, "$request", {
35
- value: { ...from.$request },
36
- enumerable: false
30
+ ;
31
+ ["$raw", "$request", "$serialized"].forEach((key) => {
32
+ from[key] && Object.defineProperty(to, key, {
33
+ get() {
34
+ return from[key];
35
+ },
36
+ enumerable: false
37
+ });
37
38
  });
38
39
  };
39
40
 
@@ -907,16 +908,18 @@ var HTTPClient = class {
907
908
  if (!data) {
908
909
  return null;
909
910
  }
910
- const transform = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
911
- if (transform && typeof transform === "object") {
912
- Object.defineProperty(transform, "$raw", {
911
+ const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
912
+ let nextObject = cameledObject;
913
+ if (cameledObject && typeof cameledObject === "object") {
914
+ nextObject = { ...cameledObject };
915
+ Object.defineProperty(nextObject, "$raw", {
913
916
  get() {
914
917
  return res;
915
918
  },
916
919
  enumerable: false,
917
920
  configurable: false
918
921
  });
919
- Object.defineProperty(transform, "$request", {
922
+ Object.defineProperty(nextObject, "$request", {
920
923
  get() {
921
924
  return {
922
925
  url,
@@ -926,8 +929,13 @@ var HTTPClient = class {
926
929
  },
927
930
  enumerable: false
928
931
  });
932
+ Object.defineProperty(nextObject, "$serialized", {
933
+ get() {
934
+ return cameledObject;
935
+ }
936
+ });
929
937
  }
930
- return transform;
938
+ return nextObject;
931
939
  };
932
940
  }
933
941
  route.push(name);
@@ -1019,7 +1027,7 @@ var SnippetType = /* @__PURE__ */ ((SnippetType2) => {
1019
1027
  return SnippetType2;
1020
1028
  })(SnippetType || {});
1021
1029
 
1022
- // ../../src/modules/subscribe/subscribe.constant.ts
1030
+ // ../../apps/core/src/modules/subscribe/subscribe.constant.ts
1023
1031
  var SubscribePostCreateBit = 1 << 0;
1024
1032
  var SubscribeNoteCreateBit = 1 << 1;
1025
1033
  var SubscribeSayCreateBit = 1 << 2;
@@ -1,4 +1,4 @@
1
- import { RequestOptions } from './instance'
1
+ import type { RequestOptions } from './instance'
2
2
 
3
3
  export type IAdaptorRequestResponseType<P> = Promise<
4
4
  Record<string, any> & { data: P }
@@ -1,5 +1,5 @@
1
- import { IController } from './controller'
2
- import { Class } from './types'
1
+ import type { IController } from './controller'
2
+ import type { Class } from './types'
3
3
 
4
4
  interface IClientOptions {
5
5
  controllers: Class<IController>[]
@@ -1,4 +1,4 @@
1
- import { RequestOptions } from './instance'
1
+ import type { RequestOptions } from './instance'
2
2
 
3
3
  type NoStringIndex<T> = { [K in keyof T as string extends K ? never : K]: T[K] }
4
4
 
@@ -70,6 +70,8 @@ type ResponseWrapperType<Response, RawData, T> = {
70
70
  method: string
71
71
  [k: string]: string
72
72
  }
73
+
74
+ $serialized: T
73
75
  }
74
76
 
75
77
  export type ResponseProxyExtraRaw<
@@ -1,10 +1,10 @@
1
- import { CategoryModel } from './category'
2
- import { NoteModel } from './note'
3
- import { PageModel } from './page'
4
- import { PostModel } from './post'
5
- import { SayModel } from './say'
6
- import { SeoOptionModel } from './setting'
7
- import { UserModel } from './user'
1
+ import type { CategoryModel } from './category'
2
+ import type { NoteModel } from './note'
3
+ import type { PageModel } from './page'
4
+ import type { PostModel } from './post'
5
+ import type { SayModel } from './say'
6
+ import type { SeoOptionModel } from './setting'
7
+ import type { UserModel } from './user'
8
8
 
9
9
  export interface AggregateRoot {
10
10
  user: UserModel
@@ -20,9 +20,20 @@ export interface Url {
20
20
  webUrl: string
21
21
  }
22
22
 
23
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
24
+ export interface AggregateTopNote
25
+ extends Pick<NoteModel, 'id' | 'title' | 'created' | 'nid' | 'images'> {}
26
+
27
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
28
+ export interface AggregateTopPost
29
+ extends Pick<
30
+ PostModel,
31
+ 'id' | 'slug' | 'created' | 'title' | 'category' | 'images'
32
+ > {}
33
+
23
34
  export interface AggregateTop {
24
- notes: Pick<NoteModel, 'id' | 'title' | 'created' | 'nid'>[]
25
- posts: Pick<PostModel, 'id' | 'slug' | 'created' | 'title' | 'category'>[]
35
+ notes: AggregateTopNote[]
36
+ posts: AggregateTopPost[]
26
37
  says: SayModel[]
27
38
  }
28
39
 
package/models/base.ts CHANGED
@@ -40,8 +40,6 @@ export interface TextBaseModel extends BaseCommentIndexModel {
40
40
  text: string
41
41
  images?: Image[]
42
42
  modified: string | null
43
-
44
- meta?: Record<string, any>
45
43
  }
46
44
 
47
45
  export type ModelWithLiked<T> = T & {
@@ -1,5 +1,5 @@
1
- import { BaseModel } from './base'
2
- import { PostModel } from './post'
1
+ import type { BaseModel } from './base'
2
+ import type { PostModel } from './post'
3
3
 
4
4
  export enum CategoryType {
5
5
  Category,
package/models/comment.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { BaseModel } from './base'
2
- import { CategoryModel } from './category'
1
+ import type { BaseModel } from './base'
2
+ import type { CategoryModel } from './category'
3
3
 
4
4
  export enum RefType {
5
5
  Page = 'Page',
package/models/link.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseModel } from './base'
1
+ import type { BaseModel } from './base'
2
2
 
3
3
  export enum LinkType {
4
4
  Friend,
package/models/note.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ModelWithLiked, TextBaseModel } from './base'
2
- import { TopicModel } from './topic'
1
+ import type { ModelWithLiked, TextBaseModel } from './base'
2
+ import type { TopicModel } from './topic'
3
3
 
4
4
  export interface NoteModel extends TextBaseModel {
5
5
  hide: boolean
package/models/page.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TextBaseModel } from './base'
1
+ import type { TextBaseModel } from './base'
2
2
 
3
3
  export enum EnumPageType {
4
4
  'md' = 'md',
package/models/post.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Count, Image, TextBaseModel } from './base'
2
- import { CategoryModel } from './category'
1
+ import type { Count, Image, TextBaseModel } from './base'
2
+ import type { CategoryModel } from './category'
3
3
 
4
4
  export interface PostModel extends TextBaseModel {
5
5
  summary?: string
package/models/project.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseModel } from './base'
1
+ import type { BaseModel } from './base'
2
2
 
3
3
  export interface ProjectModel extends BaseModel {
4
4
  name: string
@@ -1,4 +1,4 @@
1
- import { BaseCommentIndexModel } from './base'
1
+ import type { BaseCommentIndexModel } from './base'
2
2
 
3
3
  export enum RecentlyRefTypes {
4
4
  Post = 'Post',
package/models/say.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseModel } from './base'
1
+ import type { BaseModel } from './base'
2
2
 
3
3
  export interface SayModel extends BaseModel {
4
4
  text: string
package/models/snippet.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseModel } from './base'
1
+ import type { BaseModel } from './base'
2
2
 
3
3
  export enum SnippetType {
4
4
  JSON = 'json',
@@ -1,4 +1,4 @@
1
- import { SubscribeTypeToBitMap } from '@core/modules/subscribe/subscribe.constant'
1
+ import type { SubscribeTypeToBitMap } from '@core/modules/subscribe/subscribe.constant'
2
2
 
3
3
  export * from '@core/modules/subscribe/subscribe.constant'
4
4
 
package/models/topic.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseModel } from './base'
1
+ import type { BaseModel } from './base'
2
2
 
3
3
  export interface TopicModel extends BaseModel {
4
4
  description?: string
package/models/user.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseModel } from './base'
1
+ import type { BaseModel } from './base'
2
2
 
3
3
  export interface UserModel extends BaseModel {
4
4
  introduce: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-space/api-client",
3
- "version": "1.3.5",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "description": "A api client for mx-space server@next",
6
6
  "author": "Innei",
@@ -24,11 +24,6 @@
24
24
  },
25
25
  "./package.json": "./package.json"
26
26
  },
27
- "husky": {
28
- "hooks": {
29
- "pre-commit": "lint-staged"
30
- }
31
- },
32
27
  "bump": {
33
28
  "before": [
34
29
  "git pull --rebase",
@@ -41,15 +36,6 @@
41
36
  "tag": false,
42
37
  "commit_message": "chore(release): bump @mx-space/api-client to v${NEW_VERSION}"
43
38
  },
44
- "lint-staged": {
45
- "*.{js,jsx,ts,tsx}": [
46
- "prettier --ignore-path ./.prettierignore --write ",
47
- "eslint --cache"
48
- ]
49
- },
50
- "engines": {
51
- "pnpm": ">=6"
52
- },
53
39
  "scripts": {
54
40
  "package": "rm -rf dist && tsup && node mod-dts.mjs",
55
41
  "build": "npm run package",
@@ -60,17 +46,18 @@
60
46
  "devDependencies": {
61
47
  "@types/cors": "2.8.13",
62
48
  "@types/express": "4.17.17",
63
- "@types/lodash": "4.14.191",
49
+ "@types/lodash": "4.14.195",
64
50
  "abort-controller": "3.0.0",
65
- "axios": "^1.3.1",
66
- "camelcase-keys": "*",
51
+ "axios": "^1.4.0",
52
+ "camelcase-keys": "^7.0.2",
67
53
  "cors": "2.8.5",
68
54
  "express": "4.18.2",
69
- "ky": "0.33.2",
55
+ "ky": "0.33.3",
70
56
  "lodash": "4.17.21",
71
- "node-fetch": "3.3.0",
72
- "tsc-alias": "1.8.2",
73
- "tsup": "6.6.3",
74
- "umi-request": "1.4.0"
57
+ "tsup": "6.7.0",
58
+ "umi-request": "1.4.0",
59
+ "vitest": "^0.31.4",
60
+ "vite": "^4.3.9",
61
+ "form-data": "4.0.0"
75
62
  }
76
63
  }
package/tsconfig.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "*"
24
24
  ],
25
25
  "@core/*": [
26
- "../../src/*"
26
+ "../../apps/core/src/*"
27
27
  ],
28
28
  }
29
29
  },