samva 0.16.0 → 0.18.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.
Files changed (167) hide show
  1. package/AGENTS.md +9 -1
  2. package/README.md +57 -1
  3. package/dist/{rolldown-runtime-D7D4PA-g.js → _virtual/_rolldown/runtime.js} +1 -1
  4. package/dist/client/client/client.gen.js +174 -0
  5. package/dist/client/client/utils.gen.js +177 -0
  6. package/dist/client/client.gen.js +8 -0
  7. package/dist/client/core/auth.gen.js +12 -0
  8. package/dist/client/core/bodySerializer.gen.js +6 -0
  9. package/dist/client/core/params.gen.js +77 -0
  10. package/dist/client/core/pathSerializer.gen.js +82 -0
  11. package/dist/client/core/serverSentEvents.gen.js +96 -0
  12. package/dist/client/core/utils.gen.js +78 -0
  13. package/dist/client/sdk.gen.d.ts +174 -3
  14. package/dist/{promises-KrA2nSLg.js → client/sdk.gen.js} +464 -2289
  15. package/dist/client/types.gen.d.ts +1126 -11
  16. package/dist/client-attribution.js +9 -0
  17. package/dist/effect/analytics.d.ts +6 -6
  18. package/dist/effect/analytics.js +11 -9
  19. package/dist/effect/api-keys.d.ts +13 -13
  20. package/dist/effect/api-keys.js +13 -12
  21. package/dist/effect/attachments.d.ts +4 -4
  22. package/dist/effect/attachments.js +9 -7
  23. package/dist/effect/brands.d.ts +7 -7
  24. package/dist/effect/brands.js +12 -10
  25. package/dist/effect/campaigns.d.ts +18 -18
  26. package/dist/effect/campaigns.js +17 -15
  27. package/dist/effect/categories.d.ts +2 -2
  28. package/dist/effect/categories.js +95 -1
  29. package/dist/effect/client.d.ts +1 -1
  30. package/dist/effect/client.js +4 -5
  31. package/dist/effect/contact-groups.d.ts +14 -14
  32. package/dist/effect/contact-groups.js +15 -13
  33. package/dist/effect/contacts.d.ts +77 -25
  34. package/dist/effect/contacts.js +27 -22
  35. package/dist/effect/conversations.d.ts +17 -17
  36. package/dist/effect/conversations.js +18 -16
  37. package/dist/effect/custom-fields.d.ts +4 -4
  38. package/dist/effect/custom-fields.js +9 -7
  39. package/dist/effect/email.d.ts +78 -77
  40. package/dist/effect/email.js +68 -65
  41. package/dist/effect/errors.d.ts +2 -0
  42. package/dist/effect/errors.js +3 -0
  43. package/dist/effect/events.d.ts +121 -0
  44. package/dist/effect/events.js +17 -0
  45. package/dist/effect/extension-installations.d.ts +11 -11
  46. package/dist/effect/extension-installations.js +14 -12
  47. package/dist/effect/extensions.d.ts +9 -9
  48. package/dist/effect/extensions.js +10 -8
  49. package/dist/effect/feedback.d.ts +2 -2
  50. package/dist/effect/feedback.js +6 -5
  51. package/dist/effect/generated/analytics.d.ts +715 -0
  52. package/dist/effect/generated/analytics.js +188 -0
  53. package/dist/effect/generated/api-keys.d.ts +1627 -0
  54. package/dist/effect/generated/api-keys.js +249 -0
  55. package/dist/effect/generated/attachments.d.ts +554 -0
  56. package/dist/effect/generated/attachments.js +125 -0
  57. package/dist/effect/generated/brands.d.ts +1118 -0
  58. package/dist/effect/generated/brands.js +155 -0
  59. package/dist/effect/generated/campaigns.d.ts +3783 -0
  60. package/dist/effect/generated/campaigns.js +491 -0
  61. package/dist/effect/generated/contact-events.d.ts +158 -0
  62. package/dist/effect/generated/contact-events.js +37 -0
  63. package/dist/effect/generated/contact-groups.d.ts +1445 -0
  64. package/dist/effect/generated/contact-groups.js +419 -0
  65. package/dist/effect/generated/contacts.d.ts +3789 -0
  66. package/dist/effect/generated/contacts.js +709 -0
  67. package/dist/effect/generated/conversations.d.ts +2870 -0
  68. package/dist/effect/generated/conversations.js +461 -0
  69. package/dist/effect/generated/custom-fields.d.ts +562 -0
  70. package/dist/effect/generated/custom-fields.js +162 -0
  71. package/dist/effect/generated/email.d.ts +10622 -0
  72. package/dist/effect/generated/email.js +2347 -0
  73. package/dist/effect/generated/events.d.ts +463 -0
  74. package/dist/effect/generated/events.js +70 -0
  75. package/dist/effect/generated/extension-installations.d.ts +1786 -0
  76. package/dist/effect/generated/extension-installations.js +382 -0
  77. package/dist/effect/generated/extensions.d.ts +927 -0
  78. package/dist/effect/generated/extensions.js +203 -0
  79. package/dist/effect/generated/feedback.d.ts +116 -0
  80. package/dist/effect/generated/feedback.js +43 -0
  81. package/dist/effect/generated/index.d.ts +61 -0
  82. package/dist/effect/generated/journeys.d.ts +6135 -0
  83. package/dist/effect/generated/journeys.js +464 -0
  84. package/dist/effect/generated/mailboxes.d.ts +13641 -0
  85. package/dist/effect/generated/mailboxes.js +2312 -0
  86. package/dist/effect/generated/media.d.ts +741 -0
  87. package/dist/effect/generated/media.js +181 -0
  88. package/dist/effect/generated/messages.d.ts +2355 -0
  89. package/dist/effect/generated/messages.js +671 -0
  90. package/dist/effect/generated/namespaces.d.ts +654 -0
  91. package/dist/effect/generated/namespaces.js +135 -0
  92. package/dist/effect/generated/operations.d.ts +514 -0
  93. package/dist/effect/generated/operations.js +80 -0
  94. package/dist/effect/generated/organizations.d.ts +1111 -0
  95. package/dist/effect/generated/organizations.js +231 -0
  96. package/dist/effect/generated/scheduled-messages.d.ts +1798 -0
  97. package/dist/effect/generated/scheduled-messages.js +190 -0
  98. package/dist/effect/generated/shared.d.ts +3250 -0
  99. package/dist/effect/generated/shared.js +1053 -0
  100. package/dist/effect/generated/subscriptions.d.ts +188 -0
  101. package/dist/effect/generated/subscriptions.js +61 -0
  102. package/dist/effect/generated/templates.d.ts +8177 -0
  103. package/dist/effect/generated/templates.js +2214 -0
  104. package/dist/effect/generated/unsubscribe-groups.d.ts +1153 -0
  105. package/dist/effect/generated/unsubscribe-groups.js +267 -0
  106. package/dist/effect/generated/webhooks.d.ts +1697 -0
  107. package/dist/effect/generated/webhooks.js +500 -0
  108. package/dist/effect/generated/whoami.d.ts +291 -0
  109. package/dist/effect/generated/whoami.js +54 -0
  110. package/dist/effect/generated-metadata.d.ts +1627 -0
  111. package/dist/effect/generated-metadata.js +919 -0
  112. package/dist/effect/index.d.ts +3 -2
  113. package/dist/effect/index.js +33 -31
  114. package/dist/effect/internal/client.d.ts +10 -7
  115. package/dist/effect/internal/client.js +69 -0
  116. package/dist/effect/internal/email-sender.d.ts +17 -0
  117. package/dist/effect/internal/email-sender.js +21 -0
  118. package/dist/effect/internal/mailbox-events.js +33 -0
  119. package/dist/effect/internal/operation.d.ts +12 -72
  120. package/dist/effect/internal/operation.js +116 -0
  121. package/dist/effect/internal/send.d.ts +60 -0
  122. package/dist/effect/internal/send.js +56 -0
  123. package/dist/effect/journeys.d.ts +2153 -0
  124. package/dist/effect/journeys.js +39 -0
  125. package/dist/effect/mailboxes.d.ts +80 -80
  126. package/dist/effect/mailboxes.js +135 -3
  127. package/dist/effect/media.d.ts +5 -5
  128. package/dist/effect/media.js +10 -8
  129. package/dist/effect/messages.d.ts +16 -16
  130. package/dist/effect/messages.js +15 -12
  131. package/dist/effect/namespaces.d.ts +7 -7
  132. package/dist/effect/namespaces.js +10 -8
  133. package/dist/effect/operations.d.ts +5 -5
  134. package/dist/effect/operations.js +8 -6
  135. package/dist/effect/organizations.d.ts +7 -7
  136. package/dist/effect/organizations.js +12 -10
  137. package/dist/effect/pagination.js +39 -0
  138. package/dist/effect/retry.js +3 -3
  139. package/dist/effect/runtime.js +25 -0
  140. package/dist/effect/scheduled-messages.d.ts +7 -7
  141. package/dist/effect/scheduled-messages.js +10 -8
  142. package/dist/effect/subscriptions.d.ts +1 -1
  143. package/dist/effect/subscriptions.js +5 -4
  144. package/dist/effect/templates.d.ts +40 -40
  145. package/dist/effect/templates.js +39 -37
  146. package/dist/effect/unsubscribe-groups.d.ts +11 -11
  147. package/dist/effect/unsubscribe-groups.js +14 -12
  148. package/dist/effect/webhooks.d.ts +23 -23
  149. package/dist/effect/webhooks.js +16 -14
  150. package/dist/effect/whoami.d.ts +1 -1
  151. package/dist/effect/whoami.js +5 -4
  152. package/dist/index.js +4 -3
  153. package/dist/{inline-attachments-Cegg6tTF.js → inline-attachments.js} +13 -7
  154. package/dist/{mailbox-events-VKR4f3qq.js → mailbox-events.js} +2 -2
  155. package/dist/{normalize-B79uJIeb.js → normalize.js} +2 -2
  156. package/dist/package.js +6 -0
  157. package/dist/promises/errors.gen.js +1340 -0
  158. package/dist/promises/index.d.ts +7 -3
  159. package/dist/promises/index.js +288 -3
  160. package/dist/promises/types.gen.d.ts +1 -1
  161. package/dist/service-map.d.ts +85 -0
  162. package/dist/{operation-BTXjPrwf.js → service-map.js} +58 -219
  163. package/package.json +17 -3
  164. package/dist/categories-DV51kr2H.js +0 -187
  165. package/dist/client-BMUew5Wp.js +0 -13794
  166. package/dist/effect/generated.d.ts +0 -64004
  167. package/dist/mailboxes-Thp5z0oX.js +0 -161
