@t4h.framework/http 0.8.0 → 0.8.3
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/.ai/skills/framework-http/SKILL.md +83 -311
- package/CHANGELOG.md +18 -0
- package/README.md +16 -148
- package/dist/models/HttpBodyUpload.d.ts.map +1 -1
- package/dist/models/HttpBodyUpload.js +6 -4
- package/dist/models/HttpBodyUpload.js.map +1 -1
- package/dist/models/OAuth2.d.ts.map +1 -1
- package/dist/models/OAuth2.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,351 +1,123 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: framework-http
|
|
3
3
|
description: >-
|
|
4
|
-
|
|
5
|
-
`http`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
Calls external HTTP APIs from T4H Framework workflows with
|
|
5
|
+
@t4h.framework/http: the `http` client and `HttpClient` (get, post, put,
|
|
6
|
+
patch, delete, extend, baseUrl), request bodies (json, text, form, binary,
|
|
7
|
+
HttpBodyUpload, HttpBodyRef), `Response` and `Body`, and authentication
|
|
8
|
+
(Basic, bearer, header, OAuth2ClientCredentials,
|
|
9
|
+
OAuth2GrantResourceOwnerPassword, custom HttpAuth) with `Secret` credentials.
|
|
10
|
+
Use when a workflow calls a REST API, sends a webhook, uploads or downloads a
|
|
11
|
+
file over HTTP, authenticates a request, or when a test mocks
|
|
12
|
+
HttpClientRequestClaim and FileSystemClaim.
|
|
9
13
|
---
|
|
10
14
|
|
|
11
15
|
# @t4h.framework/http
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Use the `http` client in the workflow. Each call is a durable step: it runs
|
|
18
|
+
once and the workflow reuses the recorded `Response` on replay.
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
## Call an API
|
|
16
21
|
|
|
17
22
|
```typescript
|
|
18
|
-
import {
|
|
19
|
-
http,
|
|
20
|
-
HttpClient,
|
|
21
|
-
HttpClientRequestClaim,
|
|
22
|
-
HttpAuth,
|
|
23
|
-
OAuth2,
|
|
24
|
-
OAuth2ClientCredentials,
|
|
25
|
-
OAuth2GrantResourceOwnerPassword,
|
|
26
|
-
Body,
|
|
27
|
-
Response,
|
|
28
|
-
type HttpClientRequestClaimInput,
|
|
29
|
-
type HttpClientRequestClaimOutput,
|
|
30
|
-
} from '@t4h.framework/http'
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
> Workflows use the **`http` / `HttpClient`** client.
|
|
34
|
-
> `@t4h.framework/core/no-framework-activity-in-app` rejects `new` and `extends`
|
|
35
|
-
> on `HttpRequestActivity` / `AbstractHttpRequestActivity`.
|
|
36
|
-
|
|
37
|
-
## Architecture
|
|
38
|
-
|
|
39
|
-
`Workflow` → `http`/`HttpClient` (`History.bind(HttpRequestActivity)`) → `AbstractHttpRequestActivity.run` → `HttpClientRequestClaim.request` + `FileSystemClaim.write` (response → `Body`/`Response`).
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Claims
|
|
44
|
-
|
|
45
|
-
### HttpClientRequestClaim (required for HTTP)
|
|
46
|
-
|
|
47
|
-
Runtime must register an implementation:
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
{ provide: HttpClientRequestClaim, value: new MyHttpClientRequestClaimImpl() }
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Contract:
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
abstract class HttpClientRequestClaim {
|
|
57
|
-
abstract request(
|
|
58
|
-
input: HttpClientRequestClaimInput,
|
|
59
|
-
): HttpClientRequestClaimOutput | Promise<HttpClientRequestClaimOutput>
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// HttpClientRequestClaimInput
|
|
63
|
-
{
|
|
64
|
-
url: URL
|
|
65
|
-
method: HttpMethod // required on claim input
|
|
66
|
-
body: Buffer | FormData | Readable | URLSearchParams | undefined
|
|
67
|
-
headers: Record<string, string | string[] | undefined>
|
|
68
|
-
redirect: 'follow' | 'manual' | number
|
|
69
|
-
retry: boolean | HttpRequestActivityInputRetryOptions
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// HttpClientRequestClaimOutput
|
|
73
|
-
{
|
|
74
|
-
status: number
|
|
75
|
-
headers: Record<string, string | string[] | undefined>
|
|
76
|
-
body: Readable
|
|
77
|
-
}
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
The runtime provides a concrete implementation; workflow tests mock it (see **Testing** below).
|
|
81
|
-
|
|
82
|
-
### FileSystemClaim (required by the HTTP activity)
|
|
83
|
-
|
|
84
|
-
The HTTP activity persists the response body to `fs` (path `\`${uuid}-http-request-activity-response-body.${ext}\``, extension from `content-type` via `mime`, or `.bin`) and returns it wrapped in a `Body`. So any workflow that makes an HTTP call also needs a `FileSystemClaim` provider; tests mock its `write` to return a `Binary`.
|
|
85
|
-
|
|
86
|
-
### CacheClaim (OAuth only)
|
|
87
|
-
|
|
88
|
-
`HttpAuth` / `OAuth2` use `CacheClaim` for token caching. OAuth2 stores tokens at `oauth2:token:${clientId}` with TTL derived from `expires_in` (90% of lifetime).
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## HttpRequestActivityInput
|
|
93
|
-
|
|
94
|
-
Shared by activities and `HttpClient` config (minus `url` / `baseUrl` on client methods):
|
|
95
|
-
|
|
96
|
-
| Field | Type | Default / notes |
|
|
97
|
-
|-------|------|-----------------|
|
|
98
|
-
| `url` | `string` | Resolved with `new URL(url, baseUrl)` |
|
|
99
|
-
| `baseUrl` | `string?` | Optional base for relative paths |
|
|
100
|
-
| `method` | `HttpMethod?` | `'GET'` |
|
|
101
|
-
| `body` | `{ json }` \| `{ text }` \| `{ form }` \| `{ binary }` | See below |
|
|
102
|
-
| `headers` | `Record<string, string \| string[] \| Secret \| undefined>?` | A `Secret` value is read on the host right before the request. Merged with body-derived headers; `auth` sets `Authorization` and overrides a custom `Authorization` header. A default `User-Agent` is added when none is given (any casing) |
|
|
103
|
-
| `auth` | `HttpAuth` \| `{ username, password }` | Basic auth object or subclass with `getAuthorizationHeader()` |
|
|
104
|
-
| `retry` | `boolean` \| retry options | `true` |
|
|
105
|
-
| `redirect` | `'follow' \| 'manual' \| number` | `'follow'` |
|
|
106
|
-
|
|
107
|
-
**Body shapes** (handled in `AbstractHttpRequestActivity.getContent`):
|
|
108
|
-
|
|
109
|
-
- `{ json: Serializable }` → `application/json` + `Content-Length`
|
|
110
|
-
- `{ text: string }` → `text/plain` + `Content-Length`
|
|
111
|
-
- `{ form: HttpRequestActivityInputBodyFormData }` → `FormData` (nested keys as `parent[key]`; `Binary` fields get generated filenames; `undefined` / `null` skipped)
|
|
112
|
-
- `{ binary: Binary }` → the `Binary` stream, with `Content-Type` and `Content-Length` from the `Binary`
|
|
113
|
-
|
|
114
|
-
**Form values:** `string | number | boolean | null | undefined | Binary | nested object | readonly array of nested form data`.
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
## Making HTTP calls in a workflow
|
|
119
|
-
|
|
120
|
-
Always use the ready **`http` / `HttpClient`** helper — it is what the package
|
|
121
|
-
exports for workflows and it drives the underlying HTTP activity through the
|
|
122
|
-
reconciler for you (replay-safe).
|
|
123
|
-
|
|
124
|
-
For a typed result, read the response and map with plain TypeScript:
|
|
125
|
-
|
|
126
|
-
```typescript
|
|
127
|
-
const res = await http.get(`${environments.SERVICE_URL}/data`)
|
|
128
|
-
const data = await res.body.json<MyType>()
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
See **HttpClient and `http`** and **Response and Body** below.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## HttpClient and `http`
|
|
136
|
-
|
|
137
|
-
`HttpClient` wraps `HttpRequestActivity` via `History.bind`. Calls inside a workflow are **reconciler-driven** (replay-safe); they throw `PushActivity` when history needs a new step.
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
import { http } from '@t4h.framework/http'
|
|
141
|
-
|
|
142
|
-
// GET
|
|
143
|
-
const response = await http.get('https://api.example.com/users')
|
|
144
|
-
const users = await response.body.json()
|
|
145
|
-
|
|
146
|
-
// POST JSON
|
|
147
|
-
await http.post('https://api.example.com/users', {
|
|
148
|
-
json: { name: 'John', email: 'john@example.com' },
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
// Base URL client (does not mutate singleton)
|
|
152
|
-
const api = http.extend({ baseUrl: 'https://api.example.com' })
|
|
153
|
-
const list = await api.get('/users')
|
|
154
|
-
|
|
155
|
-
// Instance with default auth (password is a Secret from the EnvDesign)
|
|
156
|
-
const client = new HttpClient({
|
|
157
|
-
baseUrl: 'https://api.example.com',
|
|
158
|
-
auth: { username: 'user', password: environments.API_PASSWORD },
|
|
159
|
-
})
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
Methods: `request(url, config?)`, `get`, `post(url, body, config?)`, `put`, `patch`, `delete`. Per-request `auth` in config merges over client `config.auth`.
|
|
163
|
-
|
|
164
|
-
Workflow example:
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
import { Workflow } from '@t4h.framework/core'
|
|
168
23
|
import { http } from '@t4h.framework/http'
|
|
169
24
|
|
|
170
|
-
|
|
171
|
-
await http.post('https://example.com/webhook', {
|
|
172
|
-
json: { status: 'ok' },
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
---
|
|
25
|
+
const api = http.extend({ baseUrl: environments.SERVICE_URL })
|
|
178
26
|
|
|
179
|
-
|
|
27
|
+
const response = await api.post('/orders', { json: { id: 1 } })
|
|
180
28
|
|
|
181
|
-
`
|
|
29
|
+
if (response.status !== 201) throw new Error(`Order failed: ${response.status}`)
|
|
182
30
|
|
|
183
|
-
|
|
184
|
-
response.status // number
|
|
185
|
-
response.headers // Record<string, string | string[] | undefined>
|
|
186
|
-
response.body // Body instance
|
|
31
|
+
const order = await response.body.json<{ id: string }>()
|
|
187
32
|
```
|
|
188
33
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
response.body
|
|
193
|
-
|
|
194
|
-
await response.body.text()
|
|
195
|
-
await response.body.json<T>()
|
|
196
|
-
await response.body.stream()
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
`body.json()` accepts only `*/json` and `*/*+json` and throws for other types (`Body.ts`). Use `text()` for those.
|
|
200
|
-
|
|
201
|
-
`Body` extends `SerializableClass` (`packages/http/src/models/Body.ts`) and is
|
|
202
|
-
persisted through `FileSystemClaim`, so the `Response`/`Body` returned by the
|
|
203
|
-
`http` client **is replay-safe** — it is serialized between reconciler steps and
|
|
204
|
-
rebuilt on replay. You do **not** need a custom activity to "flatten" the body
|
|
205
|
-
into history; read it with `await res.body.json<T>()` in the workflow and
|
|
206
|
-
transform with plain TypeScript.
|
|
207
|
-
|
|
208
|
-
Serializable shape: `{ binary: ... }` via `toSerializable` / `fromSerializable`.
|
|
209
|
-
|
|
210
|
-
---
|
|
34
|
+
1. Make one client per API with `http.extend({ baseUrl, auth })`.
|
|
35
|
+
2. Give the body as a tagged object: `{ json }`, `{ text }`, `{ form }` or
|
|
36
|
+
`{ binary }`.
|
|
37
|
+
3. Check `response.status` yourself, then read the body once with
|
|
38
|
+
`json<T>()`, `text()` or `stream()`. Map the data with plain TypeScript.
|
|
211
39
|
|
|
212
|
-
##
|
|
213
|
-
|
|
214
|
-
Pass each credential as the `Secret` from the project's `EnvDesign` (`tsc` rejects a string). The activity writes the header on the host, where the value is read, so neither the workflow nor the recorded input holds it. Do not build `Authorization` in `headers` yourself: a `Secret` throws when interpolated.
|
|
215
|
-
|
|
216
|
-
### Basic (inline)
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
await http.get('https://api.example.com/data', {
|
|
220
|
-
auth: { username: 'user', password: environments.API_PASSWORD },
|
|
221
|
-
})
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Bearer token / API key header
|
|
40
|
+
## Authenticate
|
|
225
41
|
|
|
226
42
|
```typescript
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
### Several secret headers
|
|
232
|
-
|
|
233
|
-
Put the `Secret` whole as a value in `headers` when the API needs more than one credential header, or one next to `auth`:
|
|
234
|
-
|
|
235
|
-
```typescript
|
|
236
|
-
await http.get('https://api.example.com/data', {
|
|
237
|
-
headers: { 'X-Api-Key': environments.API_KEY, 'X-Client-Id': environments.CLIENT_ID },
|
|
43
|
+
// src/constants/environments.ts
|
|
44
|
+
export const environments = EnvDesign({
|
|
45
|
+
API_TOKEN: { type: Secret },
|
|
46
|
+
OAUTH_SECRET: { type: Secret },
|
|
238
47
|
})
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Custom HttpAuth
|
|
242
48
|
|
|
243
|
-
|
|
49
|
+
await http.get(url, { auth: { bearer: environments.API_TOKEN } })
|
|
244
50
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
clientId: 'my-client-id',
|
|
253
|
-
clientSecret: environments.OAUTH_SECRET, // Secret
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
await http.get('https://api.example.com/data', { auth })
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### OAuth2 resource owner password
|
|
260
|
-
|
|
261
|
-
```typescript
|
|
262
|
-
import { OAuth2GrantResourceOwnerPassword } from '@t4h.framework/http'
|
|
263
|
-
|
|
264
|
-
const auth = new OAuth2GrantResourceOwnerPassword({
|
|
265
|
-
tokenUrl: 'https://auth.example.com/token',
|
|
266
|
-
clientId: 'my-client-id',
|
|
267
|
-
clientSecret: environments.OAUTH_SECRET, // Secret
|
|
268
|
-
username: 'user',
|
|
269
|
-
password: environments.OAUTH_PASSWORD, // Secret
|
|
51
|
+
const api = http.extend({
|
|
52
|
+
baseUrl: 'https://api.example.com',
|
|
53
|
+
auth: new OAuth2ClientCredentials({
|
|
54
|
+
tokenUrl: 'https://auth.example.com/token',
|
|
55
|
+
clientId: 'my-client-id',
|
|
56
|
+
clientSecret: environments.OAUTH_SECRET,
|
|
57
|
+
}),
|
|
270
58
|
})
|
|
271
59
|
```
|
|
272
60
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
`
|
|
286
|
-
|
|
287
|
-
for
|
|
61
|
+
Other shapes: `{ username, password }`, `{ header, value }`,
|
|
62
|
+
`OAuth2GrantResourceOwnerPassword`, or a subclass of `HttpAuth`.
|
|
63
|
+
|
|
64
|
+
## Traps
|
|
65
|
+
|
|
66
|
+
- Do not use `fetch`, `node:http` or `axios` in a workflow:
|
|
67
|
+
`no-io-in-workflow` rejects them. Do not construct or extend
|
|
68
|
+
`HttpRequestActivity` or `AbstractHttpRequestActivity`:
|
|
69
|
+
`no-framework-activity-in-app` rejects it. Do not write an activity to
|
|
70
|
+
"flatten" the response: `Response` and `Body` are already replay-safe.
|
|
71
|
+
- Each credential is a `Secret` from the `EnvDesign` in
|
|
72
|
+
`src/constants/environments.ts`. `tsc` rejects a string in `password`,
|
|
73
|
+
`bearer`, `value`, `clientSecret`. Do not build `Authorization` in
|
|
74
|
+
`headers`: a `Secret` throws when interpolated. A `Secret` can be a value in
|
|
75
|
+
`headers` for extra credential headers.
|
|
76
|
+
- A 4xx or 5xx status does not throw.
|
|
77
|
+
- `body.json()` throws `Invalid content type` unless the content type matches
|
|
78
|
+
`*/json` or `*/*+json`. Use `text()` for other types.
|
|
79
|
+
- `extend` exists only on the `http` singleton. The client it returns has no
|
|
80
|
+
`extend`. A per-request `auth` replaces the client `auth`.
|
|
81
|
+
- A url that starts with `/` replaces the path of `baseUrl` (`new URL` rules).
|
|
82
|
+
- `auth` and the body headers replace a custom header with the same name.
|
|
83
|
+
- Do not put a base64 file or a pre-signed URL in a JSON body. Use
|
|
84
|
+
`new HttpBodyUpload(binary, { signer: { url } })` in the body: it uploads
|
|
85
|
+
when the request is sent and resolves to the URL.
|
|
86
|
+
- OAuth2 tokens are cached under `oauth2:token:<clientId>`. Two grants with the
|
|
87
|
+
same `clientId` share one token.
|
|
88
|
+
- The runtime must provide `HttpClientRequestClaim` and `FileSystemClaim` for
|
|
89
|
+
every call, and `CacheClaim` for OAuth2.
|
|
90
|
+
|
|
91
|
+
## Test
|
|
92
|
+
|
|
93
|
+
Run the workflow with `TestWorkflowEnvironment` and mock both claims with
|
|
94
|
+
`mockClaim` from `@t4h.framework/core/testing` (see the
|
|
95
|
+
**framework-workflow-testing** skill):
|
|
288
96
|
|
|
289
97
|
```typescript
|
|
290
|
-
|
|
291
|
-
import { Binary } from '@t4h.framework/core'
|
|
292
|
-
import { TestWorkflowEnvironment, mockClaim } from '@t4h.framework/core/testing'
|
|
293
|
-
import { HttpClientRequestClaim } from '@t4h.framework/http'
|
|
294
|
-
import { FileSystemClaim } from '@t4h.framework/fs'
|
|
295
|
-
|
|
296
|
-
// Minimal Binary the FileSystemClaim mock returns from write().
|
|
297
|
-
class MockBinary extends Binary {
|
|
298
|
-
public readonly contentType = 'application/json'
|
|
299
|
-
public readonly contentLength: number
|
|
300
|
-
|
|
301
|
-
constructor(private readonly data: Buffer) {
|
|
302
|
-
super()
|
|
303
|
-
this.contentLength = data.byteLength
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
public stream() {
|
|
307
|
-
return Readable.from(this.data)
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const body = Buffer.from(JSON.stringify({ ok: true }))
|
|
312
|
-
|
|
313
|
-
// mockImplementation (not mockResolvedValue): replay runs the workflow twice, so
|
|
314
|
-
// each call must hand back a fresh, unconsumed stream.
|
|
315
|
-
const mockRequest = vi.fn().mockImplementation(async () => ({
|
|
98
|
+
const request = vi.fn().mockImplementation(async () => ({
|
|
316
99
|
status: 200,
|
|
317
100
|
headers: { 'content-type': 'application/json' },
|
|
318
101
|
body: Readable.from(body),
|
|
319
102
|
}))
|
|
320
103
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
const env = TestWorkflowEnvironment.create({ now: 0 })
|
|
324
|
-
|
|
325
|
-
const output = await env.execute(workflow, input, {
|
|
104
|
+
await env.execute(workflow, input, {
|
|
326
105
|
claims: [
|
|
327
|
-
mockClaim(HttpClientRequestClaim, { request
|
|
328
|
-
mockClaim(FileSystemClaim, { write:
|
|
106
|
+
mockClaim(HttpClientRequestClaim, { request }),
|
|
107
|
+
mockClaim(FileSystemClaim, { write: async () => new JsonBinary(body) }),
|
|
329
108
|
],
|
|
330
|
-
env: { SERVICE_URL: 'https://api.example.com' },
|
|
331
109
|
})
|
|
332
|
-
|
|
333
|
-
// request input carries a URL object
|
|
334
|
-
expect(mockRequest.mock.calls[0][0].url).toEqual(
|
|
335
|
-
new URL('https://api.example.com/data'),
|
|
336
|
-
)
|
|
337
110
|
```
|
|
338
111
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
## Checklist for agents
|
|
112
|
+
Use `mockImplementation`, not `mockResolvedValue`: the replay check calls the
|
|
113
|
+
mock again and needs a new stream. `JsonBinary` is a small `Binary` subclass in
|
|
114
|
+
the test file only (the full example is on the site). The request mock gets
|
|
115
|
+
`url` as a `URL`; assert on `request.mock.calls`.
|
|
344
116
|
|
|
345
|
-
|
|
346
|
-
2. `@t4h.framework/core/no-io-in-workflow` rejects `fetch` in a workflow. Use the package APIs.
|
|
347
|
-
3. A missing claim provider throws `ClaimProviderNotFoundException` (core `Claim.ts`). See **Claims** for the claims each call needs.
|
|
348
|
-
4. Read responses with **`await response.body.json()`** or **`text()`**; check `status` explicitly (no automatic throw on 4xx/5xx).
|
|
349
|
-
5. Test workflows with **`TestWorkflowEnvironment`** + **`mockClaim`**, mocking **`HttpClientRequestClaim`** and **`FileSystemClaim`**; assert on `mockRequest.mock.calls`.
|
|
117
|
+
## Reference
|
|
350
118
|
|
|
351
|
-
|
|
119
|
+
- Overview, claims and testing: https://tech4humans-brasil.github.io/framework/http/
|
|
120
|
+
- Requests, options and uploads: https://tech4humans-brasil.github.io/framework/http/requests
|
|
121
|
+
- Authentication: https://tech4humans-brasil.github.io/framework/http/authentication
|
|
122
|
+
- Responses: https://tech4humans-brasil.github.io/framework/http/responses
|
|
123
|
+
- Types: `node_modules/@t4h.framework/http/dist/http.d.ts`
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @t4h.framework/http
|
|
2
2
|
|
|
3
|
+
## 0.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#276](https://github.com/tech4humans-brasil/framework/pull/276) [`7b38934`](https://github.com/tech4humans-brasil/framework/commit/7b38934e8f9207c98c33afcd76e3a7a4da7e8b14) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The docs give the peers, the fields and the errors of `HttpBodyUpload`, and the test sample imports `vitest`.
|
|
8
|
+
|
|
9
|
+
## 0.8.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#271](https://github.com/tech4humans-brasil/framework/pull/271) [`a2763a2`](https://github.com/tech4humans-brasil/framework/commit/a2763a26fbc466009293389c76036af75070a945) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - Replaces the double casts, `as never` and the conditional spreads in the source with real types and type guards. The behavior and the public API do not change.
|
|
14
|
+
|
|
15
|
+
## 0.8.1
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [#257](https://github.com/tech4humans-brasil/framework/pull/257) [`586bfb4`](https://github.com/tech4humans-brasil/framework/commit/586bfb4663f4a478527ee0c8db360603f034d615) Thanks [@gusteycamargo](https://github.com/gusteycamargo)! - The http docs now hold the full contract: request options, header order, OAuth2 token cache, custom `HttpAuth`, status codes and testing. The README is short and the skill keeps only the traps and links to the site.
|
|
20
|
+
|
|
3
21
|
## 0.8.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,165 +1,33 @@
|
|
|
1
1
|
# @t4h.framework/http
|
|
2
2
|
|
|
3
|
-
HTTP
|
|
3
|
+
HTTP client for T4H Framework workflows. Each call is a durable step: it runs
|
|
4
|
+
once, and the workflow reuses the recorded response on replay.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
+
## Install
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Abstract dependency for performing raw HTTP requests. The runtime must provide a concrete implementation.
|
|
10
|
-
|
|
11
|
-
```typescript
|
|
12
|
-
import { HttpClientRequestClaim } from '@t4h.framework/http'
|
|
13
|
-
|
|
14
|
-
// the runtime provides this:
|
|
15
|
-
// { provide: HttpClientRequestClaim, value: new MyHttpClientRequestClaimImpl() }
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Activities
|
|
19
|
-
|
|
20
|
-
### HttpRequestActivity
|
|
21
|
-
|
|
22
|
-
A `SyncActivity` that performs an HTTP request and returns a `Response`. Internally it uses `HttpClientRequestClaim` and `FileSystemClaim` to execute the request and persist the response body.
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { HttpRequestActivity } from '@t4h.framework/http'
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## HttpClient
|
|
29
|
-
|
|
30
|
-
High-level HTTP client that wraps `HttpRequestActivity` behind a simple API. Available as a singleton `http` or instantiated with custom config.
|
|
31
|
-
|
|
32
|
-
### Basic usage
|
|
33
|
-
|
|
34
|
-
```typescript
|
|
35
|
-
import { http } from '@t4h.framework/http'
|
|
36
|
-
|
|
37
|
-
const response = await http.get('https://api.example.com/users')
|
|
38
|
-
const data = await response.body.json()
|
|
8
|
+
```bash
|
|
9
|
+
npm install @t4h.framework/http
|
|
39
10
|
```
|
|
40
11
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
const response = await http.post('https://api.example.com/users', {
|
|
45
|
-
json: { name: 'John', email: 'john@example.com' },
|
|
46
|
-
})
|
|
47
|
-
```
|
|
12
|
+
Peer dependencies: `@t4h.framework/core`, `@t4h.framework/fs` and
|
|
13
|
+
`@t4h.framework/cache`.
|
|
48
14
|
|
|
49
|
-
|
|
15
|
+
## Usage
|
|
50
16
|
|
|
51
17
|
```typescript
|
|
18
|
+
import { Workflow } from '@t4h.framework/core'
|
|
52
19
|
import { http } from '@t4h.framework/http'
|
|
53
20
|
|
|
54
|
-
const
|
|
21
|
+
export const syncUsers = new Workflow({ id: 'sync-users' }, async () => {
|
|
22
|
+
const response = await http.get('https://api.example.com/users')
|
|
55
23
|
|
|
56
|
-
const
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Available methods
|
|
24
|
+
const users = await response.body.json<{ id: string }[]>()
|
|
60
25
|
|
|
61
|
-
|
|
62
|
-
http.request(url, config?)
|
|
63
|
-
http.get(url, config?)
|
|
64
|
-
http.post(url, body, config?)
|
|
65
|
-
http.put(url, body, config?)
|
|
66
|
-
http.patch(url, body, config?)
|
|
67
|
-
http.delete(url, config?)
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Authentication
|
|
71
|
-
|
|
72
|
-
Each credential is a `Secret`: `tsc` rejects a string in `clientSecret`, `password`, `bearer` or `value`. Declare it with `type: Secret` in the `EnvDesign` in `src/constants/environments.ts`, and pass the `Secret` whole:
|
|
73
|
-
|
|
74
|
-
```typescript
|
|
75
|
-
// src/constants/environments.ts
|
|
76
|
-
import { EnvDesign, Secret } from '@t4h.framework/core'
|
|
77
|
-
|
|
78
|
-
export const environments = EnvDesign({
|
|
79
|
-
OAUTH_SECRET: { type: Secret },
|
|
80
|
-
OAUTH_PASSWORD: { type: Secret },
|
|
81
|
-
API_PASSWORD: { type: Secret },
|
|
26
|
+
return { count: users.length }
|
|
82
27
|
})
|
|
83
28
|
```
|
|
84
29
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
import { http, OAuth2ClientCredentials } from '@t4h.framework/http'
|
|
89
|
-
|
|
90
|
-
import { environments } from './constants/environments.js'
|
|
30
|
+
## Documentation
|
|
91
31
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
clientId: 'my-client-id',
|
|
95
|
-
clientSecret: environments.OAUTH_SECRET,
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
const response = await http.get('https://api.example.com/data', { auth })
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### OAuth2 Resource Owner Password
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
import { OAuth2GrantResourceOwnerPassword } from '@t4h.framework/http'
|
|
105
|
-
|
|
106
|
-
import { environments } from './constants/environments.js'
|
|
107
|
-
|
|
108
|
-
const auth = new OAuth2GrantResourceOwnerPassword({
|
|
109
|
-
tokenUrl: 'https://auth.example.com/token',
|
|
110
|
-
clientId: 'my-client-id',
|
|
111
|
-
clientSecret: environments.OAUTH_SECRET,
|
|
112
|
-
username: 'user',
|
|
113
|
-
password: environments.OAUTH_PASSWORD,
|
|
114
|
-
})
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### Basic Auth
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
import { http } from '@t4h.framework/http'
|
|
121
|
-
|
|
122
|
-
import { environments } from './constants/environments.js'
|
|
123
|
-
|
|
124
|
-
const response = await http.get('https://api.example.com/data', {
|
|
125
|
-
auth: { username: 'user', password: environments.API_PASSWORD },
|
|
126
|
-
})
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
### Secret headers
|
|
130
|
-
|
|
131
|
-
A value in `headers` can be a `Secret`. Use it when an API needs more than one credential header, or a credential header next to `auth`. Add `API_KEY: { type: Secret }` and `CLIENT_ID: { type: Secret }` to the `EnvDesign`:
|
|
132
|
-
|
|
133
|
-
```typescript
|
|
134
|
-
import { http } from '@t4h.framework/http'
|
|
135
|
-
|
|
136
|
-
import { environments } from './constants/environments.js'
|
|
137
|
-
|
|
138
|
-
const response = await http.post(
|
|
139
|
-
'https://api.example.com/orders',
|
|
140
|
-
{ json: { id: 1 } },
|
|
141
|
-
{
|
|
142
|
-
headers: {
|
|
143
|
-
'X-Api-Key': environments.API_KEY,
|
|
144
|
-
'X-Client-Id': environments.CLIENT_ID,
|
|
145
|
-
'X-Tenant': 'acme',
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
)
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
## Response
|
|
152
|
-
|
|
153
|
-
The `Response` object provides access to status, headers, and body:
|
|
154
|
-
|
|
155
|
-
```typescript
|
|
156
|
-
const response = await http.get('https://api.example.com/data')
|
|
157
|
-
|
|
158
|
-
response.status // number
|
|
159
|
-
response.headers // Record<string, string | string[] | undefined>
|
|
160
|
-
|
|
161
|
-
await response.body.text() // string
|
|
162
|
-
await response.body.json() // parsed JSON
|
|
163
|
-
response.body.contentType // string
|
|
164
|
-
response.body.contentLength // number
|
|
165
|
-
```
|
|
32
|
+
Request bodies, authentication, responses and testing:
|
|
33
|
+
https://tech4humans-brasil.github.io/framework/http/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBodyUpload.d.ts","sourceRoot":"","sources":["../../src/models/HttpBodyUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8CAA8C,CAAA;AAK9E,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,UAAU,CAAA;QACnB,IAAI,CAAC,EAAE,YAAY,CAAA;QACnB,OAAO,CAAC,E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C,EAAE,UAAU,CAAA;QACnB,IAAI,CAAC,EAAE,YAAY,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACjC,CAAA;IACD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE;QACP,MAAM,CAAC,EAAE,UAAU,CAAA;QACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACjC,CAAA;CACF,CAAA;AAED,KAAK,wBAAwB,GAAG;IAC9B,MAAM,EAAE,YAAY,CAAA;IACpB,MAAM,EAAE,oBAAoB,CAAA;CAC7B,CAAA;AAYD,qBAAa,cAAe,SAAQ,WAAW;aAI3B,MAAM,EAAE,MAAM;aACd,MAAM,EAAE,oBAAoB;IAJ9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;gBAGnD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,oBAAoB;IAKjC,cAAc,CACzB,UAAU,EAAE,UAAU,GACrB,OAAO,CAAC,wBAAwB,CAAC;cAOpB,gBAAgB,CAC9B,UAAU,EAAE,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAC/D,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC,IAAI,CAAC;IAOH,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;YAQzB,WAAW;YAsDX,MAAM;CA0BrB"}
|
|
@@ -49,10 +49,12 @@ export class HttpBodyUpload extends HttpBodyRef {
|
|
|
49
49
|
redirect: 'follow',
|
|
50
50
|
retry: true,
|
|
51
51
|
headers: withDefaultUserAgent({
|
|
52
|
-
...(body
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
...(body
|
|
53
|
+
? {
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
'Content-Length': body.byteLength.toString(),
|
|
56
|
+
}
|
|
57
|
+
: {}),
|
|
56
58
|
Accept: 'application/json',
|
|
57
59
|
...signer.headers,
|
|
58
60
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBodyUpload.js","sourceRoot":"","sources":["../../src/models/HttpBodyUpload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAMN,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAE1E,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAqBnC,SAAS,IAAI,CAAC,KAAc,EAAE,IAAY;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAU,CAAC,OAAO,EAAE,GAAG,EAAE,EAAE;QACtD,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,SAAS,CAAA;QAEtC,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QAEjD,OAAQ,OAAmC,CAAC,GAAG,CAAC,CAAA;IAClD,CAAC,EAAE,KAAK,CAAC,CAAA;AACX,CAAC;AAED,MAAM,OAAO,cAAe,SAAQ,WAAW;IAI3B;IACA;IAJD,MAAM,GAAG,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAA;IAErE,YACkB,MAAc,EACd,MAA4B;QAE5C,KAAK,EAAE,CAAA;QAHS,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAsB;IAG9C,CAAC;IAEM,KAAK,CAAC,cAAc,CACzB,UAAsB;QAEtB,OAAO;YACL,MAAM,EAAE,MAAM,UAAU,CAAC,IAAI,CAAC,MAAsB,CAAC;YACrD,MAAM,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"HttpBodyUpload.js","sourceRoot":"","sources":["../../src/models/HttpBodyU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AAK;YAC/B,IAAI,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAChC,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,oBAAoB,CAAC;gBAC5B,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;gBACvC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,QAAQ,EAAE;gBACtD,GAAG,MAAM,EAAE,OAAO;aACnB,CAAC;SACH,CAAC,CAAA;QAEF,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YACpD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAChE,OAAO,CACR,CAAA;YAED,MAAM,IAAI,KAAK,CACb,+CAA+C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC,EAAE,CACpH,CAAA;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OAuth2.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"OAuth2.d.ts","sourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,eAAe,EAEpB,KAAK,UAAU,EAChB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eA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ourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,KAAK,EACL,MAAM,
|
|
1
|
+
{"version":3,"file":"OAuth2.js","sourceRoot":"","sources":["../../src/models/OAuth2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EACL,KAAK,EACL,MAAM,GAKP,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAkB1E,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAElC,MAAM,OAAgB,MAAqC,SAAQ,QAAQ;IAuC7C;IAtCT,MAAM,GAAG,IAAI,KAAK,CAAC;QACpC,IAAI,EAAE,sBAAsB;QAC5B,KAAK,EAAE,UAAU;KAClB,CAAC,CAAA;IAEF,IAAc,aAAa;QACzB,OAAO,gBAAgB,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;IAC/C,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAsB;QAChD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAiC,CAAC,CAAC,GAAG,CACxD,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YACtB,GAAG;YACH,KAAK,YAAY,MAAM,CAAC,CAAC,CAAC,MAAM,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK;SAC1D,CACF,CACF,CAAA;QAED,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAY,CAAA;IAC/C,CAAC;IAES,KAAK,CAAC,gBAAgB,CAC9B,YAAiE,EAC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S,CAAA;QAExC,MAAM,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,SAAS,EAAE,CAAA;QAErC,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE;YACrD,GAAG,EAAE,SAAS;SACf,CAAC,CAAA;QAEF,OAAO,KAAK,CAAA;IACd,CAAC;IAES,KAAK,CAAC,QAAQ;QACtB,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CACvC,IAAI,CAAC,aAAa,CACnB,CAAA;QAED,IAAI,CAAC,KAAK;YAAE,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QAE5D,IAAI,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE;YAAE,OAAO,KAAK,CAAA;QAE9C,IAAI,CAAC,KAAK,CAAC,aAAa;YAAE,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;QAE1E,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;IAChD,CAAC;IAEM,KAAK,CAAC,sBAAsB;QACjC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAA;QAEnC,OAAO,GAAG,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,YAAY,EAAE,CAAA;IACpD,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t4h.framework/http",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "HTTP module for the T4H Framework",
|
|
5
5
|
"homepage": "https://github.com/tech4humans-brasil/framework/tree/main/packages/http",
|
|
6
6
|
"bugs": "https://github.com/tech4humans-brasil/framework/issues",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"uuidv7": "^1.1.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@t4h.framework/cache": "^0.6.
|
|
43
|
-
"@t4h.framework/core": "^0.
|
|
44
|
-
"@t4h.framework/fs": "^0.
|
|
42
|
+
"@t4h.framework/cache": "^0.6.14",
|
|
43
|
+
"@t4h.framework/core": "^0.21.2",
|
|
44
|
+
"@t4h.framework/fs": "^0.14.2",
|
|
45
45
|
"@types/type-is": "^1.6.7",
|
|
46
46
|
"@vitest/coverage-v8": "^4.0.18",
|
|
47
47
|
"typescript": "^5.9.3",
|