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,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerCalendarCommands(program: Command): void;
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerCalendarCommands = registerCalendarCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerCalendarCommands(program) {
6
+ const cmd = program.command("calendar").description("Manage calendars and schedules");
7
+ cmd
8
+ .command("primary")
9
+ .description("Fetch primary calendar")
10
+ .option("--user-token <token>", "User token")
11
+ .action(async (opts) => {
12
+ const client = (0, utils_1.getClient)();
13
+ const result = await client.fetchPrimaryCalendar({ user_token: opts.userToken || undefined });
14
+ (0, utils_1.checkError)(result);
15
+ (0, utils_1.outputResult)(result);
16
+ });
17
+ cmd
18
+ .command("create-schedule")
19
+ .description("Create a schedule/event")
20
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
21
+ .requiredOption("--summary <summary>", "Schedule summary/title")
22
+ .requiredOption("--start-time <json>", "Start time JSON")
23
+ .requiredOption("--end-time <json>", "End time JSON")
24
+ .requiredOption("--attendees <json>", "Attendees JSON array")
25
+ .option("--user-token <token>", "User token")
26
+ .action(async (opts) => {
27
+ const client = (0, utils_1.getClient)();
28
+ const startTime = (0, utils_1.parseJsonOption)(opts.startTime);
29
+ const endTime = (0, utils_1.parseJsonOption)(opts.endTime);
30
+ const attendees = (0, utils_1.parseJsonOption)(opts.attendees);
31
+ const result = await client.createSchedule(opts.calendarId, opts.summary, startTime, endTime, attendees, {
32
+ user_token: opts.userToken || undefined,
33
+ });
34
+ (0, utils_1.checkError)(result);
35
+ (0, utils_1.outputResult)(result);
36
+ });
37
+ cmd
38
+ .command("fetch-schedule")
39
+ .description("Fetch a schedule by ID")
40
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
41
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
42
+ .option("--user-token <token>", "User token")
43
+ .action(async (opts) => {
44
+ const client = (0, utils_1.getClient)();
45
+ const result = await client.fetchSchedule(opts.calendarId, opts.scheduleId, { user_token: opts.userToken || undefined });
46
+ (0, utils_1.checkError)(result);
47
+ (0, utils_1.outputResult)(result);
48
+ });
49
+ cmd
50
+ .command("delete-schedule")
51
+ .description("Delete a schedule")
52
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
53
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
54
+ .option("--user-token <token>", "User token")
55
+ .action(async (opts) => {
56
+ const client = (0, utils_1.getClient)();
57
+ const result = await client.deleteSchedule(opts.calendarId, opts.scheduleId, { user_token: opts.userToken || undefined });
58
+ (0, utils_1.checkError)(result);
59
+ (0, utils_1.outputResult)(result);
60
+ });
61
+ cmd
62
+ .command("list-schedules")
63
+ .description("List schedules in a time range")
64
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
65
+ .requiredOption("--start-ts <startTs>", "Start timestamp (seconds)")
66
+ .requiredOption("--end-ts <endTs>", "End timestamp (seconds)")
67
+ .option("--user-token <token>", "User token")
68
+ .action(async (opts) => {
69
+ const client = (0, utils_1.getClient)();
70
+ const result = await client.fetchScheduleList(opts.calendarId, parseInt(opts.startTs), parseInt(opts.endTs), {
71
+ user_token: opts.userToken || undefined,
72
+ });
73
+ (0, utils_1.checkError)(result);
74
+ (0, utils_1.outputResult)(result);
75
+ });
76
+ cmd
77
+ .command("attendees")
78
+ .description("Fetch schedule attendees")
79
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
80
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
81
+ .option("--user-token <token>", "User token")
82
+ .action(async (opts) => {
83
+ const client = (0, utils_1.getClient)();
84
+ const result = await client.fetchScheduleAttendees(opts.calendarId, opts.scheduleId, { user_token: opts.userToken || undefined });
85
+ (0, utils_1.checkError)(result);
86
+ (0, utils_1.outputResult)(result);
87
+ });
88
+ cmd
89
+ .command("add-attendees")
90
+ .description("Add attendees to a schedule")
91
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
92
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
93
+ .requiredOption("--attendees <ids>", "Comma-separated attendee staff IDs")
94
+ .option("--user-token <token>", "User token")
95
+ .action(async (opts) => {
96
+ const client = (0, utils_1.getClient)();
97
+ const attendees = (0, utils_1.commaList)(opts.attendees);
98
+ const result = await client.addScheduleAttendees(opts.calendarId, opts.scheduleId, attendees, {
99
+ user_token: opts.userToken || undefined,
100
+ });
101
+ (0, utils_1.checkError)(result);
102
+ (0, utils_1.outputResult)(result);
103
+ });
104
+ cmd
105
+ .command("delete-attendees")
106
+ .description("Remove attendees from a schedule")
107
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
108
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
109
+ .requiredOption("--attendees <ids>", "Comma-separated attendee staff IDs")
110
+ .option("--user-token <token>", "User token")
111
+ .action(async (opts) => {
112
+ const client = (0, utils_1.getClient)();
113
+ const attendees = (0, utils_1.commaList)(opts.attendees);
114
+ const result = await client.deleteScheduleAttendees(opts.calendarId, opts.scheduleId, attendees, {
115
+ user_token: opts.userToken || undefined,
116
+ });
117
+ (0, utils_1.checkError)(result);
118
+ (0, utils_1.outputResult)(result);
119
+ });
120
+ cmd
121
+ .command("update-schedule")
122
+ .description("Update a schedule")
123
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
124
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
125
+ .option("--summary <summary>", "New summary/title")
126
+ .option("--user-token <token>", "User token")
127
+ .action(async (opts) => {
128
+ const client = (0, utils_1.getClient)();
129
+ const result = await client.updateSchedule(opts.calendarId, opts.scheduleId, {
130
+ summary: opts.summary || undefined,
131
+ user_token: opts.userToken || undefined,
132
+ });
133
+ (0, utils_1.checkError)(result);
134
+ (0, utils_1.outputResult)(result);
135
+ });
136
+ cmd
137
+ .command("attendee-meta")
138
+ .description("Update attendee metadata (rsvp, busy/free, reminders)")
139
+ .requiredOption("--calendar-id <calendarId>", "Calendar ID")
140
+ .requiredOption("--schedule-id <scheduleId>", "Schedule ID")
141
+ .option("--rsvp-status <status>", "RSVP status")
142
+ .option("--busy-free-state <state>", "Busy/free state")
143
+ .option("--remind-times <times>", "Comma-separated reminder times (seconds before event)")
144
+ .option("--user-token <token>", "User token")
145
+ .action(async (opts) => {
146
+ const client = (0, utils_1.getClient)();
147
+ const remindTimes = opts.remindTimes ? (0, utils_1.commaList)(opts.remindTimes).map(Number) : undefined;
148
+ const result = await client.updateScheduleAttendeeMeta(opts.calendarId, opts.scheduleId, {
149
+ rsvp_status: opts.rsvpStatus || undefined,
150
+ busy_free_state: opts.busyFreeState || undefined,
151
+ remind_times: remindTimes,
152
+ user_token: opts.userToken || undefined,
153
+ });
154
+ (0, utils_1.checkError)(result);
155
+ (0, utils_1.outputResult)(result);
156
+ });
157
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerCallbackCommands(program: Command): void;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerCallbackCommands = registerCallbackCommands;
4
+ const utils_1 = require("../utils");
5
+ const lansenger_sdk_ts_1 = require("lansenger-sdk-ts");
6
+ function registerCallbackCommands(program) {
7
+ const cmd = program.command("callback").description("Parse and verify callback/webhook payloads");
8
+ cmd
9
+ .command("parse-payload")
10
+ .description("Parse an encrypted callback payload")
11
+ .requiredOption("--data <data>", "Encrypted callback data")
12
+ .option("--encoding-key <key>", "Encoding AES key")
13
+ .option("--verify-signature", "Verify signature before parsing", false)
14
+ .option("--timestamp <ts>", "Timestamp for signature verification")
15
+ .option("--nonce <nonce>", "Nonce for signature verification")
16
+ .option("--signature <sig>", "Signature for verification")
17
+ .option("--callback-token <token>", "Callback token for verification")
18
+ .action(async (opts) => {
19
+ const events = lansenger_sdk_ts_1.LansengerClient.parseCallbackPayload(opts.data, {
20
+ encoding_key: opts.encodingKey || "",
21
+ verify_signature: opts.verifySignature,
22
+ timestamp: opts.timestamp || "",
23
+ nonce: opts.nonce || "",
24
+ signature: opts.signature || "",
25
+ callback_token: opts.callbackToken || "",
26
+ });
27
+ (0, utils_1.outputResult)(events);
28
+ });
29
+ cmd
30
+ .command("verify-signature")
31
+ .description("Verify callback signature")
32
+ .requiredOption("--timestamp <ts>", "Timestamp")
33
+ .requiredOption("--nonce <nonce>", "Nonce")
34
+ .requiredOption("--signature <sig>", "Signature")
35
+ .requiredOption("--encoding-key <key>", "Encoding AES key")
36
+ .option("--data-encrypt <data>", "Encrypted data for verification")
37
+ .option("--callback-token <token>", "Callback token")
38
+ .action(async (opts) => {
39
+ const valid = lansenger_sdk_ts_1.LansengerClient.verifyCallbackSignature(opts.timestamp, opts.nonce, opts.signature, opts.encodingKey, {
40
+ data_encrypt: opts.dataEncrypt || "",
41
+ callback_token: opts.callbackToken || "",
42
+ });
43
+ (0, utils_1.outputResult)({ valid });
44
+ });
45
+ cmd
46
+ .command("event-types")
47
+ .description("List all callback event types")
48
+ .action(async () => {
49
+ const types = lansenger_sdk_ts_1.LansengerClient.getCallbackEventTypes();
50
+ (0, utils_1.outputResult)(types);
51
+ });
52
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerChatCommands(program: Command): void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerChatCommands = registerChatCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerChatCommands(program) {
6
+ const cmd = program.command("chat").description("View chat list and message history");
7
+ cmd
8
+ .command("list")
9
+ .description("Fetch chat list (private + group chats)")
10
+ .option("--user-token <token>", "User token")
11
+ .action(async (opts) => {
12
+ const client = (0, utils_1.getClient)();
13
+ const result = await client.fetchChatList({ user_token: opts.userToken || undefined });
14
+ (0, utils_1.checkError)(result);
15
+ (0, utils_1.outputResult)(result);
16
+ });
17
+ cmd
18
+ .command("messages")
19
+ .description("Fetch chat messages")
20
+ .option("--staff-id <staffId>", "Staff ID for private chat messages")
21
+ .option("--group-id <groupId>", "Group ID for group chat messages")
22
+ .option("--user-token <token>", "User token")
23
+ .action(async (opts) => {
24
+ const client = (0, utils_1.getClient)();
25
+ const result = await client.fetchChatMessages({
26
+ staff_id: opts.staffId || undefined,
27
+ group_id: opts.groupId || undefined,
28
+ user_token: opts.userToken || undefined,
29
+ });
30
+ (0, utils_1.checkError)(result);
31
+ (0, utils_1.outputResult)(result);
32
+ });
33
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerConfigCommands(program: Command): void;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerConfigCommands = registerConfigCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerConfigCommands(program) {
6
+ const cmd = program.command("config").description("Manage CLI configuration and credentials");
7
+ cmd
8
+ .command("set")
9
+ .description("Set credentials (app_id, app_secret, api_gateway_url, passport_url, encoding_key, callback_token)")
10
+ .requiredOption("--app-id <appId>", "App ID")
11
+ .requiredOption("--app-secret <appSecret>", "App Secret")
12
+ .option("--api-gateway-url <url>", "API Gateway URL")
13
+ .option("--passport-url <url>", "Passport URL")
14
+ .option("--encoding-key <key>", "Encoding AES key")
15
+ .option("--callback-token <token>", "Callback verification token")
16
+ .action(async (opts) => {
17
+ const store = (0, utils_1.getStore)();
18
+ store.saveCredentials(opts.appId, opts.appSecret, opts.apiGatewayUrl || "", opts.passportUrl || "", opts.encodingKey || "", opts.callbackToken || "");
19
+ (0, utils_1.outputResult)({ success: true, message: "Credentials saved", profile: store.currentProfile });
20
+ });
21
+ cmd
22
+ .command("show")
23
+ .description("Show current configuration")
24
+ .action(async () => {
25
+ const store = (0, utils_1.getStore)();
26
+ const creds = store.loadCredentials();
27
+ const masked = {
28
+ app_id: creds.app_id,
29
+ app_secret: creds.app_secret ? creds.app_secret.substring(0, 8) + "..." : "",
30
+ api_gateway_url: creds.api_gateway_url,
31
+ passport_url: creds.passport_url,
32
+ encoding_key: creds.encoding_key ? "(set)" : "(not set)",
33
+ callback_token: creds.callback_token ? "(set)" : "(not set)",
34
+ profile: store.currentProfile,
35
+ has_full_config: store.hasFullConfig(),
36
+ };
37
+ (0, utils_1.outputResult)(masked);
38
+ });
39
+ cmd
40
+ .command("clear")
41
+ .description("Clear stored credentials for current profile")
42
+ .action(async () => {
43
+ const store = (0, utils_1.getStore)();
44
+ store.clearProfile();
45
+ (0, utils_1.outputResult)({ success: true, message: "Credentials cleared for profile: " + store.currentProfile });
46
+ });
47
+ cmd
48
+ .command("list-profiles")
49
+ .description("List all stored credential profiles")
50
+ .action(async () => {
51
+ const store = (0, utils_1.getStore)();
52
+ const profiles = store.listProfiles();
53
+ const active = store.getActiveProfile();
54
+ (0, utils_1.outputResult)({ profiles, active_profile: active });
55
+ });
56
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerDepartmentCommands(program: Command): void;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerDepartmentCommands = registerDepartmentCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerDepartmentCommands(program) {
6
+ const cmd = program.command("department").description("Query department/organization structure");
7
+ cmd
8
+ .command("detail")
9
+ .description("Fetch department detail")
10
+ .requiredOption("--dept-id <deptId>", "Department ID")
11
+ .option("--user-token <token>", "User token")
12
+ .action(async (opts) => {
13
+ const client = (0, utils_1.getClient)();
14
+ const result = await client.fetchDepartmentDetail(opts.deptId, { user_token: opts.userToken || undefined });
15
+ (0, utils_1.checkError)(result);
16
+ (0, utils_1.outputResult)(result);
17
+ });
18
+ cmd
19
+ .command("children")
20
+ .description("Fetch child departments")
21
+ .requiredOption("--dept-id <deptId>", "Department ID")
22
+ .option("--user-token <token>", "User token")
23
+ .action(async (opts) => {
24
+ const client = (0, utils_1.getClient)();
25
+ const result = await client.fetchDepartmentChildren(opts.deptId, { user_token: opts.userToken || undefined });
26
+ (0, utils_1.checkError)(result);
27
+ (0, utils_1.outputResult)(result);
28
+ });
29
+ cmd
30
+ .command("staffs")
31
+ .description("Fetch staff members of a department")
32
+ .requiredOption("--dept-id <deptId>", "Department ID")
33
+ .option("--page <page>", "Page number", "1")
34
+ .option("--size <size>", "Page size", "50")
35
+ .option("--user-token <token>", "User token")
36
+ .action(async (opts) => {
37
+ const client = (0, utils_1.getClient)();
38
+ const result = await client.fetchDepartmentStaffs(opts.deptId, {
39
+ page: parseInt(opts.page),
40
+ page_size: parseInt(opts.size),
41
+ user_token: opts.userToken || undefined,
42
+ });
43
+ (0, utils_1.checkError)(result);
44
+ (0, utils_1.outputResult)(result);
45
+ });
46
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerGroupCommands(program: Command): void;
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerGroupCommands = registerGroupCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerGroupCommands(program) {
6
+ const cmd = program.command("group").description("Manage groups");
7
+ cmd
8
+ .command("create")
9
+ .description("Create a new group")
10
+ .requiredOption("--name <name>", "Group name")
11
+ .requiredOption("--org-id <orgId>", "Organization ID")
12
+ .option("--staff-id-list <ids>", "Comma-separated initial member staff IDs")
13
+ .option("--owner-id <ownerId>", "Group owner ID")
14
+ .action(async (opts) => {
15
+ const client = (0, utils_1.getClient)();
16
+ const staffIdList = opts.staffIdList ? (0, utils_1.commaList)(opts.staffIdList) : undefined;
17
+ const result = await client.createGroup(opts.name, opts.orgId, {
18
+ staff_id_list: staffIdList,
19
+ owner_id: opts.ownerId || undefined,
20
+ });
21
+ (0, utils_1.checkError)(result);
22
+ (0, utils_1.outputResult)(result);
23
+ });
24
+ cmd
25
+ .command("info")
26
+ .description("Fetch group info")
27
+ .requiredOption("--group-id <groupId>", "Group ID")
28
+ .option("--user-token <token>", "User token")
29
+ .action(async (opts) => {
30
+ const client = (0, utils_1.getClient)();
31
+ const result = await client.fetchGroupInfo(opts.groupId, { user_token: opts.userToken || undefined });
32
+ (0, utils_1.checkError)(result);
33
+ (0, utils_1.outputResult)(result);
34
+ });
35
+ cmd
36
+ .command("members")
37
+ .description("Fetch group members")
38
+ .requiredOption("--group-id <groupId>", "Group ID")
39
+ .option("--user-token <token>", "User token")
40
+ .action(async (opts) => {
41
+ const client = (0, utils_1.getClient)();
42
+ const result = await client.fetchGroupMembers(opts.groupId, { user_token: opts.userToken || undefined });
43
+ (0, utils_1.checkError)(result);
44
+ (0, utils_1.outputResult)(result);
45
+ });
46
+ cmd
47
+ .command("list")
48
+ .description("List all groups")
49
+ .option("--user-token <token>", "User token")
50
+ .action(async (opts) => {
51
+ const client = (0, utils_1.getClient)();
52
+ const result = await client.fetchGroupList({ user_token: opts.userToken || undefined });
53
+ (0, utils_1.checkError)(result);
54
+ (0, utils_1.outputResult)(result);
55
+ });
56
+ cmd
57
+ .command("check")
58
+ .description("Check if a user is in a group")
59
+ .requiredOption("--group-id <groupId>", "Group ID")
60
+ .option("--staff-id <staffId>", "Staff ID to check")
61
+ .option("--user-token <token>", "User token")
62
+ .action(async (opts) => {
63
+ const client = (0, utils_1.getClient)();
64
+ const result = await client.checkIsInGroup(opts.groupId, {
65
+ staff_id: opts.staffId || undefined,
66
+ user_token: opts.userToken || undefined,
67
+ });
68
+ (0, utils_1.checkError)(result);
69
+ (0, utils_1.outputResult)(result);
70
+ });
71
+ cmd
72
+ .command("update")
73
+ .description("Update group info")
74
+ .requiredOption("--group-id <groupId>", "Group ID")
75
+ .option("--name <name>", "New group name")
76
+ .option("--user-token <token>", "User token")
77
+ .action(async (opts) => {
78
+ const client = (0, utils_1.getClient)();
79
+ const result = await client.updateGroupInfo(opts.groupId, {
80
+ name: opts.name || undefined,
81
+ user_token: opts.userToken || undefined,
82
+ });
83
+ (0, utils_1.checkError)(result);
84
+ (0, utils_1.outputResult)(result);
85
+ });
86
+ cmd
87
+ .command("update-members")
88
+ .description("Add or remove group members")
89
+ .requiredOption("--group-id <groupId>", "Group ID")
90
+ .option("--add <ids>", "Comma-separated staff IDs to add")
91
+ .option("--del <ids>", "Comma-separated staff IDs to remove")
92
+ .option("--user-token <token>", "User token")
93
+ .action(async (opts) => {
94
+ const client = (0, utils_1.getClient)();
95
+ const addUserList = opts.add ? (0, utils_1.commaList)(opts.add) : undefined;
96
+ const delUserList = opts.del ? (0, utils_1.commaList)(opts.del) : undefined;
97
+ const result = await client.updateGroupMembers(opts.groupId, {
98
+ add_user_list: addUserList,
99
+ del_user_list: delUserList,
100
+ user_token: opts.userToken || undefined,
101
+ });
102
+ (0, utils_1.checkError)(result);
103
+ (0, utils_1.outputResult)(result);
104
+ });
105
+ cmd
106
+ .command("dismiss")
107
+ .description("Dismiss/delete a group")
108
+ .requiredOption("--group-id <groupId>", "Group ID")
109
+ .option("--user-token <token>", "User token")
110
+ .action(async (opts) => {
111
+ const client = (0, utils_1.getClient)();
112
+ const result = await client.dismissGroup(opts.groupId, { user_token: opts.userToken || undefined });
113
+ (0, utils_1.checkError)(result);
114
+ (0, utils_1.outputResult)(result);
115
+ });
116
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerHealthCommands(program: Command): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerHealthCommands = registerHealthCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerHealthCommands(program) {
6
+ const cmd = program.command("health").description("Health check for API connectivity");
7
+ cmd
8
+ .command("check")
9
+ .description("Check API connectivity by attempting to get a token")
10
+ .action(async () => {
11
+ const client = (0, utils_1.getClient)();
12
+ try {
13
+ const ok = await client.healthCheck();
14
+ (0, utils_1.outputResult)({ success: ok, status: ok ? "OK" : "FAIL" });
15
+ }
16
+ catch (err) {
17
+ (0, utils_1.outputResult)({ success: false, status: "FAIL", error: err.message || String(err) });
18
+ }
19
+ });
20
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerMediaCommands(program: Command): void;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerMediaCommands = registerMediaCommands;
4
+ const utils_1 = require("../utils");
5
+ function registerMediaCommands(program) {
6
+ const cmd = program.command("media").description("Upload, download, and manage media files");
7
+ cmd
8
+ .command("upload")
9
+ .description("Upload a media file")
10
+ .requiredOption("--file-path <path>", "File path to upload")
11
+ .option("--media-type <type>", "Media type (1=video,2=image,3=file)")
12
+ .action(async (opts) => {
13
+ const client = (0, utils_1.getClient)();
14
+ const result = await client.uploadMediaFile(opts.filePath, {
15
+ media_type: opts.mediaType ? parseInt(opts.mediaType) : undefined,
16
+ });
17
+ (0, utils_1.checkError)(result);
18
+ (0, utils_1.outputResult)(result);
19
+ });
20
+ cmd
21
+ .command("download")
22
+ .description("Download a media file (to stdout as binary)")
23
+ .requiredOption("--media-id <mediaId>", "Media ID")
24
+ .action(async (opts) => {
25
+ const client = (0, utils_1.getClient)();
26
+ const result = await client.downloadMediaFile(opts.mediaId);
27
+ (0, utils_1.checkError)(result);
28
+ if (result.success && result.data) {
29
+ process.stdout.write(result.data);
30
+ }
31
+ else {
32
+ (0, utils_1.outputResult)(result);
33
+ }
34
+ });
35
+ cmd
36
+ .command("download-to-file")
37
+ .description("Download a media file to a local file")
38
+ .requiredOption("--media-id <mediaId>", "Media ID")
39
+ .option("--target-path <path>", "Target file path")
40
+ .action(async (opts) => {
41
+ const client = (0, utils_1.getClient)();
42
+ const savedPath = await client.downloadMediaToFile(opts.mediaId, {
43
+ target_path: opts.targetPath || undefined,
44
+ });
45
+ (0, utils_1.outputResult)({ success: true, path: savedPath });
46
+ });
47
+ cmd
48
+ .command("path")
49
+ .description("Fetch media path info")
50
+ .requiredOption("--media-id <mediaId>", "Media ID")
51
+ .option("--user-token <token>", "User token")
52
+ .action(async (opts) => {
53
+ const client = (0, utils_1.getClient)();
54
+ const result = await client.fetchMediaPathInfo(opts.mediaId, { user_token: opts.userToken || undefined });
55
+ (0, utils_1.checkError)(result);
56
+ (0, utils_1.outputResult)(result);
57
+ });
58
+ }
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare function registerMessageCommands(program: Command): void;