@nzyme/fetch-utils 0.4.1 → 0.6.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.
Files changed (110) hide show
  1. package/dist/cjs/FetchError.cjs +16 -0
  2. package/dist/cjs/FetchError.cjs.map +1 -0
  3. package/dist/cjs/assertResponse.cjs +11 -0
  4. package/dist/cjs/assertResponse.cjs.map +1 -0
  5. package/dist/cjs/defineEndpoint.cjs +8 -0
  6. package/dist/cjs/defineEndpoint.cjs.map +1 -0
  7. package/dist/cjs/defineFetchClient.cjs +8 -0
  8. package/dist/cjs/defineFetchClient.cjs.map +1 -0
  9. package/dist/cjs/fetchEndpoint.cjs +23 -0
  10. package/dist/cjs/fetchEndpoint.cjs.map +1 -0
  11. package/dist/cjs/fetchJson.cjs +29 -0
  12. package/dist/cjs/fetchJson.cjs.map +1 -0
  13. package/dist/cjs/fetchRequest.cjs +13 -0
  14. package/dist/cjs/fetchRequest.cjs.map +1 -0
  15. package/dist/{fetchRequest.d.ts → cjs/fetchRequest.d.ts} +1 -1
  16. package/dist/cjs/formUrlEncodedRequest.cjs +19 -0
  17. package/dist/cjs/formUrlEncodedRequest.cjs.map +1 -0
  18. package/dist/cjs/index.cjs +19 -0
  19. package/dist/cjs/index.cjs.map +1 -0
  20. package/dist/cjs/jsonRequest.cjs +17 -0
  21. package/dist/cjs/jsonRequest.cjs.map +1 -0
  22. package/dist/cjs/jsonResponse.cjs +7 -0
  23. package/dist/cjs/jsonResponse.cjs.map +1 -0
  24. package/dist/cjs/types/HttpHeaders.cjs +3 -0
  25. package/dist/cjs/types/HttpHeaders.cjs.map +1 -0
  26. package/dist/cjs/types/HttpMethod.cjs +3 -0
  27. package/dist/cjs/types/HttpMethod.cjs.map +1 -0
  28. package/dist/cjs/types/HttpResponse.cjs +3 -0
  29. package/dist/cjs/types/HttpResponse.cjs.map +1 -0
  30. package/dist/cjs/xmlRequest.cjs +18 -0
  31. package/dist/cjs/xmlRequest.cjs.map +1 -0
  32. package/dist/cjs/xmlResponse.cjs +9 -0
  33. package/dist/cjs/xmlResponse.cjs.map +1 -0
  34. package/dist/esm/FetchError.d.ts +6 -0
  35. package/dist/esm/FetchError.js.map +1 -0
  36. package/dist/esm/assertResponse.d.ts +1 -0
  37. package/dist/esm/assertResponse.js.map +1 -0
  38. package/dist/esm/defineEndpoint.d.ts +9 -0
  39. package/dist/esm/defineEndpoint.js.map +1 -0
  40. package/dist/esm/defineFetchClient.d.ts +10 -0
  41. package/dist/esm/defineFetchClient.js.map +1 -0
  42. package/dist/esm/fetchEndpoint.d.ts +9 -0
  43. package/dist/esm/fetchEndpoint.js.map +1 -0
  44. package/dist/esm/fetchJson.d.ts +16 -0
  45. package/dist/esm/fetchJson.js.map +1 -0
  46. package/dist/esm/fetchRequest.d.ts +9 -0
  47. package/dist/esm/fetchRequest.js.map +1 -0
  48. package/dist/esm/formUrlEncodedRequest.d.ts +6 -0
  49. package/dist/esm/formUrlEncodedRequest.js.map +1 -0
  50. package/dist/esm/index.d.ts +15 -0
  51. package/dist/esm/index.js.map +1 -0
  52. package/dist/esm/jsonRequest.d.ts +6 -0
  53. package/dist/esm/jsonRequest.js.map +1 -0
  54. package/dist/esm/jsonResponse.d.ts +1 -0
  55. package/dist/esm/jsonResponse.js.map +1 -0
  56. package/dist/esm/types/HttpHeaders.d.ts +1 -0
  57. package/dist/{types → esm/types}/HttpHeaders.js.map +1 -1
  58. package/dist/esm/types/HttpMethod.d.ts +1 -0
  59. package/dist/{types → esm/types}/HttpMethod.js.map +1 -1
  60. package/dist/esm/types/HttpResponse.d.ts +7 -0
  61. package/dist/{types → esm/types}/HttpResponse.js.map +1 -1
  62. package/dist/esm/xmlRequest.d.ts +6 -0
  63. package/dist/esm/xmlRequest.js.map +1 -0
  64. package/dist/esm/xmlResponse.d.ts +1 -0
  65. package/dist/esm/xmlResponse.js.map +1 -0
  66. package/package.json +28 -12
  67. package/dist/FetchError.js.map +0 -1
  68. package/dist/assertResponse.js.map +0 -1
  69. package/dist/defineEndpoint.js.map +0 -1
  70. package/dist/defineFetchClient.js.map +0 -1
  71. package/dist/fetchEndpoint.js.map +0 -1
  72. package/dist/fetchJson.js.map +0 -1
  73. package/dist/fetchRequest.js.map +0 -1
  74. package/dist/formUrlEncodedRequest.js.map +0 -1
  75. package/dist/index.js.map +0 -1
  76. package/dist/jsonRequest.js.map +0 -1
  77. package/dist/jsonResponse.js.map +0 -1
  78. package/dist/xmlRequest.js.map +0 -1
  79. package/dist/xmlResponse.js.map +0 -1
  80. /package/dist/{FetchError.d.ts → cjs/FetchError.d.ts} +0 -0
  81. /package/dist/{assertResponse.d.ts → cjs/assertResponse.d.ts} +0 -0
  82. /package/dist/{defineEndpoint.d.ts → cjs/defineEndpoint.d.ts} +0 -0
  83. /package/dist/{defineFetchClient.d.ts → cjs/defineFetchClient.d.ts} +0 -0
  84. /package/dist/{fetchEndpoint.d.ts → cjs/fetchEndpoint.d.ts} +0 -0
  85. /package/dist/{fetchJson.d.ts → cjs/fetchJson.d.ts} +0 -0
  86. /package/dist/{formUrlEncodedRequest.d.ts → cjs/formUrlEncodedRequest.d.ts} +0 -0
  87. /package/dist/{index.d.ts → cjs/index.d.ts} +0 -0
  88. /package/dist/{jsonRequest.d.ts → cjs/jsonRequest.d.ts} +0 -0
  89. /package/dist/{jsonResponse.d.ts → cjs/jsonResponse.d.ts} +0 -0
  90. /package/dist/{types → cjs/types}/HttpHeaders.d.ts +0 -0
  91. /package/dist/{types → cjs/types}/HttpMethod.d.ts +0 -0
  92. /package/dist/{types → cjs/types}/HttpResponse.d.ts +0 -0
  93. /package/dist/{xmlRequest.d.ts → cjs/xmlRequest.d.ts} +0 -0
  94. /package/dist/{xmlResponse.d.ts → cjs/xmlResponse.d.ts} +0 -0
  95. /package/dist/{FetchError.js → esm/FetchError.js} +0 -0
  96. /package/dist/{assertResponse.js → esm/assertResponse.js} +0 -0
  97. /package/dist/{defineEndpoint.js → esm/defineEndpoint.js} +0 -0
  98. /package/dist/{defineFetchClient.js → esm/defineFetchClient.js} +0 -0
  99. /package/dist/{fetchEndpoint.js → esm/fetchEndpoint.js} +0 -0
  100. /package/dist/{fetchJson.js → esm/fetchJson.js} +0 -0
  101. /package/dist/{fetchRequest.js → esm/fetchRequest.js} +0 -0
  102. /package/dist/{formUrlEncodedRequest.js → esm/formUrlEncodedRequest.js} +0 -0
  103. /package/dist/{index.js → esm/index.js} +0 -0
  104. /package/dist/{jsonRequest.js → esm/jsonRequest.js} +0 -0
  105. /package/dist/{jsonResponse.js → esm/jsonResponse.js} +0 -0
  106. /package/dist/{types → esm/types}/HttpHeaders.js +0 -0
  107. /package/dist/{types → esm/types}/HttpMethod.js +0 -0
  108. /package/dist/{types → esm/types}/HttpResponse.js +0 -0
  109. /package/dist/{xmlRequest.js → esm/xmlRequest.js} +0 -0
  110. /package/dist/{xmlResponse.js → esm/xmlResponse.js} +0 -0
