@tidal-music/api 0.8.1 → 0.9.1

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +2957 -905
  2. package/dist/index.js +66 -66
  3. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ function Z(n) {
10
10
  querySerializer: r,
11
11
  bodySerializer: i,
12
12
  pathSerializer: l,
13
- headers: f,
13
+ headers: u,
14
14
  requestInitExt: $ = void 0,
15
15
  ...J
16
16
  } = { ...n };
@@ -24,7 +24,7 @@ function Z(n) {
24
24
  headers: I,
25
25
  params: w = {},
26
26
  parseAs: j = "json",
27
- querySerializer: S,
27
+ querySerializer: E,
28
28
  bodySerializer: H = i ?? te,
29
29
  pathSerializer: Q,
30
30
  body: P,
@@ -34,9 +34,9 @@ function Z(n) {
34
34
  let C = t;
35
35
  m && (C = B(m) ?? t);
36
36
  let x = typeof r == "function" ? r : M(r);
37
- S && (x = typeof S == "function" ? S : M({
37
+ E && (x = typeof E == "function" ? E : M({
38
38
  ...typeof r == "object" ? r : {},
39
- ...S
39
+ ...E
40
40
  }));
41
41
  const k = Q || l || ee, U = P === void 0 ? void 0 : H(
42
42
  P,
@@ -45,31 +45,31 @@ function Z(n) {
45
45
  // the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
46
46
  // setting the content-type at the very beginning to be overwritten.
47
47
  // Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
48
- N(f, I, w.header)
48
+ N(u, I, w.header)
49
49
  ), _ = N(
50
50
  // with no body, we should not to set Content-Type
51
51
  U === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
52
52
  U instanceof FormData ? {} : {
53
53
  "Content-Type": "application/json"
54
54
  },
55
- f,
55
+ u,
56
56
  I,
57
57
  w.header
58
- ), y = [...g, ...G], K = {
58
+ ), h = [...g, ...G], K = {
59
59
  redirect: "follow",
60
60
  ...J,
61
61
  ...v,
62
62
  body: U,
63
63
  headers: _
64
64
  };
65
- let E, T, h = new D(
65
+ let S, T, y = new D(
66
66
  re(a, { baseUrl: C, params: w, querySerializer: x, pathSerializer: k }),
67
67
  K
68
- ), u;
68
+ ), c;
69
69
  for (const d in v)
70
- d in h || (h[d] = v[d]);
71
- if (y.length) {
72
- E = Y(), T = Object.freeze({
70
+ d in y || (y[d] = v[d]);
71
+ if (h.length) {
72
+ S = Y(), T = Object.freeze({
73
73
  baseUrl: C,
74
74
  fetch: O,
75
75
  parseAs: j,
@@ -77,97 +77,97 @@ function Z(n) {
77
77
  bodySerializer: H,
78
78
  pathSerializer: k
79
79
  });
80
- for (const d of y)
80
+ for (const d of h)
81
81
  if (d && typeof d == "object" && typeof d.onRequest == "function") {
82
- const c = await d.onRequest({
83
- request: h,
82
+ const f = await d.onRequest({
83
+ request: y,
84
84
  schemaPath: a,
85
85
  params: w,
86
86
  options: T,
87
- id: E
87
+ id: S
88
88
  });
89
- if (c)
90
- if (c instanceof D)
91
- h = c;
92
- else if (c instanceof Response) {
93
- u = c;
89
+ if (f)
90
+ if (f instanceof D)
91
+ y = f;
92
+ else if (f instanceof Response) {
93
+ c = f;
94
94
  break;
95
95
  } else
96
96
  throw new Error("onRequest: must return new Request() or Response() when modifying the request");
97
97
  }
98
98
  }
99
- if (!u) {
99
+ if (!c) {
100
100
  try {
101
- u = await O(h, $);
101
+ c = await O(y, $);
102
102
  } catch (d) {
103
- let c = d;
104
- if (y.length)
105
- for (let b = y.length - 1; b >= 0; b--) {
106
- const z = y[b];
103
+ let f = d;
104
+ if (h.length)
105
+ for (let b = h.length - 1; b >= 0; b--) {
106
+ const z = h[b];
107
107
  if (z && typeof z == "object" && typeof z.onError == "function") {
108
108
  const R = await z.onError({
109
- request: h,
110
- error: c,
109
+ request: y,
110
+ error: f,
111
111
  schemaPath: a,
112
112
  params: w,
113
113
  options: T,
114
- id: E
114
+ id: S
115
115
  });
116
116
  if (R) {
117
117
  if (R instanceof Response) {
118
- c = void 0, u = R;
118
+ f = void 0, c = R;
119
119
  break;
120
120
  }
121
121
  if (R instanceof Error) {
122
- c = R;
122
+ f = R;
123
123
  continue;
124
124
  }
125
125
  throw new Error("onError: must return new Response() or instance of Error");
126
126
  }
127
127
  }
128
128
  }
129
- if (c)
130
- throw c;
129
+ if (f)
130
+ throw f;
131
131
  }
132
- if (y.length)
133
- for (let d = y.length - 1; d >= 0; d--) {
134
- const c = y[d];
135
- if (c && typeof c == "object" && typeof c.onResponse == "function") {
136
- const b = await c.onResponse({
137
- request: h,
138
- response: u,
132
+ if (h.length)
133
+ for (let d = h.length - 1; d >= 0; d--) {
134
+ const f = h[d];
135
+ if (f && typeof f == "object" && typeof f.onResponse == "function") {
136
+ const b = await f.onResponse({
137
+ request: y,
138
+ response: c,
139
139
  schemaPath: a,
140
140
  params: w,
141
141
  options: T,
142
- id: E
142
+ id: S
143
143
  });
144
144
  if (b) {
145
145
  if (!(b instanceof Response))
146
146
  throw new Error("onResponse: must return new Response() when modifying the response");
147
- u = b;
147
+ c = b;
148
148
  }
149
149
  }
150
150
  }
151
151
  }
152
- const L = u.headers.get("Content-Length");
153
- if (u.status === 204 || h.method === "HEAD" || L === "0")
154
- return u.ok ? { data: void 0, response: u } : { error: void 0, response: u };
155
- if (u.ok)
152
+ const L = c.headers.get("Content-Length");
153
+ if (c.status === 204 || y.method === "HEAD" || L === "0" && !c.headers.get("Transfer-Encoding")?.includes("chunked"))
154
+ return c.ok ? { data: void 0, response: c } : { error: void 0, response: c };
155
+ if (c.ok)
156
156
  return { data: await (async () => {
157
157
  if (j === "stream")
158
- return u.body;
158
+ return c.body;
159
159
  if (j === "json" && !L) {
160
- const c = await u.text();
161
- return c ? JSON.parse(c) : void 0;
160
+ const f = await c.text();
161
+ return f ? JSON.parse(f) : void 0;
162
162
  }
163
- return await u[j]();
164
- })(), response: u };
165
- let q = await u.text();
163
+ return await c[j]();
164
+ })(), response: c };
165
+ let q = await c.text();
166
166
  try {
167
167
  q = JSON.parse(q);
168
168
  } catch {
169
169
  }
170
- return { error: q, response: u };
170
+ return { error: q, response: c };
171
171
  }
172
172
  return {
173
173
  request(a, s, m) {
@@ -241,8 +241,8 @@ function F(n, t, e) {
241
241
  matrix: ";"
242
242
  }[e.style] || "&";
243
243
  if (e.style !== "deepObject" && e.explode === !1) {
244
- for (const f in t)
245
- o.push(f, e.allowReserved === !0 ? t[f] : encodeURIComponent(t[f]));
244
+ for (const u in t)
245
+ o.push(u, e.allowReserved === !0 ? t[u] : encodeURIComponent(t[u]));
246
246
  const l = o.join(",");
247
247
  switch (e.style) {
248
248
  case "form":
@@ -256,8 +256,8 @@ function F(n, t, e) {
256
256
  }
257
257
  }
258
258
  for (const l in t) {
259
- const f = e.style === "deepObject" ? `${n}[${l}]` : l;
260
- o.push(A(f, t[l], e));
259
+ const u = e.style === "deepObject" ? `${n}[${l}]` : l;
260
+ o.push(A(u, t[l], e));
261
261
  }
262
262
  const i = o.join(r);
263
263
  return e.style === "label" || e.style === "matrix" ? `${r}${i}` : i;
@@ -266,7 +266,7 @@ function W(n, t, e) {
266
266
  if (!Array.isArray(t))
267
267
  return "";
268
268
  if (e.explode === !1) {
269
- const i = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[e.style] || ",", l = (e.allowReserved === !0 ? t : t.map((f) => encodeURIComponent(f))).join(i);
269
+ const i = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[e.style] || ",", l = (e.allowReserved === !0 ? t : t.map((u) => encodeURIComponent(u))).join(i);
270
270
  switch (e.style) {
271
271
  case "simple":
272
272
  return l;
@@ -328,20 +328,20 @@ function ee(n, t) {
328
328
  let r = o.substring(1, o.length - 1), i = !1, l = "simple";
329
329
  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)
330
330
  continue;
331
- const f = t[r];
332
- if (Array.isArray(f)) {
333
- e = e.replace(o, W(r, f, { style: l, explode: i }));
331
+ const u = t[r];
332
+ if (Array.isArray(u)) {
333
+ e = e.replace(o, W(r, u, { style: l, explode: i }));
334
334
  continue;
335
335
  }
336
- if (typeof f == "object") {
337
- e = e.replace(o, F(r, f, { style: l, explode: i }));
336
+ if (typeof u == "object") {
337
+ e = e.replace(o, F(r, u, { style: l, explode: i }));
338
338
  continue;
339
339
  }
340
340
  if (l === "matrix") {
341
- e = e.replace(o, `;${A(r, f)}`);
341
+ e = e.replace(o, `;${A(r, u)}`);
342
342
  continue;
343
343
  }
344
- e = e.replace(o, l === "label" ? `.${encodeURIComponent(f)}` : encodeURIComponent(f));
344
+ e = e.replace(o, l === "label" ? `.${encodeURIComponent(u)}` : encodeURIComponent(u));
345
345
  }
346
346
  return e;
347
347
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidal-music/api",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
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.16.0",
21
- "@tidal-music/api": "0.8.1"
20
+ "openapi-fetch": "0.17.0",
21
+ "@tidal-music/api": "0.9.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@vitest/coverage-v8": "4.0.18",
25
25
  "@vitest/ui": "4.0.18",
26
- "openapi-typescript": "7.12.0",
26
+ "openapi-typescript": "7.13.0",
27
27
  "typescript": "5.9.3",
28
28
  "vite": "7.3.1",
29
29
  "vite-plugin-dts": "4.5.4",
30
30
  "vitest": "4.0.18",
31
- "@tidal-music/common": "^0.2.0",
32
- "@tidal-music/auth": "^1.4.0"
31
+ "@tidal-music/auth": "^1.4.0",
32
+ "@tidal-music/common": "^0.2.0"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "vite build",