@kyoji2/intercom-cli 0.1.0 → 0.1.4
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/README.md +32 -0
- package/dist/index.js +21575 -20702
- package/package.json +7 -3
- package/src/cli/registry.ts +916 -0
- package/src/client.ts +2 -0
- package/src/commands/admins.ts +2 -2
- package/src/commands/articles.ts +8 -8
- package/src/commands/auth.ts +3 -3
- package/src/commands/companies.ts +6 -6
- package/src/commands/contacts.ts +13 -13
- package/src/commands/conversations.ts +65 -10
- package/src/commands/events.ts +4 -4
- package/src/commands/index.ts +24 -10
- package/src/commands/overview.ts +1 -1
- package/src/commands/tags.ts +6 -6
- package/src/commands/ticketTypes.ts +76 -0
- package/src/commands/tickets.ts +398 -0
- package/src/index.ts +19 -623
- package/src/utils/config.ts +31 -24
- package/src/utils/index.ts +1 -0
- package/src/utils/output.ts +1 -0
|
@@ -0,0 +1,916 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import {
|
|
3
|
+
cmdAdminGet,
|
|
4
|
+
cmdAdminList,
|
|
5
|
+
cmdArticleCreate,
|
|
6
|
+
cmdArticleDelete,
|
|
7
|
+
cmdArticleGet,
|
|
8
|
+
cmdArticleList,
|
|
9
|
+
cmdArticleSearch,
|
|
10
|
+
cmdArticleUpdate,
|
|
11
|
+
cmdCompanyCreate,
|
|
12
|
+
cmdCompanyGet,
|
|
13
|
+
cmdCompanyList,
|
|
14
|
+
cmdCompanyUpdate,
|
|
15
|
+
cmdContactAttachCompany,
|
|
16
|
+
cmdContactCreate,
|
|
17
|
+
cmdContactDelete,
|
|
18
|
+
cmdContactGet,
|
|
19
|
+
cmdContactList,
|
|
20
|
+
cmdContactNote,
|
|
21
|
+
cmdContactNotes,
|
|
22
|
+
cmdContactSearch,
|
|
23
|
+
cmdContactTag,
|
|
24
|
+
cmdContactUntag,
|
|
25
|
+
cmdContactUpdate,
|
|
26
|
+
cmdContext,
|
|
27
|
+
cmdConversationAssign,
|
|
28
|
+
cmdConversationClose,
|
|
29
|
+
cmdConversationConvert,
|
|
30
|
+
cmdConversationGet,
|
|
31
|
+
cmdConversationList,
|
|
32
|
+
cmdConversationOpen,
|
|
33
|
+
cmdConversationReply,
|
|
34
|
+
cmdConversationSearch,
|
|
35
|
+
cmdConversationSnooze,
|
|
36
|
+
cmdEventList,
|
|
37
|
+
cmdEventTrack,
|
|
38
|
+
cmdLogin,
|
|
39
|
+
cmdLogout,
|
|
40
|
+
cmdSchema,
|
|
41
|
+
cmdTagCreate,
|
|
42
|
+
cmdTagDelete,
|
|
43
|
+
cmdTagGet,
|
|
44
|
+
cmdTagList,
|
|
45
|
+
cmdTicketAssign,
|
|
46
|
+
cmdTicketClose,
|
|
47
|
+
cmdTicketCreate,
|
|
48
|
+
cmdTicketDelete,
|
|
49
|
+
cmdTicketGet,
|
|
50
|
+
cmdTicketReply,
|
|
51
|
+
cmdTicketSearch,
|
|
52
|
+
cmdTicketTypeGet,
|
|
53
|
+
cmdTicketTypeList,
|
|
54
|
+
cmdTicketUpdate,
|
|
55
|
+
cmdWhoami,
|
|
56
|
+
} from "../commands/index.ts";
|
|
57
|
+
import type { GlobalOptions } from "../utils/index.ts";
|
|
58
|
+
|
|
59
|
+
type ActionArgs = {
|
|
60
|
+
globals: GlobalOptions;
|
|
61
|
+
args: unknown[];
|
|
62
|
+
options: Record<string, unknown>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type CommandAction = (params: ActionArgs) => Promise<void>;
|
|
66
|
+
|
|
67
|
+
type OptionSpec = {
|
|
68
|
+
flags: string;
|
|
69
|
+
description: string;
|
|
70
|
+
defaultValue?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type ArgSpec = {
|
|
74
|
+
name: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
type CommandSpec = {
|
|
79
|
+
name: string;
|
|
80
|
+
description: string;
|
|
81
|
+
args?: ArgSpec[];
|
|
82
|
+
options?: OptionSpec[];
|
|
83
|
+
requiredOptions?: OptionSpec[];
|
|
84
|
+
action: CommandAction;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
type RegisterContext = {
|
|
88
|
+
getGlobalOptions: (cmd: Command) => GlobalOptions;
|
|
89
|
+
withErrorHandler: <T extends unknown[]>(fn: (...args: T) => Promise<void>) => (...args: T) => Promise<void>;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function applyOption(command: Command, option: OptionSpec, required: boolean): void {
|
|
93
|
+
if (required) {
|
|
94
|
+
if (option.defaultValue !== undefined) {
|
|
95
|
+
command.requiredOption(option.flags, option.description, option.defaultValue);
|
|
96
|
+
} else {
|
|
97
|
+
command.requiredOption(option.flags, option.description);
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (option.defaultValue !== undefined) {
|
|
103
|
+
command.option(option.flags, option.description, option.defaultValue);
|
|
104
|
+
} else {
|
|
105
|
+
command.option(option.flags, option.description);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function registerCommand(parent: Command, spec: CommandSpec, ctx: RegisterContext): void {
|
|
110
|
+
const command = parent.command(spec.name).description(spec.description);
|
|
111
|
+
|
|
112
|
+
spec.args?.forEach((arg) => {
|
|
113
|
+
command.argument(arg.name, arg.description);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
spec.options?.forEach((option) => {
|
|
117
|
+
applyOption(command, option, false);
|
|
118
|
+
});
|
|
119
|
+
spec.requiredOptions?.forEach((option) => {
|
|
120
|
+
applyOption(command, option, true);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
command.action(
|
|
124
|
+
ctx.withErrorHandler(async (...actionArgs: unknown[]) => {
|
|
125
|
+
const cmd = actionArgs.length > 0 ? (actionArgs[actionArgs.length - 1] as Command) : undefined;
|
|
126
|
+
const options = actionArgs.length > 1 ? (actionArgs[actionArgs.length - 2] as Record<string, unknown>) : {};
|
|
127
|
+
const args = actionArgs.length > 2 ? actionArgs.slice(0, -2) : [];
|
|
128
|
+
const globals = ctx.getGlobalOptions(cmd ?? command);
|
|
129
|
+
await spec.action({ globals, args, options });
|
|
130
|
+
}),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function registerGroup(
|
|
135
|
+
program: Command,
|
|
136
|
+
name: string,
|
|
137
|
+
description: string,
|
|
138
|
+
specs: CommandSpec[],
|
|
139
|
+
ctx: RegisterContext,
|
|
140
|
+
) {
|
|
141
|
+
const group = program.command(name).description(description);
|
|
142
|
+
specs.forEach((spec) => {
|
|
143
|
+
registerCommand(group, spec, ctx);
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function registerCommands(program: Command, ctx: RegisterContext): void {
|
|
148
|
+
registerCommand(
|
|
149
|
+
program,
|
|
150
|
+
{
|
|
151
|
+
name: "login",
|
|
152
|
+
description: "Login with your Intercom Access Token",
|
|
153
|
+
args: [{ name: "[token]", description: "Access token (will prompt if not provided)" }],
|
|
154
|
+
action: async ({ globals, args }) => {
|
|
155
|
+
const token = args[0] as string | undefined;
|
|
156
|
+
await cmdLogin({ ...globals, token });
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
ctx,
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
registerCommand(
|
|
163
|
+
program,
|
|
164
|
+
{
|
|
165
|
+
name: "logout",
|
|
166
|
+
description: "Remove stored credentials",
|
|
167
|
+
action: async ({ globals }) => {
|
|
168
|
+
await cmdLogout(globals);
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
ctx,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
registerCommand(
|
|
175
|
+
program,
|
|
176
|
+
{
|
|
177
|
+
name: "whoami",
|
|
178
|
+
description: "Show current admin and workspace info",
|
|
179
|
+
action: async ({ globals }) => {
|
|
180
|
+
await cmdWhoami(globals);
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
ctx,
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
registerCommand(
|
|
187
|
+
program,
|
|
188
|
+
{
|
|
189
|
+
name: "context",
|
|
190
|
+
description: "Show account context (admins, workspace)",
|
|
191
|
+
action: async ({ globals }) => {
|
|
192
|
+
await cmdContext(globals);
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
ctx,
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
registerCommand(
|
|
199
|
+
program,
|
|
200
|
+
{
|
|
201
|
+
name: "schema",
|
|
202
|
+
description: "Dump API schemas and usage examples (for AI context)",
|
|
203
|
+
action: async () => {
|
|
204
|
+
cmdSchema();
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
ctx,
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
registerGroup(
|
|
211
|
+
program,
|
|
212
|
+
"admin",
|
|
213
|
+
"Manage admins",
|
|
214
|
+
[
|
|
215
|
+
{
|
|
216
|
+
name: "list",
|
|
217
|
+
description: "List all admins in workspace",
|
|
218
|
+
action: async ({ globals }) => {
|
|
219
|
+
await cmdAdminList(globals);
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "get",
|
|
224
|
+
description: "Get admin details",
|
|
225
|
+
args: [{ name: "<id>", description: "Admin ID" }],
|
|
226
|
+
action: async ({ globals, args }) => {
|
|
227
|
+
await cmdAdminGet({ ...globals, id: String(args[0]) });
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
ctx,
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
registerGroup(
|
|
235
|
+
program,
|
|
236
|
+
"contact",
|
|
237
|
+
"Manage contacts",
|
|
238
|
+
[
|
|
239
|
+
{
|
|
240
|
+
name: "create",
|
|
241
|
+
description: "Create a new contact",
|
|
242
|
+
options: [
|
|
243
|
+
{ flags: "--email <email>", description: "Contact email" },
|
|
244
|
+
{ flags: "--name <name>", description: "Contact name" },
|
|
245
|
+
{ flags: "--phone <phone>", description: "Contact phone" },
|
|
246
|
+
{ flags: "--user-id <id>", description: "External user ID" },
|
|
247
|
+
{ flags: "--json <json>", description: "Full contact data as JSON" },
|
|
248
|
+
],
|
|
249
|
+
action: async ({ globals, options }) => {
|
|
250
|
+
await cmdContactCreate({
|
|
251
|
+
...globals,
|
|
252
|
+
email: options.email as string | undefined,
|
|
253
|
+
name: options.name as string | undefined,
|
|
254
|
+
phone: options.phone as string | undefined,
|
|
255
|
+
userId: options.userId as string | undefined,
|
|
256
|
+
json: options.json as string | undefined,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: "get",
|
|
262
|
+
description: "Get contact details",
|
|
263
|
+
args: [{ name: "<id>", description: "Contact ID" }],
|
|
264
|
+
action: async ({ globals, args }) => {
|
|
265
|
+
await cmdContactGet({ ...globals, id: String(args[0]) });
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
name: "update",
|
|
270
|
+
description: "Update a contact",
|
|
271
|
+
args: [{ name: "<id>", description: "Contact ID" }],
|
|
272
|
+
options: [
|
|
273
|
+
{ flags: "--name <name>", description: "New name" },
|
|
274
|
+
{ flags: "--email <email>", description: "New email" },
|
|
275
|
+
{ flags: "--phone <phone>", description: "New phone" },
|
|
276
|
+
{ flags: "--json <json>", description: "Update data as JSON" },
|
|
277
|
+
],
|
|
278
|
+
action: async ({ globals, args, options }) => {
|
|
279
|
+
await cmdContactUpdate({
|
|
280
|
+
...globals,
|
|
281
|
+
id: String(args[0]),
|
|
282
|
+
name: options.name as string | undefined,
|
|
283
|
+
email: options.email as string | undefined,
|
|
284
|
+
phone: options.phone as string | undefined,
|
|
285
|
+
json: options.json as string | undefined,
|
|
286
|
+
});
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: "delete",
|
|
291
|
+
description: "Delete a contact",
|
|
292
|
+
args: [{ name: "<id>", description: "Contact ID" }],
|
|
293
|
+
action: async ({ globals, args }) => {
|
|
294
|
+
await cmdContactDelete({ ...globals, id: String(args[0]) });
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "search",
|
|
299
|
+
description: "Search contacts",
|
|
300
|
+
options: [
|
|
301
|
+
{ flags: "--email <email>", description: "Search by email" },
|
|
302
|
+
{ flags: "--json <json>", description: "Search query as JSON" },
|
|
303
|
+
{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" },
|
|
304
|
+
],
|
|
305
|
+
action: async ({ globals, options }) => {
|
|
306
|
+
await cmdContactSearch({
|
|
307
|
+
...globals,
|
|
308
|
+
email: options.email as string | undefined,
|
|
309
|
+
json: options.json as string | undefined,
|
|
310
|
+
limit: options.limit as string | undefined,
|
|
311
|
+
});
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
name: "list",
|
|
316
|
+
description: "List contacts",
|
|
317
|
+
options: [{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" }],
|
|
318
|
+
action: async ({ globals, options }) => {
|
|
319
|
+
await cmdContactList({
|
|
320
|
+
...globals,
|
|
321
|
+
limit: options.limit as string | undefined,
|
|
322
|
+
});
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
name: "note",
|
|
327
|
+
description: "Add a note to contact",
|
|
328
|
+
args: [
|
|
329
|
+
{ name: "<id>", description: "Contact ID" },
|
|
330
|
+
{ name: "<body>", description: "Note body" },
|
|
331
|
+
],
|
|
332
|
+
action: async ({ globals, args }) => {
|
|
333
|
+
await cmdContactNote({ ...globals, id: String(args[0]), body: String(args[1]) });
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: "notes",
|
|
338
|
+
description: "List contact notes",
|
|
339
|
+
args: [{ name: "<id>", description: "Contact ID" }],
|
|
340
|
+
action: async ({ globals, args }) => {
|
|
341
|
+
await cmdContactNotes({ ...globals, id: String(args[0]) });
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: "tag",
|
|
346
|
+
description: "Add tag to contact",
|
|
347
|
+
args: [
|
|
348
|
+
{ name: "<contact-id>", description: "Contact ID" },
|
|
349
|
+
{ name: "<tag-id>", description: "Tag ID" },
|
|
350
|
+
],
|
|
351
|
+
action: async ({ globals, args }) => {
|
|
352
|
+
await cmdContactTag({ ...globals, contactId: String(args[0]), tagId: String(args[1]) });
|
|
353
|
+
},
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
name: "untag",
|
|
357
|
+
description: "Remove tag from contact",
|
|
358
|
+
args: [
|
|
359
|
+
{ name: "<contact-id>", description: "Contact ID" },
|
|
360
|
+
{ name: "<tag-id>", description: "Tag ID" },
|
|
361
|
+
],
|
|
362
|
+
action: async ({ globals, args }) => {
|
|
363
|
+
await cmdContactUntag({ ...globals, contactId: String(args[0]), tagId: String(args[1]) });
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
name: "attach-company",
|
|
368
|
+
description: "Attach contact to company",
|
|
369
|
+
args: [
|
|
370
|
+
{ name: "<contact-id>", description: "Contact ID" },
|
|
371
|
+
{ name: "<company-id>", description: "Company ID" },
|
|
372
|
+
],
|
|
373
|
+
action: async ({ globals, args }) => {
|
|
374
|
+
await cmdContactAttachCompany({
|
|
375
|
+
...globals,
|
|
376
|
+
contactId: String(args[0]),
|
|
377
|
+
companyId: String(args[1]),
|
|
378
|
+
});
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
],
|
|
382
|
+
ctx,
|
|
383
|
+
);
|
|
384
|
+
|
|
385
|
+
registerGroup(
|
|
386
|
+
program,
|
|
387
|
+
"conversation",
|
|
388
|
+
"Manage conversations",
|
|
389
|
+
[
|
|
390
|
+
{
|
|
391
|
+
name: "list",
|
|
392
|
+
description: "List conversations",
|
|
393
|
+
options: [{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" }],
|
|
394
|
+
action: async ({ globals, options }) => {
|
|
395
|
+
await cmdConversationList({ ...globals, limit: options.limit as string | undefined });
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: "get",
|
|
400
|
+
description: "Get conversation details",
|
|
401
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
402
|
+
action: async ({ globals, args }) => {
|
|
403
|
+
await cmdConversationGet({ ...globals, id: String(args[0]) });
|
|
404
|
+
},
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
name: "search",
|
|
408
|
+
description: "Search conversations",
|
|
409
|
+
options: [
|
|
410
|
+
{ flags: "--state <state>", description: "Filter by state (open, closed, snoozed)" },
|
|
411
|
+
{ flags: "--assignee <id>", description: "Filter by assignee admin ID" },
|
|
412
|
+
{ flags: "--json <json>", description: "Search query as JSON" },
|
|
413
|
+
{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" },
|
|
414
|
+
],
|
|
415
|
+
action: async ({ globals, options }) => {
|
|
416
|
+
await cmdConversationSearch({
|
|
417
|
+
...globals,
|
|
418
|
+
state: options.state as string | undefined,
|
|
419
|
+
assignee: options.assignee as string | undefined,
|
|
420
|
+
json: options.json as string | undefined,
|
|
421
|
+
limit: options.limit as string | undefined,
|
|
422
|
+
});
|
|
423
|
+
},
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
name: "reply",
|
|
427
|
+
description: "Reply to a conversation",
|
|
428
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
429
|
+
requiredOptions: [
|
|
430
|
+
{ flags: "--admin <id>", description: "Admin ID sending the reply" },
|
|
431
|
+
{ flags: "--body <body>", description: "Reply message body" },
|
|
432
|
+
],
|
|
433
|
+
options: [{ flags: "--json <json>", description: "Additional reply data as JSON" }],
|
|
434
|
+
action: async ({ globals, args, options }) => {
|
|
435
|
+
await cmdConversationReply({
|
|
436
|
+
...globals,
|
|
437
|
+
id: String(args[0]),
|
|
438
|
+
adminId: options.admin as string,
|
|
439
|
+
body: options.body as string,
|
|
440
|
+
json: options.json as string | undefined,
|
|
441
|
+
});
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
name: "assign",
|
|
446
|
+
description: "Assign conversation to admin/team",
|
|
447
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
448
|
+
requiredOptions: [
|
|
449
|
+
{ flags: "--admin <id>", description: "Admin ID performing assignment" },
|
|
450
|
+
{ flags: "--assignee <id>", description: "Assignee ID (admin or team)" },
|
|
451
|
+
],
|
|
452
|
+
action: async ({ globals, args, options }) => {
|
|
453
|
+
await cmdConversationAssign({
|
|
454
|
+
...globals,
|
|
455
|
+
id: String(args[0]),
|
|
456
|
+
adminId: options.admin as string,
|
|
457
|
+
assigneeId: options.assignee as string,
|
|
458
|
+
});
|
|
459
|
+
},
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
name: "close",
|
|
463
|
+
description: "Close a conversation",
|
|
464
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
465
|
+
requiredOptions: [{ flags: "--admin <id>", description: "Admin ID closing the conversation" }],
|
|
466
|
+
action: async ({ globals, args, options }) => {
|
|
467
|
+
await cmdConversationClose({
|
|
468
|
+
...globals,
|
|
469
|
+
id: String(args[0]),
|
|
470
|
+
adminId: options.admin as string,
|
|
471
|
+
});
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
name: "open",
|
|
476
|
+
description: "Reopen a conversation",
|
|
477
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
478
|
+
requiredOptions: [{ flags: "--admin <id>", description: "Admin ID opening the conversation" }],
|
|
479
|
+
action: async ({ globals, args, options }) => {
|
|
480
|
+
await cmdConversationOpen({
|
|
481
|
+
...globals,
|
|
482
|
+
id: String(args[0]),
|
|
483
|
+
adminId: options.admin as string,
|
|
484
|
+
});
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
name: "snooze",
|
|
489
|
+
description: "Snooze a conversation",
|
|
490
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
491
|
+
requiredOptions: [
|
|
492
|
+
{ flags: "--admin <id>", description: "Admin ID snoozing the conversation" },
|
|
493
|
+
{ flags: "--until <timestamp>", description: "Unix timestamp to snooze until" },
|
|
494
|
+
],
|
|
495
|
+
action: async ({ globals, args, options }) => {
|
|
496
|
+
await cmdConversationSnooze({
|
|
497
|
+
...globals,
|
|
498
|
+
id: String(args[0]),
|
|
499
|
+
adminId: options.admin as string,
|
|
500
|
+
until: options.until as string,
|
|
501
|
+
});
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
name: "convert",
|
|
506
|
+
description: "Convert conversation to a ticket",
|
|
507
|
+
args: [{ name: "<id>", description: "Conversation ID" }],
|
|
508
|
+
requiredOptions: [{ flags: "--type-id <id>", description: "Ticket type ID" }],
|
|
509
|
+
options: [
|
|
510
|
+
{ flags: "--title <title>", description: "Ticket title" },
|
|
511
|
+
{ flags: "--description <desc>", description: "Ticket description" },
|
|
512
|
+
{ flags: "--json <json>", description: "Ticket attributes as JSON" },
|
|
513
|
+
],
|
|
514
|
+
action: async ({ globals, args, options }) => {
|
|
515
|
+
await cmdConversationConvert({
|
|
516
|
+
...globals,
|
|
517
|
+
id: String(args[0]),
|
|
518
|
+
ticketTypeId: options.typeId as string,
|
|
519
|
+
title: options.title as string | undefined,
|
|
520
|
+
description: options.description as string | undefined,
|
|
521
|
+
json: options.json as string | undefined,
|
|
522
|
+
});
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
],
|
|
526
|
+
ctx,
|
|
527
|
+
);
|
|
528
|
+
|
|
529
|
+
registerGroup(
|
|
530
|
+
program,
|
|
531
|
+
"company",
|
|
532
|
+
"Manage companies",
|
|
533
|
+
[
|
|
534
|
+
{
|
|
535
|
+
name: "create",
|
|
536
|
+
description: "Create a company",
|
|
537
|
+
requiredOptions: [
|
|
538
|
+
{ flags: "--company-id <id>", description: "Unique company identifier" },
|
|
539
|
+
{ flags: "--name <name>", description: "Company name" },
|
|
540
|
+
],
|
|
541
|
+
options: [
|
|
542
|
+
{ flags: "--plan <plan>", description: "Company plan" },
|
|
543
|
+
{ flags: "--size <size>", description: "Company size" },
|
|
544
|
+
{ flags: "--website <url>", description: "Company website" },
|
|
545
|
+
{ flags: "--json <json>", description: "Additional company data as JSON" },
|
|
546
|
+
],
|
|
547
|
+
action: async ({ globals, options }) => {
|
|
548
|
+
await cmdCompanyCreate({
|
|
549
|
+
...globals,
|
|
550
|
+
companyId: options.companyId as string,
|
|
551
|
+
name: options.name as string,
|
|
552
|
+
plan: options.plan as string | undefined,
|
|
553
|
+
size: options.size as string | undefined,
|
|
554
|
+
website: options.website as string | undefined,
|
|
555
|
+
json: options.json as string | undefined,
|
|
556
|
+
});
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
name: "get",
|
|
561
|
+
description: "Get company details",
|
|
562
|
+
args: [{ name: "<id>", description: "Company ID" }],
|
|
563
|
+
action: async ({ globals, args }) => {
|
|
564
|
+
await cmdCompanyGet({ ...globals, id: String(args[0]) });
|
|
565
|
+
},
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
name: "list",
|
|
569
|
+
description: "List companies",
|
|
570
|
+
options: [{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" }],
|
|
571
|
+
action: async ({ globals, options }) => {
|
|
572
|
+
await cmdCompanyList({ ...globals, limit: options.limit as string | undefined });
|
|
573
|
+
},
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "update",
|
|
577
|
+
description: "Update a company",
|
|
578
|
+
args: [{ name: "<id>", description: "Company ID" }],
|
|
579
|
+
requiredOptions: [{ flags: "--json <json>", description: "Update data as JSON" }],
|
|
580
|
+
action: async ({ globals, args, options }) => {
|
|
581
|
+
await cmdCompanyUpdate({ ...globals, id: String(args[0]), json: options.json as string });
|
|
582
|
+
},
|
|
583
|
+
},
|
|
584
|
+
],
|
|
585
|
+
ctx,
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
registerGroup(
|
|
589
|
+
program,
|
|
590
|
+
"tag",
|
|
591
|
+
"Manage tags",
|
|
592
|
+
[
|
|
593
|
+
{
|
|
594
|
+
name: "list",
|
|
595
|
+
description: "List all tags",
|
|
596
|
+
action: async ({ globals }) => {
|
|
597
|
+
await cmdTagList(globals);
|
|
598
|
+
},
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
name: "create",
|
|
602
|
+
description: "Create a tag",
|
|
603
|
+
args: [{ name: "<name>", description: "Tag name" }],
|
|
604
|
+
action: async ({ globals, args }) => {
|
|
605
|
+
await cmdTagCreate({ ...globals, name: String(args[0]) });
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
name: "get",
|
|
610
|
+
description: "Get tag details",
|
|
611
|
+
args: [{ name: "<id>", description: "Tag ID" }],
|
|
612
|
+
action: async ({ globals, args }) => {
|
|
613
|
+
await cmdTagGet({ ...globals, id: String(args[0]) });
|
|
614
|
+
},
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
name: "delete",
|
|
618
|
+
description: "Delete a tag",
|
|
619
|
+
args: [{ name: "<id>", description: "Tag ID" }],
|
|
620
|
+
action: async ({ globals, args }) => {
|
|
621
|
+
await cmdTagDelete({ ...globals, id: String(args[0]) });
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
],
|
|
625
|
+
ctx,
|
|
626
|
+
);
|
|
627
|
+
|
|
628
|
+
registerGroup(
|
|
629
|
+
program,
|
|
630
|
+
"article",
|
|
631
|
+
"Manage help center articles",
|
|
632
|
+
[
|
|
633
|
+
{
|
|
634
|
+
name: "list",
|
|
635
|
+
description: "List articles",
|
|
636
|
+
options: [{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" }],
|
|
637
|
+
action: async ({ globals, options }) => {
|
|
638
|
+
await cmdArticleList({ ...globals, limit: options.limit as string | undefined });
|
|
639
|
+
},
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
name: "get",
|
|
643
|
+
description: "Get article details",
|
|
644
|
+
args: [{ name: "<id>", description: "Article ID" }],
|
|
645
|
+
action: async ({ globals, args }) => {
|
|
646
|
+
await cmdArticleGet({ ...globals, id: String(args[0]) });
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
name: "search",
|
|
651
|
+
description: "Search articles",
|
|
652
|
+
args: [{ name: "<query>", description: "Search query" }],
|
|
653
|
+
options: [{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" }],
|
|
654
|
+
action: async ({ globals, args, options }) => {
|
|
655
|
+
await cmdArticleSearch({
|
|
656
|
+
...globals,
|
|
657
|
+
query: String(args[0]),
|
|
658
|
+
limit: options.limit as string | undefined,
|
|
659
|
+
});
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
name: "create",
|
|
664
|
+
description: "Create an article",
|
|
665
|
+
requiredOptions: [
|
|
666
|
+
{ flags: "--title <title>", description: "Article title" },
|
|
667
|
+
{ flags: "--author-id <id>", description: "Author admin ID" },
|
|
668
|
+
],
|
|
669
|
+
options: [
|
|
670
|
+
{ flags: "--body <body>", description: "Article body (HTML)" },
|
|
671
|
+
{ flags: "--description <desc>", description: "Article description" },
|
|
672
|
+
{ flags: "--state <state>", description: "Article state (draft, published)" },
|
|
673
|
+
{ flags: "--parent-id <id>", description: "Parent collection/section ID" },
|
|
674
|
+
{ flags: "--parent-type <type>", description: "Parent type (collection, section)" },
|
|
675
|
+
],
|
|
676
|
+
action: async ({ globals, options }) => {
|
|
677
|
+
await cmdArticleCreate({
|
|
678
|
+
...globals,
|
|
679
|
+
title: options.title as string,
|
|
680
|
+
authorId: options.authorId as string,
|
|
681
|
+
body: options.body as string | undefined,
|
|
682
|
+
description: options.description as string | undefined,
|
|
683
|
+
state: options.state as string | undefined,
|
|
684
|
+
parentId: options.parentId as string | undefined,
|
|
685
|
+
parentType: options.parentType as string | undefined,
|
|
686
|
+
});
|
|
687
|
+
},
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: "update",
|
|
691
|
+
description: "Update an article",
|
|
692
|
+
args: [{ name: "<id>", description: "Article ID" }],
|
|
693
|
+
requiredOptions: [{ flags: "--json <json>", description: "Update data as JSON" }],
|
|
694
|
+
action: async ({ globals, args, options }) => {
|
|
695
|
+
await cmdArticleUpdate({ ...globals, id: String(args[0]), json: options.json as string });
|
|
696
|
+
},
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
name: "delete",
|
|
700
|
+
description: "Delete an article",
|
|
701
|
+
args: [{ name: "<id>", description: "Article ID" }],
|
|
702
|
+
action: async ({ globals, args }) => {
|
|
703
|
+
await cmdArticleDelete({ ...globals, id: String(args[0]) });
|
|
704
|
+
},
|
|
705
|
+
},
|
|
706
|
+
],
|
|
707
|
+
ctx,
|
|
708
|
+
);
|
|
709
|
+
|
|
710
|
+
registerGroup(
|
|
711
|
+
program,
|
|
712
|
+
"event",
|
|
713
|
+
"Track and list events",
|
|
714
|
+
[
|
|
715
|
+
{
|
|
716
|
+
name: "track",
|
|
717
|
+
description: "Track a custom event",
|
|
718
|
+
requiredOptions: [{ flags: "--name <name>", description: "Event name" }],
|
|
719
|
+
options: [
|
|
720
|
+
{ flags: "--user-id <id>", description: "User ID" },
|
|
721
|
+
{ flags: "--email <email>", description: "User email" },
|
|
722
|
+
{ flags: "--metadata <json>", description: "Event metadata as JSON" },
|
|
723
|
+
],
|
|
724
|
+
action: async ({ globals, options }) => {
|
|
725
|
+
await cmdEventTrack({
|
|
726
|
+
...globals,
|
|
727
|
+
name: options.name as string,
|
|
728
|
+
userId: options.userId as string | undefined,
|
|
729
|
+
email: options.email as string | undefined,
|
|
730
|
+
metadata: options.metadata as string | undefined,
|
|
731
|
+
});
|
|
732
|
+
},
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
name: "list",
|
|
736
|
+
description: "List events for a user",
|
|
737
|
+
requiredOptions: [{ flags: "--user-id <id>", description: "User ID" }],
|
|
738
|
+
action: async ({ globals, options }) => {
|
|
739
|
+
await cmdEventList({ ...globals, userId: options.userId as string });
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
],
|
|
743
|
+
ctx,
|
|
744
|
+
);
|
|
745
|
+
|
|
746
|
+
registerGroup(
|
|
747
|
+
program,
|
|
748
|
+
"ticket",
|
|
749
|
+
"Manage tickets",
|
|
750
|
+
[
|
|
751
|
+
{
|
|
752
|
+
name: "create",
|
|
753
|
+
description: "Create a new ticket",
|
|
754
|
+
options: [
|
|
755
|
+
{ flags: "--type-id <id>", description: "Ticket type ID" },
|
|
756
|
+
{ flags: "--contact-id <id>", description: "Contact ID" },
|
|
757
|
+
{ flags: "--title <title>", description: "Ticket title" },
|
|
758
|
+
{ flags: "--description <desc>", description: "Ticket description" },
|
|
759
|
+
{ flags: "--company-id <id>", description: "Company ID" },
|
|
760
|
+
{ flags: "--assignee-id <id>", description: "Assignee admin ID" },
|
|
761
|
+
{ flags: "--json <json>", description: "Full ticket data as JSON" },
|
|
762
|
+
],
|
|
763
|
+
action: async ({ globals, options }) => {
|
|
764
|
+
await cmdTicketCreate({
|
|
765
|
+
...globals,
|
|
766
|
+
ticketTypeId: options.typeId as string,
|
|
767
|
+
contactId: options.contactId as string,
|
|
768
|
+
title: options.title as string | undefined,
|
|
769
|
+
description: options.description as string | undefined,
|
|
770
|
+
companyId: options.companyId as string | undefined,
|
|
771
|
+
assigneeId: options.assigneeId as string | undefined,
|
|
772
|
+
json: options.json as string | undefined,
|
|
773
|
+
});
|
|
774
|
+
},
|
|
775
|
+
},
|
|
776
|
+
{
|
|
777
|
+
name: "get",
|
|
778
|
+
description: "Get ticket details",
|
|
779
|
+
args: [{ name: "<id>", description: "Ticket ID" }],
|
|
780
|
+
action: async ({ globals, args }) => {
|
|
781
|
+
await cmdTicketGet({ ...globals, id: String(args[0]) });
|
|
782
|
+
},
|
|
783
|
+
},
|
|
784
|
+
{
|
|
785
|
+
name: "update",
|
|
786
|
+
description: "Update a ticket",
|
|
787
|
+
args: [{ name: "<id>", description: "Ticket ID" }],
|
|
788
|
+
options: [
|
|
789
|
+
{ flags: "--state-id <id>", description: "Ticket state ID" },
|
|
790
|
+
{ flags: "--assignee-id <id>", description: "Assignee ID (admin or team)" },
|
|
791
|
+
{ flags: "--admin-id <id>", description: "Admin ID performing the update" },
|
|
792
|
+
{ flags: "--open", description: "Set ticket as open" },
|
|
793
|
+
{ flags: "--closed", description: "Set ticket as closed" },
|
|
794
|
+
{ flags: "--snoozed-until <timestamp>", description: "Unix timestamp to snooze until" },
|
|
795
|
+
{ flags: "--json <json>", description: "Update data as JSON" },
|
|
796
|
+
],
|
|
797
|
+
action: async ({ globals, args, options }) => {
|
|
798
|
+
let open: boolean | undefined;
|
|
799
|
+
if (options.open) open = true;
|
|
800
|
+
if (options.closed) open = false;
|
|
801
|
+
await cmdTicketUpdate({
|
|
802
|
+
...globals,
|
|
803
|
+
id: String(args[0]),
|
|
804
|
+
stateId: options.stateId as string | undefined,
|
|
805
|
+
assigneeId: options.assigneeId as string | undefined,
|
|
806
|
+
adminId: options.adminId as string | undefined,
|
|
807
|
+
open,
|
|
808
|
+
snoozedUntil: options.snoozedUntil as string | undefined,
|
|
809
|
+
json: options.json as string | undefined,
|
|
810
|
+
});
|
|
811
|
+
},
|
|
812
|
+
},
|
|
813
|
+
{
|
|
814
|
+
name: "delete",
|
|
815
|
+
description: "Delete a ticket",
|
|
816
|
+
args: [{ name: "<id>", description: "Ticket ID" }],
|
|
817
|
+
action: async ({ globals, args }) => {
|
|
818
|
+
await cmdTicketDelete({ ...globals, id: String(args[0]) });
|
|
819
|
+
},
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
name: "search",
|
|
823
|
+
description: "Search tickets",
|
|
824
|
+
options: [
|
|
825
|
+
{ flags: "--state <state>", description: "Filter by state (open, closed)" },
|
|
826
|
+
{ flags: "--assignee <id>", description: "Filter by assignee admin ID" },
|
|
827
|
+
{ flags: "--json <json>", description: "Search query as JSON" },
|
|
828
|
+
{ flags: "-l, --limit <limit>", description: "Maximum results", defaultValue: "25" },
|
|
829
|
+
],
|
|
830
|
+
action: async ({ globals, options }) => {
|
|
831
|
+
await cmdTicketSearch({
|
|
832
|
+
...globals,
|
|
833
|
+
state: options.state as string | undefined,
|
|
834
|
+
assignee: options.assignee as string | undefined,
|
|
835
|
+
json: options.json as string | undefined,
|
|
836
|
+
limit: options.limit as string | undefined,
|
|
837
|
+
});
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
name: "reply",
|
|
842
|
+
description: "Reply to a ticket",
|
|
843
|
+
args: [{ name: "<id>", description: "Ticket ID" }],
|
|
844
|
+
requiredOptions: [
|
|
845
|
+
{ flags: "--admin <id>", description: "Admin ID sending the reply" },
|
|
846
|
+
{ flags: "--body <body>", description: "Reply message body" },
|
|
847
|
+
],
|
|
848
|
+
options: [{ flags: "--type <type>", description: "Message type (comment, note)", defaultValue: "comment" }],
|
|
849
|
+
action: async ({ globals, args, options }) => {
|
|
850
|
+
await cmdTicketReply({
|
|
851
|
+
...globals,
|
|
852
|
+
id: String(args[0]),
|
|
853
|
+
adminId: options.admin as string,
|
|
854
|
+
body: options.body as string,
|
|
855
|
+
messageType: options.type as string | undefined,
|
|
856
|
+
});
|
|
857
|
+
},
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
name: "close",
|
|
861
|
+
description: "Close a ticket",
|
|
862
|
+
args: [{ name: "<id>", description: "Ticket ID" }],
|
|
863
|
+
requiredOptions: [{ flags: "--admin <id>", description: "Admin ID closing the ticket" }],
|
|
864
|
+
action: async ({ globals, args, options }) => {
|
|
865
|
+
await cmdTicketClose({
|
|
866
|
+
...globals,
|
|
867
|
+
id: String(args[0]),
|
|
868
|
+
adminId: options.admin as string,
|
|
869
|
+
});
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
{
|
|
873
|
+
name: "assign",
|
|
874
|
+
description: "Assign ticket to admin/team",
|
|
875
|
+
args: [{ name: "<id>", description: "Ticket ID" }],
|
|
876
|
+
requiredOptions: [
|
|
877
|
+
{ flags: "--admin <id>", description: "Admin ID performing assignment" },
|
|
878
|
+
{ flags: "--assignee <id>", description: "Assignee ID (admin or team)" },
|
|
879
|
+
],
|
|
880
|
+
action: async ({ globals, args, options }) => {
|
|
881
|
+
await cmdTicketAssign({
|
|
882
|
+
...globals,
|
|
883
|
+
id: String(args[0]),
|
|
884
|
+
adminId: options.admin as string,
|
|
885
|
+
assigneeId: options.assignee as string,
|
|
886
|
+
});
|
|
887
|
+
},
|
|
888
|
+
},
|
|
889
|
+
],
|
|
890
|
+
ctx,
|
|
891
|
+
);
|
|
892
|
+
|
|
893
|
+
registerGroup(
|
|
894
|
+
program,
|
|
895
|
+
"ticket-type",
|
|
896
|
+
"Manage ticket types",
|
|
897
|
+
[
|
|
898
|
+
{
|
|
899
|
+
name: "list",
|
|
900
|
+
description: "List all ticket types",
|
|
901
|
+
action: async ({ globals }) => {
|
|
902
|
+
await cmdTicketTypeList(globals);
|
|
903
|
+
},
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
name: "get",
|
|
907
|
+
description: "Get ticket type details",
|
|
908
|
+
args: [{ name: "<id>", description: "Ticket type ID" }],
|
|
909
|
+
action: async ({ globals, args }) => {
|
|
910
|
+
await cmdTicketTypeGet({ ...globals, id: String(args[0]) });
|
|
911
|
+
},
|
|
912
|
+
},
|
|
913
|
+
],
|
|
914
|
+
ctx,
|
|
915
|
+
);
|
|
916
|
+
}
|