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