@marlinjai/mail-contract 0.14.0 → 0.15.1

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.js CHANGED
@@ -511,6 +511,7 @@ __export(index_exports, {
511
511
  billingRoutes: () => billingRoutes,
512
512
  buildPath: () => buildPath,
513
513
  buildTemplatePatch: () => buildTemplatePatch,
514
+ canDeleteMailing: () => canDeleteMailing,
514
515
  canTransition: () => canTransition,
515
516
  canonicalLocale: () => canonicalLocale,
516
517
  choiceKeyProblem: () => choiceKeyProblem,
@@ -1834,6 +1835,10 @@ var Mailing = import_zod8.z.object({
1834
1835
  updated_at: Timestamp
1835
1836
  });
1836
1837
  var MailingSummary = Mailing.omit({ document: true });
1838
+ function canDeleteMailing(mailing) {
1839
+ if (mailing.kind !== "broadcast") return false;
1840
+ return mailing.status === "draft" || mailing.status === "cancelled" && mailing.started_at === null;
1841
+ }
1837
1842
  var MailingContent = {
1838
1843
  name: import_zod8.z.string().max(200).optional(),
1839
1844
  subject: import_zod8.z.string().min(1).max(998),
@@ -3617,6 +3622,7 @@ var AUDIT_ACTIONS = [
3617
3622
  "mailing.paused",
3618
3623
  "mailing.resumed",
3619
3624
  "mailing.cancelled",
3625
+ "mailing.deleted",
3620
3626
  "mailing.retried",
3621
3627
  "webhook.created",
3622
3628
  "webhook.updated",
@@ -5746,6 +5752,25 @@ var sendingRoutes = {
5746
5752
  access: "write",
5747
5753
  phase: "S2"
5748
5754
  },
5755
+ /**
5756
+ * Deletes a mailing that never started: a broadcast in `draft`, or one
5757
+ * `cancelled` before any send began (`canDeleteMailing`). Its recipients,
5758
+ * A/B variants and compiled content go with it. Test sends made from it stay
5759
+ * in the archive, with `mailing_id` null: they are mail that really went out.
5760
+ * Anything else is `mailing_invalid_state` (409): a scheduled mailing is
5761
+ * unscheduled first, and a mailing that started is the record of what was
5762
+ * sent. An automation's mailing is `conflict`; a transactional letter is
5763
+ * deleted only by a key that may write one (`forbidden`).
5764
+ */
5765
+ "mailings.delete": {
5766
+ method: "DELETE",
5767
+ path: "/v1/mailings/:id",
5768
+ params: IdParams,
5769
+ response: Ok,
5770
+ status: 200,
5771
+ access: "write",
5772
+ phase: "S2"
5773
+ },
5749
5774
  "mailings.retryFailed": {
5750
5775
  method: "POST",
5751
5776
  path: "/v1/mailings/:id/retry-failed",
@@ -7003,6 +7028,7 @@ function matchRoute(method, pathname) {
7003
7028
  billingRoutes,
7004
7029
  buildPath,
7005
7030
  buildTemplatePatch,
7031
+ canDeleteMailing,
7006
7032
  canTransition,
7007
7033
  canonicalLocale,
7008
7034
  choiceKeyProblem,
package/dist/index.mjs CHANGED
@@ -1195,6 +1195,10 @@ var Mailing = z8.object({
1195
1195
  updated_at: Timestamp
1196
1196
  });
1197
1197
  var MailingSummary = Mailing.omit({ document: true });
1198
+ function canDeleteMailing(mailing) {
1199
+ if (mailing.kind !== "broadcast") return false;
1200
+ return mailing.status === "draft" || mailing.status === "cancelled" && mailing.started_at === null;
1201
+ }
1198
1202
  var MailingContent = {
1199
1203
  name: z8.string().max(200).optional(),
1200
1204
  subject: z8.string().min(1).max(998),
@@ -2978,6 +2982,7 @@ var AUDIT_ACTIONS = [
2978
2982
  "mailing.paused",
2979
2983
  "mailing.resumed",
2980
2984
  "mailing.cancelled",
2985
+ "mailing.deleted",
2981
2986
  "mailing.retried",
2982
2987
  "webhook.created",
2983
2988
  "webhook.updated",
@@ -5107,6 +5112,25 @@ var sendingRoutes = {
5107
5112
  access: "write",
5108
5113
  phase: "S2"
5109
5114
  },
5115
+ /**
5116
+ * Deletes a mailing that never started: a broadcast in `draft`, or one
5117
+ * `cancelled` before any send began (`canDeleteMailing`). Its recipients,
5118
+ * A/B variants and compiled content go with it. Test sends made from it stay
5119
+ * in the archive, with `mailing_id` null: they are mail that really went out.
5120
+ * Anything else is `mailing_invalid_state` (409): a scheduled mailing is
5121
+ * unscheduled first, and a mailing that started is the record of what was
5122
+ * sent. An automation's mailing is `conflict`; a transactional letter is
5123
+ * deleted only by a key that may write one (`forbidden`).
5124
+ */
5125
+ "mailings.delete": {
5126
+ method: "DELETE",
5127
+ path: "/v1/mailings/:id",
5128
+ params: IdParams,
5129
+ response: Ok,
5130
+ status: 200,
5131
+ access: "write",
5132
+ phase: "S2"
5133
+ },
5110
5134
  "mailings.retryFailed": {
5111
5135
  method: "POST",
5112
5136
  path: "/v1/mailings/:id/retry-failed",
@@ -6363,6 +6387,7 @@ export {
6363
6387
  billingRoutes,
6364
6388
  buildPath,
6365
6389
  buildTemplatePatch,
6390
+ canDeleteMailing,
6366
6391
  canTransition,
6367
6392
  canonicalLocale,
6368
6393
  choiceKeyProblem,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.14.0",
6
+ "version": "0.15.1",
7
7
  "description": "The v1 API contract of the mail service: zod schemas and types for every request, response, error and webhook, the route table, and webhook signing helpers",
8
8
  "license": "MIT",
9
9
  "repository": {