@empathyco/x-adapter 8.0.0-alpha.6 → 8.0.0-alpha.7
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.
|
@@ -15,7 +15,6 @@ const request_error_1 = require("./errors/request-error");
|
|
|
15
15
|
*/
|
|
16
16
|
function toJson(response) {
|
|
17
17
|
if (response.ok) {
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
|
19
18
|
return response.text().then(text => (text ? JSON.parse(text) : {}));
|
|
20
19
|
}
|
|
21
20
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/http-clients/utils.ts"],"names":[],"mappings":";;;AAAA,gDAAyD;AACzD,0DAAsD;AAEtD;;;;;;;;;GASG;AACH,SAAgB,MAAM,CAAC,QAAkB;IACvC,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/http-clients/utils.ts"],"names":[],"mappings":";;;AAAA,gDAAyD;AACzD,0DAAsD;AAEtD;;;;;;;;;GASG;AACH,SAAgB,MAAM,CAAC,QAAkB;IACvC,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACrE;SAAM;QACL,MAAM,IAAI,4BAAY,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;KACpD;AACH,CAAC;AAND,wBAMC;AAED;;;;;;;;;GASG;AACH,SAAgB,QAAQ,CAAC,QAAgB,EAAE,SAA8B,EAAE;IACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,IAAA,iBAAO,EAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAC7B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAChE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CACrD,CACF,CAAC;IACF,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC;AARD,4BAQC","sourcesContent":["import { Dictionary, forEach } from '@empathyco/x-utils';\nimport { RequestError } from './errors/request-error';\n\n/**\n * Formats a response object to JSON.\n *\n * @remarks If the `response.ok` is falsy, a `RequestError` object is thrown.\n *\n * @param response - The response to convert to JSON format.\n * @returns - The resultant promise of formatting the response to JSON.\n *\n * @public\n */\nexport function toJson(response: Response): Promise<any> {\n if (response.ok) {\n return response.text().then(text => (text ? JSON.parse(text) : {}));\n } else {\n throw new RequestError('Request failed', response);\n }\n}\n\n/**\n * Builds a URL object based on the passed endpoint and the request parameters.\n *\n * @param endpoint - The endpoint.\n * @param params - The request parameters.\n *\n * @returns The `href` property of the newly built `URL` object.\n *\n * @public\n */\nexport function buildUrl(endpoint: string, params: Dictionary<unknown> = {}): URL['href'] {\n const url = new URL(endpoint);\n forEach(params, (key, value) =>\n (Array.isArray(value) ? value : [value]).forEach(arrayItemValue =>\n url.searchParams.append(key, String(arrayItemValue))\n )\n );\n return url.href;\n}\n"]}
|
|
@@ -12,7 +12,6 @@ import { RequestError } from './errors/request-error';
|
|
|
12
12
|
*/
|
|
13
13
|
export function toJson(response) {
|
|
14
14
|
if (response.ok) {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-extra-parens
|
|
16
15
|
return response.text().then(text => (text ? JSON.parse(text) : {}));
|
|
17
16
|
}
|
|
18
17
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/http-clients/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,UAAU,MAAM,CAAC,QAAkB;IACvC,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/http-clients/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD;;;;;;;;;GASG;AACH,MAAM,UAAU,MAAM,CAAC,QAAkB;IACvC,IAAI,QAAQ,CAAC,EAAE,EAAE;QACf,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACrE;SAAM;QACL,MAAM,IAAI,YAAY,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;KACpD;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAgB,EAAE,SAA8B,EAAE;IACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAC7B,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAChE,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CACrD,CACF,CAAC;IACF,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC","sourcesContent":["import { Dictionary, forEach } from '@empathyco/x-utils';\nimport { RequestError } from './errors/request-error';\n\n/**\n * Formats a response object to JSON.\n *\n * @remarks If the `response.ok` is falsy, a `RequestError` object is thrown.\n *\n * @param response - The response to convert to JSON format.\n * @returns - The resultant promise of formatting the response to JSON.\n *\n * @public\n */\nexport function toJson(response: Response): Promise<any> {\n if (response.ok) {\n return response.text().then(text => (text ? JSON.parse(text) : {}));\n } else {\n throw new RequestError('Request failed', response);\n }\n}\n\n/**\n * Builds a URL object based on the passed endpoint and the request parameters.\n *\n * @param endpoint - The endpoint.\n * @param params - The request parameters.\n *\n * @returns The `href` property of the newly built `URL` object.\n *\n * @public\n */\nexport function buildUrl(endpoint: string, params: Dictionary<unknown> = {}): URL['href'] {\n const url = new URL(endpoint);\n forEach(params, (key, value) =>\n (Array.isArray(value) ? value : [value]).forEach(arrayItemValue =>\n url.searchParams.append(key, String(arrayItemValue))\n )\n );\n return url.href;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-adapter",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.7",
|
|
4
4
|
"description": "A utils library to create a client for any API",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"prepublishOnly": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@empathyco/x-deep-merge": "^1.3.0-alpha.
|
|
35
|
+
"@empathyco/x-deep-merge": "^1.3.0-alpha.20",
|
|
36
36
|
"@empathyco/x-get-safe-property-chain": "^1.3.0-alpha.3",
|
|
37
37
|
"tslib": "~2.3.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@empathyco/x-utils": "^1.0.0-alpha.
|
|
40
|
+
"@empathyco/x-utils": "^1.0.0-alpha.6",
|
|
41
41
|
"@types/jest": "~27.0.3",
|
|
42
42
|
"concurrently": "~7.0.0",
|
|
43
43
|
"jest": "~27.3.1",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "5dac07f17af4bd325f1feddc9d26a7c48e0cc73a"
|
|
52
52
|
}
|