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