@eudiplo/sdk-core 4.0.0 → 4.2.0

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,4 +1,4 @@
1
- import { b as Config, C as Client } from '../../types.gen-D8LjzWc0.mjs';
1
+ import { b as Config, C as Client } from '../../types.gen-DKrNRB-E.mjs';
2
2
 
3
3
  declare const createClient: (config?: Config) => Client;
4
4
 
@@ -1,4 +1,4 @@
1
- import { b as Config, C as Client } from '../../types.gen-D8LjzWc0.js';
1
+ import { b as Config, C as Client } from '../../types.gen-DKrNRB-E.js';
2
2
 
3
3
  declare const createClient: (config?: Config) => Client;
4
4
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/api/core/serverSentEvents.gen.ts
4
- var createSseClient = ({
4
+ function createSseClient({
5
5
  onRequest,
6
6
  onSseError,
7
7
  onSseEvent,
@@ -13,7 +13,7 @@ var createSseClient = ({
13
13
  sseSleepFn,
14
14
  url,
15
15
  ...options
16
- }) => {
16
+ }) {
17
17
  let lastEventId;
18
18
  const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
19
19
  const createStream = async function* () {
@@ -60,7 +60,7 @@ var createSseClient = ({
60
60
  const { done, value } = await reader.read();
61
61
  if (done) break;
62
62
  buffer += value;
63
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
63
+ buffer = buffer.replace(/\r\n?/g, "\n");
64
64
  const chunks = buffer.split("\n\n");
65
65
  buffer = chunks.pop() ?? "";
66
66
  for (const chunk of chunks) {
@@ -134,7 +134,7 @@ var createSseClient = ({
134
134
  };
135
135
  const stream = createStream();
136
136
  return { stream };
137
- };
137
+ }
138
138
 
139
139
  // src/api/core/pathSerializer.gen.ts
140
140
  var separatorArrayExplode = (style) => {
@@ -637,136 +637,126 @@ var createClient = (config = {}) => {
637
637
  if (opts.body === void 0 || opts.serializedBody === "") {
638
638
  opts.headers.delete("Content-Type");
639
639
  }
640
- const url = buildUrl(opts);
641
- return { opts, url };
640
+ const resolvedOpts = opts;
641
+ const url = buildUrl(resolvedOpts);
642
+ return { opts: resolvedOpts, url };
642
643
  };
643
644
  const request = async (options) => {
644
- const { opts, url } = await beforeRequest(options);
645
- const requestInit = {
646
- redirect: "follow",
647
- ...opts,
648
- body: getValidRequestBody(opts)
649
- };
650
- let request2 = new Request(url, requestInit);
651
- for (const fn of interceptors.request.fns) {
652
- if (fn) {
653
- request2 = await fn(request2, opts);
654
- }
655
- }
656
- const _fetch = opts.fetch;
645
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
646
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
647
+ let request2;
657
648
  let response;
658
649
  try {
659
- response = await _fetch(request2);
660
- } catch (error2) {
661
- let finalError2 = error2;
662
- for (const fn of interceptors.error.fns) {
650
+ const { opts, url } = await beforeRequest(options);
651
+ const requestInit = {
652
+ redirect: "follow",
653
+ ...opts,
654
+ body: getValidRequestBody(opts)
655
+ };
656
+ request2 = new Request(url, requestInit);
657
+ for (const fn of interceptors.request.fns) {
663
658
  if (fn) {
664
- finalError2 = await fn(
665
- error2,
666
- void 0,
667
- request2,
668
- opts
669
- );
659
+ request2 = await fn(request2, opts);
670
660
  }
671
661
  }
672
- finalError2 = finalError2 || {};
673
- if (opts.throwOnError) {
674
- throw finalError2;
662
+ const _fetch = opts.fetch;
663
+ response = await _fetch(request2);
664
+ for (const fn of interceptors.response.fns) {
665
+ if (fn) {
666
+ response = await fn(response, request2, opts);
667
+ }
675
668
  }
676
- return opts.responseStyle === "data" ? void 0 : {
677
- error: finalError2,
669
+ const result = {
678
670
  request: request2,
679
- response: void 0
671
+ response
680
672
  };
681
- }
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;
673
+ if (response.ok) {
674
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
675
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
676
+ let emptyData;
677
+ switch (parseAs) {
678
+ case "arrayBuffer":
679
+ case "blob":
680
+ case "text":
681
+ emptyData = await response[parseAs]();
682
+ break;
683
+ case "formData":
684
+ emptyData = new FormData();
685
+ break;
686
+ case "stream":
687
+ emptyData = response.body;
688
+ break;
689
+ case "json":
690
+ default:
691
+ emptyData = {};
692
+ break;
693
+ }
694
+ return opts.responseStyle === "data" ? emptyData : {
695
+ data: emptyData,
696
+ ...result
697
+ };
698
+ }
699
+ let data;
695
700
  switch (parseAs) {
696
701
  case "arrayBuffer":
697
702
  case "blob":
703
+ case "formData":
698
704
  case "text":
699
- emptyData = await response[parseAs]();
705
+ data = await response[parseAs]();
700
706
  break;
701
- case "formData":
702
- emptyData = new FormData();
707
+ case "json": {
708
+ const text = await response.text();
709
+ data = text ? JSON.parse(text) : {};
703
710
  break;
711
+ }
704
712
  case "stream":
705
- emptyData = response.body;
706
- break;
707
- case "json":
708
- default:
709
- emptyData = {};
710
- break;
713
+ return opts.responseStyle === "data" ? response.body : {
714
+ data: response.body,
715
+ ...result
716
+ };
717
+ }
718
+ if (parseAs === "json") {
719
+ if (opts.responseValidator) {
720
+ await opts.responseValidator(data);
721
+ }
722
+ if (opts.responseTransformer) {
723
+ data = await opts.responseTransformer(data);
724
+ }
711
725
  }
712
- return opts.responseStyle === "data" ? emptyData : {
713
- data: emptyData,
726
+ return opts.responseStyle === "data" ? data : {
727
+ data,
714
728
  ...result
715
729
  };
716
730
  }
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
- };
731
+ const textError = await response.text();
732
+ let jsonError;
733
+ try {
734
+ jsonError = JSON.parse(textError);
735
+ } catch {
735
736
  }
736
- if (parseAs === "json") {
737
- if (opts.responseValidator) {
738
- await opts.responseValidator(data);
739
- }
740
- if (opts.responseTransformer) {
741
- data = await opts.responseTransformer(data);
737
+ throw jsonError ?? textError;
738
+ } catch (error) {
739
+ let finalError = error;
740
+ for (const fn of interceptors.error.fns) {
741
+ if (fn) {
742
+ finalError = await fn(
743
+ finalError,
744
+ response,
745
+ request2,
746
+ options
747
+ );
742
748
  }
743
749
  }
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
- const error = jsonError ?? textError;
756
- let finalError = error;
757
- for (const fn of interceptors.error.fns) {
758
- if (fn) {
759
- finalError = await fn(error, response, request2, opts);
750
+ finalError = finalError || {};
751
+ if (throwOnError) {
752
+ throw finalError;
760
753
  }
754
+ return responseStyle === "data" ? void 0 : {
755
+ error: finalError,
756
+ request: request2,
757
+ response
758
+ };
761
759
  }
762
- finalError = finalError || {};
763
- if (opts.throwOnError) {
764
- throw finalError;
765
- }
766
- return opts.responseStyle === "data" ? void 0 : {
767
- error: finalError,
768
- ...result
769
- };
770
760
  };
771
761
  const makeMethodFn = (method) => (options) => request({ ...options, method });
772
762
  const makeSseFn = (method) => async (options) => {
@@ -774,7 +764,6 @@ var createClient = (config = {}) => {
774
764
  return createSseClient({
775
765
  ...opts,
776
766
  body: opts.body,
777
- headers: opts.headers,
778
767
  method,
779
768
  onRequest: async (url2, init) => {
780
769
  let request2 = new Request(url2, init);
@@ -789,8 +778,9 @@ var createClient = (config = {}) => {
789
778
  url
790
779
  });
791
780
  };
781
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
792
782
  return {
793
- buildUrl,
783
+ buildUrl: _buildUrl,
794
784
  connect: makeMethodFn("CONNECT"),
795
785
  delete: makeMethodFn("DELETE"),
796
786
  get: makeMethodFn("GET"),
@@ -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* () {
@@ -58,7 +58,7 @@ var createSseClient = ({
58
58
  const { done, value } = await reader.read();
59
59
  if (done) break;
60
60
  buffer += value;
61
- buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
61
+ buffer = buffer.replace(/\r\n?/g, "\n");
62
62
  const chunks = buffer.split("\n\n");
63
63
  buffer = chunks.pop() ?? "";
64
64
  for (const chunk of chunks) {
@@ -132,7 +132,7 @@ var createSseClient = ({
132
132
  };
133
133
  const stream = createStream();
134
134
  return { stream };
135
- };
135
+ }
136
136
 
137
137
  // src/api/core/pathSerializer.gen.ts
138
138
  var separatorArrayExplode = (style) => {
@@ -635,136 +635,126 @@ var createClient = (config = {}) => {
635
635
  if (opts.body === void 0 || opts.serializedBody === "") {
636
636
  opts.headers.delete("Content-Type");
637
637
  }
638
- const url = buildUrl(opts);
639
- return { opts, url };
638
+ const resolvedOpts = opts;
639
+ const url = buildUrl(resolvedOpts);
640
+ return { opts: resolvedOpts, url };
640
641
  };
641
642
  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;
643
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
644
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
645
+ let request2;
655
646
  let response;
656
647
  try {
657
- response = await _fetch(request2);
658
- } catch (error2) {
659
- let finalError2 = error2;
660
- for (const fn of interceptors.error.fns) {
648
+ const { opts, url } = await beforeRequest(options);
649
+ const requestInit = {
650
+ redirect: "follow",
651
+ ...opts,
652
+ body: getValidRequestBody(opts)
653
+ };
654
+ request2 = new Request(url, requestInit);
655
+ for (const fn of interceptors.request.fns) {
661
656
  if (fn) {
662
- finalError2 = await fn(
663
- error2,
664
- void 0,
665
- request2,
666
- opts
667
- );
657
+ request2 = await fn(request2, opts);
668
658
  }
669
659
  }
670
- finalError2 = finalError2 || {};
671
- if (opts.throwOnError) {
672
- throw finalError2;
660
+ const _fetch = opts.fetch;
661
+ response = await _fetch(request2);
662
+ for (const fn of interceptors.response.fns) {
663
+ if (fn) {
664
+ response = await fn(response, request2, opts);
665
+ }
673
666
  }
674
- return opts.responseStyle === "data" ? void 0 : {
675
- error: finalError2,
667
+ const result = {
676
668
  request: request2,
677
- response: void 0
669
+ response
678
670
  };
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;
671
+ if (response.ok) {
672
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
673
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
674
+ let emptyData;
675
+ switch (parseAs) {
676
+ case "arrayBuffer":
677
+ case "blob":
678
+ case "text":
679
+ emptyData = await response[parseAs]();
680
+ break;
681
+ case "formData":
682
+ emptyData = new FormData();
683
+ break;
684
+ case "stream":
685
+ emptyData = response.body;
686
+ break;
687
+ case "json":
688
+ default:
689
+ emptyData = {};
690
+ break;
691
+ }
692
+ return opts.responseStyle === "data" ? emptyData : {
693
+ data: emptyData,
694
+ ...result
695
+ };
696
+ }
697
+ let data;
693
698
  switch (parseAs) {
694
699
  case "arrayBuffer":
695
700
  case "blob":
701
+ case "formData":
696
702
  case "text":
697
- emptyData = await response[parseAs]();
703
+ data = await response[parseAs]();
698
704
  break;
699
- case "formData":
700
- emptyData = new FormData();
705
+ case "json": {
706
+ const text = await response.text();
707
+ data = text ? JSON.parse(text) : {};
701
708
  break;
709
+ }
702
710
  case "stream":
703
- emptyData = response.body;
704
- break;
705
- case "json":
706
- default:
707
- emptyData = {};
708
- break;
711
+ return opts.responseStyle === "data" ? response.body : {
712
+ data: response.body,
713
+ ...result
714
+ };
715
+ }
716
+ if (parseAs === "json") {
717
+ if (opts.responseValidator) {
718
+ await opts.responseValidator(data);
719
+ }
720
+ if (opts.responseTransformer) {
721
+ data = await opts.responseTransformer(data);
722
+ }
709
723
  }
710
- return opts.responseStyle === "data" ? emptyData : {
711
- data: emptyData,
724
+ return opts.responseStyle === "data" ? data : {
725
+ data,
712
726
  ...result
713
727
  };
714
728
  }
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
- };
729
+ const textError = await response.text();
730
+ let jsonError;
731
+ try {
732
+ jsonError = JSON.parse(textError);
733
+ } catch {
733
734
  }
734
- if (parseAs === "json") {
735
- if (opts.responseValidator) {
736
- await opts.responseValidator(data);
737
- }
738
- if (opts.responseTransformer) {
739
- data = await opts.responseTransformer(data);
735
+ throw jsonError ?? textError;
736
+ } catch (error) {
737
+ let finalError = error;
738
+ for (const fn of interceptors.error.fns) {
739
+ if (fn) {
740
+ finalError = await fn(
741
+ finalError,
742
+ response,
743
+ request2,
744
+ options
745
+ );
740
746
  }
741
747
  }
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);
748
+ finalError = finalError || {};
749
+ if (throwOnError) {
750
+ throw finalError;
758
751
  }
752
+ return responseStyle === "data" ? void 0 : {
753
+ error: finalError,
754
+ request: request2,
755
+ response
756
+ };
759
757
  }
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
758
  };
769
759
  const makeMethodFn = (method) => (options) => request({ ...options, method });
770
760
  const makeSseFn = (method) => async (options) => {
@@ -772,7 +762,6 @@ var createClient = (config = {}) => {
772
762
  return createSseClient({
773
763
  ...opts,
774
764
  body: opts.body,
775
- headers: opts.headers,
776
765
  method,
777
766
  onRequest: async (url2, init) => {
778
767
  let request2 = new Request(url2, init);
@@ -787,8 +776,9 @@ var createClient = (config = {}) => {
787
776
  url
788
777
  });
789
778
  };
779
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
790
780
  return {
791
- buildUrl,
781
+ buildUrl: _buildUrl,
792
782
  connect: makeMethodFn("CONNECT"),
793
783
  delete: makeMethodFn("DELETE"),
794
784
  get: makeMethodFn("GET"),
@@ -1,4 +1,4 @@
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-D8LjzWc0.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-DKrNRB-E.mjs';
2
2
  export { createClient } from './client.gen.mjs';
3
3
 
4
4
  type Slot = "body" | "headers" | "path" | "query";
@@ -1,4 +1,4 @@
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-D8LjzWc0.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-DKrNRB-E.js';
2
2
  export { createClient } from './client.gen.js';
3
3
 
4
4
  type Slot = "body" | "headers" | "path" | "query";