@myapihq/cli 1.0.16 → 1.0.18
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/dist/commands/billing.js +26 -32
- package/dist/commands/config.js +20 -26
- package/dist/commands/domain.js +56 -67
- package/dist/commands/email.d.ts +1 -0
- package/dist/commands/email.js +90 -88
- package/dist/commands/funnel.js +43 -52
- package/dist/commands/image.d.ts +2 -0
- package/dist/commands/image.js +61 -22
- package/dist/commands/keys.js +22 -60
- package/dist/commands/org.js +37 -44
- package/dist/commands/pixel.d.ts +3 -0
- package/dist/commands/pixel.js +64 -0
- package/dist/commands/setup.js +13 -49
- package/dist/commands/storage.d.ts +1 -0
- package/dist/commands/storage.js +50 -31
- package/dist/commands/url.d.ts +2 -0
- package/dist/commands/url.js +29 -0
- package/dist/commands/webhook.d.ts +2 -0
- package/dist/commands/webhook.js +64 -24
- package/dist/commands/workflow.d.ts +2 -0
- package/dist/commands/workflow.js +93 -43
- package/dist/config.d.ts +1 -0
- package/dist/config.js +19 -49
- package/dist/index.js +75 -56
- package/dist/output.js +5 -12
- package/dist/utils.js +2 -6
- package/package.json +7 -2
- package/src/commands/email.ts +14 -4
- package/src/commands/image.ts +47 -7
- package/src/commands/pixel.ts +62 -0
- package/src/commands/storage.ts +37 -13
- package/src/commands/url.ts +28 -0
- package/src/commands/webhook.ts +50 -9
- package/src/commands/workflow.ts +67 -19
- package/src/config.ts +17 -5
- package/src/index.ts +59 -1
package/dist/commands/billing.js
CHANGED
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.topup = topup;
|
|
6
|
-
exports.setup = setup;
|
|
7
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
8
|
-
const config_js_1 = require("../config.js");
|
|
9
|
-
const output_js_1 = require("../output.js");
|
|
10
|
-
async function balance(flags) {
|
|
1
|
+
import { hq } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable, info, printJson } from '../output.js';
|
|
4
|
+
export async function balance(flags) {
|
|
11
5
|
if (flags.help) {
|
|
12
|
-
|
|
6
|
+
info('Usage: myapi billing balance\n\nShows your current account balance, credits, and payment method status.');
|
|
13
7
|
return;
|
|
14
8
|
}
|
|
15
|
-
const config =
|
|
16
|
-
const result = await
|
|
9
|
+
const config = requireConfig();
|
|
10
|
+
const result = await hq.getBalance(config.api_key);
|
|
17
11
|
const bal = result.balance_display || `$${(result.balance_cents / 100).toFixed(2)}`;
|
|
18
12
|
const cred = result.credits_display || `$${((result.credits_cents || 0) / 100).toFixed(2)}`;
|
|
19
13
|
const pm = result.has_payment_method ? 'yes' : 'no';
|
|
20
|
-
|
|
14
|
+
info(`Balance: ${bal} | Credits: ${cred} | Payment method: ${pm}`);
|
|
21
15
|
}
|
|
22
|
-
async function history(flags) {
|
|
16
|
+
export async function history(flags) {
|
|
23
17
|
if (flags.help) {
|
|
24
|
-
|
|
18
|
+
info('Usage: myapi billing history [--json]\n\nShows your recent billing transactions and top-ups.');
|
|
25
19
|
return;
|
|
26
20
|
}
|
|
27
|
-
const config =
|
|
28
|
-
const items = await
|
|
21
|
+
const config = requireConfig();
|
|
22
|
+
const items = await hq.getBillingHistory(config.api_key);
|
|
29
23
|
if (flags.json) {
|
|
30
|
-
|
|
24
|
+
printJson(items);
|
|
31
25
|
return;
|
|
32
26
|
}
|
|
33
27
|
const formattedItems = items.map(item => {
|
|
@@ -46,32 +40,32 @@ async function history(flags) {
|
|
|
46
40
|
Date: dateStr
|
|
47
41
|
};
|
|
48
42
|
});
|
|
49
|
-
|
|
43
|
+
printTable(formattedItems);
|
|
50
44
|
}
|
|
51
|
-
async function topup(amountStr, flags) {
|
|
45
|
+
export async function topup(amountStr, flags) {
|
|
52
46
|
if (flags.help) {
|
|
53
|
-
|
|
47
|
+
info('Usage: myapi billing topup <amount_in_dollars>\n\nAdds funds to your account balance using your saved payment method.\nExample: myapi billing topup 10.00');
|
|
54
48
|
return;
|
|
55
49
|
}
|
|
56
50
|
if (!amountStr) {
|
|
57
|
-
|
|
51
|
+
error("Missing amount. Usage: myapi billing topup <amount_in_dollars>");
|
|
58
52
|
return;
|
|
59
53
|
}
|
|
60
54
|
const amount = parseFloat(amountStr);
|
|
61
55
|
if (isNaN(amount)) {
|
|
62
|
-
|
|
56
|
+
error("Invalid amount. Must be a number in dollars (e.g., 10.00)");
|
|
63
57
|
return;
|
|
64
58
|
}
|
|
65
|
-
const config =
|
|
66
|
-
const result = await
|
|
67
|
-
|
|
59
|
+
const config = requireConfig();
|
|
60
|
+
const result = await hq.topUp(config.api_key, Math.round(amount * 100));
|
|
61
|
+
success(`Top up successful! New balance: $${(result.new_balance_cents / 100).toFixed(2)}`);
|
|
68
62
|
}
|
|
69
|
-
async function setup(flags) {
|
|
63
|
+
export async function setup(flags) {
|
|
70
64
|
if (flags.help) {
|
|
71
|
-
|
|
65
|
+
info('Usage: myapi billing setup\n\nGenerates a secure checkout link to add or update your payment method.');
|
|
72
66
|
return;
|
|
73
67
|
}
|
|
74
|
-
const config =
|
|
75
|
-
const result = await
|
|
76
|
-
|
|
68
|
+
const config = requireConfig();
|
|
69
|
+
const result = await hq.setupPayment(config.api_key);
|
|
70
|
+
success(`Open this URL in your browser to set up payment:\n${result.url}`);
|
|
77
71
|
}
|
package/dist/commands/config.js
CHANGED
|
@@ -1,43 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.setDomain = setDomain;
|
|
5
|
-
exports.view = view;
|
|
6
|
-
exports.run = run;
|
|
7
|
-
const config_js_1 = require("../config.js");
|
|
8
|
-
const output_js_1 = require("../output.js");
|
|
9
|
-
async function setOrg(id, flags) {
|
|
1
|
+
import { requireConfig, saveConfig } from '../config.js';
|
|
2
|
+
import { success, error, info } from '../output.js';
|
|
3
|
+
export async function setOrg(id, flags) {
|
|
10
4
|
if (!id || flags.help) {
|
|
11
|
-
|
|
5
|
+
info("Usage: myapi config set-org <id>\n\nSets a default organization ID for subsequent commands.");
|
|
12
6
|
return;
|
|
13
7
|
}
|
|
14
|
-
const config =
|
|
8
|
+
const config = requireConfig();
|
|
15
9
|
config.default_org = id;
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
saveConfig(config);
|
|
11
|
+
success(`Default organization set to: ${id}`);
|
|
18
12
|
}
|
|
19
|
-
async function setDomain(domain, flags) {
|
|
13
|
+
export async function setDomain(domain, flags) {
|
|
20
14
|
if (!domain || flags.help) {
|
|
21
|
-
|
|
15
|
+
info("Usage: myapi config set-domain <domain>\n\nSets a default domain for subsequent commands.");
|
|
22
16
|
return;
|
|
23
17
|
}
|
|
24
|
-
const config =
|
|
18
|
+
const config = requireConfig();
|
|
25
19
|
config.default_domain = domain;
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
saveConfig(config);
|
|
21
|
+
success(`Default domain set to: ${domain}`);
|
|
28
22
|
}
|
|
29
|
-
async function view(flags) {
|
|
23
|
+
export async function view(flags) {
|
|
30
24
|
if (flags.help) {
|
|
31
|
-
|
|
25
|
+
info("Usage: myapi config view\n\nViews current config settings.");
|
|
32
26
|
return;
|
|
33
27
|
}
|
|
34
|
-
const config =
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
const config = requireConfig();
|
|
29
|
+
info(`Default Org: ${config.default_org || 'Not set'}`);
|
|
30
|
+
info(`Default Domain: ${config.default_domain || 'Not set'}`);
|
|
37
31
|
}
|
|
38
|
-
async function run(subcommand, args, flags) {
|
|
32
|
+
export async function run(subcommand, args, flags) {
|
|
39
33
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
40
|
-
|
|
34
|
+
info('Usage: myapi config <subcommand>\n\nSubcommands:\n view View current config\n set-org Set default organization\n set-domain Set default domain');
|
|
41
35
|
return;
|
|
42
36
|
}
|
|
43
37
|
if (subcommand === 'view')
|
|
@@ -47,5 +41,5 @@ async function run(subcommand, args, flags) {
|
|
|
47
41
|
else if (subcommand === 'set-domain')
|
|
48
42
|
await setDomain(args[0], flags);
|
|
49
43
|
else
|
|
50
|
-
|
|
44
|
+
error(`Unknown subcommand: ${subcommand}. Run "myapi config --help" for a list of valid subcommands.`);
|
|
51
45
|
}
|
package/dist/commands/domain.js
CHANGED
|
@@ -1,100 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.list = list;
|
|
7
|
-
exports.assign = assign;
|
|
8
|
-
exports.unassign = unassign;
|
|
9
|
-
exports.settings = settings;
|
|
10
|
-
exports.updateSettings = updateSettings;
|
|
11
|
-
exports.run = run;
|
|
12
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
13
|
-
const config_js_1 = require("../config.js");
|
|
14
|
-
const output_js_1 = require("../output.js");
|
|
15
|
-
async function check(domainArg, flags) {
|
|
16
|
-
const config = (0, config_js_1.requireConfig)();
|
|
1
|
+
import { domain as sdkDomain } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, info, printTable, printJson } from '../output.js';
|
|
4
|
+
export async function check(domainArg, flags) {
|
|
5
|
+
const config = requireConfig();
|
|
17
6
|
const orgId = flags.org || config.default_org;
|
|
18
7
|
const domain = domainArg || config.default_domain;
|
|
19
8
|
if (!orgId || !domain)
|
|
20
|
-
|
|
21
|
-
const res = await
|
|
9
|
+
error("Missing required arguments.\nUsage: myapi domain check <domain> --org <id>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
10
|
+
const res = await sdkDomain.checkDomain(config.api_key, orgId, domain);
|
|
22
11
|
if (res.available) {
|
|
23
|
-
|
|
12
|
+
info(`${domain} — Available ✓ Price: $${(res.price_cents / 100).toFixed(2)}/yr`);
|
|
24
13
|
}
|
|
25
14
|
else {
|
|
26
|
-
|
|
15
|
+
info(`Not available ✗`);
|
|
27
16
|
}
|
|
28
17
|
}
|
|
29
|
-
async function register(domainArg, flags) {
|
|
30
|
-
const config =
|
|
18
|
+
export async function register(domainArg, flags) {
|
|
19
|
+
const config = requireConfig();
|
|
31
20
|
const orgId = flags.org || config.default_org;
|
|
32
21
|
const domain = domainArg || config.default_domain;
|
|
33
22
|
if (!orgId || !domain)
|
|
34
|
-
|
|
23
|
+
error("Missing required arguments.\nUsage: myapi domain register <domain> --org <id> [--years <num>]\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
35
24
|
const years = parseInt(flags.years) || 1;
|
|
36
|
-
const res = await
|
|
37
|
-
|
|
25
|
+
const res = await sdkDomain.registerDomain(config.api_key, orgId, domain, years);
|
|
26
|
+
success(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
38
27
|
}
|
|
39
|
-
async function importDomain(domainArg, flags) {
|
|
40
|
-
const config =
|
|
28
|
+
export async function importDomain(domainArg, flags) {
|
|
29
|
+
const config = requireConfig();
|
|
41
30
|
const orgId = flags.org || config.default_org;
|
|
42
31
|
const domain = domainArg || config.default_domain;
|
|
43
32
|
if (!orgId || !domain)
|
|
44
|
-
|
|
33
|
+
error("Missing required arguments.\nUsage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
45
34
|
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
46
|
-
|
|
35
|
+
error("Missing required arguments.\nUsage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>");
|
|
47
36
|
}
|
|
48
|
-
await
|
|
37
|
+
await sdkDomain.importDomain(config.api_key, orgId, {
|
|
49
38
|
domain,
|
|
50
39
|
namecheap_api_user: flags['namecheap-user'],
|
|
51
40
|
namecheap_api_key: flags['namecheap-key']
|
|
52
41
|
});
|
|
53
|
-
|
|
42
|
+
success(`Imported ${domain}`);
|
|
54
43
|
}
|
|
55
|
-
async function list(flags) {
|
|
56
|
-
const config =
|
|
44
|
+
export async function list(flags) {
|
|
45
|
+
const config = requireConfig();
|
|
57
46
|
const orgId = flags.org || config.default_org;
|
|
58
47
|
if (!orgId)
|
|
59
|
-
|
|
48
|
+
error("Missing required arguments.\nUsage: myapi domain list --org <id> [--filter=all|unassigned|org]\n(Or set a default org via: myapi config set-org <id>)");
|
|
60
49
|
const filter = flags.filter;
|
|
61
|
-
const domains = await
|
|
62
|
-
|
|
50
|
+
const domains = await sdkDomain.listDomains(config.api_key, orgId, filter);
|
|
51
|
+
printTable(domains);
|
|
63
52
|
}
|
|
64
|
-
async function assign(domainArg, flags) {
|
|
65
|
-
const config =
|
|
53
|
+
export async function assign(domainArg, flags) {
|
|
54
|
+
const config = requireConfig();
|
|
66
55
|
const orgId = flags.org || config.default_org;
|
|
67
56
|
const domain = domainArg || config.default_domain;
|
|
68
57
|
const targetOrgId = flags.target;
|
|
69
58
|
if (!orgId || !domain || !targetOrgId)
|
|
70
|
-
|
|
71
|
-
const res = await
|
|
72
|
-
|
|
59
|
+
error("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id> --target <target_org_id>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
60
|
+
const res = await sdkDomain.assignDomain(config.api_key, orgId, domain, targetOrgId);
|
|
61
|
+
success(`Assigned ${domain} to org ${targetOrgId}`);
|
|
73
62
|
}
|
|
74
|
-
async function unassign(domainArg, flags) {
|
|
75
|
-
const config =
|
|
63
|
+
export async function unassign(domainArg, flags) {
|
|
64
|
+
const config = requireConfig();
|
|
76
65
|
const orgId = flags.org || config.default_org;
|
|
77
66
|
const domain = domainArg || config.default_domain;
|
|
78
67
|
if (!orgId || !domain)
|
|
79
|
-
|
|
80
|
-
const res = await
|
|
81
|
-
|
|
68
|
+
error("Missing required arguments.\nUsage: myapi domain unassign <domain> --org <id>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
69
|
+
const res = await sdkDomain.unassignDomain(config.api_key, orgId, domain);
|
|
70
|
+
success(`Unassigned ${domain} from org ${orgId}`);
|
|
82
71
|
}
|
|
83
|
-
async function settings(domainArg, flags) {
|
|
84
|
-
const config =
|
|
72
|
+
export async function settings(domainArg, flags) {
|
|
73
|
+
const config = requireConfig();
|
|
85
74
|
const orgId = flags.org || config.default_org;
|
|
86
75
|
const domain = domainArg || config.default_domain;
|
|
87
76
|
if (!orgId || !domain)
|
|
88
|
-
|
|
89
|
-
const res = await
|
|
90
|
-
|
|
77
|
+
error("Missing required arguments.\nUsage: myapi domain settings <domain> --org <id>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
78
|
+
const res = await sdkDomain.getDomainSettings(config.api_key, orgId, domain);
|
|
79
|
+
printJson(res);
|
|
91
80
|
}
|
|
92
|
-
async function updateSettings(domainArg, flags) {
|
|
93
|
-
const config =
|
|
81
|
+
export async function updateSettings(domainArg, flags) {
|
|
82
|
+
const config = requireConfig();
|
|
94
83
|
const orgId = flags.org || config.default_org;
|
|
95
84
|
const domain = domainArg || config.default_domain;
|
|
96
85
|
if (!orgId || !domain)
|
|
97
|
-
|
|
86
|
+
error("Missing required arguments.\nUsage: myapi domain update-settings <domain> --org <id> [--security=...] [--browser-check=...] [--purge-cache]\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
98
87
|
const payload = {};
|
|
99
88
|
if (flags.security)
|
|
100
89
|
payload.security_level = flags.security;
|
|
@@ -102,31 +91,31 @@ async function updateSettings(domainArg, flags) {
|
|
|
102
91
|
payload.browser_check = flags['browser-check'];
|
|
103
92
|
if (flags['purge-cache'])
|
|
104
93
|
payload.purge_cache = true;
|
|
105
|
-
const res = await
|
|
106
|
-
|
|
94
|
+
const res = await sdkDomain.updateDomainSettings(config.api_key, orgId, domain, payload);
|
|
95
|
+
success(`Updated settings for ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
107
96
|
}
|
|
108
|
-
async function run(subcommand, args, flags) {
|
|
97
|
+
export async function run(subcommand, args, flags) {
|
|
109
98
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
110
|
-
|
|
99
|
+
info('Usage: myapi domain <subcommand>\n\nSubcommands:\n list List domains\n check Check domain availability\n register Register a domain\n import Import an existing domain\n assign Assign domain to org\n unassign Unassign domain from its current org\n settings Get domain settings\n update-settings Update domain settings\n\nNote: All domain commands require the --org <id> flag.');
|
|
111
100
|
return;
|
|
112
101
|
}
|
|
113
102
|
if (flags.help) {
|
|
114
103
|
if (subcommand === 'list')
|
|
115
|
-
|
|
104
|
+
info('Usage: myapi domain list --org <id> [--filter=all|unassigned|org]\n\nLists all registered domains in your account.\n --filter=all Lists all domains owned by the account.\n --filter=unassigned Lists domains not assigned to an org.\n --filter=org (Default) Lists domains assigned to the current org.');
|
|
116
105
|
else if (subcommand === 'check')
|
|
117
|
-
|
|
106
|
+
info('Usage: myapi domain check <domain> --org <id>\n\nChecks if a domain name is available for registration.');
|
|
118
107
|
else if (subcommand === 'register')
|
|
119
|
-
|
|
108
|
+
info('Usage: myapi domain register <domain> --org <id> [--years <num>]\n\nRegisters a new domain name.');
|
|
120
109
|
else if (subcommand === 'import')
|
|
121
|
-
|
|
110
|
+
info('Usage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
122
111
|
else if (subcommand === 'assign')
|
|
123
|
-
|
|
112
|
+
info('Usage: myapi domain assign <domain> --org <id> --target <target_org_id>\n\nAssigns a domain to a different organization.');
|
|
124
113
|
else if (subcommand === 'unassign')
|
|
125
|
-
|
|
114
|
+
info('Usage: myapi domain unassign <domain> --org <id>\n\nUnassigns a domain from its current organization.');
|
|
126
115
|
else if (subcommand === 'settings')
|
|
127
|
-
|
|
116
|
+
info('Usage: myapi domain settings <domain> --org <id>\n\nGets the DNS settings and configuration for a domain.');
|
|
128
117
|
else if (subcommand === 'update-settings')
|
|
129
|
-
|
|
118
|
+
info('Usage: myapi domain update-settings <domain> --org <id> [--security=essentially_off|medium|high|under_attack] [--browser-check=on|off] [--purge-cache]\n\nUpdates edge settings for a domain.');
|
|
130
119
|
return;
|
|
131
120
|
}
|
|
132
121
|
if (subcommand === 'list')
|
|
@@ -146,5 +135,5 @@ async function run(subcommand, args, flags) {
|
|
|
146
135
|
else if (subcommand === 'update-settings')
|
|
147
136
|
await updateSettings(args[0], flags);
|
|
148
137
|
else
|
|
149
|
-
|
|
138
|
+
error(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
150
139
|
}
|
package/dist/commands/email.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare function send(flags: Record<string, string | boolean>): Promise<v
|
|
|
5
5
|
export declare function inbox(address: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
6
6
|
export declare function outbox(address: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
7
7
|
export declare function listTemplates(flags: Record<string, string | boolean>): Promise<void>;
|
|
8
|
+
export declare function deleteTemplate(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
8
9
|
export declare function generateTemplate(flags: Record<string, string | boolean>): Promise<void>;
|
|
9
10
|
export declare function listCampaigns(flags: Record<string, string | boolean>): Promise<void>;
|
|
10
11
|
export declare function campaignStats(id: string, flags: Record<string, string | boolean>): Promise<void>;
|