aai-lark-bridge 0.2.39 → 0.2.40
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/bin/aai-user-read.mjs +11 -3
- package/dist/cli.js +542 -27
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/bin/aai-user-read.mjs
CHANGED
|
@@ -10,7 +10,9 @@ const SUBCOMMANDS = {
|
|
|
10
10
|
'list-chat-messages': { '--chat-id': 'chatId', '--page-size': 'pageSize', '--page-token': 'pageToken', '--sort': 'sortType' },
|
|
11
11
|
'search-docs': { '--query': 'query', '--page-size': 'pageSize', '--page-token': 'pageToken' },
|
|
12
12
|
'fetch-doc': { '--doc': 'doc' },
|
|
13
|
+
'read-file': { '--message-id': 'messageId', '--file-key': 'fileKey', '--sheet': 'sheet', '--offset': 'offset', '--limit': 'limit', '--grep': 'grep' },
|
|
13
14
|
};
|
|
15
|
+
const REQUIRED = { 'search-messages': ['query'], 'get-message': ['messageId'], 'list-chat-messages': ['chatId'], 'search-docs': ['query'], 'fetch-doc': ['doc'], 'read-file': ['messageId', 'fileKey'] };
|
|
14
16
|
const SORT = { asc: 'ByCreateTimeAsc', desc: 'ByCreateTimeDesc' };
|
|
15
17
|
|
|
16
18
|
const USAGE = `用法:aai-user-read <子命令> [参数]
|
|
@@ -18,7 +20,8 @@ const USAGE = `用法:aai-user-read <子命令> [参数]
|
|
|
18
20
|
get-message --message-id om_xxx
|
|
19
21
|
list-chat-messages --chat-id oc_xxx [--page-size N] [--page-token T] [--sort asc|desc]
|
|
20
22
|
search-docs --query <关键词> [--page-size N] [--page-token T]
|
|
21
|
-
fetch-doc --doc <文档链接或 token
|
|
23
|
+
fetch-doc --doc <文档链接或 token>
|
|
24
|
+
read-file --message-id om_xxx --file-key file_xxx [--sheet 工作表名] [--offset N] [--limit N] [--grep 关键词]`;
|
|
22
25
|
|
|
23
26
|
export function parseArgs(argv) {
|
|
24
27
|
const [sub, ...rest] = argv;
|
|
@@ -42,6 +45,10 @@ export function parseArgs(argv) {
|
|
|
42
45
|
const n = Number(value);
|
|
43
46
|
if (!Number.isInteger(n)) throw new Error('--page-size 要是整数');
|
|
44
47
|
body.pageSize = n;
|
|
48
|
+
} else if (key === 'offset' || key === 'limit') {
|
|
49
|
+
const n = Number(value);
|
|
50
|
+
if (!Number.isInteger(n) || n < 0) throw new Error(`${flag} 要是非负整数`);
|
|
51
|
+
body[key] = n;
|
|
45
52
|
} else if (key === 'sortType') {
|
|
46
53
|
if (!SORT[value]) throw new Error('--sort 只能是 asc 或 desc');
|
|
47
54
|
body.sortType = SORT[value];
|
|
@@ -49,8 +56,9 @@ export function parseArgs(argv) {
|
|
|
49
56
|
body[key] = value;
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
|
-
const required
|
|
53
|
-
|
|
59
|
+
for (const required of REQUIRED[sub]) {
|
|
60
|
+
if (body[required] === undefined) throw new Error(`${sub} 要带 ${Object.keys(flags).find((f) => flags[f] === required)}`);
|
|
61
|
+
}
|
|
54
62
|
return { api: sub, body };
|
|
55
63
|
}
|
|
56
64
|
|