@@ -0,0 +1,16 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertResponse = assertResponse;
4
+ const FetchError_js_1 = require("./FetchError.cjs");
5
+ async function assertResponse(response) {
6
+ if (!response.ok) {
7
+ const message = await response.text();
8
+ throw new FetchError_js_1.FetchError(response, message);
9
+ }
10
+ }
11
+ //# sourceMappingURL=assertResponse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertResponse.cjs","sourceRoot":"","sources":["../../src/assertResponse.ts"],"names":[],"mappings":";;AAEA,wCAKC;AAPD,mDAA6C;AAEtC,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"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineEndpoint = defineEndpoint;
4
+ /*#__NO_SIDE_EFFECTS__*/
5
+ function defineEndpoint(endpoint) {
6
+ return endpoint;
7
+ }
8
+ //# sourceMappingURL=defineEndpoint.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineEndpoint.cjs","sourceRoot":"","sources":["../../src/defineEndpoint.ts"],"names":[],"mappings":";;AAYA,wCAIC;AALD,wBAAwB;AACxB,SAAgB,cAAc,CAC1B,QAAoC;IAEpC,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineFetchClient = defineFetchClient;
4
+ /*#__NO_SIDE_EFFECTS__*/
5
+ function defineFetchClient(client) {
6
+ return client;
7
+ }
8
+ //# sourceMappingURL=defineFetchClient.cjs.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchEndpoint = fetchEndpoint;
4
+ const ufo_1 = require("ufo");
5
+ const fetchRequest_js_1 = require("./fetchRequest.cjs");
6
+ async function fetchEndpoint(endpoint, params) {
7
+ let request = endpoint.request(params.params);
8
+ request = {
9
+ ...request,
10
+ url: params.baseUrl ? (0, ufo_1.joinURL)(params.baseUrl, request.url) : request.url,
11
+ headers: {
12
+ ...params.headers,
13
+ ...request.headers,
14
+ },
15
+ };
16
+ params.onRequest?.(request);
17
+ const response = await (0, fetchRequest_js_1.fetchRequest)(request);
18
+ if (endpoint.response) {
19
+ return await endpoint.response(response, params.params);
20
+ }
21
+ return undefined;
22
+ }
23
+ //# sourceMappingURL=fetchEndpoint.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchEndpoint.cjs","sourceRoot":"","sources":["../../src/fetchEndpoint.ts"],"names":[],"mappings":";;AAaA,sCAuBC;AApCD,6BAA8B;AAI9B,uDAAiD;AAS1C,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,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,IAAA,8BAAY,EAAC,OAAO,CAAC,CAAC;IAE7C,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,SAA+B,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,29 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,13 @@
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
@@ -0,0 +1 @@
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"}
@@ -6,4 +6,4 @@ export interface FetchRequest extends RequestInit {
6
6
  method?: HttpMethod;
7
7
  headers?: Record<string, string>;
8
8
  }
