@fabriktor/client 0.0.50 → 0.0.52

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.
@@ -26,25 +26,27 @@ export class HTTPClient {
26
26
  }
27
27
  async do(opts) {
28
28
  const h = headers(opts);
29
+ const requestBody = body(opts.body);
30
+ const idempotencyPath = idempotencyRequestPath(opts.path, requestBody);
29
31
  const idempotencyToken = applyIdempotencyHeader({
30
32
  headers: h,
31
33
  store: this.idempotency,
32
34
  method: opts.method,
33
- path: opts.path,
35
+ path: idempotencyPath,
34
36
  });
35
37
  let res;
36
38
  try {
37
39
  res = await this.fetcher.fetch(url(opts.base_url, opts.path), {
38
40
  method: opts.method,
39
41
  headers: h,
40
- body: body(opts.body),
42
+ body: requestBody,
41
43
  });
42
44
  }
43
45
  catch (err) {
44
46
  throw errHTTPRequestFailed(err);
45
47
  }
46
48
  if (idempotencyToken !== undefined) {
47
- this.idempotency.reset(opts.method, opts.path);
49
+ this.idempotency.reset(opts.method, idempotencyPath);
48
50
  }
49
51
  if (!res.ok) {
50
52
  return await fail(res);
@@ -82,6 +84,9 @@ function headers(opts) {
82
84
  function body(v) {
83
85
  return v === undefined ? undefined : JSON.stringify(v);
84
86
  }
87
+ function idempotencyRequestPath(path, body) {
88
+ return typeof body === "string" ? `${path}\n${body}` : path;
89
+ }
85
90
  async function fail(res) {
86
91
  const txt = await text(res);
87
92
  throw errFromHTTP(httpErr(res, txt));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fabriktor/client",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "description": "![Fabriktor Logo](./img/fabriktor-character.gif)",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,6 +17,6 @@
17
17
  "typescript": "^6.0.3"
18
18
  },
19
19
  "dependencies": {
20
- "@fabriktor/schema": "0.0.32"
20
+ "@fabriktor/schema": "0.0.34"
21
21
  }
22
22
  }