sendlit 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -228,6 +228,151 @@ statuses({ skip: "pending_confirmation" }, [
228
228
  "awaiting_confirmation",
229
229
  "not_confirmed"
230
230
  ]);
231
+ var organizationRoleSchema = z.enum(["owner", "admin", "member"]);
232
+ var organizationSchema = z.object({
233
+ organizationId: z.string(),
234
+ name: z.string(),
235
+ status: z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
236
+ createdAt: z.string(),
237
+ updatedAt: z.string()
238
+ });
239
+ var organizationListItemSchema = organizationSchema.extend({
240
+ role: organizationRoleSchema
241
+ });
242
+ var organizationMemberSchema = z.object({
243
+ userId: z.string(),
244
+ email: z.string().email(),
245
+ name: z.string(),
246
+ image: z.string().nullable(),
247
+ role: organizationRoleSchema,
248
+ createdAt: z.string(),
249
+ updatedAt: z.string()
250
+ });
251
+ var createOrganizationBodySchema = z.object({
252
+ name: z.string().trim().min(1)
253
+ });
254
+ var updateOrganizationBodySchema = z.object({
255
+ name: z.string().trim().min(1)
256
+ });
257
+ var addOrganizationMemberBodySchema = z.object({
258
+ /** Existing Better Auth user only. This is a membership lookup, never an
259
+ * authentication or account-creation flow. */
260
+ email: z.string().trim().email(),
261
+ role: organizationRoleSchema
262
+ });
263
+ var updateOrganizationMemberBodySchema = z.object({
264
+ role: organizationRoleSchema
265
+ });
266
+ var organizationKeyScopes = [
267
+ "organization:read",
268
+ "delivery:read",
269
+ "delivery:manage",
270
+ "teams:provision",
271
+ "teams:read",
272
+ "teams:manage",
273
+ "teams:keys",
274
+ "esps:read",
275
+ "esps:manage",
276
+ "grants:manage",
277
+ "usage:read"
278
+ ];
279
+ var organizationApiKeySchema = z.object({
280
+ keyId: z.string(),
281
+ name: z.string(),
282
+ keyPrefix: z.string(),
283
+ scopes: z.array(z.enum(organizationKeyScopes)),
284
+ expiresAt: z.string().nullable(),
285
+ lastUsedAt: z.string().nullable(),
286
+ revokedAt: z.string().nullable(),
287
+ createdAt: z.string()
288
+ });
289
+ var createOrganizationApiKeyBodySchema = z.object({
290
+ name: z.string().trim().min(1),
291
+ scopes: z.array(z.enum(organizationKeyScopes)).min(1),
292
+ expiresAt: z.string().datetime().nullable().optional()
293
+ });
294
+ var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
295
+ key: z.string()
296
+ });
297
+ var organizationUsageWindowSchema = z.object({
298
+ limit: z.number().int().nullable(),
299
+ accepted: z.number().int().nonnegative(),
300
+ reserved: z.number().int().nonnegative(),
301
+ remaining: z.number().int().nullable(),
302
+ resetsAt: z.string()
303
+ });
304
+ var organizationUsageSchema = z.object({
305
+ day: organizationUsageWindowSchema,
306
+ month: organizationUsageWindowSchema
307
+ });
308
+ var organizationMailActivityQuerySchema = z.object({
309
+ rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
310
+ });
311
+ var organizationMailCountsSchema = z.object({
312
+ sent: z.number().int().nonnegative(),
313
+ queued: z.number().int().nonnegative(),
314
+ failed: z.number().int().nonnegative(),
315
+ bounced: z.number().int().nonnegative()
316
+ });
317
+ var organizationMailActivityTeamSchema = z.object({
318
+ teamId: z.string(),
319
+ name: z.string(),
320
+ status: z.enum(["active", "sending_suspended", "archived"]),
321
+ externalId: z.string().nullable(),
322
+ mail: organizationMailCountsSchema
323
+ });
324
+ var organizationMailActivitySchema = z.object({
325
+ rangeDays: z.union([z.literal(1), z.literal(3), z.literal(7), z.literal(30)]),
326
+ totals: organizationMailCountsSchema,
327
+ teams: z.array(organizationMailActivityTeamSchema)
328
+ });
329
+ var organizationEnterTeamBodySchema = z.object({});
330
+ var organizationEnterTeamResponseSchema = z.object({
331
+ teamId: z.string(),
332
+ role: z.enum(["admin", "member"]),
333
+ created: z.boolean()
334
+ });
335
+ var organizationAuditEventSchema = z.object({
336
+ action: z.string(),
337
+ actorType: z.enum(["user", "organization_key", "team_key", "system"]),
338
+ teamId: z.string().nullable(),
339
+ espId: z.string().nullable(),
340
+ grantId: z.string().nullable(),
341
+ metadata: z.record(z.any()),
342
+ createdAt: z.string()
343
+ });
344
+
345
+ // ../api-contract/src/schemas/account.ts
346
+ var accountDeletionBlockerSchema = z.enum([
347
+ "active_subscription_exists",
348
+ "billing_checkout_pending",
349
+ "last_organization_owner",
350
+ "billing_manager_required"
351
+ ]);
352
+ var accountDeletionOrganizationSchema = z.object({
353
+ organizationId: z.string(),
354
+ name: z.string(),
355
+ status: z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
356
+ role: organizationRoleSchema,
357
+ /** `delete`: they are its last owner, so it is deleted with its contacts'
358
+ * data. `leave`: someone else stays in charge; only their membership goes. */
359
+ action: z.enum(["delete", "leave"]),
360
+ teamCount: z.number().int(),
361
+ /** What has to happen before the account can be deleted, if anything. */
362
+ blocker: accountDeletionBlockerSchema.nullable()
363
+ });
364
+ var accountDeletionPreviewSchema = z.object({
365
+ email: z.string(),
366
+ organizations: z.array(accountDeletionOrganizationSchema),
367
+ blocked: z.boolean()
368
+ });
369
+ var deleteAccountBodySchema = z.object({
370
+ /** The account's email, typed to confirm. */
371
+ email: z.string().trim().min(1),
372
+ /** The code sent by `POST /account/deletion/code`. */
373
+ code: z.string().trim().min(1)
374
+ });
375
+ var accountDeletionBlockedSchema = accountDeletionPreviewSchema.omit({ email: true }).extend({ error: z.literal("account_deletion_blocked") });
231
376
  var paidPlans = ["starter", "pro", "business"];
232
377
  var billingPlans = ["oss", "free", ...paidPlans];
233
378
  var billingCatalogKeys = paidPlans.flatMap(
@@ -460,6 +605,50 @@ var emailBlockInputSchema = z.discriminatedUnion("blockType", [
460
605
  settings: z.object({ src: z.string().min(1) }).passthrough()
461
606
  }),
462
607
  blockBaseSchema.extend({ blockType: z.literal("separator") }),
608
+ blockBaseSchema.extend({
609
+ blockType: z.literal("spacer"),
610
+ settings: z.object({ height: pixelSchema.optional() }).passthrough()
611
+ }),
612
+ blockBaseSchema.extend({
613
+ blockType: z.literal("columns"),
614
+ settings: z.object({
615
+ left: z.string(),
616
+ right: z.string(),
617
+ ratio: z.enum(["11", "12", "21"]).optional(),
618
+ stack: z.boolean().optional()
619
+ }).passthrough()
620
+ }),
621
+ blockBaseSchema.extend({
622
+ blockType: z.literal("social"),
623
+ settings: z.object({
624
+ links: z.array(
625
+ z.object({
626
+ network: z.enum([
627
+ "website",
628
+ "instagram",
629
+ "linkedin",
630
+ "youtube",
631
+ "x",
632
+ "facebook",
633
+ "tiktok"
634
+ ]),
635
+ url: z.string().regex(/^(?:https?:\/\/\S+)?$/i, "Expected an http(s) URL")
636
+ })
637
+ )
638
+ }).passthrough()
639
+ }),
640
+ blockBaseSchema.extend({
641
+ blockType: z.literal("html"),
642
+ settings: z.object({ code: z.string() }).passthrough()
643
+ }),
644
+ blockBaseSchema.extend({
645
+ blockType: z.literal("conditional"),
646
+ settings: z.object({
647
+ tag: z.string().regex(/^[A-Za-z0-9][A-Za-z0-9 _.-]{0,39}$/, "Expected a plain tag name"),
648
+ has: z.boolean().optional(),
649
+ content: z.string()
650
+ }).passthrough()
651
+ }),
463
652
  blockBaseSchema.extend({ blockType: z.literal("footer") })
464
653
  ]);
