@solutiondesk/legal 1.0.0 → 1.1.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/README.md CHANGED
@@ -10,6 +10,8 @@ Typed client for the [SolutionDesk](https://solutiondesk.io) Legal Hub. Your tea
10
10
  npm install @solutiondesk/legal
11
11
  ```
12
12
 
13
+ The guide [Legal texts on your website](https://help.solutiondesk.io/docs/team/legal-website) explains the API behind this package and where to set it up in SolutionDesk; the [Host API](https://help.solutiondesk.io/docs/team/host-api) covers the calls that need an API key.
14
+
13
15
  ## Quick start
14
16
 
15
17
  ```ts
package/dist/index.cjs CHANGED
@@ -99,7 +99,7 @@ function createHttp(options = {}) {
99
99
  }
100
100
  const target = url(req.path, req.query);
101
101
  const headers = {
102
- accept: "application/json",
102
+ accept: req.accept ?? "application/json",
103
103
  ...options.headers,
104
104
  ...req.options?.headers
105
105
  };
@@ -136,7 +136,8 @@ function createHttp(options = {}) {
136
136
  if (response.status === 304 && cached) {
137
137
  return { data: cached.body, ...meta };
138
138
  }
139
- const body = parseBody(await response.text());
139
+ const text = await response.text();
140
+ const body = response.ok && req.responseType === "text" ? text : parseBody(text);
140
141
  if (!response.ok) {
141
142
  throw new SolutionDeskError(messageOf(body, response.status), {
142
143
  status: response.status,
package/dist/index.js CHANGED
@@ -97,7 +97,7 @@ function createHttp(options = {}) {
97
97
  }
98
98
  const target = url(req.path, req.query);
99
99
  const headers = {
100
- accept: "application/json",
100
+ accept: req.accept ?? "application/json",
101
101
  ...options.headers,
102
102
  ...req.options?.headers
103
103
  };
@@ -134,7 +134,8 @@ function createHttp(options = {}) {
134
134
  if (response.status === 304 && cached) {
135
135
  return { data: cached.body, ...meta };
136
136
  }
137
- const body = parseBody(await response.text());
137
+ const text = await response.text();
138
+ const body = response.ok && req.responseType === "text" ? text : parseBody(text);
138
139
  if (!response.ok) {
139
140
  throw new SolutionDeskError(messageOf(body, response.status), {
140
141
  status: response.status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solutiondesk/legal",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Typed, zero-dependency client for the SolutionDesk Legal Hub: imprint, privacy policy, terms, sub-processors, acceptances and webhook verification.",
5
5
  "keywords": [
6
6
  "solutiondesk",
@@ -13,7 +13,7 @@
13
13
  "sdk",
14
14
  "typescript"
15
15
  ],
16
- "homepage": "https://help.solutiondesk.io",
16
+ "homepage": "https://help.solutiondesk.io/docs/team/legal-website",
17
17
  "bugs": {
18
18
  "url": "https://github.com/wemogy/solutiondesk/issues"
19
19
  },