migma 1.3.0 → 1.3.2
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 -10
- package/dist/index.d.mts +80 -34
- package/dist/index.d.ts +80 -34
- package/dist/index.js +21 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ const { data: project } = await migma.projects.importAndWait({
|
|
|
27
27
|
urls: ['https://yourcompany.com'],
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
// Generate an email design with AI — returns the finished HTML directly
|
|
30
|
+
// Generate an email design with AI — returns the finished HTML directly.
|
|
31
31
|
const { data: email } = await migma.emails.generateAndWait({
|
|
32
32
|
projectId: project.projectId,
|
|
33
33
|
prompt: 'Create a welcome email for new subscribers',
|
|
@@ -35,7 +35,8 @@ const { data: email } = await migma.emails.generateAndWait({
|
|
|
35
35
|
|
|
36
36
|
if (email?.status === 'completed') {
|
|
37
37
|
console.log('Subject:', email.result.subject);
|
|
38
|
-
console.log('HTML:', email.result.html); //
|
|
38
|
+
console.log('HTML:', email.result.html); // primary email HTML
|
|
39
|
+
console.log('Artifact:', email.result.emails[0].artifactId);
|
|
39
40
|
}
|
|
40
41
|
```
|
|
41
42
|
|
|
@@ -63,15 +64,22 @@ const { data: email } = await migma.emails.generateAndWait({
|
|
|
63
64
|
prompt: 'Create a summer sale email with 30% off everything',
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
|
|
67
|
+
if (!email?.result) throw new Error('Email generation failed');
|
|
68
|
+
|
|
69
|
+
// 3. Send it — artifactId works for single emails and series slots
|
|
70
|
+
const selectedEmail = email.result.emails[0];
|
|
71
|
+
if (!selectedEmail.artifactId) throw new Error('No artifactId returned');
|
|
67
72
|
await migma.sending.send({
|
|
68
73
|
recipientType: 'email',
|
|
69
74
|
recipientEmail: 'sarah@example.com',
|
|
70
75
|
from: 'hello@yourcompany.migma.email',
|
|
71
76
|
fromName: 'Your Company',
|
|
72
|
-
subject:
|
|
73
|
-
|
|
77
|
+
subject: selectedEmail.subject,
|
|
78
|
+
artifactId: selectedEmail.artifactId,
|
|
74
79
|
});
|
|
80
|
+
|
|
81
|
+
// conversationId also works for single-email conversations.
|
|
82
|
+
// For multi-slot emails or series, use result.emails[].artifactId.
|
|
75
83
|
```
|
|
76
84
|
|
|
77
85
|
[Full OpenClaw tutorial](https://docs.migma.ai/tutorials/send-emails-from-openclaw)
|
|
@@ -89,7 +97,7 @@ await migma.sending.send({
|
|
|
89
97
|
|
|
90
98
|
## Features
|
|
91
99
|
|
|
92
|
-
- Full coverage of all Migma API v1 endpoints (80+ methods across
|
|
100
|
+
- Full coverage of all Migma API v1 endpoints (80+ methods across 15 resources)
|
|
93
101
|
- TypeScript-first with complete type definitions
|
|
94
102
|
- `{ data, error }` return pattern — methods never throw
|
|
95
103
|
- Automatic retries with exponential backoff on 5xx/429
|
|
@@ -220,7 +228,17 @@ const { data: result } = await migma.contacts.bulkImport({
|
|
|
220
228
|
Send to a single recipient, segment, tag, or full audience.
|
|
221
229
|
|
|
222
230
|
```typescript
|
|
223
|
-
// Send
|
|
231
|
+
// Send a generated email by artifactId
|
|
232
|
+
await migma.sending.send({
|
|
233
|
+
recipientType: 'email',
|
|
234
|
+
recipientEmail: 'user@example.com',
|
|
235
|
+
from: 'hello@yourdomain.com',
|
|
236
|
+
fromName: 'Your Company',
|
|
237
|
+
subject: 'Welcome!',
|
|
238
|
+
artifactId: 'artifact_abc123',
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
// Single-email conversations can also be sent by conversationId.
|
|
224
242
|
await migma.sending.send({
|
|
225
243
|
recipientType: 'email',
|
|
226
244
|
recipientEmail: 'user@example.com',
|
|
@@ -237,7 +255,7 @@ await migma.sending.send({
|
|
|
237
255
|
from: 'hello@yourdomain.com',
|
|
238
256
|
fromName: 'Your Company',
|
|
239
257
|
subject: 'Big Announcement',
|
|
240
|
-
|
|
258
|
+
artifactId: 'artifact_abc123',
|
|
241
259
|
});
|
|
242
260
|
|
|
243
261
|
// Single sends are automatically transactional — no flag needed
|
|
@@ -248,14 +266,40 @@ await migma.sending.send({
|
|
|
248
266
|
from: 'noreply@yourdomain.com',
|
|
249
267
|
fromName: 'Your Company',
|
|
250
268
|
subject: 'Your subscription renews tomorrow',
|
|
251
|
-
|
|
252
|
-
projectId: 'proj_abc123',
|
|
269
|
+
artifactId: 'artifact_abc123',
|
|
253
270
|
transactional: true,
|
|
254
271
|
});
|
|
255
272
|
```
|
|
256
273
|
|
|
257
274
|
[Sending API Reference](https://docs.migma.ai/api-reference/sending/send-email)
|
|
258
275
|
|
|
276
|
+
### Generated Series and Editing
|
|
277
|
+
|
|
278
|
+
Generate a series with `count`, then use each email's `artifactId` to fetch, compile, update, or send one slot.
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const { data: series } = await migma.emails.generateAndWait({
|
|
282
|
+
projectId: 'proj_abc123',
|
|
283
|
+
prompt: 'Create a three-email onboarding series',
|
|
284
|
+
count: 3,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
for (const generated of series?.result?.emails ?? []) {
|
|
288
|
+
console.log(generated.slot, generated.artifactId, generated.html);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const { data: email } = await migma.emails.get('artifact_abc123');
|
|
292
|
+
if (!email?.source) throw new Error('Editable source unavailable');
|
|
293
|
+
|
|
294
|
+
await migma.emails.compile('artifact_abc123', {
|
|
295
|
+
source: email.source.replace('Start now', 'Start your trial'),
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
await migma.emails.update('artifact_abc123', {
|
|
299
|
+
source: email.source.replace('Start now', 'Start your trial'),
|
|
300
|
+
});
|
|
301
|
+
```
|
|
302
|
+
|
|
259
303
|
### Email Validation
|
|
260
304
|
|
|
261
305
|
Run preflight checks — compatibility, links, spelling, and deliverability.
|
package/dist/index.d.mts
CHANGED
|
@@ -243,7 +243,6 @@ declare class Tags {
|
|
|
243
243
|
|
|
244
244
|
interface SegmentFilters {
|
|
245
245
|
tags?: string[];
|
|
246
|
-
excludeTags?: string[];
|
|
247
246
|
status?: 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced';
|
|
248
247
|
customFields?: Record<string, string[]>;
|
|
249
248
|
}
|
|
@@ -353,13 +352,22 @@ interface SendEmailParams {
|
|
|
353
352
|
replyTo?: string;
|
|
354
353
|
bcc?: string[];
|
|
355
354
|
subject: string;
|
|
356
|
-
/** Email template
|
|
355
|
+
/** Email template source. Required unless conversationId or artifactId is provided. */
|
|
357
356
|
template?: string;
|
|
358
357
|
variables?: Record<string, unknown>;
|
|
359
358
|
providerType?: ProviderType;
|
|
360
|
-
/** Required unless conversationId is provided. */
|
|
359
|
+
/** Required unless conversationId or artifactId is provided. */
|
|
361
360
|
projectId?: string;
|
|
362
|
-
/**
|
|
361
|
+
/**
|
|
362
|
+
* Slot-precise email artifact id. Use this for a selected email inside a
|
|
363
|
+
* multi-slot conversation or series. Resolves template, projectId, and parent
|
|
364
|
+
* conversation automatically.
|
|
365
|
+
*/
|
|
366
|
+
artifactId?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Conversation id. Works for single-email conversations. For multi-slot
|
|
369
|
+
* conversations, also provide artifactId so API knows which email to send.
|
|
370
|
+
*/
|
|
363
371
|
conversationId?: string;
|
|
364
372
|
/** Defaults to true for single sends, false for batch sends. Set explicitly to override. Transactional emails bypass subscription status and topic filters, and omit List-Unsubscribe headers. */
|
|
365
373
|
transactional?: boolean;
|
|
@@ -468,24 +476,6 @@ interface RetryImportResponse {
|
|
|
468
476
|
status: string;
|
|
469
477
|
message: string;
|
|
470
478
|
}
|
|
471
|
-
type FieldCatalogValueType = 'string' | 'number' | 'boolean' | 'date' | 'url' | 'unknown';
|
|
472
|
-
interface FieldCatalogEntry {
|
|
473
|
-
key: string;
|
|
474
|
-
label: string;
|
|
475
|
-
type: FieldCatalogValueType;
|
|
476
|
-
fillRate: number;
|
|
477
|
-
sample: string[];
|
|
478
|
-
auto: boolean;
|
|
479
|
-
}
|
|
480
|
-
interface FieldCatalogResponse {
|
|
481
|
-
entries: FieldCatalogEntry[];
|
|
482
|
-
totalSubscribers: number;
|
|
483
|
-
computedAt: string;
|
|
484
|
-
}
|
|
485
|
-
interface FieldCatalogParams {
|
|
486
|
-
segmentId?: string;
|
|
487
|
-
tag?: string;
|
|
488
|
-
}
|
|
489
479
|
|
|
490
480
|
interface PollingOptions {
|
|
491
481
|
/** Polling interval in ms. Default: 2000 */
|
|
@@ -512,12 +502,6 @@ declare class Projects {
|
|
|
512
502
|
import(params: ImportProjectParams): Promise<MigmaResult<ImportProjectResponse>>;
|
|
513
503
|
getImportStatus(projectId: string): Promise<MigmaResult<ImportStatusResponse>>;
|
|
514
504
|
retryImport(projectId: string): Promise<MigmaResult<RetryImportResponse>>;
|
|
515
|
-
/**
|
|
516
|
-
* Get the project's subscriber field catalog: which fields exist, how often
|
|
517
|
-
* each is populated, example values, and whether it's auto-filled at send
|
|
518
|
-
* time. Optionally scope by segment or tag.
|
|
519
|
-
*/
|
|
520
|
-
fieldCatalog(projectId: string, params?: FieldCatalogParams): Promise<MigmaResult<FieldCatalogResponse>>;
|
|
521
505
|
/**
|
|
522
506
|
* Import a project and wait for completion.
|
|
523
507
|
* Polls getImportStatus until status is 'active' or 'error'.
|
|
@@ -540,17 +524,28 @@ interface GenerateEmailParams {
|
|
|
540
524
|
languages?: string[];
|
|
541
525
|
visibility?: 'private' | 'unlisted' | 'public';
|
|
542
526
|
referenceId?: string;
|
|
527
|
+
/** Optional target email count. Omit to let Migma infer single vs series from the prompt. */
|
|
528
|
+
count?: number;
|
|
543
529
|
}
|
|
544
530
|
interface GenerateEmailResponse {
|
|
545
531
|
conversationId: string;
|
|
546
532
|
status: 'pending';
|
|
547
533
|
message: string;
|
|
548
534
|
link: string;
|
|
535
|
+
count?: number;
|
|
536
|
+
referenceId?: string;
|
|
549
537
|
}
|
|
550
538
|
interface EmailGenerationResult {
|
|
551
539
|
subject: string;
|
|
552
540
|
previewText: string;
|
|
553
541
|
html: string;
|
|
542
|
+
source?: string;
|
|
543
|
+
emails: GeneratedEmailArtifact[];
|
|
544
|
+
seriesPlan?: {
|
|
545
|
+
name?: string;
|
|
546
|
+
count?: number;
|
|
547
|
+
themeId?: string;
|
|
548
|
+
};
|
|
554
549
|
screenshotUrl: string | null;
|
|
555
550
|
screenshotFullUrl: string | null;
|
|
556
551
|
stats: {
|
|
@@ -560,6 +555,22 @@ interface EmailGenerationResult {
|
|
|
560
555
|
colors: string[];
|
|
561
556
|
};
|
|
562
557
|
languages: string[];
|
|
558
|
+
templateVariables?: unknown[];
|
|
559
|
+
}
|
|
560
|
+
interface GeneratedEmailArtifact {
|
|
561
|
+
artifactId: string | null;
|
|
562
|
+
conversationId: string;
|
|
563
|
+
messageId: string | null;
|
|
564
|
+
slotIdx: number;
|
|
565
|
+
slot: number;
|
|
566
|
+
subject: string;
|
|
567
|
+
preheader: string;
|
|
568
|
+
html: string;
|
|
569
|
+
source?: string;
|
|
570
|
+
sendOffsetDays?: number;
|
|
571
|
+
status: 'ready' | 'processing' | 'failed';
|
|
572
|
+
thumbnailUrl?: string | null;
|
|
573
|
+
templateVariables?: unknown[];
|
|
563
574
|
}
|
|
564
575
|
interface EmailGenerationStatus {
|
|
565
576
|
conversationId: string;
|
|
@@ -606,6 +617,40 @@ interface SendTestEmailResponse {
|
|
|
606
617
|
sentAt: string;
|
|
607
618
|
subject: string;
|
|
608
619
|
}
|
|
620
|
+
interface EmailArtifact {
|
|
621
|
+
artifactId: string;
|
|
622
|
+
conversationId: string;
|
|
623
|
+
messageId: string | null;
|
|
624
|
+
slotIdx: number;
|
|
625
|
+
slotUuid: string | null;
|
|
626
|
+
status: string;
|
|
627
|
+
engine: 'zinn' | 'react-email';
|
|
628
|
+
subject: string;
|
|
629
|
+
preheader: string;
|
|
630
|
+
html: string;
|
|
631
|
+
source?: string;
|
|
632
|
+
templateVariables: unknown[];
|
|
633
|
+
warnings: string[];
|
|
634
|
+
thumbnailUrl: string | null;
|
|
635
|
+
updatedAt: string;
|
|
636
|
+
}
|
|
637
|
+
interface UpdateEmailArtifactParams {
|
|
638
|
+
source: string;
|
|
639
|
+
vars?: Record<string, unknown>;
|
|
640
|
+
lang?: string;
|
|
641
|
+
label?: string;
|
|
642
|
+
}
|
|
643
|
+
interface CompileEmailArtifactParams {
|
|
644
|
+
source?: string;
|
|
645
|
+
vars?: Record<string, unknown>;
|
|
646
|
+
lang?: string;
|
|
647
|
+
}
|
|
648
|
+
interface CompileEmailArtifactResponse {
|
|
649
|
+
artifactId: string;
|
|
650
|
+
html: string;
|
|
651
|
+
warnings: string[];
|
|
652
|
+
metadata?: Record<string, unknown>;
|
|
653
|
+
}
|
|
609
654
|
|
|
610
655
|
declare class Emails {
|
|
611
656
|
private readonly client;
|
|
@@ -616,6 +661,12 @@ declare class Emails {
|
|
|
616
661
|
generate(params: GenerateEmailParams): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
617
662
|
/** Check email generation status */
|
|
618
663
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
664
|
+
/** Fetch one generated email by artifact id */
|
|
665
|
+
get(artifactId: string): Promise<MigmaResult<EmailArtifact>>;
|
|
666
|
+
/** Replace one generated email's Migma Email source and persist compiled HTML */
|
|
667
|
+
update(artifactId: string, params: UpdateEmailArtifactParams): Promise<MigmaResult<EmailArtifact>>;
|
|
668
|
+
/** Compile an email artifact's source without persisting */
|
|
669
|
+
compile(artifactId: string, params?: CompileEmailArtifactParams): Promise<MigmaResult<CompileEmailArtifactResponse>>;
|
|
619
670
|
/**
|
|
620
671
|
* Generate an email and wait for completion.
|
|
621
672
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
@@ -1127,8 +1178,6 @@ interface Campaign {
|
|
|
1127
1178
|
sentAt?: string | null;
|
|
1128
1179
|
completedAt?: string | null;
|
|
1129
1180
|
error?: string | null;
|
|
1130
|
-
archived?: boolean;
|
|
1131
|
-
archivedAt?: string | null;
|
|
1132
1181
|
triggeredBy?: 'manual' | 'api' | 'automation';
|
|
1133
1182
|
createdAt: string;
|
|
1134
1183
|
updatedAt: string;
|
|
@@ -1153,7 +1202,6 @@ interface ListCampaignsParams {
|
|
|
1153
1202
|
status?: CampaignStatus;
|
|
1154
1203
|
page?: number;
|
|
1155
1204
|
limit?: number;
|
|
1156
|
-
archived?: boolean;
|
|
1157
1205
|
}
|
|
1158
1206
|
interface ListCampaignsResponse {
|
|
1159
1207
|
campaigns: Campaign[];
|
|
@@ -1173,8 +1221,6 @@ declare class Campaigns {
|
|
|
1173
1221
|
send(id: string): Promise<MigmaResult<Campaign>>;
|
|
1174
1222
|
schedule(id: string, params: ScheduleCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1175
1223
|
cancel(id: string): Promise<MigmaResult<Campaign>>;
|
|
1176
|
-
archive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1177
|
-
unarchive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1178
1224
|
}
|
|
1179
1225
|
|
|
1180
1226
|
interface MigmaConfig {
|
|
@@ -1205,4 +1251,4 @@ declare class Migma {
|
|
|
1205
1251
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1206
1252
|
}
|
|
1207
1253
|
|
|
1208
|
-
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 EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type
|
|
1254
|
+
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 CompileEmailArtifactParams, type CompileEmailArtifactResponse, 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 EmailArtifact, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type GenerateEmailParams, type GenerateEmailResponse, type GeneratedEmailArtifact, 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 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 UpdateEmailArtifactParams, 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.d.ts
CHANGED
|
@@ -243,7 +243,6 @@ declare class Tags {
|
|
|
243
243
|
|
|
244
244
|
interface SegmentFilters {
|
|
245
245
|
tags?: string[];
|
|
246
|
-
excludeTags?: string[];
|
|
247
246
|
status?: 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced';
|
|
248
247
|
customFields?: Record<string, string[]>;
|
|
249
248
|
}
|
|
@@ -353,13 +352,22 @@ interface SendEmailParams {
|
|
|
353
352
|
replyTo?: string;
|
|
354
353
|
bcc?: string[];
|
|
355
354
|
subject: string;
|
|
356
|
-
/** Email template
|
|
355
|
+
/** Email template source. Required unless conversationId or artifactId is provided. */
|
|
357
356
|
template?: string;
|
|
358
357
|
variables?: Record<string, unknown>;
|
|
359
358
|
providerType?: ProviderType;
|
|
360
|
-
/** Required unless conversationId is provided. */
|
|
359
|
+
/** Required unless conversationId or artifactId is provided. */
|
|
361
360
|
projectId?: string;
|
|
362
|
-
/**
|
|
361
|
+
/**
|
|
362
|
+
* Slot-precise email artifact id. Use this for a selected email inside a
|
|
363
|
+
* multi-slot conversation or series. Resolves template, projectId, and parent
|
|
364
|
+
* conversation automatically.
|
|
365
|
+
*/
|
|
366
|
+
artifactId?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Conversation id. Works for single-email conversations. For multi-slot
|
|
369
|
+
* conversations, also provide artifactId so API knows which email to send.
|
|
370
|
+
*/
|
|
363
371
|
conversationId?: string;
|
|
364
372
|
/** Defaults to true for single sends, false for batch sends. Set explicitly to override. Transactional emails bypass subscription status and topic filters, and omit List-Unsubscribe headers. */
|
|
365
373
|
transactional?: boolean;
|
|
@@ -468,24 +476,6 @@ interface RetryImportResponse {
|
|
|
468
476
|
status: string;
|
|
469
477
|
message: string;
|
|
470
478
|
}
|
|
471
|
-
type FieldCatalogValueType = 'string' | 'number' | 'boolean' | 'date' | 'url' | 'unknown';
|
|
472
|
-
interface FieldCatalogEntry {
|
|
473
|
-
key: string;
|
|
474
|
-
label: string;
|
|
475
|
-
type: FieldCatalogValueType;
|
|
476
|
-
fillRate: number;
|
|
477
|
-
sample: string[];
|
|
478
|
-
auto: boolean;
|
|
479
|
-
}
|
|
480
|
-
interface FieldCatalogResponse {
|
|
481
|
-
entries: FieldCatalogEntry[];
|
|
482
|
-
totalSubscribers: number;
|
|
483
|
-
computedAt: string;
|
|
484
|
-
}
|
|
485
|
-
interface FieldCatalogParams {
|
|
486
|
-
segmentId?: string;
|
|
487
|
-
tag?: string;
|
|
488
|
-
}
|
|
489
479
|
|
|
490
480
|
interface PollingOptions {
|
|
491
481
|
/** Polling interval in ms. Default: 2000 */
|
|
@@ -512,12 +502,6 @@ declare class Projects {
|
|
|
512
502
|
import(params: ImportProjectParams): Promise<MigmaResult<ImportProjectResponse>>;
|
|
513
503
|
getImportStatus(projectId: string): Promise<MigmaResult<ImportStatusResponse>>;
|
|
514
504
|
retryImport(projectId: string): Promise<MigmaResult<RetryImportResponse>>;
|
|
515
|
-
/**
|
|
516
|
-
* Get the project's subscriber field catalog: which fields exist, how often
|
|
517
|
-
* each is populated, example values, and whether it's auto-filled at send
|
|
518
|
-
* time. Optionally scope by segment or tag.
|
|
519
|
-
*/
|
|
520
|
-
fieldCatalog(projectId: string, params?: FieldCatalogParams): Promise<MigmaResult<FieldCatalogResponse>>;
|
|
521
505
|
/**
|
|
522
506
|
* Import a project and wait for completion.
|
|
523
507
|
* Polls getImportStatus until status is 'active' or 'error'.
|
|
@@ -540,17 +524,28 @@ interface GenerateEmailParams {
|
|
|
540
524
|
languages?: string[];
|
|
541
525
|
visibility?: 'private' | 'unlisted' | 'public';
|
|
542
526
|
referenceId?: string;
|
|
527
|
+
/** Optional target email count. Omit to let Migma infer single vs series from the prompt. */
|
|
528
|
+
count?: number;
|
|
543
529
|
}
|
|
544
530
|
interface GenerateEmailResponse {
|
|
545
531
|
conversationId: string;
|
|
546
532
|
status: 'pending';
|
|
547
533
|
message: string;
|
|
548
534
|
link: string;
|
|
535
|
+
count?: number;
|
|
536
|
+
referenceId?: string;
|
|
549
537
|
}
|
|
550
538
|
interface EmailGenerationResult {
|
|
551
539
|
subject: string;
|
|
552
540
|
previewText: string;
|
|
553
541
|
html: string;
|
|
542
|
+
source?: string;
|
|
543
|
+
emails: GeneratedEmailArtifact[];
|
|
544
|
+
seriesPlan?: {
|
|
545
|
+
name?: string;
|
|
546
|
+
count?: number;
|
|
547
|
+
themeId?: string;
|
|
548
|
+
};
|
|
554
549
|
screenshotUrl: string | null;
|
|
555
550
|
screenshotFullUrl: string | null;
|
|
556
551
|
stats: {
|
|
@@ -560,6 +555,22 @@ interface EmailGenerationResult {
|
|
|
560
555
|
colors: string[];
|
|
561
556
|
};
|
|
562
557
|
languages: string[];
|
|
558
|
+
templateVariables?: unknown[];
|
|
559
|
+
}
|
|
560
|
+
interface GeneratedEmailArtifact {
|
|
561
|
+
artifactId: string | null;
|
|
562
|
+
conversationId: string;
|
|
563
|
+
messageId: string | null;
|
|
564
|
+
slotIdx: number;
|
|
565
|
+
slot: number;
|
|
566
|
+
subject: string;
|
|
567
|
+
preheader: string;
|
|
568
|
+
html: string;
|
|
569
|
+
source?: string;
|
|
570
|
+
sendOffsetDays?: number;
|
|
571
|
+
status: 'ready' | 'processing' | 'failed';
|
|
572
|
+
thumbnailUrl?: string | null;
|
|
573
|
+
templateVariables?: unknown[];
|
|
563
574
|
}
|
|
564
575
|
interface EmailGenerationStatus {
|
|
565
576
|
conversationId: string;
|
|
@@ -606,6 +617,40 @@ interface SendTestEmailResponse {
|
|
|
606
617
|
sentAt: string;
|
|
607
618
|
subject: string;
|
|
608
619
|
}
|
|
620
|
+
interface EmailArtifact {
|
|
621
|
+
artifactId: string;
|
|
622
|
+
conversationId: string;
|
|
623
|
+
messageId: string | null;
|
|
624
|
+
slotIdx: number;
|
|
625
|
+
slotUuid: string | null;
|
|
626
|
+
status: string;
|
|
627
|
+
engine: 'zinn' | 'react-email';
|
|
628
|
+
subject: string;
|
|
629
|
+
preheader: string;
|
|
630
|
+
html: string;
|
|
631
|
+
source?: string;
|
|
632
|
+
templateVariables: unknown[];
|
|
633
|
+
warnings: string[];
|
|
634
|
+
thumbnailUrl: string | null;
|
|
635
|
+
updatedAt: string;
|
|
636
|
+
}
|
|
637
|
+
interface UpdateEmailArtifactParams {
|
|
638
|
+
source: string;
|
|
639
|
+
vars?: Record<string, unknown>;
|
|
640
|
+
lang?: string;
|
|
641
|
+
label?: string;
|
|
642
|
+
}
|
|
643
|
+
interface CompileEmailArtifactParams {
|
|
644
|
+
source?: string;
|
|
645
|
+
vars?: Record<string, unknown>;
|
|
646
|
+
lang?: string;
|
|
647
|
+
}
|
|
648
|
+
interface CompileEmailArtifactResponse {
|
|
649
|
+
artifactId: string;
|
|
650
|
+
html: string;
|
|
651
|
+
warnings: string[];
|
|
652
|
+
metadata?: Record<string, unknown>;
|
|
653
|
+
}
|
|
609
654
|
|
|
610
655
|
declare class Emails {
|
|
611
656
|
private readonly client;
|
|
@@ -616,6 +661,12 @@ declare class Emails {
|
|
|
616
661
|
generate(params: GenerateEmailParams): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
617
662
|
/** Check email generation status */
|
|
618
663
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
664
|
+
/** Fetch one generated email by artifact id */
|
|
665
|
+
get(artifactId: string): Promise<MigmaResult<EmailArtifact>>;
|
|
666
|
+
/** Replace one generated email's Migma Email source and persist compiled HTML */
|
|
667
|
+
update(artifactId: string, params: UpdateEmailArtifactParams): Promise<MigmaResult<EmailArtifact>>;
|
|
668
|
+
/** Compile an email artifact's source without persisting */
|
|
669
|
+
compile(artifactId: string, params?: CompileEmailArtifactParams): Promise<MigmaResult<CompileEmailArtifactResponse>>;
|
|
619
670
|
/**
|
|
620
671
|
* Generate an email and wait for completion.
|
|
621
672
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
@@ -1127,8 +1178,6 @@ interface Campaign {
|
|
|
1127
1178
|
sentAt?: string | null;
|
|
1128
1179
|
completedAt?: string | null;
|
|
1129
1180
|
error?: string | null;
|
|
1130
|
-
archived?: boolean;
|
|
1131
|
-
archivedAt?: string | null;
|
|
1132
1181
|
triggeredBy?: 'manual' | 'api' | 'automation';
|
|
1133
1182
|
createdAt: string;
|
|
1134
1183
|
updatedAt: string;
|
|
@@ -1153,7 +1202,6 @@ interface ListCampaignsParams {
|
|
|
1153
1202
|
status?: CampaignStatus;
|
|
1154
1203
|
page?: number;
|
|
1155
1204
|
limit?: number;
|
|
1156
|
-
archived?: boolean;
|
|
1157
1205
|
}
|
|
1158
1206
|
interface ListCampaignsResponse {
|
|
1159
1207
|
campaigns: Campaign[];
|
|
@@ -1173,8 +1221,6 @@ declare class Campaigns {
|
|
|
1173
1221
|
send(id: string): Promise<MigmaResult<Campaign>>;
|
|
1174
1222
|
schedule(id: string, params: ScheduleCampaignParams): Promise<MigmaResult<Campaign>>;
|
|
1175
1223
|
cancel(id: string): Promise<MigmaResult<Campaign>>;
|
|
1176
|
-
archive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1177
|
-
unarchive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1178
1224
|
}
|
|
1179
1225
|
|
|
1180
1226
|
interface MigmaConfig {
|
|
@@ -1205,4 +1251,4 @@ declare class Migma {
|
|
|
1205
1251
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1206
1252
|
}
|
|
1207
1253
|
|
|
1208
|
-
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 EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type
|
|
1254
|
+
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 CompileEmailArtifactParams, type CompileEmailArtifactResponse, 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 EmailArtifact, type EmailGenerationResult, type EmailGenerationStatus, type EmailImage, type ExportFile, type ExportFormat, type ExportFormatsResponse, type ExportResult, type ExportStatusResponse, type GenerateEmailParams, type GenerateEmailResponse, type GeneratedEmailArtifact, 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 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 UpdateEmailArtifactParams, 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
|
@@ -71,7 +71,7 @@ var MigmaClient = class {
|
|
|
71
71
|
headers: {
|
|
72
72
|
Authorization: `Bearer ${this.apiKey}`,
|
|
73
73
|
"Content-Type": "application/json",
|
|
74
|
-
"User-Agent": "migma-node/1.
|
|
74
|
+
"User-Agent": "migma-node/1.0.0"
|
|
75
75
|
},
|
|
76
76
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
77
77
|
});
|
|
@@ -404,20 +404,6 @@ var Projects = class {
|
|
|
404
404
|
`/projects/import/${projectId}/retry`
|
|
405
405
|
);
|
|
406
406
|
}
|
|
407
|
-
/**
|
|
408
|
-
* Get the project's subscriber field catalog: which fields exist, how often
|
|
409
|
-
* each is populated, example values, and whether it's auto-filled at send
|
|
410
|
-
* time. Optionally scope by segment or tag.
|
|
411
|
-
*/
|
|
412
|
-
async fieldCatalog(projectId, params) {
|
|
413
|
-
return this.client.get(
|
|
414
|
-
`/projects/${projectId}/field-catalog`,
|
|
415
|
-
{
|
|
416
|
-
segmentId: params?.segmentId,
|
|
417
|
-
tag: params?.tag
|
|
418
|
-
}
|
|
419
|
-
);
|
|
420
|
-
}
|
|
421
407
|
/**
|
|
422
408
|
* Import a project and wait for completion.
|
|
423
409
|
* Polls getImportStatus until status is 'active' or 'error'.
|
|
@@ -465,6 +451,24 @@ var Emails = class {
|
|
|
465
451
|
`/projects/emails/${conversationId}/status`
|
|
466
452
|
);
|
|
467
453
|
}
|
|
454
|
+
/** Fetch one generated email by artifact id */
|
|
455
|
+
async get(artifactId) {
|
|
456
|
+
return this.client.get(`/emails/${artifactId}`);
|
|
457
|
+
}
|
|
458
|
+
/** Replace one generated email's Migma Email source and persist compiled HTML */
|
|
459
|
+
async update(artifactId, params) {
|
|
460
|
+
return this.client.patch(
|
|
461
|
+
`/emails/${artifactId}`,
|
|
462
|
+
params
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
/** Compile an email artifact's source without persisting */
|
|
466
|
+
async compile(artifactId, params) {
|
|
467
|
+
return this.client.post(
|
|
468
|
+
`/emails/${artifactId}/compile`,
|
|
469
|
+
params || {}
|
|
470
|
+
);
|
|
471
|
+
}
|
|
468
472
|
/**
|
|
469
473
|
* Generate an email and wait for completion.
|
|
470
474
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
@@ -756,13 +760,12 @@ var Campaigns = class {
|
|
|
756
760
|
this.client = client;
|
|
757
761
|
}
|
|
758
762
|
async list(params) {
|
|
759
|
-
const { projectId, status, page, limit
|
|
763
|
+
const { projectId, status, page, limit } = params;
|
|
760
764
|
return this.client.get("/campaigns", {
|
|
761
765
|
projectId,
|
|
762
766
|
status,
|
|
763
767
|
page,
|
|
764
|
-
limit
|
|
765
|
-
archived
|
|
768
|
+
limit
|
|
766
769
|
});
|
|
767
770
|
}
|
|
768
771
|
async create(params) {
|
|
@@ -780,12 +783,6 @@ var Campaigns = class {
|
|
|
780
783
|
async cancel(id) {
|
|
781
784
|
return this.client.post(`/campaigns/${id}/cancel`);
|
|
782
785
|
}
|
|
783
|
-
async archive(id) {
|
|
784
|
-
return this.client.post(`/campaigns/${id}/archive`);
|
|
785
|
-
}
|
|
786
|
-
async unarchive(id) {
|
|
787
|
-
return this.client.post(`/campaigns/${id}/unarchive`);
|
|
788
|
-
}
|
|
789
786
|
};
|
|
790
787
|
|
|
791
788
|
// src/migma.ts
|