@eudiplo/sdk-core 1.14.0-main.e87cefd → 1.14.0-main.eaeec84

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/")) {
@@ -466,11 +445,8 @@ var checkForExistence = (options, name) => {
466
445
  }
467
446
  return false;
468
447
  };
469
- var setAuthParams = async ({
470
- security,
471
- ...options
472
- }) => {
473
- for (const auth of security) {
448
+ async function setAuthParams(options) {
449
+ for (const auth of options.security ?? []) {
474
450
  if (checkForExistence(options, auth.name)) {
475
451
  continue;
476
452
  }
@@ -495,7 +471,7 @@ var setAuthParams = async ({
495
471
  break;
496
472
  }
497
473
  }
498
- };
474
+ }
499
475
  var buildUrl = (options) => getUrl({
500
476
  baseUrl: options.baseUrl,
501
477
  path: options.path,
@@ -621,10 +597,7 @@ var createClient = (config = {}) => {
621
597
  serializedBody: void 0
622
598
  };
623
599
  if (opts.security) {
624
- await setAuthParams({
625
- ...opts,
626
- security: opts.security
627
- });
600
+ await setAuthParams(opts);
628
601
  }
629
602
  if (opts.requestValidator) {
630
603
  await opts.requestValidator(opts);
@@ -635,136 +608,121 @@ var createClient = (config = {}) => {
635
608
  if (opts.body === void 0 || opts.serializedBody === "") {
636
609
  opts.headers.delete("Content-Type");
637
610
  }
638
- const url = buildUrl(opts);
639
- return { opts, url };
611
+ const resolvedOpts = opts;
612
+ const url = buildUrl(resolvedOpts);
613
+ return { opts: resolvedOpts, url };
640
614
  };
641
615
  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;
616
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
617
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
618
+ let request2;
655
619
  let response;
656
620
  try {
657
- response = await _fetch(request2);
658
- } catch (error2) {
659
- let finalError2 = error2;
660
- for (const fn of interceptors.error.fns) {
621
+ const { opts, url } = await beforeRequest(options);
622
+ const requestInit = {
623
+ redirect: "follow",
624
+ ...opts,
625
+ body: getValidRequestBody(opts)
626
+ };
627
+ request2 = new Request(url, requestInit);
628
+ for (const fn of interceptors.request.fns) {
661
629
  if (fn) {
662
- finalError2 = await fn(
663
- error2,
664
- void 0,
665
- request2,
666
- opts
667
- );
630
+ request2 = await fn(request2, opts);
668
631
  }
669
632
  }
670
- finalError2 = finalError2 || {};
671
- if (opts.throwOnError) {
672
- throw finalError2;
633
+ const _fetch = opts.fetch;
634
+ response = await _fetch(request2);
635
+ for (const fn of interceptors.response.fns) {
636
+ if (fn) {
637
+ response = await fn(response, request2, opts);
638
+ }
673
639
  }
674
- return opts.responseStyle === "data" ? void 0 : {
675
- error: finalError2,
640
+ const result = {
676
641
  request: request2,
677
- response: void 0
642
+ response
678
643
  };
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;
644
+ if (response.ok) {
645
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
646
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
647
+ let emptyData;
648
+ switch (parseAs) {
649
+ case "arrayBuffer":
650
+ case "blob":
651
+ case "text":
652
+ emptyData = await response[parseAs]();
653
+ break;
654
+ case "formData":
655
+ emptyData = new FormData();
656
+ break;
657
+ case "stream":
658
+ emptyData = response.body;
659
+ break;
660
+ case "json":
661
+ default:
662
+ emptyData = {};
663
+ break;
664
+ }
665
+ return opts.responseStyle === "data" ? emptyData : {
666
+ data: emptyData,
667
+ ...result
668
+ };
669
+ }
670
+ let data;
693
671
  switch (parseAs) {
694
672
  case "arrayBuffer":
695
673
  case "blob":
674
+ case "formData":
696
675
  case "text":
697
- emptyData = await response[parseAs]();
676
+ data = await response[parseAs]();
698
677
  break;
699
- case "formData":
700
- emptyData = new FormData();
678
+ case "json": {
679
+ const text = await response.text();
680
+ data = text ? JSON.parse(text) : {};
701
681
  break;
682
+ }
702
683
  case "stream":
703
- emptyData = response.body;
704
- break;
705
- case "json":
706
- default:
707
- emptyData = {};
708
- break;
684
+ return opts.responseStyle === "data" ? response.body : {
685
+ data: response.body,
686
+ ...result
687
+ };
688
+ }
689
+ if (parseAs === "json") {
690
+ if (opts.responseValidator) {
691
+ await opts.responseValidator(data);
692
+ }
693
+ if (opts.responseTransformer) {
694
+ data = await opts.responseTransformer(data);
695
+ }
709
696
  }
710
- return opts.responseStyle === "data" ? emptyData : {
711
- data: emptyData,
697
+ return opts.responseStyle === "data" ? data : {
698
+ data,
712
699
  ...result
713
700
  };
714
701
  }
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
- };
702
+ const textError = await response.text();
703
+ let jsonError;
704
+ try {
705
+ jsonError = JSON.parse(textError);
706
+ } catch {
733
707
  }
734
- if (parseAs === "json") {
735
- if (opts.responseValidator) {
736
- await opts.responseValidator(data);
737
- }
738
- if (opts.responseTransformer) {
739
- data = await opts.responseTransformer(data);
708
+ throw jsonError ?? textError;
709
+ } catch (error) {
710
+ let finalError = error;
711
+ for (const fn of interceptors.error.fns) {
712
+ if (fn) {
713
+ finalError = await fn(finalError, response, request2, options);
740
714
  }
741
715
  }
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);
716
+ finalError = finalError || {};
717
+ if (throwOnError) {
718
+ throw finalError;
758
719
  }
720
+ return responseStyle === "data" ? void 0 : {
721
+ error: finalError,
722
+ request: request2,
723
+ response
724
+ };
759
725
  }
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
726
  };
769
727
  const makeMethodFn = (method) => (options) => request({ ...options, method });
770
728
  const makeSseFn = (method) => async (options) => {
@@ -772,7 +730,6 @@ var createClient = (config = {}) => {
772
730
  return createSseClient({
773
731
  ...opts,
774
732
  body: opts.body,
775
- headers: opts.headers,
776
733
  method,
777
734
  onRequest: async (url2, init) => {
778
735
  let request2 = new Request(url2, init);
@@ -787,8 +744,9 @@ var createClient = (config = {}) => {
787
744
  url
788
745
  });
789
746
  };
747
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
790
748
  return {
791
- buildUrl,
749
+ buildUrl: _buildUrl,
792
750
  connect: makeMethodFn("CONNECT"),
793
751
  delete: makeMethodFn("DELETE"),
794
752
  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-Cc6DtXw9.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-Cc6DtXw9.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
  */