@eudiplo/sdk-core 1.14.0-main.4e97beb → 1.14.0-main.51fa8d2

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.
@@ -1,5 +1,5 @@
1
1
  // src/api/core/serverSentEvents.gen.ts
2
- var createSseClient = ({
2
+ function createSseClient({
3
3
  onRequest,
4
4
  onSseError,
5
5
  onSseEvent,
@@ -11,7 +11,7 @@ var createSseClient = ({
11
11
  sseSleepFn,
12
12
  url,
13
13
  ...options
14
- }) => {
14
+ }) {
15
15
  let lastEventId;
16
16
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
17
17
  const createStream = async function* () {
@@ -39,10 +39,7 @@ var createSseClient = ({
39
39
  }
40
40
  const _fetch = options.fetch ?? globalThis.fetch;
41
41
  const response = await _fetch(request);
42
- if (!response.ok)
43
- throw new Error(
44
- `SSE failed: ${response.status} ${response.statusText}`
45
- );
42
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
46
43
  if (!response.body) throw new Error("No body in SSE response");
47
44
  const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
48
45
  let buffer = "";
@@ -58,7 +55,7 @@ var createSseClient = ({
58
55
  const { done, value } = await reader.read();
59
56
  if (done) break;
60
57
  buffer += value;
61
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
58
+ buffer = buffer.replace(/\r\n?/g, "\n");
62
59
  const chunks = buffer.split("\n\n");
63
60
  buffer = chunks.pop() ?? "";
64
61
  for (const chunk of chunks) {
@@ -73,10 +70,7 @@ var createSseClient = ({
73
70
  } else if (line.startsWith("id:")) {
74
71
  lastEventId = line.replace(/^id:\s*/, "");
75
72
  } else if (line.startsWith("retry:")) {
76
- const parsed = Number.parseInt(
77
- line.replace(/^retry:\s*/, ""),
78
- 10
79
- );
73
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
80
74
  if (!Number.isNaN(parsed)) {
81
75
  retryDelay = parsed;
82
76
  }
@@ -122,17 +116,14 @@ var createSseClient = ({
122
116
  if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
123
117
  break;
124
118
  }
125
- const backoff = Math.min(
126
- retryDelay * 2 ** (attempt - 1),
127
- sseMaxRetryDelay ?? 3e4
128
- );
119
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
129
120
  await sleep(backoff);
130
121
  }
131
122
  }
132
123
  };
133
124
  const stream = createStream();
134
125
  return { stream };
135
- };
126
+ }
136
127
 
137
128
  // src/api/core/pathSerializer.gen.ts
138
129
  var separatorArrayExplode = (style) => {
@@ -233,11 +224,7 @@ var serializeObjectParam = ({
233
224
  if (style !== "deepObject" && !explode) {
234
225
  let values = [];
235
226
  Object.entries(value).forEach(([key, v]) => {
236
- values = [
237
- ...values,
238
- key,
239
- allowReserved ? v : encodeURIComponent(v)
240
- ];
227
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
241
228
  });
242
229
  const joinedValues2 = values.join(",");
243
230
  switch (style) {
@@ -288,10 +275,7 @@ var defaultPathSerializer = ({ path, url: _url }) => {
288
275
  continue;
289
276
  }
290
277
  if (Array.isArray(value)) {
291
- url = url.replace(
292
- match,
293
- serializeArrayParam({ explode, name, style, value })
294
- );
278
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
295
279
  continue;
296
280
  }
297
281
  if (typeof value === "object") {
@@ -379,10 +363,7 @@ var getAuthToken = async (auth, callback) => {
379
363
 
380
364
  // src/api/core/bodySerializer.gen.ts
381
365
  var jsonBodySerializer = {
382
- bodySerializer: (body) => JSON.stringify(
383
- body,
384
- (_key, value) => typeof value === "bigint" ? value.toString() : value
385
- )
366
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
386
367
  };
387
368
 
388
369
  // src/api/client/utils.gen.ts
@@ -447,9 +428,7 @@ var getParseAs = (contentType) => {
447
428
  if (cleanContent === "multipart/form-data") {
448
429
  return "formData";
449
430
  }
450
- if (["application/", "audio/", "image/", "video/"].some(
451
- (type) => cleanContent.startsWith(type)
452
- )) {
431
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
453
432
  return "blob";
454
433
  }
455
434
  if (cleanContent.startsWith("text/")) {
@@ -635,136 +614,121 @@ var createClient = (config = {}) => {
635
614
  if (opts.body === void 0 || opts.serializedBody === "") {
636
615
  opts.headers.delete("Content-Type");
637
616
  }
638
- const url = buildUrl(opts);
639
- return { opts, url };
617
+ const resolvedOpts = opts;
618
+ const url = buildUrl(resolvedOpts);
619
+ return { opts: resolvedOpts, url };
640
620
  };
641
621
  const request = async (options) => {
642
- const { opts, url } = await beforeRequest(options);
643
- const requestInit = {
644
- redirect: "follow",
645
- ...opts,
646
- body: getValidRequestBody(opts)
647
- };
648
- let request2 = new Request(url, requestInit);
649
- for (const fn of interceptors.request.fns) {
650
- if (fn) {
651
- request2 = await fn(request2, opts);
652
- }
653
- }
654
- const _fetch = opts.fetch;
622
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
623
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
624
+ let request2;
655
625
  let response;
656
626
  try {
657
- response = await _fetch(request2);
658
- } catch (error2) {
659
- let finalError2 = error2;
660
- for (const fn of interceptors.error.fns) {
627
+ const { opts, url } = await beforeRequest(options);
628
+ const requestInit = {
629
+ redirect: "follow",
630
+ ...opts,
631
+ body: getValidRequestBody(opts)
632
+ };
633
+ request2 = new Request(url, requestInit);
634
+ for (const fn of interceptors.request.fns) {
661
635
  if (fn) {
662
- finalError2 = await fn(
663
- error2,
664
- void 0,
665
- request2,
666
- opts
667
- );
636
+ request2 = await fn(request2, opts);
668
637
  }
669
638
  }
670
- finalError2 = finalError2 || {};
671
- if (opts.throwOnError) {
672
- throw finalError2;
639
+ const _fetch = opts.fetch;
640
+ response = await _fetch(request2);
641
+ for (const fn of interceptors.response.fns) {
642
+ if (fn) {
643
+ response = await fn(response, request2, opts);
644
+ }
673
645
  }
674
- return opts.responseStyle === "data" ? void 0 : {
675
- error: finalError2,
646
+ const result = {
676
647
  request: request2,
677
- response: void 0
648
+ response
678
649
  };
679
- }
680
- for (const fn of interceptors.response.fns) {
681
- if (fn) {
682
- response = await fn(response, request2, opts);
683
- }
684
- }
685
- const result = {
686
- request: request2,
687
- response
688
- };
689
- if (response.ok) {
690
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
691
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
692
- let emptyData;
650
+ if (response.ok) {
651
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
652
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
653
+ let emptyData;
654
+ switch (parseAs) {
655
+ case "arrayBuffer":
656
+ case "blob":
657
+ case "text":
658
+ emptyData = await response[parseAs]();
659
+ break;
660
+ case "formData":
661
+ emptyData = new FormData();
662
+ break;
663
+ case "stream":
664
+ emptyData = response.body;
665
+ break;
666
+ case "json":
667
+ default:
668
+ emptyData = {};
669
+ break;
670
+ }
671
+ return opts.responseStyle === "data" ? emptyData : {
672
+ data: emptyData,
673
+ ...result
674
+ };
675
+ }
676
+ let data;
693
677
  switch (parseAs) {
694
678
  case "arrayBuffer":
695
679
  case "blob":
680
+ case "formData":
696
681
  case "text":
697
- emptyData = await response[parseAs]();
682
+ data = await response[parseAs]();
698
683
  break;
699
- case "formData":
700
- emptyData = new FormData();
684
+ case "json": {
685
+ const text = await response.text();
686
+ data = text ? JSON.parse(text) : {};
701
687
  break;
688
+ }
702
689
  case "stream":
703
- emptyData = response.body;
704
- break;
705
- case "json":
706
- default:
707
- emptyData = {};
708
- break;
690
+ return opts.responseStyle === "data" ? response.body : {
691
+ data: response.body,
692
+ ...result
693
+ };
709
694
  }
710
- return opts.responseStyle === "data" ? emptyData : {
711
- data: emptyData,
695
+ if (parseAs === "json") {
696
+ if (opts.responseValidator) {
697
+ await opts.responseValidator(data);
698
+ }
699
+ if (opts.responseTransformer) {
700
+ data = await opts.responseTransformer(data);
701
+ }
702
+ }
703
+ return opts.responseStyle === "data" ? data : {
704
+ data,
712
705
  ...result
713
706
  };
714
707
  }
715
- let data;
716
- switch (parseAs) {
717
- case "arrayBuffer":
718
- case "blob":
719
- case "formData":
720
- case "text":
721
- data = await response[parseAs]();
722
- break;
723
- case "json": {
724
- const text = await response.text();
725
- data = text ? JSON.parse(text) : {};
726
- break;
727
- }
728
- case "stream":
729
- return opts.responseStyle === "data" ? response.body : {
730
- data: response.body,
731
- ...result
732
- };
708
+ const textError = await response.text();
709
+ let jsonError;
710
+ try {
711
+ jsonError = JSON.parse(textError);
712
+ } catch {
733
713
  }
734
- if (parseAs === "json") {
735
- if (opts.responseValidator) {
736
- await opts.responseValidator(data);
737
- }
738
- if (opts.responseTransformer) {
739
- data = await opts.responseTransformer(data);
714
+ throw jsonError ?? textError;
715
+ } catch (error) {
716
+ let finalError = error;
717
+ for (const fn of interceptors.error.fns) {
718
+ if (fn) {
719
+ finalError = await fn(finalError, response, request2, options);
740
720
  }
741
721
  }
742
- return opts.responseStyle === "data" ? data : {
743
- data,
744
- ...result
745
- };
746
- }
747
- const textError = await response.text();
748
- let jsonError;
749
- try {
750
- jsonError = JSON.parse(textError);
751
- } catch {
752
- }
753
- const error = jsonError ?? textError;
754
- let finalError = error;
755
- for (const fn of interceptors.error.fns) {
756
- if (fn) {
757
- finalError = await fn(error, response, request2, opts);
722
+ finalError = finalError || {};
723
+ if (throwOnError) {
724
+ throw finalError;
758
725
  }
726
+ return responseStyle === "data" ? void 0 : {
727
+ error: finalError,
728
+ request: request2,
729
+ response
730
+ };
759
731
  }
760
- finalError = finalError || {};
761
- if (opts.throwOnError) {
762
- throw finalError;
763
- }
764
- return opts.responseStyle === "data" ? void 0 : {
765
- error: finalError,
766
- ...result
767
- };
768
732
  };
769
733
  const makeMethodFn = (method) => (options) => request({ ...options, method });
770
734
  const makeSseFn = (method) => async (options) => {
@@ -772,7 +736,6 @@ var createClient = (config = {}) => {
772
736
  return createSseClient({
773
737
  ...opts,
774
738
  body: opts.body,
775
- headers: opts.headers,
776
739
  method,
777
740
  onRequest: async (url2, init) => {
778
741
  let request2 = new Request(url2, init);
@@ -787,8 +750,9 @@ var createClient = (config = {}) => {
787
750
  url
788
751
  });
789
752
  };
753
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
790
754
  return {
791
- buildUrl,
755
+ buildUrl: _buildUrl,
792
756
  connect: makeMethodFn("CONNECT"),
793
757
  delete: makeMethodFn("DELETE"),
794
758
  get: makeMethodFn("GET"),
@@ -1,9 +1,9 @@
1
- export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-DDunhhsd.mjs';
1
+ export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-B0nhFpj5.mjs';
2
2
  export { createClient } from './client.gen.mjs';
3
3
 
4
- type Slot = "body" | "headers" | "path" | "query";
4
+ type Slot = 'body' | 'headers' | 'path' | 'query';
5
5
  type Field = {
6
- in: Exclude<Slot, "body">;
6
+ in: Exclude<Slot, 'body'>;
7
7
  /**
8
8
  * Field name. This is the name we want the user to see and use.
9
9
  */
@@ -14,7 +14,7 @@ type Field = {
14
14
  */
15
15
  map?: string;
16
16
  } | {
17
- in: Extract<Slot, "body">;
17
+ in: Extract<Slot, 'body'>;
18
18
  /**
19
19
  * Key isn't required for bodies.
20
20
  */
@@ -1,9 +1,9 @@
1
- export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-DDunhhsd.js';
1
+ export { A as Auth, C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, Q as QuerySerializerOptions, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape, g as createConfig, h as formDataBodySerializer, j as jsonBodySerializer, m as mergeHeaders, u as urlSearchParamsBodySerializer } from '../../types.gen-B0nhFpj5.js';
2
2
  export { createClient } from './client.gen.js';
3
3
 
4
- type Slot = "body" | "headers" | "path" | "query";
4
+ type Slot = 'body' | 'headers' | 'path' | 'query';
5
5
  type Field = {
6
- in: Exclude<Slot, "body">;
6
+ in: Exclude<Slot, 'body'>;
7
7
  /**
8
8
  * Field name. This is the name we want the user to see and use.
9
9
  */
@@ -14,7 +14,7 @@ type Field = {
14
14
  */
15
15
  map?: string;
16
16
  } | {
17
- in: Extract<Slot, "body">;
17
+ in: Extract<Slot, 'body'>;
18
18
  /**
19
19
  * Key isn't required for bodies.
20
20
  */