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