@ccw-api/api 0.4.2 → 0.5.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.
- package/README.md +82 -10
- package/dist/esm/community-web/comment/page_by_topic.js +1 -1
- package/dist/esm/community-web/great_creation/update.js +13 -0
- package/dist/esm/community-web/great_creation/update.test.js +4 -0
- package/dist/esm/community-web/index.js +8 -0
- package/dist/esm/community-web/smart_contract/list.js +14 -0
- package/dist/esm/community-web/smart_contract/list.test.js +4 -0
- package/dist/esm/community-web/user_package/status.js +14 -0
- package/dist/esm/community-web/user_package/status.test.js +4 -0
- package/dist/esm/community-web/user_package/user_product.js +29 -0
- package/dist/esm/community-web/user_package/user_product.test.js +9 -0
- package/dist/esm/community-web-cloud-database/cloud_variable/save.js +29 -0
- package/dist/esm/community-web-cloud-database/cloud_variable/save.test.js +13 -0
- package/dist/esm/community-web-cloud-database/index.js +5 -0
- package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.js +28 -0
- package/dist/esm/gandi-main/creation/leaderboards/{oid}/records.test.js +11 -0
- package/dist/esm/gandi-main/index.js +3 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/op-parent-api/captcha/check.js +15 -0
- package/dist/esm/op-parent-api/captcha/check.test.js +12 -0
- package/dist/esm/op-parent-api/captcha/create.js +13 -0
- package/dist/esm/op-parent-api/captcha/create.test.js +13 -0
- package/dist/esm/op-parent-api/index.js +6 -0
- package/dist/esm/sso/index.js +4 -0
- package/dist/esm/sso/web/auth/assistant/captcha/v2/create.js +17 -0
- package/dist/esm/sso/web/auth/assistant/captcha/v2/create.test.js +8 -0
- package/dist/esm/sso/web/auth/login-by-password.js +4 -3
- package/dist/esm/sso/web/auth/v3/login/by-phone.js +33 -0
- package/dist/esm/sso/web/auth/v3/login/by-phone.test.js +7 -0
- package/dist/node/community-web/comment/page_by_topic.js +1 -1
- package/dist/node/community-web/great_creation/update.js +17 -0
- package/dist/node/community-web/great_creation/update.test.js +6 -0
- package/dist/node/community-web/index.js +8 -0
- package/dist/node/community-web/smart_contract/list.js +18 -0
- package/dist/node/community-web/smart_contract/list.test.js +6 -0
- package/dist/node/community-web/user_package/status.js +18 -0
- package/dist/node/community-web/user_package/status.test.js +6 -0
- package/dist/node/community-web/user_package/user_product.js +33 -0
- package/dist/node/community-web/user_package/user_product.test.js +11 -0
- package/dist/node/community-web-cloud-database/cloud_variable/save.js +34 -0
- package/dist/node/community-web-cloud-database/cloud_variable/save.test.js +15 -0
- package/dist/node/community-web-cloud-database/index.js +8 -0
- package/dist/node/gandi-main/creation/leaderboards/{oid}/records.js +33 -0
- package/dist/node/gandi-main/creation/leaderboards/{oid}/records.test.js +13 -0
- package/dist/node/gandi-main/index.js +3 -0
- package/dist/node/index.js +7 -1
- package/dist/node/op-parent-api/captcha/check.js +19 -0
- package/dist/node/op-parent-api/captcha/check.test.js +14 -0
- package/dist/node/op-parent-api/captcha/create.js +17 -0
- package/dist/node/op-parent-api/captcha/create.test.js +15 -0
- package/dist/node/op-parent-api/index.js +9 -0
- package/dist/node/sso/index.js +4 -0
- package/dist/node/sso/web/auth/assistant/captcha/v2/create.js +21 -0
- package/dist/node/sso/web/auth/assistant/captcha/v2/create.test.js +10 -0
- package/dist/node/sso/web/auth/login-by-password.js +4 -3
- package/dist/node/sso/web/auth/v3/login/by-phone.js +37 -0
- package/dist/node/sso/web/auth/v3/login/by-phone.test.js +9 -0
- package/dist/types/community-web/comment/page_by_topic.d.ts +1 -1
- package/dist/types/community-web/great_creation/update.d.ts +12 -0
- package/dist/types/community-web/index.d.ts +8 -0
- package/dist/types/community-web/smart_contract/list.d.ts +49 -0
- package/dist/types/community-web/user_package/status.d.ts +13 -0
- package/dist/types/community-web/user_package/user_product.d.ts +40 -0
- package/dist/types/community-web-cloud-database/cloud_variable/save.d.ts +26 -0
- package/dist/types/community-web-cloud-database/index.d.ts +5 -0
- package/dist/types/gandi-main/creation/leaderboards/{oid}/records.d.ts +62 -0
- package/dist/types/gandi-main/index.d.ts +3 -0
- package/dist/types/index.d.ts +19 -1
- package/dist/types/op-parent-api/captcha/check.d.ts +21 -0
- package/dist/types/op-parent-api/captcha/create.d.ts +24 -0
- package/dist/types/op-parent-api/index.d.ts +6 -0
- package/dist/types/sso/index.d.ts +4 -0
- package/dist/types/sso/web/auth/assistant/captcha/v2/create.d.ts +34 -0
- package/dist/types/sso/web/auth/login-by-password.d.ts +2 -18
- package/dist/types/sso/web/auth/v3/login/by-phone.d.ts +38 -0
- package/package.json +1 -1
|
@@ -96,6 +96,10 @@ const create_4 = require("./comment/create");
|
|
|
96
96
|
const create_5 = require("./comment/like_record/create");
|
|
97
97
|
const page_14 = require("./student/following/page");
|
|
98
98
|
const donate_1 = require("./study-trade/trade/donate");
|
|
99
|
+
const user_product_1 = require("./user_package/user_product");
|
|
100
|
+
const status_3 = require("./user_package/status");
|
|
101
|
+
const update_3 = require("./great_creation/update");
|
|
102
|
+
const list_15 = require("./smart_contract/list");
|
|
99
103
|
exports.communityWeb = {
|
|
100
104
|
acceptAward: award_1.acceptAward,
|
|
101
105
|
donateTrade: donate_1.donateTrade,
|
|
@@ -156,6 +160,7 @@ exports.communityWeb = {
|
|
|
156
160
|
getRemixedCreationPage: page_2.getRemixedCreationPage,
|
|
157
161
|
getReputationScoreLogPage: page_5.getReputationScoreLog,
|
|
158
162
|
getSearchHotWords: hot_words_1.getSearchHotWords,
|
|
163
|
+
getSmartContractList: list_15.getSmartContractList,
|
|
159
164
|
getSplitRuleDetail: detail_18.getSplitRuleDetail,
|
|
160
165
|
getSpreadFeedUnreadCount: count_1.getSpreadFeedUnreadCount,
|
|
161
166
|
getStudentBlockRecordDetail: detail_12.getStudentBlockRecordDetail,
|
|
@@ -179,6 +184,7 @@ exports.communityWeb = {
|
|
|
179
184
|
getUserAssetStorageSize: privacy_1.getUserAssetStorageSize,
|
|
180
185
|
getUserCardDetail: detail_15.getUserCardDetail,
|
|
181
186
|
getUserLabelList: list_9.getUserLabelList,
|
|
187
|
+
getUserProductsPage: user_product_1.getUserProductsPage,
|
|
182
188
|
getCreationsByStudent: page_by_student_1.getCreationsByStudent,
|
|
183
189
|
insertCheckInRecord: insert_1.insertCheckInRecord,
|
|
184
190
|
likeComment: create_5.likeComment,
|
|
@@ -187,9 +193,11 @@ exports.communityWeb = {
|
|
|
187
193
|
searchCloudAssets: search_1.searchCloudAssets,
|
|
188
194
|
searchCreationsByTag: page_3.searchCreationsByTag,
|
|
189
195
|
sendEvent: event_1.sendEvent,
|
|
196
|
+
setUserProductStatus: status_3.setUserProductStatus,
|
|
190
197
|
submitCreation: submit_1.submitCreation,
|
|
191
198
|
topComment: top_1.topComment,
|
|
192
199
|
updateCreation: update_2.updateCreation,
|
|
200
|
+
updateGreatCreation: update_3.updateGreatCreation,
|
|
193
201
|
updateStudent: update_1.updateStudent,
|
|
194
202
|
viewCreationStats: view_1.viewCreationStats,
|
|
195
203
|
};
|
|
@@ -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,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,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,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.communityWebCloudDatabase = void 0;
|
|
4
|
+
const save_1 = require("./cloud_variable/save");
|
|
5
|
+
exports.communityWebCloudDatabase = {
|
|
6
|
+
saveProjectCloudVariable: save_1.saveProjectCloudVariable,
|
|
7
|
+
saveUserCloudVariable: save_1.saveUserCloudVariable,
|
|
8
|
+
};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const records_1 = require("./records");
|
|
4
|
+
test("submit leaderboard record should fail without token", async () => {
|
|
5
|
+
await expect((0, records_1.submitLeaderboardRecord)("65a2314daa96bd09b5beae5a", 0, "65a2314daa96bd09b5beae5a", "")).rejects.toThrow();
|
|
6
|
+
});
|
|
7
|
+
test("get leaderboard records should return data", async () => {
|
|
8
|
+
const res = await (0, records_1.getLeaderboardRecords)("65a2314daa96bd09b5beae5a");
|
|
9
|
+
expect(res.oid).toBe("65a2314daa96bd09b5beae5a");
|
|
10
|
+
expect(res.title).toBeDefined();
|
|
11
|
+
expect(res.leaderboardRecordTotalNum).toBeDefined();
|
|
12
|
+
expect(Array.isArray(res.leaderboardRecords)).toBe(true);
|
|
13
|
+
});
|
|
@@ -4,8 +4,11 @@ exports.gandiMain = void 0;
|
|
|
4
4
|
const current_1 = require("./timestamp/current");
|
|
5
5
|
const page_1 = require("./bulletins/page");
|
|
6
6
|
const detail_1 = require("./bulletins/detail");
|
|
7
|
+
const records_1 = require("./creation/leaderboards/{oid}/records");
|
|
7
8
|
exports.gandiMain = {
|
|
8
9
|
getCurrentTimestamp: current_1.getCurrentTimestamp,
|
|
9
10
|
getBulletinsPage: page_1.getBulletinsPage,
|
|
10
11
|
getBulletinDetail: detail_1.getBulletinDetail,
|
|
12
|
+
submitLeaderboardRecord: records_1.submitLeaderboardRecord,
|
|
13
|
+
getLeaderboardRecords: records_1.getLeaderboardRecords,
|
|
11
14
|
};
|
package/dist/node/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setToken = exports.bfsWeb = exports.gandiMain = exports.communityWeb = exports.sso = void 0;
|
|
3
|
+
exports.setToken = exports.opParentApi = exports.communityWebCloudDatabase = exports.bfsWeb = exports.gandiMain = exports.communityWeb = exports.sso = void 0;
|
|
4
4
|
const index_1 = require("./sso/index");
|
|
5
5
|
Object.defineProperty(exports, "sso", { enumerable: true, get: function () { return index_1.sso; } });
|
|
6
6
|
const community_web_1 = require("./community-web");
|
|
@@ -9,6 +9,10 @@ const gandi_main_1 = require("./gandi-main");
|
|
|
9
9
|
Object.defineProperty(exports, "gandiMain", { enumerable: true, get: function () { return gandi_main_1.gandiMain; } });
|
|
10
10
|
const bfs_web_1 = require("./bfs-web");
|
|
11
11
|
Object.defineProperty(exports, "bfsWeb", { enumerable: true, get: function () { return bfs_web_1.bfsWeb; } });
|
|
12
|
+
const community_web_cloud_database_1 = require("./community-web-cloud-database");
|
|
13
|
+
Object.defineProperty(exports, "communityWebCloudDatabase", { enumerable: true, get: function () { return community_web_cloud_database_1.communityWebCloudDatabase; } });
|
|
14
|
+
const op_parent_api_1 = require("./op-parent-api");
|
|
15
|
+
Object.defineProperty(exports, "opParentApi", { enumerable: true, get: function () { return op_parent_api_1.opParentApi; } });
|
|
12
16
|
var axios_1 = require("@ccw-api/axios");
|
|
13
17
|
Object.defineProperty(exports, "setToken", { enumerable: true, get: function () { return axios_1.setToken; } });
|
|
14
18
|
exports.default = {
|
|
@@ -16,4 +20,6 @@ exports.default = {
|
|
|
16
20
|
communityWeb: community_web_1.communityWeb,
|
|
17
21
|
gandiMain: gandi_main_1.gandiMain,
|
|
18
22
|
bfsWeb: bfs_web_1.bfsWeb,
|
|
23
|
+
communityWebCloudDatabase: community_web_cloud_database_1.communityWebCloudDatabase,
|
|
24
|
+
opParentApi: op_parent_api_1.opParentApi,
|
|
19
25
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.url = void 0;
|
|
4
|
+
exports.checkCaptcha = checkCaptcha;
|
|
5
|
+
const axios_1 = require("@ccw-api/axios");
|
|
6
|
+
exports.url = "https://op-parent-api.xiguacity.cn/captcha/check";
|
|
7
|
+
/**
|
|
8
|
+
* 校验图形验证码(拼图滑块坐标)
|
|
9
|
+
* @param {string} token createCaptcha 返回的 token
|
|
10
|
+
* @param {number} x 拼图滑块目标位置的 x 坐标
|
|
11
|
+
* @param {number} y 拼图滑块目标位置的 y 坐标
|
|
12
|
+
* @returns {Promise<Res>} 校验结果
|
|
13
|
+
*/
|
|
14
|
+
async function checkCaptcha(token, x, y = 5) {
|
|
15
|
+
const req = { data: { x, y }, token };
|
|
16
|
+
return await axios_1.ccwAxios
|
|
17
|
+
.post(exports.url, req)
|
|
18
|
+
.then((res) => res.data.body);
|
|
19
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const check_1 = require("./check");
|
|
4
|
+
const create_1 = require("./create");
|
|
5
|
+
test("checkCaptcha returns structured result with token and coords without auth", async () => {
|
|
6
|
+
const created = await (0, create_1.createCaptcha)("BLOCK_PUZZLE");
|
|
7
|
+
const res = await (0, check_1.checkCaptcha)(created.token, 0, -1);
|
|
8
|
+
expect(res).toHaveProperty("captchaExpired");
|
|
9
|
+
expect(res).toHaveProperty("errorMsg");
|
|
10
|
+
expect(res).toHaveProperty("success");
|
|
11
|
+
expect(res.captchaExpired).toBeFalsy();
|
|
12
|
+
expect(res.success).toBeFalsy();
|
|
13
|
+
expect(res.errorMsg).toEqual("验证失败");
|
|
14
|
+
}, 30000);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.url = void 0;
|
|
4
|
+
exports.createCaptcha = createCaptcha;
|
|
5
|
+
const axios_1 = require("@ccw-api/axios");
|
|
6
|
+
exports.url = "https://op-parent-api.xiguacity.cn/captcha/create";
|
|
7
|
+
/**
|
|
8
|
+
* 创建图形验证码(拼图滑块)
|
|
9
|
+
* @param {CaptchaType} type 验证码类型,默认 BLOCK_PUZZLE(滑块拼图)
|
|
10
|
+
* @returns {Promise<Res>} 验证码信息:bgImg为背景图base64 data url,jigsawImg为拼图块base64 data url,token用于后续校验
|
|
11
|
+
*/
|
|
12
|
+
async function createCaptcha(type = "BLOCK_PUZZLE") {
|
|
13
|
+
const req = { type };
|
|
14
|
+
return await axios_1.ccwAxios
|
|
15
|
+
.post(exports.url, req)
|
|
16
|
+
.then((res) => res.data.body);
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const create_1 = require("./create");
|
|
4
|
+
test("create BLOCK_PUZZLE captcha returns bgImg, jigsawImg and token without token", async () => {
|
|
5
|
+
const res = await (0, create_1.createCaptcha)("BLOCK_PUZZLE");
|
|
6
|
+
expect(res).toHaveProperty("data");
|
|
7
|
+
expect(res.data).toHaveProperty("bgImg");
|
|
8
|
+
expect(res.data).toHaveProperty("jigsawImg");
|
|
9
|
+
expect(res).toHaveProperty("token");
|
|
10
|
+
expect(typeof res.token).toBe("string");
|
|
11
|
+
expect(typeof res.data.bgImg).toBe("string");
|
|
12
|
+
expect(typeof res.data.jigsawImg).toBe("string");
|
|
13
|
+
expect(res.data.bgImg.startsWith("data:image/png;base64,")).toBeTruthy();
|
|
14
|
+
expect(res.data.jigsawImg.startsWith("data:image/png;base64,")).toBeTruthy();
|
|
15
|
+
}, 30000);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.opParentApi = void 0;
|
|
4
|
+
const create_1 = require("./captcha/create");
|
|
5
|
+
const check_1 = require("./captcha/check");
|
|
6
|
+
exports.opParentApi = {
|
|
7
|
+
createCaptcha: create_1.createCaptcha,
|
|
8
|
+
checkCaptcha: check_1.checkCaptcha,
|
|
9
|
+
};
|
package/dist/node/sso/index.js
CHANGED
|
@@ -4,8 +4,12 @@ exports.sso = void 0;
|
|
|
4
4
|
const login_by_password_1 = require("./web/auth/login-by-password");
|
|
5
5
|
const logout_1 = require("./web/auth/logout");
|
|
6
6
|
const logout_by_session_1 = require("./web/auth/logout_by_session");
|
|
7
|
+
const create_1 = require("./web/auth/assistant/captcha/v2/create");
|
|
8
|
+
const by_phone_1 = require("./web/auth/v3/login/by-phone");
|
|
7
9
|
exports.sso = {
|
|
8
10
|
loginByPassword: login_by_password_1.loginByPassword,
|
|
9
11
|
logout: logout_1.logout,
|
|
10
12
|
logoutBySession: logout_by_session_1.logoutBySession,
|
|
13
|
+
createSmsCaptcha: create_1.createSmsCaptcha,
|
|
14
|
+
loginByPhone: by_phone_1.loginByPhone,
|
|
11
15
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.url = void 0;
|
|
4
|
+
exports.createSmsCaptcha = createSmsCaptcha;
|
|
5
|
+
const axios_1 = require("@ccw-api/axios");
|
|
6
|
+
exports.url = "https://sso.ccw.site/web/auth/assistant/captcha/v2/create";
|
|
7
|
+
/**
|
|
8
|
+
* 发送短信验证码
|
|
9
|
+
* @param {string} recipient 接收手机号,如 "10011451919"
|
|
10
|
+
* @param {SmsScene} scene 场景,默认 loginbyPhone
|
|
11
|
+
* @param {string} countryCode 国家代码,默认 "86"
|
|
12
|
+
* @param {SmsRuleCode} ruleCode 短信规则编码,默认 "ccw_sms"
|
|
13
|
+
* @param {CaptchaPayload} captcha 图形验证码校验结果(滑块拼图的坐标与token),可选(部分场景未强制要求时可省略,但失败时sendResult!=1)
|
|
14
|
+
* @returns {Promise<Res>} 发送结果:batchId 为短信批次ID,sendResult=1 表示成功
|
|
15
|
+
*/
|
|
16
|
+
async function createSmsCaptcha(recipient, scene = "loginbyPhone", countryCode = "86", ruleCode = "ccw_sms", captcha) {
|
|
17
|
+
const req = { recipient, countryCode, scene, ruleCode, captcha };
|
|
18
|
+
return await axios_1.ccwAxios
|
|
19
|
+
.post(exports.url, req)
|
|
20
|
+
.then((res) => res.data.body);
|
|
21
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const create_1 = require("./create");
|
|
4
|
+
test("createSmsCaptchaV2 returns batchId and sendResult fields without token", async () => {
|
|
5
|
+
const res = await (0, create_1.createSmsCaptcha)("12345671145", "loginbyPhone", "86", "ccw_sms");
|
|
6
|
+
expect(res).toHaveProperty("batchId");
|
|
7
|
+
expect(res).toHaveProperty("sendResult");
|
|
8
|
+
expect(res.batchId).toBeNull();
|
|
9
|
+
expect(res.sendResult).toBe(2);
|
|
10
|
+
}, 30000);
|
|
@@ -15,13 +15,14 @@ async function loginByPassword(loginKey, password, reqExtra = {
|
|
|
15
15
|
device: "Node",
|
|
16
16
|
browser: "Node.js",
|
|
17
17
|
}) {
|
|
18
|
-
const
|
|
19
|
-
.post(exports.url, {
|
|
18
|
+
const req = {
|
|
20
19
|
loginKey,
|
|
21
20
|
password,
|
|
22
21
|
clientCode: "STUDY_COMMUNITY",
|
|
23
22
|
extra: JSON.stringify({ ...reqExtra, scene: null }),
|
|
24
|
-
}
|
|
23
|
+
};
|
|
24
|
+
const { extra, ...restBody } = await axios_1.ccwAxios
|
|
25
|
+
.post(exports.url, req)
|
|
25
26
|
.then((res) => res.data.body);
|
|
26
27
|
const resExtra = JSON.parse(extra);
|
|
27
28
|
return {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.url = void 0;
|
|
4
|
+
exports.loginByPhone = loginByPhone;
|
|
5
|
+
const axios_1 = require("@ccw-api/axios");
|
|
6
|
+
exports.url = "https://sso.ccw.site/web/auth/v3/login/by_phone";
|
|
7
|
+
/**
|
|
8
|
+
* 通过手机号+短信验证码登录(V3)
|
|
9
|
+
* @param {string} phone 手机号,如 "12345671145"
|
|
10
|
+
* @param {string} code 收到的短信验证码
|
|
11
|
+
* @param {ReqExtra} reqExtra 设备和浏览器信息
|
|
12
|
+
* @param {string} countryCode 国家代码,默认 "86"
|
|
13
|
+
* @param {LoginRuleCode} ruleCode 短信规则编码,默认 "ccw_sms"
|
|
14
|
+
* @param {LoginScene} scene 登录场景,默认 "loginbyPhone"
|
|
15
|
+
* @returns {Promise<Res<Extra>>} session 信息
|
|
16
|
+
*/
|
|
17
|
+
async function loginByPhone(phone, code, reqExtra = {
|
|
18
|
+
device: "Node",
|
|
19
|
+
browser: "Node.js",
|
|
20
|
+
}, countryCode = "86", ruleCode = "ccw_sms", scene = "loginbyPhone") {
|
|
21
|
+
const { extra, ...restBody } = await axios_1.ccwAxios
|
|
22
|
+
.post(exports.url, {
|
|
23
|
+
phone,
|
|
24
|
+
code,
|
|
25
|
+
countryCode,
|
|
26
|
+
ruleCode,
|
|
27
|
+
scene,
|
|
28
|
+
clientCode: "STUDY_COMMUNITY",
|
|
29
|
+
extra: JSON.stringify({ ...reqExtra, scene: null }),
|
|
30
|
+
})
|
|
31
|
+
.then((res) => res.data.body);
|
|
32
|
+
const resExtra = JSON.parse(extra);
|
|
33
|
+
return {
|
|
34
|
+
...restBody,
|
|
35
|
+
extra: resExtra,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const by_phone_1 = require("./by-phone");
|
|
4
|
+
test("expect wrong sms code to throw error", async () => {
|
|
5
|
+
await expect((0, by_phone_1.loginByPhone)("12345671145", "000000", {
|
|
6
|
+
device: "Node.js Test",
|
|
7
|
+
browser: "Jest",
|
|
8
|
+
})).rejects.toThrow();
|
|
9
|
+
}, 30000);
|
|
@@ -12,7 +12,7 @@ export type Res = PagesRes<Comment>;
|
|
|
12
12
|
* 根据主题获取评论列表
|
|
13
13
|
* @param {string} subjectOid 主题oid
|
|
14
14
|
* @param {SubjectType} subjectType 主题类型 (如: "POST")
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {SectionType} sectionType 区块类型 (如: "COMMENT")
|
|
16
16
|
* @param {Partial<PageArgs<SortField| T>>} pageArgs_ 分页参数
|
|
17
17
|
* @returns {Promise<Res>} 评论分页结果
|
|
18
18
|
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MongoDBId } from "src/types/api";
|
|
2
|
+
export declare const url = "https://community-web.ccw.site/great_creation/update";
|
|
3
|
+
export type Req = {
|
|
4
|
+
creationOid: MongoDBId | "";
|
|
5
|
+
};
|
|
6
|
+
export type Res = boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 更换代表作
|
|
9
|
+
* @param {MongoDBId|""} creationOid 作品OID 若为""则是取消展示
|
|
10
|
+
* @returns {Promise<Res>} 更换结果
|
|
11
|
+
*/
|
|
12
|
+
export declare function updateGreatCreation(creationOid: MongoDBId | ""): Promise<Res>;
|
|
@@ -93,6 +93,10 @@ import { createComment } from "./comment/create";
|
|
|
93
93
|
import { likeComment } from "./comment/like_record/create";
|
|
94
94
|
import { getStudentFollowingPage } from "./student/following/page";
|
|
95
95
|
import { donateTrade } from "./study-trade/trade/donate";
|
|
96
|
+
import { getUserProductsPage } from "./user_package/user_product";
|
|
97
|
+
import { setUserProductStatus } from "./user_package/status";
|
|
98
|
+
import { updateGreatCreation } from "./great_creation/update";
|
|
99
|
+
import { getSmartContractList } from "./smart_contract/list";
|
|
96
100
|
export declare const communityWeb: {
|
|
97
101
|
acceptAward: typeof acceptAward;
|
|
98
102
|
donateTrade: typeof donateTrade;
|
|
@@ -153,6 +157,7 @@ export declare const communityWeb: {
|
|
|
153
157
|
getRemixedCreationPage: typeof getRemixedCreationPage;
|
|
154
158
|
getReputationScoreLogPage: typeof getReputationScoreLog;
|
|
155
159
|
getSearchHotWords: typeof getSearchHotWords;
|
|
160
|
+
getSmartContractList: typeof getSmartContractList;
|
|
156
161
|
getSplitRuleDetail: typeof getSplitRuleDetail;
|
|
157
162
|
getSpreadFeedUnreadCount: typeof getSpreadFeedUnreadCount;
|
|
158
163
|
getStudentBlockRecordDetail: typeof getStudentBlockRecordDetail;
|
|
@@ -176,6 +181,7 @@ export declare const communityWeb: {
|
|
|
176
181
|
getUserAssetStorageSize: typeof getUserAssetStorageSize;
|
|
177
182
|
getUserCardDetail: typeof getUserCardDetail;
|
|
178
183
|
getUserLabelList: typeof getUserLabelList;
|
|
184
|
+
getUserProductsPage: typeof getUserProductsPage;
|
|
179
185
|
getCreationsByStudent: typeof getCreationsByStudent;
|
|
180
186
|
insertCheckInRecord: typeof insertCheckInRecord;
|
|
181
187
|
likeComment: typeof likeComment;
|
|
@@ -184,9 +190,11 @@ export declare const communityWeb: {
|
|
|
184
190
|
searchCloudAssets: typeof searchCloudAssets;
|
|
185
191
|
searchCreationsByTag: typeof searchCreationsByTag;
|
|
186
192
|
sendEvent: typeof sendEvent;
|
|
193
|
+
setUserProductStatus: typeof setUserProductStatus;
|
|
187
194
|
submitCreation: typeof submitCreation;
|
|
188
195
|
topComment: typeof topComment;
|
|
189
196
|
updateCreation: typeof updateCreation;
|
|
197
|
+
updateGreatCreation: typeof updateGreatCreation;
|
|
190
198
|
updateStudent: typeof updateStudent;
|
|
191
199
|
viewCreationStats: typeof viewCreationStats;
|
|
192
200
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { MongoDBId } from "src/types/api";
|
|
2
|
+
export declare const url = "https://community-web.ccw.site/smart_contract/list";
|
|
3
|
+
export type SmartContractBizType = "CREATION";
|
|
4
|
+
export type Req = {
|
|
5
|
+
bizId: MongoDBId;
|
|
6
|
+
bizType: SmartContractBizType;
|
|
7
|
+
};
|
|
8
|
+
export type SmartContractRule = {
|
|
9
|
+
createdAt: number;
|
|
10
|
+
id: number;
|
|
11
|
+
rule: {
|
|
12
|
+
awardeeAccountId?: "${curUserAccountId}";
|
|
13
|
+
awarderAccountId?: "${smartContractAccountId}";
|
|
14
|
+
bucks: "${bucks}";
|
|
15
|
+
code: "donate" | "award";
|
|
16
|
+
donatorAccountId?: "${curUserAccountId}";
|
|
17
|
+
funSignature: {
|
|
18
|
+
en: string;
|
|
19
|
+
zh_cn: string;
|
|
20
|
+
};
|
|
21
|
+
splitDetailList?: {
|
|
22
|
+
accountId: "${smartContractAccountId}" | "${creationAccountId}";
|
|
23
|
+
rate: number;
|
|
24
|
+
}[];
|
|
25
|
+
title: string;
|
|
26
|
+
};
|
|
27
|
+
smartContractId: number;
|
|
28
|
+
updatedAt: number;
|
|
29
|
+
};
|
|
30
|
+
export type SmartCoinContract = {
|
|
31
|
+
accountId: MongoDBId;
|
|
32
|
+
bizId: MongoDBId;
|
|
33
|
+
bizType: SmartContractBizType;
|
|
34
|
+
createdAt: number;
|
|
35
|
+
id: number;
|
|
36
|
+
rules: SmartContractRule[];
|
|
37
|
+
status: "ENABLED";
|
|
38
|
+
title: "通用合约";
|
|
39
|
+
type: "GENERAL";
|
|
40
|
+
updatedAt: number;
|
|
41
|
+
};
|
|
42
|
+
export type Res = SmartCoinContract[];
|
|
43
|
+
/**
|
|
44
|
+
* 列出作品中的智能金币合约
|
|
45
|
+
* @param {MongoDBId} bizId 业务ID(如作品OID)
|
|
46
|
+
* @param {SmartContractBizType} bizType 业务类型,CREATION
|
|
47
|
+
* @returns {Promise<Res>} 智能合约列表
|
|
48
|
+
*/
|
|
49
|
+
export declare function getSmartContractList(bizId: MongoDBId, bizType?: SmartContractBizType): Promise<Res>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const url = "https://community-web.ccw.site/user_package/status";
|
|
2
|
+
export type Req = {
|
|
3
|
+
status: boolean;
|
|
4
|
+
id: number;
|
|
5
|
+
};
|
|
6
|
+
export type Res = boolean;
|
|
7
|
+
/**
|
|
8
|
+
* 设置用户商品状态(如佩戴/卸下头像框)
|
|
9
|
+
* @param {number} id 用户商品ID
|
|
10
|
+
* @param {boolean} status 商品状态,true为佩戴,false为卸下
|
|
11
|
+
* @returns {Promise<Res>} 设置结果
|
|
12
|
+
*/
|
|
13
|
+
export declare function setUserProductStatus(id: number, status: boolean): Promise<Res>;
|