@nzyme/fetch-utils 0.14.0 → 0.15.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/FetchError.d.ts +17 -3
- package/dist/FetchError.js +18 -5
- package/dist/FetchError.js.map +1 -1
- package/dist/HttpError.d.ts +37 -0
- package/dist/HttpError.js +36 -0
- package/dist/HttpError.js.map +1 -0
- package/dist/{types/HttpHeaders.d.ts → HttpHeaders.d.ts} +1 -1
- package/dist/{types/HttpHeaders.js.map → HttpHeaders.js.map} +1 -1
- package/dist/HttpMethod.d.ts +4 -0
- package/dist/{types/HttpMethod.js.map → HttpMethod.js.map} +1 -1
- package/dist/assertResponse.d.ts +5 -1
- package/dist/assertResponse.js +5 -1
- package/dist/assertResponse.js.map +1 -1
- package/dist/defineEndpoint.d.ts +10 -7
- package/dist/defineEndpoint.js +6 -3
- package/dist/defineEndpoint.js.map +1 -1
- package/dist/defineFetch.d.ts +9 -6
- package/dist/defineFetch.js +6 -3
- package/dist/defineFetch.js.map +1 -1
- package/dist/defineFetchClient.d.ts +21 -0
- package/dist/defineFetchClient.js +8 -1
- package/dist/defineFetchClient.js.map +1 -1
- package/dist/fetchEndpoint.d.ts +11 -5
- package/dist/fetchEndpoint.js +6 -1
- package/dist/fetchEndpoint.js.map +1 -1
- package/dist/fetchJson.d.ts +30 -6
- package/dist/fetchJson.js +8 -0
- package/dist/fetchJson.js.map +1 -1
- package/dist/fetchRequest.d.ts +23 -1
- package/dist/fetchRequest.js +7 -0
- package/dist/fetchRequest.js.map +1 -1
- package/dist/formUrlEncodedRequest.d.ts +13 -1
- package/dist/formUrlEncodedRequest.js +7 -0
- package/dist/formUrlEncodedRequest.js.map +1 -1
- package/dist/getResponseFileName.d.ts +16 -0
- package/dist/getResponseFileName.js +24 -0
- package/dist/getResponseFileName.js.map +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/jsonNullableResponse.d.ts +6 -2
- package/dist/jsonNullableResponse.js +6 -2
- package/dist/jsonNullableResponse.js.map +1 -1
- package/dist/jsonRequest.d.ts +13 -1
- package/dist/jsonRequest.js +7 -0
- package/dist/jsonRequest.js.map +1 -1
- package/dist/jsonResponse.d.ts +5 -1
- package/dist/jsonResponse.js +5 -1
- package/dist/jsonResponse.js.map +1 -1
- package/dist/xmlRequest.d.ts +13 -1
- package/dist/xmlRequest.js +8 -1
- package/dist/xmlRequest.js.map +1 -1
- package/dist/xmlResponse.d.ts +8 -2
- package/dist/xmlResponse.js +7 -2
- package/dist/xmlResponse.js.map +1 -1
- package/package.json +31 -39
- package/dist/FetchError.cjs +0 -16
- package/dist/FetchError.cjs.map +0 -1
- package/dist/assertResponse.cjs +0 -14
- package/dist/assertResponse.cjs.map +0 -1
- package/dist/defineEndpoint.cjs +0 -12
- package/dist/defineEndpoint.cjs.map +0 -1
- package/dist/defineFetch.cjs +0 -12
- package/dist/defineFetch.cjs.map +0 -1
- package/dist/defineFetchClient.cjs +0 -8
- package/dist/defineFetchClient.cjs.map +0 -1
- package/dist/fetchEndpoint.cjs +0 -30
- package/dist/fetchEndpoint.cjs.map +0 -1
- package/dist/fetchJson.cjs +0 -29
- package/dist/fetchJson.cjs.map +0 -1
- package/dist/fetchRequest.cjs +0 -13
- package/dist/fetchRequest.cjs.map +0 -1
- package/dist/formUrlEncodedRequest.cjs +0 -19
- package/dist/formUrlEncodedRequest.cjs.map +0 -1
- package/dist/index.cjs +0 -20
- package/dist/index.cjs.map +0 -1
- package/dist/jsonNullableResponse.cjs +0 -18
- package/dist/jsonNullableResponse.cjs.map +0 -1
- package/dist/jsonRequest.cjs +0 -17
- package/dist/jsonRequest.cjs.map +0 -1
- package/dist/jsonResponse.cjs +0 -12
- package/dist/jsonResponse.cjs.map +0 -1
- package/dist/types/HttpHeaders.cjs +0 -3
- package/dist/types/HttpHeaders.cjs.map +0 -1
- package/dist/types/HttpMethod.cjs +0 -3
- package/dist/types/HttpMethod.cjs.map +0 -1
- package/dist/types/HttpMethod.d.ts +0 -1
- package/dist/types/HttpResponse.cjs +0 -3
- package/dist/types/HttpResponse.cjs.map +0 -1
- package/dist/types/HttpResponse.d.ts +0 -7
- package/dist/types/HttpResponse.js +0 -2
- package/dist/types/HttpResponse.js.map +0 -1
- package/dist/xmlRequest.cjs +0 -18
- package/dist/xmlRequest.cjs.map +0 -1
- package/dist/xmlResponse.cjs +0 -14
- package/dist/xmlResponse.cjs.map +0 -1
- /package/dist/{types/HttpHeaders.js → HttpHeaders.js} +0 -0
- /package/dist/{types/HttpMethod.js → HttpMethod.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -2,15 +2,16 @@ export * from './assertResponse.js';
|
|
|
2
2
|
export * from './defineEndpoint.js';
|
|
3
3
|
export * from './defineFetchClient.js';
|
|
4
4
|
export * from './fetchEndpoint.js';
|
|
5
|
+
export * from './FetchError.js';
|
|
5
6
|
export * from './fetchJson.js';
|
|
6
7
|
export * from './fetchRequest.js';
|
|
7
|
-
export * from './FetchError.js';
|
|
8
8
|
export * from './formUrlEncodedRequest.js';
|
|
9
|
+
export * from './getResponseFileName.js';
|
|
10
|
+
export * from './HttpError.js';
|
|
11
|
+
export * from './HttpHeaders.js';
|
|
12
|
+
export * from './HttpMethod.js';
|
|
9
13
|
export * from './jsonNullableResponse.js';
|
|
10
14
|
export * from './jsonRequest.js';
|
|
11
15
|
export * from './jsonResponse.js';
|
|
12
16
|
export * from './xmlRequest.js';
|
|
13
17
|
export * from './xmlResponse.js';
|
|
14
|
-
export * from './types/HttpHeaders.js';
|
|
15
|
-
export * from './types/HttpMethod.js';
|
|
16
|
-
export * from './types/HttpResponse.js';
|
package/dist/index.js
CHANGED
|
@@ -2,16 +2,17 @@ export * from './assertResponse.js';
|
|
|
2
2
|
export * from './defineEndpoint.js';
|
|
3
3
|
export * from './defineFetchClient.js';
|
|
4
4
|
export * from './fetchEndpoint.js';
|
|
5
|
+
export * from './FetchError.js';
|
|
5
6
|
export * from './fetchJson.js';
|
|
6
7
|
export * from './fetchRequest.js';
|
|
7
|
-
export * from './FetchError.js';
|
|
8
8
|
export * from './formUrlEncodedRequest.js';
|
|
9
|
+
export * from './getResponseFileName.js';
|
|
10
|
+
export * from './HttpError.js';
|
|
11
|
+
export * from './HttpHeaders.js';
|
|
12
|
+
export * from './HttpMethod.js';
|
|
9
13
|
export * from './jsonNullableResponse.js';
|
|
10
14
|
export * from './jsonRequest.js';
|
|
11
15
|
export * from './jsonResponse.js';
|
|
12
16
|
export * from './xmlRequest.js';
|
|
13
17
|
export * from './xmlResponse.js';
|
|
14
|
-
export * from './types/HttpHeaders.js';
|
|
15
|
-
export * from './types/HttpMethod.js';
|
|
16
|
-
export * from './types/HttpResponse.js';
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Parses a Response object as JSON, with special handling for 404 responses.
|
|
3
|
+
* Unlike regular JSON parsing, this returns null for 404 status codes instead of throwing an error.
|
|
4
|
+
* @util
|
|
5
|
+
* @param response - The fetch Response object to parse
|
|
6
|
+
* @returns A promise that resolves to the parsed JSON data, or null for 404 responses
|
|
7
|
+
* @throws {FetchError} If the response status is not ok and not 404
|
|
4
8
|
*/
|
|
5
9
|
export declare function jsonNullableResponse<T>(response: Response): Promise<T | null>;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { FetchError } from './FetchError.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Parses a Response object as JSON, with special handling for 404 responses.
|
|
4
|
+
* Unlike regular JSON parsing, this returns null for 404 status codes instead of throwing an error.
|
|
5
|
+
* @util
|
|
6
|
+
* @param response - The fetch Response object to parse
|
|
7
|
+
* @returns A promise that resolves to the parsed JSON data, or null for 404 responses
|
|
8
|
+
* @throws {FetchError} If the response status is not ok and not 404
|
|
5
9
|
*/
|
|
6
10
|
export async function jsonNullableResponse(response) {
|
|
7
11
|
if (response.ok) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonNullableResponse.js","sourceRoot":"","sources":["../src/jsonNullableResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"jsonNullableResponse.js","sourceRoot":"","sources":["../src/jsonNullableResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAI,QAAkB;IAC5D,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/jsonRequest.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import type { OmitProps } from '@nzyme/types';
|
|
1
|
+
import type { OmitProps } from '@nzyme/types/Object.js';
|
|
2
2
|
import type { FetchRequest } from './fetchRequest.js';
|
|
3
|
+
/**
|
|
4
|
+
* Request configuration for JSON requests.
|
|
5
|
+
* Extends the base FetchRequest but allows for a typed body parameter.
|
|
6
|
+
*/
|
|
3
7
|
export interface EndpointJsonRequest<T = unknown> extends OmitProps<FetchRequest, 'body'> {
|
|
8
|
+
/** The request body that will be serialized as JSON */
|
|
4
9
|
body?: T;
|
|
5
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a fetch request with JSON body.
|
|
13
|
+
* Automatically sets the appropriate Content-Type header and serializes the body as JSON.
|
|
14
|
+
* @util
|
|
15
|
+
* @param request - The request configuration with JSON data
|
|
16
|
+
* @returns A FetchRequest configured for JSON submission
|
|
17
|
+
*/
|
|
6
18
|
export declare function jsonRequest<T>(request: EndpointJsonRequest<T>): FetchRequest;
|
package/dist/jsonRequest.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a fetch request with JSON body.
|
|
3
|
+
* Automatically sets the appropriate Content-Type header and serializes the body as JSON.
|
|
4
|
+
* @util
|
|
5
|
+
* @param request - The request configuration with JSON data
|
|
6
|
+
* @returns A FetchRequest configured for JSON submission
|
|
7
|
+
*/
|
|
1
8
|
export function jsonRequest(request) {
|
|
2
9
|
if (!request.body) {
|
|
3
10
|
return request;
|
package/dist/jsonRequest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonRequest.js","sourceRoot":"","sources":["../src/jsonRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsonRequest.js","sourceRoot":"","sources":["../src/jsonRequest.ts"],"names":[],"mappings":"AAaA;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAI,OAA+B;IAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,OAAuB,CAAC;IACnC,CAAC;IAED,OAAO;QACH,GAAG,OAAO;QACV,OAAO,EAAE;YACL,GAAG,OAAO,CAAC,OAAO;YAClB,cAAc,EAAE,kBAAkB;SACrC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;KACrC,CAAC;AACN,CAAC"}
|
package/dist/jsonResponse.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Parses a Response object as JSON and validates the response status.
|
|
3
|
+
* @util
|
|
4
|
+
* @param response - The fetch Response object to parse
|
|
5
|
+
* @returns A promise that resolves to the parsed JSON data
|
|
6
|
+
* @throws If the response status is not ok or if JSON parsing fails
|
|
3
7
|
*/
|
|
4
8
|
export declare function jsonResponse<T>(response: Response): Promise<T>;
|
package/dist/jsonResponse.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { assertResponse } from './assertResponse.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Parses a Response object as JSON and validates the response status.
|
|
4
|
+
* @util
|
|
5
|
+
* @param response - The fetch Response object to parse
|
|
6
|
+
* @returns A promise that resolves to the parsed JSON data
|
|
7
|
+
* @throws If the response status is not ok or if JSON parsing fails
|
|
4
8
|
*/
|
|
5
9
|
export async function jsonResponse(response) {
|
|
6
10
|
await assertResponse(response);
|
package/dist/jsonResponse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonResponse.js","sourceRoot":"","sources":["../src/jsonResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD
|
|
1
|
+
{"version":3,"file":"jsonResponse.js","sourceRoot":"","sources":["../src/jsonResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,QAAkB;IACpD,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;AACzC,CAAC"}
|
package/dist/xmlRequest.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
import type { XmlElement } from '@nzyme/xml-utils';
|
|
1
|
+
import type { XmlElement } from '@nzyme/xml-utils/xmlTypes.js';
|
|
2
2
|
import type { FetchRequest } from './fetchRequest.js';
|
|
3
|
+
/**
|
|
4
|
+
* Request configuration for XML requests.
|
|
5
|
+
* Extends the base FetchRequest but requires an XML element as the body.
|
|
6
|
+
*/
|
|
3
7
|
export interface EndpointXmlRequest extends Omit<FetchRequest, 'body'> {
|
|
8
|
+
/** The XML element to be sent as the request body */
|
|
4
9
|
body?: XmlElement;
|
|
5
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates a fetch request with XML body.
|
|
13
|
+
* Automatically sets the appropriate Content-Type header and serializes the XML element to a string.
|
|
14
|
+
* @util
|
|
15
|
+
* @param request - The request configuration with XML data
|
|
16
|
+
* @returns A FetchRequest configured for XML submission
|
|
17
|
+
*/
|
|
6
18
|
export declare function xmlRequest(request: EndpointXmlRequest): FetchRequest;
|
package/dist/xmlRequest.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import { xmlStringify } from '@nzyme/xml-utils';
|
|
1
|
+
import { xmlStringify } from '@nzyme/xml-utils/xmlStringify.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a fetch request with XML body.
|
|
4
|
+
* Automatically sets the appropriate Content-Type header and serializes the XML element to a string.
|
|
5
|
+
* @util
|
|
6
|
+
* @param request - The request configuration with XML data
|
|
7
|
+
* @returns A FetchRequest configured for XML submission
|
|
8
|
+
*/
|
|
2
9
|
export function xmlRequest(request) {
|
|
3
10
|
if (!request.body) {
|
|
4
11
|
return request;
|
package/dist/xmlRequest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xmlRequest.js","sourceRoot":"","sources":["../src/xmlRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"xmlRequest.js","sourceRoot":"","sources":["../src/xmlRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAchE;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAA2B;IAClD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,OAAuB,CAAC;IACnC,CAAC;IAED,OAAO;QACH,GAAG,OAAO;QACV,OAAO,EAAE;YACL,GAAG,OAAO,CAAC,OAAO;YAClB,cAAc,EAAE,UAAU;SAC7B;QACD,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC;KACnC,CAAC;AACN,CAAC"}
|
package/dist/xmlResponse.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
import type { XmlElement } from '@nzyme/xml-utils/xmlTypes.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* Parses a Response object as XML and validates the response status.
|
|
4
|
+
* Uses @nzyme/xml-utils for XML parsing.
|
|
5
|
+
* @util
|
|
6
|
+
* @param response - The fetch Response object to parse
|
|
7
|
+
* @returns A promise that resolves to the parsed XML document
|
|
8
|
+
* @throws If the response status is not ok or if XML parsing fails
|
|
3
9
|
*/
|
|
4
|
-
export declare function xmlResponse(response: Response): Promise<
|
|
10
|
+
export declare function xmlResponse<T = XmlElement>(response: Response): Promise<T>;
|
package/dist/xmlResponse.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import { xmlParse } from '@nzyme/xml-utils';
|
|
1
|
+
import { xmlParse } from '@nzyme/xml-utils/xmlParse.js';
|
|
2
2
|
import { assertResponse } from './assertResponse.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Parses a Response object as XML and validates the response status.
|
|
5
|
+
* Uses @nzyme/xml-utils for XML parsing.
|
|
6
|
+
* @util
|
|
7
|
+
* @param response - The fetch Response object to parse
|
|
8
|
+
* @returns A promise that resolves to the parsed XML document
|
|
9
|
+
* @throws If the response status is not ok or if XML parsing fails
|
|
5
10
|
*/
|
|
6
11
|
export async function xmlResponse(response) {
|
|
7
12
|
await assertResponse(response);
|
package/dist/xmlResponse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xmlResponse.js","sourceRoot":"","sources":["../src/xmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"xmlResponse.js","sourceRoot":"","sources":["../src/xmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAGxD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAiB,QAAkB;IAChE,MAAM,cAAc,CAAC,QAAQ,CAAC,CAAC;IAE/B,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClC,OAAO,QAAQ,CAAI,GAAG,CAAC,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,58 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nzyme/fetch-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "Fetch/HTTP client utilities",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Michał Kędrzyński <m.kedrzynski@gmail.com>",
|
|
4
7
|
"repository": {
|
|
5
8
|
"type": "git",
|
|
6
9
|
"url": "https://github.com/kedrzu/nzyme.git"
|
|
7
10
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
11
14
|
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
12
18
|
"exports": {
|
|
13
19
|
".": {
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"default": {
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
|
-
"default": "./dist/index.js"
|
|
25
|
-
}
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./*.js": {
|
|
24
|
+
"types": "./dist/*.d.ts",
|
|
25
|
+
"import": "./dist/*.js",
|
|
26
|
+
"source": "./src/*.ts",
|
|
27
|
+
"default": "./dist/*.js"
|
|
26
28
|
}
|
|
27
29
|
},
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"dist"
|
|
32
|
-
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build
|
|
35
|
-
"
|
|
36
|
-
"lint": "eslint . --fix --cache",
|
|
37
|
-
"smoke:cjs": "node tests/smoke.test.cjs",
|
|
38
|
-
"smoke:mjs": "node tests/smoke.test.mjs"
|
|
34
|
+
"build": "tsgo --build tsconfig.esm.json",
|
|
35
|
+
"format": "oxfmt ./src > /dev/null"
|
|
39
36
|
},
|
|
40
37
|
"dependencies": {
|
|
41
|
-
"@nzyme/
|
|
42
|
-
"@nzyme/
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"ufo": "^1.6.1"
|
|
38
|
+
"@nzyme/types": "0.15.0",
|
|
39
|
+
"@nzyme/xml-utils": "0.15.0",
|
|
40
|
+
"fast-xml-parser": "5.11.2",
|
|
41
|
+
"ufo": "1.6.4"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
|
-
"@nzyme/
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"typescript": "^5.8.3"
|
|
53
|
-
},
|
|
54
|
-
"publishConfig": {
|
|
55
|
-
"access": "public"
|
|
44
|
+
"@nzyme/tsconfig": "0.15.0",
|
|
45
|
+
"@types/node": "26.6.4",
|
|
46
|
+
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|
|
47
|
+
"oxfmt": "0.71.0"
|
|
56
48
|
},
|
|
57
49
|
"nzyme": {
|
|
58
50
|
"cjs": true
|
package/dist/FetchError.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FetchError = void 0;
|
|
4
|
-
class FetchError extends Error {
|
|
5
|
-
response;
|
|
6
|
-
status;
|
|
7
|
-
url;
|
|
8
|
-
constructor(response, message) {
|
|
9
|
-
super(message || response.statusText);
|
|
10
|
-
this.response = response;
|
|
11
|
-
this.url = response.url;
|
|
12
|
-
this.status = response.status;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.FetchError = FetchError;
|
|
16
|
-
//# sourceMappingURL=FetchError.cjs.map
|
package/dist/FetchError.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FetchError.cjs","sourceRoot":"","sources":["../src/FetchError.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAW,SAAQ,KAAK;IAKb;IAJJ,MAAM,CAAS;IACf,GAAG,CAAS;IAE5B,YACoB,QAAkB,EAClC,OAAgB;QAEhB,KAAK,CAAC,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;QAHtB,aAAQ,GAAR,QAAQ,CAAU;QAIlC,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC;IAClC,CAAC;CACJ;AAZD,gCAYC"}
|
package/dist/assertResponse.cjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertResponse = assertResponse;
|
|
4
|
-
const FetchError_js_1 = require("./FetchError.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* Assert that a response is ok.
|
|
7
|
-
*/
|
|
8
|
-
async function assertResponse(response) {
|
|
9
|
-
if (!response.ok) {
|
|
10
|
-
const message = await response.text();
|
|
11
|
-
throw new FetchError_js_1.FetchError(response, message);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=assertResponse.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertResponse.cjs","sourceRoot":"","sources":["../src/assertResponse.ts"],"names":[],"mappings":";;AAKA,wCAKC;AAVD,mDAA6C;AAE7C;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,QAAkB;IACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtC,MAAM,IAAI,0BAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC"}
|
package/dist/defineEndpoint.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineEndpoint = defineEndpoint;
|
|
4
|
-
/**
|
|
5
|
-
* Define a fetch endpoint.
|
|
6
|
-
*
|
|
7
|
-
* #__NO_SIDE_EFFECTS__
|
|
8
|
-
*/
|
|
9
|
-
function defineEndpoint(endpoint) {
|
|
10
|
-
return endpoint;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=defineEndpoint.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineEndpoint.cjs","sourceRoot":"","sources":["../src/defineEndpoint.ts"],"names":[],"mappings":";;AA4BA,wCAIC;AATD;;;;GAIG;AACH,SAAgB,cAAc,CAC1B,QAAoC;IAEpC,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/dist/defineFetch.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineFetch = defineFetch;
|
|
4
|
-
/**
|
|
5
|
-
* Define a fetch function.
|
|
6
|
-
*
|
|
7
|
-
* #__NO_SIDE_EFFECTS__
|
|
8
|
-
*/
|
|
9
|
-
function defineFetch(fetch) {
|
|
10
|
-
return fetch;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=defineFetch.cjs.map
|
package/dist/defineFetch.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineFetch.cjs","sourceRoot":"","sources":["../src/defineFetch.ts"],"names":[],"mappings":";;AAqBA,kCAEC;AAPD;;;;GAIG;AACH,SAAgB,WAAW,CAAiC,KAAqC;IAC7F,OAAO,KAAK,CAAC;AACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineFetchClient.cjs","sourceRoot":"","sources":["../src/defineFetchClient.ts"],"names":[],"mappings":";;AAYA,8CAEC;AAHD,wBAAwB;AACxB,SAAgB,iBAAiB,CAAC,MAAwB;IACtD,OAAO,MAAqB,CAAC;AACjC,CAAC"}
|
package/dist/fetchEndpoint.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchEndpoint = fetchEndpoint;
|
|
4
|
-
const ufo_1 = require("ufo");
|
|
5
|
-
const assertResponse_js_1 = require("./assertResponse.cjs");
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
async function fetchEndpoint(endpoint, params) {
|
|
10
|
-
let request = endpoint.request(params.params);
|
|
11
|
-
request = {
|
|
12
|
-
...request,
|
|
13
|
-
url: params.baseUrl ? (0, ufo_1.joinURL)(params.baseUrl, request.url) : request.url,
|
|
14
|
-
headers: {
|
|
15
|
-
...params.headers,
|
|
16
|
-
...request.headers,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
const url = request.query ? (0, ufo_1.withQuery)(request.url, request.query) : request.url;
|
|
20
|
-
// Clone the response to avoid "Other side closed error"
|
|
21
|
-
const response = (await fetch(url, request)).clone();
|
|
22
|
-
if (endpoint.response) {
|
|
23
|
-
return await endpoint.response(response, params.params);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
await (0, assertResponse_js_1.assertResponse)(response);
|
|
27
|
-
}
|
|
28
|
-
return undefined;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=fetchEndpoint.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchEndpoint.cjs","sourceRoot":"","sources":["../src/fetchEndpoint.ts"],"names":[],"mappings":";;AA0BA,sCA0BC;AApDD,6BAAyC;AAEzC,2DAAqD;AAqBrD;;GAEG;AACI,KAAK,UAAU,aAAa,CAC/B,QAAoC,EACpC,MAAoC;IAEpC,IAAI,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE9C,OAAO,GAAG;QACN,GAAG,OAAO;QACV,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,aAAO,EAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG;QACxE,OAAO,EAAE;YACL,GAAG,MAAM,CAAC,OAAO;YACjB,GAAG,OAAO,CAAC,OAAO;SACrB;KACJ,CAAC;IAEF,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,eAAS,EAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAChF,wDAAwD;IACxD,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAErD,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;SAAM,CAAC;QACJ,MAAM,IAAA,kCAAc,EAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,SAA+B,CAAC;AAC3C,CAAC"}
|
package/dist/fetchJson.cjs
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchJson = fetchJson;
|
|
4
|
-
const ufo_1 = require("ufo");
|
|
5
|
-
const FetchError_js_1 = require("./FetchError.cjs");
|
|
6
|
-
async function fetchJson(request) {
|
|
7
|
-
const headers = { ...request.headers };
|
|
8
|
-
let url = request.url;
|
|
9
|
-
if (request.query) {
|
|
10
|
-
url = (0, ufo_1.withQuery)(url, request.query);
|
|
11
|
-
}
|
|
12
|
-
const requestInit = {
|
|
13
|
-
method: request.method || 'GET',
|
|
14
|
-
headers: headers,
|
|
15
|
-
};
|
|
16
|
-
if (request.data) {
|
|
17
|
-
headers['Content-Type'] = 'application/json';
|
|
18
|
-
requestInit.body = JSON.stringify(request.data);
|
|
19
|
-
}
|
|
20
|
-
const response = await fetch(url, requestInit);
|
|
21
|
-
if (!response.ok) {
|
|
22
|
-
throw new FetchError_js_1.FetchError(response);
|
|
23
|
-
}
|
|
24
|
-
if (response.status === 204) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
return (await response.json());
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=fetchJson.cjs.map
|
package/dist/fetchJson.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchJson.cjs","sourceRoot":"","sources":["../src/fetchJson.ts"],"names":[],"mappings":";;AAqBA,8BA2BC;AA/CD,6BAAgC;AAEhC,mDAA6C;AAkBtC,KAAK,UAAU,SAAS,CAAI,OAAoC;IACnE,MAAM,OAAO,GAA2B,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC/D,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IACtB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,GAAG,GAAG,IAAA,eAAS,EAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,WAAW,GAAgB;QAC7B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,KAAK;QAC/B,OAAO,EAAE,OAAO;KACnB,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;QAC7C,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACf,MAAM,IAAI,0BAAU,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;AACxC,CAAC"}
|
package/dist/fetchRequest.cjs
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchRequest = fetchRequest;
|
|
4
|
-
const ufo_1 = require("ufo");
|
|
5
|
-
const assertResponse_js_1 = require("./assertResponse.cjs");
|
|
6
|
-
async function fetchRequest(request) {
|
|
7
|
-
const url = request.query ? (0, ufo_1.withQuery)(request.url, request.query) : request.url;
|
|
8
|
-
const response = await fetch(url, request);
|
|
9
|
-
await (0, assertResponse_js_1.assertResponse)(response);
|
|
10
|
-
// Clone the response to avoid "Other side closed error"
|
|
11
|
-
return response.clone();
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=fetchRequest.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRequest.cjs","sourceRoot":"","sources":["../src/fetchRequest.ts"],"names":[],"mappings":";;AAaA,oCAOC;AAnBD,6BAAgC;AAEhC,2DAAqD;AAU9C,KAAK,UAAU,YAAY,CAAC,OAAqB;IACpD,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,eAAS,EAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAChF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAE3C,MAAM,IAAA,kCAAc,EAAC,QAAQ,CAAC,CAAC;IAC/B,wDAAwD;IACxD,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formUrlEncodedRequest = formUrlEncodedRequest;
|
|
4
|
-
function formUrlEncodedRequest(request) {
|
|
5
|
-
if (!request.body) {
|
|
6
|
-
return request;
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
url: request.url,
|
|
10
|
-
method: request.method,
|
|
11
|
-
query: request.query,
|
|
12
|
-
headers: {
|
|
13
|
-
...request.headers,
|
|
14
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
15
|
-
},
|
|
16
|
-
body: new URLSearchParams(request.body),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=formUrlEncodedRequest.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formUrlEncodedRequest.cjs","sourceRoot":"","sources":["../src/formUrlEncodedRequest.ts"],"names":[],"mappings":";;AASA,sDAeC;AAfD,SAAgB,qBAAqB,CAAI,OAAyC;IAC9E,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,OAAuB,CAAC;IACnC,CAAC;IAED,OAAO;QACH,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE;YACL,GAAG,OAAO,CAAC,OAAO;YAClB,cAAc,EAAE,mCAAmC;SACtD;QACD,IAAI,EAAE,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC;KAC1C,CAAC;AACN,CAAC"}
|
package/dist/index.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./assertResponse.cjs"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./defineEndpoint.cjs"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./defineFetchClient.cjs"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./fetchEndpoint.cjs"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./fetchJson.cjs"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./fetchRequest.cjs"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./FetchError.cjs"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./formUrlEncodedRequest.cjs"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./jsonNullableResponse.cjs"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./jsonRequest.cjs"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./jsonResponse.cjs"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./xmlRequest.cjs"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./xmlResponse.cjs"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./types/HttpHeaders.cjs"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./types/HttpMethod.cjs"), exports);
|
|
19
|
-
tslib_1.__exportStar(require("./types/HttpResponse.cjs"), exports);
|
|
20
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,8DAAoC;AACpC,8DAAoC;AACpC,iEAAuC;AACvC,6DAAmC;AACnC,yDAA+B;AAC/B,4DAAkC;AAClC,0DAAgC;AAChC,qEAA2C;AAC3C,oEAA0C;AAC1C,2DAAiC;AACjC,4DAAkC;AAClC,0DAAgC;AAChC,2DAAiC;AAEjC,iEAAuC;AACvC,gEAAsC;AACtC,kEAAwC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonNullableResponse = jsonNullableResponse;
|
|
4
|
-
const FetchError_js_1 = require("./FetchError.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* Parse a JSON response.
|
|
7
|
-
* Returns null if the response is 404.
|
|
8
|
-
*/
|
|
9
|
-
async function jsonNullableResponse(response) {
|
|
10
|
-
if (response.ok) {
|
|
11
|
-
return (await response.json());
|
|
12
|
-
}
|
|
13
|
-
if (response.status === 404) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
throw new FetchError_js_1.FetchError(response);
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=jsonNullableResponse.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonNullableResponse.cjs","sourceRoot":"","sources":["../src/jsonNullableResponse.ts"],"names":[],"mappings":";;AAMA,oDAUC;AAhBD,mDAA6C;AAE7C;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CAAI,QAAkB;IAC5D,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QACd,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACxC,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,0BAAU,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/jsonRequest.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonRequest = jsonRequest;
|
|
4
|
-
function jsonRequest(request) {
|
|
5
|
-
if (!request.body) {
|
|
6
|
-
return request;
|
|
7
|
-
}
|
|
8
|
-
return {
|
|
9
|
-
...request,
|
|
10
|
-
headers: {
|
|
11
|
-
...request.headers,
|
|
12
|
-
'Content-Type': 'application/json',
|
|
13
|
-
},
|
|
14
|
-
body: JSON.stringify(request.body),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=jsonRequest.cjs.map
|
package/dist/jsonRequest.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonRequest.cjs","sourceRoot":"","sources":["../src/jsonRequest.ts"],"names":[],"mappings":";;AAQA,kCAaC;AAbD,SAAgB,WAAW,CAAI,OAA+B;IAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAChB,OAAO,OAAuB,CAAC;IACnC,CAAC;IAED,OAAO;QACH,GAAG,OAAO;QACV,OAAO,EAAE;YACL,GAAG,OAAO,CAAC,OAAO;YAClB,cAAc,EAAE,kBAAkB;SACrC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;KACrC,CAAC;AACN,CAAC"}
|
package/dist/jsonResponse.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.jsonResponse = jsonResponse;
|
|
4
|
-
const assertResponse_js_1 = require("./assertResponse.cjs");
|
|
5
|
-
/**
|
|
6
|
-
* Parse a JSON response.
|
|
7
|
-
*/
|
|
8
|
-
async function jsonResponse(response) {
|
|
9
|
-
await (0, assertResponse_js_1.assertResponse)(response);
|
|
10
|
-
return response.json();
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=jsonResponse.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jsonResponse.cjs","sourceRoot":"","sources":["../src/jsonResponse.ts"],"names":[],"mappings":";;AAKA,oCAGC;AARD,2DAAqD;AAErD;;GAEG;AACI,KAAK,UAAU,YAAY,CAAI,QAAkB;IACpD,MAAM,IAAA,kCAAc,EAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;AACzC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpHeaders.cjs","sourceRoot":"","sources":["../../src/types/HttpHeaders.ts"],"names":[],"mappings":""}
|