lansenger-cli 1.0.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.
@@ -0,0 +1,255 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerMessageCommands = registerMessageCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerMessageCommands(program) {
6
+ const cmd = program.command("message").description("Send and manage messages");
7
+ cmd
8
+ .command("send-text")
9
+ .description("Send a text message")
10
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
11
+ .requiredOption("--content <content>", "Message content")
12
+ .option("-g, --group", "Send as group message", false)
13
+ .option("--mention-all", "Mention all group members", false)
14
+ .option("--mention <ids>", "Comma-separated user IDs to mention")
15
+ .option("--user-token <token>", "User token for user-context sending")
16
+ .option("--file-path <path>", "File path to attach")
17
+ .option("--media-type <type>", "Media type (1=video,2=image,3=file)")
18
+ .action(async (opts) => {
19
+ const client = (0, utils_1.getClient)();
20
+ const mentionUserIds = opts.mention ? (0, utils_1.commaList)(opts.mention) : undefined;
21
+ const result = await client.sendText(opts.chatId, opts.content, {
22
+ is_group: opts.group,
23
+ reminder_all: opts.mentionAll,
24
+ reminder_user_ids: mentionUserIds,
25
+ user_token: opts.userToken || undefined,
26
+ file_path: opts.filePath || undefined,
27
+ media_type: opts.mediaType ? parseInt(opts.mediaType) : undefined,
28
+ });
29
+ (0, utils_1.checkError)(result);
30
+ (0, utils_1.outputResult)(result);
31
+ });
32
+ cmd
33
+ .command("send-markdown")
34
+ .description("Send a markdown/formatted text message")
35
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
36
+ .requiredOption("--content <content>", "Markdown content")
37
+ .option("-g, --group", "Send as group message", false)
38
+ .option("--mention-all", "Mention all group members", false)
39
+ .option("--mention <ids>", "Comma-separated user IDs to mention")
40
+ .option("--user-token <token>", "User token for user-context sending")
41
+ .action(async (opts) => {
42
+ const client = (0, utils_1.getClient)();
43
+ const mentionUserIds = opts.mention ? (0, utils_1.commaList)(opts.mention) : undefined;
44
+ const result = await client.sendMarkdown(opts.chatId, opts.content, {
45
+ is_group: opts.group,
46
+ reminder_all: opts.mentionAll,
47
+ reminder_user_ids: mentionUserIds,
48
+ user_token: opts.userToken || undefined,
49
+ });
50
+ (0, utils_1.checkError)(result);
51
+ (0, utils_1.outputResult)(result);
52
+ });
53
+ cmd
54
+ .command("send-file")
55
+ .description("Send a file message")
56
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
57
+ .requiredOption("--file-path <path>", "File path to send")
58
+ .option("--caption <caption>", "Caption text")
59
+ .option("--media-type <type>", "Media type (1=video,2=image,3=file)")
60
+ .option("-g, --group", "Send as group message", false)
61
+ .option("--user-token <token>", "User token for user-context sending")
62
+ .action(async (opts) => {
63
+ const client = (0, utils_1.getClient)();
64
+ const result = await client.sendFile(opts.chatId, opts.filePath, {
65
+ caption: opts.caption || undefined,
66
+ media_type: opts.mediaType ? parseInt(opts.mediaType) : undefined,
67
+ is_group: opts.group,
68
+ user_token: opts.userToken || undefined,
69
+ });
70
+ (0, utils_1.checkError)(result);
71
+ (0, utils_1.outputResult)(result);
72
+ });
73
+ cmd
74
+ .command("send-link-card")
75
+ .description("Send a link card message")
76
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
77
+ .requiredOption("--title <title>", "Card title")
78
+ .requiredOption("--link <link>", "Card link URL")
79
+ .option("--description <desc>", "Card description")
80
+ .option("-g, --group", "Send as group message", false)
81
+ .option("--user-token <token>", "User token for user-context sending")
82
+ .action(async (opts) => {
83
+ const client = (0, utils_1.getClient)();
84
+ const result = await client.sendLinkCard(opts.chatId, opts.title, opts.link, {
85
+ description: opts.description || undefined,
86
+ is_group: opts.group,
87
+ user_token: opts.userToken || undefined,
88
+ });
89
+ (0, utils_1.checkError)(result);
90
+ (0, utils_1.outputResult)(result);
91
+ });
92
+ cmd
93
+ .command("send-app-articles")
94
+ .description("Send app articles message")
95
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
96
+ .requiredOption("--articles <json>", "Articles JSON array")
97
+ .option("-g, --group", "Send as group message", false)
98
+ .option("--user-token <token>", "User token for user-context sending")
99
+ .action(async (opts) => {
100
+ const client = (0, utils_1.getClient)();
101
+ const articles = (0, utils_1.parseJsonOption)(opts.articles);
102
+ const result = await client.sendAppArticles(opts.chatId, articles, {
103
+ is_group: opts.group,
104
+ user_token: opts.userToken || undefined,
105
+ });
106
+ (0, utils_1.checkError)(result);
107
+ (0, utils_1.outputResult)(result);
108
+ });
109
+ cmd
110
+ .command("send-app-card")
111
+ .description("Send an app card message")
112
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
113
+ .requiredOption("--body-title <title>", "Card body title")
114
+ .option("--head-title <title>", "Card head title")
115
+ .option("--body-content <content>", "Card body content")
116
+ .option("--is-dynamic", "Mark as dynamic card", false)
117
+ .option("--fields <json>", "Card fields JSON array")
118
+ .option("--links <json>", "Card links JSON array")
119
+ .option("-g, --group", "Send as group message", false)
120
+ .option("--user-token <token>", "User token for user-context sending")
121
+ .action(async (opts) => {
122
+ const client = (0, utils_1.getClient)();
123
+ const fields = opts.fields ? (0, utils_1.parseJsonOption)(opts.fields) : undefined;
124
+ const links = opts.links ? (0, utils_1.parseJsonOption)(opts.links) : undefined;
125
+ const result = await client.sendAppCard(opts.chatId, opts.bodyTitle, {
126
+ head_title: opts.headTitle || undefined,
127
+ body_content: opts.bodyContent || undefined,
128
+ is_dynamic: opts.isDynamic,
129
+ fields,
130
+ links,
131
+ is_group: opts.group,
132
+ user_token: opts.userToken || undefined,
133
+ });
134
+ (0, utils_1.checkError)(result);
135
+ (0, utils_1.outputResult)(result);
136
+ });
137
+ cmd
138
+ .command("send-oacard")
139
+ .description("Send an OA card message")
140
+ .requiredOption("-c, --chat-id <chatId>", "Chat ID (receiver)")
141
+ .requiredOption("--title <title>", "OA card title")
142
+ .option("--fields <json>", "OA card fields JSON array")
143
+ .option("--link <link>", "OA card link URL")
144
+ .option("-g, --group", "Send as group message", false)
145
+ .option("--user-token <token>", "User token for user-context sending")
146
+ .action(async (opts) => {
147
+ const client = (0, utils_1.getClient)();
148
+ const fields = opts.fields ? (0, utils_1.parseJsonOption)(opts.fields) : undefined;
149
+ const result = await client.sendOacard(opts.chatId, opts.title, {
150
+ fields,
151
+ link: opts.link || undefined,
152
+ is_group: opts.group,
153
+ user_token: opts.userToken || undefined,
154
+ });
155
+ (0, utils_1.checkError)(result);
156
+ (0, utils_1.outputResult)(result);
157
+ });
158
+ cmd
159
+ .command("update-dynamic-card")
160
+ .description("Update a dynamic card message")
161
+ .requiredOption("--msg-id <msgId>", "Message ID of the dynamic card")
162
+ .option("--is-last-update", "Mark as last update", false)
163
+ .option("--head-status-info <json>", "Head status info JSON")
164
+ .option("--links <json>", "Updated links JSON array")
165
+ .action(async (opts) => {
166
+ const client = (0, utils_1.getClient)();
167
+ const headStatusInfo = opts.headStatusInfo ? (0, utils_1.parseJsonOption)(opts.headStatusInfo) : undefined;
168
+ const links = opts.links ? (0, utils_1.parseJsonOption)(opts.links) : undefined;
169
+ const result = await client.updateDynamicCard(opts.msgId, {
170
+ is_last_update: opts.isLastUpdate,
171
+ head_status_info: headStatusInfo,
172
+ links,
173
+ });
174
+ (0, utils_1.checkError)(result);
175
+ (0, utils_1.outputResult)(result);
176
+ });
177
+ cmd
178
+ .command("revoke")
179
+ .description("Revoke messages by IDs")
180
+ .requiredOption("--message-ids <ids>", "Comma-separated message IDs to revoke")
181
+ .action(async (opts) => {
182
+ const client = (0, utils_1.getClient)();
183
+ const messageIds = (0, utils_1.commaList)(opts.messageIds);
184
+ const result = await client.revokeMessage(messageIds);
185
+ (0, utils_1.checkError)(result);
186
+ (0, utils_1.outputResult)(result);
187
+ });
188
+ cmd
189
+ .command("send-account-message")
190
+ .description("Send a public account message")
191
+ .requiredOption("--msg-type <msgType>", "Message type")
192
+ .requiredOption("--msg-data <json>", "Message data JSON")
193
+ .requiredOption("--chat-ids <ids>", "Comma-separated chat IDs")
194
+ .option("--dept-ids <ids>", "Comma-separated department IDs")
195
+ .option("--account-id <id>", "Account ID")
196
+ .option("--user-token <token>", "User token")
197
+ .action(async (opts) => {
198
+ const client = (0, utils_1.getClient)();
199
+ const msgData = (0, utils_1.parseJsonOption)(opts.msgData);
200
+ const chatIds = (0, utils_1.commaList)(opts.chatIds);
201
+ const deptIds = opts.deptIds ? (0, utils_1.commaList)(opts.deptIds) : undefined;
202
+ const result = await client.sendAccountMessage(opts.msgType, msgData, chatIds, deptIds, {
203
+ account_id: opts.accountId || undefined,
204
+ user_token: opts.userToken || undefined,
205
+ });
206
+ (0, utils_1.checkError)(result);
207
+ (0, utils_1.outputResult)(result);
208
+ });
209
+ cmd
210
+ .command("send-user-message")
211
+ .description("Send a user-to-user private message")
212
+ .requiredOption("--receiver-id <receiverId>", "Receiver staff ID")
213
+ .requiredOption("--msg-type <msgType>", "Message type")
214
+ .requiredOption("--msg-data <json>", "Message data JSON")
215
+ .option("--user-token <token>", "User token")
216
+ .action(async (opts) => {
217
+ const client = (0, utils_1.getClient)();
218
+ const msgData = (0, utils_1.parseJsonOption)(opts.msgData);
219
+ const result = await client.sendUserMessage(opts.receiverId, opts.msgType, msgData, {
220
+ user_token: opts.userToken || undefined,
221
+ });
222
+ (0, utils_1.checkError)(result);
223
+ (0, utils_1.outputResult)(result);
224
+ });
225
+ cmd
226
+ .command("send-group-message")
227
+ .description("Send a group message")
228
+ .requiredOption("--group-id <groupId>", "Group ID")
229
+ .requiredOption("--msg-type <msgType>", "Message type")
230
+ .requiredOption("--msg-data <json>", "Message data JSON")
231
+ .option("--user-token <token>", "User token")
232
+ .action(async (opts) => {
233
+ const client = (0, utils_1.getClient)();
234
+ const msgData = (0, utils_1.parseJsonOption)(opts.msgData);
235
+ const result = await client.sendGroupMessage(opts.groupId, opts.msgType, msgData, {
236
+ user_token: opts.userToken || undefined,
237
+ });
238
+ (0, utils_1.checkError)(result);
239
+ (0, utils_1.outputResult)(result);
240
+ });
241
+ cmd
242
+ .command("send-reminder")
243
+ .description("Send a reminder for a message")
244
+ .requiredOption("--msg-id <msgId>", "Message ID")
245
+ .requiredOption("--reminder-types <types>", "Comma-separated reminder types (0=none,1=popup,2=sms,3=phone)")
246
+ .requiredOption("--user-ids <ids>", "Comma-separated user IDs to remind")
247
+ .action(async (opts) => {
248
+ const client = (0, utils_1.getClient)();
249
+ const reminderTypes = (0, utils_1.commaList)(opts.reminderTypes).map(Number);
250
+ const userIdList = (0, utils_1.commaList)(opts.userIds);
251
+ const result = await client.sendReminderMsg(opts.msgId, reminderTypes, userIdList);
252
+ (0, utils_1.checkError)(result);
253
+ (0, utils_1.outputResult)(result);
254
+ });
255
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerOauthCommands(program: Command): void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerOauthCommands = registerOauthCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerOauthCommands(program) {
6
+ const cmd = program.command("oauth").description("OAuth2 user authorization operations");
7
+ cmd
8
+ .command("authorize-url")
9
+ .description("Build an OAuth2 authorize URL")
10
+ .requiredOption("--redirect-uri <uri>", "Redirect URI")
11
+ .option("--scope <scope>", "OAuth2 scope")
12
+ .option("--state <state>", "State parameter for CSRF protection")
13
+ .action(async (opts) => {
14
+ const client = (0, utils_1.getClient)();
15
+ const url = client.buildAuthorizeUrl(opts.redirectUri, {
16
+ scope: opts.scope || undefined,
17
+ state: opts.state || undefined,
18
+ });
19
+ (0, utils_1.outputResult)({ authorize_url: url });
20
+ });
21
+ cmd
22
+ .command("exchange-code")
23
+ .description("Exchange an authorization code for a user token")
24
+ .requiredOption("--code <code>", "Authorization code")
25
+ .option("--redirect-uri <uri>", "Redirect URI (must match authorize call)")
26
+ .action(async (opts) => {
27
+ const client = (0, utils_1.getClient)();
28
+ const result = await client.exchangeCode(opts.code, {
29
+ redirect_uri: opts.redirectUri || undefined,
30
+ });
31
+ (0, utils_1.checkError)(result);
32
+ if (result.success && result.user_token) {
33
+ const store = (0, utils_1.getStore)();
34
+ store.saveUserToken(result.user_token, result.refresh_token || "", result.expires_in || 0);
35
+ }
36
+ (0, utils_1.outputResult)(result);
37
+ });
38
+ cmd
39
+ .command("refresh-token")
40
+ .description("Refresh a user token")
41
+ .requiredOption("--refresh-token <token>", "Refresh token")
42
+ .action(async (opts) => {
43
+ const client = (0, utils_1.getClient)();
44
+ const result = await client.refreshUserToken(opts.refreshToken);
45
+ (0, utils_1.checkError)(result);
46
+ if (result.success && result.user_token) {
47
+ const store = (0, utils_1.getStore)();
48
+ store.saveUserToken(result.user_token, result.refresh_token || "", result.expires_in || 0);
49
+ }
50
+ (0, utils_1.outputResult)(result);
51
+ });
52
+ cmd
53
+ .command("user-info")
54
+ .description("Fetch user info using a user token")
55
+ .requiredOption("--user-token <token>", "User token")
56
+ .action(async (opts) => {
57
+ const client = (0, utils_1.getClient)();
58
+ const result = await client.fetchUserInfoByToken(opts.userToken);
59
+ (0, utils_1.checkError)(result);
60
+ (0, utils_1.outputResult)(result);
61
+ });
62
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerStaffCommands(program: Command): void;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerStaffCommands = registerStaffCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerStaffCommands(program) {
6
+ const cmd = program.command("staff").description("Query staff/employee information");
7
+ cmd
8
+ .command("basic-info")
9
+ .description("Fetch basic staff info")
10
+ .requiredOption("--staff-id <staffId>", "Staff ID")
11
+ .option("--user-token <token>", "User token")
12
+ .action(async (opts) => {
13
+ const client = (0, utils_1.getClient)();
14
+ const result = await client.fetchStaffBasicInfo(opts.staffId, { user_token: opts.userToken || undefined });
15
+ (0, utils_1.checkError)(result);
16
+ (0, utils_1.outputResult)(result);
17
+ });
18
+ cmd
19
+ .command("detail")
20
+ .description("Fetch detailed staff info")
21
+ .requiredOption("--staff-id <staffId>", "Staff ID")
22
+ .option("--user-token <token>", "User token")
23
+ .action(async (opts) => {
24
+ const client = (0, utils_1.getClient)();
25
+ const result = await client.fetchStaffDetail(opts.staffId, { user_token: opts.userToken || undefined });
26
+ (0, utils_1.checkError)(result);
27
+ (0, utils_1.outputResult)(result);
28
+ });
29
+ cmd
30
+ .command("ancestors")
31
+ .description("Fetch department ancestors for a staff member")
32
+ .requiredOption("--staff-id <staffId>", "Staff ID")
33
+ .option("--user-token <token>", "User token")
34
+ .action(async (opts) => {
35
+ const client = (0, utils_1.getClient)();
36
+ const result = await client.fetchDepartmentAncestors(opts.staffId, { user_token: opts.userToken || undefined });
37
+ (0, utils_1.checkError)(result);
38
+ (0, utils_1.outputResult)(result);
39
+ });
40
+ cmd
41
+ .command("id-mapping")
42
+ .description("Map an ID (phone/email/etc.) to a staff ID")
43
+ .requiredOption("--org-id <orgId>", "Organization ID")
44
+ .requiredOption("--id-type <idType>", "ID type (e.g. mobile_phone, email)")
45
+ .requiredOption("--id-value <idValue>", "ID value to look up")
46
+ .option("--user-token <token>", "User token")
47
+ .action(async (opts) => {
48
+ const client = (0, utils_1.getClient)();
49
+ const result = await client.fetchStaffIdMapping(opts.orgId, opts.idType, opts.idValue, { user_token: opts.userToken || undefined });
50
+ (0, utils_1.checkError)(result);
51
+ (0, utils_1.outputResult)(result);
52
+ });
53
+ cmd
54
+ .command("search")
55
+ .description("Search staff by keyword")
56
+ .requiredOption("--keyword <keyword>", "Search keyword")
57
+ .option("--user-token <token>", "User token")
58
+ .action(async (opts) => {
59
+ const client = (0, utils_1.getClient)();
60
+ const result = await client.searchStaff(opts.keyword, { user_token: opts.userToken || undefined });
61
+ (0, utils_1.checkError)(result);
62
+ (0, utils_1.outputResult)(result);
63
+ });
64
+ cmd
65
+ .command("org-info")
66
+ .description("Fetch organization info")
67
+ .requiredOption("--org-id <orgId>", "Organization ID")
68
+ .option("--user-token <token>", "User token")
69
+ .action(async (opts) => {
70
+ const client = (0, utils_1.getClient)();
71
+ const result = await client.fetchOrgInfo(opts.orgId, { user_token: opts.userToken || undefined });
72
+ (0, utils_1.checkError)(result);
73
+ (0, utils_1.outputResult)(result);
74
+ });
75
+ cmd
76
+ .command("org-extra-fields")
77
+ .description("Fetch organization extra field IDs")
78
+ .requiredOption("--org-id <orgId>", "Organization ID")
79
+ .option("--user-token <token>", "User token")
80
+ .action(async (opts) => {
81
+ const client = (0, utils_1.getClient)();
82
+ const result = await client.fetchOrgExtraFieldIds(opts.orgId, { user_token: opts.userToken || undefined });
83
+ (0, utils_1.checkError)(result);
84
+ (0, utils_1.outputResult)(result);
85
+ });
86
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerStreamingCommands(program: Command): void;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerStreamingCommands = registerStreamingCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerStreamingCommands(program) {
6
+ const cmd = program.command("streaming").description("Manage stream messages (AI Agent real-time push)");
7
+ cmd
8
+ .command("create")
9
+ .description("Create a stream message session")
10
+ .requiredOption("--receiver-id <receiverId>", "Receiver ID")
11
+ .requiredOption("--receiver-type <receiverType>", "Receiver type (e.g. staff, group)")
12
+ .requiredOption("--stream-id <streamId>", "Stream session ID")
13
+ .action(async (opts) => {
14
+ const client = (0, utils_1.getClient)();
15
+ const result = await client.createStreamMessage(opts.receiverId, opts.receiverType, opts.streamId);
16
+ (0, utils_1.checkError)(result);
17
+ (0, utils_1.outputResult)(result);
18
+ });
19
+ cmd
20
+ .command("fetch")
21
+ .description("Fetch stream message status")
22
+ .requiredOption("--msg-id <msgId>", "Stream message ID")
23
+ .action(async (opts) => {
24
+ const client = (0, utils_1.getClient)();
25
+ const result = await client.fetchStreamMessage(opts.msgId);
26
+ (0, utils_1.checkError)(result);
27
+ (0, utils_1.outputResult)(result);
28
+ });
29
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerTodoCommands(program: Command): void;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerTodoCommands = registerTodoCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerTodoCommands(program) {
6
+ const cmd = program.command("todo").description("Manage todo tasks");
7
+ cmd
8
+ .command("create")
9
+ .description("Create a todo task")
10
+ .requiredOption("--title <title>", "Task title")
11
+ .requiredOption("--link <link>", "Task link URL")
12
+ .requiredOption("--pc-link <pcLink>", "Task PC link URL")
13
+ .requiredOption("--executor-ids <ids>", "Comma-separated executor staff IDs")
14
+ .requiredOption("--org-id <orgId>", "Organization ID")
15
+ .option("--type <type>", "Task type (1=notification, 2=approval)", "1")
16
+ .action(async (opts) => {
17
+ const client = (0, utils_1.getClient)();
18
+ const executorIds = (0, utils_1.commaList)(opts.executorIds);
19
+ const result = await client.createTodoTask(opts.title, opts.link, opts.pcLink, executorIds, opts.orgId, parseInt(opts.type));
20
+ (0, utils_1.checkError)(result);
21
+ (0, utils_1.outputResult)(result);
22
+ });
23
+ cmd
24
+ .command("update")
25
+ .description("Update a todo task")
26
+ .requiredOption("--task-id <taskId>", "Todo task ID")
27
+ .requiredOption("--title <title>", "New title")
28
+ .requiredOption("--link <link>", "New link URL")
29
+ .requiredOption("--pc-link <pcLink>", "New PC link URL")
30
+ .requiredOption("--org-id <orgId>", "Organization ID")
31
+ .action(async (opts) => {
32
+ const client = (0, utils_1.getClient)();
33
+ const result = await client.updateTodoTask(opts.taskId, opts.title, opts.link, opts.pcLink, opts.orgId);
34
+ (0, utils_1.checkError)(result);
35
+ (0, utils_1.outputResult)(result);
36
+ });
37
+ cmd
38
+ .command("update-status")
39
+ .description("Update todo task status")
40
+ .requiredOption("--task-id <taskId>", "Todo task ID")
41
+ .requiredOption("--status <status>", "New status (11=pending_read,12=read,21=pending_do,22=done)")
42
+ .requiredOption("--org-id <orgId>", "Organization ID")
43
+ .action(async (opts) => {
44
+ const client = (0, utils_1.getClient)();
45
+ const result = await client.updateTodoTaskStatus(opts.taskId, opts.status, opts.orgId);
46
+ (0, utils_1.checkError)(result);
47
+ (0, utils_1.outputResult)(result);
48
+ });
49
+ cmd
50
+ .command("delete")
51
+ .description("Delete a todo task")
52
+ .requiredOption("--task-id <taskId>", "Todo task ID")
53
+ .requiredOption("--org-id <orgId>", "Organization ID")
54
+ .action(async (opts) => {
55
+ const client = (0, utils_1.getClient)();
56
+ const result = await client.deleteTodoTask(opts.taskId, opts.orgId);
57
+ (0, utils_1.checkError)(result);
58
+ (0, utils_1.outputResult)(result);
59
+ });
60
+ cmd
61
+ .command("list")
62
+ .description("List todo tasks for an organization")
63
+ .requiredOption("--org-id <orgId>", "Organization ID")
64
+ .option("--user-token <token>", "User token")
65
+ .action(async (opts) => {
66
+ const client = (0, utils_1.getClient)();
67
+ const result = await client.fetchTodoTaskList(opts.orgId, { user_token: opts.userToken || undefined });
68
+ (0, utils_1.checkError)(result);
69
+ (0, utils_1.outputResult)(result);
70
+ });
71
+ cmd
72
+ .command("fetch-by-id")
73
+ .description("Fetch a todo task by ID")
74
+ .requiredOption("--task-id <taskId>", "Todo task ID")
75
+ .requiredOption("--org-id <orgId>", "Organization ID")
76
+ .option("--user-token <token>", "User token")
77
+ .action(async (opts) => {
78
+ const client = (0, utils_1.getClient)();
79
+ const result = await client.fetchTodoTaskById(opts.taskId, opts.orgId, { user_token: opts.userToken || undefined });
80
+ (0, utils_1.checkError)(result);
81
+ (0, utils_1.outputResult)(result);
82
+ });
83
+ cmd
84
+ .command("fetch-by-source")
85
+ .description("Fetch a todo task by source ID")
86
+ .requiredOption("--source-id <sourceId>", "Source ID")
87
+ .requiredOption("--org-id <orgId>", "Organization ID")
88
+ .option("--user-token <token>", "User token")
89
+ .action(async (opts) => {
90
+ const client = (0, utils_1.getClient)();
91
+ const result = await client.fetchTodoTaskBySourceId(opts.sourceId, opts.orgId, { user_token: opts.userToken || undefined });
92
+ (0, utils_1.checkError)(result);
93
+ (0, utils_1.outputResult)(result);
94
+ });
95
+ cmd
96
+ .command("status-counts")
97
+ .description("Fetch todo task status counts")
98
+ .requiredOption("--staff-id <staffId>", "Staff ID")
99
+ .requiredOption("--org-id <orgId>", "Organization ID")
100
+ .option("--user-token <token>", "User token")
101
+ .action(async (opts) => {
102
+ const client = (0, utils_1.getClient)();
103
+ const result = await client.fetchTodoTaskStatusCounts(opts.staffId, opts.orgId, { user_token: opts.userToken || undefined });
104
+ (0, utils_1.checkError)(result);
105
+ (0, utils_1.outputResult)(result);
106
+ });
107
+ cmd
108
+ .command("add-executors")
109
+ .description("Add executors to a todo task")
110
+ .requiredOption("--executor-ids <ids>", "Comma-separated executor staff IDs")
111
+ .requiredOption("--org-id <orgId>", "Organization ID")
112
+ .option("--todotask-id <taskId>", "Todo task ID")
113
+ .option("--user-token <token>", "User token")
114
+ .action(async (opts) => {
115
+ const client = (0, utils_1.getClient)();
116
+ const executorIds = (0, utils_1.commaList)(opts.executorIds);
117
+ const result = await client.addExecutors(executorIds, opts.orgId, {
118
+ todotask_id: opts.todotaskId || undefined,
119
+ user_token: opts.userToken || undefined,
120
+ });
121
+ (0, utils_1.checkError)(result);
122
+ (0, utils_1.outputResult)(result);
123
+ });
124
+ cmd
125
+ .command("delete-executors")
126
+ .description("Remove executors from a todo task")
127
+ .requiredOption("--executor-ids <ids>", "Comma-separated executor staff IDs")
128
+ .requiredOption("--org-id <orgId>", "Organization ID")
129
+ .option("--todotask-id <taskId>", "Todo task ID")
130
+ .option("--user-token <token>", "User token")
131
+ .action(async (opts) => {
132
+ const client = (0, utils_1.getClient)();
133
+ const executorIds = (0, utils_1.commaList)(opts.executorIds);
134
+ const result = await client.deleteExecutors(executorIds, opts.orgId, {
135
+ todotask_id: opts.todotaskId || undefined,
136
+ user_token: opts.userToken || undefined,
137
+ });
138
+ (0, utils_1.checkError)(result);
139
+ (0, utils_1.outputResult)(result);
140
+ });
141
+ cmd
142
+ .command("executor-list")
143
+ .description("List executors of a todo task")
144
+ .requiredOption("--task-id <taskId>", "Todo task ID")
145
+ .requiredOption("--org-id <orgId>", "Organization ID")
146
+ .option("--user-token <token>", "User token")
147
+ .action(async (opts) => {
148
+ const client = (0, utils_1.getClient)();
149
+ const result = await client.fetchExecutorList(opts.taskId, opts.orgId, { user_token: opts.userToken || undefined });
150
+ (0, utils_1.checkError)(result);
151
+ (0, utils_1.outputResult)(result);
152
+ });
153
+ }
package/dist/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/main.js ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const commander_1 = require("commander");
5
+ const utils_1 = require("./utils");
6
+ const config_1 = require("./commands/config");
7
+ const message_1 = require("./commands/message");
8
+ const staff_1 = require("./commands/staff");
9
+ const department_1 = require("./commands/department");
10
+ const group_1 = require("./commands/group");
11
+ const calendar_1 = require("./commands/calendar");
12
+ const todo_1 = require("./commands/todo");
13
+ const oauth_1 = require("./commands/oauth");
14
+ const callback_1 = require("./commands/callback");
15
+ const media_1 = require("./commands/media");
16
+ const streaming_1 = require("./commands/streaming");
17
+ const chat_1 = require("./commands/chat");
18
+ const health_1 = require("./commands/health");
19
+ const program = new commander_1.Command();
20
+ program
21
+ .name("lansenger-ts")
22
+ .description("CLI for Lansenger (蓝信) — send messages, manage groups, staff, departments, calendars, todos, and more")
23
+ .version("1.0.0")
24
+ .option("-j, --json", "Output as JSON", false)
25
+ .option("-P, --profile <profile>", "Credential profile", "default")
26
+ .hook("preAction", () => {
27
+ const opts = program.opts();
28
+ if (opts.json)
29
+ (0, utils_1.setJsonOutput)(true);
30
+ if (opts.profile)
31
+ (0, utils_1.setActiveProfile)(opts.profile);
32
+ });
33
+ (0, config_1.registerConfigCommands)(program);
34
+ (0, message_1.registerMessageCommands)(program);
35
+ (0, staff_1.registerStaffCommands)(program);
36
+ (0, department_1.registerDepartmentCommands)(program);
37
+ (0, group_1.registerGroupCommands)(program);
38
+ (0, calendar_1.registerCalendarCommands)(program);
39
+ (0, todo_1.registerTodoCommands)(program);
40
+ (0, oauth_1.registerOauthCommands)(program);
41
+ (0, callback_1.registerCallbackCommands)(program);
42
+ (0, media_1.registerMediaCommands)(program);
43
+ (0, streaming_1.registerStreamingCommands)(program);
44
+ (0, chat_1.registerChatCommands)(program);
45
+ (0, health_1.registerHealthCommands)(program);
46
+ program.parse();