@myapihq/cli 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/commands/account.js +5 -16
  2. package/dist/commands/billing.js +28 -5
  3. package/dist/commands/keys.d.ts +3 -0
  4. package/dist/commands/keys.js +80 -0
  5. package/dist/commands/org.js +40 -8
  6. package/dist/commands/setup.js +10 -99
  7. package/dist/index.js +33 -13
  8. package/package.json +1 -1
  9. package/src/commands/billing.ts +30 -3
  10. package/src/commands/keys.ts +47 -0
  11. package/src/commands/org.ts +39 -5
  12. package/src/commands/setup.ts +10 -109
  13. package/src/index.ts +29 -11
  14. package/tsconfig.json +3 -6
  15. package/dist/cli/src/commands/account.d.ts +0 -4
  16. package/dist/cli/src/commands/account.js +0 -91
  17. package/dist/cli/src/commands/billing.d.ts +0 -4
  18. package/dist/cli/src/commands/billing.js +0 -34
  19. package/dist/cli/src/commands/domain.d.ts +0 -5
  20. package/dist/cli/src/commands/domain.js +0 -56
  21. package/dist/cli/src/commands/email.d.ts +0 -8
  22. package/dist/cli/src/commands/email.js +0 -95
  23. package/dist/cli/src/commands/funnel.d.ts +0 -3
  24. package/dist/cli/src/commands/funnel.js +0 -37
  25. package/dist/cli/src/commands/image.d.ts +0 -2
  26. package/dist/cli/src/commands/image.js +0 -47
  27. package/dist/cli/src/commands/org.d.ts +0 -5
  28. package/dist/cli/src/commands/org.js +0 -67
  29. package/dist/cli/src/commands/setup.d.ts +0 -1
  30. package/dist/cli/src/commands/setup.js +0 -165
  31. package/dist/cli/src/commands/storage.d.ts +0 -3
  32. package/dist/cli/src/commands/storage.js +0 -36
  33. package/dist/cli/src/commands/webhook.d.ts +0 -3
  34. package/dist/cli/src/commands/webhook.js +0 -28
  35. package/dist/cli/src/commands/workflow.d.ts +0 -5
  36. package/dist/cli/src/commands/workflow.js +0 -57
  37. package/dist/cli/src/config.d.ts +0 -8
  38. package/dist/cli/src/config.js +0 -69
  39. package/dist/cli/src/index.d.ts +0 -2
  40. package/dist/cli/src/index.js +0 -117
  41. package/dist/cli/src/output.d.ts +0 -5
  42. package/dist/cli/src/output.js +0 -42
  43. package/dist/cli/src/utils.d.ts +0 -5
  44. package/dist/cli/src/utils.js +0 -34
  45. package/dist/sdk/src/client.d.ts +0 -6
  46. package/dist/sdk/src/client.js +0 -51
  47. package/dist/sdk/src/domain.d.ts +0 -32
  48. package/dist/sdk/src/domain.js +0 -36
  49. package/dist/sdk/src/email.d.ts +0 -144
  50. package/dist/sdk/src/email.js +0 -116
  51. package/dist/sdk/src/funnel.d.ts +0 -31
  52. package/dist/sdk/src/funnel.js +0 -28
  53. package/dist/sdk/src/hq.d.ts +0 -84
  54. package/dist/sdk/src/hq.js +0 -80
  55. package/dist/sdk/src/image.d.ts +0 -21
  56. package/dist/sdk/src/image.js +0 -16
  57. package/dist/sdk/src/index.d.ts +0 -11
  58. package/dist/sdk/src/index.js +0 -51
  59. package/dist/sdk/src/pixel.d.ts +0 -65
  60. package/dist/sdk/src/pixel.js +0 -44
  61. package/dist/sdk/src/storage.d.ts +0 -10
  62. package/dist/sdk/src/storage.js +0 -48
  63. package/dist/sdk/src/types.d.ts +0 -17
  64. package/dist/sdk/src/types.js +0 -2
  65. package/dist/sdk/src/webhook.d.ts +0 -20
  66. package/dist/sdk/src/webhook.js +0 -20
  67. package/dist/sdk/src/workflow.d.ts +0 -56
  68. package/dist/sdk/src/workflow.js +0 -40
  69. package/src/commands/account.ts +0 -63
@@ -1,37 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export declare function generate(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function list(flags: Record<string, string | boolean>): Promise<void>;
@@ -1,47 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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>;
@@ -1,67 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export declare function setup(): Promise<void>;
@@ -1,165 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.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
- }
@@ -1,3 +0,0 @@
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>;
@@ -1,36 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- export declare function list(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function create(flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function del(id: string, flags: Record<string, string | boolean>): Promise<void>;
@@ -1,28 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- export declare function list(flags: Record<string, string | boolean>): Promise<void>;
2
- export declare function create(flags: Record<string, string | boolean>): Promise<void>;
3
- export declare function 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>;
@@ -1,57 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
1
- export interface Config {
2
- api_key: string;
3
- account_id: string;
4
- pin: string;
5
- }
6
- export declare function loadConfig(): Config | null;
7
- export declare function saveConfig(config: Config): void;
8
- export declare function requireConfig(): Config;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.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
- }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};