mailmeteor 0.0.3

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 (74) hide show
  1. package/README.md +49 -0
  2. package/dist/generated-sdk/client/client.gen.d.ts +3 -0
  3. package/dist/generated-sdk/client/client.gen.d.ts.map +1 -0
  4. package/dist/generated-sdk/client/index.d.ts +9 -0
  5. package/dist/generated-sdk/client/index.d.ts.map +1 -0
  6. package/dist/generated-sdk/client/types.gen.d.ts +118 -0
  7. package/dist/generated-sdk/client/types.gen.d.ts.map +1 -0
  8. package/dist/generated-sdk/client/utils.gen.d.ts +34 -0
  9. package/dist/generated-sdk/client/utils.gen.d.ts.map +1 -0
  10. package/dist/generated-sdk/client.gen.d.ts +13 -0
  11. package/dist/generated-sdk/client.gen.d.ts.map +1 -0
  12. package/dist/generated-sdk/core/auth.gen.d.ts +19 -0
  13. package/dist/generated-sdk/core/auth.gen.d.ts.map +1 -0
  14. package/dist/generated-sdk/core/bodySerializer.gen.d.ts +26 -0
  15. package/dist/generated-sdk/core/bodySerializer.gen.d.ts.map +1 -0
  16. package/dist/generated-sdk/core/params.gen.d.ts +44 -0
  17. package/dist/generated-sdk/core/params.gen.d.ts.map +1 -0
  18. package/dist/generated-sdk/core/pathSerializer.gen.d.ts +34 -0
  19. package/dist/generated-sdk/core/pathSerializer.gen.d.ts.map +1 -0
  20. package/dist/generated-sdk/core/queryKeySerializer.gen.d.ts +19 -0
  21. package/dist/generated-sdk/core/queryKeySerializer.gen.d.ts.map +1 -0
  22. package/dist/generated-sdk/core/serverSentEvents.gen.d.ts +72 -0
  23. package/dist/generated-sdk/core/serverSentEvents.gen.d.ts.map +1 -0
  24. package/dist/generated-sdk/core/types.gen.d.ts +79 -0
  25. package/dist/generated-sdk/core/types.gen.d.ts.map +1 -0
  26. package/dist/generated-sdk/core/utils.gen.d.ts +20 -0
  27. package/dist/generated-sdk/core/utils.gen.d.ts.map +1 -0
  28. package/dist/generated-sdk/index.d.ts +4 -0
  29. package/dist/generated-sdk/index.d.ts.map +1 -0
  30. package/dist/generated-sdk/sdk.gen.d.ts +112 -0
  31. package/dist/generated-sdk/sdk.gen.d.ts.map +1 -0
  32. package/dist/generated-sdk/types.gen.d.ts +426 -0
  33. package/dist/generated-sdk/types.gen.d.ts.map +1 -0
  34. package/dist/index.cjs +1323 -0
  35. package/dist/index.cjs.map +1 -0
  36. package/dist/index.d.ts +1420 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.mjs +1320 -0
  39. package/dist/index.mjs.map +1 -0
  40. package/dist/types/generated-sdk/client/client.gen.d.ts +3 -0
  41. package/dist/types/generated-sdk/client/client.gen.d.ts.map +1 -0
  42. package/dist/types/generated-sdk/client/index.d.ts +9 -0
  43. package/dist/types/generated-sdk/client/index.d.ts.map +1 -0
  44. package/dist/types/generated-sdk/client/types.gen.d.ts +118 -0
  45. package/dist/types/generated-sdk/client/types.gen.d.ts.map +1 -0
  46. package/dist/types/generated-sdk/client/utils.gen.d.ts +34 -0
  47. package/dist/types/generated-sdk/client/utils.gen.d.ts.map +1 -0
  48. package/dist/types/generated-sdk/client.gen.d.ts +13 -0
  49. package/dist/types/generated-sdk/client.gen.d.ts.map +1 -0
  50. package/dist/types/generated-sdk/core/auth.gen.d.ts +19 -0
  51. package/dist/types/generated-sdk/core/auth.gen.d.ts.map +1 -0
  52. package/dist/types/generated-sdk/core/bodySerializer.gen.d.ts +26 -0
  53. package/dist/types/generated-sdk/core/bodySerializer.gen.d.ts.map +1 -0
  54. package/dist/types/generated-sdk/core/params.gen.d.ts +44 -0
  55. package/dist/types/generated-sdk/core/params.gen.d.ts.map +1 -0
  56. package/dist/types/generated-sdk/core/pathSerializer.gen.d.ts +34 -0
  57. package/dist/types/generated-sdk/core/pathSerializer.gen.d.ts.map +1 -0
  58. package/dist/types/generated-sdk/core/queryKeySerializer.gen.d.ts +19 -0
  59. package/dist/types/generated-sdk/core/queryKeySerializer.gen.d.ts.map +1 -0
  60. package/dist/types/generated-sdk/core/serverSentEvents.gen.d.ts +72 -0
  61. package/dist/types/generated-sdk/core/serverSentEvents.gen.d.ts.map +1 -0
  62. package/dist/types/generated-sdk/core/types.gen.d.ts +79 -0
  63. package/dist/types/generated-sdk/core/types.gen.d.ts.map +1 -0
  64. package/dist/types/generated-sdk/core/utils.gen.d.ts +20 -0
  65. package/dist/types/generated-sdk/core/utils.gen.d.ts.map +1 -0
  66. package/dist/types/generated-sdk/index.d.ts +4 -0
  67. package/dist/types/generated-sdk/index.d.ts.map +1 -0
  68. package/dist/types/generated-sdk/sdk.gen.d.ts +183 -0
  69. package/dist/types/generated-sdk/sdk.gen.d.ts.map +1 -0
  70. package/dist/types/generated-sdk/types.gen.d.ts +906 -0
  71. package/dist/types/generated-sdk/types.gen.d.ts.map +1 -0
  72. package/dist/types/index.d.ts +24 -0
  73. package/dist/types/index.d.ts.map +1 -0
  74. package/package.json +39 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,1320 @@
