@myapihq/cli 1.0.84 → 1.1.0-wip.1
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/auth.d.ts +8 -3
- package/dist/commands/auth.js +84 -60
- package/dist/commands/billing.d.ts +8 -4
- package/dist/commands/billing.js +46 -27
- package/dist/commands/config.d.ts +8 -5
- package/dist/commands/config.js +52 -27
- package/dist/commands/domain.d.ts +12 -9
- package/dist/commands/domain.js +124 -86
- package/dist/commands/email/campaign.d.ts +2 -0
- package/dist/commands/email/campaign.js +152 -0
- package/dist/commands/email/index.d.ts +4 -0
- package/dist/commands/email/index.js +98 -0
- package/dist/commands/email/mailbox.d.ts +2 -0
- package/dist/commands/email/mailbox.js +88 -0
- package/dist/commands/email/message.d.ts +2 -0
- package/dist/commands/email/message.js +115 -0
- package/dist/commands/email/template.d.ts +2 -0
- package/dist/commands/email/template.js +106 -0
- package/dist/commands/email/warmup.d.ts +2 -0
- package/dist/commands/email/warmup.js +43 -0
- package/dist/commands/email.d.ts +4 -12
- package/dist/commands/email.js +528 -146
- package/dist/commands/funnel.d.ts +10 -7
- package/dist/commands/funnel.js +79 -55
- package/dist/commands/image.js +25 -15
- package/dist/commands/keys.d.ts +8 -3
- package/dist/commands/keys.js +71 -35
- package/dist/commands/org.d.ts +9 -5
- package/dist/commands/org.js +100 -64
- package/dist/commands/pixel.js +23 -11
- package/dist/commands/setup.d.ts +3 -2
- package/dist/commands/setup.js +160 -165
- package/dist/commands/storage.js +25 -15
- package/dist/commands/update.d.ts +2 -1
- package/dist/commands/update.js +5 -0
- package/dist/commands/url.js +19 -7
- package/dist/commands/webhook.d.ts +8 -5
- package/dist/commands/webhook.js +70 -38
- package/dist/commands/workflow.d.ts +13 -7
- package/dist/commands/workflow.js +179 -58
- package/dist/config.js +10 -5
- package/dist/flags.d.ts +8 -0
- package/dist/flags.js +88 -0
- package/dist/flags.test.d.ts +1 -0
- package/dist/flags.test.js +73 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/helpers.js +31 -0
- package/dist/index.js +98 -109
- package/dist/output.d.ts +12 -1
- package/dist/output.js +16 -6
- package/dist/prompt.d.ts +24 -0
- package/dist/prompt.js +41 -0
- package/dist/skills/my-email-api/README.md +45 -0
- package/dist/skills/my-email-api/SKILL.md +104 -0
- package/dist/skills/my-email-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-email-api/make/.gitkeep +0 -0
- package/dist/skills/my-email-api/n8n/.gitkeep +0 -0
- package/dist/skills/my-email-api/openapi/.gitkeep +0 -0
- package/dist/skills/my-webhook-api/README.md +40 -0
- package/dist/skills/my-webhook-api/SKILL.md +138 -0
- package/dist/skills/my-webhook-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-webhook-api/make/.gitkeep +0 -0
- package/dist/skills/my-webhook-api/n8n/.gitkeep +0 -0
- package/dist/skills/my-webhook-api/openapi/.gitkeep +0 -0
- package/dist/skills/my-workflow-api/README.md +36 -0
- package/dist/skills/my-workflow-api/SKILL.md +156 -0
- package/dist/skills/my-workflow-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-workflow-api/make/.gitkeep +0 -0
- package/dist/skills/my-workflow-api/n8n/.gitkeep +0 -0
- package/dist/skills/my-workflow-api/openapi/.gitkeep +0 -0
- package/dist/utils.d.ts +26 -4
- package/dist/utils.js +32 -33
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +48 -0
- package/package.json +9 -4
- package/dist/commands/account.d.ts +0 -4
- package/dist/commands/account.js +0 -80
package/dist/commands/auth.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
1
|
+
import type { FlagSchema } from '../flags.js';
|
|
2
|
+
import type { Flags } from '../helpers.js';
|
|
3
|
+
export declare const SCHEMA: FlagSchema;
|
|
4
|
+
export declare const HELP = "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 \u00B7 supports --json\n link [email] Upgrade anonymous account to registered (or add a second session)\n Use myapi auth setup to create a completely new account\n switch [index] Switch active account by index or email\n config Manage CLI defaults (org, funnel, domain) \u00B7 supports set-org / set-funnel / set-domain\n install-skills Install or update the MyAPI skills pack for AI agents\n api-keys Manage API keys \u00B7 list / create / revoke\n keys Alias for api-keys";
|
|
5
|
+
export declare const INSTALL_SKILLS_HELP = "Usage: myapi auth install-skills\n\nInstalls the MyAPI skills pack for AI coding agents (Claude, Gemini, Cursor).\n\nThis command writes skill definition files to:\n ~/.agents/skills/myapi/\n\nAnd creates symlinks in the appropriate agent config directories:\n ~/.claude/ (Claude)\n ~/.gemini/ (Gemini)\n ~/.cursor/ (Cursor, if detected)\n\nThese files teach agents how to use the MyAPI CLI and API directly.\nRun this command again to update existing skills to the latest version.";
|
|
6
|
+
export declare function link(flags?: Flags, emailArg?: string): Promise<void>;
|
|
7
|
+
export declare function whoami(flags?: Flags): Promise<void>;
|
|
8
|
+
export declare function switchCmd(flags?: Flags, indexArg?: string): Promise<void>;
|
package/dist/commands/auth.js
CHANGED
|
@@ -1,47 +1,83 @@
|
|
|
1
|
-
import * as readline from 'readline';
|
|
2
1
|
import { loadConfig, saveConfig, addAccount, switchAccount, listAccounts } from '../config.js';
|
|
3
2
|
import { info, success, error, printJson } from '../output.js';
|
|
3
|
+
import { ask, confirm, withReadline } from '../prompt.js';
|
|
4
4
|
import { installSkills } from './setup.js';
|
|
5
5
|
import { hq } from '@myapihq/sdk';
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
6
|
+
export const SCHEMA = {
|
|
7
|
+
'install-skills': 'boolean',
|
|
8
|
+
'no-skills': 'boolean',
|
|
9
|
+
anonymous: 'boolean',
|
|
10
|
+
anon: 'boolean',
|
|
11
|
+
};
|
|
12
|
+
export const HELP = `Usage: myapi auth <subcommand>
|
|
13
|
+
|
|
14
|
+
Subcommands:
|
|
15
|
+
setup Configure your account
|
|
16
|
+
import-key Import an existing API key non-interactively
|
|
17
|
+
whoami Show current account · supports --json
|
|
18
|
+
link [email] Upgrade anonymous account to registered (or add a second session)
|
|
19
|
+
Use myapi auth setup to create a completely new account
|
|
20
|
+
switch [index] Switch active account by index or email
|
|
21
|
+
config Manage CLI defaults (org, funnel, domain) · supports set-org / set-funnel / set-domain
|
|
22
|
+
install-skills Install or update the MyAPI skills pack for AI agents
|
|
23
|
+
api-keys Manage API keys · list / create / revoke
|
|
24
|
+
keys Alias for api-keys`;
|
|
25
|
+
export const INSTALL_SKILLS_HELP = `Usage: myapi auth install-skills
|
|
26
|
+
|
|
27
|
+
Installs the MyAPI skills pack for AI coding agents (Claude, Gemini, Cursor).
|
|
28
|
+
|
|
29
|
+
This command writes skill definition files to:
|
|
30
|
+
~/.agents/skills/myapi/
|
|
31
|
+
|
|
32
|
+
And creates symlinks in the appropriate agent config directories:
|
|
33
|
+
~/.claude/ (Claude)
|
|
34
|
+
~/.gemini/ (Gemini)
|
|
35
|
+
~/.cursor/ (Cursor, if detected)
|
|
36
|
+
|
|
37
|
+
These files teach agents how to use the MyAPI CLI and API directly.
|
|
38
|
+
Run this command again to update existing skills to the latest version.`;
|
|
39
|
+
const LINK_HELP = `Usage: myapi auth link [email]
|
|
40
|
+
|
|
41
|
+
Behavior depends on whether the email is new or already registered:
|
|
42
|
+
|
|
43
|
+
New email: Attaches it to your current anonymous account, upgrading it
|
|
44
|
+
to a registered account. A one-time code is sent to confirm.
|
|
45
|
+
|
|
46
|
+
Existing email: Does NOT merge accounts. The existing account is added as a
|
|
47
|
+
second active session — your anonymous account stays separate.
|
|
48
|
+
Switch between sessions with: myapi auth switch
|
|
49
|
+
|
|
50
|
+
To create a completely new account from scratch, use: myapi auth setup`;
|
|
51
|
+
const WHOAMI_HELP = `Usage: myapi auth whoami [--json]
|
|
52
|
+
|
|
53
|
+
Displays the active account details: email, account ID, default org,
|
|
54
|
+
default funnel, account type, and current balance.
|
|
55
|
+
|
|
56
|
+
Flags:
|
|
57
|
+
--json Output raw JSON`;
|
|
58
|
+
const SWITCH_HELP = `Usage: myapi auth switch [index|email]
|
|
59
|
+
|
|
60
|
+
Switches the active account. Run without arguments to see a numbered list
|
|
61
|
+
of accounts and choose interactively.
|
|
62
|
+
|
|
63
|
+
Pass an index number or email address to switch non-interactively:
|
|
64
|
+
myapi auth switch 2
|
|
65
|
+
myapi auth switch you@example.com
|
|
66
|
+
|
|
67
|
+
Note: index numbers can shift as accounts are added or removed.
|
|
68
|
+
Use email as a stable identifier in scripts.`;
|
|
69
|
+
// Resolve the user's "install skills?" preference: explicit flag wins, else prompt.
|
|
70
|
+
async function resolveSkillsPreference(flags) {
|
|
71
|
+
if (flags['install-skills'])
|
|
72
|
+
return true;
|
|
73
|
+
if (flags['no-skills'])
|
|
74
|
+
return false;
|
|
75
|
+
return confirm('› Install the MyAPI skills pack? (Y/n) ', true);
|
|
40
76
|
}
|
|
41
77
|
// myapi auth link — upgrade anonymous session to registered account.
|
|
42
78
|
export async function link(flags = {}, emailArg) {
|
|
43
79
|
if (flags.help) {
|
|
44
|
-
info(
|
|
80
|
+
info(LINK_HELP);
|
|
45
81
|
return;
|
|
46
82
|
}
|
|
47
83
|
const config = loadConfig();
|
|
@@ -49,14 +85,13 @@ export async function link(flags = {}, emailArg) {
|
|
|
49
85
|
error('Not configured. Run: myapi auth setup');
|
|
50
86
|
if (!config.is_anonymous)
|
|
51
87
|
error('Already registered. Use your existing account.');
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const email = emailArg || (await ask(rl, '› Email? ')).trim();
|
|
88
|
+
await withReadline(async () => {
|
|
89
|
+
const email = emailArg || await ask('› Email? ');
|
|
55
90
|
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email))
|
|
56
91
|
error(`Invalid email address: "${email}".`);
|
|
57
92
|
let upgradeOk = true;
|
|
58
93
|
try {
|
|
59
|
-
await
|
|
94
|
+
await hq.upgradeAccount(config.api_key, email);
|
|
60
95
|
}
|
|
61
96
|
catch (err) {
|
|
62
97
|
if (err.message !== 'EMAIL_TAKEN')
|
|
@@ -64,16 +99,14 @@ export async function link(flags = {}, emailArg) {
|
|
|
64
99
|
upgradeOk = false;
|
|
65
100
|
info(`› That email already has an account — accounts cannot be merged.`);
|
|
66
101
|
info(`› Your anonymous account will be kept and you can switch back to it anytime.`);
|
|
67
|
-
|
|
68
|
-
if (!yn(ans))
|
|
102
|
+
if (!await confirm('› Sign in and add it as a second account? (Y/n) ', true))
|
|
69
103
|
return;
|
|
70
|
-
await
|
|
104
|
+
await hq.sendCode(email);
|
|
71
105
|
}
|
|
72
106
|
info(`› Sent a code to ${email} · paste it below`);
|
|
73
|
-
const code =
|
|
74
|
-
const data = await
|
|
75
|
-
const
|
|
76
|
-
const wantsSkills = skillsFromFlag !== null ? skillsFromFlag : yn((await ask(rl, '› Install the MyAPI skills pack? (Y/n) ')).trim());
|
|
107
|
+
const code = await ask('› Code? ');
|
|
108
|
+
const data = await hq.verifyCode(email, code);
|
|
109
|
+
const wantsSkills = await resolveSkillsPreference(flags);
|
|
77
110
|
if (upgradeOk) {
|
|
78
111
|
saveConfig({
|
|
79
112
|
...config,
|
|
@@ -102,15 +135,12 @@ export async function link(flags = {}, emailArg) {
|
|
|
102
135
|
}
|
|
103
136
|
if (wantsSkills)
|
|
104
137
|
await installSkills();
|
|
105
|
-
}
|
|
106
|
-
finally {
|
|
107
|
-
rl.close();
|
|
108
|
-
}
|
|
138
|
+
});
|
|
109
139
|
}
|
|
110
140
|
// myapi auth whoami — show current session info.
|
|
111
141
|
export async function whoami(flags = {}) {
|
|
112
142
|
if (flags.help) {
|
|
113
|
-
info(
|
|
143
|
+
info(WHOAMI_HELP);
|
|
114
144
|
return;
|
|
115
145
|
}
|
|
116
146
|
const config = loadConfig();
|
|
@@ -144,7 +174,7 @@ export async function whoami(flags = {}) {
|
|
|
144
174
|
// myapi auth switch [index] — switch between saved accounts.
|
|
145
175
|
export async function switchCmd(flags = {}, indexArg) {
|
|
146
176
|
if (flags.help) {
|
|
147
|
-
info(
|
|
177
|
+
info(SWITCH_HELP);
|
|
148
178
|
return;
|
|
149
179
|
}
|
|
150
180
|
const accounts = listAccounts();
|
|
@@ -163,13 +193,7 @@ export async function switchCmd(flags = {}, indexArg) {
|
|
|
163
193
|
}
|
|
164
194
|
let idxStr = indexArg ?? '';
|
|
165
195
|
if (!idxStr) {
|
|
166
|
-
|
|
167
|
-
try {
|
|
168
|
-
idxStr = (await ask(rl, `› Switch to account (1-${accounts.length})? `)).trim();
|
|
169
|
-
}
|
|
170
|
-
finally {
|
|
171
|
-
rl.close();
|
|
172
|
-
}
|
|
196
|
+
idxStr = await ask(`› Switch to account (1-${accounts.length})? `);
|
|
173
197
|
}
|
|
174
198
|
// Support email as a stable identifier
|
|
175
199
|
let idx;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
1
|
+
import type { FlagSchema } from '../flags.js';
|
|
2
|
+
import type { Flags } from '../helpers.js';
|
|
3
|
+
export declare const SCHEMA: FlagSchema;
|
|
4
|
+
export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
|
|
5
|
+
export declare function balance(flags: Flags): Promise<void>;
|
|
6
|
+
export declare function history(flags: Flags): Promise<void>;
|
|
7
|
+
export declare function topup(amountStr: string, flags: Flags): Promise<void>;
|
|
8
|
+
export declare function setup(_flags: Flags): Promise<void>;
|
package/dist/commands/billing.js
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
import * as readline from 'readline';
|
|
2
1
|
import { hq } from '@myapihq/sdk';
|
|
3
2
|
import { requireConfig } from '../config.js';
|
|
4
3
|
import { success, error, printTable, info, printJson } from '../output.js';
|
|
4
|
+
import { confirm } from '../prompt.js';
|
|
5
5
|
import { formatDate } from '../utils.js';
|
|
6
|
-
export
|
|
6
|
+
export const SCHEMA = {};
|
|
7
|
+
const SUBCOMMAND_USAGE = {
|
|
8
|
+
'balance': 'myapi billing balance [--json]',
|
|
9
|
+
'history': 'myapi billing history [--json]',
|
|
10
|
+
'topup': `myapi billing topup <amount> [--yes]
|
|
11
|
+
|
|
12
|
+
Amount is in whole dollars (e.g. "10" charges $10).
|
|
13
|
+
Confirmation is required for amounts of $50 or more — pass --yes to skip it.
|
|
14
|
+
|
|
15
|
+
Example: myapi billing topup 10`,
|
|
16
|
+
'setup': 'myapi billing setup',
|
|
17
|
+
};
|
|
18
|
+
export async function run(subcommand, args, flags) {
|
|
19
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
20
|
+
info(`Usage: myapi billing <subcommand>
|
|
21
|
+
|
|
22
|
+
Subcommands:
|
|
23
|
+
balance Check balance, credits, and payment method status
|
|
24
|
+
history View recent transactions and top-ups
|
|
25
|
+
topup Top up your balance (whole dollars)
|
|
26
|
+
setup Open a checkout link to add or update payment method`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
7
29
|
if (flags.help) {
|
|
8
|
-
|
|
30
|
+
const usage = SUBCOMMAND_USAGE[subcommand];
|
|
31
|
+
if (usage)
|
|
32
|
+
info(`Usage: ${usage}`);
|
|
33
|
+
else
|
|
34
|
+
info(`Unknown subcommand: ${subcommand}. Run "myapi billing --help" for the list.`);
|
|
9
35
|
return;
|
|
10
36
|
}
|
|
37
|
+
switch (subcommand) {
|
|
38
|
+
case 'balance': return balance(flags);
|
|
39
|
+
case 'history': return history(flags);
|
|
40
|
+
case 'topup': return topup(args[0], flags);
|
|
41
|
+
case 'setup': return setup(flags);
|
|
42
|
+
default: error(`Unknown subcommand: ${subcommand}. Run "myapi billing --help" for available subcommands.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export async function balance(flags) {
|
|
11
46
|
const config = requireConfig();
|
|
12
47
|
const result = await hq.getBalance(config.api_key);
|
|
13
48
|
if (flags.json) {
|
|
@@ -24,43 +59,31 @@ export async function balance(flags) {
|
|
|
24
59
|
info(`Balance: ${result.balance_display} | Credits: ${result.credits_display} (not usable for domains) | Payment method: ${pm}`);
|
|
25
60
|
}
|
|
26
61
|
export async function history(flags) {
|
|
27
|
-
if (flags.help) {
|
|
28
|
-
info('Usage: myapi billing history [--json]\n\nShows your recent billing transactions and top-ups.\n\nFlags:\n --json Output raw JSON');
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
62
|
const config = requireConfig();
|
|
32
63
|
const items = await hq.getBillingHistory(config.api_key);
|
|
33
64
|
if (flags.json) {
|
|
34
65
|
printJson(items);
|
|
35
66
|
return;
|
|
36
67
|
}
|
|
37
|
-
if (items.length === 0) {
|
|
38
|
-
info('No transactions yet.');
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
68
|
const formattedItems = items.map(item => ({
|
|
42
69
|
Type: item.type || 'unknown',
|
|
43
70
|
Amount: item.amount_display,
|
|
44
71
|
Status: item.status ? item.status.charAt(0).toUpperCase() + item.status.slice(1) : '',
|
|
45
72
|
Date: formatDate(item.created_at),
|
|
46
73
|
}));
|
|
47
|
-
printTable(formattedItems
|
|
74
|
+
printTable(formattedItems, {
|
|
75
|
+
flags,
|
|
76
|
+
empty: 'No transactions yet.',
|
|
77
|
+
});
|
|
48
78
|
}
|
|
49
79
|
export async function topup(amountStr, flags) {
|
|
50
|
-
if (flags.help) {
|
|
51
|
-
info('Usage: myapi billing topup <amount>\n\nAmount is in whole dollars (e.g. "10" charges $10).\nConfirmation is required for amounts of $50 or more. Use --yes to skip it.\nExample: myapi billing topup 10\n\nFlags:\n --yes Skip confirmation prompt for large amounts');
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
80
|
const amount = Math.round(parseFloat(amountStr));
|
|
55
81
|
if (!amountStr || isNaN(amount) || amount <= 0) {
|
|
56
|
-
error(
|
|
57
|
-
return;
|
|
82
|
+
error('Amount must be a positive whole number of dollars (e.g. myapi billing topup 10)');
|
|
58
83
|
}
|
|
59
84
|
if (!flags.yes && !flags.y && amount >= 50) {
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
rl.close();
|
|
63
|
-
if (ans.trim().toLowerCase() !== 'y' && ans.trim().toLowerCase() !== 'yes') {
|
|
85
|
+
const ok = await confirm(`› Charge $${amount} to your saved payment method? (y/N) `, false);
|
|
86
|
+
if (!ok) {
|
|
64
87
|
info('Cancelled.');
|
|
65
88
|
return;
|
|
66
89
|
}
|
|
@@ -69,11 +92,7 @@ export async function topup(amountStr, flags) {
|
|
|
69
92
|
const result = await hq.topUp(config.api_key, amount);
|
|
70
93
|
success(`Top up successful! New balance: ${result.new_balance_display}`);
|
|
71
94
|
}
|
|
72
|
-
export async function setup(
|
|
73
|
-
if (flags.help) {
|
|
74
|
-
info('Usage: myapi billing setup\n\nGenerates a secure checkout link to add or update your payment method.');
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
95
|
+
export async function setup(_flags) {
|
|
77
96
|
const config = requireConfig();
|
|
78
97
|
const result = await hq.setupPayment(config.api_key);
|
|
79
98
|
success(`Open this URL in your browser to set up payment:\n${result.url}`);
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
1
|
+
import type { FlagSchema } from '../flags.js';
|
|
2
|
+
import type { Flags } from '../helpers.js';
|
|
3
|
+
export declare const SCHEMA: FlagSchema;
|
|
4
|
+
export declare function setOrg(id: string, _flags: Flags, via?: string): Promise<void>;
|
|
5
|
+
export declare function setFunnel(id: string, _flags: Flags, via?: string): Promise<void>;
|
|
6
|
+
export declare function setDomain(domain: string, _flags: Flags, via?: string): Promise<void>;
|
|
7
|
+
export declare function view(flags: Flags, _via?: string): Promise<void>;
|
|
8
|
+
export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
|
package/dist/commands/config.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { hq, funnel as sdkFunnel } from '@myapihq/sdk';
|
|
2
2
|
import { requireConfig, saveConfig } from '../config.js';
|
|
3
|
-
import { success, error, info } from '../output.js';
|
|
3
|
+
import { success, error, info, printJson } from '../output.js';
|
|
4
|
+
export const SCHEMA = {
|
|
5
|
+
_via: 'string',
|
|
6
|
+
};
|
|
4
7
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
5
|
-
export async function setOrg(id,
|
|
6
|
-
if (!id
|
|
7
|
-
info(`Usage: myapi ${via} set-org <id
|
|
8
|
+
export async function setOrg(id, _flags, via = 'auth config') {
|
|
9
|
+
if (!id) {
|
|
10
|
+
info(`Usage: myapi ${via} set-org <id>`);
|
|
8
11
|
return;
|
|
9
12
|
}
|
|
10
13
|
if (!UUID_RE.test(id))
|
|
@@ -16,9 +19,9 @@ export async function setOrg(id, flags, via = 'auth config') {
|
|
|
16
19
|
saveConfig(config);
|
|
17
20
|
success(`Default organization set to: ${org.name || org.id}`);
|
|
18
21
|
}
|
|
19
|
-
export async function setFunnel(id,
|
|
20
|
-
if (!id
|
|
21
|
-
info(`Usage: myapi ${via} set-funnel <id
|
|
22
|
+
export async function setFunnel(id, _flags, via = 'auth config') {
|
|
23
|
+
if (!id) {
|
|
24
|
+
info(`Usage: myapi ${via} set-funnel <id>`);
|
|
22
25
|
return;
|
|
23
26
|
}
|
|
24
27
|
if (!UUID_RE.test(id))
|
|
@@ -34,9 +37,9 @@ export async function setFunnel(id, flags, via = 'auth config') {
|
|
|
34
37
|
saveConfig(config);
|
|
35
38
|
success(`Default funnel set to: ${funnelId}`);
|
|
36
39
|
}
|
|
37
|
-
export async function setDomain(domain,
|
|
38
|
-
if (!domain
|
|
39
|
-
info(`Usage: myapi ${via} set-domain <domain
|
|
40
|
+
export async function setDomain(domain, _flags, via = 'auth config') {
|
|
41
|
+
if (!domain) {
|
|
42
|
+
info(`Usage: myapi ${via} set-domain <domain>`);
|
|
40
43
|
return;
|
|
41
44
|
}
|
|
42
45
|
const config = requireConfig();
|
|
@@ -44,14 +47,9 @@ export async function setDomain(domain, flags, via = 'auth config') {
|
|
|
44
47
|
saveConfig(config);
|
|
45
48
|
success(`Default domain set to: ${domain}`);
|
|
46
49
|
}
|
|
47
|
-
export async function view(flags,
|
|
48
|
-
if (flags.help) {
|
|
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`);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
50
|
+
export async function view(flags, _via = 'auth config') {
|
|
52
51
|
const config = requireConfig();
|
|
53
52
|
if (flags.json) {
|
|
54
|
-
const { printJson } = await import('../output.js');
|
|
55
53
|
printJson({
|
|
56
54
|
default_org: config.default_org ?? null,
|
|
57
55
|
default_funnel: config.default_funnel ?? null,
|
|
@@ -63,20 +61,47 @@ export async function view(flags, via = 'auth config') {
|
|
|
63
61
|
info(`Default Funnel: ${config.default_funnel || 'Not set'}`);
|
|
64
62
|
info(`Default Domain: ${config.default_domain || 'Not set'}`);
|
|
65
63
|
}
|
|
64
|
+
// ── Dispatcher ───────────────────────────────────────────────────────────────
|
|
65
|
+
function subcommandUsage(via) {
|
|
66
|
+
return {
|
|
67
|
+
'view': `myapi ${via} view [--json]`,
|
|
68
|
+
'set-org': `myapi ${via} set-org <id>\n\nSets the default organization for all commands that require --org.\nThe ID is validated against the API before saving.`,
|
|
69
|
+
'set-funnel': `myapi ${via} set-funnel <id>\n\nSets the default funnel. Must belong to your current default org.\nThe ID is validated against the API before saving.`,
|
|
70
|
+
'set-domain': `myapi ${via} set-domain <domain>\n\nSets the default domain used by domain commands when the domain arg is omitted.`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
66
73
|
export async function run(subcommand, args, flags) {
|
|
67
74
|
const via = flags._via || 'auth config';
|
|
68
75
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
69
|
-
info(`Usage: myapi ${via} <subcommand
|
|
76
|
+
info(`Usage: myapi ${via} <subcommand>
|
|
77
|
+
|
|
78
|
+
Manages CLI defaults (org, funnel, domain) so you don't have to pass --org / --domain on every command.
|
|
79
|
+
|
|
80
|
+
Subcommands:
|
|
81
|
+
view Show current defaults
|
|
82
|
+
set-org Set default organization (validates access)
|
|
83
|
+
set-funnel Set default funnel (must be owned by default org)
|
|
84
|
+
set-domain Set default domain
|
|
85
|
+
|
|
86
|
+
Examples:
|
|
87
|
+
myapi ${via} set-org <id>
|
|
88
|
+
myapi ${via} set-funnel <id>
|
|
89
|
+
myapi ${via} view`);
|
|
70
90
|
return;
|
|
71
91
|
}
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
if (flags.help) {
|
|
93
|
+
const usage = subcommandUsage(via)[subcommand];
|
|
94
|
+
if (usage)
|
|
95
|
+
info(`Usage: ${usage}`);
|
|
96
|
+
else
|
|
97
|
+
info(`Unknown subcommand: ${subcommand}. Run "myapi ${via} --help" for the list.`);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
switch (subcommand) {
|
|
101
|
+
case 'view': return view(flags, via);
|
|
102
|
+
case 'set-org': return setOrg(args[0], flags, via);
|
|
103
|
+
case 'set-funnel': return setFunnel(args[0], flags, via);
|
|
104
|
+
case 'set-domain': return setDomain(args[0], flags, via);
|
|
105
|
+
default: error(`Unknown subcommand: ${subcommand}. Run "myapi ${via} --help" for a list of valid subcommands.`);
|
|
106
|
+
}
|
|
82
107
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function
|
|
9
|
-
export declare function
|
|
1
|
+
import type { FlagSchema } from '../flags.js';
|
|
2
|
+
import { type Flags } from '../helpers.js';
|
|
3
|
+
export declare const SCHEMA: FlagSchema;
|
|
4
|
+
export declare function check(domainArg: string, flags: Flags): Promise<void>;
|
|
5
|
+
export declare function register(domainArg: string, flags: Flags): Promise<void>;
|
|
6
|
+
export declare function list(flags: Flags): Promise<void>;
|
|
7
|
+
export declare function assign(domainArg: string, flags: Flags): Promise<void>;
|
|
8
|
+
export declare function unassign(domainArg: string, flags: Flags): Promise<void>;
|
|
9
|
+
export declare function status(domainArg: string, flags: Flags): Promise<void>;
|
|
10
|
+
export declare function settings(domainArg: string, flags: Flags): Promise<void>;
|
|
11
|
+
export declare function updateSettings(domainArg: string, flags: Flags): Promise<void>;
|
|
12
|
+
export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
|