@lark-apaas/miaoda-cli 0.1.19-alpha.c3da59d → 0.1.19-alpha.e4d5797
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/dist/api/comment/api.js
CHANGED
|
@@ -15,7 +15,7 @@ async function getComments(appID, onlyUnresolved = false) {
|
|
|
15
15
|
const body = await (0, http_1.getInnerApi)(url, {
|
|
16
16
|
errPrefix: 'Failed to list comments',
|
|
17
17
|
});
|
|
18
|
-
return body.
|
|
18
|
+
return body.comments ?? [];
|
|
19
19
|
}
|
|
20
20
|
/** POST /api/v1/studio/innerapi/apps/:appID/comments/:commentID/resolve — 解决评论 */
|
|
21
21
|
async function resolveComment(appID, commentID) {
|
|
@@ -37,56 +37,26 @@ exports.handleCommentList = handleCommentList;
|
|
|
37
37
|
const api = __importStar(require("../../../api/index"));
|
|
38
38
|
const shared_1 = require("../../../cli/commands/shared");
|
|
39
39
|
const output_1 = require("../../../utils/output");
|
|
40
|
-
/** 单个内联元素渲染成文本:text_run 出文本、docs_link 出链接、person 出 @user。 */
|
|
41
|
-
function renderElement(el) {
|
|
42
|
-
if (el.text_run?.text)
|
|
43
|
-
return el.text_run.text;
|
|
44
|
-
if (el.docs_link?.url)
|
|
45
|
-
return el.docs_link.url;
|
|
46
|
-
if (el.person?.user_id)
|
|
47
|
-
return `@${el.person.user_id}`;
|
|
48
|
-
return '';
|
|
49
|
-
}
|
|
50
|
-
/** 一条 reply:正文(各 element 拼接)+ extra 图片数量标注(extra.image_list)。 */
|
|
51
|
-
function renderReply(r) {
|
|
52
|
-
const body = (r.content?.elements ?? []).map(renderElement).join('').trim();
|
|
53
|
-
const images = r.extra?.image_list;
|
|
54
|
-
const imageCount = Array.isArray(images) ? images.length : 0;
|
|
55
|
-
const parts = [body, imageCount > 0 ? `[图片×${String(imageCount)}]` : ''].filter((p) => p.length > 0);
|
|
56
|
-
return parts.join(' ');
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* pretty 的 content 列:把所有 reply 渲染后用 " | " 拼接。含 @人 / 云文档链接 / 图片标注等
|
|
60
|
-
* extra 信息。仅用于 pretty 概览;JSON 模式原样透传完整 reply_list。
|
|
61
|
-
*/
|
|
62
|
-
function commentText(c) {
|
|
63
|
-
return (c.reply_list?.replies ?? [])
|
|
64
|
-
.map(renderReply)
|
|
65
|
-
.filter((t) => t.length > 0)
|
|
66
|
-
.join(' | ');
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* pretty 概览列;JSON 模式忽略 schema,原样输出完整评论结构(与 openapi file.comment 一致)。
|
|
70
|
-
* strict:pretty 只渲染这些列,不把 reply_list / quote 等嵌套字段追加成额外列。
|
|
71
|
-
*/
|
|
72
40
|
const listSchema = {
|
|
73
|
-
strict: true,
|
|
74
41
|
columns: [
|
|
75
42
|
{ key: 'comment_id', label: 'id' },
|
|
76
|
-
{ key: '
|
|
43
|
+
{ key: 'finish' },
|
|
44
|
+
{ key: 'resolved' },
|
|
77
45
|
{ key: 'user_id', label: 'user' },
|
|
78
46
|
{ key: 'create_time', label: 'time', format: output_1.fmt.sec() },
|
|
79
|
-
{
|
|
80
|
-
key: 'content',
|
|
81
|
-
label: 'content',
|
|
82
|
-
derive: (row) => commentText(row),
|
|
83
|
-
format: output_1.fmt.truncate(80),
|
|
84
|
-
},
|
|
47
|
+
{ key: 'content', format: output_1.fmt.truncate(80) },
|
|
85
48
|
],
|
|
86
49
|
};
|
|
87
50
|
async function handleCommentList(opts) {
|
|
88
51
|
const appId = (0, shared_1.resolveAppId)({ appId: opts.appId });
|
|
89
52
|
const comments = await api.comment.getComments(appId, opts.onlyUnresolved ?? false);
|
|
90
|
-
|
|
91
|
-
|
|
53
|
+
const rows = comments.map((c) => ({
|
|
54
|
+
comment_id: c.commentID,
|
|
55
|
+
content: c.content,
|
|
56
|
+
user_id: c.userID,
|
|
57
|
+
finish: c.finish,
|
|
58
|
+
resolved: c.finish === 1,
|
|
59
|
+
create_time: c.createTime,
|
|
60
|
+
}));
|
|
61
|
+
(0, output_1.emit)({ data: rows }, listSchema);
|
|
92
62
|
}
|