@ccw-api/api 0.4.2 → 0.6.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 (119) hide show
  1. package/README.md +591 -367
  2. package/dist/esm/community-web/ccw-mall/ccw/product/fe/query.js +34 -0
  3. package/dist/esm/community-web/ccw-mall/ccw/product/fe/query.test.js +8 -0
  4. package/dist/esm/community-web/comment/page_by_topic.js +1 -1
  5. package/dist/esm/community-web/extensions/creation-like/detail.js +14 -0
  6. package/dist/esm/community-web/extensions/creation-like/detail.test.js +4 -0
  7. package/dist/esm/community-web/extensions/following/status.js +14 -0
  8. package/dist/esm/community-web/extensions/following/status.test.js +4 -0
  9. package/dist/esm/community-web/great_creation/update.js +13 -0
  10. package/dist/esm/community-web/great_creation/update.test.js +4 -0
  11. package/dist/esm/community-web/index.js +22 -0
  12. package/dist/esm/community-web/post/post.test.js +0 -1
  13. package/dist/esm/community-web/smart_contract/account.js +13 -0
  14. package/dist/esm/community-web/smart_contract/account.test.js +4 -0
  15. package/dist/esm/community-web/smart_contract/detail.js +13 -0
  16. package/dist/esm/community-web/smart_contract/detail.test.js +4 -0
  17. package/dist/esm/community-web/smart_contract/execute.js +17 -0
  18. package/dist/esm/community-web/smart_contract/execute.test.js +4 -0
  19. package/dist/esm/community-web/smart_contract/list.js +14 -0
  20. package/dist/esm/community-web/smart_contract/list.test.js +4 -0
  21. package/dist/esm/community-web/study-community/following/follow.js +13 -0
  22. package/dist/esm/community-web/study-community/following/follow.test.js +4 -0
  23. package/dist/esm/community-web/user_package/status.js +14 -0
  24. package/dist/esm/community-web/user_package/status.test.js +4 -0
  25. package/dist/esm/community-web/user_package/user_product.js +29 -0
  26. package/dist/esm/community-web/user_package/user_product.test.js +9 -0
  27. package/dist/esm/community-web-cloud-database/cloud_variable/detail/v2.js +16 -0
  28. package/dist/esm/community-web-cloud-database/cloud_variable/detail/v2.test.js +4 -0
  29. package/dist/esm/community-web-cloud-database/cloud_variable/save.js +29 -0
  30. package/dist/esm/community-web-cloud-database/cloud_variable/save.test.js +13 -0
  31. package/dist/esm/community-web-cloud-database/index.js +7 -0
  32. package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.js +28 -0
  33. package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.test.js +11 -0
  34. package/dist/esm/gandi-main/index.js +3 -0
  35. package/dist/esm/index.js +5 -1
  36. package/dist/esm/op-parent-api/captcha/check.js +15 -0
  37. package/dist/esm/op-parent-api/captcha/check.test.js +12 -0
  38. package/dist/esm/op-parent-api/captcha/create.js +13 -0
  39. package/dist/esm/op-parent-api/captcha/create.test.js +13 -0
  40. package/dist/esm/op-parent-api/index.js +6 -0
  41. package/dist/esm/sso/index.js +4 -0
  42. package/dist/esm/sso/web/auth/assistant/captcha/v2/create.js +17 -0
  43. package/dist/esm/sso/web/auth/assistant/captcha/v2/create.test.js +8 -0
  44. package/dist/esm/sso/web/auth/login-by-password.js +4 -3
  45. package/dist/esm/sso/web/auth/v3/login/by-phone.js +33 -0
  46. package/dist/esm/sso/web/auth/v3/login/by-phone.test.js +7 -0
  47. package/dist/node/community-web/ccw-mall/ccw/product/fe/query.js +38 -0
  48. package/dist/node/community-web/ccw-mall/ccw/product/fe/query.test.js +10 -0
  49. package/dist/node/community-web/comment/page_by_topic.js +1 -1
  50. package/dist/node/community-web/extensions/creation-like/detail.js +18 -0
  51. package/dist/node/community-web/extensions/creation-like/detail.test.js +6 -0
  52. package/dist/node/community-web/extensions/following/status.js +18 -0
  53. package/dist/node/community-web/extensions/following/status.test.js +6 -0
  54. package/dist/node/community-web/great_creation/update.js +17 -0
  55. package/dist/node/community-web/great_creation/update.test.js +6 -0
  56. package/dist/node/community-web/index.js +22 -0
  57. package/dist/node/community-web/post/post.test.js +0 -1
  58. package/dist/node/community-web/smart_contract/account.js +17 -0
  59. package/dist/node/community-web/smart_contract/account.test.js +6 -0
  60. package/dist/node/community-web/smart_contract/detail.js +17 -0
  61. package/dist/node/community-web/smart_contract/detail.test.js +6 -0
  62. package/dist/node/community-web/smart_contract/execute.js +21 -0
  63. package/dist/node/community-web/smart_contract/execute.test.js +6 -0
  64. package/dist/node/community-web/smart_contract/list.js +18 -0
  65. package/dist/node/community-web/smart_contract/list.test.js +6 -0
  66. package/dist/node/community-web/study-community/following/follow.js +17 -0
  67. package/dist/node/community-web/study-community/following/follow.test.js +6 -0
  68. package/dist/node/community-web/user_package/status.js +18 -0
  69. package/dist/node/community-web/user_package/status.test.js +6 -0
  70. package/dist/node/community-web/user_package/user_product.js +33 -0
  71. package/dist/node/community-web/user_package/user_product.test.js +11 -0
  72. package/dist/node/community-web-cloud-database/cloud_variable/detail/v2.js +20 -0
  73. package/dist/node/community-web-cloud-database/cloud_variable/detail/v2.test.js +6 -0
  74. package/dist/node/community-web-cloud-database/cloud_variable/save.js +34 -0
  75. package/dist/node/community-web-cloud-database/cloud_variable/save.test.js +15 -0
  76. package/dist/node/community-web-cloud-database/index.js +10 -0
  77. package/dist/node/gandi-main/creation/leaderboards/{oid}/records.js +33 -0
  78. package/dist/node/gandi-main/creation/leaderboards/{oid}/records.test.js +13 -0
  79. package/dist/node/gandi-main/index.js +3 -0
  80. package/dist/node/index.js +7 -1
  81. package/dist/node/op-parent-api/captcha/check.js +19 -0
  82. package/dist/node/op-parent-api/captcha/check.test.js +14 -0
  83. package/dist/node/op-parent-api/captcha/create.js +17 -0
  84. package/dist/node/op-parent-api/captcha/create.test.js +15 -0
  85. package/dist/node/op-parent-api/index.js +9 -0
  86. package/dist/node/sso/index.js +4 -0
  87. package/dist/node/sso/web/auth/assistant/captcha/v2/create.js +21 -0
  88. package/dist/node/sso/web/auth/assistant/captcha/v2/create.test.js +10 -0
  89. package/dist/node/sso/web/auth/login-by-password.js +4 -3
  90. package/dist/node/sso/web/auth/v3/login/by-phone.js +37 -0
  91. package/dist/node/sso/web/auth/v3/login/by-phone.test.js +9 -0
  92. package/dist/types/community-web/ccw-mall/ccw/product/fe/query.d.ts +54 -0
  93. package/dist/types/community-web/comment/page_by_topic.d.ts +1 -1
  94. package/dist/types/community-web/extensions/creation-like/detail.d.ts +18 -0
  95. package/dist/types/community-web/extensions/following/status.d.ts +19 -0
  96. package/dist/types/community-web/great_creation/update.d.ts +12 -0
  97. package/dist/types/community-web/index.d.ts +22 -0
  98. package/dist/types/community-web/post/detail.d.ts +1 -1
  99. package/dist/types/community-web/smart_contract/account.d.ts +13 -0
  100. package/dist/types/community-web/smart_contract/detail.d.ts +24 -0
  101. package/dist/types/community-web/smart_contract/execute.d.ts +25 -0
  102. package/dist/types/community-web/smart_contract/list.d.ts +49 -0
  103. package/dist/types/community-web/study-community/following/follow.d.ts +12 -0
  104. package/dist/types/community-web/user_package/status.d.ts +13 -0
  105. package/dist/types/community-web/user_package/user_product.d.ts +40 -0
  106. package/dist/types/community-web-cloud-database/cloud_variable/detail/v2.d.ts +17 -0
  107. package/dist/types/community-web-cloud-database/cloud_variable/save.d.ts +26 -0
  108. package/dist/types/community-web-cloud-database/index.d.ts +7 -0
  109. package/dist/types/gandi-main/creation/leaderboards/{oid}/records.d.ts +62 -0
  110. package/dist/types/gandi-main/index.d.ts +3 -0
  111. package/dist/types/index.d.ts +27 -1
  112. package/dist/types/op-parent-api/captcha/check.d.ts +21 -0
  113. package/dist/types/op-parent-api/captcha/create.d.ts +24 -0
  114. package/dist/types/op-parent-api/index.d.ts +6 -0
  115. package/dist/types/sso/index.d.ts +4 -0
  116. package/dist/types/sso/web/auth/assistant/captcha/v2/create.d.ts +34 -0
  117. package/dist/types/sso/web/auth/login-by-password.d.ts +2 -18
  118. package/dist/types/sso/web/auth/v3/login/by-phone.d.ts +38 -0
  119. package/package.json +2 -2
