@instantkom/cli 3.129.2
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 +34 -0
- package/bin/run.js +3 -0
- package/dist/api-client.d.ts +55 -0
- package/dist/api-client.js +199 -0
- package/dist/auth/device-flow-client.d.ts +22 -0
- package/dist/auth/device-flow-client.js +70 -0
- package/dist/auth/token-resolver.d.ts +31 -0
- package/dist/auth/token-resolver.js +48 -0
- package/dist/auth/token-store.d.ts +13 -0
- package/dist/auth/token-store.js +39 -0
- package/dist/base-command.d.ts +18 -0
- package/dist/base-command.js +84 -0
- package/dist/commands/ai/reply.d.ts +18 -0
- package/dist/commands/ai/reply.js +46 -0
- package/dist/commands/auth/login.d.ts +15 -0
- package/dist/commands/auth/login.js +37 -0
- package/dist/commands/auth/logout.d.ts +14 -0
- package/dist/commands/auth/logout.js +17 -0
- package/dist/commands/auth/tokens/create.d.ts +17 -0
- package/dist/commands/auth/tokens/create.js +62 -0
- package/dist/commands/auth/tokens/list.d.ts +14 -0
- package/dist/commands/auth/tokens/list.js +41 -0
- package/dist/commands/auth/tokens/revoke.d.ts +20 -0
- package/dist/commands/auth/tokens/revoke.js +41 -0
- package/dist/commands/autocomplete/script.d.ts +11 -0
- package/dist/commands/autocomplete/script.js +90 -0
- package/dist/commands/autocomplete.d.ts +13 -0
- package/dist/commands/autocomplete.js +95 -0
- package/dist/commands/bots/create.d.ts +22 -0
- package/dist/commands/bots/create.js +39 -0
- package/dist/commands/bots/delete.d.ts +20 -0
- package/dist/commands/bots/delete.js +19 -0
- package/dist/commands/bots/env-vars/bots.d.ts +20 -0
- package/dist/commands/bots/env-vars/bots.js +18 -0
- package/dist/commands/bots/env-vars/create.d.ts +18 -0
- package/dist/commands/bots/env-vars/create.js +28 -0
- package/dist/commands/bots/env-vars/delete.d.ts +20 -0
- package/dist/commands/bots/env-vars/delete.js +19 -0
- package/dist/commands/bots/env-vars/get.d.ts +20 -0
- package/dist/commands/bots/env-vars/get.js +19 -0
- package/dist/commands/bots/env-vars/list.d.ts +18 -0
- package/dist/commands/bots/env-vars/list.js +28 -0
- package/dist/commands/bots/env-vars/update.d.ts +23 -0
- package/dist/commands/bots/env-vars/update.js +29 -0
- package/dist/commands/bots/env-vars/values/delete.d.ts +20 -0
- package/dist/commands/bots/env-vars/values/delete.js +18 -0
- package/dist/commands/bots/env-vars/values/update.d.ts +23 -0
- package/dist/commands/bots/env-vars/values/update.js +28 -0
- package/dist/commands/bots/env-vars/values.d.ts +24 -0
- package/dist/commands/bots/env-vars/values.js +30 -0
- package/dist/commands/bots/filters/create.d.ts +28 -0
- package/dist/commands/bots/filters/create.js +38 -0
- package/dist/commands/bots/filters/delete.d.ts +24 -0
- package/dist/commands/bots/filters/delete.js +19 -0
- package/dist/commands/bots/filters/get.d.ts +24 -0
- package/dist/commands/bots/filters/get.js +19 -0
- package/dist/commands/bots/filters/list.d.ts +24 -0
- package/dist/commands/bots/filters/list.js +30 -0
- package/dist/commands/bots/filters/update.d.ts +32 -0
- package/dist/commands/bots/filters/update.js +39 -0
- package/dist/commands/bots/get.d.ts +20 -0
- package/dist/commands/bots/get.js +19 -0
- package/dist/commands/bots/list.d.ts +21 -0
- package/dist/commands/bots/list.js +34 -0
- package/dist/commands/bots/matches.d.ts +23 -0
- package/dist/commands/bots/matches.js +28 -0
- package/dist/commands/bots/tags/add.d.ts +24 -0
- package/dist/commands/bots/tags/add.js +19 -0
- package/dist/commands/bots/tags/list.d.ts +20 -0
- package/dist/commands/bots/tags/list.js +18 -0
- package/dist/commands/bots/tags/remove.d.ts +24 -0
- package/dist/commands/bots/tags/remove.js +19 -0
- package/dist/commands/bots/update.d.ts +27 -0
- package/dist/commands/bots/update.js +36 -0
- package/dist/commands/broadcast/create.d.ts +25 -0
- package/dist/commands/broadcast/create.js +117 -0
- package/dist/commands/channels/create.d.ts +19 -0
- package/dist/commands/channels/create.js +43 -0
- package/dist/commands/channels/get.d.ts +20 -0
- package/dist/commands/channels/get.js +25 -0
- package/dist/commands/channels/kpis.d.ts +21 -0
- package/dist/commands/channels/kpis.js +29 -0
- package/dist/commands/channels/list.d.ts +19 -0
- package/dist/commands/channels/list.js +43 -0
- package/dist/commands/channels/update.d.ts +24 -0
- package/dist/commands/channels/update.js +43 -0
- package/dist/commands/chats/reply.d.ts +21 -0
- package/dist/commands/chats/reply.js +28 -0
- package/dist/commands/config/get.d.ts +17 -0
- package/dist/commands/config/get.js +29 -0
- package/dist/commands/config/set.d.ts +18 -0
- package/dist/commands/config/set.js +30 -0
- package/dist/commands/config/unset.d.ts +17 -0
- package/dist/commands/config/unset.js +25 -0
- package/dist/commands/contacts/create.d.ts +18 -0
- package/dist/commands/contacts/create.js +39 -0
- package/dist/commands/contacts/delete.d.ts +20 -0
- package/dist/commands/contacts/delete.js +25 -0
- package/dist/commands/contacts/export.d.ts +19 -0
- package/dist/commands/contacts/export.js +50 -0
- package/dist/commands/contacts/get.d.ts +20 -0
- package/dist/commands/contacts/get.js +25 -0
- package/dist/commands/contacts/import.d.ts +16 -0
- package/dist/commands/contacts/import.js +62 -0
- package/dist/commands/contacts/list.d.ts +25 -0
- package/dist/commands/contacts/list.js +71 -0
- package/dist/commands/contacts/update.d.ts +23 -0
- package/dist/commands/contacts/update.js +39 -0
- package/dist/commands/exports/create.d.ts +23 -0
- package/dist/commands/exports/create.js +69 -0
- package/dist/commands/exports/delete.d.ts +20 -0
- package/dist/commands/exports/delete.js +25 -0
- package/dist/commands/exports/download.d.ts +21 -0
- package/dist/commands/exports/download.js +37 -0
- package/dist/commands/exports/get.d.ts +20 -0
- package/dist/commands/exports/get.js +25 -0
- package/dist/commands/exports/list.d.ts +18 -0
- package/dist/commands/exports/list.js +39 -0
- package/dist/commands/flow/edges/create.d.ts +25 -0
- package/dist/commands/flow/edges/create.js +32 -0
- package/dist/commands/flow/edges/delete.d.ts +24 -0
- package/dist/commands/flow/edges/delete.js +19 -0
- package/dist/commands/flow/edges/get.d.ts +24 -0
- package/dist/commands/flow/edges/get.js +19 -0
- package/dist/commands/flow/edges/list.d.ts +20 -0
- package/dist/commands/flow/edges/list.js +18 -0
- package/dist/commands/flow/edges/update.d.ts +29 -0
- package/dist/commands/flow/edges/update.js +33 -0
- package/dist/commands/flow/nodes/create.d.ts +25 -0
- package/dist/commands/flow/nodes/create.js +32 -0
- package/dist/commands/flow/nodes/delete.d.ts +24 -0
- package/dist/commands/flow/nodes/delete.js +19 -0
- package/dist/commands/flow/nodes/get.d.ts +24 -0
- package/dist/commands/flow/nodes/get.js +19 -0
- package/dist/commands/flow/nodes/list.d.ts +20 -0
- package/dist/commands/flow/nodes/list.js +18 -0
- package/dist/commands/flow/nodes/update.d.ts +29 -0
- package/dist/commands/flow/nodes/update.js +33 -0
- package/dist/commands/flows/create.d.ts +20 -0
- package/dist/commands/flows/create.js +32 -0
- package/dist/commands/flows/delete.d.ts +20 -0
- package/dist/commands/flows/delete.js +19 -0
- package/dist/commands/flows/get.d.ts +20 -0
- package/dist/commands/flows/get.js +19 -0
- package/dist/commands/flows/list.d.ts +19 -0
- package/dist/commands/flows/list.js +30 -0
- package/dist/commands/flows/update.d.ts +25 -0
- package/dist/commands/flows/update.js +33 -0
- package/dist/commands/send.d.ts +23 -0
- package/dist/commands/send.js +129 -0
- package/dist/commands/status.d.ts +23 -0
- package/dist/commands/status.js +81 -0
- package/dist/commands/tail.d.ts +15 -0
- package/dist/commands/tail.js +36 -0
- package/dist/commands/templates/get.d.ts +20 -0
- package/dist/commands/templates/get.js +24 -0
- package/dist/commands/templates/list.d.ts +18 -0
- package/dist/commands/templates/list.js +37 -0
- package/dist/commands/templates/render.d.ts +21 -0
- package/dist/commands/templates/render.js +30 -0
- package/dist/commands/ticket/messages/create.d.ts +22 -0
- package/dist/commands/ticket/messages/create.js +26 -0
- package/dist/commands/ticket/messages/delete.d.ts +24 -0
- package/dist/commands/ticket/messages/delete.js +20 -0
- package/dist/commands/ticket/messages/get.d.ts +24 -0
- package/dist/commands/ticket/messages/get.js +19 -0
- package/dist/commands/ticket/messages/list.d.ts +20 -0
- package/dist/commands/ticket/messages/list.js +18 -0
- package/dist/commands/tickets/create.d.ts +22 -0
- package/dist/commands/tickets/create.js +34 -0
- package/dist/commands/tickets/delete.d.ts +21 -0
- package/dist/commands/tickets/delete.js +21 -0
- package/dist/commands/tickets/get.d.ts +21 -0
- package/dist/commands/tickets/get.js +21 -0
- package/dist/commands/tickets/list.d.ts +17 -0
- package/dist/commands/tickets/list.js +24 -0
- package/dist/commands/tickets/update.d.ts +25 -0
- package/dist/commands/tickets/update.js +31 -0
- package/dist/commands/webhooks/add.d.ts +16 -0
- package/dist/commands/webhooks/add.js +38 -0
- package/dist/commands/webhooks/list.d.ts +14 -0
- package/dist/commands/webhooks/list.js +18 -0
- package/dist/commands/webhooks/remove.d.ts +17 -0
- package/dist/commands/webhooks/remove.js +24 -0
- package/dist/commands/whoami.d.ts +15 -0
- package/dist/commands/whoami.js +40 -0
- package/dist/config/config-file.d.ts +36 -0
- package/dist/config/config-file.js +111 -0
- package/dist/config/config-path.d.ts +8 -0
- package/dist/config/config-path.js +25 -0
- package/dist/crud/csv.d.ts +6 -0
- package/dist/crud/csv.js +89 -0
- package/dist/crud/data.d.ts +4 -0
- package/dist/crud/data.js +38 -0
- package/dist/crud/request.d.ts +14 -0
- package/dist/crud/request.js +26 -0
- package/dist/errors/api-error.d.ts +6 -0
- package/dist/errors/api-error.js +10 -0
- package/dist/errors/exit-codes.d.ts +12 -0
- package/dist/errors/exit-codes.js +24 -0
- package/dist/errors/redact-token.d.ts +10 -0
- package/dist/errors/redact-token.js +17 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/output/formatter.d.ts +15 -0
- package/dist/output/formatter.js +57 -0
- package/dist/output/text-format.d.ts +13 -0
- package/dist/output/text-format.js +67 -0
- package/dist/send/api.d.ts +3 -0
- package/dist/send/api.js +21 -0
- package/dist/send/fallback.d.ts +5 -0
- package/dist/send/fallback.js +38 -0
- package/dist/send/media.d.ts +2 -0
- package/dist/send/media.js +41 -0
- package/dist/send/payload.d.ts +23 -0
- package/dist/send/payload.js +22 -0
- package/dist/send/recipient-resolver.d.ts +13 -0
- package/dist/send/recipient-resolver.js +28 -0
- package/dist/send/schedule.d.ts +1 -0
- package/dist/send/schedule.js +19 -0
- package/dist/tail/sse.d.ts +24 -0
- package/dist/tail/sse.js +139 -0
- package/dist/templates/render-template.d.ts +14 -0
- package/dist/templates/render-template.js +46 -0
- package/npm-shrinkwrap.json +11444 -0
- package/oclif.manifest.json +9286 -0
- package/package.json +157 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { getResource } from '../../crud/request.js';
|
|
4
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
5
|
+
export default class FlowsGet extends BaseCommand {
|
|
6
|
+
static description = 'Get a flow by ID';
|
|
7
|
+
static args = {
|
|
8
|
+
id: Args.integer({ description: 'Flow ID', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static flags = { ...BaseCommand.baseFlags };
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(FlowsGet);
|
|
13
|
+
this.flags = flags;
|
|
14
|
+
const client = await createCliApiClient(flags);
|
|
15
|
+
const flow = await getResource(client, '/v1/flows', args.id);
|
|
16
|
+
if (!flags.quiet)
|
|
17
|
+
this.log(this.toFormatted(flow));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class FlowsList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
channel: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
search: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
folder: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { cleanQuery } from '../../crud/data.js';
|
|
4
|
+
import { listResource } from '../../crud/request.js';
|
|
5
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
6
|
+
export default class FlowsList extends BaseCommand {
|
|
7
|
+
static description = 'List flows';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
page: Flags.integer({ description: 'Page number', default: 1 }),
|
|
11
|
+
limit: Flags.integer({ description: 'Items per page', default: 20 }),
|
|
12
|
+
channel: Flags.integer({ description: 'Filter by channel ID' }),
|
|
13
|
+
search: Flags.string({ description: 'Search in flow name or description' }),
|
|
14
|
+
folder: Flags.integer({ description: 'Filter by folder ID' }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const { flags } = await this.parse(FlowsList);
|
|
18
|
+
this.flags = flags;
|
|
19
|
+
const client = await createCliApiClient(flags);
|
|
20
|
+
const flows = await listResource(client, '/v1/flows', cleanQuery({
|
|
21
|
+
page: flags.page,
|
|
22
|
+
limit: flags.limit,
|
|
23
|
+
channelId: flags.channel,
|
|
24
|
+
search: flags.search,
|
|
25
|
+
folderId: flags.folder,
|
|
26
|
+
}));
|
|
27
|
+
if (!flags.quiet)
|
|
28
|
+
this.log(this.toFormatted(flows));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class FlowsUpdate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
6
|
+
max?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
color: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
folder: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
};
|
|
24
|
+
run(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { mergeData, parseDataFlag } from '../../crud/data.js';
|
|
4
|
+
import { updateResource } from '../../crud/request.js';
|
|
5
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
6
|
+
export default class FlowsUpdate extends BaseCommand {
|
|
7
|
+
static description = 'Update a flow';
|
|
8
|
+
static args = {
|
|
9
|
+
id: Args.integer({ description: 'Flow ID', required: true }),
|
|
10
|
+
};
|
|
11
|
+
static flags = {
|
|
12
|
+
...BaseCommand.baseFlags,
|
|
13
|
+
name: Flags.string({ description: 'Flow name' }),
|
|
14
|
+
description: Flags.string({ description: 'Flow description' }),
|
|
15
|
+
color: Flags.string({ description: 'Flow color as HEX' }),
|
|
16
|
+
folder: Flags.integer({ description: 'Folder ID' }),
|
|
17
|
+
data: Flags.string({ description: 'Additional JSON object payload' }),
|
|
18
|
+
};
|
|
19
|
+
async run() {
|
|
20
|
+
const { args, flags } = await this.parse(FlowsUpdate);
|
|
21
|
+
this.flags = flags;
|
|
22
|
+
const payload = mergeData(parseDataFlag(flags.data), {
|
|
23
|
+
name: flags.name,
|
|
24
|
+
description: flags.description,
|
|
25
|
+
color: flags.color,
|
|
26
|
+
folderId: flags.folder,
|
|
27
|
+
});
|
|
28
|
+
const client = await createCliApiClient(flags);
|
|
29
|
+
const flow = await updateResource(client, '/v1/flows', args.id, payload);
|
|
30
|
+
if (!flags.quiet)
|
|
31
|
+
this.log(this.toFormatted(flow));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCommand } from '../base-command.js';
|
|
2
|
+
export default class Send extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
channel: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
channels: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
to: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
text: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'send-at': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
'dry-run': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
'idempotency-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
media: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
private sendViaChannel;
|
|
23
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../send/api.js';
|
|
4
|
+
import { createMessagePayload } from '../send/payload.js';
|
|
5
|
+
import { resolveRecipient } from '../send/recipient-resolver.js';
|
|
6
|
+
import { parseSendAt } from '../send/schedule.js';
|
|
7
|
+
import { prepareMediaFiles } from '../send/media.js';
|
|
8
|
+
import { resolveFallbackChannels } from '../send/fallback.js';
|
|
9
|
+
import { ApiError } from '../errors/api-error.js';
|
|
10
|
+
export default class Send extends BaseCommand {
|
|
11
|
+
static description = 'Send a message to one recipient';
|
|
12
|
+
static flags = {
|
|
13
|
+
...BaseCommand.baseFlags,
|
|
14
|
+
channel: Flags.integer({
|
|
15
|
+
description: 'Channel ID to send through',
|
|
16
|
+
}),
|
|
17
|
+
channels: Flags.string({
|
|
18
|
+
description: 'Comma-separated channel fallback aliases, e.g. wa,sms',
|
|
19
|
+
}),
|
|
20
|
+
to: Flags.string({
|
|
21
|
+
description: 'Recipient identifier, usually an E.164 phone number',
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
text: Flags.string({
|
|
25
|
+
description: 'Message text',
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
28
|
+
'send-at': Flags.string({
|
|
29
|
+
description: 'Schedule send for an ISO-8601 date-time',
|
|
30
|
+
}),
|
|
31
|
+
'dry-run': Flags.boolean({
|
|
32
|
+
description: 'Validate and print the send payload without mutating API calls',
|
|
33
|
+
default: false,
|
|
34
|
+
}),
|
|
35
|
+
'idempotency-key': Flags.string({
|
|
36
|
+
description: 'Idempotency key forwarded as Idempotency-Key',
|
|
37
|
+
}),
|
|
38
|
+
media: Flags.string({
|
|
39
|
+
description: 'Media file path to upload',
|
|
40
|
+
multiple: true,
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
async run() {
|
|
44
|
+
const { flags } = await this.parse(Send);
|
|
45
|
+
this.flags = flags;
|
|
46
|
+
if (flags.channel && flags.channels) {
|
|
47
|
+
throw new ApiError('user_error', '--channel and --channels are mutually exclusive');
|
|
48
|
+
}
|
|
49
|
+
if (!flags.channel && !flags.channels) {
|
|
50
|
+
throw new ApiError('user_error', 'Either --channel or --channels is required');
|
|
51
|
+
}
|
|
52
|
+
const scheduledAt = parseSendAt(flags['send-at']);
|
|
53
|
+
const media = prepareMediaFiles(flags.media);
|
|
54
|
+
const idempotencyHeaders = flags['idempotency-key']
|
|
55
|
+
? { 'Idempotency-Key': flags['idempotency-key'] }
|
|
56
|
+
: undefined;
|
|
57
|
+
if (flags['dry-run']) {
|
|
58
|
+
const payload = {
|
|
59
|
+
channelId: flags.channel,
|
|
60
|
+
channels: flags.channels,
|
|
61
|
+
to: flags.to,
|
|
62
|
+
message: flags.text,
|
|
63
|
+
messageType: 'text',
|
|
64
|
+
scheduledAt,
|
|
65
|
+
media: media.map((file) => ({
|
|
66
|
+
filename: file.filename,
|
|
67
|
+
contentType: file.contentType,
|
|
68
|
+
})),
|
|
69
|
+
idempotencyKey: flags['idempotency-key'],
|
|
70
|
+
};
|
|
71
|
+
if (!flags.quiet) {
|
|
72
|
+
this.log(this.toFormatted(payload));
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const client = await createCliApiClient(flags);
|
|
77
|
+
const channelAttempts = flags.channels
|
|
78
|
+
? await resolveFallbackChannels(client, flags.channels)
|
|
79
|
+
: [{ alias: String(flags.channel), channelId: flags.channel }];
|
|
80
|
+
const failures = [];
|
|
81
|
+
for (const attempt of channelAttempts) {
|
|
82
|
+
try {
|
|
83
|
+
const message = await this.sendViaChannel({
|
|
84
|
+
channelId: attempt.channelId,
|
|
85
|
+
client,
|
|
86
|
+
idempotencyHeaders,
|
|
87
|
+
media,
|
|
88
|
+
scheduledAt,
|
|
89
|
+
text: flags.text,
|
|
90
|
+
to: flags.to,
|
|
91
|
+
});
|
|
92
|
+
const output = {
|
|
93
|
+
id: message.id,
|
|
94
|
+
status: message.status ?? 'pending',
|
|
95
|
+
channelId: message.channelId ?? attempt.channelId,
|
|
96
|
+
recipientId: message.recipientId,
|
|
97
|
+
recipient: message.recipientIdentifier,
|
|
98
|
+
fallbackAlias: attempt.alias,
|
|
99
|
+
};
|
|
100
|
+
if (!flags.quiet) {
|
|
101
|
+
this.log(this.toFormatted(output));
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
failures.push(`${attempt.alias}: ${error instanceof Error ? error.message : String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
throw new ApiError('user_error', `All channel attempts failed: ${failures.join('; ')}`);
|
|
110
|
+
}
|
|
111
|
+
async sendViaChannel({ channelId, client, idempotencyHeaders, media, scheduledAt, text, to, }) {
|
|
112
|
+
const recipient = await resolveRecipient({
|
|
113
|
+
client,
|
|
114
|
+
channelId,
|
|
115
|
+
to,
|
|
116
|
+
});
|
|
117
|
+
const payload = createMessagePayload({
|
|
118
|
+
recipientId: recipient.id,
|
|
119
|
+
text,
|
|
120
|
+
scheduledAt,
|
|
121
|
+
});
|
|
122
|
+
if (media.length > 0) {
|
|
123
|
+
return client.postMultipart('/v1/messages', payload, media, { headers: idempotencyHeaders });
|
|
124
|
+
}
|
|
125
|
+
return client.post('/v1/messages', payload, {
|
|
126
|
+
headers: idempotencyHeaders,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCommand } from '../base-command.js';
|
|
2
|
+
export default class Status extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
6
|
+
max?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
watch: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
interval: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
timeout: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
};
|
|
22
|
+
run(): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../base-command.js';
|
|
3
|
+
import { ApiError } from '../errors/api-error.js';
|
|
4
|
+
import { createCliApiClient } from '../send/api.js';
|
|
5
|
+
const TERMINAL_STATUSES = new Set(['sent', 'failed', 'received']);
|
|
6
|
+
function sleep(ms) {
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
setTimeout(resolve, ms);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function statusOutput(message) {
|
|
12
|
+
return {
|
|
13
|
+
id: message.id,
|
|
14
|
+
status: message.status ?? 'unknown',
|
|
15
|
+
channelId: message.channelId,
|
|
16
|
+
recipientId: message.recipientId,
|
|
17
|
+
recipient: message.recipientIdentifier,
|
|
18
|
+
error: message.errorDescription,
|
|
19
|
+
updatedAt: message.updatedAt,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export default class Status extends BaseCommand {
|
|
23
|
+
static description = 'Show message delivery status';
|
|
24
|
+
static args = {
|
|
25
|
+
id: Args.integer({
|
|
26
|
+
description: 'Message ID',
|
|
27
|
+
required: true,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
static flags = {
|
|
31
|
+
...BaseCommand.baseFlags,
|
|
32
|
+
watch: Flags.boolean({
|
|
33
|
+
description: 'Poll until the message reaches a terminal status or timeout',
|
|
34
|
+
default: false,
|
|
35
|
+
}),
|
|
36
|
+
interval: Flags.integer({
|
|
37
|
+
description: 'Polling interval in seconds',
|
|
38
|
+
default: 2,
|
|
39
|
+
}),
|
|
40
|
+
timeout: Flags.integer({
|
|
41
|
+
description: 'Maximum watch time in seconds',
|
|
42
|
+
default: 60,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
async run() {
|
|
46
|
+
const { args, flags } = await this.parse(Status);
|
|
47
|
+
this.flags = flags;
|
|
48
|
+
if (flags.interval < 1) {
|
|
49
|
+
throw new ApiError('user_error', '--interval must be at least 1 second');
|
|
50
|
+
}
|
|
51
|
+
if (flags.timeout < 1) {
|
|
52
|
+
throw new ApiError('user_error', '--timeout must be at least 1 second');
|
|
53
|
+
}
|
|
54
|
+
const client = await createCliApiClient(flags);
|
|
55
|
+
if (!flags.watch) {
|
|
56
|
+
const message = await client.get(`/v1/messages/${args.id}`);
|
|
57
|
+
if (!flags.quiet) {
|
|
58
|
+
this.log(this.toFormatted(statusOutput(message)));
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const started = Date.now();
|
|
63
|
+
let latest;
|
|
64
|
+
let lastStatus;
|
|
65
|
+
do {
|
|
66
|
+
latest = await client.get(`/v1/messages/${args.id}`);
|
|
67
|
+
const currentStatus = latest.status ?? 'unknown';
|
|
68
|
+
if (!flags.quiet && currentStatus !== lastStatus) {
|
|
69
|
+
this.log(this.toFormatted(statusOutput(latest)));
|
|
70
|
+
}
|
|
71
|
+
if (TERMINAL_STATUSES.has(currentStatus)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
lastStatus = currentStatus;
|
|
75
|
+
await sleep(flags.interval * 1000);
|
|
76
|
+
} while (Date.now() - started < flags.timeout * 1000);
|
|
77
|
+
if (!flags.quiet && latest && latest.status === lastStatus) {
|
|
78
|
+
this.log(this.toFormatted(statusOutput(latest)));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BaseCommand } from '../base-command.js';
|
|
2
|
+
export default class Tail extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
channel: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
};
|
|
14
|
+
run(): Promise<void>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { resolveToken } from '../auth/token-resolver.js';
|
|
3
|
+
import { BaseCommand } from '../base-command.js';
|
|
4
|
+
import { ApiError } from '../errors/api-error.js';
|
|
5
|
+
import { streamRealtimeEvents } from '../tail/sse.js';
|
|
6
|
+
export default class Tail extends BaseCommand {
|
|
7
|
+
static description = 'Stream inbound channel messages as JSONL';
|
|
8
|
+
static flags = {
|
|
9
|
+
...BaseCommand.baseFlags,
|
|
10
|
+
channel: Flags.integer({
|
|
11
|
+
description: 'Channel ID to stream inbound messages for',
|
|
12
|
+
required: true,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { flags } = await this.parse(Tail);
|
|
17
|
+
this.flags = flags;
|
|
18
|
+
const token = await resolveToken({
|
|
19
|
+
flag: flags['api-key'],
|
|
20
|
+
env: process.env.IKM_API_KEY,
|
|
21
|
+
profile: flags.profile,
|
|
22
|
+
});
|
|
23
|
+
if (!token) {
|
|
24
|
+
throw new ApiError('unauthorized', 'Not logged in. Run: ikm auth login');
|
|
25
|
+
}
|
|
26
|
+
await streamRealtimeEvents({
|
|
27
|
+
apiKey: token,
|
|
28
|
+
apiUrl: flags['api-url'] ?? process.env.IKM_API_URL ?? 'https://api.instantkom.app',
|
|
29
|
+
channelId: flags.channel,
|
|
30
|
+
onEvent: (event) => {
|
|
31
|
+
if (!flags.quiet)
|
|
32
|
+
this.log(JSON.stringify(event));
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class TemplatesGet extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
6
|
+
max?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
4
|
+
export default class TemplatesGet extends BaseCommand {
|
|
5
|
+
static description = 'Get a message template by ID';
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.integer({
|
|
8
|
+
description: 'Template ID',
|
|
9
|
+
required: true,
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
static flags = {
|
|
13
|
+
...BaseCommand.baseFlags,
|
|
14
|
+
};
|
|
15
|
+
async run() {
|
|
16
|
+
const { args, flags } = await this.parse(TemplatesGet);
|
|
17
|
+
this.flags = flags;
|
|
18
|
+
const client = await createCliApiClient(flags);
|
|
19
|
+
const template = await client.get(`/v1/templates/${args.id}`);
|
|
20
|
+
if (!flags.quiet) {
|
|
21
|
+
this.log(this.toFormatted(template));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class TemplatesList extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
channel: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
search: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
4
|
+
export default class TemplatesList extends BaseCommand {
|
|
5
|
+
static description = 'List message templates';
|
|
6
|
+
static flags = {
|
|
7
|
+
...BaseCommand.baseFlags,
|
|
8
|
+
channel: Flags.integer({
|
|
9
|
+
description: 'Filter by channel ID',
|
|
10
|
+
}),
|
|
11
|
+
search: Flags.string({
|
|
12
|
+
description: 'Search templates by name or content',
|
|
13
|
+
}),
|
|
14
|
+
page: Flags.integer({
|
|
15
|
+
description: 'Page number',
|
|
16
|
+
default: 1,
|
|
17
|
+
}),
|
|
18
|
+
limit: Flags.integer({
|
|
19
|
+
description: 'Items per page',
|
|
20
|
+
default: 20,
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
async run() {
|
|
24
|
+
const { flags } = await this.parse(TemplatesList);
|
|
25
|
+
this.flags = flags;
|
|
26
|
+
const client = await createCliApiClient(flags);
|
|
27
|
+
const templates = await client.get('/v1/templates', {
|
|
28
|
+
channelId: flags.channel,
|
|
29
|
+
search: flags.search,
|
|
30
|
+
page: flags.page,
|
|
31
|
+
limit: flags.limit,
|
|
32
|
+
});
|
|
33
|
+
if (!flags.quiet) {
|
|
34
|
+
this.log(this.toFormatted(templates));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class TemplatesRender extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
id: import("@oclif/core/interfaces").Arg<number, {
|
|
6
|
+
max?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
vars: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
15
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
4
|
+
import { parseVars, renderTemplate } from '../../templates/render-template.js';
|
|
5
|
+
export default class TemplatesRender extends BaseCommand {
|
|
6
|
+
static description = 'Render a message template locally';
|
|
7
|
+
static args = {
|
|
8
|
+
id: Args.integer({
|
|
9
|
+
description: 'Template ID',
|
|
10
|
+
required: true,
|
|
11
|
+
}),
|
|
12
|
+
};
|
|
13
|
+
static flags = {
|
|
14
|
+
...BaseCommand.baseFlags,
|
|
15
|
+
vars: Flags.string({
|
|
16
|
+
description: 'Template variable as key=value; may be repeated',
|
|
17
|
+
multiple: true,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
async run() {
|
|
21
|
+
const { args, flags } = await this.parse(TemplatesRender);
|
|
22
|
+
this.flags = flags;
|
|
23
|
+
const client = await createCliApiClient(flags);
|
|
24
|
+
const template = await client.get(`/v1/templates/${args.id}`);
|
|
25
|
+
const rendered = renderTemplate(template, parseVars(flags.vars));
|
|
26
|
+
if (!flags.quiet) {
|
|
27
|
+
this.log(this.toFormatted(rendered));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
2
|
+
export default class TicketMessagesCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
ticketId: import("@oclif/core/interfaces").Arg<number, {
|
|
6
|
+
max?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
}>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
message: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
16
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
17
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|