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