@eudiplo/sdk-core 4.1.0 → 4.3.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.
@@ -864,132 +864,121 @@ var createClient = (config = {}) => {
864
864
  return { opts: resolvedOpts, url };
865
865
  };
866
866
  const request = async (options) => {
867
- const { opts, url } = await beforeRequest(options);
868
- const requestInit = {
869
- redirect: "follow",
870
- ...opts,
871
- body: getValidRequestBody(opts)
872
- };
873
- let request2 = new Request(url, requestInit);
874
- for (const fn of interceptors.request.fns) {
875
- if (fn) {
876
- request2 = await fn(request2, opts);
877
- }
878
- }
879
- const _fetch = opts.fetch;
867
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
868
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
869
+ let request2;
880
870
  let response;
881
871
  try {
882
- response = await _fetch(request2);
883
- } catch (error2) {
884
- let finalError2 = error2;
885
- for (const fn of interceptors.error.fns) {
872
+ const { opts, url } = await beforeRequest(options);
873
+ const requestInit = {
874
+ redirect: "follow",
875
+ ...opts,
876
+ body: getValidRequestBody(opts)
877
+ };
878
+ request2 = new Request(url, requestInit);
879
+ for (const fn of interceptors.request.fns) {
886
880
  if (fn) {
887
- finalError2 = await fn(
888
- error2,
889
- void 0,
890
- request2,
891
- opts
892
- );
881
+ request2 = await fn(request2, opts);
893
882
  }
894
883
  }
895
- finalError2 = finalError2 || {};
896
- if (opts.throwOnError) {
897
- throw finalError2;
884
+ const _fetch = opts.fetch;
885
+ response = await _fetch(request2);
886
+ for (const fn of interceptors.response.fns) {
887
+ if (fn) {
888
+ response = await fn(response, request2, opts);
889
+ }
898
890
  }
899
- return opts.responseStyle === "data" ? void 0 : {
900
- error: finalError2,
891
+ const result = {
901
892
  request: request2,
902
- response: void 0
893
+ response
903
894
  };
904
- }
905
- for (const fn of interceptors.response.fns) {
906
- if (fn) {
907
- response = await fn(response, request2, opts);
908
- }
909
- }
910
- const result = {
911
- request: request2,
912
- response
913
- };
914
- if (response.ok) {
915
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
916
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
917
- let emptyData;
895
+ if (response.ok) {
896
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
897
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
898
+ let emptyData;
899
+ switch (parseAs) {
900
+ case "arrayBuffer":
901
+ case "blob":
902
+ case "text":
903
+ emptyData = await response[parseAs]();
904
+ break;
905
+ case "formData":
906
+ emptyData = new FormData();
907
+ break;
908
+ case "stream":
909
+ emptyData = response.body;
910
+ break;
911
+ case "json":
912
+ default:
913
+ emptyData = {};
914
+ break;
915
+ }
916
+ return opts.responseStyle === "data" ? emptyData : {
917
+ data: emptyData,
918
+ ...result
919
+ };
920
+ }
921
+ let data;
918
922
  switch (parseAs) {
919
923
  case "arrayBuffer":
920
924
  case "blob":
925
+ case "formData":
921
926
  case "text":
922
- emptyData = await response[parseAs]();
927
+ data = await response[parseAs]();
923
928
  break;
924
- case "formData":
925
- emptyData = new FormData();
929
+ case "json": {
930
+ const text = await response.text();
931
+ data = text ? JSON.parse(text) : {};
926
932
  break;
933
+ }
927
934
  case "stream":
928
- emptyData = response.body;
929
- break;
930
- case "json":
931
- default:
932
- emptyData = {};
933
- break;
935
+ return opts.responseStyle === "data" ? response.body : {
936
+ data: response.body,
937
+ ...result
938
+ };
939
+ }
940
+ if (parseAs === "json") {
941
+ if (opts.responseValidator) {
942
+ await opts.responseValidator(data);
943
+ }
944
+ if (opts.responseTransformer) {
945
+ data = await opts.responseTransformer(data);
946
+ }
934
947
  }
935
- return opts.responseStyle === "data" ? emptyData : {
936
- data: emptyData,
948
+ return opts.responseStyle === "data" ? data : {
949
+ data,
937
950
  ...result
938
951
  };
939
952
  }
940
- let data;
941
- switch (parseAs) {
942
- case "arrayBuffer":
943
- case "blob":
944
- case "formData":
945
- case "text":
946
- data = await response[parseAs]();
947
- break;
948
- case "json": {
949
- const text = await response.text();
950
- data = text ? JSON.parse(text) : {};
951
- break;
952
- }
953
- case "stream":
954
- return opts.responseStyle === "data" ? response.body : {
955
- data: response.body,
956
- ...result
957
- };
953
+ const textError = await response.text();
954
+ let jsonError;
955
+ try {
956
+ jsonError = JSON.parse(textError);
957
+ } catch {
958
958
  }
959
- if (parseAs === "json") {
960
- if (opts.responseValidator) {
961
- await opts.responseValidator(data);
962
- }
963
- if (opts.responseTransformer) {
964
- data = await opts.responseTransformer(data);
959
+ throw jsonError ?? textError;
960
+ } catch (error) {
961
+ let finalError = error;
962
+ for (const fn of interceptors.error.fns) {
963
+ if (fn) {
964
+ finalError = await fn(
965
+ finalError,
966
+ response,
967
+ request2,
968
+ options
969
+ );
965
970
  }
966
971
  }
967
- return opts.responseStyle === "data" ? data : {
968
- data,
969
- ...result
970
- };
971
- }
972
- const textError = await response.text();
973
- let jsonError;
974
- try {
975
- jsonError = JSON.parse(textError);
976
- } catch {
977
- }
978
- const error = jsonError ?? textError;
979
- let finalError = error;
980
- for (const fn of interceptors.error.fns) {
981
- if (fn) {
982
- finalError = await fn(error, response, request2, opts);
972
+ finalError = finalError || {};
973
+ if (throwOnError) {
974
+ throw finalError;
983
975
  }
976
+ return responseStyle === "data" ? void 0 : {
977
+ error: finalError,
978
+ request: request2,
979
+ response
980
+ };
984
981
  }
985
- finalError = finalError || {};
986
- if (opts.throwOnError) {
987
- throw finalError;
988
- }
989
- return opts.responseStyle === "data" ? void 0 : {
990
- error: finalError,
991
- ...result
992
- };
993
982
  };
994
983
  const makeMethodFn = (method) => (options) => request({ ...options, method });
995
984
  const makeSseFn = (method) => async (options) => {
@@ -997,7 +986,6 @@ var createClient = (config = {}) => {
997
986
  return createSseClient({
998
987
  ...opts,
999
988
  body: opts.body,
1000
- headers: opts.headers,
1001
989
  method,
1002
990
  onRequest: async (url2, init) => {
1003
991
  let request2 = new Request(url2, init);
@@ -862,132 +862,121 @@ var createClient = (config = {}) => {
862
862
  return { opts: resolvedOpts, url };
863
863
  };
864
864
  const request = async (options) => {
865
- const { opts, url } = await beforeRequest(options);
866
- const requestInit = {
867
- redirect: "follow",
868
- ...opts,
869
- body: getValidRequestBody(opts)
870
- };
871
- let request2 = new Request(url, requestInit);
872
- for (const fn of interceptors.request.fns) {
873
- if (fn) {
874
- request2 = await fn(request2, opts);
875
- }
876
- }
877
- const _fetch = opts.fetch;
865
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
866
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
867
+ let request2;
878
868
  let response;
879
869
  try {
880
- response = await _fetch(request2);
881
- } catch (error2) {
882
- let finalError2 = error2;
883
- for (const fn of interceptors.error.fns) {
870
+ const { opts, url } = await beforeRequest(options);
871
+ const requestInit = {
872
+ redirect: "follow",
873
+ ...opts,
874
+ body: getValidRequestBody(opts)
875
+ };
876
+ request2 = new Request(url, requestInit);
877
+ for (const fn of interceptors.request.fns) {
884
878
  if (fn) {
885
- finalError2 = await fn(
886
- error2,
887
- void 0,
888
- request2,
889
- opts
890
- );
879
+ request2 = await fn(request2, opts);
891
880
  }
892
881
  }
893
- finalError2 = finalError2 || {};
894
- if (opts.throwOnError) {
895
- throw finalError2;
882
+ const _fetch = opts.fetch;
883
+ response = await _fetch(request2);
884
+ for (const fn of interceptors.response.fns) {
885
+ if (fn) {
886
+ response = await fn(response, request2, opts);
887
+ }
896
888
  }
897
- return opts.responseStyle === "data" ? void 0 : {
898
- error: finalError2,
889
+ const result = {
899
890
  request: request2,
900
- response: void 0
891
+ response
901
892
  };
902
- }
903
- for (const fn of interceptors.response.fns) {
904
- if (fn) {
905
- response = await fn(response, request2, opts);
906
- }
907
- }
908
- const result = {
909
- request: request2,
910
- response
911
- };
912
- if (response.ok) {
913
- const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
914
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
915
- let emptyData;
893
+ if (response.ok) {
894
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
895
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
896
+ let emptyData;
897
+ switch (parseAs) {
898
+ case "arrayBuffer":
899
+ case "blob":
900
+ case "text":
901
+ emptyData = await response[parseAs]();
902
+ break;
903
+ case "formData":
904
+ emptyData = new FormData();
905
+ break;
906
+ case "stream":
907
+ emptyData = response.body;
908
+ break;
909
+ case "json":
910
+ default:
911
+ emptyData = {};
912
+ break;
913
+ }
914
+ return opts.responseStyle === "data" ? emptyData : {
915
+ data: emptyData,
916
+ ...result
917
+ };
918
+ }
919
+ let data;
916
920
  switch (parseAs) {
917
921
  case "arrayBuffer":
918
922
  case "blob":
923
+ case "formData":
919
924
  case "text":
920
- emptyData = await response[parseAs]();
925
+ data = await response[parseAs]();
921
926
  break;
922
- case "formData":
923
- emptyData = new FormData();
927
+ case "json": {
928
+ const text = await response.text();
929
+ data = text ? JSON.parse(text) : {};
924
930
  break;
931
+ }
925
932
  case "stream":
926
- emptyData = response.body;
927
- break;
928
- case "json":
929
- default:
930
- emptyData = {};
931
- break;
933
+ return opts.responseStyle === "data" ? response.body : {
934
+ data: response.body,
935
+ ...result
936
+ };
937
+ }
938
+ if (parseAs === "json") {
939
+ if (opts.responseValidator) {
940
+ await opts.responseValidator(data);
941
+ }
942
+ if (opts.responseTransformer) {
943
+ data = await opts.responseTransformer(data);
944
+ }
932
945
  }
933
- return opts.responseStyle === "data" ? emptyData : {
934
- data: emptyData,
946
+ return opts.responseStyle === "data" ? data : {
947
+ data,
935
948
  ...result
936
949
  };
937
950
  }
938
- let data;
939
- switch (parseAs) {
940
- case "arrayBuffer":
941
- case "blob":
942
- case "formData":
943
- case "text":
944
- data = await response[parseAs]();
945
- break;
946
- case "json": {
947
- const text = await response.text();
948
- data = text ? JSON.parse(text) : {};
949
- break;
950
- }
951
- case "stream":
952
- return opts.responseStyle === "data" ? response.body : {
953
- data: response.body,
954
- ...result
955
- };
951
+ const textError = await response.text();
952
+ let jsonError;
953
+ try {
954
+ jsonError = JSON.parse(textError);
955
+ } catch {
956
956
  }
957
- if (parseAs === "json") {
958
- if (opts.responseValidator) {
959
- await opts.responseValidator(data);
960
- }
961
- if (opts.responseTransformer) {
962
- data = await opts.responseTransformer(data);
957
+ throw jsonError ?? textError;
958
+ } catch (error) {
959
+ let finalError = error;
960
+ for (const fn of interceptors.error.fns) {
961
+ if (fn) {
962
+ finalError = await fn(
963
+ finalError,
964
+ response,
965
+ request2,
966
+ options
967
+ );
963
968
  }
964
969
  }
965
- return opts.responseStyle === "data" ? data : {
966
- data,
967
- ...result
968
- };
969
- }
970
- const textError = await response.text();
971
- let jsonError;
972
- try {
973
- jsonError = JSON.parse(textError);
974
- } catch {
975
- }
976
- const error = jsonError ?? textError;
977
- let finalError = error;
978
- for (const fn of interceptors.error.fns) {
979
- if (fn) {
980
- finalError = await fn(error, response, request2, opts);
970
+ finalError = finalError || {};
971
+ if (throwOnError) {
972
+ throw finalError;
981
973
  }
974
+ return responseStyle === "data" ? void 0 : {
975
+ error: finalError,
976
+ request: request2,
977
+ response
978
+ };
982
979
  }
983
- finalError = finalError || {};
984
- if (opts.throwOnError) {
985
- throw finalError;
986
- }
987
- return opts.responseStyle === "data" ? void 0 : {
988
- error: finalError,
989
- ...result
990
- };
991
980
  };
992
981
  const makeMethodFn = (method) => (options) => request({ ...options, method });
993
982
  const makeSseFn = (method) => async (options) => {
@@ -995,7 +984,6 @@ var createClient = (config = {}) => {
995
984
  return createSseClient({
996
985
  ...opts,
997
986
  body: opts.body,
998
- headers: opts.headers,
999
987
  method,
1000
988
  onRequest: async (url2, init) => {
1001
989
  let request2 = new Request(url2, init);
@@ -1 +1 @@
1
- export { C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape } from '../../types.gen-CVkHMB8b.mjs';
1
+ export { C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape } from '../../types.gen-DKrNRB-E.mjs';
@@ -1 +1 @@
1
- export { C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape } from '../../types.gen-CVkHMB8b.js';
1
+ export { C as Client, a as ClientOptions, b as Config, c as CreateClientConfig, O as Options, R as RequestOptions, d as RequestResult, e as ResolvedRequestOptions, f as ResponseStyle, T as TDataShape } from '../../types.gen-DKrNRB-E.js';
@@ -1,5 +1,5 @@
1
- import { C as Client, a as ClientOptions, b as Config } from '../types.gen-CVkHMB8b.mjs';
2
- import { ai as ClientOptions$1 } from '../types.gen-CVLCgolx.mjs';
1
+ import { C as Client, a as ClientOptions, b as Config } from '../types.gen-DKrNRB-E.mjs';
2
+ import { aj as ClientOptions$1 } from '../types.gen-DWk5kPkH.mjs';
3
3
 
4
4
  /**
5
5
  * The `createClientConfig()` function will be called on client initialization
@@ -1,5 +1,5 @@
1
- import { C as Client, a as ClientOptions, b as Config } from '../types.gen-CVkHMB8b.js';
2
- import { ai as ClientOptions$1 } from '../types.gen-CVLCgolx.js';
1
+ import { C as Client, a as ClientOptions, b as Config } from '../types.gen-DKrNRB-E.js';
2
+ import { aj as ClientOptions$1 } from '../types.gen-DWk5kPkH.js';
3
3
 
4
4
  /**
5
5
  * The `createClientConfig()` function will be called on client initialization