@@ -0,0 +1,34 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ import { DEFAULT_PAGE_ARGS, queryPage } from "src/queryPages";
3
+ export const url = "https://community-web.ccw.site/ccw-mall/ccw/product/fe/query";
4
+ export var ProductCategory;
5
+ (function (ProductCategory) {
6
+ ProductCategory[ProductCategory["Merchandise"] = 7] = "Merchandise";
7
+ ProductCategory[ProductCategory["AvatarFrame"] = 5] = "AvatarFrame";
8
+ ProductCategory[ProductCategory["EMOJI"] = 10] = "EMOJI";
9
+ })(ProductCategory || (ProductCategory = {}));
10
+ /**
11
+ * 分页查询CCW小商店商品列表
12
+ * @param {ProductCategory | undefined} productCategory 商品分类(可选):5=头像框,7=周边商品,10=表情 等
13
+ * @param {Partial<PageArgs<ProductSortField>>} pageArgs_ 分页参数(默认 page=1, perPage=30, sortType="DESC")
14
+ * @returns {Promise<Res>} 商品分页结果 PagesRes<Product>
15
+ */
16
+ export async function queryMallProducts(productCategory, pageArgs_ = {
17
+ sortField: "createdAt",
18
+ }) {
19
+ const pageArgs = {
20
+ ...DEFAULT_PAGE_ARGS,
21
+ ...pageArgs_,
22
+ };
23
+ const queryUrl = queryPage(url, pageArgs);
24
+ const req = {
25
+ page: pageArgs.page,
26
+ perPage: pageArgs.perPage,
27
+ sortType: pageArgs.sortType,
28
+ productCategory,
29
+ source: "CCW_OFFICIAL",
30
+ };
31
+ return await ccwAxios
32
+ .post(queryUrl, req)
33
+ .then((res) => res.data.body);
34
+ }
@@ -0,0 +1,8 @@
1
+ import { queryMallProducts } from "./query";
2
+ test("query mall product page should fail without token", async () => {
3
+ await expect(queryMallProducts(7, {
4
+ page: 1,
5
+ perPage: 30,
6
+ sortType: "DESC",
7
+ })).rejects.toThrow();
8
+ });
@@ -9,7 +9,7 @@ const dpa = {
9
9
  * 根据主题获取评论列表
10
10
  * @param {string} subjectOid 主题oid
11
11
  * @param {SubjectType} subjectType 主题类型 (如: "POST")
12
- * @param {string} sectionType 区块类型 (如: "COMMENT")
12
+ * @param {SectionType} sectionType 区块类型 (如: "COMMENT")
13
13
  * @param {Partial<PageArgs<SortField| T>>} pageArgs_ 分页参数
14
14
  * @returns {Promise<Res>} 评论分页结果
15
15
  */
@@ -0,0 +1,14 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/extensions/creation-like/detail";
3
+ /**
4
+ * [连接社区扩展] 查询用户对作品的点赞交互状态
5
+ * @param {MongoDBId} playingCreationOid 当前播放的作品 OID
6
+ * @param {MongoDBId} creationOid 目标作品 OID
7
+ * @returns {Promise<Res>} 点赞状态及作品信息
8
+ */
9
+ export async function getConnectCommunityCreationLikeStatus(playingCreationOid, creationOid) {
10
+ const req = { playingCreationOid, creationOid };
11
+ return await ccwAxios
12
+ .post(url, req)
13
+ .then((res) => res.data.body);
14
+ }
@@ -0,0 +1,4 @@
1
+ import { getConnectCommunityCreationLikeStatus } from "./detail";
2
+ test("should fail without token when getting creation like status", async () => {
3
+ await expect(getConnectCommunityCreationLikeStatus("6a3fa1ed159ed52f170c34d2", "6a3fa1ed159ed52f170c34d2")).rejects.toThrow();
4
+ });
@@ -0,0 +1,14 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/extensions/following/status";
3
+ /**
4
+ * [连接社区扩展] 查询是否关注了指定创作者
5
+ * @param {MongoDBId} playingCreationOid 当前播放的作品 OID
6
+ * @param {MongoDBId} userOid 目标用户 OID
7
+ * @returns {Promise<Res>} 关注状态及用户信息
8
+ */
9
+ export async function getConnectCommunityFollowingStatus(playingCreationOid, userOid) {
10
+ const req = { playingCreationOid, userOid };
11
+ return await ccwAxios
12
+ .post(url, req)
13
+ .then((res) => res.data.body);
14
+ }
@@ -0,0 +1,4 @@
1
+ import { getConnectCommunityFollowingStatus } from "./status";
2
+ test("should fail without token when getting following status", async () => {
3
+ await expect(getConnectCommunityFollowingStatus("6a3fa1ed159ed52f170c34d2", "651e3f7310b0530e7f80fe7a")).rejects.toThrow();
4
+ });
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/great_creation/update";
3
+ /**
4
+ * 更换代表作
5
+ * @param {MongoDBId|""} creationOid 作品OID 若为""则是取消展示
6
+ * @returns {Promise<Res>} 更换结果
7
+ */
8
+ export async function updateGreatCreation(creationOid) {
9
+ const req = { creationOid };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,4 @@
1
+ import { updateGreatCreation } from "./update";
2
+ test("should fail without token when updating great creation", async () => {
3
+ await expect(updateGreatCreation("69740f1a61b891733d5ee2c6")).rejects.toThrow();
4
+ });
@@ -9,6 +9,7 @@ import { searchCloudAssets } from "./cloud_asset/search";
9
9
  import { getCommentReplies } from "./comment/page";
10
10
  import { getCommentsByTopic } from "./comment/page_by_topic";
11
11
  import { getConfigDetail } from "./config/detail";
12
+ import { queryMallProducts } from "./ccw-mall/ccw/product/fe/query";
12
13
  import { getCreationDetail } from "./creation/detail";
13
14
  import { getExcellentCreations } from "./creation/excellent/list";
14
15
  import { getCreationIntroduction } from "./creation/introduction/detail";
@@ -93,10 +94,21 @@ import { createComment } from "./comment/create";
93
94
  import { likeComment } from "./comment/like_record/create";
94
95
  import { getStudentFollowingPage } from "./student/following/page";
95
96
  import { donateTrade } from "./study-trade/trade/donate";
97
+ import { getUserProductsPage } from "./user_package/user_product";
98
+ import { setUserProductStatus } from "./user_package/status";
99
+ import { updateGreatCreation } from "./great_creation/update";
100
+ import { executeSmartContract } from "./smart_contract/execute";
101
+ import { getSmartContractAccount } from "./smart_contract/account";
102
+ import { getSmartContractDetail } from "./smart_contract/detail";
103
+ import { getSmartContractList } from "./smart_contract/list";
104
+ import { getConnectCommunityFollowingStatus } from "./extensions/following/status";
105
+ import { getConnectCommunityCreationLikeStatus } from "./extensions/creation-like/detail";
106
+ import { followCreator } from "./study-community/following/follow";
96
107
  export const communityWeb = {
97
108
  acceptAward,
98
109
  donateTrade,
99
110
  encodeShortCode,
111
+ executeSmartContract,
100
112
  createCloudVariable,
101
113
  createComment,
102
114
  createShortUrl,
@@ -104,6 +116,7 @@ export const communityWeb = {
104
116
  decompressShortUrl,
105
117
  deleteComment,
106
118
  foldComment,
119
+ followCreator,
107
120
  getApprovalTags,
108
121
  getCampaignResources,
109
122
  getCcwMainStatus: getCCWMainStatus,
@@ -117,6 +130,7 @@ export const communityWeb = {
117
130
  getCreationDetail,
118
131
  getCreationFavoriteDetail,
119
132
  getCreationIntroduction,
133
+ getConnectCommunityCreationLikeStatus,
120
134
  getCreationRecommendPositionList,
121
135
  getCreationReleasePage,
122
136
  getCreationScreenshotPage,
@@ -125,6 +139,7 @@ export const communityWeb = {
125
139
  getCreatorScore,
126
140
  getDonatedRecordRanking,
127
141
  getExcellentCreations,
142
+ getConnectCommunityFollowingStatus,
128
143
  getEmojiCategoryList,
129
144
  getEmojiPage,
130
145
  getAllEmojis,
@@ -153,6 +168,9 @@ export const communityWeb = {
153
168
  getRemixedCreationPage,
154
169
  getReputationScoreLogPage: getReputationScoreLog,
155
170
  getSearchHotWords,
171
+ getSmartContractAccount,
172
+ getSmartContractDetail,
173
+ getSmartContractList,
156
174
  getSplitRuleDetail,
157
175
  getSpreadFeedUnreadCount,
158
176
  getStudentBlockRecordDetail,
@@ -176,6 +194,8 @@ export const communityWeb = {
176
194
  getUserAssetStorageSize,
177
195
  getUserCardDetail,
178
196
  getUserLabelList,
197
+ getUserProductsPage,
198
+ queryMallProducts,
179
199
  getCreationsByStudent,
180
200
  insertCheckInRecord,
181
201
  likeComment,
@@ -184,9 +204,11 @@ export const communityWeb = {
184
204
  searchCloudAssets,
185
205
  searchCreationsByTag,
186
206
  sendEvent,
207
+ setUserProductStatus,
187
208
  submitCreation,
188
209
  topComment,
189
210
  updateCreation,
211
+ updateGreatCreation,
190
212
  updateStudent,
191
213
  viewCreationStats,
192
214
  };
@@ -1,7 +1,6 @@
1
1
  import { getPostDetail } from "./detail";
2
2
  test("get post detail", async () => {
3
3
  const detail = await getPostDetail("0173b23d-139d-4c48-ad98-0aa17b5d3b60");
4
- console.log(detail);
5
4
  await expect(detail.title.includes("【公告通知】")).toBeTruthy();
6
5
  });
7
6
  test("error when post detail not found", async () => {
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/smart_contract/account";
3
+ /**
4
+ * 查询智能合约账户余额
5
+ * @param {number} id 合约 ID
6
+ * @returns {Promise<Res>} 合约账户余额
7
+ */
8
+ export async function getSmartContractAccount(id) {
9
+ const req = { id };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,4 @@
1
+ import { getSmartContractAccount } from "./account";
2
+ test("should fail without token when getting smart contract account", async () => {
3
+ await expect(getSmartContractAccount(2022277721908162)).rejects.toThrow();
4
+ });
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/smart_contract/detail";
3
+ /**
4
+ * 获取智能合约详情
5
+ * @param {number} id 合约 ID
6
+ * @returns {Promise<Res>} 合约详情
7
+ */
8
+ export async function getSmartContractDetail(id) {
9
+ const req = { id };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,4 @@
1
+ import { getSmartContractDetail } from "./detail";
2
+ test("should fail without token when getting smart contract detail", async () => {
3
+ await expect(getSmartContractDetail(2022277721908162)).rejects.toThrow();
4
+ });
@@ -0,0 +1,17 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/smart_contract/execute";
3
+ /**
4
+ * 执行智能合约(投币/领取奖励)
5
+ * @param {MongoDBId} bizId 业务 ID(如作品 OID)
6
+ * @param {SmartContractBizType} bizType 业务类型,CREATION
7
+ * @param {number} id 合约 ID
8
+ * @param {number} ruleId 规则 ID
9
+ * @param {number} bucks 金币数量
10
+ * @returns {Promise<Res>} 执行结果
11
+ */
12
+ export async function executeSmartContract(bizId, id, ruleId, bucks, bizType = "CREATION") {
13
+ const req = { bizId, bizType, id, ruleId, params: { bucks } };
14
+ return await ccwAxios
15
+ .post(url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,4 @@
1
+ import { executeSmartContract } from "./execute";
2
+ test("should fail without token when executing smart contract", async () => {
3
+ await expect(executeSmartContract("6a3fa1ed159ed52f170c34d2", 2022277721908162, 378074, 1)).rejects.toThrow();
4
+ });
@@ -0,0 +1,14 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/smart_contract/list";
3
+ /**
4
+ * 列出作品中的智能金币合约
5
+ * @param {MongoDBId} bizId 业务ID(如作品OID)
6
+ * @param {SmartContractBizType} bizType 业务类型,CREATION
7
+ * @returns {Promise<Res>} 智能合约列表
8
+ */
9
+ export async function getSmartContractList(bizId, bizType = "CREATION") {
10
+ const req = { bizId, bizType };
11
+ return await ccwAxios
12
+ .post(url, req)
13
+ .then((res) => res.data.body);
14
+ }
@@ -0,0 +1,4 @@
1
+ import { getSmartContractList } from "./list";
2
+ test("should fail without token when listing smart contracts", async () => {
3
+ await expect(getSmartContractList("679d79862de3ec4dde55d534")).rejects.toThrow();
4
+ });
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/study-community/following/follow";
3
+ /**
4
+ * 关注创作者
5
+ * @param {MongoDBId} followingOid 要关注的用户 OID
6
+ * @returns {Promise<Res>} "FOLLOWED" 表示关注成功
7
+ */
8
+ export async function followCreator(followingOid) {
9
+ const req = { followingOid };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,4 @@
1
+ import { followCreator } from "./follow";
2
+ test("should fail without token when following creator", async () => {
3
+ await expect(followCreator("651e3f7310b0530e7f80fe7a")).rejects.toThrow();
4
+ });
@@ -0,0 +1,14 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/user_package/status";
3
+ /**
4
+ * 设置用户商品状态(如佩戴/卸下头像框)
5
+ * @param {number} id 用户商品ID
6
+ * @param {boolean} status 商品状态,true为佩戴,false为卸下
7
+ * @returns {Promise<Res>} 设置结果
8
+ */
9
+ export async function setUserProductStatus(id, status) {
10
+ const req = { status, id };
11
+ return await ccwAxios
12
+ .post(url, req)
13
+ .then((res) => res.data.body);
14
+ }
@@ -0,0 +1,4 @@
1
+ import { setUserProductStatus } from "./status";
2
+ test("should fail without token when setting user product status", async () => {
3
+ await expect(setUserProductStatus(105847, false)).rejects.toThrow();
4
+ });
@@ -0,0 +1,29 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ import { queryPage, DEFAULT_PAGE_ARGS } from "src/queryPages";
3
+ export const url = "https://community-web.ccw.site/user_package/user_product";
4
+ export var ProductCategory;
5
+ (function (ProductCategory) {
6
+ ProductCategory[ProductCategory["AVATAR_FRAME"] = 5] = "AVATAR_FRAME";
7
+ })(ProductCategory || (ProductCategory = {}));
8
+ /**
9
+ * 分页获取用户商品(如头像框)
10
+ * @param {ProductCategory} productCategory 商品分类,默认5为头像框
11
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
12
+ * @returns {Promise<Res>} 分页用户商品数据
13
+ */
14
+ export async function getUserProductsPage(productCategory = ProductCategory.AVATAR_FRAME, pageArgs_ = {}) {
15
+ const pageArgs = {
16
+ ...DEFAULT_PAGE_ARGS,
17
+ ...pageArgs_,
18
+ };
19
+ const queryUrl = queryPage(url, pageArgs);
20
+ const req = {
21
+ page: pageArgs.page,
22
+ perPage: pageArgs.perPage,
23
+ sortType: pageArgs.sortType,
24
+ productCategory,
25
+ };
26
+ return await ccwAxios
27
+ .post(queryUrl, req)
28
+ .then((res) => res.data.body);
29
+ }
@@ -0,0 +1,9 @@
1
+ import { getUserProductsPage, ProductCategory } from "./user_product";
2
+ test("should fail without token for avatar frame products", async () => {
3
+ await expect(getUserProductsPage(ProductCategory.AVATAR_FRAME, {
4
+ page: 1,
5
+ perPage: 8,
6
+ sortType: "DESC",
7
+ sortField: "",
8
+ })).rejects.toThrow();
9
+ });
@@ -0,0 +1,16 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web-cloud-database.ccw.site/cloud_variable/detail/v2";
3
+ /**
4
+ * 查询云变量详情 V2
5
+ * @param {string} accessKey 访问密钥(如作品 OID)
6
+ * @param {string} primaryKey 主键(如 `${projectId}-u`)
7
+ * @param {string} secondaryKey 次级键
8
+ * @param {string[]} filterKeys 过滤的变量名列表
9
+ * @returns {Promise<Res>} 云变量详情
10
+ */
11
+ export async function getCloudVariableDetailV2(accessKey, primaryKey, secondaryKey, filterKeys) {
12
+ const req = { accessKey, primaryKey, secondaryKey, filterKeys };
13
+ return await ccwAxios
14
+ .post(url, req)
15
+ .then((res) => res.data.body);
16
+ }
@@ -0,0 +1,4 @@
1
+ import { getCloudVariableDetailV2 } from "./v2";
2
+ test("get cloud variable detail v2 should reject with invalid params", async () => {
3
+ await expect(getCloudVariableDetailV2("6a3fa1ed159ed52f170c34d2", "6a3fa1ed159ed52f170c34d2-u", "244373873", ["4576y!!2"])).rejects.toThrow();
4
+ });
@@ -0,0 +1,29 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web-cloud-database.ccw.site/cloud_variable/save";
3
+ async function saveCloudVariableBase(primaryKey, secondaryKey, value) {
4
+ const req = { primaryKey, secondaryKey, value };
5
+ return await ccwAxios
6
+ .post(url, req)
7
+ .then((res) => res.data.body);
8
+ }
9
+ /**
10
+ * 保存作品云变量到云数据库
11
+ * @param {MongoDBId} projectId 作品id
12
+ * @param {string} secondaryKey 次级键 - 变量名或标识
13
+ * @param {T} value 要保存数据
14
+ * @returns {Promise<SaveCloudVariableRes<T>>} 保存后的值对象
15
+ */
16
+ export async function saveProjectCloudVariable(projectId, secondaryKey, value) {
17
+ return await saveCloudVariableBase(projectId, secondaryKey, { v: value });
18
+ }
19
+ /**
20
+ * 保存数据到用户云数据库
21
+ * @param {MongoDBId} projectId 作品id
22
+ * @param {number} studentNum 次级键 - 用户id
23
+ * @param {T} value 要保存的键值对
24
+ * @returns {Promise<SaveCloudVariableRes<T>>} 保存后的值对象
25
+ */
26
+ export async function saveUserCloudVariable(projectId, studentNum, value) {
27
+ const primaryKey = `${projectId}-u`;
28
+ return await saveCloudVariableBase(primaryKey, `${studentNum}`, value);
29
+ }
@@ -0,0 +1,13 @@
1
+ import { saveProjectCloudVariable, saveUserCloudVariable } from "./save";
2
+ test("save project cloud variable should return saved value", async () => {
3
+ const testValue = "2025-07-05T17:40:53.057+0800";
4
+ const res = await saveProjectCloudVariable("68dddc63d28b025cb53fae25", "test", testValue);
5
+ expect(res).toBeDefined();
6
+ expect(res.v).toBe(testValue);
7
+ });
8
+ test("save user cloud variable should ok", async () => {
9
+ const res = await saveUserCloudVariable("68dddc63d28b025cb53fae25", 0, {
10
+ key2: "0",
11
+ });
12
+ expect(res.key2).toEqual("0");
13
+ });
@@ -0,0 +1,7 @@
1
+ import { saveProjectCloudVariable, saveUserCloudVariable, } from "./cloud_variable/save";
2
+ import { getCloudVariableDetailV2 } from "./cloud_variable/detail/v2";
3
+ export const communityWebCloudDatabase = {
4
+ saveProjectCloudVariable,
5
+ saveUserCloudVariable,
6
+ getCloudVariableDetailV2,
7
+ };
@@ -0,0 +1,28 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://gandi-main.ccw.site/creation/leaderboards";
3
+ /**
4
+ * 向作品排行榜提交一条分数记录
5
+ * @param {MongoDBId} leaderboardOid 排行榜id
6
+ * @param {number} score 分数
7
+ * @param {MongoDBId} userOid 用户id
8
+ * @param {string} ext 扩展信息(可选)
9
+ * @returns {Promise<SubmitRes>} 是否提交成功
10
+ */
11
+ export async function submitLeaderboardRecord(leaderboardOid, score, userOid, ext = "") {
12
+ const req = { score, oid: userOid, ext };
13
+ const requestUrl = `${url}/${leaderboardOid}/records`;
14
+ return await ccwAxios
15
+ .post(requestUrl, req)
16
+ .then((res) => res.data.body);
17
+ }
18
+ /**
19
+ * 获取作品排行榜记录列表
20
+ * @param {MongoDBId} leaderboardOid 排行榜id
21
+ * @returns {Promise<LeaderboardRecordsRes>} 排行榜记录列表
22
+ */
23
+ export async function getLeaderboardRecords(leaderboardOid) {
24
+ const requestUrl = `${url}/${leaderboardOid}/records`;
25
+ return await ccwAxios
26
+ .get(requestUrl)
27
+ .then((res) => res.data.body);
28
+ }
@@ -0,0 +1,11 @@
1
+ import { getLeaderboardRecords, submitLeaderboardRecord } from "./records";
2
+ test("submit leaderboard record should fail without token", async () => {
3
+ await expect(submitLeaderboardRecord("65a2314daa96bd09b5beae5a", 0, "65a2314daa96bd09b5beae5a", "")).rejects.toThrow();
4
+ });
5
+ test("get leaderboard records should return data", async () => {
6
+ const res = await getLeaderboardRecords("65a2314daa96bd09b5beae5a");
7
+ expect(res.oid).toBe("65a2314daa96bd09b5beae5a");
8
+ expect(res.title).toBeDefined();
9
+ expect(res.leaderboardRecordTotalNum).toBeDefined();
10
+ expect(Array.isArray(res.leaderboardRecords)).toBe(true);
11
+ });
@@ -1,8 +1,11 @@
1
1
  import { getCurrentTimestamp } from "./timestamp/current";
2
2
  import { getBulletinsPage } from "./bulletins/page";
3
3
  import { getBulletinDetail } from "./bulletins/detail";
4
+ import { getLeaderboardRecords, submitLeaderboardRecord, } from "./creation/leaderboards/{oid}/records";
4
5
  export const gandiMain = {
5
6
  getCurrentTimestamp,
6
7
  getBulletinsPage,
7
8
  getBulletinDetail,
9
+ submitLeaderboardRecord,
10
+ getLeaderboardRecords,
8
11
  };
package/dist/esm/index.js CHANGED
@@ -2,11 +2,15 @@ import { sso } from "./sso/index";
2
2
  import { communityWeb } from "./community-web";
3
3
  import { gandiMain } from "./gandi-main";
4
4
  import { bfsWeb } from "./bfs-web";
5
- export { sso, communityWeb, gandiMain, bfsWeb };
5
+ import { communityWebCloudDatabase } from "./community-web-cloud-database";
6
+ import { opParentApi } from "./op-parent-api";
7
+ export { sso, communityWeb, gandiMain, bfsWeb, communityWebCloudDatabase, opParentApi, };
6
8
  export { setToken } from "@ccw-api/axios";
7
9
  export default {
8
10
  sso,
9
11
  communityWeb,
10
12
  gandiMain,
11
13
  bfsWeb,
14
+ communityWebCloudDatabase,
15
+ opParentApi,
12
16
  };
@@ -0,0 +1,15 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://op-parent-api.xiguacity.cn/captcha/check";
3
+ /**
4
+ * 校验图形验证码(拼图滑块坐标)
5
+ * @param {string} token createCaptcha 返回的 token
6
+ * @param {number} x 拼图滑块目标位置的 x 坐标
7
+ * @param {number} y 拼图滑块目标位置的 y 坐标
8
+ * @returns {Promise<Res>} 校验结果
9
+ */
10
+ export async function checkCaptcha(token, x, y = 5) {
11
+ const req = { data: { x, y }, token };
12
+ return await ccwAxios
13
+ .post(url, req)
14
+ .then((res) => res.data.body);
15
+ }
@@ -0,0 +1,12 @@
1
+ import { checkCaptcha } from "./check";
2
+ import { createCaptcha } from "./create";
3
+ test("checkCaptcha returns structured result with token and coords without auth", async () => {
4
+ const created = await createCaptcha("BLOCK_PUZZLE");
5
+ const res = await checkCaptcha(created.token, 0, -1);
6
+ expect(res).toHaveProperty("captchaExpired");
7
+ expect(res).toHaveProperty("errorMsg");
8
+ expect(res).toHaveProperty("success");
9
+ expect(res.captchaExpired).toBeFalsy();
10
+ expect(res.success).toBeFalsy();
11
+ expect(res.errorMsg).toEqual("验证失败");
12
+ }, 30000);
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://op-parent-api.xiguacity.cn/captcha/create";
3
+ /**
4
+ * 创建图形验证码(拼图滑块)
5
+ * @param {CaptchaType} type 验证码类型,默认 BLOCK_PUZZLE(滑块拼图)
6
+ * @returns {Promise<Res>} 验证码信息:bgImg为背景图base64 data url,jigsawImg为拼图块base64 data url,token用于后续校验
7
+ */
8
+ export async function createCaptcha(type = "BLOCK_PUZZLE") {
9
+ const req = { type };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { createCaptcha } from "./create";
2
+ test("create BLOCK_PUZZLE captcha returns bgImg, jigsawImg and token without token", async () => {
3
+ const res = await createCaptcha("BLOCK_PUZZLE");
4
+ expect(res).toHaveProperty("data");
5
+ expect(res.data).toHaveProperty("bgImg");
6
+ expect(res.data).toHaveProperty("jigsawImg");
7
+ expect(res).toHaveProperty("token");
8
+ expect(typeof res.token).toBe("string");
9
+ expect(typeof res.data.bgImg).toBe("string");
10
+ expect(typeof res.data.jigsawImg).toBe("string");
11
+ expect(res.data.bgImg.startsWith("data:image/png;base64,")).toBeTruthy();
12
+ expect(res.data.jigsawImg.startsWith("data:image/png;base64,")).toBeTruthy();
13
+ }, 30000);
@@ -0,0 +1,6 @@
1
+ import { createCaptcha } from "./captcha/create";
2
+ import { checkCaptcha } from "./captcha/check";
3
+ export const opParentApi = {
4
+ createCaptcha,
5
+ checkCaptcha,
6
+ };
@@ -1,8 +1,12 @@
1
1
  import { loginByPassword } from "./web/auth/login-by-password";
2
2
  import { logout } from "./web/auth/logout";
3
3
  import { logoutBySession } from "./web/auth/logout_by_session";
4
+ import { createSmsCaptcha } from "./web/auth/assistant/captcha/v2/create";
5
+ import { loginByPhone } from "./web/auth/v3/login/by-phone";
4
6
  export const sso = {
5
7
  loginByPassword,
6
8
  logout,
7
9
  logoutBySession,
10
+ createSmsCaptcha,
11
+ loginByPhone,
8
12
  };
@@ -0,0 +1,17 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://sso.ccw.site/web/auth/assistant/captcha/v2/create";
3
+ /**
4
+ * 发送短信验证码
5
+ * @param {string} recipient 接收手机号,如 "10011451919"
6
+ * @param {SmsScene} scene 场景,默认 loginbyPhone
7
+ * @param {string} countryCode 国家代码,默认 "86"
8
+ * @param {SmsRuleCode} ruleCode 短信规则编码,默认 "ccw_sms"
9
+ * @param {CaptchaPayload} captcha 图形验证码校验结果(滑块拼图的坐标与token),可选(部分场景未强制要求时可省略,但失败时sendResult!=1)
10
+ * @returns {Promise<Res>} 发送结果:batchId 为短信批次ID,sendResult=1 表示成功
11
+ */
12
+ export async function createSmsCaptcha(recipient, scene = "loginbyPhone", countryCode = "86", ruleCode = "ccw_sms", captcha) {
13
+ const req = { recipient, countryCode, scene, ruleCode, captcha };
14
+ return await ccwAxios
15
+ .post(url, req)
16
+ .then((res) => res.data.body);
17
+ }