@claudebernard/patient-profile-element 0.7.3 → 0.8.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.
- package/dist/custom-elements.json +8916 -18
- package/dist/patient-profile.d.ts +24 -6
- package/dist/patient-profile.es.js +1706 -51
- package/package.json +3 -50
|
@@ -833,7 +833,7 @@ function childPughScore(score) {
|
|
|
833
833
|
}
|
|
834
834
|
return msg("Stade C");
|
|
835
835
|
}
|
|
836
|
-
const t$2 = globalThis, e$5 = t$2.ShadowRoot && (void 0 === t$2.ShadyCSS || t$2.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$2 = /* @__PURE__ */ Symbol(), o$
|
|
836
|
+
const t$2 = globalThis, e$5 = t$2.ShadowRoot && (void 0 === t$2.ShadyCSS || t$2.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, s$2 = /* @__PURE__ */ Symbol(), o$5 = /* @__PURE__ */ new WeakMap();
|
|
837
837
|
let n$3 = class n {
|
|
838
838
|
constructor(t2, e2, o2) {
|
|
839
839
|
if (this._$cssResult$ = true, o2 !== s$2) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
@@ -844,7 +844,7 @@ let n$3 = class n {
|
|
|
844
844
|
const s2 = this.t;
|
|
845
845
|
if (e$5 && void 0 === t2) {
|
|
846
846
|
const e2 = void 0 !== s2 && 1 === s2.length;
|
|
847
|
-
e2 && (t2 = o$
|
|
847
|
+
e2 && (t2 = o$5.get(s2)), void 0 === t2 && ((this.o = t2 = new CSSStyleSheet()).replaceSync(this.cssText), e2 && o$5.set(s2, t2));
|
|
848
848
|
}
|
|
849
849
|
return t2;
|
|
850
850
|
}
|
|
@@ -870,7 +870,7 @@ const r$4 = (t2) => new n$3("string" == typeof t2 ? t2 : t2 + "", void 0, s$2),
|
|
|
870
870
|
for (const s2 of t3.cssRules) e2 += s2.cssText;
|
|
871
871
|
return r$4(e2);
|
|
872
872
|
})(t2) : t2;
|
|
873
|
-
const { is: i$4, defineProperty: e$4, getOwnPropertyDescriptor: h$1, getOwnPropertyNames: r$3, getOwnPropertySymbols: o$
|
|
873
|
+
const { is: i$4, defineProperty: e$4, getOwnPropertyDescriptor: h$1, getOwnPropertyNames: r$3, getOwnPropertySymbols: o$4, getPrototypeOf: n$2 } = Object, a$1 = globalThis, c$1 = a$1.trustedTypes, l$1 = c$1 ? c$1.emptyScript : "", p$2 = a$1.reactiveElementPolyfillSupport, d$1 = (t2, s2) => t2, u$1 = { toAttribute(t2, s2) {
|
|
874
874
|
switch (s2) {
|
|
875
875
|
case Boolean:
|
|
876
876
|
t2 = t2 ? l$1 : null;
|
|
@@ -935,7 +935,7 @@ let y$1 = class y extends HTMLElement {
|
|
|
935
935
|
static finalize() {
|
|
936
936
|
if (this.hasOwnProperty(d$1("finalized"))) return;
|
|
937
937
|
if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d$1("properties"))) {
|
|
938
|
-
const t3 = this.properties, s2 = [...r$3(t3), ...o$
|
|
938
|
+
const t3 = this.properties, s2 = [...r$3(t3), ...o$4(t3)];
|
|
939
939
|
for (const i4 of s2) this.createProperty(i4, t3[i4]);
|
|
940
940
|
}
|
|
941
941
|
const t2 = this[Symbol.metadata];
|
|
@@ -1082,7 +1082,7 @@ let y$1 = class y extends HTMLElement {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
};
|
|
1084
1084
|
y$1.elementStyles = [], y$1.shadowRootOptions = { mode: "open" }, y$1[d$1("elementProperties")] = /* @__PURE__ */ new Map(), y$1[d$1("finalized")] = /* @__PURE__ */ new Map(), p$2?.({ ReactiveElement: y$1 }), (a$1.reactiveElementVersions ??= []).push("2.1.2");
|
|
1085
|
-
const t$1 = globalThis, i$3 = (t2) => t2, s$1 = t$1.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, h = "$lit$", o$
|
|
1085
|
+
const t$1 = globalThis, i$3 = (t2) => t2, s$1 = t$1.trustedTypes, e$3 = s$1 ? s$1.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, h = "$lit$", o$3 = `lit$${Math.random().toFixed(9).slice(2)}$`, n$1 = "?" + o$3, r$2 = `<${n$1}>`, l = document, c = () => l.createComment(""), a = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, u = Array.isArray, d = (t2) => u(t2) || "function" == typeof t2?.[Symbol.iterator], f = "[ \n\f\r]", v = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _ = /-->/g, m$1 = />/g, p$1 = RegExp(`>|${f}(?:([^\\s"'>=/]+)(${f}*=${f}*(?:[^
|
|
1086
1086
|
\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y2 = /^(?:script|style|textarea|title)$/i, x = (t2) => (i4, ...s2) => ({ _$litType$: t2, strings: i4, values: s2 }), b = x(1), E = /* @__PURE__ */ Symbol.for("lit-noChange"), A = /* @__PURE__ */ Symbol.for("lit-nothing"), C = /* @__PURE__ */ new WeakMap(), P = l.createTreeWalker(l, 129);
|
|
1087
1087
|
function V(t2, i4) {
|
|
1088
1088
|
if (!u(t2) || !t2.hasOwnProperty("raw")) throw Error("invalid template strings array");
|
|
@@ -1096,7 +1096,7 @@ const N = (t2, i4) => {
|
|
|
1096
1096
|
let a2, u2, d2 = -1, f2 = 0;
|
|
1097
1097
|
for (; f2 < s3.length && (c2.lastIndex = f2, u2 = c2.exec(s3), null !== u2); ) f2 = c2.lastIndex, c2 === v ? "!--" === u2[1] ? c2 = _ : void 0 !== u2[1] ? c2 = m$1 : void 0 !== u2[2] ? (y2.test(u2[2]) && (n3 = RegExp("</" + u2[2], "g")), c2 = p$1) : void 0 !== u2[3] && (c2 = p$1) : c2 === p$1 ? ">" === u2[0] ? (c2 = n3 ?? v, d2 = -1) : void 0 === u2[1] ? d2 = -2 : (d2 = c2.lastIndex - u2[2].length, a2 = u2[1], c2 = void 0 === u2[3] ? p$1 : '"' === u2[3] ? $ : g) : c2 === $ || c2 === g ? c2 = p$1 : c2 === _ || c2 === m$1 ? c2 = v : (c2 = p$1, n3 = void 0);
|
|
1098
1098
|
const x2 = c2 === p$1 && t2[i5 + 1].startsWith("/>") ? " " : "";
|
|
1099
|
-
l2 += c2 === v ? s3 + r$2 : d2 >= 0 ? (e2.push(a2), s3.slice(0, d2) + h + s3.slice(d2) + o$
|
|
1099
|
+
l2 += c2 === v ? s3 + r$2 : d2 >= 0 ? (e2.push(a2), s3.slice(0, d2) + h + s3.slice(d2) + o$3 + x2) : s3 + o$3 + (-2 === d2 ? i5 : x2);
|
|
1100
1100
|
}
|
|
1101
1101
|
return [V(t2, l2 + (t2[s2] || "<?>") + (2 === i4 ? "</svg>" : 3 === i4 ? "</math>" : "")), e2];
|
|
1102
1102
|
};
|
|
@@ -1113,11 +1113,11 @@ class S {
|
|
|
1113
1113
|
for (; null !== (r2 = P.nextNode()) && d2.length < u2; ) {
|
|
1114
1114
|
if (1 === r2.nodeType) {
|
|
1115
1115
|
if (r2.hasAttributes()) for (const t3 of r2.getAttributeNames()) if (t3.endsWith(h)) {
|
|
1116
|
-
const i5 = v2[a2++], s2 = r2.getAttribute(t3).split(o$
|
|
1116
|
+
const i5 = v2[a2++], s2 = r2.getAttribute(t3).split(o$3), e3 = /([.?@])?(.*)/.exec(i5);
|
|
1117
1117
|
d2.push({ type: 1, index: l2, name: e3[2], strings: s2, ctor: "." === e3[1] ? I : "?" === e3[1] ? L : "@" === e3[1] ? z : H }), r2.removeAttribute(t3);
|
|
1118
|
-
} else t3.startsWith(o$
|
|
1118
|
+
} else t3.startsWith(o$3) && (d2.push({ type: 6, index: l2 }), r2.removeAttribute(t3));
|
|
1119
1119
|
if (y2.test(r2.tagName)) {
|
|
1120
|
-
const t3 = r2.textContent.split(o$
|
|
1120
|
+
const t3 = r2.textContent.split(o$3), i5 = t3.length - 1;
|
|
1121
1121
|
if (i5 > 0) {
|
|
1122
1122
|
r2.textContent = s$1 ? s$1.emptyScript : "";
|
|
1123
1123
|
for (let s2 = 0; s2 < i5; s2++) r2.append(t3[s2], c()), P.nextNode(), d2.push({ type: 2, index: ++l2 });
|
|
@@ -1127,7 +1127,7 @@ class S {
|
|
|
1127
1127
|
} else if (8 === r2.nodeType) if (r2.data === n$1) d2.push({ type: 2, index: l2 });
|
|
1128
1128
|
else {
|
|
1129
1129
|
let t3 = -1;
|
|
1130
|
-
for (; -1 !== (t3 = r2.data.indexOf(o$
|
|
1130
|
+
for (; -1 !== (t3 = r2.data.indexOf(o$3, t3 + 1)); ) d2.push({ type: 7, index: l2 }), t3 += o$3.length - 1;
|
|
1131
1131
|
}
|
|
1132
1132
|
l2++;
|
|
1133
1133
|
}
|
|
@@ -1330,15 +1330,15 @@ let i$2 = class i extends y$1 {
|
|
|
1330
1330
|
}
|
|
1331
1331
|
};
|
|
1332
1332
|
i$2._$litElement$ = true, i$2["finalized"] = true, s.litElementHydrateSupport?.({ LitElement: i$2 });
|
|
1333
|
-
const o$
|
|
1334
|
-
o$
|
|
1333
|
+
const o$2 = s.litElementPolyfillSupport;
|
|
1334
|
+
o$2?.({ LitElement: i$2 });
|
|
1335
1335
|
(s.litElementVersions ??= []).push("4.2.2");
|
|
1336
1336
|
const t = (t2) => (e2, o2) => {
|
|
1337
1337
|
void 0 !== o2 ? o2.addInitializer(() => {
|
|
1338
1338
|
customElements.define(t2, e2);
|
|
1339
1339
|
}) : customElements.define(t2, e2);
|
|
1340
1340
|
};
|
|
1341
|
-
const o = { attribute: true, type: String, converter: u$1, reflect: false, hasChanged: f$1 }, r$1 = (t2 = o, e2, r2) => {
|
|
1341
|
+
const o$1 = { attribute: true, type: String, converter: u$1, reflect: false, hasChanged: f$1 }, r$1 = (t2 = o$1, e2, r2) => {
|
|
1342
1342
|
const { kind: n3, metadata: i4 } = r2;
|
|
1343
1343
|
let s2 = globalThis.litPropertyMetadata.get(i4);
|
|
1344
1344
|
if (void 0 === s2 && globalThis.litPropertyMetadata.set(i4, s2 = /* @__PURE__ */ new Map()), "setter" === n3 && ((t2 = Object.create(t2)).wrapped = true), s2.set(r2.name, t2), "accessor" === n3) {
|
|
@@ -1377,7 +1377,8 @@ function e$1(e2, r2) {
|
|
|
1377
1377
|
} });
|
|
1378
1378
|
};
|
|
1379
1379
|
}
|
|
1380
|
-
const
|
|
1380
|
+
const o = (o2) => o2 ?? A;
|
|
1381
|
+
const patientProfileCSS = '@charset "UTF-8";\n.claudebernard-patient-profile {\n font-family: var(--custom-font-family, "Ubuntu"), sans-serif;\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n padding: 1rem;\n border-radius: 0.5rem;\n background-color: var(--bcbd-white-color, #FFFFFF);\n container-type: inline-size;\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile {\n font-size: 0.8rem;\n }\n}\n.claudebernard-patient-profile__no-profile {\n display: flex;\n flex-direction: column;\n gap: 0.3rem;\n}\n.claudebernard-patient-profile__no-profile__first {\n font-weight: bold;\n}\n.claudebernard-patient-profile__no-profile__second {\n color: var(--bcbd-gray-500-color, #64748B);\n font-size: 0.8rem;\n}\n.claudebernard-patient-profile__separator {\n border-right: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n}\n.claudebernard-patient-profile__first-info-container {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n gap: 0.5rem;\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__first-info-container {\n flex-wrap: wrap;\n gap: 1rem;\n align-items: center;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__first-info-container {\n justify-content: center;\n }\n}\n.claudebernard-patient-profile__id-info-container {\n display: flex;\n flex-direction: column;\n justify-content: center;\n gap: 0.5rem;\n min-width: 0;\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__id-info-container {\n flex: 1;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__id-info-container {\n flex: 0 1 auto;\n max-width: 100%;\n align-items: center;\n }\n}\n.claudebernard-patient-profile__name-info {\n font-size: 1rem;\n max-width: 100%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.claudebernard-patient-profile__id-info {\n width: fit-content;\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n border-radius: 1rem;\n display: flex;\n flex-direction: row;\n padding: 0 0.8rem;\n gap: 0.5rem;\n}\n.claudebernard-patient-profile__id-info-info {\n padding: 0.2rem 0;\n white-space: nowrap;\n font-size: 1rem;\n}\n.claudebernard-patient-profile__physical-info-container {\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 1rem;\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile__physical-info-container {\n gap: 0.5rem;\n }\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__physical-info-container {\n order: 3;\n width: 100%;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__physical-info-container {\n order: 2;\n }\n}\n.claudebernard-patient-profile__physical-info {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: space-between;\n padding: 1rem 0;\n font-size: 1rem;\n}\n.claudebernard-patient-profile__physical-info-result {\n white-space: nowrap;\n}\n.claudebernard-patient-profile__physical-info-label {\n color: var(--bcbd-gray-600-color, #475569);\n}\n.claudebernard-patient-profile__action-buttons-container {\n display: flex;\n flex-direction: row;\n justify-content: flex-end;\n align-content: center;\n flex-wrap: wrap;\n gap: 1rem;\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile__action-buttons-container {\n gap: 0.5rem;\n }\n}\n@container (max-width: 450px) {\n .claudebernard-patient-profile__action-buttons-container {\n order: 2;\n margin: 0 auto;\n }\n}\n@container (max-width: 320px) {\n .claudebernard-patient-profile__action-buttons-container {\n order: 3;\n }\n}\n.claudebernard-patient-profile__second-info-container {\n margin-top: 1rem;\n display: none;\n}\n.claudebernard-patient-profile__second-info-container.active {\n display: flex;\n flex-direction: column;\n}\n.claudebernard-patient-profile__second-info {\n margin-top: 1rem;\n}\n.claudebernard-patient-profile__second-info bcbd-tooltip {\n display: inline-block;\n}\n.claudebernard-patient-profile__second-info bcbd-tooltip > span {\n font-size: 1rem;\n}\n.claudebernard-patient-profile__second-info-label {\n padding-right: 0.5rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n@container (max-width: 600px) {\n .claudebernard-patient-profile__second-info-label {\n font-size: 0.8rem;\n }\n}\n.claudebernard-patient-profile__second-info-result.sep-dots > * + *::before {\n content: "•";\n margin: 0 0.5rem;\n}\n.claudebernard-patient-profile__alert-container bcbd-alert {\n margin-top: 10px;\n}\n.claudebernard-patient-profile__alert-container {\n display: flex;\n flex-direction: column;\n}';
|
|
1381
1382
|
const e = (t2) => (...e2) => ({ _$litDirective$: t2, values: e2 });
|
|
1382
1383
|
let i$1 = class i2 {
|
|
1383
1384
|
constructor(t2) {
|
|
@@ -1468,9 +1469,15 @@ let PatientDemographicsForm = class extends i$2 {
|
|
|
1468
1469
|
get patientAge() {
|
|
1469
1470
|
return this.patientAgeValue === void 0 ? "" : `${this.patientAgeValue} ${this.patientUnitAge}`;
|
|
1470
1471
|
}
|
|
1472
|
+
static isPregnancyEligible(age, unit, sex) {
|
|
1473
|
+
return unit === "ans" && age >= 12 && age <= 55 && !!sex && sex !== "male";
|
|
1474
|
+
}
|
|
1471
1475
|
get isPregnancyAge() {
|
|
1472
|
-
|
|
1473
|
-
|
|
1476
|
+
return PatientDemographicsForm.isPregnancyEligible(
|
|
1477
|
+
this.patientAgeValue ?? 0,
|
|
1478
|
+
this.patientUnitAge,
|
|
1479
|
+
this.genderSelect?.value
|
|
1480
|
+
);
|
|
1474
1481
|
}
|
|
1475
1482
|
emitChange(isPregnancyEligible, triggerRenalRecalculation) {
|
|
1476
1483
|
this.dispatchEvent(new CustomEvent("demographics-change", {
|
|
@@ -1510,7 +1517,7 @@ let PatientDemographicsForm = class extends i$2 {
|
|
|
1510
1517
|
const { age, unit } = calculateAgeFromBirthDate(birthDate);
|
|
1511
1518
|
this.patientAgeValue = age;
|
|
1512
1519
|
this.patientUnitAge = unit;
|
|
1513
|
-
isPregnancyEligible = unit
|
|
1520
|
+
isPregnancyEligible = PatientDemographicsForm.isPregnancyEligible(age, unit, this.defaultPatientSex.value);
|
|
1514
1521
|
} else {
|
|
1515
1522
|
this.patientAgeValue = void 0;
|
|
1516
1523
|
this.ageErrorMessageInput = "L'âge est requis";
|
|
@@ -1813,25 +1820,879 @@ __decorateClass$7([
|
|
|
1813
1820
|
PatientReproductiveForm = __decorateClass$7([
|
|
1814
1821
|
t("bcb-patient-reproductive-form")
|
|
1815
1822
|
], PatientReproductiveForm);
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
+
const jsonBodySerializer$1 = {
|
|
1824
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
1825
|
+
};
|
|
1826
|
+
function createSseClient$1({
|
|
1827
|
+
onRequest,
|
|
1828
|
+
onSseError,
|
|
1829
|
+
onSseEvent,
|
|
1830
|
+
responseTransformer,
|
|
1831
|
+
responseValidator,
|
|
1832
|
+
sseDefaultRetryDelay,
|
|
1833
|
+
sseMaxRetryAttempts,
|
|
1834
|
+
sseMaxRetryDelay,
|
|
1835
|
+
sseSleepFn,
|
|
1836
|
+
url,
|
|
1837
|
+
...options
|
|
1838
|
+
}) {
|
|
1839
|
+
let lastEventId;
|
|
1840
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
1841
|
+
const createStream = async function* () {
|
|
1842
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
1843
|
+
let attempt = 0;
|
|
1844
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
1845
|
+
while (true) {
|
|
1846
|
+
if (signal.aborted) break;
|
|
1847
|
+
attempt++;
|
|
1848
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
1849
|
+
if (lastEventId !== void 0) {
|
|
1850
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
1851
|
+
}
|
|
1852
|
+
try {
|
|
1853
|
+
const requestInit = {
|
|
1854
|
+
redirect: "follow",
|
|
1855
|
+
...options,
|
|
1856
|
+
body: options.serializedBody,
|
|
1857
|
+
headers,
|
|
1858
|
+
signal
|
|
1859
|
+
};
|
|
1860
|
+
let request = new Request(url, requestInit);
|
|
1861
|
+
if (onRequest) {
|
|
1862
|
+
request = await onRequest(url, requestInit);
|
|
1863
|
+
}
|
|
1864
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
1865
|
+
const response = await _fetch(request);
|
|
1866
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
1867
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
1868
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
1869
|
+
let buffer = "";
|
|
1870
|
+
const abortHandler = () => {
|
|
1871
|
+
try {
|
|
1872
|
+
reader.cancel();
|
|
1873
|
+
} catch {
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
signal.addEventListener("abort", abortHandler);
|
|
1877
|
+
try {
|
|
1878
|
+
while (true) {
|
|
1879
|
+
const { done, value } = await reader.read();
|
|
1880
|
+
if (done) break;
|
|
1881
|
+
buffer += value;
|
|
1882
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
1883
|
+
const chunks = buffer.split("\n\n");
|
|
1884
|
+
buffer = chunks.pop() ?? "";
|
|
1885
|
+
for (const chunk of chunks) {
|
|
1886
|
+
const lines = chunk.split("\n");
|
|
1887
|
+
const dataLines = [];
|
|
1888
|
+
let eventName;
|
|
1889
|
+
for (const line of lines) {
|
|
1890
|
+
if (line.startsWith("data:")) {
|
|
1891
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
1892
|
+
} else if (line.startsWith("event:")) {
|
|
1893
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
1894
|
+
} else if (line.startsWith("id:")) {
|
|
1895
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
1896
|
+
} else if (line.startsWith("retry:")) {
|
|
1897
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
1898
|
+
if (!Number.isNaN(parsed)) {
|
|
1899
|
+
retryDelay = parsed;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
let data;
|
|
1904
|
+
let parsedJson = false;
|
|
1905
|
+
if (dataLines.length) {
|
|
1906
|
+
const rawData = dataLines.join("\n");
|
|
1907
|
+
try {
|
|
1908
|
+
data = JSON.parse(rawData);
|
|
1909
|
+
parsedJson = true;
|
|
1910
|
+
} catch {
|
|
1911
|
+
data = rawData;
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
if (parsedJson) {
|
|
1915
|
+
if (responseValidator) {
|
|
1916
|
+
await responseValidator(data);
|
|
1917
|
+
}
|
|
1918
|
+
if (responseTransformer) {
|
|
1919
|
+
data = await responseTransformer(data);
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
onSseEvent?.({
|
|
1923
|
+
data,
|
|
1924
|
+
event: eventName,
|
|
1925
|
+
id: lastEventId,
|
|
1926
|
+
retry: retryDelay
|
|
1927
|
+
});
|
|
1928
|
+
if (dataLines.length) {
|
|
1929
|
+
yield data;
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
} finally {
|
|
1934
|
+
signal.removeEventListener("abort", abortHandler);
|
|
1935
|
+
reader.releaseLock();
|
|
1936
|
+
}
|
|
1937
|
+
break;
|
|
1938
|
+
} catch (error) {
|
|
1939
|
+
onSseError?.(error);
|
|
1940
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
1941
|
+
break;
|
|
1942
|
+
}
|
|
1943
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
1944
|
+
await sleep(backoff);
|
|
1945
|
+
}
|
|
1946
|
+
}
|
|
1947
|
+
};
|
|
1948
|
+
const stream = createStream();
|
|
1949
|
+
return { stream };
|
|
1950
|
+
}
|
|
1951
|
+
const separatorArrayExplode$1 = (style) => {
|
|
1952
|
+
switch (style) {
|
|
1953
|
+
case "label":
|
|
1954
|
+
return ".";
|
|
1955
|
+
case "matrix":
|
|
1956
|
+
return ";";
|
|
1957
|
+
case "simple":
|
|
1958
|
+
return ",";
|
|
1959
|
+
default:
|
|
1960
|
+
return "&";
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
const separatorArrayNoExplode$1 = (style) => {
|
|
1964
|
+
switch (style) {
|
|
1965
|
+
case "form":
|
|
1966
|
+
return ",";
|
|
1967
|
+
case "pipeDelimited":
|
|
1968
|
+
return "|";
|
|
1969
|
+
case "spaceDelimited":
|
|
1970
|
+
return "%20";
|
|
1971
|
+
default:
|
|
1972
|
+
return ",";
|
|
1973
|
+
}
|
|
1974
|
+
};
|
|
1975
|
+
const separatorObjectExplode$1 = (style) => {
|
|
1976
|
+
switch (style) {
|
|
1977
|
+
case "label":
|
|
1978
|
+
return ".";
|
|
1979
|
+
case "matrix":
|
|
1980
|
+
return ";";
|
|
1981
|
+
case "simple":
|
|
1982
|
+
return ",";
|
|
1983
|
+
default:
|
|
1984
|
+
return "&";
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
const serializeArrayParam$1 = ({
|
|
1988
|
+
allowReserved,
|
|
1989
|
+
explode,
|
|
1990
|
+
name,
|
|
1991
|
+
style,
|
|
1992
|
+
value
|
|
1993
|
+
}) => {
|
|
1994
|
+
if (!explode) {
|
|
1995
|
+
const joinedValues2 = (allowReserved ? value : value.map((v2) => encodeURIComponent(v2))).join(separatorArrayNoExplode$1(style));
|
|
1996
|
+
switch (style) {
|
|
1997
|
+
case "label":
|
|
1998
|
+
return `.${joinedValues2}`;
|
|
1999
|
+
case "matrix":
|
|
2000
|
+
return `;${name}=${joinedValues2}`;
|
|
2001
|
+
case "simple":
|
|
2002
|
+
return joinedValues2;
|
|
2003
|
+
default:
|
|
2004
|
+
return `${name}=${joinedValues2}`;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
const separator = separatorArrayExplode$1(style);
|
|
2008
|
+
const joinedValues = value.map((v2) => {
|
|
2009
|
+
if (style === "label" || style === "simple") {
|
|
2010
|
+
return allowReserved ? v2 : encodeURIComponent(v2);
|
|
2011
|
+
}
|
|
2012
|
+
return serializePrimitiveParam$1({
|
|
2013
|
+
allowReserved,
|
|
2014
|
+
name,
|
|
2015
|
+
value: v2
|
|
2016
|
+
});
|
|
2017
|
+
}).join(separator);
|
|
2018
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
2019
|
+
};
|
|
2020
|
+
const serializePrimitiveParam$1 = ({
|
|
2021
|
+
allowReserved,
|
|
2022
|
+
name,
|
|
2023
|
+
value
|
|
2024
|
+
}) => {
|
|
2025
|
+
if (value === void 0 || value === null) {
|
|
2026
|
+
return "";
|
|
2027
|
+
}
|
|
2028
|
+
if (typeof value === "object") {
|
|
2029
|
+
throw new Error(
|
|
2030
|
+
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these."
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
2034
|
+
};
|
|
2035
|
+
const serializeObjectParam$1 = ({
|
|
2036
|
+
allowReserved,
|
|
2037
|
+
explode,
|
|
2038
|
+
name,
|
|
2039
|
+
style,
|
|
2040
|
+
value,
|
|
2041
|
+
valueOnly
|
|
2042
|
+
}) => {
|
|
2043
|
+
if (value instanceof Date) {
|
|
2044
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
2045
|
+
}
|
|
2046
|
+
if (style !== "deepObject" && !explode) {
|
|
2047
|
+
let values = [];
|
|
2048
|
+
Object.entries(value).forEach(([key, v2]) => {
|
|
2049
|
+
values = [...values, key, allowReserved ? v2 : encodeURIComponent(v2)];
|
|
2050
|
+
});
|
|
2051
|
+
const joinedValues2 = values.join(",");
|
|
2052
|
+
switch (style) {
|
|
2053
|
+
case "form":
|
|
2054
|
+
return `${name}=${joinedValues2}`;
|
|
2055
|
+
case "label":
|
|
2056
|
+
return `.${joinedValues2}`;
|
|
2057
|
+
case "matrix":
|
|
2058
|
+
return `;${name}=${joinedValues2}`;
|
|
2059
|
+
default:
|
|
2060
|
+
return joinedValues2;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
const separator = separatorObjectExplode$1(style);
|
|
2064
|
+
const joinedValues = Object.entries(value).map(
|
|
2065
|
+
([key, v2]) => serializePrimitiveParam$1({
|
|
2066
|
+
allowReserved,
|
|
2067
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
2068
|
+
value: v2
|
|
2069
|
+
})
|
|
2070
|
+
).join(separator);
|
|
2071
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
2072
|
+
};
|
|
2073
|
+
const PATH_PARAM_RE$1 = /\{[^{}]+\}/g;
|
|
2074
|
+
const defaultPathSerializer$1 = ({ path, url: _url }) => {
|
|
2075
|
+
let url = _url;
|
|
2076
|
+
const matches = _url.match(PATH_PARAM_RE$1);
|
|
2077
|
+
if (matches) {
|
|
2078
|
+
for (const match of matches) {
|
|
2079
|
+
let explode = false;
|
|
2080
|
+
let name = match.substring(1, match.length - 1);
|
|
2081
|
+
let style = "simple";
|
|
2082
|
+
if (name.endsWith("*")) {
|
|
2083
|
+
explode = true;
|
|
2084
|
+
name = name.substring(0, name.length - 1);
|
|
2085
|
+
}
|
|
2086
|
+
if (name.startsWith(".")) {
|
|
2087
|
+
name = name.substring(1);
|
|
2088
|
+
style = "label";
|
|
2089
|
+
} else if (name.startsWith(";")) {
|
|
2090
|
+
name = name.substring(1);
|
|
2091
|
+
style = "matrix";
|
|
2092
|
+
}
|
|
2093
|
+
const value = path[name];
|
|
2094
|
+
if (value === void 0 || value === null) {
|
|
2095
|
+
continue;
|
|
2096
|
+
}
|
|
2097
|
+
if (Array.isArray(value)) {
|
|
2098
|
+
url = url.replace(match, serializeArrayParam$1({ explode, name, style, value }));
|
|
2099
|
+
continue;
|
|
2100
|
+
}
|
|
2101
|
+
if (typeof value === "object") {
|
|
2102
|
+
url = url.replace(
|
|
2103
|
+
match,
|
|
2104
|
+
serializeObjectParam$1({
|
|
2105
|
+
explode,
|
|
2106
|
+
name,
|
|
2107
|
+
style,
|
|
2108
|
+
value,
|
|
2109
|
+
valueOnly: true
|
|
2110
|
+
})
|
|
2111
|
+
);
|
|
2112
|
+
continue;
|
|
2113
|
+
}
|
|
2114
|
+
if (style === "matrix") {
|
|
2115
|
+
url = url.replace(
|
|
2116
|
+
match,
|
|
2117
|
+
`;${serializePrimitiveParam$1({
|
|
2118
|
+
name,
|
|
2119
|
+
value
|
|
2120
|
+
})}`
|
|
2121
|
+
);
|
|
2122
|
+
continue;
|
|
2123
|
+
}
|
|
2124
|
+
const replaceValue = encodeURIComponent(
|
|
2125
|
+
style === "label" ? `.${value}` : value
|
|
2126
|
+
);
|
|
2127
|
+
url = url.replace(match, replaceValue);
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
2130
|
+
return url;
|
|
2131
|
+
};
|
|
2132
|
+
const getUrl$1 = ({
|
|
2133
|
+
baseUrl,
|
|
2134
|
+
path,
|
|
2135
|
+
query,
|
|
2136
|
+
querySerializer,
|
|
2137
|
+
url: _url
|
|
2138
|
+
}) => {
|
|
2139
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
2140
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
2141
|
+
if (path) {
|
|
2142
|
+
url = defaultPathSerializer$1({ path, url });
|
|
2143
|
+
}
|
|
2144
|
+
let search = query ? querySerializer(query) : "";
|
|
2145
|
+
if (search.startsWith("?")) {
|
|
2146
|
+
search = search.substring(1);
|
|
2147
|
+
}
|
|
2148
|
+
if (search) {
|
|
2149
|
+
url += `?${search}`;
|
|
2150
|
+
}
|
|
2151
|
+
return url;
|
|
2152
|
+
};
|
|
2153
|
+
function getValidRequestBody$1(options) {
|
|
2154
|
+
const hasBody = options.body !== void 0;
|
|
2155
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
2156
|
+
if (isSerializedBody) {
|
|
2157
|
+
if ("serializedBody" in options) {
|
|
2158
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
2159
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
2160
|
+
}
|
|
2161
|
+
return options.body !== "" ? options.body : null;
|
|
2162
|
+
}
|
|
2163
|
+
if (hasBody) {
|
|
2164
|
+
return options.body;
|
|
2165
|
+
}
|
|
2166
|
+
return void 0;
|
|
2167
|
+
}
|
|
2168
|
+
const getAuthToken$1 = async (auth, callback) => {
|
|
2169
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
2170
|
+
if (!token) {
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
if (auth.scheme === "bearer") {
|
|
2174
|
+
return `Bearer ${token}`;
|
|
2175
|
+
}
|
|
2176
|
+
if (auth.scheme === "basic") {
|
|
2177
|
+
return `Basic ${btoa(token)}`;
|
|
2178
|
+
}
|
|
2179
|
+
return token;
|
|
2180
|
+
};
|
|
2181
|
+
const createQuerySerializer$1 = ({
|
|
2182
|
+
parameters = {},
|
|
2183
|
+
...args
|
|
2184
|
+
} = {}) => {
|
|
2185
|
+
const querySerializer = (queryParams) => {
|
|
2186
|
+
const search = [];
|
|
2187
|
+
if (queryParams && typeof queryParams === "object") {
|
|
2188
|
+
for (const name in queryParams) {
|
|
2189
|
+
const value = queryParams[name];
|
|
2190
|
+
if (value === void 0 || value === null) {
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
const options = parameters[name] || args;
|
|
2194
|
+
if (Array.isArray(value)) {
|
|
2195
|
+
const serializedArray = serializeArrayParam$1({
|
|
2196
|
+
allowReserved: options.allowReserved,
|
|
2197
|
+
explode: true,
|
|
2198
|
+
name,
|
|
2199
|
+
style: "form",
|
|
2200
|
+
value,
|
|
2201
|
+
...options.array
|
|
2202
|
+
});
|
|
2203
|
+
if (serializedArray) search.push(serializedArray);
|
|
2204
|
+
} else if (typeof value === "object") {
|
|
2205
|
+
const serializedObject = serializeObjectParam$1({
|
|
2206
|
+
allowReserved: options.allowReserved,
|
|
2207
|
+
explode: true,
|
|
2208
|
+
name,
|
|
2209
|
+
style: "deepObject",
|
|
2210
|
+
value,
|
|
2211
|
+
...options.object
|
|
2212
|
+
});
|
|
2213
|
+
if (serializedObject) search.push(serializedObject);
|
|
2214
|
+
} else {
|
|
2215
|
+
const serializedPrimitive = serializePrimitiveParam$1({
|
|
2216
|
+
allowReserved: options.allowReserved,
|
|
2217
|
+
name,
|
|
2218
|
+
value
|
|
2219
|
+
});
|
|
2220
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
return search.join("&");
|
|
2225
|
+
};
|
|
2226
|
+
return querySerializer;
|
|
2227
|
+
};
|
|
2228
|
+
const getParseAs$1 = (contentType) => {
|
|
2229
|
+
if (!contentType) {
|
|
2230
|
+
return "stream";
|
|
2231
|
+
}
|
|
2232
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
2233
|
+
if (!cleanContent) {
|
|
2234
|
+
return;
|
|
2235
|
+
}
|
|
2236
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
2237
|
+
return "json";
|
|
2238
|
+
}
|
|
2239
|
+
if (cleanContent === "multipart/form-data") {
|
|
2240
|
+
return "formData";
|
|
2241
|
+
}
|
|
2242
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
2243
|
+
return "blob";
|
|
2244
|
+
}
|
|
2245
|
+
if (cleanContent.startsWith("text/")) {
|
|
2246
|
+
return "text";
|
|
2247
|
+
}
|
|
2248
|
+
return;
|
|
2249
|
+
};
|
|
2250
|
+
const checkForExistence$1 = (options, name) => {
|
|
2251
|
+
if (!name) {
|
|
2252
|
+
return false;
|
|
2253
|
+
}
|
|
2254
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
2255
|
+
return true;
|
|
2256
|
+
}
|
|
2257
|
+
return false;
|
|
2258
|
+
};
|
|
2259
|
+
async function setAuthParams$1(options) {
|
|
2260
|
+
for (const auth of options.security ?? []) {
|
|
2261
|
+
if (checkForExistence$1(options, auth.name)) {
|
|
2262
|
+
continue;
|
|
2263
|
+
}
|
|
2264
|
+
const token = await getAuthToken$1(auth, options.auth);
|
|
2265
|
+
if (!token) {
|
|
2266
|
+
continue;
|
|
2267
|
+
}
|
|
2268
|
+
const name = auth.name ?? "Authorization";
|
|
2269
|
+
switch (auth.in) {
|
|
2270
|
+
case "query":
|
|
2271
|
+
if (!options.query) {
|
|
2272
|
+
options.query = {};
|
|
2273
|
+
}
|
|
2274
|
+
options.query[name] = token;
|
|
2275
|
+
break;
|
|
2276
|
+
case "cookie":
|
|
2277
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
2278
|
+
break;
|
|
2279
|
+
case "header":
|
|
2280
|
+
default:
|
|
2281
|
+
options.headers.set(name, token);
|
|
2282
|
+
break;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
const buildUrl$1 = (options) => getUrl$1({
|
|
2287
|
+
baseUrl: options.baseUrl,
|
|
2288
|
+
path: options.path,
|
|
2289
|
+
query: options.query,
|
|
2290
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer$1(options.querySerializer),
|
|
2291
|
+
url: options.url
|
|
2292
|
+
});
|
|
2293
|
+
const mergeConfigs$1 = (a2, b2) => {
|
|
2294
|
+
const config = { ...a2, ...b2 };
|
|
2295
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
2296
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
2297
|
+
}
|
|
2298
|
+
config.headers = mergeHeaders$1(a2.headers, b2.headers);
|
|
2299
|
+
return config;
|
|
2300
|
+
};
|
|
2301
|
+
const headersEntries$1 = (headers) => {
|
|
2302
|
+
const entries = [];
|
|
2303
|
+
headers.forEach((value, key) => {
|
|
2304
|
+
entries.push([key, value]);
|
|
1823
2305
|
});
|
|
1824
|
-
return
|
|
2306
|
+
return entries;
|
|
2307
|
+
};
|
|
2308
|
+
const mergeHeaders$1 = (...headers) => {
|
|
2309
|
+
const mergedHeaders = new Headers();
|
|
2310
|
+
for (const header of headers) {
|
|
2311
|
+
if (!header) {
|
|
2312
|
+
continue;
|
|
2313
|
+
}
|
|
2314
|
+
const iterator = header instanceof Headers ? headersEntries$1(header) : Object.entries(header);
|
|
2315
|
+
for (const [key, value] of iterator) {
|
|
2316
|
+
if (value === null) {
|
|
2317
|
+
mergedHeaders.delete(key);
|
|
2318
|
+
} else if (Array.isArray(value)) {
|
|
2319
|
+
for (const v2 of value) {
|
|
2320
|
+
mergedHeaders.append(key, v2);
|
|
2321
|
+
}
|
|
2322
|
+
} else if (value !== void 0) {
|
|
2323
|
+
mergedHeaders.set(
|
|
2324
|
+
key,
|
|
2325
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
2326
|
+
);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
return mergedHeaders;
|
|
2331
|
+
};
|
|
2332
|
+
let Interceptors$1 = class Interceptors {
|
|
2333
|
+
constructor() {
|
|
2334
|
+
this.fns = [];
|
|
2335
|
+
}
|
|
2336
|
+
clear() {
|
|
2337
|
+
this.fns = [];
|
|
2338
|
+
}
|
|
2339
|
+
eject(id) {
|
|
2340
|
+
const index = this.getInterceptorIndex(id);
|
|
2341
|
+
if (this.fns[index]) {
|
|
2342
|
+
this.fns[index] = null;
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
exists(id) {
|
|
2346
|
+
const index = this.getInterceptorIndex(id);
|
|
2347
|
+
return Boolean(this.fns[index]);
|
|
2348
|
+
}
|
|
2349
|
+
getInterceptorIndex(id) {
|
|
2350
|
+
if (typeof id === "number") {
|
|
2351
|
+
return this.fns[id] ? id : -1;
|
|
2352
|
+
}
|
|
2353
|
+
return this.fns.indexOf(id);
|
|
2354
|
+
}
|
|
2355
|
+
update(id, fn) {
|
|
2356
|
+
const index = this.getInterceptorIndex(id);
|
|
2357
|
+
if (this.fns[index]) {
|
|
2358
|
+
this.fns[index] = fn;
|
|
2359
|
+
return id;
|
|
2360
|
+
}
|
|
2361
|
+
return false;
|
|
2362
|
+
}
|
|
2363
|
+
use(fn) {
|
|
2364
|
+
this.fns.push(fn);
|
|
2365
|
+
return this.fns.length - 1;
|
|
2366
|
+
}
|
|
1825
2367
|
};
|
|
1826
|
-
const
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
2368
|
+
const createInterceptors$1 = () => ({
|
|
2369
|
+
error: new Interceptors$1(),
|
|
2370
|
+
request: new Interceptors$1(),
|
|
2371
|
+
response: new Interceptors$1()
|
|
2372
|
+
});
|
|
2373
|
+
const defaultQuerySerializer$1 = createQuerySerializer$1({
|
|
2374
|
+
allowReserved: false,
|
|
2375
|
+
array: {
|
|
2376
|
+
explode: true,
|
|
2377
|
+
style: "form"
|
|
2378
|
+
},
|
|
2379
|
+
object: {
|
|
2380
|
+
explode: true,
|
|
2381
|
+
style: "deepObject"
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
const defaultHeaders$1 = {
|
|
2385
|
+
"Content-Type": "application/json"
|
|
2386
|
+
};
|
|
2387
|
+
const createConfig$1 = (override = {}) => ({
|
|
2388
|
+
...jsonBodySerializer$1,
|
|
2389
|
+
headers: defaultHeaders$1,
|
|
2390
|
+
parseAs: "auto",
|
|
2391
|
+
querySerializer: defaultQuerySerializer$1,
|
|
2392
|
+
...override
|
|
2393
|
+
});
|
|
2394
|
+
const createClient$1 = (config = {}) => {
|
|
2395
|
+
let _config = mergeConfigs$1(createConfig$1(), config);
|
|
2396
|
+
const getConfig = () => ({ ..._config });
|
|
2397
|
+
const setConfig = (config2) => {
|
|
2398
|
+
_config = mergeConfigs$1(_config, config2);
|
|
2399
|
+
return getConfig();
|
|
2400
|
+
};
|
|
2401
|
+
const interceptors = createInterceptors$1();
|
|
2402
|
+
const beforeRequest = async (options) => {
|
|
2403
|
+
const opts = {
|
|
2404
|
+
..._config,
|
|
2405
|
+
...options,
|
|
2406
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
2407
|
+
headers: mergeHeaders$1(_config.headers, options.headers),
|
|
2408
|
+
serializedBody: void 0
|
|
2409
|
+
};
|
|
2410
|
+
if (opts.security) {
|
|
2411
|
+
await setAuthParams$1(opts);
|
|
2412
|
+
}
|
|
2413
|
+
if (opts.requestValidator) {
|
|
2414
|
+
await opts.requestValidator(opts);
|
|
2415
|
+
}
|
|
2416
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
2417
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
2418
|
+
}
|
|
2419
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
2420
|
+
opts.headers.delete("Content-Type");
|
|
2421
|
+
}
|
|
2422
|
+
const resolvedOpts = opts;
|
|
2423
|
+
const url = buildUrl$1(resolvedOpts);
|
|
2424
|
+
return { opts: resolvedOpts, url };
|
|
2425
|
+
};
|
|
2426
|
+
const request = async (options) => {
|
|
2427
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
2428
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
2429
|
+
let request2;
|
|
2430
|
+
let response;
|
|
2431
|
+
try {
|
|
2432
|
+
const { opts, url } = await beforeRequest(options);
|
|
2433
|
+
const requestInit = {
|
|
2434
|
+
redirect: "follow",
|
|
2435
|
+
...opts,
|
|
2436
|
+
body: getValidRequestBody$1(opts)
|
|
2437
|
+
};
|
|
2438
|
+
request2 = new Request(url, requestInit);
|
|
2439
|
+
for (const fn of interceptors.request.fns) {
|
|
2440
|
+
if (fn) {
|
|
2441
|
+
request2 = await fn(request2, opts);
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
const _fetch = opts.fetch;
|
|
2445
|
+
response = await _fetch(request2);
|
|
2446
|
+
for (const fn of interceptors.response.fns) {
|
|
2447
|
+
if (fn) {
|
|
2448
|
+
response = await fn(response, request2, opts);
|
|
2449
|
+
}
|
|
2450
|
+
}
|
|
2451
|
+
const result = {
|
|
2452
|
+
request: request2,
|
|
2453
|
+
response
|
|
2454
|
+
};
|
|
2455
|
+
if (response.ok) {
|
|
2456
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs$1(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
2457
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
2458
|
+
let emptyData;
|
|
2459
|
+
switch (parseAs) {
|
|
2460
|
+
case "arrayBuffer":
|
|
2461
|
+
case "blob":
|
|
2462
|
+
case "text":
|
|
2463
|
+
emptyData = await response[parseAs]();
|
|
2464
|
+
break;
|
|
2465
|
+
case "formData":
|
|
2466
|
+
emptyData = new FormData();
|
|
2467
|
+
break;
|
|
2468
|
+
case "stream":
|
|
2469
|
+
emptyData = response.body;
|
|
2470
|
+
break;
|
|
2471
|
+
case "json":
|
|
2472
|
+
default:
|
|
2473
|
+
emptyData = {};
|
|
2474
|
+
break;
|
|
2475
|
+
}
|
|
2476
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
2477
|
+
data: emptyData,
|
|
2478
|
+
...result
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
let data;
|
|
2482
|
+
switch (parseAs) {
|
|
2483
|
+
case "arrayBuffer":
|
|
2484
|
+
case "blob":
|
|
2485
|
+
case "formData":
|
|
2486
|
+
case "text":
|
|
2487
|
+
data = await response[parseAs]();
|
|
2488
|
+
break;
|
|
2489
|
+
case "json": {
|
|
2490
|
+
const text = await response.text();
|
|
2491
|
+
data = text ? JSON.parse(text) : {};
|
|
2492
|
+
break;
|
|
2493
|
+
}
|
|
2494
|
+
case "stream":
|
|
2495
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
2496
|
+
data: response.body,
|
|
2497
|
+
...result
|
|
2498
|
+
};
|
|
2499
|
+
}
|
|
2500
|
+
if (parseAs === "json") {
|
|
2501
|
+
if (opts.responseValidator) {
|
|
2502
|
+
await opts.responseValidator(data);
|
|
2503
|
+
}
|
|
2504
|
+
if (opts.responseTransformer) {
|
|
2505
|
+
data = await opts.responseTransformer(data);
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
return opts.responseStyle === "data" ? data : {
|
|
2509
|
+
data,
|
|
2510
|
+
...result
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2513
|
+
const textError = await response.text();
|
|
2514
|
+
let jsonError;
|
|
2515
|
+
try {
|
|
2516
|
+
jsonError = JSON.parse(textError);
|
|
2517
|
+
} catch {
|
|
2518
|
+
}
|
|
2519
|
+
throw jsonError ?? textError;
|
|
2520
|
+
} catch (error) {
|
|
2521
|
+
let finalError = error;
|
|
2522
|
+
for (const fn of interceptors.error.fns) {
|
|
2523
|
+
if (fn) {
|
|
2524
|
+
finalError = await fn(finalError, response, request2, options);
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
finalError = finalError || {};
|
|
2528
|
+
if (throwOnError) {
|
|
2529
|
+
throw finalError;
|
|
2530
|
+
}
|
|
2531
|
+
return responseStyle === "data" ? void 0 : {
|
|
2532
|
+
error: finalError,
|
|
2533
|
+
request: request2,
|
|
2534
|
+
response
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
2539
|
+
const makeSseFn = (method) => async (options) => {
|
|
2540
|
+
const { opts, url } = await beforeRequest(options);
|
|
2541
|
+
return createSseClient$1({
|
|
2542
|
+
...opts,
|
|
2543
|
+
body: opts.body,
|
|
2544
|
+
method,
|
|
2545
|
+
onRequest: async (url2, init) => {
|
|
2546
|
+
let request2 = new Request(url2, init);
|
|
2547
|
+
for (const fn of interceptors.request.fns) {
|
|
2548
|
+
if (fn) {
|
|
2549
|
+
request2 = await fn(request2, opts);
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
return request2;
|
|
2553
|
+
},
|
|
2554
|
+
serializedBody: getValidRequestBody$1(opts),
|
|
2555
|
+
url
|
|
2556
|
+
});
|
|
2557
|
+
};
|
|
2558
|
+
const _buildUrl = (options) => buildUrl$1({ ..._config, ...options });
|
|
2559
|
+
return {
|
|
2560
|
+
buildUrl: _buildUrl,
|
|
2561
|
+
connect: makeMethodFn("CONNECT"),
|
|
2562
|
+
delete: makeMethodFn("DELETE"),
|
|
2563
|
+
get: makeMethodFn("GET"),
|
|
2564
|
+
getConfig,
|
|
2565
|
+
head: makeMethodFn("HEAD"),
|
|
2566
|
+
interceptors,
|
|
2567
|
+
options: makeMethodFn("OPTIONS"),
|
|
2568
|
+
patch: makeMethodFn("PATCH"),
|
|
2569
|
+
post: makeMethodFn("POST"),
|
|
2570
|
+
put: makeMethodFn("PUT"),
|
|
2571
|
+
request,
|
|
2572
|
+
setConfig,
|
|
2573
|
+
sse: {
|
|
2574
|
+
connect: makeSseFn("CONNECT"),
|
|
2575
|
+
delete: makeSseFn("DELETE"),
|
|
2576
|
+
get: makeSseFn("GET"),
|
|
2577
|
+
head: makeSseFn("HEAD"),
|
|
2578
|
+
options: makeSseFn("OPTIONS"),
|
|
2579
|
+
patch: makeSseFn("PATCH"),
|
|
2580
|
+
post: makeSseFn("POST"),
|
|
2581
|
+
put: makeSseFn("PUT"),
|
|
2582
|
+
trace: makeSseFn("TRACE")
|
|
2583
|
+
},
|
|
2584
|
+
trace: makeMethodFn("TRACE")
|
|
2585
|
+
};
|
|
2586
|
+
};
|
|
2587
|
+
const client$1 = createClient$1(createConfig$1({ baseUrl: "https://api-dev.claudebernard.fr/search" }));
|
|
2588
|
+
const search5 = (options) => (options?.client ?? client$1).post({
|
|
2589
|
+
url: "/pathologies/",
|
|
2590
|
+
...options,
|
|
2591
|
+
headers: {
|
|
2592
|
+
"Content-Type": "application/json",
|
|
2593
|
+
...options?.headers
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
const search6 = (options) => (options?.client ?? client$1).post({
|
|
2597
|
+
url: "/molecules/",
|
|
2598
|
+
...options,
|
|
2599
|
+
headers: {
|
|
2600
|
+
"Content-Type": "application/json",
|
|
2601
|
+
...options?.headers
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
function random$1(len) {
|
|
2605
|
+
return crypto.getRandomValues(new Uint8Array(len));
|
|
2606
|
+
}
|
|
2607
|
+
const W3C_TRACEPARENT_VERSION = "00";
|
|
2608
|
+
const FLAG_SAMPLE = 1;
|
|
2609
|
+
const FLAG_RANDOM = 2;
|
|
2610
|
+
function traceparent(version, trace_id, parent_id, flags) {
|
|
2611
|
+
return {
|
|
2612
|
+
version,
|
|
2613
|
+
trace_id,
|
|
2614
|
+
parent_id,
|
|
2615
|
+
flags,
|
|
2616
|
+
child() {
|
|
2617
|
+
return traceparent(this.version, this.trace_id, random(8), this.flags);
|
|
1831
2618
|
},
|
|
1832
|
-
|
|
2619
|
+
toString() {
|
|
2620
|
+
let flags2 = this.flags.toString(16).padStart(2, "0");
|
|
2621
|
+
return `${this.version}-${this.trace_id}-${this.parent_id}-${flags2}`;
|
|
2622
|
+
}
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
function make() {
|
|
2626
|
+
let id = random(24);
|
|
2627
|
+
return traceparent(W3C_TRACEPARENT_VERSION, id.slice(0, 32), id.slice(32), FLAG_SAMPLE | FLAG_RANDOM);
|
|
2628
|
+
}
|
|
2629
|
+
let IDX = 256, HEX = [];
|
|
2630
|
+
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
|
2631
|
+
function random(size) {
|
|
2632
|
+
let a2 = random$1(size), i4 = 0, o2 = "";
|
|
2633
|
+
for (; i4 < a2.length; i4++) o2 += HEX[a2[i4]];
|
|
2634
|
+
return o2;
|
|
2635
|
+
}
|
|
2636
|
+
const COMPONENT_HEADERS = {
|
|
2637
|
+
"Bcb-Web-Component-Package": "@claudebernard/patient-profile-element",
|
|
2638
|
+
"Bcb-Web-Component-Version": "0.8"
|
|
2639
|
+
};
|
|
2640
|
+
function makeTraceparent() {
|
|
2641
|
+
return make().child().toString();
|
|
2642
|
+
}
|
|
2643
|
+
let activeContext;
|
|
2644
|
+
function setActiveContext(context) {
|
|
2645
|
+
activeContext = context;
|
|
2646
|
+
}
|
|
2647
|
+
function buildTracingHeaders() {
|
|
2648
|
+
const headers = {
|
|
2649
|
+
traceparent: makeTraceparent(),
|
|
2650
|
+
...COMPONENT_HEADERS
|
|
2651
|
+
};
|
|
2652
|
+
if (activeContext?.consumer) {
|
|
2653
|
+
headers["Bcb-Consumer-Product"] = activeContext.consumer;
|
|
2654
|
+
}
|
|
2655
|
+
if (activeContext?.ancestry?.length) {
|
|
2656
|
+
headers["Bcb-Web-Component-Chain"] = activeContext.ancestry.map((a2) => `${a2.name}@${a2.version}`).join(",");
|
|
2657
|
+
}
|
|
2658
|
+
return headers;
|
|
2659
|
+
}
|
|
2660
|
+
function attachTracingHeaders(request) {
|
|
2661
|
+
const defaults = buildTracingHeaders();
|
|
2662
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
2663
|
+
if (!request.headers.has(key)) {
|
|
2664
|
+
request.headers.set(key, value);
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
return request;
|
|
2668
|
+
}
|
|
2669
|
+
client$1.interceptors.request.use(attachTracingHeaders);
|
|
2670
|
+
const fetchPathologiesByTerm = async (term, typePathology, params, apiUrl, context) => {
|
|
2671
|
+
client$1.setConfig({ baseUrl: `${apiUrl}/search` });
|
|
2672
|
+
setActiveContext(context);
|
|
2673
|
+
const response = await search5({
|
|
2674
|
+
query: { term, typePathology },
|
|
2675
|
+
// SearchRequestBody (@claudebernard/types) porte davantage de champs que le
|
|
2676
|
+
// SearchRequestBean généré depuis le spec OpenAPI (tous optionnels côté spec) - compatible au
|
|
2677
|
+
// runtime, cast nécessaire côté type uniquement.
|
|
2678
|
+
body: params
|
|
2679
|
+
});
|
|
2680
|
+
if (!response.data) {
|
|
2681
|
+
throw new Error(`HTTP error! status: ${response.response?.status}`);
|
|
2682
|
+
}
|
|
2683
|
+
return response.data;
|
|
2684
|
+
};
|
|
2685
|
+
const fetchMoleculesByTerm = async (term, params, apiUrl, context) => {
|
|
2686
|
+
client$1.setConfig({ baseUrl: `${apiUrl}/search` });
|
|
2687
|
+
setActiveContext(context);
|
|
2688
|
+
const response = await search6({
|
|
2689
|
+
query: { term },
|
|
2690
|
+
body: params
|
|
1833
2691
|
});
|
|
1834
|
-
|
|
2692
|
+
if (!response.data) {
|
|
2693
|
+
throw new Error(`HTTP error! status: ${response.response?.status}`);
|
|
2694
|
+
}
|
|
2695
|
+
return response.data;
|
|
1835
2696
|
};
|
|
1836
2697
|
var __defProp$5 = Object.defineProperty;
|
|
1837
2698
|
var __decorateClass$6 = (decorators, target, key, kind) => {
|
|
@@ -1895,6 +2756,9 @@ __decorateClass$6([
|
|
|
1895
2756
|
__decorateClass$6([
|
|
1896
2757
|
n2({ type: String, attribute: "api-url" })
|
|
1897
2758
|
], PatientCodeSearchFormBase.prototype, "apiUrl");
|
|
2759
|
+
__decorateClass$6([
|
|
2760
|
+
n2({ type: Object })
|
|
2761
|
+
], PatientCodeSearchFormBase.prototype, "context");
|
|
1898
2762
|
__decorateClass$6([
|
|
1899
2763
|
r()
|
|
1900
2764
|
], PatientCodeSearchFormBase.prototype, "options");
|
|
@@ -1924,7 +2788,7 @@ let PatientPathologiesForm = class extends PatientCodeSearchFormBase {
|
|
|
1924
2788
|
}
|
|
1925
2789
|
async search(term) {
|
|
1926
2790
|
const typePathology = this.preferences?.typePathology ?? "";
|
|
1927
|
-
const response = await fetchPathologiesByTerm(term, typePathology, new SearchRequestBody({}), this.apiUrl);
|
|
2791
|
+
const response = await fetchPathologiesByTerm(term, typePathology, new SearchRequestBody({}), this.apiUrl, this.context);
|
|
1928
2792
|
return response.content.map((pathology) => this.apiReturnToSelectOption(pathology));
|
|
1929
2793
|
}
|
|
1930
2794
|
render() {
|
|
@@ -1962,7 +2826,7 @@ let PatientAllergiesForm = class extends PatientCodeSearchFormBase {
|
|
|
1962
2826
|
return getPatientAllergiesWithCode(patientProfile);
|
|
1963
2827
|
}
|
|
1964
2828
|
async search(term) {
|
|
1965
|
-
const response = await fetchMoleculesByTerm(term, new SearchRequestBody({}), this.apiUrl);
|
|
2829
|
+
const response = await fetchMoleculesByTerm(term, new SearchRequestBody({}), this.apiUrl, this.context);
|
|
1966
2830
|
return response.content.map((allergy) => this.apiReturnToSelectOption(allergy));
|
|
1967
2831
|
}
|
|
1968
2832
|
render() {
|
|
@@ -1982,19 +2846,794 @@ PatientAllergiesForm.styles = i$5`${r$4(patientCodeSearchFormCSS)}`;
|
|
|
1982
2846
|
PatientAllergiesForm = __decorateClass$4([
|
|
1983
2847
|
t("bcb-patient-allergies-form")
|
|
1984
2848
|
], PatientAllergiesForm);
|
|
1985
|
-
const
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
2849
|
+
const jsonBodySerializer = {
|
|
2850
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
2851
|
+
};
|
|
2852
|
+
function createSseClient({
|
|
2853
|
+
onRequest,
|
|
2854
|
+
onSseError,
|
|
2855
|
+
onSseEvent,
|
|
2856
|
+
responseTransformer,
|
|
2857
|
+
responseValidator,
|
|
2858
|
+
sseDefaultRetryDelay,
|
|
2859
|
+
sseMaxRetryAttempts,
|
|
2860
|
+
sseMaxRetryDelay,
|
|
2861
|
+
sseSleepFn,
|
|
2862
|
+
url,
|
|
2863
|
+
...options
|
|
2864
|
+
}) {
|
|
2865
|
+
let lastEventId;
|
|
2866
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
2867
|
+
const createStream = async function* () {
|
|
2868
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
2869
|
+
let attempt = 0;
|
|
2870
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
2871
|
+
while (true) {
|
|
2872
|
+
if (signal.aborted) break;
|
|
2873
|
+
attempt++;
|
|
2874
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
2875
|
+
if (lastEventId !== void 0) {
|
|
2876
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
2877
|
+
}
|
|
2878
|
+
try {
|
|
2879
|
+
const requestInit = {
|
|
2880
|
+
redirect: "follow",
|
|
2881
|
+
...options,
|
|
2882
|
+
body: options.serializedBody,
|
|
2883
|
+
headers,
|
|
2884
|
+
signal
|
|
2885
|
+
};
|
|
2886
|
+
let request = new Request(url, requestInit);
|
|
2887
|
+
if (onRequest) {
|
|
2888
|
+
request = await onRequest(url, requestInit);
|
|
2889
|
+
}
|
|
2890
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
2891
|
+
const response = await _fetch(request);
|
|
2892
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
2893
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
2894
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
2895
|
+
let buffer = "";
|
|
2896
|
+
const abortHandler = () => {
|
|
2897
|
+
try {
|
|
2898
|
+
reader.cancel();
|
|
2899
|
+
} catch {
|
|
2900
|
+
}
|
|
2901
|
+
};
|
|
2902
|
+
signal.addEventListener("abort", abortHandler);
|
|
2903
|
+
try {
|
|
2904
|
+
while (true) {
|
|
2905
|
+
const { done, value } = await reader.read();
|
|
2906
|
+
if (done) break;
|
|
2907
|
+
buffer += value;
|
|
2908
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
2909
|
+
const chunks = buffer.split("\n\n");
|
|
2910
|
+
buffer = chunks.pop() ?? "";
|
|
2911
|
+
for (const chunk of chunks) {
|
|
2912
|
+
const lines = chunk.split("\n");
|
|
2913
|
+
const dataLines = [];
|
|
2914
|
+
let eventName;
|
|
2915
|
+
for (const line of lines) {
|
|
2916
|
+
if (line.startsWith("data:")) {
|
|
2917
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
2918
|
+
} else if (line.startsWith("event:")) {
|
|
2919
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
2920
|
+
} else if (line.startsWith("id:")) {
|
|
2921
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
2922
|
+
} else if (line.startsWith("retry:")) {
|
|
2923
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
2924
|
+
if (!Number.isNaN(parsed)) {
|
|
2925
|
+
retryDelay = parsed;
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
let data;
|
|
2930
|
+
let parsedJson = false;
|
|
2931
|
+
if (dataLines.length) {
|
|
2932
|
+
const rawData = dataLines.join("\n");
|
|
2933
|
+
try {
|
|
2934
|
+
data = JSON.parse(rawData);
|
|
2935
|
+
parsedJson = true;
|
|
2936
|
+
} catch {
|
|
2937
|
+
data = rawData;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
if (parsedJson) {
|
|
2941
|
+
if (responseValidator) {
|
|
2942
|
+
await responseValidator(data);
|
|
2943
|
+
}
|
|
2944
|
+
if (responseTransformer) {
|
|
2945
|
+
data = await responseTransformer(data);
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
onSseEvent?.({
|
|
2949
|
+
data,
|
|
2950
|
+
event: eventName,
|
|
2951
|
+
id: lastEventId,
|
|
2952
|
+
retry: retryDelay
|
|
2953
|
+
});
|
|
2954
|
+
if (dataLines.length) {
|
|
2955
|
+
yield data;
|
|
2956
|
+
}
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
} finally {
|
|
2960
|
+
signal.removeEventListener("abort", abortHandler);
|
|
2961
|
+
reader.releaseLock();
|
|
2962
|
+
}
|
|
2963
|
+
break;
|
|
2964
|
+
} catch (error) {
|
|
2965
|
+
onSseError?.(error);
|
|
2966
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
2967
|
+
break;
|
|
2968
|
+
}
|
|
2969
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
2970
|
+
await sleep(backoff);
|
|
2971
|
+
}
|
|
2972
|
+
}
|
|
2973
|
+
};
|
|
2974
|
+
const stream = createStream();
|
|
2975
|
+
return { stream };
|
|
2976
|
+
}
|
|
2977
|
+
const separatorArrayExplode = (style) => {
|
|
2978
|
+
switch (style) {
|
|
2979
|
+
case "label":
|
|
2980
|
+
return ".";
|
|
2981
|
+
case "matrix":
|
|
2982
|
+
return ";";
|
|
2983
|
+
case "simple":
|
|
2984
|
+
return ",";
|
|
2985
|
+
default:
|
|
2986
|
+
return "&";
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
const separatorArrayNoExplode = (style) => {
|
|
2990
|
+
switch (style) {
|
|
2991
|
+
case "form":
|
|
2992
|
+
return ",";
|
|
2993
|
+
case "pipeDelimited":
|
|
2994
|
+
return "|";
|
|
2995
|
+
case "spaceDelimited":
|
|
2996
|
+
return "%20";
|
|
2997
|
+
default:
|
|
2998
|
+
return ",";
|
|
2999
|
+
}
|
|
3000
|
+
};
|
|
3001
|
+
const separatorObjectExplode = (style) => {
|
|
3002
|
+
switch (style) {
|
|
3003
|
+
case "label":
|
|
3004
|
+
return ".";
|
|
3005
|
+
case "matrix":
|
|
3006
|
+
return ";";
|
|
3007
|
+
case "simple":
|
|
3008
|
+
return ",";
|
|
3009
|
+
default:
|
|
3010
|
+
return "&";
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
const serializeArrayParam = ({
|
|
3014
|
+
allowReserved,
|
|
3015
|
+
explode,
|
|
3016
|
+
name,
|
|
3017
|
+
style,
|
|
3018
|
+
value
|
|
3019
|
+
}) => {
|
|
3020
|
+
if (!explode) {
|
|
3021
|
+
const joinedValues2 = (allowReserved ? value : value.map((v2) => encodeURIComponent(v2))).join(separatorArrayNoExplode(style));
|
|
3022
|
+
switch (style) {
|
|
3023
|
+
case "label":
|
|
3024
|
+
return `.${joinedValues2}`;
|
|
3025
|
+
case "matrix":
|
|
3026
|
+
return `;${name}=${joinedValues2}`;
|
|
3027
|
+
case "simple":
|
|
3028
|
+
return joinedValues2;
|
|
3029
|
+
default:
|
|
3030
|
+
return `${name}=${joinedValues2}`;
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
const separator = separatorArrayExplode(style);
|
|
3034
|
+
const joinedValues = value.map((v2) => {
|
|
3035
|
+
if (style === "label" || style === "simple") {
|
|
3036
|
+
return allowReserved ? v2 : encodeURIComponent(v2);
|
|
3037
|
+
}
|
|
3038
|
+
return serializePrimitiveParam({
|
|
3039
|
+
allowReserved,
|
|
3040
|
+
name,
|
|
3041
|
+
value: v2
|
|
3042
|
+
});
|
|
3043
|
+
}).join(separator);
|
|
3044
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
3045
|
+
};
|
|
3046
|
+
const serializePrimitiveParam = ({
|
|
3047
|
+
allowReserved,
|
|
3048
|
+
name,
|
|
3049
|
+
value
|
|
3050
|
+
}) => {
|
|
3051
|
+
if (value === void 0 || value === null) {
|
|
3052
|
+
return "";
|
|
3053
|
+
}
|
|
3054
|
+
if (typeof value === "object") {
|
|
3055
|
+
throw new Error(
|
|
3056
|
+
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these."
|
|
3057
|
+
);
|
|
3058
|
+
}
|
|
3059
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
3060
|
+
};
|
|
3061
|
+
const serializeObjectParam = ({
|
|
3062
|
+
allowReserved,
|
|
3063
|
+
explode,
|
|
3064
|
+
name,
|
|
3065
|
+
style,
|
|
3066
|
+
value,
|
|
3067
|
+
valueOnly
|
|
3068
|
+
}) => {
|
|
3069
|
+
if (value instanceof Date) {
|
|
3070
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
3071
|
+
}
|
|
3072
|
+
if (style !== "deepObject" && !explode) {
|
|
3073
|
+
let values = [];
|
|
3074
|
+
Object.entries(value).forEach(([key, v2]) => {
|
|
3075
|
+
values = [...values, key, allowReserved ? v2 : encodeURIComponent(v2)];
|
|
3076
|
+
});
|
|
3077
|
+
const joinedValues2 = values.join(",");
|
|
3078
|
+
switch (style) {
|
|
3079
|
+
case "form":
|
|
3080
|
+
return `${name}=${joinedValues2}`;
|
|
3081
|
+
case "label":
|
|
3082
|
+
return `.${joinedValues2}`;
|
|
3083
|
+
case "matrix":
|
|
3084
|
+
return `;${name}=${joinedValues2}`;
|
|
3085
|
+
default:
|
|
3086
|
+
return joinedValues2;
|
|
3087
|
+
}
|
|
3088
|
+
}
|
|
3089
|
+
const separator = separatorObjectExplode(style);
|
|
3090
|
+
const joinedValues = Object.entries(value).map(
|
|
3091
|
+
([key, v2]) => serializePrimitiveParam({
|
|
3092
|
+
allowReserved,
|
|
3093
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
3094
|
+
value: v2
|
|
3095
|
+
})
|
|
3096
|
+
).join(separator);
|
|
3097
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
3098
|
+
};
|
|
3099
|
+
const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
3100
|
+
const defaultPathSerializer = ({ path, url: _url }) => {
|
|
3101
|
+
let url = _url;
|
|
3102
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
3103
|
+
if (matches) {
|
|
3104
|
+
for (const match of matches) {
|
|
3105
|
+
let explode = false;
|
|
3106
|
+
let name = match.substring(1, match.length - 1);
|
|
3107
|
+
let style = "simple";
|
|
3108
|
+
if (name.endsWith("*")) {
|
|
3109
|
+
explode = true;
|
|
3110
|
+
name = name.substring(0, name.length - 1);
|
|
3111
|
+
}
|
|
3112
|
+
if (name.startsWith(".")) {
|
|
3113
|
+
name = name.substring(1);
|
|
3114
|
+
style = "label";
|
|
3115
|
+
} else if (name.startsWith(";")) {
|
|
3116
|
+
name = name.substring(1);
|
|
3117
|
+
style = "matrix";
|
|
3118
|
+
}
|
|
3119
|
+
const value = path[name];
|
|
3120
|
+
if (value === void 0 || value === null) {
|
|
3121
|
+
continue;
|
|
3122
|
+
}
|
|
3123
|
+
if (Array.isArray(value)) {
|
|
3124
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
3125
|
+
continue;
|
|
3126
|
+
}
|
|
3127
|
+
if (typeof value === "object") {
|
|
3128
|
+
url = url.replace(
|
|
3129
|
+
match,
|
|
3130
|
+
serializeObjectParam({
|
|
3131
|
+
explode,
|
|
3132
|
+
name,
|
|
3133
|
+
style,
|
|
3134
|
+
value,
|
|
3135
|
+
valueOnly: true
|
|
3136
|
+
})
|
|
3137
|
+
);
|
|
3138
|
+
continue;
|
|
3139
|
+
}
|
|
3140
|
+
if (style === "matrix") {
|
|
3141
|
+
url = url.replace(
|
|
3142
|
+
match,
|
|
3143
|
+
`;${serializePrimitiveParam({
|
|
3144
|
+
name,
|
|
3145
|
+
value
|
|
3146
|
+
})}`
|
|
3147
|
+
);
|
|
3148
|
+
continue;
|
|
3149
|
+
}
|
|
3150
|
+
const replaceValue = encodeURIComponent(
|
|
3151
|
+
style === "label" ? `.${value}` : value
|
|
3152
|
+
);
|
|
3153
|
+
url = url.replace(match, replaceValue);
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
return url;
|
|
3157
|
+
};
|
|
3158
|
+
const getUrl = ({
|
|
3159
|
+
baseUrl,
|
|
3160
|
+
path,
|
|
3161
|
+
query,
|
|
3162
|
+
querySerializer,
|
|
3163
|
+
url: _url
|
|
3164
|
+
}) => {
|
|
3165
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
3166
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
3167
|
+
if (path) {
|
|
3168
|
+
url = defaultPathSerializer({ path, url });
|
|
3169
|
+
}
|
|
3170
|
+
let search = query ? querySerializer(query) : "";
|
|
3171
|
+
if (search.startsWith("?")) {
|
|
3172
|
+
search = search.substring(1);
|
|
3173
|
+
}
|
|
3174
|
+
if (search) {
|
|
3175
|
+
url += `?${search}`;
|
|
3176
|
+
}
|
|
3177
|
+
return url;
|
|
3178
|
+
};
|
|
3179
|
+
function getValidRequestBody(options) {
|
|
3180
|
+
const hasBody = options.body !== void 0;
|
|
3181
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
3182
|
+
if (isSerializedBody) {
|
|
3183
|
+
if ("serializedBody" in options) {
|
|
3184
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
3185
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
3186
|
+
}
|
|
3187
|
+
return options.body !== "" ? options.body : null;
|
|
3188
|
+
}
|
|
3189
|
+
if (hasBody) {
|
|
3190
|
+
return options.body;
|
|
3191
|
+
}
|
|
3192
|
+
return void 0;
|
|
3193
|
+
}
|
|
3194
|
+
const getAuthToken = async (auth, callback) => {
|
|
3195
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
3196
|
+
if (!token) {
|
|
3197
|
+
return;
|
|
3198
|
+
}
|
|
3199
|
+
if (auth.scheme === "bearer") {
|
|
3200
|
+
return `Bearer ${token}`;
|
|
3201
|
+
}
|
|
3202
|
+
if (auth.scheme === "basic") {
|
|
3203
|
+
return `Basic ${btoa(token)}`;
|
|
3204
|
+
}
|
|
3205
|
+
return token;
|
|
3206
|
+
};
|
|
3207
|
+
const createQuerySerializer = ({
|
|
3208
|
+
parameters = {},
|
|
3209
|
+
...args
|
|
3210
|
+
} = {}) => {
|
|
3211
|
+
const querySerializer = (queryParams) => {
|
|
3212
|
+
const search = [];
|
|
3213
|
+
if (queryParams && typeof queryParams === "object") {
|
|
3214
|
+
for (const name in queryParams) {
|
|
3215
|
+
const value = queryParams[name];
|
|
3216
|
+
if (value === void 0 || value === null) {
|
|
3217
|
+
continue;
|
|
3218
|
+
}
|
|
3219
|
+
const options = parameters[name] || args;
|
|
3220
|
+
if (Array.isArray(value)) {
|
|
3221
|
+
const serializedArray = serializeArrayParam({
|
|
3222
|
+
allowReserved: options.allowReserved,
|
|
3223
|
+
explode: true,
|
|
3224
|
+
name,
|
|
3225
|
+
style: "form",
|
|
3226
|
+
value,
|
|
3227
|
+
...options.array
|
|
3228
|
+
});
|
|
3229
|
+
if (serializedArray) search.push(serializedArray);
|
|
3230
|
+
} else if (typeof value === "object") {
|
|
3231
|
+
const serializedObject = serializeObjectParam({
|
|
3232
|
+
allowReserved: options.allowReserved,
|
|
3233
|
+
explode: true,
|
|
3234
|
+
name,
|
|
3235
|
+
style: "deepObject",
|
|
3236
|
+
value,
|
|
3237
|
+
...options.object
|
|
3238
|
+
});
|
|
3239
|
+
if (serializedObject) search.push(serializedObject);
|
|
3240
|
+
} else {
|
|
3241
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
3242
|
+
allowReserved: options.allowReserved,
|
|
3243
|
+
name,
|
|
3244
|
+
value
|
|
3245
|
+
});
|
|
3246
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
}
|
|
3250
|
+
return search.join("&");
|
|
3251
|
+
};
|
|
3252
|
+
return querySerializer;
|
|
3253
|
+
};
|
|
3254
|
+
const getParseAs = (contentType) => {
|
|
3255
|
+
if (!contentType) {
|
|
3256
|
+
return "stream";
|
|
3257
|
+
}
|
|
3258
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
3259
|
+
if (!cleanContent) {
|
|
3260
|
+
return;
|
|
3261
|
+
}
|
|
3262
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
3263
|
+
return "json";
|
|
3264
|
+
}
|
|
3265
|
+
if (cleanContent === "multipart/form-data") {
|
|
3266
|
+
return "formData";
|
|
3267
|
+
}
|
|
3268
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
3269
|
+
return "blob";
|
|
3270
|
+
}
|
|
3271
|
+
if (cleanContent.startsWith("text/")) {
|
|
3272
|
+
return "text";
|
|
3273
|
+
}
|
|
3274
|
+
return;
|
|
3275
|
+
};
|
|
3276
|
+
const checkForExistence = (options, name) => {
|
|
3277
|
+
if (!name) {
|
|
3278
|
+
return false;
|
|
3279
|
+
}
|
|
3280
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
3281
|
+
return true;
|
|
3282
|
+
}
|
|
3283
|
+
return false;
|
|
3284
|
+
};
|
|
3285
|
+
async function setAuthParams(options) {
|
|
3286
|
+
for (const auth of options.security ?? []) {
|
|
3287
|
+
if (checkForExistence(options, auth.name)) {
|
|
3288
|
+
continue;
|
|
3289
|
+
}
|
|
3290
|
+
const token = await getAuthToken(auth, options.auth);
|
|
3291
|
+
if (!token) {
|
|
3292
|
+
continue;
|
|
3293
|
+
}
|
|
3294
|
+
const name = auth.name ?? "Authorization";
|
|
3295
|
+
switch (auth.in) {
|
|
3296
|
+
case "query":
|
|
3297
|
+
if (!options.query) {
|
|
3298
|
+
options.query = {};
|
|
3299
|
+
}
|
|
3300
|
+
options.query[name] = token;
|
|
3301
|
+
break;
|
|
3302
|
+
case "cookie":
|
|
3303
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
3304
|
+
break;
|
|
3305
|
+
case "header":
|
|
3306
|
+
default:
|
|
3307
|
+
options.headers.set(name, token);
|
|
3308
|
+
break;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
const buildUrl = (options) => getUrl({
|
|
3313
|
+
baseUrl: options.baseUrl,
|
|
3314
|
+
path: options.path,
|
|
3315
|
+
query: options.query,
|
|
3316
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
3317
|
+
url: options.url
|
|
3318
|
+
});
|
|
3319
|
+
const mergeConfigs = (a2, b2) => {
|
|
3320
|
+
const config = { ...a2, ...b2 };
|
|
3321
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
3322
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
3323
|
+
}
|
|
3324
|
+
config.headers = mergeHeaders(a2.headers, b2.headers);
|
|
3325
|
+
return config;
|
|
3326
|
+
};
|
|
3327
|
+
const headersEntries = (headers) => {
|
|
3328
|
+
const entries = [];
|
|
3329
|
+
headers.forEach((value, key) => {
|
|
3330
|
+
entries.push([key, value]);
|
|
3331
|
+
});
|
|
3332
|
+
return entries;
|
|
3333
|
+
};
|
|
3334
|
+
const mergeHeaders = (...headers) => {
|
|
3335
|
+
const mergedHeaders = new Headers();
|
|
3336
|
+
for (const header of headers) {
|
|
3337
|
+
if (!header) {
|
|
3338
|
+
continue;
|
|
3339
|
+
}
|
|
3340
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
3341
|
+
for (const [key, value] of iterator) {
|
|
3342
|
+
if (value === null) {
|
|
3343
|
+
mergedHeaders.delete(key);
|
|
3344
|
+
} else if (Array.isArray(value)) {
|
|
3345
|
+
for (const v2 of value) {
|
|
3346
|
+
mergedHeaders.append(key, v2);
|
|
3347
|
+
}
|
|
3348
|
+
} else if (value !== void 0) {
|
|
3349
|
+
mergedHeaders.set(
|
|
3350
|
+
key,
|
|
3351
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
3352
|
+
);
|
|
3353
|
+
}
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
return mergedHeaders;
|
|
3357
|
+
};
|
|
3358
|
+
class Interceptors2 {
|
|
3359
|
+
constructor() {
|
|
3360
|
+
this.fns = [];
|
|
3361
|
+
}
|
|
3362
|
+
clear() {
|
|
3363
|
+
this.fns = [];
|
|
3364
|
+
}
|
|
3365
|
+
eject(id) {
|
|
3366
|
+
const index = this.getInterceptorIndex(id);
|
|
3367
|
+
if (this.fns[index]) {
|
|
3368
|
+
this.fns[index] = null;
|
|
3369
|
+
}
|
|
3370
|
+
}
|
|
3371
|
+
exists(id) {
|
|
3372
|
+
const index = this.getInterceptorIndex(id);
|
|
3373
|
+
return Boolean(this.fns[index]);
|
|
3374
|
+
}
|
|
3375
|
+
getInterceptorIndex(id) {
|
|
3376
|
+
if (typeof id === "number") {
|
|
3377
|
+
return this.fns[id] ? id : -1;
|
|
3378
|
+
}
|
|
3379
|
+
return this.fns.indexOf(id);
|
|
3380
|
+
}
|
|
3381
|
+
update(id, fn) {
|
|
3382
|
+
const index = this.getInterceptorIndex(id);
|
|
3383
|
+
if (this.fns[index]) {
|
|
3384
|
+
this.fns[index] = fn;
|
|
3385
|
+
return id;
|
|
3386
|
+
}
|
|
3387
|
+
return false;
|
|
3388
|
+
}
|
|
3389
|
+
use(fn) {
|
|
3390
|
+
this.fns.push(fn);
|
|
3391
|
+
return this.fns.length - 1;
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
const createInterceptors = () => ({
|
|
3395
|
+
error: new Interceptors2(),
|
|
3396
|
+
request: new Interceptors2(),
|
|
3397
|
+
response: new Interceptors2()
|
|
3398
|
+
});
|
|
3399
|
+
const defaultQuerySerializer = createQuerySerializer({
|
|
3400
|
+
allowReserved: false,
|
|
3401
|
+
array: {
|
|
3402
|
+
explode: true,
|
|
3403
|
+
style: "form"
|
|
3404
|
+
},
|
|
3405
|
+
object: {
|
|
3406
|
+
explode: true,
|
|
3407
|
+
style: "deepObject"
|
|
3408
|
+
}
|
|
3409
|
+
});
|
|
3410
|
+
const defaultHeaders = {
|
|
3411
|
+
"Content-Type": "application/json"
|
|
3412
|
+
};
|
|
3413
|
+
const createConfig = (override = {}) => ({
|
|
3414
|
+
...jsonBodySerializer,
|
|
3415
|
+
headers: defaultHeaders,
|
|
3416
|
+
parseAs: "auto",
|
|
3417
|
+
querySerializer: defaultQuerySerializer,
|
|
3418
|
+
...override
|
|
3419
|
+
});
|
|
3420
|
+
const createClient = (config = {}) => {
|
|
3421
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
3422
|
+
const getConfig = () => ({ ..._config });
|
|
3423
|
+
const setConfig = (config2) => {
|
|
3424
|
+
_config = mergeConfigs(_config, config2);
|
|
3425
|
+
return getConfig();
|
|
3426
|
+
};
|
|
3427
|
+
const interceptors = createInterceptors();
|
|
3428
|
+
const beforeRequest = async (options) => {
|
|
3429
|
+
const opts = {
|
|
3430
|
+
..._config,
|
|
3431
|
+
...options,
|
|
3432
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
3433
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
3434
|
+
serializedBody: void 0
|
|
3435
|
+
};
|
|
3436
|
+
if (opts.security) {
|
|
3437
|
+
await setAuthParams(opts);
|
|
3438
|
+
}
|
|
3439
|
+
if (opts.requestValidator) {
|
|
3440
|
+
await opts.requestValidator(opts);
|
|
3441
|
+
}
|
|
3442
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
3443
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
3444
|
+
}
|
|
3445
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
3446
|
+
opts.headers.delete("Content-Type");
|
|
3447
|
+
}
|
|
3448
|
+
const resolvedOpts = opts;
|
|
3449
|
+
const url = buildUrl(resolvedOpts);
|
|
3450
|
+
return { opts: resolvedOpts, url };
|
|
3451
|
+
};
|
|
3452
|
+
const request = async (options) => {
|
|
3453
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
3454
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
3455
|
+
let request2;
|
|
3456
|
+
let response;
|
|
3457
|
+
try {
|
|
3458
|
+
const { opts, url } = await beforeRequest(options);
|
|
3459
|
+
const requestInit = {
|
|
3460
|
+
redirect: "follow",
|
|
3461
|
+
...opts,
|
|
3462
|
+
body: getValidRequestBody(opts)
|
|
3463
|
+
};
|
|
3464
|
+
request2 = new Request(url, requestInit);
|
|
3465
|
+
for (const fn of interceptors.request.fns) {
|
|
3466
|
+
if (fn) {
|
|
3467
|
+
request2 = await fn(request2, opts);
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
const _fetch = opts.fetch;
|
|
3471
|
+
response = await _fetch(request2);
|
|
3472
|
+
for (const fn of interceptors.response.fns) {
|
|
3473
|
+
if (fn) {
|
|
3474
|
+
response = await fn(response, request2, opts);
|
|
3475
|
+
}
|
|
3476
|
+
}
|
|
3477
|
+
const result = {
|
|
3478
|
+
request: request2,
|
|
3479
|
+
response
|
|
3480
|
+
};
|
|
3481
|
+
if (response.ok) {
|
|
3482
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
3483
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
3484
|
+
let emptyData;
|
|
3485
|
+
switch (parseAs) {
|
|
3486
|
+
case "arrayBuffer":
|
|
3487
|
+
case "blob":
|
|
3488
|
+
case "text":
|
|
3489
|
+
emptyData = await response[parseAs]();
|
|
3490
|
+
break;
|
|
3491
|
+
case "formData":
|
|
3492
|
+
emptyData = new FormData();
|
|
3493
|
+
break;
|
|
3494
|
+
case "stream":
|
|
3495
|
+
emptyData = response.body;
|
|
3496
|
+
break;
|
|
3497
|
+
case "json":
|
|
3498
|
+
default:
|
|
3499
|
+
emptyData = {};
|
|
3500
|
+
break;
|
|
3501
|
+
}
|
|
3502
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
3503
|
+
data: emptyData,
|
|
3504
|
+
...result
|
|
3505
|
+
};
|
|
3506
|
+
}
|
|
3507
|
+
let data;
|
|
3508
|
+
switch (parseAs) {
|
|
3509
|
+
case "arrayBuffer":
|
|
3510
|
+
case "blob":
|
|
3511
|
+
case "formData":
|
|
3512
|
+
case "text":
|
|
3513
|
+
data = await response[parseAs]();
|
|
3514
|
+
break;
|
|
3515
|
+
case "json": {
|
|
3516
|
+
const text = await response.text();
|
|
3517
|
+
data = text ? JSON.parse(text) : {};
|
|
3518
|
+
break;
|
|
3519
|
+
}
|
|
3520
|
+
case "stream":
|
|
3521
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
3522
|
+
data: response.body,
|
|
3523
|
+
...result
|
|
3524
|
+
};
|
|
3525
|
+
}
|
|
3526
|
+
if (parseAs === "json") {
|
|
3527
|
+
if (opts.responseValidator) {
|
|
3528
|
+
await opts.responseValidator(data);
|
|
3529
|
+
}
|
|
3530
|
+
if (opts.responseTransformer) {
|
|
3531
|
+
data = await opts.responseTransformer(data);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
return opts.responseStyle === "data" ? data : {
|
|
3535
|
+
data,
|
|
3536
|
+
...result
|
|
3537
|
+
};
|
|
3538
|
+
}
|
|
3539
|
+
const textError = await response.text();
|
|
3540
|
+
let jsonError;
|
|
3541
|
+
try {
|
|
3542
|
+
jsonError = JSON.parse(textError);
|
|
3543
|
+
} catch {
|
|
3544
|
+
}
|
|
3545
|
+
throw jsonError ?? textError;
|
|
3546
|
+
} catch (error) {
|
|
3547
|
+
let finalError = error;
|
|
3548
|
+
for (const fn of interceptors.error.fns) {
|
|
3549
|
+
if (fn) {
|
|
3550
|
+
finalError = await fn(finalError, response, request2, options);
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
finalError = finalError || {};
|
|
3554
|
+
if (throwOnError) {
|
|
3555
|
+
throw finalError;
|
|
3556
|
+
}
|
|
3557
|
+
return responseStyle === "data" ? void 0 : {
|
|
3558
|
+
error: finalError,
|
|
3559
|
+
request: request2,
|
|
3560
|
+
response
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
};
|
|
3564
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
3565
|
+
const makeSseFn = (method) => async (options) => {
|
|
3566
|
+
const { opts, url } = await beforeRequest(options);
|
|
3567
|
+
return createSseClient({
|
|
3568
|
+
...opts,
|
|
3569
|
+
body: opts.body,
|
|
3570
|
+
method,
|
|
3571
|
+
onRequest: async (url2, init) => {
|
|
3572
|
+
let request2 = new Request(url2, init);
|
|
3573
|
+
for (const fn of interceptors.request.fns) {
|
|
3574
|
+
if (fn) {
|
|
3575
|
+
request2 = await fn(request2, opts);
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
return request2;
|
|
3579
|
+
},
|
|
3580
|
+
serializedBody: getValidRequestBody(opts),
|
|
3581
|
+
url
|
|
3582
|
+
});
|
|
3583
|
+
};
|
|
3584
|
+
const _buildUrl = (options) => buildUrl({ ..._config, ...options });
|
|
3585
|
+
return {
|
|
3586
|
+
buildUrl: _buildUrl,
|
|
3587
|
+
connect: makeMethodFn("CONNECT"),
|
|
3588
|
+
delete: makeMethodFn("DELETE"),
|
|
3589
|
+
get: makeMethodFn("GET"),
|
|
3590
|
+
getConfig,
|
|
3591
|
+
head: makeMethodFn("HEAD"),
|
|
3592
|
+
interceptors,
|
|
3593
|
+
options: makeMethodFn("OPTIONS"),
|
|
3594
|
+
patch: makeMethodFn("PATCH"),
|
|
3595
|
+
post: makeMethodFn("POST"),
|
|
3596
|
+
put: makeMethodFn("PUT"),
|
|
3597
|
+
request,
|
|
3598
|
+
setConfig,
|
|
3599
|
+
sse: {
|
|
3600
|
+
connect: makeSseFn("CONNECT"),
|
|
3601
|
+
delete: makeSseFn("DELETE"),
|
|
3602
|
+
get: makeSseFn("GET"),
|
|
3603
|
+
head: makeSseFn("HEAD"),
|
|
3604
|
+
options: makeSseFn("OPTIONS"),
|
|
3605
|
+
patch: makeSseFn("PATCH"),
|
|
3606
|
+
post: makeSseFn("POST"),
|
|
3607
|
+
put: makeSseFn("PUT"),
|
|
3608
|
+
trace: makeSseFn("TRACE")
|
|
1990
3609
|
},
|
|
1991
|
-
|
|
3610
|
+
trace: makeMethodFn("TRACE")
|
|
3611
|
+
};
|
|
3612
|
+
};
|
|
3613
|
+
const client = createClient(createConfig({ baseUrl: "https://api-dev.claudebernard.fr/prescription" }));
|
|
3614
|
+
const convertRenalInsufficiency$1 = (options) => (options.client ?? client).post({
|
|
3615
|
+
url: "/patient/fhir/renal-insufficiency-conversion",
|
|
3616
|
+
...options,
|
|
3617
|
+
headers: {
|
|
3618
|
+
"Content-Type": "application/json",
|
|
3619
|
+
...options.headers
|
|
3620
|
+
}
|
|
3621
|
+
});
|
|
3622
|
+
client.interceptors.request.use(attachTracingHeaders);
|
|
3623
|
+
const convertRenalInsufficiency = async (type, value, patient, apiUrl, context) => {
|
|
3624
|
+
client.setConfig({ baseUrl: `${apiUrl}/prescription` });
|
|
3625
|
+
setActiveContext(context);
|
|
3626
|
+
const response = await convertRenalInsufficiency$1({
|
|
3627
|
+
body: {
|
|
1992
3628
|
typeEntree: type,
|
|
1993
3629
|
valeur: value,
|
|
1994
3630
|
patient
|
|
1995
|
-
}
|
|
3631
|
+
}
|
|
1996
3632
|
});
|
|
1997
|
-
|
|
3633
|
+
if (!response.data) {
|
|
3634
|
+
throw new Error(`HTTP error! status: ${response.response?.status}`);
|
|
3635
|
+
}
|
|
3636
|
+
return response.data;
|
|
1998
3637
|
};
|
|
1999
3638
|
const patientRenalFormCSS = ".claudebernard-edition-modal {\n font-size: 0.9rem;\n}\n.claudebernard-edition-modal-large-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n width: 100%;\n}\n.claudebernard-edition-modal-information-section {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex-wrap: wrap;\n}\n.claudebernard-edition-modal-information-section span {\n white-space: nowrap;\n}\n.claudebernard-edition-modal-information-section-secondary-group {\n display: flex;\n flex-direction: row;\n gap: 16px;\n flex: 3;\n flex-wrap: wrap;\n}\n@media (max-width: 950px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n flex-basis: 100%;\n }\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-information-section-secondary-group {\n display: contents;\n }\n}\n.claudebernard-edition-modal-little-section {\n display: flex;\n flex-direction: column;\n gap: 5px;\n flex: 1;\n min-width: 0;\n}\n.claudebernard-edition-modal-little-section bcbd-input {\n height: 100%;\n}\n@media (max-width: 600px) {\n .claudebernard-edition-modal-little-section {\n flex: 1 1 calc(50% - 8px);\n }\n .claudebernard-edition-modal-little-section span {\n white-space: nowrap;\n }\n}\n.claudebernard-edition-modal-little-section__with-info {\n display: flex;\n flex-direction: row;\n align-items: center;\n height: 16px;\n gap: 8px;\n}\n.claudebernard-edition-modal-little-section__with-info bcbd-icon {\n --bcbd-icon-width: 1rem;\n --bcbd-icon-height: 1rem;\n}\n.claudebernard-edition-modal-subtitle {\n font-weight: 600;\n font-size: 1.1rem;\n color: var(--bcbd-primary-color, #0C75AD);\n}\n.claudebernard-edition-modal-error-message {\n color: var(--bcbd-danger-color, #CF406E);\n font-size: 0.8rem;\n}\n.claudebernard-edition-modal-fieldset {\n border: 1px solid var(--bcbd-border-gray-color, #CBD5E1);\n margin-inline: 0;\n border-radius: 4px;\n padding: 16px;\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\nbcbd-checkbox {\n --bcbd-checkbox-font-size: .9rem;\n}";
|
|
2000
3639
|
var __defProp$3 = Object.defineProperty;
|
|
@@ -2063,7 +3702,8 @@ let PatientRenalForm = class extends i$2 {
|
|
|
2063
3702
|
type,
|
|
2064
3703
|
value,
|
|
2065
3704
|
this.buildConversionPatient(),
|
|
2066
|
-
this.apiUrl
|
|
3705
|
+
this.apiUrl,
|
|
3706
|
+
this.context
|
|
2067
3707
|
);
|
|
2068
3708
|
if (result.error) {
|
|
2069
3709
|
this.renalLackInformationErrorMessage = result.error;
|
|
@@ -2152,6 +3792,9 @@ __decorateClass$3([
|
|
|
2152
3792
|
__decorateClass$3([
|
|
2153
3793
|
n2({ type: String, attribute: "api-url" })
|
|
2154
3794
|
], PatientRenalForm.prototype, "apiUrl", 2);
|
|
3795
|
+
__decorateClass$3([
|
|
3796
|
+
n2({ type: Object })
|
|
3797
|
+
], PatientRenalForm.prototype, "context", 2);
|
|
2155
3798
|
__decorateClass$3([
|
|
2156
3799
|
n2({ type: Object })
|
|
2157
3800
|
], PatientRenalForm.prototype, "demographics", 2);
|
|
@@ -2358,11 +4001,11 @@ let PatientProfileEdition = class extends i$2 {
|
|
|
2358
4001
|
|
|
2359
4002
|
<bcb-patient-reproductive-form .patientProfile=${this.patientProfile} .visible=${this.isPregnancyDivVisible}></bcb-patient-reproductive-form>
|
|
2360
4003
|
|
|
2361
|
-
<bcb-patient-pathologies-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .preferences=${this.preferences}></bcb-patient-pathologies-form>
|
|
4004
|
+
<bcb-patient-pathologies-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .context=${this.context} .preferences=${this.preferences}></bcb-patient-pathologies-form>
|
|
2362
4005
|
|
|
2363
|
-
<bcb-patient-allergies-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl}></bcb-patient-allergies-form>
|
|
4006
|
+
<bcb-patient-allergies-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .context=${this.context}></bcb-patient-allergies-form>
|
|
2364
4007
|
|
|
2365
|
-
<bcb-patient-renal-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl}></bcb-patient-renal-form>
|
|
4008
|
+
<bcb-patient-renal-form .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .context=${this.context}></bcb-patient-renal-form>
|
|
2366
4009
|
|
|
2367
4010
|
<bcb-patient-hepatic-form .patientProfile=${this.patientProfile}></bcb-patient-hepatic-form>
|
|
2368
4011
|
|
|
@@ -2390,6 +4033,9 @@ __decorateClass$1([
|
|
|
2390
4033
|
__decorateClass$1([
|
|
2391
4034
|
n2({ type: String, attribute: "api-key" })
|
|
2392
4035
|
], PatientProfileEdition.prototype, "apiKey", 2);
|
|
4036
|
+
__decorateClass$1([
|
|
4037
|
+
n2({ type: Object })
|
|
4038
|
+
], PatientProfileEdition.prototype, "context", 2);
|
|
2393
4039
|
__decorateClass$1([
|
|
2394
4040
|
n2({ type: Object })
|
|
2395
4041
|
], PatientProfileEdition.prototype, "preferences", 2);
|
|
@@ -2651,8 +4297,8 @@ let PatientProfile = class extends i$2 {
|
|
|
2651
4297
|
${this.editButtonVisible || this.editButtonVisible === void 0 ? b`<bcbd-button icon="pencil" size="medium" background-color="primary" outlined aria-label="Modifier le profil patient" data-test-id="modify-button" @click=${this.openEditionModal}></bcbd-button>` : A}
|
|
2652
4298
|
` : b`
|
|
2653
4299
|
<div class="${PREFIX}-patient-profile__id-info-container">
|
|
2654
|
-
<div class="${PREFIX}-patient-profile__name-info" data-test-id="patient-name">
|
|
2655
|
-
${getPatientName(this.patientProfile)}
|
|
4300
|
+
<div class="${PREFIX}-patient-profile__name-info" data-test-id="patient-name" title=${o(getPatientName(this.patientProfile))}>
|
|
4301
|
+
${getPatientName(this.patientProfile)}
|
|
2656
4302
|
</div>
|
|
2657
4303
|
${getPatientGender(this.patientProfile) === void 0 && this.getPatientAge() === null ? A : b`
|
|
2658
4304
|
<div class="${PREFIX}-patient-profile__id-info">
|
|
@@ -2703,8 +4349,14 @@ let PatientProfile = class extends i$2 {
|
|
|
2703
4349
|
</div>
|
|
2704
4350
|
|
|
2705
4351
|
<div class="${PREFIX}-patient-profile__action-buttons-container" data-test-id="action-buttons">
|
|
2706
|
-
${this.editButtonVisible || this.editButtonVisible === void 0 ? b
|
|
2707
|
-
|
|
4352
|
+
${this.editButtonVisible || this.editButtonVisible === void 0 ? b`
|
|
4353
|
+
<bcbd-tooltip content="Editer le profil patient" placement="top">
|
|
4354
|
+
<bcbd-button icon="pencil" size="medium" background-color="primary" outlined aria-label="Editer le profil patient" data-test-id="modify-button" @click=${this.openEditionModal}></bcbd-button>
|
|
4355
|
+
</bcbd-tooltip>
|
|
4356
|
+
` : A}
|
|
4357
|
+
<bcbd-tooltip content="Déplier le profil patient" placement="top">
|
|
4358
|
+
<bcbd-button icon=${this.moreInformationVisible ? "chevron-up" : "chevron-down"} size="medium" background-color="primary" aria-label=${this.moreInformationVisible ? "Masquer les informations supplémentaires" : "Afficher les informations supplémentaires"} @click=${this.handleMoreInformation} data-test-id="visible-button"></bcbd-button>
|
|
4359
|
+
</bcbd-tooltip>
|
|
2708
4360
|
</div>`}
|
|
2709
4361
|
</div>
|
|
2710
4362
|
<div class="${PREFIX}-patient-profile__alert-container" data-test-id="alert-container">
|
|
@@ -2737,7 +4389,7 @@ let PatientProfile = class extends i$2 {
|
|
|
2737
4389
|
</div>
|
|
2738
4390
|
</div>
|
|
2739
4391
|
<bcb-patient-profile-edition .patientProfile=${this.patientProfile} .apiUrl=${this.apiUrl} .apiKey=${this.apiKey}
|
|
2740
|
-
.preferences=${this.preferences}
|
|
4392
|
+
.preferences=${this.preferences} .context=${this.context}
|
|
2741
4393
|
@editPatientProfile=${this.editProfilePatient}></bcb-patient-profile-edition>
|
|
2742
4394
|
`;
|
|
2743
4395
|
}
|
|
@@ -2755,6 +4407,9 @@ __decorateClass([
|
|
|
2755
4407
|
__decorateClass([
|
|
2756
4408
|
n2({ type: String, attribute: "api-key" })
|
|
2757
4409
|
], PatientProfile.prototype, "apiKey", 2);
|
|
4410
|
+
__decorateClass([
|
|
4411
|
+
n2({ type: Object })
|
|
4412
|
+
], PatientProfile.prototype, "context", 2);
|
|
2758
4413
|
__decorateClass([
|
|
2759
4414
|
n2({ type: Object })
|
|
2760
4415
|
], PatientProfile.prototype, "preferences", 2);
|