@tidal-music/api 0.4.0 → 0.6.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/index.js CHANGED
@@ -1,8 +1,8 @@
1
- const M = /\{[^{}]+\}/g, W = () => typeof process == "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
2
- function Q() {
1
+ const W = /\{[^{}]+\}/g, Q = () => typeof process == "object" && Number.parseInt(process?.versions?.node?.substring(0, 2)) >= 18 && process.versions.undici;
2
+ function G() {
3
3
  return Math.random().toString(36).slice(2, 11);
4
4
  }
5
- function G(o) {
5
+ function J(o) {
6
6
  let {
7
7
  baseUrl: t = "",
8
8
  Request: e = globalThis.Request,
@@ -11,67 +11,67 @@ function G(o) {
11
11
  bodySerializer: i,
12
12
  headers: l,
13
13
  requestInitExt: c = void 0,
14
- ...B
14
+ ...F
15
15
  } = { ...o };
16
- c = W() ? c : void 0, t = P(t);
16
+ c = Q() ? c : void 0, t = k(t);
17
17
  const p = [];
18
18
  async function y(a, s) {
19
19
  const {
20
20
  baseUrl: m,
21
21
  fetch: z = n,
22
- Request: V = e,
23
- headers: q,
22
+ Request: q = e,
23
+ headers: O,
24
24
  params: w = {},
25
25
  parseAs: A = "json",
26
26
  querySerializer: g,
27
- bodySerializer: O = i ?? _,
28
- body: I,
27
+ bodySerializer: I = i ?? K,
28
+ body: H,
29
29
  ...$
30
30
  } = s || {};
31
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({
32
+ m && (C = k(m) ?? t);
33
+ let v = typeof r == "function" ? r : D(r);
34
+ g && (v = typeof g == "function" ? g : D({
35
35
  ...typeof r == "object" ? r : {},
36
36
  ...g
37
37
  }));
38
- const U = I === void 0 ? void 0 : O(
39
- I,
38
+ const U = H === void 0 ? void 0 : I(
39
+ H,
40
40
  // Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
41
41
  // bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
42
42
  // the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
43
43
  // setting the content-type at the very beginning to be overwritten.
44
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(
45
+ P(l, O, w.header)
46
+ ), N = P(
47
47
  // with no body, we should not to set Content-Type
48
48
  U === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
49
49
  U instanceof FormData ? {} : {
50
50
  "Content-Type": "application/json"
51
51
  },
52
52
  l,
53
- q,
53
+ O,
54
54
  w.header
55
- ), N = {
55
+ ), M = {
56
56
  redirect: "follow",
57
- ...B,
57
+ ...F,
58
58
  ...$,
59
59
  body: U,
60
- headers: F
60
+ headers: N
61
61
  };
62
- let j, E, h = new e(
63
- K(a, { baseUrl: C, params: w, querySerializer: v }),
64
- N
62
+ let j, E, h = new q(
63
+ V(a, { baseUrl: C, params: w, querySerializer: v }),
64
+ M
65
65
  ), f;
66
66
  for (const d in $)
67
67
  d in h || (h[d] = $[d]);
68
68
  if (p.length) {
69
- j = Q(), E = Object.freeze({
69
+ j = G(), E = Object.freeze({
70
70
  baseUrl: C,
71
71
  fetch: z,
72
72
  parseAs: A,
73
73
  querySerializer: v,
74
- bodySerializer: O
74
+ bodySerializer: I
75
75
  });
76
76
  for (const d of p)
77
77
  if (d && typeof d == "object" && typeof d.onRequest == "function") {
@@ -83,7 +83,7 @@ function G(o) {
83
83
  id: j
84
84
  });
85
85
  if (u)
86
- if (u instanceof e)
86
+ if (u instanceof q)
87
87
  h = u;
88
88
  else if (u instanceof Response) {
89
89
  f = u;
@@ -219,7 +219,7 @@ function S(o, t, e) {
219
219
  );
220
220
  return `${o}=${e?.allowReserved === !0 ? t : encodeURIComponent(t)}`;
221
221
  }
222
- function k(o, t, e) {
222
+ function L(o, t, e) {
223
223
  if (!t || typeof t != "object")
224
224
  return "";
225
225
  const n = [], r = {
@@ -249,7 +249,7 @@ function k(o, t, e) {
249
249
  const i = n.join(r);
250
250
  return e.style === "label" || e.style === "matrix" ? `${r}${i}` : i;
251
251
  }
252
- function L(o, t, e) {
252
+ function B(o, t, e) {
253
253
  if (!Array.isArray(t))
254
254
  return "";
255
255
  if (e.explode === !1) {
@@ -272,7 +272,7 @@ function L(o, t, e) {
272
272
  e.style === "simple" || e.style === "label" ? r.push(e.allowReserved === !0 ? i : encodeURIComponent(i)) : r.push(S(o, i, e));
273
273
  return e.style === "label" || e.style === "matrix" ? `${n}${r.join(n)}` : r.join(n);
274
274
  }
275
- function H(o) {
275
+ function D(o) {
276
276
  return function(e) {
277
277
  const n = [];
278
278
  if (e && typeof e == "object")
@@ -283,7 +283,7 @@ function H(o) {
283
283
  if (i.length === 0)
284
284
  continue;
285
285
  n.push(
286
- L(r, i, {
286
+ B(r, i, {
287
287
  style: "form",
288
288
  explode: !0,
289
289
  ...o?.array,
@@ -294,7 +294,7 @@ function H(o) {
294
294
  }
295
295
  if (typeof i == "object") {
296
296
  n.push(
297
- k(r, i, {
297
+ L(r, i, {
298
298
  style: "deepObject",
299
299
  explode: !0,
300
300
  ...o?.object,
@@ -309,19 +309,19 @@ function H(o) {
309
309
  return n.join("&");
310
310
  };
311
311
  }
312
- function J(o, t) {
312
+ function _(o, t) {
313
313
  let e = o;
314
- for (const n of o.match(M) ?? []) {
314
+ for (const n of o.match(W) ?? []) {
315
315
  let r = n.substring(1, n.length - 1), i = !1, l = "simple";
316
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)
317
317
  continue;
318
318
  const c = t[r];
319
319
  if (Array.isArray(c)) {
320
- e = e.replace(n, L(r, c, { style: l, explode: i }));
320
+ e = e.replace(n, B(r, c, { style: l, explode: i }));
321
321
  continue;
322
322
  }
323
323
  if (typeof c == "object") {
324
- e = e.replace(n, k(r, c, { style: l, explode: i }));
324
+ e = e.replace(n, L(r, c, { style: l, explode: i }));
325
325
  continue;
326
326
  }
327
327
  if (l === "matrix") {
@@ -332,16 +332,16 @@ function J(o, t) {
332
332
  }
333
333
  return e;
334
334
  }
335
- function _(o, t) {
335
+ function K(o, t) {
336
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);
337
337
  }
338
- function K(o, t) {
338
+ function V(o, t) {
339
339
  let e = `${t.baseUrl}${o}`;
340
- t.params?.path && (e = J(e, t.params.path));
340
+ t.params?.path && (e = _(e, t.params.path));
341
341
  let n = t.querySerializer(t.params.query ?? {});
342
342
  return n.startsWith("?") && (n = n.substring(1)), n && (e += `?${n}`), e;
343
343
  }
344
- function D(...o) {
344
+ function P(...o) {
345
345
  const t = new Headers();
346
346
  for (const e of o) {
347
347
  if (!e || typeof e != "object")
@@ -357,7 +357,7 @@ function D(...o) {
357
357
  }
358
358
  return t;
359
359
  }
360
- function P(o) {
360
+ function k(o) {
361
361
  return o.endsWith("/") ? o.substring(0, o.length - 1) : o;
362
362
  }
363
363
  function X(o) {
@@ -366,7 +366,7 @@ function X(o) {
366
366
  const r = await o.getCredentials();
367
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;
368
368
  }
369
- }, e = G({
369
+ }, e = J({
370
370
  baseUrl: "https://openapi.tidal.com/v2/"
371
371
  });
372
372
  return e.use(t), e;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-music/api",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -17,19 +17,19 @@
17
17
  "default": "./dist/index.js"
18
18
  },
19
19
  "dependencies": {
20
- "openapi-fetch": "0.14.0",
21
- "@tidal-music/api": "0.4.0"
20
+ "openapi-fetch": "0.14.1",
21
+ "@tidal-music/api": "0.6.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@vitest/coverage-v8": "3.2.4",
25
25
  "@vitest/ui": "3.2.4",
26
- "openapi-typescript": "7.8.0",
27
- "typescript": "5.8.3",
28
- "vite": "7.0.0",
26
+ "openapi-typescript": "7.9.1",
27
+ "typescript": "5.9.3",
28
+ "vite": "7.1.9",
29
29
  "vite-plugin-dts": "4.5.4",
30
30
  "vitest": "3.2.4",
31
- "@tidal-music/auth": "^1.3.4",
32
- "@tidal-music/common": "^0.1.5"
31
+ "@tidal-music/auth": "^1.4.0",
32
+ "@tidal-music/common": "^0.2.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "vite build",