@ccw-api/api 0.1.0 → 0.3.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 (114) hide show
  1. package/AGENT.md +271 -0
  2. package/coverage/clover.xml +605 -0
  3. package/coverage/coverage-final.json +49 -0
  4. package/coverage/lcov-report/base.css +224 -0
  5. package/coverage/lcov-report/block-navigation.js +87 -0
  6. package/coverage/lcov-report/favicon.png +0 -0
  7. package/coverage/lcov-report/index.html +671 -0
  8. package/coverage/lcov-report/prettify.css +1 -0
  9. package/coverage/lcov-report/prettify.js +2 -0
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +210 -0
  12. package/coverage/lcov.info +977 -0
  13. package/dist/esm/community-web/api/v1/short_code/encode.js +25 -0
  14. package/dist/esm/community-web/api/v1/short_code/shortcode.test.js +5 -0
  15. package/dist/esm/community-web/approval/approval.test.js +5 -0
  16. package/dist/esm/community-web/approval/list.js +16 -0
  17. package/dist/esm/community-web/base/dateTime.js +10 -0
  18. package/dist/esm/community-web/base/dateTime.test.js +6 -0
  19. package/dist/esm/community-web/campaign_resource/detail.js +12 -0
  20. package/dist/esm/community-web/campaign_resource/detail.test.js +10 -0
  21. package/dist/esm/community-web/check_in_record/check_in_record.test.js +8 -0
  22. package/dist/esm/community-web/check_in_record/detail.js +8 -0
  23. package/dist/esm/community-web/check_in_record/insert.js +12 -0
  24. package/dist/esm/community-web/cloud_asset/search.js +25 -0
  25. package/dist/esm/community-web/cloud_asset/search.test.js +6 -0
  26. package/dist/esm/community-web/cloud_asset/user/privacy.js +11 -0
  27. package/dist/esm/community-web/cloud_asset/user/privacy.test.js +4 -0
  28. package/dist/esm/community-web/comment/page.js +26 -0
  29. package/dist/esm/community-web/comment/page.test.js +15 -0
  30. package/dist/esm/community-web/comment/page_by_topic.js +26 -0
  31. package/dist/esm/community-web/comment/page_by_topic.test.js +13 -0
  32. package/dist/esm/community-web/config/detail.js +13 -0
  33. package/dist/esm/community-web/creation/creation.test.js +118 -0
  34. package/dist/esm/community-web/creation/detail.js +14 -0
  35. package/dist/esm/community-web/creation/excellent/list.js +13 -0
  36. package/dist/esm/community-web/creation/introduction/detail.js +13 -0
  37. package/dist/esm/community-web/creation/like/detail.js +13 -0
  38. package/dist/esm/community-web/creation/loading/tips.js +11 -0
  39. package/dist/esm/community-web/creation/page.js +24 -0
  40. package/dist/esm/community-web/creation/page_by_student.js +24 -0
  41. package/dist/esm/community-web/creation/potential/list.js +13 -0
  42. package/dist/esm/community-web/creation/recommend.js +23 -0
  43. package/dist/esm/community-web/creation/search/page.js +24 -0
  44. package/dist/esm/community-web/creation/student/detail.js +13 -0
  45. package/dist/esm/community-web/creation/tag/list.js +12 -0
  46. package/dist/esm/community-web/index.js +50 -0
  47. package/dist/esm/community-web/short_url/create.js +15 -0
  48. package/dist/esm/community-web/short_url/shortUrl.test.js +4 -0
  49. package/dist/esm/index.js +5 -2
  50. package/dist/esm/queryPages.js +22 -0
  51. package/dist/esm/sso/index.js +5 -3
  52. package/dist/esm/sso/web/auth/auth.test.js +13 -61
  53. package/dist/esm/sso/web/auth/login-by-password.js +25 -82
  54. package/dist/esm/sso/web/auth/logout.js +9 -48
  55. package/dist/esm/sso/web/auth/logout_by_session.js +12 -0
  56. package/dist/node/community-web/api/v1/short_code/encode.js +29 -0
  57. package/dist/node/community-web/api/v1/short_code/shortcode.test.js +7 -0
  58. package/dist/node/community-web/approval/approval.test.js +7 -0
  59. package/dist/node/community-web/approval/list.js +23 -0
  60. package/dist/node/community-web/base/dateTime.js +17 -0
  61. package/dist/node/community-web/base/dateTime.test.js +8 -0
  62. package/dist/node/community-web/campaign_resource/detail.js +16 -0
  63. package/dist/node/community-web/campaign_resource/detail.test.js +12 -0
  64. package/dist/node/community-web/check_in_record/check_in_record.test.js +10 -0
  65. package/dist/node/community-web/check_in_record/detail.js +12 -0
  66. package/dist/node/community-web/check_in_record/insert.js +16 -0
  67. package/dist/node/community-web/cloud_asset/search.js +29 -0
  68. package/dist/node/community-web/cloud_asset/search.test.js +8 -0
  69. package/dist/node/community-web/cloud_asset/user/privacy.js +15 -0
  70. package/dist/node/community-web/cloud_asset/user/privacy.test.js +6 -0
  71. package/dist/node/community-web/comment/page.js +30 -0
  72. package/dist/node/community-web/comment/page.test.js +17 -0
  73. package/dist/node/community-web/comment/page_by_topic.js +30 -0
  74. package/dist/node/community-web/comment/page_by_topic.test.js +15 -0
  75. package/dist/node/community-web/config/detail.js +17 -0
  76. package/dist/node/community-web/creation/creation.test.js +120 -0
  77. package/dist/node/community-web/creation/detail.js +18 -0
  78. package/dist/node/community-web/creation/excellent/list.js +17 -0
  79. package/dist/node/community-web/creation/introduction/detail.js +17 -0
  80. package/dist/node/community-web/creation/like/detail.js +17 -0
  81. package/dist/node/community-web/creation/loading/tips.js +15 -0
  82. package/dist/node/community-web/creation/page.js +28 -0
  83. package/dist/node/community-web/creation/page_by_student.js +28 -0
  84. package/dist/node/community-web/creation/potential/list.js +17 -0
  85. package/dist/node/community-web/creation/recommend.js +27 -0
  86. package/dist/node/community-web/creation/search/page.js +28 -0
  87. package/dist/node/community-web/creation/student/detail.js +17 -0
  88. package/dist/node/community-web/creation/tag/list.js +16 -0
  89. package/dist/node/community-web/index.js +53 -0
  90. package/dist/node/community-web/short_url/create.js +19 -0
  91. package/dist/node/community-web/short_url/shortUrl.test.js +6 -0
  92. package/dist/node/index.js +6 -2
  93. package/dist/node/queryPages.js +26 -0
  94. package/dist/node/sso/index.js +4 -2
  95. package/dist/node/sso/web/auth/auth.test.js +15 -63
  96. package/dist/node/sso/web/auth/login-by-password.js +25 -82
  97. package/dist/node/sso/web/auth/logout.js +9 -48
  98. package/dist/node/sso/web/auth/logout_by_session.js +16 -0
  99. package/package.json +7 -2
  100. package/tsconfig.json +5 -3
  101. package/dist/esm/types.js +0 -1
  102. package/dist/node/types.js +0 -2
  103. package/dist/types/index.d.ts +0 -10
  104. package/dist/types/sso/index.d.ts +0 -6
  105. package/dist/types/sso/web/auth/login-by-password.d.ts +0 -38
  106. package/dist/types/sso/web/auth/logout.d.ts +0 -3
  107. package/dist/types/types.d.ts +0 -17
  108. package/jest.config.ts +0 -13
  109. package/src/index.ts +0 -8
  110. package/src/sso/index.ts +0 -7
  111. package/src/sso/web/auth/auth.test.ts +0 -16
  112. package/src/sso/web/auth/login-by-password.ts +0 -58
  113. package/src/sso/web/auth/logout.ts +0 -9
  114. package/src/types.ts +0 -18
