@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,8 @@
1
+ import { createSmsCaptcha } from "./create";
2
+ test("createSmsCaptchaV2 returns batchId and sendResult fields without token", async () => {
3
+ const res = await createSmsCaptcha("12345671145", "loginbyPhone", "86", "ccw_sms");
4
+ expect(res).toHaveProperty("batchId");
5
+ expect(res).toHaveProperty("sendResult");
6
+ expect(res.batchId).toBeNull();
7
+ expect(res.sendResult).toBe(2);
8
+ }, 30000);
@@ -11,13 +11,14 @@ export async function loginByPassword(loginKey, password, reqExtra = {
11
11
  device: "Node",
12
12
  browser: "Node.js",
13
13
  }) {
14
- const { extra, ...restBody } = await ccwAxios
15
- .post(url, {
14
+ const req = {
16
15
  loginKey,
17
16
  password,
18
17
  clientCode: "STUDY_COMMUNITY",
19
18
  extra: JSON.stringify({ ...reqExtra, scene: null }),
20
- })
19
+ };
20
+ const { extra, ...restBody } = await ccwAxios
21
+ .post(url, req)
21
22
  .then((res) => res.data.body);
22
23
  const resExtra = JSON.parse(extra);
23
24
  return {
@@ -0,0 +1,33 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://sso.ccw.site/web/auth/v3/login/by_phone";
3
+ /**
4
+ * 通过手机号+短信验证码登录(V3)
5
+ * @param {string} phone 手机号,如 "12345671145"
6
+ * @param {string} code 收到的短信验证码
7
+ * @param {ReqExtra} reqExtra 设备和浏览器信息
8
+ * @param {string} countryCode 国家代码,默认 "86"
9
+ * @param {LoginRuleCode} ruleCode 短信规则编码,默认 "ccw_sms"
10
+ * @param {LoginScene} scene 登录场景,默认 "loginbyPhone"
11
+ * @returns {Promise<Res<Extra>>} session 信息
12
+ */
13
+ export async function loginByPhone(phone, code, reqExtra = {
14
+ device: "Node",
15
+ browser: "Node.js",
16
+ }, countryCode = "86", ruleCode = "ccw_sms", scene = "loginbyPhone") {
17
+ const { extra, ...restBody } = await ccwAxios
18
+ .post(url, {
19
+ phone,
20
+ code,
21
+ countryCode,
22
+ ruleCode,
23
+ scene,
24
+ clientCode: "STUDY_COMMUNITY",
25
+ extra: JSON.stringify({ ...reqExtra, scene: null }),
26
+ })
27
+ .then((res) => res.data.body);
28
+ const resExtra = JSON.parse(extra);
29
+ return {
30
+ ...restBody,
31
+ extra: resExtra,
32
+ };
33
+ }
@@ -0,0 +1,7 @@
1
+ import { loginByPhone } from "./by-phone";
2
+ test("expect wrong sms code to throw error", async () => {
3
+ await expect(loginByPhone("12345671145", "000000", {
4
+ device: "Node.js Test",
5
+ browser: "Jest",
6
+ })).rejects.toThrow();
7
+ }, 30000);
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductCategory = exports.url = void 0;
4
+ exports.queryMallProducts = queryMallProducts;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/ccw-mall/ccw/product/fe/query";
8
+ var ProductCategory;
9
+ (function (ProductCategory) {
10
+ ProductCategory[ProductCategory["Merchandise"] = 7] = "Merchandise";
11
+ ProductCategory[ProductCategory["AvatarFrame"] = 5] = "AvatarFrame";
12
+ ProductCategory[ProductCategory["EMOJI"] = 10] = "EMOJI";
13
+ })(ProductCategory || (exports.ProductCategory = ProductCategory = {}));
14
+ /**
15
+ * 分页查询CCW小商店商品列表
16
+ * @param {ProductCategory | undefined} productCategory 商品分类(可选):5=头像框,7=周边商品,10=表情 等
17
+ * @param {Partial<PageArgs<ProductSortField>>} pageArgs_ 分页参数(默认 page=1, perPage=30, sortType="DESC")
18
+ * @returns {Promise<Res>} 商品分页结果 PagesRes<Product>
19
+ */
20
+ async function queryMallProducts(productCategory, pageArgs_ = {
21
+ sortField: "createdAt",
22
+ }) {
23
+ const pageArgs = {
24
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
25
+ ...pageArgs_,
26
+ };
27
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
28
+ const req = {
29
+ page: pageArgs.page,
30
+ perPage: pageArgs.perPage,
31
+ sortType: pageArgs.sortType,
32
+ productCategory,
33
+ source: "CCW_OFFICIAL",
34
+ };
35
+ return await axios_1.ccwAxios
36
+ .post(queryUrl, req)
37
+ .then((res) => res.data.body);
38
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const query_1 = require("./query");
4
+ test("query mall product page should fail without token", async () => {
5
+ await expect((0, query_1.queryMallProducts)(7, {
6
+ page: 1,
7
+ perPage: 30,
8
+ sortType: "DESC",
9
+ })).rejects.toThrow();
10
+ });
@@ -13,7 +13,7 @@ const dpa = {
13
13
  * 根据主题获取评论列表
14
14
  * @param {string} subjectOid 主题oid
15
15
  * @param {SubjectType} subjectType 主题类型 (如: "POST")
16
- * @param {string} sectionType 区块类型 (如: "COMMENT")
16
+ * @param {SectionType} sectionType 区块类型 (如: "COMMENT")
17
17
  * @param {Partial<PageArgs<SortField| T>>} pageArgs_ 分页参数
18
18
  * @returns {Promise<Res>} 评论分页结果
19
19
  */
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getConnectCommunityCreationLikeStatus = getConnectCommunityCreationLikeStatus;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/extensions/creation-like/detail";
7
+ /**
8
+ * [连接社区扩展] 查询用户对作品的点赞交互状态
9
+ * @param {MongoDBId} playingCreationOid 当前播放的作品 OID
10
+ * @param {MongoDBId} creationOid 目标作品 OID
11
+ * @returns {Promise<Res>} 点赞状态及作品信息
12
+ */
13
+ async function getConnectCommunityCreationLikeStatus(playingCreationOid, creationOid) {
14
+ const req = { playingCreationOid, creationOid };
15
+ return await axios_1.ccwAxios
16
+ .post(exports.url, req)
17
+ .then((res) => res.data.body);
18
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const detail_1 = require("./detail");
4
+ test("should fail without token when getting creation like status", async () => {
5
+ await expect((0, detail_1.getConnectCommunityCreationLikeStatus)("6a3fa1ed159ed52f170c34d2", "6a3fa1ed159ed52f170c34d2")).rejects.toThrow();
6
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getConnectCommunityFollowingStatus = getConnectCommunityFollowingStatus;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/extensions/following/status";
7
+ /**
8
+ * [连接社区扩展] 查询是否关注了指定创作者
9
+ * @param {MongoDBId} playingCreationOid 当前播放的作品 OID
10
+ * @param {MongoDBId} userOid 目标用户 OID
11
+ * @returns {Promise<Res>} 关注状态及用户信息
12
+ */
13
+ async function getConnectCommunityFollowingStatus(playingCreationOid, userOid) {
14
+ const req = { playingCreationOid, userOid };
15
+ return await axios_1.ccwAxios
16
+ .post(exports.url, req)
17
+ .then((res) => res.data.body);
18
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const status_1 = require("./status");
4
+ test("should fail without token when getting following status", async () => {
5
+ await expect((0, status_1.getConnectCommunityFollowingStatus)("6a3fa1ed159ed52f170c34d2", "651e3f7310b0530e7f80fe7a")).rejects.toThrow();
6
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.updateGreatCreation = updateGreatCreation;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/great_creation/update";
7
+ /**
8
+ * 更换代表作
9
+ * @param {MongoDBId|""} creationOid 作品OID 若为""则是取消展示
10
+ * @returns {Promise<Res>} 更换结果
11
+ */
12
+ async function updateGreatCreation(creationOid) {
13
+ const req = { creationOid };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const update_1 = require("./update");
4
+ test("should fail without token when updating great creation", async () => {
5
+ await expect((0, update_1.updateGreatCreation)("69740f1a61b891733d5ee2c6")).rejects.toThrow();
6
+ });
@@ -12,6 +12,7 @@ const search_1 = require("./cloud_asset/search");
12
12
  const page_1 = require("./comment/page");
13
13
  const page_by_topic_1 = require("./comment/page_by_topic");
14
14
  const detail_3 = require("./config/detail");
15
+ const query_1 = require("./ccw-mall/ccw/product/fe/query");
15
16
  const detail_4 = require("./creation/detail");
16
17
  const list_2 = require("./creation/excellent/list");
17
18
  const detail_5 = require("./creation/introduction/detail");
@@ -96,10 +97,21 @@ const create_4 = require("./comment/create");
96
97
  const create_5 = require("./comment/like_record/create");
97
98
  const page_14 = require("./student/following/page");
98
99
  const donate_1 = require("./study-trade/trade/donate");
100
+ const user_product_1 = require("./user_package/user_product");
101
+ const status_3 = require("./user_package/status");
102
+ const update_3 = require("./great_creation/update");
103
+ const execute_1 = require("./smart_contract/execute");
104
+ const account_1 = require("./smart_contract/account");
105
+ const detail_21 = require("./smart_contract/detail");
106
+ const list_15 = require("./smart_contract/list");
107
+ const status_4 = require("./extensions/following/status");
108
+ const detail_22 = require("./extensions/creation-like/detail");
109
+ const follow_1 = require("./study-community/following/follow");
99
110
  exports.communityWeb = {
100
111
  acceptAward: award_1.acceptAward,
101
112
  donateTrade: donate_1.donateTrade,
102
113
  encodeShortCode: encode_1.encodeShortCode,
114
+ executeSmartContract: execute_1.executeSmartContract,
103
115
  createCloudVariable: create_3.createCloudVariable,
104
116
  createComment: create_4.createComment,
105
117
  createShortUrl: create_1.createShortUrl,
@@ -107,6 +119,7 @@ exports.communityWeb = {
107
119
  decompressShortUrl: decompress_1.decompressShortUrl,
108
120
  deleteComment: delete_1.deleteComment,
109
121
  foldComment: fold_1.foldComment,
122
+ followCreator: follow_1.followCreator,
110
123
  getApprovalTags: list_1.getApprovalTags,
111
124
  getCampaignResources: detail_1.getCampaignResources,
112
125
  getCcwMainStatus: status_2.getCCWMainStatus,
@@ -120,6 +133,7 @@ exports.communityWeb = {
120
133
  getCreationDetail: detail_4.getCreationDetail,
121
134
  getCreationFavoriteDetail: detail_10.getCreationFavoriteDetail,
122
135
  getCreationIntroduction: detail_5.getCreationIntroduction,
136
+ getConnectCommunityCreationLikeStatus: detail_22.getConnectCommunityCreationLikeStatus,
123
137
  getCreationRecommendPositionList: list_6.getCreationRecommendPositionList,
124
138
  getCreationReleasePage: page_12.getCreationReleasePage,
125
139
  getCreationScreenshotPage: page_4.getCreationScreenshotPage,
@@ -128,6 +142,7 @@ exports.communityWeb = {
128
142
  getCreatorScore: creator_score_1.getCreatorScore,
129
143
  getDonatedRecordRanking: ranking_list_1.getDonatedRecordRanking,
130
144
  getExcellentCreations: list_2.getExcellentCreations,
145
+ getConnectCommunityFollowingStatus: status_4.getConnectCommunityFollowingStatus,
131
146
  getEmojiCategoryList: list_10.getEmojiCategoryList,
132
147
  getEmojiPage: page_7.getEmojiPage,
133
148
  getAllEmojis: all_1.getAllEmojis,
@@ -156,6 +171,9 @@ exports.communityWeb = {
156
171
  getRemixedCreationPage: page_2.getRemixedCreationPage,
157
172
  getReputationScoreLogPage: page_5.getReputationScoreLog,
158
173
  getSearchHotWords: hot_words_1.getSearchHotWords,
174
+ getSmartContractAccount: account_1.getSmartContractAccount,
175
+ getSmartContractDetail: detail_21.getSmartContractDetail,
176
+ getSmartContractList: list_15.getSmartContractList,
159
177
  getSplitRuleDetail: detail_18.getSplitRuleDetail,
160
178
  getSpreadFeedUnreadCount: count_1.getSpreadFeedUnreadCount,
161
179
  getStudentBlockRecordDetail: detail_12.getStudentBlockRecordDetail,
@@ -179,6 +197,8 @@ exports.communityWeb = {
179
197
  getUserAssetStorageSize: privacy_1.getUserAssetStorageSize,
180
198
  getUserCardDetail: detail_15.getUserCardDetail,
181
199
  getUserLabelList: list_9.getUserLabelList,
200
+ getUserProductsPage: user_product_1.getUserProductsPage,
201
+ queryMallProducts: query_1.queryMallProducts,
182
202
  getCreationsByStudent: page_by_student_1.getCreationsByStudent,
183
203
  insertCheckInRecord: insert_1.insertCheckInRecord,
184
204
  likeComment: create_5.likeComment,
@@ -187,9 +207,11 @@ exports.communityWeb = {
187
207
  searchCloudAssets: search_1.searchCloudAssets,
188
208
  searchCreationsByTag: page_3.searchCreationsByTag,
189
209
  sendEvent: event_1.sendEvent,
210
+ setUserProductStatus: status_3.setUserProductStatus,
190
211
  submitCreation: submit_1.submitCreation,
191
212
  topComment: top_1.topComment,
192
213
  updateCreation: update_2.updateCreation,
214
+ updateGreatCreation: update_3.updateGreatCreation,
193
215
  updateStudent: update_1.updateStudent,
194
216
  viewCreationStats: view_1.viewCreationStats,
195
217
  };
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const detail_1 = require("./detail");
4
4
  test("get post detail", async () => {
5
5
  const detail = await (0, detail_1.getPostDetail)("0173b23d-139d-4c48-ad98-0aa17b5d3b60");
6
- console.log(detail);
7
6
  await expect(detail.title.includes("【公告通知】")).toBeTruthy();
8
7
  });
9
8
  test("error when post detail not found", async () => {
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getSmartContractAccount = getSmartContractAccount;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/smart_contract/account";
7
+ /**
8
+ * 查询智能合约账户余额
9
+ * @param {number} id 合约 ID
10
+ * @returns {Promise<Res>} 合约账户余额
11
+ */
12
+ async function getSmartContractAccount(id) {
13
+ const req = { id };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const account_1 = require("./account");
4
+ test("should fail without token when getting smart contract account", async () => {
5
+ await expect((0, account_1.getSmartContractAccount)(2022277721908162)).rejects.toThrow();
6
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getSmartContractDetail = getSmartContractDetail;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/smart_contract/detail";
7
+ /**
8
+ * 获取智能合约详情
9
+ * @param {number} id 合约 ID
10
+ * @returns {Promise<Res>} 合约详情
11
+ */
12
+ async function getSmartContractDetail(id) {
13
+ const req = { id };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const detail_1 = require("./detail");
4
+ test("should fail without token when getting smart contract detail", async () => {
5
+ await expect((0, detail_1.getSmartContractDetail)(2022277721908162)).rejects.toThrow();
6
+ });
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.executeSmartContract = executeSmartContract;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/smart_contract/execute";
7
+ /**
8
+ * 执行智能合约(投币/领取奖励)
9
+ * @param {MongoDBId} bizId 业务 ID(如作品 OID)
10
+ * @param {SmartContractBizType} bizType 业务类型,CREATION
11
+ * @param {number} id 合约 ID
12
+ * @param {number} ruleId 规则 ID
13
+ * @param {number} bucks 金币数量
14
+ * @returns {Promise<Res>} 执行结果
15
+ */
16
+ async function executeSmartContract(bizId, id, ruleId, bucks, bizType = "CREATION") {
17
+ const req = { bizId, bizType, id, ruleId, params: { bucks } };
18
+ return await axios_1.ccwAxios
19
+ .post(exports.url, req)
20
+ .then((res) => res.data.body);
21
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const execute_1 = require("./execute");
4
+ test("should fail without token when executing smart contract", async () => {
5
+ await expect((0, execute_1.executeSmartContract)("6a3fa1ed159ed52f170c34d2", 2022277721908162, 378074, 1)).rejects.toThrow();
6
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getSmartContractList = getSmartContractList;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/smart_contract/list";
7
+ /**
8
+ * 列出作品中的智能金币合约
9
+ * @param {MongoDBId} bizId 业务ID(如作品OID)
10
+ * @param {SmartContractBizType} bizType 业务类型,CREATION
11
+ * @returns {Promise<Res>} 智能合约列表
12
+ */
13
+ async function getSmartContractList(bizId, bizType = "CREATION") {
14
+ const req = { bizId, bizType };
15
+ return await axios_1.ccwAxios
16
+ .post(exports.url, req)
17
+ .then((res) => res.data.body);
18
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const list_1 = require("./list");
4
+ test("should fail without token when listing smart contracts", async () => {
5
+ await expect((0, list_1.getSmartContractList)("679d79862de3ec4dde55d534")).rejects.toThrow();
6
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.followCreator = followCreator;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/study-community/following/follow";
7
+ /**
8
+ * 关注创作者
9
+ * @param {MongoDBId} followingOid 要关注的用户 OID
10
+ * @returns {Promise<Res>} "FOLLOWED" 表示关注成功
11
+ */
12
+ async function followCreator(followingOid) {
13
+ const req = { followingOid };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const follow_1 = require("./follow");
4
+ test("should fail without token when following creator", async () => {
5
+ await expect((0, follow_1.followCreator)("651e3f7310b0530e7f80fe7a")).rejects.toThrow();
6
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.setUserProductStatus = setUserProductStatus;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/user_package/status";
7
+ /**
8
+ * 设置用户商品状态(如佩戴/卸下头像框)
9
+ * @param {number} id 用户商品ID
10
+ * @param {boolean} status 商品状态,true为佩戴,false为卸下
11
+ * @returns {Promise<Res>} 设置结果
12
+ */
13
+ async function setUserProductStatus(id, status) {
14
+ const req = { status, id };
15
+ return await axios_1.ccwAxios
16
+ .post(exports.url, req)
17
+ .then((res) => res.data.body);
18
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const status_1 = require("./status");
4
+ test("should fail without token when setting user product status", async () => {
5
+ await expect((0, status_1.setUserProductStatus)(105847, false)).rejects.toThrow();
6
+ });
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductCategory = exports.url = void 0;
4
+ exports.getUserProductsPage = getUserProductsPage;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/user_package/user_product";
8
+ var ProductCategory;
9
+ (function (ProductCategory) {
10
+ ProductCategory[ProductCategory["AVATAR_FRAME"] = 5] = "AVATAR_FRAME";
11
+ })(ProductCategory || (exports.ProductCategory = ProductCategory = {}));
12
+ /**
13
+ * 分页获取用户商品(如头像框)
14
+ * @param {ProductCategory} productCategory 商品分类,默认5为头像框
15
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
16
+ * @returns {Promise<Res>} 分页用户商品数据
17
+ */
18
+ async function getUserProductsPage(productCategory = ProductCategory.AVATAR_FRAME, pageArgs_ = {}) {
19
+ const pageArgs = {
20
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
21
+ ...pageArgs_,
22
+ };
23
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
24
+ const req = {
25
+ page: pageArgs.page,
26
+ perPage: pageArgs.perPage,
27
+ sortType: pageArgs.sortType,
28
+ productCategory,
29
+ };
30
+ return await axios_1.ccwAxios
31
+ .post(queryUrl, req)
32
+ .then((res) => res.data.body);
33
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const user_product_1 = require("./user_product");
4
+ test("should fail without token for avatar frame products", async () => {
5
+ await expect((0, user_product_1.getUserProductsPage)(user_product_1.ProductCategory.AVATAR_FRAME, {
6
+ page: 1,
7
+ perPage: 8,
8
+ sortType: "DESC",
9
+ sortField: "",
10
+ })).rejects.toThrow();
11
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCloudVariableDetailV2 = getCloudVariableDetailV2;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web-cloud-database.ccw.site/cloud_variable/detail/v2";
7
+ /**
8
+ * 查询云变量详情 V2
9
+ * @param {string} accessKey 访问密钥(如作品 OID)
10
+ * @param {string} primaryKey 主键(如 `${projectId}-u`)
11
+ * @param {string} secondaryKey 次级键
12
+ * @param {string[]} filterKeys 过滤的变量名列表
13
+ * @returns {Promise<Res>} 云变量详情
14
+ */
15
+ async function getCloudVariableDetailV2(accessKey, primaryKey, secondaryKey, filterKeys) {
16
+ const req = { accessKey, primaryKey, secondaryKey, filterKeys };
17
+ return await axios_1.ccwAxios
18
+ .post(exports.url, req)
19
+ .then((res) => res.data.body);
20
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const v2_1 = require("./v2");
4
+ test("get cloud variable detail v2 should reject with invalid params", async () => {
5
+ await expect((0, v2_1.getCloudVariableDetailV2)("6a3fa1ed159ed52f170c34d2", "6a3fa1ed159ed52f170c34d2-u", "244373873", ["4576y!!2"])).rejects.toThrow();
6
+ });
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.saveProjectCloudVariable = saveProjectCloudVariable;
5
+ exports.saveUserCloudVariable = saveUserCloudVariable;
6
+ const axios_1 = require("@ccw-api/axios");
7
+ exports.url = "https://community-web-cloud-database.ccw.site/cloud_variable/save";
8
+ async function saveCloudVariableBase(primaryKey, secondaryKey, value) {
9
+ const req = { primaryKey, secondaryKey, value };
10
+ return await axios_1.ccwAxios
11
+ .post(exports.url, req)
12
+ .then((res) => res.data.body);
13
+ }
14
+ /**
15
+ * 保存作品云变量到云数据库
16
+ * @param {MongoDBId} projectId 作品id
17
+ * @param {string} secondaryKey 次级键 - 变量名或标识
18
+ * @param {T} value 要保存数据
19
+ * @returns {Promise<SaveCloudVariableRes<T>>} 保存后的值对象
20
+ */
21
+ async function saveProjectCloudVariable(projectId, secondaryKey, value) {
22
+ return await saveCloudVariableBase(projectId, secondaryKey, { v: value });
23
+ }
24
+ /**
25
+ * 保存数据到用户云数据库
26
+ * @param {MongoDBId} projectId 作品id
27
+ * @param {number} studentNum 次级键 - 用户id
28
+ * @param {T} value 要保存的键值对
29
+ * @returns {Promise<SaveCloudVariableRes<T>>} 保存后的值对象
30
+ */
31
+ async function saveUserCloudVariable(projectId, studentNum, value) {
32
+ const primaryKey = `${projectId}-u`;
33
+ return await saveCloudVariableBase(primaryKey, `${studentNum}`, value);
34
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const save_1 = require("./save");
4
+ test("save project cloud variable should return saved value", async () => {
5
+ const testValue = "2025-07-05T17:40:53.057+0800";
6
+ const res = await (0, save_1.saveProjectCloudVariable)("68dddc63d28b025cb53fae25", "test", testValue);
7
+ expect(res).toBeDefined();
8
+ expect(res.v).toBe(testValue);
9
+ });
10
+ test("save user cloud variable should ok", async () => {
11
+ const res = await (0, save_1.saveUserCloudVariable)("68dddc63d28b025cb53fae25", 0, {
12
+ key2: "0",
13
+ });
14
+ expect(res.key2).toEqual("0");
15
+ });
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.communityWebCloudDatabase = void 0;
4
+ const save_1 = require("./cloud_variable/save");
5
+ const v2_1 = require("./cloud_variable/detail/v2");
6
+ exports.communityWebCloudDatabase = {
7
+ saveProjectCloudVariable: save_1.saveProjectCloudVariable,
8
+ saveUserCloudVariable: save_1.saveUserCloudVariable,
9
+ getCloudVariableDetailV2: v2_1.getCloudVariableDetailV2,
10
+ };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.submitLeaderboardRecord = submitLeaderboardRecord;
5
+ exports.getLeaderboardRecords = getLeaderboardRecords;
6
+ const axios_1 = require("@ccw-api/axios");
7
+ exports.url = "https://gandi-main.ccw.site/creation/leaderboards";
8
+ /**
9
+ * 向作品排行榜提交一条分数记录
10
+ * @param {MongoDBId} leaderboardOid 排行榜id
11
+ * @param {number} score 分数
12
+ * @param {MongoDBId} userOid 用户id
13
+ * @param {string} ext 扩展信息(可选)
14
+ * @returns {Promise<SubmitRes>} 是否提交成功
15
+ */
16
+ async function submitLeaderboardRecord(leaderboardOid, score, userOid, ext = "") {
17
+ const req = { score, oid: userOid, ext };
18
+ const requestUrl = `${exports.url}/${leaderboardOid}/records`;
19
+ return await axios_1.ccwAxios
20
+ .post(requestUrl, req)
21
+ .then((res) => res.data.body);
22
+ }
23
+ /**
24
+ * 获取作品排行榜记录列表
25
+ * @param {MongoDBId} leaderboardOid 排行榜id
26
+ * @returns {Promise<LeaderboardRecordsRes>} 排行榜记录列表
27
+ */
28
+ async function getLeaderboardRecords(leaderboardOid) {
29
+ const requestUrl = `${exports.url}/${leaderboardOid}/records`;
30
+ return await axios_1.ccwAxios
31
+ .get(requestUrl)
32
+ .then((res) => res.data.body);
33
+ }