@ccw-api/api 0.5.0 → 0.7.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 (440) hide show
  1. package/README.md +591 -439
  2. package/dist/esm/bfs-web/index.js +2 -2
  3. package/dist/esm/bfs-web/users/{oid}/extensions.js +1 -1
  4. package/dist/esm/community-web/ccw-mall/ccw/product/fe/query.js +34 -0
  5. package/dist/esm/community-web/cloud_asset/search.js +1 -1
  6. package/dist/esm/community-web/comment/page.js +1 -1
  7. package/dist/esm/community-web/comment/page_by_topic.js +1 -1
  8. package/dist/esm/community-web/creation/own/page.js +1 -1
  9. package/dist/esm/community-web/creation/page.js +1 -1
  10. package/dist/esm/community-web/creation/page_by_student.js +1 -1
  11. package/dist/esm/community-web/creation/recommend.js +1 -1
  12. package/dist/esm/community-web/creation/search/page.js +1 -1
  13. package/dist/esm/community-web/creation/teamwork_log/page.js +1 -1
  14. package/dist/esm/community-web/creation_donated_record/ranking_list.js +1 -1
  15. package/dist/esm/community-web/creation_release/page.js +1 -1
  16. package/dist/esm/community-web/creation_screenshot/page.js +1 -1
  17. package/dist/esm/community-web/emoji/page.js +1 -1
  18. package/dist/esm/community-web/extensions/creation-like/detail.js +14 -0
  19. package/dist/esm/community-web/extensions/following/status.js +14 -0
  20. package/dist/esm/community-web/hash_tag/managed/list.js +1 -1
  21. package/dist/esm/community-web/hash_tag_creation/mine.js +1 -1
  22. package/dist/esm/community-web/historical_team_member/page.js +1 -1
  23. package/dist/esm/community-web/index.js +113 -99
  24. package/dist/esm/community-web/notification/page.js +2 -2
  25. package/dist/esm/community-web/smart_contract/account.js +13 -0
  26. package/dist/esm/community-web/smart_contract/detail.js +13 -0
  27. package/dist/esm/community-web/smart_contract/execute.js +17 -0
  28. package/dist/esm/community-web/student/block_record/list.js +1 -1
  29. package/dist/esm/community-web/student/following/page.js +1 -1
  30. package/dist/esm/community-web/students/list_sessions.js +1 -1
  31. package/dist/esm/community-web/students/reputation_score_log/page.js +1 -1
  32. package/dist/esm/community-web/study-community/following/follow.js +13 -0
  33. package/dist/esm/community-web/subject_area/page.js +1 -1
  34. package/dist/esm/community-web/subject_area/page_by_channel.js +1 -1
  35. package/dist/esm/community-web/typical_project/page.js +1 -1
  36. package/dist/esm/community-web/user_package/user_product.js +1 -1
  37. package/dist/esm/community-web-cloud-database/cloud_variable/detail/v2.js +16 -0
  38. package/dist/esm/community-web-cloud-database/index.js +3 -1
  39. package/dist/esm/gandi-main/bulletins/page.js +1 -1
  40. package/dist/esm/gandi-main/index.js +4 -4
  41. package/dist/esm/index.js +6 -6
  42. package/dist/esm/op-parent-api/index.js +2 -2
  43. package/dist/esm/sso/index.js +5 -5
  44. package/dist/esm/types/account.js +1 -0
  45. package/dist/esm/types/api.js +1 -0
  46. package/dist/esm/types/approval.js +1 -0
  47. package/dist/esm/types/comment.js +1 -0
  48. package/dist/esm/types/creation.js +1 -0
  49. package/dist/esm/types/extensions.js +1 -0
  50. package/dist/esm/types/hashTag.js +1 -0
  51. package/dist/esm/types/index.js +1 -0
  52. package/dist/esm/types/pages.js +1 -0
  53. package/dist/esm/types/session.js +1 -0
  54. package/dist/esm/types/teamwork.js +1 -0
  55. package/dist/esm/types/userData.js +1 -0
  56. package/dist/node/bfs-web/users/{oid}/extensions.js +1 -1
  57. package/dist/node/community-web/ccw-mall/ccw/product/fe/query.js +38 -0
  58. package/dist/node/community-web/cloud_asset/search.js +1 -1
  59. package/dist/node/community-web/comment/page.js +1 -1
  60. package/dist/node/community-web/comment/page_by_topic.js +1 -1
  61. package/dist/node/community-web/creation/own/page.js +1 -1
  62. package/dist/node/community-web/creation/page.js +1 -1
  63. package/dist/node/community-web/creation/page_by_student.js +1 -1
  64. package/dist/node/community-web/creation/recommend.js +1 -1
  65. package/dist/node/community-web/creation/search/page.js +1 -1
  66. package/dist/node/community-web/creation/teamwork_log/page.js +1 -1
  67. package/dist/node/community-web/creation_donated_record/ranking_list.js +1 -1
  68. package/dist/node/community-web/creation_release/page.js +1 -1
  69. package/dist/node/community-web/creation_screenshot/page.js +1 -1
  70. package/dist/node/community-web/emoji/page.js +1 -1
  71. package/dist/node/community-web/extensions/creation-like/detail.js +18 -0
  72. package/dist/node/community-web/extensions/following/status.js +18 -0
  73. package/dist/node/community-web/hash_tag/managed/list.js +1 -1
  74. package/dist/node/community-web/hash_tag_creation/mine.js +1 -1
  75. package/dist/node/community-web/historical_team_member/page.js +1 -1
  76. package/dist/node/community-web/index.js +14 -0
  77. package/dist/node/community-web/notification/page.js +2 -2
  78. package/dist/node/community-web/smart_contract/account.js +17 -0
  79. package/dist/node/community-web/smart_contract/detail.js +17 -0
  80. package/dist/node/community-web/smart_contract/execute.js +21 -0
  81. package/dist/node/community-web/student/block_record/list.js +1 -1
  82. package/dist/node/community-web/student/following/page.js +1 -1
  83. package/dist/node/community-web/students/list_sessions.js +1 -1
  84. package/dist/node/community-web/students/reputation_score_log/page.js +1 -1
  85. package/dist/node/community-web/study-community/following/follow.js +17 -0
  86. package/dist/node/community-web/subject_area/page.js +1 -1
  87. package/dist/node/community-web/subject_area/page_by_channel.js +1 -1
  88. package/dist/node/community-web/typical_project/page.js +1 -1
  89. package/dist/node/community-web/user_package/user_product.js +1 -1
  90. package/dist/node/community-web-cloud-database/cloud_variable/detail/v2.js +20 -0
  91. package/dist/node/community-web-cloud-database/index.js +2 -0
  92. package/dist/node/gandi-main/bulletins/page.js +1 -1
  93. package/dist/node/types/account.js +2 -0
  94. package/dist/node/types/api.js +2 -0
  95. package/dist/node/types/approval.js +2 -0
  96. package/dist/node/types/comment.js +2 -0
  97. package/dist/node/types/creation.js +2 -0
  98. package/dist/node/types/extensions.js +2 -0
  99. package/dist/node/types/hashTag.js +2 -0
  100. package/dist/node/types/index.js +2 -0
  101. package/dist/node/types/pages.js +2 -0
  102. package/dist/node/types/session.js +2 -0
  103. package/dist/node/types/teamwork.js +2 -0
  104. package/dist/node/types/userData.js +2 -0
  105. package/dist/types/bfs-web/users/{oid}/extensions.d.ts +3 -3
  106. package/dist/types/community-web/api/v1/short_code/encode.d.ts +2 -2
  107. package/dist/types/community-web/approval/list.d.ts +3 -3
  108. package/dist/types/community-web/ccw-mall/ccw/product/fe/query.d.ts +54 -0
  109. package/dist/types/community-web/cloud_asset/search.d.ts +2 -2
  110. package/dist/types/community-web/comment/create.d.ts +3 -3
  111. package/dist/types/community-web/comment/page.d.ts +2 -2
  112. package/dist/types/community-web/comment/page_by_topic.d.ts +2 -2
  113. package/dist/types/community-web/creation/detail.d.ts +2 -2
  114. package/dist/types/community-web/creation/excellent/list.d.ts +1 -1
  115. package/dist/types/community-web/creation/introduction/detail.d.ts +2 -2
  116. package/dist/types/community-web/creation/like/detail.d.ts +2 -2
  117. package/dist/types/community-web/creation/loading/tips.d.ts +1 -1
  118. package/dist/types/community-web/creation/own/page.d.ts +2 -2
  119. package/dist/types/community-web/creation/page.d.ts +3 -3
  120. package/dist/types/community-web/creation/page_by_student.d.ts +3 -3
  121. package/dist/types/community-web/creation/potential/list.d.ts +1 -1
  122. package/dist/types/community-web/creation/recommend.d.ts +2 -2
  123. package/dist/types/community-web/creation/search/page.d.ts +2 -2
  124. package/dist/types/community-web/creation/smart_contract/split_rule/create.d.ts +1 -1
  125. package/dist/types/community-web/creation/smart_contract/split_rule/detail.d.ts +2 -2
  126. package/dist/types/community-web/creation/student/detail.d.ts +2 -2
  127. package/dist/types/community-web/creation/submit.d.ts +2 -2
  128. package/dist/types/community-web/creation/tag/list.d.ts +1 -1
  129. package/dist/types/community-web/creation/team_member/list.d.ts +2 -2
  130. package/dist/types/community-web/creation/team_member/produce_ticket.d.ts +1 -1
  131. package/dist/types/community-web/creation/teamwork_log/page.d.ts +2 -2
  132. package/dist/types/community-web/creation/update.d.ts +2 -2
  133. package/dist/types/community-web/creation_activity_stats/list.d.ts +1 -1
  134. package/dist/types/community-web/creation_attribute/detail.d.ts +1 -1
  135. package/dist/types/community-web/creation_donated_record/ranking_list.d.ts +3 -3
  136. package/dist/types/community-web/creation_favorite/detail.d.ts +2 -2
  137. package/dist/types/community-web/creation_recommend_position/list.d.ts +1 -1
  138. package/dist/types/community-web/creation_release/code_profiling/detail.d.ts +1 -1
  139. package/dist/types/community-web/creation_release/page.d.ts +3 -3
  140. package/dist/types/community-web/creation_screenshot/page.d.ts +3 -3
  141. package/dist/types/community-web/creation_stats/view.d.ts +1 -1
  142. package/dist/types/community-web/emoji/all.d.ts +1 -1
  143. package/dist/types/community-web/emoji/category/list.d.ts +1 -1
  144. package/dist/types/community-web/emoji/page.d.ts +1 -1
  145. package/dist/types/community-web/extensions/creation-like/detail.d.ts +18 -0
  146. package/dist/types/community-web/extensions/following/status.d.ts +19 -0
  147. package/dist/types/community-web/great_creation/update.d.ts +1 -1
  148. package/dist/types/community-web/hash_tag/detail.d.ts +1 -1
  149. package/dist/types/community-web/hash_tag/managed/list.d.ts +3 -3
  150. package/dist/types/community-web/hash_tag/recommend/list.d.ts +1 -1
  151. package/dist/types/community-web/hash_tag_creation/list_relation.d.ts +2 -2
  152. package/dist/types/community-web/hash_tag_creation/mine.d.ts +2 -2
  153. package/dist/types/community-web/hash_tag_favorite/detail.d.ts +1 -1
  154. package/dist/types/community-web/historical_team_member/page.d.ts +2 -2
  155. package/dist/types/community-web/index.d.ts +14 -0
  156. package/dist/types/community-web/leaflets/item/list.d.ts +1 -1
  157. package/dist/types/community-web/locked_user/detail.d.ts +2 -2
  158. package/dist/types/community-web/notification/page.d.ts +2 -2
  159. package/dist/types/community-web/notification/stats/v2.d.ts +1 -1
  160. package/dist/types/community-web/post/detail.d.ts +2 -2
  161. package/dist/types/community-web/smart_contract/account.d.ts +13 -0
  162. package/dist/types/community-web/smart_contract/detail.d.ts +24 -0
  163. package/dist/types/community-web/smart_contract/execute.d.ts +25 -0
  164. package/dist/types/community-web/smart_contract/list.d.ts +1 -1
  165. package/dist/types/community-web/student/block_record/detail.d.ts +2 -2
  166. package/dist/types/community-web/student/block_record/list.d.ts +2 -2
  167. package/dist/types/community-web/student/block_record/status.d.ts +1 -1
  168. package/dist/types/community-web/student/following/page.d.ts +3 -3
  169. package/dist/types/community-web/students/creator_score.d.ts +1 -1
  170. package/dist/types/community-web/students/last_active_at.d.ts +1 -1
  171. package/dist/types/community-web/students/list.d.ts +2 -2
  172. package/dist/types/community-web/students/list_sessions.d.ts +2 -2
  173. package/dist/types/community-web/students/profile.d.ts +2 -2
  174. package/dist/types/community-web/students/reputation_score_log/page.d.ts +2 -2
  175. package/dist/types/community-web/students/self/detail.d.ts +1 -1
  176. package/dist/types/community-web/students/stats.d.ts +2 -2
  177. package/dist/types/community-web/students/update.d.ts +1 -1
  178. package/dist/types/community-web/study-community/cloud_variable/create.d.ts +1 -1
  179. package/dist/types/community-web/study-community/following/follow.d.ts +12 -0
  180. package/dist/types/community-web/study-community/member/detail.d.ts +2 -2
  181. package/dist/types/community-web/study-community/spread_feed/unread/count.d.ts +1 -1
  182. package/dist/types/community-web/study-trade/trade/donate.d.ts +1 -1
  183. package/dist/types/community-web/subject_area/page.d.ts +2 -2
  184. package/dist/types/community-web/subject_area/page_by_channel.d.ts +2 -2
  185. package/dist/types/community-web/task/award.d.ts +1 -1
  186. package/dist/types/community-web/task/mine.d.ts +1 -1
  187. package/dist/types/community-web/typical_project/page.d.ts +2 -2
  188. package/dist/types/community-web/typical_project/student/unread_count.d.ts +1 -1
  189. package/dist/types/community-web/user-card/detail.d.ts +2 -2
  190. package/dist/types/community-web/user_label/list.d.ts +1 -1
  191. package/dist/types/community-web/user_package/user_product.d.ts +3 -3
  192. package/dist/types/community-web-cloud-database/cloud_variable/detail/v2.d.ts +17 -0
  193. package/dist/types/community-web-cloud-database/cloud_variable/save.d.ts +1 -1
  194. package/dist/types/community-web-cloud-database/index.d.ts +2 -0
  195. package/dist/types/gandi-main/bulletins/page.d.ts +1 -1
  196. package/dist/types/gandi-main/creation/leaderboards/{oid}/records.d.ts +2 -2
  197. package/dist/types/index.d.ts +8 -0
  198. package/dist/types/queryPages.d.ts +1 -1
  199. package/dist/types/sso/web/auth/login-by-password.d.ts +2 -2
  200. package/dist/types/sso/web/auth/v3/login/by-phone.d.ts +2 -2
  201. package/dist/types/types/account.d.ts +1 -0
  202. package/dist/types/types/api.d.ts +27 -0
  203. package/dist/types/types/approval.d.ts +18 -0
  204. package/dist/types/types/comment.d.ts +60 -0
  205. package/dist/types/types/creation.d.ts +171 -0
  206. package/dist/types/types/extensions.d.ts +60 -0
  207. package/dist/types/types/hashTag.d.ts +71 -0
  208. package/dist/types/types/index.d.ts +11 -0
  209. package/dist/types/types/notification.d.ts +3 -3
  210. package/dist/types/types/pages.d.ts +37 -0
  211. package/dist/types/types/session.d.ts +38 -0
  212. package/dist/types/types/teamwork.d.ts +15 -0
  213. package/dist/types/types/userData.d.ts +363 -0
  214. package/package.json +4 -3
  215. package/dist/esm/bfs-web/extensions/{eid}/donate.test.js +0 -4
  216. package/dist/esm/bfs-web/users/{oid}/extensions.test.js +0 -4
  217. package/dist/esm/community-web/api/v1/short_code/shortcode.test.js +0 -5
  218. package/dist/esm/community-web/approval/approval.test.js +0 -5
  219. package/dist/esm/community-web/base/dateTime.test.js +0 -6
  220. package/dist/esm/community-web/campaign_resource/detail.test.js +0 -10
  221. package/dist/esm/community-web/ccw-main/status.test.js +0 -4
  222. package/dist/esm/community-web/check_in_record/check_in_record.test.js +0 -8
  223. package/dist/esm/community-web/cloud_asset/search.test.js +0 -6
  224. package/dist/esm/community-web/cloud_asset/user/privacy.test.js +0 -4
  225. package/dist/esm/community-web/comment/create.test.js +0 -13
  226. package/dist/esm/community-web/comment/like_record/create.test.js +0 -4
  227. package/dist/esm/community-web/comment/page.test.js +0 -15
  228. package/dist/esm/community-web/comment/page_by_topic.test.js +0 -13
  229. package/dist/esm/community-web/comment/reply.test.js +0 -4
  230. package/dist/esm/community-web/config/detail.test.js +0 -9
  231. package/dist/esm/community-web/creation/detail.test.js +0 -18
  232. package/dist/esm/community-web/creation/excellent/list.test.js +0 -10
  233. package/dist/esm/community-web/creation/introduction/detail.test.js +0 -17
  234. package/dist/esm/community-web/creation/like/detail.test.js +0 -19
  235. package/dist/esm/community-web/creation/loading/tips.test.js +0 -8
  236. package/dist/esm/community-web/creation/own/page.test.js +0 -4
  237. package/dist/esm/community-web/creation/page.test.js +0 -16
  238. package/dist/esm/community-web/creation/page_by_student.test.js +0 -20
  239. package/dist/esm/community-web/creation/potential/list.test.js +0 -10
  240. package/dist/esm/community-web/creation/recommend.test.js +0 -10
  241. package/dist/esm/community-web/creation/search/page.test.js +0 -5
  242. package/dist/esm/community-web/creation/smart_contract/split_rule/create.test.js +0 -4
  243. package/dist/esm/community-web/creation/smart_contract/split_rule/detail.test.js +0 -4
  244. package/dist/esm/community-web/creation/student/detail.test.js +0 -17
  245. package/dist/esm/community-web/creation/submit.test.js +0 -32
  246. package/dist/esm/community-web/creation/tag/list.test.js +0 -10
  247. package/dist/esm/community-web/creation/team_member/list.test.js +0 -4
  248. package/dist/esm/community-web/creation/team_member/produce_ticket.test.js +0 -4
  249. package/dist/esm/community-web/creation/teamwork_log/page.test.js +0 -4
  250. package/dist/esm/community-web/creation/update.test.js +0 -4
  251. package/dist/esm/community-web/creation_activity_stats/list.test.js +0 -5
  252. package/dist/esm/community-web/creation_attribute/detail.test.js +0 -10
  253. package/dist/esm/community-web/creation_donated_record/ranking_list.test.js +0 -12
  254. package/dist/esm/community-web/creation_favorite/detail.test.js +0 -5
  255. package/dist/esm/community-web/creation_recommend_position/list.test.js +0 -5
  256. package/dist/esm/community-web/creation_release/code_profiling/detail.test.js +0 -5
  257. package/dist/esm/community-web/creation_release/page.test.js +0 -12
  258. package/dist/esm/community-web/creation_screenshot/page.test.js +0 -11
  259. package/dist/esm/community-web/creation_stats/view.test.js +0 -6
  260. package/dist/esm/community-web/currency/account/personal.test.js +0 -4
  261. package/dist/esm/community-web/emoji/all.test.js +0 -11
  262. package/dist/esm/community-web/emoji/category/list.test.js +0 -9
  263. package/dist/esm/community-web/emoji/page.test.js +0 -12
  264. package/dist/esm/community-web/event.test.js +0 -5
  265. package/dist/esm/community-web/great_creation/update.test.js +0 -4
  266. package/dist/esm/community-web/hash_tag/hash_tag_detail.test.js +0 -9
  267. package/dist/esm/community-web/hash_tag/managed/managed_list.test.js +0 -10
  268. package/dist/esm/community-web/hash_tag/recommend/list.test.js +0 -4
  269. package/dist/esm/community-web/hash_tag_creation/hash_tag_creation_list_relation.test.js +0 -4
  270. package/dist/esm/community-web/hash_tag_creation/hash_tag_creation_mine.test.js +0 -4
  271. package/dist/esm/community-web/hash_tag_creation/list_relation.test.js +0 -5
  272. package/dist/esm/community-web/hash_tag_favorite/hash_tag_favorite_detail.test.js +0 -4
  273. package/dist/esm/community-web/health/check.test.js +0 -10
  274. package/dist/esm/community-web/historical_team_member/page.test.js +0 -12
  275. package/dist/esm/community-web/leaflets/item/list.test.js +0 -5
  276. package/dist/esm/community-web/locked_user/detail.test.js +0 -6
  277. package/dist/esm/community-web/muted_user/detail.test.js +0 -6
  278. package/dist/esm/community-web/notification/page.test.js +0 -4
  279. package/dist/esm/community-web/notification/stats/v2.test.js +0 -4
  280. package/dist/esm/community-web/notify_message/notify_message.test.js +0 -5
  281. package/dist/esm/community-web/post/post.test.js +0 -9
  282. package/dist/esm/community-web/search/search.test.js +0 -6
  283. package/dist/esm/community-web/short_url/decompress.test.js +0 -4
  284. package/dist/esm/community-web/short_url/shortUrl.test.js +0 -4
  285. package/dist/esm/community-web/smart_contract/list.test.js +0 -4
  286. package/dist/esm/community-web/student/block_record/block_record_list.test.js +0 -4
  287. package/dist/esm/community-web/student/block_record/block_record_status.test.js +0 -8
  288. package/dist/esm/community-web/student/block_record/detail.test.js +0 -4
  289. package/dist/esm/community-web/student/following/page.test.js +0 -6
  290. package/dist/esm/community-web/students/creator_score.test.js +0 -4
  291. package/dist/esm/community-web/students/last_active_at.test.js +0 -6
  292. package/dist/esm/community-web/students/list.test.js +0 -7
  293. package/dist/esm/community-web/students/list_sessions.test.js +0 -4
  294. package/dist/esm/community-web/students/profile.test.js +0 -6
  295. package/dist/esm/community-web/students/reputation_score_log/reputation_score_log.test.js +0 -4
  296. package/dist/esm/community-web/students/self/self_detail.test.js +0 -4
  297. package/dist/esm/community-web/students/stats.test.js +0 -7
  298. package/dist/esm/community-web/students/update.test.js +0 -4
  299. package/dist/esm/community-web/study-community/cloud_variable/create.test.js +0 -4
  300. package/dist/esm/community-web/study-community/comment/delete.test.js +0 -4
  301. package/dist/esm/community-web/study-community/comment/fold.test.js +0 -4
  302. package/dist/esm/community-web/study-community/comment/reset_weight.test.js +0 -4
  303. package/dist/esm/community-web/study-community/comment/top.test.js +0 -4
  304. package/dist/esm/community-web/study-community/member/member_detail.test.js +0 -4
  305. package/dist/esm/community-web/study-community/spread_feed/unread/spread_feed_unread_count.test.js +0 -5
  306. package/dist/esm/community-web/study-trade/trade/donate.test.js +0 -4
  307. package/dist/esm/community-web/subject_area/subject_area_page.test.js +0 -5
  308. package/dist/esm/community-web/subject_area/subject_area_page_by_channel.test.js +0 -5
  309. package/dist/esm/community-web/task/task_award.test.js +0 -5
  310. package/dist/esm/community-web/task/task_mine.test.js +0 -4
  311. package/dist/esm/community-web/typical_project/page.test.js +0 -12
  312. package/dist/esm/community-web/typical_project/student/unread_count.test.js +0 -4
  313. package/dist/esm/community-web/user-card/user_card_detail.test.js +0 -6
  314. package/dist/esm/community-web/user_label/user_label_list.test.js +0 -5
  315. package/dist/esm/community-web/user_package/status.test.js +0 -4
  316. package/dist/esm/community-web/user_package/user_product.test.js +0 -9
  317. package/dist/esm/community-web-cloud-database/cloud_variable/save.test.js +0 -13
  318. package/dist/esm/coverage.test.js +0 -5
  319. package/dist/esm/gandi-main/bulletins/detail.test.js +0 -17
  320. package/dist/esm/gandi-main/bulletins/page.test.js +0 -6
  321. package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.test.js +0 -11
  322. package/dist/esm/gandi-main/timestamp/current.test.js +0 -6
  323. package/dist/esm/op-parent-api/captcha/check.test.js +0 -12
  324. package/dist/esm/op-parent-api/captcha/create.test.js +0 -13
  325. package/dist/esm/sso/web/auth/assistant/captcha/v2/create.test.js +0 -8
  326. package/dist/esm/sso/web/auth/auth.test.js +0 -15
  327. package/dist/esm/sso/web/auth/v3/login/by-phone.test.js +0 -7
  328. package/dist/node/bfs-web/extensions/{eid}/donate.test.js +0 -6
  329. package/dist/node/bfs-web/users/{oid}/extensions.test.js +0 -6
  330. package/dist/node/community-web/api/v1/short_code/shortcode.test.js +0 -7
  331. package/dist/node/community-web/approval/approval.test.js +0 -7
  332. package/dist/node/community-web/base/dateTime.test.js +0 -8
  333. package/dist/node/community-web/campaign_resource/detail.test.js +0 -12
  334. package/dist/node/community-web/ccw-main/status.test.js +0 -6
  335. package/dist/node/community-web/check_in_record/check_in_record.test.js +0 -10
  336. package/dist/node/community-web/cloud_asset/search.test.js +0 -8
  337. package/dist/node/community-web/cloud_asset/user/privacy.test.js +0 -6
  338. package/dist/node/community-web/comment/create.test.js +0 -15
  339. package/dist/node/community-web/comment/like_record/create.test.js +0 -6
  340. package/dist/node/community-web/comment/page.test.js +0 -17
  341. package/dist/node/community-web/comment/page_by_topic.test.js +0 -15
  342. package/dist/node/community-web/comment/reply.test.js +0 -6
  343. package/dist/node/community-web/config/detail.test.js +0 -11
  344. package/dist/node/community-web/creation/detail.test.js +0 -20
  345. package/dist/node/community-web/creation/excellent/list.test.js +0 -12
  346. package/dist/node/community-web/creation/introduction/detail.test.js +0 -19
  347. package/dist/node/community-web/creation/like/detail.test.js +0 -21
  348. package/dist/node/community-web/creation/loading/tips.test.js +0 -10
  349. package/dist/node/community-web/creation/own/page.test.js +0 -6
  350. package/dist/node/community-web/creation/page.test.js +0 -18
  351. package/dist/node/community-web/creation/page_by_student.test.js +0 -22
  352. package/dist/node/community-web/creation/potential/list.test.js +0 -12
  353. package/dist/node/community-web/creation/recommend.test.js +0 -12
  354. package/dist/node/community-web/creation/search/page.test.js +0 -7
  355. package/dist/node/community-web/creation/smart_contract/split_rule/create.test.js +0 -6
  356. package/dist/node/community-web/creation/smart_contract/split_rule/detail.test.js +0 -6
  357. package/dist/node/community-web/creation/student/detail.test.js +0 -19
  358. package/dist/node/community-web/creation/submit.test.js +0 -34
  359. package/dist/node/community-web/creation/tag/list.test.js +0 -12
  360. package/dist/node/community-web/creation/team_member/list.test.js +0 -6
  361. package/dist/node/community-web/creation/team_member/produce_ticket.test.js +0 -6
  362. package/dist/node/community-web/creation/teamwork_log/page.test.js +0 -6
  363. package/dist/node/community-web/creation/update.test.js +0 -6
  364. package/dist/node/community-web/creation_activity_stats/list.test.js +0 -7
  365. package/dist/node/community-web/creation_attribute/detail.test.js +0 -12
  366. package/dist/node/community-web/creation_donated_record/ranking_list.test.js +0 -14
  367. package/dist/node/community-web/creation_favorite/detail.test.js +0 -7
  368. package/dist/node/community-web/creation_recommend_position/list.test.js +0 -7
  369. package/dist/node/community-web/creation_release/code_profiling/detail.test.js +0 -7
  370. package/dist/node/community-web/creation_release/page.test.js +0 -14
  371. package/dist/node/community-web/creation_screenshot/page.test.js +0 -13
  372. package/dist/node/community-web/creation_stats/view.test.js +0 -8
  373. package/dist/node/community-web/currency/account/personal.test.js +0 -6
  374. package/dist/node/community-web/emoji/all.test.js +0 -13
  375. package/dist/node/community-web/emoji/category/list.test.js +0 -11
  376. package/dist/node/community-web/emoji/page.test.js +0 -14
  377. package/dist/node/community-web/event.test.js +0 -7
  378. package/dist/node/community-web/great_creation/update.test.js +0 -6
  379. package/dist/node/community-web/hash_tag/hash_tag_detail.test.js +0 -11
  380. package/dist/node/community-web/hash_tag/managed/managed_list.test.js +0 -12
  381. package/dist/node/community-web/hash_tag/recommend/list.test.js +0 -6
  382. package/dist/node/community-web/hash_tag_creation/hash_tag_creation_list_relation.test.js +0 -6
  383. package/dist/node/community-web/hash_tag_creation/hash_tag_creation_mine.test.js +0 -6
  384. package/dist/node/community-web/hash_tag_creation/list_relation.test.js +0 -7
  385. package/dist/node/community-web/hash_tag_favorite/hash_tag_favorite_detail.test.js +0 -6
  386. package/dist/node/community-web/health/check.test.js +0 -12
  387. package/dist/node/community-web/historical_team_member/page.test.js +0 -14
  388. package/dist/node/community-web/leaflets/item/list.test.js +0 -7
  389. package/dist/node/community-web/locked_user/detail.test.js +0 -8
  390. package/dist/node/community-web/muted_user/detail.test.js +0 -8
  391. package/dist/node/community-web/notification/page.test.js +0 -6
  392. package/dist/node/community-web/notification/stats/v2.test.js +0 -6
  393. package/dist/node/community-web/notify_message/notify_message.test.js +0 -7
  394. package/dist/node/community-web/post/post.test.js +0 -11
  395. package/dist/node/community-web/search/search.test.js +0 -8
  396. package/dist/node/community-web/short_url/decompress.test.js +0 -6
  397. package/dist/node/community-web/short_url/shortUrl.test.js +0 -6
  398. package/dist/node/community-web/smart_contract/list.test.js +0 -6
  399. package/dist/node/community-web/student/block_record/block_record_list.test.js +0 -6
  400. package/dist/node/community-web/student/block_record/block_record_status.test.js +0 -10
  401. package/dist/node/community-web/student/block_record/detail.test.js +0 -6
  402. package/dist/node/community-web/student/following/page.test.js +0 -8
  403. package/dist/node/community-web/students/creator_score.test.js +0 -6
  404. package/dist/node/community-web/students/last_active_at.test.js +0 -8
  405. package/dist/node/community-web/students/list.test.js +0 -9
  406. package/dist/node/community-web/students/list_sessions.test.js +0 -6
  407. package/dist/node/community-web/students/profile.test.js +0 -8
  408. package/dist/node/community-web/students/reputation_score_log/reputation_score_log.test.js +0 -6
  409. package/dist/node/community-web/students/self/self_detail.test.js +0 -6
  410. package/dist/node/community-web/students/stats.test.js +0 -9
  411. package/dist/node/community-web/students/update.test.js +0 -6
  412. package/dist/node/community-web/study-community/cloud_variable/create.test.js +0 -6
  413. package/dist/node/community-web/study-community/comment/delete.test.js +0 -6
  414. package/dist/node/community-web/study-community/comment/fold.test.js +0 -6
  415. package/dist/node/community-web/study-community/comment/reset_weight.test.js +0 -6
  416. package/dist/node/community-web/study-community/comment/top.test.js +0 -6
  417. package/dist/node/community-web/study-community/member/member_detail.test.js +0 -6
  418. package/dist/node/community-web/study-community/spread_feed/unread/spread_feed_unread_count.test.js +0 -7
  419. package/dist/node/community-web/study-trade/trade/donate.test.js +0 -6
  420. package/dist/node/community-web/subject_area/subject_area_page.test.js +0 -7
  421. package/dist/node/community-web/subject_area/subject_area_page_by_channel.test.js +0 -7
  422. package/dist/node/community-web/task/task_award.test.js +0 -7
  423. package/dist/node/community-web/task/task_mine.test.js +0 -6
  424. package/dist/node/community-web/typical_project/page.test.js +0 -14
  425. package/dist/node/community-web/typical_project/student/unread_count.test.js +0 -6
  426. package/dist/node/community-web/user-card/user_card_detail.test.js +0 -8
  427. package/dist/node/community-web/user_label/user_label_list.test.js +0 -7
  428. package/dist/node/community-web/user_package/status.test.js +0 -6
  429. package/dist/node/community-web/user_package/user_product.test.js +0 -11
  430. package/dist/node/community-web-cloud-database/cloud_variable/save.test.js +0 -15
  431. package/dist/node/coverage.test.js +0 -7
  432. package/dist/node/gandi-main/bulletins/detail.test.js +0 -19
  433. package/dist/node/gandi-main/bulletins/page.test.js +0 -8
  434. package/dist/node/gandi-main/creation/leaderboards/{oid}/records.test.js +0 -13
  435. package/dist/node/gandi-main/timestamp/current.test.js +0 -8
  436. package/dist/node/op-parent-api/captcha/check.test.js +0 -14
  437. package/dist/node/op-parent-api/captcha/create.test.js +0 -15
  438. package/dist/node/sso/web/auth/assistant/captcha/v2/create.test.js +0 -10
  439. package/dist/node/sso/web/auth/auth.test.js +0 -17
  440. package/dist/node/sso/web/auth/v3/login/by-phone.test.js +0 -9
