@ccw-api/api 0.0.2 → 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 (129) 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.esm.json +2 -1
  101. package/tsconfig.json +5 -3
  102. package/tsconfig.node.json +2 -1
  103. package/tsconfig.types.json +1 -1
  104. package/dist/esm/index.d.ts +0 -10
  105. package/dist/esm/sso/index.d.ts +0 -6
  106. package/dist/esm/sso/web/auth/auth.test.d.ts +0 -1
  107. package/dist/esm/sso/web/auth/login-by-password.d.ts +0 -38
  108. package/dist/esm/sso/web/auth/logout.d.ts +0 -3
  109. package/dist/esm/types.d.ts +0 -17
  110. package/dist/esm/types.js +0 -1
  111. package/dist/index.d.ts +0 -10
  112. package/dist/node/index.d.ts +0 -10
  113. package/dist/node/sso/index.d.ts +0 -6
  114. package/dist/node/sso/web/auth/auth.test.d.ts +0 -1
  115. package/dist/node/sso/web/auth/login-by-password.d.ts +0 -38
  116. package/dist/node/sso/web/auth/logout.d.ts +0 -3
  117. package/dist/node/types.d.ts +0 -17
  118. package/dist/node/types.js +0 -2
  119. package/dist/sso/index.d.ts +0 -6
  120. package/dist/sso/web/auth/login-by-password.d.ts +0 -38
  121. package/dist/sso/web/auth/logout.d.ts +0 -3
  122. package/dist/types.d.ts +0 -17
  123. package/jest.config.ts +0 -13
  124. package/src/index.ts +0 -8
  125. package/src/sso/index.ts +0 -7
  126. package/src/sso/web/auth/auth.test.ts +0 -16
  127. package/src/sso/web/auth/login-by-password.ts +0 -58
  128. package/src/sso/web/auth/logout.ts +0 -9
  129. package/src/types.ts +0 -18
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCommentReplies = getCommentReplies;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/comment/page";
8
+ const dpa = {
9
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
10
+ sortField: null,
11
+ };
12
+ /**
13
+ * 根据topicId获取评论的回复
14
+ * @param {number} topicId 话题id
15
+ * @param {number} parentId 父评论id
16
+ * @param {("PUBLISHED" | "FOLDED")[]} statuses 状态过滤
17
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
18
+ * @returns {Promise<Comment[]>} 评论列表
19
+ */
20
+ async function getCommentReplies(topicId, parentId, statuses = ["PUBLISHED", "FOLDED"], pageArgs_ = {}) {
21
+ const pageArgs = {
22
+ ...dpa,
23
+ ...pageArgs_,
24
+ };
25
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
26
+ const req = { topicId, parentId, statuses };
27
+ return await axios_1.ccwAxios
28
+ .post(queryUrl, req)
29
+ .then((res) => res.data.body.data);
30
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const page_1 = require("./page");
4
+ test("get comment replies should return data", async () => {
5
+ const topicId = 819086;
6
+ const parentId = 9611280;
7
+ const statuses = ["PUBLISHED", "FOLDED"];
8
+ const res = await (0, page_1.getCommentReplies)(topicId, parentId, statuses);
9
+ expect(Array.isArray(res)).toBe(true);
10
+ res.forEach((comment) => {
11
+ expect(comment.id).toBeDefined();
12
+ expect(comment.topicId).toBe(topicId);
13
+ expect(comment.parentId).toBe(parentId);
14
+ expect(comment.content).toBeDefined();
15
+ expect(["PUBLISHED", "FOLDED"]).toContain(comment.status);
16
+ });
17
+ });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCommentsByTopic = getCommentsByTopic;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/comment/page_by_topic";
8
+ const dpa = {
9
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
10
+ sortField: "createdAt",
11
+ };
12
+ /**
13
+ * 根据主题获取评论列表
14
+ * @param {string} subjectOid 主题oid
15
+ * @param {SubjectType} subjectType 主题类型 (如: "POST")
16
+ * @param {string} sectionType 区块类型 (如: "COMMENT")
17
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
18
+ * @returns {Promise<Comment[]>} 评论列表
19
+ */
20
+ async function getCommentsByTopic(subjectOid, subjectType, sectionType, pageArgs_ = {}) {
21
+ const pageArgs = {
22
+ ...dpa,
23
+ ...pageArgs_,
24
+ };
25
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
26
+ const req = { subjectOid, subjectType, sectionType };
27
+ return await axios_1.ccwAxios
28
+ .post(queryUrl, req)
29
+ .then((res) => res.data.body.data);
30
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const page_by_topic_1 = require("./page_by_topic");
4
+ test("get comments by topic should return data", async () => {
5
+ const subjectOid = "6a3c73a3b6c84711978d92f2";
6
+ const subjectType = "POST";
7
+ const sectionType = "COMMENT";
8
+ const res = await (0, page_by_topic_1.getCommentsByTopic)(subjectOid, subjectType, sectionType);
9
+ expect(Array.isArray(res)).toBe(true);
10
+ res.forEach((comment) => {
11
+ expect(comment.id).toBeDefined();
12
+ expect(comment.content).toBeDefined();
13
+ expect(["PUBLISHED", "FOLDED"]).toContain(comment.status);
14
+ });
15
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getConfigDetail = getConfigDetail;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/config/detail";
7
+ /**
8
+ * 获取配置详情
9
+ * @param {string} key 配置键
10
+ * @returns {Promise<Res>} 配置值
11
+ */
12
+ async function getConfigDetail(key) {
13
+ const req = { key };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const list_1 = require("./excellent/list");
4
+ const list_2 = require("./potential/list");
5
+ const recommend_1 = require("./recommend");
6
+ const page_1 = require("./search/page");
7
+ const list_3 = require("./tag/list");
8
+ const tips_1 = require("./loading/tips");
9
+ const detail_1 = require("./detail");
10
+ const detail_2 = require("./introduction/detail");
11
+ const detail_3 = require("./like/detail");
12
+ const page_2 = require("./page");
13
+ const page_by_student_1 = require("./page_by_student");
14
+ const detail_4 = require("./student/detail");
15
+ let sampleCreationOid;
16
+ let sampleStudentOid;
17
+ beforeAll(async () => {
18
+ const creations = await (0, list_1.getExcellentCreations)(1);
19
+ if (creations.length > 0) {
20
+ sampleCreationOid = creations[0].oid;
21
+ sampleStudentOid = creations[0].studentOid;
22
+ }
23
+ }, 30000);
24
+ test("get excellent creations should return data", async () => {
25
+ const res = await (0, list_1.getExcellentCreations)(10);
26
+ expect(Array.isArray(res)).toBe(true);
27
+ res.forEach((c) => {
28
+ expect(c.oid).toBeDefined();
29
+ expect(c.title).toBeDefined();
30
+ });
31
+ });
32
+ test("get potential creations should return data", async () => {
33
+ const res = await (0, list_2.getPotentialCreations)(10);
34
+ expect(Array.isArray(res)).toBe(true);
35
+ res.forEach((c) => {
36
+ expect(c.oid).toBeDefined();
37
+ expect(c.title).toBeDefined();
38
+ });
39
+ });
40
+ test("get recommend creations should return data", async () => {
41
+ const res = await (0, recommend_1.getRecommendCreations)(10);
42
+ expect(Array.isArray(res)).toBe(true);
43
+ res.forEach((c) => {
44
+ expect(c.oid).toBeDefined();
45
+ expect(c.title).toBeDefined();
46
+ });
47
+ });
48
+ test("search creations by tag should return data", async () => {
49
+ const res = await (0, page_1.searchCreationsByTag)("史莱姆之森");
50
+ expect(Array.isArray(res)).toBe(true);
51
+ });
52
+ test("get creation tags should return data", async () => {
53
+ const res = await (0, list_3.getCreationTags)();
54
+ expect(Array.isArray(res)).toBe(true);
55
+ res.forEach((tag) => {
56
+ expect(tag.id).toBeDefined();
57
+ expect(tag.title).toBeDefined();
58
+ expect(tag.code).toBeDefined();
59
+ });
60
+ });
61
+ test("get loading tips should return data", async () => {
62
+ const res = await (0, tips_1.getLoadingTips)();
63
+ expect(res["小八"]).toBeDefined();
64
+ expect(res["胖达"]).toBeDefined();
65
+ expect(res["妮可"]).toBeDefined();
66
+ expect(res["孙小弟"]).toBeDefined();
67
+ });
68
+ test("get creation detail should return data", async () => {
69
+ if (!sampleCreationOid) {
70
+ return;
71
+ }
72
+ const res = await (0, detail_1.getCreationDetail)(sampleCreationOid, "");
73
+ expect(res.oid).toBe(sampleCreationOid);
74
+ expect(res.title).toBeDefined();
75
+ expect(res.student).toBeDefined();
76
+ });
77
+ test("get creation introduction should return data", async () => {
78
+ if (!sampleStudentOid) {
79
+ return;
80
+ }
81
+ const res = await (0, detail_2.getCreationIntroduction)(sampleStudentOid);
82
+ expect(res.oid).toBeDefined();
83
+ expect(res.title).toBeDefined();
84
+ });
85
+ test("get like detail should return data", async () => {
86
+ if (!sampleCreationOid) {
87
+ return;
88
+ }
89
+ const res = await (0, detail_3.getLikeDetail)(sampleCreationOid);
90
+ if (res) {
91
+ expect(res.creationOid).toBe(sampleCreationOid);
92
+ expect(res.action).toBeDefined();
93
+ }
94
+ });
95
+ test("get creation page should return data", async () => {
96
+ if (!sampleCreationOid) {
97
+ return;
98
+ }
99
+ const res = await (0, page_2.getCreationPage)([sampleCreationOid]);
100
+ expect(Array.isArray(res)).toBe(true);
101
+ });
102
+ test("get creations by student should return data", async () => {
103
+ if (!sampleStudentOid) {
104
+ return;
105
+ }
106
+ const res = await (0, page_by_student_1.getCreationsByStudent)([sampleStudentOid]);
107
+ expect(Array.isArray(res)).toBe(true);
108
+ res.forEach((c) => {
109
+ expect(c.oid).toBeDefined();
110
+ expect(c.studentOid).toBeDefined();
111
+ });
112
+ });
113
+ test("get creation student detail should return data", async () => {
114
+ if (!sampleStudentOid) {
115
+ return;
116
+ }
117
+ const res = await (0, detail_4.getCreationStudentDetail)(sampleStudentOid);
118
+ expect(res.oid).toBe(sampleStudentOid);
119
+ expect(res.name).toBeDefined();
120
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCreationDetail = getCreationDetail;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/detail";
7
+ /**
8
+ * 获取作品详情
9
+ * @param {MongoDBId} oid 作品id
10
+ * @param {string} accessKey
11
+ * @returns {Promise<Creation>} 作品详情
12
+ */
13
+ async function getCreationDetail(oid, accessKey) {
14
+ const req = { oid, accessKey };
15
+ return await axios_1.ccwAxios
16
+ .post(exports.url, req)
17
+ .then((res) => res.data.body);
18
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getExcellentCreations = getExcellentCreations;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/excellent/list";
7
+ /**
8
+ * 获取精选作品列表
9
+ * @param {number} num 数量
10
+ * @returns {Promise<CreationSimple[]>} 作品列表
11
+ */
12
+ async function getExcellentCreations(num) {
13
+ const req = { num };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCreationIntroduction = getCreationIntroduction;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/introduction/detail";
7
+ /**
8
+ * 获取用户代表作
9
+ * @param {MongoDBId} studentOid 学生id
10
+ * @returns {Promise<Creation>} 作品详情
11
+ */
12
+ async function getCreationIntroduction(studentOid) {
13
+ const req = { studentOid };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getLikeDetail = getLikeDetail;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/like/detail";
7
+ /**
8
+ * 获取用户是否曾给作品点赞及点赞动作
9
+ * @param {MongoDBId} creationOid 作品id
10
+ * @returns {Promise<UserLikeDetail>} 点赞详情
11
+ */
12
+ async function getLikeDetail(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,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getLoadingTips = getLoadingTips;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/loading/tips";
7
+ /**
8
+ * 获取加载提示语
9
+ * @returns {Promise<LoadingTip>} 加载提示语
10
+ */
11
+ async function getLoadingTips() {
12
+ return await axios_1.ccwAxios
13
+ .post(exports.url, {})
14
+ .then((res) => res.data.body);
15
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCreationPage = getCreationPage;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/creation/page";
8
+ const dpa = {
9
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
10
+ sortField: "createdAt",
11
+ };
12
+ /**
13
+ * 根据原作品id获取改编作品分页列表
14
+ * @param {MongoDBId[]} remixCreationOids 原作品id列表
15
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
16
+ * @returns {Promise<CreationSimple[]>} 改编作品列表
17
+ */
18
+ async function getCreationPage(remixCreationOids, pageArgs_ = {}) {
19
+ const pageArgs = {
20
+ ...dpa,
21
+ ...pageArgs_,
22
+ };
23
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
24
+ const req = { remixCreationOids };
25
+ return await axios_1.ccwAxios
26
+ .post(queryUrl, req)
27
+ .then((res) => res.data.body.data);
28
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCreationsByStudent = getCreationsByStudent;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/creation/page_by_student";
8
+ const dpa = {
9
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
10
+ sortField: "createdAt",
11
+ };
12
+ /**
13
+ * 获取学生的作品列表
14
+ * @param {MongoDBId[]} studentOids 学生id列表
15
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
16
+ * @returns {Promise<Creation[]>} 作品列表
17
+ */
18
+ async function getCreationsByStudent(studentOids, pageArgs_ = {}) {
19
+ const pageArgs = {
20
+ ...dpa,
21
+ ...pageArgs_,
22
+ };
23
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
24
+ const req = { studentOids };
25
+ return await axios_1.ccwAxios
26
+ .post(queryUrl, req)
27
+ .then((res) => res.data.body.data);
28
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getPotentialCreations = getPotentialCreations;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/potential/list";
7
+ /**
8
+ * 获取潜力作品列表
9
+ * @param {number} num 数量
10
+ * @returns {Promise<CreationSimple[]>} 作品列表
11
+ */
12
+ async function getPotentialCreations(num) {
13
+ const req = { num };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getRecommendCreations = getRecommendCreations;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/creation/recommend";
8
+ const dpa = {
9
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
10
+ sortField: "createdAt",
11
+ };
12
+ /**
13
+ * 获取推荐作品列表
14
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
15
+ * @returns {Promise<CreationSimple[]>} 作品列表
16
+ */
17
+ async function getRecommendCreations(num, pageArgs_ = {}) {
18
+ const pageArgs = {
19
+ ...dpa,
20
+ ...pageArgs_,
21
+ };
22
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
23
+ const req = { num, subjectType: "POTENTIAL" };
24
+ return await axios_1.ccwAxios
25
+ .post(queryUrl, req)
26
+ .then((res) => res.data.body.data);
27
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.searchCreationsByTag = searchCreationsByTag;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ const queryPages_1 = require("src/queryPages");
7
+ exports.url = "https://community-web.ccw.site/creation/search/page";
8
+ const dpa = {
9
+ ...queryPages_1.DEFAULT_PAGE_ARGS,
10
+ sortField: "createdAt",
11
+ };
12
+ /**
13
+ * 按标签搜索作品
14
+ * @param {string} tag 标签 例如:游戏 动画故事 角色扮演
15
+ * @param {Partial<PageArgs<SortField>>} pageArgs_ 分页参数
16
+ * @returns {Promise<CreationSimple[]>} 作品列表
17
+ */
18
+ async function searchCreationsByTag(tag, pageArgs_ = {}) {
19
+ const pageArgs = {
20
+ ...dpa,
21
+ ...pageArgs_,
22
+ };
23
+ const queryUrl = (0, queryPages_1.queryPage)(exports.url, pageArgs);
24
+ const req = { tag };
25
+ return await axios_1.ccwAxios
26
+ .post(queryUrl, req)
27
+ .then((res) => res.data.body.data);
28
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCreationStudentDetail = getCreationStudentDetail;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/student/detail";
7
+ /**
8
+ * 获取学生详情
9
+ * @param {MongoDBId} studentOid 学生id
10
+ * @returns {Promise<Student>} 学生详情
11
+ */
12
+ async function getCreationStudentDetail(studentOid) {
13
+ const req = { studentOid };
14
+ return await axios_1.ccwAxios
15
+ .post(exports.url, req)
16
+ .then((res) => res.data.body);
17
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.getCreationTags = getCreationTags;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/creation/tag/list";
7
+ /**
8
+ * 获取作品标签列表 例如 https://www.ccw.site/pages/tags/anime
9
+ * @returns {Promise<CreationTag[]>} 标签列表
10
+ */
11
+ async function getCreationTags() {
12
+ const req = { visibility: "PUBLIC" };
13
+ return await axios_1.ccwAxios
14
+ .post(exports.url, req)
15
+ .then((res) => res.data.body);
16
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.communityWeb = void 0;
4
+ const encode_1 = require("./api/v1/short_code/encode");
5
+ const list_1 = require("./approval/list");
6
+ const dateTime_1 = require("./base/dateTime");
7
+ const detail_1 = require("./campaign_resource/detail");
8
+ const detail_2 = require("./check_in_record/detail");
9
+ const insert_1 = require("./check_in_record/insert");
10
+ const privacy_1 = require("./cloud_asset/user/privacy");
11
+ const search_1 = require("./cloud_asset/search");
12
+ const page_1 = require("./comment/page");
13
+ const page_by_topic_1 = require("./comment/page_by_topic");
14
+ const detail_3 = require("./config/detail");
15
+ const detail_4 = require("./creation/detail");
16
+ const list_2 = require("./creation/excellent/list");
17
+ const detail_5 = require("./creation/introduction/detail");
18
+ const detail_6 = require("./creation/like/detail");
19
+ const tips_1 = require("./creation/loading/tips");
20
+ const page_2 = require("./creation/page");
21
+ const page_by_student_1 = require("./creation/page_by_student");
22
+ const list_3 = require("./creation/potential/list");
23
+ const recommend_1 = require("./creation/recommend");
24
+ const page_3 = require("./creation/search/page");
25
+ const detail_7 = require("./creation/student/detail");
26
+ const list_4 = require("./creation/tag/list");
27
+ const create_1 = require("./short_url/create");
28
+ exports.communityWeb = {
29
+ encodeShortCode: encode_1.encodeShortCode,
30
+ createShortUrl: create_1.createShortUrl,
31
+ getApprovalTags: list_1.getApprovalTags,
32
+ getCampaignResources: detail_1.getCampaignResources,
33
+ getCheckInRecords: detail_2.getCheckInRecords,
34
+ getCommentReplies: page_1.getCommentReplies,
35
+ getCommentsByTopic: page_by_topic_1.getCommentsByTopic,
36
+ getConfigDetail: detail_3.getConfigDetail,
37
+ getCreationDetail: detail_4.getCreationDetail,
38
+ getCreationIntroduction: detail_5.getCreationIntroduction,
39
+ getCreationPage: page_2.getCreationPage,
40
+ getCreationStudentDetail: detail_7.getCreationStudentDetail,
41
+ getCreationTags: list_4.getCreationTags,
42
+ getCreationsByStudent: page_by_student_1.getCreationsByStudent,
43
+ getExcellentCreations: list_2.getExcellentCreations,
44
+ getLikeDetail: detail_6.getLikeDetail,
45
+ getLoadingTips: tips_1.getLoadingTips,
46
+ getPotentialCreations: list_3.getPotentialCreations,
47
+ getRecommendCreations: recommend_1.getRecommendCreations,
48
+ getUserAssetStorageSize: privacy_1.getUserAssetStorageSize,
49
+ insertCheckInRecord: insert_1.insertCheckInRecord,
50
+ searchCloudAssets: search_1.searchCloudAssets,
51
+ searchCreationsByTag: page_3.searchCreationsByTag,
52
+ getTime: dateTime_1.getTime,
53
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.url = void 0;
4
+ exports.createShortUrl = createShortUrl;
5
+ const axios_1 = require("@ccw-api/axios");
6
+ exports.url = "https://community-web.ccw.site/short_url/create";
7
+ /**
8
+ * 创建短链接(用于分享)
9
+ * @param originUrl 原链接
10
+ * @returns {Promise<Res>} 创建的短链接
11
+ */
12
+ async function createShortUrl(originUrl) {
13
+ const req = {
14
+ originUrl,
15
+ };
16
+ return await axios_1.ccwAxios
17
+ .post(exports.url, req)
18
+ .then((res) => res.data.body);
19
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const create_1 = require("./create");
4
+ test("create short url", async () => {
5
+ expect(await (0, create_1.createShortUrl)("https://www.ccw.site/detail/6386e11cfc1ed14684de07f8?inviteCode=yZdXmD3PvwVPA30W")).toEqual("https://ccw.site/s/1Wr61k");
6
+ });
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sso = void 0;
4
- var index_1 = require("./sso/index");
3
+ exports.communityWeb = exports.sso = void 0;
4
+ /// <reference path="../types/types.d.ts">
5
+ const index_1 = require("./sso/index");
5
6
  Object.defineProperty(exports, "sso", { enumerable: true, get: function () { return index_1.sso; } });
7
+ const community_web_1 = require("./community-web");
8
+ Object.defineProperty(exports, "communityWeb", { enumerable: true, get: function () { return community_web_1.communityWeb; } });
6
9
  exports.default = {
7
10
  sso: index_1.sso,
11
+ communityWeb: community_web_1.communityWeb,
8
12
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_PAGE_ARGS = void 0;
4
+ exports.queryPage = queryPage;
5
+ /**
6
+ * 生成ccw分页查询url
7
+ * @param url_ 分页查询api
8
+ * @param {PageArgs} pageArgs 分页参数
9
+ * @returns 生成的实际查询url
10
+ */
11
+ function queryPage(url_, pageArgs) {
12
+ const url = new URL(url_);
13
+ Object.entries(pageArgs).forEach(([k, v]) => {
14
+ if (v == null) {
15
+ return;
16
+ }
17
+ url.searchParams.set(k, v);
18
+ });
19
+ return url.toString();
20
+ }
21
+ exports.DEFAULT_PAGE_ARGS = {
22
+ page: 1,
23
+ perPage: 20,
24
+ sortType: "DESC",
25
+ sortField: "",
26
+ };
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sso = void 0;
4
- var login_by_password_1 = require("./web/auth/login-by-password");
5
- var logout_1 = require("./web/auth/logout");
4
+ const login_by_password_1 = require("./web/auth/login-by-password");
5
+ const logout_1 = require("./web/auth/logout");
6
+ const logout_by_session_1 = require("./web/auth/logout_by_session");
6
7
  exports.sso = {
7
8
  loginByPassword: login_by_password_1.loginByPassword,
8
9
  logout: logout_1.logout,
10
+ logoutBySession: logout_by_session_1.logoutBySession,
9
11
  };