samva 0.17.0 → 0.19.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 (143) hide show
  1. package/AGENTS.md +5 -0
  2. package/README.md +18 -3
  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 +39 -23
  14. package/dist/{promises---Kbh-7z.js → client/sdk.gen.js} +87 -2314
  15. package/dist/client/types.gen.d.ts +175 -44
  16. package/dist/client-attribution.js +9 -0
  17. package/dist/effect/analytics.d.ts +6 -6
  18. package/dist/effect/analytics.js +23 -2
  19. package/dist/effect/api-keys.d.ts +12 -12
  20. package/dist/effect/api-keys.js +29 -2
  21. package/dist/effect/attachments.d.ts +4 -4
  22. package/dist/effect/attachments.js +19 -2
  23. package/dist/effect/brands.d.ts +6 -6
  24. package/dist/effect/brands.js +26 -3
  25. package/dist/effect/campaigns.d.ts +18 -18
  26. package/dist/effect/campaigns.js +35 -2
  27. package/dist/effect/categories.d.ts +2 -2
  28. package/dist/effect/categories.js +95 -1
  29. package/dist/effect/client.js +3 -3
  30. package/dist/effect/contact-groups.d.ts +53 -17
  31. package/dist/effect/contact-groups.js +31 -2
  32. package/dist/effect/contacts.d.ts +244 -41
  33. package/dist/effect/contacts.js +54 -2
  34. package/dist/effect/conversations.d.ts +28 -28
  35. package/dist/effect/conversations.js +37 -2
  36. package/dist/effect/custom-fields.d.ts +4 -4
  37. package/dist/effect/custom-fields.js +19 -2
  38. package/dist/effect/email.d.ts +75 -75
  39. package/dist/effect/email.js +140 -2
  40. package/dist/effect/errors.d.ts +2 -0
  41. package/dist/effect/errors.js +3 -0
  42. package/dist/effect/events.d.ts +2 -2
  43. package/dist/effect/events.js +17 -3
  44. package/dist/effect/extension-installations.d.ts +23 -23
  45. package/dist/effect/extension-installations.js +29 -2
  46. package/dist/effect/extensions.d.ts +12 -12
  47. package/dist/effect/extensions.js +21 -2
  48. package/dist/effect/feedback.d.ts +1 -1
  49. package/dist/effect/feedback.js +14 -3
  50. package/dist/{analytics-CaqPRsry.js → effect/generated/analytics.js} +4 -23
  51. package/dist/{api-keys-Ce1Y4_Ip.js → effect/generated/api-keys.js} +4 -29
  52. package/dist/{attachments-DYqVIraC.js → effect/generated/attachments.js} +3 -18
  53. package/dist/{brands-ZwuOGIWO.js → effect/generated/brands.js} +5 -25
  54. package/dist/{campaigns-DZlz1E9E.js → effect/generated/campaigns.js} +4 -35
  55. package/dist/effect/generated/contact-events.js +37 -0
  56. package/dist/effect/generated/contact-groups.d.ts +33 -3
  57. package/dist/{contact-groups-BLbFXnjq.js → effect/generated/contact-groups.js} +3 -30
  58. package/dist/effect/generated/contacts.d.ts +477 -54
  59. package/dist/{contacts-BbsoXXB4.js → effect/generated/contacts.js} +41 -89
  60. package/dist/effect/generated/conversations.d.ts +25 -25
  61. package/dist/{conversations-_sRHueML.js → effect/generated/conversations.js} +4 -37
  62. package/dist/{custom-fields-BHWbwlKn.js → effect/generated/custom-fields.js} +5 -19
  63. package/dist/{email-R0NAA9PW.js → effect/generated/email.js} +995 -1146
  64. package/dist/{events-CxbTUHYT.js → effect/generated/events.js} +3 -15
  65. package/dist/effect/generated/extension-installations.d.ts +44 -44
  66. package/dist/{extension-installations-CD94LPmk.js → effect/generated/extension-installations.js} +10 -29
  67. package/dist/effect/generated/extensions.d.ts +10 -10
  68. package/dist/{extensions-BKyNQLvu.js → effect/generated/extensions.js} +5 -20
  69. package/dist/{feedback-Bpa09JOS.js → effect/generated/feedback.js} +3 -12
  70. package/dist/{journeys-CARo_BJT.js → effect/generated/journeys.js} +3 -38
  71. package/dist/effect/generated/mailboxes.d.ts +310 -0
  72. package/dist/{mailboxes-BRDn7BIK.js → effect/generated/mailboxes.js} +829 -954
  73. package/dist/{media-VrrtNnft.js → effect/generated/media.js} +3 -3
  74. package/dist/effect/generated/messages.d.ts +31 -0
  75. package/dist/effect/generated/messages.js +677 -0
  76. package/dist/{namespaces-CcvEbG-y.js → effect/generated/namespaces.js} +3 -20
  77. package/dist/{operations-CmB3FHwf.js → effect/generated/operations.js} +3 -16
  78. package/dist/effect/generated/organizations.d.ts +13 -11
  79. package/dist/{organizations-A-plufWc.js → effect/generated/organizations.js} +9 -26
  80. package/dist/{scheduled-messages-DkKZRRaN.js → effect/generated/scheduled-messages.js} +4 -21
  81. package/dist/effect/generated/shared.d.ts +70 -20
  82. package/dist/effect/generated/shared.js +1073 -0
  83. package/dist/{subscriptions-DEXYtMXg.js → effect/generated/subscriptions.js} +3 -9
  84. package/dist/{templates-DZomxsG7.js → effect/generated/templates.js} +3 -78
  85. package/dist/effect/generated/unsubscribe-groups.d.ts +173 -78
  86. package/dist/{unsubscribe-groups-Iqk4Isf9.js → effect/generated/unsubscribe-groups.js} +77 -84
  87. package/dist/effect/generated/webhooks.d.ts +19 -19
  88. package/dist/{webhooks-CPXuu8Xf.js → effect/generated/webhooks.js} +12 -34
  89. package/dist/{whoami-Ccz0jwlt.js → effect/generated/whoami.js} +5 -10
  90. package/dist/effect/generated-metadata.d.ts +7 -2
  91. package/dist/effect/generated-metadata.js +925 -0
  92. package/dist/effect/index.d.ts +1 -2
  93. package/dist/effect/index.js +32 -32
  94. package/dist/effect/internal/client.js +69 -0
  95. package/dist/effect/internal/email-sender.js +21 -0
  96. package/dist/effect/internal/mailbox-events.js +33 -0
  97. package/dist/effect/internal/operation.js +116 -0
  98. package/dist/effect/internal/send.js +56 -0
  99. package/dist/effect/journeys.d.ts +18 -18
  100. package/dist/effect/journeys.js +39 -2
  101. package/dist/effect/mailboxes.d.ts +314 -182
  102. package/dist/effect/mailboxes.js +135 -3
  103. package/dist/effect/media.d.ts +5 -5
  104. package/dist/effect/media.js +10 -10
  105. package/dist/effect/messages.d.ts +19 -14
  106. package/dist/effect/messages.js +15 -14
  107. package/dist/effect/namespaces.d.ts +7 -7
  108. package/dist/effect/namespaces.js +21 -2
  109. package/dist/effect/operations.d.ts +5 -5
  110. package/dist/effect/operations.js +17 -2
  111. package/dist/effect/organizations.d.ts +11 -11
  112. package/dist/effect/organizations.js +25 -2
  113. package/dist/effect/pagination.js +39 -0
  114. package/dist/effect/retry.js +3 -3
  115. package/dist/{runtime-P0l1_2-C.js → effect/runtime.js} +2 -2
  116. package/dist/effect/scheduled-messages.d.ts +7 -7
  117. package/dist/effect/scheduled-messages.js +21 -2
  118. package/dist/effect/subscriptions.d.ts +1 -1
  119. package/dist/effect/subscriptions.js +10 -2
  120. package/dist/effect/templates.d.ts +39 -39
  121. package/dist/effect/templates.js +80 -3
  122. package/dist/effect/unsubscribe-groups.d.ts +39 -28
  123. package/dist/effect/unsubscribe-groups.js +29 -2
  124. package/dist/effect/webhooks.d.ts +22 -22
  125. package/dist/effect/webhooks.js +35 -3
  126. package/dist/effect/whoami.d.ts +9 -9
  127. package/dist/effect/whoami.js +10 -2
  128. package/dist/index.js +4 -3
  129. package/dist/{inline-attachments-Bi1hDltp.js → inline-attachments.js} +13 -7
  130. package/dist/mailbox-events.d.ts +31 -4
  131. package/dist/{mailbox-events-VKR4f3qq.js → mailbox-events.js} +41 -13
  132. package/dist/{normalize-B79uJIeb.js → normalize.js} +2 -2
  133. package/dist/package.js +6 -0
  134. package/dist/promises/errors.gen.js +1340 -0
  135. package/dist/promises/index.d.ts +1 -1
  136. package/dist/promises/index.js +288 -3
  137. package/dist/promises/types.gen.d.ts +1 -1
  138. package/dist/service-map.d.ts +9 -4
  139. package/dist/{operation-n_IYgNVK.js → service-map.js} +12 -150
  140. package/package.json +6 -2
  141. package/dist/categories-CA4XIQAb.js +0 -1011
  142. package/dist/client-DOzUrdTE.js +0 -1115
  143. package/dist/send-Bxc0XfGE.js +0 -722
