@myapihq/cli 1.0.82 → 1.0.84

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.
@@ -28,10 +28,11 @@ export async function setFunnel(id, flags, via = 'auth config') {
28
28
  if (!orgId)
29
29
  error('No default organization set. Run: myapi auth config set-org <id>');
30
30
  info('› Validating…');
31
- const funnel = await sdkFunnel.getFunnel(config.api_key, orgId, id);
32
- config.default_funnel = funnel.id;
31
+ const rawFunnel = await sdkFunnel.getFunnel(config.api_key, orgId, id);
32
+ const funnelId = rawFunnel.funnel?.id ?? rawFunnel.id;
33
+ config.default_funnel = funnelId;
33
34
  saveConfig(config);
34
- success(`Default funnel set to: ${funnel.id}`);
35
+ success(`Default funnel set to: ${funnelId}`);
35
36
  }
36
37
  export async function setDomain(domain, flags, via = 'auth config') {
37
38
  if (!domain || flags.help) {
@@ -45,10 +46,19 @@ export async function setDomain(domain, flags, via = 'auth config') {
45
46
  }
46
47
  export async function view(flags, via = 'auth config') {
47
48
  if (flags.help) {
48
- info(`Usage: myapi ${via} view\n\nShows the currently configured defaults: default org, funnel, and domain.`);
49
+ info(`Usage: myapi ${via} view [--json]\n\nShows the currently configured defaults: default org, funnel, and domain.\n\nFlags:\n --json Output raw JSON`);
49
50
  return;
50
51
  }
51
52
  const config = requireConfig();
53
+ if (flags.json) {
54
+ const { printJson } = await import('../output.js');
55
+ printJson({
56
+ default_org: config.default_org ?? null,
57
+ default_funnel: config.default_funnel ?? null,
58
+ default_domain: config.default_domain ?? null,
59
+ });
60
+ return;
61
+ }
52
62
  info(`Default Org: ${config.default_org || 'Not set'}`);
53
63
  info(`Default Funnel: ${config.default_funnel || 'Not set'}`);
54
64
  info(`Default Domain: ${config.default_domain || 'Not set'}`);
@@ -86,6 +86,9 @@ export async function push(slug, flags) {
86
86
  config.default_funnel = funnelId;
87
87
  saveConfig(config);
88
88
  }
89
+ if (process.stdin.isTTY) {
90
+ error("No content provided via stdin. Use a pipe or file:\n echo '<h1>Hello</h1>' | myapi funnel push /\n cat page.html | myapi funnel push /about");
91
+ }
89
92
  const html = await new Promise((resolve, reject) => {
90
93
  let data = '';
91
94
  process.stdin.setEncoding('utf-8');
@@ -1,4 +1,4 @@
1
- export declare function create(flags: Record<string, string | boolean>): Promise<void>;
1
+ export declare function create(restArgs: string[], flags: Record<string, string | boolean>): Promise<void>;
2
2
  export declare function list(flags: Record<string, string | boolean>): Promise<void>;
3
3
  export declare function get(id: string, flags: Record<string, string | boolean>): Promise<void>;
4
4
  export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
@@ -3,17 +3,18 @@ import { hq, funnel as sdkFunnel } from '@myapihq/sdk';
3
3
  import { requireConfig, saveConfig } from '../config.js';
4
4
  import { success, error, printTable, printJson, info } from '../output.js';
5
5
  import { sleep, formatDate } from '../utils.js';
6
- export async function create(flags) {
6
+ export async function create(restArgs, flags) {
7
7
  if (flags.help) {
8
- info('Usage: myapi org create --name <name> [options]\n\nCreates a new organization. A funnel (website) is automatically created alongside it.\n\nOptions:\n --name Organization name (required). Use quotes for names with spaces.\n --tagline Short tagline\n --description Detailed description\n --business-sector Sector (e.g. Technology)\n --logo-url URL to logo image\n --yes Skip the "set as default?" prompt (useful in CI / agent workflows)\n\nExamples:\n myapi org create --name "Acme Inc"\n myapi org create --name "Acme Inc" --yes');
8
+ info('Usage: myapi org create <name> [options]\n myapi org create --name <name> [options]\n\nCreates a new organization. A funnel (website) is automatically created alongside it.\n\nOptions:\n --name Organization name (alternative to positional argument)\n --tagline Short tagline\n --description Detailed description\n --business-sector Sector (e.g. Technology)\n --logo-url URL to logo image\n --yes Skip the "set as default?" prompt (useful in CI / agent workflows)\n --json Output raw JSON (non-interactive, skips prompts)\n\nExamples:\n myapi org create "Acme Inc"\n myapi org create "Acme Inc" --yes\n myapi org create --name "Acme Inc" --yes');
9
9
  return;
10
10
  }
11
- if (!flags.name) {
12
- error("Missing --name flag. Run 'myapi org create --help' for details.");
11
+ const name = flags.name || restArgs[0];
12
+ if (!name) {
13
+ error("Missing org name. Usage: myapi org create \"My Company\" [--yes]");
13
14
  return;
14
15
  }
15
16
  const config = requireConfig();
16
- const payload = { name: flags.name };
17
+ const payload = { name };
17
18
  if (flags.tagline)
18
19
  payload.tagline = flags.tagline;
19
20
  if (flags.description)
@@ -23,9 +24,11 @@ export async function create(flags) {
23
24
  if (flags['logo-url'])
24
25
  payload.logo_url = flags['logo-url'];
25
26
  const org = await hq.createOrg(config.api_key, payload);
26
- success(`Org created! ID: ${org.id}, Name: ${org.name}`);
27
- if (org.preview_subdomain) {
28
- info(`Preview domain: https://${org.preview_subdomain}.makeautonomous.com`);
27
+ if (!flags.json) {
28
+ success(`Org created! ID: ${org.id}, Name: ${org.name}`);
29
+ if (org.preview_subdomain) {
30
+ info(`Preview domain: https://${org.preview_subdomain}.makeautonomous.com`);
31
+ }
29
32
  }
30
33
  const setDefault = flags.yes || await new Promise(resolve => {
31
34
  const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
@@ -34,13 +37,25 @@ export async function create(flags) {
34
37
  resolve(ans.trim().toLowerCase() !== 'n');
35
38
  });
36
39
  });
40
+ let funnelId;
37
41
  if (setDefault) {
38
42
  config.default_org = org.id;
39
43
  const funnels = await sdkFunnel.listFunnels(config.api_key, org.id);
40
- if (funnels.length > 0)
44
+ if (funnels.length > 0) {
41
45
  config.default_funnel = funnels[0].id;
46
+ funnelId = funnels[0].id;
47
+ }
42
48
  saveConfig(config);
43
- success(`Default org${funnels.length > 0 ? ' and funnel' : ''} updated.`);
49
+ if (!flags.json)
50
+ success(`Default org${funnelId ? ' and funnel' : ''} updated.`);
51
+ }
52
+ if (flags.json) {
53
+ const result = { id: org.id, name: org.name };
54
+ if (org.preview_subdomain)
55
+ result.preview_url = `https://${org.preview_subdomain}.makeautonomous.com`;
56
+ if (funnelId)
57
+ result.funnel_id = funnelId;
58
+ printJson(result);
44
59
  }
45
60
  }
46
61
  export async function list(flags) {
package/dist/index.js CHANGED
@@ -31,9 +31,13 @@ const ERROR_MESSAGES = {
31
31
  DOMAIN_NOT_AVAILABLE: 'This domain is not available for registration.',
32
32
  db_error: 'Resource not found or invalid ID.',
33
33
  NOT_FOUND: 'Resource not found.',
34
+ domain_not_found: 'Domain not found.',
35
+ invalid_domain: 'Invalid domain name.',
36
+ invalid_org: 'Invalid organization.',
34
37
  FORBIDDEN: 'You do not have permission to perform this action.',
35
38
  RATE_LIMITED: 'Too many requests. Please wait a moment and try again.',
36
39
  INSUFFICIENT_BALANCE: 'Insufficient balance. Run: myapi billing topup <amount>',
40
+ INVALID_AMOUNT: 'Amount out of range. Maximum single top-up is $100. Run: myapi billing topup <amount>',
37
41
  };
38
42
  function friendlyError(code) {
39
43
  return ERROR_MESSAGES[code] || code;
@@ -115,13 +119,13 @@ async function main() {
115
119
  break;
116
120
  case 'org':
117
121
  if (!subcommand || (flags.help && !subcommand)) {
118
- info('Usage: myapi org <subcommand>\n\nSubcommands:\n list List organizations\n create Create an organization (use --yes to auto-set it as your default org and funnel)\n get Get details of an organization\n delete Delete an organization\n sync-brand Sync brand info (name, logo, description) from an existing website into an org');
122
+ info('Usage: myapi org <subcommand>\n\nSubcommands:\n list List organizations\n create Create an organization · myapi org create "Name" --yes\n get Get details of an organization\n delete Delete an organization\n sync-brand Sync brand info (name, logo, description) from an existing website into an org');
119
123
  break;
120
124
  }
121
125
  if (subcommand === 'list')
122
126
  await orgCmd.list(flags);
123
127
  else if (subcommand === 'create')
124
- await orgCmd.create(flags);
128
+ await orgCmd.create(restArgs, flags);
125
129
  else if (subcommand === 'get')
126
130
  await orgCmd.get(restArgs[0], flags);
127
131
  else if (subcommand === 'delete')
@@ -195,7 +199,7 @@ async function main() {
195
199
  else if (subcommand === 'auth')
196
200
  info('Usage: myapi auth <subcommand>\n\nSubcommands:\n setup Configure your account\n import-key Import an existing API key non-interactively\n whoami Show current account · supports --json\n link [email] Upgrade anonymous account to registered (or add a second session)\n switch [index] Switch active account by index or email\n config Manage CLI defaults (org, funnel, domain)\n install-skills Install or update the MyAPI skills pack for AI agents\n api-keys Manage API keys · list / create / revoke');
197
201
  else if (subcommand === 'org')
198
- info('Usage: myapi org <subcommand>\n\nSubcommands:\n list List organizations\n create Create an organization\n get Get details of an organization\n delete Delete an organization\n sync-brand Sync brand info from an existing website into an org');
202
+ info('Usage: myapi org <subcommand>\n\nSubcommands:\n list List organizations\n create Create an organization · myapi org create "Name" --yes\n get Get details of an organization\n delete Delete an organization\n sync-brand Sync brand info from an existing website into an org');
199
203
  else if (subcommand === 'billing')
200
204
  info('Usage: myapi billing <subcommand>\n\nSubcommands:\n balance Check balance\n history View billing history\n topup Top up your balance\n setup Setup a payment method');
201
205
  else if (subcommand === 'keys')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myapihq/cli",
3
- "version": "1.0.82",
3
+ "version": "1.0.84",
4
4
  "description": "MyAPI command-line interface",
5
5
  "type": "module",
6
6
  "files": [