@myapihq/cli 1.0.5 → 1.0.7
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.js +5 -16
- package/dist/commands/billing.js +28 -5
- package/dist/commands/keys.d.ts +3 -0
- package/dist/commands/keys.js +80 -0
- package/dist/commands/org.js +40 -8
- package/dist/commands/setup.js +10 -99
- package/dist/index.js +33 -13
- package/package.json +1 -1
- package/src/commands/billing.ts +30 -3
- package/src/commands/keys.ts +47 -0
- package/src/commands/org.ts +39 -5
- package/src/commands/setup.ts +10 -109
- package/src/index.ts +29 -11
- package/tsconfig.json +3 -6
- package/dist/cli/src/commands/account.d.ts +0 -4
- package/dist/cli/src/commands/account.js +0 -91
- package/dist/cli/src/commands/billing.d.ts +0 -4
- package/dist/cli/src/commands/billing.js +0 -34
- package/dist/cli/src/commands/domain.d.ts +0 -5
- package/dist/cli/src/commands/domain.js +0 -56
- package/dist/cli/src/commands/email.d.ts +0 -8
- package/dist/cli/src/commands/email.js +0 -95
- package/dist/cli/src/commands/funnel.d.ts +0 -3
- package/dist/cli/src/commands/funnel.js +0 -37
- package/dist/cli/src/commands/image.d.ts +0 -2
- package/dist/cli/src/commands/image.js +0 -47
- package/dist/cli/src/commands/org.d.ts +0 -5
- package/dist/cli/src/commands/org.js +0 -67
- package/dist/cli/src/commands/setup.d.ts +0 -1
- package/dist/cli/src/commands/setup.js +0 -165
- package/dist/cli/src/commands/storage.d.ts +0 -3
- package/dist/cli/src/commands/storage.js +0 -36
- package/dist/cli/src/commands/webhook.d.ts +0 -3
- package/dist/cli/src/commands/webhook.js +0 -28
- package/dist/cli/src/commands/workflow.d.ts +0 -5
- package/dist/cli/src/commands/workflow.js +0 -57
- package/dist/cli/src/config.d.ts +0 -8
- package/dist/cli/src/config.js +0 -69
- package/dist/cli/src/index.d.ts +0 -2
- package/dist/cli/src/index.js +0 -117
- package/dist/cli/src/output.d.ts +0 -5
- package/dist/cli/src/output.js +0 -42
- package/dist/cli/src/utils.d.ts +0 -5
- package/dist/cli/src/utils.js +0 -34
- package/dist/sdk/src/client.d.ts +0 -6
- package/dist/sdk/src/client.js +0 -51
- package/dist/sdk/src/domain.d.ts +0 -32
- package/dist/sdk/src/domain.js +0 -36
- package/dist/sdk/src/email.d.ts +0 -144
- package/dist/sdk/src/email.js +0 -116
- package/dist/sdk/src/funnel.d.ts +0 -31
- package/dist/sdk/src/funnel.js +0 -28
- package/dist/sdk/src/hq.d.ts +0 -84
- package/dist/sdk/src/hq.js +0 -80
- package/dist/sdk/src/image.d.ts +0 -21
- package/dist/sdk/src/image.js +0 -16
- package/dist/sdk/src/index.d.ts +0 -11
- package/dist/sdk/src/index.js +0 -51
- package/dist/sdk/src/pixel.d.ts +0 -65
- package/dist/sdk/src/pixel.js +0 -44
- package/dist/sdk/src/storage.d.ts +0 -10
- package/dist/sdk/src/storage.js +0 -48
- package/dist/sdk/src/types.d.ts +0 -17
- package/dist/sdk/src/types.js +0 -2
- package/dist/sdk/src/webhook.d.ts +0 -20
- package/dist/sdk/src/webhook.js +0 -20
- package/dist/sdk/src/workflow.d.ts +0 -56
- package/dist/sdk/src/workflow.js +0 -40
- package/src/commands/account.ts +0 -63
package/src/commands/org.ts
CHANGED
|
@@ -1,41 +1,75 @@
|
|
|
1
1
|
import { hq } from '@myapihq/sdk';
|
|
2
2
|
import { requireConfig } from '../config.js';
|
|
3
|
-
import { success, error, printTable, printJson } from '../output.js';
|
|
3
|
+
import { success, error, printTable, printJson, info } from '../output.js';
|
|
4
4
|
import { sleep } from '../utils.js';
|
|
5
5
|
|
|
6
6
|
export async function create(flags: Record<string, string | boolean>) {
|
|
7
|
-
if (
|
|
7
|
+
if (flags.help) {
|
|
8
|
+
info('Usage: myapi org create --name="My Org" [options]\n\nOptions:\n --name Organization name (required)\n --tagline Short tagline\n --description Detailed description\n --business-sector Sector (e.g. Technology)\n --logo-url URL to logo image');
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (!flags.name) {
|
|
12
|
+
error("Missing --name flag. Run 'myapi org create --help' for details.");
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
8
15
|
const config = requireConfig();
|
|
9
16
|
const payload: any = { name: flags.name as string };
|
|
10
17
|
if (flags.tagline) payload.tagline = flags.tagline as string;
|
|
11
18
|
if (flags.description) payload.description = flags.description as string;
|
|
19
|
+
if (flags['business-sector']) payload.business_sector = flags['business-sector'] as string;
|
|
20
|
+
if (flags['logo-url']) payload.logo_url = flags['logo-url'] as string;
|
|
12
21
|
|
|
13
22
|
const org = await hq.createOrg(config.api_key, payload);
|
|
14
23
|
success(`Org created! ID: ${org.id}, Name: ${org.name}`);
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
export async function list(flags: Record<string, string | boolean>) {
|
|
27
|
+
if (flags.help) {
|
|
28
|
+
info('Usage: myapi org list\n\nLists all organizations in your account.');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
18
31
|
const config = requireConfig();
|
|
19
32
|
const orgs = await hq.listOrgs(config.api_key);
|
|
20
33
|
printTable(orgs as unknown as Record<string, unknown>[]);
|
|
21
34
|
}
|
|
22
35
|
|
|
23
36
|
export async function get(id: string, flags: Record<string, string | boolean>) {
|
|
24
|
-
if (
|
|
37
|
+
if (flags.help) {
|
|
38
|
+
info('Usage: myapi org get <id>\n\nFetches details of a specific organization.');
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!id) {
|
|
42
|
+
error("Missing org id. Usage: myapi org get <id>");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
25
45
|
const config = requireConfig();
|
|
26
46
|
const org = await hq.getOrg(config.api_key, id);
|
|
27
47
|
printJson(org);
|
|
28
48
|
}
|
|
29
49
|
|
|
30
50
|
export async function del(id: string, flags: Record<string, string | boolean>) {
|
|
31
|
-
if (
|
|
51
|
+
if (flags.help) {
|
|
52
|
+
info('Usage: myapi org delete <id>\n\nDeletes an organization.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!id) {
|
|
56
|
+
error("Missing org id. Usage: myapi org delete <id>");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
32
59
|
const config = requireConfig();
|
|
33
60
|
await hq.deleteOrg(config.api_key, id);
|
|
34
61
|
success(`Org ${id} deleted`);
|
|
35
62
|
}
|
|
36
63
|
|
|
37
64
|
export async function importOrg(domain: string, flags: Record<string, string | boolean>) {
|
|
38
|
-
if (
|
|
65
|
+
if (flags.help) {
|
|
66
|
+
info('Usage: myapi org import <domain>\n\nAutomatically extracts brand info from an existing website and creates an organization.');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (!domain) {
|
|
70
|
+
error("Missing domain. Usage: myapi org import <domain>");
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
39
73
|
const config = requireConfig();
|
|
40
74
|
|
|
41
75
|
const result = await hq.importOrg(config.api_key, domain);
|
package/src/commands/setup.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import { hq } from '@myapihq/sdk';
|
|
2
1
|
import { loadConfig, saveConfig } from '../config.js';
|
|
3
2
|
import { success, info } from '../output.js';
|
|
4
3
|
import * as readline from 'readline';
|
|
5
|
-
import { execSync } from 'child_process';
|
|
6
|
-
import * as fs from 'fs';
|
|
7
|
-
import * as path from 'path';
|
|
8
|
-
import * as os from 'os';
|
|
9
4
|
|
|
10
5
|
function ask(rl: readline.Interface, q: string): Promise<string> {
|
|
11
6
|
return new Promise(resolve => rl.question(q, resolve));
|
|
@@ -17,49 +12,11 @@ function yn(answer: string, defaultYes = true): boolean {
|
|
|
17
12
|
return t === 'y' || t === 'yes';
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
async function
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
saveConfig({ api_key: key.trim(), account_id: '', pin: '' });
|
|
26
|
-
success('API key saved to ~/.myapi/config.json');
|
|
27
|
-
return key.trim();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
info('Creating account...');
|
|
31
|
-
const agent = await hq.createAgentAccount();
|
|
32
|
-
const keyInfo = await hq.createApiKey(agent.token, 'default');
|
|
33
|
-
saveConfig({ api_key: keyInfo.api_key, account_id: agent.account_id, pin: agent.pin });
|
|
34
|
-
success(`Account created!\n\nAPI Key: ${keyInfo.api_key}\nPIN: ${agent.pin}\n\nSave your PIN — it's the only way to recover your account.`);
|
|
35
|
-
return keyInfo.api_key;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function registerClaudeMcp() {
|
|
39
|
-
try {
|
|
40
|
-
execSync('claude mcp add myapi -- npx -y @myapihq/mcp', { stdio: 'inherit' });
|
|
41
|
-
success('Claude Code MCP registered');
|
|
42
|
-
} catch {
|
|
43
|
-
info('Could not auto-register. Run manually:\n claude mcp add myapi -- npx -y @myapihq/mcp');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function registerGeminiMcp() {
|
|
48
|
-
const configPath = path.join(os.homedir(), '.gemini', 'settings.json');
|
|
49
|
-
try {
|
|
50
|
-
let settings: Record<string, any> = {};
|
|
51
|
-
if (fs.existsSync(configPath)) {
|
|
52
|
-
settings = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
53
|
-
}
|
|
54
|
-
settings.mcpServers = settings.mcpServers ?? {};
|
|
55
|
-
settings.mcpServers.myapi = { command: 'npx', args: ['-y', '@myapihq/mcp'] };
|
|
56
|
-
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
57
|
-
fs.writeFileSync(configPath, JSON.stringify(settings, null, 2));
|
|
58
|
-
success('Gemini CLI MCP registered (~/.gemini/settings.json)');
|
|
59
|
-
} catch {
|
|
60
|
-
info('Could not auto-configure Gemini CLI. Add manually to ~/.gemini/settings.json:');
|
|
61
|
-
info(' { "mcpServers": { "myapi": { "command": "npx", "args": ["-y", "@myapihq/mcp"] } } }');
|
|
62
|
-
}
|
|
15
|
+
async function getKey(rl: readline.Interface): Promise<string> {
|
|
16
|
+
const key = await ask(rl, 'Paste your API key (get it from https://myapihq.com): ');
|
|
17
|
+
saveConfig({ api_key: key.trim(), account_id: '', pin: '' });
|
|
18
|
+
success('API key saved to ~/.myapi/config.json');
|
|
19
|
+
return key.trim();
|
|
63
20
|
}
|
|
64
21
|
|
|
65
22
|
export async function setup() {
|
|
@@ -67,79 +24,23 @@ export async function setup() {
|
|
|
67
24
|
|
|
68
25
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
69
26
|
|
|
70
|
-
// Step 1: credentials
|
|
71
27
|
const existing = loadConfig();
|
|
72
28
|
if (existing?.api_key) {
|
|
73
29
|
const reuse = await ask(rl, `Found existing account (${existing.account_id || existing.api_key.slice(0, 20) + '...'}). Use it? [Y/n]: `);
|
|
74
30
|
if (!yn(reuse, true)) {
|
|
75
|
-
await
|
|
31
|
+
await getKey(rl);
|
|
76
32
|
} else {
|
|
77
33
|
info('Using existing credentials.');
|
|
78
34
|
}
|
|
79
35
|
} else {
|
|
80
|
-
await
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Step 2: which agents
|
|
84
|
-
info('\nWhich AI agents do you use?');
|
|
85
|
-
const useClaude = yn(await ask(rl, ' Claude Code? [Y/n]: '), true);
|
|
86
|
-
const useGemini = yn(await ask(rl, ' Gemini CLI? [Y/n]: '), true);
|
|
87
|
-
const useCursor = yn(await ask(rl, ' Cursor? [y/N]: '), false);
|
|
88
|
-
const useWindsurf = yn(await ask(rl, ' Windsurf? [y/N]: '), false);
|
|
89
|
-
const useKiro = yn(await ask(rl, ' Kiro? [y/N]: '), false);
|
|
90
|
-
const useCopilot = yn(await ask(rl, ' GitHub Copilot? [y/N]: '), false);
|
|
91
|
-
const useOther = yn(await ask(rl, ' Other / Codex? [y/N]: '), false);
|
|
92
|
-
|
|
93
|
-
// Step 3: Claude — MCP or Skills or both
|
|
94
|
-
let claudeMcp = false;
|
|
95
|
-
let claudeSkills = false;
|
|
96
|
-
if (useClaude) {
|
|
97
|
-
info('\nFor Claude Code, how do you want to connect?');
|
|
98
|
-
claudeMcp = yn(await ask(rl, ' MCP server — live API calls via tool use? [Y/n]: '), true);
|
|
99
|
-
claudeSkills = yn(await ask(rl, ' Skills plugin — inline docs + prompts? [y/N]: '), false);
|
|
36
|
+
await getKey(rl);
|
|
100
37
|
}
|
|
101
38
|
|
|
102
39
|
rl.close();
|
|
103
40
|
|
|
104
|
-
|
|
105
|
-
info('
|
|
106
|
-
|
|
107
|
-
if (claudeMcp) registerClaudeMcp();
|
|
108
|
-
if (useGemini) registerGeminiMcp();
|
|
109
|
-
|
|
110
|
-
if (claudeSkills) {
|
|
111
|
-
info('To install the MyAPI skill inside Claude Code, run:');
|
|
112
|
-
info(' /plugin marketplace add myapihq/claude-skills');
|
|
113
|
-
info(' /plugin install my-api-hq@myapi-skills');
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const skillsUrl = 'https://github.com/myapihq/agent-skills/blob/main/skills/my-api-hq/SKILL.md';
|
|
117
|
-
|
|
118
|
-
if (useCursor) {
|
|
119
|
-
info('\nCursor — copy the skill into .cursor/rules/:');
|
|
120
|
-
info(` ${skillsUrl}`);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (useWindsurf) {
|
|
124
|
-
info('\nWindsurf — add the skill to your rules configuration:');
|
|
125
|
-
info(` ${skillsUrl}`);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if (useKiro) {
|
|
129
|
-
info('\nKiro — copy the skill into .kiro/skills/:');
|
|
130
|
-
info(` ${skillsUrl}`);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if (useCopilot) {
|
|
134
|
-
info('\nGitHub Copilot — paste the skill into .github/copilot-instructions.md:');
|
|
135
|
-
info(` ${skillsUrl}`);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
if (useOther) {
|
|
139
|
-
info('\nOther agents — copy the skill markdown as a system prompt or instruction file:');
|
|
140
|
-
info(` ${skillsUrl}`);
|
|
141
|
-
}
|
|
41
|
+
info('\nTo integrate MyAPI with AI agents (Claude, Cursor, Copilot, etc.),');
|
|
42
|
+
info('please follow the instructions in our skills repository:');
|
|
43
|
+
info('https://github.com/myapihq/agent-skills\n');
|
|
142
44
|
|
|
143
|
-
info('');
|
|
144
45
|
success('Setup complete! Try: myapi billing balance');
|
|
145
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { parseArgs } from './utils.js';
|
|
4
4
|
import { error, info } from './output.js';
|
|
5
5
|
import { MyApiError } from '@myapihq/sdk';
|
|
6
|
-
import * as
|
|
6
|
+
import * as keysCmd from './commands/keys.js';
|
|
7
7
|
import * as billingCmd from './commands/billing.js';
|
|
8
8
|
import * as orgCmd from './commands/org.js';
|
|
9
9
|
import * as setupCmd from './commands/setup.js';
|
|
@@ -15,21 +15,39 @@ async function main() {
|
|
|
15
15
|
try {
|
|
16
16
|
switch (command) {
|
|
17
17
|
case 'setup':
|
|
18
|
+
if (flags.help) {
|
|
19
|
+
info('Usage: myapi setup\n\nSetup CLI credentials and view integration instructions');
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
18
22
|
await setupCmd.setup();
|
|
19
23
|
break;
|
|
20
|
-
case '
|
|
21
|
-
if (subcommand
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
case 'keys':
|
|
25
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
26
|
+
info('Usage: myapi keys <subcommand>\n\nSubcommands:\n list List your API keys\n create Create a new API key\n revoke Revoke an API key (e.g. myapi keys revoke <id>)');
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
if (subcommand === 'create') await keysCmd.createNew(flags);
|
|
30
|
+
else if (subcommand === 'list') await keysCmd.list(flags);
|
|
31
|
+
else if (subcommand === 'revoke') await keysCmd.revoke(restArgs[0], flags);
|
|
25
32
|
else printHelp();
|
|
26
33
|
break;
|
|
27
34
|
case 'org':
|
|
35
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
36
|
+
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 import Extract org from domain');
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
28
39
|
if (subcommand === 'list') await orgCmd.list(flags);
|
|
29
40
|
else if (subcommand === 'create') await orgCmd.create(flags);
|
|
41
|
+
else if (subcommand === 'get') await orgCmd.get(restArgs[0], flags);
|
|
42
|
+
else if (subcommand === 'delete') await orgCmd.del(restArgs[0], flags);
|
|
43
|
+
else if (subcommand === 'import') await orgCmd.importOrg(restArgs[0], flags);
|
|
30
44
|
else printHelp();
|
|
31
45
|
break;
|
|
32
46
|
case 'billing':
|
|
47
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
48
|
+
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');
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
33
51
|
if (subcommand === 'balance') await billingCmd.balance(flags);
|
|
34
52
|
else if (subcommand === 'history') await billingCmd.history(flags);
|
|
35
53
|
else if (subcommand === 'topup') await billingCmd.topup(restArgs[0], flags);
|
|
@@ -55,12 +73,12 @@ function printHelp() {
|
|
|
55
73
|
Usage: myapi <command> [subcommand] [args]
|
|
56
74
|
|
|
57
75
|
Commands:
|
|
58
|
-
|
|
59
|
-
billing
|
|
60
|
-
org
|
|
61
|
-
setup
|
|
76
|
+
keys Manage API keys
|
|
77
|
+
billing Check balance and manage billing
|
|
78
|
+
org Manage organizations
|
|
79
|
+
setup Setup CLI credentials and view integration instructions
|
|
62
80
|
|
|
63
|
-
Run "myapi <command>" for subcommand help.`);
|
|
81
|
+
Run "myapi <command> --help" for subcommand help.`);
|
|
64
82
|
}
|
|
65
83
|
|
|
66
84
|
main().catch(err => { error(err.message || String(err)); });
|
package/tsconfig.json
CHANGED
|
@@ -5,14 +5,11 @@
|
|
|
5
5
|
"moduleResolution": "NodeNext",
|
|
6
6
|
"declaration": true,
|
|
7
7
|
"outDir": "./dist",
|
|
8
|
+
"rootDir": "./src",
|
|
8
9
|
"strict": true,
|
|
9
10
|
"esModuleInterop": true,
|
|
10
11
|
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true
|
|
12
|
-
"paths": {
|
|
13
|
-
"@myapihq/sdk": ["../sdk/src/index.ts"],
|
|
14
|
-
"@myapihq/sdk/*": ["../sdk/src/*"]
|
|
15
|
-
}
|
|
12
|
+
"forceConsistentCasingInFileNames": true
|
|
16
13
|
},
|
|
17
14
|
"include": ["src/**/*"]
|
|
18
|
-
}
|
|
15
|
+
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function create(): Promise<void>;
|
|
2
|
-
export declare function token(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
-
export declare function listKeys(flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
-
export declare function revokeKey(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.create = create;
|
|
37
|
-
exports.token = token;
|
|
38
|
-
exports.listKeys = listKeys;
|
|
39
|
-
exports.revokeKey = revokeKey;
|
|
40
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
41
|
-
const config_js_1 = require("../config.js");
|
|
42
|
-
const output_js_1 = require("../output.js");
|
|
43
|
-
const readline = __importStar(require("readline"));
|
|
44
|
-
async function create() {
|
|
45
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
46
|
-
const ask = (q) => new Promise(resolve => rl.question(q, resolve));
|
|
47
|
-
const choice = await ask('Do you want to (1) auto-create a new account or (2) paste an existing API key? [1/2]: ');
|
|
48
|
-
rl.close();
|
|
49
|
-
if (choice.trim() === '2') {
|
|
50
|
-
const rl2 = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
51
|
-
const key = await new Promise(resolve => rl2.question('Paste your API key: ', resolve));
|
|
52
|
-
rl2.close();
|
|
53
|
-
(0, config_js_1.saveConfig)({ api_key: key.trim(), account_id: '', pin: '' });
|
|
54
|
-
(0, output_js_1.success)(`API key saved to ~/.myapi/config.json`);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const agent = await sdk_1.hq.createAgentAccount();
|
|
58
|
-
const keyInfo = await sdk_1.hq.createApiKey(agent.token, 'default');
|
|
59
|
-
(0, config_js_1.saveConfig)({
|
|
60
|
-
api_key: keyInfo.api_key,
|
|
61
|
-
account_id: agent.account_id,
|
|
62
|
-
pin: agent.pin
|
|
63
|
-
});
|
|
64
|
-
(0, output_js_1.success)(`Account created!\n\nAPI Key: ${keyInfo.api_key}\nAccount ID: ${agent.account_id}\nPIN: ${agent.pin}\n\nCredentials saved to ~/.myapi/config.json\nKeep your PIN safe — it's the only way to recover your account.`);
|
|
65
|
-
}
|
|
66
|
-
async function token(flags) {
|
|
67
|
-
let pin = flags.pin;
|
|
68
|
-
if (!pin) {
|
|
69
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
70
|
-
pin = await new Promise(resolve => rl.question('Enter PIN: ', resolve));
|
|
71
|
-
rl.close();
|
|
72
|
-
}
|
|
73
|
-
const result = await sdk_1.hq.recoverAgentToken(pin);
|
|
74
|
-
const keyInfo = await sdk_1.hq.createApiKey(result.token, 'recovered');
|
|
75
|
-
const config = (0, config_js_1.requireConfig)();
|
|
76
|
-
config.api_key = keyInfo.api_key;
|
|
77
|
-
(0, config_js_1.saveConfig)(config);
|
|
78
|
-
(0, output_js_1.success)(`Token recovered! New API Key: ${keyInfo.api_key}`);
|
|
79
|
-
}
|
|
80
|
-
async function listKeys(flags) {
|
|
81
|
-
const config = (0, config_js_1.requireConfig)();
|
|
82
|
-
const keys = await sdk_1.hq.listApiKeys(config.api_key);
|
|
83
|
-
(0, output_js_1.printTable)(keys);
|
|
84
|
-
}
|
|
85
|
-
async function revokeKey(id, flags) {
|
|
86
|
-
if (!id)
|
|
87
|
-
(0, output_js_1.error)("Missing key id");
|
|
88
|
-
const config = (0, config_js_1.requireConfig)();
|
|
89
|
-
await sdk_1.hq.revokeApiKey(config.api_key, id);
|
|
90
|
-
(0, output_js_1.success)(`Key ${id} revoked`);
|
|
91
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export declare function balance(flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
-
export declare function history(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
-
export declare function topup(amountStr: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
-
export declare function setup(flags: Record<string, string | boolean>): Promise<void>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.balance = balance;
|
|
4
|
-
exports.history = history;
|
|
5
|
-
exports.topup = topup;
|
|
6
|
-
exports.setup = setup;
|
|
7
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
8
|
-
const config_js_1 = require("../config.js");
|
|
9
|
-
const output_js_1 = require("../output.js");
|
|
10
|
-
async function balance(flags) {
|
|
11
|
-
const config = (0, config_js_1.requireConfig)();
|
|
12
|
-
const result = await sdk_1.hq.getBalance(config.api_key);
|
|
13
|
-
(0, output_js_1.info)(`Balance: $${(result.balance_cents / 100).toFixed(2)} | Payment method: ${result.has_payment_method ? 'yes' : 'no'}`);
|
|
14
|
-
}
|
|
15
|
-
async function history(flags) {
|
|
16
|
-
const config = (0, config_js_1.requireConfig)();
|
|
17
|
-
const items = await sdk_1.hq.getBillingHistory(config.api_key);
|
|
18
|
-
(0, output_js_1.printTable)(items);
|
|
19
|
-
}
|
|
20
|
-
async function topup(amountStr, flags) {
|
|
21
|
-
if (!amountStr)
|
|
22
|
-
(0, output_js_1.error)("Missing amount");
|
|
23
|
-
const amount = parseFloat(amountStr);
|
|
24
|
-
if (isNaN(amount))
|
|
25
|
-
(0, output_js_1.error)("Invalid amount");
|
|
26
|
-
const config = (0, config_js_1.requireConfig)();
|
|
27
|
-
const result = await sdk_1.hq.topUp(config.api_key, Math.round(amount * 100));
|
|
28
|
-
(0, output_js_1.success)(`Top up successful! New balance: $${(result.new_balance_cents / 100).toFixed(2)}`);
|
|
29
|
-
}
|
|
30
|
-
async function setup(flags) {
|
|
31
|
-
const config = (0, config_js_1.requireConfig)();
|
|
32
|
-
const result = await sdk_1.hq.setupPayment(config.api_key);
|
|
33
|
-
(0, output_js_1.success)(`Open this URL in your browser to set up payment:\n${result.url}`);
|
|
34
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
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>;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.check = check;
|
|
4
|
-
exports.register = register;
|
|
5
|
-
exports.importDomain = importDomain;
|
|
6
|
-
exports.list = list;
|
|
7
|
-
exports.settings = settings;
|
|
8
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
9
|
-
const config_js_1 = require("../config.js");
|
|
10
|
-
const output_js_1 = require("../output.js");
|
|
11
|
-
async function check(domain, flags) {
|
|
12
|
-
if (!domain)
|
|
13
|
-
(0, output_js_1.error)("Missing domain");
|
|
14
|
-
const config = (0, config_js_1.requireConfig)();
|
|
15
|
-
const res = await sdk_1.domain.checkDomain(config.api_key, domain);
|
|
16
|
-
if (res.available) {
|
|
17
|
-
(0, output_js_1.info)(`${domain} — Available ✓ Price: $${(res.price_cents / 100).toFixed(2)}/yr`);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
(0, output_js_1.info)(`Not available ✗`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
async function register(domain, flags) {
|
|
24
|
-
if (!domain)
|
|
25
|
-
(0, output_js_1.error)("Missing domain");
|
|
26
|
-
const years = parseInt(flags.years) || 1;
|
|
27
|
-
const config = (0, config_js_1.requireConfig)();
|
|
28
|
-
const res = await sdk_1.domain.registerDomain(config.api_key, domain, years);
|
|
29
|
-
(0, output_js_1.success)(`Registered ${domain}!\n${JSON.stringify(res, null, 2)}`);
|
|
30
|
-
}
|
|
31
|
-
async function importDomain(domain, flags) {
|
|
32
|
-
if (!domain)
|
|
33
|
-
(0, output_js_1.error)("Missing domain");
|
|
34
|
-
if (!flags['namecheap-user'] || !flags['namecheap-key']) {
|
|
35
|
-
(0, output_js_1.error)("Missing --namecheap-user or --namecheap-key flags");
|
|
36
|
-
}
|
|
37
|
-
const config = (0, config_js_1.requireConfig)();
|
|
38
|
-
await sdk_1.domain.importDomain(config.api_key, {
|
|
39
|
-
domain,
|
|
40
|
-
namecheap_api_user: flags['namecheap-user'],
|
|
41
|
-
namecheap_api_key: flags['namecheap-key']
|
|
42
|
-
});
|
|
43
|
-
(0, output_js_1.success)(`Imported ${domain}`);
|
|
44
|
-
}
|
|
45
|
-
async function list(flags) {
|
|
46
|
-
const config = (0, config_js_1.requireConfig)();
|
|
47
|
-
const domains = await sdk_1.domain.listDomains(config.api_key);
|
|
48
|
-
(0, output_js_1.printTable)(domains);
|
|
49
|
-
}
|
|
50
|
-
async function settings(domain, flags) {
|
|
51
|
-
if (!domain)
|
|
52
|
-
(0, output_js_1.error)("Missing domain");
|
|
53
|
-
const config = (0, config_js_1.requireConfig)();
|
|
54
|
-
const res = await sdk_1.domain.getDomainSettings(config.api_key, domain);
|
|
55
|
-
(0, output_js_1.printJson)(res);
|
|
56
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function createMailbox(flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
-
export declare function listMailboxes(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
-
export declare function send(flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
-
export declare function inbox(address: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
-
export declare function listTemplates(flags: Record<string, string | boolean>): Promise<void>;
|
|
6
|
-
export declare function generateTemplate(flags: Record<string, string | boolean>): Promise<void>;
|
|
7
|
-
export declare function listCampaigns(flags: Record<string, string | boolean>): Promise<void>;
|
|
8
|
-
export declare function campaignStats(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createMailbox = createMailbox;
|
|
4
|
-
exports.listMailboxes = listMailboxes;
|
|
5
|
-
exports.send = send;
|
|
6
|
-
exports.inbox = inbox;
|
|
7
|
-
exports.listTemplates = listTemplates;
|
|
8
|
-
exports.generateTemplate = generateTemplate;
|
|
9
|
-
exports.listCampaigns = listCampaigns;
|
|
10
|
-
exports.campaignStats = campaignStats;
|
|
11
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
12
|
-
const config_js_1 = require("../config.js");
|
|
13
|
-
const output_js_1 = require("../output.js");
|
|
14
|
-
const utils_js_1 = require("../utils.js");
|
|
15
|
-
async function createMailbox(flags) {
|
|
16
|
-
if (!flags.domain || !flags.username)
|
|
17
|
-
(0, output_js_1.error)("Missing --domain or --username flags");
|
|
18
|
-
const config = (0, config_js_1.requireConfig)();
|
|
19
|
-
const address = await sdk_1.email.createMailbox(config.api_key, flags.domain, flags.username);
|
|
20
|
-
(0, output_js_1.success)(`Mailbox created: ${address.address}`);
|
|
21
|
-
}
|
|
22
|
-
async function listMailboxes(flags) {
|
|
23
|
-
const config = (0, config_js_1.requireConfig)();
|
|
24
|
-
const mailboxes = await sdk_1.email.listMailboxes(config.api_key);
|
|
25
|
-
(0, output_js_1.printTable)(mailboxes);
|
|
26
|
-
}
|
|
27
|
-
async function send(flags) {
|
|
28
|
-
if (!flags.from || !flags.to || !flags.subject || !flags.body) {
|
|
29
|
-
(0, output_js_1.error)("Missing --from, --to, --subject, or --body flags");
|
|
30
|
-
}
|
|
31
|
-
const config = (0, config_js_1.requireConfig)();
|
|
32
|
-
const res = await sdk_1.email.sendEmail(config.api_key, {
|
|
33
|
-
from: flags.from,
|
|
34
|
-
to: [flags.to],
|
|
35
|
-
subject: flags.subject,
|
|
36
|
-
text: flags.body
|
|
37
|
-
});
|
|
38
|
-
(0, output_js_1.success)(`Email sent! Message ID: ${res.message_id}`);
|
|
39
|
-
}
|
|
40
|
-
async function inbox(address, flags) {
|
|
41
|
-
if (!address)
|
|
42
|
-
(0, output_js_1.error)("Missing address");
|
|
43
|
-
const config = (0, config_js_1.requireConfig)();
|
|
44
|
-
const messages = await sdk_1.email.getInbox(config.api_key, address);
|
|
45
|
-
(0, output_js_1.printTable)(messages);
|
|
46
|
-
}
|
|
47
|
-
async function listTemplates(flags) {
|
|
48
|
-
const config = (0, config_js_1.requireConfig)();
|
|
49
|
-
const templates = await sdk_1.email.listTemplates(config.api_key);
|
|
50
|
-
(0, output_js_1.printTable)(templates);
|
|
51
|
-
}
|
|
52
|
-
async function generateTemplate(flags) {
|
|
53
|
-
if (!flags['org-id'] || !flags.prompt || !flags.name) {
|
|
54
|
-
(0, output_js_1.error)("Missing --org-id, --prompt, or --name flags");
|
|
55
|
-
}
|
|
56
|
-
const config = (0, config_js_1.requireConfig)();
|
|
57
|
-
const job = await sdk_1.email.generateTemplate(config.api_key, {
|
|
58
|
-
org_id: flags['org-id'],
|
|
59
|
-
prompt: flags.prompt,
|
|
60
|
-
name: flags.name
|
|
61
|
-
});
|
|
62
|
-
process.stdout.write("Generating template ");
|
|
63
|
-
const chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
64
|
-
let i = 0;
|
|
65
|
-
let elapsed = 0;
|
|
66
|
-
while (elapsed < 90000) {
|
|
67
|
-
const status = await sdk_1.email.getTemplateJobStatus(config.api_key, job.job_id);
|
|
68
|
-
if (status.status === 'completed') {
|
|
69
|
-
process.stdout.write('\r\x1b[K');
|
|
70
|
-
(0, output_js_1.success)(`Template generated! ID: ${status.template_id}\nPreview: ${status.result?.preview_url}`);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
if (status.status === 'failed') {
|
|
74
|
-
process.stdout.write('\r\x1b[K');
|
|
75
|
-
(0, output_js_1.error)("Template generation failed");
|
|
76
|
-
}
|
|
77
|
-
process.stdout.write(`\rGenerating template ${chars[i++ % chars.length]}`);
|
|
78
|
-
await (0, utils_js_1.sleep)(3000);
|
|
79
|
-
elapsed += 3000;
|
|
80
|
-
}
|
|
81
|
-
process.stdout.write('\r\x1b[K');
|
|
82
|
-
(0, output_js_1.error)("Template generation timed out");
|
|
83
|
-
}
|
|
84
|
-
async function listCampaigns(flags) {
|
|
85
|
-
const config = (0, config_js_1.requireConfig)();
|
|
86
|
-
const campaigns = await sdk_1.email.listCampaigns(config.api_key);
|
|
87
|
-
(0, output_js_1.printTable)(campaigns);
|
|
88
|
-
}
|
|
89
|
-
async function campaignStats(id, flags) {
|
|
90
|
-
if (!id)
|
|
91
|
-
(0, output_js_1.error)("Missing campaign id");
|
|
92
|
-
const config = (0, config_js_1.requireConfig)();
|
|
93
|
-
const stats = await sdk_1.email.getCampaignStats(config.api_key, id);
|
|
94
|
-
(0, output_js_1.printJson)(stats);
|
|
95
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function list(flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
-
export declare function create(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
-
export declare function push(id: string, slug: string, flags: Record<string, string | boolean>): Promise<void>;
|