@myapihq/cli 1.0.11 → 1.0.12
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/domain.d.ts +3 -0
- package/dist/commands/domain.js +58 -19
- package/dist/commands/org.js +1 -1
- package/package.json +1 -1
- package/src/commands/domain.ts +43 -11
- package/src/commands/org.ts +1 -1
|
@@ -2,5 +2,8 @@ export declare function check(domain: string, flags: Record<string, string | boo
|
|
|
2
2
|
export declare function register(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
3
3
|
export declare function importDomain(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
4
|
export declare function list(flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
+
export declare function assign(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
6
|
+
export declare function unassign(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
7
|
export declare function settings(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
8
|
+
export declare function updateSettings(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
6
9
|
export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
|
package/dist/commands/domain.js
CHANGED
|
@@ -4,17 +4,18 @@ exports.check = check;
|
|
|
4
4
|
exports.register = register;
|
|
5
5
|
exports.importDomain = importDomain;
|
|
6
6
|
exports.list = list;
|
|
7
|
+
exports.assign = assign;
|
|
8
|
+
exports.unassign = unassign;
|
|
7
9
|
exports.settings = settings;
|
|
10
|
+
exports.updateSettings = updateSettings;
|
|
8
11
|
exports.run = run;
|
|
9
12
|
const sdk_1 = require("@myapihq/sdk");
|
|
10
13
|
const config_js_1 = require("../config.js");
|
|
11
14
|
const output_js_1 = require("../output.js");
|
|
12
15
|
async function check(domain, flags) {
|
|
13
16
|
const orgId = flags.org;
|
|
14
|
-
if (!orgId)
|
|
15
|
-
(0, output_js_1.error)("Missing --org <id>
|
|
16
|
-
if (!domain)
|
|
17
|
-
(0, output_js_1.error)("Missing domain");
|
|
17
|
+
if (!orgId || !domain)
|
|
18
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain check <domain> --org <id>");
|
|
18
19
|
const config = (0, config_js_1.requireConfig)();
|
|
19
20
|
const res = await sdk_1.domain.checkDomain(config.api_key, orgId, domain);
|
|
20
21
|
if (res.available) {
|
|
@@ -26,10 +27,8 @@ async function check(domain, flags) {
|
|
|
26
27
|
}
|
|
27
28
|
async function register(domain, flags) {
|
|
28
29
|
const orgId = flags.org;
|
|
29
|
-
if (!orgId)
|
|
30
|
-
(0, output_js_1.error)("Missing --org <id>
|
|
31
|
-
if (!domain)
|
|
32
|
-
(0, output_js_1.error)("Missing domain");
|
|
30
|
+
if (!orgId || !domain)
|
|
31
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain register <domain> --org <id> [--years <num>]");
|
|
33
32
|
const years = parseInt(flags.years) || 1;
|
|
34
33
|
const config = (0, config_js_1.requireConfig)();
|
|
35
34
|
const res = await sdk_1.domain.registerDomain(config.api_key, orgId, domain, years);
|
|
@@ -37,12 +36,10 @@ async function register(domain, flags) {
|
|
|
37
36
|
}
|
|
38
37
|
async function importDomain(domain, flags) {
|
|
39
38
|
const orgId = flags.org;
|
|
40
|
-
if (!orgId)
|
|
41
|
-
(0, output_js_1.error)("Missing --org <id>
|
|
42
|
-
if (!domain)
|
|
43
|
-
(0, output_js_1.error)("Missing domain");
|
|
39
|
+
if (!orgId || !domain)
|
|
40
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>");
|
|
44
41
|
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
45
|
-
(0, output_js_1.error)("Missing --namecheap-user
|
|
42
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>");
|
|
46
43
|
}
|
|
47
44
|
const config = (0, config_js_1.requireConfig)();
|
|
48
45
|
await sdk_1.domain.importDomain(config.api_key, orgId, {
|
|
@@ -55,25 +52,55 @@ async function importDomain(domain, flags) {
|
|
|
55
52
|
async function list(flags) {
|
|
56
53
|
const orgId = flags.org;
|
|
57
54
|
if (!orgId)
|
|
58
|
-
(0, output_js_1.error)("Missing --org <id>
|
|
55
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain list --org <id> [--filter=all|unassigned|org]");
|
|
59
56
|
const config = (0, config_js_1.requireConfig)();
|
|
60
57
|
const filter = flags.filter;
|
|
61
58
|
const domains = await sdk_1.domain.listDomains(config.api_key, orgId, filter);
|
|
62
59
|
(0, output_js_1.printTable)(domains);
|
|
63
60
|
}
|
|
61
|
+
async function assign(domain, flags) {
|
|
62
|
+
const orgId = flags.org;
|
|
63
|
+
const targetOrgId = flags.target;
|
|
64
|
+
if (!orgId || !domain || !targetOrgId)
|
|
65
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id> --target <target_org_id>");
|
|
66
|
+
const config = (0, config_js_1.requireConfig)();
|
|
67
|
+
const res = await sdk_1.domain.assignDomain(config.api_key, orgId, domain, targetOrgId);
|
|
68
|
+
(0, output_js_1.success)(`Assigned ${domain} to org ${targetOrgId}`);
|
|
69
|
+
}
|
|
70
|
+
async function unassign(domain, flags) {
|
|
71
|
+
const orgId = flags.org;
|
|
72
|
+
if (!orgId || !domain)
|
|
73
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain unassign <domain> --org <id>");
|
|
74
|
+
const config = (0, config_js_1.requireConfig)();
|
|
75
|
+
const res = await sdk_1.domain.unassignDomain(config.api_key, orgId, domain);
|
|
76
|
+
(0, output_js_1.success)(`Unassigned ${domain} from org ${orgId}`);
|
|
77
|
+
}
|
|
64
78
|
async function settings(domain, flags) {
|
|
65
79
|
const orgId = flags.org;
|
|
66
|
-
if (!orgId)
|
|
67
|
-
(0, output_js_1.error)("Missing --org <id>
|
|
68
|
-
if (!domain)
|
|
69
|
-
(0, output_js_1.error)("Missing domain");
|
|
80
|
+
if (!orgId || !domain)
|
|
81
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain settings <domain> --org <id>");
|
|
70
82
|
const config = (0, config_js_1.requireConfig)();
|
|
71
83
|
const res = await sdk_1.domain.getDomainSettings(config.api_key, orgId, domain);
|
|
72
84
|
(0, output_js_1.printJson)(res);
|
|
73
85
|
}
|
|
86
|
+
async function updateSettings(domain, flags) {
|
|
87
|
+
const orgId = flags.org;
|
|
88
|
+
if (!orgId || !domain)
|
|
89
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi domain update-settings <domain> --org <id> [--security=...] [--browser-check=...] [--purge-cache]");
|
|
90
|
+
const config = (0, config_js_1.requireConfig)();
|
|
91
|
+
const payload = {};
|
|
92
|
+
if (flags.security)
|
|
93
|
+
payload.security_level = flags.security;
|
|
94
|
+
if (flags['browser-check'])
|
|
95
|
+
payload.browser_check = flags['browser-check'];
|
|
96
|
+
if (flags['purge-cache'])
|
|
97
|
+
payload.purge_cache = true;
|
|
98
|
+
const res = await sdk_1.domain.updateDomainSettings(config.api_key, orgId, domain, payload);
|
|
99
|
+
(0, output_js_1.success)(`Updated settings for ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
100
|
+
}
|
|
74
101
|
async function run(subcommand, args, flags) {
|
|
75
102
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
76
|
-
(0, output_js_1.info)('Usage: myapi domain <subcommand>\n\nSubcommands:\n list
|
|
103
|
+
(0, output_js_1.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.');
|
|
77
104
|
return;
|
|
78
105
|
}
|
|
79
106
|
if (flags.help) {
|
|
@@ -85,8 +112,14 @@ async function run(subcommand, args, flags) {
|
|
|
85
112
|
(0, output_js_1.info)('Usage: myapi domain register <domain> --org <id> [--years <num>]\n\nRegisters a new domain name.');
|
|
86
113
|
else if (subcommand === 'import')
|
|
87
114
|
(0, output_js_1.info)('Usage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
115
|
+
else if (subcommand === 'assign')
|
|
116
|
+
(0, output_js_1.info)('Usage: myapi domain assign <domain> --org <id> --target <target_org_id>\n\nAssigns a domain to a different organization.');
|
|
117
|
+
else if (subcommand === 'unassign')
|
|
118
|
+
(0, output_js_1.info)('Usage: myapi domain unassign <domain> --org <id>\n\nUnassigns a domain from its current organization.');
|
|
88
119
|
else if (subcommand === 'settings')
|
|
89
120
|
(0, output_js_1.info)('Usage: myapi domain settings <domain> --org <id>\n\nGets the DNS settings and configuration for a domain.');
|
|
121
|
+
else if (subcommand === 'update-settings')
|
|
122
|
+
(0, output_js_1.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.');
|
|
90
123
|
return;
|
|
91
124
|
}
|
|
92
125
|
if (subcommand === 'list')
|
|
@@ -97,8 +130,14 @@ async function run(subcommand, args, flags) {
|
|
|
97
130
|
await register(args[0], flags);
|
|
98
131
|
else if (subcommand === 'import')
|
|
99
132
|
await importDomain(args[0], flags);
|
|
133
|
+
else if (subcommand === 'assign')
|
|
134
|
+
await assign(args[0], flags);
|
|
135
|
+
else if (subcommand === 'unassign')
|
|
136
|
+
await unassign(args[0], flags);
|
|
100
137
|
else if (subcommand === 'settings')
|
|
101
138
|
await settings(args[0], flags);
|
|
139
|
+
else if (subcommand === 'update-settings')
|
|
140
|
+
await updateSettings(args[0], flags);
|
|
102
141
|
else
|
|
103
142
|
(0, output_js_1.error)(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
104
143
|
}
|
package/dist/commands/org.js
CHANGED
|
@@ -74,7 +74,7 @@ async function importOrg(args, flags) {
|
|
|
74
74
|
const domain = args[0];
|
|
75
75
|
const orgId = flags.org;
|
|
76
76
|
if (!domain || !orgId) {
|
|
77
|
-
(0, output_js_1.error)("Missing
|
|
77
|
+
(0, output_js_1.error)("Missing required arguments.\nUsage: myapi org import <domain> --org <id>");
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
const config = (0, config_js_1.requireConfig)();
|
package/package.json
CHANGED
package/src/commands/domain.ts
CHANGED
|
@@ -4,8 +4,7 @@ import { success, error, info, printTable, printJson } from '../output.js';
|
|
|
4
4
|
|
|
5
5
|
export async function check(domain: string, flags: Record<string, string | boolean>) {
|
|
6
6
|
const orgId = flags.org as string;
|
|
7
|
-
if (!orgId) error("Missing --org <id>
|
|
8
|
-
if (!domain) error("Missing domain");
|
|
7
|
+
if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain check <domain> --org <id>");
|
|
9
8
|
const config = requireConfig();
|
|
10
9
|
const res = await sdkDomain.checkDomain(config.api_key, orgId, domain);
|
|
11
10
|
if (res.available) {
|
|
@@ -17,8 +16,7 @@ export async function check(domain: string, flags: Record<string, string | boole
|
|
|
17
16
|
|
|
18
17
|
export async function register(domain: string, flags: Record<string, string | boolean>) {
|
|
19
18
|
const orgId = flags.org as string;
|
|
20
|
-
if (!orgId) error("Missing --org <id>
|
|
21
|
-
if (!domain) error("Missing domain");
|
|
19
|
+
if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain register <domain> --org <id> [--years <num>]");
|
|
22
20
|
const years = parseInt(flags.years as string) || 1;
|
|
23
21
|
const config = requireConfig();
|
|
24
22
|
const res = await sdkDomain.registerDomain(config.api_key, orgId, domain, years);
|
|
@@ -27,10 +25,9 @@ export async function register(domain: string, flags: Record<string, string | bo
|
|
|
27
25
|
|
|
28
26
|
export async function importDomain(domain: string, flags: Record<string, string | boolean>) {
|
|
29
27
|
const orgId = flags.org as string;
|
|
30
|
-
if (!orgId) error("Missing --org <id>
|
|
31
|
-
if (!domain) error("Missing domain");
|
|
28
|
+
if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>");
|
|
32
29
|
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
33
|
-
error("Missing --namecheap-user
|
|
30
|
+
error("Missing required arguments.\nUsage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>");
|
|
34
31
|
}
|
|
35
32
|
const config = requireConfig();
|
|
36
33
|
await sdkDomain.importDomain(config.api_key, orgId, {
|
|
@@ -43,25 +40,54 @@ export async function importDomain(domain: string, flags: Record<string, string
|
|
|
43
40
|
|
|
44
41
|
export async function list(flags: Record<string, string | boolean>) {
|
|
45
42
|
const orgId = flags.org as string;
|
|
46
|
-
if (!orgId) error("Missing --org <id>
|
|
43
|
+
if (!orgId) error("Missing required arguments.\nUsage: myapi domain list --org <id> [--filter=all|unassigned|org]");
|
|
47
44
|
const config = requireConfig();
|
|
48
45
|
const filter = flags.filter as 'all' | 'unassigned' | 'org' | undefined;
|
|
49
46
|
const domains = await sdkDomain.listDomains(config.api_key, orgId, filter);
|
|
50
47
|
printTable(domains as unknown as Record<string, unknown>[]);
|
|
51
48
|
}
|
|
52
49
|
|
|
50
|
+
export async function assign(domain: string, flags: Record<string, string | boolean>) {
|
|
51
|
+
const orgId = flags.org as string;
|
|
52
|
+
const targetOrgId = flags.target as string;
|
|
53
|
+
if (!orgId || !domain || !targetOrgId) error("Missing required arguments.\nUsage: myapi domain assign <domain> --org <id> --target <target_org_id>");
|
|
54
|
+
const config = requireConfig();
|
|
55
|
+
const res = await sdkDomain.assignDomain(config.api_key, orgId, domain, targetOrgId);
|
|
56
|
+
success(`Assigned ${domain} to org ${targetOrgId}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function unassign(domain: string, flags: Record<string, string | boolean>) {
|
|
60
|
+
const orgId = flags.org as string;
|
|
61
|
+
if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain unassign <domain> --org <id>");
|
|
62
|
+
const config = requireConfig();
|
|
63
|
+
const res = await sdkDomain.unassignDomain(config.api_key, orgId, domain);
|
|
64
|
+
success(`Unassigned ${domain} from org ${orgId}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
53
67
|
export async function settings(domain: string, flags: Record<string, string | boolean>) {
|
|
54
68
|
const orgId = flags.org as string;
|
|
55
|
-
if (!orgId) error("Missing --org <id>
|
|
56
|
-
if (!domain) error("Missing domain");
|
|
69
|
+
if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain settings <domain> --org <id>");
|
|
57
70
|
const config = requireConfig();
|
|
58
71
|
const res = await sdkDomain.getDomainSettings(config.api_key, orgId, domain);
|
|
59
72
|
printJson(res);
|
|
60
73
|
}
|
|
61
74
|
|
|
75
|
+
export async function updateSettings(domain: string, flags: Record<string, string | boolean>) {
|
|
76
|
+
const orgId = flags.org as string;
|
|
77
|
+
if (!orgId || !domain) error("Missing required arguments.\nUsage: myapi domain update-settings <domain> --org <id> [--security=...] [--browser-check=...] [--purge-cache]");
|
|
78
|
+
const config = requireConfig();
|
|
79
|
+
const payload: any = {};
|
|
80
|
+
if (flags.security) payload.security_level = flags.security as string;
|
|
81
|
+
if (flags['browser-check']) payload.browser_check = flags['browser-check'] as string;
|
|
82
|
+
if (flags['purge-cache']) payload.purge_cache = true;
|
|
83
|
+
|
|
84
|
+
const res = await sdkDomain.updateDomainSettings(config.api_key, orgId, domain, payload);
|
|
85
|
+
success(`Updated settings for ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
86
|
+
}
|
|
87
|
+
|
|
62
88
|
export async function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>) {
|
|
63
89
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
64
|
-
info('Usage: myapi domain <subcommand>\n\nSubcommands:\n list
|
|
90
|
+
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.');
|
|
65
91
|
return;
|
|
66
92
|
}
|
|
67
93
|
|
|
@@ -70,7 +96,10 @@ export async function run(subcommand: string | undefined, args: string[], flags:
|
|
|
70
96
|
else if (subcommand === 'check') info('Usage: myapi domain check <domain> --org <id>\n\nChecks if a domain name is available for registration.');
|
|
71
97
|
else if (subcommand === 'register') info('Usage: myapi domain register <domain> --org <id> [--years <num>]\n\nRegisters a new domain name.');
|
|
72
98
|
else if (subcommand === 'import') info('Usage: myapi domain import <domain> --org <id> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
|
|
99
|
+
else if (subcommand === 'assign') info('Usage: myapi domain assign <domain> --org <id> --target <target_org_id>\n\nAssigns a domain to a different organization.');
|
|
100
|
+
else if (subcommand === 'unassign') info('Usage: myapi domain unassign <domain> --org <id>\n\nUnassigns a domain from its current organization.');
|
|
73
101
|
else if (subcommand === 'settings') info('Usage: myapi domain settings <domain> --org <id>\n\nGets the DNS settings and configuration for a domain.');
|
|
102
|
+
else if (subcommand === 'update-settings') 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.');
|
|
74
103
|
return;
|
|
75
104
|
}
|
|
76
105
|
|
|
@@ -78,6 +107,9 @@ export async function run(subcommand: string | undefined, args: string[], flags:
|
|
|
78
107
|
else if (subcommand === 'check') await check(args[0], flags);
|
|
79
108
|
else if (subcommand === 'register') await register(args[0], flags);
|
|
80
109
|
else if (subcommand === 'import') await importDomain(args[0], flags);
|
|
110
|
+
else if (subcommand === 'assign') await assign(args[0], flags);
|
|
111
|
+
else if (subcommand === 'unassign') await unassign(args[0], flags);
|
|
81
112
|
else if (subcommand === 'settings') await settings(args[0], flags);
|
|
113
|
+
else if (subcommand === 'update-settings') await updateSettings(args[0], flags);
|
|
82
114
|
else error(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
|
|
83
115
|
}
|
package/src/commands/org.ts
CHANGED
|
@@ -70,7 +70,7 @@ export async function importOrg(args: string[], flags: Record<string, string | b
|
|
|
70
70
|
const orgId = flags.org as string;
|
|
71
71
|
|
|
72
72
|
if (!domain || !orgId) {
|
|
73
|
-
error("Missing
|
|
73
|
+
error("Missing required arguments.\nUsage: myapi org import <domain> --org <id>");
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
const config = requireConfig();
|