@inweb/client 26.10.5 → 26.11.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/client.js CHANGED
@@ -251,6 +251,15 @@
251
251
  }
252
252
  }
253
253
 
254
+ function normalizeParam(param, separator = "|") {
255
+ if (typeof param === "string")
256
+ param = param.split(",");
257
+ if (Array.isArray(param))
258
+ param = param.filter((x) => x).join(separator);
259
+ if (typeof param === "string")
260
+ param = param.trim();
261
+ return param.toString();
262
+ }
254
263
  function delay(ms, signal) {
255
264
  return new Promise((resolve) => {
256
265
  let timeoutId = 0;
@@ -261,7 +270,7 @@
261
270
  timeoutId = window.setTimeout(() => {
262
271
  signal.removeEventListener("abort", abortHandler);
263
272
  resolve(false);
264
- }, ms);
273
+ }, ms || 0);
265
274
  signal.addEventListener("abort", abortHandler, { once: true });
266
275
  });
267
276
  }
@@ -588,10 +597,7 @@
588
597
  if (name)
589
598
  searchParams.set("name", name);
590
599
  if (ids) {
591
- if (Array.isArray(ids))
592
- ids = ids.join("|");
593
- if (typeof ids === "string")
594
- ids = ids.trim();
600
+ ids = normalizeParam(ids);
595
601
  if (ids)
596
602
  searchParams.set("id", ids);
597
603
  }
@@ -1753,7 +1759,7 @@
1753
1759
  .then((filesInformation) => filesInformation.map((item) => item.file.reference))
1754
1760
  .then((ids) => {
1755
1761
  const files = new Endpoint("/files", this.httpClient, this.headers);
1756
- return files.get(`?id=${ids.join("|")}`);
1762
+ return files.get(`?id=${normalizeParam(ids)}`);
1757
1763
  })
1758
1764
  .then((response) => response.json())
1759
1765
  .then((files) => files.result.map((data) => new File(data, this.httpClient)));
@@ -2235,7 +2241,7 @@
2235
2241
  .then((data) => ({
2236
2242
  ...data,
2237
2243
  server: data.version,
2238
- client: "26.10.5",
2244
+ client: "26.11.0",
2239
2245
  }));
2240
2246
  }
2241
2247
  registerUser(email, password, userName) {
@@ -2405,17 +2411,14 @@
2405
2411
  if (name)
2406
2412
  searchParams.set("name", name);
2407
2413
  if (ext) {
2408
- if (Array.isArray(ext))
2409
- ext = ext.join("|");
2410
- if (typeof ext === "string")
2411
- ext = ext.toLowerCase();
2414
+ ext = normalizeParam(ext);
2412
2415
  if (ext)
2413
- searchParams.set("ext", ext);
2416
+ searchParams.set("ext", ext.toLowerCase());
2414
2417
  }
2415
2418
  if (ids) {
2416
- if (Array.isArray(ids))
2417
- ids = ids.join("|");
2418
- searchParams.set("id", ids);
2419
+ ids = normalizeParam(ids);
2420
+ if (ids)
2421
+ searchParams.set("id", ids);
2419
2422
  }
2420
2423
  if (sortByDesc !== undefined)
2421
2424
  searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
@@ -2484,12 +2487,9 @@
2484
2487
  if (limit > 0)
2485
2488
  searchParams.set("limit", limit.toString());
2486
2489
  if (status) {
2487
- if (Array.isArray(status))
2488
- status = status.join("|");
2489
- if (typeof status === "string")
2490
- status = status.trim().toLowerCase();
2490
+ status = normalizeParam(status);
2491
2491
  if (status)
2492
- searchParams.set("status", status);
2492
+ searchParams.set("status", status.toLowerCase());
2493
2493
  }
2494
2494
  if (sortByDesc !== undefined)
2495
2495
  searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
@@ -2534,10 +2534,7 @@
2534
2534
  if (name)
2535
2535
  searchParams.set("name", name);
2536
2536
  if (ids) {
2537
- if (Array.isArray(ids))
2538
- ids = ids.join("|");
2539
- if (typeof ids === "string")
2540
- ids = ids.trim();
2537
+ ids = normalizeParam(ids);
2541
2538
  if (ids)
2542
2539
  searchParams.set("id", ids);
2543
2540
  }
@@ -2591,10 +2588,7 @@
2591
2588
  if (name)
2592
2589
  searchParams.set("name", name);
2593
2590
  if (ids) {
2594
- if (Array.isArray(ids))
2595
- ids = ids.join("|");
2596
- if (typeof ids === "string")
2597
- ids = ids.trim();
2591
+ ids = normalizeParam(ids);
2598
2592
  if (ids)
2599
2593
  searchParams.set("id", ids);
2600
2594
  }
@@ -2731,7 +2725,7 @@
2731
2725
  }
2732
2726
  }
2733
2727
 
2734
- const version = "26.10.5";
2728
+ const version = "26.11.0";
2735
2729
 
2736
2730
  exports.Assembly = Assembly;
2737
2731
  exports.ClashTest = ClashTest;
@@ -2750,6 +2744,8 @@
2750
2744
  exports.SharedFile = SharedFile;
2751
2745
  exports.SharedLink = SharedLink;
2752
2746
  exports.User = User;
2747
+ exports.delay = delay;
2748
+ exports.normalizeParam = normalizeParam;
2753
2749
  exports.parseArgs = parseArgs;
2754
2750
  exports.statusText = statusText;
2755
2751
  exports.userFullName = userFullName;