@marlinjai/mail-contract 0.21.0 → 0.23.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.js CHANGED
@@ -107,6 +107,8 @@ __export(index_exports, {
107
107
  BEARER_PREFIX: () => BEARER_PREFIX,
108
108
  BILLING_NOT_CONFIGURED_REASON: () => BILLING_NOT_CONFIGURED_REASON,
109
109
  BillingAddons: () => BillingAddons,
110
+ BoughtDomain: () => BoughtDomain,
111
+ BoughtDomainRecordParams: () => BoughtDomainRecordParams,
110
112
  BoundedAutomationFilter: () => BoundedAutomationFilter,
111
113
  BoundedSegmentFilter: () => BoundedSegmentFilter,
112
114
  COMPANY_GRANT_ROLES: () => COMPANY_GRANT_ROLES,
@@ -141,21 +143,33 @@ __export(index_exports, {
141
143
  DATE_PASSED_ANSWERS: () => DATE_PASSED_ANSWERS,
142
144
  DEFAULT_INVITE_TTL_DAYS: () => DEFAULT_INVITE_TTL_DAYS,
143
145
  DEFAULT_PAGE_LIMIT: () => DEFAULT_PAGE_LIMIT,
146
+ DNS_RECORD_TYPES: () => DNS_RECORD_TYPES,
144
147
  DOCUMENT_SCHEMA_VERSIONS: () => DOCUMENT_SCHEMA_VERSIONS,
145
148
  DOMAIN_BUYING_BLOCKS: () => DOMAIN_BUYING_BLOCKS,
146
149
  DOMAIN_BUYING_NOT_CONFIGURED_REASON: () => DOMAIN_BUYING_NOT_CONFIGURED_REASON,
150
+ DOMAIN_LEAVE_STATES: () => DOMAIN_LEAVE_STATES,
151
+ DOMAIN_LEAVE_WAYS: () => DOMAIN_LEAVE_WAYS,
152
+ DOMAIN_ORDER_KINDS: () => DOMAIN_ORDER_KINDS,
147
153
  DOMAIN_ORDER_STATES: () => DOMAIN_ORDER_STATES,
148
154
  DOMAIN_PRICE_CHANGED_REASON: () => DOMAIN_PRICE_CHANGED_REASON,
149
155
  DOMAIN_UNAVAILABLE_REASONS: () => DOMAIN_UNAVAILABLE_REASONS,
150
156
  DateOnly: () => DateOnly,
151
157
  DatePassedAnswer: () => DatePassedAnswer,
152
158
  DelayStep: () => DelayStep,
159
+ DnsRecordType: () => DnsRecordType,
153
160
  DocumentSchemaVersion: () => DocumentSchemaVersion,
154
161
  DomainBuyingBlock: () => DomainBuyingBlock,
162
+ DomainLeave: () => DomainLeave,
163
+ DomainLeaveCreate: () => DomainLeaveCreate,
164
+ DomainLeaveState: () => DomainLeaveState,
165
+ DomainLeaveWay: () => DomainLeaveWay,
155
166
  DomainOffer: () => DomainOffer,
156
167
  DomainOrder: () => DomainOrder,
157
168
  DomainOrderCreate: () => DomainOrderCreate,
169
+ DomainOrderKind: () => DomainOrderKind,
158
170
  DomainOrderState: () => DomainOrderState,
171
+ DomainRecord: () => DomainRecord,
172
+ DomainRecordInput: () => DomainRecordInput,
159
173
  DomainRegistrant: () => DomainRegistrant,
160
174
  DomainSearchQuery: () => DomainSearchQuery,
161
175
  DomainSearchResult: () => DomainSearchResult,
@@ -368,6 +382,7 @@ __export(index_exports, {
368
382
  QuietHours: () => QuietHours,
369
383
  RECIPIENT_REJECTIONS: () => RECIPIENT_REJECTIONS,
370
384
  RECIPIENT_STATUSES: () => RECIPIENT_STATUSES,
385
+ REGISTRY_PHONE: () => REGISTRY_PHONE,
371
386
  REQUEST_ID_HEADER: () => REQUEST_ID_HEADER,
372
387
  RESEND_EVENT_TYPES: () => RESEND_EVENT_TYPES,
373
388
  RESERVED_MERGE_FIELDS: () => RESERVED_MERGE_FIELDS,
@@ -532,6 +547,7 @@ __export(index_exports, {
532
547
  WorkspaceMove: () => WorkspaceMove,
533
548
  WorkspaceSettings: () => WorkspaceSettings,
534
549
  WorkspaceUpdate: () => WorkspaceUpdate,
550
+ ZoneFile: () => ZoneFile,
535
551
  acceptsIdempotencyKey: () => acceptsIdempotencyKey,
536
552
  addInsertion: () => addInsertion,
537
553
  addInsertionChoice: () => addInsertionChoice,
@@ -541,6 +557,7 @@ __export(index_exports, {
541
557
  automationFilterFamily: () => automationFilterFamily,
542
558
  automationRoutes: () => automationRoutes,
543
559
  billingRoutes: () => billingRoutes,
560
+ boughtDomainRoutes: () => boughtDomainRoutes,
544
561
  buildPath: () => buildPath,
545
562
  buildTemplatePatch: () => buildTemplatePatch,
546
563
  canDeleteMailing: () => canDeleteMailing,
@@ -605,6 +622,7 @@ __export(index_exports, {
605
622
  missingInsertionTexts: () => missingInsertionTexts,
606
623
  missingRequiredMergeFields: () => missingRequiredMergeFields,
607
624
  normalizeChoiceKey: () => normalizeChoiceKey,
625
+ normalizePhone: () => normalizePhone,
608
626
  nowSeconds: () => nowSeconds,
609
627
  operationsWithAccess: () => operationsWithAccess,
610
628
  ownEntry: () => ownEntry,
@@ -3721,8 +3739,15 @@ var AUDIT_ACTIONS = [
3721
3739
  "domain_order.registered",
3722
3740
  "domain_order.ready",
3723
3741
  "domain_order.needs_attention",
3742
+ "domain_order.kind_changed",
3724
3743
  "domain_order.refunded",
3725
3744
  "domain_order.cancelled",
3745
+ // Bought domains, managed by their holder
3746
+ "domain_record.created",
3747
+ "domain_record.updated",
3748
+ "domain_record.deleted",
3749
+ "domain_leave.requested",
3750
+ "domain_leave.done",
3726
3751
  // A1: automations
3727
3752
  "automation.created",
3728
3753
  "automation.updated",
@@ -4648,6 +4673,292 @@ var SendingDomainUpdate = import_zod15.z.object({ from_name: SenderFields.from_n
4648
4673
 
4649
4674
  // src/domains.ts
4650
4675
  var import_zod16 = require("zod");
4676
+
4677
+ // src/phone.ts
4678
+ var REGISTRY_PHONE = /^\+\d{1,3}\.\d{4,14}$/;
4679
+ var CALLING_CODE_OF_COUNTRY = {
4680
+ DE: "49",
4681
+ AT: "43",
4682
+ CH: "41",
4683
+ LI: "423",
4684
+ LU: "352",
4685
+ NL: "31",
4686
+ BE: "32",
4687
+ FR: "33",
4688
+ IT: "39",
4689
+ ES: "34",
4690
+ PT: "351",
4691
+ IE: "353",
4692
+ GB: "44",
4693
+ DK: "45",
4694
+ SE: "46",
4695
+ NO: "47",
4696
+ FI: "358",
4697
+ IS: "354",
4698
+ PL: "48",
4699
+ CZ: "420",
4700
+ SK: "421",
4701
+ HU: "36",
4702
+ SI: "386",
4703
+ HR: "385",
4704
+ RO: "40",
4705
+ BG: "359",
4706
+ GR: "30",
4707
+ CY: "357",
4708
+ MT: "356",
4709
+ EE: "372",
4710
+ LV: "371",
4711
+ LT: "370",
4712
+ US: "1",
4713
+ CA: "1",
4714
+ AU: "61",
4715
+ NZ: "64",
4716
+ TR: "90",
4717
+ IL: "972",
4718
+ AE: "971",
4719
+ IN: "91",
4720
+ JP: "81",
4721
+ CN: "86",
4722
+ SG: "65",
4723
+ ZA: "27",
4724
+ BR: "55",
4725
+ MX: "52",
4726
+ UA: "380",
4727
+ RS: "381"
4728
+ };
4729
+ var CALLING_CODES = /* @__PURE__ */ new Set([
4730
+ "1",
4731
+ "7",
4732
+ "20",
4733
+ "27",
4734
+ "30",
4735
+ "31",
4736
+ "32",
4737
+ "33",
4738
+ "34",
4739
+ "36",
4740
+ "39",
4741
+ "40",
4742
+ "41",
4743
+ "43",
4744
+ "44",
4745
+ "45",
4746
+ "46",
4747
+ "47",
4748
+ "48",
4749
+ "49",
4750
+ "51",
4751
+ "52",
4752
+ "53",
4753
+ "54",
4754
+ "55",
4755
+ "56",
4756
+ "57",
4757
+ "58",
4758
+ "60",
4759
+ "61",
4760
+ "62",
4761
+ "63",
4762
+ "64",
4763
+ "65",
4764
+ "66",
4765
+ "81",
4766
+ "82",
4767
+ "84",
4768
+ "86",
4769
+ "90",
4770
+ "91",
4771
+ "92",
4772
+ "93",
4773
+ "94",
4774
+ "95",
4775
+ "98",
4776
+ "211",
4777
+ "212",
4778
+ "213",
4779
+ "216",
4780
+ "218",
4781
+ "220",
4782
+ "221",
4783
+ "222",
4784
+ "223",
4785
+ "224",
4786
+ "225",
4787
+ "226",
4788
+ "227",
4789
+ "228",
4790
+ "229",
4791
+ "230",
4792
+ "231",
4793
+ "232",
4794
+ "233",
4795
+ "234",
4796
+ "235",
4797
+ "236",
4798
+ "237",
4799
+ "238",
4800
+ "239",
4801
+ "240",
4802
+ "241",
4803
+ "242",
4804
+ "243",
4805
+ "244",
4806
+ "245",
4807
+ "246",
4808
+ "247",
4809
+ "248",
4810
+ "249",
4811
+ "250",
4812
+ "251",
4813
+ "252",
4814
+ "253",
4815
+ "254",
4816
+ "255",
4817
+ "256",
4818
+ "257",
4819
+ "258",
4820
+ "260",
4821
+ "261",
4822
+ "262",
4823
+ "263",
4824
+ "264",
4825
+ "265",
4826
+ "266",
4827
+ "267",
4828
+ "268",
4829
+ "269",
4830
+ "290",
4831
+ "291",
4832
+ "297",
4833
+ "298",
4834
+ "299",
4835
+ "350",
4836
+ "351",
4837
+ "352",
4838
+ "353",
4839
+ "354",
4840
+ "355",
4841
+ "356",
4842
+ "357",
4843
+ "358",
4844
+ "359",
4845
+ "370",
4846
+ "371",
4847
+ "372",
4848
+ "373",
4849
+ "374",
4850
+ "375",
4851
+ "376",
4852
+ "377",
4853
+ "378",
4854
+ "379",
4855
+ "380",
4856
+ "381",
4857
+ "382",
4858
+ "383",
4859
+ "385",
4860
+ "386",
4861
+ "387",
4862
+ "389",
4863
+ "420",
4864
+ "421",
4865
+ "423",
4866
+ "500",
4867
+ "501",
4868
+ "502",
4869
+ "503",
4870
+ "504",
4871
+ "505",
4872
+ "506",
4873
+ "507",
4874
+ "508",
4875
+ "509",
4876
+ "590",
4877
+ "591",
4878
+ "592",
4879
+ "593",
4880
+ "594",
4881
+ "595",
4882
+ "596",
4883
+ "597",
4884
+ "598",
4885
+ "599",
4886
+ "670",
4887
+ "672",
4888
+ "673",
4889
+ "674",
4890
+ "675",
4891
+ "676",
4892
+ "677",
4893
+ "678",
4894
+ "679",
4895
+ "680",
4896
+ "681",
4897
+ "682",
4898
+ "683",
4899
+ "685",
4900
+ "686",
4901
+ "687",
4902
+ "688",
4903
+ "689",
4904
+ "690",
4905
+ "691",
4906
+ "692",
4907
+ "850",
4908
+ "852",
4909
+ "853",
4910
+ "855",
4911
+ "856",
4912
+ "880",
4913
+ "886",
4914
+ "960",
4915
+ "961",
4916
+ "962",
4917
+ "963",
4918
+ "964",
4919
+ "965",
4920
+ "966",
4921
+ "967",
4922
+ "968",
4923
+ "970",
4924
+ "971",
4925
+ "972",
4926
+ "973",
4927
+ "974",
4928
+ "975",
4929
+ "976",
4930
+ "977",
4931
+ "992",
4932
+ "993",
4933
+ "994",
4934
+ "995",
4935
+ "996",
4936
+ "998"
4937
+ ]);
4938
+ var KEEPS_LEADING_ZERO = /* @__PURE__ */ new Set(["39", "378", "379"]);
4939
+ function normalizePhone(raw, country) {
4940
+ const text = raw.trim();
4941
+ if (REGISTRY_PHONE.test(text)) return text;
4942
+ const compact = text.replace(/\(0\)/g, "").replace(/[\s\-./()]/g, "");
4943
+ let international;
4944
+ if (/^\+\d+$/.test(compact)) international = compact.slice(1);
4945
+ else if (/^00\d+$/.test(compact)) international = compact.slice(2);
4946
+ else if (/^0\d+$/.test(compact)) {
4947
+ const code = country ? CALLING_CODE_OF_COUNTRY[country.trim().toUpperCase()] : void 0;
4948
+ if (!code) return raw;
4949
+ return `+${code}.${KEEPS_LEADING_ZERO.has(code) ? compact : compact.slice(1)}`;
4950
+ } else return raw;
4951
+ for (const length of [1, 2, 3]) {
4952
+ const code = international.slice(0, length);
4953
+ if (CALLING_CODES.has(code)) {
4954
+ const rest = international.slice(length);
4955
+ return `+${code}.${KEEPS_LEADING_ZERO.has(code) ? rest : rest.replace(/^0/, "")}`;
4956
+ }
4957
+ }
4958
+ return raw;
4959
+ }
4960
+
4961
+ // src/domains.ts
4651
4962
  var DomainSearchQuery = import_zod16.z.object({ q: import_zod16.z.string().trim().min(1).max(63) });
4652
4963
  var DOMAIN_UNAVAILABLE_REASONS = ["taken", "extension_not_supported", "premium", "not_registrable"];
4653
4964
  var DomainUnavailableReason = import_zod16.z.enum(DOMAIN_UNAVAILABLE_REASONS);
@@ -4669,20 +4980,27 @@ var DomainRegistrant = import_zod16.z.object({
4669
4980
  name: import_zod16.z.string().trim().min(3).max(120).regex(/\S+\s+\S+/, "must be a first and a last name"),
4670
4981
  organization: import_zod16.z.string().trim().min(1).max(120).nullable().optional(),
4671
4982
  email: Email,
4672
- phone: import_zod16.z.string().trim().regex(/^\+\d{1,3}\.\d{4,14}$/, "must be +<country code>.<number>, such as +49.3012345678"),
4983
+ phone: import_zod16.z.string().trim().min(1).max(40),
4673
4984
  street: import_zod16.z.string().trim().min(3).max(200),
4674
4985
  city: import_zod16.z.string().trim().min(1).max(100),
4675
4986
  state: import_zod16.z.string().trim().min(1).max(100),
4676
4987
  postal_code: import_zod16.z.string().trim().min(2).max(20),
4677
4988
  country_code: import_zod16.z.string().trim().toUpperCase().regex(/^[A-Z]{2}$/, "must be a two-letter country code such as DE")
4678
- });
4989
+ }).superRefine((holder, ctx) => {
4990
+ if (typeof holder.phone === "string" && !REGISTRY_PHONE.test(normalizePhone(holder.phone, holder.country_code))) {
4991
+ ctx.addIssue({ code: import_zod16.z.ZodIssueCode.custom, path: ["phone"], message: "must be a phone number with its country code, such as +49 30 1234 5678" });
4992
+ }
4993
+ }).transform((holder) => ({ ...holder, phone: normalizePhone(holder.phone, holder.country_code) }));
4679
4994
  var MAX_DOMAIN_ORDERS_PER_DAY = 2;
4995
+ var DOMAIN_ORDER_KINDS = ["sending", "domain_only"];
4996
+ var DomainOrderKind = import_zod16.z.enum(DOMAIN_ORDER_KINDS);
4680
4997
  var DomainOrderCreate = import_zod16.z.object({
4681
4998
  domain: SendingDomainName,
4682
4999
  price_cents: import_zod16.z.number().int().min(0),
4683
5000
  registrant: DomainRegistrant,
4684
- from_name: import_zod16.z.string().trim().min(1).max(120),
4685
- from_local_part: import_zod16.z.string().trim().toLowerCase().regex(/^[a-z0-9](?:[a-z0-9._+-]{0,62}[a-z0-9])?$/, "must be the part before the @, such as hello"),
5001
+ kind: DomainOrderKind.default("sending"),
5002
+ from_name: import_zod16.z.string().trim().min(1).max(120).optional(),
5003
+ from_local_part: import_zod16.z.string().trim().toLowerCase().regex(/^[a-z0-9](?:[a-z0-9._+-]{0,62}[a-z0-9])?$/, "must be the part before the @, such as hello").optional(),
4686
5004
  /**
4687
5005
  * Where Stripe returns to after paying, and after leaving the payment. The
4688
5006
  * service adds `domain_order=<order id>` to both, so the page coming back
@@ -4693,6 +5011,10 @@ var DomainOrderCreate = import_zod16.z.object({
4693
5011
  cancel_url: import_zod16.z.string().url(),
4694
5012
  /** The buyer accepted the terms of service (which cover bought domains) of this version. */
4695
5013
  accept_terms: AcceptTerms
5014
+ }).superRefine((order, ctx) => {
5015
+ if (order.kind !== "sending") return;
5016
+ if (!order.from_name) ctx.addIssue({ code: import_zod16.z.ZodIssueCode.custom, path: ["from_name"], message: "is needed for a domain mail is sent from" });
5017
+ if (!order.from_local_part) ctx.addIssue({ code: import_zod16.z.ZodIssueCode.custom, path: ["from_local_part"], message: "is needed for a domain mail is sent from" });
4696
5018
  });
4697
5019
  var DOMAIN_ORDER_STATES = [
4698
5020
  "awaiting_payment",
@@ -4715,8 +5037,10 @@ var DomainOrder = import_zod16.z.object({
4715
5037
  /** Stripe's payment page while `awaiting_payment`; null otherwise. */
4716
5038
  checkout_url: import_zod16.z.string().url().nullable(),
4717
5039
  registrant_name: import_zod16.z.string(),
4718
- from_name: import_zod16.z.string(),
4719
- from_email: Email,
5040
+ kind: DomainOrderKind,
5041
+ /** The sender, for a `sending` order; null for `domain_only`. */
5042
+ from_name: import_zod16.z.string().nullable(),
5043
+ from_email: Email.nullable(),
4720
5044
  /** The sending domain once `ready`. */
4721
5045
  sending_domain_id: Id.nullable(),
4722
5046
  /** When the paid year ends, once registered. */
@@ -4729,36 +5053,124 @@ var DomainOrder = import_zod16.z.object({
4729
5053
  updated_at: Timestamp
4730
5054
  });
4731
5055
 
4732
- // src/contacts.ts
5056
+ // src/bought-domains.ts
4733
5057
  var import_zod17 = require("zod");
4734
- var Topic = import_zod17.z.object({
5058
+ var DOMAIN_LEAVE_WAYS = ["cloudflare_account", "transfer"];
5059
+ var DomainLeaveWay = import_zod17.z.enum(DOMAIN_LEAVE_WAYS);
5060
+ var DOMAIN_LEAVE_STATES = ["requested", "done", "cancelled"];
5061
+ var DomainLeaveState = import_zod17.z.enum(DOMAIN_LEAVE_STATES);
5062
+ var DomainLeave = import_zod17.z.object({
5063
+ id: Id,
5064
+ way: DomainLeaveWay,
5065
+ state: DomainLeaveState,
5066
+ /** The Cloudflare account the domain moves into (way `cloudflare_account`). */
5067
+ target_account_id: import_zod17.z.string().nullable(),
5068
+ /** The transfer code, once support has it (way `transfer`, state `done`); only owners and admins read it. */
5069
+ auth_code: import_zod17.z.string().nullable(),
5070
+ requested_at: Timestamp,
5071
+ done_at: Timestamp.nullable()
5072
+ });
5073
+ var BoughtDomain = import_zod17.z.object({
5074
+ /** The order the domain was bought with. */
5075
+ id: Id,
5076
+ domain: import_zod17.z.string(),
5077
+ kind: DomainOrderKind,
5078
+ registrant_name: import_zod17.z.string(),
5079
+ registered_at: Timestamp,
5080
+ /** When the paid year ends. */
5081
+ expires_at: Timestamp.nullable(),
5082
+ /** Each further year, final, in euro cents; 0 for a domain registered without a charge. */
5083
+ renewal_price_cents: import_zod17.z.number().int().min(0),
5084
+ currency: import_zod17.z.literal("EUR"),
5085
+ /** Registered for one of Lumitra's own companies, never charged. */
5086
+ no_charge: import_zod17.z.boolean(),
5087
+ /** The earliest moment each way of leaving is possible. */
5088
+ move_account_from: Timestamp,
5089
+ transfer_from: Timestamp,
5090
+ /** The latest request to leave, if any. */
5091
+ leave: DomainLeave.nullable(),
5092
+ /** True once the domain has left: its records are no longer Lumitra Mail's to edit. */
5093
+ left: import_zod17.z.boolean()
5094
+ });
5095
+ var DNS_RECORD_TYPES = ["A", "AAAA", "CNAME", "TXT", "MX", "NS"];
5096
+ var DnsRecordType = import_zod17.z.enum(DNS_RECORD_TYPES);
5097
+ var DomainRecord = import_zod17.z.object({
5098
+ id: import_zod17.z.string(),
5099
+ type: import_zod17.z.string(),
5100
+ /** The full name (www.example.com). */
5101
+ name: import_zod17.z.string(),
5102
+ content: import_zod17.z.string(),
5103
+ /** Seconds; 1 is automatic. */
5104
+ ttl: import_zod17.z.number().int(),
5105
+ /** Served through Cloudflare's proxy (A, AAAA, CNAME only). */
5106
+ proxied: import_zod17.z.boolean(),
5107
+ priority: import_zod17.z.number().int().nullable(),
5108
+ /**
5109
+ * Not the holder's to change: a record Lumitra Mail wrote for sending (it
5110
+ * keeps those right itself), or a type the dashboard does not edit.
5111
+ */
5112
+ locked: import_zod17.z.boolean()
5113
+ });
5114
+ var IPV4 = /^(25[0-5]|2[0-4]\d|1?\d?\d)(\.(25[0-5]|2[0-4]\d|1?\d?\d)){3}$/;
5115
+ var HOSTNAME = /^(?=.{1,253}\.?$)([a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9])?\.)*[a-z0-9_](?:[a-z0-9_-]{0,61}[a-z0-9])?\.?$/i;
5116
+ var DomainRecordInput = import_zod17.z.object({
5117
+ type: DnsRecordType,
5118
+ name: import_zod17.z.string().trim().min(1).max(253),
5119
+ content: import_zod17.z.string().trim().min(1).max(2048),
5120
+ ttl: import_zod17.z.union([import_zod17.z.literal(1), import_zod17.z.number().int().min(60).max(86400)]).default(1),
5121
+ proxied: import_zod17.z.boolean().default(false),
5122
+ priority: import_zod17.z.number().int().min(0).max(65535).nullable().optional()
5123
+ }).superRefine((r, ctx) => {
5124
+ const bad = (path, message) => ctx.addIssue({ code: import_zod17.z.ZodIssueCode.custom, path: [path], message });
5125
+ if (r.type === "A" && !IPV4.test(r.content)) bad("content", "must be an IPv4 address, such as 192.0.2.10");
5126
+ if (r.type === "AAAA" && (!r.content.includes(":") || !/^[0-9a-f:.]+$/i.test(r.content))) bad("content", "must be an IPv6 address, such as 2001:db8::10");
5127
+ if ((r.type === "CNAME" || r.type === "MX" || r.type === "NS") && !HOSTNAME.test(r.content)) bad("content", "must be a host name, such as host.example.com");
5128
+ if (r.type === "MX" && (r.priority === void 0 || r.priority === null)) bad("priority", "is needed for an MX record");
5129
+ if (r.type !== "MX" && r.priority !== void 0 && r.priority !== null) bad("priority", "is only for an MX record");
5130
+ if (r.proxied && !["A", "AAAA", "CNAME"].includes(r.type)) bad("proxied", "is only for A, AAAA and CNAME records");
5131
+ });
5132
+ var BoughtDomainRecordParams = import_zod17.z.object({ id: Id, record_id: import_zod17.z.string().regex(/^[0-9a-f]{32}$/, "must be a record id") });
5133
+ var DomainLeaveCreate = import_zod17.z.object({
5134
+ way: DomainLeaveWay,
5135
+ /** The holder's own Cloudflare account id (32 hex characters), for `cloudflare_account`. */
5136
+ target_account_id: import_zod17.z.string().trim().toLowerCase().regex(/^[0-9a-f]{32}$/, "must be a Cloudflare account id: 32 letters and digits, from the account\u2019s overview page").optional()
5137
+ }).superRefine((r, ctx) => {
5138
+ if (r.way === "cloudflare_account" && !r.target_account_id) {
5139
+ ctx.addIssue({ code: import_zod17.z.ZodIssueCode.custom, path: ["target_account_id"], message: "is needed to move the domain into your Cloudflare account" });
5140
+ }
5141
+ });
5142
+ var ZoneFile = import_zod17.z.object({ domain: import_zod17.z.string(), zone_file: import_zod17.z.string() });
5143
+
5144
+ // src/contacts.ts
5145
+ var import_zod18 = require("zod");
5146
+ var Topic = import_zod18.z.object({
4735
5147
  id: Id,
4736
5148
  slug: Slug,
4737
- name: import_zod17.z.string().min(1).max(120),
5149
+ name: import_zod18.z.string().min(1).max(120),
4738
5150
  /** Shown on the hosted preference page. */
4739
- description: import_zod17.z.string().max(1e3).nullable(),
5151
+ description: import_zod18.z.string().max(1e3).nullable(),
4740
5152
  /** Translations of `name` and `description` per locale, for the hosted page. */
4741
- translations: import_zod17.z.record(
4742
- import_zod17.z.object({ name: import_zod17.z.string().min(1).max(120), description: import_zod17.z.string().max(1e3).nullable() })
5153
+ translations: import_zod18.z.record(
5154
+ import_zod18.z.object({ name: import_zod18.z.string().min(1).max(120), description: import_zod18.z.string().max(1e3).nullable() })
4743
5155
  ),
4744
5156
  created_at: Timestamp,
4745
5157
  updated_at: Timestamp
4746
5158
  });
4747
- var TopicCreate = import_zod17.z.object({
5159
+ var TopicCreate = import_zod18.z.object({
4748
5160
  slug: Slug,
4749
- name: import_zod17.z.string().min(1).max(120),
4750
- description: import_zod17.z.string().max(1e3).optional(),
5161
+ name: import_zod18.z.string().min(1).max(120),
5162
+ description: import_zod18.z.string().max(1e3).optional(),
4751
5163
  translations: Topic.shape.translations.optional()
4752
5164
  });
4753
5165
  var TopicUpdate = TopicCreate.omit({ slug: true }).partial().refine((v) => Object.keys(v).length > 0, "at least one field");
4754
- var Contact = import_zod17.z.object({
5166
+ var Contact = import_zod18.z.object({
4755
5167
  id: Id,
4756
- external_id: import_zod17.z.string().min(1).max(255).nullable(),
5168
+ external_id: import_zod18.z.string().min(1).max(255).nullable(),
4757
5169
  /** Stored lowercased, unique per workspace. */
4758
5170
  email: Email,
4759
- first_name: import_zod17.z.string().max(200).nullable(),
4760
- last_name: import_zod17.z.string().max(200).nullable(),
4761
- locale: import_zod17.z.string().min(2).max(35).nullable(),
5171
+ first_name: import_zod18.z.string().max(200).nullable(),
5172
+ last_name: import_zod18.z.string().max(200).nullable(),
5173
+ locale: import_zod18.z.string().min(2).max(35).nullable(),
4762
5174
  /**
4763
5175
  * The person's own time zone, an IANA name such as `Europe/Berlin` (A1).
4764
5176
  * Every wall clock an automation waits for is read in it, falling back to the
@@ -4766,65 +5178,65 @@ var Contact = import_zod17.z.object({
4766
5178
  */
4767
5179
  timezone: TimezoneName.nullable(),
4768
5180
  properties: Properties,
4769
- topics: import_zod17.z.array(Slug),
5181
+ topics: import_zod18.z.array(Slug),
4770
5182
  /** The slugs of the contact's tags (S4). */
4771
- tags: import_zod17.z.array(Slug),
5183
+ tags: import_zod18.z.array(Slug),
4772
5184
  created_at: Timestamp,
4773
5185
  updated_at: Timestamp
4774
5186
  });
4775
- var ContactUpsert = import_zod17.z.object({
4776
- external_id: import_zod17.z.string().min(1).max(255).optional(),
5187
+ var ContactUpsert = import_zod18.z.object({
5188
+ external_id: import_zod18.z.string().min(1).max(255).optional(),
4777
5189
  email: Email.optional(),
4778
- first_name: import_zod17.z.string().max(200).nullable().optional(),
4779
- last_name: import_zod17.z.string().max(200).nullable().optional(),
4780
- locale: import_zod17.z.string().min(2).max(35).nullable().optional(),
5190
+ first_name: import_zod18.z.string().max(200).nullable().optional(),
5191
+ last_name: import_zod18.z.string().max(200).nullable().optional(),
5192
+ locale: import_zod18.z.string().min(2).max(35).nullable().optional(),
4781
5193
  timezone: TimezoneName.nullable().optional(),
4782
5194
  properties: Properties.optional(),
4783
- topics: import_zod17.z.array(Slug).max(100).optional()
5195
+ topics: import_zod18.z.array(Slug).max(100).optional()
4784
5196
  }).refine((v) => v.external_id !== void 0 || v.email !== void 0, {
4785
5197
  message: "external_id or email is required",
4786
5198
  path: ["email"]
4787
5199
  });
4788
- var ContactUpsertResult = import_zod17.z.object({
5200
+ var ContactUpsertResult = import_zod18.z.object({
4789
5201
  contact: Contact,
4790
- created: import_zod17.z.boolean()
5202
+ created: import_zod18.z.boolean()
4791
5203
  });
4792
5204
  var ContactListQuery = PageQuery.extend({
4793
- email: import_zod17.z.string().min(1).max(254).optional(),
4794
- external_id: import_zod17.z.string().min(1).max(255).optional(),
5205
+ email: import_zod18.z.string().min(1).max(254).optional(),
5206
+ external_id: import_zod18.z.string().min(1).max(255).optional(),
4795
5207
  topic: Slug.optional()
4796
5208
  });
4797
- var ContactErased = import_zod17.z.object({
4798
- ok: import_zod17.z.literal(true),
4799
- erased_messages: import_zod17.z.number().int().min(0),
4800
- erased_recipients: import_zod17.z.number().int().min(0),
4801
- suppressions_kept: import_zod17.z.number().int().min(0)
5209
+ var ContactErased = import_zod18.z.object({
5210
+ ok: import_zod18.z.literal(true),
5211
+ erased_messages: import_zod18.z.number().int().min(0),
5212
+ erased_recipients: import_zod18.z.number().int().min(0),
5213
+ suppressions_kept: import_zod18.z.number().int().min(0)
4802
5214
  });
4803
5215
  var SUPPRESSION_REASONS = ["unsubscribed", "bounced", "complained", "manual"];
4804
- var SuppressionReason = import_zod17.z.enum(SUPPRESSION_REASONS);
4805
- var Suppression = import_zod17.z.object({
5216
+ var SuppressionReason = import_zod18.z.enum(SUPPRESSION_REASONS);
5217
+ var Suppression = import_zod18.z.object({
4806
5218
  id: Id,
4807
5219
  email: Email,
4808
5220
  reason: SuppressionReason,
4809
5221
  topic: Slug.nullable(),
4810
5222
  source_message_id: Id.nullable(),
4811
- note: import_zod17.z.string().max(1e3).nullable(),
5223
+ note: import_zod18.z.string().max(1e3).nullable(),
4812
5224
  created_at: Timestamp
4813
5225
  });
4814
- var SuppressionCreate = import_zod17.z.object({
5226
+ var SuppressionCreate = import_zod18.z.object({
4815
5227
  email: Email,
4816
- reason: import_zod17.z.enum(["manual", "unsubscribed"]),
5228
+ reason: import_zod18.z.enum(["manual", "unsubscribed"]),
4817
5229
  topic: Slug.nullable().optional(),
4818
- note: import_zod17.z.string().max(1e3).optional()
5230
+ note: import_zod18.z.string().max(1e3).optional()
4819
5231
  });
4820
5232
  var SuppressionListQuery = PageQuery.extend({
4821
- email: import_zod17.z.string().min(1).max(254).optional(),
5233
+ email: import_zod18.z.string().min(1).max(254).optional(),
4822
5234
  reason: SuppressionReason.optional(),
4823
5235
  topic: Slug.optional()
4824
5236
  });
4825
5237
 
4826
5238
  // src/webhooks.ts
4827
- var import_zod18 = require("zod");
5239
+ var import_zod19 = require("zod");
4828
5240
  var WEBHOOK_EVENT_TYPES = [
4829
5241
  "message.sent",
4830
5242
  "message.failed",
@@ -4868,23 +5280,23 @@ var WEBHOOK_EVENT_TYPES = [
4868
5280
  "template.updated",
4869
5281
  "template.deleted"
4870
5282
  ];
4871
- var WebhookEventType = import_zod18.z.enum(WEBHOOK_EVENT_TYPES);
4872
- var MessageEventBase = import_zod18.z.object({
5283
+ var WebhookEventType = import_zod19.z.enum(WEBHOOK_EVENT_TYPES);
5284
+ var MessageEventBase = import_zod19.z.object({
4873
5285
  message_id: Id,
4874
5286
  mailing_id: Id.nullable(),
4875
5287
  mailing_metadata: MailingMetadata.nullable(),
4876
5288
  recipient_id: Id.nullable(),
4877
5289
  contact_id: Id.nullable(),
4878
- external_id: import_zod18.z.string().nullable(),
5290
+ external_id: import_zod19.z.string().nullable(),
4879
5291
  email: Email,
4880
- subject: import_zod18.z.string(),
5292
+ subject: import_zod19.z.string(),
4881
5293
  topic: Slug.nullable(),
4882
- provider_message_id: import_zod18.z.string().nullable(),
4883
- is_test: import_zod18.z.boolean()
5294
+ provider_message_id: import_zod19.z.string().nullable(),
5295
+ is_test: import_zod19.z.boolean()
4884
5296
  });
4885
5297
  var MessageSentData = MessageEventBase.extend({
4886
5298
  /** The final HTML as sent, so the client can archive it beside its own records. */
4887
- html: import_zod18.z.string(),
5299
+ html: import_zod19.z.string(),
4888
5300
  sent_at: Timestamp,
4889
5301
  /**
4890
5302
  * The choice each insertion made (see `Message.insertions`); absent or null
@@ -4895,20 +5307,20 @@ var MessageSentData = MessageEventBase.extend({
4895
5307
  insertions: InsertionChoices.nullish()
4896
5308
  });
4897
5309
  var MessageFailedData = MessageEventBase.extend({
4898
- error: import_zod18.z.string(),
5310
+ error: import_zod19.z.string(),
4899
5311
  /** False when the provider rejected permanently; the recipient will not be retried. */
4900
- retryable: import_zod18.z.boolean(),
5312
+ retryable: import_zod19.z.boolean(),
4901
5313
  failed_at: Timestamp
4902
5314
  });
4903
5315
  var UNSUBSCRIBE_SOURCES = ["hosted_page", "one_click", "api", "dashboard", "signup_form"];
4904
- var ContactUnsubscribedData = import_zod18.z.object({
5316
+ var ContactUnsubscribedData = import_zod19.z.object({
4905
5317
  contact_id: Id.nullable(),
4906
- external_id: import_zod18.z.string().nullable(),
5318
+ external_id: import_zod19.z.string().nullable(),
4907
5319
  email: Email,
4908
5320
  /** The topic unsubscribed from; null means every topic. */
4909
5321
  topic: Slug.nullable(),
4910
5322
  mailing_id: Id.nullable(),
4911
- source: import_zod18.z.enum(UNSUBSCRIBE_SOURCES),
5323
+ source: import_zod19.z.enum(UNSUBSCRIBE_SOURCES),
4912
5324
  unsubscribed_at: Timestamp
4913
5325
  });
4914
5326
  var ContactResubscribedData = ContactUnsubscribedData.omit({ unsubscribed_at: true }).extend({
@@ -4917,142 +5329,142 @@ var ContactResubscribedData = ContactUnsubscribedData.omit({ unsubscribed_at: tr
4917
5329
  * breaker undid a `bounced` block it judged false (a `contact.bounced` for the
4918
5330
  * same address and mailing went out before); `topic` is null.
4919
5331
  */
4920
- source: import_zod18.z.enum([...UNSUBSCRIBE_SOURCES, "bounce_reverted"]),
5332
+ source: import_zod19.z.enum([...UNSUBSCRIBE_SOURCES, "bounce_reverted"]),
4921
5333
  resubscribed_at: Timestamp
4922
5334
  });
4923
- var ContactBouncedData = import_zod18.z.object({
5335
+ var ContactBouncedData = import_zod19.z.object({
4924
5336
  contact_id: Id.nullable(),
4925
- external_id: import_zod18.z.string().nullable(),
5337
+ external_id: import_zod19.z.string().nullable(),
4926
5338
  email: Email,
4927
5339
  /** `bounced` for a hard bounce, `complained` for a spam complaint. */
4928
- reason: import_zod18.z.enum(["bounced", "complained"]),
5340
+ reason: import_zod19.z.enum(["bounced", "complained"]),
4929
5341
  message_id: Id.nullable(),
4930
- diagnostic: import_zod18.z.string().nullable(),
5342
+ diagnostic: import_zod19.z.string().nullable(),
4931
5343
  bounced_at: Timestamp
4932
5344
  });
4933
- var MailingFinishedData = import_zod18.z.object({
5345
+ var MailingFinishedData = import_zod19.z.object({
4934
5346
  mailing_id: Id,
4935
5347
  mailing_metadata: MailingMetadata,
4936
- status: import_zod18.z.enum(["sent", "partially_failed", "cancelled"]),
5348
+ status: import_zod19.z.enum(["sent", "partially_failed", "cancelled"]),
4937
5349
  counts: MailingCounts,
4938
5350
  finished_at: Timestamp
4939
5351
  });
4940
- var ContactSubscribedData = import_zod18.z.object({
5352
+ var ContactSubscribedData = import_zod19.z.object({
4941
5353
  contact_id: Id,
4942
- external_id: import_zod18.z.string().nullable(),
5354
+ external_id: import_zod19.z.string().nullable(),
4943
5355
  email: Email,
4944
- topics: import_zod18.z.array(Slug),
4945
- source: import_zod18.z.enum(["signup_form", "api", "dashboard", "automation"]),
5356
+ topics: import_zod19.z.array(Slug),
5357
+ source: import_zod19.z.enum(["signup_form", "api", "dashboard", "automation"]),
4946
5358
  signup_form_id: Id.nullable(),
4947
- signup_form_version: import_zod18.z.number().int().min(1).nullable(),
5359
+ signup_form_version: import_zod19.z.number().int().min(1).nullable(),
4948
5360
  subscribed_at: Timestamp
4949
5361
  });
4950
- var ImportFinishedData = import_zod18.z.object({
5362
+ var ImportFinishedData = import_zod19.z.object({
4951
5363
  import_id: Id,
4952
- status: import_zod18.z.enum(["completed", "cancelled", "failed"]),
5364
+ status: import_zod19.z.enum(["completed", "cancelled", "failed"]),
4953
5365
  result: ImportReport.nullable(),
4954
- error: import_zod18.z.string().nullable(),
5366
+ error: import_zod19.z.string().nullable(),
4955
5367
  finished_at: Timestamp
4956
5368
  });
4957
- var MailingScheduledData = import_zod18.z.object({
5369
+ var MailingScheduledData = import_zod19.z.object({
4958
5370
  mailing_id: Id,
4959
5371
  mailing_metadata: MailingMetadata,
4960
5372
  scheduled_at: Timestamp.nullable()
4961
5373
  });
4962
- var MailingStartedData = import_zod18.z.object({
5374
+ var MailingStartedData = import_zod19.z.object({
4963
5375
  mailing_id: Id,
4964
5376
  mailing_metadata: MailingMetadata,
4965
- trigger: import_zod18.z.enum(["send", "schedule"]),
4966
- recipients: import_zod18.z.number().int().min(0),
5377
+ trigger: import_zod19.z.enum(["send", "schedule"]),
5378
+ recipients: import_zod19.z.number().int().min(0),
4967
5379
  started_at: Timestamp
4968
5380
  });
4969
- var MailingScheduleFailedData = import_zod18.z.object({
5381
+ var MailingScheduleFailedData = import_zod19.z.object({
4970
5382
  mailing_id: Id,
4971
5383
  mailing_metadata: MailingMetadata,
4972
- code: import_zod18.z.string(),
4973
- message: import_zod18.z.string(),
5384
+ code: import_zod19.z.string(),
5385
+ message: import_zod19.z.string(),
4974
5386
  failed_at: Timestamp
4975
5387
  });
4976
- var MailingAbWinnerSelectedData = import_zod18.z.object({
5388
+ var MailingAbWinnerSelectedData = import_zod19.z.object({
4977
5389
  mailing_id: Id,
4978
5390
  mailing_metadata: MailingMetadata,
4979
- winner: import_zod18.z.string(),
4980
- decided_by: import_zod18.z.enum(["metric", "manual"]),
4981
- variants: import_zod18.z.array(VariantAnalytics),
5391
+ winner: import_zod19.z.string(),
5392
+ decided_by: import_zod19.z.enum(["metric", "manual"]),
5393
+ variants: import_zod19.z.array(VariantAnalytics),
4982
5394
  decided_at: Timestamp
4983
5395
  });
4984
- var ContactTaggedData = import_zod18.z.object({
5396
+ var ContactTaggedData = import_zod19.z.object({
4985
5397
  contact_id: Id,
4986
- external_id: import_zod18.z.string().nullable(),
5398
+ external_id: import_zod19.z.string().nullable(),
4987
5399
  email: Email,
4988
5400
  /** Only the tags the contact did not already have. */
4989
- tags: import_zod18.z.array(Slug).min(1),
4990
- source: import_zod18.z.enum(["api", "dashboard", "signup_form", "import", "automation"]),
5401
+ tags: import_zod19.z.array(Slug).min(1),
5402
+ source: import_zod19.z.enum(["api", "dashboard", "signup_form", "import", "automation"]),
4991
5403
  tagged_at: Timestamp
4992
5404
  });
4993
- var ContactUpdatedData = import_zod18.z.object({
5405
+ var ContactUpdatedData = import_zod19.z.object({
4994
5406
  contact_id: Id,
4995
- external_id: import_zod18.z.string().nullable(),
5407
+ external_id: import_zod19.z.string().nullable(),
4996
5408
  email: Email,
4997
- changed: import_zod18.z.array(import_zod18.z.string()).min(1),
5409
+ changed: import_zod19.z.array(import_zod19.z.string()).min(1),
4998
5410
  properties: Properties,
4999
- source: import_zod18.z.enum(["api", "dashboard", "signup_form", "import", "automation"]),
5411
+ source: import_zod19.z.enum(["api", "dashboard", "signup_form", "import", "automation"]),
5000
5412
  updated_at: Timestamp
5001
5413
  });
5002
- var AutomationRunEventBase = import_zod18.z.object({
5414
+ var AutomationRunEventBase = import_zod19.z.object({
5003
5415
  automation_id: Id,
5004
- automation_name: import_zod18.z.string(),
5416
+ automation_name: import_zod19.z.string(),
5005
5417
  run_id: Id,
5006
- version: import_zod18.z.number().int().min(1),
5418
+ version: import_zod19.z.number().int().min(1),
5007
5419
  contact_id: Id,
5008
- external_id: import_zod18.z.string().nullable(),
5420
+ external_id: import_zod19.z.string().nullable(),
5009
5421
  email: Email
5010
5422
  });
5011
5423
  var AutomationRunStartedData = AutomationRunEventBase.extend({
5012
5424
  /** What let them in: a trigger kind, or `manual` for an explicit enrolment. */
5013
- trigger_kind: import_zod18.z.string(),
5425
+ trigger_kind: import_zod19.z.string(),
5014
5426
  entered_at: Timestamp
5015
5427
  });
5016
5428
  var AutomationRunCompletedData = AutomationRunEventBase.extend({
5017
- last_step_id: import_zod18.z.string().nullable(),
5429
+ last_step_id: import_zod19.z.string().nullable(),
5018
5430
  completed_at: Timestamp
5019
5431
  });
5020
5432
  var AutomationRunExitedData = AutomationRunEventBase.extend({
5021
5433
  reason: AutomationEndReason,
5022
- step_id: import_zod18.z.string().nullable(),
5434
+ step_id: import_zod19.z.string().nullable(),
5023
5435
  exited_at: Timestamp
5024
5436
  });
5025
5437
  var AutomationRunFailedData = AutomationRunEventBase.extend({
5026
- reason: import_zod18.z.string(),
5027
- step_id: import_zod18.z.string().nullable(),
5438
+ reason: import_zod19.z.string(),
5439
+ step_id: import_zod19.z.string().nullable(),
5028
5440
  failed_at: Timestamp
5029
5441
  });
5030
5442
  var AutomationWebhookData = AutomationRunEventBase.extend({
5031
- step_id: import_zod18.z.string(),
5443
+ step_id: import_zod19.z.string(),
5032
5444
  /** The step's own label, when it was given one, so a receiver can branch on a name. */
5033
- step_label: import_zod18.z.string().nullable(),
5445
+ step_label: import_zod19.z.string().nullable(),
5034
5446
  /** Whatever the step carries, verbatim. Null when it carries nothing. */
5035
5447
  payload: JsonValue.nullable(),
5036
5448
  fired_at: Timestamp
5037
5449
  });
5038
- var TemplateEventBase = import_zod18.z.object({
5450
+ var TemplateEventBase = import_zod19.z.object({
5039
5451
  template_id: Id,
5040
- name: import_zod18.z.string().min(1).max(200),
5041
- version: import_zod18.z.number().int().min(1),
5042
- source: import_zod18.z.enum(["api", "dashboard", "mjml_import"])
5452
+ name: import_zod19.z.string().min(1).max(200),
5453
+ version: import_zod19.z.number().int().min(1),
5454
+ source: import_zod19.z.enum(["api", "dashboard", "mjml_import"])
5043
5455
  });
5044
5456
  var TemplateCreatedData = TemplateEventBase.extend({ created_at: Timestamp });
5045
- var TemplateUpdatedData = TemplateEventBase.extend({ archived: import_zod18.z.boolean(), updated_at: Timestamp });
5457
+ var TemplateUpdatedData = TemplateEventBase.extend({ archived: import_zod19.z.boolean(), updated_at: Timestamp });
5046
5458
  var TemplateDeletedData = TemplateEventBase.extend({ deleted_at: Timestamp });
5047
- var envelope = (type, data) => import_zod18.z.object({
5459
+ var envelope = (type, data) => import_zod19.z.object({
5048
5460
  /** Unique per event: a receiver deduplicates on it (deliveries may repeat). */
5049
5461
  id: Id,
5050
- type: import_zod18.z.literal(type),
5462
+ type: import_zod19.z.literal(type),
5051
5463
  created_at: Timestamp,
5052
5464
  workspace_id: Id,
5053
5465
  data
5054
5466
  });
5055
- var WebhookEvent = import_zod18.z.discriminatedUnion("type", [
5467
+ var WebhookEvent = import_zod19.z.discriminatedUnion("type", [
5056
5468
  envelope("message.sent", MessageSentData),
5057
5469
  envelope("message.failed", MessageFailedData),
5058
5470
  envelope("contact.unsubscribed", ContactUnsubscribedData),
@@ -5076,16 +5488,16 @@ var WebhookEvent = import_zod18.z.discriminatedUnion("type", [
5076
5488
  envelope("template.updated", TemplateUpdatedData),
5077
5489
  envelope("template.deleted", TemplateDeletedData)
5078
5490
  ]);
5079
- var WebhookEndpoint = import_zod18.z.object({
5491
+ var WebhookEndpoint = import_zod19.z.object({
5080
5492
  id: Id,
5081
- url: import_zod18.z.string().url(),
5082
- description: import_zod18.z.string().max(500).nullable(),
5083
- events: import_zod18.z.array(WebhookEventType).min(1),
5084
- enabled: import_zod18.z.boolean(),
5493
+ url: import_zod19.z.string().url(),
5494
+ description: import_zod19.z.string().max(500).nullable(),
5495
+ events: import_zod19.z.array(WebhookEventType).min(1),
5496
+ enabled: import_zod19.z.boolean(),
5085
5497
  created_at: Timestamp,
5086
5498
  updated_at: Timestamp
5087
5499
  });
5088
- var WebhookUrl = import_zod18.z.string().url().refine((u) => {
5500
+ var WebhookUrl = import_zod19.z.string().url().refine((u) => {
5089
5501
  try {
5090
5502
  const url = new URL(u);
5091
5503
  if (url.protocol === "https:") return true;
@@ -5094,35 +5506,35 @@ var WebhookUrl = import_zod18.z.string().url().refine((u) => {
5094
5506
  return false;
5095
5507
  }
5096
5508
  }, "must be https (http only for localhost)");
5097
- var WebhookEndpointCreate = import_zod18.z.object({
5509
+ var WebhookEndpointCreate = import_zod19.z.object({
5098
5510
  url: WebhookUrl,
5099
- description: import_zod18.z.string().max(500).optional(),
5100
- events: import_zod18.z.array(WebhookEventType).min(1),
5101
- enabled: import_zod18.z.boolean().optional()
5511
+ description: import_zod19.z.string().max(500).optional(),
5512
+ events: import_zod19.z.array(WebhookEventType).min(1),
5513
+ enabled: import_zod19.z.boolean().optional()
5102
5514
  });
5103
- var WebhookEndpointUpdate = import_zod18.z.object({
5515
+ var WebhookEndpointUpdate = import_zod19.z.object({
5104
5516
  url: WebhookUrl,
5105
- description: import_zod18.z.string().max(500).nullable(),
5106
- events: import_zod18.z.array(WebhookEventType).min(1),
5107
- enabled: import_zod18.z.boolean()
5517
+ description: import_zod19.z.string().max(500).nullable(),
5518
+ events: import_zod19.z.array(WebhookEventType).min(1),
5519
+ enabled: import_zod19.z.boolean()
5108
5520
  }).partial().refine((v) => Object.keys(v).length > 0, "at least one field");
5109
- var WebhookEndpointWithSecret = import_zod18.z.object({
5521
+ var WebhookEndpointWithSecret = import_zod19.z.object({
5110
5522
  endpoint: WebhookEndpoint,
5111
- secret: import_zod18.z.string().min(32)
5523
+ secret: import_zod19.z.string().min(32)
5112
5524
  });
5113
5525
  var WEBHOOK_DELIVERY_STATUSES = ["pending", "succeeded", "failed"];
5114
- var WebhookDeliveryStatus = import_zod18.z.enum(WEBHOOK_DELIVERY_STATUSES);
5526
+ var WebhookDeliveryStatus = import_zod19.z.enum(WEBHOOK_DELIVERY_STATUSES);
5115
5527
  var WEBHOOK_MAX_ATTEMPTS = 8;
5116
5528
  var WEBHOOK_RETRY_DELAYS_SECONDS = [30, 120, 600, 1800, 3600, 7200, 21600];
5117
- var WebhookDelivery = import_zod18.z.object({
5529
+ var WebhookDelivery = import_zod19.z.object({
5118
5530
  id: Id,
5119
5531
  endpoint_id: Id,
5120
5532
  event_id: Id,
5121
5533
  event_type: WebhookEventType,
5122
5534
  status: WebhookDeliveryStatus,
5123
- attempts: import_zod18.z.number().int().min(0),
5124
- last_status_code: import_zod18.z.number().int().min(100).max(599).nullable(),
5125
- last_error: import_zod18.z.string().nullable(),
5535
+ attempts: import_zod19.z.number().int().min(0),
5536
+ last_status_code: import_zod19.z.number().int().min(100).max(599).nullable(),
5537
+ last_error: import_zod19.z.string().nullable(),
5126
5538
  next_attempt_at: Timestamp.nullable(),
5127
5539
  delivered_at: Timestamp.nullable(),
5128
5540
  created_at: Timestamp
@@ -5131,7 +5543,7 @@ var WebhookDeliveryListQuery = PageQuery.extend({
5131
5543
  status: WebhookDeliveryStatus.optional(),
5132
5544
  event_type: WebhookEventType.optional()
5133
5545
  });
5134
- var WebhookDeliveryParams = import_zod18.z.object({ id: Id, delivery_id: Id });
5546
+ var WebhookDeliveryParams = import_zod19.z.object({ id: Id, delivery_id: Id });
5135
5547
 
5136
5548
  // src/webhook-signing.ts
5137
5549
  var WEBHOOK_SIGNATURE_HEADER = "x-mail-signature";
@@ -5198,99 +5610,99 @@ async function verifyWebhook(input) {
5198
5610
  }
5199
5611
 
5200
5612
  // src/billing.ts
5201
- var import_zod19 = require("zod");
5613
+ var import_zod20 = require("zod");
5202
5614
  var PLAN_IDS = ["free", "starter", "growth", "design_partner"];
5203
- var PlanId = import_zod19.z.enum(PLAN_IDS);
5204
- var PlanLimits = import_zod19.z.object({
5205
- monthly_messages: import_zod19.z.number().int().min(0).nullable(),
5206
- contacts: import_zod19.z.number().int().min(0).nullable(),
5207
- members: import_zod19.z.number().int().min(1).nullable(),
5208
- providers: import_zod19.z.number().int().min(1).nullable(),
5209
- webhook_endpoints: import_zod19.z.number().int().min(0).nullable(),
5615
+ var PlanId = import_zod20.z.enum(PLAN_IDS);
5616
+ var PlanLimits = import_zod20.z.object({
5617
+ monthly_messages: import_zod20.z.number().int().min(0).nullable(),
5618
+ contacts: import_zod20.z.number().int().min(0).nullable(),
5619
+ members: import_zod20.z.number().int().min(1).nullable(),
5620
+ providers: import_zod20.z.number().int().min(1).nullable(),
5621
+ webhook_endpoints: import_zod20.z.number().int().min(0).nullable(),
5210
5622
  /** Automations that may be live (active or paused) at once (A1). */
5211
- active_automations: import_zod19.z.number().int().min(0).nullable(),
5623
+ active_automations: import_zod20.z.number().int().min(0).nullable(),
5212
5624
  /** Steps one automation may hold. Null is the flow's own cap, not unlimited. */
5213
- automation_steps: import_zod19.z.number().int().min(1).nullable(),
5625
+ automation_steps: import_zod20.z.number().int().min(1).nullable(),
5214
5626
  /** Own domains Lumitra Mail sends from (managed sending domains); 0 when the plan has none. */
5215
- sending_domains: import_zod19.z.number().int().min(0).nullable()
5627
+ sending_domains: import_zod20.z.number().int().min(0).nullable()
5216
5628
  });
5217
- var PlanFeatures = import_zod19.z.object({
5629
+ var PlanFeatures = import_zod20.z.object({
5218
5630
  /** A/B tests of subject and content on a mailing (S4). */
5219
- ab_testing: import_zod19.z.boolean(),
5631
+ ab_testing: import_zod20.z.boolean(),
5220
5632
  /** Open and click tracking, still off until a workspace turns it on (`settings.tracking_enabled`). */
5221
- tracking: import_zod19.z.boolean(),
5633
+ tracking: import_zod20.z.boolean(),
5222
5634
  /** Automations: flows a person walks through step by step (A1). */
5223
- automations: import_zod19.z.boolean()
5635
+ automations: import_zod20.z.boolean()
5224
5636
  });
5225
5637
  var PLAN_FEATURES = ["ab_testing", "tracking", "automations"];
5226
- var Plan = import_zod19.z.object({
5638
+ var Plan = import_zod20.z.object({
5227
5639
  id: PlanId,
5228
- name: import_zod19.z.string().min(1),
5640
+ name: import_zod20.z.string().min(1),
5229
5641
  /** Price in the smallest currency unit per month; null for plans not sold. */
5230
- monthly_price_cents: import_zod19.z.number().int().min(0).nullable(),
5231
- currency: import_zod19.z.string().length(3),
5642
+ monthly_price_cents: import_zod20.z.number().int().min(0).nullable(),
5643
+ currency: import_zod20.z.string().length(3),
5232
5644
  limits: PlanLimits,
5233
5645
  features: PlanFeatures
5234
5646
  });
5235
- var CatalogPlan = Plan.extend({ sellable: import_zod19.z.boolean() });
5236
- var Subscription = import_zod19.z.object({
5647
+ var CatalogPlan = Plan.extend({ sellable: import_zod20.z.boolean() });
5648
+ var Subscription = import_zod20.z.object({
5237
5649
  workspace_id: Id,
5238
5650
  plan: PlanId,
5239
- status: import_zod19.z.enum(["active", "trialing", "past_due", "cancelled"]),
5651
+ status: import_zod20.z.enum(["active", "trialing", "past_due", "cancelled"]),
5240
5652
  current_period_start: Timestamp,
5241
5653
  current_period_end: Timestamp,
5242
- cancel_at_period_end: import_zod19.z.boolean(),
5654
+ cancel_at_period_end: import_zod20.z.boolean(),
5243
5655
  /**
5244
5656
  * A design partner outside billing (plan `design_partner`, no limits, no
5245
5657
  * checkout). Set only by an operator, never through the API.
5246
5658
  */
5247
- billing_exempt: import_zod19.z.boolean(),
5659
+ billing_exempt: import_zod20.z.boolean(),
5248
5660
  /**
5249
5661
  * Own sending domains bought on top of the plan's included ones (the
5250
5662
  * add-on), each a monthly charge on the same subscription. 0 without the
5251
5663
  * add-on; the usage limit `sending_domains` is the plan's plus these.
5252
5664
  */
5253
- extra_sending_domains: import_zod19.z.number().int().min(0)
5665
+ extra_sending_domains: import_zod20.z.number().int().min(0)
5254
5666
  });
5255
- var BillingAddons = import_zod19.z.object({
5256
- sending_domain: import_zod19.z.object({
5257
- monthly_price_cents: import_zod19.z.number().int().min(0),
5258
- currency: import_zod19.z.string().length(3),
5259
- sellable: import_zod19.z.boolean()
5667
+ var BillingAddons = import_zod20.z.object({
5668
+ sending_domain: import_zod20.z.object({
5669
+ monthly_price_cents: import_zod20.z.number().int().min(0),
5670
+ currency: import_zod20.z.string().length(3),
5671
+ sellable: import_zod20.z.boolean()
5260
5672
  })
5261
5673
  });
5262
5674
  var MAX_EXTRA_SENDING_DOMAINS = 100;
5263
- var ExtraSendingDomainsUpdate = import_zod19.z.object({ quantity: import_zod19.z.number().int().min(0).max(MAX_EXTRA_SENDING_DOMAINS) });
5675
+ var ExtraSendingDomainsUpdate = import_zod20.z.object({ quantity: import_zod20.z.number().int().min(0).max(MAX_EXTRA_SENDING_DOMAINS) });
5264
5676
  var USAGE_METRICS = ["messages", "contacts", "members", "providers", "webhook_endpoints", "active_automations", "sending_domains"];
5265
- var UsageMetric = import_zod19.z.enum(USAGE_METRICS);
5677
+ var UsageMetric = import_zod20.z.enum(USAGE_METRICS);
5266
5678
  var USAGE_WARNING_RATIO = 0.8;
5267
- var UsageWarning = import_zod19.z.object({
5679
+ var UsageWarning = import_zod20.z.object({
5268
5680
  metric: UsageMetric,
5269
- used: import_zod19.z.number().int().min(0),
5270
- limit: import_zod19.z.number().int().min(0),
5681
+ used: import_zod20.z.number().int().min(0),
5682
+ limit: import_zod20.z.number().int().min(0),
5271
5683
  /** `approaching`: at or above USAGE_WARNING_RATIO of the limit; `reached`: at or above the limit. */
5272
- level: import_zod19.z.enum(["approaching", "reached"])
5684
+ level: import_zod20.z.enum(["approaching", "reached"])
5273
5685
  });
5274
- var TermsStatus = import_zod19.z.object({ accepted_version: import_zod19.z.string().nullable(), current_version: import_zod19.z.string() });
5275
- var Usage = import_zod19.z.object({
5686
+ var TermsStatus = import_zod20.z.object({ accepted_version: import_zod20.z.string().nullable(), current_version: import_zod20.z.string() });
5687
+ var Usage = import_zod20.z.object({
5276
5688
  plan: PlanId,
5277
5689
  period_start: Timestamp,
5278
5690
  period_end: Timestamp,
5279
- metrics: import_zod19.z.record(UsageMetric, import_zod19.z.object({ used: import_zod19.z.number().int().min(0), limit: import_zod19.z.number().int().min(0).nullable() })),
5280
- warnings: import_zod19.z.array(UsageWarning),
5691
+ metrics: import_zod20.z.record(UsageMetric, import_zod20.z.object({ used: import_zod20.z.number().int().min(0), limit: import_zod20.z.number().int().min(0).nullable() })),
5692
+ warnings: import_zod20.z.array(UsageWarning),
5281
5693
  terms: TermsStatus
5282
5694
  });
5283
- var TermsAcceptance = import_zod19.z.object({ accept_terms: AcceptTerms });
5284
- var CheckoutRequest = import_zod19.z.object({
5285
- plan: import_zod19.z.enum(["starter", "growth"]),
5286
- success_url: import_zod19.z.string().url(),
5287
- cancel_url: import_zod19.z.string().url(),
5695
+ var TermsAcceptance = import_zod20.z.object({ accept_terms: AcceptTerms });
5696
+ var CheckoutRequest = import_zod20.z.object({
5697
+ plan: import_zod20.z.enum(["starter", "growth"]),
5698
+ success_url: import_zod20.z.string().url(),
5699
+ cancel_url: import_zod20.z.string().url(),
5288
5700
  /** The buyer accepted the terms of service and the processing agreement of this version. */
5289
5701
  accept_terms: AcceptTerms
5290
5702
  });
5291
- var CheckoutSession = import_zod19.z.object({ url: import_zod19.z.string().url() });
5292
- var PortalRequest = import_zod19.z.object({ return_url: import_zod19.z.string().url() });
5293
- var PortalSession = import_zod19.z.object({ url: import_zod19.z.string().url() });
5703
+ var CheckoutSession = import_zod20.z.object({ url: import_zod20.z.string().url() });
5704
+ var PortalRequest = import_zod20.z.object({ return_url: import_zod20.z.string().url() });
5705
+ var PortalSession = import_zod20.z.object({ url: import_zod20.z.string().url() });
5294
5706
  var USAGE_WARNING_HEADER = "x-mail-usage-warning";
5295
5707
  function formatUsageWarningHeader(warnings) {
5296
5708
  if (warnings.length === 0) return null;
@@ -5310,7 +5722,7 @@ function parseUsageWarningHeader(value) {
5310
5722
  }
5311
5723
 
5312
5724
  // src/routes.ts
5313
- var import_zod20 = require("zod");
5725
+ var import_zod21 = require("zod");
5314
5726
  var list = (item) => page(item);
5315
5727
  var foundationRoutes = {
5316
5728
  "workspaces.create": {
@@ -5556,7 +5968,7 @@ var templateRoutes = {
5556
5968
  path: "/v1/templates/:id/export",
5557
5969
  params: IdParams,
5558
5970
  query: TemplateExportQuery,
5559
- response: import_zod20.z.string(),
5971
+ response: import_zod21.z.string(),
5560
5972
  responseType: "text",
5561
5973
  status: 200,
5562
5974
  access: "read",
@@ -5936,7 +6348,7 @@ var sendingRoutes = {
5936
6348
  path: "/v1/mailings/:id/export",
5937
6349
  params: IdParams,
5938
6350
  query: MailingExportQuery,
5939
- response: import_zod20.z.string(),
6351
+ response: import_zod21.z.string(),
5940
6352
  responseType: "text",
5941
6353
  status: 200,
5942
6354
  access: "read",
@@ -6203,7 +6615,7 @@ var platformRoutes = {
6203
6615
  "contactProperties.list": {
6204
6616
  method: "GET",
6205
6617
  path: "/v1/contact-properties",
6206
- response: import_zod20.z.object({ data: import_zod20.z.array(ContactPropertyDefinition) }),
6618
+ response: import_zod21.z.object({ data: import_zod21.z.array(ContactPropertyDefinition) }),
6207
6619
  status: 200,
6208
6620
  access: "read",
6209
6621
  phase: "S4"
@@ -6502,7 +6914,7 @@ var billingRoutes = {
6502
6914
  "billing.plans": {
6503
6915
  method: "GET",
6504
6916
  path: "/v1/billing/plans",
6505
- response: import_zod20.z.object({ data: import_zod20.z.array(CatalogPlan), addons: BillingAddons }),
6917
+ response: import_zod21.z.object({ data: import_zod21.z.array(CatalogPlan), addons: BillingAddons }),
6506
6918
  status: 200,
6507
6919
  access: "read",
6508
6920
  phase: "S5"
@@ -6591,6 +7003,73 @@ var domainBuyingRoutes = {
6591
7003
  phase: "S5"
6592
7004
  }
6593
7005
  };
7006
+ var boughtDomainRoutes = {
7007
+ "boughtDomains.list": {
7008
+ method: "GET",
7009
+ path: "/v1/bought-domains",
7010
+ response: import_zod21.z.object({ data: import_zod21.z.array(BoughtDomain) }),
7011
+ status: 200,
7012
+ access: "admin",
7013
+ phase: "S5"
7014
+ },
7015
+ "boughtDomains.records": {
7016
+ method: "GET",
7017
+ path: "/v1/bought-domains/:id/records",
7018
+ params: IdParams,
7019
+ response: import_zod21.z.object({ data: import_zod21.z.array(DomainRecord) }),
7020
+ status: 200,
7021
+ access: "admin",
7022
+ phase: "S5"
7023
+ },
7024
+ "boughtDomains.createRecord": {
7025
+ method: "POST",
7026
+ path: "/v1/bought-domains/:id/records",
7027
+ params: IdParams,
7028
+ body: DomainRecordInput,
7029
+ response: DomainRecord,
7030
+ status: 201,
7031
+ access: "admin",
7032
+ phase: "S5"
7033
+ },
7034
+ "boughtDomains.updateRecord": {
7035
+ method: "PATCH",
7036
+ path: "/v1/bought-domains/:id/records/:record_id",
7037
+ params: BoughtDomainRecordParams,
7038
+ body: DomainRecordInput,
7039
+ response: DomainRecord,
7040
+ status: 200,
7041
+ access: "admin",
7042
+ phase: "S5"
7043
+ },
7044
+ "boughtDomains.deleteRecord": {
7045
+ method: "DELETE",
7046
+ path: "/v1/bought-domains/:id/records/:record_id",
7047
+ params: BoughtDomainRecordParams,
7048
+ response: Ok,
7049
+ status: 200,
7050
+ access: "admin",
7051
+ phase: "S5"
7052
+ },
7053
+ "boughtDomains.zoneFile": {
7054
+ method: "GET",
7055
+ path: "/v1/bought-domains/:id/zone-file",
7056
+ params: IdParams,
7057
+ response: ZoneFile,
7058
+ status: 200,
7059
+ access: "admin",
7060
+ phase: "S5"
7061
+ },
7062
+ "boughtDomains.leave": {
7063
+ method: "POST",
7064
+ path: "/v1/bought-domains/:id/leave",
7065
+ params: IdParams,
7066
+ body: DomainLeaveCreate,
7067
+ response: BoughtDomain,
7068
+ status: 201,
7069
+ access: "admin",
7070
+ phase: "S5"
7071
+ }
7072
+ };
6594
7073
  var inviteRoutes = {
6595
7074
  "invites.create": {
6596
7075
  method: "POST",
@@ -6700,7 +7179,7 @@ var automationRoutes = {
6700
7179
  method: "POST",
6701
7180
  path: "/v1/automations/:id/pause",
6702
7181
  params: IdParams,
6703
- body: import_zod20.z.object({}).strict(),
7182
+ body: import_zod21.z.object({}).strict(),
6704
7183
  response: Automation,
6705
7184
  status: 200,
6706
7185
  access: "write",
@@ -6710,7 +7189,7 @@ var automationRoutes = {
6710
7189
  method: "POST",
6711
7190
  path: "/v1/automations/:id/resume",
6712
7191
  params: IdParams,
6713
- body: import_zod20.z.object({}).strict(),
7192
+ body: import_zod21.z.object({}).strict(),
6714
7193
  response: Automation,
6715
7194
  status: 200,
6716
7195
  access: "write",
@@ -6720,7 +7199,7 @@ var automationRoutes = {
6720
7199
  method: "POST",
6721
7200
  path: "/v1/automations/:id/archive",
6722
7201
  params: IdParams,
6723
- body: import_zod20.z.object({}).strict(),
7202
+ body: import_zod21.z.object({}).strict(),
6724
7203
  response: Automation,
6725
7204
  status: 200,
6726
7205
  access: "write",
@@ -6836,6 +7315,7 @@ var routes = {
6836
7315
  ...platformRoutes,
6837
7316
  ...billingRoutes,
6838
7317
  ...domainBuyingRoutes,
7318
+ ...boughtDomainRoutes,
6839
7319
  ...automationRoutes
6840
7320
  };
6841
7321
  var TRUSTED_APP_OPERATIONS = {
@@ -6968,6 +7448,8 @@ function matchRoute(method, pathname) {
6968
7448
  BEARER_PREFIX,
6969
7449
  BILLING_NOT_CONFIGURED_REASON,
6970
7450
  BillingAddons,
7451
+ BoughtDomain,
7452
+ BoughtDomainRecordParams,
6971
7453
  BoundedAutomationFilter,
6972
7454
  BoundedSegmentFilter,
6973
7455
  COMPANY_GRANT_ROLES,
@@ -7002,21 +7484,33 @@ function matchRoute(method, pathname) {
7002
7484
  DATE_PASSED_ANSWERS,
7003
7485
  DEFAULT_INVITE_TTL_DAYS,
7004
7486
  DEFAULT_PAGE_LIMIT,
7487
+ DNS_RECORD_TYPES,
7005
7488
  DOCUMENT_SCHEMA_VERSIONS,
7006
7489
  DOMAIN_BUYING_BLOCKS,
7007
7490
  DOMAIN_BUYING_NOT_CONFIGURED_REASON,
7491
+ DOMAIN_LEAVE_STATES,
7492
+ DOMAIN_LEAVE_WAYS,
7493
+ DOMAIN_ORDER_KINDS,
7008
7494
  DOMAIN_ORDER_STATES,
7009
7495
  DOMAIN_PRICE_CHANGED_REASON,
7010
7496
  DOMAIN_UNAVAILABLE_REASONS,
7011
7497
  DateOnly,
7012
7498
  DatePassedAnswer,
7013
7499
  DelayStep,
7500
+ DnsRecordType,
7014
7501
  DocumentSchemaVersion,
7015
7502
  DomainBuyingBlock,
7503
+ DomainLeave,
7504
+ DomainLeaveCreate,
7505
+ DomainLeaveState,
7506
+ DomainLeaveWay,
7016
7507
  DomainOffer,
7017
7508
  DomainOrder,
7018
7509
  DomainOrderCreate,
7510
+ DomainOrderKind,
7019
7511
  DomainOrderState,
7512
+ DomainRecord,
7513
+ DomainRecordInput,
7020
7514
  DomainRegistrant,
7021
7515
  DomainSearchQuery,
7022
7516
  DomainSearchResult,
@@ -7229,6 +7723,7 @@ function matchRoute(method, pathname) {
7229
7723
  QuietHours,
7230
7724
  RECIPIENT_REJECTIONS,
7231
7725
  RECIPIENT_STATUSES,
7726
+ REGISTRY_PHONE,
7232
7727
  REQUEST_ID_HEADER,
7233
7728
  RESEND_EVENT_TYPES,
7234
7729
  RESERVED_MERGE_FIELDS,
@@ -7393,6 +7888,7 @@ function matchRoute(method, pathname) {
7393
7888
  WorkspaceMove,
7394
7889
  WorkspaceSettings,
7395
7890
  WorkspaceUpdate,
7891
+ ZoneFile,
7396
7892
  acceptsIdempotencyKey,
7397
7893
  addInsertion,
7398
7894
  addInsertionChoice,
@@ -7402,6 +7898,7 @@ function matchRoute(method, pathname) {
7402
7898
  automationFilterFamily,
7403
7899
  automationRoutes,
7404
7900
  billingRoutes,
7901
+ boughtDomainRoutes,
7405
7902
  buildPath,
7406
7903
  buildTemplatePatch,
7407
7904
  canDeleteMailing,
@@ -7466,6 +7963,7 @@ function matchRoute(method, pathname) {
7466
7963
  missingInsertionTexts,
7467
7964
  missingRequiredMergeFields,
7468
7965
  normalizeChoiceKey,
7966
+ normalizePhone,
7469
7967
  nowSeconds,
7470
7968
  operationsWithAccess,
7471
7969
  ownEntry,