@myapihq/cli 1.0.4 → 1.0.5
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/cli/src/commands/account.d.ts +4 -0
- package/dist/cli/src/commands/account.js +91 -0
- package/dist/cli/src/commands/billing.d.ts +4 -0
- package/dist/cli/src/commands/billing.js +34 -0
- package/dist/cli/src/commands/domain.d.ts +5 -0
- package/dist/cli/src/commands/domain.js +56 -0
- package/dist/cli/src/commands/email.d.ts +8 -0
- package/dist/cli/src/commands/email.js +95 -0
- package/dist/cli/src/commands/funnel.d.ts +3 -0
- package/dist/cli/src/commands/funnel.js +37 -0
- package/dist/cli/src/commands/image.d.ts +2 -0
- package/dist/cli/src/commands/image.js +47 -0
- package/dist/cli/src/commands/org.d.ts +5 -0
- package/dist/cli/src/commands/org.js +67 -0
- package/dist/cli/src/commands/setup.d.ts +1 -0
- package/dist/cli/src/commands/setup.js +165 -0
- package/dist/cli/src/commands/storage.d.ts +3 -0
- package/dist/cli/src/commands/storage.js +36 -0
- package/dist/cli/src/commands/webhook.d.ts +3 -0
- package/dist/cli/src/commands/webhook.js +28 -0
- package/dist/cli/src/commands/workflow.d.ts +5 -0
- package/dist/cli/src/commands/workflow.js +57 -0
- package/dist/cli/src/config.d.ts +8 -0
- package/dist/cli/src/config.js +69 -0
- package/dist/cli/src/index.d.ts +2 -0
- package/dist/cli/src/index.js +117 -0
- package/dist/cli/src/output.d.ts +5 -0
- package/dist/cli/src/output.js +42 -0
- package/dist/cli/src/utils.d.ts +5 -0
- package/dist/cli/src/utils.js +34 -0
- package/dist/commands/storage.js +12 -3
- package/dist/sdk/src/client.d.ts +6 -0
- package/dist/sdk/src/client.js +51 -0
- package/dist/sdk/src/domain.d.ts +32 -0
- package/dist/sdk/src/domain.js +36 -0
- package/dist/sdk/src/email.d.ts +144 -0
- package/dist/sdk/src/email.js +116 -0
- package/dist/sdk/src/funnel.d.ts +31 -0
- package/dist/sdk/src/funnel.js +28 -0
- package/dist/sdk/src/hq.d.ts +84 -0
- package/dist/sdk/src/hq.js +80 -0
- package/dist/sdk/src/image.d.ts +21 -0
- package/dist/sdk/src/image.js +16 -0
- package/dist/sdk/src/index.d.ts +11 -0
- package/dist/sdk/src/index.js +51 -0
- package/dist/sdk/src/pixel.d.ts +65 -0
- package/dist/sdk/src/pixel.js +44 -0
- package/dist/sdk/src/storage.d.ts +10 -0
- package/dist/sdk/src/storage.js +48 -0
- package/dist/sdk/src/types.d.ts +17 -0
- package/dist/sdk/src/types.js +2 -0
- package/dist/sdk/src/webhook.d.ts +20 -0
- package/dist/sdk/src/webhook.js +20 -0
- package/dist/sdk/src/workflow.d.ts +56 -0
- package/dist/sdk/src/workflow.js +40 -0
- package/package.json +1 -1
- package/src/commands/storage.ts +12 -3
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,4 @@
|
|
|
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>;
|
|
@@ -0,0 +1,91 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
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>;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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>;
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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>;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
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>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = list;
|
|
4
|
+
exports.create = create;
|
|
5
|
+
exports.push = push;
|
|
6
|
+
const sdk_1 = require("@myapihq/sdk");
|
|
7
|
+
const config_js_1 = require("../config.js");
|
|
8
|
+
const output_js_1 = require("../output.js");
|
|
9
|
+
async function list(flags) {
|
|
10
|
+
const config = (0, config_js_1.requireConfig)();
|
|
11
|
+
const funnels = await sdk_1.funnel.listFunnels(config.api_key);
|
|
12
|
+
(0, output_js_1.printTable)(funnels);
|
|
13
|
+
}
|
|
14
|
+
async function create(flags) {
|
|
15
|
+
if (!flags['org-id'] || !flags.domain) {
|
|
16
|
+
(0, output_js_1.error)("Missing --org-id or --domain flags");
|
|
17
|
+
}
|
|
18
|
+
const config = (0, config_js_1.requireConfig)();
|
|
19
|
+
const funnel = await sdk_1.funnel.createFunnel(config.api_key, flags['org-id'], flags.domain);
|
|
20
|
+
(0, output_js_1.success)(`Funnel created! ID: ${funnel.id}`);
|
|
21
|
+
}
|
|
22
|
+
async function push(id, slug, flags) {
|
|
23
|
+
if (!id || !slug)
|
|
24
|
+
(0, output_js_1.error)("Missing id or slug");
|
|
25
|
+
const config = (0, config_js_1.requireConfig)();
|
|
26
|
+
const html = await new Promise((resolve, reject) => {
|
|
27
|
+
let data = '';
|
|
28
|
+
process.stdin.setEncoding('utf-8');
|
|
29
|
+
process.stdin.on('data', chunk => { data += chunk; });
|
|
30
|
+
process.stdin.on('end', () => resolve(data));
|
|
31
|
+
process.stdin.on('error', reject);
|
|
32
|
+
});
|
|
33
|
+
if (!html)
|
|
34
|
+
(0, output_js_1.error)("No HTML provided via stdin");
|
|
35
|
+
await sdk_1.funnel.pushPage(config.api_key, id, slug, html);
|
|
36
|
+
(0, output_js_1.success)(`Pushed page to ${slug}`);
|
|
37
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generate = generate;
|
|
4
|
+
exports.list = list;
|
|
5
|
+
const sdk_1 = require("@myapihq/sdk");
|
|
6
|
+
const config_js_1 = require("../config.js");
|
|
7
|
+
const output_js_1 = require("../output.js");
|
|
8
|
+
const utils_js_1 = require("../utils.js");
|
|
9
|
+
async function generate(flags) {
|
|
10
|
+
if (!flags.prompt)
|
|
11
|
+
(0, output_js_1.error)("Missing --prompt flag");
|
|
12
|
+
const config = (0, config_js_1.requireConfig)();
|
|
13
|
+
const payload = { prompt: flags.prompt };
|
|
14
|
+
if (flags.ratio)
|
|
15
|
+
payload.aspect_ratio = flags.ratio;
|
|
16
|
+
if (flags.style)
|
|
17
|
+
payload.style = flags.style;
|
|
18
|
+
if (flags.colors)
|
|
19
|
+
payload.colors = flags.colors;
|
|
20
|
+
const res = await sdk_1.image.generateImage(config.api_key, payload);
|
|
21
|
+
process.stdout.write("Generating image ");
|
|
22
|
+
const chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
23
|
+
let i = 0;
|
|
24
|
+
let elapsed = 0;
|
|
25
|
+
while (elapsed < 60000) {
|
|
26
|
+
const job = await sdk_1.image.getImageJob(config.api_key, res.job_id);
|
|
27
|
+
if (job.status === 'completed') {
|
|
28
|
+
process.stdout.write('\r\x1b[K');
|
|
29
|
+
(0, output_js_1.success)(`Image generated!\nURL: ${job.url}`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (job.status === 'failed') {
|
|
33
|
+
process.stdout.write('\r\x1b[K');
|
|
34
|
+
(0, output_js_1.error)(`Image generation failed: ${job.error || 'Unknown error'}`);
|
|
35
|
+
}
|
|
36
|
+
process.stdout.write(`\rGenerating image ${chars[i++ % chars.length]}`);
|
|
37
|
+
await (0, utils_js_1.sleep)(3000);
|
|
38
|
+
elapsed += 3000;
|
|
39
|
+
}
|
|
40
|
+
process.stdout.write('\r\x1b[K');
|
|
41
|
+
(0, output_js_1.error)("Image generation timed out");
|
|
42
|
+
}
|
|
43
|
+
async function list(flags) {
|
|
44
|
+
const config = (0, config_js_1.requireConfig)();
|
|
45
|
+
const images = await sdk_1.image.listImages(config.api_key);
|
|
46
|
+
(0, output_js_1.printTable)(images);
|
|
47
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function create(flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
+
export declare function list(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
+
export declare function get(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
+
export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
+
export declare function importOrg(domain: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = create;
|
|
4
|
+
exports.list = list;
|
|
5
|
+
exports.get = get;
|
|
6
|
+
exports.del = del;
|
|
7
|
+
exports.importOrg = importOrg;
|
|
8
|
+
const sdk_1 = require("@myapihq/sdk");
|
|
9
|
+
const config_js_1 = require("../config.js");
|
|
10
|
+
const output_js_1 = require("../output.js");
|
|
11
|
+
const utils_js_1 = require("../utils.js");
|
|
12
|
+
async function create(flags) {
|
|
13
|
+
if (!flags.name)
|
|
14
|
+
(0, output_js_1.error)("Missing --name flag");
|
|
15
|
+
const config = (0, config_js_1.requireConfig)();
|
|
16
|
+
const payload = { name: flags.name };
|
|
17
|
+
if (flags.tagline)
|
|
18
|
+
payload.tagline = flags.tagline;
|
|
19
|
+
if (flags.description)
|
|
20
|
+
payload.description = flags.description;
|
|
21
|
+
const org = await sdk_1.hq.createOrg(config.api_key, payload);
|
|
22
|
+
(0, output_js_1.success)(`Org created! ID: ${org.id}, Name: ${org.name}`);
|
|
23
|
+
}
|
|
24
|
+
async function list(flags) {
|
|
25
|
+
const config = (0, config_js_1.requireConfig)();
|
|
26
|
+
const orgs = await sdk_1.hq.listOrgs(config.api_key);
|
|
27
|
+
(0, output_js_1.printTable)(orgs);
|
|
28
|
+
}
|
|
29
|
+
async function get(id, flags) {
|
|
30
|
+
if (!id)
|
|
31
|
+
(0, output_js_1.error)("Missing org id");
|
|
32
|
+
const config = (0, config_js_1.requireConfig)();
|
|
33
|
+
const org = await sdk_1.hq.getOrg(config.api_key, id);
|
|
34
|
+
(0, output_js_1.printJson)(org);
|
|
35
|
+
}
|
|
36
|
+
async function del(id, flags) {
|
|
37
|
+
if (!id)
|
|
38
|
+
(0, output_js_1.error)("Missing org id");
|
|
39
|
+
const config = (0, config_js_1.requireConfig)();
|
|
40
|
+
await sdk_1.hq.deleteOrg(config.api_key, id);
|
|
41
|
+
(0, output_js_1.success)(`Org ${id} deleted`);
|
|
42
|
+
}
|
|
43
|
+
async function importOrg(domain, flags) {
|
|
44
|
+
if (!domain)
|
|
45
|
+
(0, output_js_1.error)("Missing domain");
|
|
46
|
+
const config = (0, config_js_1.requireConfig)();
|
|
47
|
+
const result = await sdk_1.hq.importOrg(config.api_key, domain);
|
|
48
|
+
const importId = result.job_id;
|
|
49
|
+
process.stdout.write("Importing ");
|
|
50
|
+
const chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
51
|
+
let i = 0;
|
|
52
|
+
while (true) {
|
|
53
|
+
const status = await sdk_1.hq.getOrgImportStatus(config.api_key, importId);
|
|
54
|
+
if (status.status === 'awaiting_confirm') {
|
|
55
|
+
process.stdout.write('\r\x1b[K');
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
if (status.status === 'failed') {
|
|
59
|
+
process.stdout.write('\r\x1b[K');
|
|
60
|
+
(0, output_js_1.error)("Import failed");
|
|
61
|
+
}
|
|
62
|
+
process.stdout.write(`\rImporting ${chars[i++ % chars.length]}`);
|
|
63
|
+
await (0, utils_js_1.sleep)(3000);
|
|
64
|
+
}
|
|
65
|
+
const org = await sdk_1.hq.confirmOrgImport(config.api_key, importId);
|
|
66
|
+
(0, output_js_1.success)(`Import complete! Org ID: ${org.id}`);
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setup(): Promise<void>;
|
|
@@ -0,0 +1,165 @@
|
|
|
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.setup = setup;
|
|
37
|
+
const sdk_1 = require("@myapihq/sdk");
|
|
38
|
+
const config_js_1 = require("../config.js");
|
|
39
|
+
const output_js_1 = require("../output.js");
|
|
40
|
+
const readline = __importStar(require("readline"));
|
|
41
|
+
const child_process_1 = require("child_process");
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const os = __importStar(require("os"));
|
|
45
|
+
function ask(rl, q) {
|
|
46
|
+
return new Promise(resolve => rl.question(q, resolve));
|
|
47
|
+
}
|
|
48
|
+
function yn(answer, defaultYes = true) {
|
|
49
|
+
const t = answer.trim().toLowerCase();
|
|
50
|
+
if (t === '')
|
|
51
|
+
return defaultYes;
|
|
52
|
+
return t === 'y' || t === 'yes';
|
|
53
|
+
}
|
|
54
|
+
async function getOrCreateKey(rl) {
|
|
55
|
+
const choice = await ask(rl, '\n(1) Auto-create a new account (2) Paste an existing API key [1/2]: ');
|
|
56
|
+
if (choice.trim() === '2') {
|
|
57
|
+
const key = await ask(rl, 'Paste your API key: ');
|
|
58
|
+
(0, config_js_1.saveConfig)({ api_key: key.trim(), account_id: '', pin: '' });
|
|
59
|
+
(0, output_js_1.success)('API key saved to ~/.myapi/config.json');
|
|
60
|
+
return key.trim();
|
|
61
|
+
}
|
|
62
|
+
(0, output_js_1.info)('Creating account...');
|
|
63
|
+
const agent = await sdk_1.hq.createAgentAccount();
|
|
64
|
+
const keyInfo = await sdk_1.hq.createApiKey(agent.token, 'default');
|
|
65
|
+
(0, config_js_1.saveConfig)({ api_key: keyInfo.api_key, account_id: agent.account_id, pin: agent.pin });
|
|
66
|
+
(0, output_js_1.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.`);
|
|
67
|
+
return keyInfo.api_key;
|
|
68
|
+
}
|
|
69
|
+
function registerClaudeMcp() {
|
|
70
|
+
try {
|
|
71
|
+
(0, child_process_1.execSync)('claude mcp add myapi -- npx -y @myapihq/mcp', { stdio: 'inherit' });
|
|
72
|
+
(0, output_js_1.success)('Claude Code MCP registered');
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
(0, output_js_1.info)('Could not auto-register. Run manually:\n claude mcp add myapi -- npx -y @myapihq/mcp');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function registerGeminiMcp() {
|
|
79
|
+
const configPath = path.join(os.homedir(), '.gemini', 'settings.json');
|
|
80
|
+
try {
|
|
81
|
+
let settings = {};
|
|
82
|
+
if (fs.existsSync(configPath)) {
|
|
83
|
+
settings = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
84
|
+
}
|
|
85
|
+
settings.mcpServers = settings.mcpServers ?? {};
|
|
86
|
+
settings.mcpServers.myapi = { command: 'npx', args: ['-y', '@myapihq/mcp'] };
|
|
87
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
88
|
+
fs.writeFileSync(configPath, JSON.stringify(settings, null, 2));
|
|
89
|
+
(0, output_js_1.success)('Gemini CLI MCP registered (~/.gemini/settings.json)');
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
(0, output_js_1.info)('Could not auto-configure Gemini CLI. Add manually to ~/.gemini/settings.json:');
|
|
93
|
+
(0, output_js_1.info)(' { "mcpServers": { "myapi": { "command": "npx", "args": ["-y", "@myapihq/mcp"] } } }');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function setup() {
|
|
97
|
+
(0, output_js_1.info)('MyAPI Setup\n');
|
|
98
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
99
|
+
// Step 1: credentials
|
|
100
|
+
const existing = (0, config_js_1.loadConfig)();
|
|
101
|
+
if (existing?.api_key) {
|
|
102
|
+
const reuse = await ask(rl, `Found existing account (${existing.account_id || existing.api_key.slice(0, 20) + '...'}). Use it? [Y/n]: `);
|
|
103
|
+
if (!yn(reuse, true)) {
|
|
104
|
+
await getOrCreateKey(rl);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
(0, output_js_1.info)('Using existing credentials.');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
await getOrCreateKey(rl);
|
|
112
|
+
}
|
|
113
|
+
// Step 2: which agents
|
|
114
|
+
(0, output_js_1.info)('\nWhich AI agents do you use?');
|
|
115
|
+
const useClaude = yn(await ask(rl, ' Claude Code? [Y/n]: '), true);
|
|
116
|
+
const useGemini = yn(await ask(rl, ' Gemini CLI? [Y/n]: '), true);
|
|
117
|
+
const useCursor = yn(await ask(rl, ' Cursor? [y/N]: '), false);
|
|
118
|
+
const useWindsurf = yn(await ask(rl, ' Windsurf? [y/N]: '), false);
|
|
119
|
+
const useKiro = yn(await ask(rl, ' Kiro? [y/N]: '), false);
|
|
120
|
+
const useCopilot = yn(await ask(rl, ' GitHub Copilot? [y/N]: '), false);
|
|
121
|
+
const useOther = yn(await ask(rl, ' Other / Codex? [y/N]: '), false);
|
|
122
|
+
// Step 3: Claude — MCP or Skills or both
|
|
123
|
+
let claudeMcp = false;
|
|
124
|
+
let claudeSkills = false;
|
|
125
|
+
if (useClaude) {
|
|
126
|
+
(0, output_js_1.info)('\nFor Claude Code, how do you want to connect?');
|
|
127
|
+
claudeMcp = yn(await ask(rl, ' MCP server — live API calls via tool use? [Y/n]: '), true);
|
|
128
|
+
claudeSkills = yn(await ask(rl, ' Skills plugin — inline docs + prompts? [y/N]: '), false);
|
|
129
|
+
}
|
|
130
|
+
rl.close();
|
|
131
|
+
// Step 4: apply
|
|
132
|
+
(0, output_js_1.info)('\nApplying configuration...\n');
|
|
133
|
+
if (claudeMcp)
|
|
134
|
+
registerClaudeMcp();
|
|
135
|
+
if (useGemini)
|
|
136
|
+
registerGeminiMcp();
|
|
137
|
+
if (claudeSkills) {
|
|
138
|
+
(0, output_js_1.info)('To install the MyAPI skill inside Claude Code, run:');
|
|
139
|
+
(0, output_js_1.info)(' /plugin marketplace add myapihq/claude-skills');
|
|
140
|
+
(0, output_js_1.info)(' /plugin install my-api-hq@myapi-skills');
|
|
141
|
+
}
|
|
142
|
+
const skillsUrl = 'https://github.com/myapihq/agent-skills/blob/main/skills/my-api-hq/SKILL.md';
|
|
143
|
+
if (useCursor) {
|
|
144
|
+
(0, output_js_1.info)('\nCursor — copy the skill into .cursor/rules/:');
|
|
145
|
+
(0, output_js_1.info)(` ${skillsUrl}`);
|
|
146
|
+
}
|
|
147
|
+
if (useWindsurf) {
|
|
148
|
+
(0, output_js_1.info)('\nWindsurf — add the skill to your rules configuration:');
|
|
149
|
+
(0, output_js_1.info)(` ${skillsUrl}`);
|
|
150
|
+
}
|
|
151
|
+
if (useKiro) {
|
|
152
|
+
(0, output_js_1.info)('\nKiro — copy the skill into .kiro/skills/:');
|
|
153
|
+
(0, output_js_1.info)(` ${skillsUrl}`);
|
|
154
|
+
}
|
|
155
|
+
if (useCopilot) {
|
|
156
|
+
(0, output_js_1.info)('\nGitHub Copilot — paste the skill into .github/copilot-instructions.md:');
|
|
157
|
+
(0, output_js_1.info)(` ${skillsUrl}`);
|
|
158
|
+
}
|
|
159
|
+
if (useOther) {
|
|
160
|
+
(0, output_js_1.info)('\nOther agents — copy the skill markdown as a system prompt or instruction file:');
|
|
161
|
+
(0, output_js_1.info)(` ${skillsUrl}`);
|
|
162
|
+
}
|
|
163
|
+
(0, output_js_1.info)('');
|
|
164
|
+
(0, output_js_1.success)('Setup complete! Try: myapi billing balance');
|
|
165
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function list(flags: Record<string, string | boolean>): Promise<void>;
|
|
2
|
+
export declare function ingest(url: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
3
|
+
export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
|