@myapihq/cli 1.0.16 → 1.0.17
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/billing.js +26 -32
- package/dist/commands/config.js +20 -26
- package/dist/commands/domain.js +56 -67
- package/dist/commands/email.js +75 -88
- package/dist/commands/funnel.js +43 -52
- package/dist/commands/image.js +17 -21
- package/dist/commands/keys.js +22 -60
- package/dist/commands/org.js +37 -44
- package/dist/commands/setup.js +13 -49
- package/dist/commands/storage.js +18 -23
- package/dist/commands/url.d.ts +2 -0
- package/dist/commands/url.js +29 -0
- package/dist/commands/webhook.d.ts +2 -0
- package/dist/commands/webhook.js +64 -24
- package/dist/commands/workflow.d.ts +1 -0
- package/dist/commands/workflow.js +81 -43
- package/dist/config.js +6 -44
- package/dist/index.js +41 -56
- package/dist/output.js +5 -12
- package/dist/utils.js +2 -6
- package/package.json +5 -2
- package/src/commands/url.ts +28 -0
- package/src/commands/webhook.ts +50 -9
- package/src/commands/workflow.ts +55 -18
- package/src/index.ts +23 -0
package/dist/commands/funnel.js
CHANGED
|
@@ -1,54 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.del = del;
|
|
7
|
-
exports.push = push;
|
|
8
|
-
exports.verify = verify;
|
|
9
|
-
exports.run = run;
|
|
10
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
11
|
-
const config_js_1 = require("../config.js");
|
|
12
|
-
const output_js_1 = require("../output.js");
|
|
13
|
-
async function list(flags) {
|
|
14
|
-
const config = (0, config_js_1.requireConfig)();
|
|
1
|
+
import { funnel as sdkFunnel } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable, info, printJson } from '../output.js';
|
|
4
|
+
export async function list(flags) {
|
|
5
|
+
const config = requireConfig();
|
|
15
6
|
const orgId = flags.org || config.default_org;
|
|
16
7
|
if (!orgId)
|
|
17
|
-
|
|
18
|
-
const funnels = await
|
|
19
|
-
|
|
8
|
+
error("Missing required arguments.\nUsage: myapi funnel list --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
9
|
+
const funnels = await sdkFunnel.listFunnels(config.api_key, orgId);
|
|
10
|
+
printTable(funnels);
|
|
20
11
|
}
|
|
21
|
-
async function create(flags) {
|
|
22
|
-
const config =
|
|
12
|
+
export async function create(flags) {
|
|
13
|
+
const config = requireConfig();
|
|
23
14
|
const orgId = flags.org || config.default_org;
|
|
24
15
|
const domain = flags.domain || config.default_domain;
|
|
25
16
|
if (!orgId || !domain) {
|
|
26
|
-
|
|
17
|
+
error("Missing required arguments.\nUsage: myapi funnel create --org <id> --domain <domain>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
27
18
|
}
|
|
28
|
-
const funnel = await
|
|
29
|
-
|
|
19
|
+
const funnel = await sdkFunnel.createFunnel(config.api_key, orgId, domain);
|
|
20
|
+
success(`Funnel created! ID: ${funnel.id}`);
|
|
30
21
|
}
|
|
31
|
-
async function get(id, flags) {
|
|
32
|
-
const config =
|
|
22
|
+
export async function get(id, flags) {
|
|
23
|
+
const config = requireConfig();
|
|
33
24
|
const orgId = flags.org || config.default_org;
|
|
34
25
|
if (!orgId || !id)
|
|
35
|
-
|
|
36
|
-
const funnel = await
|
|
37
|
-
|
|
26
|
+
error("Missing required arguments.\nUsage: myapi funnel get <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
27
|
+
const funnel = await sdkFunnel.getFunnel(config.api_key, orgId, id);
|
|
28
|
+
printJson(funnel);
|
|
38
29
|
}
|
|
39
|
-
async function del(id, flags) {
|
|
40
|
-
const config =
|
|
30
|
+
export async function del(id, flags) {
|
|
31
|
+
const config = requireConfig();
|
|
41
32
|
const orgId = flags.org || config.default_org;
|
|
42
33
|
if (!orgId || !id)
|
|
43
|
-
|
|
44
|
-
await
|
|
45
|
-
|
|
34
|
+
error("Missing required arguments.\nUsage: myapi funnel delete <id> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
35
|
+
await sdkFunnel.deleteFunnel(config.api_key, orgId, id);
|
|
36
|
+
success(`Funnel ${id} deleted`);
|
|
46
37
|
}
|
|
47
|
-
async function push(id, slug, flags) {
|
|
48
|
-
const config =
|
|
38
|
+
export async function push(id, slug, flags) {
|
|
39
|
+
const config = requireConfig();
|
|
49
40
|
const orgId = flags.org || config.default_org;
|
|
50
41
|
if (!orgId || !id || !slug) {
|
|
51
|
-
|
|
42
|
+
error("Missing required arguments.\nUsage: myapi funnel push <funnel_id> <slug> --org <id> < index.html\n(Or set defaults via: myapi config set-org <id>)");
|
|
52
43
|
}
|
|
53
44
|
const html = await new Promise((resolve, reject) => {
|
|
54
45
|
let data = '';
|
|
@@ -58,39 +49,39 @@ async function push(id, slug, flags) {
|
|
|
58
49
|
process.stdin.on('error', reject);
|
|
59
50
|
});
|
|
60
51
|
if (!html)
|
|
61
|
-
|
|
62
|
-
await
|
|
63
|
-
|
|
52
|
+
error("No HTML provided via stdin");
|
|
53
|
+
await sdkFunnel.pushFunnelPage(config.api_key, orgId, id, { slug, html });
|
|
54
|
+
success(`Pushed page to ${slug}`);
|
|
64
55
|
}
|
|
65
|
-
async function verify(id, flags) {
|
|
66
|
-
const config =
|
|
56
|
+
export async function verify(id, flags) {
|
|
57
|
+
const config = requireConfig();
|
|
67
58
|
const orgId = flags.org || config.default_org;
|
|
68
59
|
if (!orgId || !id)
|
|
69
|
-
|
|
60
|
+
error("Missing required arguments.\nUsage: myapi funnel verify <id> --org <id> [--slug <slug>]\n(Or set defaults via: myapi config set-org <id>)");
|
|
70
61
|
const opts = {};
|
|
71
62
|
if (flags.slug)
|
|
72
63
|
opts.slug = flags.slug;
|
|
73
|
-
const v = await
|
|
74
|
-
|
|
64
|
+
const v = await sdkFunnel.verifyFunnel(config.api_key, orgId, id, opts);
|
|
65
|
+
printJson(v);
|
|
75
66
|
}
|
|
76
|
-
async function run(subcommand, args, flags) {
|
|
67
|
+
export async function run(subcommand, args, flags) {
|
|
77
68
|
if (!subcommand || (flags.help && !subcommand)) {
|
|
78
|
-
|
|
69
|
+
info('Usage: myapi funnel <subcommand>\n\nSubcommands:\n list List funnels\n create Create a funnel\n get Get funnel details\n delete Delete a funnel\n push Push a raw HTML page to a slug\n verify Verify links and webhooks\n\nNote: All funnel commands require the --org <id> flag.');
|
|
79
70
|
return;
|
|
80
71
|
}
|
|
81
72
|
if (flags.help) {
|
|
82
73
|
if (subcommand === 'list')
|
|
83
|
-
|
|
74
|
+
info('Usage: myapi funnel list --org <id>');
|
|
84
75
|
else if (subcommand === 'create')
|
|
85
|
-
|
|
76
|
+
info('Usage: myapi funnel create --org <id> --domain <domain>');
|
|
86
77
|
else if (subcommand === 'get')
|
|
87
|
-
|
|
78
|
+
info('Usage: myapi funnel get <id> --org <id>');
|
|
88
79
|
else if (subcommand === 'delete')
|
|
89
|
-
|
|
80
|
+
info('Usage: myapi funnel delete <id> --org <id>');
|
|
90
81
|
else if (subcommand === 'push')
|
|
91
|
-
|
|
82
|
+
info('Usage: myapi funnel push <funnel_id> <slug> --org <id> < index.html\n\nPushes HTML content from stdin to the specified funnel.');
|
|
92
83
|
else if (subcommand === 'verify')
|
|
93
|
-
|
|
84
|
+
info('Usage: myapi funnel verify <id> --org <id> [--slug <slug>]\n\nVerifies syntax and structure before pushing.');
|
|
94
85
|
return;
|
|
95
86
|
}
|
|
96
87
|
if (subcommand === 'list')
|
|
@@ -106,5 +97,5 @@ async function run(subcommand, args, flags) {
|
|
|
106
97
|
else if (subcommand === 'verify')
|
|
107
98
|
await verify(args[0], flags);
|
|
108
99
|
else
|
|
109
|
-
|
|
100
|
+
error(`Unknown subcommand: ${subcommand}. Run "myapi funnel --help" for a list of valid subcommands.`);
|
|
110
101
|
}
|
package/dist/commands/image.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) {
|
|
1
|
+
import { image as sdkImage } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable } from '../output.js';
|
|
4
|
+
import { sleep } from '../utils.js';
|
|
5
|
+
export async function generate(flags) {
|
|
10
6
|
if (!flags.prompt)
|
|
11
|
-
|
|
12
|
-
const config =
|
|
7
|
+
error("Missing --prompt flag");
|
|
8
|
+
const config = requireConfig();
|
|
13
9
|
const payload = { prompt: flags.prompt };
|
|
14
10
|
if (flags.ratio)
|
|
15
11
|
payload.aspect_ratio = flags.ratio;
|
|
@@ -17,31 +13,31 @@ async function generate(flags) {
|
|
|
17
13
|
payload.style = flags.style;
|
|
18
14
|
if (flags.colors)
|
|
19
15
|
payload.colors = flags.colors;
|
|
20
|
-
const res = await
|
|
16
|
+
const res = await sdkImage.generateImage(config.api_key, payload);
|
|
21
17
|
process.stdout.write("Generating image ");
|
|
22
18
|
const chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
23
19
|
let i = 0;
|
|
24
20
|
let elapsed = 0;
|
|
25
21
|
while (elapsed < 60000) {
|
|
26
|
-
const job = await
|
|
22
|
+
const job = await sdkImage.getImageJob(config.api_key, res.job_id);
|
|
27
23
|
if (job.status === 'completed') {
|
|
28
24
|
process.stdout.write('\r\x1b[K');
|
|
29
|
-
|
|
25
|
+
success(`Image generated!\nURL: ${job.url}`);
|
|
30
26
|
return;
|
|
31
27
|
}
|
|
32
28
|
if (job.status === 'failed') {
|
|
33
29
|
process.stdout.write('\r\x1b[K');
|
|
34
|
-
|
|
30
|
+
error(`Image generation failed: ${job.error || 'Unknown error'}`);
|
|
35
31
|
}
|
|
36
32
|
process.stdout.write(`\rGenerating image ${chars[i++ % chars.length]}`);
|
|
37
|
-
await
|
|
33
|
+
await sleep(3000);
|
|
38
34
|
elapsed += 3000;
|
|
39
35
|
}
|
|
40
36
|
process.stdout.write('\r\x1b[K');
|
|
41
|
-
|
|
37
|
+
error("Image generation timed out");
|
|
42
38
|
}
|
|
43
|
-
async function list(flags) {
|
|
44
|
-
const config =
|
|
45
|
-
const images = await
|
|
46
|
-
|
|
39
|
+
export async function list(flags) {
|
|
40
|
+
const config = requireConfig();
|
|
41
|
+
const images = await sdkImage.listImages(config.api_key);
|
|
42
|
+
printTable(images);
|
|
47
43
|
}
|
package/dist/commands/keys.js
CHANGED
|
@@ -1,70 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.createNew = createNew;
|
|
37
|
-
exports.list = list;
|
|
38
|
-
exports.revoke = revoke;
|
|
39
|
-
const sdk_1 = require("@myapihq/sdk");
|
|
40
|
-
const config_js_1 = require("../config.js");
|
|
41
|
-
const output_js_1 = require("../output.js");
|
|
42
|
-
const readline = __importStar(require("readline"));
|
|
43
|
-
async function createNew(flags) {
|
|
1
|
+
import { hq } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable, info, printJson } from '../output.js';
|
|
4
|
+
import * as readline from 'readline';
|
|
5
|
+
export async function createNew(flags) {
|
|
44
6
|
if (flags.help) {
|
|
45
|
-
|
|
7
|
+
info('Usage: myapi keys create\n\nCreates a new API key. You will be prompted to enter a name for the key.');
|
|
46
8
|
return;
|
|
47
9
|
}
|
|
48
|
-
const config =
|
|
10
|
+
const config = requireConfig();
|
|
49
11
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
50
12
|
const name = await new Promise(resolve => rl.question('Enter a name for the new key: ', resolve));
|
|
51
13
|
rl.close();
|
|
52
14
|
if (!name.trim()) {
|
|
53
|
-
|
|
15
|
+
error('Key name cannot be empty.');
|
|
54
16
|
return;
|
|
55
17
|
}
|
|
56
|
-
const keyInfo = await
|
|
57
|
-
|
|
18
|
+
const keyInfo = await hq.createApiKey(config.api_key, name.trim());
|
|
19
|
+
success(`New API key created!\n\nName: ${keyInfo.prefix}...\nKey: ${keyInfo.api_key}\n\nMake sure to copy your new API key now. You won't be able to see it again!`);
|
|
58
20
|
}
|
|
59
|
-
async function list(flags) {
|
|
21
|
+
export async function list(flags) {
|
|
60
22
|
if (flags.help) {
|
|
61
|
-
|
|
23
|
+
info('Usage: myapi keys list [--json]\n\nLists all API keys associated with your account.');
|
|
62
24
|
return;
|
|
63
25
|
}
|
|
64
|
-
const config =
|
|
65
|
-
const keysList = await
|
|
26
|
+
const config = requireConfig();
|
|
27
|
+
const keysList = await hq.listApiKeys(config.api_key);
|
|
66
28
|
if (flags.json) {
|
|
67
|
-
|
|
29
|
+
printJson(keysList);
|
|
68
30
|
return;
|
|
69
31
|
}
|
|
70
32
|
const formattedKeys = keysList.map(k => {
|
|
@@ -85,18 +47,18 @@ async function list(flags) {
|
|
|
85
47
|
'Last Used': lastUsedStr
|
|
86
48
|
};
|
|
87
49
|
});
|
|
88
|
-
|
|
50
|
+
printTable(formattedKeys);
|
|
89
51
|
}
|
|
90
|
-
async function revoke(id, flags) {
|
|
52
|
+
export async function revoke(id, flags) {
|
|
91
53
|
if (flags.help) {
|
|
92
|
-
|
|
54
|
+
info('Usage: myapi keys revoke <id>\n\nRevokes an API key permanently.');
|
|
93
55
|
return;
|
|
94
56
|
}
|
|
95
57
|
if (!id) {
|
|
96
|
-
|
|
58
|
+
error("Missing key ID. Usage: myapi keys revoke <id>");
|
|
97
59
|
return;
|
|
98
60
|
}
|
|
99
|
-
const config =
|
|
100
|
-
await
|
|
101
|
-
|
|
61
|
+
const config = requireConfig();
|
|
62
|
+
await hq.revokeApiKey(config.api_key, id);
|
|
63
|
+
success(`Key ${id} revoked successfully.`);
|
|
102
64
|
}
|
package/dist/commands/org.js
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) {
|
|
1
|
+
import { hq } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printJson, info } from '../output.js';
|
|
4
|
+
import { sleep } from '../utils.js';
|
|
5
|
+
export async function create(flags) {
|
|
13
6
|
if (flags.help) {
|
|
14
|
-
|
|
7
|
+
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');
|
|
15
8
|
return;
|
|
16
9
|
}
|
|
17
10
|
if (!flags.name) {
|
|
18
|
-
|
|
11
|
+
error("Missing --name flag. Run 'myapi org create --help' for details.");
|
|
19
12
|
return;
|
|
20
13
|
}
|
|
21
|
-
const config =
|
|
14
|
+
const config = requireConfig();
|
|
22
15
|
const payload = { name: flags.name };
|
|
23
16
|
if (flags.tagline)
|
|
24
17
|
payload.tagline = flags.tagline;
|
|
@@ -28,74 +21,74 @@ async function create(flags) {
|
|
|
28
21
|
payload.business_sector = flags['business-sector'];
|
|
29
22
|
if (flags['logo-url'])
|
|
30
23
|
payload.logo_url = flags['logo-url'];
|
|
31
|
-
const org = await
|
|
32
|
-
|
|
24
|
+
const org = await hq.createOrg(config.api_key, payload);
|
|
25
|
+
success(`Org created! ID: ${org.id}, Name: ${org.name}`);
|
|
33
26
|
}
|
|
34
|
-
async function list(flags) {
|
|
27
|
+
export async function list(flags) {
|
|
35
28
|
if (flags.help) {
|
|
36
|
-
|
|
29
|
+
info('Usage: myapi org list\n\nLists all organizations in your account as JSON.');
|
|
37
30
|
return;
|
|
38
31
|
}
|
|
39
|
-
const config =
|
|
40
|
-
const orgs = await
|
|
41
|
-
|
|
32
|
+
const config = requireConfig();
|
|
33
|
+
const orgs = await hq.listOrgs(config.api_key);
|
|
34
|
+
printJson(orgs);
|
|
42
35
|
}
|
|
43
|
-
async function get(id, flags) {
|
|
36
|
+
export async function get(id, flags) {
|
|
44
37
|
if (flags.help) {
|
|
45
|
-
|
|
38
|
+
info('Usage: myapi org get <id>\n\nFetches details of a specific organization.');
|
|
46
39
|
return;
|
|
47
40
|
}
|
|
48
41
|
if (!id) {
|
|
49
|
-
|
|
42
|
+
error("Missing org id. Usage: myapi org get <id>");
|
|
50
43
|
return;
|
|
51
44
|
}
|
|
52
|
-
const config =
|
|
53
|
-
const org = await
|
|
54
|
-
|
|
45
|
+
const config = requireConfig();
|
|
46
|
+
const org = await hq.getOrg(config.api_key, id);
|
|
47
|
+
printJson(org);
|
|
55
48
|
}
|
|
56
|
-
async function del(id, flags) {
|
|
49
|
+
export async function del(id, flags) {
|
|
57
50
|
if (flags.help) {
|
|
58
|
-
|
|
51
|
+
info('Usage: myapi org delete <id>\n\nDeletes an organization.');
|
|
59
52
|
return;
|
|
60
53
|
}
|
|
61
54
|
if (!id) {
|
|
62
|
-
|
|
55
|
+
error("Missing org id. Usage: myapi org delete <id>");
|
|
63
56
|
return;
|
|
64
57
|
}
|
|
65
|
-
const config =
|
|
66
|
-
await
|
|
67
|
-
|
|
58
|
+
const config = requireConfig();
|
|
59
|
+
await hq.deleteOrg(config.api_key, id);
|
|
60
|
+
success(`Org ${id} deleted`);
|
|
68
61
|
}
|
|
69
|
-
async function importOrg(args, flags) {
|
|
62
|
+
export async function importOrg(args, flags) {
|
|
70
63
|
if (flags.help) {
|
|
71
|
-
|
|
64
|
+
info('Usage: myapi org import <domain> --org <id>\n\nAutomatically extracts brand info from an existing website and updates the organization.\n\nNote: You must create a placeholder organization first using `myapi org create` to get an org_id.');
|
|
72
65
|
return;
|
|
73
66
|
}
|
|
74
|
-
const config =
|
|
67
|
+
const config = requireConfig();
|
|
75
68
|
const domain = args[0] || config.default_domain;
|
|
76
69
|
const orgId = flags.org || config.default_org;
|
|
77
70
|
if (!domain || !orgId) {
|
|
78
|
-
|
|
71
|
+
error("Missing required arguments.\nUsage: myapi org import <domain> --org <id>\n(Or set defaults via: myapi config set-org <id> / set-domain <domain>)");
|
|
79
72
|
return;
|
|
80
73
|
}
|
|
81
|
-
const result = await
|
|
74
|
+
const result = await hq.importOrg(config.api_key, orgId, domain);
|
|
82
75
|
const importId = result.job_id;
|
|
83
76
|
process.stdout.write("Importing ");
|
|
84
77
|
const chars = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
85
78
|
let i = 0;
|
|
86
79
|
while (true) {
|
|
87
|
-
const status = await
|
|
80
|
+
const status = await hq.getOrgImportStatus(config.api_key, importId);
|
|
88
81
|
if (status.status === 'awaiting_confirm') {
|
|
89
82
|
process.stdout.write('\r\x1b[K');
|
|
90
83
|
break;
|
|
91
84
|
}
|
|
92
85
|
if (status.status === 'failed') {
|
|
93
86
|
process.stdout.write('\r\x1b[K');
|
|
94
|
-
|
|
87
|
+
error("Import failed");
|
|
95
88
|
}
|
|
96
89
|
process.stdout.write(`\rImporting ${chars[i++ % chars.length]}`);
|
|
97
|
-
await
|
|
90
|
+
await sleep(3000);
|
|
98
91
|
}
|
|
99
|
-
const org = await
|
|
100
|
-
|
|
92
|
+
const org = await hq.confirmOrgImport(config.api_key, importId);
|
|
93
|
+
success(`Import complete! Org ID: ${org.id}`);
|
|
101
94
|
}
|
package/dist/commands/setup.js
CHANGED
|
@@ -1,42 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 config_js_1 = require("../config.js");
|
|
38
|
-
const output_js_1 = require("../output.js");
|
|
39
|
-
const readline = __importStar(require("readline"));
|
|
1
|
+
import { loadConfig, saveConfig } from '../config.js';
|
|
2
|
+
import { success, info } from '../output.js';
|
|
3
|
+
import * as readline from 'readline';
|
|
40
4
|
function ask(rl, q) {
|
|
41
5
|
return new Promise(resolve => rl.question(q, resolve));
|
|
42
6
|
}
|
|
@@ -48,29 +12,29 @@ function yn(answer, defaultYes = true) {
|
|
|
48
12
|
}
|
|
49
13
|
async function getKey(rl) {
|
|
50
14
|
const key = await ask(rl, 'Paste your API key (get it from https://myapihq.com): ');
|
|
51
|
-
|
|
52
|
-
|
|
15
|
+
saveConfig({ api_key: key.trim(), account_id: '', pin: '' });
|
|
16
|
+
success('API key saved to ~/.myapi/config.json');
|
|
53
17
|
return key.trim();
|
|
54
18
|
}
|
|
55
|
-
async function setup() {
|
|
56
|
-
|
|
19
|
+
export async function setup() {
|
|
20
|
+
info('MyAPI Setup\n');
|
|
57
21
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
58
|
-
const existing =
|
|
22
|
+
const existing = loadConfig();
|
|
59
23
|
if (existing?.api_key) {
|
|
60
24
|
const reuse = await ask(rl, `Found existing account (${existing.account_id || existing.api_key.slice(0, 20) + '...'}). Use it? [Y/n]: `);
|
|
61
25
|
if (!yn(reuse, true)) {
|
|
62
26
|
await getKey(rl);
|
|
63
27
|
}
|
|
64
28
|
else {
|
|
65
|
-
|
|
29
|
+
info('Using existing credentials.');
|
|
66
30
|
}
|
|
67
31
|
}
|
|
68
32
|
else {
|
|
69
33
|
await getKey(rl);
|
|
70
34
|
}
|
|
71
35
|
rl.close();
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
36
|
+
info('\nTo integrate MyAPI with AI agents (Claude, Cursor, Copilot, etc.),');
|
|
37
|
+
info('please follow the instructions in our skills repository:');
|
|
38
|
+
info('https://github.com/myapihq/agent-skills\n');
|
|
39
|
+
success('Setup complete! Try: myapi billing balance');
|
|
76
40
|
}
|
package/dist/commands/storage.js
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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");
|
|
1
|
+
import { storage as sdkStorage } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, printTable } from '../output.js';
|
|
9
4
|
function getOrgId(flags, config) {
|
|
10
5
|
const orgId = flags.org || config.org_id;
|
|
11
6
|
if (!orgId)
|
|
12
|
-
|
|
7
|
+
error("Missing org-id. Pass --org or set it in config.");
|
|
13
8
|
return orgId;
|
|
14
9
|
}
|
|
15
|
-
async function list(flags) {
|
|
16
|
-
const config =
|
|
10
|
+
export async function list(flags) {
|
|
11
|
+
const config = requireConfig();
|
|
17
12
|
const orgId = getOrgId(flags, config);
|
|
18
|
-
const assets = await
|
|
19
|
-
|
|
13
|
+
const assets = await sdkStorage.listAssets(config.api_key, orgId);
|
|
14
|
+
printTable(assets);
|
|
20
15
|
}
|
|
21
|
-
async function ingest(url, flags) {
|
|
16
|
+
export async function ingest(url, flags) {
|
|
22
17
|
if (!url)
|
|
23
|
-
|
|
24
|
-
const config =
|
|
18
|
+
error("Missing url");
|
|
19
|
+
const config = requireConfig();
|
|
25
20
|
const orgId = getOrgId(flags, config);
|
|
26
|
-
const res = await
|
|
27
|
-
|
|
21
|
+
const res = await sdkStorage.ingestAsset(config.api_key, orgId, url, flags.name);
|
|
22
|
+
success(`Asset ingested! ID: ${res.asset_id}\nHosted URL: ${res.url}`);
|
|
28
23
|
}
|
|
29
|
-
async function del(id, flags) {
|
|
24
|
+
export async function del(id, flags) {
|
|
30
25
|
if (!id)
|
|
31
|
-
|
|
32
|
-
const config =
|
|
26
|
+
error("Missing id");
|
|
27
|
+
const config = requireConfig();
|
|
33
28
|
const orgId = getOrgId(flags, config);
|
|
34
|
-
await
|
|
35
|
-
|
|
29
|
+
await sdkStorage.deleteAsset(config.api_key, orgId, id);
|
|
30
|
+
success(`Asset ${id} deleted`);
|
|
36
31
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { url as sdkUrl } from '@myapihq/sdk';
|
|
2
|
+
import { requireConfig } from '../config.js';
|
|
3
|
+
import { success, error, info, printJson } from '../output.js';
|
|
4
|
+
export async function shorten(targetUrl, flags) {
|
|
5
|
+
const config = requireConfig();
|
|
6
|
+
const orgId = flags.org || config.default_org;
|
|
7
|
+
if (!orgId || !targetUrl)
|
|
8
|
+
error("Missing required arguments.\nUsage: myapi url shorten <url> --org <id>\n(Or set defaults via: myapi config set-org <id>)");
|
|
9
|
+
const res = await sdkUrl.shortenUrl(config.api_key, orgId, targetUrl);
|
|
10
|
+
if (flags.json)
|
|
11
|
+
printJson(res);
|
|
12
|
+
else
|
|
13
|
+
success(`Shortened URL: ${res.short_url}\nCode: ${res.short_code}`);
|
|
14
|
+
}
|
|
15
|
+
export async function run(subcommand, args, flags) {
|
|
16
|
+
if (!subcommand || (flags.help && !subcommand)) {
|
|
17
|
+
info('Usage: myapi url <subcommand>\n\nSubcommands:\n shorten Shorten a long URL\n\nNote: All url commands require the --org <id> flag.');
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (flags.help) {
|
|
21
|
+
if (subcommand === 'shorten')
|
|
22
|
+
info('Usage: myapi url shorten <url> --org <id> [--json]\n\nShortens a long URL and returns the compact myurlto.com link.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (subcommand === 'shorten')
|
|
26
|
+
await shorten(args[0], flags);
|
|
27
|
+
else
|
|
28
|
+
error(`Unknown subcommand: ${subcommand}. Run "myapi url --help" for a list of valid subcommands.`);
|
|
29
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export declare function list(flags: Record<string, string | boolean>): Promise<void>;
|
|
2
2
|
export declare function create(flags: Record<string, string | boolean>): Promise<void>;
|
|
3
3
|
export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
4
|
+
export declare function delivery(id: string, flags: Record<string, string | boolean>): Promise<void>;
|
|
5
|
+
export declare function run(subcommand: string | undefined, args: string[], flags: Record<string, string | boolean>): Promise<void>;
|