@netlify/api 14.0.3 → 14.0.5
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/lib/methods/params.js +6 -1
- package/lib/methods/response.d.ts +13 -0
- package/lib/methods/response.js +25 -1
- package/lib/methods/url.js +2 -2
- package/package.json +10 -14
package/lib/methods/params.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
function camelCase(str) {
|
|
2
|
+
return str
|
|
3
|
+
.toLowerCase()
|
|
4
|
+
.replace(/[-_\s]+(.)?/g, (_, chr) => (chr ? chr.toUpperCase() : ''))
|
|
5
|
+
.replace(/^[A-Z]/, (match) => match.toLowerCase());
|
|
6
|
+
}
|
|
2
7
|
export const getRequestParams = function (params, requestParams, name) {
|
|
3
8
|
const entries = Object.values(params).map((param) => getRequestParam(param, requestParams, name));
|
|
4
9
|
return Object.assign({}, ...entries);
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
+
export class HTTPError extends Error {
|
|
2
|
+
constructor(response: any);
|
|
3
|
+
stack: string | undefined;
|
|
4
|
+
status: any;
|
|
5
|
+
}
|
|
6
|
+
export class TextHTTPError extends HTTPError {
|
|
7
|
+
constructor(response: any, data: any);
|
|
8
|
+
data: any;
|
|
9
|
+
}
|
|
10
|
+
export class JSONHTTPError extends HTTPError {
|
|
11
|
+
constructor(response: any, json: any);
|
|
12
|
+
json: any;
|
|
13
|
+
}
|
|
1
14
|
export function parseResponse(response: any): Promise<any>;
|
|
2
15
|
export function getFetchError(error: any, url: any, opts: any): any;
|
package/lib/methods/response.js
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
|
-
import { JSONHTTPError, TextHTTPError } from 'micro-api-client';
|
|
2
1
|
import omit from '../omit.js';
|
|
2
|
+
export class HTTPError extends Error {
|
|
3
|
+
constructor(response) {
|
|
4
|
+
super(response.statusText);
|
|
5
|
+
this.name = this.constructor.name;
|
|
6
|
+
if (typeof Error.captureStackTrace === 'function') {
|
|
7
|
+
Error.captureStackTrace(this, this.constructor);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
this.stack = new Error(response.statusText).stack;
|
|
11
|
+
}
|
|
12
|
+
this.status = response.status;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export class TextHTTPError extends HTTPError {
|
|
16
|
+
constructor(response, data) {
|
|
17
|
+
super(response);
|
|
18
|
+
this.data = data;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class JSONHTTPError extends HTTPError {
|
|
22
|
+
constructor(response, json) {
|
|
23
|
+
super(response);
|
|
24
|
+
this.json = json;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
3
27
|
// Read and parse the HTTP response
|
|
4
28
|
export const parseResponse = async function (response) {
|
|
5
29
|
const responseType = getResponseType(response);
|
package/lib/methods/url.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { stringify } from 'picoquery';
|
|
2
2
|
import { getRequestParams } from './params.js';
|
|
3
3
|
// Replace path parameters and query parameters in the URI, using the OpenAPI
|
|
4
4
|
// definition
|
|
@@ -20,5 +20,5 @@ const addQueryParams = function (url, parameters, requestParams) {
|
|
|
20
20
|
if (Object.keys(queryParams).length === 0) {
|
|
21
21
|
return url;
|
|
22
22
|
}
|
|
23
|
-
return `${url}?${
|
|
23
|
+
return `${url}?${stringify(queryParams, { arrayRepeat: true, arrayRepeatSyntax: 'bracket', nestingSyntax: 'index' })}`;
|
|
24
24
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/api",
|
|
3
3
|
"description": "Netlify Node.js API client",
|
|
4
|
-
"version": "14.0.
|
|
4
|
+
"version": "14.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
7
7
|
"main": "./lib/index.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"prebuild": "rm -rf lib",
|
|
14
14
|
"build": "tsc",
|
|
15
|
-
"test": "
|
|
16
|
-
"test:dev": "
|
|
17
|
-
"test:ci": "
|
|
15
|
+
"test": "vitest run",
|
|
16
|
+
"test:dev": "vitest",
|
|
17
|
+
"test:ci": "vitest run --reporter=default"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "Netlify Inc.",
|
|
@@ -41,26 +41,22 @@
|
|
|
41
41
|
"node client"
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@netlify/open-api": "^2.
|
|
45
|
-
"lodash-es": "^4.17.21",
|
|
46
|
-
"micro-api-client": "^3.3.0",
|
|
44
|
+
"@netlify/open-api": "^2.38.0",
|
|
47
45
|
"node-fetch": "^3.0.0",
|
|
48
46
|
"p-wait-for": "^5.0.0",
|
|
49
|
-
"
|
|
47
|
+
"picoquery": "^2.5.0"
|
|
50
48
|
},
|
|
51
49
|
"devDependencies": {
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/node": "^18.0.0",
|
|
54
|
-
"ava": "^5.0.0",
|
|
55
|
-
"c8": "^10.0.0",
|
|
50
|
+
"@types/node": "^18.19.111",
|
|
56
51
|
"from2-string": "^1.1.0",
|
|
57
52
|
"nock": "^13.0.0",
|
|
58
53
|
"ts-node": "^10.9.1",
|
|
59
54
|
"typescript": "^5.0.0",
|
|
60
|
-
"uuid": "^11.0.0"
|
|
55
|
+
"uuid": "^11.0.0",
|
|
56
|
+
"vitest": "^3.2.3"
|
|
61
57
|
},
|
|
62
58
|
"engines": {
|
|
63
59
|
"node": ">=18.14.0"
|
|
64
60
|
},
|
|
65
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "f01bed379ebde07ecabca6591701fd1c3ec517d2"
|
|
66
62
|
}
|