@@ -1,679 +1,5 @@
1
- import { a as withUploadedAttachments, n as mediaCreateBody, o as CLIENT_ATTRIBUTION_HEADER, r as planInlineUploads, s as clientAttribution, t as MediaUploadError } from "./inline-attachments-Bi1hDltp.js";
2
- import { t as MailboxEventStream } from "./mailbox-events-VKR4f3qq.js";
3
- import { n as buildMessagesSendPayload, r as replyToEmailsPayload, t as buildEmailSendPayload } from "./normalize-B79uJIeb.js";
4
- //#region src/client/core/bodySerializer.gen.ts
5
- const jsonBodySerializer = { bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value) };
6
- //#endregion
7
- //#region src/client/core/params.gen.ts
8
- const extraPrefixes = Object.entries({
9
- $body_: "body",
10
- $headers_: "headers",
11
- $path_: "path",
12
- $query_: "query"
13
- });
14
- function buildKeyMap(fields, map) {
15
- if (!map) map = /* @__PURE__ */ new Map();
16
- for (const config of fields) if ("in" in config) {
17
- if (config.key) map.set(config.key, {
18
- in: config.in,
19
- map: config.map
20
- });
21
- } else if ("key" in config) map.set(config.key, { map: config.map });
22
- else if (config.args) buildKeyMap(config.args, map);
23
- return map;
24
- }
25
- function stripEmptySlots(params) {
26
- for (const [slot, value] of Object.entries(params)) {
27
- if (slot === "body") continue;
28
- if (value && typeof value === "object" && !Array.isArray(value) && !Object.keys(value).length) delete params[slot];
29
- }
30
- }
31
- function buildClientParams(args, fields) {
32
- const params = {
33
- headers: Object.create(null),
34
- path: Object.create(null),
35
- query: Object.create(null)
36
- };
37
- const map = buildKeyMap(fields);
38
- function writeSlot(slot, key, value) {
39
- let record = params[slot];
40
- if (record === void 0) {
41
- record = Object.create(null);
42
- params[slot] = record;
43
- }
44
- record[key] = value;
45
- }
46
- let config;
47
- for (const [index, arg] of args.entries()) {
48
- if (fields[index]) config = fields[index];
49
- if (!config) continue;
50
- if ("in" in config) {
51
- if (config.key) {
52
- const field = map.get(config.key);
53
- const name = field.map || config.key;
54
- if (field.in) writeSlot(field.in, name, arg);
55
- } else params.body = arg;
56
- } else for (const [key, value] of Object.entries(arg ?? {})) {
57
- const field = map.get(key);
58
- if (field) {
59
- if (field.in) {
60
- const name = field.map || key;
61
- writeSlot(field.in, name, value);
62
- } else params[field.map] = value;
63
- } else {
64
- const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
65
- if (extra) {
66
- const [prefix, slot] = extra;
67
- writeSlot(slot, key.slice(prefix.length), value);
68
- } else if ("allowExtra" in config && config.allowExtra) {
69
- for (const [slot, allowed] of Object.entries(config.allowExtra)) if (allowed) {
70
- writeSlot(slot, key, value);
71
- break;
72
- }
73
- }
74
- }
75
- }
76
- }
77
- stripEmptySlots(params);
78
- return params;
79
- }
80
- //#endregion
81
- //#region src/client/core/serverSentEvents.gen.ts
82
- function createSseClient({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) {
83
- let lastEventId;
84
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
85
- const createStream = async function* () {
86
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
87
- let attempt = 0;
88
- const signal = options.signal ?? new AbortController().signal;
89
- while (true) {
90
- if (signal.aborted) break;
91
- attempt++;
92
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
93
- if (lastEventId !== void 0) headers.set("Last-Event-ID", lastEventId);
94
- try {
95
- const requestInit = {
96
- redirect: "follow",
97
- ...options,
98
- body: options.serializedBody,
99
- headers,
100
- signal
101
- };
102
- let request = new Request(url, requestInit);
103
- if (onRequest) request = await onRequest(url, requestInit);
104
- const response = await (options.fetch ?? globalThis.fetch)(request);
105
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
106
- if (!response.body) throw new Error("No body in SSE response");
107
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
108
- let buffer = "";
109
- const abortHandler = () => {
110
- try {
111
- reader.cancel();
112
- } catch {}
113
- };
114
- signal.addEventListener("abort", abortHandler);
115
- try {
116
- while (true) {
117
- const { done, value } = await reader.read();
118
- if (done) break;
119
- buffer += value;
120
- buffer = buffer.replace(/\r\n?/g, "\n");
121
- const chunks = buffer.split("\n\n");
122
- buffer = chunks.pop() ?? "";
123
- for (const chunk of chunks) {
124
- const lines = chunk.split("\n");
125
- const dataLines = [];
126
- let eventName;
127
- for (const line of lines) if (line.startsWith("data:")) dataLines.push(line.replace(/^data:\s*/, ""));
128
- else if (line.startsWith("event:")) eventName = line.replace(/^event:\s*/, "");
129
- else if (line.startsWith("id:")) lastEventId = line.replace(/^id:\s*/, "");
130
- else if (line.startsWith("retry:")) {
131
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
132
- if (!Number.isNaN(parsed)) retryDelay = parsed;
133
- }
134
- let data;
135
- let parsedJson = false;
136
- if (dataLines.length) {
137
- const rawData = dataLines.join("\n");
138
- try {
139
- data = JSON.parse(rawData);
140
- parsedJson = true;
141
- } catch {
142
- data = rawData;
143
- }
144
- }
145
- if (parsedJson) {
146
- if (responseValidator) await responseValidator(data);
147
- if (responseTransformer) data = await responseTransformer(data);
148
- }
149
- onSseEvent?.({
150
- data,
151
- event: eventName,
152
- id: lastEventId,
153
- retry: retryDelay
154
- });
155
- if (dataLines.length) yield data;
156
- }
157
- }
158
- } finally {
159
- signal.removeEventListener("abort", abortHandler);
160
- reader.releaseLock();
161
- }
162
- break;
163
- } catch (error) {
164
- onSseError?.(error);
165
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) break;
166
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
167
- await sleep(backoff);
168
- }
169
- }
170
- };
171
- return { stream: createStream() };
172
- }
173
- //#endregion
174
- //#region src/client/core/pathSerializer.gen.ts
175
- const separatorArrayExplode = (style) => {
176
- switch (style) {
177
- case "label": return ".";
178
- case "matrix": return ";";
179
- case "simple": return ",";
180
- default: return "&";
181
- }
182
- };
183
- const separatorArrayNoExplode = (style) => {
184
- switch (style) {
185
- case "form": return ",";
186
- case "pipeDelimited": return "|";
187
- case "spaceDelimited": return "%20";
188
- default: return ",";
189
- }
190
- };
191
- const separatorObjectExplode = (style) => {
192
- switch (style) {
193
- case "label": return ".";
194
- case "matrix": return ";";
195
- case "simple": return ",";
196
- default: return "&";
197
- }
198
- };
199
- const serializeArrayParam = ({ allowReserved, explode, name, style, value }) => {
200
- if (!explode) {
201
- const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
202
- switch (style) {
203
- case "label": return `.${joinedValues}`;
204
- case "matrix": return `;${name}=${joinedValues}`;
205
- case "simple": return joinedValues;
206
- default: return `${name}=${joinedValues}`;
207
- }
208
- }
209
- const separator = separatorArrayExplode(style);
210
- const joinedValues = value.map((v) => {
211
- if (style === "label" || style === "simple") return allowReserved ? v : encodeURIComponent(v);
212
- return serializePrimitiveParam({
213
- allowReserved,
214
- name,
215
- value: v
216
- });
217
- }).join(separator);
218
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
219
- };
220
- const serializePrimitiveParam = ({ allowReserved, name, value }) => {
221
- if (value === void 0 || value === null) return "";
222
- if (typeof value === "object") throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
223
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
224
- };
225
- const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly }) => {
226
- if (value instanceof Date) return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
227
- if (style !== "deepObject" && !explode) {
228
- let values = [];
229
- Object.entries(value).forEach(([key, v]) => {
230
- values = [
231
- ...values,
232
- key,
233
- allowReserved ? v : encodeURIComponent(v)
234
- ];
235
- });
236
- const joinedValues = values.join(",");
237
- switch (style) {
238
- case "form": return `${name}=${joinedValues}`;
239
- case "label": return `.${joinedValues}`;
240
- case "matrix": return `;${name}=${joinedValues}`;
241
- default: return joinedValues;
242
- }
243
- }
244
- const separator = separatorObjectExplode(style);
245
- const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
246
- allowReserved,
247
- name: style === "deepObject" ? `${name}[${key}]` : key,
248
- value: v
249
- })).join(separator);
250
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
251
- };
252
- //#endregion
253
- //#region src/client/core/utils.gen.ts
254
- const PATH_PARAM_RE = /\{[^{}]+\}/g;
255
- const defaultPathSerializer = ({ path, url: _url }) => {
256
- let url = _url;
257
- const matches = _url.match(PATH_PARAM_RE);
258
- if (matches) for (const match of matches) {
259
- let explode = false;
260
- let name = match.substring(1, match.length - 1);
261
- let style = "simple";
262
- if (name.endsWith("*")) {
263
- explode = true;
264
- name = name.substring(0, name.length - 1);
265
- }
266
- if (name.startsWith(".")) {
267
- name = name.substring(1);
268
- style = "label";
269
- } else if (name.startsWith(";")) {
270
- name = name.substring(1);
271
- style = "matrix";
272
- }
273
- const value = path[name];
274
- if (value === void 0 || value === null) continue;
275
- if (Array.isArray(value)) {
276
- url = url.replace(match, serializeArrayParam({
277
- explode,
278
- name,
279
- style,
280
- value
281
- }));
282
- continue;
283
- }
284
- if (typeof value === "object") {
285
- url = url.replace(match, serializeObjectParam({
286
- explode,
287
- name,
288
- style,
289
- value,
290
- valueOnly: true
291
- }));
292
- continue;
293
- }
294
- if (style === "matrix") {
295
- url = url.replace(match, `;${serializePrimitiveParam({
296
- name,
297
- value
298
- })}`);
299
- continue;
300
- }
301
- const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
302
- url = url.replace(match, replaceValue);
303
- }
304
- return url;
305
- };
306
- const getUrl = ({ baseUrl, path, query, querySerializer, url: _url }) => {
307
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
308
- let url = (baseUrl ?? "") + pathUrl;
309
- if (path) url = defaultPathSerializer({
310
- path,
311
- url
312
- });
313
- let search = query ? querySerializer(query) : "";
314
- if (search.startsWith("?")) search = search.substring(1);
315
- if (search) url += `?${search}`;
316
- return url;
317
- };
318
- function getValidRequestBody(options) {
319
- const hasBody = options.body !== void 0;
320
- if (hasBody && options.bodySerializer) {
321
- if ("serializedBody" in options) return options.serializedBody !== void 0 && options.serializedBody !== "" ? options.serializedBody : null;
322
- return options.body !== "" ? options.body : null;
323
- }
324
- if (hasBody) return options.body;
325
- }
326
- //#endregion
327
- //#region src/client/core/auth.gen.ts
328
- const getAuthToken = async (auth, callback) => {
329
- const token = typeof callback === "function" ? await callback(auth) : callback;
330
- if (!token) return;
331
- if (auth.scheme === "bearer") return `Bearer ${token}`;
332
- if (auth.scheme === "basic") return `Basic ${btoa(token)}`;
333
- return token;
334
- };
335
- //#endregion
336
- //#region src/client/client/utils.gen.ts
337
- const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
338
- const querySerializer = (queryParams) => {
339
- const search = [];
340
- if (queryParams && typeof queryParams === "object") for (const name in queryParams) {
341
- const value = queryParams[name];
342
- if (value === void 0 || value === null) continue;
343
- const options = parameters[name] || args;
344
- if (Array.isArray(value)) {
345
- const serializedArray = serializeArrayParam({
346
- allowReserved: options.allowReserved,
347
- explode: true,
348
- name,
349
- style: "form",
350
- value,
351
- ...options.array
352
- });
353
- if (serializedArray) search.push(serializedArray);
354
- } else if (typeof value === "object") {
355
- const serializedObject = serializeObjectParam({
356
- allowReserved: options.allowReserved,
357
- explode: true,
358
- name,
359
- style: "deepObject",
360
- value,
361
- ...options.object
362
- });
363
- if (serializedObject) search.push(serializedObject);
364
- } else {
365
- const serializedPrimitive = serializePrimitiveParam({
366
- allowReserved: options.allowReserved,
367
- name,
368
- value
369
- });
370
- if (serializedPrimitive) search.push(serializedPrimitive);
371
- }
372
- }
373
- return search.join("&");
374
- };
375
- return querySerializer;
376
- };
377
- /**
378
- * Infers parseAs value from provided Content-Type header.
379
- */
380
- const getParseAs = (contentType) => {
381
- if (!contentType) return "stream";
382
- const cleanContent = contentType.split(";")[0]?.trim();
383
- if (!cleanContent) return;
384
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) return "json";
385
- if (cleanContent === "multipart/form-data") return "formData";
386
- if ([
387
- "application/",
388
- "audio/",
389
- "image/",
390
- "video/"
391
- ].some((type) => cleanContent.startsWith(type))) return "blob";
392
- if (cleanContent.startsWith("text/")) return "text";
393
- };
394
- const checkForExistence = (options, name) => {
395
- if (!name) return false;
396
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) return true;
397
- return false;
398
- };
399
- async function setAuthParams(options) {
400
- for (const auth of options.security ?? []) {
401
- if (checkForExistence(options, auth.name)) continue;
402
- const token = await getAuthToken(auth, options.auth);
403
- if (!token) continue;
404
- const name = auth.name ?? "Authorization";
405
- switch (auth.in) {
406
- case "query":
407
- if (!options.query) options.query = {};
408
- options.query[name] = token;
409
- break;
410
- case "cookie":
411
- options.headers.append("Cookie", `${name}=${token}`);
412
- break;
413
- default: options.headers.set(name, token);
414
- }
415
- }
416
- }
417
- const buildUrl = (options) => getUrl({
418
- baseUrl: options.baseUrl,
419
- path: options.path,
420
- query: options.query,
421
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
422
- url: options.url
423
- });
424
- const mergeConfigs = (a, b) => {
425
- const config = {
426
- ...a,
427
- ...b
428
- };
429
- if (config.baseUrl?.endsWith("/")) config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
430
- config.headers = mergeHeaders(a.headers, b.headers);
431
- return config;
432
- };
433
- const headersEntries = (headers) => {
434
- const entries = [];
435
- headers.forEach((value, key) => {
436
- entries.push([key, value]);
437
- });
438
- return entries;
439
- };
440
- const mergeHeaders = (...headers) => {
441
- const mergedHeaders = new Headers();
442
- for (const header of headers) {
443
- if (!header) continue;
444
- const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
445
- for (const [key, value] of iterator) if (value === null) mergedHeaders.delete(key);
446
- else if (Array.isArray(value)) for (const v of value) mergedHeaders.append(key, v);
447
- else if (value !== void 0) mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
448
- }
449
- return mergedHeaders;
450
- };
451
- var Interceptors = class {
452
- fns = [];
453
- clear() {
454
- this.fns = [];
455
- }
456
- eject(id) {
457
- const index = this.getInterceptorIndex(id);
458
- if (this.fns[index]) this.fns[index] = null;
459
- }
460
- exists(id) {
461
- const index = this.getInterceptorIndex(id);
462
- return Boolean(this.fns[index]);
463
- }
464
- getInterceptorIndex(id) {
465
- if (typeof id === "number") return this.fns[id] ? id : -1;
466
- return this.fns.indexOf(id);
467
- }
468
- update(id, fn) {
469
- const index = this.getInterceptorIndex(id);
470
- if (this.fns[index]) {
471
- this.fns[index] = fn;
472
- return id;
473
- }
474
- return false;
475
- }
476
- use(fn) {
477
- this.fns.push(fn);
478
- return this.fns.length - 1;
479
- }
480
- };
481
- const createInterceptors = () => ({
482
- error: new Interceptors(),
483
- request: new Interceptors(),
484
- response: new Interceptors()
485
- });
486
- const defaultQuerySerializer = createQuerySerializer({
487
- allowReserved: false,
488
- array: {
489
- explode: true,
490
- style: "form"
491
- },
492
- object: {
493
- explode: true,
494
- style: "deepObject"
495
- }
496
- });
497
- const defaultHeaders = { "Content-Type": "application/json" };
498
- const createConfig = (override = {}) => ({
499
- ...jsonBodySerializer,
500
- headers: defaultHeaders,
501
- parseAs: "auto",
502
- querySerializer: defaultQuerySerializer,
503
- ...override
504
- });
505
- //#endregion
506
- //#region src/client/client/client.gen.ts
507
- const createClient$1 = (config = {}) => {
508
- let _config = mergeConfigs(createConfig(), config);
509
- const getConfig = () => ({ ..._config });
510
- const setConfig = (config) => {
511
- _config = mergeConfigs(_config, config);
512
- return getConfig();
513
- };
514
- const interceptors = createInterceptors();
515
- const beforeRequest = async (options) => {
516
- const opts = {
517
- ..._config,
518
- ...options,
519
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
520
- headers: mergeHeaders(_config.headers, options.headers),
521
- serializedBody: void 0
522
- };
523
- if (opts.security) await setAuthParams(opts);
524
- if (opts.requestValidator) await opts.requestValidator(opts);
525
- if (opts.body !== void 0 && opts.bodySerializer) opts.serializedBody = opts.bodySerializer(opts.body);
526
- if (opts.body === void 0 || opts.serializedBody === "") opts.headers.delete("Content-Type");
527
- const resolvedOpts = opts;
528
- return {
529
- opts: resolvedOpts,
530
- url: buildUrl(resolvedOpts)
531
- };
532
- };
533
- const request = async (options) => {
534
- const throwOnError = options.throwOnError ?? _config.throwOnError;
535
- const responseStyle = options.responseStyle ?? _config.responseStyle;
536
- let request;
537
- let response;
538
- try {
539
- const { opts, url } = await beforeRequest(options);
540
- const requestInit = {
541
- redirect: "follow",
542
- ...opts,
543
- body: getValidRequestBody(opts)
544
- };
545
- request = new Request(url, requestInit);
546
- for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
547
- const _fetch = opts.fetch;
548
- response = await _fetch(request);
549
- for (const fn of interceptors.response.fns) if (fn) response = await fn(response, request, opts);
550
- const result = {
551
- request,
552
- response
553
- };
554
- if (response.ok) {
555
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
556
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
557
- let emptyData;
558
- switch (parseAs) {
559
- case "arrayBuffer":
560
- case "blob":
561
- case "text":
562
- emptyData = await response[parseAs]();
563
- break;
564
- case "formData":
565
- emptyData = new FormData();
566
- break;
567
- case "stream":
568
- emptyData = response.body;
569
- break;
570
- default: emptyData = {};
571
- }
572
- return opts.responseStyle === "data" ? emptyData : {
573
- data: emptyData,
574
- ...result
575
- };
576
- }
577
- let data;
578
- switch (parseAs) {
579
- case "arrayBuffer":
580
- case "blob":
581
- case "formData":
582
- case "text":
583
- data = await response[parseAs]();
584
- break;
585
- case "json": {
586
- const text = await response.text();
587
- data = text ? JSON.parse(text) : {};
588
- break;
589
- }
590
- case "stream": return opts.responseStyle === "data" ? response.body : {
591
- data: response.body,
592
- ...result
593
- };
594
- }
595
- if (parseAs === "json") {
596
- if (opts.responseValidator) await opts.responseValidator(data);
597
- if (opts.responseTransformer) data = await opts.responseTransformer(data);
598
- }
599
- return opts.responseStyle === "data" ? data : {
600
- data,
601
- ...result
602
- };
603
- }
604
- const textError = await response.text();
605
- let jsonError;
606
- try {
607
- jsonError = JSON.parse(textError);
608
- } catch {}
609
- throw jsonError ?? textError;
610
- } catch (error) {
611
- let finalError = error;
612
- for (const fn of interceptors.error.fns) if (fn) finalError = await fn(finalError, response, request, options);
613
- finalError = finalError || {};
614
- if (throwOnError) throw finalError;
615
- return responseStyle === "data" ? void 0 : {
616
- error: finalError,
617
- request,
618
- response
619
- };
620
- }
621
- };
622
- const makeMethodFn = (method) => (options) => request({
623
- ...options,
624
- method
625
- });
626
- const makeSseFn = (method) => async (options) => {
627
- const { opts, url } = await beforeRequest(options);
628
- return createSseClient({
629
- ...opts,
630
- body: opts.body,
631
- method,
632
- onRequest: async (url, init) => {
633
- let request = new Request(url, init);
634
- for (const fn of interceptors.request.fns) if (fn) request = await fn(request, opts);
635
- return request;
636
- },
637
- serializedBody: getValidRequestBody(opts),
638
- url
639
- });
640
- };
641
- const _buildUrl = (options) => buildUrl({
642
- ..._config,
643
- ...options
644
- });
645
- return {
646
- buildUrl: _buildUrl,
647
- connect: makeMethodFn("CONNECT"),
648
- delete: makeMethodFn("DELETE"),
649
- get: makeMethodFn("GET"),
650
- getConfig,
651
- head: makeMethodFn("HEAD"),
652
- interceptors,
653
- options: makeMethodFn("OPTIONS"),
654
- patch: makeMethodFn("PATCH"),
655
- post: makeMethodFn("POST"),
656
- put: makeMethodFn("PUT"),
657
- request,
658
- setConfig,
659
- sse: {
660
- connect: makeSseFn("CONNECT"),
661
- delete: makeSseFn("DELETE"),
662
- get: makeSseFn("GET"),
663
- head: makeSseFn("HEAD"),
664
- options: makeSseFn("OPTIONS"),
665
- patch: makeSseFn("PATCH"),
666
- post: makeSseFn("POST"),
667
- put: makeSseFn("PUT"),
668
- trace: makeSseFn("TRACE")
669
- },
670
- trace: makeMethodFn("TRACE")
671
- };
672
- };
673
- //#endregion
674
- //#region src/client/client.gen.ts
675
- const client = createClient$1(createConfig({ baseUrl: "https://api.samva.dev" }));
676
- //#endregion
1
+ import { buildClientParams } from "./core/params.gen.js";
2
+ import { client } from "./client.gen.js";
677
3
  //#region src/client/sdk.gen.ts
