api-def 0.9.2 → 0.9.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/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# [api-def](https://github.com/Censkh/api-def/) · [](https://github.com/Censkh/api-def/blob/master/LICENSE) [](https://www.npmjs.com/package/api-def) [ · [](https://github.com/Censkh/api-def/blob/master/LICENSE) [](https://www.npmjs.com/package/api-def) [](https://github.com/Censkh/api-def/actions)
|
|
2
2
|
|
|
3
3
|
Typed APIs with middleware support
|
|
4
4
|
|
|
@@ -109,24 +109,25 @@ var FetchRequestBackend = /** @class */ (function () {
|
|
|
109
109
|
responseType = (_a = context.responseType) !== null && _a !== void 0 ? _a : (0, ApiUtils_1.inferResponseType)(response.headers.get("Content-Type"));
|
|
110
110
|
_b.label = 1;
|
|
111
111
|
case 1:
|
|
112
|
-
_b.trys.push([1,
|
|
112
|
+
_b.trys.push([1, 8, , 9]);
|
|
113
113
|
if (!(responseType === "arraybuffer")) return [3 /*break*/, 3];
|
|
114
114
|
return [4 /*yield*/, response.arrayBuffer()];
|
|
115
115
|
case 2:
|
|
116
116
|
data = _b.sent();
|
|
117
|
-
return [3 /*break*/,
|
|
117
|
+
return [3 /*break*/, 7];
|
|
118
118
|
case 3:
|
|
119
119
|
if (!(responseType === "json")) return [3 /*break*/, 5];
|
|
120
120
|
return [4 /*yield*/, response.text()];
|
|
121
121
|
case 4:
|
|
122
122
|
text = _b.sent();
|
|
123
123
|
data = JSON.parse(text);
|
|
124
|
-
return [3 /*break*/,
|
|
125
|
-
case 5:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
case 7:
|
|
124
|
+
return [3 /*break*/, 7];
|
|
125
|
+
case 5: return [4 /*yield*/, response.text()];
|
|
126
|
+
case 6:
|
|
127
|
+
data = _b.sent();
|
|
128
|
+
_b.label = 7;
|
|
129
|
+
case 7: return [3 /*break*/, 9];
|
|
130
|
+
case 8:
|
|
130
131
|
error_1 = _b.sent();
|
|
131
132
|
throw (0, RequestError_1.convertToRequestError)({
|
|
132
133
|
error: Object.assign(new Error("[api-def] Failed to parse response as '".concat(responseType, "'").concat(text ? ", got: ".concat(text) : "")), {
|
|
@@ -136,7 +137,7 @@ var FetchRequestBackend = /** @class */ (function () {
|
|
|
136
137
|
context: context,
|
|
137
138
|
response: convertedResponse,
|
|
138
139
|
});
|
|
139
|
-
case
|
|
140
|
+
case 9:
|
|
140
141
|
convertedResponse.data = data;
|
|
141
142
|
return [2 /*return*/, convertedResponse];
|
|
142
143
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api-def",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Typed API definitions with middleware support",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"types": "esm/index.d.ts",
|
|
7
7
|
"module": "esm/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"scripts": {
|
|
10
|
-
"prepublishOnly": "npm run test && npm run build",
|
|
11
|
-
"test": "
|
|
12
|
-
"test:unit": "bun test --timeout 10000",
|
|
13
|
-
"test:types": "tsc --noEmit -p .",
|
|
10
|
+
"prepublishOnly": "npm run check && npm run test && npm run build",
|
|
11
|
+
"test": "jest",
|
|
14
12
|
"example:start": "cd example && npm run start",
|
|
15
13
|
"check:fix": "tsc --noEmit --project tsconfig.json && npx @biomejs/biome check --apply-unsafe .",
|
|
16
14
|
"check": "tsc --noEmit --project tsconfig.json && npx @biomejs/biome check .",
|
|
@@ -41,15 +39,22 @@
|
|
|
41
39
|
"esm/",
|
|
42
40
|
"cjs/"
|
|
43
41
|
],
|
|
42
|
+
"jest": {
|
|
43
|
+
"transform": {
|
|
44
|
+
"^.+\\.(t|j)sx?$": "@swc/jest"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
44
47
|
"repository": "https://github.com/Censkh/api-def",
|
|
45
48
|
"devDependencies": {
|
|
46
49
|
"@biomejs/biome": "^1.5.3",
|
|
50
|
+
"@swc/jest": "0.2.31",
|
|
47
51
|
"@types/axios": "0.14.0",
|
|
48
52
|
"@types/jest": "^29.5.11",
|
|
49
53
|
"@types/node": "20.11.6",
|
|
50
54
|
"@types/qs": "6.9.11",
|
|
51
55
|
"axios": "1.6.6",
|
|
52
56
|
"cross-env": "7.0.3",
|
|
57
|
+
"jest": "29.7.0",
|
|
53
58
|
"npm-run-all": "4.1.5",
|
|
54
59
|
"qs": "6.11.2",
|
|
55
60
|
"rimraf": "5.0.5",
|