@shukka/sdk 0.0.0-stage → 0.1.1

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