migma 1.8.0 → 1.9.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/README.md +54 -3
- package/dist/index.d.mts +215 -60
- package/dist/index.d.ts +215 -60
- package/dist/index.js +53 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -61,9 +61,12 @@ interface RequestOptions {
|
|
|
61
61
|
body?: Record<string, unknown>;
|
|
62
62
|
query?: Record<string, string | number | boolean | undefined>;
|
|
63
63
|
headers?: Record<string, string>;
|
|
64
|
+
maxRetries?: number;
|
|
64
65
|
}
|
|
65
66
|
/** Per-call options for write methods (POST/PATCH/DELETE). */
|
|
66
67
|
interface CallOptions {
|
|
68
|
+
/** Override automatic retries for this call. Use 0 for unsafe writes. */
|
|
69
|
+
maxRetries?: number;
|
|
67
70
|
/**
|
|
68
71
|
* Optional Idempotency-Key (max 100 chars). Same key + same body within 24h
|
|
69
72
|
* replays the original response; a different body returns 409 IDEMPOTENCY_CONFLICT.
|
|
@@ -100,6 +103,64 @@ declare class MigmaClient {
|
|
|
100
103
|
private sleep;
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
interface SegmentFieldFilter {
|
|
107
|
+
key: string;
|
|
108
|
+
/** Exact/pattern, date, or numeric comparison. Date/number comparisons use one
|
|
109
|
+
* value; date_between/number_between use two ordered bounds. */
|
|
110
|
+
mode?: 'is' | 'is_not' | 'starts_with' | 'ends_with' | 'contains' | 'not_contains' | 'date_after' | 'date_before' | 'date_on' | 'date_between' | 'number_gt' | 'number_gte' | 'number_lt' | 'number_lte' | 'number_between';
|
|
111
|
+
values: string[];
|
|
112
|
+
}
|
|
113
|
+
interface SegmentActivityFilter {
|
|
114
|
+
action: 'sent' | 'opened' | 'clicked';
|
|
115
|
+
channel?: 'email';
|
|
116
|
+
mode: 'within' | 'before' | 'never' | 'between';
|
|
117
|
+
unit?: 'hours' | 'days';
|
|
118
|
+
amount?: number;
|
|
119
|
+
from?: string | Date;
|
|
120
|
+
to?: string | Date;
|
|
121
|
+
campaignId?: string;
|
|
122
|
+
}
|
|
123
|
+
interface SegmentFilters {
|
|
124
|
+
/** Combines this group's conditions and child groups. Defaults to all (AND).
|
|
125
|
+
* Campaign-scoped activity requires all in its group and every ancestor. */
|
|
126
|
+
match?: 'all' | 'any';
|
|
127
|
+
/** Nonempty child groups: at most 10 per group, 3 levels below the root,
|
|
128
|
+
* and 50 conditions across the entire filter tree. The root may be empty. */
|
|
129
|
+
groups?: SegmentFilters[];
|
|
130
|
+
tags?: string[];
|
|
131
|
+
excludeTags?: string[];
|
|
132
|
+
status?: 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced';
|
|
133
|
+
validationStatus?: 'valid' | 'invalid' | 'risky' | 'unknown';
|
|
134
|
+
customFields?: Record<string, string[]>;
|
|
135
|
+
fields?: SegmentFieldFilter[];
|
|
136
|
+
activity?: SegmentActivityFilter[];
|
|
137
|
+
}
|
|
138
|
+
interface Segment {
|
|
139
|
+
id: string;
|
|
140
|
+
name: string;
|
|
141
|
+
description: string;
|
|
142
|
+
filters: SegmentFilters;
|
|
143
|
+
count: number;
|
|
144
|
+
createdAt: string;
|
|
145
|
+
updatedAt: string;
|
|
146
|
+
}
|
|
147
|
+
interface CreateSegmentParams {
|
|
148
|
+
name: string;
|
|
149
|
+
description?: string;
|
|
150
|
+
filters?: SegmentFilters;
|
|
151
|
+
projectId: string;
|
|
152
|
+
}
|
|
153
|
+
interface UpdateSegmentParams {
|
|
154
|
+
name?: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
filters?: SegmentFilters;
|
|
157
|
+
projectId: string;
|
|
158
|
+
}
|
|
159
|
+
interface ListSegmentsResponse {
|
|
160
|
+
data: Segment[];
|
|
161
|
+
count: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
103
164
|
type ContactStatus = 'subscribed' | 'unsubscribed' | 'bounced' | 'non-subscribed';
|
|
104
165
|
interface Contact {
|
|
105
166
|
id: string;
|
|
@@ -209,6 +270,64 @@ interface ChangeStatusParams {
|
|
|
209
270
|
tags?: string[];
|
|
210
271
|
projectId: string;
|
|
211
272
|
}
|
|
273
|
+
interface CreateContactExportParams {
|
|
274
|
+
projectId: string;
|
|
275
|
+
segmentId?: string;
|
|
276
|
+
/** Same filters used by saved segments; tags are IDs, not names. */
|
|
277
|
+
filters?: SegmentFilters & {
|
|
278
|
+
search?: string;
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
interface ContactExportStatus {
|
|
282
|
+
jobId: string;
|
|
283
|
+
projectId: string;
|
|
284
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
285
|
+
contactCount: number;
|
|
286
|
+
fileName: string;
|
|
287
|
+
createdAt: string;
|
|
288
|
+
completedAt: string | null;
|
|
289
|
+
/** Present only after the private CSV has been uploaded. Expires after one hour. */
|
|
290
|
+
downloadUrl?: string;
|
|
291
|
+
downloadExpiresAt?: string;
|
|
292
|
+
error?: string;
|
|
293
|
+
}
|
|
294
|
+
type ContactImportProvider = 'klaviyo' | 'mailchimp' | 'hubspot';
|
|
295
|
+
/** A list or segment in the connected provider account that can be imported. */
|
|
296
|
+
interface ProviderImportSource {
|
|
297
|
+
id: string;
|
|
298
|
+
type: 'audience' | 'segment' | 'tag' | 'list';
|
|
299
|
+
name: string;
|
|
300
|
+
[key: string]: unknown;
|
|
301
|
+
}
|
|
302
|
+
interface ListProviderImportSourcesParams {
|
|
303
|
+
provider: ContactImportProvider;
|
|
304
|
+
projectId: string;
|
|
305
|
+
/** Only when the brand has several accounts connected for this provider. */
|
|
306
|
+
connectionId?: string;
|
|
307
|
+
}
|
|
308
|
+
interface ImportFromProviderParams {
|
|
309
|
+
provider: ContactImportProvider;
|
|
310
|
+
projectId: string;
|
|
311
|
+
/** 1 to 25 sources from listProviderImportSources. */
|
|
312
|
+
sources: Pick<ProviderImportSource, 'id' | 'type' | 'name'>[];
|
|
313
|
+
/** Default subscribed-only. */
|
|
314
|
+
consentMode?: 'subscribed-only' | 'include-all';
|
|
315
|
+
connectionId?: string;
|
|
316
|
+
}
|
|
317
|
+
/** Each import becomes a tag and a segment named after its sources. Poll the import with its id. */
|
|
318
|
+
interface ProviderImportStarted {
|
|
319
|
+
object: 'contact_import';
|
|
320
|
+
id: string;
|
|
321
|
+
status: 'pending';
|
|
322
|
+
tag: {
|
|
323
|
+
id: string;
|
|
324
|
+
name: string;
|
|
325
|
+
};
|
|
326
|
+
segment: {
|
|
327
|
+
id: string;
|
|
328
|
+
name: string;
|
|
329
|
+
};
|
|
330
|
+
}
|
|
212
331
|
|
|
213
332
|
declare class Contacts {
|
|
214
333
|
private readonly client;
|
|
@@ -222,6 +341,15 @@ declare class Contacts {
|
|
|
222
341
|
getBulkImportStatus(jobId: string): Promise<MigmaResult<BulkImportJobStatus>>;
|
|
223
342
|
/** Batch delete contacts by email (up to 1000). Emails with no match come back in `notFound`. */
|
|
224
343
|
bulkDeleteByEmail(params: BatchDeleteContactsParams, options?: CallOptions): Promise<MigmaResult<BatchDeleteResponse>>;
|
|
344
|
+
/** Queue a filtered CSV export. Poll getExport; do not list every contact to build a CSV. */
|
|
345
|
+
createExport(params: CreateContactExportParams, options?: CallOptions): Promise<MigmaResult<ContactExportStatus>>;
|
|
346
|
+
getExport(jobId: string, projectId: string): Promise<MigmaResult<ContactExportStatus>>;
|
|
347
|
+
/** Lists and segments in the brand's connected Klaviyo, Mailchimp or HubSpot account. A 409 error message includes the link to connect it. */
|
|
348
|
+
listProviderImportSources(params: ListProviderImportSourcesParams): Promise<MigmaResult<{
|
|
349
|
+
sources: ProviderImportSource[];
|
|
350
|
+
}>>;
|
|
351
|
+
/** Import provider sources as contacts (subscribed only by default). Poll GET /contacts/imports/{id} for counts. */
|
|
352
|
+
importFromProvider(params: ImportFromProviderParams, options?: CallOptions): Promise<MigmaResult<ProviderImportStarted>>;
|
|
225
353
|
changeStatus(params: ChangeStatusParams, options?: CallOptions): Promise<MigmaResult<{
|
|
226
354
|
success: boolean;
|
|
227
355
|
}>>;
|
|
@@ -272,59 +400,6 @@ declare class Tags {
|
|
|
272
400
|
remove(id: string, projectId: string): Promise<MigmaResult<DeleteResponse>>;
|
|
273
401
|
}
|
|
274
402
|
|
|
275
|
-
interface SegmentFieldFilter {
|
|
276
|
-
key: string;
|
|
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';
|
|
281
|
-
values: string[];
|
|
282
|
-
}
|
|
283
|
-
interface SegmentActivityFilter {
|
|
284
|
-
action: 'sent' | 'opened' | 'clicked';
|
|
285
|
-
channel?: 'email';
|
|
286
|
-
mode: 'within' | 'before' | 'never' | 'between';
|
|
287
|
-
unit?: 'hours' | 'days';
|
|
288
|
-
amount?: number;
|
|
289
|
-
from?: string | Date;
|
|
290
|
-
to?: string | Date;
|
|
291
|
-
campaignId?: string;
|
|
292
|
-
}
|
|
293
|
-
interface SegmentFilters {
|
|
294
|
-
tags?: string[];
|
|
295
|
-
excludeTags?: string[];
|
|
296
|
-
status?: 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced';
|
|
297
|
-
validationStatus?: 'valid' | 'invalid' | 'risky' | 'unknown';
|
|
298
|
-
customFields?: Record<string, string[]>;
|
|
299
|
-
fields?: SegmentFieldFilter[];
|
|
300
|
-
activity?: SegmentActivityFilter[];
|
|
301
|
-
}
|
|
302
|
-
interface Segment {
|
|
303
|
-
id: string;
|
|
304
|
-
name: string;
|
|
305
|
-
description: string;
|
|
306
|
-
filters: SegmentFilters;
|
|
307
|
-
count: number;
|
|
308
|
-
createdAt: string;
|
|
309
|
-
updatedAt: string;
|
|
310
|
-
}
|
|
311
|
-
interface CreateSegmentParams {
|
|
312
|
-
name: string;
|
|
313
|
-
description?: string;
|
|
314
|
-
filters?: SegmentFilters;
|
|
315
|
-
projectId: string;
|
|
316
|
-
}
|
|
317
|
-
interface UpdateSegmentParams {
|
|
318
|
-
name?: string;
|
|
319
|
-
description?: string;
|
|
320
|
-
filters?: SegmentFilters;
|
|
321
|
-
projectId: string;
|
|
322
|
-
}
|
|
323
|
-
interface ListSegmentsResponse {
|
|
324
|
-
data: Segment[];
|
|
325
|
-
count: number;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
403
|
declare class Segments {
|
|
329
404
|
private readonly client;
|
|
330
405
|
constructor(client: MigmaClient);
|
|
@@ -472,6 +547,38 @@ declare class Sending {
|
|
|
472
547
|
getBatchStatus(batchId: string): Promise<MigmaResult<BatchStatus>>;
|
|
473
548
|
}
|
|
474
549
|
|
|
550
|
+
interface ConnectedToolScope {
|
|
551
|
+
projectId: string;
|
|
552
|
+
serverId: string;
|
|
553
|
+
toolName: string;
|
|
554
|
+
}
|
|
555
|
+
interface ListConnectedToolsParams {
|
|
556
|
+
projectId: string;
|
|
557
|
+
search?: string;
|
|
558
|
+
offset?: number;
|
|
559
|
+
limit?: number;
|
|
560
|
+
}
|
|
561
|
+
interface ConnectedToolSummary {
|
|
562
|
+
name: string;
|
|
563
|
+
serverId: string;
|
|
564
|
+
description: string;
|
|
565
|
+
requiresApproval: boolean;
|
|
566
|
+
annotations?: Record<string, unknown>;
|
|
567
|
+
}
|
|
568
|
+
interface ConnectedToolSchema extends ConnectedToolSummary {
|
|
569
|
+
inputSchema: Record<string, unknown>;
|
|
570
|
+
}
|
|
571
|
+
interface ListConnectedToolsResponse {
|
|
572
|
+
tools: ConnectedToolSummary[];
|
|
573
|
+
total: number;
|
|
574
|
+
nextOffset: number | null;
|
|
575
|
+
unreachableServers: string[];
|
|
576
|
+
authRequired: Array<{
|
|
577
|
+
serverId: string;
|
|
578
|
+
authUrl: string;
|
|
579
|
+
}>;
|
|
580
|
+
}
|
|
581
|
+
|
|
475
582
|
interface Project {
|
|
476
583
|
_id: string;
|
|
477
584
|
name: string;
|
|
@@ -620,6 +727,12 @@ declare class Projects {
|
|
|
620
727
|
references(projectId: string): Promise<MigmaResult<ProjectReferencesResponse>>;
|
|
621
728
|
retryImport(projectId: string): Promise<MigmaResult<RetryImportResponse>>;
|
|
622
729
|
fieldCatalog(projectId: string, params?: FieldCatalogParams): Promise<MigmaResult<FieldCatalogResponse>>;
|
|
730
|
+
listConnectedTools(params: ListConnectedToolsParams): Promise<MigmaResult<ListConnectedToolsResponse>>;
|
|
731
|
+
getConnectedTool(params: ConnectedToolScope): Promise<MigmaResult<ConnectedToolSchema>>;
|
|
732
|
+
/** Never automatically replay external writes; provider outcome can be unknown. */
|
|
733
|
+
callConnectedTool(params: ConnectedToolScope & {
|
|
734
|
+
parameters: Record<string, unknown>;
|
|
735
|
+
}): Promise<MigmaResult<unknown>>;
|
|
623
736
|
/**
|
|
624
737
|
* Import a project and wait for completion.
|
|
625
738
|
* Polls getImportStatus until status is 'active' or 'error'.
|
|
@@ -773,6 +886,21 @@ interface EditEmailParams {
|
|
|
773
886
|
prompt: string;
|
|
774
887
|
label?: string;
|
|
775
888
|
}
|
|
889
|
+
interface EmailEditOperation {
|
|
890
|
+
editId: string;
|
|
891
|
+
emailId: string;
|
|
892
|
+
conversationId: string;
|
|
893
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
894
|
+
stage: string;
|
|
895
|
+
createdAt: string;
|
|
896
|
+
updatedAt: string;
|
|
897
|
+
pollAfterMs: number;
|
|
898
|
+
error?: string;
|
|
899
|
+
/** Inspect the saved email before starting another edit after a failure. */
|
|
900
|
+
changesMayHaveBeenSaved?: boolean;
|
|
901
|
+
/** Current saved email, included by getEditStatus after completion. */
|
|
902
|
+
result?: Email;
|
|
903
|
+
}
|
|
776
904
|
interface EmailMetricsSummary {
|
|
777
905
|
totalEmails: number;
|
|
778
906
|
delivered: number;
|
|
@@ -875,8 +1003,12 @@ declare class Emails {
|
|
|
875
1003
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
876
1004
|
/** Fetch one generated email by email id */
|
|
877
1005
|
get(emailId: string): Promise<MigmaResult<Email>>;
|
|
878
|
-
/**
|
|
1006
|
+
/** Synchronous edit. No automatic retries; use startEdit for long edits. */
|
|
879
1007
|
edit(emailId: string, params: EditEmailParams): Promise<MigmaResult<Email>>;
|
|
1008
|
+
/** Queue an edit immediately. Retain an explicit key to recover uncertain submissions. */
|
|
1009
|
+
startEdit(emailId: string, params: EditEmailParams, options?: CallOptions): Promise<MigmaResult<EmailEditOperation>>;
|
|
1010
|
+
/** Poll the exact edit; a completed conversation may belong to an earlier turn. */
|
|
1011
|
+
getEditStatus(emailId: string, editId: string): Promise<MigmaResult<EmailEditOperation>>;
|
|
880
1012
|
/**
|
|
881
1013
|
* Generate an email and wait for completion.
|
|
882
1014
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
@@ -1182,6 +1314,8 @@ interface Domain {
|
|
|
1182
1314
|
status: string;
|
|
1183
1315
|
isVerified?: boolean;
|
|
1184
1316
|
dnsRecords?: DnsRecord[];
|
|
1317
|
+
/** Set while a custom domain cannot send yet: a Migma page that starts one-click DNS setup. */
|
|
1318
|
+
connectUrl?: string;
|
|
1185
1319
|
trackingSettings?: {
|
|
1186
1320
|
openTracking?: boolean;
|
|
1187
1321
|
clickTracking?: boolean;
|
|
@@ -1386,16 +1520,20 @@ interface CreditStatus {
|
|
|
1386
1520
|
type UpgradePlan = 'basic' | 'premium' | 'business' | 'basic_annual' | 'premium_annual' | 'business_annual';
|
|
1387
1521
|
interface UpgradeLinkParams {
|
|
1388
1522
|
/**
|
|
1389
|
-
*
|
|
1390
|
-
*
|
|
1523
|
+
* User-chosen plan for new subscription checkout. Omit for an existing
|
|
1524
|
+
* Stripe customer's billing portal. Passing plan for an active subscription
|
|
1525
|
+
* can change it and charge immediately; requires explicit charge approval.
|
|
1391
1526
|
*/
|
|
1392
1527
|
plan?: UpgradePlan;
|
|
1393
1528
|
}
|
|
1394
1529
|
interface UpgradeLink {
|
|
1395
|
-
/**
|
|
1530
|
+
/** Checkout, invoice, confirmation, or portal URL; not proof of payment. */
|
|
1396
1531
|
url: string;
|
|
1532
|
+
/** checkout includes an existing plan-change result; portal is the billing portal. */
|
|
1397
1533
|
kind: 'checkout' | 'portal';
|
|
1534
|
+
/** Present when a new Stripe Checkout session was created. */
|
|
1398
1535
|
sessionId?: string;
|
|
1536
|
+
/** Migma checkout order id or Stripe invoice id for an existing plan change. */
|
|
1399
1537
|
orderId?: string;
|
|
1400
1538
|
}
|
|
1401
1539
|
|
|
@@ -1405,8 +1543,10 @@ declare class Billing {
|
|
|
1405
1543
|
/** Plan and remaining credits for the API key owner. */
|
|
1406
1544
|
credits(): Promise<MigmaResult<CreditStatus>>;
|
|
1407
1545
|
/**
|
|
1408
|
-
*
|
|
1409
|
-
*
|
|
1546
|
+
* Create checkout for a user-chosen new plan, or omit plan for the existing
|
|
1547
|
+
* customer's billing portal. Passing plan for an active subscription can
|
|
1548
|
+
* change it and charge prorated payment immediately; obtain charge approval.
|
|
1549
|
+
* The returned URL alone does not confirm payment. Do not retry unknown writes.
|
|
1410
1550
|
*/
|
|
1411
1551
|
upgradeLink(params?: UpgradeLinkParams): Promise<MigmaResult<UpgradeLink>>;
|
|
1412
1552
|
}
|
|
@@ -1512,6 +1652,13 @@ interface KnowledgeBaseEntry {
|
|
|
1512
1652
|
thumbnailUrl?: string;
|
|
1513
1653
|
screenshotUrl?: string;
|
|
1514
1654
|
referenceOrigin?: ReferenceOrigin;
|
|
1655
|
+
sourceFileName?: string;
|
|
1656
|
+
/** Preparation runs after save; poll list() for completion. Retry failures by updating the original content. */
|
|
1657
|
+
conversion?: {
|
|
1658
|
+
status: 'pending' | 'complete' | 'failed';
|
|
1659
|
+
revision: string;
|
|
1660
|
+
error?: string;
|
|
1661
|
+
};
|
|
1515
1662
|
}
|
|
1516
1663
|
interface KnowledgeBaseListResponse {
|
|
1517
1664
|
entries: KnowledgeBaseEntry[];
|
|
@@ -1520,6 +1667,8 @@ interface KnowledgeBaseListResponse {
|
|
|
1520
1667
|
interface AddKnowledgeBaseParams {
|
|
1521
1668
|
title: string;
|
|
1522
1669
|
content: string;
|
|
1670
|
+
/** Original upload name, including .html, .eml, or .mjml; at most 255 characters. */
|
|
1671
|
+
sourceFileName?: string;
|
|
1523
1672
|
/** Set to mark the entry as a design reference generation should match. */
|
|
1524
1673
|
referenceOrigin?: ReferenceOrigin;
|
|
1525
1674
|
previewHtml?: string;
|
|
@@ -1529,6 +1678,8 @@ interface AddKnowledgeBaseParams {
|
|
|
1529
1678
|
interface UpdateKnowledgeBaseParams {
|
|
1530
1679
|
title?: string;
|
|
1531
1680
|
content?: string;
|
|
1681
|
+
/** Empty string clears the previous upload name. */
|
|
1682
|
+
sourceFileName?: string;
|
|
1532
1683
|
}
|
|
1533
1684
|
|
|
1534
1685
|
declare class KnowledgeBase {
|
|
@@ -1592,6 +1743,8 @@ interface Campaign {
|
|
|
1592
1743
|
replyTo?: string | null;
|
|
1593
1744
|
recipientType: 'audience' | 'tag';
|
|
1594
1745
|
recipientId: string;
|
|
1746
|
+
/** Present when the campaign targets more than one segment or list. */
|
|
1747
|
+
recipientIds?: string[];
|
|
1595
1748
|
topicId?: string | null;
|
|
1596
1749
|
estimatedRecipients?: number | null;
|
|
1597
1750
|
providerType: string;
|
|
@@ -1622,6 +1775,8 @@ interface CreateCampaignParams {
|
|
|
1622
1775
|
replyTo?: string;
|
|
1623
1776
|
recipientType: 'audience' | 'tag';
|
|
1624
1777
|
recipientId: string;
|
|
1778
|
+
/** Full list of segment or list IDs of the same type. When set, this is the selection; recipientId is stored as the first id. Unique people receive one email. Max 20. */
|
|
1779
|
+
recipientIds?: string[];
|
|
1625
1780
|
topicId?: string;
|
|
1626
1781
|
providerType?: 'ses' | 'resend' | 'sendgrid' | 'mailgun' | 'migma';
|
|
1627
1782
|
variables?: Record<string, unknown>;
|
|
@@ -1816,4 +1971,4 @@ declare class Migma {
|
|
|
1816
1971
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1817
1972
|
}
|
|
1818
1973
|
|
|
1819
|
-
export { type AddCustomDnsRecordParams, type AddImageParams, type AddKnowledgeBaseParams, type AnalyzeDeliverabilityParams, type AnalyzeLinksParams, type ApiResponse, type BatchDeleteContactsParams, type BatchDeleteResponse, type BatchStatus, type BrandGuidelinesParams, type BrandGuidelinesResponse, type BrandImageStyle, 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 CreditStatus, type CustomDnsRecord, type CustomDnsRecordList, type CustomDnsRecordType, type DeleteResponse, type DeliverabilityResponse, type DesignReferenceItem, type DeviceCategoriesResponse, type DnsRecord, type Domain, type DomainAvailability, type DomainDeleteResponse, type DomainPurchaseCheckout, type DomainPurchaseParams, type DomainPurchaseQuote, type DomainPurchaseSearchParams, type DomainRegistration, type DomainRegistrationStatus, type DomainStream, type DomainVerificationResult, type EditEmailParams, type Email, type EmailFavorite, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type EmailLogsParams, type EmailLogsResponse, type EmailMetrics, type EmailMetricsCountry, type EmailMetricsSummary, type EmailMetricsTimePoint, type EmailSendLog, 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 ImportHtmlEmailFile, type ImportHtmlEmailParams, 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 ListWorkspacesResponse, 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 ProjectReferencesResponse, type ProviderType, type ProvisionStreamParams, type RecipientType, type ReferenceOrigin, type RetryImportResponse, type ScheduleCampaignParams, type Segment, type SegmentActivityFilter, type SegmentFieldFilter, type SegmentFilters, type SendEmailParams, type SendEmailResponse, type SendTestEmailParams, type SendTestEmailResponse, type SendingMetrics, type SendingMetricsCounts, type SendingMetricsHistoryEntry, type SendingMetricsParams, type SendingMetricsToday, 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 UpgradeLink, type UpgradeLinkParams, type UpgradePlan, type ValidateAllParams, type ValidateAllResponse, type Webhook, type WebhookDeliveriesResponse, type WebhookDelivery, type WebhookDetail, type WebhookEvent, type WebhookEventType, type WebhookEventsResponse, type WebhookTestResult, type Workspace, poll };
|
|
1974
|
+
export { type AddCustomDnsRecordParams, type AddImageParams, type AddKnowledgeBaseParams, type AnalyzeDeliverabilityParams, type AnalyzeLinksParams, type ApiResponse, type BatchDeleteContactsParams, type BatchDeleteResponse, type BatchStatus, type BrandGuidelinesParams, type BrandGuidelinesResponse, type BrandImageStyle, 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 ConnectedToolSchema, type ConnectedToolScope, type ConnectedToolSummary, type Contact, type ContactExportStatus, type ContactImportProvider, type ContactStatus, type CreateCampaignParams, type CreateContactExportParams, type CreateContactParams, type CreateDomainParams, type CreateManagedDomainParams, type CreatePreviewParams, type CreatePreviewResponse, type CreateSegmentParams, type CreateTagParams, type CreateTopicParams, type CreateWebhookParams, type CreateWebhookResponse, type CreditStatus, type CustomDnsRecord, type CustomDnsRecordList, type CustomDnsRecordType, type DeleteResponse, type DeliverabilityResponse, type DesignReferenceItem, type DeviceCategoriesResponse, type DnsRecord, type Domain, type DomainAvailability, type DomainDeleteResponse, type DomainPurchaseCheckout, type DomainPurchaseParams, type DomainPurchaseQuote, type DomainPurchaseSearchParams, type DomainRegistration, type DomainRegistrationStatus, type DomainStream, type DomainVerificationResult, type EditEmailParams, type Email, type EmailEditOperation, type EmailFavorite, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type EmailLogsParams, type EmailLogsResponse, type EmailMetrics, type EmailMetricsCountry, type EmailMetricsSummary, type EmailMetricsTimePoint, type EmailSendLog, 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 ImportFromProviderParams, type ImportHtmlEmailFile, type ImportHtmlEmailParams, type ImportProjectParams, type ImportProjectResponse, type ImportStatusResponse, type KnowledgeBaseEntry, type KnowledgeBaseListResponse, type LinkAnalysisResponse, type ListCampaignsParams, type ListCampaignsResponse, type ListConnectedToolsParams, type ListConnectedToolsResponse, type ListContactsParams, type ListContactsResponse, type ListEmailsEmail, type ListEmailsParams, type ListEmailsResponse, type ListProjectsParams, type ListProjectsResponse, type ListProviderImportSourcesParams, type ListSegmentsResponse, type ListTagsParams, type ListTagsResponse, type ListTopicsParams, type ListTopicsResponse, type ListWebhooksResponse, type ListWorkspacesResponse, 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 ProjectReferencesResponse, type ProviderImportSource, type ProviderImportStarted, type ProviderType, type ProvisionStreamParams, type RecipientType, type ReferenceOrigin, type RetryImportResponse, type ScheduleCampaignParams, type Segment, type SegmentActivityFilter, type SegmentFieldFilter, type SegmentFilters, type SendEmailParams, type SendEmailResponse, type SendTestEmailParams, type SendTestEmailResponse, type SendingMetrics, type SendingMetricsCounts, type SendingMetricsHistoryEntry, type SendingMetricsParams, type SendingMetricsToday, 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 UpgradeLink, type UpgradeLinkParams, type UpgradePlan, type ValidateAllParams, type ValidateAllResponse, type Webhook, type WebhookDeliveriesResponse, type WebhookDelivery, type WebhookDetail, type WebhookEvent, type WebhookEventType, type WebhookEventsResponse, type WebhookTestResult, type Workspace, poll };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
|
|
3
5
|
// src/agent-identity.ts
|
|
4
6
|
var AGENT_ID_PATTERN = /^ai:[a-z0-9][a-z0-9._-]{0,62}$/;
|
|
5
7
|
var HOST_AGENT_ENV = [
|
|
@@ -89,7 +91,7 @@ var MigmaClient = class {
|
|
|
89
91
|
}
|
|
90
92
|
async request(options) {
|
|
91
93
|
const url = this.buildUrl(options.path, options.query);
|
|
92
|
-
const attempts = this.config.maxRetries + 1;
|
|
94
|
+
const attempts = (options.maxRetries ?? this.config.maxRetries) + 1;
|
|
93
95
|
let lastError = null;
|
|
94
96
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
95
97
|
try {
|
|
@@ -173,16 +175,16 @@ var MigmaClient = class {
|
|
|
173
175
|
return this.requestWithCount({ method: "GET", path, query });
|
|
174
176
|
}
|
|
175
177
|
async post(path, body, options) {
|
|
176
|
-
return this.request({ method: "POST", path, body, headers: this.callHeaders(options) });
|
|
178
|
+
return this.request({ method: "POST", path, body, headers: this.callHeaders(options), maxRetries: options?.maxRetries });
|
|
177
179
|
}
|
|
178
180
|
async patch(path, body, options) {
|
|
179
|
-
return this.request({ method: "PATCH", path, body, headers: this.callHeaders(options) });
|
|
181
|
+
return this.request({ method: "PATCH", path, body, headers: this.callHeaders(options), maxRetries: options?.maxRetries });
|
|
180
182
|
}
|
|
181
183
|
async put(path, body) {
|
|
182
184
|
return this.request({ method: "PUT", path, body });
|
|
183
185
|
}
|
|
184
186
|
async delete(path, query, options) {
|
|
185
|
-
return this.request({ method: "DELETE", path, query, headers: this.callHeaders(options) });
|
|
187
|
+
return this.request({ method: "DELETE", path, query, headers: this.callHeaders(options), maxRetries: options?.maxRetries });
|
|
186
188
|
}
|
|
187
189
|
callHeaders(options) {
|
|
188
190
|
if (options?.idempotencyKey) {
|
|
@@ -252,6 +254,22 @@ var Contacts = class {
|
|
|
252
254
|
async bulkDeleteByEmail(params, options) {
|
|
253
255
|
return this.client.post("/contacts/bulk-delete", params, options);
|
|
254
256
|
}
|
|
257
|
+
/** Queue a filtered CSV export. Poll getExport; do not list every contact to build a CSV. */
|
|
258
|
+
async createExport(params, options) {
|
|
259
|
+
return this.client.post("/contacts/exports", params, { ...options, maxRetries: options?.idempotencyKey ? options.maxRetries : 0 });
|
|
260
|
+
}
|
|
261
|
+
async getExport(jobId, projectId) {
|
|
262
|
+
return this.client.get(`/contacts/exports/${encodeURIComponent(jobId)}`, { projectId });
|
|
263
|
+
}
|
|
264
|
+
/** Lists and segments in the brand's connected Klaviyo, Mailchimp or HubSpot account. A 409 error message includes the link to connect it. */
|
|
265
|
+
async listProviderImportSources(params) {
|
|
266
|
+
const { provider, projectId, connectionId } = params;
|
|
267
|
+
return this.client.get(`/contacts/imports/providers/${encodeURIComponent(provider)}/sources`, { projectId, connectionId });
|
|
268
|
+
}
|
|
269
|
+
/** Import provider sources as contacts (subscribed only by default). Poll GET /contacts/imports/{id} for counts. */
|
|
270
|
+
async importFromProvider(params, options) {
|
|
271
|
+
return this.client.post("/contacts/imports/provider", params, { ...options, maxRetries: options?.idempotencyKey ? options.maxRetries : 0 });
|
|
272
|
+
}
|
|
255
273
|
async changeStatus(params, options) {
|
|
256
274
|
return this.client.post("/contacts/status", params, options);
|
|
257
275
|
}
|
|
@@ -454,6 +472,16 @@ var Projects = class {
|
|
|
454
472
|
}
|
|
455
473
|
);
|
|
456
474
|
}
|
|
475
|
+
async listConnectedTools(params) {
|
|
476
|
+
return this.client.get("/connected-tools", { ...params });
|
|
477
|
+
}
|
|
478
|
+
async getConnectedTool(params) {
|
|
479
|
+
return this.client.get("/connected-tools/schema", { ...params });
|
|
480
|
+
}
|
|
481
|
+
/** Never automatically replay external writes; provider outcome can be unknown. */
|
|
482
|
+
async callConnectedTool(params) {
|
|
483
|
+
return this.client.post("/connected-tools/call", { ...params }, { maxRetries: 0 });
|
|
484
|
+
}
|
|
457
485
|
/**
|
|
458
486
|
* Import a project and wait for completion.
|
|
459
487
|
* Polls getImportStatus until status is 'active' or 'error'.
|
|
@@ -471,8 +499,6 @@ var Projects = class {
|
|
|
471
499
|
);
|
|
472
500
|
}
|
|
473
501
|
};
|
|
474
|
-
|
|
475
|
-
// src/resources/emails.ts
|
|
476
502
|
var Emails = class {
|
|
477
503
|
constructor(client) {
|
|
478
504
|
this.client = client;
|
|
@@ -514,11 +540,26 @@ var Emails = class {
|
|
|
514
540
|
async get(emailId) {
|
|
515
541
|
return this.client.get(`/emails/${emailId}`);
|
|
516
542
|
}
|
|
517
|
-
/**
|
|
543
|
+
/** Synchronous edit. No automatic retries; use startEdit for long edits. */
|
|
518
544
|
async edit(emailId, params) {
|
|
519
545
|
return this.client.post(
|
|
520
546
|
`/emails/${emailId}/edit`,
|
|
521
|
-
params
|
|
547
|
+
params,
|
|
548
|
+
{ maxRetries: 0 }
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
/** Queue an edit immediately. Retain an explicit key to recover uncertain submissions. */
|
|
552
|
+
async startEdit(emailId, params, options) {
|
|
553
|
+
return this.client.post(
|
|
554
|
+
`/emails/${encodeURIComponent(emailId)}/edit`,
|
|
555
|
+
{ ...params, async: true },
|
|
556
|
+
{ ...options, idempotencyKey: options?.idempotencyKey || crypto.randomUUID() }
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
/** Poll the exact edit; a completed conversation may belong to an earlier turn. */
|
|
560
|
+
async getEditStatus(emailId, editId) {
|
|
561
|
+
return this.client.get(
|
|
562
|
+
`/emails/${encodeURIComponent(emailId)}/edits/${encodeURIComponent(editId)}`
|
|
522
563
|
);
|
|
523
564
|
}
|
|
524
565
|
/**
|
|
@@ -821,8 +862,10 @@ var Billing = class {
|
|
|
821
862
|
return this.client.get("/billing/credits");
|
|
822
863
|
}
|
|
823
864
|
/**
|
|
824
|
-
*
|
|
825
|
-
*
|
|
865
|
+
* Create checkout for a user-chosen new plan, or omit plan for the existing
|
|
866
|
+
* customer's billing portal. Passing plan for an active subscription can
|
|
867
|
+
* change it and charge prorated payment immediately; obtain charge approval.
|
|
868
|
+
* The returned URL alone does not confirm payment. Do not retry unknown writes.
|
|
826
869
|
*/
|
|
827
870
|
async upgradeLink(params = {}) {
|
|
828
871
|
return this.client.post("/billing/upgrade-link", params);
|