From 98553117392ccccd7683ecff2b7268969ddc2e5c Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Fri, 9 Oct 2020 10:05:26 +0000 Subject: [PATCH] fix(core): update --- package-lock.json | 41 ++++++++++++++++++++++++++++++---------- package.json | 1 + ts/index.ts | 20 ++++++++++++++------ ts/webrequest.plugins.ts | 3 ++- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3395ac4..e0c2a70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1409,15 +1409,29 @@ "@pushrocks/smartpromise": "^3.0.6", "@types/through2": "^2.0.34", "through2": "^3.0.1" + }, + "dependencies": { + "@pushrocks/smartjson": { + "version": "3.0.10", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.10.tgz", + "integrity": "sha512-0tBkET2yjmSSIf4DlgeyU8U/J2EshTmQGuMY28EjPq9VvuCFXLh72WmETpA4QqKRMqhWp1+P+RZgnQupW3GQxQ==", + "dev": true, + "requires": { + "@types/fast-json-stable-stringify": "^2.0.0", + "fast-json-stable-stringify": "^2.1.0", + "lodash.clonedeep": "^4.5.0" + } + } } }, "@pushrocks/smartjson": { - "version": "3.0.10", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-3.0.10.tgz", - "integrity": "sha512-0tBkET2yjmSSIf4DlgeyU8U/J2EshTmQGuMY28EjPq9VvuCFXLh72WmETpA4QqKRMqhWp1+P+RZgnQupW3GQxQ==", - "dev": true, + "version": "4.0.5", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartjson/-/smartjson-4.0.5.tgz", + "integrity": "sha512-i4kBjZSbs1t8swcAPEdPkDJHci2higzvMIkNUKTgXWrcxUFMuOis/B5huUnnIqg/Td8R+mAdf/B/CMfgjABTlg==", "requires": { + "@types/buffer-json": "^2.0.0", "@types/fast-json-stable-stringify": "^2.0.0", + "buffer-json": "^2.0.0", "fast-json-stable-stringify": "^2.1.0", "lodash.clonedeep": "^4.5.0" } @@ -1957,6 +1971,11 @@ "@types/node": "*" } }, + "@types/buffer-json": { + "version": "2.0.0", + "resolved": "https://verdaccio.lossless.one/@types%2fbuffer-json/-/buffer-json-2.0.0.tgz", + "integrity": "sha512-nFKOrY93Tvv5Tobws+YbkGlPOJsn1nVpZah3BlSyQ4EniFm97KLvSr54tZ5xQp8mlf/XxbYwskNCYQB9EdrPlQ==" + }, "@types/chai": { "version": "4.2.11", "resolved": "https://verdaccio.lossless.one/@types%2fchai/-/chai-4.2.11.tgz", @@ -2043,8 +2062,7 @@ "@types/fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://verdaccio.lossless.one/@types%2ffast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha512-mky/O83TXmGY39P1H9YbUpjV6l6voRYlufqfFCvel8l1phuy8HRjdWc1rrPuN53ITBJlbyMSV6z3niOySO5pgQ==", - "dev": true + "integrity": "sha512-mky/O83TXmGY39P1H9YbUpjV6l6voRYlufqfFCvel8l1phuy8HRjdWc1rrPuN53ITBJlbyMSV6z3niOySO5pgQ==" }, "@types/figures": { "version": "3.0.1", @@ -3026,6 +3044,11 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, + "buffer-json": { + "version": "2.0.0", + "resolved": "https://verdaccio.lossless.one/buffer-json/-/buffer-json-2.0.0.tgz", + "integrity": "sha512-+jjPFVqyfF1esi9fvfUs3NqM0pH1ziZ36VP4hmA/y/Ssfo/5w5xHKfTw9BwQjoJ1w/oVtpLomqwUHKdefGyuHw==" + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://verdaccio.lossless.one/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -4974,8 +4997,7 @@ "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://verdaccio.lossless.one/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", - "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", - "dev": true + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, "fast-levenshtein": { "version": "2.0.6", @@ -6979,8 +7001,7 @@ "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://verdaccio.lossless.one/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", - "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", - "dev": true + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" }, "lodash.isarguments": { "version": "3.1.0", diff --git a/package.json b/package.json index 279de8f..75fd043 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "dependencies": { "@pushrocks/smartdelay": "^2.0.9", "@pushrocks/smartenv": "^4.0.10", + "@pushrocks/smartjson": "^4.0.5", "node-fetch": "^2.6.0" }, "files": [ diff --git a/ts/index.ts b/ts/index.ts index 7fe71c0..f6fe43f 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -21,7 +21,9 @@ export class WebRequest { const response: Response = await this.request(urlArg, { method: 'GET' }); - return response.json(); + const responseText = await response.text(); + const responseResult = plugins.smartjson.parse(responseText); + return responseResult; } /** @@ -29,10 +31,12 @@ export class WebRequest { */ public async postJson(urlArg: string, requestBody?: any) { const response: Response = await this.request(urlArg, { - body: JSON.stringify(requestBody), + body: plugins.smartjson.stringify(requestBody), method: 'POST' }); - return response.json(); + const responseText = await response.text(); + const responseResult = plugins.smartjson.parse(responseText); + return responseResult; } /** @@ -40,10 +44,12 @@ export class WebRequest { */ public async putJson(urlArg: string, requestBody?: any) { const response: Response = await this.request(urlArg, { - body: JSON.stringify(requestBody), + body: plugins.smartjson.stringify(requestBody), method: 'PUT' }); - return response.json(); + const responseText = await response.text(); + const responseResult = plugins.smartjson.parse(responseText); + return responseResult; } /** @@ -53,7 +59,9 @@ export class WebRequest { const response: Response = await this.request(urlArg, { method: 'GET' }); - return response.json(); + const responseText = await response.text(); + const responseResult = plugins.smartjson.parse(responseText); + return responseResult; } /** diff --git a/ts/webrequest.plugins.ts b/ts/webrequest.plugins.ts index 6df2124..760b717 100644 --- a/ts/webrequest.plugins.ts +++ b/ts/webrequest.plugins.ts @@ -1,4 +1,5 @@ import * as smartdelay from '@pushrocks/smartdelay'; import * as smartenv from '@pushrocks/smartenv'; +import * as smartjson from '@pushrocks/smartjson'; -export { smartdelay, smartenv }; +export { smartdelay, smartenv, smartjson };