@mittwald/api-client-commons 4.47.2 → 4.58.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.
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ApiClientError } from "../core/index.js";
|
|
2
|
+
import assertStatus from "./assertStatus.js";
|
|
3
|
+
import { AxiosHeaders } from "axios";
|
|
4
|
+
const headerName = "x-pagination-totalcount";
|
|
5
|
+
const baseError = `Header '${headerName}' is not valid`;
|
|
6
|
+
export const extractTotalCountHeader = (response) => {
|
|
7
|
+
assertStatus(response, 200);
|
|
8
|
+
if (!(response.headers instanceof AxiosHeaders)) {
|
|
9
|
+
throw ApiClientError.fromResponse(`${baseError}: Expected headers to be of type AxiosHeaders`, response);
|
|
10
|
+
}
|
|
11
|
+
const headerContent = response.headers.get(headerName);
|
|
12
|
+
if (typeof headerContent !== "string") {
|
|
13
|
+
throw ApiClientError.fromResponse(`${baseError}: value is not of type string (is ${typeof headerContent} instead)`, response);
|
|
14
|
+
}
|
|
15
|
+
const asNumber = Number.parseInt(headerContent);
|
|
16
|
+
if (isNaN(asNumber)) {
|
|
17
|
+
throw ApiClientError.fromResponse(`${baseError}: value is not a valid number`, response);
|
|
18
|
+
}
|
|
19
|
+
return asNumber;
|
|
20
|
+
};
|
package/dist/esm/types/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mittwald/api-client-commons",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.58.1",
|
|
4
4
|
"author": "Mittwald CM Service GmbH & Co. KG <opensource@mittwald.de>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Common types and utilities for mittwald API clients",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/parse-path": "^7.0.3",
|
|
44
44
|
"axios": "^1.7.4",
|
|
45
45
|
"parse-path": "^7.0.0",
|
|
46
|
-
"path-to-regexp": "^
|
|
46
|
+
"path-to-regexp": "^8.1.0",
|
|
47
47
|
"type-fest": "^4.23.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"optional": true
|
|
79
79
|
}
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "df0b8fa85d0a03da0dbab27569adc4db65fd84f2"
|
|
82
82
|
}
|