@oazapfts/runtime
Advanced tools
Comparing version 1.0.3 to 1.0.4
44
index.js
import { form as w } from "./query.js"; | ||
import { joinUrl as b } from "./util.js"; | ||
import { mergeHeaders as d, normalizeHeaders as h } from "./headers.js"; | ||
function J(a = {}) { | ||
function J(o = {}) { | ||
async function e(r, n) { | ||
@@ -20,3 +20,3 @@ const t = await p(r, n); | ||
async function i(r, n = {}) { | ||
const { status: t, headers: s, contentType: u, data: o } = await e(r, { | ||
const { status: t, headers: s, contentType: u, data: c } = await e(r, { | ||
...n, | ||
@@ -33,4 +33,4 @@ headers: d( | ||
headers: s, | ||
data: o ? JSON.parse(o) : null | ||
} : { status: t, headers: s, data: o }; | ||
data: c ? JSON.parse(c) : null | ||
} : { status: t, headers: s, data: c }; | ||
} | ||
@@ -52,7 +52,7 @@ async function f(r, n = {}) { | ||
} = { | ||
...a, | ||
...o, | ||
...n, | ||
headers: d(a.headers, n.headers) | ||
}, o = b(t, r); | ||
return await (s || fetch)(o, u); | ||
headers: d(o.headers, n.headers) | ||
}, c = b(t, r); | ||
return await (s || fetch)(c, u); | ||
} | ||
@@ -92,10 +92,10 @@ return { | ||
return { ...t, body: r, headers: h(n) }; | ||
const s = new (a.formDataConstructor || t.formDataConstructor || FormData)(), u = (o, c) => { | ||
typeof c == "string" || c instanceof Blob ? s.append(o, c) : typeof c == "number" ? s.append(o, String(c)) : s.append( | ||
o, | ||
new Blob([JSON.stringify(c)], { type: "application/json" }) | ||
const s = new (o.formDataConstructor || t.formDataConstructor || FormData)(), u = (c, a) => { | ||
typeof a == "string" || a instanceof Blob ? s.append(c, a) : typeof a == "number" || typeof a == "boolean" ? s.append(c, String(a)) : s.append( | ||
c, | ||
new Blob([JSON.stringify(a)], { type: "application/json" }) | ||
); | ||
}; | ||
return Object.entries(r).forEach(([o, c]) => { | ||
Array.isArray(c) ? c.forEach((m) => u(o, m)) : u(o, c); | ||
return Object.entries(r).forEach(([c, a]) => { | ||
Array.isArray(a) ? a.forEach((m) => u(c, m)) : u(c, a); | ||
}), { | ||
@@ -109,4 +109,4 @@ ...t, | ||
} | ||
async function O(a, e) { | ||
const { status: i, data: f, headers: p } = await a, r = e[i]; | ||
async function O(o, e) { | ||
const { status: i, data: f, headers: p } = await o, r = e[i]; | ||
if (r) | ||
@@ -119,4 +119,4 @@ return r(f); | ||
const j = [200, 201, 202, 204]; | ||
async function y(a) { | ||
const e = await a; | ||
async function y(o) { | ||
const e = await o; | ||
if (j.some((i) => i == e.status)) | ||
@@ -126,8 +126,8 @@ return e.data; | ||
} | ||
function E(a) { | ||
return (...e) => y(a(...e)); | ||
function E(o) { | ||
return (...e) => y(o(...e)); | ||
} | ||
function x(a) { | ||
function x(o) { | ||
const e = {}; | ||
return Object.entries(a).forEach(([i, f]) => { | ||
return Object.entries(o).forEach(([i, f]) => { | ||
e[i] = typeof f == "function" ? E(f) : f; | ||
@@ -134,0 +134,0 @@ }), e; |
{ | ||
"name": "@oazapfts/runtime", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Runtime for OpenApi TypeScript client generator", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65117