@tidal-music/api 0.2.0 → 0.4.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/README.md +1 -0
- package/dist/index.d.ts +3088 -9420
- package/dist/index.js +211 -196
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,180 +1,196 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
return typeof process == "object" && Number.parseInt((t = (r = process == null ? void 0 : process.versions) == null ? void 0 : r.node) == null ? void 0 : t.substring(0, 2)) >= 18 && process.versions.undici;
|
|
4
|
-
};
|
|
5
|
-
function M() {
|
|
1
|
+
const M = /\{[^{}]+\}/g, W = () => typeof process == "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
|
|
2
|
+
function Q() {
|
|
6
3
|
return Math.random().toString(36).slice(2, 11);
|
|
7
4
|
}
|
|
8
|
-
function
|
|
5
|
+
function G(o) {
|
|
9
6
|
let {
|
|
10
7
|
baseUrl: t = "",
|
|
11
8
|
Request: e = globalThis.Request,
|
|
12
|
-
fetch:
|
|
13
|
-
querySerializer:
|
|
14
|
-
bodySerializer:
|
|
9
|
+
fetch: n = globalThis.fetch,
|
|
10
|
+
querySerializer: r,
|
|
11
|
+
bodySerializer: i,
|
|
15
12
|
headers: l,
|
|
16
|
-
requestInitExt:
|
|
17
|
-
...
|
|
18
|
-
} = { ...
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
async function
|
|
13
|
+
requestInitExt: c = void 0,
|
|
14
|
+
...B
|
|
15
|
+
} = { ...o };
|
|
16
|
+
c = W() ? c : void 0, t = P(t);
|
|
17
|
+
const p = [];
|
|
18
|
+
async function y(a, s) {
|
|
22
19
|
const {
|
|
23
20
|
baseUrl: m,
|
|
24
|
-
fetch:
|
|
25
|
-
Request:
|
|
26
|
-
headers:
|
|
21
|
+
fetch: z = n,
|
|
22
|
+
Request: V = e,
|
|
23
|
+
headers: q,
|
|
27
24
|
params: w = {},
|
|
28
|
-
parseAs:
|
|
29
|
-
querySerializer:
|
|
30
|
-
bodySerializer:
|
|
31
|
-
body:
|
|
32
|
-
|
|
25
|
+
parseAs: A = "json",
|
|
26
|
+
querySerializer: g,
|
|
27
|
+
bodySerializer: O = i ?? _,
|
|
28
|
+
body: I,
|
|
29
|
+
...$
|
|
33
30
|
} = s || {};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...
|
|
31
|
+
let C = t;
|
|
32
|
+
m && (C = P(m) ?? t);
|
|
33
|
+
let v = typeof r == "function" ? r : H(r);
|
|
34
|
+
g && (v = typeof g == "function" ? g : H({
|
|
35
|
+
...typeof r == "object" ? r : {},
|
|
36
|
+
...g
|
|
39
37
|
}));
|
|
40
|
-
const
|
|
38
|
+
const U = I === void 0 ? void 0 : O(
|
|
39
|
+
I,
|
|
40
|
+
// Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
|
|
41
|
+
// bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
|
|
42
|
+
// the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
|
|
43
|
+
// setting the content-type at the very beginning to be overwritten.
|
|
44
|
+
// Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
|
|
45
|
+
D(l, q, w.header)
|
|
46
|
+
), F = D(
|
|
41
47
|
// with no body, we should not to set Content-Type
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
U === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
|
|
49
|
+
U instanceof FormData ? {} : {
|
|
44
50
|
"Content-Type": "application/json"
|
|
45
|
-
}
|
|
51
|
+
},
|
|
52
|
+
l,
|
|
53
|
+
q,
|
|
54
|
+
w.header
|
|
46
55
|
), N = {
|
|
47
56
|
redirect: "follow",
|
|
48
|
-
...
|
|
49
|
-
|
|
50
|
-
body:
|
|
51
|
-
headers:
|
|
57
|
+
...B,
|
|
58
|
+
...$,
|
|
59
|
+
body: U,
|
|
60
|
+
headers: F
|
|
52
61
|
};
|
|
53
|
-
let
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
let j, E, h = new e(
|
|
63
|
+
K(a, { baseUrl: C, params: w, querySerializer: v }),
|
|
64
|
+
N
|
|
65
|
+
), f;
|
|
66
|
+
for (const d in $)
|
|
67
|
+
d in h || (h[d] = $[d]);
|
|
68
|
+
if (p.length) {
|
|
69
|
+
j = Q(), E = Object.freeze({
|
|
70
|
+
baseUrl: C,
|
|
71
|
+
fetch: z,
|
|
72
|
+
parseAs: A,
|
|
73
|
+
querySerializer: v,
|
|
74
|
+
bodySerializer: O
|
|
63
75
|
});
|
|
64
|
-
for (const
|
|
65
|
-
if (
|
|
66
|
-
const
|
|
67
|
-
request:
|
|
76
|
+
for (const d of p)
|
|
77
|
+
if (d && typeof d == "object" && typeof d.onRequest == "function") {
|
|
78
|
+
const u = await d.onRequest({
|
|
79
|
+
request: h,
|
|
68
80
|
schemaPath: a,
|
|
69
81
|
params: w,
|
|
70
82
|
options: E,
|
|
71
|
-
id:
|
|
83
|
+
id: j
|
|
72
84
|
});
|
|
73
|
-
if (
|
|
74
|
-
if (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
85
|
+
if (u)
|
|
86
|
+
if (u instanceof e)
|
|
87
|
+
h = u;
|
|
88
|
+
else if (u instanceof Response) {
|
|
89
|
+
f = u;
|
|
90
|
+
break;
|
|
91
|
+
} else
|
|
92
|
+
throw new Error("onRequest: must return new Request() or Response() when modifying the request");
|
|
78
93
|
}
|
|
79
94
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
if (!f) {
|
|
96
|
+
try {
|
|
97
|
+
f = await z(h, c);
|
|
98
|
+
} catch (d) {
|
|
99
|
+
let u = d;
|
|
100
|
+
if (p.length)
|
|
101
|
+
for (let b = p.length - 1; b >= 0; b--) {
|
|
102
|
+
const T = p[b];
|
|
103
|
+
if (T && typeof T == "object" && typeof T.onError == "function") {
|
|
104
|
+
const R = await T.onError({
|
|
105
|
+
request: h,
|
|
106
|
+
error: u,
|
|
107
|
+
schemaPath: a,
|
|
108
|
+
params: w,
|
|
109
|
+
options: E,
|
|
110
|
+
id: j
|
|
111
|
+
});
|
|
112
|
+
if (R) {
|
|
113
|
+
if (R instanceof Response) {
|
|
114
|
+
u = void 0, f = R;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
if (R instanceof Error) {
|
|
118
|
+
u = R;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
throw new Error("onError: must return new Response() or instance of Error");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (u)
|
|
126
|
+
throw u;
|
|
127
|
+
}
|
|
128
|
+
if (p.length)
|
|
129
|
+
for (let d = p.length - 1; d >= 0; d--) {
|
|
130
|
+
const u = p[d];
|
|
131
|
+
if (u && typeof u == "object" && typeof u.onResponse == "function") {
|
|
132
|
+
const b = await u.onResponse({
|
|
133
|
+
request: h,
|
|
134
|
+
response: f,
|
|
92
135
|
schemaPath: a,
|
|
93
136
|
params: w,
|
|
94
137
|
options: E,
|
|
95
|
-
id:
|
|
138
|
+
id: j
|
|
96
139
|
});
|
|
97
|
-
if (
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
if (R instanceof Error) {
|
|
103
|
-
d = R;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
throw new Error("onError: must return new Response() or instance of Error");
|
|
140
|
+
if (b) {
|
|
141
|
+
if (!(b instanceof Response))
|
|
142
|
+
throw new Error("onResponse: must return new Response() when modifying the response");
|
|
143
|
+
f = b;
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
146
|
}
|
|
110
|
-
if (d)
|
|
111
|
-
throw d;
|
|
112
147
|
}
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
request: b,
|
|
119
|
-
response: c,
|
|
120
|
-
schemaPath: a,
|
|
121
|
-
params: w,
|
|
122
|
-
options: E,
|
|
123
|
-
id: g
|
|
124
|
-
});
|
|
125
|
-
if (p) {
|
|
126
|
-
if (!(p instanceof Response))
|
|
127
|
-
throw new Error("onResponse: must return new Response() when modifying the response");
|
|
128
|
-
c = p;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (c.status === 204 || c.headers.get("Content-Length") === "0")
|
|
133
|
-
return c.ok ? { data: void 0, response: c } : { error: void 0, response: c };
|
|
134
|
-
if (c.ok)
|
|
135
|
-
return S === "stream" ? { data: c.body, response: c } : { data: await c[S](), response: c };
|
|
136
|
-
let T = await c.text();
|
|
148
|
+
if (f.status === 204 || h.method === "HEAD" || f.headers.get("Content-Length") === "0")
|
|
149
|
+
return f.ok ? { data: void 0, response: f } : { error: void 0, response: f };
|
|
150
|
+
if (f.ok)
|
|
151
|
+
return A === "stream" ? { data: f.body, response: f } : { data: await f[A](), response: f };
|
|
152
|
+
let x = await f.text();
|
|
137
153
|
try {
|
|
138
|
-
|
|
154
|
+
x = JSON.parse(x);
|
|
139
155
|
} catch {
|
|
140
156
|
}
|
|
141
|
-
return { error:
|
|
157
|
+
return { error: x, response: f };
|
|
142
158
|
}
|
|
143
159
|
return {
|
|
144
160
|
request(a, s, m) {
|
|
145
|
-
return
|
|
161
|
+
return y(s, { ...m, method: a.toUpperCase() });
|
|
146
162
|
},
|
|
147
163
|
/** Call a GET endpoint */
|
|
148
164
|
GET(a, s) {
|
|
149
|
-
return
|
|
165
|
+
return y(a, { ...s, method: "GET" });
|
|
150
166
|
},
|
|
151
167
|
/** Call a PUT endpoint */
|
|
152
168
|
PUT(a, s) {
|
|
153
|
-
return
|
|
169
|
+
return y(a, { ...s, method: "PUT" });
|
|
154
170
|
},
|
|
155
171
|
/** Call a POST endpoint */
|
|
156
172
|
POST(a, s) {
|
|
157
|
-
return
|
|
173
|
+
return y(a, { ...s, method: "POST" });
|
|
158
174
|
},
|
|
159
175
|
/** Call a DELETE endpoint */
|
|
160
176
|
DELETE(a, s) {
|
|
161
|
-
return
|
|
177
|
+
return y(a, { ...s, method: "DELETE" });
|
|
162
178
|
},
|
|
163
179
|
/** Call a OPTIONS endpoint */
|
|
164
180
|
OPTIONS(a, s) {
|
|
165
|
-
return
|
|
181
|
+
return y(a, { ...s, method: "OPTIONS" });
|
|
166
182
|
},
|
|
167
183
|
/** Call a HEAD endpoint */
|
|
168
184
|
HEAD(a, s) {
|
|
169
|
-
return
|
|
185
|
+
return y(a, { ...s, method: "HEAD" });
|
|
170
186
|
},
|
|
171
187
|
/** Call a PATCH endpoint */
|
|
172
188
|
PATCH(a, s) {
|
|
173
|
-
return
|
|
189
|
+
return y(a, { ...s, method: "PATCH" });
|
|
174
190
|
},
|
|
175
191
|
/** Call a TRACE endpoint */
|
|
176
192
|
TRACE(a, s) {
|
|
177
|
-
return
|
|
193
|
+
return y(a, { ...s, method: "TRACE" });
|
|
178
194
|
},
|
|
179
195
|
/** Register middleware */
|
|
180
196
|
use(...a) {
|
|
@@ -182,180 +198,179 @@ function W(r) {
|
|
|
182
198
|
if (s) {
|
|
183
199
|
if (typeof s != "object" || !("onRequest" in s || "onResponse" in s || "onError" in s))
|
|
184
200
|
throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
|
|
185
|
-
|
|
201
|
+
p.push(s);
|
|
186
202
|
}
|
|
187
203
|
},
|
|
188
204
|
/** Unregister middleware */
|
|
189
205
|
eject(...a) {
|
|
190
206
|
for (const s of a) {
|
|
191
|
-
const m =
|
|
192
|
-
m !== -1 &&
|
|
207
|
+
const m = p.indexOf(s);
|
|
208
|
+
m !== -1 && p.splice(m, 1);
|
|
193
209
|
}
|
|
194
210
|
}
|
|
195
211
|
};
|
|
196
212
|
}
|
|
197
|
-
function
|
|
213
|
+
function S(o, t, e) {
|
|
198
214
|
if (t == null)
|
|
199
215
|
return "";
|
|
200
216
|
if (typeof t == "object")
|
|
201
217
|
throw new Error(
|
|
202
218
|
"Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these."
|
|
203
219
|
);
|
|
204
|
-
return `${
|
|
220
|
+
return `${o}=${e?.allowReserved === !0 ? t : encodeURIComponent(t)}`;
|
|
205
221
|
}
|
|
206
|
-
function
|
|
222
|
+
function k(o, t, e) {
|
|
207
223
|
if (!t || typeof t != "object")
|
|
208
224
|
return "";
|
|
209
|
-
const
|
|
225
|
+
const n = [], r = {
|
|
210
226
|
simple: ",",
|
|
211
227
|
label: ".",
|
|
212
228
|
matrix: ";"
|
|
213
229
|
}[e.style] || "&";
|
|
214
230
|
if (e.style !== "deepObject" && e.explode === !1) {
|
|
215
|
-
for (const
|
|
216
|
-
|
|
217
|
-
const l =
|
|
231
|
+
for (const c in t)
|
|
232
|
+
n.push(c, e.allowReserved === !0 ? t[c] : encodeURIComponent(t[c]));
|
|
233
|
+
const l = n.join(",");
|
|
218
234
|
switch (e.style) {
|
|
219
235
|
case "form":
|
|
220
|
-
return `${
|
|
236
|
+
return `${o}=${l}`;
|
|
221
237
|
case "label":
|
|
222
238
|
return `.${l}`;
|
|
223
239
|
case "matrix":
|
|
224
|
-
return `;${
|
|
240
|
+
return `;${o}=${l}`;
|
|
225
241
|
default:
|
|
226
242
|
return l;
|
|
227
243
|
}
|
|
228
244
|
}
|
|
229
245
|
for (const l in t) {
|
|
230
|
-
const
|
|
231
|
-
|
|
246
|
+
const c = e.style === "deepObject" ? `${o}[${l}]` : l;
|
|
247
|
+
n.push(S(c, t[l], e));
|
|
232
248
|
}
|
|
233
|
-
const
|
|
234
|
-
return e.style === "label" || e.style === "matrix" ? `${
|
|
249
|
+
const i = n.join(r);
|
|
250
|
+
return e.style === "label" || e.style === "matrix" ? `${r}${i}` : i;
|
|
235
251
|
}
|
|
236
|
-
function
|
|
252
|
+
function L(o, t, e) {
|
|
237
253
|
if (!Array.isArray(t))
|
|
238
254
|
return "";
|
|
239
255
|
if (e.explode === !1) {
|
|
240
|
-
const
|
|
256
|
+
const i = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[e.style] || ",", l = (e.allowReserved === !0 ? t : t.map((c) => encodeURIComponent(c))).join(i);
|
|
241
257
|
switch (e.style) {
|
|
242
258
|
case "simple":
|
|
243
259
|
return l;
|
|
244
260
|
case "label":
|
|
245
261
|
return `.${l}`;
|
|
246
262
|
case "matrix":
|
|
247
|
-
return `;${
|
|
263
|
+
return `;${o}=${l}`;
|
|
248
264
|
// case "spaceDelimited":
|
|
249
265
|
// case "pipeDelimited":
|
|
250
266
|
default:
|
|
251
|
-
return `${
|
|
267
|
+
return `${o}=${l}`;
|
|
252
268
|
}
|
|
253
269
|
}
|
|
254
|
-
const
|
|
255
|
-
for (const
|
|
256
|
-
e.style === "simple" || e.style === "label" ?
|
|
257
|
-
return e.style === "label" || e.style === "matrix" ? `${
|
|
270
|
+
const n = { simple: ",", label: ".", matrix: ";" }[e.style] || "&", r = [];
|
|
271
|
+
for (const i of t)
|
|
272
|
+
e.style === "simple" || e.style === "label" ? r.push(e.allowReserved === !0 ? i : encodeURIComponent(i)) : r.push(S(o, i, e));
|
|
273
|
+
return e.style === "label" || e.style === "matrix" ? `${n}${r.join(n)}` : r.join(n);
|
|
258
274
|
}
|
|
259
|
-
function
|
|
275
|
+
function H(o) {
|
|
260
276
|
return function(e) {
|
|
261
|
-
const
|
|
277
|
+
const n = [];
|
|
262
278
|
if (e && typeof e == "object")
|
|
263
|
-
for (const
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
if (Array.isArray(
|
|
267
|
-
if (
|
|
279
|
+
for (const r in e) {
|
|
280
|
+
const i = e[r];
|
|
281
|
+
if (i != null) {
|
|
282
|
+
if (Array.isArray(i)) {
|
|
283
|
+
if (i.length === 0)
|
|
268
284
|
continue;
|
|
269
|
-
|
|
270
|
-
|
|
285
|
+
n.push(
|
|
286
|
+
L(r, i, {
|
|
271
287
|
style: "form",
|
|
272
288
|
explode: !0,
|
|
273
|
-
...
|
|
274
|
-
allowReserved:
|
|
289
|
+
...o?.array,
|
|
290
|
+
allowReserved: o?.allowReserved || !1
|
|
275
291
|
})
|
|
276
292
|
);
|
|
277
293
|
continue;
|
|
278
294
|
}
|
|
279
|
-
if (typeof
|
|
280
|
-
|
|
281
|
-
|
|
295
|
+
if (typeof i == "object") {
|
|
296
|
+
n.push(
|
|
297
|
+
k(r, i, {
|
|
282
298
|
style: "deepObject",
|
|
283
299
|
explode: !0,
|
|
284
|
-
...
|
|
285
|
-
allowReserved:
|
|
300
|
+
...o?.object,
|
|
301
|
+
allowReserved: o?.allowReserved || !1
|
|
286
302
|
})
|
|
287
303
|
);
|
|
288
304
|
continue;
|
|
289
305
|
}
|
|
290
|
-
|
|
306
|
+
n.push(S(r, i, o));
|
|
291
307
|
}
|
|
292
308
|
}
|
|
293
|
-
return
|
|
309
|
+
return n.join("&");
|
|
294
310
|
};
|
|
295
311
|
}
|
|
296
|
-
function
|
|
297
|
-
let e =
|
|
298
|
-
for (const
|
|
299
|
-
let
|
|
300
|
-
if (
|
|
312
|
+
function J(o, t) {
|
|
313
|
+
let e = o;
|
|
314
|
+
for (const n of o.match(M) ?? []) {
|
|
315
|
+
let r = n.substring(1, n.length - 1), i = !1, l = "simple";
|
|
316
|
+
if (r.endsWith("*") && (i = !0, r = r.substring(0, r.length - 1)), r.startsWith(".") ? (l = "label", r = r.substring(1)) : r.startsWith(";") && (l = "matrix", r = r.substring(1)), !t || t[r] === void 0 || t[r] === null)
|
|
301
317
|
continue;
|
|
302
|
-
const
|
|
303
|
-
if (Array.isArray(
|
|
304
|
-
e = e.replace(
|
|
318
|
+
const c = t[r];
|
|
319
|
+
if (Array.isArray(c)) {
|
|
320
|
+
e = e.replace(n, L(r, c, { style: l, explode: i }));
|
|
305
321
|
continue;
|
|
306
322
|
}
|
|
307
|
-
if (typeof
|
|
308
|
-
e = e.replace(
|
|
323
|
+
if (typeof c == "object") {
|
|
324
|
+
e = e.replace(n, k(r, c, { style: l, explode: i }));
|
|
309
325
|
continue;
|
|
310
326
|
}
|
|
311
327
|
if (l === "matrix") {
|
|
312
|
-
e = e.replace(
|
|
328
|
+
e = e.replace(n, `;${S(r, c)}`);
|
|
313
329
|
continue;
|
|
314
330
|
}
|
|
315
|
-
e = e.replace(
|
|
331
|
+
e = e.replace(n, l === "label" ? `.${encodeURIComponent(c)}` : encodeURIComponent(c));
|
|
316
332
|
}
|
|
317
333
|
return e;
|
|
318
334
|
}
|
|
319
|
-
function
|
|
320
|
-
return
|
|
335
|
+
function _(o, t) {
|
|
336
|
+
return o instanceof FormData ? o : t && (t.get instanceof Function ? t.get("Content-Type") ?? t.get("content-type") : t["Content-Type"] ?? t["content-type"]) === "application/x-www-form-urlencoded" ? new URLSearchParams(o).toString() : JSON.stringify(o);
|
|
321
337
|
}
|
|
322
|
-
function
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
return i.startsWith("?") && (i = i.substring(1)), i && (e += `?${i}`), e;
|
|
338
|
+
function K(o, t) {
|
|
339
|
+
let e = `${t.baseUrl}${o}`;
|
|
340
|
+
t.params?.path && (e = J(e, t.params.path));
|
|
341
|
+
let n = t.querySerializer(t.params.query ?? {});
|
|
342
|
+
return n.startsWith("?") && (n = n.substring(1)), n && (e += `?${n}`), e;
|
|
328
343
|
}
|
|
329
|
-
function
|
|
344
|
+
function D(...o) {
|
|
330
345
|
const t = new Headers();
|
|
331
|
-
for (const e of
|
|
346
|
+
for (const e of o) {
|
|
332
347
|
if (!e || typeof e != "object")
|
|
333
348
|
continue;
|
|
334
|
-
const
|
|
335
|
-
for (const [
|
|
336
|
-
if (
|
|
337
|
-
t.delete(
|
|
338
|
-
else if (Array.isArray(
|
|
339
|
-
for (const l of
|
|
340
|
-
t.append(
|
|
341
|
-
else
|
|
349
|
+
const n = e instanceof Headers ? e.entries() : Object.entries(e);
|
|
350
|
+
for (const [r, i] of n)
|
|
351
|
+
if (i === null)
|
|
352
|
+
t.delete(r);
|
|
353
|
+
else if (Array.isArray(i))
|
|
354
|
+
for (const l of i)
|
|
355
|
+
t.append(r, l);
|
|
356
|
+
else i !== void 0 && t.set(r, i);
|
|
342
357
|
}
|
|
343
358
|
return t;
|
|
344
359
|
}
|
|
345
|
-
function
|
|
346
|
-
return
|
|
360
|
+
function P(o) {
|
|
361
|
+
return o.endsWith("/") ? o.substring(0, o.length - 1) : o;
|
|
347
362
|
}
|
|
348
|
-
function
|
|
363
|
+
function X(o) {
|
|
349
364
|
const t = {
|
|
350
|
-
async onRequest({ request:
|
|
351
|
-
const
|
|
352
|
-
return
|
|
365
|
+
async onRequest({ request: n }) {
|
|
366
|
+
const r = await o.getCredentials();
|
|
367
|
+
return n.headers.set("Authorization", `Bearer ${r.token}`), (n.method === "POST" || n.method === "PATCH" || n.method === "DELETE") && n.headers.set("Content-Type", "application/vnd.api+json"), n;
|
|
353
368
|
}
|
|
354
|
-
}, e =
|
|
369
|
+
}, e = G({
|
|
355
370
|
baseUrl: "https://openapi.tidal.com/v2/"
|
|
356
371
|
});
|
|
357
372
|
return e.use(t), e;
|
|
358
373
|
}
|
|
359
374
|
export {
|
|
360
|
-
|
|
375
|
+
X as createAPIClient
|
|
361
376
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tidal-music/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"default": "./dist/index.js"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"openapi-fetch": "0.
|
|
21
|
-
"@tidal-music/api": "0.
|
|
20
|
+
"openapi-fetch": "0.14.0",
|
|
21
|
+
"@tidal-music/api": "0.4.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@vitest/coverage-v8": "3.
|
|
25
|
-
"@vitest/ui": "3.
|
|
26
|
-
"openapi-typescript": "7.
|
|
27
|
-
"typescript": "5.8.
|
|
28
|
-
"vite": "
|
|
29
|
-
"vite-plugin-dts": "4.5.
|
|
30
|
-
"vitest": "3.
|
|
24
|
+
"@vitest/coverage-v8": "3.2.4",
|
|
25
|
+
"@vitest/ui": "3.2.4",
|
|
26
|
+
"openapi-typescript": "7.8.0",
|
|
27
|
+
"typescript": "5.8.3",
|
|
28
|
+
"vite": "7.0.0",
|
|
29
|
+
"vite-plugin-dts": "4.5.4",
|
|
30
|
+
"vitest": "3.2.4",
|
|
31
31
|
"@tidal-music/auth": "^1.3.4",
|
|
32
32
|
"@tidal-music/common": "^0.1.5"
|
|
33
33
|
},
|