@@ -0,0 +1,1340 @@
1
+ //#region src/promises/errors.gen.ts
2
+ const redactRequest = (request) => request === void 0 ? void 0 : new Request(request.url, { method: request.method });
3
+ /** Base class for failures declared by the public Samva OpenAPI contract. */
4
+ var SamvaApiError = class extends Error {
5
+ request;
6
+ response;
7
+ status;
8
+ constructor(message, context = {}) {
9
+ super(message);
10
+ this.name = new.target.name;
11
+ this.request = redactRequest(context.request);
12
+ this.response = context.response;
13
+ this.status = context.response?.status;
14
+ }
15
+ };
16
+ /** A transport or malformed-response failure that is not part of the API error contract. */
17
+ var SamvaTransportError = class extends Error {
18
+ _tag = "SamvaTransportError";
19
+ request;
20
+ response;
21
+ status;
22
+ cause;
23
+ constructor(cause, context = {}) {
24
+ super(cause instanceof Error ? cause.message : "Samva request failed", { cause });
25
+ this.name = "SamvaTransportError";
26
+ this.cause = cause;
27
+ this.request = redactRequest(context.request);
28
+ this.response = context.response;
29
+ this.status = context.response?.status;
30
+ }
31
+ };
32
+ const messageOf = (tag, payload) => {
33
+ const message = payload.message;
34
+ return typeof message === "string" ? message : tag;
35
+ };
36
+ var AnalyticsQueryError = class extends SamvaApiError {
37
+ _tag = "AnalyticsQueryError";
38
+ constructor(payload, context = {}) {
39
+ super(messageOf("AnalyticsQueryError", payload), context);
40
+ Object.assign(this, payload);
41
+ }
42
+ };
43
+ var BillingProviderError = class extends SamvaApiError {
44
+ _tag = "BillingProviderError";
45
+ constructor(payload, context = {}) {
46
+ super(messageOf("BillingProviderError", payload), context);
47
+ Object.assign(this, payload);
48
+ }
49
+ };
50
+ var BrandAddressRequiredError = class extends SamvaApiError {
51
+ _tag = "BrandAddressRequiredError";
52
+ constructor(payload, context = {}) {
53
+ super(messageOf("BrandAddressRequiredError", payload), context);
54
+ Object.assign(this, payload);
55
+ }
56
+ };
57
+ var CampaignFooterRequiredError = class extends SamvaApiError {
58
+ _tag = "CampaignFooterRequiredError";
59
+ constructor(payload, context = {}) {
60
+ super(messageOf("CampaignFooterRequiredError", payload), context);
61
+ Object.assign(this, payload);
62
+ }
63
+ };
64
+ var ConflictError = class extends SamvaApiError {
65
+ _tag = "ConflictError";
66
+ constructor(payload, context = {}) {
67
+ super(messageOf("ConflictError", payload), context);
68
+ Object.assign(this, payload);
69
+ }
70
+ };
71
+ var DeliveryUnavailableError = class extends SamvaApiError {
72
+ _tag = "DeliveryUnavailableError";
73
+ constructor(payload, context = {}) {
74
+ super(messageOf("DeliveryUnavailableError", payload), context);
75
+ Object.assign(this, payload);
76
+ }
77
+ };
78
+ var EmailChannelError = class extends SamvaApiError {
79
+ _tag = "EmailChannelError";
80
+ constructor(payload, context = {}) {
81
+ super(messageOf("EmailChannelError", payload), context);
82
+ Object.assign(this, payload);
83
+ }
84
+ };
85
+ var ExternalServiceError = class extends SamvaApiError {
86
+ _tag = "ExternalServiceError";
87
+ constructor(payload, context = {}) {
88
+ super(messageOf("ExternalServiceError", payload), context);
89
+ Object.assign(this, payload);
90
+ }
91
+ };
92
+ var FlagDisabledError = class extends SamvaApiError {
93
+ _tag = "FlagDisabledError";
94
+ constructor(payload, context = {}) {
95
+ super(messageOf("FlagDisabledError", payload), context);
96
+ Object.assign(this, payload);
97
+ }
98
+ };
99
+ var ForbiddenError = class extends SamvaApiError {
100
+ _tag = "ForbiddenError";
101
+ constructor(payload, context = {}) {
102
+ super(messageOf("ForbiddenError", payload), context);
103
+ Object.assign(this, payload);
104
+ }
105
+ };
106
+ var GatewayTimeoutError = class extends SamvaApiError {
107
+ _tag = "GatewayTimeoutError";
108
+ constructor(payload, context = {}) {
109
+ super(messageOf("GatewayTimeoutError", payload), context);
110
+ Object.assign(this, payload);
111
+ }
112
+ };
113
+ var InternalError = class extends SamvaApiError {
114
+ _tag = "InternalError";
115
+ constructor(payload, context = {}) {
116
+ super(messageOf("InternalError", payload), context);
117
+ Object.assign(this, payload);
118
+ }
119
+ };
120
+ var MailboxChannelUnsupportedError = class extends SamvaApiError {
121
+ _tag = "MailboxChannelUnsupportedError";
122
+ constructor(payload, context = {}) {
123
+ super(messageOf("MailboxChannelUnsupportedError", payload), context);
124
+ Object.assign(this, payload);
125
+ }
126
+ };
127
+ var MailboxSendConflictError = class extends SamvaApiError {
128
+ _tag = "MailboxSendConflictError";
129
+ constructor(payload, context = {}) {
130
+ super(messageOf("MailboxSendConflictError", payload), context);
131
+ Object.assign(this, payload);
132
+ }
133
+ };
134
+ var MailboxSendRefusedError = class extends SamvaApiError {
135
+ _tag = "MailboxSendRefusedError";
136
+ constructor(payload, context = {}) {
137
+ super(messageOf("MailboxSendRefusedError", payload), context);
138
+ Object.assign(this, payload);
139
+ }
140
+ };
141
+ var OnboardingReviewRequiredError = class extends SamvaApiError {
142
+ _tag = "OnboardingReviewRequiredError";
143
+ constructor(payload, context = {}) {
144
+ super(messageOf("OnboardingReviewRequiredError", payload), context);
145
+ Object.assign(this, payload);
146
+ }
147
+ };
148
+ var PaymentRequiredError = class extends SamvaApiError {
149
+ _tag = "PaymentRequiredError";
150
+ constructor(payload, context = {}) {
151
+ super(messageOf("PaymentRequiredError", payload), context);
152
+ Object.assign(this, payload);
153
+ }
154
+ };
155
+ var RateLimitedError = class extends SamvaApiError {
156
+ _tag = "RateLimitedError";
157
+ constructor(payload, context = {}) {
158
+ super(messageOf("RateLimitedError", payload), context);
159
+ Object.assign(this, payload);
160
+ }
161
+ };
162
+ var ResourceNotFoundError = class extends SamvaApiError {
163
+ _tag = "ResourceNotFoundError";
164
+ constructor(payload, context = {}) {
165
+ super(messageOf("ResourceNotFoundError", payload), context);
166
+ Object.assign(this, payload);
167
+ }
168
+ };
169
+ var SenderNotReadyError = class extends SamvaApiError {
170
+ _tag = "SenderNotReadyError";
171
+ constructor(payload, context = {}) {
172
+ super(messageOf("SenderNotReadyError", payload), context);
173
+ Object.assign(this, payload);
174
+ }
175
+ };
176
+ var UnauthorizedError = class extends SamvaApiError {
177
+ _tag = "UnauthorizedError";
178
+ constructor(payload, context = {}) {
179
+ super(messageOf("UnauthorizedError", payload), context);
180
+ Object.assign(this, payload);
181
+ }
182
+ };
183
+ var ValidationError = class extends SamvaApiError {
184
+ _tag = "ValidationError";
185
+ constructor(payload, context = {}) {
186
+ super(messageOf("ValidationError", payload), context);
187
+ Object.assign(this, payload);
188
+ }
189
+ };
190
+ const constructors = {
191
+ AnalyticsQueryError,
192
+ BillingProviderError,
193
+ BrandAddressRequiredError,
194
+ CampaignFooterRequiredError,
195
+ ConflictError,
196
+ DeliveryUnavailableError,
197
+ EmailChannelError,
198
+ ExternalServiceError,
199
+ FlagDisabledError,
200
+ ForbiddenError,
201
+ GatewayTimeoutError,
202
+ InternalError,
203
+ MailboxChannelUnsupportedError,
204
+ MailboxSendConflictError,
205
+ MailboxSendRefusedError,
206
+ OnboardingReviewRequiredError,
207
+ PaymentRequiredError,
208
+ RateLimitedError,
209
+ ResourceNotFoundError,
210
+ SenderNotReadyError,
211
+ UnauthorizedError,
212
+ ValidationError
213
+ };
214
+ const payloadSchemas = {
215
+ AnalyticsQueryError: {
216
+ type: "object",
217
+ properties: {
218
+ _tag: {
219
+ type: "string",
220
+ enum: ["AnalyticsQueryError"]
221
+ },
222
+ message: { type: "string" }
223
+ },
224
+ required: ["_tag", "message"],
225
+ additionalProperties: false
226
+ },
227
+ BillingProviderError: {
228
+ type: "object",
229
+ properties: {
230
+ _tag: {
231
+ type: "string",
232
+ enum: ["BillingProviderError"]
233
+ },
234
+ message: { type: "string" }
235
+ },
236
+ required: ["_tag", "message"],
237
+ additionalProperties: false,
238
+ "x-category": ["transient"],
239
+ "x-retryable": true
240
+ },
241
+ BrandAddressRequiredError: {
242
+ type: "object",
243
+ properties: {
244
+ _tag: {
245
+ type: "string",
246
+ enum: ["BrandAddressRequiredError"]
247
+ },
248
+ message: { type: "string" },
249
+ brand: { anyOf: [{ type: "string" }, { type: "null" }] }
250
+ },
251
+ required: [
252
+ "_tag",
253
+ "message",
254
+ "brand"
255
+ ],
256
+ additionalProperties: false
257
+ },
258
+ CampaignFooterRequiredError: {
259
+ type: "object",
260
+ properties: {
261
+ _tag: {
262
+ type: "string",
263
+ enum: ["CampaignFooterRequiredError"]
264
+ },
265
+ message: { type: "string" }
266
+ },
267
+ required: ["_tag", "message"],
268
+ additionalProperties: false
269
+ },
270
+ ConflictError: {
271
+ type: "object",
272
+ properties: {
273
+ _tag: {
274
+ type: "string",
275
+ enum: ["ConflictError"]
276
+ },
277
+ message: { type: "string" },
278
+ resource: { type: "string" },
279
+ id: { anyOf: [{ type: "string" }, { type: "null" }] }
280
+ },
281
+ required: [
282
+ "_tag",
283
+ "message",
284
+ "resource"
285
+ ],
286
+ additionalProperties: false,
287
+ "x-category": ["conflict"],
288
+ "x-retryable": false
289
+ },
290
+ DeliveryUnavailableError: {
291
+ type: "object",
292
+ properties: {
293
+ _tag: {
294
+ type: "string",
295
+ enum: ["DeliveryUnavailableError"]
296
+ },
297
+ message: { type: "string" },
298
+ retryAfterSeconds: { type: "number" }
299
+ },
300
+ required: [
301
+ "_tag",
302
+ "message",
303
+ "retryAfterSeconds"
304
+ ],
305
+ additionalProperties: false,
306
+ "x-category": ["transient"],
307
+ "x-retryable": true
308
+ },
309
+ EmailChannelError: {
310
+ type: "object",
311
+ properties: {
312
+ _tag: {
313
+ type: "string",
314
+ enum: ["EmailChannelError"]
315
+ },
316
+ reason: {
317
+ type: "string",
318
+ enum: [
319
+ "transport",
320
+ "rejected",
321
+ "rate_limited",
322
+ "auth"
323
+ ]
324
+ },
325
+ message: { type: "string" },
326
+ statusCode: { anyOf: [{ type: "number" }, { type: "null" }] }
327
+ },
328
+ required: [
329
+ "_tag",
330
+ "reason",
331
+ "message"
332
+ ],
333
+ additionalProperties: false
334
+ },
335
+ ExternalServiceError: {
336
+ type: "object",
337
+ properties: {
338
+ _tag: {
339
+ type: "string",
340
+ enum: ["ExternalServiceError"]
341
+ },
342
+ message: { type: "string" }
343
+ },
344
+ required: ["_tag", "message"],
345
+ additionalProperties: false,
346
+ "x-category": ["transient"],
347
+ "x-retryable": true
348
+ },
349
+ FlagDisabledError: {
350
+ type: "object",
351
+ properties: {
352
+ _tag: {
353
+ type: "string",
354
+ enum: ["FlagDisabledError"]
355
+ },
356
+ flag: { type: "string" },
357
+ message: { type: "string" }
358
+ },
359
+ required: [
360
+ "_tag",
361
+ "flag",
362
+ "message"
363
+ ],
364
+ additionalProperties: false,
365
+ "x-retryable": false
366
+ },
367
+ ForbiddenError: {
368
+ type: "object",
369
+ properties: {
370
+ _tag: {
371
+ type: "string",
372
+ enum: ["ForbiddenError"]
373
+ },
374
+ message: { type: "string" }
375
+ },
376
+ required: ["_tag", "message"],
377
+ additionalProperties: false,
378
+ "x-category": ["auth"],
379
+ "x-retryable": false
380
+ },
381
+ GatewayTimeoutError: {
382
+ type: "object",
383
+ properties: {
384
+ _tag: {
385
+ type: "string",
386
+ enum: ["GatewayTimeoutError"]
387
+ },
388
+ message: { type: "string" },
389
+ retryAfterSeconds: { type: "number" }
390
+ },
391
+ required: [
392
+ "_tag",
393
+ "message",
394
+ "retryAfterSeconds"
395
+ ],
396
+ additionalProperties: false,
397
+ "x-category": ["transient"],
398
+ "x-retryable": true
399
+ },
400
+ InternalError: {
401
+ type: "object",
402
+ properties: {
403
+ _tag: {
404
+ type: "string",
405
+ enum: ["InternalError"]
406
+ },
407
+ message: { type: "string" }
408
+ },
409
+ required: ["_tag", "message"],
410
+ additionalProperties: false,
411
+ "x-category": ["transient"],
412
+ "x-retryable": true
413
+ },
414
+ MailboxChannelUnsupportedError: {
415
+ type: "object",
416
+ properties: {
417
+ _tag: {
418
+ type: "string",
419
+ enum: ["MailboxChannelUnsupportedError"]
420
+ },
421
+ message: { type: "string" },
422
+ channel: { type: "string" }
423
+ },
424
+ required: [
425
+ "_tag",
426
+ "message",
427
+ "channel"
428
+ ],
429
+ additionalProperties: false
430
+ },
431
+ MailboxSendConflictError: {
432
+ type: "object",
433
+ properties: {
434
+ _tag: {
435
+ type: "string",
436
+ enum: ["MailboxSendConflictError"]
437
+ },
438
+ message: { type: "string" },
439
+ resource: { type: "string" },
440
+ id: {
441
+ type: "string",
442
+ pattern: "^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$",
443
+ "x-samva-brand": "MailboxActionId"
444
+ },
445
+ receipt: {
446
+ type: "object",
447
+ properties: {
448
+ actionId: {
449
+ type: "string",
450
+ pattern: "^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$",
451
+ "x-samva-brand": "MailboxActionId"
452
+ },
453
+ draftId: { anyOf: [{
454
+ type: "string",
455
+ pattern: "^mdraft_[0-9a-hjkmnp-tv-z]{16,24}$",
456
+ "x-samva-brand": "MailboxDraftId"
457
+ }, { type: "null" }] },
458
+ messageId: { anyOf: [{
459
+ type: "string",
460
+ pattern: "^msg_[0-9a-hjkmnp-tv-z]{16,24}$",
461
+ "x-samva-brand": "MessageId"
462
+ }, { type: "null" }] },
463
+ threadId: { anyOf: [{
464
+ type: "string",
465
+ pattern: "^thread_[0-9a-hjkmnp-tv-z]{16,24}$",
466
+ "x-samva-brand": "MailboxThreadId"
467
+ }, { type: "null" }] },
468
+ state: {
469
+ type: "string",
470
+ enum: [
471
+ "approvalRequired",
472
+ "queued",
473
+ "accepted",
474
+ "completed",
475
+ "notSent",
476
+ "uncertain"
477
+ ]
478
+ },
479
+ acceptedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
480
+ waitReason: { anyOf: [{
481
+ type: "string",
482
+ enum: [
483
+ "rate",
484
+ "daily-quota",
485
+ "domain-health",
486
+ "sending-paused",
487
+ "upstream-unavailable",
488
+ "retry",
489
+ "campaign-paused",
490
+ "domain-warming",
491
+ "onboarding-review",
492
+ "content-review",
493
+ "screening-unavailable"
494
+ ]
495
+ }, { type: "null" }] },
496
+ reviewExpectedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
497
+ skippedRecipients: {
498
+ type: "array",
499
+ items: {
500
+ type: "object",
501
+ properties: {
502
+ address: { type: "string" },
503
+ reason: {
504
+ type: "string",
505
+ enum: [
506
+ "bounce",
507
+ "complaint",
508
+ "unsubscribe",
509
+ "manual",
510
+ "group-unsubscribe"
511
+ ]
512
+ },
513
+ unsubscribeGroupId: { anyOf: [{
514
+ type: "string",
515
+ pattern: "^unsub_[0-9a-hjkmnp-tv-z]{16,24}$",
516
+ "x-samva-brand": "UnsubscribeId"
517
+ }, { type: "null" }] }
518
+ },
519
+ required: ["address", "reason"],
520
+ additionalProperties: false
521
+ }
522
+ },
523
+ executeUntil: { anyOf: [{ type: "string" }, { type: "null" }] },
524
+ retryAt: { anyOf: [{ type: "string" }, { type: "null" }] },
525
+ problem: { anyOf: [{
526
+ type: "object",
527
+ properties: {
528
+ code: { type: "string" },
529
+ message: { type: "string" },
530
+ error: { anyOf: [{ anyOf: [
531
+ {
532
+ type: "object",
533
+ properties: {
534
+ _tag: {
535
+ type: "string",
536
+ enum: ["SenderNotReadyError"]
537
+ },
538
+ message: { type: "string" },
539
+ sender: { type: "string" },
540
+ retryAfterSeconds: { anyOf: [{ type: "number" }, { type: "null" }] }
541
+ },
542
+ required: [
543
+ "_tag",
544
+ "message",
545
+ "sender"
546
+ ],
547
+ additionalProperties: false
548
+ },
549
+ {
550
+ type: "object",
551
+ properties: {
552
+ _tag: {
553
+ type: "string",
554
+ enum: ["RateLimitedError"]
555
+ },
556
+ message: { type: "string" },
557
+ retryAfterSeconds: { type: "number" }
558
+ },
559
+ required: [
560
+ "_tag",
561
+ "message",
562
+ "retryAfterSeconds"
563
+ ],
564
+ additionalProperties: false
565
+ },
566
+ {
567
+ type: "object",
568
+ properties: {
569
+ _tag: {
570
+ type: "string",
571
+ enum: ["OnboardingReviewRequiredError"]
572
+ },
573
+ message: { type: "string" },
574
+ code: {
575
+ type: "string",
576
+ enum: [
577
+ "review_required",
578
+ "review_in_progress",
579
+ "information_required",
580
+ "review_rejected",
581
+ "identity_review_required",
582
+ "identity_review_rejected",
583
+ "identity_changed"
584
+ ]
585
+ },
586
+ decision: {
587
+ type: "string",
588
+ enum: [
589
+ "undecided",
590
+ "approved",
591
+ "rejected"
592
+ ]
593
+ },
594
+ stage: {
595
+ type: "string",
596
+ enum: [
597
+ "collecting",
598
+ "automated_review",
599
+ "manual_review",
600
+ "information_requested",
601
+ "complete"
602
+ ]
603
+ },
604
+ nextAction: {
605
+ type: "string",
606
+ enum: [
607
+ "wait_for_review",
608
+ "provide_information",
609
+ "verify_sending_identity",
610
+ "reapply",
611
+ "contact_support"
612
+ ]
613
+ },
614
+ identityId: { anyOf: [{ type: "string" }, { type: "null" }] }
615
+ },
616
+ required: [
617
+ "_tag",
618
+ "message",
619
+ "code",
620
+ "decision",
621
+ "stage",
622
+ "nextAction"
623
+ ],
624
+ additionalProperties: false
625
+ },
626
+ {
627
+ type: "object",
628
+ properties: {
629
+ _tag: {
630
+ type: "string",
631
+ enum: ["PaymentRequiredError"]
632
+ },
633
+ message: { type: "string" },
634
+ resource: { type: "string" },
635
+ currentUsage: { type: "number" },
636
+ limit: { type: "number" }
637
+ },
638
+ required: [
639
+ "_tag",
640
+ "message",
641
+ "resource",
642
+ "currentUsage",
643
+ "limit"
644
+ ],
645
+ additionalProperties: false
646
+ },
647
+ {
648
+ type: "object",
649
+ properties: {
650
+ _tag: {
651
+ type: "string",
652
+ enum: ["ValidationError"]
653
+ },
654
+ message: { type: "string" },
655
+ fields: { anyOf: [{
656
+ type: "object",
657
+ additionalProperties: {
658
+ type: "array",
659
+ items: { type: "string" }
660
+ }
661
+ }, { type: "null" }] }
662
+ },
663
+ required: ["_tag", "message"],
664
+ additionalProperties: false
665
+ },
666
+ {
667
+ type: "object",
668
+ properties: {
669
+ _tag: {
670
+ type: "string",
671
+ enum: ["ForbiddenError"]
672
+ },
673
+ message: { type: "string" }
674
+ },
675
+ required: ["_tag", "message"],
676
+ additionalProperties: false
677
+ },
678
+ {
679
+ type: "object",
680
+ properties: {
681
+ _tag: {
682
+ type: "string",
683
+ enum: ["ResourceNotFoundError"]
684
+ },
685
+ resource: { type: "string" },
686
+ id: { type: "string" },
687
+ message: { type: "string" }
688
+ },
689
+ required: [
690
+ "_tag",
691
+ "resource",
692
+ "id",
693
+ "message"
694
+ ],
695
+ additionalProperties: false
696
+ }
697
+ ] }, { type: "null" }] }
698
+ },
699
+ required: ["code", "message"],
700
+ additionalProperties: false
701
+ }, { type: "null" }] },
702
+ retryEligible: { type: "boolean" },
703
+ decision: { anyOf: [{
704
+ type: "object",
705
+ properties: {
706
+ outcome: {
707
+ type: "string",
708
+ enum: [
709
+ "allow",
710
+ "requireApproval",
711
+ "deny"
712
+ ]
713
+ },
714
+ reason: { anyOf: [{ type: "string" }, { type: "null" }] },
715
+ policyId: { anyOf: [{
716
+ type: "string",
717
+ pattern: "^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$",
718
+ "x-samva-brand": "MailboxPolicyId"
719
+ }, { type: "null" }] },
720
+ source: { anyOf: [{
721
+ type: "string",
722
+ enum: [
723
+ "grant",
724
+ "installation",
725
+ "policy"
726
+ ]
727
+ }, { type: "null" }] },
728
+ decidedAt: { type: "string" }
729
+ },
730
+ required: [
731
+ "outcome",
732
+ "reason",
733
+ "policyId",
734
+ "source",
735
+ "decidedAt"
736
+ ],
737
+ additionalProperties: false
738
+ }, { type: "null" }] },
739
+ createdAt: { type: "string" },
740
+ updatedAt: { type: "string" }
741
+ },
742
+ required: [
743
+ "actionId",
744
+ "draftId",
745
+ "messageId",
746
+ "threadId",
747
+ "state",
748
+ "acceptedAt",
749
+ "waitReason",
750
+ "reviewExpectedAt",
751
+ "skippedRecipients",
752
+ "executeUntil",
753
+ "retryAt",
754
+ "problem",
755
+ "retryEligible",
756
+ "decision",
757
+ "createdAt",
758
+ "updatedAt"
759
+ ],
760
+ additionalProperties: false
761
+ }
762
+ },
763
+ required: [
764
+ "_tag",
765
+ "message",
766
+ "resource",
767
+ "id",
768
+ "receipt"
769
+ ],
770
+ additionalProperties: false
771
+ },
772
+ MailboxSendRefusedError: {
773
+ type: "object",
774
+ properties: {
775
+ _tag: {
776
+ type: "string",
777
+ enum: ["MailboxSendRefusedError"]
778
+ },
779
+ message: { type: "string" },
780
+ receipt: {
781
+ type: "object",
782
+ properties: {
783
+ actionId: {
784
+ type: "string",
785
+ pattern: "^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$",
786
+ "x-samva-brand": "MailboxActionId"
787
+ },
788
+ draftId: { anyOf: [{
789
+ type: "string",
790
+ pattern: "^mdraft_[0-9a-hjkmnp-tv-z]{16,24}$",
791
+ "x-samva-brand": "MailboxDraftId"
792
+ }, { type: "null" }] },
793
+ messageId: { anyOf: [{
794
+ type: "string",
795
+ pattern: "^msg_[0-9a-hjkmnp-tv-z]{16,24}$",
796
+ "x-samva-brand": "MessageId"
797
+ }, { type: "null" }] },
798
+ threadId: { anyOf: [{
799
+ type: "string",
800
+ pattern: "^thread_[0-9a-hjkmnp-tv-z]{16,24}$",
801
+ "x-samva-brand": "MailboxThreadId"
802
+ }, { type: "null" }] },
803
+ state: {
804
+ type: "string",
805
+ enum: [
806
+ "approvalRequired",
807
+ "queued",
808
+ "accepted",
809
+ "completed",
810
+ "notSent",
811
+ "uncertain"
812
+ ]
813
+ },
814
+ acceptedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
815
+ waitReason: { anyOf: [{
816
+ type: "string",
817
+ enum: [
818
+ "rate",
819
+ "daily-quota",
820
+ "domain-health",
821
+ "sending-paused",
822
+ "upstream-unavailable",
823
+ "retry",
824
+ "campaign-paused",
825
+ "domain-warming",
826
+ "onboarding-review",
827
+ "content-review",
828
+ "screening-unavailable"
829
+ ]
830
+ }, { type: "null" }] },
831
+ reviewExpectedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
832
+ skippedRecipients: {
833
+ type: "array",
834
+ items: {
835
+ type: "object",
836
+ properties: {
837
+ address: { type: "string" },
838
+ reason: {
839
+ type: "string",
840
+ enum: [
841
+ "bounce",
842
+ "complaint",
843
+ "unsubscribe",
844
+ "manual",
845
+ "group-unsubscribe"
846
+ ]
847
+ },
848
+ unsubscribeGroupId: { anyOf: [{
849
+ type: "string",
850
+ pattern: "^unsub_[0-9a-hjkmnp-tv-z]{16,24}$",
851
+ "x-samva-brand": "UnsubscribeId"
852
+ }, { type: "null" }] }
853
+ },
854
+ required: ["address", "reason"],
855
+ additionalProperties: false
856
+ }
857
+ },
858
+ executeUntil: { anyOf: [{ type: "string" }, { type: "null" }] },
859
+ retryAt: { anyOf: [{ type: "string" }, { type: "null" }] },
860
+ problem: { anyOf: [{
861
+ type: "object",
862
+ properties: {
863
+ code: { type: "string" },
864
+ message: { type: "string" },
865
+ error: { anyOf: [{ anyOf: [
866
+ {
867
+ type: "object",
868
+ properties: {
869
+ _tag: {
870
+ type: "string",
871
+ enum: ["SenderNotReadyError"]
872
+ },
873
+ message: { type: "string" },
874
+ sender: { type: "string" },
875
+ retryAfterSeconds: { anyOf: [{ type: "number" }, { type: "null" }] }
876
+ },
877
+ required: [
878
+ "_tag",
879
+ "message",
880
+ "sender"
881
+ ],
882
+ additionalProperties: false
883
+ },
884
+ {
885
+ type: "object",
886
+ properties: {
887
+ _tag: {
888
+ type: "string",
889
+ enum: ["RateLimitedError"]
890
+ },
891
+ message: { type: "string" },
892
+ retryAfterSeconds: { type: "number" }
893
+ },
894
+ required: [
895
+ "_tag",
896
+ "message",
897
+ "retryAfterSeconds"
898
+ ],
899
+ additionalProperties: false
900
+ },
901
+ {
902
+ type: "object",
903
+ properties: {
904
+ _tag: {
905
+ type: "string",
906
+ enum: ["OnboardingReviewRequiredError"]
907
+ },
908
+ message: { type: "string" },
909
+ code: {
910
+ type: "string",
911
+ enum: [
912
+ "review_required",
913
+ "review_in_progress",
914
+ "information_required",
915
+ "review_rejected",
916
+ "identity_review_required",
917
+ "identity_review_rejected",
918
+ "identity_changed"
919
+ ]
920
+ },
921
+ decision: {
922
+ type: "string",
923
+ enum: [
924
+ "undecided",
925
+ "approved",
926
+ "rejected"
927
+ ]
928
+ },
929
+ stage: {
930
+ type: "string",
931
+ enum: [
932
+ "collecting",
933
+ "automated_review",
934
+ "manual_review",
935
+ "information_requested",
936
+ "complete"
937
+ ]
938
+ },
939
+ nextAction: {
940
+ type: "string",
941
+ enum: [
942
+ "wait_for_review",
943
+ "provide_information",
944
+ "verify_sending_identity",
945
+ "reapply",
946
+ "contact_support"
947
+ ]
948
+ },
949
+ identityId: { anyOf: [{ type: "string" }, { type: "null" }] }
950
+ },
951
+ required: [
952
+ "_tag",
953
+ "message",
954
+ "code",
955
+ "decision",
956
+ "stage",
957
+ "nextAction"
958
+ ],
959
+ additionalProperties: false
960
+ },
961
+ {
962
+ type: "object",
963
+ properties: {
964
+ _tag: {
965
+ type: "string",
966
+ enum: ["PaymentRequiredError"]
967
+ },
968
+ message: { type: "string" },
969
+ resource: { type: "string" },
970
+ currentUsage: { type: "number" },
971
+ limit: { type: "number" }
972
+ },
973
+ required: [
974
+ "_tag",
975
+ "message",
976
+ "resource",
977
+ "currentUsage",
978
+ "limit"
979
+ ],
980
+ additionalProperties: false
981
+ },
982
+ {
983
+ type: "object",
984
+ properties: {
985
+ _tag: {
986
+ type: "string",
987
+ enum: ["ValidationError"]
988
+ },
989
+ message: { type: "string" },
990
+ fields: { anyOf: [{
991
+ type: "object",
992
+ additionalProperties: {
993
+ type: "array",
994
+ items: { type: "string" }
995
+ }
996
+ }, { type: "null" }] }
997
+ },
998
+ required: ["_tag", "message"],
999
+ additionalProperties: false
1000
+ },
1001
+ {
1002
+ type: "object",
1003
+ properties: {
1004
+ _tag: {
1005
+ type: "string",
1006
+ enum: ["ForbiddenError"]
1007
+ },
1008
+ message: { type: "string" }
1009
+ },
1010
+ required: ["_tag", "message"],
1011
+ additionalProperties: false
1012
+ },
1013
+ {
1014
+ type: "object",
1015
+ properties: {
1016
+ _tag: {
1017
+ type: "string",
1018
+ enum: ["ResourceNotFoundError"]
1019
+ },
1020
+ resource: { type: "string" },
1021
+ id: { type: "string" },
1022
+ message: { type: "string" }
1023
+ },
1024
+ required: [
1025
+ "_tag",
1026
+ "resource",
1027
+ "id",
1028
+ "message"
1029
+ ],
1030
+ additionalProperties: false
1031
+ }
1032
+ ] }, { type: "null" }] }
1033
+ },
1034
+ required: ["code", "message"],
1035
+ additionalProperties: false
1036
+ }, { type: "null" }] },
1037
+ retryEligible: { type: "boolean" },
1038
+ decision: { anyOf: [{
1039
+ type: "object",
1040
+ properties: {
1041
+ outcome: {
1042
+ type: "string",
1043
+ enum: [
1044
+ "allow",
1045
+ "requireApproval",
1046
+ "deny"
1047
+ ]
1048
+ },
1049
+ reason: { anyOf: [{ type: "string" }, { type: "null" }] },
1050
+ policyId: { anyOf: [{
1051
+ type: "string",
1052
+ pattern: "^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$",
1053
+ "x-samva-brand": "MailboxPolicyId"
1054
+ }, { type: "null" }] },
1055
+ source: { anyOf: [{
1056
+ type: "string",
1057
+ enum: [
1058
+ "grant",
1059
+ "installation",
1060
+ "policy"
1061
+ ]
1062
+ }, { type: "null" }] },
1063
+ decidedAt: { type: "string" }
1064
+ },
1065
+ required: [
1066
+ "outcome",
1067
+ "reason",
1068
+ "policyId",
1069
+ "source",
1070
+ "decidedAt"
1071
+ ],
1072
+ additionalProperties: false
1073
+ }, { type: "null" }] },
1074
+ createdAt: { type: "string" },
1075
+ updatedAt: { type: "string" }
1076
+ },
1077
+ required: [
1078
+ "actionId",
1079
+ "draftId",
1080
+ "messageId",
1081
+ "threadId",
1082
+ "state",
1083
+ "acceptedAt",
1084
+ "waitReason",
1085
+ "reviewExpectedAt",
1086
+ "skippedRecipients",
1087
+ "executeUntil",
1088
+ "retryAt",
1089
+ "problem",
1090
+ "retryEligible",
1091
+ "decision",
1092
+ "createdAt",
1093
+ "updatedAt"
1094
+ ],
1095
+ additionalProperties: false
1096
+ }
1097
+ },
1098
+ required: [
1099
+ "_tag",
1100
+ "message",
1101
+ "receipt"
1102
+ ],
1103
+ additionalProperties: false
1104
+ },
1105
+ OnboardingReviewRequiredError: {
1106
+ type: "object",
1107
+ properties: {
1108
+ _tag: {
1109
+ type: "string",
1110
+ enum: ["OnboardingReviewRequiredError"]
1111
+ },
1112
+ message: { type: "string" },
1113
+ code: {
1114
+ type: "string",
1115
+ enum: [
1116
+ "review_required",
1117
+ "review_in_progress",
1118
+ "information_required",
1119
+ "review_rejected",
1120
+ "identity_review_required",
1121
+ "identity_review_rejected",
1122
+ "identity_changed"
1123
+ ]
1124
+ },
1125
+ decision: {
1126
+ type: "string",
1127
+ enum: [
1128
+ "undecided",
1129
+ "approved",
1130
+ "rejected"
1131
+ ]
1132
+ },
1133
+ stage: {
1134
+ type: "string",
1135
+ enum: [
1136
+ "collecting",
1137
+ "automated_review",
1138
+ "manual_review",
1139
+ "information_requested",
1140
+ "complete"
1141
+ ]
1142
+ },
1143
+ nextAction: {
1144
+ type: "string",
1145
+ enum: [
1146
+ "wait_for_review",
1147
+ "provide_information",
1148
+ "verify_sending_identity",
1149
+ "reapply",
1150
+ "contact_support"
1151
+ ]
1152
+ },
1153
+ identityId: { anyOf: [{ type: "string" }, { type: "null" }] }
1154
+ },
1155
+ required: [
1156
+ "_tag",
1157
+ "message",
1158
+ "code",
1159
+ "decision",
1160
+ "stage",
1161
+ "nextAction"
1162
+ ],
1163
+ additionalProperties: false,
1164
+ "x-category": ["validation"],
1165
+ "x-retryable": false
1166
+ },
1167
+ PaymentRequiredError: {
1168
+ type: "object",
1169
+ properties: {
1170
+ _tag: {
1171
+ type: "string",
1172
+ enum: ["PaymentRequiredError"]
1173
+ },
1174
+ message: { type: "string" },
1175
+ resource: { type: "string" },
1176
+ currentUsage: { type: "number" },
1177
+ limit: { type: "number" }
1178
+ },
1179
+ required: [
1180
+ "_tag",
1181
+ "message",
1182
+ "resource",
1183
+ "currentUsage",
1184
+ "limit"
1185
+ ],
1186
+ additionalProperties: false,
1187
+ "x-category": ["billing"],
1188
+ "x-retryable": false
1189
+ },
1190
+ RateLimitedError: {
1191
+ type: "object",
1192
+ properties: {
1193
+ _tag: {
1194
+ type: "string",
1195
+ enum: ["RateLimitedError"]
1196
+ },
1197
+ message: { type: "string" },
1198
+ retryAfterSeconds: { type: "number" }
1199
+ },
1200
+ required: [
1201
+ "_tag",
1202
+ "message",
1203
+ "retryAfterSeconds"
1204
+ ],
1205
+ additionalProperties: false,
1206
+ "x-category": ["throttling", "transient"],
1207
+ "x-retryable": true
1208
+ },
1209
+ ResourceNotFoundError: {
1210
+ type: "object",
1211
+ properties: {
1212
+ _tag: {
1213
+ type: "string",
1214
+ enum: ["ResourceNotFoundError"]
1215
+ },
1216
+ resource: { type: "string" },
1217
+ id: { type: "string" },
1218
+ message: { type: "string" }
1219
+ },
1220
+ required: [
1221
+ "_tag",
1222
+ "resource",
1223
+ "id",
1224
+ "message"
1225
+ ],
1226
+ additionalProperties: false,
1227
+ "x-category": ["notFound"],
1228
+ "x-retryable": false
1229
+ },
1230
+ SenderNotReadyError: {
1231
+ type: "object",
1232
+ properties: {
1233
+ _tag: {
1234
+ type: "string",
1235
+ enum: ["SenderNotReadyError"]
1236
+ },
1237
+ message: { type: "string" },
1238
+ sender: { type: "string" },
1239
+ retryAfterSeconds: { anyOf: [{ type: "number" }, { type: "null" }] }
1240
+ },
1241
+ required: [
1242
+ "_tag",
1243
+ "message",
1244
+ "sender"
1245
+ ],
1246
+ additionalProperties: false,
1247
+ "x-category": ["transient"],
1248
+ "x-retryable": true
1249
+ },
1250
+ UnauthorizedError: {
1251
+ type: "object",
1252
+ properties: {
1253
+ _tag: {
1254
+ type: "string",
1255
+ enum: ["UnauthorizedError"]
1256
+ },
1257
+ message: { type: "string" }
1258
+ },
1259
+ required: ["_tag", "message"],
1260
+ additionalProperties: false,
1261
+ "x-category": ["auth"],
1262
+ "x-retryable": false
1263
+ },
1264
+ ValidationError: {
1265
+ type: "object",
1266
+ properties: {
1267
+ _tag: {
1268
+ type: "string",
1269
+ enum: ["ValidationError"]
1270
+ },
1271
+ message: { type: "string" },
1272
+ fields: { anyOf: [{
1273
+ type: "object",
1274
+ additionalProperties: {
1275
+ type: "array",
1276
+ items: { type: "string" }
1277
+ }
1278
+ }, { type: "null" }] }
1279
+ },
1280
+ required: ["_tag", "message"],
1281
+ additionalProperties: false,
1282
+ "x-category": ["validation"],
1283
+ "x-retryable": false
1284
+ }
1285
+ };
1286
+ const isRecord = (value) => typeof value === "object" && value !== null;
1287
+ const matchesType = (value, type) => {
1288
+ switch (type) {
1289
+ case "string": return typeof value === "string";
1290
+ case "number": return typeof value === "number" && Number.isFinite(value);
1291
+ case "integer": return typeof value === "number" && Number.isInteger(value);
1292
+ case "boolean": return typeof value === "boolean";
1293
+ case "null": return value === null;
1294
+ case "array": return Array.isArray(value);
1295
+ case "object": return isRecord(value) && !Array.isArray(value);
1296
+ default: return false;
1297
+ }
1298
+ };
1299
+ const matchesSchema = (value, schema) => {
1300
+ if (schema.anyOf !== void 0 && !schema.anyOf.some((member) => matchesSchema(value, member))) return false;
1301
+ if (schema.enum !== void 0 && !schema.enum.some((member) => Object.is(value, member))) return false;
1302
+ if (schema.type !== void 0) {
1303
+ if (!(typeof schema.type === "string" ? [schema.type] : schema.type).some((type) => matchesType(value, type))) return false;
1304
+ }
1305
+ const items = schema.items;
1306
+ if (Array.isArray(value) && items !== void 0) return value.every((item) => matchesSchema(item, items));
1307
+ if (!isRecord(value) || Array.isArray(value)) return true;
1308
+ if (schema.required?.some((key) => !Object.hasOwn(value, key)) === true) return false;
1309
+ const properties = schema.properties ?? {};
1310
+ for (const [key, propertySchema] of Object.entries(properties)) if (Object.hasOwn(value, key) && !matchesSchema(value[key], propertySchema)) return false;
1311
+ if (schema.additionalProperties === false) {
1312
+ if (Object.keys(value).some((key) => !Object.hasOwn(properties, key))) return false;
1313
+ } else if (typeof schema.additionalProperties === "object") {
1314
+ for (const [key, propertyValue] of Object.entries(value)) if (!Object.hasOwn(properties, key) && !matchesSchema(propertyValue, schema.additionalProperties)) return false;
1315
+ }
1316
+ return true;
1317
+ };
1318
+ /** Convert a decoded error payload into its generated JavaScript error class. */
1319
+ function fromApiError(error, context = {}) {
1320
+ if (error instanceof SamvaApiError) return error;
1321
+ if (error instanceof SamvaTransportError) return error;
1322
+ if (isRecord(error) && typeof error._tag === "string" && Object.hasOwn(constructors, error._tag)) {
1323
+ const tag = error._tag;
1324
+ if (!matchesSchema(error, payloadSchemas[tag])) return new SamvaTransportError(error, context);
1325
+ const Constructor = constructors[tag];
1326
+ return new Constructor(error, context);
1327
+ }
1328
+ if (context.response?.status === 504) {
1329
+ const retryAfter = Number(context.response.headers.get("retry-after"));
1330
+ return new GatewayTimeoutError({
1331
+ message: "The request did not finish in time. Retry with the same idempotency key.",
1332
+ retryAfterSeconds: Number.isInteger(retryAfter) && retryAfter > 0 ? retryAfter : 1
1333
+ }, context);
1334
+ }
1335
+ return new SamvaTransportError(error, context);
1336
+ }
1337
+ //#endregion
1338
+ export { AnalyticsQueryError, BillingProviderError, BrandAddressRequiredError, CampaignFooterRequiredError, ConflictError, DeliveryUnavailableError, EmailChannelError, ExternalServiceError, FlagDisabledError, ForbiddenError, GatewayTimeoutError, InternalError, MailboxChannelUnsupportedError, MailboxSendConflictError, MailboxSendRefusedError, OnboardingReviewRequiredError, PaymentRequiredError, RateLimitedError, ResourceNotFoundError, SamvaApiError, SamvaTransportError, SenderNotReadyError, UnauthorizedError, ValidationError, fromApiError };
1339
+
1340
+ //# sourceMappingURL=errors.gen.js.map