@myapihq/cli 1.0.2 → 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/setup.js +26 -5
- package/dist/commands/storage.js +12 -3
- package/dist/index.js +19 -12
- 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/setup.ts +33 -7
- package/src/commands/storage.ts +12 -3
- package/src/index.ts +15 -23
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = list;
|
|
4
|
+
exports.ingest = ingest;
|
|
5
|
+
exports.del = del;
|
|
6
|
+
const sdk_1 = require("@myapihq/sdk");
|
|
7
|
+
const config_js_1 = require("../config.js");
|
|
8
|
+
const output_js_1 = require("../output.js");
|
|
9
|
+
function getOrgId(flags, config) {
|
|
10
|
+
const orgId = flags.org || config.org_id;
|
|
11
|
+
if (!orgId)
|
|
12
|
+
(0, output_js_1.error)("Missing org-id. Pass --org or set it in config.");
|
|
13
|
+
return orgId;
|
|
14
|
+
}
|
|
15
|
+
async function list(flags) {
|
|
16
|
+
const config = (0, config_js_1.requireConfig)();
|
|
17
|
+
const orgId = getOrgId(flags, config);
|
|
18
|
+
const assets = await sdk_1.storage.listAssets(config.api_key, orgId);
|
|
19
|
+
(0, output_js_1.printTable)(assets);
|
|
20
|
+
}
|
|
21
|
+
async function ingest(url, flags) {
|
|
22
|
+
if (!url)
|
|
23
|
+
(0, output_js_1.error)("Missing url");
|
|
24
|
+
const config = (0, config_js_1.requireConfig)();
|
|
25
|
+
const orgId = getOrgId(flags, config);
|
|
26
|
+
const res = await sdk_1.storage.ingestAsset(config.api_key, orgId, url, flags.name);
|
|
27
|
+
(0, output_js_1.success)(`Asset ingested! ID: ${res.asset_id}\nHosted URL: ${res.url}`);
|
|
28
|
+
}
|
|
29
|
+
async function del(id, flags) {
|
|
30
|
+
if (!id)
|
|
31
|
+
(0, output_js_1.error)("Missing id");
|
|
32
|
+
const config = (0, config_js_1.requireConfig)();
|
|
33
|
+
const orgId = getOrgId(flags, config);
|
|
34
|
+
await sdk_1.storage.deleteAsset(config.api_key, orgId, id);
|
|
35
|
+
(0, output_js_1.success)(`Asset ${id} deleted`);
|
|
36
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = list;
|
|
4
|
+
exports.create = create;
|
|
5
|
+
exports.del = del;
|
|
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 endpoints = await sdk_1.webhook.listEndpoints(config.api_key);
|
|
12
|
+
(0, output_js_1.printTable)(endpoints);
|
|
13
|
+
}
|
|
14
|
+
async function create(flags) {
|
|
15
|
+
if (!flags['org-id'] || !flags.name || !flags.description) {
|
|
16
|
+
(0, output_js_1.error)("Missing --org-id, --name, or --description flags");
|
|
17
|
+
}
|
|
18
|
+
const config = (0, config_js_1.requireConfig)();
|
|
19
|
+
const res = await sdk_1.webhook.createEndpoint(config.api_key, flags['org-id'], flags.name, flags.description);
|
|
20
|
+
(0, output_js_1.success)(`Webhook created! ID: ${res.id}\nInbound URL: ${res.inbound_url}`);
|
|
21
|
+
}
|
|
22
|
+
async function del(id, flags) {
|
|
23
|
+
if (!id)
|
|
24
|
+
(0, output_js_1.error)("Missing id");
|
|
25
|
+
const config = (0, config_js_1.requireConfig)();
|
|
26
|
+
await sdk_1.webhook.deleteEndpoint(config.api_key, id);
|
|
27
|
+
(0, output_js_1.success)(`Webhook ${id} deleted`);
|
|
28
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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 enable(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
+
export declare function disable(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
+
export declare function runs(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = list;
|
|
4
|
+
exports.create = create;
|
|
5
|
+
exports.enable = enable;
|
|
6
|
+
exports.disable = disable;
|
|
7
|
+
exports.runs = runs;
|
|
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 list(flags) {
|
|
12
|
+
const config = (0, config_js_1.requireConfig)();
|
|
13
|
+
const workflows = await sdk_1.workflow.listWorkflows(config.api_key);
|
|
14
|
+
(0, output_js_1.printTable)(workflows);
|
|
15
|
+
}
|
|
16
|
+
async function create(flags) {
|
|
17
|
+
if (!flags['org-id'] || !flags.name || !flags['endpoint-id'] || !flags.steps) {
|
|
18
|
+
(0, output_js_1.error)("Missing --org-id, --name, --endpoint-id, or --steps flags");
|
|
19
|
+
}
|
|
20
|
+
const config = (0, config_js_1.requireConfig)();
|
|
21
|
+
let steps;
|
|
22
|
+
try {
|
|
23
|
+
steps = JSON.parse(flags.steps);
|
|
24
|
+
}
|
|
25
|
+
catch (err) {
|
|
26
|
+
(0, output_js_1.error)("Invalid JSON for --steps");
|
|
27
|
+
}
|
|
28
|
+
const wf = await sdk_1.workflow.createWorkflow(config.api_key, {
|
|
29
|
+
org_id: flags['org-id'],
|
|
30
|
+
name: flags.name,
|
|
31
|
+
trigger_config: { endpoint_id: flags['endpoint-id'] },
|
|
32
|
+
steps
|
|
33
|
+
});
|
|
34
|
+
await sdk_1.workflow.enableWorkflow(config.api_key, wf.id);
|
|
35
|
+
(0, output_js_1.success)(`Workflow created and enabled! ID: ${wf.id}`);
|
|
36
|
+
}
|
|
37
|
+
async function enable(id, flags) {
|
|
38
|
+
if (!id)
|
|
39
|
+
(0, output_js_1.error)("Missing id");
|
|
40
|
+
const config = (0, config_js_1.requireConfig)();
|
|
41
|
+
await sdk_1.workflow.enableWorkflow(config.api_key, id);
|
|
42
|
+
(0, output_js_1.success)(`Workflow ${id} enabled`);
|
|
43
|
+
}
|
|
44
|
+
async function disable(id, flags) {
|
|
45
|
+
if (!id)
|
|
46
|
+
(0, output_js_1.error)("Missing id");
|
|
47
|
+
const config = (0, config_js_1.requireConfig)();
|
|
48
|
+
await sdk_1.workflow.disableWorkflow(config.api_key, id);
|
|
49
|
+
(0, output_js_1.success)(`Workflow ${id} disabled`);
|
|
50
|
+
}
|
|
51
|
+
async function runs(id, flags) {
|
|
52
|
+
if (!id)
|
|
53
|
+
(0, output_js_1.error)("Missing id");
|
|
54
|
+
const config = (0, config_js_1.requireConfig)();
|
|
55
|
+
const runs = await sdk_1.workflow.listWorkflowRuns(config.api_key, id);
|
|
56
|
+
(0, output_js_1.printTable)(runs);
|
|
57
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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.loadConfig = loadConfig;
|
|
37
|
+
exports.saveConfig = saveConfig;
|
|
38
|
+
exports.requireConfig = requireConfig;
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const CONFIG_DIR = path.join(os.homedir(), '.myapi');
|
|
43
|
+
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
44
|
+
function loadConfig() {
|
|
45
|
+
try {
|
|
46
|
+
if (!fs.existsSync(CONFIG_FILE)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const data = fs.readFileSync(CONFIG_FILE, 'utf-8');
|
|
50
|
+
return JSON.parse(data);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function saveConfig(config) {
|
|
57
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
58
|
+
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
59
|
+
}
|
|
60
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
61
|
+
}
|
|
62
|
+
function requireConfig() {
|
|
63
|
+
const config = loadConfig();
|
|
64
|
+
if (!config || !config.api_key) {
|
|
65
|
+
console.error("No API key found. Run: myapi account create");
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
return config;
|
|
69
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
// AUTO-GENERATED by scripts/generate-indexes.js — do not edit manually
|
|
38
|
+
const utils_js_1 = require("./utils.js");
|
|
39
|
+
const output_js_1 = require("./output.js");
|
|
40
|
+
const sdk_1 = require("@myapihq/sdk");
|
|
41
|
+
const accountCmd = __importStar(require("./commands/account.js"));
|
|
42
|
+
const billingCmd = __importStar(require("./commands/billing.js"));
|
|
43
|
+
const orgCmd = __importStar(require("./commands/org.js"));
|
|
44
|
+
const setupCmd = __importStar(require("./commands/setup.js"));
|
|
45
|
+
async function main() {
|
|
46
|
+
const { args, flags } = (0, utils_js_1.parseArgs)(process.argv.slice(2));
|
|
47
|
+
if (args.length === 0) {
|
|
48
|
+
printHelp();
|
|
49
|
+
process.exit(0);
|
|
50
|
+
}
|
|
51
|
+
const [command, subcommand, ...restArgs] = args;
|
|
52
|
+
try {
|
|
53
|
+
switch (command) {
|
|
54
|
+
case 'setup':
|
|
55
|
+
await setupCmd.setup();
|
|
56
|
+
break;
|
|
57
|
+
case 'account':
|
|
58
|
+
if (subcommand === 'create')
|
|
59
|
+
await accountCmd.create();
|
|
60
|
+
else if (subcommand === 'token')
|
|
61
|
+
await accountCmd.token(flags);
|
|
62
|
+
else if (subcommand === 'keys')
|
|
63
|
+
await accountCmd.listKeys(flags);
|
|
64
|
+
else if (subcommand === 'revoke')
|
|
65
|
+
await accountCmd.revokeKey(restArgs[0], flags);
|
|
66
|
+
else
|
|
67
|
+
printHelp();
|
|
68
|
+
break;
|
|
69
|
+
case 'org':
|
|
70
|
+
if (subcommand === 'list')
|
|
71
|
+
await orgCmd.list(flags);
|
|
72
|
+
else if (subcommand === 'create')
|
|
73
|
+
await orgCmd.create(flags);
|
|
74
|
+
else
|
|
75
|
+
printHelp();
|
|
76
|
+
break;
|
|
77
|
+
case 'billing':
|
|
78
|
+
if (subcommand === 'balance')
|
|
79
|
+
await billingCmd.balance(flags);
|
|
80
|
+
else if (subcommand === 'history')
|
|
81
|
+
await billingCmd.history(flags);
|
|
82
|
+
else if (subcommand === 'topup')
|
|
83
|
+
await billingCmd.topup(restArgs[0], flags);
|
|
84
|
+
else if (subcommand === 'setup')
|
|
85
|
+
await billingCmd.setup(flags);
|
|
86
|
+
else
|
|
87
|
+
printHelp();
|
|
88
|
+
break;
|
|
89
|
+
default:
|
|
90
|
+
printHelp();
|
|
91
|
+
process.exit(0);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
if (err instanceof sdk_1.MyApiError) {
|
|
96
|
+
if (err.status === 402)
|
|
97
|
+
(0, output_js_1.error)('Insufficient balance. Run: myapi billing topup <amount>');
|
|
98
|
+
else if (err.status === 401)
|
|
99
|
+
(0, output_js_1.error)('Invalid API key. Run: myapi setup');
|
|
100
|
+
}
|
|
101
|
+
(0, output_js_1.error)(err.message || String(err));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function printHelp() {
|
|
105
|
+
(0, output_js_1.info)(`myapi - MyAPI command-line interface
|
|
106
|
+
|
|
107
|
+
Usage: myapi <command> [subcommand] [args]
|
|
108
|
+
|
|
109
|
+
Commands:
|
|
110
|
+
account
|
|
111
|
+
billing
|
|
112
|
+
org
|
|
113
|
+
setup
|
|
114
|
+
|
|
115
|
+
Run "myapi <command>" for subcommand help.`);
|
|
116
|
+
}
|
|
117
|
+
main().catch(err => { (0, output_js_1.error)(err.message || String(err)); });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function success(message: string): void;
|
|
2
|
+
export declare function error(message: string): never;
|
|
3
|
+
export declare function info(message: string): void;
|
|
4
|
+
export declare function printJson(data: unknown): void;
|
|
5
|
+
export declare function printTable(rows: Record<string, unknown>[]): void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.success = success;
|
|
4
|
+
exports.error = error;
|
|
5
|
+
exports.info = info;
|
|
6
|
+
exports.printJson = printJson;
|
|
7
|
+
exports.printTable = printTable;
|
|
8
|
+
function success(message) {
|
|
9
|
+
console.log(`\x1b[32m✓\x1b[0m ${message}`);
|
|
10
|
+
}
|
|
11
|
+
function error(message) {
|
|
12
|
+
console.error(`\x1b[31m✗\x1b[0m ${message}`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
function info(message) {
|
|
16
|
+
console.log(message);
|
|
17
|
+
}
|
|
18
|
+
function printJson(data) {
|
|
19
|
+
console.log(JSON.stringify(data, null, 2));
|
|
20
|
+
}
|
|
21
|
+
function printTable(rows) {
|
|
22
|
+
if (process.argv.includes('--json')) {
|
|
23
|
+
printJson(rows);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (rows.length === 0) {
|
|
27
|
+
console.log("No data found.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const columns = Object.keys(rows[0]);
|
|
31
|
+
const colWidths = columns.map(col => {
|
|
32
|
+
return Math.max(col.length, ...rows.map(row => String(row[col] ?? '').length));
|
|
33
|
+
});
|
|
34
|
+
const printRow = (row) => {
|
|
35
|
+
console.log(row.map((cell, i) => cell.padEnd(colWidths[i] + 2)).join(''));
|
|
36
|
+
};
|
|
37
|
+
printRow(columns);
|
|
38
|
+
console.log(colWidths.map(w => '-'.repeat(w + 2)).join(''));
|
|
39
|
+
for (const row of rows) {
|
|
40
|
+
printRow(columns.map(col => String(row[col] ?? '')));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseArgs = parseArgs;
|
|
4
|
+
exports.sleep = sleep;
|
|
5
|
+
function parseArgs(argv) {
|
|
6
|
+
const args = [];
|
|
7
|
+
const flags = {};
|
|
8
|
+
for (let i = 0; i < argv.length; i++) {
|
|
9
|
+
const arg = argv[i];
|
|
10
|
+
if (arg.startsWith('--')) {
|
|
11
|
+
if (arg.includes('=')) {
|
|
12
|
+
const [key, value] = arg.slice(2).split('=', 2);
|
|
13
|
+
flags[key] = value;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const next = argv[i + 1];
|
|
17
|
+
if (next && !next.startsWith('--')) {
|
|
18
|
+
flags[arg.slice(2)] = next;
|
|
19
|
+
i++;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
flags[arg.slice(2)] = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
args.push(arg);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { args, flags };
|
|
31
|
+
}
|
|
32
|
+
function sleep(ms) {
|
|
33
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
34
|
+
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -112,9 +112,13 @@ async function setup() {
|
|
|
112
112
|
}
|
|
113
113
|
// Step 2: which agents
|
|
114
114
|
(0, output_js_1.info)('\nWhich AI agents do you use?');
|
|
115
|
-
const useClaude = yn(await ask(rl, ' Claude Code?
|
|
116
|
-
const useGemini = yn(await ask(rl, ' Gemini CLI?
|
|
117
|
-
const useCursor = yn(await ask(rl, ' Cursor
|
|
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);
|
|
118
122
|
// Step 3: Claude — MCP or Skills or both
|
|
119
123
|
let claudeMcp = false;
|
|
120
124
|
let claudeSkills = false;
|
|
@@ -135,9 +139,26 @@ async function setup() {
|
|
|
135
139
|
(0, output_js_1.info)(' /plugin marketplace add myapihq/claude-skills');
|
|
136
140
|
(0, output_js_1.info)(' /plugin install my-api-hq@myapi-skills');
|
|
137
141
|
}
|
|
142
|
+
const skillsUrl = 'https://github.com/myapihq/agent-skills/blob/main/skills/my-api-hq/SKILL.md';
|
|
138
143
|
if (useCursor) {
|
|
139
|
-
(0, output_js_1.info)('\
|
|
140
|
-
(0, output_js_1.info)(
|
|
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}`);
|
|
141
162
|
}
|
|
142
163
|
(0, output_js_1.info)('');
|
|
143
164
|
(0, output_js_1.success)('Setup complete! Try: myapi billing balance');
|
package/dist/commands/storage.js
CHANGED
|
@@ -6,22 +6,31 @@ exports.del = del;
|
|
|
6
6
|
const sdk_1 = require("@myapihq/sdk");
|
|
7
7
|
const config_js_1 = require("../config.js");
|
|
8
8
|
const output_js_1 = require("../output.js");
|
|
9
|
+
function getOrgId(flags, config) {
|
|
10
|
+
const orgId = flags.org || config.org_id;
|
|
11
|
+
if (!orgId)
|
|
12
|
+
(0, output_js_1.error)("Missing org-id. Pass --org or set it in config.");
|
|
13
|
+
return orgId;
|
|
14
|
+
}
|
|
9
15
|
async function list(flags) {
|
|
10
16
|
const config = (0, config_js_1.requireConfig)();
|
|
11
|
-
const
|
|
17
|
+
const orgId = getOrgId(flags, config);
|
|
18
|
+
const assets = await sdk_1.storage.listAssets(config.api_key, orgId);
|
|
12
19
|
(0, output_js_1.printTable)(assets);
|
|
13
20
|
}
|
|
14
21
|
async function ingest(url, flags) {
|
|
15
22
|
if (!url)
|
|
16
23
|
(0, output_js_1.error)("Missing url");
|
|
17
24
|
const config = (0, config_js_1.requireConfig)();
|
|
18
|
-
const
|
|
25
|
+
const orgId = getOrgId(flags, config);
|
|
26
|
+
const res = await sdk_1.storage.ingestAsset(config.api_key, orgId, url, flags.name);
|
|
19
27
|
(0, output_js_1.success)(`Asset ingested! ID: ${res.asset_id}\nHosted URL: ${res.url}`);
|
|
20
28
|
}
|
|
21
29
|
async function del(id, flags) {
|
|
22
30
|
if (!id)
|
|
23
31
|
(0, output_js_1.error)("Missing id");
|
|
24
32
|
const config = (0, config_js_1.requireConfig)();
|
|
25
|
-
|
|
33
|
+
const orgId = getOrgId(flags, config);
|
|
34
|
+
await sdk_1.storage.deleteAsset(config.api_key, orgId, id);
|
|
26
35
|
(0, output_js_1.success)(`Asset ${id} deleted`);
|
|
27
36
|
}
|
package/dist/index.js
CHANGED
|
@@ -34,11 +34,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
// AUTO-GENERATED by scripts/generate-indexes.js — do not edit manually
|
|
37
38
|
const utils_js_1 = require("./utils.js");
|
|
38
39
|
const output_js_1 = require("./output.js");
|
|
39
40
|
const sdk_1 = require("@myapihq/sdk");
|
|
40
41
|
const accountCmd = __importStar(require("./commands/account.js"));
|
|
41
42
|
const billingCmd = __importStar(require("./commands/billing.js"));
|
|
43
|
+
const orgCmd = __importStar(require("./commands/org.js"));
|
|
42
44
|
const setupCmd = __importStar(require("./commands/setup.js"));
|
|
43
45
|
async function main() {
|
|
44
46
|
const { args, flags } = (0, utils_js_1.parseArgs)(process.argv.slice(2));
|
|
@@ -64,6 +66,14 @@ async function main() {
|
|
|
64
66
|
else
|
|
65
67
|
printHelp();
|
|
66
68
|
break;
|
|
69
|
+
case 'org':
|
|
70
|
+
if (subcommand === 'list')
|
|
71
|
+
await orgCmd.list(flags);
|
|
72
|
+
else if (subcommand === 'create')
|
|
73
|
+
await orgCmd.create(flags);
|
|
74
|
+
else
|
|
75
|
+
printHelp();
|
|
76
|
+
break;
|
|
67
77
|
case 'billing':
|
|
68
78
|
if (subcommand === 'balance')
|
|
69
79
|
await billingCmd.balance(flags);
|
|
@@ -83,12 +93,10 @@ async function main() {
|
|
|
83
93
|
}
|
|
84
94
|
catch (err) {
|
|
85
95
|
if (err instanceof sdk_1.MyApiError) {
|
|
86
|
-
if (err.status === 402)
|
|
87
|
-
(0, output_js_1.error)(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
(0, output_js_1.error)("Invalid API key. Run: myapi account create");
|
|
91
|
-
}
|
|
96
|
+
if (err.status === 402)
|
|
97
|
+
(0, output_js_1.error)('Insufficient balance. Run: myapi billing topup <amount>');
|
|
98
|
+
else if (err.status === 401)
|
|
99
|
+
(0, output_js_1.error)('Invalid API key. Run: myapi setup');
|
|
92
100
|
}
|
|
93
101
|
(0, output_js_1.error)(err.message || String(err));
|
|
94
102
|
}
|
|
@@ -99,12 +107,11 @@ function printHelp() {
|
|
|
99
107
|
Usage: myapi <command> [subcommand] [args]
|
|
100
108
|
|
|
101
109
|
Commands:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
110
|
+
account
|
|
111
|
+
billing
|
|
112
|
+
org
|
|
113
|
+
setup
|
|
105
114
|
|
|
106
115
|
Run "myapi <command>" for subcommand help.`);
|
|
107
116
|
}
|
|
108
|
-
main().catch(err => {
|
|
109
|
-
(0, output_js_1.error)(err.message || String(err));
|
|
110
|
-
});
|
|
117
|
+
main().catch(err => { (0, output_js_1.error)(err.message || String(err)); });
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MyApiError = void 0;
|
|
4
|
+
exports.request = request;
|
|
5
|
+
class MyApiError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
status;
|
|
8
|
+
constructor(code, status) {
|
|
9
|
+
super(code);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.name = 'MyApiError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.MyApiError = MyApiError;
|
|
16
|
+
async function request(method, url, apiKey, body) {
|
|
17
|
+
const headers = {};
|
|
18
|
+
if (apiKey) {
|
|
19
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
20
|
+
}
|
|
21
|
+
if (body !== undefined) {
|
|
22
|
+
headers['Content-Type'] = 'application/json';
|
|
23
|
+
}
|
|
24
|
+
const options = {
|
|
25
|
+
method,
|
|
26
|
+
headers,
|
|
27
|
+
};
|
|
28
|
+
if (body !== undefined) {
|
|
29
|
+
options.body = JSON.stringify(body);
|
|
30
|
+
}
|
|
31
|
+
const response = await fetch(url, options);
|
|
32
|
+
if (response.status === 204) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
result = await response.json();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
throw new MyApiError('invalid_json_response', response.status);
|
|
41
|
+
}
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
const code = result?.error || 'unknown_error';
|
|
44
|
+
throw new MyApiError(code, response.status);
|
|
45
|
+
}
|
|
46
|
+
const apiResponse = result;
|
|
47
|
+
if (!apiResponse.success) {
|
|
48
|
+
throw new MyApiError(apiResponse.error || 'unknown_error', response.status);
|
|
49
|
+
}
|
|
50
|
+
return apiResponse.data;
|
|
51
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface DomainRecord {
|
|
2
|
+
domain: string;
|
|
3
|
+
status: string;
|
|
4
|
+
expires_at?: string;
|
|
5
|
+
created_at: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DomainSettings {
|
|
8
|
+
domain: string;
|
|
9
|
+
security_level: string;
|
|
10
|
+
browser_check: string;
|
|
11
|
+
ai_bots_protection: string;
|
|
12
|
+
is_robots_txt_managed: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function checkDomain(apiKey: string, domain: string): Promise<{
|
|
15
|
+
available: boolean;
|
|
16
|
+
price_cents: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function registerDomain(apiKey: string, domain: string, years?: number): Promise<DomainRecord>;
|
|
19
|
+
export declare function importDomain(apiKey: string, payload: {
|
|
20
|
+
domain: string;
|
|
21
|
+
namecheap_api_user?: string;
|
|
22
|
+
namecheap_api_key?: string;
|
|
23
|
+
}): Promise<DomainRecord>;
|
|
24
|
+
export declare function listDomains(apiKey: string): Promise<DomainRecord[]>;
|
|
25
|
+
export declare function getDomainStatus(apiKey: string, domain: string): Promise<DomainRecord>;
|
|
26
|
+
export declare function renewDomain(apiKey: string, domain: string, years?: number): Promise<DomainRecord>;
|
|
27
|
+
export declare function getDomainSettings(apiKey: string, domain: string): Promise<DomainSettings>;
|
|
28
|
+
export declare function updateDomainSettings(apiKey: string, domain: string, payload: {
|
|
29
|
+
security_level?: 'essentially_off' | 'medium' | 'high' | 'under_attack';
|
|
30
|
+
browser_check?: 'on' | 'off';
|
|
31
|
+
purge_cache?: boolean;
|
|
32
|
+
}): Promise<DomainSettings>;
|