@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.
Files changed (62) hide show
  1. package/dist/cli/src/commands/account.d.ts +4 -0
  2. package/dist/cli/src/commands/account.js +91 -0
  3. package/dist/cli/src/commands/billing.d.ts +4 -0
  4. package/dist/cli/src/commands/billing.js +34 -0
  5. package/dist/cli/src/commands/domain.d.ts +5 -0
  6. package/dist/cli/src/commands/domain.js +56 -0
  7. package/dist/cli/src/commands/email.d.ts +8 -0
  8. package/dist/cli/src/commands/email.js +95 -0
  9. package/dist/cli/src/commands/funnel.d.ts +3 -0
  10. package/dist/cli/src/commands/funnel.js +37 -0
  11. package/dist/cli/src/commands/image.d.ts +2 -0
  12. package/dist/cli/src/commands/image.js +47 -0
  13. package/dist/cli/src/commands/org.d.ts +5 -0
  14. package/dist/cli/src/commands/org.js +67 -0
  15. package/dist/cli/src/commands/setup.d.ts +1 -0
  16. package/dist/cli/src/commands/setup.js +165 -0
  17. package/dist/cli/src/commands/storage.d.ts +3 -0
  18. package/dist/cli/src/commands/storage.js +36 -0
  19. package/dist/cli/src/commands/webhook.d.ts +3 -0
  20. package/dist/cli/src/commands/webhook.js +28 -0
  21. package/dist/cli/src/commands/workflow.d.ts +5 -0
  22. package/dist/cli/src/commands/workflow.js +57 -0
  23. package/dist/cli/src/config.d.ts +8 -0
  24. package/dist/cli/src/config.js +69 -0
  25. package/dist/cli/src/index.d.ts +2 -0
  26. package/dist/cli/src/index.js +117 -0
  27. package/dist/cli/src/output.d.ts +5 -0
  28. package/dist/cli/src/output.js +42 -0
  29. package/dist/cli/src/utils.d.ts +5 -0
  30. package/dist/cli/src/utils.js +34 -0
  31. package/dist/commands/setup.js +26 -5
  32. package/dist/commands/storage.js +12 -3
  33. package/dist/index.js +19 -12
  34. package/dist/sdk/src/client.d.ts +6 -0
  35. package/dist/sdk/src/client.js +51 -0
  36. package/dist/sdk/src/domain.d.ts +32 -0
  37. package/dist/sdk/src/domain.js +36 -0
  38. package/dist/sdk/src/email.d.ts +144 -0
  39. package/dist/sdk/src/email.js +116 -0
  40. package/dist/sdk/src/funnel.d.ts +31 -0
  41. package/dist/sdk/src/funnel.js +28 -0
  42. package/dist/sdk/src/hq.d.ts +84 -0
  43. package/dist/sdk/src/hq.js +80 -0
  44. package/dist/sdk/src/image.d.ts +21 -0
  45. package/dist/sdk/src/image.js +16 -0
  46. package/dist/sdk/src/index.d.ts +11 -0
  47. package/dist/sdk/src/index.js +51 -0
  48. package/dist/sdk/src/pixel.d.ts +65 -0
  49. package/dist/sdk/src/pixel.js +44 -0
  50. package/dist/sdk/src/storage.d.ts +10 -0
  51. package/dist/sdk/src/storage.js +48 -0
  52. package/dist/sdk/src/types.d.ts +17 -0
  53. package/dist/sdk/src/types.js +2 -0
  54. package/dist/sdk/src/webhook.d.ts +20 -0
  55. package/dist/sdk/src/webhook.js +20 -0
  56. package/dist/sdk/src/workflow.d.ts +56 -0
  57. package/dist/sdk/src/workflow.js +40 -0
  58. package/package.json +1 -1
  59. package/src/commands/setup.ts +33 -7
  60. package/src/commands/storage.ts +12 -3
  61. package/src/index.ts +15 -23
  62. package/tsconfig.json +5 -1
