@myapihq/cli 1.3.12 → 2.0.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/account.d.ts +7 -1
- package/dist/commands/account.js +356 -18
- package/dist/commands/authproduct.d.ts +7 -0
- package/dist/commands/authproduct.js +286 -0
- package/dist/commands/billing.js +1 -1
- package/dist/commands/config.js +1 -1
- package/dist/commands/container.d.ts +1 -0
- package/dist/commands/container.js +115 -11
- package/dist/commands/domain.js +2 -2
- package/dist/commands/email/index.js +0 -13
- package/dist/commands/fn.d.ts +1 -0
- package/dist/commands/fn.js +64 -12
- package/dist/commands/keys.js +3 -3
- package/dist/commands/queue.d.ts +1 -0
- package/dist/commands/queue.js +10 -0
- package/dist/commands/setup.js +8 -8
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.js +11 -27
- package/dist/commands/storage.js +3 -1
- package/dist/commands/workflow.js +21 -6
- package/dist/completion.js +5 -4
- package/dist/config.js +1 -1
- package/dist/exposes.test.js +1 -2
- package/dist/index.js +31 -28
- package/dist/registrant.js +5 -5
- package/dist/sdk-queue.test.js +3 -2
- package/dist/skills/my-api-hq/SKILL.md +15 -12
- package/dist/skills/my-auth-api/README.md +33 -0
- package/dist/skills/my-auth-api/SKILL.md +112 -0
- package/dist/skills/my-auth-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-auth-api/openapi/.gitkeep +0 -0
- package/dist/skills/my-crm-api/SKILL.md +1 -1
- package/dist/skills/my-domain-api/SKILL.md +4 -4
- package/dist/skills/my-email-api/README.md +1 -1
- package/dist/skills/my-email-api/SKILL.md +7 -18
- package/dist/skills/my-email-api/claude/.claude-plugin/plugin.json +1 -1
- package/dist/skills/my-email-verify-api/SKILL.md +1 -1
- package/dist/skills/my-email-verify-api/claude/.claude-plugin/plugin.json +1 -1
- package/dist/skills/my-git-api/README.md +43 -0
- package/dist/skills/my-git-api/SKILL.md +115 -0
- package/dist/skills/my-git-api/claude/.claude-plugin/plugin.json +6 -0
- package/dist/skills/my-git-api/openapi/.gitkeep +0 -0
- package/dist/skills/my-llm-api/claude/.claude-plugin/plugin.json +1 -1
- package/package.json +5 -4
- package/dist/commands/auth.d.ts +0 -11
- package/dist/commands/auth.js +0 -345
- package/dist/commands/email/campaign.d.ts +0 -4
- package/dist/commands/email/campaign.js +0 -200
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { FlagSchema } from '../flags.js';
|
|
2
2
|
import type { Flags } from '../helpers.js';
|
|
3
3
|
import type { Exposes } from '../exposes.js';
|
|
4
|
-
export declare const SCHEMA: FlagSchema;
|
|
5
4
|
export declare const EXPOSES: Exposes;
|
|
5
|
+
export declare const SCHEMA: FlagSchema;
|
|
6
|
+
export declare const HELP = "Usage: myapi account <subcommand>\n\nSubcommands:\n api-keys Manage API keys \u00B7 list / create / revoke\n config Manage CLI defaults (org, funnel, domain) \u00B7 supports set-org / set-funnel / set-domain\n import-key Import an existing API key non-interactively\n install-skills DEPRECATED \u2014 use `myapi install-skills` instead\n keys Alias for api-keys\n link [email] Upgrade anonymous account to registered (or add a second session)\n Use myapi account setup to create a completely new account\n mailing-address Get or set the account's mailing address (CAN-SPAM)\n registrant Manage stored WHOIS contact info for domain registration \u00B7 set / get / clear\n setup Configure your account\n switch [index] Switch active account by index or email\n whoami Show current account \u00B7 supports --json";
|
|
7
|
+
export declare const INSTALL_SKILLS_HELP = "Usage: myapi install-skills\n\nInstalls the MyAPI skills pack for AI coding agents (Claude, Codex, Gemini, \u2026).\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.\n\nNote: `myapi account install-skills` is deprecated and will be removed in the next minor.\nUse `myapi install-skills` going forward.";
|
|
8
|
+
export declare function link(flags?: Flags, emailArg?: string): Promise<void>;
|
|
9
|
+
export declare function whoami(flags?: Flags): Promise<void>;
|
|
10
|
+
export declare function switchCmd(flags?: Flags, indexArg?: string): Promise<void>;
|
|
11
|
+
export declare function registrant(sub: string | undefined, flags?: Flags): Promise<void>;
|
|
6
12
|
export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
|
package/dist/commands/account.js
CHANGED
|
@@ -1,16 +1,104 @@
|
|
|
1
|
-
// `myapi account` — account-scoped operations
|
|
1
|
+
// `myapi account` — operator/account-scoped operations: your MyAPI account and
|
|
2
|
+
// its sessions (setup/link/switch/whoami), API keys (via `keys`), CLI config,
|
|
3
|
+
// the WHOIS registrant, and the CAN-SPAM mailing address.
|
|
2
4
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
5
|
+
// Formerly `myapi auth`. As of v2, `auth` is the end-user auth product
|
|
6
|
+
// (my-auth-api); everything operator-facing lives here. See
|
|
7
|
+
// docs/decision-auth-product-and-namespace.
|
|
8
|
+
import { loadConfig, saveConfig, addAccount, switchAccount, listAccounts, requireConfig } from '../config.js';
|
|
9
|
+
import { info, success, error, printJson } from '../output.js';
|
|
10
|
+
import { ask, confirm, withReadline } from '../prompt.js';
|
|
11
|
+
import { installSkills } from './setup.js';
|
|
12
|
+
import { hq } from '@myapihq/sdk';
|
|
13
|
+
import { promptAndSave as promptAndSaveRegistrant } from '../registrant.js';
|
|
10
14
|
export const EXPOSES = [
|
|
15
|
+
'PATCH /hq/account/upgrade',
|
|
16
|
+
'POST /hq/account/send-code',
|
|
17
|
+
'POST /hq/account/verify-code',
|
|
18
|
+
'GET /hq/billing/balance',
|
|
19
|
+
'GET /hq/account/free-tier',
|
|
11
20
|
'GET /hq/account/mailing-address',
|
|
12
21
|
'PATCH /hq/account/mailing-address',
|
|
13
22
|
];
|
|
23
|
+
export const SCHEMA = {
|
|
24
|
+
'install-skills': 'boolean',
|
|
25
|
+
'no-skills': 'boolean',
|
|
26
|
+
anonymous: 'boolean',
|
|
27
|
+
anon: 'boolean',
|
|
28
|
+
};
|
|
29
|
+
export const HELP = `Usage: myapi account <subcommand>
|
|
30
|
+
|
|
31
|
+
Subcommands:
|
|
32
|
+
api-keys Manage API keys · list / create / revoke
|
|
33
|
+
config Manage CLI defaults (org, funnel, domain) · supports set-org / set-funnel / set-domain
|
|
34
|
+
import-key Import an existing API key non-interactively
|
|
35
|
+
install-skills DEPRECATED — use \`myapi install-skills\` instead
|
|
36
|
+
keys Alias for api-keys
|
|
37
|
+
link [email] Upgrade anonymous account to registered (or add a second session)
|
|
38
|
+
Use myapi account setup to create a completely new account
|
|
39
|
+
mailing-address Get or set the account's mailing address (CAN-SPAM)
|
|
40
|
+
registrant Manage stored WHOIS contact info for domain registration · set / get / clear
|
|
41
|
+
setup Configure your account
|
|
42
|
+
switch [index] Switch active account by index or email
|
|
43
|
+
whoami Show current account · supports --json`;
|
|
44
|
+
export const INSTALL_SKILLS_HELP = `Usage: myapi install-skills
|
|
45
|
+
|
|
46
|
+
Installs the MyAPI skills pack for AI coding agents (Claude, Codex, Gemini, …).
|
|
47
|
+
|
|
48
|
+
This command writes skill definition files to:
|
|
49
|
+
~/.agents/skills/myapi/
|
|
50
|
+
|
|
51
|
+
And creates symlinks in the appropriate agent config directories:
|
|
52
|
+
~/.claude/ (Claude)
|
|
53
|
+
~/.gemini/ (Gemini)
|
|
54
|
+
~/.cursor/ (Cursor, if detected)
|
|
55
|
+
|
|
56
|
+
These files teach agents how to use the MyAPI CLI and API directly.
|
|
57
|
+
Run this command again to update existing skills to the latest version.
|
|
58
|
+
|
|
59
|
+
Note: \`myapi account install-skills\` is deprecated and will be removed in the next minor.
|
|
60
|
+
Use \`myapi install-skills\` going forward.`;
|
|
61
|
+
const LINK_HELP = `Usage: myapi account link [email]
|
|
62
|
+
|
|
63
|
+
Behavior depends on whether the email is new or already registered:
|
|
64
|
+
|
|
65
|
+
New email: Attaches it to your current anonymous account, upgrading it
|
|
66
|
+
to a registered account. A one-time code is sent to confirm.
|
|
67
|
+
|
|
68
|
+
Existing email: Does NOT merge accounts. The existing account is added as a
|
|
69
|
+
second active session — your anonymous account stays separate.
|
|
70
|
+
Switch between sessions with: myapi account switch
|
|
71
|
+
|
|
72
|
+
To create a completely new account from scratch, use: myapi account setup`;
|
|
73
|
+
const WHOAMI_HELP = `Usage: myapi account whoami [--json]
|
|
74
|
+
|
|
75
|
+
Displays the active account details: email, account ID, default org,
|
|
76
|
+
default funnel, account type, and current balance.
|
|
77
|
+
|
|
78
|
+
Flags:
|
|
79
|
+
--json Output raw JSON`;
|
|
80
|
+
const SWITCH_HELP = `Usage: myapi account switch [index|email]
|
|
81
|
+
|
|
82
|
+
Switches the active account. Run without arguments to see a numbered list
|
|
83
|
+
of accounts and choose interactively.
|
|
84
|
+
|
|
85
|
+
Pass an index number or email address to switch non-interactively:
|
|
86
|
+
myapi account switch 2
|
|
87
|
+
myapi account switch you@example.com
|
|
88
|
+
|
|
89
|
+
Note: index numbers can shift as accounts are added or removed.
|
|
90
|
+
Use email as a stable identifier in scripts.`;
|
|
91
|
+
const REGISTRANT_HELP = `Usage: myapi account registrant <set|get|clear>
|
|
92
|
+
|
|
93
|
+
Manages the locally-stored WHOIS contact info that \`myapi domain register\`
|
|
94
|
+
requires (ICANN-mandated). Stored in ~/.myapi/config.json under the active
|
|
95
|
+
account; never synced to the backend except as a per-request field.
|
|
96
|
+
|
|
97
|
+
Subcommands:
|
|
98
|
+
clear Remove the stored registrant from the active account.
|
|
99
|
+
get Print the stored registrant (or "not set").
|
|
100
|
+
set Interactive prompt for all fields. Or pass --registrant-json
|
|
101
|
+
'<json>' to set non-interactively (agent-friendly).`;
|
|
14
102
|
const SUBCOMMAND_USAGE = {
|
|
15
103
|
'mailing-address': `myapi account mailing-address Show current value (null if unset)
|
|
16
104
|
myapi account mailing-address "<address>" Set the mailing address
|
|
@@ -20,12 +108,266 @@ The mailing address is required for transactional email (CAN-SPAM):
|
|
|
20
108
|
Pass the full postal address as a single string — e.g.
|
|
21
109
|
"123 Main St, Springfield, IL 62701, USA".`,
|
|
22
110
|
};
|
|
111
|
+
// Resolve the user's "install skills?" preference: explicit flag wins, else prompt.
|
|
112
|
+
async function resolveSkillsPreference(flags) {
|
|
113
|
+
if (flags['install-skills'])
|
|
114
|
+
return true;
|
|
115
|
+
if (flags['no-skills'])
|
|
116
|
+
return false;
|
|
117
|
+
return confirm('› Install the MyAPI skills pack? (Y/n) ', true);
|
|
118
|
+
}
|
|
119
|
+
// myapi account link — upgrade anonymous session to registered account.
|
|
120
|
+
export async function link(flags = {}, emailArg) {
|
|
121
|
+
if (flags.help) {
|
|
122
|
+
info(LINK_HELP);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const config = loadConfig();
|
|
126
|
+
if (!config?.api_key)
|
|
127
|
+
error('Not configured. Run: myapi account setup');
|
|
128
|
+
if (!config.is_anonymous)
|
|
129
|
+
error('Already registered. Use your existing account.');
|
|
130
|
+
await withReadline(async () => {
|
|
131
|
+
const email = emailArg || await ask('› Email? ');
|
|
132
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email))
|
|
133
|
+
error(`Invalid email address: "${email}".`);
|
|
134
|
+
let upgradeOk = true;
|
|
135
|
+
try {
|
|
136
|
+
await hq.upgradeAccount(config.api_key, email);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
if (err.message !== 'EMAIL_TAKEN')
|
|
140
|
+
throw err;
|
|
141
|
+
upgradeOk = false;
|
|
142
|
+
info(`› That email already has an account — accounts cannot be merged.`);
|
|
143
|
+
info(`› Your anonymous account will be kept and you can switch back to it anytime.`);
|
|
144
|
+
if (!await confirm('› Sign in and add it as a second account? (Y/n) ', true))
|
|
145
|
+
return;
|
|
146
|
+
await hq.sendCode(email);
|
|
147
|
+
}
|
|
148
|
+
info(`› Sent a code to ${email} · paste it below`);
|
|
149
|
+
const code = await ask('› Code? ');
|
|
150
|
+
const data = await hq.verifyCode(email, code);
|
|
151
|
+
const wantsSkills = await resolveSkillsPreference(flags);
|
|
152
|
+
if (upgradeOk) {
|
|
153
|
+
saveConfig({
|
|
154
|
+
...config,
|
|
155
|
+
api_key: data.api_key,
|
|
156
|
+
account_id: data.account_id,
|
|
157
|
+
email,
|
|
158
|
+
default_org: data.default_org || config.default_org,
|
|
159
|
+
default_funnel: data.default_funnel || config.default_funnel,
|
|
160
|
+
is_anonymous: false,
|
|
161
|
+
skills_installed: wantsSkills,
|
|
162
|
+
});
|
|
163
|
+
success(`› Welcome! Account upgraded · ${email}`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
const idx = addAccount({
|
|
167
|
+
api_key: data.api_key,
|
|
168
|
+
account_id: data.account_id,
|
|
169
|
+
email,
|
|
170
|
+
default_org: data.default_org,
|
|
171
|
+
default_funnel: data.default_funnel,
|
|
172
|
+
is_anonymous: false,
|
|
173
|
+
skills_installed: wantsSkills,
|
|
174
|
+
});
|
|
175
|
+
success(`› Signed in · ${email} (account #${idx + 1})`);
|
|
176
|
+
info(`› Use "myapi account switch" to toggle between accounts.`);
|
|
177
|
+
}
|
|
178
|
+
if (wantsSkills)
|
|
179
|
+
await installSkills();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
// myapi account whoami — show current session info.
|
|
183
|
+
export async function whoami(flags = {}) {
|
|
184
|
+
if (flags.help) {
|
|
185
|
+
info(WHOAMI_HELP);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const config = loadConfig();
|
|
189
|
+
if (!config?.api_key)
|
|
190
|
+
error('Not configured. Run: myapi account setup');
|
|
191
|
+
let balance = null;
|
|
192
|
+
// Backend returns an array of per-service entries, or null. The SDK type
|
|
193
|
+
// used to lie about this (claimed scalar) — see hq.ts FreeTierEntry.
|
|
194
|
+
let freeTier = null;
|
|
195
|
+
// Note any auth-rejection from the balance probe so we don't silently
|
|
196
|
+
// print stale cached config when the key has actually been invalidated
|
|
197
|
+
// server-side. Other failures (endpoint missing, transient 500s) stay
|
|
198
|
+
// swallowed — balance is best-effort, not a key-validation primitive.
|
|
199
|
+
let keyRejected = false;
|
|
200
|
+
try {
|
|
201
|
+
balance = await hq.getBalance(config.api_key);
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
if (err?.status === 401 || /invalid api key/i.test(err?.code ?? ''))
|
|
205
|
+
keyRejected = true;
|
|
206
|
+
}
|
|
207
|
+
// Free-tier query is best-effort — backend may not have it for every
|
|
208
|
+
// account type, and surfacing nothing is better than failing whoami.
|
|
209
|
+
try {
|
|
210
|
+
freeTier = await hq.getFreeTier(config.api_key);
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
if (err?.status === 401 || /invalid api key/i.test(err?.code ?? ''))
|
|
214
|
+
keyRejected = true;
|
|
215
|
+
}
|
|
216
|
+
if (flags.json) {
|
|
217
|
+
printJson({
|
|
218
|
+
email: config.email ?? null,
|
|
219
|
+
account_id: config.account_id,
|
|
220
|
+
default_org: config.default_org ?? null,
|
|
221
|
+
default_funnel: config.default_funnel ?? null,
|
|
222
|
+
is_anonymous: config.is_anonymous ?? false,
|
|
223
|
+
balance: balance?.balance_display ?? null,
|
|
224
|
+
credits: balance?.credits_display ?? null,
|
|
225
|
+
free_tier: freeTier ?? null,
|
|
226
|
+
key_rejected: keyRejected,
|
|
227
|
+
});
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (keyRejected) {
|
|
231
|
+
info('⚠ The backend rejected your API key. The values below are from local config and may not match server state.');
|
|
232
|
+
info(' Run: myapi account setup');
|
|
233
|
+
info('');
|
|
234
|
+
}
|
|
235
|
+
if (config.email)
|
|
236
|
+
info(`Email: ${config.email}`);
|
|
237
|
+
info(`Account: ${config.account_id}`);
|
|
238
|
+
info(`Org: ${config.default_org ?? '(none)'}`);
|
|
239
|
+
info(`Funnel: ${config.default_funnel ?? '(none)'}`);
|
|
240
|
+
info(`Type: ${config.is_anonymous ? 'anonymous' : 'registered'}`);
|
|
241
|
+
info(`Balance: ${balance ? `${balance.balance_display} | Credits: ${balance.credits_display} (not usable for domains)` : '(unavailable)'}`);
|
|
242
|
+
if (Array.isArray(freeTier) && freeTier.length > 0) {
|
|
243
|
+
const parts = freeTier
|
|
244
|
+
.filter((e) => e && typeof e.service === 'string')
|
|
245
|
+
.map((e) => `${e.service} ${e.used ?? 0}/${e.allowance ?? '?'}`);
|
|
246
|
+
if (parts.length > 0)
|
|
247
|
+
info(`FreeTier: ${parts.join(' · ')}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// myapi account switch [index] — switch between saved accounts.
|
|
251
|
+
export async function switchCmd(flags = {}, indexArg) {
|
|
252
|
+
if (flags.help) {
|
|
253
|
+
info(SWITCH_HELP);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const accounts = listAccounts();
|
|
257
|
+
if (accounts.length === 0)
|
|
258
|
+
error('No accounts configured. Run: myapi account setup');
|
|
259
|
+
if (accounts.length === 1) {
|
|
260
|
+
info(`Only one account configured: ${accounts[0].email ?? accounts[0].account_id}`);
|
|
261
|
+
info('To add another account, run: myapi account setup');
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
info('Accounts:');
|
|
265
|
+
for (const a of accounts) {
|
|
266
|
+
const label = a.email ?? (a.is_anonymous ? `anonymous · ${a.account_id.slice(0, 8)}` : a.account_id.slice(0, 8));
|
|
267
|
+
const marker = a.active ? ' ◀ active' : '';
|
|
268
|
+
info(` ${a.index + 1}. ${label}${marker}`);
|
|
269
|
+
}
|
|
270
|
+
let idxStr = indexArg ?? '';
|
|
271
|
+
if (!idxStr) {
|
|
272
|
+
idxStr = await ask(`› Switch to account (1-${accounts.length})? `);
|
|
273
|
+
}
|
|
274
|
+
// Support email as a stable identifier
|
|
275
|
+
let idx;
|
|
276
|
+
const byEmail = accounts.find(a => a.email && a.email.toLowerCase() === idxStr.toLowerCase());
|
|
277
|
+
if (byEmail) {
|
|
278
|
+
idx = byEmail.index;
|
|
279
|
+
}
|
|
280
|
+
else if (idxStr.includes('@')) {
|
|
281
|
+
error(`No account found with email "${idxStr}". Run "myapi account switch" to list configured accounts.`);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
idx = parseInt(idxStr, 10) - 1;
|
|
285
|
+
if (isNaN(idx) || idx < 0 || idx >= accounts.length) {
|
|
286
|
+
error(`Invalid selection "${idxStr}". Use an index number (1-${accounts.length}) or an email address.`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (switchAccount(idx)) {
|
|
290
|
+
const a = accounts[idx];
|
|
291
|
+
success(`› Switched to ${a.email ?? a.account_id}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// ── myapi account registrant <set|get|clear> ─────────────────────────────────
|
|
295
|
+
//
|
|
296
|
+
// Manages the locally-stored WHOIS registrant info that `myapi domain
|
|
297
|
+
// register` injects into every call. `set` is the one-time interactive
|
|
298
|
+
// setup; `--registrant-json` is the agent-friendly bypass. `get` and
|
|
299
|
+
// `clear` are housekeeping.
|
|
300
|
+
export async function registrant(sub, flags = {}) {
|
|
301
|
+
if (flags.help || !sub) {
|
|
302
|
+
info(REGISTRANT_HELP);
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const config = requireConfig();
|
|
306
|
+
switch (sub) {
|
|
307
|
+
case 'set': {
|
|
308
|
+
// Agent path: --registrant-json '<inline>' writes directly without prompting.
|
|
309
|
+
const inlineJson = typeof flags['registrant-json'] === 'string' ? flags['registrant-json'] : null;
|
|
310
|
+
if (inlineJson) {
|
|
311
|
+
let parsed;
|
|
312
|
+
try {
|
|
313
|
+
parsed = JSON.parse(inlineJson);
|
|
314
|
+
}
|
|
315
|
+
catch (e) {
|
|
316
|
+
error(`--registrant-json is not valid JSON: ${e.message}`);
|
|
317
|
+
}
|
|
318
|
+
const required = ['name', 'email', 'phone', 'street', 'city', 'postal_code', 'country_code'];
|
|
319
|
+
const missing = required.filter(k => !parsed[k]);
|
|
320
|
+
if (missing.length > 0)
|
|
321
|
+
error(`Missing required field(s): ${missing.join(', ')}`);
|
|
322
|
+
saveConfig({ ...config, registrant: parsed });
|
|
323
|
+
success('Saved registrant from --registrant-json.');
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const r = await promptAndSaveRegistrant(config, config.registrant);
|
|
327
|
+
success(`Saved. ${r.name} · ${r.email} · ${r.country_code}`);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
case 'get': {
|
|
331
|
+
if (!config.registrant) {
|
|
332
|
+
info('No registrant stored. Set one with: myapi account registrant set');
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (flags.json) {
|
|
336
|
+
printJson(config.registrant);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
const r = config.registrant;
|
|
340
|
+
info(`Name: ${r.name}`);
|
|
341
|
+
info(`Email: ${r.email}`);
|
|
342
|
+
info(`Phone: ${r.phone}`);
|
|
343
|
+
info(`Street: ${r.street}`);
|
|
344
|
+
info(`City: ${r.city}`);
|
|
345
|
+
if (r.state)
|
|
346
|
+
info(`State: ${r.state}`);
|
|
347
|
+
info(`Postal code: ${r.postal_code}`);
|
|
348
|
+
info(`Country: ${r.country_code}`);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
case 'clear': {
|
|
352
|
+
if (!config.registrant) {
|
|
353
|
+
info('No registrant stored — nothing to clear.');
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const { registrant: _drop, ...rest } = config;
|
|
357
|
+
saveConfig(rest);
|
|
358
|
+
success('Cleared.');
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
default:
|
|
362
|
+
error(`Unknown subcommand: ${sub}. Run \`myapi account registrant --help\` for the list.`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
23
365
|
async function mailingAddress(args, flags) {
|
|
24
366
|
const config = requireConfig();
|
|
25
367
|
// Positional arg present → set. Absent → get.
|
|
26
368
|
const value = args[0];
|
|
27
369
|
if (value === undefined) {
|
|
28
|
-
const res = await
|
|
370
|
+
const res = await hq.getMailingAddress(config.api_key);
|
|
29
371
|
if (flags.json) {
|
|
30
372
|
printJson(res);
|
|
31
373
|
return;
|
|
@@ -45,7 +387,7 @@ async function mailingAddress(args, flags) {
|
|
|
45
387
|
if (!trimmed) {
|
|
46
388
|
error('Mailing address must be a non-empty string. Example: "123 Main St, Springfield, IL 62701, USA".');
|
|
47
389
|
}
|
|
48
|
-
const res = await
|
|
390
|
+
const res = await hq.setMailingAddress(config.api_key, trimmed);
|
|
49
391
|
if (flags.json) {
|
|
50
392
|
printJson(res);
|
|
51
393
|
return;
|
|
@@ -54,19 +396,15 @@ async function mailingAddress(args, flags) {
|
|
|
54
396
|
}
|
|
55
397
|
export async function run(subcommand, args, flags) {
|
|
56
398
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
57
|
-
info(
|
|
58
|
-
|
|
59
|
-
Subcommands:
|
|
60
|
-
mailing-address Get or set the account's mailing address (CAN-SPAM)`);
|
|
399
|
+
info(HELP);
|
|
61
400
|
return;
|
|
62
401
|
}
|
|
63
402
|
if (flags.help) {
|
|
64
403
|
const usage = SUBCOMMAND_USAGE[subcommand];
|
|
65
|
-
if (usage)
|
|
404
|
+
if (usage) {
|
|
66
405
|
info(`Usage: ${usage}`);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
70
408
|
}
|
|
71
409
|
switch (subcommand) {
|
|
72
410
|
case 'mailing-address': return mailingAddress(args, flags);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FlagSchema } from '../flags.js';
|
|
2
|
+
import { type Flags } from '../helpers.js';
|
|
3
|
+
import type { Exposes } from '../exposes.js';
|
|
4
|
+
export declare const SCHEMA: FlagSchema;
|
|
5
|
+
export declare const EXPOSES: Exposes;
|
|
6
|
+
export declare const HELP = "Usage: myapi auth <subcommand>\n\nAuthentication for your app's end users \u2014 a managed OIDC identity provider\n(\u00E0 la Kinde/Auth0). One auth tenant per org; register OIDC clients (apps)\nagainst it; sign users in via the hosted login page or the JS SDK; verify\ntokens locally against the tenant JWKS.\n\nEnd users sign in with managed Google, email/password, or magic links \u2014 pick\nwhich via `tenant create --connections`. (Operator/account commands moved to\n`myapi account`.)\n\nSubcommands:\n client Register and list OIDC clients (your apps)\n domain Serve auth on your own domain (auth.acme.com)\n tenant Show or create your org's OIDC auth tenant (+ sign-in methods)\n usage Monthly active users (MAU) for the current period";
|
|
7
|
+
export declare function run(subcommand: string | undefined, args: string[], flags: Flags): Promise<void>;
|