@tcds-io/http-client 0.1.0 → 0.1.1
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 +2 -2
- package/dist/json-http-client.d.ts +1 -1
- package/dist/json-http-client.js +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @tcds-io/http-client
|
|
2
2
|
|
|
3
|
-
A JSON `fetch` client for partner APIs, with a test double. It throws [`@tcds-io/
|
|
3
|
+
A JSON `fetch` client for partner APIs, with a test double. It throws [`@tcds-io/domain`](../domain) errors that carry the partner, the status and a redacted excerpt, and tells a request that will never pass (4xx) from one worth retrying (5xx, 429, timeout).
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import { JsonHttpClient, multipart } from '@tcds-io/http-client';
|
|
@@ -39,4 +39,4 @@ It runs the real client over a fake `fetch`, so a stubbed `429` or `400` becomes
|
|
|
39
39
|
|
|
40
40
|
## Peers
|
|
41
41
|
|
|
42
|
-
`@tcds-io/
|
|
42
|
+
`@tcds-io/domain` and `@tcds-io/redact` are peer dependencies: install them yourself so `instanceof` and `Secret` work across the app (ADR-0070).
|
package/dist/json-http-client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppError, ExternalPartyError, RateLimitedError, RefusedByExternalPartyError } from '@tcds-io/
|
|
1
|
+
import { AppError, ExternalPartyError, RateLimitedError, RefusedByExternalPartyError } from '@tcds-io/domain';
|
|
2
2
|
import { createRedactor, redactHeaders, Secret } from '@tcds-io/redact';
|
|
3
3
|
import { MultipartBody } from './multipart.js';
|
|
4
4
|
import { revealDeep } from './reveal.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type HttpResponse<T = unknown> = {
|
|
|
19
19
|
readonly body: T;
|
|
20
20
|
};
|
|
21
21
|
export interface HttpClient {
|
|
22
|
-
/** Resolves on a 2xx. Anything else throws an `@tcds-io/
|
|
22
|
+
/** Resolves on a 2xx. Anything else throws an `@tcds-io/domain` error carrying the status and a redacted excerpt. */
|
|
23
23
|
request<T = unknown>(request: HttpRequest): Promise<HttpResponse<T>>;
|
|
24
24
|
}
|
|
25
25
|
export type { MultipartBody };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tcds-io/http-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "JSON fetch client that throws external-party errors, with a recording test double that redacts secrets.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
"@types/node": "^22.10.2",
|
|
32
32
|
"typescript": "^5.7.2",
|
|
33
33
|
"vitest": "^2.1.8",
|
|
34
|
-
"@tcds-io/
|
|
34
|
+
"@tcds-io/domain": "^0.1.0",
|
|
35
35
|
"@tcds-io/redact": "^0.1.0"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@tcds-io/
|
|
41
|
+
"@tcds-io/domain": "~0.1.0",
|
|
42
42
|
"@tcds-io/redact": "~0.1.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"build": "tsc -p tsconfig.build.json",
|
|
45
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
|
|
46
46
|
"check:types": "tsc --noEmit -p .",
|
|
47
47
|
"test": "vitest run"
|
|
48
48
|
}
|