package/README.md CHANGED
@@ -1,439 +1,591 @@
1
- # @ccw-api/api
2
-
3
- CCW(创作社区)前后端接口 SDK,整合 `sso.ccw.site`、`community-web.ccw.site`、
4
- `gandi-main.ccw.site`、`bfs-web.ccw.site`、`community-web-cloud-database.ccw.site`
5
- 五大服务的常用 API,提供完整的 TypeScript 类型与开箱即用的分页封装。
6
-
7
- - 包格式:**ESM + CJS + .d.ts 三产物**同时产出
8
- - 类型:所有请求 / 响应字段**强类型**,后端 key 固定约束(如 `MongoDBId`、`CNameOssUrl`、`UUID`)
9
- - 分页:统一返回 `PagesRes<T>`(含 `totalNum` / `totalPages` / `sortField` 等元信息)
10
-
11
- ---
12
-
13
- ## 安装
14
-
15
- ```bash
16
- npm install @ccw-api/api
17
- #
18
- pnpm add @ccw-api/api
19
- #
20
- yarn add @ccw-api/api
21
- ```
22
-
23
- > 唯一运行时依赖:`@ccw-api/axios`(内置鉴权 header 注入的 axios 封装)。
24
- > `@ccw-api/api` 已将常用的 token 设置方法 **`setToken` 重新导出**,无需再单独依赖 axios 包。
25
-
26
- ---
27
-
28
- ## 快速开始
29
-
30
- ### 1. 初始化 Token(前置条件)
31
-
32
- ```ts
33
- import { setToken } from "@ccw-api/api";
34
-
35
- // 直接传入后端下发的 session token
36
- setToken("abcdefgfoo");
37
- ```
38
-
39
- 所有 `@ccw-api/api` 的方法都会复用同一个 axios 单例,**调用 API 时无需再传入鉴权参数**。
40
-
41
- ### 2. 调用方式
42
-
43
- ```ts
44
- import {
45
- sso,
46
- communityWeb,
47
- gandiMain,
48
- bfsWeb,
49
- communityWebCloudDatabase,
50
- } from "@ccw-api/api"; // ✅ 推荐:具名导入
51
- // 或
52
- import api from "@ccw-api/api"; // ✅ default 导入:api.sso / api.communityWeb / api.gandiMain / api.bfsWeb / api.communityWebCloudDatabase
53
- ```
54
-
55
- ---
56
-
57
- ## 模块一:SSO(sso.ccw.site)
58
-
59
- 账号认证相关,共 3 个 API:
60
-
61
- ```ts
62
- const { loginByPassword, logout, logoutBySession } = sso;
63
-
64
- // 账号密码登录
65
- await loginByPassword("student_number", "xxxxx", {
66
- device: "WEB",
67
- browser: "Chrome",
68
- });
69
-
70
- // 登出当前 session
71
- await logout();
72
-
73
- // 强制某个 session 下线用于登陆设备管理
74
- await logoutBySession("64...session_oid");
75
- ```
76
-
77
- ---
78
-
79
- ## 模块二:Community-Web(community-web.ccw.site)
80
-
81
- 覆盖作品 / 学生 / 星球 / 评论 / 通知 / 任务 / 表情 / 签到 / 云资产 / 学科专区 / 打赏 等业务领域,共 **96 个 API**。
82
- 下面是常用场景示例。
83
-
84
- ### 学生与作品
85
-
86
- ```ts
87
- // 拉取学生档案
88
- const profile = await communityWeb.getStudentProfile(
89
- "63c2807d669fa967f17f5559",
90
- );
91
- // ^? StudentOverview(包含头像、简介、统计字段等)
92
-
93
- // 我的创作分
94
- const score = await communityWeb.getCreatorScore();
95
- console.log(score.rank); // "ORDINARY" | "HACKER" | "ADVANCED"
96
-
97
- // 分页拉取某学生的作品列表(含 totalNum / totalPages)
98
- const creations = await communityWeb.getCreationsByStudent(
99
- "63c2807d669fa967f17f5559",
100
- { page: 1, perPage: 12, sortField: "createdAt", sortType: "DESC" },
101
- );
102
- // creations: PagesRes<CreationSimple>
103
- console.log(creations.totalNum, creations.data[0].title);
104
- ```
105
-
106
- ### 星球(HashTag)与作品关联
107
-
108
- ```ts
109
- // 查询某作品加入了哪些星球
110
- const planets = await communityWeb.getPlanetsOfCreation(
111
- "69929185f8d6142487fd4b2e",
112
- );
113
- // planets: HashTagCreationRelation[]
114
- // planets[0].rank "ORDINARY"(星球审核等级,与创作分 CreatorScore.rank 概念不同)
115
-
116
- // 查询我加入某星球的作品分页(排除一个星球 + 过滤状态)
117
- const mine = await communityWeb.getMyHashTagCreations(
118
- "蔚蓝档案",
119
- ["PUBLISHED"],
120
- { page: 1, perPage: 8, sortField: "lastPassedAt", sortType: "DESC" },
121
- );
122
- ```
123
-
124
- ### 通知(细化了 15 种 contentCategory)
125
-
126
- ```ts
127
- import type {
128
- NotificationContent,
129
- PostCommentContent,
130
- FollowedContent,
131
- } from "@ccw-api/api";
132
-
133
- const page = await communityWeb.getNotificationPage("COMMENT_TO_ME", {
134
- page: 1,
135
- perPage: 20,
136
- });
137
- // page.data[].content 类型是 NotificationContent(判别联合)
138
- // 用 contentCategory 做类型收窄:
139
-
140
- for (const notif of page.data) {
141
- switch (notif.contentCategory) {
142
- case "POST_COMMENT": {
143
- const c = notif.content as PostCommentContent;
144
- console.log("评论者:", c.sender, "文章:", c.subject_outline);
145
- break;
146
- }
147
- case "FOLLOWED": {
148
- const c = notif.content as FollowedContent;
149
- console.log("新粉丝:", c.sender, c.sender_id);
150
- break;
151
- }
152
- case "CREATION_SHARE":
153
- case "SESSION_CREATED":
154
- case "COMMUNITY_ACTIVITY":
155
- case "POST_VISIBILITY_CHANGED":
156
- // ……共 15 种,可按 IDE 补全逐项处理
157
- }
158
- }
159
-
160
- // 拉取所有分组的未读统计
161
- const stats = await communityWeb.getNotificationStats();
162
- // stats.creationInteraction stats.commentToMe stats.followMe ……
163
- ```
164
-
165
- ### 任务、表情、金币、签到
166
-
167
- ```ts
168
- // 我的任务列表
169
- const tasks = await communityWeb.getMyTasks();
170
-
171
- // 领取某个任务奖励
172
- await communityWeb.acceptAward("61273ccf1730f4308e853f6a");
173
-
174
- // 个人金币余额(充值 / 赠送 / 提现 三栏分离)
175
- const coin = await communityWeb.getPersonalCurrencyAccount();
176
- // coin: { internalCurrencyBalance, topUpCurrencyBalance, withdrawCurrencyBalance }
177
-
178
- // 全部表情包 + 分页 + 分类
179
- const [allEmoji, emojiPage, categories] = await Promise.all([
180
- communityWeb.getAllEmojis(),
181
- communityWeb.getEmojiPage("ENABLED", { page: 1, perPage: 50 }),
182
- communityWeb.getEmojiCategoryList(),
183
- ]);
184
-
185
- // 签到
186
- await communityWeb.insertCheckInRecord(); // 今日打卡
187
- const history = await communityWeb.getCheckInRecords();
188
-
189
- // 作品 / 评论 打赏(需要token,消耗账户金币)
190
- // 给某个作品打赏 1 金币(objectType 默认 "CREATION")
191
- await communityWeb.donateTrade(1, "68ce4849811b737483bf7027", "CREATION");
192
- ```
193
-
194
- ### 黑名单、封禁、禁言查询
195
-
196
- ```ts
197
- const STUDENT = "63c2807d669fa967f17f5559";
198
-
199
- // 轻量:是否拉黑(只返回 NOT_BLOCKED / BLOCKING)
200
- const s = await communityWeb.getStudentBlockStatus(STUDENT);
201
-
202
- // 详细:完整的 BlockActionRecord(拉黑动作记录,oid / createdAt / fromEntityId)
203
- const detail = await communityWeb.getStudentBlockRecordDetail(STUDENT);
204
-
205
- // 封禁详情(带泛型,locked=false 时其他字段全为 null
206
- const locked = await communityWeb.getLockedUserDetail<true>(
207
- "642c0e8a59230841adf62406",
208
- );
209
-
210
- // 禁言详情(studentNumber 是 244373873 这种数字字符串,null 表示未禁言)
211
- const muted = await communityWeb.getMutedUserDetail("244373873");
212
- ```
213
-
214
- ---
215
-
216
- ## 模块三:Gandi-Main(gandi-main.ccw.site)
217
-
218
- 公告、服务器时间与作品排行榜相关,共 **5 API**:
219
-
220
- ```ts
221
- const {
222
- getCurrentTimestamp,
223
- getBulletinsPage,
224
- getBulletinDetail,
225
- submitLeaderboardRecord,
226
- getLeaderboardRecords,
227
- } = gandiMain;
228
-
229
- // 服务端当前毫秒级时间戳(比客户端时间更可靠,可用于签到、排行榜等需要严格时间判断的场景)
230
- const ts = await gandiMain.getCurrentTimestamp();
231
-
232
- // 分页拉取公告列表(默认按 publishedAt 倒序,过滤已发布)
233
- const bulletins = await gandiMain.getBulletinsPage("PUBLISHED", {
234
- page: 1,
235
- perPage: 10,
236
- });
237
- // bulletins.data[0].title / id / publishedAt
238
-
239
- // 某条公告详情
240
- const detail = await gandiMain.getBulletinDetail(123);
241
-
242
- // ====== 作品排行榜 ======
243
-
244
- // 获取排行榜记录(含榜单配置、当前用户排名、完整记录分页列表)
245
- const board = await gandiMain.getLeaderboardRecords("65a2314daa96bd09b5beae5a");
246
- console.log(board.title); // "总收益"
247
- console.log(board.scoreUnit); // "币"
248
- console.log(board.sortType); // "DESC"
249
- console.log(board.leaderboardRecordTotalNum); // 834
250
- console.log(board.curUserLeaderboardRecord?.ranking); // 139
251
- console.log(board.leaderboardRecords[0].ranking); // 1
252
- console.log(board.leaderboardRecords[0].score); // 排行榜最高分
253
- console.log(board.leaderboardRecords[0].user?.nickname); // 榜首昵称
254
-
255
- // 向排行榜提交分数记录(需要token:userOid必须对应当前登录用户)
256
- await gandiMain.submitLeaderboardRecord(
257
- "65a2314daa96bd09b5beae5a", // 排行榜oid
258
- 1500, // 分数
259
- "6a42413ccc79993c436d04b6", // 用户oid
260
- "", // 扩展信息(可选)
261
- );
262
- ```
263
-
264
- ---
265
-
266
- ## 模块四:BFS-Web(bfs-web.ccw.site)
267
-
268
- 用户扩展(extension)管理与扩展打赏,共 **2 API**:
269
-
270
- ```ts
271
- const { getUserExtensions, donateExtension } = bfsWeb;
272
-
273
- // 分页查询某用户上传/使用过的扩展列表(默认按 updatedAt 倒序)
274
- const exts = await bfsWeb.getUserExtensions("63c2807d669fa967f17f5559", {
275
- page: 1,
276
- perPage: 20,
277
- });
278
- // exts: PagesRes<Extension>
279
-
280
- // 给某个扩展打赏(需要token,消耗账户金币)
281
- await bfsWeb.donateExtension(
282
- "spineAnimation", // 扩展id(eid)
283
- 5, // 打赏金币数量
284
- );
285
- ```
286
-
287
- ---
288
-
289
- ## 模块五:Community-Web-Cloud-Database(community-web-cloud-database.ccw.site)
290
-
291
- 作品 / 用户的云变量(键值对存储)管理,共 **2 个 API**:
292
-
293
- ```ts
294
- const { saveProjectCloudVariable, saveUserCloudVariable } =
295
- communityWebCloudDatabase;
296
-
297
- // 保存作品云变量(无需token,主键是作品id;value结构任意,泛型自动推导返回)
298
- const saved1 = await communityWebCloudDatabase.saveProjectCloudVariable(
299
- "651c9a5142f8fb5ada70fad2",
300
- "backup_65d31eaeb2ce1b785ebea87b_云时间",
301
- { v: "2025-07-05T17:40:53.057+0800" },
302
- );
303
- // saved1: { v: string }
304
- // ^? 泛型自动匹配 value 传入的结构
305
-
306
- // 保存用户云变量(需要token,主键内部自动为 userId 拼接 "-u" 后缀)
307
- const saved2 = await communityWebCloudDatabase.saveUserCloudVariable(
308
- "68dddc63d28b025cb53fae25",
309
- "256053228",
310
- { key2: "0" },
311
- );
312
- // saved2: { key2: string }
313
- ```
314
-
315
- ---
316
-
317
- ### 通用工具型 API
318
-
319
- ```ts
320
- // 生成短链
321
- await communityWeb.createShortUrl("https://ccw.site/detail/xxx");
322
-
323
- // 生成邀请码(api/v1/short_code/encode)
324
- await communityWeb.encodeShortCode("hello world", 1, 6);
325
-
326
- // 服务器时间
327
- await communityWeb.getTime();
328
-
329
- // 埋点事件上报
330
- await communityWeb.sendEvent("creation_detail_view_6880873d2211fa69e41c9d19");
331
-
332
- // 广告横幅
333
- await communityWeb.getLeafletsItemList(1001);
334
-
335
- // 学科专区(分页 / 按频道)
336
- await communityWeb.getSubjectAreaPage({ page: 1, perPage: 20 });
337
- await communityWeb.getSubjectAreaPageByChannel("PRIMARY");
338
- ```
339
-
340
- ---
341
-
342
- ## 类型系统
343
-
344
- ### 原语类型(`types/api.d.ts`)
345
-
346
- 可直接从包顶层作为 `type` 导入:
347
-
348
- ```ts
349
- import type {
350
- MongoDBId, // 24 位 hex 字符串(ObjectId)
351
- CNameOssUrl, // https://m.ccw.site/... 或 https://m.xiguacity.cn/... OSS URL
352
- UUID, // `${string}-${string}-${string}-${string}-${string}` 类型体操
353
- ApiResponse, // { code, msg, body: T } 后端统一响应壳(SDK 内部已拆)
354
- } from "@ccw-api/api";
355
- ```
356
-
357
- ### 领域命名空间
358
-
359
- 每个 `types/*.d.ts` 作为一个命名空间重新导出,**避免同名类型冲突**(典型如 `Student` vs `StudentOverview` vs `Account.Types.Student`):
360
-
361
- ```ts
362
- import type {
363
- Api, // 原语类型(MongoDBId / CNameOssUrl / UUID / ApiResponse ...)
364
- UserData, // Student / StudentOverview / CreatorScore / UserCard ...
365
- Creation, // Creation / HashTag / HashTagCreationRank / CreationRelease ...
366
- Comment, // Comment / CommentStatus ...
367
- Notification, // Notification / NotificationSenderInfo / NotificationGroup ...
368
- NotificationContent, // 15 种通知 content 判别联合
369
- Pages, // PageArgs / PagesRes
370
- Session, // StudentSession / SessionArea
371
- Account, // AccountTypes
372
- Approval, // ApprovalTag
373
- } from "@ccw-api/api";
374
-
375
- type Score = UserData.CreatorScore["rank"]; // "ORDINARY" | "HACKER" | "ADVANCED"
376
- type PlanetRank = Creation.HashTagCreationRank; // "ORDINARY"
377
- ```
378
-
379
- ---
380
-
381
- ## 分页约定
382
-
383
- 所有分页 API 都遵循同一套形状(详见 `types/pages.d.ts` + `src/queryPages.ts`):
384
-
385
- ```ts
386
- import type { PageArgs, PagesRes } from "@ccw-api/api";
387
-
388
- // 入参 T extends string
389
- // Partial<PageArgs<SortField|T>>,默认 { page:1, perPage:20, sortType:"DESC" }
390
- // 出参 PagesRes<T> 完整结构:
391
- const p: PagesRes<Creation.Creation> = {
392
- data: [], // 当前页数据
393
- page: 1,
394
- perPage: 20,
395
- offset: 0,
396
- totalNum: 1234, // 总条数 —— 之前版本被截断,目前 SDK 已完整透出
397
- totalPages: 62, // 总页数
398
- sortField: "createdAt",
399
- sortType: "DESC",
400
- };
401
- ```
402
-
403
- ---
404
-
405
- ## 开发 & 发布
406
-
407
- ```bash
408
- # 三产物构建(node / esm / .d.ts)
409
- npm run build
410
-
411
- # 跑测试(Jest 30 + ts-jest,105 suites / 112 tests
412
- npm test
413
- npm run test:dev # watch 模式
414
-
415
- # 文档(TypeDoc,生成到 doc/ 或默认输出目录)
416
- npm run doc
417
- npm run doc:dev
418
- ```
419
-
420
- `npm publish` 会自动触发 `prepublishOnly` → **build + test** 全跑一遍,失败会阻断发布。
421
-
422
- ---
423
-
424
- ## 目录与规范
425
-
426
- 所有 API 文件严格遵循 `AGENT.md` 规范:
427
-
428
- - **按域名分组**:`src/sso` / `src/community-web` / `src/gandi-main` / `src/bfs-web`,内部子目录对应 URL 路径
429
- - **单文件单接口**:文件名 `kebab-case`,对应 endpoint 最后一段
430
- - **7 段式模板**(每个 API 文件内部固定顺序):
431
- 1. `import`
432
- 2. `export const url = "https://..."`(调试 & 测试直接引用)
433
- 3. `export type Req = { ... }`
434
- 4. `export type Res = { ... }`(响应体内部,不含 `ApiResponse` 外层)
435
- 5. 辅助类型
436
- 6. JSDoc(`@param` / `@returns`)
437
- 7. `export async function xxx(): Promise<Res>`
438
-
439
- 新增 API 时,**最后记得在对应服务的 `index.ts`(如 `src/community-web/index.ts`、`src/gandi-main/index.ts` 等)里 `import + 对象字面量聚合导出`**,否则外部访问不到。
1
+ # @ccw-api/api
2
+
3
+ CCW(创作社区)前后端接口 SDK,整合 `sso.ccw.site`、`community-web.ccw.site`、
4
+ `gandi-main.ccw.site`、`bfs-web.ccw.site`、`community-web-cloud-database.ccw.site`、
5
+ `op-parent-api.xiguacity.cn`
6
+ 六大服务的常用 API,提供完整的 TypeScript 类型与开箱即用的分页封装。
7
+
8
+ - 包格式:**ESM + CJS + .d.ts 三产物**同时产出
9
+ - 类型:所有请求 / 响应字段**强类型**,后端 key 固定约束(如 `MongoDBId`、`CNameOssUrl`、`UUID`)
10
+ - 分页:统一返回 `PagesRes<T>`(含 `totalNum` / `totalPages` / `sortField` 等元信息)
11
+
12
+ ---
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ npm install @ccw-api/api
18
+ #
19
+ pnpm add @ccw-api/api
20
+ #
21
+ yarn add @ccw-api/api
22
+ ```
23
+
24
+ > 唯一运行时依赖:`@ccw-api/axios`(内置鉴权 header 注入的 axios 封装)。
25
+ > `@ccw-api/api` 已将常用的 token 设置方法 **`setToken` 重新导出**,无需再单独依赖 axios 包。
26
+
27
+ ---
28
+
29
+ ## 快速开始
30
+
31
+ ### 1. 初始化 Token(前置条件)
32
+
33
+ ```ts
34
+ import { setToken } from "@ccw-api/api";
35
+
36
+ // 直接传入后端下发的 session token
37
+ setToken("abcdefgfoo");
38
+ ```
39
+
40
+ 所有 `@ccw-api/api` 的方法都会复用同一个 axios 单例,**调用 API 时无需再传入鉴权参数**。
41
+
42
+ ### 2. 调用方式
43
+
44
+ ```ts
45
+ import {
46
+ sso,
47
+ communityWeb,
48
+ gandiMain,
49
+ bfsWeb,
50
+ communityWebCloudDatabase,
51
+ opParentApi,
52
+ } from "@ccw-api/api"; // ✅ 推荐:具名导入
53
+ // 或
54
+ import api from "@ccw-api/api";
55
+ // ✅ default 导入:api.sso / api.communityWeb / api.gandiMain / api.bfsWeb / api.communityWebCloudDatabase / api.opParentApi
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 模块一:SSO(sso.ccw.site)
61
+
62
+ 账号认证相关,共 **5 API**:
63
+
64
+ ```ts
65
+ const {
66
+ loginByPassword,
67
+ logout,
68
+ logoutBySession,
69
+ loginByPhone,
70
+ createSmsCaptcha,
71
+ } = sso;
72
+
73
+ // 账号密码登录
74
+ await loginByPassword("student_number", "xxxxx", {
75
+ device: "WEB",
76
+ browser: "Chrome",
77
+ });
78
+
79
+ // 登出当前 session
80
+ await logout();
81
+
82
+ // 强制某个 session 下线用于登陆设备管理
83
+ await logoutBySession(12345);
84
+
85
+ // 手机号+短信验证码登录(V3)
86
+ await loginByPhone("12345671145", "123456");
87
+
88
+ // 发送短信验证码(图形验证码可选)
89
+ await createSmsCaptcha("10011451919");
90
+ ```
91
+
92
+ ---
93
+
94
+ ## 模块二:Community-Web(community-web.ccw.site)
95
+
96
+ 覆盖作品 / 学生 / 星球 / 评论 / 通知 / 任务 / 表情 / 签到 / 云资产 / 学科专区 / 打赏 / 商城 / 商品 等业务领域,共 **106 个 API**。
97
+ 下面是常用场景示例。
98
+
99
+ ### 学生与作品
100
+
101
+ ```ts
102
+ // 拉取学生档案
103
+ const profile = await communityWeb.getStudentProfile(
104
+ "63c2807d669fa967f17f5559",
105
+ );
106
+ // ^? StudentOverview(包含头像、简介、统计字段等)
107
+
108
+ // 我的创作分
109
+ const score = await communityWeb.getCreatorScore();
110
+ console.log(score.rank); // "ORDINARY" | "HACKER" | "ADVANCED"
111
+
112
+ // 分页拉取某学生的作品列表(含 totalNum / totalPages)
113
+ const creations = await communityWeb.getCreationsByStudent(
114
+ "63c2807d669fa967f17f5559",
115
+ { page: 1, perPage: 12, sortField: "createdAt", sortType: "DESC" },
116
+ );
117
+ // creations: PagesRes<CreationSimple>
118
+ console.log(creations.totalNum, creations.data[0].title);
119
+ ```
120
+
121
+ ### 星球(HashTag)与作品关联
122
+
123
+ ```ts
124
+ // 查询某作品加入了哪些星球
125
+ const planets = await communityWeb.getPlanetsOfCreation(
126
+ "69929185f8d6142487fd4b2e",
127
+ );
128
+ // planets: HashTagCreationRelation[]
129
+ // planets[0].rank → "ORDINARY"(星球审核等级,与创作分 CreatorScore.rank 概念不同)
130
+
131
+ // 查询我加入某星球的作品分页(排除一个星球 + 过滤状态)
132
+ const mine = await communityWeb.getMyHashTagCreations(
133
+ "蔚蓝档案",
134
+ ["PUBLISHED"],
135
+ { page: 1, perPage: 8, sortField: "lastPassedAt", sortType: "DESC" },
136
+ );
137
+ ```
138
+
139
+ ### 通知(细化了 15 种 contentCategory)
140
+
141
+ ```ts
142
+ import type {
143
+ NotificationContent,
144
+ PostCommentContent,
145
+ FollowedContent,
146
+ } from "@ccw-api/api";
147
+
148
+ const page = await communityWeb.getNotificationPage("COMMENT_TO_ME", {
149
+ page: 1,
150
+ perPage: 20,
151
+ });
152
+ // page.data[].content 类型是 NotificationContent(判别联合)
153
+ // 用 contentCategory 做类型收窄:
154
+
155
+ for (const notif of page.data) {
156
+ switch (notif.contentCategory) {
157
+ case "POST_COMMENT": {
158
+ const c = notif.content as PostCommentContent;
159
+ console.log("评论者:", c.sender, "文章:", c.subject_outline);
160
+ break;
161
+ }
162
+ case "FOLLOWED": {
163
+ const c = notif.content as FollowedContent;
164
+ console.log("新粉丝:", c.sender, c.sender_id);
165
+ break;
166
+ }
167
+ case "CREATION_SHARE":
168
+ case "SESSION_CREATED":
169
+ case "COMMUNITY_ACTIVITY":
170
+ case "POST_VISIBILITY_CHANGED":
171
+ // ……共 15 种,可按 IDE 补全逐项处理
172
+ }
173
+ }
174
+
175
+ // 拉取所有分组的未读统计
176
+ const stats = await communityWeb.getNotificationStats();
177
+ // stats.creationInteraction stats.commentToMe stats.followMe ……
178
+ ```
179
+
180
+ ### 任务、表情、金币、签到
181
+
182
+ ```ts
183
+ // 我的任务列表
184
+ const tasks = await communityWeb.getMyTasks();
185
+
186
+ // 领取某个任务奖励
187
+ await communityWeb.acceptAward("61273ccf1730f4308e853f6a");
188
+
189
+ // 个人金币余额(充值 / 赠送 / 提现 三栏分离)
190
+ const coin = await communityWeb.getPersonalCurrencyAccount();
191
+ // coin: { internalCurrencyBalance, topUpCurrencyBalance, withdrawCurrencyBalance }
192
+
193
+ // 全部表情包 + 分页 + 分类
194
+ const [allEmoji, emojiPage, categories] = await Promise.all([
195
+ communityWeb.getAllEmojis(),
196
+ communityWeb.getEmojiPage("ENABLED", { page: 1, perPage: 50 }),
197
+ communityWeb.getEmojiCategoryList(),
198
+ ]);
199
+
200
+ // 签到
201
+ await communityWeb.insertCheckInRecord(); // 今日打卡
202
+ const history = await communityWeb.getCheckInRecords();
203
+
204
+ // 作品 / 评论 打赏(需要token,消耗账户金币)
205
+ // 给某个作品打赏 1 金币(objectType 默认 "CREATION"
206
+ await communityWeb.donateTrade(1, "68ce4849811b737483bf7027", "CREATION");
207
+ ```
208
+
209
+ ### 黑名单、封禁、禁言查询
210
+
211
+ ```ts
212
+ const STUDENT = "63c2807d669fa967f17f5559";
213
+
214
+ // 轻量:是否拉黑(只返回 NOT_BLOCKED / BLOCKING)
215
+ const s = await communityWeb.getStudentBlockStatus(STUDENT);
216
+
217
+ // 详细:完整的 BlockActionRecord(拉黑动作记录,oid / createdAt / fromEntityId)
218
+ const detail = await communityWeb.getStudentBlockRecordDetail(STUDENT);
219
+
220
+ // 封禁详情(带泛型,locked=false 时其他字段全为 null)
221
+ const locked = await communityWeb.getLockedUserDetail<true>(
222
+ "642c0e8a59230841adf62406",
223
+ );
224
+
225
+ // 禁言详情(studentNumber 是 244373873 这种数字字符串,null 表示未禁言)
226
+ const muted = await communityWeb.getMutedUserDetail("244373873");
227
+ ```
228
+
229
+ ### 智能金币合约
230
+
231
+ ```ts
232
+ // 列出作品中的智能金币合约
233
+ const contracts = await communityWeb.getSmartContractList(
234
+ "6a3fa1ed159ed52f170c34d2",
235
+ );
236
+ // contracts: SmartCoinContract[]
237
+
238
+ // 查询合约账户余额
239
+ const account = await communityWeb.getSmartContractAccount(2022277721908162);
240
+ // account: { balance: 300 }
241
+
242
+ // 获取合约详情
243
+ const detail = await communityWeb.getSmartContractDetail(2022277721908162);
244
+ // detail: { accountId, bizId, rules, status, title, type, ... }
245
+
246
+ // 执行合约(领取试玩奖励 / 玩家投币)
247
+ const result = await communityWeb.executeSmartContract(
248
+ "6a3fa1ed159ed52f170c34d2", // bizId
249
+ 2022277721908162, // contract id
250
+ 378074, // rule id(award)
251
+ 1, // bucks
252
+ );
253
+ // result: { success: true }
254
+ ```
255
+
256
+ ### 连接社区扩展
257
+
258
+ ```ts
259
+ // 查询是否关注了创作者
260
+ const following = await communityWeb.getConnectCommunityFollowingStatus(
261
+ "6a3fa1ed159ed52f170c34d2", // 当前播放的作品 OID
262
+ "651e3f7310b0530e7f80fe7a", // 目标用户 OID
263
+ );
264
+ // following: { avatar, isFollowing: boolean, name, oid }
265
+
266
+ // 查询用户对作品的点赞交互状态
267
+ const like = await communityWeb.getConnectCommunityCreationLikeStatus(
268
+ "6a3fa1ed159ed52f170c34d2", // 当前播放的作品 OID
269
+ "6a3fa1ed159ed52f170c34d2", // 目标作品 OID
270
+ );
271
+ // like: { interactionStatus: boolean, oid, title }
272
+
273
+ // 关注创作者(需要 token)
274
+ await communityWeb.followCreator("651e3f7310b0530e7f80fe7a");
275
+ // → "FOLLOWED"
276
+ ```
277
+
278
+ ### 商城商品 & 用户商店(头像框 / 表情 / 周边)
279
+
280
+ ```ts
281
+ // ====== CCW 官方商城(商品分页查询) ======
282
+ // ProductCategory: 5=头像框, 7=周边商品, 10=表情
283
+ // ProductSource: "CCW_OFFICIAL"
284
+
285
+ // 查询周边商品分类的商城列表
286
+ const mallPage1 = await communityWeb.queryMallProductPage(
287
+ 7, // productCategory: 周边商品
288
+ "CCW_OFFICIAL", // source
289
+ { page: 1, perPage: 30, sortType: "DESC" },
290
+ );
291
+ // mallPage1: PagesRes<Product>
292
+ console.log(mallPage1.totalNum); // 293
293
+ console.log(mallPage1.data[0].name); // "运动好物|Star世达足球"
294
+ console.log(mallPage1.data[0].pointPrice); // 13299(金币价格)
295
+ console.log(mallPage1.data[0].stockNum); // 库存
296
+
297
+ // 查询头像框分类
298
+ const avatarFrames = await communityWeb.queryMallProductPage(
299
+ 5, // productCategory: 头像框
300
+ "CCW_OFFICIAL",
301
+ { page: 1, perPage: 8, sortType: "DESC" },
302
+ );
303
+ // avatarFrames.data[0].virtualValue 头像框图片 URL
304
+
305
+ // 查询表情分类
306
+ const emojis = await communityWeb.queryMallProductPage(
307
+ 10, // productCategory: 表情
308
+ "CCW_OFFICIAL",
309
+ );
310
+ // emojis.data[0].virtualValue → 表情包 ID(如 "13"
311
+
312
+ // ====== 用户已拥有的商品(需要 token) ======
313
+ // 拉取用户拥有的头像框列表
314
+ const myProducts = await communityWeb.getUserProductsPage(
315
+ 5, // productCategory=5 头像框
316
+ { page: 1, perPage: 8, sortType: "DESC", sortField: "" },
317
+ );
318
+ // myProducts: PagesRes<UserProduct>
319
+ // myProducts.data[0].status → 1=已佩戴, 0=未佩戴
320
+
321
+ // 切换商品佩戴状态(需要 token)
322
+ // 卸下头像框
323
+ await communityWeb.setUserProductStatus(false, 105847); // id, status=false
324
+ // 佩戴头像框
325
+ await communityWeb.setUserProductStatus(true, 105847);
326
+ ```
327
+
328
+ ### 更换代表作
329
+
330
+ ```ts
331
+ // 将指定作品设为个人代表作(需要 token,creationOid 必须是自己的作品)
332
+ await communityWeb.updateGreatCreation("68ce4849811b737483bf7027");
333
+ // → true 表示成功
334
+ ```
335
+
336
+ ---
337
+
338
+ ## 模块三:Gandi-Main(gandi-main.ccw.site)
339
+
340
+ 公告、服务器时间与作品排行榜相关,共 **5 个 API**:
341
+
342
+ ```ts
343
+ const {
344
+ getCurrentTimestamp,
345
+ getBulletinsPage,
346
+ getBulletinDetail,
347
+ submitLeaderboardRecord,
348
+ getLeaderboardRecords,
349
+ } = gandiMain;
350
+
351
+ // 服务端当前毫秒级时间戳(比客户端时间更可靠,可用于签到、排行榜等需要严格时间判断的场景)
352
+ const ts = await gandiMain.getCurrentTimestamp();
353
+
354
+ // 分页拉取公告列表(默认按 publishedAt 倒序,过滤已发布)
355
+ const bulletins = await gandiMain.getBulletinsPage("PUBLISHED", {
356
+ page: 1,
357
+ perPage: 10,
358
+ });
359
+ // bulletins.data[0].title / id / publishedAt
360
+
361
+ // 某条公告详情
362
+ const detail = await gandiMain.getBulletinDetail(123);
363
+
364
+ // ====== 作品排行榜 ======
365
+
366
+ // 获取排行榜记录(含榜单配置、当前用户排名、完整记录分页列表)
367
+ const board = await gandiMain.getLeaderboardRecords("65a2314daa96bd09b5beae5a");
368
+ console.log(board.title); // "总收益"
369
+ console.log(board.scoreUnit); // "币"
370
+ console.log(board.sortType); // "DESC"
371
+ console.log(board.leaderboardRecordTotalNum); // 834
372
+ console.log(board.curUserLeaderboardRecord?.ranking); // 139
373
+ console.log(board.leaderboardRecords[0].ranking); // 1
374
+ console.log(board.leaderboardRecords[0].score); // 排行榜最高分
375
+ console.log(board.leaderboardRecords[0].user?.nickname); // 榜首昵称
376
+
377
+ // 向排行榜提交分数记录(需要token:userOid必须对应当前登录用户)
378
+ await gandiMain.submitLeaderboardRecord(
379
+ "65a2314daa96bd09b5beae5a", // 排行榜oid
380
+ 1500, // 分数
381
+ "6a42413ccc79993c436d04b6", // 用户oid
382
+ "", // 扩展信息(可选)
383
+ );
384
+ ```
385
+
386
+ ---
387
+
388
+ ## 模块四:BFS-Web(bfs-web.ccw.site)
389
+
390
+ 用户扩展(extension)管理与扩展打赏,共 **2 API**:
391
+
392
+ ```ts
393
+ const { getUserExtensions, donateExtension } = bfsWeb;
394
+
395
+ // 分页查询某用户上传/使用过的扩展列表(默认按 updatedAt 倒序)
396
+ const exts = await bfsWeb.getUserExtensions("63c2807d669fa967f17f5559", {
397
+ page: 1,
398
+ perPage: 20,
399
+ });
400
+ // exts: PagesRes<Extension>
401
+
402
+ // 给某个扩展打赏(需要token,消耗账户金币)
403
+ await bfsWeb.donateExtension(
404
+ "spineAnimation", // 扩展id(eid)
405
+ 5, // 打赏金币数量
406
+ );
407
+ ```
408
+
409
+ ---
410
+
411
+ ## 模块五:Community-Web-Cloud-Database(community-web-cloud-database.ccw.site
412
+
413
+ 作品 / 用户的云变量(键值对存储)管理,共 **3 个 API**:
414
+
415
+ ```ts
416
+ const {
417
+ saveProjectCloudVariable,
418
+ saveUserCloudVariable,
419
+ getCloudVariableDetailV2,
420
+ } = communityWebCloudDatabase;
421
+
422
+ // 保存作品云变量(无需token,主键是作品id;value结构任意,泛型自动推导返回)
423
+ const saved1 = await communityWebCloudDatabase.saveProjectCloudVariable(
424
+ "651c9a5142f8fb5ada70fad2",
425
+ "backup_65d31eaeb2ce1b785ebea87b_云时间",
426
+ { v: "2025-07-05T17:40:53.057+0800" },
427
+ );
428
+ // saved1: { v: string }
429
+ // ^? 泛型自动匹配 value 传入的结构
430
+
431
+ // 保存用户云变量(需要token,主键内部自动为 userId 拼接 "-u" 后缀)
432
+ const saved2 = await communityWebCloudDatabase.saveUserCloudVariable(
433
+ "68dddc63d28b025cb53fae25",
434
+ "256053228",
435
+ { key2: "0" },
436
+ );
437
+ // saved2: { key2: string }
438
+
439
+ // 查询云变量详情 V2
440
+ const detail = await communityWebCloudDatabase.getCloudVariableDetailV2(
441
+ "6a3fa1ed159ed52f170c34d2", // accessKey
442
+ "6a3fa1ed159ed52f170c34d2-u", // primaryKey
443
+ "244373873", // secondaryKey
444
+ ["4576y!!2"], // filterKeys
445
+ );
446
+ // detail: { ... } // 具体结构取决于存储的数据
447
+ ```
448
+
449
+ ---
450
+
451
+ ## 模块六:OP-Parent-API(op-parent-api.xiguacity.cn)
452
+
453
+ 家长端图形验证码服务,共 **2 个 API**:
454
+
455
+ ```ts
456
+ const { createCaptcha, checkCaptcha } = opParentApi;
457
+
458
+ // 创建图形验证码(滑块拼图)
459
+ const captcha = await opParentApi.createCaptcha("BLOCK_PUZZLE");
460
+ // captcha: { data: { bgImg: string, jigsawImg: string }, token: string }
461
+
462
+ // 校验图形验证码(拼图滑块坐标)
463
+ const result = await opParentApi.checkCaptcha(captcha.token, 120, 5);
464
+ // result: { captchaExpired: boolean, errorMsg: string | null, success: boolean }
465
+ ```
466
+
467
+ ---
468
+
469
+ ### 通用工具型 API
470
+
471
+ ```ts
472
+ // 生成短链
473
+ await communityWeb.createShortUrl("https://ccw.site/detail/xxx");
474
+
475
+ // 生成邀请码(api/v1/short_code/encode)
476
+ await communityWeb.encodeShortCode("hello world", 1, 6);
477
+
478
+ // 服务器时间
479
+ await communityWeb.getTime();
480
+
481
+ // 埋点事件上报
482
+ await communityWeb.sendEvent("creation_detail_view_6880873d2211fa69e41c9d19");
483
+
484
+ // 广告横幅
485
+ await communityWeb.getLeafletsItemList(1001);
486
+
487
+ // 学科专区(分页 / 按频道)
488
+ await communityWeb.getSubjectAreaPage({ page: 1, perPage: 20 });
489
+ await communityWeb.getSubjectAreaPageByChannel("PRIMARY");
490
+ ```
491
+
492
+ ---
493
+
494
+ ## 类型系统
495
+
496
+ ### 原语类型(`types/api.d.ts`)
497
+
498
+ 可直接从包顶层作为 `type` 导入:
499
+
500
+ ```ts
501
+ import type {
502
+ MongoDBId, // 24 位 hex 字符串(ObjectId)
503
+ CNameOssUrl, // https://m.ccw.site/... 或 https://m.xiguacity.cn/... OSS URL
504
+ UUID, // `${string}-${string}-${string}-${string}-${string}` 类型体操
505
+ ApiResponse, // { code, msg, body: T } 后端统一响应壳(SDK 内部已拆)
506
+ } from "@ccw-api/api";
507
+ ```
508
+
509
+ ### 领域命名空间
510
+
511
+ 每个 `types/*.d.ts` 作为一个命名空间重新导出,**避免同名类型冲突**(典型如 `Student` vs `StudentOverview` vs `Account.Types.Student`):
512
+
513
+ ```ts
514
+ import type {
515
+ Api, // 原语类型(MongoDBId / CNameOssUrl / UUID / ApiResponse ...)
516
+ UserData, // Student / StudentOverview / CreatorScore / UserCard ...
517
+ Creation, // Creation / HashTag / HashTagCreationRank / CreationRelease ...
518
+ Comment, // Comment / CommentStatus ...
519
+ Notification, // Notification / NotificationSenderInfo / NotificationGroup ...
520
+ NotificationContent, // 15 种通知 content 判别联合
521
+ Pages, // PageArgs / PagesRes
522
+ Session, // StudentSession / SessionArea
523
+ Account, // AccountTypes
524
+ Approval, // ApprovalTag
525
+ } from "@ccw-api/api";
526
+
527
+ type Score = UserData.CreatorScore["rank"]; // "ORDINARY" | "HACKER" | "ADVANCED"
528
+ type PlanetRank = Creation.HashTagCreationRank; // "ORDINARY"
529
+ ```
530
+
531
+ ---
532
+
533
+ ## 分页约定
534
+
535
+ 所有分页 API 都遵循同一套形状(详见 `types/pages.d.ts` + `src/queryPages.ts`):
536
+
537
+ ```ts
538
+ import type { PageArgs, PagesRes } from "@ccw-api/api";
539
+
540
+ // 入参 T extends string
541
+ // Partial<PageArgs<SortField|T>>,默认 { page:1, perPage:20, sortType:"DESC" }
542
+ // 出参 PagesRes<T> 完整结构:
543
+ const p: PagesRes<Creation.Creation> = {
544
+ data: [], // 当前页数据
545
+ page: 1,
546
+ perPage: 20,
547
+ offset: 0,
548
+ totalNum: 1234, // 总条数 —— 之前版本被截断,目前 SDK 已完整透出
549
+ totalPages: 62, // 总页数
550
+ sortField: "createdAt",
551
+ sortType: "DESC",
552
+ };
553
+ ```
554
+
555
+ ---
556
+
557
+ ## 开发 & 发布
558
+
559
+ ```bash
560
+ # 三产物构建(node / esm / .d.ts)
561
+ npm run build
562
+
563
+ # 跑测试(Jest 30 + ts-jest,121 suites / 128 tests)
564
+ npm test
565
+ npm run test:dev # watch 模式
566
+
567
+ # 文档(TypeDoc,生成到 doc/ 或默认输出目录)
568
+ npm run doc
569
+ npm run doc:dev
570
+ ```
571
+
572
+ `npm publish` 会自动触发 `prepublishOnly` → **build + test** 全跑一遍,失败会阻断发布。
573
+
574
+ ---
575
+
576
+ ## 目录与规范
577
+
578
+ 所有 API 文件严格遵循 `AGENT.md` 规范:
579
+
580
+ - **按域名分组**:`src/sso` / `src/community-web` / `src/gandi-main` / `src/bfs-web` / `src/community-web-cloud-database` / `src/op-parent-api`,内部子目录对应 URL 路径
581
+ - **单文件单接口**:文件名 `kebab-case`,对应 endpoint 最后一段
582
+ - **7 段式模板**(每个 API 文件内部固定顺序):
583
+ 1. `import`
584
+ 2. `export const url = "https://..."`(调试 & 测试直接引用)
585
+ 3. `export type Req = { ... }`
586
+ 4. `export type Res = { ... }`(响应体内部,不含 `ApiResponse` 外层)
587
+ 5. 辅助类型
588
+ 6. JSDoc(`@param` / `@returns`)
589
+ 7. `export async function xxx(): Promise<Res>`
590
+
591
+ 新增 API 时,**最后记得在对应服务的 `index.ts`(如 `src/community-web/index.ts`、`src/gandi-main/index.ts` 等)里 `import + 对象字面量聚合导出`**,否则外部访问不到。