From b8387aaa5ac4870c0a3e54caa37bb0d4011ebc41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Augustin=20=C5=A0ulc?= Date: Thu, 19 Dec 2019 11:33:23 +0100 Subject: [PATCH] Added deleteJson and deleteString functions to apiConnector --- demo/package.json | 16 ++++++++-------- lerna.json | 2 +- packages/apiclient/package.json | 4 ++-- packages/apiclient/src/fetchApiConnector.ts | 7 +++++++ packages/apiclient/src/restRequestBuilder.ts | 6 ++++-- packages/apiclient/src/types.ts | 2 ++ packages/bootstrap/package.json | 8 ++++---- packages/data/package.json | 2 +- packages/datascreens/package.json | 12 ++++++------ packages/dirtycheck/package.json | 4 ++-- packages/helpers/package.json | 2 +- packages/screens/package.json | 4 ++-- packages/validation/package.json | 4 ++-- packages/views/package.json | 6 +++--- stories/package.json | 12 ++++++------ 15 files changed, 51 insertions(+), 40 deletions(-) diff --git a/demo/package.json b/demo/package.json index d9f6818d..0efee28b 100644 --- a/demo/package.json +++ b/demo/package.json @@ -1,7 +1,7 @@ { "name": "@frui.ts/demo", "private": true, - "version": "0.7.0", + "version": "0.7.1", "description": "> TODO: description", "author": "Augustin Šulc ", "license": "ISC", @@ -24,12 +24,12 @@ "proxy": "lcp --proxyUrl https://redmine.dev.eman.cz" }, "dependencies": { - "@frui.ts/apiclient": "^0.7.0", - "@frui.ts/data": "^0.7.0", - "@frui.ts/datascreens": "^0.7.0", - "@frui.ts/dirtycheck": "^0.7.0", - "@frui.ts/screens": "^0.7.0", - "@frui.ts/validation": "^0.7.0", - "@frui.ts/views": "^0.7.0" + "@frui.ts/apiclient": "^0.7.1", + "@frui.ts/data": "^0.7.1", + "@frui.ts/datascreens": "^0.7.1", + "@frui.ts/dirtycheck": "^0.7.1", + "@frui.ts/screens": "^0.7.1", + "@frui.ts/validation": "^0.7.1", + "@frui.ts/views": "^0.7.1" } } diff --git a/lerna.json b/lerna.json index e9155223..c3dd909b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.7.0", + "version": "0.7.1", "packages": [ "demo", "packages/*", diff --git a/packages/apiclient/package.json b/packages/apiclient/package.json index 52375d6d..a8f5cdf2 100644 --- a/packages/apiclient/package.json +++ b/packages/apiclient/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Frui.ts helpers for http communication", "author": "Augustin Šulc ", "license": "ISC", @@ -24,6 +24,6 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/helpers": "^0.7.0" + "@frui.ts/helpers": "^0.7.1" } } diff --git a/packages/apiclient/src/fetchApiConnector.ts b/packages/apiclient/src/fetchApiConnector.ts index 39f2d741..5c5271ed 100644 --- a/packages/apiclient/src/fetchApiConnector.ts +++ b/packages/apiclient/src/fetchApiConnector.ts @@ -48,9 +48,16 @@ export class FetchApiConnector implements IApiConnector { patchFormData(url: string, data: FormData, params?: RequestInit): Promise { return this.fetchFunction(url, { ...params, method: "patch", body: data }).then(this.middleware); } + delete(url: string, params?: RequestInit): Promise { return this.fetchFunction(url, { ...params, method: "delete" }).then(this.middleware); } + deleteJson(url: string, content: any, params?: RequestInit): Promise { + return this.deleteText(url, JSON.stringify(content), appendJsonHeader(params)); + } + deleteText(url: string, text: string, params?: RequestInit): Promise { + return this.fetchFunction(url, { ...params, method: "delete", body: text }).then(this.middleware); + } } /** Middleware used by FetchApiConnector to handle response status codes other than 2xx as errors */ diff --git a/packages/apiclient/src/restRequestBuilder.ts b/packages/apiclient/src/restRequestBuilder.ts index 7fd9e2d5..1fc16430 100644 --- a/packages/apiclient/src/restRequestBuilder.ts +++ b/packages/apiclient/src/restRequestBuilder.ts @@ -73,8 +73,10 @@ export class RestRequestBuilder { return this.apiConnector.patchJson(this.url, content, this.params); } - delete() { - return this.apiConnector.delete(this.url, this.params); + delete(content: any) { + return content + ? this.apiConnector.deleteJson(this.url, content, this.params) + : this.apiConnector.delete(this.url, this.params); } withBaseUrl(url: string) { diff --git a/packages/apiclient/src/types.ts b/packages/apiclient/src/types.ts index fa232704..7ffc8c9c 100644 --- a/packages/apiclient/src/types.ts +++ b/packages/apiclient/src/types.ts @@ -14,4 +14,6 @@ export interface IApiConnector { patchFormData(url: string, data: FormData, params?: RequestInit): Promise; delete(url: string, params?: RequestInit): Promise; + deleteText(url: string, text: string, params?: RequestInit): Promise; + deleteJson(url: string, content: any, params?: RequestInit): Promise; } diff --git a/packages/bootstrap/package.json b/packages/bootstrap/package.json index da72e0cb..f75129c5 100644 --- a/packages/bootstrap/package.json +++ b/packages/bootstrap/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Bootstrap controls ready for Frui.ts integration", "author": "Augustin Šulc ", "license": "ISC", @@ -24,9 +24,9 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/dirtycheck": "^0.7.0", - "@frui.ts/validation": "^0.7.0", - "@frui.ts/views": "^0.7.0", + "@frui.ts/dirtycheck": "^0.7.1", + "@frui.ts/validation": "^0.7.1", + "@frui.ts/views": "^0.7.1", "bind-decorator": "^1.0.11", "bootstrap": "^4.3.1", "react-bootstrap": "^1.0.0-beta.12" diff --git a/packages/data/package.json b/packages/data/package.json index e66709a8..b6f449f7 100644 --- a/packages/data/package.json +++ b/packages/data/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Helpers and interfaces for handling paged and sorted data sets", "author": "Augustin Šulc ", "license": "ISC", diff --git a/packages/datascreens/package.json b/packages/datascreens/package.json index 90b1a946..54f057a4 100644 --- a/packages/datascreens/package.json +++ b/packages/datascreens/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "> TODO: description", "author": "Augustin Šulc ", "homepage": "", @@ -25,10 +25,10 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/data": "^0.7.0", - "@frui.ts/dirtycheck": "^0.7.0", - "@frui.ts/helpers": "^0.7.0", - "@frui.ts/screens": "^0.7.0", - "@frui.ts/validation": "^0.7.0" + "@frui.ts/data": "^0.7.1", + "@frui.ts/dirtycheck": "^0.7.1", + "@frui.ts/helpers": "^0.7.1", + "@frui.ts/screens": "^0.7.1", + "@frui.ts/validation": "^0.7.1" } } diff --git a/packages/dirtycheck/package.json b/packages/dirtycheck/package.json index afa626dd..8a1909b6 100644 --- a/packages/dirtycheck/package.json +++ b/packages/dirtycheck/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Observable dirty checking", "author": "Augustin Šulc ", "license": "ISC", @@ -24,6 +24,6 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/helpers": "^0.7.0" + "@frui.ts/helpers": "^0.7.1" } } diff --git a/packages/helpers/package.json b/packages/helpers/package.json index 6c053831..39367f44 100644 --- a/packages/helpers/package.json +++ b/packages/helpers/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Frui.ts helper functions", "keywords": [ "frui.ts" diff --git a/packages/screens/package.json b/packages/screens/package.json index a65bd798..201d1423 100644 --- a/packages/screens/package.json +++ b/packages/screens/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Frui.ts screens", "author": "Augustin Šulc ", "license": "ISC", @@ -24,7 +24,7 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/helpers": "^0.7.0", + "@frui.ts/helpers": "^0.7.1", "query-string": "^6.9.0" } } diff --git a/packages/validation/package.json b/packages/validation/package.json index 754efc63..8cc5fa73 100644 --- a/packages/validation/package.json +++ b/packages/validation/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "Observable validation", "keywords": [ "mobx", @@ -28,6 +28,6 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/helpers": "^0.7.0" + "@frui.ts/helpers": "^0.7.1" } } diff --git a/packages/views/package.json b/packages/views/package.json index 612627bc..b5bf9eaa 100644 --- a/packages/views/package.json +++ b/packages/views/package.json @@ -3,7 +3,7 @@ "publishConfig": { "registry": "https://nexus.eman.cz/repository/eman-npm/" }, - "version": "0.7.0", + "version": "0.7.1", "description": "> TODO: description", "author": "Augustin Šulc ", "homepage": "", @@ -25,7 +25,7 @@ "build": "tsc" }, "dependencies": { - "@frui.ts/helpers": "^0.7.0", - "@frui.ts/screens": "^0.7.0" + "@frui.ts/helpers": "^0.7.1", + "@frui.ts/screens": "^0.7.1" } } diff --git a/stories/package.json b/stories/package.json index 0e69ff34..4e10b09f 100644 --- a/stories/package.json +++ b/stories/package.json @@ -1,7 +1,7 @@ { "name": "@frui.ts/stories", "private": true, - "version": "0.7.0", + "version": "0.7.1", "description": "> TODO: description", "author": "Augustin Šulc ", "license": "ISC", @@ -20,11 +20,11 @@ "prebuild": "rimraf dist" }, "dependencies": { - "@frui.ts/bootstrap": "^0.7.0", - "@frui.ts/dirtycheck": "^0.7.0", - "@frui.ts/screens": "^0.7.0", - "@frui.ts/validation": "^0.7.0", - "@frui.ts/views": "^0.7.0", + "@frui.ts/bootstrap": "^0.7.1", + "@frui.ts/dirtycheck": "^0.7.1", + "@frui.ts/screens": "^0.7.1", + "@frui.ts/validation": "^0.7.1", + "@frui.ts/views": "^0.7.1", "bootstrap": "^4.3.1", "react-bootstrap": "^1.0.0-beta.12" }