migma 1.3.3 → 1.3.4
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/README.md +155 -4
- package/dist/index.d.mts +167 -20
- package/dist/index.d.ts +167 -20
- package/dist/index.js +71 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -60,6 +60,16 @@ interface RequestOptions {
|
|
|
60
60
|
path: string;
|
|
61
61
|
body?: Record<string, unknown>;
|
|
62
62
|
query?: Record<string, string | number | boolean | undefined>;
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
}
|
|
65
|
+
/** Per-call options for write methods (POST/PATCH/DELETE). */
|
|
66
|
+
interface CallOptions {
|
|
67
|
+
/**
|
|
68
|
+
* Optional Idempotency-Key (max 100 chars). Same key + same body within 24h
|
|
69
|
+
* replays the original response; a different body returns 409 IDEMPOTENCY_CONFLICT.
|
|
70
|
+
* Reused across the SDK's own automatic retries so a retried call never duplicates.
|
|
71
|
+
*/
|
|
72
|
+
idempotencyKey?: string;
|
|
63
73
|
}
|
|
64
74
|
declare class MigmaClient {
|
|
65
75
|
private readonly apiKey;
|
|
@@ -80,16 +90,17 @@ declare class MigmaClient {
|
|
|
80
90
|
data: T;
|
|
81
91
|
count: number;
|
|
82
92
|
}>>;
|
|
83
|
-
post<T>(path: string, body?: Record<string, unknown
|
|
84
|
-
patch<T>(path: string, body?: Record<string, unknown
|
|
93
|
+
post<T>(path: string, body?: Record<string, unknown>, options?: CallOptions): Promise<MigmaResult<T>>;
|
|
94
|
+
patch<T>(path: string, body?: Record<string, unknown>, options?: CallOptions): Promise<MigmaResult<T>>;
|
|
85
95
|
put<T>(path: string, body?: Record<string, unknown>): Promise<MigmaResult<T>>;
|
|
86
|
-
delete<T>(path: string, query?: Record<string, string | number | boolean | undefined
|
|
96
|
+
delete<T>(path: string, query?: Record<string, string | number | boolean | undefined>, options?: CallOptions): Promise<MigmaResult<T>>;
|
|
97
|
+
private callHeaders;
|
|
87
98
|
private buildUrl;
|
|
88
99
|
private parseRetryAfter;
|
|
89
100
|
private sleep;
|
|
90
101
|
}
|
|
91
102
|
|
|
92
|
-
type ContactStatus = '
|
|
103
|
+
type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
93
104
|
interface Contact {
|
|
94
105
|
id: string;
|
|
95
106
|
email: string;
|
|
@@ -116,6 +127,7 @@ interface CreateContactParams {
|
|
|
116
127
|
language?: string;
|
|
117
128
|
tags?: string[];
|
|
118
129
|
customFields?: Record<string, unknown>;
|
|
130
|
+
status?: ContactStatus;
|
|
119
131
|
projectId: string;
|
|
120
132
|
}
|
|
121
133
|
interface UpdateContactParams {
|
|
@@ -150,6 +162,7 @@ interface BulkImportContactItem {
|
|
|
150
162
|
language?: string;
|
|
151
163
|
tags?: string[];
|
|
152
164
|
customFields?: Record<string, unknown>;
|
|
165
|
+
status?: ContactStatus;
|
|
153
166
|
}
|
|
154
167
|
interface BulkImportParams {
|
|
155
168
|
subscribers: BulkImportContactItem[];
|
|
@@ -178,6 +191,17 @@ interface BulkImportJobStatus {
|
|
|
178
191
|
createdAt: string;
|
|
179
192
|
completedAt: string | null;
|
|
180
193
|
}
|
|
194
|
+
interface BatchDeleteContactsParams {
|
|
195
|
+
/** Email addresses to delete (1-1000 per request). */
|
|
196
|
+
emails: string[];
|
|
197
|
+
projectId: string;
|
|
198
|
+
}
|
|
199
|
+
interface BatchDeleteResponse {
|
|
200
|
+
/** Number of contacts actually deleted. */
|
|
201
|
+
deleted: number;
|
|
202
|
+
/** Submitted emails with no matching contact (not an error). */
|
|
203
|
+
notFound: string[];
|
|
204
|
+
}
|
|
181
205
|
interface ChangeStatusParams {
|
|
182
206
|
email: string;
|
|
183
207
|
status: 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
@@ -189,14 +213,16 @@ interface ChangeStatusParams {
|
|
|
189
213
|
declare class Contacts {
|
|
190
214
|
private readonly client;
|
|
191
215
|
constructor(client: MigmaClient);
|
|
192
|
-
create(params: CreateContactParams): Promise<MigmaResult<Contact>>;
|
|
216
|
+
create(params: CreateContactParams, options?: CallOptions): Promise<MigmaResult<Contact>>;
|
|
193
217
|
list(params: ListContactsParams): Promise<MigmaResult<ListContactsResponse>>;
|
|
194
218
|
get(id: string, projectId: string): Promise<MigmaResult<Contact>>;
|
|
195
|
-
update(id: string, params: UpdateContactParams): Promise<MigmaResult<Contact>>;
|
|
196
|
-
remove(id: string, projectId: string): Promise<MigmaResult<DeleteResponse>>;
|
|
197
|
-
bulkImport(params: BulkImportParams): Promise<MigmaResult<BulkImportResponse>>;
|
|
219
|
+
update(id: string, params: UpdateContactParams, options?: CallOptions): Promise<MigmaResult<Contact>>;
|
|
220
|
+
remove(id: string, projectId: string, options?: CallOptions): Promise<MigmaResult<DeleteResponse>>;
|
|
221
|
+
bulkImport(params: BulkImportParams, options?: CallOptions): Promise<MigmaResult<BulkImportResponse>>;
|
|
198
222
|
getBulkImportStatus(jobId: string): Promise<MigmaResult<BulkImportJobStatus>>;
|
|
199
|
-
|
|
223
|
+
/** Batch delete contacts by email (up to 1000). Emails with no match come back in `notFound`. */
|
|
224
|
+
bulkDeleteByEmail(params: BatchDeleteContactsParams, options?: CallOptions): Promise<MigmaResult<BatchDeleteResponse>>;
|
|
225
|
+
changeStatus(params: ChangeStatusParams, options?: CallOptions): Promise<MigmaResult<{
|
|
200
226
|
success: boolean;
|
|
201
227
|
}>>;
|
|
202
228
|
}
|
|
@@ -248,11 +274,15 @@ declare class Tags {
|
|
|
248
274
|
|
|
249
275
|
interface SegmentFieldFilter {
|
|
250
276
|
key: string;
|
|
251
|
-
|
|
277
|
+
/** Exact match (is/is_not) or pattern match (starts_with/ends_with/contains/not_contains,
|
|
278
|
+
* compiled to anchored case-insensitive regex). Pattern modes keep a value group
|
|
279
|
+
* like "email ends_with .vc" accurate as new contacts arrive. */
|
|
280
|
+
mode?: 'is' | 'is_not' | 'starts_with' | 'ends_with' | 'contains' | 'not_contains';
|
|
252
281
|
values: string[];
|
|
253
282
|
}
|
|
254
283
|
interface SegmentActivityFilter {
|
|
255
284
|
action: 'sent' | 'opened' | 'clicked';
|
|
285
|
+
channel?: 'email';
|
|
256
286
|
mode: 'within' | 'before' | 'never' | 'between';
|
|
257
287
|
unit?: 'hours' | 'days';
|
|
258
288
|
amount?: number;
|
|
@@ -430,7 +460,7 @@ interface BatchStatus {
|
|
|
430
460
|
declare class Sending {
|
|
431
461
|
private readonly client;
|
|
432
462
|
constructor(client: MigmaClient);
|
|
433
|
-
send(params: SendEmailParams): Promise<MigmaResult<SendEmailResponse>>;
|
|
463
|
+
send(params: SendEmailParams, options?: CallOptions): Promise<MigmaResult<SendEmailResponse>>;
|
|
434
464
|
getBatchStatus(batchId: string): Promise<MigmaResult<BatchStatus>>;
|
|
435
465
|
}
|
|
436
466
|
|
|
@@ -684,7 +714,7 @@ declare class Emails {
|
|
|
684
714
|
/** List emails for a project */
|
|
685
715
|
list(params: ListEmailsParams): Promise<MigmaResult<ListEmailsResponse>>;
|
|
686
716
|
/** Start async email generation */
|
|
687
|
-
generate(params: GenerateEmailParams): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
717
|
+
generate(params: GenerateEmailParams, options?: CallOptions): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
688
718
|
/** Check email generation status */
|
|
689
719
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
690
720
|
/** Fetch one generated email by email id */
|
|
@@ -695,7 +725,7 @@ declare class Emails {
|
|
|
695
725
|
* Generate an email and wait for completion.
|
|
696
726
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
697
727
|
*/
|
|
698
|
-
generateAndWait(params: GenerateEmailParams, options?: PollingOptions): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
728
|
+
generateAndWait(params: GenerateEmailParams, options?: PollingOptions, callOptions?: CallOptions): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
699
729
|
/** Send a test email from a completed conversation */
|
|
700
730
|
sendTest(params: SendTestEmailParams): Promise<MigmaResult<SendTestEmailResponse>>;
|
|
701
731
|
}
|
|
@@ -1011,6 +1041,34 @@ interface CreateManagedDomainParams {
|
|
|
1011
1041
|
prefix: string;
|
|
1012
1042
|
region?: string;
|
|
1013
1043
|
}
|
|
1044
|
+
type DomainStream = 'transactional' | 'marketing';
|
|
1045
|
+
interface ProvisionStreamParams {
|
|
1046
|
+
/** Apex domain you own, e.g. 'acme.com'. */
|
|
1047
|
+
rootDomain: string;
|
|
1048
|
+
/** 'transactional' provisions notify.<rootDomain>; 'marketing' provisions send.<rootDomain>. */
|
|
1049
|
+
stream: DomainStream;
|
|
1050
|
+
region?: 'us-east-1' | 'eu-west-1';
|
|
1051
|
+
/** Show the apex domain in the From header when its DMARC passes. */
|
|
1052
|
+
vanityRootFrom?: boolean;
|
|
1053
|
+
}
|
|
1054
|
+
interface SetupDomainParams {
|
|
1055
|
+
/** Apex domain you own, e.g. 'acme.com'. */
|
|
1056
|
+
rootDomain: string;
|
|
1057
|
+
region?: 'us-east-1' | 'eu-west-1';
|
|
1058
|
+
/** Default From display name applied to both provisioned streams. */
|
|
1059
|
+
fromName?: string;
|
|
1060
|
+
/** Associate the provisioned streams with a project. */
|
|
1061
|
+
projectId?: string;
|
|
1062
|
+
/** Show the apex domain in the From header when its DMARC passes. Defaults to true. */
|
|
1063
|
+
vanityRootFrom?: boolean;
|
|
1064
|
+
}
|
|
1065
|
+
/** Both stream identities provisioned for a root domain by `domains.setup`. */
|
|
1066
|
+
interface SetupDomainResponse {
|
|
1067
|
+
/** send.<rootDomain> marketing stream identity. */
|
|
1068
|
+
marketing: Domain;
|
|
1069
|
+
/** notify.<rootDomain> transactional stream identity. */
|
|
1070
|
+
transactional: Domain;
|
|
1071
|
+
}
|
|
1014
1072
|
interface DomainDeleteResponse {
|
|
1015
1073
|
domain: string;
|
|
1016
1074
|
deleted: boolean;
|
|
@@ -1029,6 +1087,18 @@ declare class Domains {
|
|
|
1029
1087
|
listManaged(): Promise<MigmaResult<Domain[]>>;
|
|
1030
1088
|
createManaged(params: CreateManagedDomainParams): Promise<MigmaResult<Domain>>;
|
|
1031
1089
|
removeManaged(domain: string): Promise<MigmaResult<DomainDeleteResponse>>;
|
|
1090
|
+
/**
|
|
1091
|
+
* Provision a transactional or marketing stream identity on a domain you own.
|
|
1092
|
+
* Creates notify.<rootDomain> (transactional) or send.<rootDomain> (marketing)
|
|
1093
|
+
* to isolate transactional reputation from marketing. Returns DNS records to publish.
|
|
1094
|
+
*/
|
|
1095
|
+
provisionStream(params: ProvisionStreamParams): Promise<MigmaResult<Domain>>;
|
|
1096
|
+
/**
|
|
1097
|
+
* Provision BOTH stream identities for a domain you own in one call:
|
|
1098
|
+
* send.<rootDomain> (marketing) and notify.<rootDomain> (transactional).
|
|
1099
|
+
* Idempotent. Returns both domains with DNS records to publish.
|
|
1100
|
+
*/
|
|
1101
|
+
setup(params: SetupDomainParams): Promise<MigmaResult<SetupDomainResponse>>;
|
|
1032
1102
|
}
|
|
1033
1103
|
|
|
1034
1104
|
type WebhookEventType = 'email.generation.started' | 'email.generation.completed' | 'email.generation.failed' | 'email.test.sent' | 'project.import.started' | 'project.import.processing' | 'project.import.completed' | 'project.import.failed' | 'export.completed' | 'export.failed' | 'subscriber.added' | 'subscriber.updated' | 'subscriber.unsubscribed' | 'subscriber.bulk_imported' | 'api_key.created' | 'api_key.revoked';
|
|
@@ -1050,10 +1120,19 @@ interface Webhook {
|
|
|
1050
1120
|
url: string;
|
|
1051
1121
|
events: WebhookEventType[];
|
|
1052
1122
|
active: boolean;
|
|
1053
|
-
secret
|
|
1123
|
+
/** Whether a signing secret is configured. Returned by create and get. */
|
|
1124
|
+
secretConfigured?: boolean;
|
|
1054
1125
|
description?: string;
|
|
1055
1126
|
createdAt: string;
|
|
1056
1127
|
}
|
|
1128
|
+
interface CreateWebhookResponse extends Webhook {
|
|
1129
|
+
/**
|
|
1130
|
+
* The signing secret, returned ONCE at creation. Store it now — GET and list
|
|
1131
|
+
* never return it. To rotate, delete and recreate the webhook.
|
|
1132
|
+
*/
|
|
1133
|
+
secret: string;
|
|
1134
|
+
secretConfigured: boolean;
|
|
1135
|
+
}
|
|
1057
1136
|
interface WebhookDetail extends Webhook {
|
|
1058
1137
|
customHeaders?: Record<string, string>;
|
|
1059
1138
|
successCount: number;
|
|
@@ -1098,7 +1177,7 @@ declare class Webhooks {
|
|
|
1098
1177
|
private readonly client;
|
|
1099
1178
|
constructor(client: MigmaClient);
|
|
1100
1179
|
list(): Promise<MigmaResult<ListWebhooksResponse>>;
|
|
1101
|
-
create(params: CreateWebhookParams): Promise<MigmaResult<
|
|
1180
|
+
create(params: CreateWebhookParams): Promise<MigmaResult<CreateWebhookResponse>>;
|
|
1102
1181
|
get(webhookId: string): Promise<MigmaResult<WebhookDetail>>;
|
|
1103
1182
|
update(webhookId: string, params: UpdateWebhookParams): Promise<MigmaResult<{
|
|
1104
1183
|
updated: boolean;
|
|
@@ -1241,16 +1320,84 @@ interface ScheduleCampaignParams {
|
|
|
1241
1320
|
scheduledAt: string;
|
|
1242
1321
|
scheduledTimezone?: string;
|
|
1243
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Aggregated engagement metrics for a campaign.
|
|
1325
|
+
*
|
|
1326
|
+
* Sourced from the email tracking worker and cached on the campaign, so values
|
|
1327
|
+
* may be slightly stale. `botOpens`, `botClicks`, and `mppOpens` are present
|
|
1328
|
+
* when Apple Mail Privacy Protection / bot detection data is available.
|
|
1329
|
+
*/
|
|
1330
|
+
interface CampaignStats {
|
|
1331
|
+
totalSent: number;
|
|
1332
|
+
totalDelivered: number;
|
|
1333
|
+
uniqueOpens: number;
|
|
1334
|
+
totalOpens: number;
|
|
1335
|
+
uniqueClicks: number;
|
|
1336
|
+
totalClicks: number;
|
|
1337
|
+
unsubscribes: number;
|
|
1338
|
+
bounces: number;
|
|
1339
|
+
/** 0-100 */
|
|
1340
|
+
openRate: number;
|
|
1341
|
+
/** 0-100 */
|
|
1342
|
+
clickRate: number;
|
|
1343
|
+
/** ISO 8601 timestamp of when these stats were last refreshed. */
|
|
1344
|
+
lastUpdated: string;
|
|
1345
|
+
botOpens?: number;
|
|
1346
|
+
botClicks?: number;
|
|
1347
|
+
mppOpens?: number;
|
|
1348
|
+
}
|
|
1349
|
+
/**
|
|
1350
|
+
* A single per-recipient email log row for a campaign. Returned directly from
|
|
1351
|
+
* the tracking worker's D1 `emails` table, so the field names are snake_case
|
|
1352
|
+
* (unlike the rest of the API).
|
|
1353
|
+
*/
|
|
1354
|
+
interface CampaignLog {
|
|
1355
|
+
id: number;
|
|
1356
|
+
tracking_id: string;
|
|
1357
|
+
user_id: string;
|
|
1358
|
+
domain: string;
|
|
1359
|
+
from_email: string;
|
|
1360
|
+
to_email: string;
|
|
1361
|
+
subscriber_id: string | null;
|
|
1362
|
+
subject: string | null;
|
|
1363
|
+
/** Delivery status, e.g. 'sent', 'delivered', 'bounced', 'suppressed'. */
|
|
1364
|
+
status: string;
|
|
1365
|
+
opened_at: string | null;
|
|
1366
|
+
clicked_at: string | null;
|
|
1367
|
+
open_count: number;
|
|
1368
|
+
click_count: number;
|
|
1369
|
+
bounce_type: string | null;
|
|
1370
|
+
complaint_type: string | null;
|
|
1371
|
+
suppression_type: string | null;
|
|
1372
|
+
suppression_reason: string | null;
|
|
1373
|
+
conversation_id: string | null;
|
|
1374
|
+
campaign_id: string | null;
|
|
1375
|
+
created_at: string;
|
|
1376
|
+
}
|
|
1377
|
+
interface CampaignLogsParams {
|
|
1378
|
+
limit?: number;
|
|
1379
|
+
cursor?: string;
|
|
1380
|
+
status?: 'delivered' | 'opened' | 'clicked' | 'bounced' | 'spam_report';
|
|
1381
|
+
}
|
|
1382
|
+
interface CampaignLogsResponse {
|
|
1383
|
+
emails: CampaignLog[];
|
|
1384
|
+
nextCursor: string | null;
|
|
1385
|
+
hasMore: boolean;
|
|
1386
|
+
}
|
|
1244
1387
|
|
|
1245
1388
|
declare class Campaigns {
|
|
1246
1389
|
private readonly client;
|
|
1247
1390
|
constructor(client: MigmaClient);
|
|
1248
1391
|
list(params: ListCampaignsParams): Promise<MigmaResult<ListCampaignsResponse>>;
|
|
1249
|
-
create(params: CreateCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1392
|
+
create(params: CreateCampaignParams, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1250
1393
|
get(id: string): Promise<MigmaResult<Campaign>>;
|
|
1251
|
-
send(id: string): Promise<MigmaResult<Campaign>>;
|
|
1252
|
-
schedule(id: string, params: ScheduleCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1253
|
-
cancel(id: string): Promise<MigmaResult<Campaign>>;
|
|
1394
|
+
send(id: string, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1395
|
+
schedule(id: string, params: ScheduleCampaignParams, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1396
|
+
cancel(id: string, options?: CallOptions): Promise<MigmaResult<Campaign>>;
|
|
1397
|
+
/** Aggregated engagement metrics for a campaign (cached, may be slightly stale). */
|
|
1398
|
+
stats(id: string): Promise<MigmaResult<CampaignStats>>;
|
|
1399
|
+
/** Per-recipient email logs for a campaign (cursor-paginated). */
|
|
1400
|
+
logs(id: string, params?: CampaignLogsParams): Promise<MigmaResult<CampaignLogsResponse>>;
|
|
1254
1401
|
archive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1255
1402
|
unarchive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1256
1403
|
}
|
|
@@ -1283,4 +1430,4 @@ declare class Migma {
|
|
|
1283
1430
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1284
1431
|
}
|
|
1285
1432
|
|
|
1286
|
-
export { type AddImageParams, type AddKnowledgeBaseParams, type AnalyzeDeliverabilityParams, type AnalyzeLinksParams, type ApiResponse, type BatchStatus, type BulkImportAsyncResponse, type BulkImportContactItem, type BulkImportJobStatus, type BulkImportParams, type BulkImportResponse, type BulkImportSyncResponse, type Campaign, type CampaignStatus, type ChangeStatusParams, type CheckCompatibilityParams, type CheckSpellingParams, type CheckedLink, type ClientConfig, type CompatibilityResponse, type Contact, type ContactStatus, type CreateCampaignParams, type CreateContactParams, type CreateDomainParams, type CreateManagedDomainParams, type CreatePreviewParams, type CreatePreviewResponse, type CreateSegmentParams, type CreateTagParams, type CreateTopicParams, type CreateWebhookParams, type DeleteResponse, type DeliverabilityResponse, type DeviceCategoriesResponse, type DnsRecord, type Domain, type DomainAvailability, type DomainDeleteResponse, type DomainVerificationResult, type EditEmailParams, type Email, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type FieldCatalogEntry, type FieldCatalogEntryType, type FieldCatalogParams, type FieldCatalogResponse, type GenerateEmailParams, type GenerateEmailResponse, type GeneratedEmail, type GetDevicePreviewResponse, type GetPreviewResponse, type GetPreviewStatusResponse, type GetSupportedDevicesResponse, type HubspotExportParams, type ImportProjectParams, type ImportProjectResponse, type ImportStatusResponse, type KnowledgeBaseEntry, type KnowledgeBaseListResponse, type LinkAnalysisResponse, type ListCampaignsParams, type ListCampaignsResponse, type ListContactsParams, type ListContactsResponse, type ListEmailsEmail, type ListEmailsParams, type ListEmailsResponse, type ListProjectsParams, type ListProjectsResponse, type ListSegmentsResponse, type ListTagsParams, type ListTagsResponse, type ListTopicsParams, type ListTopicsResponse, type ListWebhooksResponse, type LogosResponse, type MessageResponse, Migma, MigmaClient, type MigmaConfig, MigmaError, MigmaErrorCode, type MigmaResult, type PollingOptions, type PreviewDevice, type PreviewDeviceCategory, type PreviewDeviceStatus, type PreviewMetadata, type PreviewStatus, type Project, type ProjectImage, type ProviderType, type RecipientType, type RetryImportResponse, type ScheduleCampaignParams, type Segment, type SegmentActivityFilter, type SegmentFieldFilter, type SegmentFilters, type SendEmailParams, type SendEmailResponse, type SendTestEmailParams, type SendTestEmailResponse, type SpellingResponse, type SupportedDevice, type Tag, type Topic, type TopicSubscriptionParams, type TopicSubscriptionResponse, type UpdateContactParams, type UpdateDomainParams, type UpdateImageParams, type UpdateKnowledgeBaseParams, type UpdateLogosParams, type UpdateSegmentParams, type UpdateTagParams, type UpdateTopicParams, type UpdateWebhookParams, type ValidateAllParams, type ValidateAllResponse, type Webhook, type WebhookDeliveriesResponse, type WebhookDelivery, type WebhookDetail, type WebhookEvent, type WebhookEventType, type WebhookEventsResponse, type WebhookTestResult, poll };
|
|
1433
|
+
export { type AddImageParams, type AddKnowledgeBaseParams, type AnalyzeDeliverabilityParams, type AnalyzeLinksParams, type ApiResponse, type BatchDeleteContactsParams, type BatchDeleteResponse, type BatchStatus, type BulkImportAsyncResponse, type BulkImportContactItem, type BulkImportJobStatus, type BulkImportParams, type BulkImportResponse, type BulkImportSyncResponse, type Campaign, type CampaignLog, type CampaignLogsParams, type CampaignLogsResponse, type CampaignStats, type CampaignStatus, type ChangeStatusParams, type CheckCompatibilityParams, type CheckSpellingParams, type CheckedLink, type ClientConfig, type CompatibilityResponse, type Contact, type ContactStatus, type CreateCampaignParams, type CreateContactParams, type CreateDomainParams, type CreateManagedDomainParams, type CreatePreviewParams, type CreatePreviewResponse, type CreateSegmentParams, type CreateTagParams, type CreateTopicParams, type CreateWebhookParams, type CreateWebhookResponse, type DeleteResponse, type DeliverabilityResponse, type DeviceCategoriesResponse, type DnsRecord, type Domain, type DomainAvailability, type DomainDeleteResponse, type DomainStream, type DomainVerificationResult, type EditEmailParams, type Email, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type FieldCatalogEntry, type FieldCatalogEntryType, type FieldCatalogParams, type FieldCatalogResponse, type GenerateEmailParams, type GenerateEmailResponse, type GeneratedEmail, type GetDevicePreviewResponse, type GetPreviewResponse, type GetPreviewStatusResponse, type GetSupportedDevicesResponse, type HubspotExportParams, type ImportProjectParams, type ImportProjectResponse, type ImportStatusResponse, type KnowledgeBaseEntry, type KnowledgeBaseListResponse, type LinkAnalysisResponse, type ListCampaignsParams, type ListCampaignsResponse, type ListContactsParams, type ListContactsResponse, type ListEmailsEmail, type ListEmailsParams, type ListEmailsResponse, type ListProjectsParams, type ListProjectsResponse, type ListSegmentsResponse, type ListTagsParams, type ListTagsResponse, type ListTopicsParams, type ListTopicsResponse, type ListWebhooksResponse, type LogosResponse, type MessageResponse, Migma, MigmaClient, type MigmaConfig, MigmaError, MigmaErrorCode, type MigmaResult, type PollingOptions, type PreviewDevice, type PreviewDeviceCategory, type PreviewDeviceStatus, type PreviewMetadata, type PreviewStatus, type Project, type ProjectImage, type ProviderType, type ProvisionStreamParams, type RecipientType, type RetryImportResponse, type ScheduleCampaignParams, type Segment, type SegmentActivityFilter, type SegmentFieldFilter, type SegmentFilters, type SendEmailParams, type SendEmailResponse, type SendTestEmailParams, type SendTestEmailResponse, type SetupDomainParams, type SetupDomainResponse, type SpellingResponse, type SupportedDevice, type Tag, type Topic, type TopicSubscriptionParams, type TopicSubscriptionResponse, type UpdateContactParams, type UpdateDomainParams, type UpdateImageParams, type UpdateKnowledgeBaseParams, type UpdateLogosParams, type UpdateSegmentParams, type UpdateTagParams, type UpdateTopicParams, type UpdateWebhookParams, type ValidateAllParams, type ValidateAllResponse, type Webhook, type WebhookDeliveriesResponse, type WebhookDelivery, type WebhookDetail, type WebhookEvent, type WebhookEventType, type WebhookEventsResponse, type WebhookTestResult, poll };
|
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ var MigmaClient = class {
|
|
|
95
95
|
try {
|
|
96
96
|
const response = await fetch(url, {
|
|
97
97
|
method: options.method,
|
|
98
|
-
headers: this.headers,
|
|
98
|
+
headers: { ...this.headers, ...options.headers },
|
|
99
99
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
100
100
|
});
|
|
101
101
|
const json = await response.json();
|
|
@@ -138,7 +138,7 @@ var MigmaClient = class {
|
|
|
138
138
|
try {
|
|
139
139
|
const response = await fetch(url, {
|
|
140
140
|
method: options.method,
|
|
141
|
-
headers: this.headers,
|
|
141
|
+
headers: { ...this.headers, ...options.headers },
|
|
142
142
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
143
143
|
});
|
|
144
144
|
const json = await response.json();
|
|
@@ -172,17 +172,23 @@ var MigmaClient = class {
|
|
|
172
172
|
async getWithCount(path, query) {
|
|
173
173
|
return this.requestWithCount({ method: "GET", path, query });
|
|
174
174
|
}
|
|
175
|
-
async post(path, body) {
|
|
176
|
-
return this.request({ method: "POST", path, body });
|
|
175
|
+
async post(path, body, options) {
|
|
176
|
+
return this.request({ method: "POST", path, body, headers: this.callHeaders(options) });
|
|
177
177
|
}
|
|
178
|
-
async patch(path, body) {
|
|
179
|
-
return this.request({ method: "PATCH", path, body });
|
|
178
|
+
async patch(path, body, options) {
|
|
179
|
+
return this.request({ method: "PATCH", path, body, headers: this.callHeaders(options) });
|
|
180
180
|
}
|
|
181
181
|
async put(path, body) {
|
|
182
182
|
return this.request({ method: "PUT", path, body });
|
|
183
183
|
}
|
|
184
|
-
async delete(path, query) {
|
|
185
|
-
return this.request({ method: "DELETE", path, query });
|
|
184
|
+
async delete(path, query, options) {
|
|
185
|
+
return this.request({ method: "DELETE", path, query, headers: this.callHeaders(options) });
|
|
186
|
+
}
|
|
187
|
+
callHeaders(options) {
|
|
188
|
+
if (options?.idempotencyKey) {
|
|
189
|
+
return { "Idempotency-Key": options.idempotencyKey };
|
|
190
|
+
}
|
|
191
|
+
return void 0;
|
|
186
192
|
}
|
|
187
193
|
buildUrl(path, query) {
|
|
188
194
|
const url = new URL(`${this.config.baseUrl}${path}`);
|
|
@@ -213,8 +219,8 @@ var Contacts = class {
|
|
|
213
219
|
constructor(client) {
|
|
214
220
|
this.client = client;
|
|
215
221
|
}
|
|
216
|
-
async create(params) {
|
|
217
|
-
return this.client.post("/contacts", params);
|
|
222
|
+
async create(params, options) {
|
|
223
|
+
return this.client.post("/contacts", params, options);
|
|
218
224
|
}
|
|
219
225
|
async list(params) {
|
|
220
226
|
const { projectId, page, limit, tags, status, search } = params;
|
|
@@ -230,20 +236,24 @@ var Contacts = class {
|
|
|
230
236
|
async get(id, projectId) {
|
|
231
237
|
return this.client.get(`/contacts/${id}`, { projectId });
|
|
232
238
|
}
|
|
233
|
-
async update(id, params) {
|
|
234
|
-
return this.client.patch(`/contacts/${id}`, params);
|
|
239
|
+
async update(id, params, options) {
|
|
240
|
+
return this.client.patch(`/contacts/${id}`, params, options);
|
|
235
241
|
}
|
|
236
|
-
async remove(id, projectId) {
|
|
237
|
-
return this.client.delete(`/contacts/${id}`, { projectId });
|
|
242
|
+
async remove(id, projectId, options) {
|
|
243
|
+
return this.client.delete(`/contacts/${id}`, { projectId }, options);
|
|
238
244
|
}
|
|
239
|
-
async bulkImport(params) {
|
|
240
|
-
return this.client.post("/contacts/bulk", params);
|
|
245
|
+
async bulkImport(params, options) {
|
|
246
|
+
return this.client.post("/contacts/bulk", params, options);
|
|
241
247
|
}
|
|
242
248
|
async getBulkImportStatus(jobId) {
|
|
243
249
|
return this.client.get(`/contacts/bulk/${jobId}`);
|
|
244
250
|
}
|
|
245
|
-
|
|
246
|
-
|
|
251
|
+
/** Batch delete contacts by email (up to 1000). Emails with no match come back in `notFound`. */
|
|
252
|
+
async bulkDeleteByEmail(params, options) {
|
|
253
|
+
return this.client.post("/contacts/bulk-delete", params, options);
|
|
254
|
+
}
|
|
255
|
+
async changeStatus(params, options) {
|
|
256
|
+
return this.client.post("/contacts/status", params, options);
|
|
247
257
|
}
|
|
248
258
|
};
|
|
249
259
|
|
|
@@ -344,8 +354,8 @@ var Sending = class {
|
|
|
344
354
|
constructor(client) {
|
|
345
355
|
this.client = client;
|
|
346
356
|
}
|
|
347
|
-
async send(params) {
|
|
348
|
-
return this.client.post("/sending", params);
|
|
357
|
+
async send(params, options) {
|
|
358
|
+
return this.client.post("/sending", params, options);
|
|
349
359
|
}
|
|
350
360
|
async getBatchStatus(batchId) {
|
|
351
361
|
return this.client.get(`/sending/batches/${batchId}`);
|
|
@@ -467,10 +477,11 @@ var Emails = class {
|
|
|
467
477
|
});
|
|
468
478
|
}
|
|
469
479
|
/** Start async email generation */
|
|
470
|
-
async generate(params) {
|
|
480
|
+
async generate(params, options) {
|
|
471
481
|
return this.client.post(
|
|
472
482
|
"/projects/emails/generate",
|
|
473
|
-
params
|
|
483
|
+
params,
|
|
484
|
+
options
|
|
474
485
|
);
|
|
475
486
|
}
|
|
476
487
|
/** Check email generation status */
|
|
@@ -494,8 +505,8 @@ var Emails = class {
|
|
|
494
505
|
* Generate an email and wait for completion.
|
|
495
506
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
496
507
|
*/
|
|
497
|
-
async generateAndWait(params, options) {
|
|
498
|
-
const startResult = await this.generate(params);
|
|
508
|
+
async generateAndWait(params, options, callOptions) {
|
|
509
|
+
const startResult = await this.generate(params, callOptions);
|
|
499
510
|
if (startResult.error) {
|
|
500
511
|
return { data: null, error: startResult.error };
|
|
501
512
|
}
|
|
@@ -673,6 +684,22 @@ var Domains = class {
|
|
|
673
684
|
async removeManaged(domain) {
|
|
674
685
|
return this.client.delete(`/domains/managed/${domain}`);
|
|
675
686
|
}
|
|
687
|
+
/**
|
|
688
|
+
* Provision a transactional or marketing stream identity on a domain you own.
|
|
689
|
+
* Creates notify.<rootDomain> (transactional) or send.<rootDomain> (marketing)
|
|
690
|
+
* to isolate transactional reputation from marketing. Returns DNS records to publish.
|
|
691
|
+
*/
|
|
692
|
+
async provisionStream(params) {
|
|
693
|
+
return this.client.post("/domains/streams", params);
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Provision BOTH stream identities for a domain you own in one call:
|
|
697
|
+
* send.<rootDomain> (marketing) and notify.<rootDomain> (transactional).
|
|
698
|
+
* Idempotent. Returns both domains with DNS records to publish.
|
|
699
|
+
*/
|
|
700
|
+
async setup(params) {
|
|
701
|
+
return this.client.post("/domains/setup", params);
|
|
702
|
+
}
|
|
676
703
|
};
|
|
677
704
|
|
|
678
705
|
// src/resources/webhooks.ts
|
|
@@ -790,20 +817,32 @@ var Campaigns = class {
|
|
|
790
817
|
archived
|
|
791
818
|
});
|
|
792
819
|
}
|
|
793
|
-
async create(params) {
|
|
794
|
-
return this.client.post("/campaigns", params);
|
|
820
|
+
async create(params, options) {
|
|
821
|
+
return this.client.post("/campaigns", params, options);
|
|
795
822
|
}
|
|
796
823
|
async get(id) {
|
|
797
824
|
return this.client.get(`/campaigns/${id}`);
|
|
798
825
|
}
|
|
799
|
-
async send(id) {
|
|
800
|
-
return this.client.post(`/campaigns/${id}/send
|
|
826
|
+
async send(id, options) {
|
|
827
|
+
return this.client.post(`/campaigns/${id}/send`, void 0, options);
|
|
801
828
|
}
|
|
802
|
-
async schedule(id, params) {
|
|
803
|
-
return this.client.post(`/campaigns/${id}/schedule`, params);
|
|
829
|
+
async schedule(id, params, options) {
|
|
830
|
+
return this.client.post(`/campaigns/${id}/schedule`, params, options);
|
|
804
831
|
}
|
|
805
|
-
async cancel(id) {
|
|
806
|
-
return this.client.post(`/campaigns/${id}/cancel
|
|
832
|
+
async cancel(id, options) {
|
|
833
|
+
return this.client.post(`/campaigns/${id}/cancel`, void 0, options);
|
|
834
|
+
}
|
|
835
|
+
/** Aggregated engagement metrics for a campaign (cached, may be slightly stale). */
|
|
836
|
+
async stats(id) {
|
|
837
|
+
return this.client.get(`/campaigns/${id}/stats`);
|
|
838
|
+
}
|
|
839
|
+
/** Per-recipient email logs for a campaign (cursor-paginated). */
|
|
840
|
+
async logs(id, params) {
|
|
841
|
+
return this.client.get(`/campaigns/${id}/logs`, {
|
|
842
|
+
limit: params?.limit,
|
|
843
|
+
cursor: params?.cursor,
|
|
844
|
+
status: params?.status
|
|
845
|
+
});
|
|
807
846
|
}
|
|
808
847
|
async archive(id) {
|
|
809
848
|
return this.client.post(`/campaigns/${id}/archive`);
|