@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,30 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
3
|
+
import { cleanQuery } from '../../../crud/data.js';
|
|
4
|
+
import { createCliApiClient } from '../../../send/api.js';
|
|
5
|
+
export default class BotsFiltersList extends BaseCommand {
|
|
6
|
+
static description = 'List bot filters';
|
|
7
|
+
static args = {
|
|
8
|
+
botId: Args.integer({ description: 'Bot ID', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseCommand.baseFlags,
|
|
12
|
+
page: Flags.integer({ description: 'Page number', default: 1 }),
|
|
13
|
+
limit: Flags.integer({ description: 'Items per page', default: 20 }),
|
|
14
|
+
status: Flags.integer({ description: 'Status filter: 0 inactive, 1 active', options: ['0', '1'] }),
|
|
15
|
+
search: Flags.string({ description: 'Search in name or description' }),
|
|
16
|
+
};
|
|
17
|
+
async run() {
|
|
18
|
+
const { args, flags } = await this.parse(BotsFiltersList);
|
|
19
|
+
this.flags = flags;
|
|
20
|
+
const client = await createCliApiClient(flags);
|
|
21
|
+
const filters = await client.get(`/v1/bots/${args.botId}/filters`, cleanQuery({
|
|
22
|
+
page: flags.page,
|
|
23
|
+
limit: flags.limit,
|
|
24
|
+
status: flags.status,
|
|
25
|
+
search: flags.search,
|
|
26
|
+
}));
|
|
27
|
+
if (!flags.quiet)
|
|
28
|
+
this.log(this.toFormatted(filters));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
2
|
+
export default class BotsFiltersUpdate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static args: {
|
|
5
|
+
botId: import("@oclif/core/interfaces").Arg<number, {
|
|
6
|
+
max?: number;
|
|
7
|
+
min?: number;
|
|
8
|
+
}>;
|
|
9
|
+
filterId: import("@oclif/core/interfaces").Arg<number, {
|
|
10
|
+
max?: number;
|
|
11
|
+
min?: number;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
static flags: {
|
|
15
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
operator: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
'filter-object': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'filter-attribute': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'filter-comparator': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'filter-value': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
status: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
26
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
27
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
28
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
29
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
30
|
+
};
|
|
31
|
+
run(): Promise<void>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
3
|
+
import { mergeData, parseDataFlag } from '../../../crud/data.js';
|
|
4
|
+
import { createCliApiClient } from '../../../send/api.js';
|
|
5
|
+
export default class BotsFiltersUpdate extends BaseCommand {
|
|
6
|
+
static description = 'Update a bot filter';
|
|
7
|
+
static args = {
|
|
8
|
+
botId: Args.integer({ description: 'Bot ID', required: true }),
|
|
9
|
+
filterId: Args.integer({ description: 'Filter ID', required: true }),
|
|
10
|
+
};
|
|
11
|
+
static flags = {
|
|
12
|
+
...BaseCommand.baseFlags,
|
|
13
|
+
name: Flags.string({ description: 'Filter name' }),
|
|
14
|
+
operator: Flags.string({ description: 'Logical operator' }),
|
|
15
|
+
'filter-object': Flags.string({ description: 'Filter object type' }),
|
|
16
|
+
'filter-attribute': Flags.string({ description: 'Filter attribute' }),
|
|
17
|
+
'filter-comparator': Flags.string({ description: 'Filter comparator' }),
|
|
18
|
+
'filter-value': Flags.string({ description: 'Filter value' }),
|
|
19
|
+
status: Flags.integer({ description: 'Status: 0 inactive, 1 active', options: ['0', '1'] }),
|
|
20
|
+
data: Flags.string({ description: 'Additional JSON object payload' }),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
const { args, flags } = await this.parse(BotsFiltersUpdate);
|
|
24
|
+
this.flags = flags;
|
|
25
|
+
const payload = mergeData(parseDataFlag(flags.data), {
|
|
26
|
+
name: flags.name,
|
|
27
|
+
operator: flags.operator,
|
|
28
|
+
objectType: flags['filter-object'],
|
|
29
|
+
attribute: flags['filter-attribute'],
|
|
30
|
+
comparator: flags['filter-comparator'],
|
|
31
|
+
value: flags['filter-value'],
|
|
32
|
+
status: flags.status,
|
|
33
|
+
});
|
|
34
|
+
const client = await createCliApiClient(flags);
|
|
35
|
+
const filter = await client.put(`/v1/bots/${args.botId}/filters/${args.filterId}`, payload);
|
|
36
|
+
if (!flags.quiet)
|
|
37
|
+
this.log(this.toFormatted(filter));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class BotsGet 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,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 BotsGet extends BaseCommand {
|
|
6
|
+
static description = 'Get a bot by ID';
|
|
7
|
+
static args = {
|
|
8
|
+
id: Args.integer({ description: 'Bot ID', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static flags = { ...BaseCommand.baseFlags };
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(BotsGet);
|
|
13
|
+
this.flags = flags;
|
|
14
|
+
const client = await createCliApiClient(flags);
|
|
15
|
+
const bot = await getResource(client, '/v1/bots', args.id);
|
|
16
|
+
if (!flags.quiet)
|
|
17
|
+
this.log(this.toFormatted(bot));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class BotsList 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
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
search: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
tags: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
|
+
'tag-match': 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,34 @@
|
|
|
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 BotsList extends BaseCommand {
|
|
7
|
+
static description = 'List bots';
|
|
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
|
+
type: Flags.string({ description: 'Filter by bot type' }),
|
|
14
|
+
search: Flags.string({ description: 'Search in bot name or message' }),
|
|
15
|
+
tags: Flags.string({ description: 'Comma-separated tag IDs' }),
|
|
16
|
+
'tag-match': Flags.string({ description: 'Tag match mode', options: ['any', 'all'] }),
|
|
17
|
+
};
|
|
18
|
+
async run() {
|
|
19
|
+
const { flags } = await this.parse(BotsList);
|
|
20
|
+
this.flags = flags;
|
|
21
|
+
const client = await createCliApiClient(flags);
|
|
22
|
+
const bots = await listResource(client, '/v1/bots', cleanQuery({
|
|
23
|
+
page: flags.page,
|
|
24
|
+
limit: flags.limit,
|
|
25
|
+
channelId: flags.channel,
|
|
26
|
+
type: flags.type,
|
|
27
|
+
search: flags.search,
|
|
28
|
+
tagIds: flags.tags,
|
|
29
|
+
tagMatchMode: flags['tag-match'],
|
|
30
|
+
}));
|
|
31
|
+
if (!flags.quiet)
|
|
32
|
+
this.log(this.toFormatted(bots));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class BotsMatches 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
|
+
page: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
search: import("@oclif/core/interfaces").OptionFlag<string | undefined, 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,28 @@
|
|
|
1
|
+
import { Args, Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../base-command.js';
|
|
3
|
+
import { cleanQuery } from '../../crud/data.js';
|
|
4
|
+
import { createCliApiClient } from '../../send/api.js';
|
|
5
|
+
export default class BotsMatches extends BaseCommand {
|
|
6
|
+
static description = 'List bot match history';
|
|
7
|
+
static args = {
|
|
8
|
+
id: Args.integer({ description: 'Bot ID', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseCommand.baseFlags,
|
|
12
|
+
page: Flags.integer({ description: 'Page number', default: 1 }),
|
|
13
|
+
limit: Flags.integer({ description: 'Items per page', default: 50 }),
|
|
14
|
+
search: Flags.string({ description: 'Search in matches' }),
|
|
15
|
+
};
|
|
16
|
+
async run() {
|
|
17
|
+
const { args, flags } = await this.parse(BotsMatches);
|
|
18
|
+
this.flags = flags;
|
|
19
|
+
const client = await createCliApiClient(flags);
|
|
20
|
+
const matches = await client.get(`/v1/bots/${args.id}/matches`, cleanQuery({
|
|
21
|
+
page: flags.page,
|
|
22
|
+
limit: flags.limit,
|
|
23
|
+
search: flags.search,
|
|
24
|
+
}));
|
|
25
|
+
if (!flags.quiet)
|
|
26
|
+
this.log(this.toFormatted(matches));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
2
|
+
export default class BotsTagsAdd 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
|
+
tagId: import("@oclif/core/interfaces").Arg<number, {
|
|
10
|
+
max?: number;
|
|
11
|
+
min?: number;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
static flags: {
|
|
15
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
};
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../../../send/api.js';
|
|
4
|
+
export default class BotsTagsAdd extends BaseCommand {
|
|
5
|
+
static description = 'Add a tag to a bot';
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.integer({ description: 'Bot ID', required: true }),
|
|
8
|
+
tagId: Args.integer({ description: 'Tag ID', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static flags = { ...BaseCommand.baseFlags };
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(BotsTagsAdd);
|
|
13
|
+
this.flags = flags;
|
|
14
|
+
const client = await createCliApiClient(flags);
|
|
15
|
+
const tag = await client.post(`/v1/bots/${args.id}/tags`, { tagId: args.tagId });
|
|
16
|
+
if (!flags.quiet)
|
|
17
|
+
this.log(this.toFormatted(tag));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
2
|
+
export default class BotsTagsList 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,18 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../../../send/api.js';
|
|
4
|
+
export default class BotsTagsList extends BaseCommand {
|
|
5
|
+
static description = 'List tags assigned to a bot';
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.integer({ description: 'Bot ID', required: true }),
|
|
8
|
+
};
|
|
9
|
+
static flags = { ...BaseCommand.baseFlags };
|
|
10
|
+
async run() {
|
|
11
|
+
const { args, flags } = await this.parse(BotsTagsList);
|
|
12
|
+
this.flags = flags;
|
|
13
|
+
const client = await createCliApiClient(flags);
|
|
14
|
+
const tags = await client.get(`/v1/bots/${args.id}/tags`);
|
|
15
|
+
if (!flags.quiet)
|
|
16
|
+
this.log(this.toFormatted(tags));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
2
|
+
export default class BotsTagsRemove 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
|
+
tagId: import("@oclif/core/interfaces").Arg<number, {
|
|
10
|
+
max?: number;
|
|
11
|
+
min?: number;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
static flags: {
|
|
15
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
};
|
|
23
|
+
run(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../../base-command.js';
|
|
3
|
+
import { createCliApiClient } from '../../../send/api.js';
|
|
4
|
+
export default class BotsTagsRemove extends BaseCommand {
|
|
5
|
+
static description = 'Remove a tag from a bot';
|
|
6
|
+
static args = {
|
|
7
|
+
id: Args.integer({ description: 'Bot ID', required: true }),
|
|
8
|
+
tagId: Args.integer({ description: 'Tag ID', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static flags = { ...BaseCommand.baseFlags };
|
|
11
|
+
async run() {
|
|
12
|
+
const { args, flags } = await this.parse(BotsTagsRemove);
|
|
13
|
+
this.flags = flags;
|
|
14
|
+
const client = await createCliApiClient(flags);
|
|
15
|
+
await client.delete(`/v1/bots/${args.id}/tags/${args.tagId}`);
|
|
16
|
+
if (!flags.quiet)
|
|
17
|
+
this.log(this.toFormatted({ removed: true, id: args.id, tagId: args.tagId }));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class BotsUpdate 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
|
+
type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
message: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
response: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
color: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
tags: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'api-key': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
format: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
21
|
+
quiet: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
22
|
+
'no-color': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
23
|
+
profile: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
'api-url': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
};
|
|
26
|
+
run(): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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 BotsUpdate extends BaseCommand {
|
|
7
|
+
static description = 'Update a bot';
|
|
8
|
+
static args = {
|
|
9
|
+
id: Args.integer({ description: 'Bot ID', required: true }),
|
|
10
|
+
};
|
|
11
|
+
static flags = {
|
|
12
|
+
...BaseCommand.baseFlags,
|
|
13
|
+
name: Flags.string({ description: 'Bot name' }),
|
|
14
|
+
type: Flags.string({ description: 'Bot type', options: ['keyword', 'schedule', 'event', 'ai'] }),
|
|
15
|
+
message: Flags.string({ description: 'Bot message content' }),
|
|
16
|
+
response: Flags.string({ description: 'Alias for --message' }),
|
|
17
|
+
color: Flags.string({ description: 'Bot color as HEX' }),
|
|
18
|
+
tags: Flags.string({ description: 'Comma-separated tags' }),
|
|
19
|
+
data: Flags.string({ description: 'Additional JSON object payload' }),
|
|
20
|
+
};
|
|
21
|
+
async run() {
|
|
22
|
+
const { args, flags } = await this.parse(BotsUpdate);
|
|
23
|
+
this.flags = flags;
|
|
24
|
+
const payload = mergeData(parseDataFlag(flags.data), {
|
|
25
|
+
name: flags.name,
|
|
26
|
+
type: flags.type,
|
|
27
|
+
message: flags.message ?? flags.response,
|
|
28
|
+
color: flags.color,
|
|
29
|
+
tags: flags.tags,
|
|
30
|
+
});
|
|
31
|
+
const client = await createCliApiClient(flags);
|
|
32
|
+
const bot = await updateResource(client, '/v1/bots', args.id, payload);
|
|
33
|
+
if (!flags.quiet)
|
|
34
|
+
this.log(this.toFormatted(bot));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class BroadcastCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
channel: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
segment: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
target: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, 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
|
+
'template-id': import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'send-status': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'auto-approve': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
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,117 @@
|
|
|
1
|
+
import { 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
|
+
import { createBroadcastPayload } from '../../send/payload.js';
|
|
6
|
+
import { parseSendAt } from '../../send/schedule.js';
|
|
7
|
+
import { prepareMediaFiles } from '../../send/media.js';
|
|
8
|
+
export default class BroadcastCreate extends BaseCommand {
|
|
9
|
+
static description = 'Create a broadcast for channels or segments';
|
|
10
|
+
static flags = {
|
|
11
|
+
...BaseCommand.baseFlags,
|
|
12
|
+
channel: Flags.integer({
|
|
13
|
+
description: 'Channel ID target',
|
|
14
|
+
}),
|
|
15
|
+
segment: Flags.integer({
|
|
16
|
+
description: 'Segment ID within --channel',
|
|
17
|
+
}),
|
|
18
|
+
target: Flags.string({
|
|
19
|
+
description: 'Target as channelId or channelId:segmentId; may be repeated',
|
|
20
|
+
multiple: true,
|
|
21
|
+
}),
|
|
22
|
+
text: Flags.string({
|
|
23
|
+
description: 'Broadcast message text',
|
|
24
|
+
required: true,
|
|
25
|
+
}),
|
|
26
|
+
'send-at': Flags.string({
|
|
27
|
+
description: 'Schedule send for an ISO-8601 date-time',
|
|
28
|
+
}),
|
|
29
|
+
'dry-run': Flags.boolean({
|
|
30
|
+
description: 'Validate and print the broadcast payload without mutating API calls',
|
|
31
|
+
default: false,
|
|
32
|
+
}),
|
|
33
|
+
'idempotency-key': Flags.string({
|
|
34
|
+
description: 'Idempotency key forwarded as Idempotency-Key',
|
|
35
|
+
}),
|
|
36
|
+
media: Flags.string({
|
|
37
|
+
description: 'Media file path to upload',
|
|
38
|
+
multiple: true,
|
|
39
|
+
}),
|
|
40
|
+
'template-id': Flags.integer({
|
|
41
|
+
description: 'WhatsApp template ID',
|
|
42
|
+
}),
|
|
43
|
+
'send-status': Flags.string({
|
|
44
|
+
description: 'Initial broadcast send status',
|
|
45
|
+
options: ['draft', 'scheduled', 'sending'],
|
|
46
|
+
default: 'draft',
|
|
47
|
+
}),
|
|
48
|
+
'auto-approve': Flags.boolean({
|
|
49
|
+
description: 'Auto-approve broadcast when allowed by API permissions',
|
|
50
|
+
default: false,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
async run() {
|
|
54
|
+
const { flags } = await this.parse(BroadcastCreate);
|
|
55
|
+
this.flags = flags;
|
|
56
|
+
const targets = parseTargets(flags.target);
|
|
57
|
+
if (targets.length > 0 && (flags.channel || flags.segment)) {
|
|
58
|
+
throw new ApiError('user_error', '--target cannot be combined with --channel or --segment');
|
|
59
|
+
}
|
|
60
|
+
if (targets.length === 0 && !flags.channel) {
|
|
61
|
+
throw new ApiError('user_error', 'Either --channel or --target is required');
|
|
62
|
+
}
|
|
63
|
+
if (flags.segment && !flags.channel) {
|
|
64
|
+
throw new ApiError('user_error', '--segment requires --channel');
|
|
65
|
+
}
|
|
66
|
+
const scheduledAt = parseSendAt(flags['send-at']);
|
|
67
|
+
const media = prepareMediaFiles(flags.media);
|
|
68
|
+
const payload = createBroadcastPayload({
|
|
69
|
+
channelId: targets.length === 0 ? flags.channel : undefined,
|
|
70
|
+
segmentId: targets.length === 0 ? flags.segment : undefined,
|
|
71
|
+
targets: targets.length > 0 ? targets : undefined,
|
|
72
|
+
text: flags.text,
|
|
73
|
+
scheduledAt,
|
|
74
|
+
templateId: flags['template-id'],
|
|
75
|
+
sendStatus: flags['send-status'],
|
|
76
|
+
autoApprove: flags['auto-approve'],
|
|
77
|
+
});
|
|
78
|
+
if (flags['dry-run']) {
|
|
79
|
+
if (!flags.quiet) {
|
|
80
|
+
this.log(this.toFormatted({
|
|
81
|
+
...payload,
|
|
82
|
+
targets,
|
|
83
|
+
media: media.map((file) => ({
|
|
84
|
+
filename: file.filename,
|
|
85
|
+
contentType: file.contentType,
|
|
86
|
+
})),
|
|
87
|
+
idempotencyKey: flags['idempotency-key'],
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const client = await createCliApiClient(flags);
|
|
93
|
+
const headers = flags['idempotency-key']
|
|
94
|
+
? { 'Idempotency-Key': flags['idempotency-key'] }
|
|
95
|
+
: undefined;
|
|
96
|
+
const response = media.length > 0
|
|
97
|
+
? await client.postMultipart('/v1/broadcasts', payload, media, { headers })
|
|
98
|
+
: await client.post('/v1/broadcasts', payload, { headers });
|
|
99
|
+
if (!flags.quiet) {
|
|
100
|
+
this.log(this.toFormatted(response));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function parseTargets(values) {
|
|
105
|
+
return (values ?? []).map((value) => {
|
|
106
|
+
const [channelRaw, segmentRaw] = value.split(':');
|
|
107
|
+
const channelId = Number(channelRaw);
|
|
108
|
+
const segmentId = segmentRaw ? Number(segmentRaw) : undefined;
|
|
109
|
+
if (!Number.isInteger(channelId) || channelId < 1) {
|
|
110
|
+
throw new ApiError('user_error', `Invalid --target channel: ${value}`);
|
|
111
|
+
}
|
|
112
|
+
if (segmentRaw && (!Number.isInteger(segmentId) || (segmentId ?? 0) < 1)) {
|
|
113
|
+
throw new ApiError('user_error', `Invalid --target segment: ${value}`);
|
|
114
|
+
}
|
|
115
|
+
return segmentId ? { channelId, segmentId } : { channelId };
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseCommand } from '../../base-command.js';
|
|
2
|
+
export default class ChannelsCreate extends BaseCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
+
'gateway-type': import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
status: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
data: import("@oclif/core/interfaces").OptionFlag<string | 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
|
+
}
|