migma 1.3.1 → 1.3.3
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 +45 -17
- package/dist/index.d.mts +90 -352
- package/dist/index.d.ts +90 -352
- package/dist/index.js +40 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -160
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,7 @@ interface RequestOptions {
|
|
|
64
64
|
declare class MigmaClient {
|
|
65
65
|
private readonly apiKey;
|
|
66
66
|
private readonly config;
|
|
67
|
+
private readonly headers;
|
|
67
68
|
constructor(apiKey: string, config: ClientConfig);
|
|
68
69
|
request<T>(options: RequestOptions): Promise<MigmaResult<T>>;
|
|
69
70
|
/**
|
|
@@ -94,6 +95,7 @@ interface Contact {
|
|
|
94
95
|
email: string;
|
|
95
96
|
firstName?: string;
|
|
96
97
|
lastName?: string;
|
|
98
|
+
phone?: string;
|
|
97
99
|
country?: string;
|
|
98
100
|
language?: string;
|
|
99
101
|
tags: string[];
|
|
@@ -107,6 +109,7 @@ interface CreateContactParams {
|
|
|
107
109
|
email: string;
|
|
108
110
|
firstName?: string;
|
|
109
111
|
lastName?: string;
|
|
112
|
+
phone?: string;
|
|
110
113
|
/** ISO 3166-1 alpha-2 country code (e.g., US, CA, GB) */
|
|
111
114
|
country?: string;
|
|
112
115
|
/** Language code in ISO 639-1 or BCP 47 format (e.g., en, en-US) */
|
|
@@ -118,6 +121,7 @@ interface CreateContactParams {
|
|
|
118
121
|
interface UpdateContactParams {
|
|
119
122
|
firstName?: string;
|
|
120
123
|
lastName?: string;
|
|
124
|
+
phone?: string | null;
|
|
121
125
|
country?: string;
|
|
122
126
|
language?: string;
|
|
123
127
|
tags?: string[];
|
|
@@ -141,6 +145,7 @@ interface BulkImportContactItem {
|
|
|
141
145
|
email: string;
|
|
142
146
|
firstName?: string;
|
|
143
147
|
lastName?: string;
|
|
148
|
+
phone?: string;
|
|
144
149
|
country?: string;
|
|
145
150
|
language?: string;
|
|
146
151
|
tags?: string[];
|
|
@@ -241,11 +246,28 @@ declare class Tags {
|
|
|
241
246
|
remove(id: string, projectId: string): Promise<MigmaResult<DeleteResponse>>;
|
|
242
247
|
}
|
|
243
248
|
|
|
249
|
+
interface SegmentFieldFilter {
|
|
250
|
+
key: string;
|
|
251
|
+
mode?: 'is' | 'is_not';
|
|
252
|
+
values: string[];
|
|
253
|
+
}
|
|
254
|
+
interface SegmentActivityFilter {
|
|
255
|
+
action: 'sent' | 'opened' | 'clicked';
|
|
256
|
+
mode: 'within' | 'before' | 'never' | 'between';
|
|
257
|
+
unit?: 'hours' | 'days';
|
|
258
|
+
amount?: number;
|
|
259
|
+
from?: string | Date;
|
|
260
|
+
to?: string | Date;
|
|
261
|
+
campaignId?: string;
|
|
262
|
+
}
|
|
244
263
|
interface SegmentFilters {
|
|
245
264
|
tags?: string[];
|
|
246
265
|
excludeTags?: string[];
|
|
247
266
|
status?: 'subscribed' | 'unsubscribed' | 'non-subscribed' | 'bounced';
|
|
267
|
+
validationStatus?: 'valid' | 'invalid' | 'risky' | 'unknown';
|
|
248
268
|
customFields?: Record<string, string[]>;
|
|
269
|
+
fields?: SegmentFieldFilter[];
|
|
270
|
+
activity?: SegmentActivityFilter[];
|
|
249
271
|
}
|
|
250
272
|
interface Segment {
|
|
251
273
|
id: string;
|
|
@@ -353,21 +375,19 @@ interface SendEmailParams {
|
|
|
353
375
|
replyTo?: string;
|
|
354
376
|
bcc?: string[];
|
|
355
377
|
subject: string;
|
|
356
|
-
/** Email template source. Required unless conversationId or artifactId is provided. */
|
|
357
|
-
template?: string;
|
|
358
378
|
variables?: Record<string, unknown>;
|
|
359
379
|
providerType?: ProviderType;
|
|
360
|
-
/**
|
|
380
|
+
/** Optional when emailId or conversationId can resolve project automatically. */
|
|
361
381
|
projectId?: string;
|
|
362
382
|
/**
|
|
363
|
-
*
|
|
364
|
-
* multi-slot
|
|
365
|
-
* conversation automatically.
|
|
383
|
+
* Generated email id from result.emails[].emailId. Use this for selected
|
|
384
|
+
* emails inside multi-slot conversations or series. Resolves template,
|
|
385
|
+
* projectId, and parent conversation automatically.
|
|
366
386
|
*/
|
|
367
|
-
|
|
387
|
+
emailId?: string;
|
|
368
388
|
/**
|
|
369
389
|
* Conversation id. Works for single-email conversations. For multi-slot
|
|
370
|
-
* conversations,
|
|
390
|
+
* conversations, use emailId so API knows which email to send.
|
|
371
391
|
*/
|
|
372
392
|
conversationId?: string;
|
|
373
393
|
/** 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. */
|
|
@@ -477,11 +497,15 @@ interface RetryImportResponse {
|
|
|
477
497
|
status: string;
|
|
478
498
|
message: string;
|
|
479
499
|
}
|
|
480
|
-
|
|
500
|
+
interface FieldCatalogParams {
|
|
501
|
+
segmentId?: string;
|
|
502
|
+
tag?: string;
|
|
503
|
+
}
|
|
504
|
+
type FieldCatalogEntryType = 'string' | 'number' | 'boolean' | 'date' | 'url' | 'unknown';
|
|
481
505
|
interface FieldCatalogEntry {
|
|
482
506
|
key: string;
|
|
483
507
|
label: string;
|
|
484
|
-
type:
|
|
508
|
+
type: FieldCatalogEntryType;
|
|
485
509
|
fillRate: number;
|
|
486
510
|
sample: string[];
|
|
487
511
|
auto: boolean;
|
|
@@ -491,10 +515,6 @@ interface FieldCatalogResponse {
|
|
|
491
515
|
totalSubscribers: number;
|
|
492
516
|
computedAt: string;
|
|
493
517
|
}
|
|
494
|
-
interface FieldCatalogParams {
|
|
495
|
-
segmentId?: string;
|
|
496
|
-
tag?: string;
|
|
497
|
-
}
|
|
498
518
|
|
|
499
519
|
interface PollingOptions {
|
|
500
520
|
/** Polling interval in ms. Default: 2000 */
|
|
@@ -521,11 +541,6 @@ declare class Projects {
|
|
|
521
541
|
import(params: ImportProjectParams): Promise<MigmaResult<ImportProjectResponse>>;
|
|
522
542
|
getImportStatus(projectId: string): Promise<MigmaResult<ImportStatusResponse>>;
|
|
523
543
|
retryImport(projectId: string): Promise<MigmaResult<RetryImportResponse>>;
|
|
524
|
-
/**
|
|
525
|
-
* Get the project's subscriber field catalog: which fields exist, how often
|
|
526
|
-
* each is populated, example values, and whether it's auto-filled at send
|
|
527
|
-
* time. Optionally scope by segment or tag.
|
|
528
|
-
*/
|
|
529
544
|
fieldCatalog(projectId: string, params?: FieldCatalogParams): Promise<MigmaResult<FieldCatalogResponse>>;
|
|
530
545
|
/**
|
|
531
546
|
* Import a project and wait for completion.
|
|
@@ -549,17 +564,27 @@ interface GenerateEmailParams {
|
|
|
549
564
|
languages?: string[];
|
|
550
565
|
visibility?: 'private' | 'unlisted' | 'public';
|
|
551
566
|
referenceId?: string;
|
|
567
|
+
/** Optional target email count. Omit to let Migma infer single vs series from the prompt. */
|
|
568
|
+
count?: number;
|
|
552
569
|
}
|
|
553
570
|
interface GenerateEmailResponse {
|
|
554
571
|
conversationId: string;
|
|
555
572
|
status: 'pending';
|
|
556
573
|
message: string;
|
|
557
574
|
link: string;
|
|
575
|
+
count?: number;
|
|
576
|
+
referenceId?: string;
|
|
558
577
|
}
|
|
559
578
|
interface EmailGenerationResult {
|
|
560
579
|
subject: string;
|
|
561
580
|
previewText: string;
|
|
562
581
|
html: string;
|
|
582
|
+
emails: GeneratedEmail[];
|
|
583
|
+
seriesPlan?: {
|
|
584
|
+
name?: string;
|
|
585
|
+
count?: number;
|
|
586
|
+
themeId?: string;
|
|
587
|
+
};
|
|
563
588
|
screenshotUrl: string | null;
|
|
564
589
|
screenshotFullUrl: string | null;
|
|
565
590
|
stats: {
|
|
@@ -570,6 +595,21 @@ interface EmailGenerationResult {
|
|
|
570
595
|
};
|
|
571
596
|
languages: string[];
|
|
572
597
|
}
|
|
598
|
+
interface GeneratedEmail {
|
|
599
|
+
id: string | null;
|
|
600
|
+
emailId: string | null;
|
|
601
|
+
conversationId: string;
|
|
602
|
+
messageId: string | null;
|
|
603
|
+
slotIdx: number;
|
|
604
|
+
slot: number;
|
|
605
|
+
subject: string;
|
|
606
|
+
preheader: string;
|
|
607
|
+
html: string;
|
|
608
|
+
sendOffsetDays?: number;
|
|
609
|
+
status: 'ready' | 'processing' | 'failed';
|
|
610
|
+
screenshotUrl?: string | null;
|
|
611
|
+
thumbnailUrl?: string | null;
|
|
612
|
+
}
|
|
573
613
|
interface EmailGenerationStatus {
|
|
574
614
|
conversationId: string;
|
|
575
615
|
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
@@ -605,16 +645,38 @@ interface ListEmailsResponse {
|
|
|
605
645
|
};
|
|
606
646
|
}
|
|
607
647
|
interface SendTestEmailParams {
|
|
608
|
-
|
|
648
|
+
emailId?: string;
|
|
649
|
+
conversationId?: string;
|
|
609
650
|
to: string;
|
|
610
651
|
}
|
|
611
652
|
interface SendTestEmailResponse {
|
|
612
653
|
messageId: string;
|
|
654
|
+
emailId?: string;
|
|
613
655
|
conversationId: string;
|
|
614
656
|
sentTo: string;
|
|
615
657
|
sentAt: string;
|
|
616
658
|
subject: string;
|
|
617
659
|
}
|
|
660
|
+
interface Email {
|
|
661
|
+
id: string;
|
|
662
|
+
emailId: string;
|
|
663
|
+
conversationId: string;
|
|
664
|
+
messageId: string | null;
|
|
665
|
+
slotIdx: number;
|
|
666
|
+
slotUuid: string | null;
|
|
667
|
+
status: string;
|
|
668
|
+
subject: string;
|
|
669
|
+
preheader: string;
|
|
670
|
+
html: string;
|
|
671
|
+
screenshotUrl: string | null;
|
|
672
|
+
warnings: string[];
|
|
673
|
+
thumbnailUrl: string | null;
|
|
674
|
+
updatedAt: string;
|
|
675
|
+
}
|
|
676
|
+
interface EditEmailParams {
|
|
677
|
+
prompt: string;
|
|
678
|
+
label?: string;
|
|
679
|
+
}
|
|
618
680
|
|
|
619
681
|
declare class Emails {
|
|
620
682
|
private readonly client;
|
|
@@ -625,6 +687,10 @@ declare class Emails {
|
|
|
625
687
|
generate(params: GenerateEmailParams): Promise<MigmaResult<GenerateEmailResponse>>;
|
|
626
688
|
/** Check email generation status */
|
|
627
689
|
getGenerationStatus(conversationId: string): Promise<MigmaResult<EmailGenerationStatus>>;
|
|
690
|
+
/** Fetch one generated email by email id */
|
|
691
|
+
get(emailId: string): Promise<MigmaResult<Email>>;
|
|
692
|
+
/** Prompt Migma to edit one generated email */
|
|
693
|
+
edit(emailId: string, params: EditEmailParams): Promise<MigmaResult<Email>>;
|
|
628
694
|
/**
|
|
629
695
|
* Generate an email and wait for completion.
|
|
630
696
|
* Polls getGenerationStatus until status is 'completed' or 'failed'.
|
|
@@ -1118,6 +1184,7 @@ interface Campaign {
|
|
|
1118
1184
|
projectId: string;
|
|
1119
1185
|
name: string;
|
|
1120
1186
|
conversationId: string;
|
|
1187
|
+
emailId?: string | null;
|
|
1121
1188
|
subject: string;
|
|
1122
1189
|
preheaderText?: string | null;
|
|
1123
1190
|
from: string;
|
|
@@ -1146,6 +1213,8 @@ interface CreateCampaignParams {
|
|
|
1146
1213
|
projectId: string;
|
|
1147
1214
|
name: string;
|
|
1148
1215
|
conversationId: string;
|
|
1216
|
+
/** Generated email ID from result.emails[].emailId. Recommended for series slots. */
|
|
1217
|
+
emailId?: string;
|
|
1149
1218
|
subject?: string;
|
|
1150
1219
|
preheaderText?: string;
|
|
1151
1220
|
from: string;
|
|
@@ -1186,336 +1255,6 @@ declare class Campaigns {
|
|
|
1186
1255
|
unarchive(id: string): Promise<MigmaResult<Campaign>>;
|
|
1187
1256
|
}
|
|
1188
1257
|
|
|
1189
|
-
/**
|
|
1190
|
-
* Design v2 — SDK types for the `/v1/flows/*` and `/v1/emails/*` REST surface
|
|
1191
|
-
* shipped in P5 of the design-v2 plan.
|
|
1192
|
-
*
|
|
1193
|
-
* Mongo ObjectIds and Dates serialize to JSON strings on the wire, so every
|
|
1194
|
-
* id and timestamp on this surface is `string`. These types intentionally do
|
|
1195
|
-
* not import from the backend — the SDK is versioned independently and must
|
|
1196
|
-
* not take a peer dep on the backend package.
|
|
1197
|
-
*/
|
|
1198
|
-
type FlowStatus = 'draft' | 'generating' | 'ready' | 'archived';
|
|
1199
|
-
type EmailStatus = 'pending' | 'streaming' | 'ready' | 'failed' | 'sent';
|
|
1200
|
-
type ImageGenMode = 'auto' | 'manual' | 'off';
|
|
1201
|
-
type EmailVariableSource = 'persona' | 'manual' | 'system';
|
|
1202
|
-
type EmailEditKind = 'chat' | 'visual' | 'tool';
|
|
1203
|
-
type ImageJobStatus = 'queued' | 'running' | 'succeeded' | 'failed';
|
|
1204
|
-
interface FlowToolPolicy {
|
|
1205
|
-
localization: boolean;
|
|
1206
|
-
validate: boolean;
|
|
1207
|
-
imageGen: ImageGenMode;
|
|
1208
|
-
mcpEnabled: {
|
|
1209
|
-
shopify: boolean;
|
|
1210
|
-
notion: boolean;
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
interface FlowReferenceSelection {
|
|
1214
|
-
selected: string[];
|
|
1215
|
-
autoIncluded: string[];
|
|
1216
|
-
}
|
|
1217
|
-
interface FlowMeta {
|
|
1218
|
-
creditsSpent: number;
|
|
1219
|
-
tokensIn: number;
|
|
1220
|
-
tokensOut: number;
|
|
1221
|
-
model: string;
|
|
1222
|
-
}
|
|
1223
|
-
interface Flow {
|
|
1224
|
-
_id: string;
|
|
1225
|
-
userId: string;
|
|
1226
|
-
projectId: string;
|
|
1227
|
-
title: string;
|
|
1228
|
-
goal: string;
|
|
1229
|
-
status: FlowStatus;
|
|
1230
|
-
emailIds: string[];
|
|
1231
|
-
references: FlowReferenceSelection;
|
|
1232
|
-
agentSessionId: string | null;
|
|
1233
|
-
toolPolicy: FlowToolPolicy;
|
|
1234
|
-
meta: FlowMeta;
|
|
1235
|
-
createdAt: string;
|
|
1236
|
-
updatedAt: string;
|
|
1237
|
-
archivedAt?: string;
|
|
1238
|
-
}
|
|
1239
|
-
interface ListFlowsParams {
|
|
1240
|
-
projectId?: string;
|
|
1241
|
-
limit?: number;
|
|
1242
|
-
cursor?: string;
|
|
1243
|
-
}
|
|
1244
|
-
interface ListFlowsResponse {
|
|
1245
|
-
items: Flow[];
|
|
1246
|
-
nextCursor: string | null;
|
|
1247
|
-
}
|
|
1248
|
-
interface CreateFlowParams {
|
|
1249
|
-
projectId: string;
|
|
1250
|
-
title?: string;
|
|
1251
|
-
description?: string;
|
|
1252
|
-
}
|
|
1253
|
-
interface FlowPatch {
|
|
1254
|
-
title?: string;
|
|
1255
|
-
description?: string;
|
|
1256
|
-
status?: FlowStatus;
|
|
1257
|
-
toolPolicy?: Partial<FlowToolPolicy>;
|
|
1258
|
-
references?: {
|
|
1259
|
-
selected?: string[];
|
|
1260
|
-
autoIncluded?: string[];
|
|
1261
|
-
};
|
|
1262
|
-
}
|
|
1263
|
-
interface DeleteFlowResponse {
|
|
1264
|
-
archived: true;
|
|
1265
|
-
}
|
|
1266
|
-
interface EmailVariable {
|
|
1267
|
-
name: string;
|
|
1268
|
-
defaultValue: string;
|
|
1269
|
-
source: EmailVariableSource;
|
|
1270
|
-
required?: boolean;
|
|
1271
|
-
}
|
|
1272
|
-
interface EmailAsset {
|
|
1273
|
-
url: string;
|
|
1274
|
-
type: string;
|
|
1275
|
-
alt?: string;
|
|
1276
|
-
w?: number;
|
|
1277
|
-
h?: number;
|
|
1278
|
-
sourceTool?: string;
|
|
1279
|
-
replicateId?: string;
|
|
1280
|
-
}
|
|
1281
|
-
interface EmailEdit {
|
|
1282
|
-
at: string;
|
|
1283
|
-
kind: EmailEditKind;
|
|
1284
|
-
summary: string;
|
|
1285
|
-
astPatch: Record<string, unknown>;
|
|
1286
|
-
}
|
|
1287
|
-
interface ImageJob {
|
|
1288
|
-
jobId: string;
|
|
1289
|
-
status: ImageJobStatus;
|
|
1290
|
-
prompt: string;
|
|
1291
|
-
replicateUrl?: string;
|
|
1292
|
-
finalUrl?: string;
|
|
1293
|
-
}
|
|
1294
|
-
interface EmailExport {
|
|
1295
|
-
at: string;
|
|
1296
|
-
format: string;
|
|
1297
|
-
platform?: string;
|
|
1298
|
-
url?: string;
|
|
1299
|
-
}
|
|
1300
|
-
interface EmailSend {
|
|
1301
|
-
lastSentAt?: string;
|
|
1302
|
-
recipients: number;
|
|
1303
|
-
esp?: string;
|
|
1304
|
-
}
|
|
1305
|
-
interface EmailDesign {
|
|
1306
|
-
_id: string;
|
|
1307
|
-
flowId: string | null;
|
|
1308
|
-
userId: string;
|
|
1309
|
-
projectId: string;
|
|
1310
|
-
index: number;
|
|
1311
|
-
title: string;
|
|
1312
|
-
subject: string;
|
|
1313
|
-
preheader: string;
|
|
1314
|
-
/**
|
|
1315
|
-
* Internal-only on the backend, but exposed through the REST surface for
|
|
1316
|
-
* SDK consumers. Treat as canonical source of truth for the email content.
|
|
1317
|
-
*/
|
|
1318
|
-
zinnSource: string;
|
|
1319
|
-
ast: Record<string, unknown>;
|
|
1320
|
-
html: string;
|
|
1321
|
-
htmlPartial: string | null;
|
|
1322
|
-
text: string;
|
|
1323
|
-
markdown: string;
|
|
1324
|
-
assets: EmailAsset[];
|
|
1325
|
-
compatibility: Record<string, unknown>;
|
|
1326
|
-
warnings: string[];
|
|
1327
|
-
status: EmailStatus;
|
|
1328
|
-
agentSessionId: string | null;
|
|
1329
|
-
edits: EmailEdit[];
|
|
1330
|
-
imageJobs: ImageJob[];
|
|
1331
|
-
exports: EmailExport[];
|
|
1332
|
-
send: EmailSend;
|
|
1333
|
-
variables: EmailVariable[];
|
|
1334
|
-
firstCompileAt?: string | null;
|
|
1335
|
-
createdAt: string;
|
|
1336
|
-
updatedAt: string;
|
|
1337
|
-
}
|
|
1338
|
-
/**
|
|
1339
|
-
* Response envelope from `GET /v1/emails/:id`. Mirrors the backend
|
|
1340
|
-
* `EmailWithHistory` shape so callers don't have to make a second call to
|
|
1341
|
-
* `history()` for the most recent edit.
|
|
1342
|
-
*/
|
|
1343
|
-
interface EmailWithHistory {
|
|
1344
|
-
email: EmailDesign;
|
|
1345
|
-
history: {
|
|
1346
|
-
count: number;
|
|
1347
|
-
latest: EmailEdit | null;
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
interface EmailDesignPatch {
|
|
1351
|
-
title?: string;
|
|
1352
|
-
subject?: string;
|
|
1353
|
-
preheader?: string;
|
|
1354
|
-
zinnSource?: string;
|
|
1355
|
-
status?: EmailStatus;
|
|
1356
|
-
}
|
|
1357
|
-
interface UpdateEmailParams {
|
|
1358
|
-
/** Apply a structured patch to email fields (synchronous). */
|
|
1359
|
-
patch?: EmailDesignPatch;
|
|
1360
|
-
/**
|
|
1361
|
-
* Natural-language instruction routed to the design agent (async). Mutually
|
|
1362
|
-
* exclusive with `patch`. The SDK does NOT enforce the exclusion — pass one
|
|
1363
|
-
* or the other; passing both makes `instruction` win at the controller.
|
|
1364
|
-
*/
|
|
1365
|
-
instruction?: string;
|
|
1366
|
-
}
|
|
1367
|
-
interface EmailRevisionRef {
|
|
1368
|
-
blobId: string;
|
|
1369
|
-
by: 'user' | 'agent';
|
|
1370
|
-
summary: string;
|
|
1371
|
-
at: string;
|
|
1372
|
-
}
|
|
1373
|
-
/**
|
|
1374
|
-
* One revision returned from `GET /v1/emails/:id/history`. Carries the same
|
|
1375
|
-
* payload as `EmailEdit` for now — the backend writes both `flow_emails.edits`
|
|
1376
|
-
* (ring buffer, capped at 50) and the design-history store, and the history
|
|
1377
|
-
* endpoint reads from the latter. Defined separately so the wire shape can
|
|
1378
|
-
* diverge from `edits[]` without a SDK break.
|
|
1379
|
-
*/
|
|
1380
|
-
type EmailRevision = EmailEdit;
|
|
1381
|
-
/**
|
|
1382
|
-
* Synchronous result of `PATCH /v1/emails/:id` with a `patch` body.
|
|
1383
|
-
*/
|
|
1384
|
-
interface UpdateEmailPatchResult {
|
|
1385
|
-
mode: 'patch';
|
|
1386
|
-
email: EmailDesign;
|
|
1387
|
-
revision: EmailRevisionRef | null;
|
|
1388
|
-
}
|
|
1389
|
-
/**
|
|
1390
|
-
* Async-accepted result of `PATCH /v1/emails/:id` with an `instruction` body.
|
|
1391
|
-
* The HTTP layer returns 202 Accepted; the SDK surfaces `status: 202` in the
|
|
1392
|
-
* body for symmetry with the spec, even though the SDK does not expose raw
|
|
1393
|
-
* HTTP status codes elsewhere.
|
|
1394
|
-
*
|
|
1395
|
-
* **`sessionId` is a P2 stub.** Until the agent runtime from P2 wires up,
|
|
1396
|
-
* the controller returns `stub_p2_<emailId>_<timestamp>` instead of a real
|
|
1397
|
-
* session id. Consumers detecting `sessionId.startsWith('stub_p2_')` should
|
|
1398
|
-
* display a "pending" indicator and not open an SSE stream until P2 ships.
|
|
1399
|
-
*/
|
|
1400
|
-
interface UpdateEmailInstructionResult {
|
|
1401
|
-
mode: 'instruction';
|
|
1402
|
-
accepted: true;
|
|
1403
|
-
status: 202;
|
|
1404
|
-
sessionId: string;
|
|
1405
|
-
}
|
|
1406
|
-
type EmailUpdateResult = UpdateEmailPatchResult | UpdateEmailInstructionResult;
|
|
1407
|
-
interface CompileEmailParams {
|
|
1408
|
-
vars?: Record<string, unknown>;
|
|
1409
|
-
}
|
|
1410
|
-
interface CompileEmailWarning {
|
|
1411
|
-
code: string;
|
|
1412
|
-
line: number;
|
|
1413
|
-
message: string;
|
|
1414
|
-
}
|
|
1415
|
-
interface CompileEmailResult {
|
|
1416
|
-
html: string;
|
|
1417
|
-
ms: number;
|
|
1418
|
-
warnings: ReadonlyArray<CompileEmailWarning>;
|
|
1419
|
-
}
|
|
1420
|
-
interface DeleteEmailResponse {
|
|
1421
|
-
archived: true;
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
/**
|
|
1425
|
-
* Wraps `/v1/flows/*` — the design-v2 flow CRUD surface (P5).
|
|
1426
|
-
*
|
|
1427
|
-
* Mounted on `client.design.flows`. Internally the wire path is `/flows/...`
|
|
1428
|
-
* (the SDK's base URL already includes the `/v1` prefix).
|
|
1429
|
-
*/
|
|
1430
|
-
declare class FlowsResource {
|
|
1431
|
-
private readonly client;
|
|
1432
|
-
constructor(client: MigmaClient);
|
|
1433
|
-
/** List non-archived flows for the authenticated user. */
|
|
1434
|
-
list(params?: ListFlowsParams): Promise<MigmaResult<ListFlowsResponse>>;
|
|
1435
|
-
/** Fetch a single flow by id. */
|
|
1436
|
-
get(flowId: string): Promise<MigmaResult<Flow>>;
|
|
1437
|
-
/** Create a new flow under a project. */
|
|
1438
|
-
create(params: CreateFlowParams): Promise<MigmaResult<Flow>>;
|
|
1439
|
-
/** Patch a flow (partial fields). */
|
|
1440
|
-
update(flowId: string, patch: FlowPatch): Promise<MigmaResult<Flow>>;
|
|
1441
|
-
/**
|
|
1442
|
-
* Soft-delete a flow. The backend marks `status: 'archived'` so existing
|
|
1443
|
-
* email/history references stay resolvable.
|
|
1444
|
-
*/
|
|
1445
|
-
delete(flowId: string): Promise<MigmaResult<DeleteFlowResponse>>;
|
|
1446
|
-
/** List the emails that belong to a flow, ordered by `index` ascending. */
|
|
1447
|
-
listEmails(flowId: string): Promise<MigmaResult<EmailDesign[]>>;
|
|
1448
|
-
}
|
|
1449
|
-
|
|
1450
|
-
/**
|
|
1451
|
-
* Wraps `/v1/emails/*` — the design-v2 single-email surface (P5).
|
|
1452
|
-
*
|
|
1453
|
-
* Mounted on `client.design.emails`. Distinct from the legacy `client.emails`
|
|
1454
|
-
* resource (which targets `/projects/emails/*` for the generation flow);
|
|
1455
|
-
* design v2 owns the `/emails/:id` namespace.
|
|
1456
|
-
*/
|
|
1457
|
-
declare class EmailsResource {
|
|
1458
|
-
private readonly client;
|
|
1459
|
-
constructor(client: MigmaClient);
|
|
1460
|
-
/**
|
|
1461
|
-
* Fetch a single email plus a thin history summary (count + latest edit).
|
|
1462
|
-
* Mirrors the backend `EmailWithHistory` shape so the common UI case
|
|
1463
|
-
* (header chip showing last-edit metadata) avoids a second round trip.
|
|
1464
|
-
*/
|
|
1465
|
-
get(emailId: string): Promise<MigmaResult<EmailWithHistory>>;
|
|
1466
|
-
/**
|
|
1467
|
-
* Update an email. Two mutually exclusive modes:
|
|
1468
|
-
*
|
|
1469
|
-
* - `patch`: structured field update (title / subject / preheader /
|
|
1470
|
-
* zinnSource / status). Returns the updated email plus the recorded
|
|
1471
|
-
* revision (when `zinnSource` changed).
|
|
1472
|
-
*
|
|
1473
|
-
* - `instruction`: natural-language edit routed to the design agent.
|
|
1474
|
-
* Returns `{ mode: 'instruction', accepted: true, status: 202, sessionId }`.
|
|
1475
|
-
*
|
|
1476
|
-
* **`sessionId` is a P2 stub.** Until the agent runtime ships, the
|
|
1477
|
-
* controller returns `stub_p2_<emailId>_<timestamp>`. Consumers that
|
|
1478
|
-
* detect `sessionId.startsWith('stub_p2_')` should render a "pending"
|
|
1479
|
-
* indicator and not open an SSE stream until P2 lands. The contract
|
|
1480
|
-
* (mode/accepted/status/sessionId) will not change when P2 wires real
|
|
1481
|
-
* sessions — only the id format will.
|
|
1482
|
-
*/
|
|
1483
|
-
update(emailId: string, body: UpdateEmailParams): Promise<MigmaResult<EmailUpdateResult>>;
|
|
1484
|
-
/**
|
|
1485
|
-
* Soft-delete an email. The backend flips `status: 'failed'` so revert and
|
|
1486
|
-
* history endpoints still resolve. The response is `{ archived: true }`
|
|
1487
|
-
* for symmetry with `FlowsResource.delete`.
|
|
1488
|
-
*/
|
|
1489
|
-
delete(emailId: string): Promise<MigmaResult<DeleteEmailResponse>>;
|
|
1490
|
-
/** Compile an email's zinn source to HTML, optionally supplying merge vars. */
|
|
1491
|
-
compile(emailId: string, opts?: CompileEmailParams): Promise<MigmaResult<CompileEmailResult>>;
|
|
1492
|
-
/** List the email's full edit history (capped server-side). */
|
|
1493
|
-
history(emailId: string): Promise<MigmaResult<EmailRevision[]>>;
|
|
1494
|
-
/**
|
|
1495
|
-
* Revert an email to a prior revision. Re-compiles and returns the fresh
|
|
1496
|
-
* `CompileEmailResult`; the server also writes a new history entry tagged
|
|
1497
|
-
* "Reverted to <blobId>".
|
|
1498
|
-
*/
|
|
1499
|
-
revert(emailId: string, rev: string): Promise<MigmaResult<CompileEmailResult>>;
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
/**
|
|
1503
|
-
* Namespace wrapper exposing the design-v2 surface (P5) under `client.design`.
|
|
1504
|
-
*
|
|
1505
|
-
* Sub-resources are instantiated eagerly — same pattern as every other
|
|
1506
|
-
* resource on the `Migma` client, keeps the public surface side-effect-free
|
|
1507
|
-
* at module-load time and avoids per-call allocation.
|
|
1508
|
-
*
|
|
1509
|
-
* Naming: internally the wire path is `/v1/flows/*` (matches DB + REST), but
|
|
1510
|
-
* the user-facing SDK surface is `client.design.flows` / `client.design.emails`
|
|
1511
|
-
* so call sites read naturally for design tooling.
|
|
1512
|
-
*/
|
|
1513
|
-
declare class DesignResource {
|
|
1514
|
-
readonly flows: FlowsResource;
|
|
1515
|
-
readonly emails: EmailsResource;
|
|
1516
|
-
constructor(client: MigmaClient);
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
1258
|
interface MigmaConfig {
|
|
1520
1259
|
/** API base URL. Default: 'https://api.migma.ai/v1' */
|
|
1521
1260
|
baseUrl?: string;
|
|
@@ -1541,8 +1280,7 @@ declare class Migma {
|
|
|
1541
1280
|
readonly knowledgeBase: KnowledgeBase;
|
|
1542
1281
|
readonly images: Images;
|
|
1543
1282
|
readonly campaigns: Campaigns;
|
|
1544
|
-
readonly design: DesignResource;
|
|
1545
1283
|
constructor(apiKey: string, config?: MigmaConfig);
|
|
1546
1284
|
}
|
|
1547
1285
|
|
|
1548
|
-
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
|
|
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 };
|