@@ -0,0 +1,25 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/api/v1/short_code/encode";
3
+ /**
4
+ * 生成作品邀请码
5
+ * @param {MongoDBId} inviterId 邀请人id
6
+ * @param {CachedOssUrl} inviterAvatar 邀请人头像
7
+ * @param {string} inviterName 邀请人用户名
8
+ * @param {MongoDBId} creationOid 作品id
9
+ * @returns {Promise<Res>}
10
+ */
11
+ export async function encodeShortCode(inviterId, inviterAvatar, inviterName, creationOid) {
12
+ const req = {
13
+ origin: {
14
+ inviterAvatar,
15
+ inviterName,
16
+ inviterId,
17
+ inviterType: "STUDENT",
18
+ entrance: "create_detail",
19
+ creationOid,
20
+ },
21
+ };
22
+ return await ccwAxios
23
+ .post(url, req)
24
+ .then((res) => res.data.body);
25
+ }
@@ -0,0 +1,5 @@
1
+ import { encodeShortCode } from "./encode";
2
+ test("test shortcode", async () => {
3
+ const res = await encodeShortCode("63c2807d669fa967f17f5559", "https://m.ccw.site/user_projects_assets/244373873/3fc7886d05aed9f369d2c0bb2d677fc0.jpeg", "孟夫子驾到", "6386e11cfc1ed14684de07f8");
4
+ expect(res.code).toHaveLength("yZdXmD3PvwVPA30W".length);
5
+ });
@@ -0,0 +1,5 @@
1
+ import { getApprovalTags } from "./list";
2
+ test("test approval list", async () => {
3
+ const tags = await getApprovalTags("63c2807d669fa967f17f5559");
4
+ expect(tags.find((v) => v.approvalTagId == 235).approvalTagName).toEqual("Gandi 开发者");
5
+ });
@@ -0,0 +1,16 @@
1
+ import ccwAxios from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/approval/list";
3
+ /**
4
+ * 获取特定用户的勋章数据
5
+ * @param {MongoDBId} studentOid 用户id
6
+ * @returns {Promise<Res<Tid, Tn>>} 勋章数据
7
+ */
8
+ export async function getApprovalTags(studentOid) {
9
+ const req = {
10
+ objectId: studentOid,
11
+ objectType: "STUDENT",
12
+ };
13
+ return await ccwAxios
14
+ .post(url, req)
15
+ .then((res) => res.data.body);
16
+ }
@@ -0,0 +1,10 @@
1
+ import ccwAxios from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/base/dateTime";
3
+ /**
4
+ * @returns {Promise<number>} 当前时间戳,相当于Date.now()
5
+ */
6
+ export async function getTime() {
7
+ return ccwAxios
8
+ .post(url, undefined)
9
+ .then((res) => res.data.body);
10
+ }
@@ -0,0 +1,6 @@
1
+ import { getTime } from "../base/dateTime";
2
+ test("get time should return a number", async () => {
3
+ const time = await getTime();
4
+ expect(typeof time).toBe("number");
5
+ expect(time).toBeGreaterThan(0);
6
+ });
@@ -0,0 +1,12 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/campaign_resource/detail";
3
+ /**
4
+ * 不知道这个接口有什么用,请查看https://www.ccw.site/pages/tags自行寻找用法
5
+ * @param {K} keyword 活动关键词
6
+ * @returns {Promise<Res<K>>}
7
+ */
8
+ export async function getCampaignResources(keyword) {
9
+ return await ccwAxios
10
+ .post(url, { keyword })
11
+ .then((res) => res.data.body);
12
+ }
@@ -0,0 +1,10 @@
1
+ import { getCampaignResources } from "./detail";
2
+ test("get campaign resources with tags keyword", async () => {
3
+ const res = await getCampaignResources("tags");
4
+ expect(res.keyword).toBe("tags");
5
+ expect(res.resourceType).toBe("SUBJECT_AREA");
6
+ });
7
+ test("get campaign resources with mmo keyword", async () => {
8
+ const res = await getCampaignResources("mmo");
9
+ expect(res.keyword).toBe("mmo");
10
+ });
@@ -0,0 +1,8 @@
1
+ import { getCheckInRecords } from "./detail";
2
+ import { insertCheckInRecord } from "./insert";
3
+ test("get check in records should fail without channel", async () => {
4
+ await expect(getCheckInRecords).rejects.toThrow("ccw axios Request failed: token为空(4001082401)");
5
+ });
6
+ test("insert check in record should fail without token", async () => {
7
+ await expect(insertCheckInRecord).rejects.toThrow("ccw axios Request failed: token为空(4001082401)");
8
+ });
@@ -0,0 +1,8 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/check_in_record/detail";
3
+ export async function getCheckInRecords() {
4
+ const req = { scene: "HOMEPAGE" };
5
+ return await ccwAxios
6
+ .post(url, req)
7
+ .then((res) => res.data.body);
8
+ }
@@ -0,0 +1,12 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/check_in_record/insert";
3
+ /**
4
+ * 插入签到记录
5
+ * @returns {Promise<boolean>} 是否成功
6
+ */
7
+ export async function insertCheckInRecord() {
8
+ const req = { scene: "HOMEPAGE" };
9
+ return await ccwAxios
10
+ .post(url, req)
11
+ .then((res) => res.data.body);
12
+ }
@@ -0,0 +1,25 @@
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/cloud_asset/search";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: "createdAt",
7
+ };
8
+ /**
9
+ *
10
+ * @param {MongoDBId} creatorOid 用户id
11
+ * @param {string} path 目录(例如'/23azZqHBnqj/2BzzTdi5I5C/')
12
+ * @param {Partial<PageArgs>} pageArgs_ 分页参数
13
+ * @returns {Promise<CloudAsset[]>} 目录内的素材
14
+ */
15
+ export async function searchCloudAssets(creatorOid, path = "/", pageArgs_ = {}) {
16
+ const pageArgs = {
17
+ ...dpa,
18
+ ...pageArgs_,
19
+ };
20
+ const queryUrl = queryPage(url, pageArgs);
21
+ const req = { creatorOid, path };
22
+ return await ccwAxios
23
+ .post(queryUrl, req)
24
+ .then((res) => res.data.body.data);
25
+ }
@@ -0,0 +1,6 @@
1
+ import { searchCloudAssets } from "./search";
2
+ test("search cloud assets should fail without token", async () => {
3
+ const userId = "63c2807d669fa967f17f5559";
4
+ const path = "/23azZqHBnqj/";
5
+ await expect(searchCloudAssets(userId, path)).rejects.toThrow("ccw axios Request failed: token为空(4001082401)");
6
+ });
@@ -0,0 +1,11 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/cloud_asset/user/privacy";
3
+ /**
4
+ * 获取用户云存储空间信息
5
+ * @returns {Promise<Res>} 存储空间信息
6
+ */
7
+ export async function getUserAssetStorageSize() {
8
+ return await ccwAxios
9
+ .post(url, {})
10
+ .then((res) => res.data.body);
11
+ }
@@ -0,0 +1,4 @@
1
+ import { getUserAssetStorageSize } from "./privacy";
2
+ test("get user asset storage size should fail without token", async () => {
3
+ await expect(getUserAssetStorageSize()).rejects.toThrow("ccw axios Request failed: token为空");
4
+ });
@@ -0,0 +1,26 @@
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/comment/page";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: null,
7
+ };
8
+ /**
9
+ * 根据topicId获取评论的回复
10
+ * @param {number} topicId 话题id
11
+ * @param {number} parentId 父评论id
12
+ * @param {("PUBLISHED" | "FOLDED")[]} statuses 状态过滤
13
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
14
+ * @returns {Promise<Comment[]>} 评论列表
15
+ */
16
+ export async function getCommentReplies(topicId, parentId, statuses = ["PUBLISHED", "FOLDED"], pageArgs_ = {}) {
17
+ const pageArgs = {
18
+ ...dpa,
19
+ ...pageArgs_,
20
+ };
21
+ const queryUrl = queryPage(url, pageArgs);
22
+ const req = { topicId, parentId, statuses };
23
+ return await ccwAxios
24
+ .post(queryUrl, req)
25
+ .then((res) => res.data.body.data);
26
+ }
@@ -0,0 +1,15 @@
1
+ import { getCommentReplies } from "./page";
2
+ test("get comment replies should return data", async () => {
3
+ const topicId = 819086;
4
+ const parentId = 9611280;
5
+ const statuses = ["PUBLISHED", "FOLDED"];
6
+ const res = await getCommentReplies(topicId, parentId, statuses);
7
+ expect(Array.isArray(res)).toBe(true);
8
+ res.forEach((comment) => {
9
+ expect(comment.id).toBeDefined();
10
+ expect(comment.topicId).toBe(topicId);
11
+ expect(comment.parentId).toBe(parentId);
12
+ expect(comment.content).toBeDefined();
13
+ expect(["PUBLISHED", "FOLDED"]).toContain(comment.status);
14
+ });
15
+ });
@@ -0,0 +1,26 @@
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/comment/page_by_topic";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: "createdAt",
7
+ };
8
+ /**
9
+ * 根据主题获取评论列表
10
+ * @param {string} subjectOid 主题oid
11
+ * @param {SubjectType} subjectType 主题类型 (如: "POST")
12
+ * @param {string} sectionType 区块类型 (如: "COMMENT")
13
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
14
+ * @returns {Promise<Comment[]>} 评论列表
15
+ */
16
+ export async function getCommentsByTopic(subjectOid, subjectType, sectionType, pageArgs_ = {}) {
17
+ const pageArgs = {
18
+ ...dpa,
19
+ ...pageArgs_,
20
+ };
21
+ const queryUrl = queryPage(url, pageArgs);
22
+ const req = { subjectOid, subjectType, sectionType };
23
+ return await ccwAxios
24
+ .post(queryUrl, req)
25
+ .then((res) => res.data.body.data);
26
+ }
@@ -0,0 +1,13 @@
1
+ import { getCommentsByTopic } from "./page_by_topic";
2
+ test("get comments by topic should return data", async () => {
3
+ const subjectOid = "6a3c73a3b6c84711978d92f2";
4
+ const subjectType = "POST";
5
+ const sectionType = "COMMENT";
6
+ const res = await getCommentsByTopic(subjectOid, subjectType, sectionType);
7
+ expect(Array.isArray(res)).toBe(true);
8
+ res.forEach((comment) => {
9
+ expect(comment.id).toBeDefined();
10
+ expect(comment.content).toBeDefined();
11
+ expect(["PUBLISHED", "FOLDED"]).toContain(comment.status);
12
+ });
13
+ });
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/config/detail";
3
+ /**
4
+ * 获取配置详情
5
+ * @param {string} key 配置键
6
+ * @returns {Promise<Res>} 配置值
7
+ */
8
+ export async function getConfigDetail(key) {
9
+ const req = { key };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,118 @@
1
+ import { getExcellentCreations } from "./excellent/list";
2
+ import { getPotentialCreations } from "./potential/list";
3
+ import { getRecommendCreations } from "./recommend";
4
+ import { searchCreationsByTag } from "./search/page";
5
+ import { getCreationTags } from "./tag/list";
6
+ import { getLoadingTips } from "./loading/tips";
7
+ import { getCreationDetail } from "./detail";
8
+ import { getCreationIntroduction } from "./introduction/detail";
9
+ import { getLikeDetail } from "./like/detail";
10
+ import { getCreationPage } from "./page";
11
+ import { getCreationsByStudent } from "./page_by_student";
12
+ import { getCreationStudentDetail } from "./student/detail";
13
+ let sampleCreationOid;
14
+ let sampleStudentOid;
15
+ beforeAll(async () => {
16
+ const creations = await getExcellentCreations(1);
17
+ if (creations.length > 0) {
18
+ sampleCreationOid = creations[0].oid;
19
+ sampleStudentOid = creations[0].studentOid;
20
+ }
21
+ }, 30000);
22
+ test("get excellent creations should return data", async () => {
23
+ const res = await getExcellentCreations(10);
24
+ expect(Array.isArray(res)).toBe(true);
25
+ res.forEach((c) => {
26
+ expect(c.oid).toBeDefined();
27
+ expect(c.title).toBeDefined();
28
+ });
29
+ });
30
+ test("get potential creations should return data", async () => {
31
+ const res = await getPotentialCreations(10);
32
+ expect(Array.isArray(res)).toBe(true);
33
+ res.forEach((c) => {
34
+ expect(c.oid).toBeDefined();
35
+ expect(c.title).toBeDefined();
36
+ });
37
+ });
38
+ test("get recommend creations should return data", async () => {
39
+ const res = await getRecommendCreations(10);
40
+ expect(Array.isArray(res)).toBe(true);
41
+ res.forEach((c) => {
42
+ expect(c.oid).toBeDefined();
43
+ expect(c.title).toBeDefined();
44
+ });
45
+ });
46
+ test("search creations by tag should return data", async () => {
47
+ const res = await searchCreationsByTag("史莱姆之森");
48
+ expect(Array.isArray(res)).toBe(true);
49
+ });
50
+ test("get creation tags should return data", async () => {
51
+ const res = await getCreationTags();
52
+ expect(Array.isArray(res)).toBe(true);
53
+ res.forEach((tag) => {
54
+ expect(tag.id).toBeDefined();
55
+ expect(tag.title).toBeDefined();
56
+ expect(tag.code).toBeDefined();
57
+ });
58
+ });
59
+ test("get loading tips should return data", async () => {
60
+ const res = await getLoadingTips();
61
+ expect(res["小八"]).toBeDefined();
62
+ expect(res["胖达"]).toBeDefined();
63
+ expect(res["妮可"]).toBeDefined();
64
+ expect(res["孙小弟"]).toBeDefined();
65
+ });
66
+ test("get creation detail should return data", async () => {
67
+ if (!sampleCreationOid) {
68
+ return;
69
+ }
70
+ const res = await getCreationDetail(sampleCreationOid, "");
71
+ expect(res.oid).toBe(sampleCreationOid);
72
+ expect(res.title).toBeDefined();
73
+ expect(res.student).toBeDefined();
74
+ });
75
+ test("get creation introduction should return data", async () => {
76
+ if (!sampleStudentOid) {
77
+ return;
78
+ }
79
+ const res = await getCreationIntroduction(sampleStudentOid);
80
+ expect(res.oid).toBeDefined();
81
+ expect(res.title).toBeDefined();
82
+ });
83
+ test("get like detail should return data", async () => {
84
+ if (!sampleCreationOid) {
85
+ return;
86
+ }
87
+ const res = await getLikeDetail(sampleCreationOid);
88
+ if (res) {
89
+ expect(res.creationOid).toBe(sampleCreationOid);
90
+ expect(res.action).toBeDefined();
91
+ }
92
+ });
93
+ test("get creation page should return data", async () => {
94
+ if (!sampleCreationOid) {
95
+ return;
96
+ }
97
+ const res = await getCreationPage([sampleCreationOid]);
98
+ expect(Array.isArray(res)).toBe(true);
99
+ });
100
+ test("get creations by student should return data", async () => {
101
+ if (!sampleStudentOid) {
102
+ return;
103
+ }
104
+ const res = await getCreationsByStudent([sampleStudentOid]);
105
+ expect(Array.isArray(res)).toBe(true);
106
+ res.forEach((c) => {
107
+ expect(c.oid).toBeDefined();
108
+ expect(c.studentOid).toBeDefined();
109
+ });
110
+ });
111
+ test("get creation student detail should return data", async () => {
112
+ if (!sampleStudentOid) {
113
+ return;
114
+ }
115
+ const res = await getCreationStudentDetail(sampleStudentOid);
116
+ expect(res.oid).toBe(sampleStudentOid);
117
+ expect(res.name).toBeDefined();
118
+ });
@@ -0,0 +1,14 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/detail";
3
+ /**
4
+ * 获取作品详情
5
+ * @param {MongoDBId} oid 作品id
6
+ * @param {string} accessKey
7
+ * @returns {Promise<Creation>} 作品详情
8
+ */
9
+ export async function getCreationDetail(oid, accessKey) {
10
+ const req = { oid, accessKey };
11
+ return await ccwAxios
12
+ .post(url, req)
13
+ .then((res) => res.data.body);
14
+ }
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/excellent/list";
3
+ /**
4
+ * 获取精选作品列表
5
+ * @param {number} num 数量
6
+ * @returns {Promise<CreationSimple[]>} 作品列表
7
+ */
8
+ export async function getExcellentCreations(num) {
9
+ const req = { num };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/introduction/detail";
3
+ /**
4
+ * 获取用户代表作
5
+ * @param {MongoDBId} studentOid 学生id
6
+ * @returns {Promise<Creation>} 作品详情
7
+ */
8
+ export async function getCreationIntroduction(studentOid) {
9
+ const req = { studentOid };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/like/detail";
3
+ /**
4
+ * 获取用户是否曾给作品点赞及点赞动作
5
+ * @param {MongoDBId} creationOid 作品id
6
+ * @returns {Promise<UserLikeDetail>} 点赞详情
7
+ */
8
+ export async function getLikeDetail(creationOid) {
9
+ const req = { creationOid };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,11 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/loading/tips";
3
+ /**
4
+ * 获取加载提示语
5
+ * @returns {Promise<LoadingTip>} 加载提示语
6
+ */
7
+ export async function getLoadingTips() {
8
+ return await ccwAxios
9
+ .post(url, {})
10
+ .then((res) => res.data.body);
11
+ }
@@ -0,0 +1,24 @@
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/creation/page";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: "createdAt",
7
+ };
8
+ /**
9
+ * 根据原作品id获取改编作品分页列表
10
+ * @param {MongoDBId[]} remixCreationOids 原作品id列表
11
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
12
+ * @returns {Promise<CreationSimple[]>} 改编作品列表
13
+ */
14
+ export async function getCreationPage(remixCreationOids, pageArgs_ = {}) {
15
+ const pageArgs = {
16
+ ...dpa,
17
+ ...pageArgs_,
18
+ };
19
+ const queryUrl = queryPage(url, pageArgs);
20
+ const req = { remixCreationOids };
21
+ return await ccwAxios
22
+ .post(queryUrl, req)
23
+ .then((res) => res.data.body.data);
24
+ }
@@ -0,0 +1,24 @@
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/creation/page_by_student";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: "createdAt",
7
+ };
8
+ /**
9
+ * 获取学生的作品列表
10
+ * @param {MongoDBId[]} studentOids 学生id列表
11
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
12
+ * @returns {Promise<Creation[]>} 作品列表
13
+ */
14
+ export async function getCreationsByStudent(studentOids, pageArgs_ = {}) {
15
+ const pageArgs = {
16
+ ...dpa,
17
+ ...pageArgs_,
18
+ };
19
+ const queryUrl = queryPage(url, pageArgs);
20
+ const req = { studentOids };
21
+ return await ccwAxios
22
+ .post(queryUrl, req)
23
+ .then((res) => res.data.body.data);
24
+ }
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/potential/list";
3
+ /**
4
+ * 获取潜力作品列表
5
+ * @param {number} num 数量
6
+ * @returns {Promise<CreationSimple[]>} 作品列表
7
+ */
8
+ export async function getPotentialCreations(num) {
9
+ const req = { num };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,23 @@
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/creation/recommend";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: "createdAt",
7
+ };
8
+ /**
9
+ * 获取推荐作品列表
10
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
11
+ * @returns {Promise<CreationSimple[]>} 作品列表
12
+ */
13
+ export async function getRecommendCreations(num, pageArgs_ = {}) {
14
+ const pageArgs = {
15
+ ...dpa,
16
+ ...pageArgs_,
17
+ };
18
+ const queryUrl = queryPage(url, pageArgs);
19
+ const req = { num, subjectType: "POTENTIAL" };
20
+ return await ccwAxios
21
+ .post(queryUrl, req)
22
+ .then((res) => res.data.body.data);
23
+ }
@@ -0,0 +1,24 @@
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/creation/search/page";
4
+ const dpa = {
5
+ ...DEFAULT_PAGE_ARGS,
6
+ sortField: "createdAt",
7
+ };
8
+ /**
9
+ * 按标签搜索作品
10
+ * @param {string} tag 标签 例如:游戏 动画故事 角色扮演
11
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
12
+ * @returns {Promise<CreationSimple[]>} 作品列表
13
+ */
14
+ export async function searchCreationsByTag(tag, pageArgs_ = {}) {
15
+ const pageArgs = {
16
+ ...dpa,
17
+ ...pageArgs_,
18
+ };
19
+ const queryUrl = queryPage(url, pageArgs);
20
+ const req = { tag };
21
+ return await ccwAxios
22
+ .post(queryUrl, req)
23
+ .then((res) => res.data.body.data);
24
+ }
@@ -0,0 +1,13 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/student/detail";
3
+ /**
4
+ * 获取学生详情
5
+ * @param {MongoDBId} studentOid 学生id
6
+ * @returns {Promise<Student>} 学生详情
7
+ */
8
+ export async function getCreationStudentDetail(studentOid) {
9
+ const req = { studentOid };
10
+ return await ccwAxios
11
+ .post(url, req)
12
+ .then((res) => res.data.body);
13
+ }
@@ -0,0 +1,12 @@
1
+ import { ccwAxios } from "@ccw-api/axios";
2
+ export const url = "https://community-web.ccw.site/creation/tag/list";
3
+ /**
4
+ * 获取作品标签列表 例如 https://www.ccw.site/pages/tags/anime
5
+ * @returns {Promise<CreationTag[]>} 标签列表
6
+ */
7
+ export async function getCreationTags() {
8
+ const req = { visibility: "PUBLIC" };
9
+ return await ccwAxios
10
+ .post(url, req)
11
+ .then((res) => res.data.body);
12
+ }