@myapihq/sdk 1.0.0

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/index.js ADDED
@@ -0,0 +1,50 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.workflow = exports.webhook = exports.storage = exports.pixel = exports.image = exports.funnel = exports.email = exports.domain = exports.hq = void 0;
40
+ __exportStar(require("./types"), exports);
41
+ __exportStar(require("./client"), exports);
42
+ exports.hq = __importStar(require("./hq"));
43
+ exports.domain = __importStar(require("./domain"));
44
+ exports.email = __importStar(require("./email"));
45
+ exports.funnel = __importStar(require("./funnel"));
46
+ exports.image = __importStar(require("./image"));
47
+ exports.pixel = __importStar(require("./pixel"));
48
+ exports.storage = __importStar(require("./storage"));
49
+ exports.webhook = __importStar(require("./webhook"));
50
+ exports.workflow = __importStar(require("./workflow"));
@@ -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
+ }>;
package/dist/pixel.js ADDED
@@ -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, url: string, name?: string): Promise<Asset>;
8
+ export declare function uploadAsset(apiKey: string, file: Blob | Buffer, contentType: 'image/jpeg' | 'image/png', name?: string): Promise<Asset>;
9
+ export declare function listAssets(apiKey: string): Promise<Asset[]>;
10
+ export declare function deleteAsset(apiKey: 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, url, name) {
10
+ return (0, client_1.request)('POST', `${BASE_URL}/hq/assets/ingest`, apiKey, { url, name });
11
+ }
12
+ async function uploadAsset(apiKey, 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}/hq/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) {
44
+ return (0, client_1.request)('GET', `${BASE_URL}/hq/assets`, apiKey);
45
+ }
46
+ async function deleteAsset(apiKey, assetId) {
47
+ return (0, client_1.request)('DELETE', `${BASE_URL}/hq/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
+ }
package/dist/types.js ADDED
@@ -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 ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "@myapihq/sdk",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript SDK for the MyAPI ecosystem",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "dev": "tsc --watch"
10
+ },
11
+ "devDependencies": {
12
+ "@types/node": "^25.6.0",
13
+ "typescript": "^5.4.0"
14
+ }
15
+ }
package/src/client.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { ApiResponse } from './types';
2
+
3
+ export class MyApiError extends Error {
4
+ constructor(public code: string, public status: number) {
5
+ super(code);
6
+ this.name = 'MyApiError';
7
+ }
8
+ }
9
+
10
+ export async function request<T>(
11
+ method: string,
12
+ url: string,
13
+ apiKey?: string,
14
+ body?: unknown
15
+ ): Promise<T> {
16
+ const headers: Record<string, string> = {};
17
+
18
+ if (apiKey) {
19
+ headers['Authorization'] = `Bearer ${apiKey}`;
20
+ }
21
+
22
+ if (body !== undefined) {
23
+ headers['Content-Type'] = 'application/json';
24
+ }
25
+
26
+ const options: RequestInit = {
27
+ method,
28
+ headers,
29
+ };
30
+
31
+ if (body !== undefined) {
32
+ options.body = JSON.stringify(body);
33
+ }
34
+
35
+ const response = await fetch(url, options);
36
+
37
+ if (response.status === 204) {
38
+ return undefined as T;
39
+ }
40
+
41
+ let result: any;
42
+ try {
43
+ result = await response.json();
44
+ } catch {
45
+ throw new MyApiError('invalid_json_response', response.status);
46
+ }
47
+
48
+ if (!response.ok) {
49
+ const code = result?.error || 'unknown_error';
50
+ throw new MyApiError(code, response.status);
51
+ }
52
+
53
+ const apiResponse = result as ApiResponse<T>;
54
+ if (!apiResponse.success) {
55
+ throw new MyApiError(apiResponse.error || 'unknown_error', response.status);
56
+ }
57
+
58
+ return apiResponse.data as T;
59
+ }
package/src/domain.ts ADDED
@@ -0,0 +1,54 @@
1
+ import { request } from './client';
2
+
3
+ const BASE_URL = 'https://api.mydomainapi.com';
4
+
5
+ export interface DomainRecord {
6
+ domain: string;
7
+ status: string;
8
+ expires_at?: string;
9
+ created_at: string;
10
+ }
11
+
12
+ export interface DomainSettings {
13
+ domain: string;
14
+ security_level: string;
15
+ browser_check: string;
16
+ ai_bots_protection: string;
17
+ is_robots_txt_managed: boolean;
18
+ }
19
+
20
+ export async function checkDomain(apiKey: string, domain: string): Promise<{ available: boolean; price_cents: number }> {
21
+ return request('GET', `${BASE_URL}/domain/check/${encodeURIComponent(domain)}`, apiKey);
22
+ }
23
+
24
+ export async function registerDomain(apiKey: string, domain: string, years?: number): Promise<DomainRecord> {
25
+ return request('POST', `${BASE_URL}/domain/register`, apiKey, { domain, years });
26
+ }
27
+
28
+ export async function importDomain(apiKey: string, payload: { domain: string; namecheap_api_user?: string; namecheap_api_key?: string; }): Promise<DomainRecord> {
29
+ return request('POST', `${BASE_URL}/domain/import`, apiKey, payload);
30
+ }
31
+
32
+ export async function listDomains(apiKey: string): Promise<DomainRecord[]> {
33
+ return request('GET', `${BASE_URL}/domain/list/me`, apiKey);
34
+ }
35
+
36
+ export async function getDomainStatus(apiKey: string, domain: string): Promise<DomainRecord> {
37
+ return request('GET', `${BASE_URL}/domain/status/${encodeURIComponent(domain)}`, apiKey);
38
+ }
39
+
40
+ export async function renewDomain(apiKey: string, domain: string, years?: number): Promise<DomainRecord> {
41
+ return request('POST', `${BASE_URL}/domain/renew/${encodeURIComponent(domain)}`, apiKey, { years });
42
+ }
43
+
44
+ export async function getDomainSettings(apiKey: string, domain: string): Promise<DomainSettings> {
45
+ return request('GET', `${BASE_URL}/domain/settings/${encodeURIComponent(domain)}`, apiKey);
46
+ }
47
+
48
+ export async function updateDomainSettings(apiKey: string, domain: string, payload: {
49
+ security_level?: 'essentially_off' | 'medium' | 'high' | 'under_attack';
50
+ browser_check?: 'on' | 'off';
51
+ purge_cache?: boolean;
52
+ }): Promise<DomainSettings> {
53
+ return request('POST', `${BASE_URL}/domain/settings/${encodeURIComponent(domain)}`, apiKey, payload);
54
+ }
package/src/email.ts ADDED
@@ -0,0 +1,102 @@
1
+ import { request } from './client';
2
+
3
+ const BASE_URL = 'https://api.myemailapi.com';
4
+
5
+ export interface EmailMessage { message_id: string; from: string; subject: string; body?: string; received_at: string }
6
+ export interface EmailTemplate { id: string; name: string; subject: string; preview_url: string; created_at: string; updated_at: string }
7
+ export interface Campaign { id: string; name: string; status: string; template_id: string; from_address: string; rate_per_minute: number; per_hour_limit: number; created_at: string }
8
+ export interface CampaignStats {
9
+ campaign: Campaign;
10
+ validation: { total: number; valid: number; invalid: number; pending: number; list_status: string };
11
+ dispatch: { sent: number; remaining: number; sent_this_hour: number; hour_limit: number; last_dispatch_at: string };
12
+ engagement: { sent: number; opens: number; clicks: number; page_visits: number };
13
+ }
14
+
15
+ export async function createMailbox(apiKey: string, domain: string, username: string): Promise<{ address: string; created_at: string }> {
16
+ return request('POST', `${BASE_URL}/email/mailbox/create`, apiKey, { domain, username });
17
+ }
18
+ export async function listMailboxes(apiKey: string): Promise<{ address: string; created_at: string }[]> {
19
+ return request('GET', `${BASE_URL}/email/mailbox/list/me`, apiKey);
20
+ }
21
+ export async function activateSending(apiKey: string, address: string): Promise<{ status: string }> {
22
+ return request('POST', `${BASE_URL}/email/sending/activate`, apiKey, { address });
23
+ }
24
+
25
+ export async function sendEmail(apiKey: string, payload: { from: string; to: string[]; subject: string; html?: string; text?: string; }): Promise<{ message_id: string }> {
26
+ return request('POST', `${BASE_URL}/email/send`, apiKey, payload);
27
+ }
28
+ export async function getEmailStatus(apiKey: string, messageId: string): Promise<{ status: string; delivered_at?: string }> {
29
+ return request('GET', `${BASE_URL}/email/status/${encodeURIComponent(messageId)}`, apiKey);
30
+ }
31
+ export async function getInbox(apiKey: string, address: string): Promise<EmailMessage[]> {
32
+ return request('GET', `${BASE_URL}/email/inbox/${encodeURIComponent(address)}`, apiKey);
33
+ }
34
+ export async function getMessage(apiKey: string, messageId: string, address: string): Promise<EmailMessage> {
35
+ return request('GET', `${BASE_URL}/email/message/${encodeURIComponent(messageId)}?address=${encodeURIComponent(address)}`, apiKey);
36
+ }
37
+
38
+ export async function startWarmup(apiKey: string, address: string): Promise<{ warmup_status: string }> {
39
+ return request('POST', `${BASE_URL}/email/warmup/start`, apiKey, { address });
40
+ }
41
+ export async function pauseWarmup(apiKey: string, address: string): Promise<void> {
42
+ return request('POST', `${BASE_URL}/email/warmup/pause`, apiKey, { address });
43
+ }
44
+ export async function resumeWarmup(apiKey: string, address: string): Promise<void> {
45
+ return request('POST', `${BASE_URL}/email/warmup/resume`, apiKey, { address });
46
+ }
47
+ export async function stopWarmup(apiKey: string, address: string): Promise<void> {
48
+ return request('POST', `${BASE_URL}/email/warmup/stop`, apiKey, { address });
49
+ }
50
+ export async function getWarmupStats(apiKey: string, address: string): Promise<{ sent: number; landed_inbox: number; landed_spam: number; health_score: number }> {
51
+ return request('GET', `${BASE_URL}/email/warmup/stats/${encodeURIComponent(address)}`, apiKey);
52
+ }
53
+
54
+ export async function generateTemplate(apiKey: string, payload: { org_id: string; prompt: string; name: string; }): Promise<{ job_id: string; template_id: string; status: string; preview_url: string }> {
55
+ return request('POST', `${BASE_URL}/email/templates/generate`, apiKey, payload);
56
+ }
57
+ export async function getTemplateJobStatus(apiKey: string, jobId: string): Promise<{ status: 'processing' | 'completed' | 'failed'; template_id: string; result?: { subject: string; preview_url: string } }> {
58
+ return request('GET', `${BASE_URL}/email/template-jobs/${encodeURIComponent(jobId)}`, apiKey);
59
+ }
60
+ export async function editTemplate(apiKey: string, templateId: string, prompt: string): Promise<{ template_id: string; preview_url: string }> {
61
+ return request('POST', `${BASE_URL}/email/templates/${encodeURIComponent(templateId)}/edit`, apiKey, { prompt });
62
+ }
63
+ export async function sendTestEmail(apiKey: string, templateId: string, to: string): Promise<{ ok: boolean; message_id: string }> {
64
+ return request('POST', `${BASE_URL}/email/templates/${encodeURIComponent(templateId)}/send-test`, apiKey, { to });
65
+ }
66
+ export async function listTemplates(apiKey: string): Promise<EmailTemplate[]> {
67
+ return request('GET', `${BASE_URL}/email/templates`, apiKey);
68
+ }
69
+ export async function deleteTemplate(apiKey: string, templateId: string): Promise<void> {
70
+ return request('DELETE', `${BASE_URL}/email/templates/${encodeURIComponent(templateId)}`, apiKey);
71
+ }
72
+
73
+ export async function createCampaign(apiKey: string, payload: { name: string; template_id: string; from_address: string; rate_per_minute?: number; per_hour_limit?: number; }): Promise<Campaign> {
74
+ return request('POST', `${BASE_URL}/email/campaigns`, apiKey, payload);
75
+ }
76
+ export async function uploadContactList(apiKey: string, campaignId: string, emails: string[]): Promise<{ list_id: string; total: number; status: string }> {
77
+ return request('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/contacts/upload-list`, apiKey, { emails });
78
+ }
79
+ export async function getContactUploadStatus(apiKey: string, campaignId: string): Promise<{ upload_status: 'ready' | 'validating' | 'failed'; total: number; valid_count: number; invalid_count: number }> {
80
+ return request('GET', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/contacts/status`, apiKey);
81
+ }
82
+ export async function startCampaign(apiKey: string, campaignId: string): Promise<{ status: string }> {
83
+ return request('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/start`, apiKey);
84
+ }
85
+ export async function pauseCampaign(apiKey: string, campaignId: string): Promise<void> {
86
+ return request('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/pause`, apiKey);
87
+ }
88
+ export async function resumeCampaign(apiKey: string, campaignId: string): Promise<void> {
89
+ return request('POST', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/resume`, apiKey);
90
+ }
91
+ export async function getCampaignStats(apiKey: string, campaignId: string): Promise<CampaignStats> {
92
+ return request('GET', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}/stats`, apiKey);
93
+ }
94
+ export async function listCampaigns(apiKey: string): Promise<Campaign[]> {
95
+ return request('GET', `${BASE_URL}/email/campaigns`, apiKey);
96
+ }
97
+ export async function getCampaign(apiKey: string, campaignId: string): Promise<Campaign> {
98
+ return request('GET', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}`, apiKey);
99
+ }
100
+ export async function updateCampaign(apiKey: string, campaignId: string, payload: { name?: string; per_day_limit?: number }): Promise<Campaign> {
101
+ return request('PATCH', `${BASE_URL}/email/campaigns/${encodeURIComponent(campaignId)}`, apiKey, payload);
102
+ }
package/src/funnel.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { request } from './client';
2
+
3
+ const BASE_URL = 'https://api.myfunnelapi.com';
4
+
5
+ export interface Funnel { id: string; org_id: string; domain: string; created_at: string }
6
+ export interface VerifyResult {
7
+ pages?: Array<{ slug: string; tests: VerifyTest[] }>;
8
+ tests?: VerifyTest[];
9
+ }
10
+ export interface VerifyTest { type: 'link' | 'webhook'; url: string; passed: boolean; details: string }
11
+
12
+ export async function createFunnel(apiKey: string, orgId: string, domain: string): Promise<Funnel> {
13
+ return request('POST', `${BASE_URL}/funnel/funnels/create-raw`, apiKey, { org_id: orgId, domain });
14
+ }
15
+ export async function pushPage(apiKey: string, funnelId: string, slug: string, html: string): Promise<{ status: string; key: string }> {
16
+ return request('POST', `${BASE_URL}/funnel/funnels/${encodeURIComponent(funnelId)}/push-page`, apiKey, { slug, html });
17
+ }
18
+ export async function verifyFunnel(apiKey: string, funnelId: string, opts?: { html?: string; slug?: string }): Promise<VerifyResult> {
19
+ return request('POST', `${BASE_URL}/funnel/funnels/${encodeURIComponent(funnelId)}/verify`, apiKey, opts || {});
20
+ }
21
+ export async function listFunnels(apiKey: string): Promise<Funnel[]> {
22
+ return request('GET', `${BASE_URL}/funnel/funnels`, apiKey);
23
+ }
24
+ export async function getFunnel(apiKey: string, funnelId: string): Promise<Funnel> {
25
+ return request('GET', `${BASE_URL}/funnel/funnels/${encodeURIComponent(funnelId)}`, apiKey);
26
+ }
27
+ export async function deleteFunnel(apiKey: string, funnelId: string): Promise<void> {
28
+ return request('DELETE', `${BASE_URL}/funnel/funnels/${encodeURIComponent(funnelId)}`, apiKey);
29
+ }