9
- export declare function fetchRequest(request: FetchRequest): Promise<Response>;
9
+ export declare function fetchRequest(request: FetchRequest): Promise<import("undici-types").Response>;
@@ -0,0 +1,19 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,19 @@
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("./jsonRequest.cjs"), exports);
13
+ tslib_1.__exportStar(require("./jsonResponse.cjs"), exports);
14
+ tslib_1.__exportStar(require("./xmlRequest.cjs"), exports);
15
+ tslib_1.__exportStar(require("./xmlResponse.cjs"), exports);
16
+ tslib_1.__exportStar(require("./types/HttpHeaders.cjs"), exports);
17
+ tslib_1.__exportStar(require("./types/HttpMethod.cjs"), exports);
18
+ tslib_1.__exportStar(require("./types/HttpResponse.cjs"), exports);
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
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,2DAAiC;AACjC,4DAAkC;AAClC,0DAAgC;AAChC,2DAAiC;AAEjC,iEAAuC;AACvC,gEAAsC;AACtC,kEAAwC"}
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.jsonResponse = jsonResponse;
4
+ function jsonResponse(response) {
5
+ return response.json();
6
+ }
7
+ //# sourceMappingURL=jsonResponse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonResponse.cjs","sourceRoot":"","sources":["../../src/jsonResponse.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAFD,SAAgB,YAAY,CAAI,QAAkB;IAC9C,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;AACzC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=HttpHeaders.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpHeaders.cjs","sourceRoot":"","sources":["../../../src/types/HttpHeaders.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=HttpMethod.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpMethod.cjs","sourceRoot":"","sources":["../../../src/types/HttpMethod.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=HttpResponse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpResponse.cjs","sourceRoot":"","sources":["../../../src/types/HttpResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xmlRequest = xmlRequest;
4
+ const xml_utils_1 = require("@nzyme/xml-utils");
5
+ function xmlRequest(request) {
6
+ if (!request.body) {
7
+ return request;
8
+ }
9
+ return {
10
+ ...request,
11
+ headers: {
12
+ ...request.headers,
13
+ 'Content-Type': 'text/xml',
14
+ },
15
+ body: (0, xml_utils_1.xmlStringify)(request.body),
16
+ };
17
+ }
18
+ //# sourceMappingURL=xmlRequest.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmlRequest.cjs","sourceRoot":"","sources":["../../src/xmlRequest.ts"],"names":[],"mappings":";;AASA,gCAaC;AArBD,gDAAgD;AAQhD,SAAgB,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,IAAA,wBAAY,EAAC,OAAO,CAAC,IAAI,CAAC;KACnC,CAAC;AACN,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xmlResponse = xmlResponse;
4
+ const xml_utils_1 = require("@nzyme/xml-utils");
5
+ async function xmlResponse(response) {
6
+ const xml = await response.text();
7
+ return (0, xml_utils_1.xmlParse)(xml);
8
+ }
9
+ //# sourceMappingURL=xmlResponse.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmlResponse.cjs","sourceRoot":"","sources":["../../src/xmlResponse.ts"],"names":[],"mappings":";;AAEA,kCAGC;AALD,gDAA4C;AAErC,KAAK,UAAU,WAAW,CAAC,QAAkB;IAChD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClC,OAAO,IAAA,oBAAQ,EAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare class FetchError extends Error {
2
+ readonly response: Response;
3
+ readonly status: number;
4
+ readonly url: string;
5
+ constructor(response: Response, message?: string);
6
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FetchError.js","sourceRoot":"","sources":["../../src/FetchError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,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"}
@@ -0,0 +1 @@
1
+ export declare function assertResponse(response: Response): Promise<void>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertResponse.js","sourceRoot":"","sources":["../../src/assertResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,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,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { FetchRequest } from './fetchRequest.js';
2
+ export interface Endpoint<TParams, TResult> {
3
+ request: (params: TParams) => FetchRequest;
4
+ response?: (response: Response, params: TParams) => Promise<TResult>;
5
+ }
6
+ export interface EndpointResponse<T> {
7
+ (response: Response): Promise<T>;
8
+ }
9
+ export declare function defineEndpoint<TParams = void, TResult = void>(endpoint: Endpoint<TParams, TResult>): Endpoint<TParams, TResult>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineEndpoint.js","sourceRoot":"","sources":["../../src/defineEndpoint.ts"],"names":[],"mappings":"AAWA,wBAAwB;AACxB,MAAM,UAAU,cAAc,CAC1B,QAAoC;IAEpC,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { Endpoint } from './defineEndpoint.js';
2
+ export interface FetchClient {
3
+ <TResult>(endpoint: Endpoint<void, TResult>): Promise<TResult>;
4
+ <TParams, TResult>(endpoint: Endpoint<TParams, TResult>, params: TParams): Promise<TResult>;
5
+ }
6
+ interface FetchClientInput {
7
+ (endpoint: Endpoint<unknown, unknown>, params?: unknown): Promise<unknown>;
8
+ }
9
+ export declare function defineFetchClient(client: FetchClientInput): FetchClient;
10
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineFetchClient.js","sourceRoot":"","sources":["../../src/defineFetchClient.ts"],"names":[],"mappings":"AAWA,wBAAwB;AACxB,MAAM,UAAU,iBAAiB,CAAC,MAAwB;IACtD,OAAO,MAAqB,CAAC;AACjC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Endpoint } from './defineEndpoint.js';
2
+ import type { FetchRequest } from './fetchRequest.js';
3
+ export interface FetchEndpointParams<TParams> {
4
+ params: TParams;
5
+ baseUrl?: string;
6
+ headers?: Record<string, string>;
7
+ onRequest?: (request: FetchRequest) => void;
8
+ }
9
+ export declare function fetchEndpoint<TParams, TResult>(endpoint: Endpoint<TParams, TResult>, params: FetchEndpointParams<TParams>): Promise<TResult>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchEndpoint.js","sourceRoot":"","sources":["../../src/fetchEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAI9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,MAAM,CAAC,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,OAAO,CAAC,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,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAE7C,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,SAA+B,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { QueryObject } from 'ufo';
2
+ interface BaseRequest {
3
+ url: string;
4
+ query?: QueryObject;
5
+ headers?: Record<string, string>;
6
+ }
7
+ interface SimpleRequest extends BaseRequest {
8
+ method?: 'GET' | 'HEAD' | 'DELETE';
9
+ data?: never;
10
+ }
11
+ interface DataRequest extends BaseRequest {
12
+ method: 'POST' | 'PUT' | 'PATCH';
13
+ data?: unknown;
14
+ }
15
+ export declare function fetchJson<T>(request: SimpleRequest | DataRequest): Promise<T | null>;
16
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../../src/fetchJson.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkB7C,MAAM,CAAC,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,SAAS,CAAC,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,UAAU,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"}
@@ -0,0 +1,9 @@
1
+ import type { QueryObject } from 'ufo';
2
+ import type { HttpMethod } from './types/HttpMethod.js';
3
+ export interface FetchRequest extends RequestInit {
4
+ url: string;
5
+ query?: QueryObject;
6
+ method?: HttpMethod;
7
+ headers?: Record<string, string>;
8
+ }
9
+ export declare function fetchRequest(request: FetchRequest): Promise<import("undici-types").Response>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchRequest.js","sourceRoot":"","sources":["../../src/fetchRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqB;IACpD,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,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,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC/B,wDAAwD;IACxD,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { OmitProps } from '@nzyme/types';
2
+ import type { FetchRequest } from './fetchRequest.js';
3
+ export interface EndpointFormUrlEncodedRequest<T = unknown> extends OmitProps<FetchRequest, 'body'> {
4
+ body?: T;
5
+ }
6
+ export declare function formUrlEncodedRequest<T>(request: EndpointFormUrlEncodedRequest<T>): FetchRequest;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formUrlEncodedRequest.js","sourceRoot":"","sources":["../../src/formUrlEncodedRequest.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,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"}
@@ -0,0 +1,15 @@
1
+ export * from './assertResponse.js';
2
+ export * from './defineEndpoint.js';
3
+ export * from './defineFetchClient.js';
4
+ export * from './fetchEndpoint.js';
5
+ export * from './fetchJson.js';
6
+ export * from './fetchRequest.js';
7
+ export * from './FetchError.js';
8
+ export * from './formUrlEncodedRequest.js';
9
+ export * from './jsonRequest.js';
10
+ export * from './jsonResponse.js';
11
+ export * from './xmlRequest.js';
12
+ export * from './xmlResponse.js';
13
+ export * from './types/HttpHeaders.js';
14
+ export * from './types/HttpMethod.js';
15
+ export * from './types/HttpResponse.js';
@@ -0,0 +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,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { OmitProps } from '@nzyme/types';
2
+ import type { FetchRequest } from './fetchRequest.js';
3
+ export interface EndpointJsonRequest<T = unknown> extends OmitProps<FetchRequest, 'body'> {
4
+ body?: T;
5
+ }
6
+ export declare function jsonRequest<T>(request: EndpointJsonRequest<T>): FetchRequest;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonRequest.js","sourceRoot":"","sources":["../../src/jsonRequest.ts"],"names":[],"mappings":"AAQA,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"}
@@ -0,0 +1 @@
1
+ export declare function jsonResponse<T>(response: Response): Promise<T>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonResponse.js","sourceRoot":"","sources":["../../src/jsonResponse.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAI,QAAkB;IAC9C,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;AACzC,CAAC"}
@@ -0,0 +1 @@
1
+ export type { IncomingHttpHeaders as HttpRequestHeaders, OutgoingHttpHeaders as HttpResponseHeaders, } from 'http';
@@ -1 +1 @@
1
- {"version":3,"file":"HttpHeaders.js","sourceRoot":"","sources":["../../src/types/HttpHeaders.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"HttpHeaders.js","sourceRoot":"","sources":["../../../src/types/HttpHeaders.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD' | 'CONNECT' | 'TRACE';
@@ -1 +1 @@
1
- {"version":3,"file":"HttpMethod.js","sourceRoot":"","sources":["../../src/types/HttpMethod.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"HttpMethod.js","sourceRoot":"","sources":["../../../src/types/HttpMethod.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import type { HttpResponseHeaders } from './HttpHeaders.js';
2
+ export interface HttpResponse {
3
+ status: number;
4
+ statusText?: string;
5
+ body?: string | Blob;
6
+ headers: HttpResponseHeaders;
7
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../src/types/HttpResponse.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"HttpResponse.js","sourceRoot":"","sources":["../../../src/types/HttpResponse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { XmlElement } from '@nzyme/xml-utils';
2
+ import type { FetchRequest } from './fetchRequest.js';
3
+ export interface EndpointXmlRequest extends Omit<FetchRequest, 'body'> {
4
+ body?: XmlElement;
5
+ }
6
+ export declare function xmlRequest(request: EndpointXmlRequest): FetchRequest;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmlRequest.js","sourceRoot":"","sources":["../../src/xmlRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQhD,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"}
@@ -0,0 +1 @@
1
+ export declare function xmlResponse(response: Response): Promise<import("@nzyme/xml-utils").XmlElement>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xmlResponse.js","sourceRoot":"","sources":["../../src/xmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAkB;IAChD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,6 @@
1
1
  {
2
2
  "name": "@nzyme/fetch-utils",
3
- "version": "0.4.1",
4
- "type": "module",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
3
+ "version": "0.6.0",
8
4
  "sideEffects": false,
9
5
  "license": "MIT",
10
6
  "repository": {
@@ -12,25 +8,45 @@
12
8
  "url": "https://github.com/kedrzu/nzyme.git"
13
9
  },
14
10
  "author": "Michał Kędrzyński <m.kedrzynski@gmail.com>",
11
+ "type": "module",
15
12
  "publishConfig": {
16
13
  "access": "public"
17
14
  },
18
15
  "files": [
19
16
  "dist"
20
17
  ],
18
+ "main": "./dist/cjs/index.cjs",
19
+ "types": "./dist/cjs/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": {
23
+ "types": "./dist/esm/index.d.ts",
24
+ "default": "./dist/esm/index.js"
25
+ },
26
+ "require": {
27
+ "types": "./dist/cjs/index.d.ts",
28
+ "default": "./dist/cjs/index.cjs"
29
+ }
30
+ }
31
+ },
21
32
  "scripts": {
22
33
  "eslint": "eslint . --fix --cache",
23
- "build": "tsc --build"
34
+ "build:esm": "tsc --build ./tsconfig.esm.json",
35
+ "build:cjs": "tsc --build ./tsconfig.cjs.json",
36
+ "smoke:mjs": "node tests/smoke.test.mjs",
37
+ "smoke:cjs": "node tests/smoke.test.cjs"
24
38
  },
25
39
  "dependencies": {
26
- "@nzyme/ioc": "^0.4.1",
27
- "@nzyme/types": "^0.4.1",
28
- "@nzyme/xml-utils": "^0.4.1",
40
+ "@nzyme/ioc": "^0.6.0",
41
+ "@nzyme/types": "^0.6.0",
42
+ "@nzyme/xml-utils": "^0.6.0",
43
+ "tslib": "^2.8.1",
29
44
  "ufo": "^1.5.4"
30
45
  },
31
46
  "devDependencies": {
32
- "@nzyme/eslint": "^0.4.1",
33
- "@nzyme/tsconfig": "^0.4.1",
34
- "@types/node": "^22.10.6"
47
+ "@nzyme/eslint": "^0.6.0",
48
+ "@nzyme/tsconfig": "^0.6.0",
49
+ "@types/node": "^22.13.4",
50
+ "typescript": "^5.7.3"
35
51
  }
36
52
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"FetchError.js","sourceRoot":"","sources":["../src/FetchError.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertResponse.js","sourceRoot":"","sources":["../src/assertResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,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,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineEndpoint.js","sourceRoot":"","sources":["../src/defineEndpoint.ts"],"names":[],"mappings":"AAWA,wBAAwB;AACxB,MAAM,UAAU,cAAc,CAC1B,QAAoC;IAEpC,OAAO,QAAQ,CAAC;AACpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defineFetchClient.js","sourceRoot":"","sources":["../src/defineFetchClient.ts"],"names":[],"mappings":"AAWA,wBAAwB;AACxB,MAAM,UAAU,iBAAiB,CAAC,MAAwB;IACtD,OAAO,MAAqB,CAAC;AACjC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchEndpoint.js","sourceRoot":"","sources":["../src/fetchEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAI9B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AASjD,MAAM,CAAC,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,OAAO,CAAC,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,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC;IAC5B,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;IAE7C,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,MAAM,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC;IAED,OAAO,SAA+B,CAAC;AAC3C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchJson.js","sourceRoot":"","sources":["../src/fetchJson.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkB7C,MAAM,CAAC,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,SAAS,CAAC,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,UAAU,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetchRequest.js","sourceRoot":"","sources":["../src/fetchRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAUrD,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAAqB;IACpD,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,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,cAAc,CAAC,QAAQ,CAAC,CAAC;IAC/B,wDAAwD;IACxD,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC5B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"formUrlEncodedRequest.js","sourceRoot":"","sources":["../src/formUrlEncodedRequest.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,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.js.map DELETED
@@ -1 +0,0 @@
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,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonRequest.js","sourceRoot":"","sources":["../src/jsonRequest.ts"],"names":[],"mappings":"AAQA,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"jsonResponse.js","sourceRoot":"","sources":["../src/jsonResponse.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,YAAY,CAAI,QAAkB;IAC9C,OAAO,QAAQ,CAAC,IAAI,EAAgB,CAAC;AACzC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"xmlRequest.js","sourceRoot":"","sources":["../src/xmlRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQhD,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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"xmlResponse.js","sourceRoot":"","sources":["../src/xmlResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAkB;IAChD,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAClC,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes