@myapihq/cli 1.0.49 → 1.0.50
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 +1 -1
- package/dist/commands/auth.js +3 -3
- package/dist/commands/setup.js +2 -3
- package/dist/index.js +6 -6
- package/package.json +1 -1
- package/src/commands/auth.ts +3 -3
- package/src/commands/setup.ts +2 -3
- package/src/index.ts +5 -5
package/dist/commands/auth.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function link(flags?: Record<string, string | boolean>): Promise<void>;
|
|
2
2
|
export declare function whoami(flags?: Record<string, string | boolean>): Promise<void>;
|
|
3
3
|
export declare function switchCmd(flags?: Record<string, string | boolean>, indexArg?: string): Promise<void>;
|
package/dist/commands/auth.js
CHANGED
|
@@ -38,10 +38,10 @@ async function patch(path, body, apiKey) {
|
|
|
38
38
|
throw new Error(json.error ?? `HTTP ${res.status}`);
|
|
39
39
|
return json.data ?? json;
|
|
40
40
|
}
|
|
41
|
-
// myapi auth
|
|
42
|
-
export async function
|
|
41
|
+
// myapi auth link — upgrade anonymous session to registered account.
|
|
42
|
+
export async function link(flags = {}) {
|
|
43
43
|
if (flags.help) {
|
|
44
|
-
info('Usage: myapi auth
|
|
44
|
+
info('Usage: myapi auth link\n\nLinks an email to your anonymous account, upgrading it to a registered account.\nA verification code will be sent — you must enter it interactively.\nIf the email is already in use, adds it as a second account instead.');
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
const config = loadConfig();
|
package/dist/commands/setup.js
CHANGED
|
@@ -208,8 +208,7 @@ export async function setup(flags = {}) {
|
|
|
208
208
|
subdomainUrl = data.subdomain_url;
|
|
209
209
|
isAnonymous = true;
|
|
210
210
|
}
|
|
211
|
-
const
|
|
212
|
-
const wantsSkills = skillsFromFlag !== null ? skillsFromFlag : yn(skillsAns);
|
|
211
|
+
const wantsSkills = skillsFromFlag !== null ? skillsFromFlag : flags.yes ? true : yn(await ask(rl, '› Install the MyAPI skills pack? (Y/n) '));
|
|
213
212
|
addAccount({
|
|
214
213
|
api_key: apiKey,
|
|
215
214
|
account_id: accountId,
|
|
@@ -270,7 +269,7 @@ export async function setup(flags = {}) {
|
|
|
270
269
|
success('› Setup complete. No card, no email, ready to ship.');
|
|
271
270
|
if (subdomainUrl)
|
|
272
271
|
info(`› Your funnel: ${subdomainUrl}`);
|
|
273
|
-
info('› Upgrade anytime — myapi auth
|
|
272
|
+
info('› Upgrade anytime — myapi auth link');
|
|
274
273
|
}
|
|
275
274
|
else {
|
|
276
275
|
success(`› Setup complete. Org ${defaultOrg} ready · $5.00 free credits added.`);
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ async function main() {
|
|
|
42
42
|
switch (command) {
|
|
43
43
|
case 'auth':
|
|
44
44
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
45
|
-
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\n
|
|
45
|
+
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\n link Link an email to upgrade your anonymous account\n switch [index] Switch between accounts\n config Manage CLI defaults (org_id, domain…)\n install-skills Install the MyAPI skills pack\n api-keys Manage API keys');
|
|
46
46
|
break;
|
|
47
47
|
}
|
|
48
48
|
if (subcommand === 'setup')
|
|
@@ -51,8 +51,8 @@ async function main() {
|
|
|
51
51
|
await setupCmd.importKey(restArgs[0], flags);
|
|
52
52
|
else if (subcommand === 'whoami')
|
|
53
53
|
await authCmd.whoami(flags);
|
|
54
|
-
else if (subcommand === '
|
|
55
|
-
await authCmd.
|
|
54
|
+
else if (subcommand === 'link')
|
|
55
|
+
await authCmd.link(flags);
|
|
56
56
|
else if (subcommand === 'switch')
|
|
57
57
|
await authCmd.switchCmd(flags, restArgs[0]);
|
|
58
58
|
else if (subcommand === 'install-skills') {
|
|
@@ -144,9 +144,9 @@ async function main() {
|
|
|
144
144
|
error('Invalid API key. Run: myapi auth setup');
|
|
145
145
|
else if (err.status === 402) {
|
|
146
146
|
if (err.code === 'REGISTRATION_REQUIRED')
|
|
147
|
-
error('A verified email is required. Run: myapi auth
|
|
147
|
+
error('A verified email is required. Run: myapi auth link');
|
|
148
148
|
else if (err.code === 'UPGRADE_REQUIRED')
|
|
149
|
-
error('A verified email is required. Run: myapi auth
|
|
149
|
+
error('A verified email is required. Run: myapi auth link');
|
|
150
150
|
else
|
|
151
151
|
error(`Insufficient balance. Run: myapi billing topup <amount>`);
|
|
152
152
|
}
|
|
@@ -172,7 +172,7 @@ Usage: myapi <command> [subcommand] [args]
|
|
|
172
172
|
myapi --version
|
|
173
173
|
|
|
174
174
|
Commands:
|
|
175
|
-
auth Manage account · setup · whoami ·
|
|
175
|
+
auth Manage account · setup · whoami · link
|
|
176
176
|
billing Check balance and manage billing
|
|
177
177
|
org Manage organizations
|
|
178
178
|
update Update CLI and skills to the latest version
|
package/package.json
CHANGED
package/src/commands/auth.ts
CHANGED
|
@@ -41,10 +41,10 @@ async function patch(path: string, body: unknown, apiKey: string): Promise<unkno
|
|
|
41
41
|
return json.data ?? json;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// myapi auth
|
|
45
|
-
export async function
|
|
44
|
+
// myapi auth link — upgrade anonymous session to registered account.
|
|
45
|
+
export async function link(flags: Record<string, string | boolean> = {}) {
|
|
46
46
|
if (flags.help) {
|
|
47
|
-
info('Usage: myapi auth
|
|
47
|
+
info('Usage: myapi auth link\n\nLinks an email to your anonymous account, upgrading it to a registered account.\nA verification code will be sent — you must enter it interactively.\nIf the email is already in use, adds it as a second account instead.');
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
50
|
const config = loadConfig();
|
package/src/commands/setup.ts
CHANGED
|
@@ -258,8 +258,7 @@ export async function setup(flags: Record<string, string | boolean> = {}) {
|
|
|
258
258
|
isAnonymous = true;
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
const
|
|
262
|
-
const wantsSkills = skillsFromFlag !== null ? skillsFromFlag : yn(skillsAns);
|
|
261
|
+
const wantsSkills = skillsFromFlag !== null ? skillsFromFlag : flags.yes ? true : yn(await ask(rl, '› Install the MyAPI skills pack? (Y/n) '));
|
|
263
262
|
|
|
264
263
|
addAccount({
|
|
265
264
|
api_key: apiKey,
|
|
@@ -325,7 +324,7 @@ export async function setup(flags: Record<string, string | boolean> = {}) {
|
|
|
325
324
|
if (isAnonymous) {
|
|
326
325
|
success('› Setup complete. No card, no email, ready to ship.');
|
|
327
326
|
if (subdomainUrl) info(`› Your funnel: ${subdomainUrl}`);
|
|
328
|
-
info('› Upgrade anytime — myapi auth
|
|
327
|
+
info('› Upgrade anytime — myapi auth link');
|
|
329
328
|
} else {
|
|
330
329
|
success(`› Setup complete. Org ${defaultOrg} ready · $5.00 free credits added.`);
|
|
331
330
|
}
|
package/src/index.ts
CHANGED
|
@@ -48,13 +48,13 @@ async function main() {
|
|
|
48
48
|
switch (command) {
|
|
49
49
|
case 'auth':
|
|
50
50
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
51
|
-
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\n
|
|
51
|
+
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\n link Link an email to upgrade your anonymous account\n switch [index] Switch between accounts\n config Manage CLI defaults (org_id, domain…)\n install-skills Install the MyAPI skills pack\n api-keys Manage API keys');
|
|
52
52
|
break;
|
|
53
53
|
}
|
|
54
54
|
if (subcommand === 'setup') await setupCmd.setup(flags);
|
|
55
55
|
else if (subcommand === 'import-key') await setupCmd.importKey(restArgs[0], flags);
|
|
56
56
|
else if (subcommand === 'whoami') await authCmd.whoami(flags);
|
|
57
|
-
|
|
57
|
+
else if (subcommand === 'link') await authCmd.link(flags);
|
|
58
58
|
else if (subcommand === 'switch') await authCmd.switchCmd(flags, restArgs[0]);
|
|
59
59
|
else if (subcommand === 'install-skills') {
|
|
60
60
|
if (flags.help) {
|
|
@@ -121,8 +121,8 @@ async function main() {
|
|
|
121
121
|
if (err instanceof MyApiError) {
|
|
122
122
|
if (err.status === 401) error('Invalid API key. Run: myapi auth setup');
|
|
123
123
|
else if (err.status === 402) {
|
|
124
|
-
if (err.code === 'REGISTRATION_REQUIRED') error('A verified email is required. Run: myapi auth
|
|
125
|
-
else if (err.code === 'UPGRADE_REQUIRED') error('A verified email is required. Run: myapi auth
|
|
124
|
+
if (err.code === 'REGISTRATION_REQUIRED') error('A verified email is required. Run: myapi auth link');
|
|
125
|
+
else if (err.code === 'UPGRADE_REQUIRED') error('A verified email is required. Run: myapi auth link');
|
|
126
126
|
else error(`Insufficient balance. Run: myapi billing topup <amount>`);
|
|
127
127
|
}
|
|
128
128
|
else error(err.code || err.message);
|
|
@@ -146,7 +146,7 @@ Usage: myapi <command> [subcommand] [args]
|
|
|
146
146
|
myapi --version
|
|
147
147
|
|
|
148
148
|
Commands:
|
|
149
|
-
auth Manage account · setup · whoami ·
|
|
149
|
+
auth Manage account · setup · whoami · link
|
|
150
150
|
billing Check balance and manage billing
|
|
151
151
|
org Manage organizations
|
|
152
152
|
update Update CLI and skills to the latest version
|