1
+ const jsonBodySerializer = {
2
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === 'bigint' ? value.toString() : value),
3
+ };
4
+
5
+ const extraPrefixesMap = {
6
+ $body_: 'body',
7
+ $headers_: 'headers',
8
+ $path_: 'path',
9
+ $query_: 'query',
10
+ };
11
+ const extraPrefixes = Object.entries(extraPrefixesMap);
12
+ const buildKeyMap = (fields, map) => {
13
+ if (!map) {
14
+ map = new Map();
15
+ }
16
+ for (const config of fields) {
17
+ if ('in' in config) {
18
+ if (config.key) {
19
+ map.set(config.key, {
20
+ in: config.in,
21
+ map: config.map,
22
+ });
23
+ }
24
+ }
25
+ else if ('key' in config) {
26
+ map.set(config.key, {
27
+ map: config.map,
28
+ });
29
+ }
30
+ else if (config.args) {
31
+ buildKeyMap(config.args, map);
32
+ }
33
+ }
34
+ return map;
35
+ };
36
+ const stripEmptySlots = (params) => {
37
+ for (const [slot, value] of Object.entries(params)) {
38
+ if (value && typeof value === 'object' && !Object.keys(value).length) {
39
+ delete params[slot];
40
+ }
41
+ }
42
+ };
43
+ const buildClientParams = (args, fields) => {
44
+ const params = {
45
+ body: {},
46
+ headers: {},
47
+ path: {},
48
+ query: {},
49
+ };
50
+ const map = buildKeyMap(fields);
51
+ let config;
52
+ for (const [index, arg] of args.entries()) {
53
+ if (fields[index]) {
54
+ config = fields[index];
55
+ }
56
+ if (!config) {
57
+ continue;
58
+ }
59
+ if ('in' in config) {
60
+ if (config.key) {
61
+ const field = map.get(config.key);
62
+ const name = field.map || config.key;
63
+ if (field.in) {
64
+ params[field.in][name] = arg;
65
+ }
66
+ }
67
+ else {
68
+ params.body = arg;
69
+ }
70
+ }
71
+ else {
72
+ for (const [key, value] of Object.entries(arg ?? {})) {
73
+ const field = map.get(key);
74
+ if (field) {
75
+ if (field.in) {
76
+ const name = field.map || key;
77
+ params[field.in][name] = value;
78
+ }
79
+ else {
80
+ params[field.map] = value;
81
+ }
82
+ }
83
+ else {
84
+ const extra = extraPrefixes.find(([prefix]) => key.startsWith(prefix));
85
+ if (extra) {
86
+ const [prefix, slot] = extra;
87
+ params[slot][key.slice(prefix.length)] = value;
88
+ }
89
+ else if ('allowExtra' in config && config.allowExtra) {
90
+ for (const [slot, allowed] of Object.entries(config.allowExtra)) {
91
+ if (allowed) {
92
+ params[slot][key] = value;
93
+ break;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ }
99
+ }
100
+ }
101
+ stripEmptySlots(params);
102
+ return params;
103
+ };
104
+
105
+ const createSseClient = ({ onRequest, onSseError, onSseEvent, responseTransformer, responseValidator, sseDefaultRetryDelay, sseMaxRetryAttempts, sseMaxRetryDelay, sseSleepFn, url, ...options }) => {
106
+ let lastEventId;
107
+ const sleep = sseSleepFn ??
108
+ ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
109
+ const createStream = async function* () {
110
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
111
+ let attempt = 0;
112
+ const signal = options.signal ?? new AbortController().signal;
113
+ while (true) {
114
+ if (signal.aborted)
115
+ break;
116
+ attempt++;
117
+ const headers = options.headers instanceof Headers
118
+ ? options.headers
119
+ : new Headers(options.headers);
120
+ if (lastEventId !== undefined) {
121
+ headers.set('Last-Event-ID', lastEventId);
122
+ }
123
+ try {
124
+ const requestInit = {
125
+ redirect: 'follow',
126
+ ...options,
127
+ body: options.serializedBody,
128
+ headers,
129
+ signal,
130
+ };
131
+ let request = new Request(url, requestInit);
132
+ if (onRequest) {
133
+ request = await onRequest(url, requestInit);
134
+ }
135
+ const _fetch = options.fetch ?? globalThis.fetch;
136
+ const response = await _fetch(request);
137
+ if (!response.ok)
138
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
139
+ if (!response.body)
140
+ throw new Error('No body in SSE response');
141
+ const reader = response.body
142
+ .pipeThrough(new TextDecoderStream())
143
+ .getReader();
144
+ let buffer = '';
145
+ const abortHandler = () => {
146
+ try {
147
+ reader.cancel();
148
+ }
149
+ catch {
150
+ }
151
+ };
152
+ signal.addEventListener('abort', abortHandler);
153
+ try {
154
+ while (true) {
155
+ const { done, value } = await reader.read();
156
+ if (done)
157
+ break;
158
+ buffer += value;
159
+ buffer = buffer.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
160
+ const chunks = buffer.split('\n\n');
161
+ buffer = chunks.pop() ?? '';
162
+ for (const chunk of chunks) {
163
+ const lines = chunk.split('\n');
164
+ const dataLines = [];
165
+ let eventName;
166
+ for (const line of lines) {
167
+ if (line.startsWith('data:')) {
168
+ dataLines.push(line.replace(/^data:\s*/, ''));
169
+ }
170
+ else if (line.startsWith('event:')) {
171
+ eventName = line.replace(/^event:\s*/, '');
172
+ }
173
+ else if (line.startsWith('id:')) {
174
+ lastEventId = line.replace(/^id:\s*/, '');
175
+ }
176
+ else if (line.startsWith('retry:')) {
177
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ''), 10);
178
+ if (!Number.isNaN(parsed)) {
179
+ retryDelay = parsed;
180
+ }
181
+ }
182
+ }
183
+ let data;
184
+ let parsedJson = false;
185
+ if (dataLines.length) {
186
+ const rawData = dataLines.join('\n');
187
+ try {
188
+ data = JSON.parse(rawData);
189
+ parsedJson = true;
190
+ }
191
+ catch {
192
+ data = rawData;
193
+ }
194
+ }
195
+ if (parsedJson) {
196
+ if (responseValidator) {
197
+ await responseValidator(data);
198
+ }
199
+ if (responseTransformer) {
200
+ data = await responseTransformer(data);
201
+ }
202
+ }
203
+ onSseEvent?.({
204
+ data,
205
+ event: eventName,
206
+ id: lastEventId,
207
+ retry: retryDelay,
208
+ });
209
+ if (dataLines.length) {
210
+ yield data;
211
+ }
212
+ }
213
+ }
214
+ }
215
+ finally {
216
+ signal.removeEventListener('abort', abortHandler);
217
+ reader.releaseLock();
218
+ }
219
+ break;
220
+ }
221
+ catch (error) {
222
+ onSseError?.(error);
223
+ if (sseMaxRetryAttempts !== undefined &&
224
+ attempt >= sseMaxRetryAttempts) {
225
+ break;
226
+ }
227
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
228
+ await sleep(backoff);
229
+ }
230
+ }
231
+ };
232
+ const stream = createStream();
233
+ return { stream };
234
+ };
235
+
236
+ const separatorArrayExplode = (style) => {
237
+ switch (style) {
238
+ case 'label':
239
+ return '.';
240
+ case 'matrix':
241
+ return ';';
242
+ case 'simple':
243
+ return ',';
244
+ default:
245
+ return '&';
246
+ }
247
+ };
248
+ const separatorArrayNoExplode = (style) => {
249
+ switch (style) {
250
+ case 'form':
251
+ return ',';
252
+ case 'pipeDelimited':
253
+ return '|';
254
+ case 'spaceDelimited':
255
+ return '%20';
256
+ default:
257
+ return ',';
258
+ }
259
+ };
260
+ const separatorObjectExplode = (style) => {
261
+ switch (style) {
262
+ case 'label':
263
+ return '.';
264
+ case 'matrix':
265
+ return ';';
266
+ case 'simple':
267
+ return ',';
268
+ default:
269
+ return '&';
270
+ }
271
+ };
272
+ const serializeArrayParam = ({ allowReserved, explode, name, style, value, }) => {
273
+ if (!explode) {
274
+ const joinedValues = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
275
+ switch (style) {
276
+ case 'label':
277
+ return `.${joinedValues}`;
278
+ case 'matrix':
279
+ return `;${name}=${joinedValues}`;
280
+ case 'simple':
281
+ return joinedValues;
282
+ default:
283
+ return `${name}=${joinedValues}`;
284
+ }
285
+ }
286
+ const separator = separatorArrayExplode(style);
287
+ const joinedValues = value
288
+ .map((v) => {
289
+ if (style === 'label' || style === 'simple') {
290
+ return allowReserved ? v : encodeURIComponent(v);
291
+ }
292
+ return serializePrimitiveParam({
293
+ allowReserved,
294
+ name,
295
+ value: v,
296
+ });
297
+ })
298
+ .join(separator);
299
+ return style === 'label' || style === 'matrix'
300
+ ? separator + joinedValues
301
+ : joinedValues;
302
+ };
303
+ const serializePrimitiveParam = ({ allowReserved, name, value, }) => {
304
+ if (value === undefined || value === null) {
305
+ return '';
306
+ }
307
+ if (typeof value === 'object') {
308
+ throw new Error('Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.');
309
+ }
310
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
311
+ };
312
+ const serializeObjectParam = ({ allowReserved, explode, name, style, value, valueOnly, }) => {
313
+ if (value instanceof Date) {
314
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
315
+ }
316
+ if (style !== 'deepObject' && !explode) {
317
+ let values = [];
318
+ Object.entries(value).forEach(([key, v]) => {
319
+ values = [
320
+ ...values,
321
+ key,
322
+ allowReserved ? v : encodeURIComponent(v),
323
+ ];
324
+ });
325
+ const joinedValues = values.join(',');
326
+ switch (style) {
327
+ case 'form':
328
+ return `${name}=${joinedValues}`;
329
+ case 'label':
330
+ return `.${joinedValues}`;
331
+ case 'matrix':
332
+ return `;${name}=${joinedValues}`;
333
+ default:
334
+ return joinedValues;
335
+ }
336
+ }
337
+ const separator = separatorObjectExplode(style);
338
+ const joinedValues = Object.entries(value)
339
+ .map(([key, v]) => serializePrimitiveParam({
340
+ allowReserved,
341
+ name: style === 'deepObject' ? `${name}[${key}]` : key,
342
+ value: v,
343
+ }))
344
+ .join(separator);
345
+ return style === 'label' || style === 'matrix'
346
+ ? separator + joinedValues
347
+ : joinedValues;
348
+ };
349
+
350
+ const PATH_PARAM_RE = /\{[^{}]+\}/g;
351
+ const defaultPathSerializer = ({ path, url: _url }) => {
352
+ let url = _url;
353
+ const matches = _url.match(PATH_PARAM_RE);
354
+ if (matches) {
355
+ for (const match of matches) {
356
+ let explode = false;
357
+ let name = match.substring(1, match.length - 1);
358
+ let style = 'simple';
359
+ if (name.endsWith('*')) {
360
+ explode = true;
361
+ name = name.substring(0, name.length - 1);
362
+ }
363
+ if (name.startsWith('.')) {
364
+ name = name.substring(1);
365
+ style = 'label';
366
+ }
367
+ else if (name.startsWith(';')) {
368
+ name = name.substring(1);
369
+ style = 'matrix';
370
+ }
371
+ const value = path[name];
372
+ if (value === undefined || value === null) {
373
+ continue;
374
+ }
375
+ if (Array.isArray(value)) {
376
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
377
+ continue;
378
+ }
379
+ if (typeof value === 'object') {
380
+ url = url.replace(match, serializeObjectParam({
381
+ explode,
382
+ name,
383
+ style,
384
+ value: value,
385
+ valueOnly: true,
386
+ }));
387
+ continue;
388
+ }
389
+ if (style === 'matrix') {
390
+ url = url.replace(match, `;${serializePrimitiveParam({
391
+ name,
392
+ value: value,
393
+ })}`);
394
+ continue;
395
+ }
396
+ const replaceValue = encodeURIComponent(style === 'label' ? `.${value}` : value);
397
+ url = url.replace(match, replaceValue);
398
+ }
399
+ }
400
+ return url;
401
+ };
402
+ const getUrl = ({ baseUrl, path, query, querySerializer, url: _url, }) => {
403
+ const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
404
+ let url = (baseUrl ?? '') + pathUrl;
405
+ if (path) {
406
+ url = defaultPathSerializer({ path, url });
407
+ }
408
+ let search = query ? querySerializer(query) : '';
409
+ if (search.startsWith('?')) {
410
+ search = search.substring(1);
411
+ }
412
+ if (search) {
413
+ url += `?${search}`;
414
+ }
415
+ return url;
416
+ };
417
+ function getValidRequestBody(options) {
418
+ const hasBody = options.body !== undefined;
419
+ const isSerializedBody = hasBody && options.bodySerializer;
420
+ if (isSerializedBody) {
421
+ if ('serializedBody' in options) {
422
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== '';
423
+ return hasSerializedBody ? options.serializedBody : null;
424
+ }
425
+ return options.body !== '' ? options.body : null;
426
+ }
427
+ if (hasBody) {
428
+ return options.body;
429
+ }
430
+ return undefined;
431
+ }
432
+
433
+ const getAuthToken = async (auth, callback) => {
434
+ const token = typeof callback === 'function' ? await callback(auth) : callback;
435
+ if (!token) {
436
+ return;
437
+ }
438
+ if (auth.scheme === 'bearer') {
439
+ return `Bearer ${token}`;
440
+ }
441
+ if (auth.scheme === 'basic') {
442
+ return `Basic ${btoa(token)}`;
443
+ }
444
+ return token;
445
+ };
446
+
447
+ const createQuerySerializer = ({ parameters = {}, ...args } = {}) => {
448
+ const querySerializer = (queryParams) => {
449
+ const search = [];
450
+ if (queryParams && typeof queryParams === 'object') {
451
+ for (const name in queryParams) {
452
+ const value = queryParams[name];
453
+ if (value === undefined || value === null) {
454
+ continue;
455
+ }
456
+ const options = parameters[name] || args;
457
+ if (Array.isArray(value)) {
458
+ const serializedArray = serializeArrayParam({
459
+ allowReserved: options.allowReserved,
460
+ explode: true,
461
+ name,
462
+ style: 'form',
463
+ value,
464
+ ...options.array,
465
+ });
466
+ if (serializedArray)
467
+ search.push(serializedArray);
468
+ }
469
+ else if (typeof value === 'object') {
470
+ const serializedObject = serializeObjectParam({
471
+ allowReserved: options.allowReserved,
472
+ explode: true,
473
+ name,
474
+ style: 'deepObject',
475
+ value: value,
476
+ ...options.object,
477
+ });
478
+ if (serializedObject)
479
+ search.push(serializedObject);
480
+ }
481
+ else {
482
+ const serializedPrimitive = serializePrimitiveParam({
483
+ allowReserved: options.allowReserved,
484
+ name,
485
+ value: value,
486
+ });
487
+ if (serializedPrimitive)
488
+ search.push(serializedPrimitive);
489
+ }
490
+ }
491
+ }
492
+ return search.join('&');
493
+ };
494
+ return querySerializer;
495
+ };
496
+ const getParseAs = (contentType) => {
497
+ if (!contentType) {
498
+ return 'stream';
499
+ }
500
+ const cleanContent = contentType.split(';')[0]?.trim();
501
+ if (!cleanContent) {
502
+ return;
503
+ }
504
+ if (cleanContent.startsWith('application/json') ||
505
+ cleanContent.endsWith('+json')) {
506
+ return 'json';
507
+ }
508
+ if (cleanContent === 'multipart/form-data') {
509
+ return 'formData';
510
+ }
511
+ if (['application/', 'audio/', 'image/', 'video/'].some((type) => cleanContent.startsWith(type))) {
512
+ return 'blob';
513
+ }
514
+ if (cleanContent.startsWith('text/')) {
515
+ return 'text';
516
+ }
517
+ return;
518
+ };
519
+ const checkForExistence = (options, name) => {
520
+ if (!name) {
521
+ return false;
522
+ }
523
+ if (options.headers.has(name) ||
524
+ options.query?.[name] ||
525
+ options.headers.get('Cookie')?.includes(`${name}=`)) {
526
+ return true;
527
+ }
528
+ return false;
529
+ };
530
+ const setAuthParams = async ({ security, ...options }) => {
531
+ for (const auth of security) {
532
+ if (checkForExistence(options, auth.name)) {
533
+ continue;
534
+ }
535
+ const token = await getAuthToken(auth, options.auth);
536
+ if (!token) {
537
+ continue;
538
+ }
539
+ const name = auth.name ?? 'Authorization';
540
+ switch (auth.in) {
541
+ case 'query':
542
+ if (!options.query) {
543
+ options.query = {};
544
+ }
545
+ options.query[name] = token;
546
+ break;
547
+ case 'cookie':
548
+ options.headers.append('Cookie', `${name}=${token}`);
549
+ break;
550
+ case 'header':
551
+ default:
552
+ options.headers.set(name, token);
553
+ break;
554
+ }
555
+ }
556
+ };
557
+ const buildUrl = (options) => getUrl({
558
+ baseUrl: options.baseUrl,
559
+ path: options.path,
560
+ query: options.query,
561
+ querySerializer: typeof options.querySerializer === 'function'
562
+ ? options.querySerializer
563
+ : createQuerySerializer(options.querySerializer),
564
+ url: options.url,
565
+ });
566
+ const mergeConfigs = (a, b) => {
567
+ const config = { ...a, ...b };
568
+ if (config.baseUrl?.endsWith('/')) {
569
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
570
+ }
571
+ config.headers = mergeHeaders(a.headers, b.headers);
572
+ return config;
573
+ };
574
+ const headersEntries = (headers) => {
575
+ const entries = [];
576
+ headers.forEach((value, key) => {
577
+ entries.push([key, value]);
578
+ });
579
+ return entries;
580
+ };
581
+ const mergeHeaders = (...headers) => {
582
+ const mergedHeaders = new Headers();
583
+ for (const header of headers) {
584
+ if (!header) {
585
+ continue;
586
+ }
587
+ const iterator = header instanceof Headers
588
+ ? headersEntries(header)
589
+ : Object.entries(header);
590
+ for (const [key, value] of iterator) {
591
+ if (value === null) {
592
+ mergedHeaders.delete(key);
593
+ }
594
+ else if (Array.isArray(value)) {
595
+ for (const v of value) {
596
+ mergedHeaders.append(key, v);
597
+ }
598
+ }
599
+ else if (value !== undefined) {
600
+ mergedHeaders.set(key, typeof value === 'object' ? JSON.stringify(value) : value);
601
+ }
602
+ }
603
+ }
604
+ return mergedHeaders;
605
+ };
606
+ class Interceptors {
607
+ constructor() {
608
+ this.fns = [];
609
+ }
610
+ clear() {
611
+ this.fns = [];
612
+ }
613
+ eject(id) {
614
+ const index = this.getInterceptorIndex(id);
615
+ if (this.fns[index]) {
616
+ this.fns[index] = null;
617
+ }
618
+ }
619
+ exists(id) {
620
+ const index = this.getInterceptorIndex(id);
621
+ return Boolean(this.fns[index]);
622
+ }
623
+ getInterceptorIndex(id) {
624
+ if (typeof id === 'number') {
625
+ return this.fns[id] ? id : -1;
626
+ }
627
+ return this.fns.indexOf(id);
628
+ }
629
+ update(id, fn) {
630
+ const index = this.getInterceptorIndex(id);
631
+ if (this.fns[index]) {
632
+ this.fns[index] = fn;
633
+ return id;
634
+ }
635
+ return false;
636
+ }
637
+ use(fn) {
638
+ this.fns.push(fn);
639
+ return this.fns.length - 1;
640
+ }
641
+ }
642
+ const createInterceptors = () => ({
643
+ error: new Interceptors(),
644
+ request: new Interceptors(),
645
+ response: new Interceptors(),
646
+ });
647
+ const defaultQuerySerializer = createQuerySerializer({
648
+ allowReserved: false,
649
+ array: {
650
+ explode: true,
651
+ style: 'form',
652
+ },
653
+ object: {
654
+ explode: true,
655
+ style: 'deepObject',
656
+ },
657
+ });
658
+ const defaultHeaders = {
659
+ 'Content-Type': 'application/json',
660
+ };
661
+ const createConfig = (override = {}) => ({
662
+ ...jsonBodySerializer,
663
+ headers: defaultHeaders,
664
+ parseAs: 'auto',
665
+ querySerializer: defaultQuerySerializer,
666
+ ...override,
667
+ });
668
+
669
+ const createClient = (config = {}) => {
670
+ let _config = mergeConfigs(createConfig(), config);
671
+ const getConfig = () => ({ ..._config });
672
+ const setConfig = (config) => {
673
+ _config = mergeConfigs(_config, config);
674
+ return getConfig();
675
+ };
676
+ const interceptors = createInterceptors();
677
+ const beforeRequest = async (options) => {
678
+ const opts = {
679
+ ..._config,
680
+ ...options,
681
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
682
+ headers: mergeHeaders(_config.headers, options.headers),
683
+ serializedBody: undefined,
684
+ };
685
+ if (opts.security) {
686
+ await setAuthParams({
687
+ ...opts,
688
+ security: opts.security,
689
+ });
690
+ }
691
+ if (opts.requestValidator) {
692
+ await opts.requestValidator(opts);
693
+ }
694
+ if (opts.body !== undefined && opts.bodySerializer) {
695
+ opts.serializedBody = opts.bodySerializer(opts.body);
696
+ }
697
+ if (opts.body === undefined || opts.serializedBody === '') {
698
+ opts.headers.delete('Content-Type');
699
+ }
700
+ const url = buildUrl(opts);
701
+ return { opts, url };
702
+ };
703
+ const request = async (options) => {
704
+ const { opts, url } = await beforeRequest(options);
705
+ const requestInit = {
706
+ redirect: 'follow',
707
+ ...opts,
708
+ body: getValidRequestBody(opts),
709
+ };
710
+ let request = new Request(url, requestInit);
711
+ for (const fn of interceptors.request.fns) {
712
+ if (fn) {
713
+ request = await fn(request, opts);
714
+ }
715
+ }
716
+ const _fetch = opts.fetch;
717
+ let response;
718
+ try {
719
+ response = await _fetch(request);
720
+ }
721
+ catch (error) {
722
+ let finalError = error;
723
+ for (const fn of interceptors.error.fns) {
724
+ if (fn) {
725
+ finalError = (await fn(error, undefined, request, opts));
726
+ }
727
+ }
728
+ finalError = finalError || {};
729
+ if (opts.throwOnError) {
730
+ throw finalError;
731
+ }
732
+ return opts.responseStyle === 'data'
733
+ ? undefined
734
+ : {
735
+ error: finalError,
736
+ request,
737
+ response: undefined,
738
+ };
739
+ }
740
+ for (const fn of interceptors.response.fns) {
741
+ if (fn) {
742
+ response = await fn(response, request, opts);
743
+ }
744
+ }
745
+ const result = {
746
+ request,
747
+ response,
748
+ };
749
+ if (response.ok) {
750
+ const parseAs = (opts.parseAs === 'auto'
751
+ ? getParseAs(response.headers.get('Content-Type'))
752
+ : opts.parseAs) ?? 'json';
753
+ if (response.status === 204 ||
754
+ response.headers.get('Content-Length') === '0') {
755
+ let emptyData;
756
+ switch (parseAs) {
757
+ case 'arrayBuffer':
758
+ case 'blob':
759
+ case 'text':
760
+ emptyData = await response[parseAs]();
761
+ break;
762
+ case 'formData':
763
+ emptyData = new FormData();
764
+ break;
765
+ case 'stream':
766
+ emptyData = response.body;
767
+ break;
768
+ case 'json':
769
+ default:
770
+ emptyData = {};
771
+ break;
772
+ }
773
+ return opts.responseStyle === 'data'
774
+ ? emptyData
775
+ : {
776
+ data: emptyData,
777
+ ...result,
778
+ };
779
+ }
780
+ let data;
781
+ switch (parseAs) {
782
+ case 'arrayBuffer':
783
+ case 'blob':
784
+ case 'formData':
785
+ case 'text':
786
+ data = await response[parseAs]();
787
+ break;
788
+ case 'json': {
789
+ const text = await response.text();
790
+ data = text ? JSON.parse(text) : {};
791
+ break;
792
+ }
793
+ case 'stream':
794
+ return opts.responseStyle === 'data'
795
+ ? response.body
796
+ : {
797
+ data: response.body,
798
+ ...result,
799
+ };
800
+ }
801
+ if (parseAs === 'json') {
802
+ if (opts.responseValidator) {
803
+ await opts.responseValidator(data);
804
+ }
805
+ if (opts.responseTransformer) {
806
+ data = await opts.responseTransformer(data);
807
+ }
808
+ }
809
+ return opts.responseStyle === 'data'
810
+ ? data
811
+ : {
812
+ data,
813
+ ...result,
814
+ };
815
+ }
816
+ const textError = await response.text();
817
+ let jsonError;
818
+ try {
819
+ jsonError = JSON.parse(textError);
820
+ }
821
+ catch {
822
+ }
823
+ const error = jsonError ?? textError;
824
+ let finalError = error;
825
+ for (const fn of interceptors.error.fns) {
826
+ if (fn) {
827
+ finalError = (await fn(error, response, request, opts));
828
+ }
829
+ }
830
+ finalError = finalError || {};
831
+ if (opts.throwOnError) {
832
+ throw finalError;
833
+ }
834
+ return opts.responseStyle === 'data'
835
+ ? undefined
836
+ : {
837
+ error: finalError,
838
+ ...result,
839
+ };
840
+ };
841
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
842
+ const makeSseFn = (method) => async (options) => {
843
+ const { opts, url } = await beforeRequest(options);
844
+ return createSseClient({
845
+ ...opts,
846
+ body: opts.body,
847
+ headers: opts.headers,
848
+ method,
849
+ onRequest: async (url, init) => {
850
+ let request = new Request(url, init);
851
+ for (const fn of interceptors.request.fns) {
852
+ if (fn) {
853
+ request = await fn(request, opts);
854
+ }
855
+ }
856
+ return request;
857
+ },
858
+ serializedBody: getValidRequestBody(opts),
859
+ url,
860
+ });
861
+ };
862
+ return {
863
+ buildUrl,
864
+ connect: makeMethodFn('CONNECT'),
865
+ delete: makeMethodFn('DELETE'),
866
+ get: makeMethodFn('GET'),
867
+ getConfig,
868
+ head: makeMethodFn('HEAD'),
869
+ interceptors,
870
+ options: makeMethodFn('OPTIONS'),
871
+ patch: makeMethodFn('PATCH'),
872
+ post: makeMethodFn('POST'),
873
+ put: makeMethodFn('PUT'),
874
+ request,
875
+ setConfig,
876
+ sse: {
877
+ connect: makeSseFn('CONNECT'),
878
+ delete: makeSseFn('DELETE'),
879
+ get: makeSseFn('GET'),
880
+ head: makeSseFn('HEAD'),
881
+ options: makeSseFn('OPTIONS'),
882
+ patch: makeSseFn('PATCH'),
883
+ post: makeSseFn('POST'),
884
+ put: makeSseFn('PUT'),
885
+ trace: makeSseFn('TRACE'),
886
+ },
887
+ trace: makeMethodFn('TRACE'),
888
+ };
889
+ };
890
+
891
+ const client = createClient(createConfig({ baseUrl: '/v1' }));
892
+
893
+ class HeyApiClient {
894
+ constructor(args) {
895
+ this.client = args?.client ?? client;
896
+ }
897
+ }
898
+ class HeyApiRegistry {
899
+ constructor() {
900
+ this.defaultKey = 'default';
901
+ this.instances = new Map();
902
+ }
903
+ get(key) {
904
+ const instance = this.instances.get(key ?? this.defaultKey);
905
+ if (!instance) {
906
+ throw new Error(`No SDK client found. Create one with "new BillingAddons2()" to fix this error.`);
907
+ }
908
+ return instance;
909
+ }
910
+ set(value, key) {
911
+ this.instances.set(key ?? this.defaultKey, value);
912
+ }
913
+ }
914
+ class HeyApiRegistry2 {
915
+ constructor() {
916
+ this.defaultKey = 'default';
917
+ this.instances = new Map();
918
+ }
919
+ get(key) {
920
+ const instance = this.instances.get(key ?? this.defaultKey);
921
+ if (!instance) {
922
+ throw new Error(`No SDK client found. Create one with "new BillingSubscription2()" to fix this error.`);
923
+ }
924
+ return instance;
925
+ }
926
+ set(value, key) {
927
+ this.instances.set(key ?? this.defaultKey, value);
928
+ }
929
+ }
930
+ class HeyApiRegistry3 {
931
+ constructor() {
932
+ this.defaultKey = 'default';
933
+ this.instances = new Map();
934
+ }
935
+ get(key) {
936
+ const instance = this.instances.get(key ?? this.defaultKey);
937
+ if (!instance) {
938
+ throw new Error(`No SDK client found. Create one with "new Billing2()" to fix this error.`);
939
+ }
940
+ return instance;
941
+ }
942
+ set(value, key) {
943
+ this.instances.set(key ?? this.defaultKey, value);
944
+ }
945
+ }
946
+ class HeyApiRegistry4 {
947
+ constructor() {
948
+ this.defaultKey = 'default';
949
+ this.instances = new Map();
950
+ }
951
+ get(key) {
952
+ const instance = this.instances.get(key ?? this.defaultKey);
953
+ if (!instance) {
954
+ throw new Error(`No SDK client found. Create one with "new Organizations()" to fix this error.`);
955
+ }
956
+ return instance;
957
+ }
958
+ set(value, key) {
959
+ this.instances.set(key ?? this.defaultKey, value);
960
+ }
961
+ }
962
+ class HeyApiRegistry5 {
963
+ constructor() {
964
+ this.defaultKey = 'default';
965
+ this.instances = new Map();
966
+ }
967
+ get(key) {
968
+ const instance = this.instances.get(key ?? this.defaultKey);
969
+ if (!instance) {
970
+ throw new Error(`No SDK client found. Create one with "new OrganizationMembers()" to fix this error.`);
971
+ }
972
+ return instance;
973
+ }
974
+ set(value, key) {
975
+ this.instances.set(key ?? this.defaultKey, value);
976
+ }
977
+ }
978
+ class HeyApiRegistry6 {
979
+ constructor() {
980
+ this.defaultKey = 'default';
981
+ this.instances = new Map();
982
+ }
983
+ get(key) {
984
+ const instance = this.instances.get(key ?? this.defaultKey);
985
+ if (!instance) {
986
+ throw new Error(`No SDK client found. Create one with "new Default()" to fix this error.`);
987
+ }
988
+ return instance;
989
+ }
990
+ set(value, key) {
991
+ this.instances.set(key ?? this.defaultKey, value);
992
+ }
993
+ }
994
+ class BillingAddons extends HeyApiClient {
995
+ getAddons(options) {
996
+ return (options?.client ?? this.client).get({
997
+ responseStyle: 'data',
998
+ url: '/billing/addons',
999
+ ...options
1000
+ });
1001
+ }
1002
+ previewUpdate(parameters, options) {
1003
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'addon' }, { in: 'body', key: 'quantity' }] }]);
1004
+ return (options?.client ?? this.client).post({
1005
+ responseStyle: 'data',
1006
+ url: '/billing/addons/{addon}/preview',
1007
+ ...options,
1008
+ ...params,
1009
+ headers: {
1010
+ 'Content-Type': 'application/json',
1011
+ ...options?.headers,
1012
+ ...params.headers
1013
+ }
1014
+ });
1015
+ }
1016
+ getAddonUsages(parameters, options) {
1017
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'addon' }] }]);
1018
+ return (options?.client ?? this.client).get({
1019
+ responseStyle: 'data',
1020
+ url: '/billing/addons/{addon}',
1021
+ ...options,
1022
+ ...params
1023
+ });
1024
+ }
1025
+ update(parameters, options) {
1026
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'addon' }, { in: 'body', key: 'quantity' }] }]);
1027
+ return (options?.client ?? this.client).post({
1028
+ responseStyle: 'data',
1029
+ url: '/billing/addons/{addon}',
1030
+ ...options,
1031
+ ...params,
1032
+ headers: {
1033
+ 'Content-Type': 'application/json',
1034
+ ...options?.headers,
1035
+ ...params.headers
1036
+ }
1037
+ });
1038
+ }
1039
+ }
1040
+ class BillingAddons2 extends HeyApiClient {
1041
+ constructor(args) {
1042
+ super(args);
1043
+ BillingAddons2.__registry.set(this, args?.key);
1044
+ }
1045
+ get billingAddons() {
1046
+ return this._billingAddons ?? (this._billingAddons = new BillingAddons({ client: this.client }));
1047
+ }
1048
+ }
1049
+ BillingAddons2.__registry = new HeyApiRegistry();
1050
+ class BillingSubscription extends HeyApiClient {
1051
+ get(options) {
1052
+ return (options?.client ?? this.client).get({
1053
+ responseStyle: 'data',
1054
+ url: '/billing/subscription',
1055
+ ...options
1056
+ });
1057
+ }
1058
+ update(parameters, options) {
1059
+ const params = buildClientParams([parameters], [{ args: [{ in: 'body', key: 'plan' }, { in: 'body', key: 'billing_period' }] }]);
1060
+ return (options?.client ?? this.client).post({
1061
+ responseStyle: 'data',
1062
+ url: '/billing/subscription',
1063
+ ...options,
1064
+ ...params,
1065
+ headers: {
1066
+ 'Content-Type': 'application/json',
1067
+ ...options?.headers,
1068
+ ...params.headers
1069
+ }
1070
+ });
1071
+ }
1072
+ previewUpdate(parameters, options) {
1073
+ const params = buildClientParams([parameters], [{ args: [{ in: 'body', key: 'plan' }, { in: 'body', key: 'billing_period' }] }]);
1074
+ return (options?.client ?? this.client).post({
1075
+ responseStyle: 'data',
1076
+ url: '/billing/subscription/preview',
1077
+ ...options,
1078
+ ...params,
1079
+ headers: {
1080
+ 'Content-Type': 'application/json',
1081
+ ...options?.headers,
1082
+ ...params.headers
1083
+ }
1084
+ });
1085
+ }
1086
+ }
1087
+ class BillingSubscription2 extends HeyApiClient {
1088
+ constructor(args) {
1089
+ super(args);
1090
+ BillingSubscription2.__registry.set(this, args?.key);
1091
+ }
1092
+ get billingSubscription() {
1093
+ return this._billingSubscription ?? (this._billingSubscription = new BillingSubscription({ client: this.client }));
1094
+ }
1095
+ }
1096
+ BillingSubscription2.__registry = new HeyApiRegistry2();
1097
+ class Billing extends HeyApiClient {
1098
+ getPrices(parameters, options) {
1099
+ const params = buildClientParams([parameters], [{ args: [{ in: 'query', key: 'currency' }] }]);
1100
+ return (options?.client ?? this.client).get({
1101
+ responseStyle: 'data',
1102
+ url: '/billing/prices',
1103
+ ...options,
1104
+ ...params
1105
+ });
1106
+ }
1107
+ }
1108
+ class Billing2 extends HeyApiClient {
1109
+ constructor(args) {
1110
+ super(args);
1111
+ Billing2.__registry.set(this, args?.key);
1112
+ }
1113
+ get billing() {
1114
+ return this._billing ?? (this._billing = new Billing({ client: this.client }));
1115
+ }
1116
+ }
1117
+ Billing2.__registry = new HeyApiRegistry3();
1118
+ class Organization extends HeyApiClient {
1119
+ getCurrent(options) {
1120
+ return (options?.client ?? this.client).get({
1121
+ responseStyle: 'data',
1122
+ url: '/organizations/current',
1123
+ ...options
1124
+ });
1125
+ }
1126
+ setCurrent(parameters, options) {
1127
+ const params = buildClientParams([parameters], [{ args: [{ in: 'body', key: 'organization_id' }] }]);
1128
+ return (options?.client ?? this.client).put({
1129
+ responseStyle: 'data',
1130
+ url: '/organizations/current',
1131
+ ...options,
1132
+ ...params,
1133
+ headers: {
1134
+ 'Content-Type': 'application/json',
1135
+ ...options?.headers,
1136
+ ...params.headers
1137
+ }
1138
+ });
1139
+ }
1140
+ list(options) {
1141
+ return (options?.client ?? this.client).get({
1142
+ responseStyle: 'data',
1143
+ url: '/organizations',
1144
+ ...options
1145
+ });
1146
+ }
1147
+ create(parameters, options) {
1148
+ const params = buildClientParams([parameters], [{ args: [{ in: 'body', key: 'name' }] }]);
1149
+ return (options?.client ?? this.client).post({
1150
+ responseStyle: 'data',
1151
+ url: '/organizations',
1152
+ ...options,
1153
+ ...params,
1154
+ headers: {
1155
+ 'Content-Type': 'application/json',
1156
+ ...options?.headers,
1157
+ ...params.headers
1158
+ }
1159
+ });
1160
+ }
1161
+ delete(parameters, options) {
1162
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'organization_id' }] }]);
1163
+ return (options?.client ?? this.client).delete({
1164
+ responseStyle: 'data',
1165
+ url: '/organizations/{organization_id}',
1166
+ ...options,
1167
+ ...params
1168
+ });
1169
+ }
1170
+ retrieve(parameters, options) {
1171
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'organization_id' }] }]);
1172
+ return (options?.client ?? this.client).get({
1173
+ responseStyle: 'data',
1174
+ url: '/organizations/{organization_id}',
1175
+ ...options,
1176
+ ...params
1177
+ });
1178
+ }
1179
+ update(parameters, options) {
1180
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'organization_id' }, { in: 'body', key: 'name' }] }]);
1181
+ return (options?.client ?? this.client).patch({
1182
+ responseStyle: 'data',
1183
+ url: '/organizations/{organization_id}',
1184
+ ...options,
1185
+ ...params,
1186
+ headers: {
1187
+ 'Content-Type': 'application/json',
1188
+ ...options?.headers,
1189
+ ...params.headers
1190
+ }
1191
+ });
1192
+ }
1193
+ }
1194
+ class Organizations extends HeyApiClient {
1195
+ constructor(args) {
1196
+ super(args);
1197
+ Organizations.__registry.set(this, args?.key);
1198
+ }
1199
+ get organization() {
1200
+ return this._organization ?? (this._organization = new Organization({ client: this.client }));
1201
+ }
1202
+ }
1203
+ Organizations.__registry = new HeyApiRegistry4();
1204
+ class OrganizationMember extends HeyApiClient {
1205
+ list(parameters, options) {
1206
+ const params = buildClientParams([parameters], [{ args: [
1207
+ { in: 'path', key: 'organization_id' },
1208
+ { in: 'query', key: 'limit' },
1209
+ { in: 'query', key: 'starting_after' }
1210
+ ] }]);
1211
+ return (options?.client ?? this.client).get({
1212
+ responseStyle: 'data',
1213
+ url: '/organizations/{organization_id}/members',
1214
+ ...options,
1215
+ ...params
1216
+ });
1217
+ }
1218
+ create(parameters, options) {
1219
+ const params = buildClientParams([parameters], [{ args: [
1220
+ { in: 'path', key: 'organization_id' },
1221
+ { in: 'body', key: 'email' },
1222
+ { in: 'body', key: 'role' }
1223
+ ] }]);
1224
+ return (options?.client ?? this.client).post({
1225
+ responseStyle: 'data',
1226
+ url: '/organizations/{organization_id}/members',
1227
+ ...options,
1228
+ ...params,
1229
+ headers: {
1230
+ 'Content-Type': 'application/json',
1231
+ ...options?.headers,
1232
+ ...params.headers
1233
+ }
1234
+ });
1235
+ }
1236
+ delete(parameters, options) {
1237
+ const params = buildClientParams([parameters], [{ args: [{ in: 'path', key: 'organization_id' }, { in: 'path', key: 'member_id' }] }]);
1238
+ return (options?.client ?? this.client).delete({
1239
+ responseStyle: 'data',
1240
+ url: '/organizations/{organization_id}/members/{member_id}',
1241
+ ...options,
1242
+ ...params
1243
+ });
1244
+ }
1245
+ update(parameters, options) {
1246
+ const params = buildClientParams([parameters], [{ args: [
1247
+ { in: 'path', key: 'organization_id' },
1248
+ { in: 'path', key: 'member_id' },
1249
+ { in: 'body', key: 'role' }
1250
+ ] }]);
1251
+ return (options?.client ?? this.client).patch({
1252
+ responseStyle: 'data',
1253
+ url: '/organizations/{organization_id}/members/{member_id}',
1254
+ ...options,
1255
+ ...params,
1256
+ headers: {
1257
+ 'Content-Type': 'application/json',
1258
+ ...options?.headers,
1259
+ ...params.headers
1260
+ }
1261
+ });
1262
+ }
1263
+ }
1264
+ class OrganizationMembers extends HeyApiClient {
1265
+ constructor(args) {
1266
+ super(args);
1267
+ OrganizationMembers.__registry.set(this, args?.key);
1268
+ }
1269
+ get organizationMember() {
1270
+ return this._organizationMember ?? (this._organizationMember = new OrganizationMember({ client: this.client }));
1271
+ }
1272
+ }
1273
+ OrganizationMembers.__registry = new HeyApiRegistry5();
1274
+ class Default extends HeyApiClient {
1275
+ constructor(args) {
1276
+ super(args);
1277
+ Default.__registry.set(this, args?.key);
1278
+ }
1279
+ getOpenapiJson(options) {
1280
+ return (options?.client ?? this.client).get({
1281
+ responseStyle: 'data',
1282
+ url: '/openapi.json',
1283
+ ...options
1284
+ });
1285
+ }
1286
+ }
1287
+ Default.__registry = new HeyApiRegistry6();
1288
+
1289
+ var types_gen = /*#__PURE__*/Object.freeze({
1290
+ __proto__: null
1291
+ });
1292
+
1293
+ class Mailmeteor {
1294
+ constructor(key, config) {
1295
+ const baseUrl = config?.baseUrl || "https://api.mailmeteor.com/v1";
1296
+ this.client = createClient(createConfig({
1297
+ baseUrl,
1298
+ headers: {
1299
+ 'Authorization': `Bearer ${key}`,
1300
+ },
1301
+ }));
1302
+ this.billingAddons = new BillingAddons({ client: this.client });
1303
+ this.billingSubscription = new BillingSubscription({ client: this.client });
1304
+ this.billing = new Billing({ client: this.client });
1305
+ }
1306
+ setApiKey(key) {
1307
+ const currentConfig = this.client.getConfig();
1308
+ const currentHeaders = currentConfig.headers ?? {};
1309
+ this.client.setConfig({
1310
+ ...currentConfig,
1311
+ headers: {
1312
+ ...currentHeaders,
1313
+ 'Authorization': `Bearer ${key}`,
1314
+ },
1315
+ });
1316
+ }
1317
+ }
1318
+
1319
+ export { Mailmeteor, types_gen as MailmeteorTypes };
1320
+ //# sourceMappingURL=index.mjs.map