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