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