@@ -0,0 +1,65 @@
1
+ export interface InteractionsResponse {
2
+ interactions: (Visit | PixelEvent)[];
3
+ total_visits: number;
4
+ total_events: number;
5
+ limit: number;
6
+ offset: number;
7
+ }
8
+ export interface Visit {
9
+ type: 'visit';
10
+ pixel_id: string;
11
+ from_url: string;
12
+ to_url: string;
13
+ ts: string;
14
+ }
15
+ export interface PixelEvent {
16
+ type: 'event';
17
+ pixel_id: string;
18
+ event_type: 'sent' | 'open' | 'click' | 'page_visit';
19
+ url?: string;
20
+ campaign_id?: string;
21
+ ts: string;
22
+ }
23
+ export declare function getInteractions(apiKey: string, params: {
24
+ website?: string;
25
+ domain?: string;
26
+ campaign_id?: string;
27
+ from?: string;
28
+ to?: string;
29
+ limit?: number;
30
+ offset?: number;
31
+ }): Promise<InteractionsResponse>;
32
+ export declare function getVisits(apiKey: string, params: {
33
+ website: string;
34
+ from?: string;
35
+ to?: string;
36
+ limit?: number;
37
+ offset?: number;
38
+ }): Promise<{
39
+ visits: Visit[];
40
+ total: number;
41
+ limit: number;
42
+ offset: number;
43
+ }>;
44
+ export declare function getEvents(apiKey: string, params: {
45
+ campaign_id?: string;
46
+ domain?: string;
47
+ from?: string;
48
+ to?: string;
49
+ limit?: number;
50
+ offset?: number;
51
+ }): Promise<{
52
+ events: PixelEvent[];
53
+ total: number;
54
+ limit: number;
55
+ offset: number;
56
+ }>;
57
+ export declare function getIdentity(apiKey: string, pixelId: string): Promise<{
58
+ uuid: string;
59
+ is_resolved: boolean;
60
+ nodes: Record<string, {
61
+ type: string;
62
+ probability: number;
63
+ }>;
64
+ latency_ms: number;
65
+ }>;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInteractions = getInteractions;
4
+ exports.getVisits = getVisits;
5
+ exports.getEvents = getEvents;
6
+ exports.getIdentity = getIdentity;
7
+ const client_1 = require("./client");
8
+ const BASE_URL = 'https://api.mypixelapi.com';
9
+ async function getInteractions(apiKey, params) {
10
+ const qs = new URLSearchParams();
11
+ for (const [key, val] of Object.entries(params)) {
12
+ if (val !== undefined && val !== null) {
13
+ qs.set(key, String(val));
14
+ }
15
+ }
16
+ const queryString = qs.toString();
17
+ const url = `${BASE_URL}/pixel/interactions${queryString ? `?${queryString}` : ''}`;
18
+ return (0, client_1.request)('GET', url, apiKey);
19
+ }
20
+ async function getVisits(apiKey, params) {
21
+ const qs = new URLSearchParams();
22
+ for (const [key, val] of Object.entries(params)) {
23
+ if (val !== undefined && val !== null) {
24
+ qs.set(key, String(val));
25
+ }
26
+ }
27
+ const queryString = qs.toString();
28
+ const url = `${BASE_URL}/pixel/visits${queryString ? `?${queryString}` : ''}`;
29
+ return (0, client_1.request)('GET', url, apiKey);
30
+ }
31
+ async function getEvents(apiKey, params) {
32
+ const qs = new URLSearchParams();
33
+ for (const [key, val] of Object.entries(params)) {
34
+ if (val !== undefined && val !== null) {
35
+ qs.set(key, String(val));
36
+ }
37
+ }
38
+ const queryString = qs.toString();
39
+ const url = `${BASE_URL}/pixel/events${queryString ? `?${queryString}` : ''}`;
40
+ return (0, client_1.request)('GET', url, apiKey);
41
+ }
42
+ async function getIdentity(apiKey, pixelId) {
43
+ return (0, client_1.request)('GET', `${BASE_URL}/pixel/identity/${encodeURIComponent(pixelId)}`, apiKey);
44
+ }
@@ -0,0 +1,10 @@
1
+ export interface Asset {
2
+ asset_id: string;
3
+ url: string;
4
+ name: string;
5
+ created_at: string;
6
+ }
7
+ export declare function ingestAsset(apiKey: string, orgId: string, url: string, name?: string): Promise<Asset>;
8
+ export declare function uploadAsset(apiKey: string, orgId: string, file: Blob | Buffer, contentType: 'image/jpeg' | 'image/png', name?: string): Promise<Asset>;
9
+ export declare function listAssets(apiKey: string, orgId: string): Promise<Asset[]>;
10
+ export declare function deleteAsset(apiKey: string, orgId: string, assetId: string): Promise<void>;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ingestAsset = ingestAsset;
4
+ exports.uploadAsset = uploadAsset;
5
+ exports.listAssets = listAssets;
6
+ exports.deleteAsset = deleteAsset;
7
+ const client_1 = require("./client");
8
+ const BASE_URL = 'https://api.mystorageapi.com';
9
+ async function ingestAsset(apiKey, orgId, url, name) {
10
+ return (0, client_1.request)('POST', `${BASE_URL}/storage/orgs/${encodeURIComponent(orgId)}/assets/ingest`, apiKey, { url, name });
11
+ }
12
+ async function uploadAsset(apiKey, orgId, file, contentType, name) {
13
+ const headers = {
14
+ 'Authorization': `Bearer ${apiKey}`
15
+ };
16
+ const formData = new FormData();
17
+ formData.append('file', new Blob([file], { type: contentType }));
18
+ if (name) {
19
+ formData.append('name', name);
20
+ }
21
+ const response = await fetch(`${BASE_URL}/storage/orgs/${encodeURIComponent(orgId)}/assets/upload`, {
22
+ method: 'POST',
23
+ headers,
24
+ body: formData
25
+ });
26
+ let result;
27
+ try {
28
+ result = await response.json();
29
+ }
30
+ catch {
31
+ throw new client_1.MyApiError('invalid_json_response', response.status);
32
+ }
33
+ if (!response.ok) {
34
+ const code = result?.error || 'unknown_error';
35
+ throw new client_1.MyApiError(code, response.status);
36
+ }
37
+ const apiResponse = result;
38
+ if (!apiResponse.success) {
39
+ throw new client_1.MyApiError(apiResponse.error || 'unknown_error', response.status);
40
+ }
41
+ return apiResponse.data;
42
+ }
43
+ async function listAssets(apiKey, orgId) {
44
+ return (0, client_1.request)('GET', `${BASE_URL}/storage/orgs/${encodeURIComponent(orgId)}/assets`, apiKey);
45
+ }
46
+ async function deleteAsset(apiKey, orgId, assetId) {
47
+ return (0, client_1.request)('DELETE', `${BASE_URL}/storage/orgs/${encodeURIComponent(orgId)}/assets/${encodeURIComponent(assetId)}`, apiKey);
48
+ }
@@ -0,0 +1,17 @@
1
+ export interface ApiResponse<T> {
2
+ success: boolean;
3
+ data: T | null;
4
+ error: string | null;
5
+ meta: {
6
+ request_id: string;
7
+ latency_ms: number;
8
+ service: string;
9
+ version: string;
10
+ };
11
+ }
12
+ export interface PaginatedResponse<T> {
13
+ data: T[];
14
+ total: number;
15
+ limit: number;
16
+ offset: number;
17
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,20 @@
1
+ export interface WebhookEndpoint {
2
+ id: string;
3
+ org_id: string;
4
+ name: string;
5
+ slug: string;
6
+ inbound_url: string;
7
+ created_at: string;
8
+ }
9
+ export interface Delivery {
10
+ id: string;
11
+ endpoint_id: string;
12
+ payload: unknown;
13
+ headers: Record<string, string>;
14
+ status: string;
15
+ created_at: string;
16
+ }
17
+ export declare function createEndpoint(apiKey: string, orgId: string, name: string, description?: string): Promise<WebhookEndpoint>;
18
+ export declare function listEndpoints(apiKey: string): Promise<WebhookEndpoint[]>;
19
+ export declare function deleteEndpoint(apiKey: string, endpointId: string): Promise<void>;
20
+ export declare function getDelivery(apiKey: string, deliveryId: string): Promise<Delivery>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createEndpoint = createEndpoint;
4
+ exports.listEndpoints = listEndpoints;
5
+ exports.deleteEndpoint = deleteEndpoint;
6
+ exports.getDelivery = getDelivery;
7
+ const client_1 = require("./client");
8
+ const BASE_URL = 'https://api.mywebhookapi.com';
9
+ async function createEndpoint(apiKey, orgId, name, description) {
10
+ return (0, client_1.request)('POST', `${BASE_URL}/webhook/endpoints`, apiKey, { org_id: orgId, name, description });
11
+ }
12
+ async function listEndpoints(apiKey) {
13
+ return (0, client_1.request)('GET', `${BASE_URL}/webhook/endpoints`, apiKey);
14
+ }
15
+ async function deleteEndpoint(apiKey, endpointId) {
16
+ return (0, client_1.request)('DELETE', `${BASE_URL}/webhook/endpoints/${encodeURIComponent(endpointId)}`, apiKey);
17
+ }
18
+ async function getDelivery(apiKey, deliveryId) {
19
+ return (0, client_1.request)('GET', `${BASE_URL}/webhook/deliveries/${encodeURIComponent(deliveryId)}`, apiKey);
20
+ }
@@ -0,0 +1,56 @@
1
+ export type WorkflowStep = {
2
+ type: 'send_email';
3
+ from: string;
4
+ to: string;
5
+ subject: string;
6
+ template_id?: string;
7
+ html?: string;
8
+ } | {
9
+ type: 'slack_message';
10
+ webhook_url: string;
11
+ text: string;
12
+ };
13
+ export interface Workflow {
14
+ id: string;
15
+ org_id: string;
16
+ name: string;
17
+ status: 'enabled' | 'disabled';
18
+ trigger_config: {
19
+ endpoint_id: string;
20
+ };
21
+ steps: WorkflowStep[];
22
+ created_at: string;
23
+ }
24
+ export interface WorkflowRun {
25
+ id: string;
26
+ workflow_id: string;
27
+ trigger_payload: unknown;
28
+ status: 'pending' | 'running' | 'completed' | 'failed';
29
+ error?: string;
30
+ attempt: number;
31
+ started_at: string;
32
+ finished_at?: string;
33
+ created_at: string;
34
+ }
35
+ export declare function createWorkflow(apiKey: string, payload: {
36
+ org_id: string;
37
+ name: string;
38
+ trigger_config: {
39
+ endpoint_id: string;
40
+ };
41
+ steps: WorkflowStep[];
42
+ }): Promise<Workflow>;
43
+ export declare function listWorkflows(apiKey: string): Promise<Workflow[]>;
44
+ export declare function getWorkflow(apiKey: string, workflowId: string): Promise<Workflow>;
45
+ export declare function updateWorkflow(apiKey: string, workflowId: string, payload: {
46
+ name?: string;
47
+ trigger_config?: {
48
+ endpoint_id: string;
49
+ };
50
+ steps?: WorkflowStep[];
51
+ }): Promise<Workflow>;
52
+ export declare function enableWorkflow(apiKey: string, workflowId: string): Promise<void>;
53
+ export declare function disableWorkflow(apiKey: string, workflowId: string): Promise<void>;
54
+ export declare function deleteWorkflow(apiKey: string, workflowId: string): Promise<void>;
55
+ export declare function listWorkflowRuns(apiKey: string, workflowId: string): Promise<WorkflowRun[]>;
56
+ export declare function getWorkflowRun(apiKey: string, runId: string): Promise<WorkflowRun>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWorkflow = createWorkflow;
4
+ exports.listWorkflows = listWorkflows;
5
+ exports.getWorkflow = getWorkflow;
6
+ exports.updateWorkflow = updateWorkflow;
7
+ exports.enableWorkflow = enableWorkflow;
8
+ exports.disableWorkflow = disableWorkflow;
9
+ exports.deleteWorkflow = deleteWorkflow;
10
+ exports.listWorkflowRuns = listWorkflowRuns;
11
+ exports.getWorkflowRun = getWorkflowRun;
12
+ const client_1 = require("./client");
13
+ const BASE_URL = 'https://api.myworkflowapi.com';
14
+ async function createWorkflow(apiKey, payload) {
15
+ return (0, client_1.request)('POST', `${BASE_URL}/workflow/workflows`, apiKey, payload);
16
+ }
17
+ async function listWorkflows(apiKey) {
18
+ return (0, client_1.request)('GET', `${BASE_URL}/workflow/workflows`, apiKey);
19
+ }
20
+ async function getWorkflow(apiKey, workflowId) {
21
+ return (0, client_1.request)('GET', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}`, apiKey);
22
+ }
23
+ async function updateWorkflow(apiKey, workflowId, payload) {
24
+ return (0, client_1.request)('PATCH', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}`, apiKey, payload);
25
+ }
26
+ async function enableWorkflow(apiKey, workflowId) {
27
+ return (0, client_1.request)('POST', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}/enable`, apiKey);
28
+ }
29
+ async function disableWorkflow(apiKey, workflowId) {
30
+ return (0, client_1.request)('POST', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}/disable`, apiKey);
31
+ }
32
+ async function deleteWorkflow(apiKey, workflowId) {
33
+ return (0, client_1.request)('DELETE', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}`, apiKey);
34
+ }
35
+ async function listWorkflowRuns(apiKey, workflowId) {
36
+ return (0, client_1.request)('GET', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}/runs`, apiKey);
37
+ }
38
+ async function getWorkflowRun(apiKey, runId) {
39
+ return (0, client_1.request)('GET', `${BASE_URL}/workflow/runs/${encodeURIComponent(runId)}`, apiKey);
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myapihq/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "MyAPI command-line interface",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -82,9 +82,13 @@ export async function setup() {
82
82
 
83
83
  // Step 2: which agents
84
84
  info('\nWhich AI agents do you use?');
85
- const useClaude = yn(await ask(rl, ' Claude Code? [Y/n]: '), true);
86
- const useGemini = yn(await ask(rl, ' Gemini CLI? [y/N]: '), false);
87
- const useCursor = yn(await ask(rl, ' Cursor / Windsurf? [y/N]: '), false);
85
+ const useClaude = yn(await ask(rl, ' Claude Code? [Y/n]: '), true);
86
+ const useGemini = yn(await ask(rl, ' Gemini CLI? [Y/n]: '), true);
87
+ const useCursor = yn(await ask(rl, ' Cursor? [y/N]: '), false);
88
+ const useWindsurf = yn(await ask(rl, ' Windsurf? [y/N]: '), false);
89
+ const useKiro = yn(await ask(rl, ' Kiro? [y/N]: '), false);
90
+ const useCopilot = yn(await ask(rl, ' GitHub Copilot? [y/N]: '), false);
91
+ const useOther = yn(await ask(rl, ' Other / Codex? [y/N]: '), false);
88
92
 
89
93
  // Step 3: Claude — MCP or Skills or both
90
94
  let claudeMcp = false;
@@ -100,8 +104,8 @@ export async function setup() {
100
104
  // Step 4: apply
101
105
  info('\nApplying configuration...\n');
102
106
 
103
- if (claudeMcp) registerClaudeMcp();
104
- if (useGemini) registerGeminiMcp();
107
+ if (claudeMcp) registerClaudeMcp();
108
+ if (useGemini) registerGeminiMcp();
105
109
 
106
110
  if (claudeSkills) {
107
111
  info('To install the MyAPI skill inside Claude Code, run:');
@@ -109,9 +113,31 @@ export async function setup() {
109
113
  info(' /plugin install my-api-hq@myapi-skills');
110
114
  }
111
115
 
116
+ const skillsUrl = 'https://github.com/myapihq/agent-skills/blob/main/skills/my-api-hq/SKILL.md';
117
+
112
118
  if (useCursor) {
113
- info('\nFor Cursor / Windsurf add the skill as a rule:');
114
- info(' https://github.com/myapihq/claude-skills/blob/main/skills/my-api-hq/SKILL.md');
119
+ info('\nCursorcopy the skill into .cursor/rules/:');
120
+ info(` ${skillsUrl}`);
121
+ }
122
+
123
+ if (useWindsurf) {
124
+ info('\nWindsurf — add the skill to your rules configuration:');
125
+ info(` ${skillsUrl}`);
126
+ }
127
+
128
+ if (useKiro) {
129
+ info('\nKiro — copy the skill into .kiro/skills/:');
130
+ info(` ${skillsUrl}`);
131
+ }
132
+
133
+ if (useCopilot) {
134
+ info('\nGitHub Copilot — paste the skill into .github/copilot-instructions.md:');
135
+ info(` ${skillsUrl}`);
136
+ }
137
+
138
+ if (useOther) {
139
+ info('\nOther agents — copy the skill markdown as a system prompt or instruction file:');
140
+ info(` ${skillsUrl}`);
115
141
  }
116
142
 
117
143
  info('');
@@ -2,22 +2,31 @@ import { storage as sdkStorage } from '@myapihq/sdk';
2
2
  import { requireConfig } from '../config.js';
3
3
  import { success, error, printTable } from '../output.js';
4
4
 
5
+ function getOrgId(flags: Record<string, string | boolean>, config: any): string {
6
+ const orgId = flags.org || config.org_id;
7
+ if (!orgId) error("Missing org-id. Pass --org or set it in config.");
8
+ return orgId as string;
9
+ }
10
+
5
11
  export async function list(flags: Record<string, string | boolean>) {
6
12
  const config = requireConfig();
7
- const assets = await sdkStorage.listAssets(config.api_key);
13
+ const orgId = getOrgId(flags, config);
14
+ const assets = await sdkStorage.listAssets(config.api_key, orgId);
8
15
  printTable(assets as unknown as Record<string, unknown>[]);
9
16
  }
10
17
 
11
18
  export async function ingest(url: string, flags: Record<string, string | boolean>) {
12
19
  if (!url) error("Missing url");
13
20
  const config = requireConfig();
14
- const res = await sdkStorage.ingestAsset(config.api_key, url, flags.name as string);
21
+ const orgId = getOrgId(flags, config);
22
+ const res = await sdkStorage.ingestAsset(config.api_key, orgId, url, flags.name as string);
15
23
  success(`Asset ingested! ID: ${res.asset_id}\nHosted URL: ${res.url}`);
16
24
  }
17
25
 
18
26
  export async function del(id: string, flags: Record<string, string | boolean>) {
19
27
  if (!id) error("Missing id");
20
28
  const config = requireConfig();
21
- await sdkStorage.deleteAsset(config.api_key, id);
29
+ const orgId = getOrgId(flags, config);
30
+ await sdkStorage.deleteAsset(config.api_key, orgId, id);
22
31
  success(`Asset ${id} deleted`);
23
32
  }
package/src/index.ts CHANGED
@@ -1,29 +1,22 @@
1
1
  #!/usr/bin/env node
2
-
2
+ // AUTO-GENERATED by scripts/generate-indexes.js — do not edit manually
3
3
  import { parseArgs } from './utils.js';
4
4
  import { error, info } from './output.js';
5
5
  import { MyApiError } from '@myapihq/sdk';
6
-
7
6
  import * as accountCmd from './commands/account.js';
8
7
  import * as billingCmd from './commands/billing.js';
8
+ import * as orgCmd from './commands/org.js';
9
9
  import * as setupCmd from './commands/setup.js';
10
10
 
11
11
  async function main() {
12
12
  const { args, flags } = parseArgs(process.argv.slice(2));
13
-
14
- if (args.length === 0) {
15
- printHelp();
16
- process.exit(0);
17
- }
18
-
13
+ if (args.length === 0) { printHelp(); process.exit(0); }
19
14
  const [command, subcommand, ...restArgs] = args;
20
-
21
15
  try {
22
16
  switch (command) {
23
17
  case 'setup':
24
18
  await setupCmd.setup();
25
19
  break;
26
-
27
20
  case 'account':
28
21
  if (subcommand === 'create') await accountCmd.create();
29
22
  else if (subcommand === 'token') await accountCmd.token(flags);
@@ -31,7 +24,11 @@ async function main() {
31
24
  else if (subcommand === 'revoke') await accountCmd.revokeKey(restArgs[0], flags);
32
25
  else printHelp();
33
26
  break;
34
-
27
+ case 'org':
28
+ if (subcommand === 'list') await orgCmd.list(flags);
29
+ else if (subcommand === 'create') await orgCmd.create(flags);
30
+ else printHelp();
31
+ break;
35
32
  case 'billing':
36
33
  if (subcommand === 'balance') await billingCmd.balance(flags);
37
34
  else if (subcommand === 'history') await billingCmd.history(flags);
@@ -39,18 +36,14 @@ async function main() {
39
36
  else if (subcommand === 'setup') await billingCmd.setup(flags);
40
37
  else printHelp();
41
38
  break;
42
-
43
39
  default:
44
40
  printHelp();
45
41
  process.exit(0);
46
42
  }
47
43
  } catch (err: any) {
48
44
  if (err instanceof MyApiError) {
49
- if (err.status === 402) {
50
- error("Insufficient balance. Run: myapi billing topup <amount>");
51
- } else if (err.status === 401) {
52
- error("Invalid API key. Run: myapi account create");
53
- }
45
+ if (err.status === 402) error('Insufficient balance. Run: myapi billing topup <amount>');
46
+ else if (err.status === 401) error('Invalid API key. Run: myapi setup');
54
47
  }
55
48
  error(err.message || String(err));
56
49
  }
@@ -62,13 +55,12 @@ function printHelp() {
62
55
  Usage: myapi <command> [subcommand] [args]
63
56
 
64
57
  Commands:
65
- setup Interactive setup wizard
66
- account Manage your account and API keys
67
- billing Check balance and top up
58
+ account
59
+ billing
60
+ org
61
+ setup
68
62
 
69
63
  Run "myapi <command>" for subcommand help.`);
70
64
  }
71
65
 
72
- main().catch(err => {
73
- error(err.message || String(err));
74
- });
66
+ main().catch(err => { error(err.message || String(err)); });
package/tsconfig.json CHANGED
@@ -8,7 +8,11 @@
8
8
  "strict": true,
9
9
  "esModuleInterop": true,
10
10
  "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true
11
+ "forceConsistentCasingInFileNames": true,
12
+ "paths": {
13
+ "@myapihq/sdk": ["../sdk/src/index.ts"],
14
+ "@myapihq/sdk/*": ["../sdk/src/*"]
15
+ }
12
16
  },
13
17
  "include": ["src/**/*"]
14
18
  }