@meshscale/sdk 0.1.7

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.
package/dist/index.js ADDED
@@ -0,0 +1,1013 @@
1
+ // generated/core/bodySerializer.gen.ts
2
+ var jsonBodySerializer = {
3
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
4
+ };
5
+
6
+ // generated/core/params.gen.ts
7
+ var extraPrefixesMap = {
8
+ $body_: "body",
9
+ $headers_: "headers",
10
+ $path_: "path",
11
+ $query_: "query"
12
+ };
13
+ var extraPrefixes = Object.entries(extraPrefixesMap);
14
+
15
+ // generated/core/serverSentEvents.gen.ts
16
+ function createSseClient({
17
+ onRequest,
18
+ onSseError,
19
+ onSseEvent,
20
+ responseTransformer,
21
+ responseValidator,
22
+ sseDefaultRetryDelay,
23
+ sseMaxRetryAttempts,
24
+ sseMaxRetryDelay,
25
+ sseSleepFn,
26
+ url,
27
+ ...options
28
+ }) {
29
+ let lastEventId;
30
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
31
+ const createStream = async function* () {
32
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
33
+ let attempt = 0;
34
+ const signal = options.signal ?? new AbortController().signal;
35
+ while (true) {
36
+ if (signal.aborted) break;
37
+ attempt++;
38
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
39
+ if (lastEventId !== void 0) {
40
+ headers.set("Last-Event-ID", lastEventId);
41
+ }
42
+ try {
43
+ const requestInit = {
44
+ redirect: "follow",
45
+ ...options,
46
+ body: options.serializedBody,
47
+ headers,
48
+ signal
49
+ };
50
+ let request = new Request(url, requestInit);
51
+ if (onRequest) {
52
+ request = await onRequest(url, requestInit);
53
+ }
54
+ const _fetch = options.fetch ?? globalThis.fetch;
55
+ const response = await _fetch(request);
56
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
57
+ if (!response.body) throw new Error("No body in SSE response");
58
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
59
+ let buffer = "";
60
+ const abortHandler = () => {
61
+ try {
62
+ reader.cancel();
63
+ } catch {
64
+ }
65
+ };
66
+ signal.addEventListener("abort", abortHandler);
67
+ try {
68
+ while (true) {
69
+ const { done, value } = await reader.read();
70
+ if (done) break;
71
+ buffer += value;
72
+ buffer = buffer.replace(/\r\n?/g, "\n");
73
+ const chunks = buffer.split("\n\n");
74
+ buffer = chunks.pop() ?? "";
75
+ for (const chunk of chunks) {
76
+ const lines = chunk.split("\n");
77
+ const dataLines = [];
78
+ let eventName;
79
+ for (const line of lines) {
80
+ if (line.startsWith("data:")) {
81
+ dataLines.push(line.replace(/^data:\s*/, ""));
82
+ } else if (line.startsWith("event:")) {
83
+ eventName = line.replace(/^event:\s*/, "");
84
+ } else if (line.startsWith("id:")) {
85
+ lastEventId = line.replace(/^id:\s*/, "");
86
+ } else if (line.startsWith("retry:")) {
87
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
88
+ if (!Number.isNaN(parsed)) {
89
+ retryDelay = parsed;
90
+ }
91
+ }
92
+ }
93
+ let data;
94
+ let parsedJson = false;
95
+ if (dataLines.length) {
96
+ const rawData = dataLines.join("\n");
97
+ try {
98
+ data = JSON.parse(rawData);
99
+ parsedJson = true;
100
+ } catch {
101
+ data = rawData;
102
+ }
103
+ }
104
+ if (parsedJson) {
105
+ if (responseValidator) {
106
+ await responseValidator(data);
107
+ }
108
+ if (responseTransformer) {
109
+ data = await responseTransformer(data);
110
+ }
111
+ }
112
+ onSseEvent?.({
113
+ data,
114
+ event: eventName,
115
+ id: lastEventId,
116
+ retry: retryDelay
117
+ });
118
+ if (dataLines.length) {
119
+ yield data;
120
+ }
121
+ }
122
+ }
123
+ } finally {
124
+ signal.removeEventListener("abort", abortHandler);
125
+ reader.releaseLock();
126
+ }
127
+ break;
128
+ } catch (error) {
129
+ onSseError?.(error);
130
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
131
+ break;
132
+ }
133
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
134
+ await sleep(backoff);
135
+ }
136
+ }
137
+ };
138
+ const stream = createStream();
139
+ return { stream };
140
+ }
141
+
142
+ // generated/core/pathSerializer.gen.ts
143
+ var separatorArrayExplode = (style) => {
144
+ switch (style) {
145
+ case "label":
146
+ return ".";
147
+ case "matrix":
148
+ return ";";
149
+ case "simple":
150
+ return ",";
151
+ default:
152
+ return "&";
153
+ }
154
+ };
155
+ var separatorArrayNoExplode = (style) => {
156
+ switch (style) {
157
+ case "form":
158
+ return ",";
159
+ case "pipeDelimited":
160
+ return "|";
161
+ case "spaceDelimited":
162
+ return "%20";
163
+ default:
164
+ return ",";
165
+ }
166
+ };
167
+ var separatorObjectExplode = (style) => {
168
+ switch (style) {
169
+ case "label":
170
+ return ".";
171
+ case "matrix":
172
+ return ";";
173
+ case "simple":
174
+ return ",";
175
+ default:
176
+ return "&";
177
+ }
178
+ };
179
+ var serializeArrayParam = ({
180
+ allowReserved,
181
+ explode,
182
+ name,
183
+ style,
184
+ value
185
+ }) => {
186
+ if (!explode) {
187
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
188
+ switch (style) {
189
+ case "label":
190
+ return `.${joinedValues2}`;
191
+ case "matrix":
192
+ return `;${name}=${joinedValues2}`;
193
+ case "simple":
194
+ return joinedValues2;
195
+ default:
196
+ return `${name}=${joinedValues2}`;
197
+ }
198
+ }
199
+ const separator = separatorArrayExplode(style);
200
+ const joinedValues = value.map((v) => {
201
+ if (style === "label" || style === "simple") {
202
+ return allowReserved ? v : encodeURIComponent(v);
203
+ }
204
+ return serializePrimitiveParam({
205
+ allowReserved,
206
+ name,
207
+ value: v
208
+ });
209
+ }).join(separator);
210
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
211
+ };
212
+ var serializePrimitiveParam = ({
213
+ allowReserved,
214
+ name,
215
+ value
216
+ }) => {
217
+ if (value === void 0 || value === null) {
218
+ return "";
219
+ }
220
+ if (typeof value === "object") {
221
+ throw new Error(
222
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
223
+ );
224
+ }
225
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
226
+ };
227
+ var serializeObjectParam = ({
228
+ allowReserved,
229
+ explode,
230
+ name,
231
+ style,
232
+ value,
233
+ valueOnly
234
+ }) => {
235
+ if (value instanceof Date) {
236
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
237
+ }
238
+ if (style !== "deepObject" && !explode) {
239
+ let values = [];
240
+ Object.entries(value).forEach(([key, v]) => {
241
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
242
+ });
243
+ const joinedValues2 = values.join(",");
244
+ switch (style) {
245
+ case "form":
246
+ return `${name}=${joinedValues2}`;
247
+ case "label":
248
+ return `.${joinedValues2}`;
249
+ case "matrix":
250
+ return `;${name}=${joinedValues2}`;
251
+ default:
252
+ return joinedValues2;
253
+ }
254
+ }
255
+ const separator = separatorObjectExplode(style);
256
+ const joinedValues = Object.entries(value).map(
257
+ ([key, v]) => serializePrimitiveParam({
258
+ allowReserved,
259
+ name: style === "deepObject" ? `${name}[${key}]` : key,
260
+ value: v
261
+ })
262
+ ).join(separator);
263
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
264
+ };
265
+
266
+ // generated/core/utils.gen.ts
267
+ function getValidRequestBody(options) {
268
+ const hasBody = options.body !== void 0;
269
+ const isSerializedBody = hasBody && options.bodySerializer;
270
+ if (isSerializedBody) {
271
+ if ("serializedBody" in options) {
272
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
273
+ return hasSerializedBody ? options.serializedBody : null;
274
+ }
275
+ return options.body !== "" ? options.body : null;
276
+ }
277
+ if (hasBody) {
278
+ return options.body;
279
+ }
280
+ return void 0;
281
+ }
282
+
283
+ // generated/core/auth.gen.ts
284
+ var getAuthToken = async (auth, callback) => {
285
+ const token = typeof callback === "function" ? await callback(auth) : callback;
286
+ if (!token) {
287
+ return;
288
+ }
289
+ if (auth.scheme === "bearer") {
290
+ return `Bearer ${token}`;
291
+ }
292
+ if (auth.scheme === "basic") {
293
+ return `Basic ${btoa(token)}`;
294
+ }
295
+ return token;
296
+ };
297
+
298
+ // generated/client/utils.gen.ts
299
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
300
+ var defaultPathSerializer = ({ path, url: _url }) => {
301
+ let url = _url;
302
+ const matches = _url.match(PATH_PARAM_RE);
303
+ if (matches) {
304
+ for (const match of matches) {
305
+ let explode = false;
306
+ let name = match.substring(1, match.length - 1);
307
+ let style = "simple";
308
+ if (name.endsWith("*")) {
309
+ explode = true;
310
+ name = name.substring(0, name.length - 1);
311
+ }
312
+ if (name.startsWith(".")) {
313
+ name = name.substring(1);
314
+ style = "label";
315
+ } else if (name.startsWith(";")) {
316
+ name = name.substring(1);
317
+ style = "matrix";
318
+ }
319
+ const value = path[name];
320
+ if (value === void 0 || value === null) {
321
+ continue;
322
+ }
323
+ if (Array.isArray(value)) {
324
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
325
+ continue;
326
+ }
327
+ if (typeof value === "object") {
328
+ url = url.replace(
329
+ match,
330
+ serializeObjectParam({
331
+ explode,
332
+ name,
333
+ style,
334
+ value,
335
+ valueOnly: true
336
+ })
337
+ );
338
+ continue;
339
+ }
340
+ if (style === "matrix") {
341
+ url = url.replace(
342
+ match,
343
+ `;${serializePrimitiveParam({
344
+ name,
345
+ value
346
+ })}`
347
+ );
348
+ continue;
349
+ }
350
+ const replaceValue = encodeURIComponent(
351
+ style === "label" ? `.${value}` : value
352
+ );
353
+ url = url.replace(match, replaceValue);
354
+ }
355
+ }
356
+ return url;
357
+ };
358
+ var createQuerySerializer = ({
359
+ parameters = {},
360
+ ...args
361
+ } = {}) => {
362
+ const querySerializer = (queryParams) => {
363
+ const search = [];
364
+ if (queryParams && typeof queryParams === "object") {
365
+ for (const name in queryParams) {
366
+ const value = queryParams[name];
367
+ if (value === void 0 || value === null) {
368
+ continue;
369
+ }
370
+ const options = parameters[name] || args;
371
+ if (Array.isArray(value)) {
372
+ const serializedArray = serializeArrayParam({
373
+ allowReserved: options.allowReserved,
374
+ explode: true,
375
+ name,
376
+ style: "form",
377
+ value,
378
+ ...options.array
379
+ });
380
+ if (serializedArray) search.push(serializedArray);
381
+ } else if (typeof value === "object") {
382
+ const serializedObject = serializeObjectParam({
383
+ allowReserved: options.allowReserved,
384
+ explode: true,
385
+ name,
386
+ style: "deepObject",
387
+ value,
388
+ ...options.object
389
+ });
390
+ if (serializedObject) search.push(serializedObject);
391
+ } else {
392
+ const serializedPrimitive = serializePrimitiveParam({
393
+ allowReserved: options.allowReserved,
394
+ name,
395
+ value
396
+ });
397
+ if (serializedPrimitive) search.push(serializedPrimitive);
398
+ }
399
+ }
400
+ }
401
+ return search.join("&");
402
+ };
403
+ return querySerializer;
404
+ };
405
+ var getParseAs = (contentType) => {
406
+ if (!contentType) {
407
+ return "stream";
408
+ }
409
+ const cleanContent = contentType.split(";")[0]?.trim();
410
+ if (!cleanContent) {
411
+ return;
412
+ }
413
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
414
+ return "json";
415
+ }
416
+ if (cleanContent === "multipart/form-data") {
417
+ return "formData";
418
+ }
419
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
420
+ return "blob";
421
+ }
422
+ if (cleanContent.startsWith("text/")) {
423
+ return "text";
424
+ }
425
+ return;
426
+ };
427
+ var checkForExistence = (options, name) => {
428
+ if (!name) {
429
+ return false;
430
+ }
431
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
432
+ return true;
433
+ }
434
+ return false;
435
+ };
436
+ async function setAuthParams(options) {
437
+ for (const auth of options.security ?? []) {
438
+ if (checkForExistence(options, auth.name)) {
439
+ continue;
440
+ }
441
+ const token = await getAuthToken(auth, options.auth);
442
+ if (!token) {
443
+ continue;
444
+ }
445
+ const name = auth.name ?? "Authorization";
446
+ switch (auth.in) {
447
+ case "query":
448
+ if (!options.query) {
449
+ options.query = {};
450
+ }
451
+ options.query[name] = token;
452
+ break;
453
+ case "cookie":
454
+ options.headers.append("Cookie", `${name}=${token}`);
455
+ break;
456
+ case "header":
457
+ default:
458
+ options.headers.set(name, token);
459
+ break;
460
+ }
461
+ }
462
+ }
463
+ var buildUrl = (options) => {
464
+ const url = getUrl({
465
+ baseUrl: options.baseUrl,
466
+ path: options.path,
467
+ query: options.query,
468
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
469
+ url: options.url
470
+ });
471
+ return url;
472
+ };
473
+ var getUrl = ({
474
+ baseUrl,
475
+ path,
476
+ query,
477
+ querySerializer,
478
+ url: _url
479
+ }) => {
480
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
481
+ let url = (baseUrl ?? "") + pathUrl;
482
+ if (path) {
483
+ url = defaultPathSerializer({ path, url });
484
+ }
485
+ let search = query ? querySerializer(query) : "";
486
+ if (search.startsWith("?")) {
487
+ search = search.substring(1);
488
+ }
489
+ if (search) {
490
+ url += `?${search}`;
491
+ }
492
+ return url;
493
+ };
494
+ var mergeConfigs = (a, b) => {
495
+ const config = { ...a, ...b };
496
+ if (config.baseUrl?.endsWith("/")) {
497
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
498
+ }
499
+ config.headers = mergeHeaders(a.headers, b.headers);
500
+ return config;
501
+ };
502
+ var headersEntries = (headers) => {
503
+ const entries = [];
504
+ headers.forEach((value, key) => {
505
+ entries.push([key, value]);
506
+ });
507
+ return entries;
508
+ };
509
+ var mergeHeaders = (...headers) => {
510
+ const mergedHeaders = new Headers();
511
+ for (const header of headers) {
512
+ if (!header || typeof header !== "object") {
513
+ continue;
514
+ }
515
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
516
+ for (const [key, value] of iterator) {
517
+ if (value === null) {
518
+ mergedHeaders.delete(key);
519
+ } else if (Array.isArray(value)) {
520
+ for (const v of value) {
521
+ mergedHeaders.append(key, v);
522
+ }
523
+ } else if (value !== void 0) {
524
+ mergedHeaders.set(
525
+ key,
526
+ typeof value === "object" ? JSON.stringify(value) : value
527
+ );
528
+ }
529
+ }
530
+ }
531
+ return mergedHeaders;
532
+ };
533
+ var Interceptors = class {
534
+ fns = [];
535
+ clear() {
536
+ this.fns = [];
537
+ }
538
+ eject(id) {
539
+ const index = this.getInterceptorIndex(id);
540
+ if (this.fns[index]) {
541
+ this.fns[index] = null;
542
+ }
543
+ }
544
+ exists(id) {
545
+ const index = this.getInterceptorIndex(id);
546
+ return Boolean(this.fns[index]);
547
+ }
548
+ getInterceptorIndex(id) {
549
+ if (typeof id === "number") {
550
+ return this.fns[id] ? id : -1;
551
+ }
552
+ return this.fns.indexOf(id);
553
+ }
554
+ update(id, fn) {
555
+ const index = this.getInterceptorIndex(id);
556
+ if (this.fns[index]) {
557
+ this.fns[index] = fn;
558
+ return id;
559
+ }
560
+ return false;
561
+ }
562
+ use(fn) {
563
+ this.fns.push(fn);
564
+ return this.fns.length - 1;
565
+ }
566
+ };
567
+ var createInterceptors = () => ({
568
+ error: new Interceptors(),
569
+ request: new Interceptors(),
570
+ response: new Interceptors()
571
+ });
572
+ var defaultQuerySerializer = createQuerySerializer({
573
+ allowReserved: false,
574
+ array: {
575
+ explode: true,
576
+ style: "form"
577
+ },
578
+ object: {
579
+ explode: true,
580
+ style: "deepObject"
581
+ }
582
+ });
583
+ var defaultHeaders = {
584
+ "Content-Type": "application/json"
585
+ };
586
+ var createConfig = (override = {}) => ({
587
+ ...jsonBodySerializer,
588
+ headers: defaultHeaders,
589
+ parseAs: "auto",
590
+ querySerializer: defaultQuerySerializer,
591
+ ...override
592
+ });
593
+
594
+ // generated/client/client.gen.ts
595
+ var createClient = (config = {}) => {
596
+ let _config = mergeConfigs(createConfig(), config);
597
+ const getConfig = () => ({ ..._config });
598
+ const setConfig = (config2) => {
599
+ _config = mergeConfigs(_config, config2);
600
+ return getConfig();
601
+ };
602
+ const interceptors = createInterceptors();
603
+ const beforeRequest = async (options) => {
604
+ const opts = {
605
+ ..._config,
606
+ ...options,
607
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
608
+ headers: mergeHeaders(_config.headers, options.headers),
609
+ serializedBody: void 0
610
+ };
611
+ if (opts.security) {
612
+ await setAuthParams(opts);
613
+ }
614
+ if (opts.requestValidator) {
615
+ await opts.requestValidator(opts);
616
+ }
617
+ if (opts.body !== void 0 && opts.bodySerializer) {
618
+ opts.serializedBody = opts.bodySerializer(opts.body);
619
+ }
620
+ if (opts.body === void 0 || opts.serializedBody === "") {
621
+ opts.headers.delete("Content-Type");
622
+ }
623
+ const resolvedOpts = opts;
624
+ const url = buildUrl(resolvedOpts);
625
+ return { opts: resolvedOpts, url };
626
+ };
627
+ const request = async (options) => {
628
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
629
+ let response;
630
+ try {
631
+ const { opts, url } = await beforeRequest(options);
632
+ for (const fn of interceptors.request.fns) {
633
+ if (fn) {
634
+ await fn(opts);
635
+ }
636
+ }
637
+ const _fetch = opts.fetch;
638
+ const requestInit = {
639
+ ...opts,
640
+ body: getValidRequestBody(opts)
641
+ };
642
+ response = await _fetch(url, requestInit);
643
+ for (const fn of interceptors.response.fns) {
644
+ if (fn) {
645
+ response = await fn(response, opts);
646
+ }
647
+ }
648
+ const result = {
649
+ response
650
+ };
651
+ if (response.ok) {
652
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
653
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
654
+ let emptyData;
655
+ switch (parseAs) {
656
+ case "arrayBuffer":
657
+ case "blob":
658
+ case "text":
659
+ emptyData = await response[parseAs]();
660
+ break;
661
+ case "formData":
662
+ emptyData = new FormData();
663
+ break;
664
+ case "stream":
665
+ emptyData = response.body;
666
+ break;
667
+ case "json":
668
+ default:
669
+ emptyData = {};
670
+ break;
671
+ }
672
+ return {
673
+ data: emptyData,
674
+ ...result
675
+ };
676
+ }
677
+ let data;
678
+ switch (parseAs) {
679
+ case "arrayBuffer":
680
+ case "blob":
681
+ case "formData":
682
+ case "text":
683
+ data = await response[parseAs]();
684
+ break;
685
+ case "json": {
686
+ const text = await response.text();
687
+ data = text ? JSON.parse(text) : {};
688
+ break;
689
+ }
690
+ case "stream":
691
+ return {
692
+ data: response.body,
693
+ ...result
694
+ };
695
+ }
696
+ if (parseAs === "json") {
697
+ if (opts.responseValidator) {
698
+ await opts.responseValidator(data);
699
+ }
700
+ if (opts.responseTransformer) {
701
+ data = await opts.responseTransformer(data);
702
+ }
703
+ }
704
+ return {
705
+ data,
706
+ ...result
707
+ };
708
+ }
709
+ const textError = await response.text();
710
+ let jsonError;
711
+ try {
712
+ jsonError = JSON.parse(textError);
713
+ } catch {
714
+ }
715
+ throw jsonError ?? textError;
716
+ } catch (error) {
717
+ let finalError = error;
718
+ for (const fn of interceptors.error.fns) {
719
+ if (fn) {
720
+ finalError = await fn(finalError, response, options);
721
+ }
722
+ }
723
+ finalError = finalError || {};
724
+ if (throwOnError) {
725
+ throw finalError;
726
+ }
727
+ return {
728
+ error: finalError,
729
+ response
730
+ };
731
+ }
732
+ };
733
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
734
+ const makeSseFn = (method) => async (options) => {
735
+ const { opts, url } = await beforeRequest(options);
736
+ return createSseClient({
737
+ ...opts,
738
+ body: opts.body,
739
+ method,
740
+ onRequest: async (url2, init) => {
741
+ let request2 = new Request(url2, init);
742
+ const requestInit = { ...init, url: url2 };
743
+ for (const fn of interceptors.request.fns) {
744
+ if (fn) {
745
+ await fn(requestInit);
746
+ request2 = new Request(requestInit.url, requestInit);
747
+ }
748
+ }
749
+ return request2;
750
+ },
751
+ serializedBody: getValidRequestBody(opts),
752
+ url
753
+ });
754
+ };
755
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
756
+ return {
757
+ buildUrl: _buildUrl,
758
+ connect: makeMethodFn("CONNECT"),
759
+ delete: makeMethodFn("DELETE"),
760
+ get: makeMethodFn("GET"),
761
+ getConfig,
762
+ head: makeMethodFn("HEAD"),
763
+ interceptors,
764
+ options: makeMethodFn("OPTIONS"),
765
+ patch: makeMethodFn("PATCH"),
766
+ post: makeMethodFn("POST"),
767
+ put: makeMethodFn("PUT"),
768
+ request,
769
+ setConfig,
770
+ sse: {
771
+ connect: makeSseFn("CONNECT"),
772
+ delete: makeSseFn("DELETE"),
773
+ get: makeSseFn("GET"),
774
+ head: makeSseFn("HEAD"),
775
+ options: makeSseFn("OPTIONS"),
776
+ patch: makeSseFn("PATCH"),
777
+ post: makeSseFn("POST"),
778
+ put: makeSseFn("PUT"),
779
+ trace: makeSseFn("TRACE")
780
+ },
781
+ trace: makeMethodFn("TRACE")
782
+ };
783
+ };
784
+
785
+ // generated/client.gen.ts
786
+ var client = createClient(createConfig({ baseUrl: "http://localhost:3002" }));
787
+
788
+ // generated/sdk.gen.ts
789
+ var getHealth = (options) => (options?.client ?? client).get({ url: "/api/v1/health", ...options });
790
+ var listRegions = (options) => (options?.client ?? client).get({ url: "/api/v1/regions", ...options });
791
+ var getUser = (options) => (options?.client ?? client).get({
792
+ security: [{ scheme: "bearer", type: "http" }],
793
+ url: "/api/v1/user",
794
+ ...options
795
+ });
796
+ var getUserPreferences = (options) => (options?.client ?? client).get({
797
+ security: [{ scheme: "bearer", type: "http" }],
798
+ url: "/api/v1/user/preferences",
799
+ ...options
800
+ });
801
+ var updateUserPreferences = (options) => (options.client ?? client).patch({
802
+ security: [{ scheme: "bearer", type: "http" }],
803
+ url: "/api/v1/user/preferences",
804
+ ...options,
805
+ headers: {
806
+ "Content-Type": "application/json",
807
+ ...options.headers
808
+ }
809
+ });
810
+ var listOrganizations = (options) => (options?.client ?? client).get({
811
+ security: [{ scheme: "bearer", type: "http" }],
812
+ url: "/api/v1/organizations",
813
+ ...options
814
+ });
815
+ var setActiveOrganization = (options) => (options.client ?? client).patch({
816
+ security: [{ scheme: "bearer", type: "http" }],
817
+ url: "/api/v1/organizations",
818
+ ...options,
819
+ headers: {
820
+ "Content-Type": "application/json",
821
+ ...options.headers
822
+ }
823
+ });
824
+ var createOrganization = (options) => (options.client ?? client).post({
825
+ security: [{ scheme: "bearer", type: "http" }],
826
+ url: "/api/v1/organizations",
827
+ ...options,
828
+ headers: {
829
+ "Content-Type": "application/json",
830
+ ...options.headers
831
+ }
832
+ });
833
+ var getTeamSettings = (options) => (options?.client ?? client).get({
834
+ security: [{ scheme: "bearer", type: "http" }],
835
+ url: "/api/v1/organizations/settings",
836
+ ...options
837
+ });
838
+ var updateTeamSettings = (options) => (options.client ?? client).patch({
839
+ security: [{ scheme: "bearer", type: "http" }],
840
+ url: "/api/v1/organizations/settings",
841
+ ...options,
842
+ headers: {
843
+ "Content-Type": "application/json",
844
+ ...options.headers
845
+ }
846
+ });
847
+ var listProjects = (options) => (options?.client ?? client).get({
848
+ security: [{ scheme: "bearer", type: "http" }],
849
+ url: "/api/v1/projects",
850
+ ...options
851
+ });
852
+ var createProject = (options) => (options.client ?? client).post({
853
+ security: [{ scheme: "bearer", type: "http" }],
854
+ url: "/api/v1/projects",
855
+ ...options,
856
+ headers: {
857
+ "Content-Type": "application/json",
858
+ ...options.headers
859
+ }
860
+ });
861
+ var deleteProject = (options) => (options.client ?? client).delete({
862
+ security: [{ scheme: "bearer", type: "http" }],
863
+ url: "/api/v1/projects/{projectId}",
864
+ ...options
865
+ });
866
+ var getProject = (options) => (options.client ?? client).get({
867
+ security: [{ scheme: "bearer", type: "http" }],
868
+ url: "/api/v1/projects/{projectId}",
869
+ ...options
870
+ });
871
+ var updateProject = (options) => (options.client ?? client).patch({
872
+ security: [{ scheme: "bearer", type: "http" }],
873
+ url: "/api/v1/projects/{projectId}",
874
+ ...options,
875
+ headers: {
876
+ "Content-Type": "application/json",
877
+ ...options.headers
878
+ }
879
+ });
880
+ var getProjectSettings = (options) => (options.client ?? client).get({
881
+ security: [{ scheme: "bearer", type: "http" }],
882
+ url: "/api/v1/projects/{projectId}/settings",
883
+ ...options
884
+ });
885
+ var updateProjectSettings = (options) => (options.client ?? client).patch({
886
+ security: [{ scheme: "bearer", type: "http" }],
887
+ url: "/api/v1/projects/{projectId}/settings",
888
+ ...options,
889
+ headers: {
890
+ "Content-Type": "application/json",
891
+ ...options.headers
892
+ }
893
+ });
894
+ var listBuilds = (options) => (options?.client ?? client).get({
895
+ security: [{ scheme: "bearer", type: "http" }],
896
+ url: "/api/v1/builds",
897
+ ...options
898
+ });
899
+ var createBuild = (options) => (options.client ?? client).post({
900
+ security: [{ scheme: "bearer", type: "http" }],
901
+ url: "/api/v1/builds",
902
+ ...options,
903
+ headers: {
904
+ "Content-Type": "application/json",
905
+ ...options.headers
906
+ }
907
+ });
908
+ var listDeployments = (options) => (options?.client ?? client).get({
909
+ security: [{ scheme: "bearer", type: "http" }],
910
+ url: "/api/v1/deployments",
911
+ ...options
912
+ });
913
+ var createDeployment = (options) => (options.client ?? client).post({
914
+ security: [{ scheme: "bearer", type: "http" }],
915
+ url: "/api/v1/deployments",
916
+ ...options,
917
+ headers: {
918
+ "Content-Type": "application/json",
919
+ ...options.headers
920
+ }
921
+ });
922
+ var deleteDeployment = (options) => (options.client ?? client).delete({
923
+ security: [{ scheme: "bearer", type: "http" }],
924
+ url: "/api/v1/deployments/{deploymentId}",
925
+ ...options
926
+ });
927
+ var getDeployment = (options) => (options.client ?? client).get({
928
+ security: [{ scheme: "bearer", type: "http" }],
929
+ url: "/api/v1/deployments/{deploymentId}",
930
+ ...options
931
+ });
932
+ var updateDeployment = (options) => (options.client ?? client).patch({
933
+ security: [{ scheme: "bearer", type: "http" }],
934
+ url: "/api/v1/deployments/{deploymentId}",
935
+ ...options,
936
+ headers: {
937
+ "Content-Type": "application/json",
938
+ ...options.headers
939
+ }
940
+ });
941
+
942
+ // index.ts
943
+ var DEFAULT_BASE_URL = "https://api.meshscale.cloud";
944
+ var ORGANIZATION_HEADER = "X-MeshScale-Organization";
945
+ function createMeshScaleClient({
946
+ organizationId: initialOrganizationId = null,
947
+ ...options
948
+ } = {}) {
949
+ const transport = createClient({
950
+ baseUrl: DEFAULT_BASE_URL,
951
+ ...options
952
+ });
953
+ let organizationId = initialOrganizationId;
954
+ transport.interceptors.request.use((request) => {
955
+ if (organizationId && !request.headers.has(ORGANIZATION_HEADER)) {
956
+ request.headers.set(ORGANIZATION_HEADER, organizationId);
957
+ }
958
+ });
959
+ return {
960
+ getOrganization: () => organizationId,
961
+ setOrganization: (id) => {
962
+ organizationId = id;
963
+ },
964
+ health: {
965
+ get: (requestOptions) => getHealth({ ...requestOptions, client: transport })
966
+ },
967
+ deployments: {
968
+ list: (requestOptions) => listDeployments({ ...requestOptions, client: transport }),
969
+ create: (requestOptions) => createDeployment({ ...requestOptions, client: transport }),
970
+ get: (requestOptions) => getDeployment({ ...requestOptions, client: transport }),
971
+ update: (requestOptions) => updateDeployment({ ...requestOptions, client: transport }),
972
+ delete: (requestOptions) => deleteDeployment({ ...requestOptions, client: transport })
973
+ },
974
+ builds: {
975
+ list: (requestOptions) => listBuilds({ ...requestOptions, client: transport }),
976
+ create: (requestOptions) => createBuild({ ...requestOptions, client: transport })
977
+ },
978
+ organizations: {
979
+ list: (requestOptions) => listOrganizations({ ...requestOptions, client: transport }),
980
+ create: (requestOptions) => createOrganization({ ...requestOptions, client: transport }),
981
+ setActive: (requestOptions) => setActiveOrganization({ ...requestOptions, client: transport }),
982
+ settings: {
983
+ get: (requestOptions) => getTeamSettings({ ...requestOptions, client: transport }),
984
+ update: (requestOptions) => updateTeamSettings({ ...requestOptions, client: transport })
985
+ }
986
+ },
987
+ projects: {
988
+ list: (requestOptions) => listProjects({ ...requestOptions, client: transport }),
989
+ create: (requestOptions) => createProject({ ...requestOptions, client: transport }),
990
+ get: (requestOptions) => getProject({ ...requestOptions, client: transport }),
991
+ update: (requestOptions) => updateProject({ ...requestOptions, client: transport }),
992
+ delete: (requestOptions) => deleteProject({ ...requestOptions, client: transport }),
993
+ settings: {
994
+ get: (requestOptions) => getProjectSettings({ ...requestOptions, client: transport }),
995
+ update: (requestOptions) => updateProjectSettings({ ...requestOptions, client: transport })
996
+ }
997
+ },
998
+ regions: {
999
+ list: (requestOptions) => listRegions({ ...requestOptions, client: transport })
1000
+ },
1001
+ user: {
1002
+ get: (requestOptions) => getUser({ ...requestOptions, client: transport }),
1003
+ preferences: {
1004
+ get: (requestOptions) => getUserPreferences({ ...requestOptions, client: transport }),
1005
+ update: (requestOptions) => updateUserPreferences({ ...requestOptions, client: transport })
1006
+ }
1007
+ }
1008
+ };
1009
+ }
1010
+ export {
1011
+ ORGANIZATION_HEADER,
1012
+ createMeshScaleClient
1013
+ };