@npora/request 1.10.2 → 1.10.3
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.cjs +14 -0
- package/dist/index.js +14 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -601,15 +601,29 @@ const BODY_FIELDS = [
|
|
|
601
601
|
"form",
|
|
602
602
|
"formData"
|
|
603
603
|
];
|
|
604
|
+
const RESPONSE_TYPES = [
|
|
605
|
+
"json",
|
|
606
|
+
"text",
|
|
607
|
+
"blob",
|
|
608
|
+
"arrayBuffer",
|
|
609
|
+
"stream",
|
|
610
|
+
"sse",
|
|
611
|
+
"ndjson"
|
|
612
|
+
];
|
|
604
613
|
function validateRequestConfig(config) {
|
|
605
614
|
validateURL(config);
|
|
606
615
|
validateTimeout(config);
|
|
607
616
|
validateLimits(config);
|
|
617
|
+
validateResponseOptions(config);
|
|
608
618
|
validateSchema(config);
|
|
609
619
|
const headers = validateHeaders(config);
|
|
610
620
|
validateBody(config);
|
|
611
621
|
return headers;
|
|
612
622
|
}
|
|
623
|
+
function validateResponseOptions(config) {
|
|
624
|
+
if (config.responseType !== void 0 && !RESPONSE_TYPES.includes(config.responseType)) throw configError("Request responseType is invalid", config);
|
|
625
|
+
if (config.validateStatus !== void 0 && typeof config.validateStatus !== "function") throw configError("Request validateStatus must be a function", config);
|
|
626
|
+
}
|
|
613
627
|
function validateSchema(config) {
|
|
614
628
|
if (config.schema === void 0) return;
|
|
615
629
|
try {
|
package/dist/index.js
CHANGED
|
@@ -600,15 +600,29 @@ const BODY_FIELDS = [
|
|
|
600
600
|
"form",
|
|
601
601
|
"formData"
|
|
602
602
|
];
|
|
603
|
+
const RESPONSE_TYPES = [
|
|
604
|
+
"json",
|
|
605
|
+
"text",
|
|
606
|
+
"blob",
|
|
607
|
+
"arrayBuffer",
|
|
608
|
+
"stream",
|
|
609
|
+
"sse",
|
|
610
|
+
"ndjson"
|
|
611
|
+
];
|
|
603
612
|
function validateRequestConfig(config) {
|
|
604
613
|
validateURL(config);
|
|
605
614
|
validateTimeout(config);
|
|
606
615
|
validateLimits(config);
|
|
616
|
+
validateResponseOptions(config);
|
|
607
617
|
validateSchema(config);
|
|
608
618
|
const headers = validateHeaders(config);
|
|
609
619
|
validateBody(config);
|
|
610
620
|
return headers;
|
|
611
621
|
}
|
|
622
|
+
function validateResponseOptions(config) {
|
|
623
|
+
if (config.responseType !== void 0 && !RESPONSE_TYPES.includes(config.responseType)) throw configError("Request responseType is invalid", config);
|
|
624
|
+
if (config.validateStatus !== void 0 && typeof config.validateStatus !== "function") throw configError("Request validateStatus must be a function", config);
|
|
625
|
+
}
|
|
612
626
|
function validateSchema(config) {
|
|
613
627
|
if (config.schema === void 0) return;
|
|
614
628
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@npora/request",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.3",
|
|
4
4
|
"description": "A modern, TypeScript-first HTTP client powered by the Fetch API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"npora",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@changesets/cli": "^2.31.0",
|
|
53
53
|
"@playwright/test": "^1.61.1",
|
|
54
|
-
"@types/node": "^26.
|
|
54
|
+
"@types/node": "^26.2.0",
|
|
55
55
|
"@vitest/coverage-v8": "^4.1.10",
|
|
56
56
|
"tsdown": "^0.22.14",
|
|
57
|
-
"tsx": "^4.23.
|
|
57
|
+
"tsx": "^4.23.11",
|
|
58
58
|
"typescript": "^7.0.2",
|
|
59
59
|
"typescript-api": "npm:@typescript/typescript6@^6.0.2",
|
|
60
60
|
"vitest": "^4.1.10"
|