678
4
  var Messages = class {
679
5
  /**
@@ -4202,7 +3528,7 @@ var Contacts = class {
4202
3528
  /**
4203
3529
  * Find a contact
4204
3530
  *
4205
- * Looks up a single contact by email address or external ID and returns null when no contact matches.
3531
+ * Looks up a single contact by exactly one of email address, phone number, or external ID and returns null when no contact matches. A phone number without `+` is read in the organization's default region.
4206
3532
  */
4207
3533
  static find(parameters, options) {
4208
3534
  const params = buildClientParams([parameters], [{ args: [
@@ -4378,7 +3704,7 @@ var Contacts = class {
4378
3704
  },
4379
3705
  {
4380
3706
  in: "body",
4381
- key: "channel"
3707
+ key: "type"
4382
3708
  },
4383
3709
  {
4384
3710
  in: "body",
@@ -4428,6 +3754,57 @@ var Contacts = class {
4428
3754
  });
4429
3755
  }
4430
3756
  /**
3757
+ * Record contact consent
3758
+ *
3759
+ * Records the contact's consent on one channel at one of its addresses and returns the contact. `opted_out` stops every send on that channel to that address until the contact opts back in; `opted_in` is what channels that require opt-in check for. `source` and `capturedAt` say where and when the contact decided; `proof` keeps your evidence. A decision captured before the recorded one is ignored. A change publishes `contact.consent_changed`.
3760
+ */
3761
+ static setConsent(parameters, options) {
3762
+ const params = buildClientParams([parameters], [{ args: [
3763
+ {
3764
+ in: "path",
3765
+ key: "id"
3766
+ },
3767
+ {
3768
+ in: "path",
3769
+ key: "identityId"
3770
+ },
3771
+ {
3772
+ in: "path",
3773
+ key: "channel"
3774
+ },
3775
+ {
3776
+ in: "body",
3777
+ key: "status"
3778
+ },
3779
+ {
3780
+ in: "body",
3781
+ key: "source"
3782
+ },
3783
+ {
3784
+ in: "body",
3785
+ key: "capturedAt"
3786
+ },
3787
+ {
3788
+ in: "body",
3789
+ key: "proof"
3790
+ }
3791
+ ] }]);
3792
+ return (options?.client ?? client).put({
3793
+ security: [{
3794
+ name: "x-api-key",
3795
+ type: "apiKey"
3796
+ }],
3797
+ url: "/v1/contacts/{id}/identities/{identityId}/consent/{channel}",
3798
+ ...options,
3799
+ ...params,
3800
+ headers: {
3801
+ "Content-Type": "application/json",
3802
+ ...options?.headers,
3803
+ ...params.headers
3804
+ }
3805
+ });
3806
+ }
3807
+ /**
4431
3808
  * Remove contact tags
4432
3809
  *
4433
3810
  * Removes the given tags from the contact and returns the contact. A tag the contact does not have is ignored.
@@ -5821,15 +5198,15 @@ var Unsubscribe = class {
5821
5198
  /**
5822
5199
  * Remove contacts from an unsubscribe group
5823
5200
  *
5824
- * Removes one or more email addresses from an unsubscribe group and returns the number removed.
5201
+ * Returns contacts to an unsubscribe group's audience and returns the number removed. Each member is a contact ID, an email address, or a phone number; an address no contact holds is skipped.
5825
5202
  */
5826
- static removeEmails(parameters, options) {
5203
+ static removeMembers(parameters, options) {
5827
5204
  const params = buildClientParams([parameters], [{ args: [{
5828
5205
  in: "path",
5829
5206
  key: "id"
5830
5207
  }, {
5831
5208
  in: "body",
5832
- key: "emails"
5209
+ key: "members"
5833
5210
  }] }]);
5834
5211
  return (options?.client ?? client).delete({
5835
5212
  security: [{
@@ -5849,7 +5226,7 @@ var Unsubscribe = class {
5849
5226
  /**
5850
5227
  * List unsubscribe group members
5851
5228
  *
5852
- * Returns the email addresses in an unsubscribe group, newest first. Pass `nextCursor` back as `cursor` for the next page; it is null on the last page.
5229
+ * Returns the contacts that have left an unsubscribe group, newest first. Pass `nextCursor` back as `cursor` for the next page; it is null on the last page.
5853
5230
  */
5854
5231
  static listMembers(parameters, options) {
5855
5232
  const params = buildClientParams([parameters], [{ args: [
@@ -5879,9 +5256,9 @@ var Unsubscribe = class {
5879
5256
  /**
5880
5257
  * Add contacts to an unsubscribe group
5881
5258
  *
5882
- * Adds one or more email addresses to an unsubscribe group and returns the number added and the number skipped.
5259
+ * Moves contacts out of an unsubscribe group's audience and returns the number added and the number skipped. Leaving a group stops that group's sends to the contact on every channel. Each member is a contact ID, an email address, or a phone number; an address no contact holds gets a new contact, so an import from another email service needs no contacts first.
5883
5260
  */
5884
- static addEmails(parameters, options) {
5261
+ static addMembers(parameters, options) {
5885
5262
  const params = buildClientParams([parameters], [{ args: [
5886
5263
  {
5887
5264
  in: "path",
@@ -5889,7 +5266,7 @@ var Unsubscribe = class {
5889
5266
  },
5890
5267
  {
5891
5268
  in: "body",
5892
- key: "emails"
5269
+ key: "members"
5893
5270
  },
5894
5271
  {
5895
5272
  in: "body",
@@ -5914,16 +5291,27 @@ var Unsubscribe = class {
5914
5291
  /**
5915
5292
  * Check unsubscribe group membership
5916
5293
  *
5917
- * Returns the unsubscribe groups that an email address has unsubscribed from, optionally limited to a specified set of groups.
5294
+ * Returns the unsubscribe groups a contact has left, optionally limited to a specified set of groups. Name the contact by exactly one of `contactId`, `email`, or `phone`. Membership belongs to the contact, so the answer is the same whichever identifier names it; `contactId` is null, and no groups are returned, when no contact holds the email or phone.
5918
5295
  */
5919
5296
  static checkSubscription(parameters, options) {
5920
- const params = buildClientParams([parameters], [{ args: [{
5921
- in: "query",
5922
- key: "email"
5923
- }, {
5924
- in: "query",
5925
- key: "groupIds"
5926
- }] }]);
5297
+ const params = buildClientParams([parameters], [{ args: [
5298
+ {
5299
+ in: "query",
5300
+ key: "contactId"
5301
+ },
5302
+ {
5303
+ in: "query",
5304
+ key: "email"
5305
+ },
5306
+ {
5307
+ in: "query",
5308
+ key: "phone"
5309
+ },
5310
+ {
5311
+ in: "query",
5312
+ key: "groupIds"
5313
+ }
5314
+ ] }]);
5927
5315
  return (options?.client ?? client).get({
5928
5316
  security: [{
5929
5317
  name: "x-api-key",
@@ -7719,7 +7107,7 @@ var Organizations = class {
7719
7107
  },
7720
7108
  {
7721
7109
  in: "body",
7722
- key: "countryCode"
7110
+ key: "defaultRegion"
7723
7111
  },
7724
7112
  {
7725
7113
  in: "body",
@@ -10057,7 +9445,7 @@ var Mailboxes = class {
10057
9445
  /**
10058
9446
  * Cancel a mailbox send
10059
9447
  *
10060
- * Cancels a definitely unsent action and reopens its draft atomically. Only an authorized person who proposed the send or can approve actions may cancel. Accepted sends return 409 with their winning receipt and cannot be withdrawn. An uncertain send requires reconciliation and cannot be cancelled as unsent.
9448
+ * Cancels a definitely unsent action and reopens its draft atomically. Only an authorized person who proposed the send or can approve actions may cancel. Accepted sends return 409 with their winning receipt and cannot be withdrawn. An uncertain send requires reconciliation and cannot be cancelled as unsent. Cancelling a send held for approval records `resolution.outcome: cancelled` and publishes one `mailbox.action.resolved` event.
10061
9449
  */
10062
9450
  static cancelAction(parameters, options) {
10063
9451
  const params = buildClientParams([parameters], [{ args: [{
@@ -10103,7 +9491,7 @@ var Mailboxes = class {
10103
9491
  /**
10104
9492
  * Approve a mailbox action
10105
9493
  *
10106
- * Records approval of a send and returns 202 while it is pending. A send is queued for automatic retry within 15 minutes of approval; repeating approval does not extend this deadline. Accepted, completed, and notSent replays return 200. No expiry applies before approval. Only a person signed in or through OAuth may approve, and never the proposer. Non-send approvals execute synchronously and return 200 with their own execution states.
9494
+ * Records approval of a send and returns 202 while it is pending. A send is queued for automatic retry within 15 minutes of approval; repeating approval does not extend this deadline. Accepted, completed, and notSent replays return 200. No expiry applies before approval. Only a person signed in or through OAuth may approve, and never the proposer. Non-send approvals execute synchronously and return 200 with their own execution states. The action's `resolution` names the approver; approving a held send publishes one `mailbox.action.resolved` event.
10107
9495
  */
10108
9496
  static approveAction(parameters, options) {
10109
9497
  const params = buildClientParams([parameters], [{ args: [{
@@ -10126,7 +9514,7 @@ var Mailboxes = class {
10126
9514
  /**
10127
9515
  * Deny a mailbox action
10128
9516
  *
10129
- * Denies an action waiting for approval with a reason and returns it without executing it. Only a person signed in or through OAuth may deny, and never the one who proposed it.
9517
+ * Denies an action waiting for approval with a reason and returns it without executing it. Only a person signed in or through OAuth may deny, and never the one who proposed it. The action's `resolution` records the denier and reason; denying a held send publishes one `mailbox.action.resolved` event.
10130
9518
  */
10131
9519
  static denyAction(parameters, options) {
10132
9520
  const params = buildClientParams([parameters], [{ args: [
@@ -10723,1621 +10111,6 @@ var ExtensionInstallations = class {
10723
10111
  }
10724
10112
  };
10725
10113
  //#endregion
10726
- //#region src/promises/errors.gen.ts
10727
- const redactRequest = (request) => request === void 0 ? void 0 : new Request(request.url, { method: request.method });
10728
- /** Base class for failures declared by the public Samva OpenAPI contract. */
10729
- var SamvaApiError = class extends Error {
10730
- request;
10731
- response;
10732
- status;
10733
- constructor(message, context = {}) {
10734
- super(message);
10735
- this.name = new.target.name;
10736
- this.request = redactRequest(context.request);
10737
- this.response = context.response;
10738
- this.status = context.response?.status;
10739
- }
10740
- };
10741
- /** A transport or malformed-response failure that is not part of the API error contract. */
10742
- var SamvaTransportError = class extends Error {
10743
- _tag = "SamvaTransportError";
10744
- request;
10745
- response;
10746
- status;
10747
- cause;
10748
- constructor(cause, context = {}) {
10749
- super(cause instanceof Error ? cause.message : "Samva request failed", { cause });
10750
- this.name = "SamvaTransportError";
10751
- this.cause = cause;
10752
- this.request = redactRequest(context.request);
10753
- this.response = context.response;
10754
- this.status = context.response?.status;
10755
- }
10756
- };
10757
- const messageOf = (tag, payload) => {
10758
- const message = payload.message;
10759
- return typeof message === "string" ? message : tag;
10760
- };
10761
- var AnalyticsQueryError = class extends SamvaApiError {
10762
- _tag = "AnalyticsQueryError";
10763
- constructor(payload, context = {}) {
10764
- super(messageOf("AnalyticsQueryError", payload), context);
10765
- Object.assign(this, payload);
10766
- }
10767
- };
10768
- var BillingProviderError = class extends SamvaApiError {
10769
- _tag = "BillingProviderError";
10770
- constructor(payload, context = {}) {
10771
- super(messageOf("BillingProviderError", payload), context);
10772
- Object.assign(this, payload);
10773
- }
10774
- };
10775
- var BrandAddressRequiredError = class extends SamvaApiError {
10776
- _tag = "BrandAddressRequiredError";
10777
- constructor(payload, context = {}) {
10778
- super(messageOf("BrandAddressRequiredError", payload), context);
10779
- Object.assign(this, payload);
10780
- }
10781
- };
10782
- var CampaignFooterRequiredError = class extends SamvaApiError {
10783
- _tag = "CampaignFooterRequiredError";
10784
- constructor(payload, context = {}) {
10785
- super(messageOf("CampaignFooterRequiredError", payload), context);
10786
- Object.assign(this, payload);
10787
- }
10788
- };
10789
- var ConflictError = class extends SamvaApiError {
10790
- _tag = "ConflictError";
10791
- constructor(payload, context = {}) {
10792
- super(messageOf("ConflictError", payload), context);
10793
- Object.assign(this, payload);
10794
- }
10795
- };
10796
- var DeliveryUnavailableError = class extends SamvaApiError {
10797
- _tag = "DeliveryUnavailableError";
10798
- constructor(payload, context = {}) {
10799
- super(messageOf("DeliveryUnavailableError", payload), context);
10800
- Object.assign(this, payload);
10801
- }
10802
- };
10803
- var EmailChannelError = class extends SamvaApiError {
10804
- _tag = "EmailChannelError";
10805
- constructor(payload, context = {}) {
10806
- super(messageOf("EmailChannelError", payload), context);
10807
- Object.assign(this, payload);
10808
- }
10809
- };
10810
- var ExternalServiceError = class extends SamvaApiError {
10811
- _tag = "ExternalServiceError";
10812
- constructor(payload, context = {}) {
10813
- super(messageOf("ExternalServiceError", payload), context);
10814
- Object.assign(this, payload);
10815
- }
10816
- };
10817
- var FlagDisabledError = class extends SamvaApiError {
10818
- _tag = "FlagDisabledError";
10819
- constructor(payload, context = {}) {
10820
- super(messageOf("FlagDisabledError", payload), context);
10821
- Object.assign(this, payload);
10822
- }
10823
- };
10824
- var ForbiddenError = class extends SamvaApiError {
10825
- _tag = "ForbiddenError";
10826
- constructor(payload, context = {}) {
10827
- super(messageOf("ForbiddenError", payload), context);
10828
- Object.assign(this, payload);
10829
- }
10830
- };
10831
- var GatewayTimeoutError = class extends SamvaApiError {
10832
- _tag = "GatewayTimeoutError";
10833
- constructor(payload, context = {}) {
10834
- super(messageOf("GatewayTimeoutError", payload), context);
10835
- Object.assign(this, payload);
10836
- }
10837
- };
10838
- var InternalError = class extends SamvaApiError {
10839
- _tag = "InternalError";
10840
- constructor(payload, context = {}) {
10841
- super(messageOf("InternalError", payload), context);
10842
- Object.assign(this, payload);
10843
- }
10844
- };
10845
- var MailboxChannelUnsupportedError = class extends SamvaApiError {
10846
- _tag = "MailboxChannelUnsupportedError";
10847
- constructor(payload, context = {}) {
10848
- super(messageOf("MailboxChannelUnsupportedError", payload), context);
10849
- Object.assign(this, payload);
10850
- }
10851
- };
10852
- var MailboxSendConflictError = class extends SamvaApiError {
10853
- _tag = "MailboxSendConflictError";
10854
- constructor(payload, context = {}) {
10855
- super(messageOf("MailboxSendConflictError", payload), context);
10856
- Object.assign(this, payload);
10857
- }
10858
- };
10859
- var MailboxSendRefusedError = class extends SamvaApiError {
10860
- _tag = "MailboxSendRefusedError";
10861
- constructor(payload, context = {}) {
10862
- super(messageOf("MailboxSendRefusedError", payload), context);
10863
- Object.assign(this, payload);
10864
- }
10865
- };
10866
- var OnboardingReviewRequiredError = class extends SamvaApiError {
10867
- _tag = "OnboardingReviewRequiredError";
10868
- constructor(payload, context = {}) {
10869
- super(messageOf("OnboardingReviewRequiredError", payload), context);
10870
- Object.assign(this, payload);
10871
- }
10872
- };
10873
- var PaymentRequiredError = class extends SamvaApiError {
10874
- _tag = "PaymentRequiredError";
10875
- constructor(payload, context = {}) {
10876
- super(messageOf("PaymentRequiredError", payload), context);
10877
- Object.assign(this, payload);
10878
- }
10879
- };
10880
- var RateLimitedError = class extends SamvaApiError {
10881
- _tag = "RateLimitedError";
10882
- constructor(payload, context = {}) {
10883
- super(messageOf("RateLimitedError", payload), context);
10884
- Object.assign(this, payload);
10885
- }
10886
- };
10887
- var ResourceNotFoundError = class extends SamvaApiError {
10888
- _tag = "ResourceNotFoundError";
10889
- constructor(payload, context = {}) {
10890
- super(messageOf("ResourceNotFoundError", payload), context);
10891
- Object.assign(this, payload);
10892
- }
10893
- };
10894
- var SenderNotReadyError = class extends SamvaApiError {
10895
- _tag = "SenderNotReadyError";
10896
- constructor(payload, context = {}) {
10897
- super(messageOf("SenderNotReadyError", payload), context);
10898
- Object.assign(this, payload);
10899
- }
10900
- };
10901
- var UnauthorizedError = class extends SamvaApiError {
10902
- _tag = "UnauthorizedError";
10903
- constructor(payload, context = {}) {
10904
- super(messageOf("UnauthorizedError", payload), context);
10905
- Object.assign(this, payload);
10906
- }
10907
- };
10908
- var ValidationError = class extends SamvaApiError {
10909
- _tag = "ValidationError";
10910
- constructor(payload, context = {}) {
10911
- super(messageOf("ValidationError", payload), context);
10912
- Object.assign(this, payload);
10913
- }
10914
- };
10915
- const constructors = {
10916
- AnalyticsQueryError,
10917
- BillingProviderError,
10918
- BrandAddressRequiredError,
10919
- CampaignFooterRequiredError,
10920
- ConflictError,
10921
- DeliveryUnavailableError,
10922
- EmailChannelError,
10923
- ExternalServiceError,
10924
- FlagDisabledError,
10925
- ForbiddenError,
10926
- GatewayTimeoutError,
10927
- InternalError,
10928
- MailboxChannelUnsupportedError,
10929
- MailboxSendConflictError,
10930
- MailboxSendRefusedError,
10931
- OnboardingReviewRequiredError,
10932
- PaymentRequiredError,
10933
- RateLimitedError,
10934
- ResourceNotFoundError,
10935
- SenderNotReadyError,
10936
- UnauthorizedError,
10937
- ValidationError
10938
- };
10939
- const payloadSchemas = {
10940
- AnalyticsQueryError: {
10941
- type: "object",
10942
- properties: {
10943
- _tag: {
10944
- type: "string",
10945
- enum: ["AnalyticsQueryError"]
10946
- },
10947
- message: { type: "string" }
10948
- },
10949
- required: ["_tag", "message"],
10950
- additionalProperties: false
10951
- },
10952
- BillingProviderError: {
10953
- type: "object",
10954
- properties: {
10955
- _tag: {
10956
- type: "string",
10957
- enum: ["BillingProviderError"]
10958
- },
10959
- message: { type: "string" }
10960
- },
10961
- required: ["_tag", "message"],
10962
- additionalProperties: false,
10963
- "x-category": ["transient"],
10964
- "x-retryable": true
10965
- },
10966
- BrandAddressRequiredError: {
10967
- type: "object",
10968
- properties: {
10969
- _tag: {
10970
- type: "string",
10971
- enum: ["BrandAddressRequiredError"]
10972
- },
10973
- message: { type: "string" },
10974
- brand: { anyOf: [{ type: "string" }, { type: "null" }] }
10975
- },
10976
- required: [
10977
- "_tag",
10978
- "message",
10979
- "brand"
10980
- ],
10981
- additionalProperties: false
10982
- },
10983
- CampaignFooterRequiredError: {
10984
- type: "object",
10985
- properties: {
10986
- _tag: {
10987
- type: "string",
10988
- enum: ["CampaignFooterRequiredError"]
10989
- },
10990
- message: { type: "string" }
10991
- },
10992
- required: ["_tag", "message"],
10993
- additionalProperties: false
10994
- },
10995
- ConflictError: {
10996
- type: "object",
10997
- properties: {
10998
- _tag: {
10999
- type: "string",
11000
- enum: ["ConflictError"]
11001
- },
11002
- message: { type: "string" },
11003
- resource: { type: "string" },
11004
- id: { anyOf: [{ type: "string" }, { type: "null" }] }
11005
- },
11006
- required: [
11007
- "_tag",
11008
- "message",
11009
- "resource"
11010
- ],
11011
- additionalProperties: false,
11012
- "x-category": ["conflict"],
11013
- "x-retryable": false
11014
- },
11015
- DeliveryUnavailableError: {
11016
- type: "object",
11017
- properties: {
11018
- _tag: {
11019
- type: "string",
11020
- enum: ["DeliveryUnavailableError"]
11021
- },
11022
- message: { type: "string" },
11023
- retryAfterSeconds: { type: "number" }
11024
- },
11025
- required: [
11026
- "_tag",
11027
- "message",
11028
- "retryAfterSeconds"
11029
- ],
11030
- additionalProperties: false,
11031
- "x-category": ["transient"],
11032
- "x-retryable": true
11033
- },
11034
- EmailChannelError: {
11035
- type: "object",
11036
- properties: {
11037
- _tag: {
11038
- type: "string",
11039
- enum: ["EmailChannelError"]
11040
- },
11041
- reason: {
11042
- type: "string",
11043
- enum: [
11044
- "transport",
11045
- "rejected",
11046
- "rate_limited",
11047
- "auth"
11048
- ]
11049
- },
11050
- message: { type: "string" },
11051
- statusCode: { anyOf: [{ type: "number" }, { type: "null" }] }
11052
- },
11053
- required: [
11054
- "_tag",
11055
- "reason",
11056
- "message"
11057
- ],
11058
- additionalProperties: false
11059
- },
11060
- ExternalServiceError: {
11061
- type: "object",
11062
- properties: {
11063
- _tag: {
11064
- type: "string",
11065
- enum: ["ExternalServiceError"]
11066
- },
11067
- message: { type: "string" }
11068
- },
11069
- required: ["_tag", "message"],
11070
- additionalProperties: false,
11071
- "x-category": ["transient"],
11072
- "x-retryable": true
11073
- },
11074
- FlagDisabledError: {
11075
- type: "object",
11076
- properties: {
11077
- _tag: {
11078
- type: "string",
11079
- enum: ["FlagDisabledError"]
11080
- },
11081
- flag: { type: "string" },
11082
- message: { type: "string" }
11083
- },
11084
- required: [
11085
- "_tag",
11086
- "flag",
11087
- "message"
11088
- ],
11089
- additionalProperties: false,
11090
- "x-retryable": false
11091
- },
11092
- ForbiddenError: {
11093
- type: "object",
11094
- properties: {
11095
- _tag: {
11096
- type: "string",
11097
- enum: ["ForbiddenError"]
11098
- },
11099
- message: { type: "string" }
11100
- },
11101
- required: ["_tag", "message"],
11102
- additionalProperties: false,
11103
- "x-category": ["auth"],
11104
- "x-retryable": false
11105
- },
11106
- GatewayTimeoutError: {
11107
- type: "object",
11108
- properties: {
11109
- _tag: {
11110
- type: "string",
11111
- enum: ["GatewayTimeoutError"]
11112
- },
11113
- message: { type: "string" },
11114
- retryAfterSeconds: { type: "number" }
11115
- },
11116
- required: [
11117
- "_tag",
11118
- "message",
11119
- "retryAfterSeconds"
11120
- ],
11121
- additionalProperties: false,
11122
- "x-category": ["transient"],
11123
- "x-retryable": true
11124
- },
11125
- InternalError: {
11126
- type: "object",
11127
- properties: {
11128
- _tag: {
11129
- type: "string",
11130
- enum: ["InternalError"]
11131
- },
11132
- message: { type: "string" }
11133
- },
11134
- required: ["_tag", "message"],
11135
- additionalProperties: false,
11136
- "x-category": ["transient"],
11137
- "x-retryable": true
11138
- },
11139
- MailboxChannelUnsupportedError: {
11140
- type: "object",
11141
- properties: {
11142
- _tag: {
11143
- type: "string",
11144
- enum: ["MailboxChannelUnsupportedError"]
11145
- },
11146
- message: { type: "string" },
11147
- channel: { type: "string" }
11148
- },
11149
- required: [
11150
- "_tag",
11151
- "message",
11152
- "channel"
11153
- ],
11154
- additionalProperties: false
11155
- },
11156
- MailboxSendConflictError: {
11157
- type: "object",
11158
- properties: {
11159
- _tag: {
11160
- type: "string",
11161
- enum: ["MailboxSendConflictError"]
11162
- },
11163
- message: { type: "string" },
11164
- resource: { type: "string" },
11165
- id: {
11166
- type: "string",
11167
- pattern: "^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$",
11168
- "x-samva-brand": "MailboxActionId"
11169
- },
11170
- receipt: {
11171
- type: "object",
11172
- properties: {
11173
- actionId: {
11174
- type: "string",
11175
- pattern: "^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$",
11176
- "x-samva-brand": "MailboxActionId"
11177
- },
11178
- draftId: { anyOf: [{
11179
- type: "string",
11180
- pattern: "^mdraft_[0-9a-hjkmnp-tv-z]{16,24}$",
11181
- "x-samva-brand": "MailboxDraftId"
11182
- }, { type: "null" }] },
11183
- messageId: { anyOf: [{
11184
- type: "string",
11185
- pattern: "^msg_[0-9a-hjkmnp-tv-z]{16,24}$",
11186
- "x-samva-brand": "MessageId"
11187
- }, { type: "null" }] },
11188
- threadId: { anyOf: [{
11189
- type: "string",
11190
- pattern: "^thread_[0-9a-hjkmnp-tv-z]{16,24}$",
11191
- "x-samva-brand": "MailboxThreadId"
11192
- }, { type: "null" }] },
11193
- state: {
11194
- type: "string",
11195
- enum: [
11196
- "approvalRequired",
11197
- "queued",
11198
- "accepted",
11199
- "completed",
11200
- "notSent",
11201
- "uncertain"
11202
- ]
11203
- },
11204
- acceptedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
11205
- waitReason: { anyOf: [{
11206
- type: "string",
11207
- enum: [
11208
- "rate",
11209
- "daily-quota",
11210
- "domain-health",
11211
- "sending-paused",
11212
- "upstream-unavailable",
11213
- "retry",
11214
- "campaign-paused",
11215
- "domain-warming",
11216
- "onboarding-review",
11217
- "content-review",
11218
- "screening-unavailable"
11219
- ]
11220
- }, { type: "null" }] },
11221
- reviewExpectedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
11222
- skippedRecipients: {
11223
- type: "array",
11224
- items: {
11225
- type: "object",
11226
- properties: {
11227
- address: { type: "string" },
11228
- reason: {
11229
- type: "string",
11230
- enum: [
11231
- "bounce",
11232
- "complaint",
11233
- "unsubscribe",
11234
- "manual",
11235
- "group-unsubscribe"
11236
- ]
11237
- },
11238
- unsubscribeGroupId: { anyOf: [{
11239
- type: "string",
11240
- pattern: "^unsub_[0-9a-hjkmnp-tv-z]{16,24}$",
11241
- "x-samva-brand": "UnsubscribeId"
11242
- }, { type: "null" }] }
11243
- },
11244
- required: ["address", "reason"],
11245
- additionalProperties: false
11246
- }
11247
- },
11248
- executeUntil: { anyOf: [{ type: "string" }, { type: "null" }] },
11249
- retryAt: { anyOf: [{ type: "string" }, { type: "null" }] },
11250
- problem: { anyOf: [{
11251
- type: "object",
11252
- properties: {
11253
- code: { type: "string" },
11254
- message: { type: "string" },
11255
- error: { anyOf: [{ anyOf: [
11256
- {
11257
- type: "object",
11258
- properties: {
11259
- _tag: {
11260
- type: "string",
11261
- enum: ["SenderNotReadyError"]
11262
- },
11263
- message: { type: "string" },
11264
- sender: { type: "string" },
11265
- retryAfterSeconds: { anyOf: [{ type: "number" }, { type: "null" }] }
11266
- },
11267
- required: [
11268
- "_tag",
11269
- "message",
11270
- "sender"
11271
- ],
11272
- additionalProperties: false
11273
- },
11274
- {
11275
- type: "object",
11276
- properties: {
11277
- _tag: {
11278
- type: "string",
11279
- enum: ["RateLimitedError"]
11280
- },
11281
- message: { type: "string" },
11282
- retryAfterSeconds: { type: "number" }
11283
- },
11284
- required: [
11285
- "_tag",
11286
- "message",
11287
- "retryAfterSeconds"
11288
- ],
11289
- additionalProperties: false
11290
- },
11291
- {
11292
- type: "object",
11293
- properties: {
11294
- _tag: {
11295
- type: "string",
11296
- enum: ["OnboardingReviewRequiredError"]
11297
- },
11298
- message: { type: "string" },
11299
- code: {
11300
- type: "string",
11301
- enum: [
11302
- "review_required",
11303
- "review_in_progress",
11304
- "information_required",
11305
- "review_rejected",
11306
- "identity_review_required",
11307
- "identity_review_rejected",
11308
- "identity_changed"
11309
- ]
11310
- },
11311
- decision: {
11312
- type: "string",
11313
- enum: [
11314
- "undecided",
11315
- "approved",
11316
- "rejected"
11317
- ]
11318
- },
11319
- stage: {
11320
- type: "string",
11321
- enum: [
11322
- "collecting",
11323
- "automated_review",
11324
- "manual_review",
11325
- "information_requested",
11326
- "complete"
11327
- ]
11328
- },
11329
- nextAction: {
11330
- type: "string",
11331
- enum: [
11332
- "wait_for_review",
11333
- "provide_information",
11334
- "verify_sending_identity",
11335
- "reapply",
11336
- "contact_support"
11337
- ]
11338
- },
11339
- identityId: { anyOf: [{ type: "string" }, { type: "null" }] }
11340
- },
11341
- required: [
11342
- "_tag",
11343
- "message",
11344
- "code",
11345
- "decision",
11346
- "stage",
11347
- "nextAction"
11348
- ],
11349
- additionalProperties: false
11350
- },
11351
- {
11352
- type: "object",
11353
- properties: {
11354
- _tag: {
11355
- type: "string",
11356
- enum: ["PaymentRequiredError"]
11357
- },
11358
- message: { type: "string" },
11359
- resource: { type: "string" },
11360
- currentUsage: { type: "number" },
11361
- limit: { type: "number" }
11362
- },
11363
- required: [
11364
- "_tag",
11365
- "message",
11366
- "resource",
11367
- "currentUsage",
11368
- "limit"
11369
- ],
11370
- additionalProperties: false
11371
- },
11372
- {
11373
- type: "object",
11374
- properties: {
11375
- _tag: {
11376
- type: "string",
11377
- enum: ["ValidationError"]
11378
- },
11379
- message: { type: "string" },
11380
- fields: { anyOf: [{
11381
- type: "object",
11382
- additionalProperties: {
11383
- type: "array",
11384
- items: { type: "string" }
11385
- }
11386
- }, { type: "null" }] }
11387
- },
11388
- required: ["_tag", "message"],
11389
- additionalProperties: false
11390
- },
11391
- {
11392
- type: "object",
11393
- properties: {
11394
- _tag: {
11395
- type: "string",
11396
- enum: ["ForbiddenError"]
11397
- },
11398
- message: { type: "string" }
11399
- },
11400
- required: ["_tag", "message"],
11401
- additionalProperties: false
11402
- },
11403
- {
11404
- type: "object",
11405
- properties: {
11406
- _tag: {
11407
- type: "string",
11408
- enum: ["ResourceNotFoundError"]
11409
- },
11410
- resource: { type: "string" },
11411
- id: { type: "string" },
11412
- message: { type: "string" }
11413
- },
11414
- required: [
11415
- "_tag",
11416
- "resource",
11417
- "id",
11418
- "message"
11419
- ],
11420
- additionalProperties: false
11421
- }
11422
- ] }, { type: "null" }] }
11423
- },
11424
- required: ["code", "message"],
11425
- additionalProperties: false
11426
- }, { type: "null" }] },
11427
- retryEligible: { type: "boolean" },
11428
- decision: { anyOf: [{
11429
- type: "object",
11430
- properties: {
11431
- outcome: {
11432
- type: "string",
11433
- enum: [
11434
- "allow",
11435
- "requireApproval",
11436
- "deny"
11437
- ]
11438
- },
11439
- reason: { anyOf: [{ type: "string" }, { type: "null" }] },
11440
- policyId: { anyOf: [{
11441
- type: "string",
11442
- pattern: "^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$",
11443
- "x-samva-brand": "MailboxPolicyId"
11444
- }, { type: "null" }] },
11445
- source: { anyOf: [{
11446
- type: "string",
11447
- enum: [
11448
- "grant",
11449
- "installation",
11450
- "policy"
11451
- ]
11452
- }, { type: "null" }] },
11453
- decidedAt: { type: "string" }
11454
- },
11455
- required: [
11456
- "outcome",
11457
- "reason",
11458
- "policyId",
11459
- "source",
11460
- "decidedAt"
11461
- ],
11462
- additionalProperties: false
11463
- }, { type: "null" }] },
11464
- createdAt: { type: "string" },
11465
- updatedAt: { type: "string" }
11466
- },
11467
- required: [
11468
- "actionId",
11469
- "draftId",
11470
- "messageId",
11471
- "threadId",
11472
- "state",
11473
- "acceptedAt",
11474
- "waitReason",
11475
- "reviewExpectedAt",
11476
- "skippedRecipients",
11477
- "executeUntil",
11478
- "retryAt",
11479
- "problem",
11480
- "retryEligible",
11481
- "decision",
11482
- "createdAt",
11483
- "updatedAt"
11484
- ],
11485
- additionalProperties: false
11486
- }
11487
- },
11488
- required: [
11489
- "_tag",
11490
- "message",
11491
- "resource",
11492
- "id",
11493
- "receipt"
11494
- ],
11495
- additionalProperties: false
11496
- },
11497
- MailboxSendRefusedError: {
11498
- type: "object",
11499
- properties: {
11500
- _tag: {
11501
- type: "string",
11502
- enum: ["MailboxSendRefusedError"]
11503
- },
11504
- message: { type: "string" },
11505
- receipt: {
11506
- type: "object",
11507
- properties: {
11508
- actionId: {
11509
- type: "string",
11510
- pattern: "^mbxact_[0-9a-hjkmnp-tv-z]{16,24}$",
11511
- "x-samva-brand": "MailboxActionId"
11512
- },
11513
- draftId: { anyOf: [{
11514
- type: "string",
11515
- pattern: "^mdraft_[0-9a-hjkmnp-tv-z]{16,24}$",
11516
- "x-samva-brand": "MailboxDraftId"
11517
- }, { type: "null" }] },
11518
- messageId: { anyOf: [{
11519
- type: "string",
11520
- pattern: "^msg_[0-9a-hjkmnp-tv-z]{16,24}$",
11521
- "x-samva-brand": "MessageId"
11522
- }, { type: "null" }] },
11523
- threadId: { anyOf: [{
11524
- type: "string",
11525
- pattern: "^thread_[0-9a-hjkmnp-tv-z]{16,24}$",
11526
- "x-samva-brand": "MailboxThreadId"
11527
- }, { type: "null" }] },
11528
- state: {
11529
- type: "string",
11530
- enum: [
11531
- "approvalRequired",
11532
- "queued",
11533
- "accepted",
11534
- "completed",
11535
- "notSent",
11536
- "uncertain"
11537
- ]
11538
- },
11539
- acceptedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
11540
- waitReason: { anyOf: [{
11541
- type: "string",
11542
- enum: [
11543
- "rate",
11544
- "daily-quota",
11545
- "domain-health",
11546
- "sending-paused",
11547
- "upstream-unavailable",
11548
- "retry",
11549
- "campaign-paused",
11550
- "domain-warming",
11551
- "onboarding-review",
11552
- "content-review",
11553
- "screening-unavailable"
11554
- ]
11555
- }, { type: "null" }] },
11556
- reviewExpectedAt: { anyOf: [{ type: "string" }, { type: "null" }] },
11557
- skippedRecipients: {
11558
- type: "array",
11559
- items: {
11560
- type: "object",
11561
- properties: {
11562
- address: { type: "string" },
11563
- reason: {
11564
- type: "string",
11565
- enum: [
11566
- "bounce",
11567
- "complaint",
11568
- "unsubscribe",
11569
- "manual",
11570
- "group-unsubscribe"
11571
- ]
11572
- },
11573
- unsubscribeGroupId: { anyOf: [{
11574
- type: "string",
11575
- pattern: "^unsub_[0-9a-hjkmnp-tv-z]{16,24}$",
11576
- "x-samva-brand": "UnsubscribeId"
11577
- }, { type: "null" }] }
11578
- },
11579
- required: ["address", "reason"],
11580
- additionalProperties: false
11581
- }
11582
- },
11583
- executeUntil: { anyOf: [{ type: "string" }, { type: "null" }] },
11584
- retryAt: { anyOf: [{ type: "string" }, { type: "null" }] },
11585
- problem: { anyOf: [{
11586
- type: "object",
11587
- properties: {
11588
- code: { type: "string" },
11589
- message: { type: "string" },
11590
- error: { anyOf: [{ anyOf: [
11591
- {
11592
- type: "object",
11593
- properties: {
11594
- _tag: {
11595
- type: "string",
11596
- enum: ["SenderNotReadyError"]
11597
- },
11598
- message: { type: "string" },
11599
- sender: { type: "string" },
11600
- retryAfterSeconds: { anyOf: [{ type: "number" }, { type: "null" }] }
11601
- },
11602
- required: [
11603
- "_tag",
11604
- "message",
11605
- "sender"
11606
- ],
11607
- additionalProperties: false
11608
- },
11609
- {
11610
- type: "object",
11611
- properties: {
11612
- _tag: {
11613
- type: "string",
11614
- enum: ["RateLimitedError"]
11615
- },
11616
- message: { type: "string" },
11617
- retryAfterSeconds: { type: "number" }
11618
- },
11619
- required: [
11620
- "_tag",
11621
- "message",
11622
- "retryAfterSeconds"
11623
- ],
11624
- additionalProperties: false
11625
- },
11626
- {
11627
- type: "object",
11628
- properties: {
11629
- _tag: {
11630
- type: "string",
11631
- enum: ["OnboardingReviewRequiredError"]
11632
- },
11633
- message: { type: "string" },
11634
- code: {
11635
- type: "string",
11636
- enum: [
11637
- "review_required",
11638
- "review_in_progress",
11639
- "information_required",
11640
- "review_rejected",
11641
- "identity_review_required",
11642
- "identity_review_rejected",
11643
- "identity_changed"
11644
- ]
11645
- },
11646
- decision: {
11647
- type: "string",
11648
- enum: [
11649
- "undecided",
11650
- "approved",
11651
- "rejected"
11652
- ]
11653
- },
11654
- stage: {
11655
- type: "string",
11656
- enum: [
11657
- "collecting",
11658
- "automated_review",
11659
- "manual_review",
11660
- "information_requested",
11661
- "complete"
11662
- ]
11663
- },
11664
- nextAction: {
11665
- type: "string",
11666
- enum: [
11667
- "wait_for_review",
11668
- "provide_information",
11669
- "verify_sending_identity",
11670
- "reapply",
11671
- "contact_support"
11672
- ]
11673
- },
11674
- identityId: { anyOf: [{ type: "string" }, { type: "null" }] }
11675
- },
11676
- required: [
11677
- "_tag",
11678
- "message",
11679
- "code",
11680
- "decision",
11681
- "stage",
11682
- "nextAction"
11683
- ],
11684
- additionalProperties: false
11685
- },
11686
- {
11687
- type: "object",
11688
- properties: {
11689
- _tag: {
11690
- type: "string",
11691
- enum: ["PaymentRequiredError"]
11692
- },
11693
- message: { type: "string" },
11694
- resource: { type: "string" },
11695
- currentUsage: { type: "number" },
11696
- limit: { type: "number" }
11697
- },
11698
- required: [
11699
- "_tag",
11700
- "message",
11701
- "resource",
11702
- "currentUsage",
11703
- "limit"
11704
- ],
11705
- additionalProperties: false
11706
- },
11707
- {
11708
- type: "object",
11709
- properties: {
11710
- _tag: {
11711
- type: "string",
11712
- enum: ["ValidationError"]
11713
- },
11714
- message: { type: "string" },
11715
- fields: { anyOf: [{
11716
- type: "object",
11717
- additionalProperties: {
11718
- type: "array",
11719
- items: { type: "string" }
11720
- }
11721
- }, { type: "null" }] }
11722
- },
11723
- required: ["_tag", "message"],
11724
- additionalProperties: false
11725
- },
11726
- {
11727
- type: "object",
11728
- properties: {
11729
- _tag: {
11730
- type: "string",
11731
- enum: ["ForbiddenError"]
11732
- },
11733
- message: { type: "string" }
11734
- },
11735
- required: ["_tag", "message"],
11736
- additionalProperties: false
11737
- },
11738
- {
11739
- type: "object",
11740
- properties: {
11741
- _tag: {
11742
- type: "string",
11743
- enum: ["ResourceNotFoundError"]
11744
- },
11745
- resource: { type: "string" },
11746
- id: { type: "string" },
11747
- message: { type: "string" }
11748
- },
11749
- required: [
11750
- "_tag",
11751
- "resource",
11752
- "id",
11753
- "message"
11754
- ],
11755
- additionalProperties: false
11756
- }
11757
- ] }, { type: "null" }] }
11758
- },
11759
- required: ["code", "message"],
11760
- additionalProperties: false
11761
- }, { type: "null" }] },
11762
- retryEligible: { type: "boolean" },
11763
- decision: { anyOf: [{
11764
- type: "object",
11765
- properties: {
11766
- outcome: {
11767
- type: "string",
11768
- enum: [
11769
- "allow",
11770
- "requireApproval",
11771
- "deny"
11772
- ]
11773
- },
11774
- reason: { anyOf: [{ type: "string" }, { type: "null" }] },
11775
- policyId: { anyOf: [{
11776
- type: "string",
11777
- pattern: "^mbxpol_[0-9a-hjkmnp-tv-z]{16,24}$",
11778
- "x-samva-brand": "MailboxPolicyId"
11779
- }, { type: "null" }] },
11780
- source: { anyOf: [{
11781
- type: "string",
11782
- enum: [
11783
- "grant",
11784
- "installation",
11785
- "policy"
11786
- ]
11787
- }, { type: "null" }] },
11788
- decidedAt: { type: "string" }
11789
- },
11790
- required: [
11791
- "outcome",
11792
- "reason",
11793
- "policyId",
11794
- "source",
11795
- "decidedAt"
11796
- ],
11797
- additionalProperties: false
11798
- }, { type: "null" }] },
11799
- createdAt: { type: "string" },
11800
- updatedAt: { type: "string" }
11801
- },
11802
- required: [
11803
- "actionId",
11804
- "draftId",
11805
- "messageId",
11806
- "threadId",
11807
- "state",
11808
- "acceptedAt",
11809
- "waitReason",
11810
- "reviewExpectedAt",
11811
- "skippedRecipients",
11812
- "executeUntil",
11813
- "retryAt",
11814
- "problem",
11815
- "retryEligible",
11816
- "decision",
11817
- "createdAt",
11818
- "updatedAt"
11819
- ],
11820
- additionalProperties: false
11821
- }
11822
- },
11823
- required: [
11824
- "_tag",
11825
- "message",
11826
- "receipt"
11827
- ],
11828
- additionalProperties: false
11829
- },
11830
- OnboardingReviewRequiredError: {
11831
- type: "object",
11832
- properties: {
11833
- _tag: {
11834
- type: "string",
11835
- enum: ["OnboardingReviewRequiredError"]
11836
- },
11837
- message: { type: "string" },
11838
- code: {
11839
- type: "string",
11840
- enum: [
11841
- "review_required",
11842
- "review_in_progress",
11843
- "information_required",
11844
- "review_rejected",
11845
- "identity_review_required",
11846
- "identity_review_rejected",
11847
- "identity_changed"
11848
- ]
11849
- },
11850
- decision: {
11851
- type: "string",
11852
- enum: [
11853
- "undecided",
11854
- "approved",
11855
- "rejected"
11856
- ]
11857
- },
11858
- stage: {
11859
- type: "string",
11860
- enum: [
11861
- "collecting",
11862
- "automated_review",
11863
- "manual_review",
11864
- "information_requested",
11865
- "complete"
11866
- ]
11867
- },
11868
- nextAction: {
11869
- type: "string",
11870
- enum: [
11871
- "wait_for_review",
11872
- "provide_information",
11873
- "verify_sending_identity",
11874
- "reapply",
11875
- "contact_support"
11876
- ]
11877
- },
11878
- identityId: { anyOf: [{ type: "string" }, { type: "null" }] }
11879
- },
11880
- required: [
11881
- "_tag",
11882
- "message",
11883
- "code",
11884
- "decision",
11885
- "stage",
11886
- "nextAction"
11887
- ],
11888
- additionalProperties: false,
11889
- "x-category": ["validation"],
11890
- "x-retryable": false
11891
- },
11892
- PaymentRequiredError: {
11893
- type: "object",
11894
- properties: {
11895
- _tag: {
11896
- type: "string",
11897
- enum: ["PaymentRequiredError"]
11898
- },
11899
- message: { type: "string" },
11900
- resource: { type: "string" },
11901
- currentUsage: { type: "number" },
11902
- limit: { type: "number" }
11903
- },
11904
- required: [
11905
- "_tag",
11906
- "message",
11907
- "resource",
11908
- "currentUsage",
11909
- "limit"
11910
- ],
11911
- additionalProperties: false,
11912
- "x-category": ["billing"],
11913
- "x-retryable": false
11914
- },
11915
- RateLimitedError: {
11916
- type: "object",
11917
- properties: {
11918
- _tag: {
11919
- type: "string",
11920
- enum: ["RateLimitedError"]
11921
- },
11922
- message: { type: "string" },
11923
- retryAfterSeconds: { type: "number" }
11924
- },
11925
- required: [
11926
- "_tag",
11927
- "message",
11928
- "retryAfterSeconds"
11929
- ],
11930
- additionalProperties: false,
11931
- "x-category": ["throttling", "transient"],
11932
- "x-retryable": true
11933
- },
11934
- ResourceNotFoundError: {
11935
- type: "object",
11936
- properties: {
11937
- _tag: {
11938
- type: "string",
11939
- enum: ["ResourceNotFoundError"]
11940
- },
11941
- resource: { type: "string" },
11942
- id: { type: "string" },
11943
- message: { type: "string" }
11944
- },
11945
- required: [
11946
- "_tag",
11947
- "resource",
11948
- "id",
11949
- "message"
11950
- ],
11951
- additionalProperties: false,
11952
- "x-category": ["notFound"],
11953
- "x-retryable": false
11954
- },
11955
- SenderNotReadyError: {
11956
- type: "object",
11957
- properties: {
11958
- _tag: {
11959
- type: "string",
11960
- enum: ["SenderNotReadyError"]
11961
- },
11962
- message: { type: "string" },
11963
- sender: { type: "string" },
11964
- retryAfterSeconds: { anyOf: [{ type: "number" }, { type: "null" }] }
11965
- },
11966
- required: [
11967
- "_tag",
11968
- "message",
11969
- "sender"
11970
- ],
11971
- additionalProperties: false,
11972
- "x-category": ["transient"],
11973
- "x-retryable": true
11974
- },
11975
- UnauthorizedError: {
11976
- type: "object",
11977
- properties: {
11978
- _tag: {
11979
- type: "string",
11980
- enum: ["UnauthorizedError"]
11981
- },
11982
- message: { type: "string" }
11983
- },
11984
- required: ["_tag", "message"],
11985
- additionalProperties: false,
11986
- "x-category": ["auth"],
11987
- "x-retryable": false
11988
- },
11989
- ValidationError: {
11990
- type: "object",
11991
- properties: {
11992
- _tag: {
11993
- type: "string",
11994
- enum: ["ValidationError"]
11995
- },
11996
- message: { type: "string" },
11997
- fields: { anyOf: [{
11998
- type: "object",
11999
- additionalProperties: {
12000
- type: "array",
12001
- items: { type: "string" }
12002
- }
12003
- }, { type: "null" }] }
12004
- },
12005
- required: ["_tag", "message"],
12006
- additionalProperties: false,
12007
- "x-category": ["validation"],
12008
- "x-retryable": false
12009
- }
12010
- };
12011
- const isRecord = (value) => typeof value === "object" && value !== null;
12012
- const matchesType = (value, type) => {
12013
- switch (type) {
12014
- case "string": return typeof value === "string";
12015
- case "number": return typeof value === "number" && Number.isFinite(value);
12016
- case "integer": return typeof value === "number" && Number.isInteger(value);
12017
- case "boolean": return typeof value === "boolean";
12018
- case "null": return value === null;
12019
- case "array": return Array.isArray(value);
12020
- case "object": return isRecord(value) && !Array.isArray(value);
12021
- default: return false;
12022
- }
12023
- };
12024
- const matchesSchema = (value, schema) => {
12025
- if (schema.anyOf !== void 0 && !schema.anyOf.some((member) => matchesSchema(value, member))) return false;
12026
- if (schema.enum !== void 0 && !schema.enum.some((member) => Object.is(value, member))) return false;
12027
- if (schema.type !== void 0) {
12028
- if (!(typeof schema.type === "string" ? [schema.type] : schema.type).some((type) => matchesType(value, type))) return false;
12029
- }
12030
- const items = schema.items;
12031
- if (Array.isArray(value) && items !== void 0) return value.every((item) => matchesSchema(item, items));
12032
- if (!isRecord(value) || Array.isArray(value)) return true;
12033
- if (schema.required?.some((key) => !Object.hasOwn(value, key)) === true) return false;
12034
- const properties = schema.properties ?? {};
12035
- for (const [key, propertySchema] of Object.entries(properties)) if (Object.hasOwn(value, key) && !matchesSchema(value[key], propertySchema)) return false;
12036
- if (schema.additionalProperties === false) {
12037
- if (Object.keys(value).some((key) => !Object.hasOwn(properties, key))) return false;
12038
- } else if (typeof schema.additionalProperties === "object") {
12039
- for (const [key, propertyValue] of Object.entries(value)) if (!Object.hasOwn(properties, key) && !matchesSchema(propertyValue, schema.additionalProperties)) return false;
12040
- }
12041
- return true;
12042
- };
12043
- /** Convert a decoded error payload into its generated JavaScript error class. */
12044
- function fromApiError(error, context = {}) {
12045
- if (error instanceof SamvaApiError) return error;
12046
- if (error instanceof SamvaTransportError) return error;
12047
- if (isRecord(error) && typeof error._tag === "string" && Object.hasOwn(constructors, error._tag)) {
12048
- const tag = error._tag;
12049
- if (!matchesSchema(error, payloadSchemas[tag])) return new SamvaTransportError(error, context);
12050
- const Constructor = constructors[tag];
12051
- return new Constructor(error, context);
12052
- }
12053
- if (context.response?.status === 504) {
12054
- const retryAfter = Number(context.response.headers.get("retry-after"));
12055
- return new GatewayTimeoutError({
12056
- message: "The request did not finish in time. Retry with the same idempotency key.",
12057
- retryAfterSeconds: Number.isInteger(retryAfter) && retryAfter > 0 ? retryAfter : 1
12058
- }, context);
12059
- }
12060
- return new SamvaTransportError(error, context);
12061
- }
12062
- //#endregion
12063
- //#region src/promises/index.ts
12064
- /**
12065
- * Samva SDK - TypeScript client for the Samva API.
12066
- *
12067
- * Ergonomic methods resolve with decoded success values and throw generated
12068
- * plain-JavaScript error classes. The bound Hey API result surface remains
12069
- * available under `client.raw` for transport-level access.
12070
- *
12071
- * @example
12072
- * ```typescript
12073
- * import { createClient, RateLimitedError } from "samva";
12074
- *
12075
- * const samva = createClient({ apiKey: "<samva-api-key>" });
12076
- *
12077
- * try {
12078
- * const { contact } = await samva.contacts.findOrCreate({
12079
- * create: { name: "Ada Lovelace" },
12080
- * lookup: { type: "email", value: "ada@example.com" },
12081
- * });
12082
- * await samva.email.send({
12083
- * to: contact,
12084
- * subject: "Hello",
12085
- * html: "<p>Hi there!</p>",
12086
- * });
12087
- * } catch (error) {
12088
- * if (error instanceof RateLimitedError) console.log(error.retryAfterSeconds);
12089
- * }
12090
- * ```
12091
- */
12092
- const isObject = (value) => typeof value === "object" && value !== null;
12093
- /**
12094
- * The key a retry-safe call sends as `idempotency-key`: the `idempotencyKey`
12095
- * option, else one the caller set in `headers`, else a fresh UUID. The
12096
- * generated header parameter is applied after request headers, so it must carry
12097
- * a caller-set header value rather than overwrite it.
12098
- */
12099
- function resolveIdempotencyKey(options) {
12100
- const { idempotencyKey, ...requestOptions } = options ?? {};
12101
- return {
12102
- idempotencyKey: idempotencyKey ?? mergeHeaders(requestOptions.headers).get("idempotency-key") ?? crypto.randomUUID(),
12103
- requestOptions
12104
- };
12105
- }
12106
- /**
12107
- * Inline attachment content over the API's request cap travels as media instead: the largest
12108
- * attachments are uploaded (create, put to the presigned URL, complete) and replaced by their
12109
- * `mediaId`. The returned payload is the one request every send attempt reuses, so nothing is
12110
- * uploaded twice.
12111
- */
12112
- async function uploadOversizedAttachments(clientInstance, payload, requestOptions) {
12113
- const plan = planInlineUploads(payload);
12114
- if (plan.length === 0) return payload;
12115
- const uploaded = /* @__PURE__ */ new Map();
12116
- const directMedia = createDirectService(createBoundService(Media, clientInstance));
12117
- for (const upload of plan) {
12118
- const created = await directMedia.create(mediaCreateBody(upload), requestOptions);
12119
- await putUpload(clientInstance, upload, created, requestOptions.signal ?? void 0);
12120
- await directMedia.complete({ id: created.id }, requestOptions);
12121
- uploaded.set(upload.index, {
12122
- mediaId: created.id,
12123
- upload
12124
- });
12125
- }
12126
- return withUploadedAttachments(payload, uploaded);
12127
- }
12128
- /**
12129
- * Send with oversized inline attachments uploaded first. Within the cap this is the send call
12130
- * itself, one request and no extra await, so its result is returned unchanged.
12131
- */
12132
- function sendWithUploads(clientInstance, payload, requestOptions, send) {
12133
- if (planInlineUploads(payload).length === 0) return send(payload);
12134
- return uploadOversizedAttachments(clientInstance, payload, requestOptions).then(send);
12135
- }
12136
- async function putUpload(clientInstance, upload, created, signal) {
12137
- const fail = (status, cause) => new MediaUploadError({
12138
- filename: upload.filename,
12139
- mediaId: created.id,
12140
- status,
12141
- cause
12142
- });
12143
- let response;
12144
- try {
12145
- response = await (clientInstance.getConfig().fetch ?? globalThis.fetch)(new Request(created.upload.url, {
12146
- method: created.upload.method,
12147
- headers: created.upload.headers,
12148
- body: upload.bytes,
12149
- signal: signal ?? null
12150
- }));
12151
- } catch (error) {
12152
- throw fail(void 0, error);
12153
- }
12154
- if (!response.ok) throw fail(response.status);
12155
- }
12156
- function createPromiseMessagesTransport(clientInstance) {
12157
- const boundMessages = createBoundService(Messages, clientInstance);
12158
- return {
12159
- list: boundMessages.list,
12160
- remove: boundMessages.remove,
12161
- get: boundMessages.get,
12162
- getEmail: boundMessages.getEmail,
12163
- getStatus: boundMessages.getStatus,
12164
- getEvents: boundMessages.getEvents,
12165
- listDeliveries: boundMessages.listDeliveries,
12166
- getContent: boundMessages.getContent,
12167
- validateEmail: boundMessages.validateEmail,
12168
- send: (input, options) => {
12169
- const { idempotencyKey, requestOptions } = resolveIdempotencyKey(options);
12170
- return sendWithUploads(clientInstance, buildMessagesSendPayload(input), requestOptions, (payload) => Messages.send({
12171
- "idempotency-key": idempotencyKey,
12172
- ...payload
12173
- }, {
12174
- ...requestOptions,
12175
- client: clientInstance
12176
- }));
12177
- }
12178
- };
12179
- }
12180
- function createPromiseEmailTransport(clientInstance) {
12181
- const boundEmail = createBoundService(Email, clientInstance);
12182
- return Object.assign(boundEmail, {
12183
- addSender: (input, options) => {
12184
- const { replyToEmails, ...sender } = input;
12185
- const { idempotencyKey, requestOptions } = resolveIdempotencyKey(options);
12186
- return Email.addSender({
12187
- "idempotency-key": idempotencyKey,
12188
- ...sender,
12189
- ...replyToEmailsPayload(replyToEmails)
12190
- }, {
12191
- ...requestOptions,
12192
- client: clientInstance
12193
- });
12194
- },
12195
- send: (input, options) => {
12196
- const { idempotencyKey, requestOptions } = resolveIdempotencyKey(options);
12197
- return sendWithUploads(clientInstance, buildEmailSendPayload(input), requestOptions, (payload) => Messages.send({
12198
- "idempotency-key": idempotencyKey,
12199
- ...payload
12200
- }, {
12201
- ...requestOptions,
12202
- client: clientInstance
12203
- }));
12204
- }
12205
- });
12206
- }
12207
- function createPromiseTemplatesTransport(clientInstance) {
12208
- return createBoundService(Templates, clientInstance);
12209
- }
12210
- function createBoundService(service, clientInstance) {
12211
- const bound = {};
12212
- for (const key of Object.getOwnPropertyNames(service)) {
12213
- if (key === "length" || key === "name" || key === "prototype") continue;
12214
- const value = service[key];
12215
- if (typeof value === "function") bound[key] = value.length >= 2 ? (parameters, options) => value(parameters ?? {}, {
12216
- ...options,
12217
- client: clientInstance
12218
- }) : (options) => value({
12219
- ...options,
12220
- client: clientInstance
12221
- });
12222
- else if (isObject(value)) bound[key] = createBoundService(value, clientInstance);
12223
- else bound[key] = value;
12224
- }
12225
- return bound;
12226
- }
12227
- const directOptions = (options) => ({
12228
- ...isObject(options) ? options : {},
12229
- responseStyle: "fields",
12230
- throwOnError: false
12231
- });
12232
- async function unwrap(method, arguments_) {
12233
- let result;
12234
- try {
12235
- result = await method(...arguments_);
12236
- } catch (error) {
12237
- if (error instanceof MediaUploadError) throw error;
12238
- throw fromApiError(error);
12239
- }
12240
- if (!isObject(result)) throw new SamvaTransportError(result);
12241
- const raw = result;
12242
- const context = {
12243
- request: raw.request,
12244
- response: raw.response
12245
- };
12246
- if (raw.error !== void 0) throw fromApiError(raw.error, context);
12247
- if ("data" in raw) return raw.data;
12248
- throw new SamvaTransportError(result, context);
12249
- }
12250
- function createDirectService(service) {
12251
- const direct = {};
12252
- for (const [key, value] of Object.entries(service)) if (typeof value === "function") direct[key] = value.length >= 2 ? (parameters = {}, options = {}) => unwrap(value, [parameters, directOptions(options)]) : (options = {}) => unwrap(value, [directOptions(options)]);
12253
- else if (isObject(value)) direct[key] = createDirectService(value);
12254
- else direct[key] = value;
12255
- return direct;
12256
- }
12257
- /** Create a configured Promise client. */
12258
- function createClient(config) {
12259
- const authHeaders = config.authToken !== void 0 ? { Authorization: `Bearer ${config.authToken}` } : { "X-API-Key": config.apiKey };
12260
- const clientInstance = createClient$1({
12261
- ...config,
12262
- baseUrl: config.baseUrl ?? "https://api.samva.dev",
12263
- headers: mergeHeaders({ [CLIENT_ATTRIBUTION_HEADER]: clientAttribution("typescript-promise") }, config.headers, authHeaders),
12264
- responseStyle: "fields",
12265
- throwOnError: false
12266
- });
12267
- clientInstance.interceptors.request.use((request) => {
12268
- const headers = new Headers(request.headers);
12269
- for (const [name, value] of Object.entries(authHeaders)) headers.set(name, value);
12270
- return new Request(request, { headers });
12271
- });
12272
- const raw = {
12273
- client: clientInstance,
12274
- messages: createBoundService(Messages, clientInstance),
12275
- scheduledMessages: createBoundService(ScheduledMessages, clientInstance),
12276
- brands: createBoundService(Brands, clientInstance),
12277
- campaigns: createBoundService(Campaigns, clientInstance),
12278
- email: createBoundService(Email, clientInstance),
12279
- media: createBoundService(Media, clientInstance),
12280
- templates: createPromiseTemplatesTransport(clientInstance),
12281
- contacts: Object.assign(createBoundService(Contacts, clientInstance), createBoundService(ContactEvents, clientInstance)),
12282
- events: createBoundService(Events, clientInstance),
12283
- conversations: createBoundService(Conversations, clientInstance),
12284
- webhooks: createBoundService(Webhooks, clientInstance),
12285
- operations: createBoundService(Operations, clientInstance),
12286
- apiKeys: createBoundService(ApiKeys, clientInstance),
12287
- organizations: createBoundService(Organizations, clientInstance),
12288
- attachments: createBoundService(Attachments, clientInstance),
12289
- contactGroups: createBoundService(ContactGroups, clientInstance),
12290
- customFields: createBoundService(CustomFields, clientInstance),
12291
- subscriptions: createBoundService(Subscriptions, clientInstance),
12292
- unsubscribeGroups: createBoundService(Unsubscribe, clientInstance),
12293
- analytics: createBoundService(Analytics, clientInstance),
12294
- feedback: createBoundService(Feedback, clientInstance),
12295
- whoami: createBoundService(Whoami, clientInstance),
12296
- journeys: createBoundService(Journeys, clientInstance),
12297
- mailboxes: createBoundService(Mailboxes, clientInstance),
12298
- namespaces: createBoundService(Namespaces, clientInstance),
12299
- extensions: createBoundService(Extensions, clientInstance),
12300
- extensionInstallations: createBoundService(ExtensionInstallations, clientInstance)
12301
- };
12302
- const streamConnection = {
12303
- baseUrl: config.baseUrl ?? "https://api.samva.dev",
12304
- headers: async () => Object.fromEntries(mergeHeaders({ [CLIENT_ATTRIBUTION_HEADER]: clientAttribution("typescript-promise") }, config.headers, authHeaders).entries()),
12305
- fetch: config.fetch
12306
- };
12307
- const promiseMessages = createPromiseMessagesTransport(clientInstance);
12308
- const promiseEmail = createPromiseEmailTransport(clientInstance);
12309
- return {
12310
- raw,
12311
- messages: createDirectService(promiseMessages),
12312
- scheduledMessages: createDirectService(raw.scheduledMessages),
12313
- brands: createDirectService(raw.brands),
12314
- campaigns: createDirectService(raw.campaigns),
12315
- email: createDirectService(promiseEmail),
12316
- media: createDirectService(raw.media),
12317
- templates: createDirectService(raw.templates),
12318
- contacts: createDirectService(raw.contacts),
12319
- events: createDirectService(raw.events),
12320
- conversations: createDirectService(raw.conversations),
12321
- webhooks: createDirectService(raw.webhooks),
12322
- operations: createDirectService(raw.operations),
12323
- apiKeys: createDirectService(raw.apiKeys),
12324
- organizations: createDirectService(raw.organizations),
12325
- attachments: createDirectService(raw.attachments),
12326
- contactGroups: createDirectService(raw.contactGroups),
12327
- customFields: createDirectService(raw.customFields),
12328
- subscriptions: createDirectService(raw.subscriptions),
12329
- unsubscribeGroups: createDirectService(raw.unsubscribeGroups),
12330
- analytics: createDirectService(raw.analytics),
12331
- feedback: createDirectService(raw.feedback),
12332
- whoami: createDirectService(raw.whoami),
12333
- journeys: createDirectService(raw.journeys),
12334
- mailboxes: Object.assign(createDirectService(raw.mailboxes), { events: (options) => new MailboxEventStream(streamConnection, options) }),
12335
- namespaces: createDirectService(raw.namespaces),
12336
- extensions: createDirectService(raw.extensions),
12337
- extensionInstallations: createDirectService(raw.extensionInstallations)
12338
- };
12339
- }
12340
- //#endregion
12341
- export { SenderNotReadyError as C, fromApiError as E, SamvaTransportError as S, ValidationError as T, OnboardingReviewRequiredError as _, CampaignFooterRequiredError as a, ResourceNotFoundError as b, EmailChannelError as c, ForbiddenError as d, GatewayTimeoutError as f, MailboxSendRefusedError as g, MailboxSendConflictError as h, BrandAddressRequiredError as i, ExternalServiceError as l, MailboxChannelUnsupportedError as m, AnalyticsQueryError as n, ConflictError as o, InternalError as p, BillingProviderError as r, DeliveryUnavailableError as s, createClient as t, FlagDisabledError as u, PaymentRequiredError as v, UnauthorizedError as w, SamvaApiError as x, RateLimitedError as y };
10114
+ export { Analytics, ApiKeys, Attachments, Brands, Campaigns, ContactEvents, ContactGroups, Contacts, Conversations, CustomFields, Email, Events, ExtensionInstallations, Extensions, Feedback, Journeys, Mailboxes, Media, Messages, Namespaces, Operations, Organizations, ScheduledMessages, Subscriptions, Templates, Unsubscribe, Webhooks, Whoami };
12342
10115
 
12343
- //# sourceMappingURL=promises---Kbh-7z.js.map
10116
+ //# sourceMappingURL=sdk.gen.js.map