@sebspark/openapi-client 1.3.1 → 1.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/dist/index.js CHANGED
@@ -41,6 +41,13 @@ var import_retry = require("@sebspark/retry");
41
41
  var import_axios = __toESM(require("axios"));
42
42
 
43
43
  // src/paramsSerializer.ts
44
+ var encodeParam = (param) => encodeURIComponent(param);
45
+ var encodeValue = (param, encodeCommas = false) => {
46
+ if (encodeCommas) {
47
+ return encodeURIComponent(param);
48
+ }
49
+ return param.split(",").map((p) => encodeURIComponent(p)).join(",");
50
+ };
44
51
  var paramsSerializer = (format) => (
45
52
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
46
53
  (params) => {
@@ -50,29 +57,23 @@ var paramsSerializer = (format) => (
50
57
  return Object.entries(params).filter(([, value]) => value !== void 0).flatMap(([key, value]) => {
51
58
  if (Array.isArray(value)) {
52
59
  if (format === "comma") {
53
- return `${encodeURIComponent(key)}=${value.map((v) => encodeURIComponent(v)).join(",")}`;
60
+ return `${encodeParam(key)}=${value.map((v) => encodeValue(v, true)).join(",")}`;
54
61
  }
55
62
  return value.map((arrayValue, ix) => {
56
63
  switch (format) {
57
64
  case "indices": {
58
- return `${encodeURIComponent(key)}[${ix}]=${encodeURIComponent(
59
- arrayValue
60
- )}`;
65
+ return `${encodeParam(key)}[${ix}]=${encodeValue(arrayValue)}`;
61
66
  }
62
67
  case "repeat": {
63
- return `${encodeURIComponent(key)}=${encodeURIComponent(
64
- arrayValue
65
- )}`;
68
+ return `${encodeParam(key)}=${encodeValue(arrayValue)}`;
66
69
  }
67
70
  default: {
68
- return `${encodeURIComponent(key)}[]=${encodeURIComponent(
69
- arrayValue
70
- )}`;
71
+ return `${encodeParam(key)}[]=${encodeValue(arrayValue)}`;
71
72
  }
72
73
  }
73
74
  });
74
75
  }
75
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
76
+ return `${encodeParam(key)}=${encodeValue(value)}`;
76
77
  }).join("&");
77
78
  }
78
79
  );
package/dist/index.mjs CHANGED
@@ -6,6 +6,13 @@ import { retry } from "@sebspark/retry";
6
6
  import axios from "axios";
7
7
 
8
8
  // src/paramsSerializer.ts
9
+ var encodeParam = (param) => encodeURIComponent(param);
10
+ var encodeValue = (param, encodeCommas = false) => {
11
+ if (encodeCommas) {
12
+ return encodeURIComponent(param);
13
+ }
14
+ return param.split(",").map((p) => encodeURIComponent(p)).join(",");
15
+ };
9
16
  var paramsSerializer = (format) => (
10
17
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
11
18
  (params) => {
@@ -15,29 +22,23 @@ var paramsSerializer = (format) => (
15
22
  return Object.entries(params).filter(([, value]) => value !== void 0).flatMap(([key, value]) => {
16
23
  if (Array.isArray(value)) {
17
24
  if (format === "comma") {
18
- return `${encodeURIComponent(key)}=${value.map((v) => encodeURIComponent(v)).join(",")}`;
25
+ return `${encodeParam(key)}=${value.map((v) => encodeValue(v, true)).join(",")}`;
19
26
  }
20
27
  return value.map((arrayValue, ix) => {
21
28
  switch (format) {
22
29
  case "indices": {
23
- return `${encodeURIComponent(key)}[${ix}]=${encodeURIComponent(
24
- arrayValue
25
- )}`;
30
+ return `${encodeParam(key)}[${ix}]=${encodeValue(arrayValue)}`;
26
31
  }
27
32
  case "repeat": {
28
- return `${encodeURIComponent(key)}=${encodeURIComponent(
29
- arrayValue
30
- )}`;
33
+ return `${encodeParam(key)}=${encodeValue(arrayValue)}`;
31
34
  }
32
35
  default: {
33
- return `${encodeURIComponent(key)}[]=${encodeURIComponent(
34
- arrayValue
35
- )}`;
36
+ return `${encodeParam(key)}[]=${encodeValue(arrayValue)}`;
36
37
  }
37
38
  }
38
39
  });
39
40
  }
40
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
41
+ return `${encodeParam(key)}=${encodeValue(value)}`;
41
42
  }).join("&");
42
43
  }
43
44
  );
package/package.json CHANGED
@@ -1,13 +1,11 @@
1
1
  {
2
2
  "name": "@sebspark/openapi-client",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
8
+ "files": ["dist"],
11
9
  "scripts": {
12
10
  "generate": "yarn openapi-typegen -i ./src/test/ -o ./src/test/",
13
11
  "build": "tsup-node src/index.ts --format esm,cjs --dts",
@@ -24,6 +22,6 @@
24
22
  "dependencies": {
25
23
  "@sebspark/openapi-core": "*",
26
24
  "@sebspark/retry": "*",
27
- "axios": "1.6.7"
25
+ "axios": "1.6.8"
28
26
  }
29
- }
27
+ }