@mx-space/api-client 1.17.0 → 1.18.0

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 (288) hide show
  1. package/controllers/ack.ts +1 -2
  2. package/controllers/activity.ts +1 -2
  3. package/controllers/aggregate.ts +1 -2
  4. package/controllers/ai.ts +1 -2
  5. package/controllers/base.ts +1 -2
  6. package/controllers/category.ts +4 -6
  7. package/controllers/comment.ts +1 -2
  8. package/controllers/link.ts +1 -3
  9. package/controllers/note.ts +5 -3
  10. package/controllers/page.ts +1 -2
  11. package/controllers/post.ts +1 -2
  12. package/controllers/project.ts +1 -3
  13. package/controllers/recently.ts +1 -2
  14. package/controllers/say.ts +1 -3
  15. package/controllers/search.ts +2 -3
  16. package/controllers/severless.ts +1 -2
  17. package/controllers/snippet.ts +1 -2
  18. package/controllers/subscribe.ts +1 -2
  19. package/controllers/topic.ts +1 -3
  20. package/controllers/user.ts +1 -2
  21. package/dist/adapter-B1dtiutp.d.cts +25 -0
  22. package/dist/adapter-CRsPadpS.d.mts +25 -0
  23. package/dist/adaptors/axios.cjs +53 -57
  24. package/dist/adaptors/axios.d.cts +5 -4
  25. package/dist/adaptors/axios.d.mts +7 -0
  26. package/dist/adaptors/axios.mjs +33 -0
  27. package/dist/adaptors/fetch.cjs +72 -108
  28. package/dist/adaptors/fetch.d.cts +4 -3
  29. package/dist/adaptors/fetch.d.mts +6 -0
  30. package/dist/adaptors/fetch.mjs +75 -0
  31. package/dist/adaptors/umi-request.cjs +32 -54
  32. package/dist/adaptors/umi-request.d.cts +5 -4
  33. package/dist/adaptors/umi-request.d.mts +7 -0
  34. package/dist/adaptors/umi-request.mjs +33 -0
  35. package/dist/index.cjs +1043 -1207
  36. package/dist/index.d.cts +1754 -1690
  37. package/dist/index.d.mts +2016 -0
  38. package/dist/index.mjs +1101 -0
  39. package/interfaces/request.ts +3 -1
  40. package/mod-dts.mjs +13 -10
  41. package/models/comment.ts +1 -2
  42. package/models/note.ts +1 -1
  43. package/models/recently.ts +2 -0
  44. package/package.json +16 -16
  45. package/{tsup.config.ts → tsdown.config.ts} +2 -2
  46. package/.eslintcache +0 -1
  47. package/coverage/clover.xml +0 -591
  48. package/coverage/coverage-final.json +0 -5944
  49. package/coverage/lcov-report/adaptors/axios.ts.html +0 -201
  50. package/coverage/lcov-report/adaptors/index.html +0 -196
  51. package/coverage/lcov-report/adaptors/umi-request.ts.html +0 -186
  52. package/coverage/lcov-report/auto-bind.ts.html +0 -228
  53. package/coverage/lcov-report/base.css +0 -354
  54. package/coverage/lcov-report/block-navigation.js +0 -85
  55. package/coverage/lcov-report/controllers/aggregate.ts.html +0 -294
  56. package/coverage/lcov-report/controllers/base.ts.html +0 -183
  57. package/coverage/lcov-report/controllers/category.ts.html +0 -441
  58. package/coverage/lcov-report/controllers/comment.ts.html +0 -291
  59. package/coverage/lcov-report/controllers/index.html +0 -476
  60. package/coverage/lcov-report/controllers/index.ts.html +0 -297
  61. package/coverage/lcov-report/controllers/link.ts.html +0 -216
  62. package/coverage/lcov-report/controllers/note.ts.html +0 -375
  63. package/coverage/lcov-report/controllers/page.ts.html +0 -279
  64. package/coverage/lcov-report/controllers/post.ts.html +0 -369
  65. package/coverage/lcov-report/controllers/project.ts.html +0 -168
  66. package/coverage/lcov-report/controllers/recently.ts.html +0 -246
  67. package/coverage/lcov-report/controllers/say.ts.html +0 -207
  68. package/coverage/lcov-report/controllers/search.ts.html +0 -411
  69. package/coverage/lcov-report/controllers/severless.ts.html +0 -180
  70. package/coverage/lcov-report/controllers/snippet.ts.html +0 -195
  71. package/coverage/lcov-report/controllers/user.ts.html +0 -240
  72. package/coverage/lcov-report/core/attach-request.ts.html +0 -216
  73. package/coverage/lcov-report/core/client.ts.html +0 -786
  74. package/coverage/lcov-report/core/error.ts.html +0 -117
  75. package/coverage/lcov-report/core/index.html +0 -236
  76. package/coverage/lcov-report/core/index.ts.html +0 -93
  77. package/coverage/lcov-report/favicon.png +0 -0
  78. package/coverage/lcov-report/index.html +0 -276
  79. package/coverage/lcov-report/index.ts.html +0 -243
  80. package/coverage/lcov-report/models/aggregate.ts.html +0 -300
  81. package/coverage/lcov-report/models/category.ts.html +0 -162
  82. package/coverage/lcov-report/models/index.html +0 -196
  83. package/coverage/lcov-report/prettify.css +0 -101
  84. package/coverage/lcov-report/prettify.js +0 -1004
  85. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  86. package/coverage/lcov-report/sorter.js +0 -191
  87. package/coverage/lcov-report/utils/auto-bind.ts.html +0 -231
  88. package/coverage/lcov-report/utils/index.html +0 -216
  89. package/coverage/lcov-report/utils/index.ts.html +0 -246
  90. package/coverage/lcov-report/utils/path.ts.html +0 -105
  91. package/coverage/lcov.info +0 -1209
  92. package/dist/adapter-B8tKfr1O.d.cts +0 -23
  93. package/dist/adapter-B8tKfr1O.d.ts +0 -23
  94. package/dist/adaptors/axios.d.ts +0 -6
  95. package/dist/adaptors/axios.global.js +0 -15030
  96. package/dist/adaptors/axios.js +0 -33
  97. package/dist/adaptors/fetch.d.ts +0 -5
  98. package/dist/adaptors/fetch.global.js +0 -87
  99. package/dist/adaptors/fetch.js +0 -87
  100. package/dist/adaptors/umi-request.d.ts +0 -6
  101. package/dist/adaptors/umi-request.global.js +0 -7625
  102. package/dist/adaptors/umi-request.js +0 -33
  103. package/dist/index.d.ts +0 -1952
  104. package/dist/index.global.js +0 -1200
  105. package/dist/index.js +0 -1241
  106. package/esm/apps/core/src/modules/subscribe/subscribe.constant.d.ts +0 -12
  107. package/esm/apps/core/src/modules/subscribe/subscribe.constant.js +0 -16
  108. package/esm/apps/core/src/modules/subscribe/subscribe.constant.js.map +0 -1
  109. package/esm/packages/api-client/adaptors/axios.d.ts +0 -4
  110. package/esm/packages/api-client/adaptors/axios.js +0 -37
  111. package/esm/packages/api-client/adaptors/axios.js.map +0 -1
  112. package/esm/packages/api-client/adaptors/fetch.d.ts +0 -2
  113. package/esm/packages/api-client/adaptors/fetch.js +0 -95
  114. package/esm/packages/api-client/adaptors/fetch.js.map +0 -1
  115. package/esm/packages/api-client/adaptors/ky.d.ts +0 -23
  116. package/esm/packages/api-client/adaptors/ky.js +0 -62
  117. package/esm/packages/api-client/adaptors/ky.js.map +0 -1
  118. package/esm/packages/api-client/adaptors/umi-request.d.ts +0 -4
  119. package/esm/packages/api-client/adaptors/umi-request.js +0 -31
  120. package/esm/packages/api-client/adaptors/umi-request.js.map +0 -1
  121. package/esm/packages/api-client/controllers/aggregate.d.ts +0 -64
  122. package/esm/packages/api-client/controllers/aggregate.js +0 -46
  123. package/esm/packages/api-client/controllers/aggregate.js.map +0 -1
  124. package/esm/packages/api-client/controllers/base.d.ts +0 -43
  125. package/esm/packages/api-client/controllers/base.js +0 -27
  126. package/esm/packages/api-client/controllers/base.js.map +0 -1
  127. package/esm/packages/api-client/controllers/category.d.ts +0 -120
  128. package/esm/packages/api-client/controllers/category.js +0 -68
  129. package/esm/packages/api-client/controllers/category.js.map +0 -1
  130. package/esm/packages/api-client/controllers/comment.d.ts +0 -81
  131. package/esm/packages/api-client/controllers/comment.js +0 -47
  132. package/esm/packages/api-client/controllers/comment.js.map +0 -1
  133. package/esm/packages/api-client/controllers/index.d.ts +0 -19
  134. package/esm/packages/api-client/controllers/index.js +0 -60
  135. package/esm/packages/api-client/controllers/index.js.map +0 -1
  136. package/esm/packages/api-client/controllers/link.d.ts +0 -20
  137. package/esm/packages/api-client/controllers/link.js +0 -21
  138. package/esm/packages/api-client/controllers/link.js.map +0 -1
  139. package/esm/packages/api-client/controllers/note.d.ts +0 -103
  140. package/esm/packages/api-client/controllers/note.js +0 -68
  141. package/esm/packages/api-client/controllers/note.js.map +0 -1
  142. package/esm/packages/api-client/controllers/page.d.ts +0 -59
  143. package/esm/packages/api-client/controllers/page.js +0 -42
  144. package/esm/packages/api-client/controllers/page.js.map +0 -1
  145. package/esm/packages/api-client/controllers/post.d.ts +0 -72
  146. package/esm/packages/api-client/controllers/post.js +0 -52
  147. package/esm/packages/api-client/controllers/post.js.map +0 -1
  148. package/esm/packages/api-client/controllers/project.d.ts +0 -15
  149. package/esm/packages/api-client/controllers/project.js +0 -12
  150. package/esm/packages/api-client/controllers/project.js.map +0 -1
  151. package/esm/packages/api-client/controllers/recently.d.ts +0 -110
  152. package/esm/packages/api-client/controllers/recently.js +0 -49
  153. package/esm/packages/api-client/controllers/recently.js.map +0 -1
  154. package/esm/packages/api-client/controllers/say.d.ts +0 -37
  155. package/esm/packages/api-client/controllers/say.js +0 -21
  156. package/esm/packages/api-client/controllers/say.js.map +0 -1
  157. package/esm/packages/api-client/controllers/search.d.ts +0 -87
  158. package/esm/packages/api-client/controllers/search.js +0 -28
  159. package/esm/packages/api-client/controllers/search.js.map +0 -1
  160. package/esm/packages/api-client/controllers/severless.d.ts +0 -24
  161. package/esm/packages/api-client/controllers/severless.js +0 -16
  162. package/esm/packages/api-client/controllers/severless.js.map +0 -1
  163. package/esm/packages/api-client/controllers/snippet.d.ts +0 -24
  164. package/esm/packages/api-client/controllers/snippet.js +0 -19
  165. package/esm/packages/api-client/controllers/snippet.js.map +0 -1
  166. package/esm/packages/api-client/controllers/subscribe.d.ts +0 -64
  167. package/esm/packages/api-client/controllers/subscribe.js +0 -35
  168. package/esm/packages/api-client/controllers/subscribe.js.map +0 -1
  169. package/esm/packages/api-client/controllers/topic.d.ts +0 -26
  170. package/esm/packages/api-client/controllers/topic.js +0 -18
  171. package/esm/packages/api-client/controllers/topic.js.map +0 -1
  172. package/esm/packages/api-client/controllers/user.d.ts +0 -70
  173. package/esm/packages/api-client/controllers/user.js +0 -40
  174. package/esm/packages/api-client/controllers/user.js.map +0 -1
  175. package/esm/packages/api-client/core/attach-request.d.ts +0 -2
  176. package/esm/packages/api-client/core/attach-request.js +0 -36
  177. package/esm/packages/api-client/core/attach-request.js.map +0 -1
  178. package/esm/packages/api-client/core/client.d.ts +0 -29
  179. package/esm/packages/api-client/core/client.js +0 -193
  180. package/esm/packages/api-client/core/client.js.map +0 -1
  181. package/esm/packages/api-client/core/error.d.ts +0 -6
  182. package/esm/packages/api-client/core/error.js +0 -9
  183. package/esm/packages/api-client/core/error.js.map +0 -1
  184. package/esm/packages/api-client/core/index.d.ts +0 -2
  185. package/esm/packages/api-client/core/index.js +0 -3
  186. package/esm/packages/api-client/core/index.js.map +0 -1
  187. package/esm/packages/api-client/dtos/comment.d.ts +0 -8
  188. package/esm/packages/api-client/dtos/comment.js +0 -2
  189. package/esm/packages/api-client/dtos/comment.js.map +0 -1
  190. package/esm/packages/api-client/dtos/index.d.ts +0 -1
  191. package/esm/packages/api-client/dtos/index.js +0 -2
  192. package/esm/packages/api-client/dtos/index.js.map +0 -1
  193. package/esm/packages/api-client/index.d.ts +0 -8
  194. package/esm/packages/api-client/index.js +0 -9
  195. package/esm/packages/api-client/index.js.map +0 -1
  196. package/esm/packages/api-client/interfaces/adapter.d.ts +0 -14
  197. package/esm/packages/api-client/interfaces/adapter.js +0 -2
  198. package/esm/packages/api-client/interfaces/adapter.js.map +0 -1
  199. package/esm/packages/api-client/interfaces/client.d.ts +0 -13
  200. package/esm/packages/api-client/interfaces/client.js +0 -2
  201. package/esm/packages/api-client/interfaces/client.js.map +0 -1
  202. package/esm/packages/api-client/interfaces/controller.d.ts +0 -4
  203. package/esm/packages/api-client/interfaces/controller.js +0 -2
  204. package/esm/packages/api-client/interfaces/controller.js.map +0 -1
  205. package/esm/packages/api-client/interfaces/instance.d.ts +0 -7
  206. package/esm/packages/api-client/interfaces/instance.js +0 -2
  207. package/esm/packages/api-client/interfaces/instance.js.map +0 -1
  208. package/esm/packages/api-client/interfaces/options.d.ts +0 -1
  209. package/esm/packages/api-client/interfaces/options.js +0 -2
  210. package/esm/packages/api-client/interfaces/options.js.map +0 -1
  211. package/esm/packages/api-client/interfaces/params.d.ts +0 -4
  212. package/esm/packages/api-client/interfaces/params.js +0 -2
  213. package/esm/packages/api-client/interfaces/params.js.map +0 -1
  214. package/esm/packages/api-client/interfaces/request.d.ts +0 -44
  215. package/esm/packages/api-client/interfaces/request.js +0 -2
  216. package/esm/packages/api-client/interfaces/request.js.map +0 -1
  217. package/esm/packages/api-client/interfaces/types.d.ts +0 -2
  218. package/esm/packages/api-client/interfaces/types.js +0 -2
  219. package/esm/packages/api-client/interfaces/types.js.map +0 -1
  220. package/esm/packages/api-client/models/aggregate.d.ts +0 -67
  221. package/esm/packages/api-client/models/aggregate.js +0 -6
  222. package/esm/packages/api-client/models/aggregate.js.map +0 -1
  223. package/esm/packages/api-client/models/base.d.ts +0 -40
  224. package/esm/packages/api-client/models/base.js +0 -2
  225. package/esm/packages/api-client/models/base.js.map +0 -1
  226. package/esm/packages/api-client/models/category.d.ts +0 -22
  227. package/esm/packages/api-client/models/category.js +0 -6
  228. package/esm/packages/api-client/models/category.js.map +0 -1
  229. package/esm/packages/api-client/models/comment.d.ts +0 -39
  230. package/esm/packages/api-client/models/comment.js +0 -13
  231. package/esm/packages/api-client/models/comment.js.map +0 -1
  232. package/esm/packages/api-client/models/index.d.ts +0 -16
  233. package/esm/packages/api-client/models/index.js +0 -17
  234. package/esm/packages/api-client/models/index.js.map +0 -1
  235. package/esm/packages/api-client/models/link.d.ts +0 -22
  236. package/esm/packages/api-client/models/link.js +0 -14
  237. package/esm/packages/api-client/models/link.js.map +0 -1
  238. package/esm/packages/api-client/models/note.d.ts +0 -38
  239. package/esm/packages/api-client/models/note.js +0 -2
  240. package/esm/packages/api-client/models/note.js.map +0 -1
  241. package/esm/packages/api-client/models/page.d.ts +0 -14
  242. package/esm/packages/api-client/models/page.js +0 -7
  243. package/esm/packages/api-client/models/page.js.map +0 -1
  244. package/esm/packages/api-client/models/post.d.ts +0 -17
  245. package/esm/packages/api-client/models/post.js +0 -2
  246. package/esm/packages/api-client/models/post.js.map +0 -1
  247. package/esm/packages/api-client/models/project.d.ts +0 -11
  248. package/esm/packages/api-client/models/project.js +0 -2
  249. package/esm/packages/api-client/models/project.js.map +0 -1
  250. package/esm/packages/api-client/models/recently.d.ts +0 -20
  251. package/esm/packages/api-client/models/recently.js +0 -7
  252. package/esm/packages/api-client/models/recently.js.map +0 -1
  253. package/esm/packages/api-client/models/say.d.ts +0 -6
  254. package/esm/packages/api-client/models/say.js +0 -2
  255. package/esm/packages/api-client/models/say.js.map +0 -1
  256. package/esm/packages/api-client/models/setting.d.ts +0 -66
  257. package/esm/packages/api-client/models/setting.js +0 -2
  258. package/esm/packages/api-client/models/setting.js.map +0 -1
  259. package/esm/packages/api-client/models/snippet.d.ts +0 -18
  260. package/esm/packages/api-client/models/snippet.js +0 -8
  261. package/esm/packages/api-client/models/snippet.js.map +0 -1
  262. package/esm/packages/api-client/models/subscribe.d.ts +0 -3
  263. package/esm/packages/api-client/models/subscribe.js +0 -2
  264. package/esm/packages/api-client/models/subscribe.js.map +0 -1
  265. package/esm/packages/api-client/models/topic.d.ts +0 -8
  266. package/esm/packages/api-client/models/topic.js +0 -2
  267. package/esm/packages/api-client/models/topic.js.map +0 -1
  268. package/esm/packages/api-client/models/user.d.ts +0 -21
  269. package/esm/packages/api-client/models/user.js +0 -2
  270. package/esm/packages/api-client/models/user.js.map +0 -1
  271. package/esm/packages/api-client/tsup.config.d.ts +0 -2
  272. package/esm/packages/api-client/tsup.config.js +0 -14
  273. package/esm/packages/api-client/tsup.config.js.map +0 -1
  274. package/esm/packages/api-client/utils/auto-bind.d.ts +0 -4
  275. package/esm/packages/api-client/utils/auto-bind.js +0 -36
  276. package/esm/packages/api-client/utils/auto-bind.js.map +0 -1
  277. package/esm/packages/api-client/utils/camelcase-keys.d.ts +0 -6
  278. package/esm/packages/api-client/utils/camelcase-keys.js +0 -23
  279. package/esm/packages/api-client/utils/camelcase-keys.js.map +0 -1
  280. package/esm/packages/api-client/utils/index.d.ts +0 -5
  281. package/esm/packages/api-client/utils/index.js +0 -43
  282. package/esm/packages/api-client/utils/index.js.map +0 -1
  283. package/esm/packages/api-client/utils/path.d.ts +0 -1
  284. package/esm/packages/api-client/utils/path.js +0 -7
  285. package/esm/packages/api-client/utils/path.js.map +0 -1
  286. package/esm/packages/api-client/vitest.config.d.ts +0 -2
  287. package/esm/packages/api-client/vitest.config.js +0 -15
  288. package/esm/packages/api-client/vitest.config.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,1308 +1,1144 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ Object.defineProperty(exports, '__esModule', { value: true });
