@multisender.app/multisender-sdk 0.0.1 → 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.
@@ -0,0 +1,1149 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __toCommonJS = (from) => {
33
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
34
+ if (entry)
35
+ return entry;
36
+ entry = __defProp({}, "__esModule", { value: true });
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (var key of __getOwnPropNames(from))
39
+ if (!__hasOwnProp.call(entry, key))
40
+ __defProp(entry, key, {
41
+ get: __accessProp.bind(from, key),
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ }
45
+ __moduleCache.set(from, entry);
46
+ return entry;
47
+ };
48
+ var __moduleCache;
49
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
50
+ var __returnValue = (v) => v;
51
+ function __exportSetter(name, newValue) {
52
+ this[name] = __returnValue.bind(null, newValue);
53
+ }
54
+ var __export = (target, all) => {
55
+ for (var name in all)
56
+ __defProp(target, name, {
57
+ get: all[name],
58
+ enumerable: true,
59
+ configurable: true,
60
+ set: __exportSetter.bind(all, name)
61
+ });
62
+ };
63
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
64
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
65
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
66
+ }) : x)(function(x) {
67
+ if (typeof require !== "undefined")
68
+ return require.apply(this, arguments);
69
+ throw Error('Dynamic require of "' + x + '" is not supported');
70
+ });
71
+
72
+ // src/gen/core/bodySerializer.gen.ts
73
+ var serializeFormDataPair = (data, key, value) => {
74
+ if (typeof value === "string" || value instanceof Blob) {
75
+ data.append(key, value);
76
+ } else if (value instanceof Date) {
77
+ data.append(key, value.toISOString());
78
+ } else {
79
+ data.append(key, JSON.stringify(value));
80
+ }
81
+ };
82
+ var formDataBodySerializer = {
83
+ bodySerializer: (body) => {
84
+ const data = new FormData;
85
+ Object.entries(body).forEach(([key, value]) => {
86
+ if (value === undefined || value === null) {
87
+ return;
88
+ }
89
+ if (Array.isArray(value)) {
90
+ value.forEach((v) => serializeFormDataPair(data, key, v));
91
+ } else {
92
+ serializeFormDataPair(data, key, value);
93
+ }
94
+ });
95
+ return data;
96
+ }
97
+ };
98
+ var jsonBodySerializer = {
99
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
100
+ };
101
+ // src/gen/core/params.gen.ts
102
+ var extraPrefixesMap = {
103
+ $body_: "body",
104
+ $headers_: "headers",
105
+ $path_: "path",
106
+ $query_: "query"
107
+ };
108
+ var extraPrefixes = Object.entries(extraPrefixesMap);
109
+ // src/gen/core/serverSentEvents.gen.ts
110
+ var createSseClient = ({
111
+ onRequest,
112
+ onSseError,
113
+ onSseEvent,
114
+ responseTransformer,
115
+ responseValidator,
116
+ sseDefaultRetryDelay,
117
+ sseMaxRetryAttempts,
118
+ sseMaxRetryDelay,
119
+ sseSleepFn,
120
+ url,
121
+ ...options
122
+ }) => {
123
+ let lastEventId;
124
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
125
+ const createStream = async function* () {
126
+ let retryDelay = sseDefaultRetryDelay ?? 3000;
127
+ let attempt = 0;
128
+ const signal = options.signal ?? new AbortController().signal;
129
+ while (true) {
130
+ if (signal.aborted)
131
+ break;
132
+ attempt++;
133
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
134
+ if (lastEventId !== undefined) {
135
+ headers.set("Last-Event-ID", lastEventId);
136
+ }
137
+ try {
138
+ const requestInit = {
139
+ redirect: "follow",
140
+ ...options,
141
+ body: options.serializedBody,
142
+ headers,
143
+ signal
144
+ };
145
+ let request = new Request(url, requestInit);
146
+ if (onRequest) {
147
+ request = await onRequest(url, requestInit);
148
+ }
149
+ const _fetch = options.fetch ?? globalThis.fetch;
150
+ const response = await _fetch(request);
151
+ if (!response.ok)
152
+ throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
153
+ if (!response.body)
154
+ throw new Error("No body in SSE response");
155
+ const reader = response.body.pipeThrough(new TextDecoderStream).getReader();
156
+ let buffer = "";
157
+ const abortHandler = () => {
158
+ try {
159
+ reader.cancel();
160
+ } catch {}
161
+ };
162
+ signal.addEventListener("abort", abortHandler);
163
+ try {
164
+ while (true) {
165
+ const { done, value } = await reader.read();
166
+ if (done)
167
+ break;
168
+ buffer += value;
169
+ buffer = buffer.replace(/\r\n/g, `
170
+ `).replace(/\r/g, `
171
+ `);
172
+ const chunks = buffer.split(`
173
+
174
+ `);
175
+ buffer = chunks.pop() ?? "";
176
+ for (const chunk of chunks) {
177
+ const lines = chunk.split(`
178
+ `);
179
+ const dataLines = [];
180
+ let eventName;
181
+ for (const line of lines) {
182
+ if (line.startsWith("data:")) {
183
+ dataLines.push(line.replace(/^data:\s*/, ""));
184
+ } else if (line.startsWith("event:")) {
185
+ eventName = line.replace(/^event:\s*/, "");
186
+ } else if (line.startsWith("id:")) {
187
+ lastEventId = line.replace(/^id:\s*/, "");
188
+ } else if (line.startsWith("retry:")) {
189
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
190
+ if (!Number.isNaN(parsed)) {
191
+ retryDelay = parsed;
192
+ }
193
+ }
194
+ }
195
+ let data;
196
+ let parsedJson = false;
197
+ if (dataLines.length) {
198
+ const rawData = dataLines.join(`
199
+ `);
200
+ try {
201
+ data = JSON.parse(rawData);
202
+ parsedJson = true;
203
+ } catch {
204
+ data = rawData;
205
+ }
206
+ }
207
+ if (parsedJson) {
208
+ if (responseValidator) {
209
+ await responseValidator(data);
210
+ }
211
+ if (responseTransformer) {
212
+ data = await responseTransformer(data);
213
+ }
214
+ }
215
+ onSseEvent?.({
216
+ data,
217
+ event: eventName,
218
+ id: lastEventId,
219
+ retry: retryDelay
220
+ });
221
+ if (dataLines.length) {
222
+ yield data;
223
+ }
224
+ }
225
+ }
226
+ } finally {
227
+ signal.removeEventListener("abort", abortHandler);
228
+ reader.releaseLock();
229
+ }
230
+ break;
231
+ } catch (error) {
232
+ onSseError?.(error);
233
+ if (sseMaxRetryAttempts !== undefined && attempt >= sseMaxRetryAttempts) {
234
+ break;
235
+ }
236
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 30000);
237
+ await sleep(backoff);
238
+ }
239
+ }
240
+ };
241
+ const stream = createStream();
242
+ return { stream };
243
+ };
244
+
245
+ // src/gen/core/pathSerializer.gen.ts
246
+ var separatorArrayExplode = (style) => {
247
+ switch (style) {
248
+ case "label":
249
+ return ".";
250
+ case "matrix":
251
+ return ";";
252
+ case "simple":
253
+ return ",";
254
+ default:
255
+ return "&";
256
+ }
257
+ };
258
+ var separatorArrayNoExplode = (style) => {
259
+ switch (style) {
260
+ case "form":
261
+ return ",";
262
+ case "pipeDelimited":
263
+ return "|";
264
+ case "spaceDelimited":
265
+ return "%20";
266
+ default:
267
+ return ",";
268
+ }
269
+ };
270
+ var separatorObjectExplode = (style) => {
271
+ switch (style) {
272
+ case "label":
273
+ return ".";
274
+ case "matrix":
275
+ return ";";
276
+ case "simple":
277
+ return ",";
278
+ default:
279
+ return "&";
280
+ }
281
+ };
282
+ var serializeArrayParam = ({
283
+ allowReserved,
284
+ explode,
285
+ name,
286
+ style,
287
+ value
288
+ }) => {
289
+ if (!explode) {
290
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
291
+ switch (style) {
292
+ case "label":
293
+ return `.${joinedValues2}`;
294
+ case "matrix":
295
+ return `;${name}=${joinedValues2}`;
296
+ case "simple":
297
+ return joinedValues2;
298
+ default:
299
+ return `${name}=${joinedValues2}`;
300
+ }
301
+ }
302
+ const separator = separatorArrayExplode(style);
303
+ const joinedValues = value.map((v) => {
304
+ if (style === "label" || style === "simple") {
305
+ return allowReserved ? v : encodeURIComponent(v);
306
+ }
307
+ return serializePrimitiveParam({
308
+ allowReserved,
309
+ name,
310
+ value: v
311
+ });
312
+ }).join(separator);
313
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
314
+ };
315
+ var serializePrimitiveParam = ({
316
+ allowReserved,
317
+ name,
318
+ value
319
+ }) => {
320
+ if (value === undefined || value === null) {
321
+ return "";
322
+ }
323
+ if (typeof value === "object") {
324
+ throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");
325
+ }
326
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
327
+ };
328
+ var serializeObjectParam = ({
329
+ allowReserved,
330
+ explode,
331
+ name,
332
+ style,
333
+ value,
334
+ valueOnly
335
+ }) => {
336
+ if (value instanceof Date) {
337
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
338
+ }
339
+ if (style !== "deepObject" && !explode) {
340
+ let values = [];
341
+ Object.entries(value).forEach(([key, v]) => {
342
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
343
+ });
344
+ const joinedValues2 = values.join(",");
345
+ switch (style) {
346
+ case "form":
347
+ return `${name}=${joinedValues2}`;
348
+ case "label":
349
+ return `.${joinedValues2}`;
350
+ case "matrix":
351
+ return `;${name}=${joinedValues2}`;
352
+ default:
353
+ return joinedValues2;
354
+ }
355
+ }
356
+ const separator = separatorObjectExplode(style);
357
+ const joinedValues = Object.entries(value).map(([key, v]) => serializePrimitiveParam({
358
+ allowReserved,
359
+ name: style === "deepObject" ? `${name}[${key}]` : key,
360
+ value: v
361
+ })).join(separator);
362
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
363
+ };
364
+
365
+ // src/gen/core/utils.gen.ts
366
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
367
+ var defaultPathSerializer = ({ path, url: _url }) => {
368
+ let url = _url;
369
+ const matches = _url.match(PATH_PARAM_RE);
370
+ if (matches) {
371
+ for (const match of matches) {
372
+ let explode = false;
373
+ let name = match.substring(1, match.length - 1);
374
+ let style = "simple";
375
+ if (name.endsWith("*")) {
376
+ explode = true;
377
+ name = name.substring(0, name.length - 1);
378
+ }
379
+ if (name.startsWith(".")) {
380
+ name = name.substring(1);
381
+ style = "label";
382
+ } else if (name.startsWith(";")) {
383
+ name = name.substring(1);
384
+ style = "matrix";
385
+ }
386
+ const value = path[name];
387
+ if (value === undefined || value === null) {
388
+ continue;
389
+ }
390
+ if (Array.isArray(value)) {
391
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
392
+ continue;
393
+ }
394
+ if (typeof value === "object") {
395
+ url = url.replace(match, serializeObjectParam({
396
+ explode,
397
+ name,
398
+ style,
399
+ value,
400
+ valueOnly: true
401
+ }));
402
+ continue;
403
+ }
404
+ if (style === "matrix") {
405
+ url = url.replace(match, `;${serializePrimitiveParam({
406
+ name,
407
+ value
408
+ })}`);
409
+ continue;
410
+ }
411
+ const replaceValue = encodeURIComponent(style === "label" ? `.${value}` : value);
412
+ url = url.replace(match, replaceValue);
413
+ }
414
+ }
415
+ return url;
416
+ };
417
+ var getUrl = ({
418
+ baseUrl,
419
+ path,
420
+ query,
421
+ querySerializer,
422
+ url: _url
423
+ }) => {
424
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
425
+ let url = (baseUrl ?? "") + pathUrl;
426
+ if (path) {
427
+ url = defaultPathSerializer({ path, url });
428
+ }
429
+ let search = query ? querySerializer(query) : "";
430
+ if (search.startsWith("?")) {
431
+ search = search.substring(1);
432
+ }
433
+ if (search) {
434
+ url += `?${search}`;
435
+ }
436
+ return url;
437
+ };
438
+ function getValidRequestBody(options) {
439
+ const hasBody = options.body !== undefined;
440
+ const isSerializedBody = hasBody && options.bodySerializer;
441
+ if (isSerializedBody) {
442
+ if ("serializedBody" in options) {
443
+ const hasSerializedBody = options.serializedBody !== undefined && options.serializedBody !== "";
444
+ return hasSerializedBody ? options.serializedBody : null;
445
+ }
446
+ return options.body !== "" ? options.body : null;
447
+ }
448
+ if (hasBody) {
449
+ return options.body;
450
+ }
451
+ return;
452
+ }
453
+
454
+ // src/gen/core/auth.gen.ts
455
+ var getAuthToken = async (auth, callback) => {
456
+ const token = typeof callback === "function" ? await callback(auth) : callback;
457
+ if (!token) {
458
+ return;
459
+ }
460
+ if (auth.scheme === "bearer") {
461
+ return `Bearer ${token}`;
462
+ }
463
+ if (auth.scheme === "basic") {
464
+ return `Basic ${btoa(token)}`;
465
+ }
466
+ return token;
467
+ };
468
+
469
+ // src/gen/client/utils.gen.ts
470
+ var createQuerySerializer = ({
471
+ parameters = {},
472
+ ...args
473
+ } = {}) => {
474
+ const querySerializer = (queryParams) => {
475
+ const search = [];
476
+ if (queryParams && typeof queryParams === "object") {
477
+ for (const name in queryParams) {
478
+ const value = queryParams[name];
479
+ if (value === undefined || value === null) {
480
+ continue;
481
+ }
482
+ const options = parameters[name] || args;
483
+ if (Array.isArray(value)) {
484
+ const serializedArray = serializeArrayParam({
485
+ allowReserved: options.allowReserved,
486
+ explode: true,
487
+ name,
488
+ style: "form",
489
+ value,
490
+ ...options.array
491
+ });
492
+ if (serializedArray)
493
+ search.push(serializedArray);
494
+ } else if (typeof value === "object") {
495
+ const serializedObject = serializeObjectParam({
496
+ allowReserved: options.allowReserved,
497
+ explode: true,
498
+ name,
499
+ style: "deepObject",
500
+ value,
501
+ ...options.object
502
+ });
503
+ if (serializedObject)
504
+ search.push(serializedObject);
505
+ } else {
506
+ const serializedPrimitive = serializePrimitiveParam({
507
+ allowReserved: options.allowReserved,
508
+ name,
509
+ value
510
+ });
511
+ if (serializedPrimitive)
512
+ search.push(serializedPrimitive);
513
+ }
514
+ }
515
+ }
516
+ return search.join("&");
517
+ };
518
+ return querySerializer;
519
+ };
520
+ var getParseAs = (contentType) => {
521
+ if (!contentType) {
522
+ return "stream";
523
+ }
524
+ const cleanContent = contentType.split(";")[0]?.trim();
525
+ if (!cleanContent) {
526
+ return;
527
+ }
528
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
529
+ return "json";
530
+ }
531
+ if (cleanContent === "multipart/form-data") {
532
+ return "formData";
533
+ }
534
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
535
+ return "blob";
536
+ }
537
+ if (cleanContent.startsWith("text/")) {
538
+ return "text";
539
+ }
540
+ return;
541
+ };
542
+ var checkForExistence = (options, name) => {
543
+ if (!name) {
544
+ return false;
545
+ }
546
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
547
+ return true;
548
+ }
549
+ return false;
550
+ };
551
+ var setAuthParams = async ({
552
+ security,
553
+ ...options
554
+ }) => {
555
+ for (const auth of security) {
556
+ if (checkForExistence(options, auth.name)) {
557
+ continue;
558
+ }
559
+ const token = await getAuthToken(auth, options.auth);
560
+ if (!token) {
561
+ continue;
562
+ }
563
+ const name = auth.name ?? "Authorization";
564
+ switch (auth.in) {
565
+ case "query":
566
+ if (!options.query) {
567
+ options.query = {};
568
+ }
569
+ options.query[name] = token;
570
+ break;
571
+ case "cookie":
572
+ options.headers.append("Cookie", `${name}=${token}`);
573
+ break;
574
+ case "header":
575
+ default:
576
+ options.headers.set(name, token);
577
+ break;
578
+ }
579
+ }
580
+ };
581
+ var buildUrl = (options) => getUrl({
582
+ baseUrl: options.baseUrl,
583
+ path: options.path,
584
+ query: options.query,
585
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
586
+ url: options.url
587
+ });
588
+ var mergeConfigs = (a, b) => {
589
+ const config = { ...a, ...b };
590
+ if (config.baseUrl?.endsWith("/")) {
591
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
592
+ }
593
+ config.headers = mergeHeaders(a.headers, b.headers);
594
+ return config;
595
+ };
596
+ var headersEntries = (headers) => {
597
+ const entries = [];
598
+ headers.forEach((value, key) => {
599
+ entries.push([key, value]);
600
+ });
601
+ return entries;
602
+ };
603
+ var mergeHeaders = (...headers) => {
604
+ const mergedHeaders = new Headers;
605
+ for (const header of headers) {
606
+ if (!header) {
607
+ continue;
608
+ }
609
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
610
+ for (const [key, value] of iterator) {
611
+ if (value === null) {
612
+ mergedHeaders.delete(key);
613
+ } else if (Array.isArray(value)) {
614
+ for (const v of value) {
615
+ mergedHeaders.append(key, v);
616
+ }
617
+ } else if (value !== undefined) {
618
+ mergedHeaders.set(key, typeof value === "object" ? JSON.stringify(value) : value);
619
+ }
620
+ }
621
+ }
622
+ return mergedHeaders;
623
+ };
624
+
625
+ class Interceptors {
626
+ fns = [];
627
+ clear() {
628
+ this.fns = [];
629
+ }
630
+ eject(id) {
631
+ const index = this.getInterceptorIndex(id);
632
+ if (this.fns[index]) {
633
+ this.fns[index] = null;
634
+ }
635
+ }
636
+ exists(id) {
637
+ const index = this.getInterceptorIndex(id);
638
+ return Boolean(this.fns[index]);
639
+ }
640
+ getInterceptorIndex(id) {
641
+ if (typeof id === "number") {
642
+ return this.fns[id] ? id : -1;
643
+ }
644
+ return this.fns.indexOf(id);
645
+ }
646
+ update(id, fn) {
647
+ const index = this.getInterceptorIndex(id);
648
+ if (this.fns[index]) {
649
+ this.fns[index] = fn;
650
+ return id;
651
+ }
652
+ return false;
653
+ }
654
+ use(fn) {
655
+ this.fns.push(fn);
656
+ return this.fns.length - 1;
657
+ }
658
+ }
659
+ var createInterceptors = () => ({
660
+ error: new Interceptors,
661
+ request: new Interceptors,
662
+ response: new Interceptors
663
+ });
664
+ var defaultQuerySerializer = createQuerySerializer({
665
+ allowReserved: false,
666
+ array: {
667
+ explode: true,
668
+ style: "form"
669
+ },
670
+ object: {
671
+ explode: true,
672
+ style: "deepObject"
673
+ }
674
+ });
675
+ var defaultHeaders = {
676
+ "Content-Type": "application/json"
677
+ };
678
+ var createConfig = (override = {}) => ({
679
+ ...jsonBodySerializer,
680
+ headers: defaultHeaders,
681
+ parseAs: "auto",
682
+ querySerializer: defaultQuerySerializer,
683
+ ...override
684
+ });
685
+
686
+ // src/gen/client/client.gen.ts
687
+ var createClient = (config = {}) => {
688
+ let _config = mergeConfigs(createConfig(), config);
689
+ const getConfig = () => ({ ..._config });
690
+ const setConfig = (config2) => {
691
+ _config = mergeConfigs(_config, config2);
692
+ return getConfig();
693
+ };
694
+ const interceptors = createInterceptors();
695
+ const beforeRequest = async (options) => {
696
+ const opts = {
697
+ ..._config,
698
+ ...options,
699
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
700
+ headers: mergeHeaders(_config.headers, options.headers),
701
+ serializedBody: undefined
702
+ };
703
+ if (opts.security) {
704
+ await setAuthParams({
705
+ ...opts,
706
+ security: opts.security
707
+ });
708
+ }
709
+ if (opts.requestValidator) {
710
+ await opts.requestValidator(opts);
711
+ }
712
+ if (opts.body !== undefined && opts.bodySerializer) {
713
+ opts.serializedBody = opts.bodySerializer(opts.body);
714
+ }
715
+ if (opts.body === undefined || opts.serializedBody === "") {
716
+ opts.headers.delete("Content-Type");
717
+ }
718
+ const url = buildUrl(opts);
719
+ return { opts, url };
720
+ };
721
+ const request = async (options) => {
722
+ const { opts, url } = await beforeRequest(options);
723
+ const requestInit = {
724
+ redirect: "follow",
725
+ ...opts,
726
+ body: getValidRequestBody(opts)
727
+ };
728
+ let request2 = new Request(url, requestInit);
729
+ for (const fn of interceptors.request.fns) {
730
+ if (fn) {
731
+ request2 = await fn(request2, opts);
732
+ }
733
+ }
734
+ const _fetch = opts.fetch;
735
+ let response;
736
+ try {
737
+ response = await _fetch(request2);
738
+ } catch (error2) {
739
+ let finalError2 = error2;
740
+ for (const fn of interceptors.error.fns) {
741
+ if (fn) {
742
+ finalError2 = await fn(error2, undefined, request2, opts);
743
+ }
744
+ }
745
+ finalError2 = finalError2 || {};
746
+ if (opts.throwOnError) {
747
+ throw finalError2;
748
+ }
749
+ return opts.responseStyle === "data" ? undefined : {
750
+ error: finalError2,
751
+ request: request2,
752
+ response: undefined
753
+ };
754
+ }
755
+ for (const fn of interceptors.response.fns) {
756
+ if (fn) {
757
+ response = await fn(response, request2, opts);
758
+ }
759
+ }
760
+ const result = {
761
+ request: request2,
762
+ response
763
+ };
764
+ if (response.ok) {
765
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
766
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
767
+ let emptyData;
768
+ switch (parseAs) {
769
+ case "arrayBuffer":
770
+ case "blob":
771
+ case "text":
772
+ emptyData = await response[parseAs]();
773
+ break;
774
+ case "formData":
775
+ emptyData = new FormData;
776
+ break;
777
+ case "stream":
778
+ emptyData = response.body;
779
+ break;
780
+ case "json":
781
+ default:
782
+ emptyData = {};
783
+ break;
784
+ }
785
+ return opts.responseStyle === "data" ? emptyData : {
786
+ data: emptyData,
787
+ ...result
788
+ };
789
+ }
790
+ let data;
791
+ switch (parseAs) {
792
+ case "arrayBuffer":
793
+ case "blob":
794
+ case "formData":
795
+ case "text":
796
+ data = await response[parseAs]();
797
+ break;
798
+ case "json": {
799
+ const text = await response.text();
800
+ data = text ? JSON.parse(text) : {};
801
+ break;
802
+ }
803
+ case "stream":
804
+ return opts.responseStyle === "data" ? response.body : {
805
+ data: response.body,
806
+ ...result
807
+ };
808
+ }
809
+ if (parseAs === "json") {
810
+ if (opts.responseValidator) {
811
+ await opts.responseValidator(data);
812
+ }
813
+ if (opts.responseTransformer) {
814
+ data = await opts.responseTransformer(data);
815
+ }
816
+ }
817
+ return opts.responseStyle === "data" ? data : {
818
+ data,
819
+ ...result
820
+ };
821
+ }
822
+ const textError = await response.text();
823
+ let jsonError;
824
+ try {
825
+ jsonError = JSON.parse(textError);
826
+ } catch {}
827
+ const error = jsonError ?? textError;
828
+ let finalError = error;
829
+ for (const fn of interceptors.error.fns) {
830
+ if (fn) {
831
+ finalError = await fn(error, response, request2, opts);
832
+ }
833
+ }
834
+ finalError = finalError || {};
835
+ if (opts.throwOnError) {
836
+ throw finalError;
837
+ }
838
+ return opts.responseStyle === "data" ? undefined : {
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 (url2, init) => {
852
+ let request2 = new Request(url2, init);
853
+ for (const fn of interceptors.request.fns) {
854
+ if (fn) {
855
+ request2 = await fn(request2, opts);
856
+ }
857
+ }
858
+ return request2;
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
+ // src/openapi-runtime.ts
893
+ var DEFAULT_BASE_URL = "https://api.multisender.app";
894
+ var DEFAULT_TIMEOUT = 30000;
895
+ var defaultRuntimeConfig = {
896
+ apiKey: "",
897
+ baseUrl: DEFAULT_BASE_URL,
898
+ timeout: DEFAULT_TIMEOUT,
899
+ headers: {}
900
+ };
901
+ var mergeHeaders2 = (headers) => ({
902
+ ...headers
903
+ });
904
+ var withTimeoutFetch = (timeoutMs) => {
905
+ const timeout = timeoutMs ?? DEFAULT_TIMEOUT;
906
+ return async (input, init) => {
907
+ if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") {
908
+ const timeoutSignal = AbortSignal.timeout(timeout);
909
+ if (!init?.signal) {
910
+ return fetch(input, { ...init, signal: timeoutSignal });
911
+ }
912
+ const controller2 = new AbortController;
913
+ const abort = () => controller2.abort();
914
+ timeoutSignal.addEventListener("abort", abort, { once: true });
915
+ init.signal.addEventListener("abort", abort, { once: true });
916
+ const signal2 = controller2.signal;
917
+ return fetch(input, { ...init, signal: signal2 });
918
+ }
919
+ const controller = new AbortController;
920
+ const timer = setTimeout(() => controller.abort(), timeout);
921
+ init?.signal?.addEventListener("abort", () => controller.abort(), { once: true });
922
+ const signal = controller.signal;
923
+ try {
924
+ return await fetch(input, { ...init, signal });
925
+ } finally {
926
+ clearTimeout(timer);
927
+ }
928
+ };
929
+ };
930
+ var toClientConfig = (config) => ({
931
+ baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
932
+ fetch: withTimeoutFetch(config.timeout),
933
+ headers: {
934
+ ...mergeHeaders2(config.headers),
935
+ ...config.apiKey ? { "X-API-Key": config.apiKey } : {}
936
+ }
937
+ });
938
+ var setRuntimeConfig = (config) => {
939
+ return toClientConfig({
940
+ ...defaultRuntimeConfig,
941
+ ...config,
942
+ headers: {
943
+ ...defaultRuntimeConfig.headers,
944
+ ...mergeHeaders2(config.headers)
945
+ }
946
+ });
947
+ };
948
+ var createClientConfig = (override = {}) => ({
949
+ ...toClientConfig(defaultRuntimeConfig),
950
+ ...override,
951
+ headers: {
952
+ ...toClientConfig(defaultRuntimeConfig).headers,
953
+ ...override.headers ?? {}
954
+ }
955
+ });
956
+
957
+ // src/gen/client.gen.ts
958
+ var client = createClient(createClientConfig(createConfig()));
959
+
960
+ // src/gen/sdk.gen.ts
961
+ var getProjectInfo = (options) => (options.client ?? client).get({ url: "/api/v1/project", ...options });
962
+ var getProjectMembers = (options) => (options.client ?? client).get({ url: "/api/v1/project/members", ...options });
963
+ var getApiKeys = (options) => (options.client ?? client).get({ url: "/api/v1/project/api-keys", ...options });
964
+ var createApiKey = (options) => (options.client ?? client).post({
965
+ url: "/api/v1/project/api-keys",
966
+ ...options,
967
+ headers: {
968
+ "Content-Type": "application/json",
969
+ ...options.headers
970
+ }
971
+ });
972
+ var deleteApiKey = (options) => (options.client ?? client).delete({ url: "/api/v1/project/api-keys/{apiKeyId}", ...options });
973
+ var updateApiKey = (options) => (options.client ?? client).patch({
974
+ url: "/api/v1/project/api-keys/{apiKeyId}",
975
+ ...options,
976
+ headers: {
977
+ "Content-Type": "application/json",
978
+ ...options.headers
979
+ }
980
+ });
981
+ var findAll = (options) => (options.client ?? client).get({ url: "/api/v1/lists", ...options });
982
+ var create = (options) => (options.client ?? client).post({
983
+ url: "/api/v1/lists",
984
+ ...options,
985
+ headers: {
986
+ "Content-Type": "application/json",
987
+ ...options.headers
988
+ }
989
+ });
990
+ var remove = (options) => (options.client ?? client).delete({ url: "/api/v1/lists/{listId}", ...options });
991
+ var findOne = (options) => (options.client ?? client).get({ url: "/api/v1/lists/{listId}", ...options });
992
+ var update = (options) => (options.client ?? client).patch({
993
+ url: "/api/v1/lists/{listId}",
994
+ ...options,
995
+ headers: {
996
+ "Content-Type": "application/json",
997
+ ...options.headers
998
+ }
999
+ });
1000
+ var getRecipients = (options) => (options.client ?? client).get({ url: "/api/v1/lists/{listId}/recipients", ...options });
1001
+ var addRecipient = (options) => (options.client ?? client).post({
1002
+ url: "/api/v1/lists/{listId}/recipients",
1003
+ ...options,
1004
+ headers: {
1005
+ "Content-Type": "application/json",
1006
+ ...options.headers
1007
+ }
1008
+ });
1009
+ var addRecipientsBulk = (options) => (options.client ?? client).post({
1010
+ url: "/api/v1/lists/{listId}/recipients/bulk",
1011
+ ...options,
1012
+ headers: {
1013
+ "Content-Type": "application/json",
1014
+ ...options.headers
1015
+ }
1016
+ });
1017
+ var removeRecipient = (options) => (options.client ?? client).delete({ url: "/api/v1/lists/{listId}/recipients/{recipientId}", ...options });
1018
+ var importFromFile = (options) => (options.client ?? client).post({
1019
+ ...formDataBodySerializer,
1020
+ url: "/api/v1/lists/{listId}/import",
1021
+ ...options,
1022
+ headers: {
1023
+ "Content-Type": null,
1024
+ ...options.headers
1025
+ }
1026
+ });
1027
+ var createDistributionList = (options) => (options.client ?? client).post({
1028
+ url: "/api/v1/lists/distribution",
1029
+ ...options,
1030
+ headers: {
1031
+ "Content-Type": "application/json",
1032
+ ...options.headers
1033
+ }
1034
+ });
1035
+ var validateDistributionRecipients = (options) => (options.client ?? client).post({
1036
+ url: "/api/v1/lists/distribution/validate",
1037
+ ...options,
1038
+ headers: {
1039
+ "Content-Type": "application/json",
1040
+ ...options.headers
1041
+ }
1042
+ });
1043
+ var importCsvDistribution = (options) => (options.client ?? client).post({
1044
+ url: "/api/v1/lists/distribution/csv",
1045
+ ...options,
1046
+ headers: {
1047
+ "Content-Type": "application/json",
1048
+ ...options.headers
1049
+ }
1050
+ });
1051
+ var distribute = (options) => (options.client ?? client).post({
1052
+ url: "/api/v1/distribute",
1053
+ ...options,
1054
+ headers: {
1055
+ "Content-Type": "application/json",
1056
+ ...options.headers
1057
+ }
1058
+ });
1059
+ var findAll2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions", ...options });
1060
+ var create2 = (options) => (options.client ?? client).post({
1061
+ url: "/api/v1/distributions",
1062
+ ...options,
1063
+ headers: {
1064
+ "Content-Type": "application/json",
1065
+ ...options.headers
1066
+ }
1067
+ });
1068
+ var findOne2 = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}", ...options });
1069
+ var update2 = (options) => (options.client ?? client).patch({
1070
+ url: "/api/v1/distributions/{id}",
1071
+ ...options,
1072
+ headers: {
1073
+ "Content-Type": "application/json",
1074
+ ...options.headers
1075
+ }
1076
+ });
1077
+ var updateRecipients = (options) => (options.client ?? client).patch({
1078
+ url: "/api/v1/distributions/{id}/recipients",
1079
+ ...options,
1080
+ headers: {
1081
+ "Content-Type": "application/json",
1082
+ ...options.headers
1083
+ }
1084
+ });
1085
+ var prepareTransactions = (options) => (options.client ?? client).post({
1086
+ url: "/api/v1/distributions/{id}/prepare",
1087
+ ...options,
1088
+ headers: {
1089
+ "Content-Type": "application/json",
1090
+ ...options.headers
1091
+ }
1092
+ });
1093
+ var getTransactions = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/transactions", ...options });
1094
+ var getStats = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/stats", ...options });
1095
+ var cancel = (options) => (options.client ?? client).post({ url: "/api/v1/distributions/{id}/cancel", ...options });
1096
+ var getApproveCalldata = (options) => (options.client ?? client).post({
1097
+ url: "/api/v1/approve-calldata",
1098
+ ...options,
1099
+ headers: {
1100
+ "Content-Type": "application/json",
1101
+ ...options.headers
1102
+ }
1103
+ });
1104
+ var getApproveCalldataForDistribution = (options) => (options.client ?? client).get({ url: "/api/v1/distributions/{id}/approve-calldata", ...options });
1105
+ var getChains = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains", ...options });
1106
+ var getChain = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/chains/{chainId}", ...options });
1107
+ var getTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens", ...options });
1108
+ var searchTokens = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens/search", ...options });
1109
+ var getToken = (options) => (options.client ?? client).get({ url: "/api/v1/catalogs/tokens/{chainId}/{address}", ...options });
1110
+ export {
1111
+ validateDistributionRecipients,
1112
+ updateRecipients,
1113
+ updateApiKey,
1114
+ update2,
1115
+ update,
1116
+ searchTokens,
1117
+ removeRecipient,
1118
+ remove,
1119
+ prepareTransactions,
1120
+ importFromFile,
1121
+ importCsvDistribution,
1122
+ getTransactions,
1123
+ getTokens,
1124
+ getToken,
1125
+ getStats,
1126
+ getRecipients,
1127
+ getProjectMembers,
1128
+ getProjectInfo,
1129
+ getChains,
1130
+ getChain,
1131
+ getApproveCalldataForDistribution,
1132
+ getApproveCalldata,
1133
+ getApiKeys,
1134
+ findOne2,
1135
+ findOne,
1136
+ findAll2,
1137
+ findAll,
1138
+ distribute,
1139
+ deleteApiKey,
1140
+ createDistributionList,
1141
+ createApiKey,
1142
+ create2,
1143
+ create,
1144
+ cancel,
1145
+ addRecipientsBulk,
1146
+ addRecipient
1147
+ };
1148
+
1149
+ //# debugId=51C6D739A35AA45964756E2164756E21