@myapihq/cli 1.0.10 → 1.0.11

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.
@@ -1,6 +1,6 @@
1
- export declare function check(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function register(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function importDomain(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
4
- export declare function list(orgId: string, flags: Record<string, string | boolean>): Promise<void>;
5
- export declare function settings(orgId: string, domain: string, flags: Record<string, string | boolean>): Promise<void>;
1
+ export declare function check(domain: string, flags: Record<string, string | boolean>): Promise<void>;
2
+ export declare function register(domain: string, flags: Record<string, string | boolean>): Promise<void>;
3
+ export declare function importDomain(domain: string, flags: Record<string, string | boolean>): Promise<void>;
4
+ export declare function list(flags: Record<string, string | boolean>): Promise<void>;
5
+ export declare function settings(domain: string, flags: Record<string, string | boolean>): Promise<void>;
6
6
  export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
@@ -9,9 +9,12 @@ exports.run = run;
9
9
  const sdk_1 = require("@myapihq/sdk");
10
10
  const config_js_1 = require("../config.js");
11
11
  const output_js_1 = require("../output.js");
12
- async function check(orgId, domain, flags) {
13
- if (!orgId || !domain)
14
- (0, output_js_1.error)("Missing org_id or domain");
12
+ async function check(domain, flags) {
13
+ const orgId = flags.org;
14
+ if (!orgId)
15
+ (0, output_js_1.error)("Missing --org <id> flag");
16
+ if (!domain)
17
+ (0, output_js_1.error)("Missing domain");
15
18
  const config = (0, config_js_1.requireConfig)();
16
19
  const res = await sdk_1.domain.checkDomain(config.api_key, orgId, domain);
17
20
  if (res.available) {
@@ -21,17 +24,23 @@ async function check(orgId, domain, flags) {
21
24
  (0, output_js_1.info)(`Not available ✗`);
22
25
  }
23
26
  }
24
- async function register(orgId, domain, flags) {
25
- if (!orgId || !domain)
26
- (0, output_js_1.error)("Missing org_id or domain");
27
+ async function register(domain, flags) {
28
+ const orgId = flags.org;
29
+ if (!orgId)
30
+ (0, output_js_1.error)("Missing --org <id> flag");
31
+ if (!domain)
32
+ (0, output_js_1.error)("Missing domain");
27
33
  const years = parseInt(flags.years) || 1;
28
34
  const config = (0, config_js_1.requireConfig)();
29
35
  const res = await sdk_1.domain.registerDomain(config.api_key, orgId, domain, years);
30
36
  (0, output_js_1.success)(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
31
37
  }
32
- async function importDomain(orgId, domain, flags) {
33
- if (!orgId || !domain)
34
- (0, output_js_1.error)("Missing org_id or domain");
38
+ async function importDomain(domain, flags) {
39
+ const orgId = flags.org;
40
+ if (!orgId)
41
+ (0, output_js_1.error)("Missing --org <id> flag");
42
+ if (!domain)
43
+ (0, output_js_1.error)("Missing domain");
35
44
  if (!flags['namecheap-user'] || !flags['namecheap-key']) {
36
45
  (0, output_js_1.error)("Missing --namecheap-user or --namecheap-key flags");
37
46
  }
@@ -43,49 +52,53 @@ async function importDomain(orgId, domain, flags) {
43
52
  });
44
53
  (0, output_js_1.success)(`Imported ${domain}`);
45
54
  }
46
- async function list(orgId, flags) {
55
+ async function list(flags) {
56
+ const orgId = flags.org;
47
57
  if (!orgId)
48
- (0, output_js_1.error)("Missing org_id");
58
+ (0, output_js_1.error)("Missing --org <id> flag");
49
59
  const config = (0, config_js_1.requireConfig)();
50
60
  const filter = flags.filter;
51
61
  const domains = await sdk_1.domain.listDomains(config.api_key, orgId, filter);
52
62
  (0, output_js_1.printTable)(domains);
53
63
  }
54
- async function settings(orgId, domain, flags) {
55
- if (!orgId || !domain)
56
- (0, output_js_1.error)("Missing org_id or domain");
64
+ async function settings(domain, flags) {
65
+ const orgId = flags.org;
66
+ if (!orgId)
67
+ (0, output_js_1.error)("Missing --org <id> flag");
68
+ if (!domain)
69
+ (0, output_js_1.error)("Missing domain");
57
70
  const config = (0, config_js_1.requireConfig)();
58
71
  const res = await sdk_1.domain.getDomainSettings(config.api_key, orgId, domain);
59
72
  (0, output_js_1.printJson)(res);
60
73
  }
61
74
  async function run(subcommand, args, flags) {
62
75
  if (!subcommand || (flags.help && !subcommand)) {
63
- (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 settings Get domain settings');
76
+ (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 settings Get domain settings\n\nNote: All domain commands require the --org <id> flag.');
64
77
  return;
65
78
  }
66
79
  if (flags.help) {
67
80
  if (subcommand === 'list')
68
- (0, output_js_1.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.');
81
+ (0, output_js_1.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.');
69
82
  else if (subcommand === 'check')
70
- (0, output_js_1.info)('Usage: myapi domain check <org_id> <domain>\n\nChecks if a domain name is available for registration.');
83
+ (0, output_js_1.info)('Usage: myapi domain check <domain> --org <id>\n\nChecks if a domain name is available for registration.');
71
84
  else if (subcommand === 'register')
72
- (0, output_js_1.info)('Usage: myapi domain register <org_id> <domain> [--years <num>]\n\nRegisters a new domain name.');
85
+ (0, output_js_1.info)('Usage: myapi domain register <domain> --org <id> [--years <num>]\n\nRegisters a new domain name.');
73
86
  else if (subcommand === 'import')
74
- (0, output_js_1.info)('Usage: myapi domain import <org_id> <domain> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
87
+ (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.');
75
88
  else if (subcommand === 'settings')
76
- (0, output_js_1.info)('Usage: myapi domain settings <org_id> <domain>\n\nGets the DNS settings and configuration for a domain.');
89
+ (0, output_js_1.info)('Usage: myapi domain settings <domain> --org <id>\n\nGets the DNS settings and configuration for a domain.');
77
90
  return;
78
91
  }
79
92
  if (subcommand === 'list')
80
- await list(args[0], flags);
93
+ await list(flags);
81
94
  else if (subcommand === 'check')
82
- await check(args[0], args[1], flags);
95
+ await check(args[0], flags);
83
96
  else if (subcommand === 'register')
84
- await register(args[0], args[1], flags);
97
+ await register(args[0], flags);
85
98
  else if (subcommand === 'import')
86
- await importDomain(args[0], args[1], flags);
99
+ await importDomain(args[0], flags);
87
100
  else if (subcommand === 'settings')
88
- await settings(args[0], args[1], flags);
101
+ await settings(args[0], flags);
89
102
  else
90
103
  (0, output_js_1.error)(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
91
104
  }
@@ -68,13 +68,13 @@ async function del(id, flags) {
68
68
  }
69
69
  async function importOrg(args, flags) {
70
70
  if (flags.help) {
71
- (0, output_js_1.info)('Usage: myapi org import <org_id> <domain>\n\nAutomatically extracts brand info from an existing website and updates the organization.\n\nNote: You must create a placeholder organization first using `myapi org create` to get an org_id.');
71
+ (0, output_js_1.info)('Usage: myapi org import <domain> --org <id>\n\nAutomatically extracts brand info from an existing website and updates the organization.\n\nNote: You must create a placeholder organization first using `myapi org create` to get an org_id.');
72
72
  return;
73
73
  }
74
- const orgId = args[0];
75
- const domain = args[1];
76
- if (!orgId || !domain) {
77
- (0, output_js_1.error)("Missing arguments. Usage: myapi org import <org_id> <domain>");
74
+ const domain = args[0];
75
+ const orgId = flags.org;
76
+ if (!domain || !orgId) {
77
+ (0, output_js_1.error)("Missing domain or --org flag. Usage: myapi org import <domain> --org <id>");
78
78
  return;
79
79
  }
80
80
  const config = (0, config_js_1.requireConfig)();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myapihq/cli",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "MyAPI command-line interface",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -2,8 +2,10 @@ import { domain as sdkDomain } from '@myapihq/sdk';
2
2
  import { requireConfig } from '../config.js';
3
3
  import { success, error, info, printTable, printJson } from '../output.js';
4
4
 
5
- export async function check(orgId: string, domain: string, flags: Record<string, string | boolean>) {
6
- if (!orgId || !domain) error("Missing org_id or domain");
5
+ export async function check(domain: string, flags: Record<string, string | boolean>) {
6
+ const orgId = flags.org as string;
7
+ if (!orgId) error("Missing --org <id> flag");
8
+ if (!domain) error("Missing domain");
7
9
  const config = requireConfig();
8
10
  const res = await sdkDomain.checkDomain(config.api_key, orgId, domain);
9
11
  if (res.available) {
@@ -13,16 +15,20 @@ export async function check(orgId: string, domain: string, flags: Record<string,
13
15
  }
14
16
  }
15
17
 
16
- export async function register(orgId: string, domain: string, flags: Record<string, string | boolean>) {
17
- if (!orgId || !domain) error("Missing org_id or domain");
18
+ export async function register(domain: string, flags: Record<string, string | boolean>) {
19
+ const orgId = flags.org as string;
20
+ if (!orgId) error("Missing --org <id> flag");
21
+ if (!domain) error("Missing domain");
18
22
  const years = parseInt(flags.years as string) || 1;
19
23
  const config = requireConfig();
20
24
  const res = await sdkDomain.registerDomain(config.api_key, orgId, domain, years);
21
25
  success(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
22
26
  }
23
27
 
24
- export async function importDomain(orgId: string, domain: string, flags: Record<string, string | boolean>) {
25
- if (!orgId || !domain) error("Missing org_id or domain");
28
+ export async function importDomain(domain: string, flags: Record<string, string | boolean>) {
29
+ const orgId = flags.org as string;
30
+ if (!orgId) error("Missing --org <id> flag");
31
+ if (!domain) error("Missing domain");
26
32
  if (!flags['namecheap-user'] || !flags['namecheap-key']) {
27
33
  error("Missing --namecheap-user or --namecheap-key flags");
28
34
  }
@@ -35,16 +41,19 @@ export async function importDomain(orgId: string, domain: string, flags: Record<
35
41
  success(`Imported ${domain}`);
36
42
  }
37
43
 
38
- export async function list(orgId: string, flags: Record<string, string | boolean>) {
39
- if (!orgId) error("Missing org_id");
44
+ export async function list(flags: Record<string, string | boolean>) {
45
+ const orgId = flags.org as string;
46
+ if (!orgId) error("Missing --org <id> flag");
40
47
  const config = requireConfig();
41
48
  const filter = flags.filter as 'all' | 'unassigned' | 'org' | undefined;
42
49
  const domains = await sdkDomain.listDomains(config.api_key, orgId, filter);
43
50
  printTable(domains as unknown as Record<string, unknown>[]);
44
51
  }
45
52
 
46
- export async function settings(orgId: string, domain: string, flags: Record<string, string | boolean>) {
47
- if (!orgId || !domain) error("Missing org_id or domain");
53
+ export async function settings(domain: string, flags: Record<string, string | boolean>) {
54
+ const orgId = flags.org as string;
55
+ if (!orgId) error("Missing --org <id> flag");
56
+ if (!domain) error("Missing domain");
48
57
  const config = requireConfig();
49
58
  const res = await sdkDomain.getDomainSettings(config.api_key, orgId, domain);
50
59
  printJson(res);
@@ -52,23 +61,23 @@ export async function settings(orgId: string, domain: string, flags: Record<stri
52
61
 
53
62
  export async function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>) {
54
63
  if (!subcommand || (flags.help && !subcommand)) {
55
- 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 settings Get domain settings');
64
+ 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 settings Get domain settings\n\nNote: All domain commands require the --org <id> flag.');
56
65
  return;
57
66
  }
58
67
 
59
68
  if (flags.help) {
60
- if (subcommand === 'list') 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.');
61
- else if (subcommand === 'check') info('Usage: myapi domain check <org_id> <domain>\n\nChecks if a domain name is available for registration.');
62
- else if (subcommand === 'register') info('Usage: myapi domain register <org_id> <domain> [--years <num>]\n\nRegisters a new domain name.');
63
- else if (subcommand === 'import') info('Usage: myapi domain import <org_id> <domain> --namecheap-user <user> --namecheap-key <key>\n\nImports an existing domain from Namecheap.');
64
- else if (subcommand === 'settings') info('Usage: myapi domain settings <org_id> <domain>\n\nGets the DNS settings and configuration for a domain.');
69
+ if (subcommand === 'list') 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.');
70
+ else if (subcommand === 'check') info('Usage: myapi domain check <domain> --org <id>\n\nChecks if a domain name is available for registration.');
71
+ else if (subcommand === 'register') info('Usage: myapi domain register <domain> --org <id> [--years <num>]\n\nRegisters a new domain name.');
72
+ 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.');
73
+ else if (subcommand === 'settings') info('Usage: myapi domain settings <domain> --org <id>\n\nGets the DNS settings and configuration for a domain.');
65
74
  return;
66
75
  }
67
76
 
68
- if (subcommand === 'list') await list(args[0], flags);
69
- else if (subcommand === 'check') await check(args[0], args[1], flags);
70
- else if (subcommand === 'register') await register(args[0], args[1], flags);
71
- else if (subcommand === 'import') await importDomain(args[0], args[1], flags);
72
- else if (subcommand === 'settings') await settings(args[0], args[1], flags);
77
+ if (subcommand === 'list') await list(flags);
78
+ else if (subcommand === 'check') await check(args[0], flags);
79
+ else if (subcommand === 'register') await register(args[0], flags);
80
+ else if (subcommand === 'import') await importDomain(args[0], flags);
81
+ else if (subcommand === 'settings') await settings(args[0], flags);
73
82
  else error(`Unknown subcommand: ${subcommand}. Run "myapi domain --help" for a list of valid subcommands.`);
74
83
  }
@@ -63,14 +63,14 @@ export async function del(id: string, flags: Record<string, string | boolean>) {
63
63
 
64
64
  export async function importOrg(args: string[], flags: Record<string, string | boolean>) {
65
65
  if (flags.help) {
66
- info('Usage: myapi org import <org_id> <domain>\n\nAutomatically extracts brand info from an existing website and updates the organization.\n\nNote: You must create a placeholder organization first using `myapi org create` to get an org_id.');
66
+ info('Usage: myapi org import <domain> --org <id>\n\nAutomatically extracts brand info from an existing website and updates the organization.\n\nNote: You must create a placeholder organization first using `myapi org create` to get an org_id.');
67
67
  return;
68
68
  }
69
- const orgId = args[0];
70
- const domain = args[1];
69
+ const domain = args[0];
70
+ const orgId = flags.org as string;
71
71
 
72
- if (!orgId || !domain) {
73
- error("Missing arguments. Usage: myapi org import <org_id> <domain>");
72
+ if (!domain || !orgId) {
73
+ error("Missing domain or --org flag. Usage: myapi org import <domain> --org <id>");
74
74
  return;
75
75
  }
76
76
  const config = requireConfig();