19
2
 
20
- // index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- AIController: () => AIController,
24
- AckController: () => AckController,
25
- ActivityController: () => ActivityController,
26
- AggregateController: () => AggregateController,
27
- CategoryController: () => CategoryController,
28
- CategoryType: () => CategoryType,
29
- CollectionRefTypes: () => CollectionRefTypes,
30
- CommentController: () => CommentController,
31
- CommentState: () => CommentState,
32
- EnumPageType: () => EnumPageType,
33
- LinkController: () => LinkController,
34
- LinkState: () => LinkState,
35
- LinkType: () => LinkType,
36
- NoteController: () => NoteController,
37
- PageController: () => PageController,
38
- PostController: () => PostController,
39
- ProjectController: () => ProjectController,
40
- RecentlyAttitudeEnum: () => RecentlyAttitudeEnum,
41
- RecentlyAttitudeResultEnum: () => RecentlyAttitudeResultEnum,
42
- RecentlyController: () => RecentlyController,
43
- RecentlyRefTypes: () => RecentlyRefTypes,
44
- RequestError: () => RequestError,
45
- SayController: () => SayController,
46
- SearchController: () => SearchController,
47
- ServerlessController: () => ServerlessController,
48
- SnippetController: () => SnippetController,
49
- SnippetType: () => SnippetType,
50
- SubscribeAllBit: () => SubscribeAllBit,
51
- SubscribeController: () => SubscribeController,
52
- SubscribeNoteCreateBit: () => SubscribeNoteCreateBit,
53
- SubscribePostCreateBit: () => SubscribePostCreateBit,
54
- SubscribeRecentCreateBit: () => SubscribeRecentCreateBit,
55
- SubscribeSayCreateBit: () => SubscribeSayCreateBit,
56
- SubscribeTypeToBitMap: () => SubscribeTypeToBitMap,
57
- TimelineType: () => TimelineType,
58
- TopicController: () => TopicController,
59
- UserController: () => UserController,
60
- allControllerNames: () => allControllerNames,
61
- allControllers: () => allControllers,
62
- createClient: () => createClient,
63
- default: () => index_default,
64
- simpleCamelcaseKeys: () => camelcaseKeys
65
- });
66
- module.exports = __toCommonJS(index_exports);
67
-
68
- // utils/index.ts
69
- var isPlainObject = (obj) => isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]" && Object.getPrototypeOf(obj) === Object.prototype;
70
- var sortOrderToNumber = (order) => {
71
- return {
72
- asc: 1,
73
- desc: -1
74
- }[order] || 1;
3
+ //#region utils/index.ts
4
+ const isPlainObject = (obj) => isObject(obj) && Object.prototype.toString.call(obj) === "[object Object]" && Object.getPrototypeOf(obj) === Object.prototype;
5
+ const sortOrderToNumber = (order) => {
6
+ return {
7
+ asc: 1,
8
+ desc: -1
9
+ }[order] || 1;
75
10
  };
76
- var isObject = (obj) => obj && typeof obj === "object";
77
- var destructureData = (payload) => {
78
- if (typeof payload !== "object") {
79
- return payload;
80
- }
81
- if (payload === null) {
82
- return payload;
83
- }
84
- const data = payload.data;
85
- const dataIsPlainObject = isPlainObject(data);
86
- if (dataIsPlainObject && Object.keys(payload).length === 1) {
87
- const d = Object.assign({}, data);
88
- attachRawFromOneToAnthor(payload, d);
89
- return d;
90
- }
91
- return payload;
11
+ const isObject = (obj) => obj && typeof obj === "object";
12
+ const destructureData = (payload) => {
13
+ if (typeof payload !== "object") return payload;
14
+ if (payload === null) return payload;
15
+ const data = payload.data;
16
+ if (isPlainObject(data) && Object.keys(payload).length === 1) {
17
+ const d = Object.assign({}, data);
18
+ attachRawFromOneToAnthor(payload, d);
19
+ return d;
20
+ }
21
+ return payload;
92
22
  };
93
- var attachRawFromOneToAnthor = (from, to) => {
94
- if (!from || !isObject(to)) {
95
- return;
96
- }
97
- ;
98
- ["$raw", "$request", "$serialized"].forEach((key) => {
99
- from[key] && Object.defineProperty(to, key, {
100
- get() {
101
- return from[key];
102
- },
103
- enumerable: false
104
- });
105
- });
23
+ const attachRawFromOneToAnthor = (from, to) => {
24
+ if (!from || !isObject(to)) return;
25
+ [
26
+ "$raw",
27
+ "$request",
28
+ "$serialized"
29
+ ].forEach((key) => {
30
+ from[key] && Object.defineProperty(to, key, {
31
+ get() {
32
+ return from[key];
33
+ },
34
+ enumerable: false
35
+ });
36
+ });
106
37
  };
107
38
 
108
- // utils/camelcase-keys.ts
109
- var camelcaseKeys = (obj) => {
110
- if (Array.isArray(obj)) {
111
- return obj.map((x) => camelcaseKeys(x));
112
- }
113
- if (isPlainObject(obj)) {
114
- return Object.keys(obj).reduce((result, key) => {
115
- const nextKey = isMongoId(key) ? key : camelcase(key);
116
- result[nextKey] = camelcaseKeys(obj[key]);
117
- return result;
118
- }, {});
119
- }
120
- return obj;
39
+ //#endregion
40
+ //#region utils/camelcase-keys.ts
41
+ /**
42
+ * A simple camelCase function that only handles strings, but not handling symbol, date, or other complex case.
43
+ * If you need to handle more complex cases, please use camelcase-keys package.
44
+ */
45
+ const camelcaseKeys = (obj) => {
46
+ if (Array.isArray(obj)) return obj.map((x) => camelcaseKeys(x));
47
+ if (isPlainObject(obj)) return Object.keys(obj).reduce((result, key) => {
48
+ const nextKey = isMongoId(key) ? key : camelcase(key);
49
+ result[nextKey] = camelcaseKeys(obj[key]);
50
+ return result;
51
+ }, {});
52
+ return obj;
121
53
  };
122
54
  function camelcase(str) {
123
- return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
124
- return $1.toUpperCase().replace("-", "").replace("_", "");
125
- });
55
+ return str.replace(/^_+/, "").replaceAll(/([_-][a-z])/gi, ($1) => {
56
+ return $1.toUpperCase().replace("-", "").replace("_", "");
57
+ });
126
58
  }
127
- var isMongoId = (id) => id.length === 24 && /^[\dA-F]{24}$/i.test(id);
59
+ const isMongoId = (id) => id.length === 24 && /^[\dA-F]{24}$/i.test(id);
128
60
 
129
- // utils/path.ts
130
- var resolveFullPath = (endpoint, path) => {
131
- if (!path.startsWith("/")) {
132
- path = `/${path}`;
133
- }
134
- return `${endpoint}${path}`;
61
+ //#endregion
62
+ //#region utils/path.ts
63
+ const resolveFullPath = (endpoint, path) => {
64
+ if (!path.startsWith("/")) path = `/${path}`;
65
+ return `${endpoint}${path}`;
135
66
  };
136
67
 
137
- // utils/auto-bind.ts
138
- var getAllProperties = (object) => {
139
- const properties = /* @__PURE__ */ new Set();
140
- do {
141
- for (const key of Reflect.ownKeys(object)) {
142
- properties.add([object, key]);
143
- }
144
- } while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
145
- return properties;
68
+ //#endregion
69
+ //#region utils/auto-bind.ts
70
+ const getAllProperties = (object) => {
71
+ const properties = /* @__PURE__ */ new Set();
72
+ do
73
+ for (const key of Reflect.ownKeys(object)) properties.add([object, key]);
74
+ while ((object = Reflect.getPrototypeOf(object)) && object !== Object.prototype);
75
+ return properties;
146
76
  };
147
77
  function autoBind(self, { include, exclude } = {}) {
148
- const filter = (key) => {
149
- const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
150
- if (include) {
151
- return include.some(match);
152
- }
153
- if (exclude) {
154
- return !exclude.some(match);
155
- }
156
- return true;
157
- };
158
- for (const [object, key] of getAllProperties(self.constructor.prototype)) {
159
- if (key === "constructor" || !filter(key)) {
160
- continue;
161
- }
162
- const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
163
- if (descriptor && typeof descriptor.value === "function") {
164
- self[key] = self[key].bind(self);
165
- }
166
- }
167
- return self;
78
+ const filter = (key) => {
79
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
80
+ if (include) return include.some(match);
81
+ if (exclude) return !exclude.some(match);
82
+ return true;
83
+ };
84
+ for (const [object, key] of getAllProperties(self.constructor.prototype)) {
85
+ if (key === "constructor" || !filter(key)) continue;
86
+ const descriptor = Reflect.getOwnPropertyDescriptor(object, key);
87
+ if (descriptor && typeof descriptor.value === "function") self[key] = self[key].bind(self);
88
+ }
89
+ return self;
168
90
  }
169
91
 
170
- // controllers/ack.ts
92
+ //#endregion
93
+ //#region controllers/ack.ts
94
+ /**
95
+ * @support core >= 4.4.0
96
+ */
171
97
  var AckController = class {
172
- constructor(client) {
173
- this.client = client;
174
- this.base = "ack";
175
- this.name = "ack";
176
- autoBind(this);
177
- }
178
- get proxy() {
179
- return this.client.proxy(this.base);
180
- }
181
- read(type, id) {
182
- return this.proxy.post({
183
- data: {
184
- type: "read",
185
- payload: {
186
- type,
187
- id
188
- }
189
- }
190
- });
191
- }
98
+ constructor(client) {
99
+ this.client = client;
100
+ this.base = "ack";
101
+ this.name = "ack";
102
+ autoBind(this);
103
+ }
104
+ get proxy() {
105
+ return this.client.proxy(this.base);
106
+ }
107
+ read(type, id) {
108
+ return this.proxy.post({ data: {
109
+ type: "read",
110
+ payload: {
111
+ type,
112
+ id
113
+ }
114
+ } });
115
+ }
192
116
  };
193
117
 
194
- // controllers/activity.ts
118
+ //#endregion
119
+ //#region controllers/activity.ts
120
+ /**
121
+ * @support core >= 4.3.0
122
+ */
195
123
  var ActivityController = class {
196
- constructor(client) {
197
- this.client = client;
198
- this.base = "activity";
199
- this.name = "activity";
200
- autoBind(this);
201
- }
202
- get proxy() {
203
- return this.client.proxy(this.base);
204
- }
205
- likeIt(type, id) {
206
- return this.proxy.like.post({
207
- data: {
208
- type: type.toLowerCase(),
209
- id
210
- }
211
- });
212
- }
213
- /**
214
- *
215
- * @support core >= 5.0.0
216
- */
217
- getPresence(roomName) {
218
- return this.proxy.presence.get({
219
- params: {
220
- room_name: roomName
221
- }
222
- });
223
- }
224
- /**
225
- *
226
- * @support core >= 5.0.0
227
- */
228
- updatePresence({
229
- identity,
230
- position,
231
- roomName,
232
- sid,
233
- ts,
234
- displayName,
235
- readerId
236
- }) {
237
- return this.proxy.presence.update.post({
238
- data: {
239
- identity,
240
- position,
241
- ts: ts || Date.now(),
242
- roomName,
243
- sid,
244
- readerId,
245
- displayName
246
- }
247
- });
248
- }
249
- async getRoomsInfo() {
250
- return this.proxy.rooms.get();
251
- }
252
- async getRecentActivities() {
253
- return this.proxy.recent.get();
254
- }
255
- async getLastYearPublication() {
256
- return this.proxy(`last-year`).publication.get();
257
- }
124
+ constructor(client) {
125
+ this.client = client;
126
+ this.base = "activity";
127
+ this.name = "activity";
128
+ autoBind(this);
129
+ }
130
+ get proxy() {
131
+ return this.client.proxy(this.base);
132
+ }
133
+ likeIt(type, id) {
134
+ return this.proxy.like.post({ data: {
135
+ type: type.toLowerCase(),
136
+ id
137
+ } });
138
+ }
139
+ /**
140
+ *
141
+ * @support core >= 5.0.0
142
+ */
143
+ getPresence(roomName) {
144
+ return this.proxy.presence.get({ params: { room_name: roomName } });
145
+ }
146
+ /**
147
+ *
148
+ * @support core >= 5.0.0
149
+ */
150
+ updatePresence({ identity, position, roomName, sid, ts, displayName, readerId }) {
151
+ return this.proxy.presence.update.post({ data: {
152
+ identity,
153
+ position,
154
+ ts: ts || Date.now(),
155
+ roomName,
156
+ sid,
157
+ readerId,
158
+ displayName
159
+ } });
160
+ }
161
+ async getRoomsInfo() {
162
+ return this.proxy.rooms.get();
163
+ }
164
+ async getRecentActivities() {
165
+ return this.proxy.recent.get();
166
+ }
167
+ async getLastYearPublication() {
168
+ return this.proxy(`last-year`).publication.get();
169
+ }
258
170
  };
259
171
 
260
- // controllers/aggregate.ts
172
+ //#endregion
173
+ //#region controllers/aggregate.ts
261
174
  var AggregateController = class {
262
- constructor(client) {
263
- this.client = client;
264
- this.base = "aggregate";
265
- this.name = "aggregate";
266
- autoBind(this);
267
- }
268
- get proxy() {
269
- return this.client.proxy(this.base);
270
- }
271
- /**
272
- * 获取聚合数据
273
- */
274
- getAggregateData(theme) {
275
- return this.proxy.get({
276
- params: {
277
- theme
278
- }
279
- });
280
- }
281
- /**
282
- * 获取最新发布的内容
283
- */
284
- getTop(size = 5) {
285
- return this.proxy.top.get({ params: { size } });
286
- }
287
- getTimeline(options) {
288
- const { sort, type, year } = options || {};
289
- return this.proxy.timeline.get({
290
- params: {
291
- sort: sort && sortOrderToNumber(sort),
292
- type,
293
- year
294
- }
295
- });
296
- }
297
- /**
298
- * 获取聚合数据统计
299
- */
300
- getStat() {
301
- return this.proxy.stat.get();
302
- }
175
+ constructor(client) {
176
+ this.client = client;
177
+ this.base = "aggregate";
178
+ this.name = "aggregate";
179
+ autoBind(this);
180
+ }
181
+ get proxy() {
182
+ return this.client.proxy(this.base);
183
+ }
184
+ /**
185
+ * 获取聚合数据
186
+ */
187
+ getAggregateData(theme) {
188
+ return this.proxy.get({ params: { theme } });
189
+ }
190
+ /**
191
+ * 获取最新发布的内容
192
+ */
193
+ getTop(size = 5) {
194
+ return this.proxy.top.get({ params: { size } });
195
+ }
196
+ getTimeline(options) {
197
+ const { sort, type, year } = options || {};
198
+ return this.proxy.timeline.get({ params: {
199
+ sort: sort && sortOrderToNumber(sort),
200
+ type,
201
+ year
202
+ } });
203
+ }
204
+ /**
205
+ * 获取聚合数据统计
206
+ */
207
+ getStat() {
208
+ return this.proxy.stat.get();
209
+ }
303
210
  };
304
211
 
305
- // controllers/ai.ts
212
+ //#endregion
213
+ //#region controllers/ai.ts
214
+ /**
215
+ * @support core >= 5.6.0
216
+ */
306
217
  var AIController = class {
307
- constructor(client) {
308
- this.client = client;
309
- this.base = "ai";
310
- this.name = "ai";
311
- autoBind(this);
312
- }
313
- get proxy() {
314
- return this.client.proxy(this.base);
315
- }
316
- async getSummary({
317
- articleId,
318
- lang = "zh-CN",
319
- onlyDb
320
- }) {
321
- return this.proxy.summaries.article(articleId).get({
322
- params: {
323
- lang,
324
- onlyDb
325
- }
326
- });
327
- }
328
- async generateSummary(articleId, lang = "zh-CN", token = "") {
329
- return this.proxy.summaries.generate.post({
330
- params: {
331
- token
332
- },
333
- data: {
334
- lang,
335
- refId: articleId
336
- }
337
- });
338
- }
339
- /**
340
- * Core >= 8.3.0
341
- * @param articleId
342
- */
343
- async getDeepReading(articleId) {
344
- return this.proxy("deep-readings").article(articleId).get();
345
- }
218
+ constructor(client) {
219
+ this.client = client;
220
+ this.base = "ai";
221
+ this.name = "ai";
222
+ autoBind(this);
223
+ }
224
+ get proxy() {
225
+ return this.client.proxy(this.base);
226
+ }
227
+ async getSummary({ articleId, lang = "zh-CN", onlyDb }) {
228
+ return this.proxy.summaries.article(articleId).get({ params: {
229
+ lang,
230
+ onlyDb
231
+ } });
232
+ }
233
+ async generateSummary(articleId, lang = "zh-CN", token = "") {
234
+ return this.proxy.summaries.generate.post({
235
+ params: { token },
236
+ data: {
237
+ lang,
238
+ refId: articleId
239
+ }
240
+ });
241
+ }
242
+ /**
243
+ * Core >= 8.3.0
244
+ * @param articleId
245
+ */
246
+ async getDeepReading(articleId) {
247
+ return this.proxy("deep-readings").article(articleId).get();
248
+ }
346
249
  };
347
250
 
348
- // core/error.ts
251
+ //#endregion
252
+ //#region core/error.ts
349
253
  var RequestError = class extends Error {
350
- constructor(message, status, path, raw) {
351
- super(message);
352
- this.status = status;
353
- this.path = path;
354
- this.raw = raw;
355
- }
254
+ constructor(message, status, path, raw) {
255
+ super(message);
256
+ this.status = status;
257
+ this.path = path;
258
+ this.raw = raw;
259
+ }
356
260
  };
357
261
 
358
- // models/category.ts
359
- var CategoryType = /* @__PURE__ */ ((CategoryType2) => {
360
- CategoryType2[CategoryType2["Category"] = 0] = "Category";
361
- CategoryType2[CategoryType2["Tag"] = 1] = "Tag";
362
- return CategoryType2;
363
- })(CategoryType || {});
262
+ //#endregion
263
+ //#region models/category.ts
264
+ let CategoryType = /* @__PURE__ */ function(CategoryType$1) {
265
+ CategoryType$1[CategoryType$1["Category"] = 0] = "Category";
266
+ CategoryType$1[CategoryType$1["Tag"] = 1] = "Tag";
267
+ return CategoryType$1;
268
+ }({});
364
269
 
365
- // controllers/category.ts
270
+ //#endregion
271
+ //#region controllers/category.ts
366
272
  var CategoryController = class {
367
- constructor(client) {
368
- this.client = client;
369
- this.name = "category";
370
- this.base = "categories";
371
- autoBind(this);
372
- }
373
- get proxy() {
374
- return this.client.proxy(this.base);
375
- }
376
- getAllCategories() {
377
- return this.proxy.get({
378
- params: {
379
- type: 0 /* Category */
380
- }
381
- });
382
- }
383
- getAllTags() {
384
- return this.proxy.get({
385
- params: {
386
- type: 1 /* Tag */
387
- }
388
- });
389
- }
390
- async getCategoryDetail(ids) {
391
- if (typeof ids === "string") {
392
- const data = await this.proxy.get({
393
- params: {
394
- ids
395
- }
396
- });
397
- const result = Object.values(data.entries)[0];
398
- attachRawFromOneToAnthor(data, result);
399
- return result;
400
- } else if (Array.isArray(ids)) {
401
- const data = await this.proxy.get({
402
- params: {
403
- ids: ids.join(",")
404
- }
405
- });
406
- const entries = data?.entries;
407
- if (!entries) {
408
- throw new RequestError(
409
- "data structure error",
410
- 500,
411
- data.$request.path,
412
- data
413
- );
414
- }
415
- const map = new Map(
416
- Object.entries(entries).map(([id, value]) => [id.toLowerCase(), value])
417
- );
418
- attachRawFromOneToAnthor(data, map);
419
- return map;
420
- }
421
- }
422
- async getCategoryByIdOrSlug(idOrSlug) {
423
- const res = await this.proxy(idOrSlug).get();
424
- return destructureData(res);
425
- }
426
- async getTagByName(name) {
427
- const res = await this.proxy(name).get({
428
- params: {
429
- tag: 1
430
- }
431
- });
432
- return res;
433
- }
273
+ constructor(client) {
274
+ this.client = client;
275
+ this.name = "category";
276
+ this.base = "categories";
277
+ autoBind(this);
278
+ }
279
+ get proxy() {
280
+ return this.client.proxy(this.base);
281
+ }
282
+ getAllCategories() {
283
+ return this.proxy.get({ params: { type: CategoryType.Category } });
284
+ }
285
+ getAllTags() {
286
+ return this.proxy.get({ params: { type: CategoryType.Tag } });
287
+ }
288
+ async getCategoryDetail(ids) {
289
+ if (typeof ids === "string") {
290
+ const data = await this.proxy.get({ params: { ids } });
291
+ const result = Object.values(data.entries)[0];
292
+ attachRawFromOneToAnthor(data, result);
293
+ return result;
294
+ } else if (Array.isArray(ids)) {
295
+ const data = await this.proxy.get({ params: { ids: ids.join(",") } });
296
+ const entries = data?.entries;
297
+ if (!entries) throw new RequestError("data structure error", 500, data.$request.path, data);
298
+ const map = new Map(Object.entries(entries).map(([id, value]) => [id.toLowerCase(), value]));
299
+ attachRawFromOneToAnthor(data, map);
300
+ return map;
301
+ }
302
+ }
303
+ async getCategoryByIdOrSlug(idOrSlug) {
304
+ return destructureData(await this.proxy(idOrSlug).get());
305
+ }
306
+ async getTagByName(name) {
307
+ return await this.proxy(name).get({ params: { tag: 1 } });
308
+ }
434
309
  };
435
310
 
436
- // controllers/comment.ts
311
+ //#endregion
312
+ //#region controllers/comment.ts
437
313
  var CommentController = class {
438
- constructor(client) {
439
- this.client = client;
440
- this.base = "comments";
441
- this.name = "comment";
442
- autoBind(this);
443
- }
444
- get proxy() {
445
- return this.client.proxy(this.base);
446
- }
447
- /**
448
- * 根据 comment id 获取评论,包括子评论
449
- */
450
- getById(id) {
451
- return this.proxy(id).get();
452
- }
453
- /**
454
- * 获取文章的评论列表
455
- * @param refId 文章 Id
456
- */
457
- getByRefId(refId, pagination = {}) {
458
- const { page, size } = pagination;
459
- return this.proxy.ref(refId).get({
460
- params: { page: page || 1, size: size || 10 }
461
- });
462
- }
463
- /**
464
- * 评论
465
- */
466
- comment(refId, data) {
467
- return this.proxy(refId).post({
468
- data
469
- });
470
- }
471
- /**
472
- * 回复评论
473
- */
474
- reply(commentId, data) {
475
- return this.proxy.reply(commentId).post({
476
- data
477
- });
478
- }
314
+ constructor(client) {
315
+ this.client = client;
316
+ this.base = "comments";
317
+ this.name = "comment";
318
+ autoBind(this);
319
+ }
320
+ get proxy() {
321
+ return this.client.proxy(this.base);
322
+ }
323
+ /**
324
+ * 根据 comment id 获取评论,包括子评论
325
+ */
326
+ getById(id) {
327
+ return this.proxy(id).get();
328
+ }
329
+ /**
330
+ * 获取文章的评论列表
331
+ * @param refId 文章 Id
332
+ */
333
+ getByRefId(refId, pagination = {}) {
334
+ const { page, size } = pagination;
335
+ return this.proxy.ref(refId).get({ params: {
336
+ page: page || 1,
337
+ size: size || 10
338
+ } });
339
+ }
340
+ /**
341
+ * 评论
342
+ */
343
+ comment(refId, data) {
344
+ return this.proxy(refId).post({ data });
345
+ }
346
+ /**
347
+ * 回复评论
348
+ */
349
+ reply(commentId, data) {
350
+ return this.proxy.reply(commentId).post({ data });
351
+ }
479
352
  };
480
353
 
481
- // controllers/base.ts
354
+ //#endregion
355
+ //#region controllers/base.ts
482
356
  var BaseCrudController = class {
483
- constructor(client) {
484
- this.client = client;
485
- autoBind(this);
486
- }
487
- get proxy() {
488
- return this.client.proxy(this.base);
489
- }
490
- getById(id) {
491
- return this.proxy(id).get();
492
- }
493
- getAll() {
494
- return this.proxy.all.get();
495
- }
496
- /**
497
- * 带分页的查询
498
- * @param page
499
- * @param perPage
500
- */
501
- getAllPaginated(page, perPage, sortOption) {
502
- return this.proxy.get({
503
- params: { page, size: perPage, ...sortOption }
504
- });
505
- }
357
+ constructor(client) {
358
+ this.client = client;
359
+ autoBind(this);
360
+ }
361
+ get proxy() {
362
+ return this.client.proxy(this.base);
363
+ }
364
+ getById(id) {
365
+ return this.proxy(id).get();
366
+ }
367
+ getAll() {
368
+ return this.proxy.all.get();
369
+ }
370
+ /**
371
+ * 带分页的查询
372
+ * @param page
373
+ * @param perPage
374
+ */
375
+ getAllPaginated(page, perPage, sortOption) {
376
+ return this.proxy.get({ params: {
377
+ page,
378
+ size: perPage,
379
+ ...sortOption
380
+ } });
381
+ }
506
382
  };
507
383
 
508
- // controllers/link.ts
384
+ //#endregion
385
+ //#region controllers/link.ts
509
386
  var LinkController = class extends BaseCrudController {
510
- constructor(client) {
511
- super(client);
512
- this.client = client;
513
- this.name = ["link", "friend"];
514
- this.base = "links";
515
- autoBind(this);
516
- }
517
- // 是否可以申请友链
518
- async canApplyLink() {
519
- const { can } = await this.proxy.audit.get();
520
- return can;
521
- }
522
- // 申请友链
523
- async applyLink(data) {
524
- return await this.proxy.audit.post({ data });
525
- }
387
+ constructor(client) {
388
+ super(client);
389
+ this.client = client;
390
+ this.name = ["link", "friend"];
391
+ this.base = "links";
392
+ autoBind(this);
393
+ }
394
+ async canApplyLink() {
395
+ const { can } = await this.proxy.audit.get();
396
+ return can;
397
+ }
398
+ async applyLink(data) {
399
+ return await this.proxy.audit.post({ data });
400
+ }
526
401
  };
527
402
 
528
- // controllers/note.ts
403
+ //#endregion
404
+ //#region controllers/note.ts
529
405
  var NoteController = class {
530
- constructor(client) {
531
- this.client = client;
532
- this.base = "notes";
533
- this.name = "note";
534
- autoBind(this);
535
- }
536
- get proxy() {
537
- return this.client.proxy(this.base);
538
- }
539
- /**
540
- * 最新日记
541
- */
542
- getLatest() {
543
- return this.proxy.latest.get();
544
- }
545
- getNoteById(...rest) {
546
- const [id, password = void 0, singleResult = false] = rest;
547
- if (typeof id === "number") {
548
- return this.proxy.nid(id.toString()).get({
549
- params: { password, single: singleResult ? "1" : void 0 }
550
- });
551
- } else {
552
- return this.proxy(id).get();
553
- }
554
- }
555
- /**
556
- * 日记列表分页
557
- */
558
- getList(page = 1, perPage = 10, options = {}) {
559
- const { select, sortBy, sortOrder, year } = options;
560
- return this.proxy.get({
561
- params: {
562
- page,
563
- size: perPage,
564
- select: select?.join(" "),
565
- sortBy,
566
- sortOrder,
567
- year
568
- }
569
- });
570
- }
571
- /**
572
- * 获取当前日记的上下各 n / 2 篇日记
573
- */
574
- getMiddleList(id, size = 5) {
575
- return this.proxy.list(id).get({
576
- params: { size }
577
- });
578
- }
579
- /**
580
- * 获取专栏内的所有日记
581
- */
582
- getNoteByTopicId(topicId, page = 1, size = 10, sortOptions = {}) {
583
- return this.proxy.topics(topicId).get({
584
- params: { page, size, ...sortOptions }
585
- });
586
- }
406
+ constructor(client) {
407
+ this.client = client;
408
+ this.base = "notes";
409
+ this.name = "note";
410
+ autoBind(this);
411
+ }
412
+ get proxy() {
413
+ return this.client.proxy(this.base);
414
+ }
415
+ /**
416
+ * 最新日记
417
+ */
418
+ getLatest() {
419
+ return this.proxy.latest.get();
420
+ }
421
+ getNoteById(...rest) {
422
+ const [id, password = void 0, singleResult = false] = rest;
423
+ if (typeof id === "number") return this.proxy.nid(id.toString()).get({ params: {
424
+ password,
425
+ single: singleResult ? "1" : void 0
426
+ } });
427
+ else return this.proxy(id).get();
428
+ }
429
+ /**
430
+ * 日记列表分页
431
+ */
432
+ getList(page = 1, perPage = 10, options = {}) {
433
+ const { select, sortBy, sortOrder, year } = options;
434
+ return this.proxy.get({ params: {
435
+ page,
436
+ size: perPage,
437
+ select: select?.join(" "),
438
+ sortBy,
439
+ sortOrder,
440
+ year
441
+ } });
442
+ }
443
+ /**
444
+ * 获取当前日记的上下各 n / 2 篇日记
445
+ */
446
+ getMiddleList(id, size = 5) {
447
+ return this.proxy.list(id).get({ params: { size } });
448
+ }
449
+ /**
450
+ * 获取专栏内的所有日记
451
+ */
452
+ getNoteByTopicId(topicId, page = 1, size = 10, sortOptions = {}) {
453
+ return this.proxy.topics(topicId).get({ params: {
454
+ page,
455
+ size,
456
+ ...sortOptions
457
+ } });
458
+ }
587
459
  };
588
460
 
589
- // controllers/page.ts
461
+ //#endregion
462
+ //#region controllers/page.ts
590
463
  var PageController = class {
591
- constructor(client) {
592
- this.client = client;
593
- this.base = "pages";
594
- this.name = "page";
595
- autoBind(this);
596
- }
597
- get proxy() {
598
- return this.client.proxy(this.base);
599
- }
600
- /**
601
- * 页面列表
602
- */
603
- getList(page = 1, perPage = 10, options = {}) {
604
- const { select, sortBy, sortOrder } = options;
605
- return this.proxy.get({
606
- params: {
607
- page,
608
- size: perPage,
609
- select: select?.join(" "),
610
- sortBy,
611
- sortOrder
612
- }
613
- });
614
- }
615
- /**
616
- * 页面详情
617
- */
618
- getById(id) {
619
- return this.proxy(id).get();
620
- }
621
- /**
622
- * 根据路径获取页面
623
- * @param slug 路径
624
- * @returns
625
- */
626
- getBySlug(slug) {
627
- return this.proxy.slug(slug).get({});
628
- }
464
+ constructor(client) {
465
+ this.client = client;
466
+ this.base = "pages";
467
+ this.name = "page";
468
+ autoBind(this);
469
+ }
470
+ get proxy() {
471
+ return this.client.proxy(this.base);
472
+ }
473
+ /**
474
+ * 页面列表
475
+ */
476
+ getList(page = 1, perPage = 10, options = {}) {
477
+ const { select, sortBy, sortOrder } = options;
478
+ return this.proxy.get({ params: {
479
+ page,
480
+ size: perPage,
481
+ select: select?.join(" "),
482
+ sortBy,
483
+ sortOrder
484
+ } });
485
+ }
486
+ /**
487
+ * 页面详情
488
+ */
489
+ getById(id) {
490
+ return this.proxy(id).get();
491
+ }
492
+ /**
493
+ * 根据路径获取页面
494
+ * @param slug 路径
495
+ * @returns
496
+ */
497
+ getBySlug(slug) {
498
+ return this.proxy.slug(slug).get({});
499
+ }
629
500
  };
630
501
 
631
- // controllers/post.ts
502
+ //#endregion
503
+ //#region controllers/post.ts
632
504
  var PostController = class {
633
- constructor(client) {
634
- this.client = client;
635
- this.base = "posts";
636
- this.name = "post";
637
- autoBind(this);
638
- }
639
- get proxy() {
640
- return this.client.proxy(this.base);
641
- }
642
- /**
643
- * 获取文章列表分页
644
- * @param page
645
- * @param perPage
646
- * @returns
647
- */
648
- getList(page = 1, perPage = 10, options = {}) {
649
- const { select, sortBy, sortOrder, year, truncate } = options;
650
- return this.proxy.get({
651
- params: {
652
- page,
653
- size: perPage,
654
- select: select?.join(" "),
655
- sortBy,
656
- sortOrder,
657
- year,
658
- truncate
659
- }
660
- });
661
- }
662
- getPost(idOrCategoryName, slug) {
663
- if (arguments.length == 1) {
664
- return this.proxy(idOrCategoryName).get();
665
- } else {
666
- return this.proxy(idOrCategoryName)(slug).get();
667
- }
668
- }
669
- /**
670
- * 获取最新的文章
671
- */
672
- getLatest() {
673
- return this.proxy.latest.get();
674
- }
675
- getFullUrl(slug) {
676
- return this.proxy("get-url")(slug).get();
677
- }
505
+ constructor(client) {
506
+ this.client = client;
507
+ this.base = "posts";
508
+ this.name = "post";
509
+ autoBind(this);
510
+ }
511
+ get proxy() {
512
+ return this.client.proxy(this.base);
513
+ }
514
+ /**
515
+ * 获取文章列表分页
516
+ * @param page
517
+ * @param perPage
518
+ * @returns
519
+ */
520
+ getList(page = 1, perPage = 10, options = {}) {
521
+ const { select, sortBy, sortOrder, year, truncate } = options;
522
+ return this.proxy.get({ params: {
523
+ page,
524
+ size: perPage,
525
+ select: select?.join(" "),
526
+ sortBy,
527
+ sortOrder,
528
+ year,
529
+ truncate
530
+ } });
531
+ }
532
+ getPost(idOrCategoryName, slug) {
533
+ if (arguments.length == 1) return this.proxy(idOrCategoryName).get();
534
+ else return this.proxy(idOrCategoryName)(slug).get();
535
+ }
536
+ /**
537
+ * 获取最新的文章
538
+ */
539
+ getLatest() {
540
+ return this.proxy.latest.get();
541
+ }
542
+ getFullUrl(slug) {
543
+ return this.proxy("get-url")(slug).get();
544
+ }
678
545
  };
679
546
 
680
- // controllers/project.ts
547
+ //#endregion
548
+ //#region controllers/project.ts
681
549
  var ProjectController = class extends BaseCrudController {
682
- constructor(client) {
683
- super(client);
684
- this.client = client;
685
- this.base = "projects";
686
- this.name = "project";
687
- autoBind(this);
688
- }
550
+ constructor(client) {
551
+ super(client);
552
+ this.client = client;
553
+ this.base = "projects";
554
+ this.name = "project";
555
+ autoBind(this);
556
+ }
689
557
  };
690
558
 
691
- // controllers/recently.ts
692
- var RecentlyAttitudeResultEnum = /* @__PURE__ */ ((RecentlyAttitudeResultEnum2) => {
693
- RecentlyAttitudeResultEnum2[RecentlyAttitudeResultEnum2["Inc"] = 1] = "Inc";
694
- RecentlyAttitudeResultEnum2[RecentlyAttitudeResultEnum2["Dec"] = -1] = "Dec";
695
- return RecentlyAttitudeResultEnum2;
696
- })(RecentlyAttitudeResultEnum || {});
697
- var RecentlyAttitudeEnum = /* @__PURE__ */ ((RecentlyAttitudeEnum2) => {
698
- RecentlyAttitudeEnum2[RecentlyAttitudeEnum2["Up"] = 0] = "Up";
699
- RecentlyAttitudeEnum2[RecentlyAttitudeEnum2["Down"] = 1] = "Down";
700
- return RecentlyAttitudeEnum2;
701
- })(RecentlyAttitudeEnum || {});
559
+ //#endregion
560
+ //#region controllers/recently.ts
561
+ let RecentlyAttitudeResultEnum = /* @__PURE__ */ function(RecentlyAttitudeResultEnum$1) {
562
+ RecentlyAttitudeResultEnum$1[RecentlyAttitudeResultEnum$1["Inc"] = 1] = "Inc";
563
+ RecentlyAttitudeResultEnum$1[RecentlyAttitudeResultEnum$1["Dec"] = -1] = "Dec";
564
+ return RecentlyAttitudeResultEnum$1;
565
+ }({});
566
+ let RecentlyAttitudeEnum = /* @__PURE__ */ function(RecentlyAttitudeEnum$1) {
567
+ RecentlyAttitudeEnum$1[RecentlyAttitudeEnum$1["Up"] = 0] = "Up";
568
+ RecentlyAttitudeEnum$1[RecentlyAttitudeEnum$1["Down"] = 1] = "Down";
569
+ return RecentlyAttitudeEnum$1;
570
+ }({});
702
571
  var RecentlyController = class {
703
- constructor(client) {
704
- this.client = client;
705
- this.base = "recently";
706
- this.name = ["recently", "shorthand"];
707
- autoBind(this);
708
- }
709
- get proxy() {
710
- return this.client.proxy(this.base);
711
- }
712
- /**
713
- * 获取最新一条
714
- */
715
- getLatestOne() {
716
- return this.proxy.latest.get();
717
- }
718
- getAll() {
719
- return this.proxy.all.get();
720
- }
721
- getList({
722
- before,
723
- after,
724
- size
725
- } = {}) {
726
- return this.proxy.get({
727
- params: {
728
- before,
729
- after,
730
- size
731
- }
732
- });
733
- }
734
- getById(id) {
735
- return this.proxy(id).get();
736
- }
737
- /** 表态:点赞,点踩 */
738
- attitude(id, attitude) {
739
- return this.proxy.attitude(id).get({
740
- params: {
741
- attitude
742
- }
743
- });
744
- }
572
+ constructor(client) {
573
+ this.client = client;
574
+ this.base = "recently";
575
+ this.name = ["recently", "shorthand"];
576
+ autoBind(this);
577
+ }
578
+ get proxy() {
579
+ return this.client.proxy(this.base);
580
+ }
581
+ /**
582
+ * 获取最新一条
583
+ */
584
+ getLatestOne() {
585
+ return this.proxy.latest.get();
586
+ }
587
+ getAll() {
588
+ return this.proxy.all.get();
589
+ }
590
+ getList({ before, after, size } = {}) {
591
+ return this.proxy.get({ params: {
592
+ before,
593
+ after,
594
+ size
595
+ } });
596
+ }
597
+ getById(id) {
598
+ return this.proxy(id).get();
599
+ }
600
+ /** 表态:点赞,点踩 */
601
+ attitude(id, attitude) {
602
+ return this.proxy.attitude(id).get({ params: { attitude } });
603
+ }
745
604
  };
746
605
 
747
- // controllers/say.ts
606
+ //#endregion
607
+ //#region controllers/say.ts
748
608
  var SayController = class extends BaseCrudController {
749
- constructor(client) {
750
- super(client);
751
- this.client = client;
752
- this.base = "says";
753
- this.name = "say";
754
- autoBind(this);
755
- }
756
- get proxy() {
757
- return this.client.proxy(this.base);
758
- }
759
- /**
760
- * 获取随机一条
761
- */
762
- getRandom() {
763
- return this.proxy.random.get();
764
- }
609
+ constructor(client) {
610
+ super(client);
611
+ this.client = client;
612
+ this.base = "says";
613
+ this.name = "say";
614
+ autoBind(this);
615
+ }
616
+ get proxy() {
617
+ return this.client.proxy(this.base);
618
+ }
619
+ /**
620
+ * 获取随机一条
621
+ */
622
+ getRandom() {
623
+ return this.proxy.random.get();
624
+ }
765
625
  };
766
626
 
767
- // controllers/search.ts
627
+ //#endregion
628
+ //#region controllers/search.ts
768
629
  var SearchController = class {
769
- constructor(client) {
770
- this.client = client;
771
- this.base = "search";
772
- this.name = "search";
773
- autoBind(this);
774
- }
775
- get proxy() {
776
- return this.client.proxy(this.base);
777
- }
778
- search(type, keyword, options = {}) {
779
- return this.proxy(type).get({
780
- params: { keyword, ...options }
781
- });
782
- }
783
- /**
784
- * 从 algolya 搜索
785
- * https://www.algolia.com/doc/api-reference/api-methods/search/
786
- * @param keyword
787
- * @param options
788
- * @returns
789
- */
790
- searchByAlgolia(keyword, options) {
791
- return this.proxy("algolia").get({ params: { keyword, ...options } });
792
- }
630
+ constructor(client) {
631
+ this.client = client;
632
+ this.base = "search";
633
+ this.name = "search";
634
+ autoBind(this);
635
+ }
636
+ get proxy() {
637
+ return this.client.proxy(this.base);
638
+ }
639
+ search(type, keyword, options = {}) {
640
+ return this.proxy(type).get({ params: {
641
+ keyword,
642
+ ...options
643
+ } });
644
+ }
645
+ /**
646
+ * 从 algolya 搜索
647
+ * https://www.algolia.com/doc/api-reference/api-methods/search/
648
+ * @param keyword
649
+ * @param options
650
+ * @returns
651
+ */
652
+ searchByAlgolia(keyword, options) {
653
+ return this.proxy("algolia").get({ params: {
654
+ keyword,
655
+ ...options
656
+ } });
657
+ }
793
658
  };
794
659
 
795
- // controllers/severless.ts
660
+ //#endregion
661
+ //#region controllers/severless.ts
796
662
  var ServerlessController = class {
797
- constructor(client) {
798
- this.client = client;
799
- this.base = "serverless";
800
- this.name = "serverless";
801
- autoBind(this);
802
- }
803
- get proxy() {
804
- return this.client.proxy(this.base);
805
- }
806
- getByReferenceAndName(reference, name) {
807
- return this.proxy(reference)(name).get();
808
- }
663
+ constructor(client) {
664
+ this.client = client;
665
+ this.base = "serverless";
666
+ this.name = "serverless";
667
+ autoBind(this);
668
+ }
669
+ get proxy() {
670
+ return this.client.proxy(this.base);
671
+ }
672
+ getByReferenceAndName(reference, name) {
673
+ return this.proxy(reference)(name).get();
674
+ }
809
675
  };
810
676
 
811
- // controllers/snippet.ts
677
+ //#endregion
678
+ //#region controllers/snippet.ts
812
679
  var SnippetController = class {
813
- constructor(client) {
814
- this.client = client;
815
- this.base = "snippets";
816
- this.name = "snippet";
817
- autoBind(this);
818
- }
819
- get proxy() {
820
- return this.client.proxy(this.base);
821
- }
822
- // getById(id: string) {
823
- // return this.proxy(id).get<Omit<SnippetModel, 'data'>>()
824
- // }
825
- getByReferenceAndName(reference, name) {
826
- return this.proxy(reference)(name).get();
827
- }
680
+ constructor(client) {
681
+ this.client = client;
682
+ this.base = "snippets";
683
+ this.name = "snippet";
684
+ autoBind(this);
685
+ }
686
+ get proxy() {
687
+ return this.client.proxy(this.base);
688
+ }
689
+ getByReferenceAndName(reference, name) {
690
+ return this.proxy(reference)(name).get();
691
+ }
828
692
  };
829
693
 
830
- // controllers/subscribe.ts
694
+ //#endregion
695
+ //#region controllers/subscribe.ts
831
696
  var SubscribeController = class {
832
- constructor(client) {
833
- this.client = client;
834
- this.base = "subscribe";
835
- this.name = "subscribe";
836
- autoBind(this);
837
- }
838
- get proxy() {
839
- return this.client.proxy(this.base);
840
- }
841
- /**
842
- * 检查开启状态
843
- */
844
- check() {
845
- return this.proxy.status.get();
846
- }
847
- subscribe(email, types) {
848
- return this.proxy.post({
849
- data: {
850
- email,
851
- types
852
- }
853
- });
854
- }
855
- unsubscribe(email, cancelToken) {
856
- return this.proxy.unsubscribe.get({
857
- params: {
858
- email,
859
- cancelToken
860
- }
861
- });
862
- }
697
+ constructor(client) {
698
+ this.client = client;
699
+ this.base = "subscribe";
700
+ this.name = "subscribe";
701
+ autoBind(this);
702
+ }
703
+ get proxy() {
704
+ return this.client.proxy(this.base);
705
+ }
706
+ /**
707
+ * 检查开启状态
708
+ */
709
+ check() {
710
+ return this.proxy.status.get();
711
+ }
712
+ subscribe(email, types) {
713
+ return this.proxy.post({ data: {
714
+ email,
715
+ types
716
+ } });
717
+ }
718
+ unsubscribe(email, cancelToken) {
719
+ return this.proxy.unsubscribe.get({ params: {
720
+ email,
721
+ cancelToken
722
+ } });
723
+ }
863
724
  };
864
725
 
865
- // controllers/topic.ts
726
+ //#endregion
727
+ //#region controllers/topic.ts
866
728
  var TopicController = class extends BaseCrudController {
867
- constructor(client) {
868
- super(client);
869
- this.client = client;
870
- this.base = "topics";
871
- this.name = "topic";
872
- autoBind(this);
873
- }
874
- get proxy() {
875
- return this.client.proxy(this.base);
876
- }
877
- getTopicBySlug(slug) {
878
- return this.proxy.slug(slug).get();
879
- }
729
+ constructor(client) {
730
+ super(client);
731
+ this.client = client;
732
+ this.base = "topics";
733
+ this.name = "topic";
734
+ autoBind(this);
735
+ }
736
+ get proxy() {
737
+ return this.client.proxy(this.base);
738
+ }
739
+ getTopicBySlug(slug) {
740
+ return this.proxy.slug(slug).get();
741
+ }
880
742
  };
881
743
 
882
- // controllers/user.ts
744
+ //#endregion
745
+ //#region controllers/user.ts
883
746
  var UserController = class {
884
- constructor(client) {
885
- this.client = client;
886
- this.base = "master";
887
- this.name = ["user", "master"];
888
- autoBind(this);
889
- }
890
- get proxy() {
891
- return this.client.proxy(this.base);
892
- }
893
- getMasterInfo() {
894
- return this.proxy.get();
895
- }
896
- login(username, password) {
897
- return this.proxy.login.post({
898
- data: {
899
- username,
900
- password
901
- }
902
- });
903
- }
904
- loginWithToken(token) {
905
- return this.proxy.login.put({
906
- params: token ? {
907
- token: `bearer ${token.replace(/^bearer\s/i, "")}`
908
- } : void 0
909
- });
910
- }
911
- checkTokenValid(token) {
912
- return this.proxy.check_logged.get({
913
- params: {
914
- token: `bearer ${token.replace(/^bearer\s/i, "")}`
915
- }
916
- });
917
- }
747
+ constructor(client) {
748
+ this.client = client;
749
+ this.base = "master";
750
+ this.name = ["user", "master"];
751
+ autoBind(this);
752
+ }
753
+ get proxy() {
754
+ return this.client.proxy(this.base);
755
+ }
756
+ getMasterInfo() {
757
+ return this.proxy.get();
758
+ }
759
+ login(username, password) {
760
+ return this.proxy.login.post({ data: {
761
+ username,
762
+ password
763
+ } });
764
+ }
765
+ loginWithToken(token) {
766
+ return this.proxy.login.put({ params: token ? { token: `bearer ${token.replace(/^bearer\s/i, "")}` } : void 0 });
767
+ }
768
+ checkTokenValid(token) {
769
+ return this.proxy.check_logged.get({ params: { token: `bearer ${token.replace(/^bearer\s/i, "")}` } });
770
+ }
918
771
  };
919
772
 
920
- // controllers/index.ts
921
- var allControllers = [
922
- AckController,
923
- ActivityController,
924
- AggregateController,
925
- AIController,
926
- CategoryController,
927
- CommentController,
928
- LinkController,
929
- NoteController,
930
- PageController,
931
- PostController,
932
- ProjectController,
933
- RecentlyController,
934
- SayController,
935
- SearchController,
936
- ServerlessController,
937
- SnippetController,
938
- SubscribeController,
939
- TopicController,
940
- UserController
773
+ //#endregion
774
+ //#region controllers/index.ts
775
+ const allControllers = [
776
+ AckController,
777
+ ActivityController,
778
+ AggregateController,
779
+ AIController,
780
+ CategoryController,
781
+ CommentController,
782
+ LinkController,
783
+ NoteController,
784
+ PageController,
785
+ PostController,
786
+ ProjectController,
787
+ RecentlyController,
788
+ SayController,
789
+ SearchController,
790
+ ServerlessController,
791
+ SnippetController,
792
+ SubscribeController,
793
+ TopicController,
794
+ UserController
941
795
  ];
942
- var allControllerNames = [
943
- "ai",
944
- "ack",
945
- "activity",
946
- "aggregate",
947
- "category",
948
- "comment",
949
- "link",
950
- "note",
951
- "page",
952
- "post",
953
- "project",
954
- "topic",
955
- "recently",
956
- "say",
957
- "search",
958
- "snippet",
959
- "serverless",
960
- "subscribe",
961
- "user",
962
- // alias,
963
- "friend",
964
- "master",
965
- "shorthand"
796
+ const allControllerNames = [
797
+ "ai",
798
+ "ack",
799
+ "activity",
800
+ "aggregate",
801
+ "category",
802
+ "comment",
803
+ "link",
804
+ "note",
805
+ "page",
806
+ "post",
807
+ "project",
808
+ "topic",
809
+ "recently",
810
+ "say",
811
+ "search",
812
+ "snippet",
813
+ "serverless",
814
+ "subscribe",
815
+ "user",
816
+ "friend",
817
+ "master",
818
+ "shorthand"
966
819
  ];
967
820
 
968
- // core/attach-request.ts
821
+ //#endregion
822
+ //#region core/attach-request.ts
969
823
  function attachRequestMethod(target) {
970
- Object.defineProperty(target, "$$get", {
971
- value(url, options) {
972
- const { params = {}, ...rest } = options;
973
- const qs = handleSearchParams(params);
974
- return target.instance.get(`${url}${qs ? String(`?${qs}`) : ""}`, rest);
975
- }
976
- });
977
- ["put", "post", "patch", "delete"].forEach((method) => {
978
- Object.defineProperty(target, `$$${method}`, {
979
- value(path, options) {
980
- return target.instance[method](path, options);
981
- }
982
- });
983
- });
824
+ Object.defineProperty(target, "$$get", { value(url, options) {
825
+ const { params = {}, ...rest } = options;
826
+ const qs = handleSearchParams(params);
827
+ return target.instance.get(`${url}${qs ? String(`?${qs}`) : ""}`, rest);
828
+ } });
829
+ [
830
+ "put",
831
+ "post",
832
+ "patch",
833
+ "delete"
834
+ ].forEach((method) => {
835
+ Object.defineProperty(target, `$$${method}`, { value(path, options) {
836
+ return target.instance[method](path, options);
837
+ } });
838
+ });
984
839
  }
985
840
  function handleSearchParams(obj) {
986
- if (!obj && typeof obj !== "object") {
987
- throw new TypeError("params must be object.");
988
- }
989
- if (obj instanceof URLSearchParams) {
990
- return obj.toString();
991
- }
992
- const search = new URLSearchParams();
993
- Object.entries(obj).forEach(([k, v]) => {
994
- if (typeof v === "undefined" || Object.prototype.toString.call(v) === "[object Null]") {
995
- return;
996
- }
997
- search.set(k, v);
998
- });
999
- return search.toString();
841
+ if (!obj && typeof obj !== "object") throw new TypeError("params must be object.");
842
+ if (obj instanceof URLSearchParams) return obj.toString();
843
+ const search = new URLSearchParams();
844
+ Object.entries(obj).forEach(([k, v]) => {
845
+ if (typeof v === "undefined" || Object.prototype.toString.call(v) === "[object Null]") return;
846
+ search.set(k, v);
847
+ });
848
+ return search.toString();
1000
849
  }
1001
850
 
1002
- // core/client.ts
1003
- var methodPrefix = "_$";
851
+ //#endregion
852
+ //#region core/client.ts
853
+ const methodPrefix = "_$";
1004
854
  var HTTPClient = class {
1005
- constructor(_endpoint, _adaptor, options = {}) {
1006
- this._endpoint = _endpoint;
1007
- this._adaptor = _adaptor;
1008
- this.options = options;
1009
- this._endpoint = _endpoint.replace(/\/*$/, "");
1010
- this._proxy = this.buildRoute(this)();
1011
- options.transformResponse || (options.transformResponse = (data) => camelcaseKeys(data));
1012
- options.getDataFromResponse || (options.getDataFromResponse = (res) => res.data);
1013
- this.initGetClient();
1014
- attachRequestMethod(this);
1015
- }
1016
- initGetClient() {
1017
- for (const name of allControllerNames) {
1018
- Object.defineProperty(this, name, {
1019
- get() {
1020
- const client = Reflect.get(this, `${methodPrefix}${name}`);
1021
- if (!client) {
1022
- throw new ReferenceError(
1023
- `${name.charAt(0).toUpperCase() + name.slice(1)} Client not inject yet, please inject with client.injectClients(...)`
1024
- );
1025
- }
1026
- return client;
1027
- },
1028
- configurable: false,
1029
- enumerable: false
1030
- });
1031
- }
1032
- }
1033
- injectControllers(Controller, ...rest) {
1034
- Controller = Array.isArray(Controller) ? Controller : [Controller, ...rest];
1035
- for (const Client of Controller) {
1036
- const cl = new Client(this);
1037
- if (Array.isArray(cl.name)) {
1038
- for (const name of cl.name) {
1039
- attach.call(this, name, cl);
1040
- }
1041
- } else {
1042
- attach.call(this, cl.name, cl);
1043
- }
1044
- }
1045
- function attach(name, cl) {
1046
- Object.defineProperty(this, `${methodPrefix}${name.toLowerCase()}`, {
1047
- get() {
1048
- return cl;
1049
- },
1050
- enumerable: false,
1051
- configurable: false
1052
- });
1053
- }
1054
- }
1055
- get endpoint() {
1056
- return this._endpoint;
1057
- }
1058
- get instance() {
1059
- return this._adaptor;
1060
- }
1061
- request(options) {
1062
- return this[`$$${String(options.method || "get").toLowerCase()}`](
1063
- options.url,
1064
- options
1065
- );
1066
- }
1067
- get proxy() {
1068
- return this._proxy;
1069
- }
1070
- buildRoute(manager) {
1071
- const noop = () => {
1072
- };
1073
- const methods = ["get", "post", "delete", "patch", "put"];
1074
- const reflectors = [
1075
- "toString",
1076
- "valueOf",
1077
- "inspect",
1078
- "constructor",
1079
- Symbol.toPrimitive
1080
- ];
1081
- const that = this;
1082
- return () => {
1083
- const route = [""];
1084
- const handler = {
1085
- get(target, name) {
1086
- if (reflectors.includes(name))
1087
- return (withBase) => {
1088
- if (withBase) {
1089
- const path = resolveFullPath(that.endpoint, route.join("/"));
1090
- route.length = 0;
1091
- return path;
1092
- } else {
1093
- const path = route.join("/");
1094
- route.length = 0;
1095
- return path.startsWith("/") ? path : `/${path}`;
1096
- }
1097
- };
1098
- if (methods.includes(name)) {
1099
- return async (options) => {
1100
- const url = resolveFullPath(that.endpoint, route.join("/"));
1101
- route.length = 0;
1102
- let res;
1103
- try {
1104
- res = await manager.request({
1105
- method: name,
1106
- ...options,
1107
- url
1108
- });
1109
- } catch (error) {
1110
- let message = error.message;
1111
- let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
1112
- if (that.options.getCodeMessageFromException) {
1113
- const errorInfo = that.options.getCodeMessageFromException(error);
1114
- message = errorInfo.message || message;
1115
- code = errorInfo.code || code;
1116
- }
1117
- throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
1118
- }
1119
- const data = that.options.getDataFromResponse(res);
1120
- if (!data) {
1121
- return null;
1122
- }
1123
- const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
1124
- let nextObject = cameledObject;
1125
- if (cameledObject && typeof cameledObject === "object") {
1126
- nextObject = Array.isArray(cameledObject) ? [...cameledObject] : { ...cameledObject };
1127
- Object.defineProperty(nextObject, "$raw", {
1128
- get() {
1129
- return res;
1130
- },
1131
- enumerable: false,
1132
- configurable: false
1133
- });
1134
- Object.defineProperty(nextObject, "$request", {
1135
- get() {
1136
- return {
1137
- url,
1138
- method: name,
1139
- options
1140
- };
1141
- },
1142
- enumerable: false
1143
- });
1144
- Object.defineProperty(nextObject, "$serialized", {
1145
- get() {
1146
- return cameledObject;
1147
- }
1148
- });
1149
- }
1150
- return nextObject;
1151
- };
1152
- }
1153
- route.push(name);
1154
- return new Proxy(noop, handler);
1155
- },
1156
- // @ts-ignore
1157
- apply(target, _, args) {
1158
- route.push(...args.filter((x) => x !== null));
1159
- return new Proxy(noop, handler);
1160
- }
1161
- };
1162
- return new Proxy(noop, handler);
1163
- };
1164
- }
855
+ constructor(_endpoint, _adaptor, options = {}) {
856
+ this._endpoint = _endpoint;
857
+ this._adaptor = _adaptor;
858
+ this.options = options;
859
+ this._endpoint = _endpoint.replace(/\/*$/, "");
860
+ this._proxy = this.buildRoute(this)();
861
+ options.transformResponse || (options.transformResponse = (data) => camelcaseKeys(data));
862
+ options.getDataFromResponse || (options.getDataFromResponse = (res) => res.data);
863
+ this.initGetClient();
864
+ attachRequestMethod(this);
865
+ }
866
+ initGetClient() {
867
+ for (const name of allControllerNames) Object.defineProperty(this, name, {
868
+ get() {
869
+ const client = Reflect.get(this, `${methodPrefix}${name}`);
870
+ if (!client) throw new ReferenceError(`${name.charAt(0).toUpperCase() + name.slice(1)} Client not inject yet, please inject with client.injectClients(...)`);
871
+ return client;
872
+ },
873
+ configurable: false,
874
+ enumerable: false
875
+ });
876
+ }
877
+ injectControllers(Controller, ...rest) {
878
+ Controller = Array.isArray(Controller) ? Controller : [Controller, ...rest];
879
+ for (const Client of Controller) {
880
+ const cl = new Client(this);
881
+ if (Array.isArray(cl.name)) for (const name of cl.name) attach.call(this, name, cl);
882
+ else attach.call(this, cl.name, cl);
883
+ }
884
+ function attach(name, cl) {
885
+ Object.defineProperty(this, `${methodPrefix}${name.toLowerCase()}`, {
886
+ get() {
887
+ return cl;
888
+ },
889
+ enumerable: false,
890
+ configurable: false
891
+ });
892
+ }
893
+ }
894
+ get endpoint() {
895
+ return this._endpoint;
896
+ }
897
+ get instance() {
898
+ return this._adaptor;
899
+ }
900
+ request(options) {
901
+ return this[`$$${String(options.method || "get").toLowerCase()}`](options.url, options);
902
+ }
903
+ get proxy() {
904
+ return this._proxy;
905
+ }
906
+ buildRoute(manager) {
907
+ const noop = () => {};
908
+ const methods = [
909
+ "get",
910
+ "post",
911
+ "delete",
912
+ "patch",
913
+ "put"
914
+ ];
915
+ const reflectors = [
916
+ "toString",
917
+ "valueOf",
918
+ "inspect",
919
+ "constructor",
920
+ Symbol.toPrimitive
921
+ ];
922
+ const that = this;
923
+ return () => {
924
+ const route = [""];
925
+ const handler = {
926
+ get(target, name) {
927
+ if (reflectors.includes(name)) return (withBase) => {
928
+ if (withBase) {
929
+ const path = resolveFullPath(that.endpoint, route.join("/"));
930
+ route.length = 0;
931
+ return path;
932
+ } else {
933
+ const path = route.join("/");
934
+ route.length = 0;
935
+ return path.startsWith("/") ? path : `/${path}`;
936
+ }
937
+ };
938
+ if (methods.includes(name)) return async (options) => {
939
+ const url = resolveFullPath(that.endpoint, route.join("/"));
940
+ route.length = 0;
941
+ let res;
942
+ try {
943
+ res = await manager.request({
944
+ method: name,
945
+ ...options,
946
+ url
947
+ });
948
+ } catch (error) {
949
+ let message = error.message;
950
+ let code = error.code || error.status || error.statusCode || error.response?.status || error.response?.statusCode || error.response?.code || 500;
951
+ if (that.options.getCodeMessageFromException) {
952
+ const errorInfo = that.options.getCodeMessageFromException(error);
953
+ message = errorInfo.message || message;
954
+ code = errorInfo.code || code;
955
+ }
956
+ throw that.options.customThrowResponseError ? that.options.customThrowResponseError(error) : new RequestError(message, code, url, error);
957
+ }
958
+ const data = that.options.getDataFromResponse(res);
959
+ if (!data) return null;
960
+ const cameledObject = (Array.isArray(data) || isPlainObject(data)) && that.options.transformResponse ? that.options.transformResponse(data) : data;
961
+ let nextObject = cameledObject;
962
+ if (cameledObject && typeof cameledObject === "object") {
963
+ nextObject = Array.isArray(cameledObject) ? [...cameledObject] : { ...cameledObject };
964
+ Object.defineProperty(nextObject, "$raw", {
965
+ get() {
966
+ return res;
967
+ },
968
+ enumerable: false,
969
+ configurable: false
970
+ });
971
+ Object.defineProperty(nextObject, "$request", {
972
+ get() {
973
+ return {
974
+ url,
975
+ method: name,
976
+ options
977
+ };
978
+ },
979
+ enumerable: false
980
+ });
981
+ Object.defineProperty(nextObject, "$serialized", { get() {
982
+ return cameledObject;
983
+ } });
984
+ }
985
+ return nextObject;
986
+ };
987
+ route.push(name);
988
+ return new Proxy(noop, handler);
989
+ },
990
+ apply(target, _, args) {
991
+ route.push(...args.filter((x) => x !== null));
992
+ return new Proxy(noop, handler);
993
+ }
994
+ };
995
+ return new Proxy(noop, handler);
996
+ };
997
+ }
1165
998
  };
1166
999
  function createClient(adapter) {
1167
- return (endpoint, options) => {
1168
- const client = new HTTPClient(
1169
- endpoint,
1170
- adapter,
1171
- options
1172
- );
1173
- const { controllers } = options || {};
1174
- if (controllers) {
1175
- client.injectControllers(controllers);
1176
- }
1177
- return client;
1178
- };
1000
+ return (endpoint, options) => {
1001
+ const client = new HTTPClient(endpoint, adapter, options);
1002
+ const { controllers } = options || {};
1003
+ if (controllers) client.injectControllers(controllers);
1004
+ return client;
1005
+ };
1179
1006
  }
1180
1007
 
1181
- // models/aggregate.ts
1182
- var TimelineType = /* @__PURE__ */ ((TimelineType2) => {
1183
- TimelineType2[TimelineType2["Post"] = 0] = "Post";
1184
- TimelineType2[TimelineType2["Note"] = 1] = "Note";
1185
- return TimelineType2;
1186
- })(TimelineType || {});
1008
+ //#endregion
1009
+ //#region models/aggregate.ts
1010
+ let TimelineType = /* @__PURE__ */ function(TimelineType$1) {
1011
+ TimelineType$1[TimelineType$1["Post"] = 0] = "Post";
1012
+ TimelineType$1[TimelineType$1["Note"] = 1] = "Note";
1013
+ return TimelineType$1;
1014
+ }({});
1187
1015
 
1188
- // ../../apps/core/src/constants/db.constant.ts
1189
- var POST_COLLECTION_NAME = "posts";
1190
- var NOTE_COLLECTION_NAME = "notes";
1191
- var PAGE_COLLECTION_NAME = "pages";
1192
- var RECENTLY_COLLECTION_NAME = "recentlies";
1193
- var CollectionRefTypes = /* @__PURE__ */ ((CollectionRefTypes2) => {
1194
- CollectionRefTypes2[CollectionRefTypes2["Post"] = POST_COLLECTION_NAME] = "Post";
1195
- CollectionRefTypes2[CollectionRefTypes2["Note"] = NOTE_COLLECTION_NAME] = "Note";
1196
- CollectionRefTypes2[CollectionRefTypes2["Page"] = PAGE_COLLECTION_NAME] = "Page";
1197
- CollectionRefTypes2[CollectionRefTypes2["Recently"] = RECENTLY_COLLECTION_NAME] = "Recently";
1198
- return CollectionRefTypes2;
1199
- })(CollectionRefTypes || {});
1016
+ //#endregion
1017
+ //#region ../../apps/core/src/constants/db.constant.ts
1018
+ const POST_COLLECTION_NAME = "posts";
1019
+ const NOTE_COLLECTION_NAME = "notes";
1020
+ const PAGE_COLLECTION_NAME = "pages";
1021
+ const RECENTLY_COLLECTION_NAME = "recentlies";
1022
+ let CollectionRefTypes = /* @__PURE__ */ function(CollectionRefTypes$1) {
1023
+ CollectionRefTypes$1[CollectionRefTypes$1["Post"] = POST_COLLECTION_NAME] = "Post";
1024
+ CollectionRefTypes$1[CollectionRefTypes$1["Note"] = NOTE_COLLECTION_NAME] = "Note";
1025
+ CollectionRefTypes$1[CollectionRefTypes$1["Page"] = PAGE_COLLECTION_NAME] = "Page";
1026
+ CollectionRefTypes$1[CollectionRefTypes$1["Recently"] = RECENTLY_COLLECTION_NAME] = "Recently";
1027
+ return CollectionRefTypes$1;
1028
+ }({});
1200
1029
 
1201
- // models/comment.ts
1202
- var CommentState = /* @__PURE__ */ ((CommentState2) => {
1203
- CommentState2[CommentState2["Unread"] = 0] = "Unread";
1204
- CommentState2[CommentState2["Read"] = 1] = "Read";
1205
- CommentState2[CommentState2["Junk"] = 2] = "Junk";
1206
- return CommentState2;
1207
- })(CommentState || {});
1030
+ //#endregion
1031
+ //#region models/comment.ts
1032
+ let CommentState = /* @__PURE__ */ function(CommentState$1) {
1033
+ CommentState$1[CommentState$1["Unread"] = 0] = "Unread";
1034
+ CommentState$1[CommentState$1["Read"] = 1] = "Read";
1035
+ CommentState$1[CommentState$1["Junk"] = 2] = "Junk";
1036
+ return CommentState$1;
1037
+ }({});
1208
1038
 
1209
- // models/link.ts
1210
- var LinkType = /* @__PURE__ */ ((LinkType2) => {
1211
- LinkType2[LinkType2["Friend"] = 0] = "Friend";
1212
- LinkType2[LinkType2["Collection"] = 1] = "Collection";
1213
- return LinkType2;
1214
- })(LinkType || {});
1215
- var LinkState = /* @__PURE__ */ ((LinkState2) => {
1216
- LinkState2[LinkState2["Pass"] = 0] = "Pass";
1217
- LinkState2[LinkState2["Audit"] = 1] = "Audit";
1218
- LinkState2[LinkState2["Outdate"] = 2] = "Outdate";
1219
- LinkState2[LinkState2["Banned"] = 3] = "Banned";
1220
- LinkState2[LinkState2["Reject"] = 4] = "Reject";
1221
- return LinkState2;
1222
- })(LinkState || {});
1039
+ //#endregion
1040
+ //#region models/link.ts
1041
+ let LinkType = /* @__PURE__ */ function(LinkType$1) {
1042
+ LinkType$1[LinkType$1["Friend"] = 0] = "Friend";
1043
+ LinkType$1[LinkType$1["Collection"] = 1] = "Collection";
1044
+ return LinkType$1;
1045
+ }({});
1046
+ let LinkState = /* @__PURE__ */ function(LinkState$1) {
1047
+ LinkState$1[LinkState$1["Pass"] = 0] = "Pass";
1048
+ LinkState$1[LinkState$1["Audit"] = 1] = "Audit";
1049
+ LinkState$1[LinkState$1["Outdate"] = 2] = "Outdate";
1050
+ LinkState$1[LinkState$1["Banned"] = 3] = "Banned";
1051
+ LinkState$1[LinkState$1["Reject"] = 4] = "Reject";
1052
+ return LinkState$1;
1053
+ }({});
1223
1054
 
1224
- // models/page.ts
1225
- var EnumPageType = /* @__PURE__ */ ((EnumPageType2) => {
1226
- EnumPageType2["md"] = "md";
1227
- EnumPageType2["html"] = "html";
1228
- EnumPageType2["frame"] = "frame";
1229
- return EnumPageType2;
1230
- })(EnumPageType || {});
1055
+ //#endregion
1056
+ //#region models/page.ts
1057
+ let EnumPageType = /* @__PURE__ */ function(EnumPageType$1) {
1058
+ EnumPageType$1["md"] = "md";
1059
+ EnumPageType$1["html"] = "html";
1060
+ EnumPageType$1["frame"] = "frame";
1061
+ return EnumPageType$1;
1062
+ }({});
1231
1063
 
1232
- // models/recently.ts
1233
- var RecentlyRefTypes = /* @__PURE__ */ ((RecentlyRefTypes2) => {
1234
- RecentlyRefTypes2["Post"] = "Post";
1235
- RecentlyRefTypes2["Note"] = "Note";
1236
- RecentlyRefTypes2["Page"] = "Page";
1237
- return RecentlyRefTypes2;
1238
- })(RecentlyRefTypes || {});
1064
+ //#endregion
1065
+ //#region models/recently.ts
1066
+ let RecentlyRefTypes = /* @__PURE__ */ function(RecentlyRefTypes$1) {
1067
+ RecentlyRefTypes$1["Post"] = "Post";
1068
+ RecentlyRefTypes$1["Note"] = "Note";
1069
+ RecentlyRefTypes$1["Page"] = "Page";
1070
+ return RecentlyRefTypes$1;
1071
+ }({});
1239
1072
 
1240
- // models/snippet.ts
1241
- var SnippetType = /* @__PURE__ */ ((SnippetType2) => {
1242
- SnippetType2["JSON"] = "json";
1243
- SnippetType2["Function"] = "function";
1244
- SnippetType2["Text"] = "text";
1245
- SnippetType2["YAML"] = "yaml";
1246
- return SnippetType2;
1247
- })(SnippetType || {});
1073
+ //#endregion
1074
+ //#region models/snippet.ts
1075
+ let SnippetType = /* @__PURE__ */ function(SnippetType$1) {
1076
+ SnippetType$1["JSON"] = "json";
1077
+ SnippetType$1["Function"] = "function";
1078
+ SnippetType$1["Text"] = "text";
1079
+ SnippetType$1["YAML"] = "yaml";
1080
+ return SnippetType$1;
1081
+ }({});
1248
1082
 
1249
- // ../../apps/core/src/modules/subscribe/subscribe.constant.ts
1250
- var SubscribePostCreateBit = Math.trunc(1);
1251
- var SubscribeNoteCreateBit = 1 << 1;
1252
- var SubscribeSayCreateBit = 1 << 2;
1253
- var SubscribeRecentCreateBit = 1 << 3;
1254
- var SubscribeAllBit = SubscribePostCreateBit | SubscribeNoteCreateBit | SubscribeSayCreateBit | SubscribeRecentCreateBit;
1255
- var SubscribeTypeToBitMap = {
1256
- post_c: SubscribePostCreateBit,
1257
- note_c: SubscribeNoteCreateBit,
1258
- say_c: SubscribeSayCreateBit,
1259
- recently_c: SubscribeRecentCreateBit,
1260
- all: SubscribeAllBit
1083
+ //#endregion
1084
+ //#region ../../apps/core/src/modules/subscribe/subscribe.constant.ts
1085
+ const SubscribePostCreateBit = Math.trunc(1);
1086
+ const SubscribeNoteCreateBit = 2;
1087
+ const SubscribeSayCreateBit = 4;
1088
+ const SubscribeRecentCreateBit = 8;
1089
+ const SubscribeAllBit = 15;
1090
+ const SubscribeTypeToBitMap = {
1091
+ post_c: SubscribePostCreateBit,
1092
+ note_c: SubscribeNoteCreateBit,
1093
+ say_c: SubscribeSayCreateBit,
1094
+ recently_c: SubscribeRecentCreateBit,
1095
+ all: SubscribeAllBit
1261
1096
  };
1262
1097
 
1263
- // index.ts
1264
- var index_default = createClient;
1265
- // Annotate the CommonJS export names for ESM import in node:
1266
- 0 && (module.exports = {
1267
- AIController,
1268
- AckController,
1269
- ActivityController,
1270
- AggregateController,
1271
- CategoryController,
1272
- CategoryType,
1273
- CollectionRefTypes,
1274
- CommentController,
1275
- CommentState,
1276
- EnumPageType,
1277
- LinkController,
1278
- LinkState,
1279
- LinkType,
1280
- NoteController,
1281
- PageController,
1282
- PostController,
1283
- ProjectController,
1284
- RecentlyAttitudeEnum,
1285
- RecentlyAttitudeResultEnum,
1286
- RecentlyController,
1287
- RecentlyRefTypes,
1288
- RequestError,
1289
- SayController,
1290
- SearchController,
1291
- ServerlessController,
1292
- SnippetController,
1293
- SnippetType,
1294
- SubscribeAllBit,
1295
- SubscribeController,
1296
- SubscribeNoteCreateBit,
1297
- SubscribePostCreateBit,
1298
- SubscribeRecentCreateBit,
1299
- SubscribeSayCreateBit,
1300
- SubscribeTypeToBitMap,
1301
- TimelineType,
1302
- TopicController,
1303
- UserController,
1304
- allControllerNames,
1305
- allControllers,
1306
- createClient,
1307
- simpleCamelcaseKeys
1308
- });
1098
+ //#endregion
1099
+ //#region index.ts
1100
+ var api_client_default = createClient;
1101
+
1102
+ //#endregion
1103
+ exports.AIController = AIController;
1104
+ exports.AckController = AckController;
1105
+ exports.ActivityController = ActivityController;
1106
+ exports.AggregateController = AggregateController;
1107
+ exports.CategoryController = CategoryController;
1108
+ exports.CategoryType = CategoryType;
1109
+ exports.CollectionRefTypes = CollectionRefTypes;
1110
+ exports.CommentController = CommentController;
1111
+ exports.CommentState = CommentState;
1112
+ exports.EnumPageType = EnumPageType;
1113
+ exports.LinkController = LinkController;
1114
+ exports.LinkState = LinkState;
1115
+ exports.LinkType = LinkType;
1116
+ exports.NoteController = NoteController;
1117
+ exports.PageController = PageController;
1118
+ exports.PostController = PostController;
1119
+ exports.ProjectController = ProjectController;
1120
+ exports.RecentlyAttitudeEnum = RecentlyAttitudeEnum;
1121
+ exports.RecentlyAttitudeResultEnum = RecentlyAttitudeResultEnum;
1122
+ exports.RecentlyController = RecentlyController;
1123
+ exports.RecentlyRefTypes = RecentlyRefTypes;
1124
+ exports.RequestError = RequestError;
1125
+ exports.SayController = SayController;
1126
+ exports.SearchController = SearchController;
1127
+ exports.ServerlessController = ServerlessController;
1128
+ exports.SnippetController = SnippetController;
1129
+ exports.SnippetType = SnippetType;
1130
+ exports.SubscribeAllBit = SubscribeAllBit;
1131
+ exports.SubscribeController = SubscribeController;
1132
+ exports.SubscribeNoteCreateBit = SubscribeNoteCreateBit;
1133
+ exports.SubscribePostCreateBit = SubscribePostCreateBit;
1134
+ exports.SubscribeRecentCreateBit = SubscribeRecentCreateBit;
1135
+ exports.SubscribeSayCreateBit = SubscribeSayCreateBit;
1136
+ exports.SubscribeTypeToBitMap = SubscribeTypeToBitMap;
1137
+ exports.TimelineType = TimelineType;
1138
+ exports.TopicController = TopicController;
1139
+ exports.UserController = UserController;
1140
+ exports.allControllerNames = allControllerNames;
1141
+ exports.allControllers = allControllers;
1142
+ exports.createClient = createClient;
1143
+ exports.default = api_client_default;
1144
+ exports.simpleCamelcaseKeys = camelcaseKeys;