@myapihq/sdk 1.0.12 → 1.0.14

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/src/storage.js ADDED
@@ -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
+ }
package/src/types.d.ts ADDED
@@ -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
+ }
package/src/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/src/url.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { request } from './client';
2
+
3
+ const BASE_URL = 'https://api.myurlto.com';
4
+
5
+ export interface ShortenResponse {
6
+ short_code: string;
7
+ short_url: string;
8
+ }
9
+
10
+ export async function shortenUrl(apiKey: string, orgId: string, url: string): Promise<ShortenResponse> {
11
+ return request('POST', `${BASE_URL}/url/orgs/${encodeURIComponent(orgId)}/shorten`, apiKey, { url });
12
+ }
@@ -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>;
package/src/webhook.js ADDED
@@ -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
+ }
package/src/webhook.ts CHANGED
@@ -6,17 +6,17 @@ export interface WebhookEndpoint { id: string; org_id: string; name: string; slu
6
6
  export interface Delivery { id: string; endpoint_id: string; payload: unknown; headers: Record<string, string>; status: string; created_at: string }
7
7
 
8
8
  export async function createEndpoint(apiKey: string, orgId: string, name: string, description?: string): Promise<WebhookEndpoint> {
9
- return request('POST', `${BASE_URL}/webhook/endpoints`, apiKey, { org_id: orgId, name, description });
9
+ return request('POST', `${BASE_URL}/webhook/orgs/${encodeURIComponent(orgId)}/endpoints`, apiKey, { name, description });
10
10
  }
11
11
 
12
- export async function listEndpoints(apiKey: string): Promise<WebhookEndpoint[]> {
13
- return request('GET', `${BASE_URL}/webhook/endpoints`, apiKey);
12
+ export async function listEndpoints(apiKey: string, orgId: string): Promise<WebhookEndpoint[]> {
13
+ return request('GET', `${BASE_URL}/webhook/orgs/${encodeURIComponent(orgId)}/endpoints`, apiKey);
14
14
  }
15
15
 
16
- export async function deleteEndpoint(apiKey: string, endpointId: string): Promise<void> {
17
- return request('DELETE', `${BASE_URL}/webhook/endpoints/${encodeURIComponent(endpointId)}`, apiKey);
16
+ export async function deleteEndpoint(apiKey: string, orgId: string, endpointId: string): Promise<void> {
17
+ return request('DELETE', `${BASE_URL}/webhook/orgs/${encodeURIComponent(orgId)}/endpoints/${encodeURIComponent(endpointId)}`, apiKey);
18
18
  }
19
19
 
20
- export async function getDelivery(apiKey: string, deliveryId: string): Promise<Delivery> {
21
- return request('GET', `${BASE_URL}/webhook/deliveries/${encodeURIComponent(deliveryId)}`, apiKey);
20
+ export async function getDelivery(apiKey: string, orgId: string, deliveryId: string): Promise<Delivery> {
21
+ return request('GET', `${BASE_URL}/webhook/orgs/${encodeURIComponent(orgId)}/deliveries/${encodeURIComponent(deliveryId)}`, apiKey);
22
22
  }
@@ -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/src/workflow.ts CHANGED
@@ -9,43 +9,42 @@ export type WorkflowStep =
9
9
  export interface Workflow { id: string; org_id: string; name: string; status: 'enabled' | 'disabled'; trigger_config: { endpoint_id: string }; steps: WorkflowStep[]; created_at: string }
10
10
  export interface WorkflowRun { id: string; workflow_id: string; trigger_payload: unknown; status: 'pending' | 'running' | 'completed' | 'failed'; error?: string; attempt: number; started_at: string; finished_at?: string; created_at: string }
11
11
 
12
- export async function createWorkflow(apiKey: string, payload: {
13
- org_id: string;
12
+ export async function createWorkflow(apiKey: string, orgId: string, payload: {
14
13
  name: string;
15
14
  trigger_config: { endpoint_id: string };
16
15
  steps: WorkflowStep[];
17
16
  }): Promise<Workflow> {
18
- return request('POST', `${BASE_URL}/workflow/workflows`, apiKey, payload);
17
+ return request('POST', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows`, apiKey, payload);
19
18
  }
20
19
 
21
- export async function listWorkflows(apiKey: string): Promise<Workflow[]> {
22
- return request('GET', `${BASE_URL}/workflow/workflows`, apiKey);
20
+ export async function listWorkflows(apiKey: string, orgId: string): Promise<Workflow[]> {
21
+ return request('GET', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows`, apiKey);
23
22
  }
24
23
 
25
- export async function getWorkflow(apiKey: string, workflowId: string): Promise<Workflow> {
26
- return request('GET', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}`, apiKey);
24
+ export async function getWorkflow(apiKey: string, orgId: string, workflowId: string): Promise<Workflow> {
25
+ return request('GET', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows/${encodeURIComponent(workflowId)}`, apiKey);
27
26
  }
28
27
 
29
- export async function updateWorkflow(apiKey: string, workflowId: string, payload: { name?: string; trigger_config?: { endpoint_id: string }; steps?: WorkflowStep[] }): Promise<Workflow> {
30
- return request('PATCH', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}`, apiKey, payload);
28
+ export async function updateWorkflow(apiKey: string, orgId: string, workflowId: string, payload: { name?: string; trigger_config?: { endpoint_id: string }; steps?: WorkflowStep[] }): Promise<Workflow> {
29
+ return request('PATCH', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows/${encodeURIComponent(workflowId)}`, apiKey, payload);
31
30
  }
32
31
 
33
- export async function enableWorkflow(apiKey: string, workflowId: string): Promise<void> {
34
- return request('POST', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}/enable`, apiKey);
32
+ export async function enableWorkflow(apiKey: string, orgId: string, workflowId: string): Promise<void> {
33
+ return request('POST', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows/${encodeURIComponent(workflowId)}/enable`, apiKey);
35
34
  }
36
35
 
37
- export async function disableWorkflow(apiKey: string, workflowId: string): Promise<void> {
38
- return request('POST', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}/disable`, apiKey);
36
+ export async function disableWorkflow(apiKey: string, orgId: string, workflowId: string): Promise<void> {
37
+ return request('POST', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows/${encodeURIComponent(workflowId)}/disable`, apiKey);
39
38
  }
40
39
 
41
- export async function deleteWorkflow(apiKey: string, workflowId: string): Promise<void> {
42
- return request('DELETE', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}`, apiKey);
40
+ export async function deleteWorkflow(apiKey: string, orgId: string, workflowId: string): Promise<void> {
41
+ return request('DELETE', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows/${encodeURIComponent(workflowId)}`, apiKey);
43
42
  }
44
43
 
45
- export async function listWorkflowRuns(apiKey: string, workflowId: string): Promise<WorkflowRun[]> {
46
- return request('GET', `${BASE_URL}/workflow/workflows/${encodeURIComponent(workflowId)}/runs`, apiKey);
44
+ export async function listWorkflowRuns(apiKey: string, orgId: string, workflowId: string): Promise<WorkflowRun[]> {
45
+ return request('GET', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/workflows/${encodeURIComponent(workflowId)}/runs`, apiKey);
47
46
  }
48
47
 
49
- export async function getWorkflowRun(apiKey: string, runId: string): Promise<WorkflowRun> {
50
- return request('GET', `${BASE_URL}/workflow/runs/${encodeURIComponent(runId)}`, apiKey);
48
+ export async function getWorkflowRun(apiKey: string, orgId: string, runId: string): Promise<WorkflowRun> {
49
+ return request('GET', `${BASE_URL}/workflow/orgs/${encodeURIComponent(orgId)}/runs/${encodeURIComponent(runId)}`, apiKey);
51
50
  }