@1msg/cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +21 -0
- package/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/commands.d.ts +8 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +90 -0
- package/dist/commands.js.map +1 -0
- package/dist/completion.d.ts +11 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +205 -0
- package/dist/completion.js.map +1 -0
- package/dist/config.d.ts +37 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +185 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +30 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +111 -0
- package/dist/context.js.map +1 -0
- package/dist/dest.d.ts +27 -0
- package/dist/dest.d.ts.map +1 -0
- package/dist/dest.js +63 -0
- package/dist/dest.js.map +1 -0
- package/dist/errors.d.ts +34 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +133 -0
- package/dist/errors.js.map +1 -0
- package/dist/execute.d.ts +11 -0
- package/dist/execute.d.ts.map +1 -0
- package/dist/execute.js +89 -0
- package/dist/execute.js.map +1 -0
- package/dist/help-text.d.ts +3 -0
- package/dist/help-text.d.ts.map +1 -0
- package/dist/help-text.js +55 -0
- package/dist/help-text.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +14 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +128 -0
- package/dist/io.js.map +1 -0
- package/dist/local.d.ts +30 -0
- package/dist/local.d.ts.map +1 -0
- package/dist/local.js +247 -0
- package/dist/local.js.map +1 -0
- package/dist/output.d.ts +20 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +118 -0
- package/dist/output.js.map +1 -0
- package/dist/paths.d.ts +5 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +33 -0
- package/dist/paths.js.map +1 -0
- package/dist/program.d.ts +5 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +507 -0
- package/dist/program.js.map +1 -0
- package/dist/rest.d.ts +112 -0
- package/dist/rest.d.ts.map +1 -0
- package/dist/rest.js +549 -0
- package/dist/rest.js.map +1 -0
- package/dist/run.d.ts +3 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +33 -0
- package/dist/run.js.map +1 -0
- package/dist/send.d.ts +188 -0
- package/dist/send.d.ts.map +1 -0
- package/dist/send.js +498 -0
- package/dist/send.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/package.json +50 -0
package/dist/rest.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import type { CliContext } from './context';
|
|
3
|
+
export declare function handleChannelInfo(ctx: CliContext, cmd: Command): Promise<number>;
|
|
4
|
+
export declare function handleStatus(ctx: CliContext, cmd: Command): Promise<number>;
|
|
5
|
+
export declare function handleMe(ctx: CliContext, cmd: Command): Promise<number>;
|
|
6
|
+
export declare function handleMeUpdate(ctx: CliContext, cmd: Command, opts: {
|
|
7
|
+
about?: string;
|
|
8
|
+
address?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
email?: string;
|
|
11
|
+
vertical?: string;
|
|
12
|
+
photo?: string;
|
|
13
|
+
website?: string[];
|
|
14
|
+
}): Promise<number>;
|
|
15
|
+
export declare function handleChannelSettings(ctx: CliContext, cmd: Command): Promise<number>;
|
|
16
|
+
export declare function handleChannelSettingsSet(ctx: CliContext, cmd: Command, opts: Record<string, unknown>): Promise<number>;
|
|
17
|
+
export declare function handleMmLite(ctx: CliContext, cmd: Command): Promise<number>;
|
|
18
|
+
export declare function handleAutomation(ctx: CliContext, cmd: Command): Promise<number>;
|
|
19
|
+
export declare function handleAutomationSet(ctx: CliContext, cmd: Command, opts: {
|
|
20
|
+
welcome?: boolean;
|
|
21
|
+
noWelcome?: boolean;
|
|
22
|
+
prompt?: string[];
|
|
23
|
+
command?: string[];
|
|
24
|
+
}): Promise<number>;
|
|
25
|
+
export declare function handleWebhookGet(ctx: CliContext, cmd: Command): Promise<number>;
|
|
26
|
+
export declare function handleWebhookSet(ctx: CliContext, cmd: Command, opts: {
|
|
27
|
+
url?: string[];
|
|
28
|
+
}): Promise<number>;
|
|
29
|
+
export declare function handleWebhookClear(ctx: CliContext, cmd: Command): Promise<number>;
|
|
30
|
+
export declare function handleMediaUpload(ctx: CliContext, cmd: Command, opts: {
|
|
31
|
+
file?: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
}): Promise<number>;
|
|
34
|
+
export declare function handleMediaGet(ctx: CliContext, cmd: Command, opts: {
|
|
35
|
+
id?: string;
|
|
36
|
+
}): Promise<number>;
|
|
37
|
+
export declare function handleMediaDelete(ctx: CliContext, cmd: Command, opts: {
|
|
38
|
+
id?: string;
|
|
39
|
+
}): Promise<number>;
|
|
40
|
+
export declare function handleUserBlocked(ctx: CliContext, cmd: Command): Promise<number>;
|
|
41
|
+
export declare function handleUserBlock(ctx: CliContext, cmd: Command, opts: {
|
|
42
|
+
to?: string;
|
|
43
|
+
}, action: 'block' | 'unblock'): Promise<number>;
|
|
44
|
+
export declare function handleCatalogGet(ctx: CliContext, cmd: Command): Promise<number>;
|
|
45
|
+
export declare function handleCatalogSet(ctx: CliContext, cmd: Command, opts: {
|
|
46
|
+
cart?: boolean;
|
|
47
|
+
noCart?: boolean;
|
|
48
|
+
visible?: boolean;
|
|
49
|
+
noVisible?: boolean;
|
|
50
|
+
}): Promise<number>;
|
|
51
|
+
export declare function handleGroupList(ctx: CliContext, cmd: Command, opts: {
|
|
52
|
+
limit?: string;
|
|
53
|
+
before?: string;
|
|
54
|
+
after?: string;
|
|
55
|
+
}): Promise<number>;
|
|
56
|
+
export declare function handleGroupCreate(ctx: CliContext, cmd: Command, opts: {
|
|
57
|
+
name?: string;
|
|
58
|
+
description?: string;
|
|
59
|
+
}): Promise<number>;
|
|
60
|
+
export declare function handleGroupGet(ctx: CliContext, cmd: Command, id: string | undefined, opts: {
|
|
61
|
+
fields?: string;
|
|
62
|
+
}): Promise<number>;
|
|
63
|
+
export declare function handleGroupUpdate(ctx: CliContext, cmd: Command, id: string | undefined, opts: {
|
|
64
|
+
subject?: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
picture?: string;
|
|
67
|
+
}): Promise<number>;
|
|
68
|
+
export declare function handleGroupDelete(ctx: CliContext, cmd: Command, id: string | undefined): Promise<number>;
|
|
69
|
+
export declare function handleGroupInviteLink(ctx: CliContext, cmd: Command, id: string | undefined, reset: boolean): Promise<number>;
|
|
70
|
+
export declare function handleFlowList(ctx: CliContext, cmd: Command, opts: {
|
|
71
|
+
wabaAccountId?: string;
|
|
72
|
+
fields?: string;
|
|
73
|
+
}): Promise<number>;
|
|
74
|
+
export declare function handleFlowCreate(ctx: CliContext, cmd: Command, opts: {
|
|
75
|
+
name?: string;
|
|
76
|
+
category?: string[];
|
|
77
|
+
endpoint?: string;
|
|
78
|
+
publish?: boolean;
|
|
79
|
+
jsonFile?: string;
|
|
80
|
+
wabaAccountId?: string;
|
|
81
|
+
}): Promise<number>;
|
|
82
|
+
export declare function handleFlowIdOp(ctx: CliContext, cmd: Command, id: string | undefined, kind: 'get' | 'delete' | 'preview' | 'publish' | 'deprecate', opts: {
|
|
83
|
+
wabaAccountId?: string;
|
|
84
|
+
}): Promise<number>;
|
|
85
|
+
export declare function handleFlowMetadata(ctx: CliContext, cmd: Command, id: string | undefined, opts: {
|
|
86
|
+
name?: string;
|
|
87
|
+
category?: string[];
|
|
88
|
+
endpoint?: string;
|
|
89
|
+
wabaAccountId?: string;
|
|
90
|
+
}): Promise<number>;
|
|
91
|
+
export declare function handleFlowAssets(ctx: CliContext, cmd: Command, id: string | undefined, opts: {
|
|
92
|
+
jsonFile?: string;
|
|
93
|
+
wabaAccountId?: string;
|
|
94
|
+
}): Promise<number>;
|
|
95
|
+
export declare function handleFlowEncryption(ctx: CliContext, cmd: Command): Promise<number>;
|
|
96
|
+
export declare function handleFlowEncryptionSet(ctx: CliContext, cmd: Command, opts: {
|
|
97
|
+
pemFile?: string;
|
|
98
|
+
}): Promise<number>;
|
|
99
|
+
export declare function handleCallSettings(ctx: CliContext, cmd: Command): Promise<number>;
|
|
100
|
+
export declare function handleCallSettingsSet(ctx: CliContext, cmd: Command, opts: {
|
|
101
|
+
fromFile?: string;
|
|
102
|
+
}): Promise<number>;
|
|
103
|
+
export declare function handleCallConnect(ctx: CliContext, cmd: Command, opts: {
|
|
104
|
+
to?: string;
|
|
105
|
+
sdpFile?: string;
|
|
106
|
+
callbackData?: string;
|
|
107
|
+
}): Promise<number>;
|
|
108
|
+
export declare function handleCallControl(ctx: CliContext, cmd: Command, action: 'pre_accept' | 'accept' | 'reject' | 'terminate', opts: {
|
|
109
|
+
callId?: string;
|
|
110
|
+
sdpFile?: string;
|
|
111
|
+
}): Promise<number>;
|
|
112
|
+
//# sourceMappingURL=rest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA8B5C,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBtF;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAYjF;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CA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C,CAgBjB;AAED,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,UAAU,EACf,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,YAAY,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,EACxD,IAAI,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1C,OAAO,CAAC,MAAM,CAAC,CAiBjB"}
|
package/dist/rest.js
ADDED
|
@@ -0,0 +1,549 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleChannelInfo = handleChannelInfo;
|
|
4
|
+
exports.handleStatus = handleStatus;
|
|
5
|
+
exports.handleMe = handleMe;
|
|
6
|
+
exports.handleMeUpdate = handleMeUpdate;
|
|
7
|
+
exports.handleChannelSettings = handleChannelSettings;
|
|
8
|
+
exports.handleChannelSettingsSet = handleChannelSettingsSet;
|
|
9
|
+
exports.handleMmLite = handleMmLite;
|
|
10
|
+
exports.handleAutomation = handleAutomation;
|
|
11
|
+
exports.handleAutomationSet = handleAutomationSet;
|
|
12
|
+
exports.handleWebhookGet = handleWebhookGet;
|
|
13
|
+
exports.handleWebhookSet = handleWebhookSet;
|
|
14
|
+
exports.handleWebhookClear = handleWebhookClear;
|
|
15
|
+
exports.handleMediaUpload = handleMediaUpload;
|
|
16
|
+
exports.handleMediaGet = handleMediaGet;
|
|
17
|
+
exports.handleMediaDelete = handleMediaDelete;
|
|
18
|
+
exports.handleUserBlocked = handleUserBlocked;
|
|
19
|
+
exports.handleUserBlock = handleUserBlock;
|
|
20
|
+
exports.handleCatalogGet = handleCatalogGet;
|
|
21
|
+
exports.handleCatalogSet = handleCatalogSet;
|
|
22
|
+
exports.handleGroupList = handleGroupList;
|
|
23
|
+
exports.handleGroupCreate = handleGroupCreate;
|
|
24
|
+
exports.handleGroupGet = handleGroupGet;
|
|
25
|
+
exports.handleGroupUpdate = handleGroupUpdate;
|
|
26
|
+
exports.handleGroupDelete = handleGroupDelete;
|
|
27
|
+
exports.handleGroupInviteLink = handleGroupInviteLink;
|
|
28
|
+
exports.handleFlowList = handleFlowList;
|
|
29
|
+
exports.handleFlowCreate = handleFlowCreate;
|
|
30
|
+
exports.handleFlowIdOp = handleFlowIdOp;
|
|
31
|
+
exports.handleFlowMetadata = handleFlowMetadata;
|
|
32
|
+
exports.handleFlowAssets = handleFlowAssets;
|
|
33
|
+
exports.handleFlowEncryption = handleFlowEncryption;
|
|
34
|
+
exports.handleFlowEncryptionSet = handleFlowEncryptionSet;
|
|
35
|
+
exports.handleCallSettings = handleCallSettings;
|
|
36
|
+
exports.handleCallSettingsSet = handleCallSettingsSet;
|
|
37
|
+
exports.handleCallConnect = handleCallConnect;
|
|
38
|
+
exports.handleCallControl = handleCallControl;
|
|
39
|
+
const dest_1 = require("./dest");
|
|
40
|
+
const errors_1 = require("./errors");
|
|
41
|
+
const execute_1 = require("./execute");
|
|
42
|
+
const io_1 = require("./io");
|
|
43
|
+
const local_1 = require("./local");
|
|
44
|
+
const output_1 = require("./output");
|
|
45
|
+
function settingsApi(client) {
|
|
46
|
+
return client.channel;
|
|
47
|
+
}
|
|
48
|
+
/** Commander dual `--foo` / `--no-foo` share one boolean; omitted stays undefined. */
|
|
49
|
+
function dualBool(value, negated) {
|
|
50
|
+
if (negated === true)
|
|
51
|
+
return false;
|
|
52
|
+
if (value === true)
|
|
53
|
+
return true;
|
|
54
|
+
if (value === false)
|
|
55
|
+
return false;
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
async function handleChannelInfo(ctx, cmd) {
|
|
59
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
60
|
+
const status = await (0, execute_1.withClient)(ctx, flags, (client) => client.channel.getStatus(client.config.token));
|
|
61
|
+
const me = await (0, execute_1.withClient)(ctx, flags, (client) => client.profile.getMe(client.config.token));
|
|
62
|
+
const combined = { status, me };
|
|
63
|
+
(0, execute_1.printApiResult)(ctx, flags, combined, () => {
|
|
64
|
+
const s = (0, output_1.asRecord)(status);
|
|
65
|
+
const m = (0, output_1.asRecord)(me);
|
|
66
|
+
(0, output_1.printKv)(ctx.stdout, [
|
|
67
|
+
['status', s.status],
|
|
68
|
+
['accountStatus', s.accountStatus],
|
|
69
|
+
['mm_lite_available', s.mm_lite_available],
|
|
70
|
+
...Object.entries(m).filter(([key]) => key !== 'token'),
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
return (0, execute_1.ok)();
|
|
74
|
+
}
|
|
75
|
+
async function handleStatus(ctx, cmd) {
|
|
76
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
77
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.channel.getStatus(client.config.token));
|
|
78
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
79
|
+
const rec = (0, output_1.asRecord)(body);
|
|
80
|
+
(0, output_1.printKv)(ctx.stdout, [
|
|
81
|
+
['status', rec.status],
|
|
82
|
+
['accountStatus', rec.accountStatus],
|
|
83
|
+
['mm_lite_available', rec.mm_lite_available],
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
return (0, execute_1.ok)();
|
|
87
|
+
}
|
|
88
|
+
async function handleMe(ctx, cmd) {
|
|
89
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
90
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.profile.getMe(client.config.token));
|
|
91
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
92
|
+
(0, output_1.printKv)(ctx.stdout, Object.entries((0, output_1.asRecord)(body)));
|
|
93
|
+
});
|
|
94
|
+
return (0, execute_1.ok)();
|
|
95
|
+
}
|
|
96
|
+
async function handleMeUpdate(ctx, cmd, opts) {
|
|
97
|
+
const payload = {};
|
|
98
|
+
if (opts.about !== undefined)
|
|
99
|
+
payload.about = opts.about;
|
|
100
|
+
if (opts.address !== undefined)
|
|
101
|
+
payload.address = opts.address;
|
|
102
|
+
if (opts.description !== undefined)
|
|
103
|
+
payload.description = opts.description;
|
|
104
|
+
if (opts.email !== undefined)
|
|
105
|
+
payload.email = opts.email;
|
|
106
|
+
if (opts.vertical !== undefined)
|
|
107
|
+
payload.vertical = opts.vertical;
|
|
108
|
+
if (opts.photo !== undefined)
|
|
109
|
+
payload.photo = opts.photo;
|
|
110
|
+
if (opts.website?.length)
|
|
111
|
+
payload.websites = opts.website;
|
|
112
|
+
if (Object.keys(payload).length === 0)
|
|
113
|
+
(0, errors_1.usage)('pass at least one flag', '1msg me --help');
|
|
114
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
115
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.profile.updateMe(client.config.token, payload));
|
|
116
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
117
|
+
return (0, execute_1.ok)();
|
|
118
|
+
}
|
|
119
|
+
async function handleChannelSettings(ctx, cmd) {
|
|
120
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
121
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => settingsApi(client).listSettings(client.config.token));
|
|
122
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
123
|
+
(0, output_1.printKv)(ctx.stdout, Object.entries((0, output_1.asRecord)(body)));
|
|
124
|
+
});
|
|
125
|
+
return (0, execute_1.ok)();
|
|
126
|
+
}
|
|
127
|
+
async function handleChannelSettingsSet(ctx, cmd, opts) {
|
|
128
|
+
const payload = {};
|
|
129
|
+
const urls = opts.webhookUrl;
|
|
130
|
+
if (urls && urls.length) {
|
|
131
|
+
if (urls.length > 5)
|
|
132
|
+
(0, errors_1.usage)('--webhook-url max 5', '1msg channel --help');
|
|
133
|
+
payload.webhookUrl = urls.length === 1 ? urls[0] : urls;
|
|
134
|
+
}
|
|
135
|
+
const guaranteed = dualBool(opts.guaranteedHooks, opts.noGuaranteedHooks);
|
|
136
|
+
if (guaranteed !== undefined)
|
|
137
|
+
payload.guaranteedHooks = guaranteed;
|
|
138
|
+
const ack = dualBool(opts.ackNotifications, opts.noAckNotifications);
|
|
139
|
+
if (ack !== undefined)
|
|
140
|
+
payload.ackNotificationsOn = ack;
|
|
141
|
+
const rawHooks = dualBool(opts.rawHooks, opts.noRawHooks);
|
|
142
|
+
if (rawHooks !== undefined)
|
|
143
|
+
payload.rawHooks = rawHooks;
|
|
144
|
+
const analytics = dualBool(opts.templateAnalytics, opts.noTemplateAnalytics);
|
|
145
|
+
if (analytics !== undefined)
|
|
146
|
+
payload.template_analytics_enabled = analytics;
|
|
147
|
+
const ctaOptOut = dualBool(opts.ctaTrackingOptOut, opts.noCtaTrackingOptOut);
|
|
148
|
+
if (ctaOptOut !== undefined)
|
|
149
|
+
payload.cta_url_link_tracking_opted_out = ctaOptOut;
|
|
150
|
+
if (Object.keys(payload).length === 0)
|
|
151
|
+
(0, errors_1.usage)('pass at least one settings flag', '1msg channel --help');
|
|
152
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
153
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => settingsApi(client).createSettings(client.config.token, payload));
|
|
154
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
155
|
+
return (0, execute_1.ok)();
|
|
156
|
+
}
|
|
157
|
+
async function handleMmLite(ctx, cmd) {
|
|
158
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
159
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.messaging.getMmLiteStatus(client.config.token));
|
|
160
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
161
|
+
return (0, execute_1.ok)();
|
|
162
|
+
}
|
|
163
|
+
async function handleAutomation(ctx, cmd) {
|
|
164
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
165
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.channel.getConversationalAutomation(client.config.token));
|
|
166
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
167
|
+
return (0, execute_1.ok)();
|
|
168
|
+
}
|
|
169
|
+
async function handleAutomationSet(ctx, cmd, opts) {
|
|
170
|
+
const payload = {};
|
|
171
|
+
const welcome = dualBool(opts.welcome, opts.noWelcome);
|
|
172
|
+
if (welcome !== undefined)
|
|
173
|
+
payload.enable_welcome_message = welcome;
|
|
174
|
+
if (opts.prompt?.length) {
|
|
175
|
+
if (opts.prompt.length > 4)
|
|
176
|
+
(0, errors_1.usage)('--prompt max 4', '1msg channel --help');
|
|
177
|
+
for (const p of opts.prompt) {
|
|
178
|
+
if (p.length > 80)
|
|
179
|
+
(0, errors_1.usage)('each --prompt must be ≤ 80 chars', '1msg channel --help');
|
|
180
|
+
}
|
|
181
|
+
payload.prompts = opts.prompt;
|
|
182
|
+
}
|
|
183
|
+
if (opts.command?.length) {
|
|
184
|
+
payload.commands = opts.command.map((raw) => {
|
|
185
|
+
const idx = raw.indexOf(':');
|
|
186
|
+
if (idx <= 0)
|
|
187
|
+
(0, errors_1.usage)('--command must be name:description', '1msg channel --help');
|
|
188
|
+
return { command_name: raw.slice(0, idx), command_description: raw.slice(idx + 1) };
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
if (Object.keys(payload).length === 0)
|
|
192
|
+
(0, errors_1.usage)('pass at least one automation flag', '1msg channel --help');
|
|
193
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
194
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.channel.setConversationalAutomation(client.config.token, payload));
|
|
195
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
196
|
+
return (0, execute_1.ok)();
|
|
197
|
+
}
|
|
198
|
+
async function handleWebhookGet(ctx, cmd) {
|
|
199
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
200
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.webhooks.getWebhook(client.config.token));
|
|
201
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
202
|
+
return (0, execute_1.ok)();
|
|
203
|
+
}
|
|
204
|
+
async function handleWebhookSet(ctx, cmd, opts) {
|
|
205
|
+
const urls = opts.url ?? [];
|
|
206
|
+
if (!urls.length)
|
|
207
|
+
(0, errors_1.usage)('--url is required', '1msg webhook --help');
|
|
208
|
+
if (urls.length > 5)
|
|
209
|
+
(0, errors_1.usage)('--url max 5', '1msg webhook --help');
|
|
210
|
+
const webhookUrl = urls.length === 1 ? urls[0] : urls;
|
|
211
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
212
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.webhooks.setWebhook(client.config.token, { webhookUrl }));
|
|
213
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
214
|
+
return (0, execute_1.ok)();
|
|
215
|
+
}
|
|
216
|
+
async function handleWebhookClear(ctx, cmd) {
|
|
217
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
218
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => settingsApi(client).createSettings(client.config.token, { webhookUrl: '' }));
|
|
219
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
220
|
+
return (0, execute_1.ok)();
|
|
221
|
+
}
|
|
222
|
+
async function handleMediaUpload(ctx, cmd, opts) {
|
|
223
|
+
if (Boolean(opts.file) === Boolean(opts.url))
|
|
224
|
+
(0, errors_1.usage)('pass exactly one of --file or --url', '1msg media --help');
|
|
225
|
+
let bodyField;
|
|
226
|
+
if (opts.url) {
|
|
227
|
+
bodyField = opts.url;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
const buf = (0, io_1.readBinaryFile)(ctx, opts.file);
|
|
231
|
+
bodyField = (0, io_1.fileToDataUri)(buf, (0, io_1.basenameOf)(opts.file));
|
|
232
|
+
}
|
|
233
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
234
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.messaging.createUploadMedia(client.config.token, {
|
|
235
|
+
body: bodyField,
|
|
236
|
+
url: opts.url,
|
|
237
|
+
}));
|
|
238
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
239
|
+
const rec = (0, output_1.asRecord)(body);
|
|
240
|
+
ctx.stdout.write(`${rec.mediaId ?? ''}\n`);
|
|
241
|
+
});
|
|
242
|
+
return (0, execute_1.ok)();
|
|
243
|
+
}
|
|
244
|
+
async function handleMediaGet(ctx, cmd, opts) {
|
|
245
|
+
if (!opts.id)
|
|
246
|
+
(0, errors_1.usage)('--id is required', '1msg media --help');
|
|
247
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
248
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.messaging.retrieveMedia(client.config.token, opts.id));
|
|
249
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
250
|
+
return (0, execute_1.ok)();
|
|
251
|
+
}
|
|
252
|
+
async function handleMediaDelete(ctx, cmd, opts) {
|
|
253
|
+
if (!opts.id)
|
|
254
|
+
(0, errors_1.usage)('--id is required', '1msg media --help');
|
|
255
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
256
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.messaging.deleteMedia(client.config.token, opts.id));
|
|
257
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
258
|
+
return (0, execute_1.ok)();
|
|
259
|
+
}
|
|
260
|
+
async function handleUserBlocked(ctx, cmd) {
|
|
261
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
262
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.users.listBlockedUsers(client.config.token));
|
|
263
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
264
|
+
const rec = (0, output_1.asRecord)(body);
|
|
265
|
+
const users = (0, output_1.asArray)(rec.blockedUsers ?? rec.users ?? rec.data);
|
|
266
|
+
const rows = users.map((item) => {
|
|
267
|
+
const row = (0, output_1.asRecord)(item);
|
|
268
|
+
return { phone: (0, output_1.pickString)(row, ['phone', 'wa_id', 'id']) || String(item) };
|
|
269
|
+
});
|
|
270
|
+
(0, output_1.printTable)(ctx.stdout, ctx.stderr, ['phone'], rows);
|
|
271
|
+
});
|
|
272
|
+
return (0, execute_1.ok)();
|
|
273
|
+
}
|
|
274
|
+
async function handleUserBlock(ctx, cmd, opts, action) {
|
|
275
|
+
if (!opts.to)
|
|
276
|
+
(0, errors_1.usage)('--to is required', '1msg user --help');
|
|
277
|
+
const phone = (0, dest_1.parsePhone)(opts.to);
|
|
278
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
279
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => action === 'block'
|
|
280
|
+
? client.users.blockUser(client.config.token, { phone })
|
|
281
|
+
: client.users.unblockUser(client.config.token, { phone }));
|
|
282
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
283
|
+
return (0, execute_1.ok)();
|
|
284
|
+
}
|
|
285
|
+
async function handleCatalogGet(ctx, cmd) {
|
|
286
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
287
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.catalog.getCommerce(client.config.token));
|
|
288
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
289
|
+
const items = Array.isArray(body) ? body : (0, output_1.asArray)((0, output_1.asRecord)(body).data);
|
|
290
|
+
const rows = items.map((item) => {
|
|
291
|
+
const row = (0, output_1.asRecord)(item);
|
|
292
|
+
return {
|
|
293
|
+
id: (0, output_1.pickString)(row, ['id']),
|
|
294
|
+
cart: String(row.is_cart_enabled === true),
|
|
295
|
+
visible: String(row.is_catalog_visible === true),
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
(0, output_1.printTable)(ctx.stdout, ctx.stderr, ['id', 'cart', 'visible'], rows);
|
|
299
|
+
});
|
|
300
|
+
return (0, execute_1.ok)();
|
|
301
|
+
}
|
|
302
|
+
async function handleCatalogSet(ctx, cmd, opts) {
|
|
303
|
+
const cart = dualBool(opts.cart, opts.noCart);
|
|
304
|
+
const visible = dualBool(opts.visible, opts.noVisible);
|
|
305
|
+
if (cart === undefined || visible === undefined) {
|
|
306
|
+
(0, errors_1.usage)('pass --cart/--no-cart and --visible/--no-visible', '1msg catalog --help');
|
|
307
|
+
}
|
|
308
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
309
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.catalog.createCommerce(client.config.token, {
|
|
310
|
+
params: { is_cart_enabled: cart, is_catalog_visible: visible },
|
|
311
|
+
}));
|
|
312
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
313
|
+
return (0, execute_1.ok)();
|
|
314
|
+
}
|
|
315
|
+
function groupId(raw, help) {
|
|
316
|
+
if (!raw)
|
|
317
|
+
(0, errors_1.usage)('missing group id', help);
|
|
318
|
+
return raw.replace(/@g\.us$/i, '');
|
|
319
|
+
}
|
|
320
|
+
async function handleGroupList(ctx, cmd, opts) {
|
|
321
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
322
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.groups.listGroups(client.config.token, (0, io_1.parseInteger)(opts.limit, '--limit'), opts.before, opts.after));
|
|
323
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
324
|
+
const rec = (0, output_1.asRecord)(body);
|
|
325
|
+
const groups = (0, output_1.asArray)(rec.groups ?? rec.data ?? rec.items);
|
|
326
|
+
const rows = groups.map((item) => {
|
|
327
|
+
const row = (0, output_1.asRecord)(item);
|
|
328
|
+
const id = (0, output_1.pickString)(row, ['id', 'groupId']).replace(/@g\.us$/i, '');
|
|
329
|
+
return { id, subject: (0, output_1.pickString)(row, ['subject', 'name', 'groupName']) };
|
|
330
|
+
});
|
|
331
|
+
(0, output_1.printTable)(ctx.stdout, ctx.stderr, ['id', 'subject'], rows);
|
|
332
|
+
});
|
|
333
|
+
return (0, execute_1.ok)();
|
|
334
|
+
}
|
|
335
|
+
async function handleGroupCreate(ctx, cmd, opts) {
|
|
336
|
+
if (!opts.name)
|
|
337
|
+
(0, errors_1.usage)('--name is required', '1msg group --help');
|
|
338
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
339
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.groups.createGroups(client.config.token, {
|
|
340
|
+
groupName: opts.name,
|
|
341
|
+
description: opts.description,
|
|
342
|
+
}));
|
|
343
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
344
|
+
return (0, execute_1.ok)();
|
|
345
|
+
}
|
|
346
|
+
async function handleGroupGet(ctx, cmd, id, opts) {
|
|
347
|
+
const gid = groupId(id, '1msg group --help');
|
|
348
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
349
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.groups.getGroupsGroupId(gid, client.config.token, opts.fields));
|
|
350
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
351
|
+
return (0, execute_1.ok)();
|
|
352
|
+
}
|
|
353
|
+
async function handleGroupUpdate(ctx, cmd, id, opts) {
|
|
354
|
+
const gid = groupId(id, '1msg group --help');
|
|
355
|
+
const payload = {};
|
|
356
|
+
if (opts.subject)
|
|
357
|
+
payload.subject = opts.subject;
|
|
358
|
+
if (opts.description)
|
|
359
|
+
payload.description = opts.description;
|
|
360
|
+
if (opts.picture)
|
|
361
|
+
payload.profile_picture_file = opts.picture;
|
|
362
|
+
if (!Object.keys(payload).length)
|
|
363
|
+
(0, errors_1.usage)('pass --subject, --description, or --picture', '1msg group --help');
|
|
364
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
365
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.groups.createGroupsGroupId(gid, client.config.token, payload));
|
|
366
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
367
|
+
return (0, execute_1.ok)();
|
|
368
|
+
}
|
|
369
|
+
async function handleGroupDelete(ctx, cmd, id) {
|
|
370
|
+
const gid = groupId(id, '1msg group --help');
|
|
371
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
372
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.groups.deleteGroupsGroupId(gid, client.config.token));
|
|
373
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
374
|
+
return (0, execute_1.ok)();
|
|
375
|
+
}
|
|
376
|
+
async function handleGroupInviteLink(ctx, cmd, id, reset) {
|
|
377
|
+
const gid = groupId(id, '1msg group --help');
|
|
378
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
379
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => reset
|
|
380
|
+
? client.groups.createGroupsGroupIdInvitelink(gid, client.config.token)
|
|
381
|
+
: client.groups.getGroupsGroupIdInvitelink(gid, client.config.token));
|
|
382
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
383
|
+
return (0, execute_1.ok)();
|
|
384
|
+
}
|
|
385
|
+
function waba(opts) {
|
|
386
|
+
return opts.wabaAccountId;
|
|
387
|
+
}
|
|
388
|
+
async function handleFlowList(ctx, cmd, opts) {
|
|
389
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
390
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.flows.listFlows(client.config.token, waba(opts), opts.fields));
|
|
391
|
+
(0, execute_1.printApiResult)(ctx, flags, body, () => {
|
|
392
|
+
const rec = (0, output_1.asRecord)(body);
|
|
393
|
+
const items = (0, output_1.asArray)(rec.items ?? rec.data ?? rec.flows);
|
|
394
|
+
const rows = items.map((item) => {
|
|
395
|
+
const row = (0, output_1.asRecord)(item);
|
|
396
|
+
const categories = row.categories;
|
|
397
|
+
return {
|
|
398
|
+
id: (0, output_1.pickString)(row, ['id']),
|
|
399
|
+
name: (0, output_1.pickString)(row, ['name']),
|
|
400
|
+
status: (0, output_1.pickString)(row, ['status']),
|
|
401
|
+
categories: Array.isArray(categories) ? categories.join(',') : String(categories ?? ''),
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
(0, output_1.printTable)(ctx.stdout, ctx.stderr, ['id', 'name', 'status', 'categories'], rows);
|
|
405
|
+
});
|
|
406
|
+
return (0, execute_1.ok)();
|
|
407
|
+
}
|
|
408
|
+
async function handleFlowCreate(ctx, cmd, opts) {
|
|
409
|
+
if (!opts.name)
|
|
410
|
+
(0, errors_1.usage)('--name is required', '1msg flow --help');
|
|
411
|
+
const categories = opts.category ?? [];
|
|
412
|
+
const payload = { name: opts.name, categories };
|
|
413
|
+
if (opts.endpoint)
|
|
414
|
+
payload.endpointUri = opts.endpoint;
|
|
415
|
+
if (opts.publish)
|
|
416
|
+
payload.publish = true;
|
|
417
|
+
if (opts.jsonFile) {
|
|
418
|
+
const raw = await (0, io_1.readFromFile)(ctx, opts.jsonFile);
|
|
419
|
+
payload.flowJson = JSON.parse(raw || '{}');
|
|
420
|
+
}
|
|
421
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
422
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.flows.createFlows(client.config.token, payload, waba(opts)));
|
|
423
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
424
|
+
return (0, execute_1.ok)();
|
|
425
|
+
}
|
|
426
|
+
async function handleFlowIdOp(ctx, cmd, id, kind, opts) {
|
|
427
|
+
if (!id)
|
|
428
|
+
(0, errors_1.usage)('missing flow id', '1msg flow --help');
|
|
429
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
430
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => {
|
|
431
|
+
const token = client.config.token;
|
|
432
|
+
const w = waba(opts);
|
|
433
|
+
switch (kind) {
|
|
434
|
+
case 'get':
|
|
435
|
+
return client.flows.getFlowsFlowId(id, token, w);
|
|
436
|
+
case 'delete':
|
|
437
|
+
return client.flows.deleteFlowsFlowId(id, token, w);
|
|
438
|
+
case 'preview':
|
|
439
|
+
return client.flows.getFlowsFlowIdPreview(id, token, w);
|
|
440
|
+
case 'publish':
|
|
441
|
+
return client.flows.createFlowsFlowIdPublish(id, token, w);
|
|
442
|
+
case 'deprecate':
|
|
443
|
+
return client.flows.createFlowsFlowIdDeprecate(id, token, w);
|
|
444
|
+
default:
|
|
445
|
+
(0, errors_1.usage)('unknown flow command', '1msg flow --help');
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
449
|
+
return (0, execute_1.ok)();
|
|
450
|
+
}
|
|
451
|
+
async function handleFlowMetadata(ctx, cmd, id, opts) {
|
|
452
|
+
if (!id)
|
|
453
|
+
(0, errors_1.usage)('missing flow id', '1msg flow --help');
|
|
454
|
+
const payload = {};
|
|
455
|
+
if (opts.name)
|
|
456
|
+
payload.name = opts.name;
|
|
457
|
+
if (opts.category?.length)
|
|
458
|
+
payload.categories = opts.category;
|
|
459
|
+
if (opts.endpoint)
|
|
460
|
+
payload.endpointUri = opts.endpoint;
|
|
461
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
462
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.flows.patchFlowsFlowIdMetadata(id, client.config.token, payload, waba(opts)));
|
|
463
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
464
|
+
return (0, execute_1.ok)();
|
|
465
|
+
}
|
|
466
|
+
async function handleFlowAssets(ctx, cmd, id, opts) {
|
|
467
|
+
if (!id)
|
|
468
|
+
(0, errors_1.usage)('missing flow id', '1msg flow --help');
|
|
469
|
+
if (!opts.jsonFile)
|
|
470
|
+
(0, errors_1.usage)('--json-file is required', '1msg flow --help');
|
|
471
|
+
const raw = await (0, io_1.readFromFile)(ctx, opts.jsonFile);
|
|
472
|
+
const flowJson = JSON.parse(raw || '{}');
|
|
473
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
474
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.flows.patchFlowsFlowIdAssets(id, client.config.token, { flowJson }, waba(opts)));
|
|
475
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
476
|
+
return (0, execute_1.ok)();
|
|
477
|
+
}
|
|
478
|
+
async function handleFlowEncryption(ctx, cmd) {
|
|
479
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
480
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.flows.getWhatsappBusinessEncryption(client.config.token));
|
|
481
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
482
|
+
return (0, execute_1.ok)();
|
|
483
|
+
}
|
|
484
|
+
async function handleFlowEncryptionSet(ctx, cmd, opts) {
|
|
485
|
+
if (!opts.pemFile)
|
|
486
|
+
(0, errors_1.usage)('--pem-file is required', '1msg flow --help');
|
|
487
|
+
const pem = (await (0, io_1.readFromFile)(ctx, opts.pemFile)) ?? '';
|
|
488
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
489
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.flows.setWhatsappBusinessEncryption(client.config.token, {
|
|
490
|
+
business_public_key: pem,
|
|
491
|
+
}));
|
|
492
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
493
|
+
return (0, execute_1.ok)();
|
|
494
|
+
}
|
|
495
|
+
async function handleCallSettings(ctx, cmd) {
|
|
496
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
497
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.calling.getCallingSettings(client.config.token));
|
|
498
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
499
|
+
return (0, execute_1.ok)();
|
|
500
|
+
}
|
|
501
|
+
async function handleCallSettingsSet(ctx, cmd, opts) {
|
|
502
|
+
if (!opts.fromFile)
|
|
503
|
+
(0, errors_1.usage)('--from-file is required', '1msg call --help');
|
|
504
|
+
const payload = await (0, io_1.readJsonFile)(ctx, opts.fromFile);
|
|
505
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
506
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.calling.updateCallingSettings(client.config.token, payload));
|
|
507
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
508
|
+
return (0, execute_1.ok)();
|
|
509
|
+
}
|
|
510
|
+
async function readSdp(ctx, filePath, help) {
|
|
511
|
+
if (!filePath)
|
|
512
|
+
(0, errors_1.usage)('--sdp-file is required', help);
|
|
513
|
+
return (await (0, io_1.readFromFile)(ctx, filePath)) ?? '';
|
|
514
|
+
}
|
|
515
|
+
async function handleCallConnect(ctx, cmd, opts) {
|
|
516
|
+
if (!opts.to)
|
|
517
|
+
(0, errors_1.usage)('--to is required', '1msg call --help');
|
|
518
|
+
const sdp = await readSdp(ctx, opts.sdpFile, '1msg call --help');
|
|
519
|
+
const payload = {
|
|
520
|
+
messaging_product: 'whatsapp',
|
|
521
|
+
action: 'connect',
|
|
522
|
+
to: String((0, dest_1.parsePhone)(opts.to)),
|
|
523
|
+
session: { sdp_type: 'offer', sdp },
|
|
524
|
+
};
|
|
525
|
+
if (opts.callbackData)
|
|
526
|
+
payload.biz_opaque_callback_data = opts.callbackData;
|
|
527
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
528
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.calling.initiateCall(client.config.token, payload));
|
|
529
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
530
|
+
return (0, execute_1.ok)();
|
|
531
|
+
}
|
|
532
|
+
async function handleCallControl(ctx, cmd, action, opts) {
|
|
533
|
+
if (!opts.callId)
|
|
534
|
+
(0, errors_1.usage)('--call-id is required', '1msg call --help');
|
|
535
|
+
const payload = {
|
|
536
|
+
messaging_product: 'whatsapp',
|
|
537
|
+
action,
|
|
538
|
+
call_id: opts.callId,
|
|
539
|
+
};
|
|
540
|
+
if (action === 'pre_accept' || action === 'accept') {
|
|
541
|
+
const sdp = await readSdp(ctx, opts.sdpFile, '1msg call --help');
|
|
542
|
+
payload.session = { sdp_type: 'answer', sdp };
|
|
543
|
+
}
|
|
544
|
+
const flags = (0, local_1.globalsFrom)(cmd);
|
|
545
|
+
const body = await (0, execute_1.withClient)(ctx, flags, (client) => client.calling.initiateCall(client.config.token, payload));
|
|
546
|
+
(0, execute_1.printApiResult)(ctx, flags, body);
|
|
547
|
+
return (0, execute_1.ok)();
|
|
548
|
+
}
|
|
549
|
+
//# sourceMappingURL=rest.js.map
|