465
654
  var emailMetaInputSchema = z.object({
@@ -802,6 +991,15 @@ var sequenceEmailSchema = z.object({
802
991
  /** Hosted content check: `clean`, `review` (held for SendLit's review),
803
992
  * `blocked`, or `approved` after review; `null` when not scanned. */
804
993
  contentScanVerdict: z.string().nullable().optional(),
994
+ /** Unpublished edits saved while the broadcast or sequence is active. `subject` and
995
+ * `content` above are the published version that sends use. */
996
+ draft: z.object({
997
+ subject: z.string(),
998
+ content: emailContentSchema,
999
+ updatedAt: z.string().nullable()
1000
+ }).nullable().optional(),
1001
+ /** Whether `draft` holds changes that aren't published yet. */
1002
+ hasUnpublishedChanges: z.boolean().optional(),
805
1003
  createdAt: z.string().nullable(),
806
1004
  updatedAt: z.string().nullable()
807
1005
  });
@@ -898,9 +1096,13 @@ var sequenceSchema = z.object({
898
1096
  /** Whether sends link a hosted web version ("View in browser"). On for
899
1097
  * new broadcasts, off for new sequences. */
900
1098
  viewInBrowser: z.boolean(),
1099
+ /** When a sent broadcast was archived; `null` when it isn't. */
1100
+ archivedAt: z.string().nullable().optional(),
901
1101
  createdAt: z.string().nullable(),
902
1102
  updatedAt: z.string().nullable(),
903
1103
  emails: z.array(sequenceEmailSchema),
1104
+ /** Whether any of its emails has unpublished changes. */
1105
+ hasUnpublishedChanges: z.boolean().optional(),
904
1106
  /** Set while a running broadcast of a new hosted organization is sent
905
1107
  * gradually (`get` only). */
906
1108
  pacing: z.object({
@@ -911,8 +1113,12 @@ var sequenceSchema = z.object({
911
1113
  estimatedCompletionAt: z.string()
912
1114
  }).nullable().optional()
913
1115
  });
1116
+ var archivedFilters = ["exclude", "only", "include"];
914
1117
  var listSequencesQuerySchema = z.object({
915
1118
  type: z.enum(mailTypes),
1119
+ archived: z.enum(archivedFilters).optional().describe(
1120
+ "Archived broadcasts: exclude (default) hides them, only lists just them, include lists both"
1121
+ ),
916
1122
  offset: z.coerce.number().int().min(1).optional(),
917
1123
  itemsPerPage: z.coerce.number().int().min(1).max(50).optional()
918
1124
  });
@@ -961,6 +1167,24 @@ var updateSequenceEmailBodySchema = z.object({
961
1167
  actionData: z.record(z.any()).optional(),
962
1168
  published: z.boolean().optional()
963
1169
  });
1170
+ var publishScopes = ["in_flight", "new_entrants"];
1171
+ var emailIdsSchema = z.array(z.string()).min(1).optional().describe("The emails to act on; omit for every email with unpublished changes");
1172
+ var publishSequenceChangesBodySchema = z.object({
1173
+ emailIds: emailIdsSchema,
1174
+ scope: z.enum(publishScopes).optional().describe(
1175
+ "Sequences only. in_flight (default): contacts already in the sequence get the new version at their next step. new_entrants: they keep the version they entered with; only contacts who enter from now on get the new one."
1176
+ )
1177
+ });
1178
+ var discardSequenceChangesBodySchema = z.object({
1179
+ emailIds: emailIdsSchema
1180
+ });
1181
+ var sequenceEmailVersionSchema = z.object({
1182
+ versionId: z.string(),
1183
+ subject: z.string(),
1184
+ content: emailContentSchema,
1185
+ publishedAt: z.string().describe("When this version last went live"),
1186
+ live: z.boolean().describe("Whether sends use this version now")
1187
+ });
964
1188
  var sendSequenceEmailTestBodySchema = z.object({
965
1189
  to: z.array(z.string().email()).max(5).optional().describe(
966
1190
  "Up to 5 addresses. Defaults to the signed-in user's address; API keys must set it."
@@ -983,6 +1207,42 @@ var sequenceStatsSchema = z.object({
983
1207
  bounceRate: z.number().optional(),
984
1208
  complaintRate: z.number().optional()
985
1209
  });
1210
+ var sequenceScheduleSchema = z.object({
1211
+ waiting: z.number().describe("Contacts in the sequence who are waiting for their next email"),
1212
+ emails: z.array(
1213
+ z.object({
1214
+ emailId: z.string(),
1215
+ waiting: z.number().describe("Contacts whose next email is this one"),
1216
+ nextSendAt: z.number().nullable().describe(
1217
+ "The earliest due time among them (epoch millis), not a time they share: each contact's delay counts from their own entry. null when no one is waiting"
1218
+ )
1219
+ })
1220
+ )
1221
+ });
1222
+ var waitingContactSchema = z.object({
1223
+ contactId: z.string(),
1224
+ email: z.string(),
1225
+ name: z.string().nullable(),
1226
+ nextSendAt: z.number().describe("When this contact is due to get the email (epoch millis)")
1227
+ });
1228
+ var listWaitingContactsQuerySchema = z.object({
1229
+ after: z.string().optional().describe("The previous page's `nextCursor`; omit for the first page"),
1230
+ limit: z.coerce.number().int().min(1).max(100).optional(),
1231
+ q: z.string().optional().describe("Matches the contact's email or name")
1232
+ });
1233
+ var waitingContactsPageSchema = z.object({
1234
+ items: z.array(waitingContactSchema),
1235
+ total: z.number().describe("Every waiting contact that matches, across all pages"),
1236
+ nextCursor: z.string().nullable().describe("Pass as `after` for the next page; null on the last page")
1237
+ });
1238
+ var sequenceDeletionPreviewSchema = z.object({
1239
+ status: z.string().describe("The broadcast or sequence's current status"),
1240
+ blocker: z.enum(["sequence_active", "broadcast_sent"]).nullable().describe(
1241
+ "Why it can't be deleted right now (sequence_active: pause it first; broadcast_sent: archive the broadcast instead), or null when it can"
1242
+ ),
1243
+ enrolledCount: z.number().int().describe("Contacts currently in the sequence; deleting it stops their emails"),
1244
+ emailsSentCount: z.number().int().describe("Emails it has sent; their delivery, open and click history is deleted")
1245
+ });
986
1246
  var listSubscribersQuerySchema = z.object({
987
1247
  page: z.coerce.number().int().min(1).optional(),
988
1248
  limit: z.coerce.number().int().min(1).optional()
@@ -1080,6 +1340,46 @@ var exportContactsQuerySchema = z.object({
1080
1340
  segmentId: z.string().optional().describe("Only export this saved segment"),
1081
1341
  filter: z.string().optional().describe("Serialized ContactFilterWithAggregator JSON; combines with segmentId")
1082
1342
  });
1343
+ var contactSelectionObjectSchema = z.object({
1344
+ contactIds: z.array(z.string().min(1)).min(1).max(1e3).optional().describe("Contact IDs, up to 1000. Unknown IDs are ignored."),
1345
+ match: z.object({
1346
+ q: z.string().optional().describe("Search term matched against email or name"),
1347
+ segmentId: z.string().optional().describe("Only contacts in this saved segment"),
1348
+ filter: contactFilterSchema.optional().describe("Inline ContactFilterWithAggregator; combines with q and segmentId")
1349
+ }).optional().describe(
1350
+ "Every contact matching q, segmentId and filter (AND). `{}` selects every contact in the team."
1351
+ )
1352
+ });
1353
+ var exactlyOneSelection = (body) => Boolean(body.contactIds) !== Boolean(body.match);
1354
+ var exactlyOneSelectionMessage = {
1355
+ message: "Pass exactly one of contactIds or match"
1356
+ };
1357
+ var contactSelectionSchema = contactSelectionObjectSchema.refine(
1358
+ exactlyOneSelection,
1359
+ exactlyOneSelectionMessage
1360
+ );
1361
+ var previewContactDeletionResultSchema = z.object({
1362
+ count: z.number().int().describe("Contacts that would be deleted right now"),
1363
+ unsubscribed: z.number().int().describe(
1364
+ "How many of them are unsubscribed; their addresses are added to the suppression list"
1365
+ )
1366
+ });
1367
+ var deleteContactsObjectSchema = contactSelectionObjectSchema.extend({
1368
+ expectedCount: z.number().int().min(0).optional().describe(
1369
+ "The count from the preview. Required with match: if the live count differs, nothing is deleted and the response is 409 count_changed."
1370
+ )
1371
+ });
1372
+ var deleteContactsBodySchema = deleteContactsObjectSchema.refine(exactlyOneSelection, exactlyOneSelectionMessage).refine((body) => !body.match || body.expectedCount !== void 0, {
1373
+ message: "expectedCount is required with match",
1374
+ path: ["expectedCount"]
1375
+ });
1376
+ var contactDeletionSchema = z.object({
1377
+ deletionId: z.string().nullable().describe("Background job id for large deletions; null when it ran inline"),
1378
+ status: z.enum(["queued", "running", "completed", "failed"]),
1379
+ count: z.number().int().describe("Contacts selected for deletion"),
1380
+ deleted: z.number().int().describe("Contacts deleted so far"),
1381
+ suppressed: z.number().int().describe("Unsubscribed addresses newly added to the suppression list")
1382
+ });
1083
1383
  var deliveryEventType = [
1084
1384
  "accepted",
1085
1385
  "delivered",
@@ -1299,6 +1599,14 @@ var testFeedbackConnectionResponseSchema = z.object({
1299
1599
  success: z.boolean(),
1300
1600
  error: z.string().optional()
1301
1601
  });
1602
+ var feedbackRequirementSchema = z.object({
1603
+ /** False on self-hosted SendLit, where the rule doesn't apply. */
1604
+ required: z.boolean(),
1605
+ /** Emails the organization can send before the rule applies. */
1606
+ requiredAfterSends: z.number().int(),
1607
+ /** Emails the organization has sent so far, across all its teams. */
1608
+ sentSoFar: z.number().int()
1609
+ });
1302
1610
  var signupFormSchema = z.object({
1303
1611
  formId: z.string(),
1304
1612
  name: z.string(),
@@ -1341,7 +1649,7 @@ var mediaSchema = z.object({
1341
1649
  updatedAt: z.string().or(z.date()).nullable().optional()
1342
1650
  });
1343
1651
  var mediaReferenceSchema = z.object({
1344
- resourceType: z.enum(["TEMPLATE", "SEQUENCE_EMAIL"]),
1652
+ resourceType: z.enum(["TEMPLATE", "SEQUENCE_EMAIL", "BROADCAST_WEB_PAGE"]),
1345
1653
  resourcePublicId: z.string(),
1346
1654
  parentResourcePublicId: z.string().nullable().optional(),
1347
1655
  createdAt: z.string().or(z.date()).nullable().optional(),
@@ -1360,116 +1668,6 @@ var mediaUploadSignatureSchema = z.object({
1360
1668
  signature: z.string(),
1361
1669
  endpoint: z.string()
1362
1670
  });
1363
- var organizationRoleSchema = z.enum(["owner", "admin", "member"]);
1364
- var organizationSchema = z.object({
1365
- organizationId: z.string(),
1366
- name: z.string(),
1367
- status: z.enum(["pending_payment", "active", "suspended", "abandoned", "closed"]),
1368
- createdAt: z.string(),
1369
- updatedAt: z.string()
1370
- });
1371
- var organizationMemberSchema = z.object({
1372
- userId: z.string(),
1373
- email: z.string().email(),
1374
- name: z.string(),
1375
- image: z.string().nullable(),
1376
- role: organizationRoleSchema,
1377
- createdAt: z.string(),
1378
- updatedAt: z.string()
1379
- });
1380
- var createOrganizationBodySchema = z.object({
1381
- name: z.string().trim().min(1)
1382
- });
1383
- var updateOrganizationBodySchema = z.object({
1384
- name: z.string().trim().min(1)
1385
- });
1386
- var addOrganizationMemberBodySchema = z.object({
1387
- /** Existing Better Auth user only. This is a membership lookup, never an
1388
- * authentication or account-creation flow. */
1389
- email: z.string().trim().email(),
1390
- role: organizationRoleSchema
1391
- });
1392
- var updateOrganizationMemberBodySchema = z.object({
1393
- role: organizationRoleSchema
1394
- });
1395
- var organizationKeyScopes = [
1396
- "organization:read",
1397
- "delivery:read",
1398
- "delivery:manage",
1399
- "teams:provision",
1400
- "teams:read",
1401
- "teams:manage",
1402
- "teams:keys",
1403
- "esps:read",
1404
- "esps:manage",
1405
- "grants:manage",
1406
- "usage:read"
1407
- ];
1408
- var organizationApiKeySchema = z.object({
1409
- keyId: z.string(),
1410
- name: z.string(),
1411
- keyPrefix: z.string(),
1412
- scopes: z.array(z.enum(organizationKeyScopes)),
1413
- expiresAt: z.string().nullable(),
1414
- lastUsedAt: z.string().nullable(),
1415
- revokedAt: z.string().nullable(),
1416
- createdAt: z.string()
1417
- });
1418
- var createOrganizationApiKeyBodySchema = z.object({
1419
- name: z.string().trim().min(1),
1420
- scopes: z.array(z.enum(organizationKeyScopes)).min(1),
1421
- expiresAt: z.string().datetime().nullable().optional()
1422
- });
1423
- var createdOrganizationApiKeySchema = organizationApiKeySchema.extend({
1424
- key: z.string()
1425
- });
1426
- var organizationUsageWindowSchema = z.object({
1427
- limit: z.number().int().nullable(),
1428
- accepted: z.number().int().nonnegative(),
1429
- reserved: z.number().int().nonnegative(),
1430
- remaining: z.number().int().nullable(),
1431
- resetsAt: z.string()
1432
- });
1433
- var organizationUsageSchema = z.object({
1434
- day: organizationUsageWindowSchema,
1435
- month: organizationUsageWindowSchema
1436
- });
1437
- var organizationMailActivityQuerySchema = z.object({
1438
- rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
1439
- });
1440
- var organizationMailCountsSchema = z.object({
1441
- sent: z.number().int().nonnegative(),
1442
- queued: z.number().int().nonnegative(),
1443
- failed: z.number().int().nonnegative(),
1444
- bounced: z.number().int().nonnegative()
1445
- });
1446
- var organizationMailActivityTeamSchema = z.object({
1447
- teamId: z.string(),
1448
- name: z.string(),
1449
- status: z.enum(["active", "sending_suspended", "archived"]),
1450
- externalId: z.string().nullable(),
1451
- mail: organizationMailCountsSchema
1452
- });
1453
- var organizationMailActivitySchema = z.object({
1454
- rangeDays: z.union([z.literal(1), z.literal(3), z.literal(7), z.literal(30)]),
1455
- totals: organizationMailCountsSchema,
1456
- teams: z.array(organizationMailActivityTeamSchema)
1457
- });
1458
- var organizationEnterTeamBodySchema = z.object({});
1459
- var organizationEnterTeamResponseSchema = z.object({
1460
- teamId: z.string(),
1461
- role: z.enum(["admin", "member"]),
1462
- created: z.boolean()
1463
- });
1464
- var organizationAuditEventSchema = z.object({
1465
- action: z.string(),
1466
- actorType: z.enum(["user", "organization_key", "team_key", "system"]),
1467
- teamId: z.string().nullable(),
1468
- espId: z.string().nullable(),
1469
- grantId: z.string().nullable(),
1470
- metadata: z.record(z.any()),
1471
- createdAt: z.string()
1472
- });
1473
1671
  var overviewQuerySchema = z.object({
1474
1672
  /** Delivery activity window, in days. Defaults to the last 7 days. */
1475
1673
  rangeDays: z.coerce.number().int().refine((value) => [1, 3, 7, 30].includes(value)).optional()
@@ -1632,6 +1830,47 @@ var createSuppressionBodySchema = z.object({
1632
1830
  "Why the address is blocked, e.g. a legal request; kept in the audit trail"
1633
1831
  )
1634
1832
  });
1833
+ var tagSummarySchema = z.object({
1834
+ tag: z.string(),
1835
+ contactCount: z.number().int()
1836
+ });
1837
+ var tagSequenceUsageSchema = z.enum([
1838
+ "filter",
1839
+ "exclude_filter",
1840
+ "trigger",
1841
+ "email_action"
1842
+ ]);
1843
+ var tagReferencesSchema = z.object({
1844
+ tag: z.string(),
1845
+ contactCount: z.number().int(),
1846
+ segments: z.array(z.object({ segmentId: z.string(), name: z.string() })),
1847
+ sequences: z.array(
1848
+ z.object({
1849
+ sequenceId: z.string(),
1850
+ title: z.string(),
1851
+ type: z.enum(["broadcast", "sequence"]),
1852
+ status: z.string(),
1853
+ usages: z.array(tagSequenceUsageSchema)
1854
+ })
1855
+ ),
1856
+ signupForms: z.array(z.object({ formId: z.string(), name: z.string() }))
1857
+ });
1858
+ var renameTagBodySchema = z.object({
1859
+ name: z.string().trim().min(1).describe("The tag's new name")
1860
+ });
1861
+ var renameTagResultSchema = z.object({
1862
+ tag: z.string(),
1863
+ previousTag: z.string(),
1864
+ contactsUpdated: z.number().int(),
1865
+ segmentsUpdated: z.number().int(),
1866
+ sequencesUpdated: z.number().int(),
1867
+ signupFormsUpdated: z.number().int()
1868
+ });
1869
+ var deleteTagResultSchema = z.object({
1870
+ tag: z.string(),
1871
+ contactsUpdated: z.number().int(),
1872
+ references: tagReferencesSchema
1873
+ });
1635
1874
  var teamSchema = z.object({
1636
1875
  teamId: z.string(),
1637
1876
  /** Public organization identifier. Present when an end user lists the
@@ -1823,6 +2062,16 @@ var transactionalEmailDetailSchema = transactionalEmailSchema.extend({
1823
2062
  /** Caller-supplied plain text; `null` when it was generated from `html`. */
1824
2063
  text: z.string().nullable().optional()
1825
2064
  });
2065
+ var MAX_SENDER_NAME_LENGTH = 100;
2066
+ function isValidSenderName(name) {
2067
+ const trimmed = name.trim();
2068
+ return trimmed.length > 0 && trimmed.length <= MAX_SENDER_NAME_LENGTH && !/[\p{Cc}\p{Cf}<>@]/u.test(trimmed);
2069
+ }
2070
+ var senderNameSchema = z.string().refine(isValidSenderName, {
2071
+ message: `1-${MAX_SENDER_NAME_LENGTH} characters, without control or invisible formatting characters, <, > or @`
2072
+ }).describe(
2073
+ "The From name for this email, instead of the delivery source's. The address stays the delivery source's."
2074
+ );
1826
2075
  var reservedHeaders = ["from", "to", "subject", "content-type"];
1827
2076
  var emailHeadersSchema = z.record(z.string()).superRefine((headers2, ctx) => {
1828
2077
  for (const [name, value] of Object.entries(headers2)) {
@@ -1848,6 +2097,7 @@ var sendEmailBodySchema = z.object({
1848
2097
  "Plain-text part, sent verbatim. When omitted it is generated from the HTML."
1849
2098
  ),
1850
2099
  variables: z.record(z.any()).optional(),
2100
+ fromName: senderNameSchema.optional(),
1851
2101
  replyTo: z.string().email().optional(),
1852
2102
  headers: emailHeadersSchema.optional(),
1853
2103
  idempotencyKey: z.string().min(1).max(256).optional(),
@@ -1885,7 +2135,7 @@ var webPublishingSchema = z.object({
1885
2135
  ogImage: z.string().nullable(),
1886
2136
  noindex: z.boolean(),
1887
2137
  canonicalUrl: z.string().nullable(),
1888
- /** Published and already sent, so the page is public. */
2138
+ /** Published, already sent and not archived, so the page is public. */
1889
2139
  live: z.boolean(),
1890
2140
  /** When the issue was sent; `null` until then. */
1891
2141
  publishedAt: z.string().nullable(),
@@ -1897,7 +2147,9 @@ var updateWebPublishingBodySchema = z.object({
1897
2147
  slug: webSlugSchema.optional().describe("URL slug; defaults to one made from the title"),
1898
2148
  seoTitle: z.string().trim().max(200).nullable().optional(),
1899
2149
  seoDescription: z.string().trim().max(500).nullable().optional(),
1900
- ogImage: httpUrl.nullable().optional().describe("Image for social previews"),
2150
+ ogImage: httpUrl.nullable().optional().describe(
2151
+ "Image for social previews. An image uploaded to MediaLit is added to the media library and can't be deleted while the page uses it"
2152
+ ),
1901
2153
  noindex: z.boolean().optional().describe("Ask search engines not to index the page"),
1902
2154
  canonicalUrl: httpUrl.nullable().optional().describe("Canonical URL, when a platform hosts the issue on its own site")
1903
2155
  });
@@ -1991,6 +2243,39 @@ var contactsContract = c.router(
1991
2243
  summary: "Export contacts as CSV",
1992
2244
  description: "Returns every contact, or those matching segmentId and/or filter, as CSV: email, name, status (subscribed, unsubscribed, bounced or complained), tags, created_at, suppression_reason, then one column per custom field."
1993
2245
  },
2246
+ previewBulkDelete: {
2247
+ method: "POST",
2248
+ path: "/contacts/bulk-delete/preview",
2249
+ body: contactSelectionSchema,
2250
+ responses: {
2251
+ 200: previewContactDeletionResultSchema,
2252
+ 400: errorSchema,
2253
+ 404: errorSchema
2254
+ },
2255
+ summary: "Preview a bulk contact deletion",
2256
+ description: "Counts the contacts a bulk delete would remove (and how many are unsubscribed) without deleting anything. Pass the count to bulkDelete as expectedCount. 404 when segmentId doesn't exist."
2257
+ },
2258
+ bulkDelete: {
2259
+ method: "POST",
2260
+ path: "/contacts/bulk-delete",
2261
+ body: deleteContactsBodySchema,
2262
+ responses: {
2263
+ 200: contactDeletionSchema,
2264
+ 202: contactDeletionSchema,
2265
+ 400: errorSchema,
2266
+ 404: errorSchema,
2267
+ 409: errorSchema.extend({ count: z.number().int().optional() })
2268
+ },
2269
+ summary: "Delete contacts in bulk",
2270
+ description: "Permanently deletes up to 1000 contacts by id, or every contact matching q, segmentId and filter. With match, pass the preview's count as expectedCount; if the live count differs nothing is deleted (409 count_changed, with the new count). Only contacts that existed when the request arrived are deleted. Up to 1000 contacts are deleted before the response (200, status completed); larger selections run in the background (202, status queued) and report progress at GET /contacts/bulk-delete/{deletionId}. Each contact's custom field values, sequence progress, events and delivery records are deleted with it, and no sequence triggers fire. Suppressions are kept, and the address of every deleted unsubscribed contact is added to the suppression list (reason manual), so re-importing or re-adding it never mails it again. This is not a full privacy erasure: delivery logs and the suppression list keep the address."
2271
+ },
2272
+ bulkDeleteStatus: {
2273
+ method: "GET",
2274
+ path: "/contacts/bulk-delete/:deletionId",
2275
+ responses: { 200: contactDeletionSchema, 404: errorSchema },
2276
+ summary: "Get a bulk contact deletion",
2277
+ description: "Progress of a background bulk delete. Finished deletions are kept for 24 hours."
2278
+ },
1994
2279
  get: {
1995
2280
  method: "GET",
1996
2281
  path: "/contacts/:contactId",
@@ -2048,6 +2333,45 @@ var contactsContract = c.router(
2048
2333
  },
2049
2334
  { metadata: { tag: "Contacts" } }
2050
2335
  );
2336
+ var tagsContract = c.router(
2337
+ {
2338
+ list: {
2339
+ method: "GET",
2340
+ path: "/tags",
2341
+ responses: { 200: itemsList(tagSummarySchema) },
2342
+ summary: "List tags",
2343
+ description: "Returns every tag carried by at least one of the team's contacts, sorted by name, with the number of contacts that carry it."
2344
+ },
2345
+ references: {
2346
+ method: "GET",
2347
+ path: "/tags/:tag/references",
2348
+ responses: { 200: tagReferencesSchema },
2349
+ summary: "List where a tag is used",
2350
+ description: "Returns how many contacts carry the tag and the segments, broadcasts, sequences (audience filters, tag triggers, email tag actions) and signup forms that name it. Call it before deleting a tag."
2351
+ },
2352
+ rename: {
2353
+ method: "PATCH",
2354
+ path: "/tags/:tag",
2355
+ body: renameTagBodySchema,
2356
+ responses: {
2357
+ 200: renameTagResultSchema,
2358
+ 400: errorSchema,
2359
+ 404: errorSchema
2360
+ },
2361
+ summary: "Rename a tag",
2362
+ description: "Renames the tag on every contact, and in segments, broadcast and sequence filters and tag triggers, sequence email tag actions and signup forms. Renaming to a tag that already exists merges the two. Sent broadcasts keep their original filters. Renaming doesn't trigger tag-added or tag-removed sequences. 404 `tag_not_found` when nothing uses the tag; 400 `tag_unchanged` when the new name is the same."
2363
+ },
2364
+ remove: {
2365
+ method: "DELETE",
2366
+ path: "/tags/:tag",
2367
+ body: c.noBody(),
2368
+ responses: { 200: deleteTagResultSchema, 404: errorSchema },
2369
+ summary: "Delete a tag from every contact",
2370
+ description: "Removes the tag from every contact of the team. Segments, filters, triggers, email actions and signup forms that name the tag are left as they are and returned in `references`: a filter on a deleted tag matches nobody, and a trigger or form can add it again. Check `GET /tags/:tag/references` first. Deleting doesn't trigger tag-removed sequences. 404 `tag_not_found` when nothing uses the tag."
2371
+ }
2372
+ },
2373
+ { metadata: { tag: "Tags" } }
2374
+ );
2051
2375
  var segmentsContract = c.router(
2052
2376
  {
2053
2377
  create: {
@@ -2213,7 +2537,8 @@ var templatesContract = c.router(
2213
2537
  method: "DELETE",
2214
2538
  path: "/templates/:templateId",
2215
2539
  responses: { 204: c.noBody() },
2216
- summary: "Delete an email template"
2540
+ summary: "Delete an email template",
2541
+ description: "Permanently deletes the template. Its images that no other template or email uses are deleted from the media library and storage, unless a transactional email was sent with the template."
2217
2542
  }
2218
2543
  },
2219
2544
  { metadata: { tag: "Templates" } }
@@ -2237,7 +2562,8 @@ var sequencesContract = c.router(
2237
2562
  path: "/sequences",
2238
2563
  query: listSequencesQuerySchema,
2239
2564
  responses: { 200: paginated(sequenceSchema) },
2240
- summary: "List broadcasts or sequences"
2565
+ summary: "List broadcasts or sequences",
2566
+ description: "Archived broadcasts are left out unless `archived` is `only` or `include`."
2241
2567
  },
2242
2568
  get: {
2243
2569
  method: "GET",
@@ -2255,13 +2581,37 @@ var sequencesContract = c.router(
2255
2581
  404: errorSchema
2256
2582
  },
2257
2583
  summary: "Update a broadcast or sequence",
2258
- description: "A broadcast's title is its email's subject, so once the broadcast has been sent, changing the title returns 400 with the error \"This broadcast has already been sent\". `viewInBrowser` can be changed at any time; turning it off also takes down the web versions linked from emails already sent."
2584
+ description: "A broadcast's title is its email's published subject. While it's scheduled, a new title is saved as the email's draft subject (see `draft`) and becomes the title when the changes are published. Once the broadcast has been sent, changing the title returns 400 with the error \"This broadcast has already been sent\". `viewInBrowser` can be changed at any time; turning it off also takes down the web versions linked from emails already sent."
2259
2585
  },
2260
2586
  remove: {
2261
2587
  method: "DELETE",
2262
2588
  path: "/sequences/:sequenceId",
2263
- responses: { 204: c.noBody(), 404: errorSchema },
2264
- summary: "Delete a broadcast or sequence"
2589
+ responses: { 204: c.noBody(), 404: errorSchema, 409: errorSchema },
2590
+ summary: "Delete a broadcast or sequence",
2591
+ description: "Permanently deletes the broadcast or sequence, its emails and triggers. An active sequence or a sending broadcast can't be deleted: pause it first (409 `sequence_active`). A draft or scheduled broadcast can be deleted; one that has started sending can't (409 `broadcast_sent`): archive it instead with POST /sequences/{sequenceId}/archive. Contacts still enrolled in a paused sequence leave it, and its delivery, open and click history is deleted too, so its stats are gone; check GET /sequences/{sequenceId}/deletion-preview first. The outbound message log and suppressions are kept. Images it uses that nothing else uses are deleted from the media library and storage; images used by sent mail are kept."
2592
+ },
2593
+ deletionPreview: {
2594
+ method: "GET",
2595
+ path: "/sequences/:sequenceId/deletion-preview",
2596
+ responses: { 200: sequenceDeletionPreviewSchema, 404: errorSchema },
2597
+ summary: "Preview what deleting a broadcast or sequence removes",
2598
+ description: "How many contacts are enrolled and how many emails it has sent, and whether it can be deleted right now. Nothing is changed."
2599
+ },
2600
+ archive: {
2601
+ method: "POST",
2602
+ path: "/sequences/:sequenceId/archive",
2603
+ body: c.noBody(),
2604
+ responses: { 200: sequenceSchema, 404: errorSchema, 409: errorSchema },
2605
+ summary: "Archive a sent broadcast",
2606
+ description: 'Hides a sent broadcast from the broadcasts list (see `archived` on GET /sequences) and from the public web archive, its feed and sitemap. Its report, delivery history and images are kept, and recipients\' "view in browser" links keep working. 409 `broadcast_not_sent` for a draft or scheduled broadcast (delete it instead) and `sequence_active` while it is sending. Archiving an archived broadcast changes nothing. 404 for sequences.'
2607
+ },
2608
+ unarchive: {
2609
+ method: "POST",
2610
+ path: "/sequences/:sequenceId/unarchive",
2611
+ body: c.noBody(),
2612
+ responses: { 200: sequenceSchema, 404: errorSchema },
2613
+ summary: "Restore an archived broadcast",
2614
+ description: "Puts an archived broadcast back in the broadcasts list, and back on the web archive when it is published there."
2265
2615
  },
2266
2616
  addEmail: {
2267
2617
  method: "POST",
@@ -2287,7 +2637,50 @@ var sequencesContract = c.router(
2287
2637
  422: templateNotMarketingErrorSchema
2288
2638
  },
2289
2639
  summary: "Update an email within a sequence",
2290
- description: `When templateId is supplied, it must identify a marketing template; transactional templates return 422 template_not_marketing. Edits to an active sequence's email apply to later sends only: the "view in browser" page of an email already sent keeps showing what was sent. A sent broadcast can't be edited; the request returns it unchanged.`
2640
+ description: "When templateId is supplied, it must identify a marketing template; transactional templates return 422 template_not_marketing. While a broadcast or sequence is active (a running sequence or a scheduled broadcast), `subject` and `content` are saved as a draft (returned as the email's `draft`) and sends keep using the published version until the changes are published with POST /sequences/{sequenceId}/publish-changes. Otherwise nothing is sending, so they're saved directly, along with any open draft. Delay, published and tag action changes always apply right away. The \"view in browser\" page of an email already sent keeps showing what was sent. A sent broadcast can't be edited; the request returns it unchanged."
2641
+ },
2642
+ publishChanges: {
2643
+ method: "POST",
2644
+ path: "/sequences/:sequenceId/publish-changes",
2645
+ body: publishSequenceChangesBodySchema,
2646
+ responses: {
2647
+ 200: sequenceSchema,
2648
+ 400: errorSchema,
2649
+ 404: errorSchema,
2650
+ 409: errorSchema
2651
+ },
2652
+ summary: "Publish the unpublished changes of a broadcast or sequence",
2653
+ description: "Makes the drafts of the given emails (or all of them) the version that sends use. Emails without unpublished changes are left alone, so publishing twice changes nothing. For a sequence, `scope` says whether contacts already in it get the new version at their next step (`in_flight`, the default) or keep the version they entered with (`new_entrants`). Each published version is kept in the email's history (GET /sequences/{sequenceId}/emails/{emailId}/versions), including the one it replaces. On SendLit Cloud the content is checked first, as when a sequence starts. 404 `email_not_found` for an email the sequence doesn't have; 409 `mail_already_sent` for a broadcast that has started sending (its unpublished changes are dropped then); 409 `draft_changed` when the draft was edited during the publish (publish again)."
2654
+ },
2655
+ discardChanges: {
2656
+ method: "POST",
2657
+ path: "/sequences/:sequenceId/discard-changes",
2658
+ body: discardSequenceChangesBodySchema,
2659
+ responses: { 200: sequenceSchema, 404: errorSchema },
2660
+ summary: "Discard the unpublished changes of a broadcast or sequence",
2661
+ description: "Deletes the drafts of the given emails (or all of them), so they show the published version again. A broadcast's title goes back to its published subject. Sends are not affected."
2662
+ },
2663
+ emailVersions: {
2664
+ method: "GET",
2665
+ path: "/sequences/:sequenceId/emails/:emailId/versions",
2666
+ responses: {
2667
+ 200: itemsList(sequenceEmailVersionSchema),
2668
+ 404: errorSchema
2669
+ },
2670
+ summary: "List the published versions of a broadcast or sequence email",
2671
+ description: "The live version first, then the versions the email was published with before, newest first (at most 20). Restore one with POST /sequences/{sequenceId}/emails/{emailId}/versions/{versionId}/restore."
2672
+ },
2673
+ restoreEmailVersion: {
2674
+ method: "POST",
2675
+ path: "/sequences/:sequenceId/emails/:emailId/versions/:versionId/restore",
2676
+ body: c.noBody(),
2677
+ responses: {
2678
+ 200: sequenceSchema,
2679
+ 404: errorSchema,
2680
+ 409: errorSchema
2681
+ },
2682
+ summary: "Restore an earlier version of a broadcast or sequence email",
2683
+ description: "Loads a published version's subject and content into the email's draft; publish it to roll back. Unless the broadcast or sequence is active, it's restored directly. Restoring the live version discards the draft. A broadcast's title follows the restored subject once it's published. 404 `version_not_found` for a version that isn't one of this email's published versions; 409 `mail_already_sent` for a broadcast that has started sending."
2291
2684
  },
2292
2685
  sendEmailTest: {
2293
2686
  method: "POST",
@@ -2300,7 +2693,7 @@ var sequencesContract = c.router(
2300
2693
  429: errorSchema
2301
2694
  },
2302
2695
  summary: "Send a test of a broadcast or sequence email",
2303
- description: "Renders the email exactly like a real send (merge tags, footer, tracking) and sends it with a `[Test]` subject prefix through the delivery source the real send would use. Its \"view in browser\" link shows the email as it was when tested, not later edits. Merge tags use the recipient's contact data when they are a contact. Opens, clicks and the unsubscribe link in a test change nothing. Suppressed addresses are skipped. Every recipient counts as one test: by default a team can send 100 test emails in any 24 hours (50 in any 3 hours) and 20 per email per 24 hours, after which this returns 429 `test_send_limit_reached` or `test_send_email_limit_reached`. Tests through an organization's shared mailbox also count against the team's shared-delivery quota (429 `organization_team_quota_exhausted` or `organization_quota_exhausted`)."
2696
+ description: "Renders the email exactly like a real send (merge tags, footer, tracking) and sends it with a `[Test]` subject prefix through the delivery source the real send would use. When the email has unpublished changes, the test sends the draft, so they can be checked before they're published. Its \"view in browser\" link shows the email as it was when tested, not later edits. Merge tags use the recipient's contact data when they are a contact. Opens, clicks and the unsubscribe link in a test change nothing. Suppressed addresses are skipped. Every recipient counts as one test: by default a team can send 100 test emails in any 24 hours (50 in any 3 hours) and 20 per email per 24 hours, after which this returns 429 `test_send_limit_reached` or `test_send_email_limit_reached`. Tests through an organization's shared mailbox also count against the team's shared-delivery quota (429 `organization_team_quota_exhausted` or `organization_quota_exhausted`)."
2304
2697
  },
2305
2698
  removeEmail: {
2306
2699
  method: "DELETE",
@@ -2310,7 +2703,8 @@ var sequencesContract = c.router(
2310
2703
  400: errorSchema,
2311
2704
  404: errorSchema
2312
2705
  },
2313
- summary: "Remove an email from a sequence"
2706
+ summary: "Remove an email from a sequence",
2707
+ description: "Removes the email. Images it uses that nothing else uses are deleted from the media library and storage; images used by sent mail are kept."
2314
2708
  },
2315
2709
  start: {
2316
2710
  method: "POST",
@@ -2356,6 +2750,25 @@ var sequencesContract = c.router(
2356
2750
  responses: { 200: sequenceStatsSchema, 404: errorSchema },
2357
2751
  summary: "Delivery / open-rate / click-through-rate stats for a sequence"
2358
2752
  },
2753
+ schedule: {
2754
+ method: "GET",
2755
+ path: "/sequences/:sequenceId/schedule",
2756
+ responses: { 200: sequenceScheduleSchema, 404: errorSchema },
2757
+ summary: "Contacts waiting for each email of a sequence",
2758
+ description: "For each email, in send order: how many contacts in the sequence will get it next and the earliest of their due times. A contact counts once, against the email they're waiting for, so emails they've had or will get later don't count them. Each contact's delay counts from their own entry, so their due times differ; list them with `GET /sequences/{sequenceId}/emails/{emailId}/waiting`. Due times are the earliest a contact can get the email; pauses and sending limits can make it later."
2759
+ },
2760
+ waitingContacts: {
2761
+ method: "GET",
2762
+ path: "/sequences/:sequenceId/emails/:emailId/waiting",
2763
+ query: listWaitingContactsQuerySchema,
2764
+ responses: {
2765
+ 200: waitingContactsPageSchema,
2766
+ 400: errorSchema,
2767
+ 404: errorSchema
2768
+ },
2769
+ summary: "Contacts waiting for a sequence email",
2770
+ description: "The contacts whose next email in the sequence is this one, soonest due first, each with their own due time. `q` matches email or name. Pages hold `limit` contacts (default 10, at most 100); pass `nextCursor` as `after` for the next page. `total` counts every match. A cursor that can't be read returns 400 `invalid_cursor`."
2771
+ },
2359
2772
  subscribers: {
2360
2773
  method: "GET",
2361
2774
  path: "/sequences/:sequenceId/subscribers",
@@ -2518,7 +2931,7 @@ var espCollectionContract = c.router(
2518
2931
  409: errorSchema
2519
2932
  },
2520
2933
  summary: "Remove a user-managed ESP configuration",
2521
- description: "Removes an ESP with no active or queued dependencies. Draft, paused, and completed sequences are detached first."
2934
+ description: "Deletes an ESP that has never carried delivery history; delivery history is never deleted. Draft, paused, and completed sequences are detached first. 409 explains a blocked delete: `esp_is_default` (the team's live default; pick another default or retire it first), `delivery_source_in_use` (a sending sequence or broadcast, or queued email, needs it), or `esp_has_delivery_history` (transactional email, delivery feedback, or grants point at it; retire it instead)."
2522
2935
  },
2523
2936
  domainAuthentication: {
2524
2937
  method: "GET",
@@ -2913,7 +3326,7 @@ var organizationsContract = c.router(
2913
3326
  path: "/organizations",
2914
3327
  responses: {
2915
3328
  200: z.object({
2916
- items: z.array(organizationSchema),
3329
+ items: z.array(organizationListItemSchema),
2917
3330
  ownsFreeOrganization: z.boolean()
2918
3331
  }),
2919
3332
  403: errorSchema
@@ -2963,7 +3376,8 @@ var organizationsContract = c.router(
2963
3376
  409: errorSchema,
2964
3377
  503: errorSchema
2965
3378
  },
2966
- summary: "Close an organization"
3379
+ summary: "Delete an organization",
3380
+ description: "Owner only, from a dashboard session. Fails with `409 active_subscription_exists` while a subscription is active or paid through a future date (cancel it in billing first), and with `409 billing_checkout_pending` while a checkout is open. Deleting closes the organization, archives its teams, revokes organization and team API keys and sending domains, retires every ESP config with its credentials wiped, and deletes its teams' MediaLit files. Billing history, audit events, delivery reporting and suppressions are kept."
2967
3381
  },
2968
3382
  abandon: {
2969
3383
  method: "POST",
@@ -3211,7 +3625,8 @@ var organizationsContract = c.router(
3211
3625
  404: errorSchema,
3212
3626
  409: errorSchema
3213
3627
  },
3214
- summary: "Delete an eligible never-activated organization ESP"
3628
+ summary: "Delete an eligible never-activated organization ESP",
3629
+ description: "Only a never-activated draft with no history is deleted. 409 explains a blocked delete: `esp_retire_instead` (it has been activated; retire it instead), `esp_has_delivery_history`, or `delivery_source_in_use`."
3215
3630
  },
3216
3631
  getEspFeedback: {
3217
3632
  method: "GET",
@@ -3461,6 +3876,13 @@ var overviewContract = c.router(
3461
3876
  );
3462
3877
  var feedbackContract = c.router(
3463
3878
  {
3879
+ requirement: {
3880
+ method: "GET",
3881
+ path: "/settings/feedback-requirement",
3882
+ responses: { 200: feedbackRequirementSchema },
3883
+ summary: "Get when ESPs need a delivery-feedback connection",
3884
+ description: "On SendLit Cloud, once the organization has sent `requiredAfterSends` emails, SendLit only sends through ESPs with a healthy bounce/complaint feedback connection. `required` is false on self-hosted SendLit."
3885
+ },
3464
3886
  get: {
3465
3887
  method: "GET",
3466
3888
  path: "/settings/esps/:espId/feedback",
@@ -3765,9 +4187,51 @@ var billingContract = c.router(
3765
4187
  },
3766
4188
  { metadata: { tag: "Billing" } }
3767
4189
  );
4190
+ var accountContract = c.router({
4191
+ getDeletion: {
4192
+ method: "GET",
4193
+ path: "/account/deletion",
4194
+ responses: {
4195
+ 200: accountDeletionPreviewSchema,
4196
+ 401: errorSchema,
4197
+ 403: errorSchema
4198
+ },
4199
+ summary: "Preview deleting your account",
4200
+ description: "Dashboard session only. Lists every organization you belong to and what deleting your account does to it: `delete` when you are its last owner (it is deleted and its contacts' personal data erased), `leave` otherwise. `blocker` says what has to happen first: `active_subscription_exists` or `billing_checkout_pending` (cancel billing), `last_organization_owner` (other people are members: make one of them an owner or remove them), `billing_manager_required` (you pay for a running subscription of an organization you would leave)."
4201
+ },
4202
+ sendDeletionCode: {
4203
+ method: "POST",
4204
+ path: "/account/deletion/code",
4205
+ body: c.noBody(),
4206
+ responses: {
4207
+ 204: c.noBody(),
4208
+ 401: errorSchema,
4209
+ 403: errorSchema,
4210
+ 429: errorSchema
4211
+ },
4212
+ summary: "Email a code to confirm deleting your account",
4213
+ description: "Dashboard session only. Sends a one-time code, valid for 5 minutes, to the account's email. `POST /account/deletion` needs it."
4214
+ },
4215
+ delete: {
4216
+ method: "POST",
4217
+ path: "/account/deletion",
4218
+ body: deleteAccountBodySchema,
4219
+ responses: {
4220
+ 204: c.noBody(),
4221
+ 400: errorSchema,
4222
+ 401: errorSchema,
4223
+ 403: errorSchema,
4224
+ 409: accountDeletionBlockedSchema
4225
+ },
4226
+ summary: "Delete your account",
4227
+ description: "Dashboard session only, with the account's email typed to confirm and the code from `POST /account/deletion/code` (`400 email_mismatch`, `400 invalid_code`). Fails with `409 account_deletion_blocked`, listing the blocking organizations, while any blocker from `GET /account/deletion` remains; nothing changes then. Otherwise every organization you are the last owner of is deleted like `DELETE /organizations/:organizationId` and its contacts, signup confirmations, recipient addresses and raw webhook payloads are erased (suppression hashes stay); you leave every other organization and team; your sessions, sign-in methods, OAuth tokens and consents end; and your name and email are erased. Billing records and audit events keep an anonymous id. Signing in again with the same email creates a new, empty account."
4228
+ }
4229
+ });
3768
4230
  var contract = c.router({
4231
+ account: accountContract,
3769
4232
  contacts: contactsContract,
3770
4233
  segments: segmentsContract,
4234
+ tags: tagsContract,
3771
4235
  media: mediaContract,
3772
4236
  templates: templatesContract,
3773
4237
  sequences: sequencesContract,
@@ -3989,8 +4453,19 @@ var Events = class {
3989
4453
  }
3990
4454
  };
3991
4455
 
4456
+ // src/resources/overview.ts
4457
+ var routes5 = contract.overview;
4458
+ var OverviewResource = class {
4459
+ constructor(http) {
4460
+ this.http = http;
4461
+ }
4462
+ async get(query = {}) {
4463
+ return this.http.request(routes5.get, { query });
4464
+ }
4465
+ };
4466
+
3992
4467
  // src/resources/provisioning.ts
3993
- var routes5 = contract.provisioning;
4468
+ var routes6 = contract.provisioning;
3994
4469
  var Provisioning = class {
3995
4470
  constructor(http) {
3996
4471
  this.http = http;
@@ -4001,20 +4476,20 @@ var Provisioning = class {
4001
4476
  * `created: false, apiKey: null`, so it's safe to retry.
4002
4477
  */
4003
4478
  async provisionTeam(input) {
4004
- return this.http.request(routes5.provisionTeam, {
4479
+ return this.http.request(routes6.provisionTeam, {
4005
4480
  body: input,
4006
4481
  retrySafe: true
4007
4482
  });
4008
4483
  }
4009
4484
  /** `teams:read` */
4010
4485
  async getTeam(teamId) {
4011
- return this.http.request(routes5.getTeam, {
4486
+ return this.http.request(routes6.getTeam, {
4012
4487
  params: { teamId: assertId(teamId, "teamId") }
4013
4488
  });
4014
4489
  }
4015
4490
  /** `teams:manage` */
4016
4491
  async updateTeam(teamId, input) {
4017
- return this.http.request(routes5.updateTeam, {
4492
+ return this.http.request(routes6.updateTeam, {
4018
4493
  params: { teamId: assertId(teamId, "teamId") },
4019
4494
  body: input
4020
4495
  });
@@ -4022,106 +4497,106 @@ var Provisioning = class {
4022
4497
  /** Replaces the team's integration key (`teams:keys`); keys previously
4023
4498
  * issued through provisioning are revoked. */
4024
4499
  async createTeamKey(teamId, input) {
4025
- return this.http.request(routes5.createTeamKey, {
4500
+ return this.http.request(routes6.createTeamKey, {
4026
4501
  params: { teamId: assertId(teamId, "teamId") },
4027
4502
  body: input
4028
4503
  });
4029
4504
  }
4030
4505
  /** `teams:manage` */
4031
4506
  async suspendTeam(teamId) {
4032
- return this.http.request(routes5.suspendTeam, {
4507
+ return this.http.request(routes6.suspendTeam, {
4033
4508
  params: { teamId: assertId(teamId, "teamId") }
4034
4509
  });
4035
4510
  }
4036
4511
  /** `teams:manage` */
4037
4512
  async resumeTeam(teamId) {
4038
- return this.http.request(routes5.resumeTeam, {
4513
+ return this.http.request(routes6.resumeTeam, {
4039
4514
  params: { teamId: assertId(teamId, "teamId") }
4040
4515
  });
4041
4516
  }
4042
4517
  /** Soft-deprovisions the team (`teams:manage`). There is no unarchive. */
4043
4518
  async archiveTeam(teamId) {
4044
- await this.http.request(routes5.archiveTeam, {
4519
+ await this.http.request(routes6.archiveTeam, {
4045
4520
  params: { teamId: assertId(teamId, "teamId") }
4046
4521
  });
4047
4522
  }
4048
4523
  /** `usage:read` */
4049
4524
  async getTeamUsage(teamId) {
4050
- return this.http.request(routes5.getTeamUsage, {
4525
+ return this.http.request(routes6.getTeamUsage, {
4051
4526
  params: { teamId: assertId(teamId, "teamId") }
4052
4527
  });
4053
4528
  }
4054
4529
  };
4055
4530
 
4056
4531
  // src/resources/segments.ts
4057
- var routes6 = contract.segments;
4532
+ var routes7 = contract.segments;
4058
4533
  var Segments = class {
4059
4534
  constructor(http) {
4060
4535
  this.http = http;
4061
4536
  }
4062
4537
  async create(input) {
4063
- return this.http.request(routes6.create, { body: input });
4538
+ return this.http.request(routes7.create, { body: input });
4064
4539
  }
4065
4540
  async list() {
4066
- return this.http.request(routes6.list);
4541
+ return this.http.request(routes7.list);
4067
4542
  }
4068
4543
  async get(segmentId) {
4069
- return this.http.request(routes6.get, {
4544
+ return this.http.request(routes7.get, {
4070
4545
  params: { segmentId: assertId(segmentId, "segmentId") }
4071
4546
  });
4072
4547
  }
4073
4548
  async update(segmentId, input) {
4074
- return this.http.request(routes6.update, {
4549
+ return this.http.request(routes7.update, {
4075
4550
  params: { segmentId: assertId(segmentId, "segmentId") },
4076
4551
  body: input
4077
4552
  });
4078
4553
  }
4079
4554
  async remove(segmentId) {
4080
- await this.http.request(routes6.remove, {
4555
+ await this.http.request(routes7.remove, {
4081
4556
  params: { segmentId: assertId(segmentId, "segmentId") }
4082
4557
  });
4083
4558
  }
4084
4559
  };
4085
4560
 
4086
4561
  // src/resources/sequences.ts
4087
- var routes7 = contract.sequences;
4562
+ var routes8 = contract.sequences;
4088
4563
  var Sequences = class {
4089
4564
  constructor(http) {
4090
4565
  this.http = http;
4091
4566
  }
4092
4567
  async create(input) {
4093
- return this.http.request(routes7.create, { body: input });
4568
+ return this.http.request(routes8.create, { body: input });
4094
4569
  }
4095
4570
  async list(query) {
4096
- return this.http.request(routes7.list, { query });
4571
+ return this.http.request(routes8.list, { query });
4097
4572
  }
4098
4573
  listAll(query) {
4099
4574
  return paginate((offset) => this.list({ ...query, offset }));
4100
4575
  }
4101
4576
  async get(sequenceId) {
4102
- return this.http.request(routes7.get, {
4577
+ return this.http.request(routes8.get, {
4103
4578
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4104
4579
  });
4105
4580
  }
4106
4581
  async update(sequenceId, input) {
4107
- return this.http.request(routes7.update, {
4582
+ return this.http.request(routes8.update, {
4108
4583
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4109
4584
  body: input
4110
4585
  });
4111
4586
  }
4112
4587
  async remove(sequenceId) {
4113
- await this.http.request(routes7.remove, {
4588
+ await this.http.request(routes8.remove, {
4114
4589
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4115
4590
  });
4116
4591
  }
4117
4592
  async addEmail(sequenceId, input) {
4118
- return this.http.request(routes7.addEmail, {
4593
+ return this.http.request(routes8.addEmail, {
4119
4594
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4120
4595
  body: input
4121
4596
  });
4122
4597
  }
4123
4598
  async updateEmail(sequenceId, emailId, input) {
4124
- return this.http.request(routes7.updateEmail, {
4599
+ return this.http.request(routes8.updateEmail, {
4125
4600
  params: {
4126
4601
  sequenceId: assertId(sequenceId, "sequenceId"),
4127
4602
  emailId: assertId(emailId, "emailId")
@@ -4129,8 +4604,45 @@ var Sequences = class {
4129
4604
  body: input
4130
4605
  });
4131
4606
  }
4607
+ /** Publishes unpublished email changes (drafts) of a broadcast or
4608
+ * sequence, so sends use them. While it's active, `updateEmail` saves
4609
+ * subject and content changes as a draft. */
4610
+ async publishChanges(sequenceId, input = {}) {
4611
+ return this.http.request(routes8.publishChanges, {
4612
+ params: { sequenceId: assertId(sequenceId, "sequenceId") },
4613
+ body: input
4614
+ });
4615
+ }
4616
+ /** Throws away unpublished email changes. Sends are not affected. */
4617
+ async discardChanges(sequenceId, input = {}) {
4618
+ return this.http.request(routes8.discardChanges, {
4619
+ params: { sequenceId: assertId(sequenceId, "sequenceId") },
4620
+ body: input
4621
+ });
4622
+ }
4623
+ /** The versions an email has been published with, live one first. */
4624
+ async emailVersions(sequenceId, emailId) {
4625
+ const { items } = await this.http.request(routes8.emailVersions, {
4626
+ params: {
4627
+ sequenceId: assertId(sequenceId, "sequenceId"),
4628
+ emailId: assertId(emailId, "emailId")
4629
+ }
4630
+ });
4631
+ return items;
4632
+ }
4633
+ /** Loads an earlier published version into the email's draft; publish
4634
+ * it with `publishChanges` to roll back. */
4635
+ async restoreEmailVersion(sequenceId, emailId, versionId) {
4636
+ return this.http.request(routes8.restoreEmailVersion, {
4637
+ params: {
4638
+ sequenceId: assertId(sequenceId, "sequenceId"),
4639
+ emailId: assertId(emailId, "emailId"),
4640
+ versionId: assertId(versionId, "versionId")
4641
+ }
4642
+ });
4643
+ }
4132
4644
  async removeEmail(sequenceId, emailId) {
4133
- return this.http.request(routes7.removeEmail, {
4645
+ return this.http.request(routes8.removeEmail, {
4134
4646
  params: {
4135
4647
  sequenceId: assertId(sequenceId, "sequenceId"),
4136
4648
  emailId: assertId(emailId, "emailId")
@@ -4140,92 +4652,152 @@ var Sequences = class {
4140
4652
  /** Sends a broadcast, or activates a sequence so its trigger starts
4141
4653
  * enrolling contacts. Requires a mailing address in general settings. */
4142
4654
  async start(sequenceId) {
4143
- return this.http.request(routes7.start, {
4655
+ return this.http.request(routes8.start, {
4144
4656
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4145
4657
  });
4146
4658
  }
4147
4659
  async pause(sequenceId) {
4148
- return this.http.request(routes7.pause, {
4660
+ return this.http.request(routes8.pause, {
4149
4661
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4150
4662
  });
4151
4663
  }
4152
4664
  async stats(sequenceId) {
4153
- return this.http.request(routes7.stats, {
4665
+ return this.http.request(routes8.stats, {
4154
4666
  params: { sequenceId: assertId(sequenceId, "sequenceId") }
4155
4667
  });
4156
4668
  }
4669
+ /** Sends a test of one broadcast or sequence email, rendered like a real
4670
+ * send with a `[Test]` subject prefix. Tests count against the team's test
4671
+ * limits (429 `test_send_limit_reached` / `test_send_email_limit_reached`). */
4672
+ async sendEmailTest(sequenceId, emailId, input) {
4673
+ return this.http.request(routes8.sendEmailTest, {
4674
+ params: {
4675
+ sequenceId: assertId(sequenceId, "sequenceId"),
4676
+ emailId: assertId(emailId, "emailId")
4677
+ },
4678
+ body: input
4679
+ });
4680
+ }
4157
4681
  /** IDs of contacts that have received this broadcast or sequence. */
4158
4682
  async subscribers(sequenceId, query = {}) {
4159
- return this.http.request(routes7.subscribers, {
4683
+ return this.http.request(routes8.subscribers, {
4160
4684
  params: { sequenceId: assertId(sequenceId, "sequenceId") },
4161
4685
  query
4162
4686
  });
4163
4687
  }
4164
4688
  };
4165
4689
 
4690
+ // src/resources/settings.ts
4691
+ var routes9 = contract.settings.general;
4692
+ var GeneralSettingsResource = class {
4693
+ constructor(http) {
4694
+ this.http = http;
4695
+ }
4696
+ async get() {
4697
+ return this.http.request(routes9.get);
4698
+ }
4699
+ async update(input) {
4700
+ return this.http.request(routes9.update, { body: input });
4701
+ }
4702
+ };
4703
+ var Settings = class {
4704
+ constructor(http) {
4705
+ this.general = new GeneralSettingsResource(http);
4706
+ }
4707
+ };
4708
+
4166
4709
  // src/resources/suppressions.ts
4167
- var routes8 = contract.suppressions;
4710
+ var routes10 = contract.suppressions;
4168
4711
  var Suppressions = class {
4169
4712
  constructor(http) {
4170
4713
  this.http = http;
4171
4714
  }
4172
4715
  async list(query = {}) {
4173
- return this.http.request(routes8.list, { query });
4716
+ return this.http.request(routes10.list, { query });
4174
4717
  }
4175
4718
  listAll(query = {}) {
4176
4719
  return paginate((offset) => this.list({ ...query, offset }));
4177
4720
  }
4178
4721
  async get(suppressionId) {
4179
- return this.http.request(routes8.get, {
4722
+ return this.http.request(routes10.get, {
4180
4723
  params: { suppressionId: assertId(suppressionId, "suppressionId") }
4181
4724
  });
4182
4725
  }
4183
4726
  /** Complaint suppressions can't be released (409
4184
4727
  * `suppression_not_releasable`). */
4185
4728
  async release(suppressionId, input = {}) {
4186
- return this.http.request(routes8.release, {
4729
+ return this.http.request(routes10.release, {
4187
4730
  params: { suppressionId: assertId(suppressionId, "suppressionId") },
4188
4731
  body: input
4189
4732
  });
4190
4733
  }
4191
4734
  };
4192
4735
 
4736
+ // src/resources/tags.ts
4737
+ var routes11 = contract.tags;
4738
+ var Tags = class {
4739
+ constructor(http) {
4740
+ this.http = http;
4741
+ }
4742
+ async list() {
4743
+ return this.http.request(routes11.list);
4744
+ }
4745
+ async references(tag) {
4746
+ return this.http.request(routes11.references, {
4747
+ params: { tag: encodeSegment(tag, "tag") }
4748
+ });
4749
+ }
4750
+ /** Renames a tag on every contact and everywhere it's referenced. */
4751
+ async rename(tag, input) {
4752
+ return this.http.request(routes11.rename, {
4753
+ params: { tag: encodeSegment(tag, "tag") },
4754
+ body: input
4755
+ });
4756
+ }
4757
+ /** Removes a tag from every contact. */
4758
+ async remove(tag) {
4759
+ return this.http.request(routes11.remove, {
4760
+ params: { tag: encodeSegment(tag, "tag") }
4761
+ });
4762
+ }
4763
+ };
4764
+
4193
4765
  // src/resources/templates.ts
4194
- var routes9 = contract.templates;
4766
+ var routes12 = contract.templates;
4195
4767
  var Templates = class {
4196
4768
  constructor(http) {
4197
4769
  this.http = http;
4198
4770
  }
4199
4771
  async list(query = {}) {
4200
- return this.http.request(routes9.list, { query });
4772
+ return this.http.request(routes12.list, { query });
4201
4773
  }
4202
4774
  /** Built-in starters, shared by every team. Duplicate one into the team
4203
4775
  * before using it for transactional sends. */
4204
4776
  async listSystem(query = {}) {
4205
- return this.http.request(routes9.listSystem, { query });
4777
+ return this.http.request(routes12.listSystem, { query });
4206
4778
  }
4207
4779
  async get(templateId) {
4208
- return this.http.request(routes9.get, {
4780
+ return this.http.request(routes12.get, {
4209
4781
  params: { templateId: assertId(templateId, "templateId") }
4210
4782
  });
4211
4783
  }
4212
4784
  async create(input) {
4213
- return this.http.request(routes9.create, { body: input });
4785
+ return this.http.request(routes12.create, { body: input });
4214
4786
  }
4215
4787
  async update(templateId, input) {
4216
- return this.http.request(routes9.update, {
4788
+ return this.http.request(routes12.update, {
4217
4789
  params: { templateId: assertId(templateId, "templateId") },
4218
4790
  body: input
4219
4791
  });
4220
4792
  }
4221
4793
  async duplicate(templateId, input = {}) {
4222
- return this.http.request(routes9.duplicate, {
4794
+ return this.http.request(routes12.duplicate, {
4223
4795
  params: { templateId: assertId(templateId, "templateId") },
4224
4796
  body: input
4225
4797
  });
4226
4798
  }
4227
4799
  async remove(templateId) {
4228
- await this.http.request(routes9.remove, {
4800
+ await this.http.request(routes12.remove, {
4229
4801
  params: { templateId: assertId(templateId, "templateId") }
4230
4802
  });
4231
4803
  }
@@ -4293,7 +4865,10 @@ var SendLit = class {
4293
4865
  this.provisioning = new Provisioning(http);
4294
4866
  this.suppressions = new Suppressions(http);
4295
4867
  this.deliveryEvents = new DeliveryEvents(http);
4868
+ this.tags = new Tags(http);
4869
+ this.settings = new Settings(http);
4870
+ this.overview = new OverviewResource(http);
4296
4871
  }
4297
4872
  };
4298
4873
 
4299
- export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, EventDefinitions, Events, Provisioning, Segments, SendLit, SendLitError, Sequences, Suppressions, Templates };
4874
+ export { Contacts, DEFAULT_ENDPOINT, DeliveryEvents, Emails, EventDefinitions, Events, GeneralSettingsResource, OverviewResource, Provisioning, Segments, SendLit, SendLitError, Sequences, Settings, Suppressions, Tags, Templates };