@t4h.framework/http 0.2.0 → 0.3.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/.ai/skills/framework-http/SKILL.md +402 -0
- package/dist/models/HttpAuth.d.ts +1 -2
- package/dist/models/HttpAuth.d.ts.map +1 -1
- package/dist/models/HttpAuth.js +1 -2
- package/dist/models/HttpAuth.js.map +1 -1
- package/dist/testing/index.d.ts +3 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +15 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +9 -8
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: framework-http
|
|
3
|
+
description: >-
|
|
4
|
+
Guides correct use of @t4h.framework/http in T4H Framework workflows: HTTP
|
|
5
|
+
activities (HttpRequestActivity, AbstractHttpRequestActivity), claims
|
|
6
|
+
(HttpClientRequestClaim, FileSystemClaim, CacheClaim for OAuth), the http
|
|
7
|
+
client, request/response bodies, and auth. Use when implementing or testing
|
|
8
|
+
HTTP calls in workflows, wiring HTTP claim providers, extending HTTP
|
|
9
|
+
activities, OAuth2/Basic auth, or working in packages/http.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# @t4h.framework/http
|
|
13
|
+
|
|
14
|
+
HTTP activities, claims, and a reconciler-aware client for workflows. Package path: `framework/packages/http`. Peer dependencies: `@t4h.framework/core`, `@t4h.framework/fs`, `@t4h.framework/cache` (OAuth).
|
|
15
|
+
|
|
16
|
+
Import surface (from `src/http.ts` only — do not reference unexported modules such as `src/errors/HttpError.ts`):
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import {
|
|
20
|
+
http,
|
|
21
|
+
HttpClient,
|
|
22
|
+
HttpRequestActivity,
|
|
23
|
+
AbstractHttpRequestActivity,
|
|
24
|
+
HttpClientRequestClaim,
|
|
25
|
+
HttpAuth,
|
|
26
|
+
OAuth2,
|
|
27
|
+
OAuth2ClientCredentials,
|
|
28
|
+
OAuth2GrantResourceOwnerPassword,
|
|
29
|
+
Body,
|
|
30
|
+
Response,
|
|
31
|
+
type HttpRequestActivityInput,
|
|
32
|
+
type HttpRequestActivityOutput,
|
|
33
|
+
type HttpClientRequestClaimInput,
|
|
34
|
+
type HttpClientRequestClaimOutput,
|
|
35
|
+
} from '@t4h.framework/http'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Architecture
|
|
39
|
+
|
|
40
|
+
`Workflow` → `http`/`HttpClient` (`History.bind(HttpRequestActivity)`) → `AbstractHttpRequestActivity.run` → `HttpClientRequestClaim.request` + `FileSystemClaim.write` (response → `Body`/`Response`).
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Claims
|
|
45
|
+
|
|
46
|
+
### HttpClientRequestClaim (required for HTTP)
|
|
47
|
+
|
|
48
|
+
Runtime must register an implementation:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
{ provide: HttpClientRequestClaim, value: new MyHttpClientRequestClaimImpl() }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Contract:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
abstract class HttpClientRequestClaim {
|
|
58
|
+
abstract request(
|
|
59
|
+
input: HttpClientRequestClaimInput,
|
|
60
|
+
): HttpClientRequestClaimOutput | Promise<HttpClientRequestClaimOutput>
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// HttpClientRequestClaimInput
|
|
64
|
+
{
|
|
65
|
+
url: URL
|
|
66
|
+
method: HttpMethod // required on claim input
|
|
67
|
+
body: Buffer | FormData | Readable | URLSearchParams | undefined
|
|
68
|
+
headers: Record<string, string | string[] | undefined>
|
|
69
|
+
redirect: 'follow' | 'manual' | number
|
|
70
|
+
retry: boolean | HttpRequestActivityInputRetryOptions
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// HttpClientRequestClaimOutput
|
|
74
|
+
{
|
|
75
|
+
status: number
|
|
76
|
+
headers: Record<string, string | string[] | undefined>
|
|
77
|
+
body: Readable
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Dev: register a concrete `HttpClientRequestClaim` in the runtime (or mock in tests via `Claim.run`).
|
|
82
|
+
|
|
83
|
+
### FileSystemClaim (required by activities)
|
|
84
|
+
|
|
85
|
+
`AbstractHttpRequestActivity` persists the response body with `fs.write(\`${uuid}-http-request-activity-response-body.${ext}\`, response.body)`. Extension comes from `content-type` via `mime`, or `.bin` if missing. Tests mock `FileSystemClaim.write` to build a `Binary` for `Body`.
|
|
86
|
+
|
|
87
|
+
### CacheClaim (OAuth only)
|
|
88
|
+
|
|
89
|
+
`HttpAuth` / `OAuth2` use `CacheClaim` for token caching. OAuth2 stores tokens at `oauth2:token:${clientId}` with TTL derived from `expires_in` (90% of lifetime).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## HttpRequestActivityInput
|
|
94
|
+
|
|
95
|
+
Shared by activities and `HttpClient` config (minus `url` / `baseUrl` on client methods):
|
|
96
|
+
|
|
97
|
+
| Field | Type | Default / notes |
|
|
98
|
+
|-------|------|-----------------|
|
|
99
|
+
| `url` | `string` | Resolved with `new URL(url, baseUrl)` |
|
|
100
|
+
| `baseUrl` | `string?` | Optional base for relative paths |
|
|
101
|
+
| `method` | `HttpMethod?` | `'GET'` |
|
|
102
|
+
| `body` | `{ json }` \| `{ text }` \| `{ form }` | See below |
|
|
103
|
+
| `headers` | `Record<...>?` | Merged with body-derived headers; `auth` sets `Authorization` and overrides a custom `Authorization` header |
|
|
104
|
+
| `auth` | `HttpAuth` \| `{ username, password }` | Basic auth object or subclass with `getAuthorizationHeader()` |
|
|
105
|
+
| `retry` | `boolean` \| retry options | `true` |
|
|
106
|
+
| `redirect` | `'follow' \| 'manual' \| number` | `'follow'` |
|
|
107
|
+
|
|
108
|
+
**Body shapes** (handled in `AbstractHttpRequestActivity.getContent`):
|
|
109
|
+
|
|
110
|
+
- `{ json: Serializable }` → `application/json` + `Content-Length`
|
|
111
|
+
- `{ text: string }` → `text/plain` + `Content-Length`
|
|
112
|
+
- `{ form: HttpRequestActivityInputBodyFormData }` → `FormData` (nested keys as `parent[key]`; `Binary` fields get generated filenames; `undefined` / `null` skipped)
|
|
113
|
+
|
|
114
|
+
Invalid body shape throws `Invalid body`.
|
|
115
|
+
|
|
116
|
+
**Form values:** `string | number | boolean | null | undefined | Binary | nested object | readonly array of nested form data`.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## Activities
|
|
121
|
+
|
|
122
|
+
### HttpRequestActivity
|
|
123
|
+
|
|
124
|
+
Direct use when workflow input matches HTTP config:
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
import { HttpRequestActivity } from '@t4h.framework/http'
|
|
128
|
+
|
|
129
|
+
// Inside Claim.run or reconciler context:
|
|
130
|
+
const activity = new HttpRequestActivity()
|
|
131
|
+
const output = await activity.run({
|
|
132
|
+
url: 'https://api.example.com/data',
|
|
133
|
+
method: 'GET',
|
|
134
|
+
})
|
|
135
|
+
// Serializable output is HttpRequestActivityOutput; toOutput wraps Response
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`toInput` / `toHttpInput` pass input through; `toOutput` returns `new Response(output)`.
|
|
139
|
+
|
|
140
|
+
### AbstractHttpRequestActivity (custom activities)
|
|
141
|
+
|
|
142
|
+
Extend with **four** type parameters: `TArgs`, `TInput`, `TSerializableOutput`, `TOutput`.
|
|
143
|
+
|
|
144
|
+
Implement:
|
|
145
|
+
|
|
146
|
+
- `toInput(...args)` — map workflow args → activity input
|
|
147
|
+
- `toOutput(serializable, ...args)` — map serializable result → workflow return type
|
|
148
|
+
- `protected toHttpInput(input)` — map to `HttpRequestActivityInput`
|
|
149
|
+
- `protected toHttpOutput(output)` — map `HttpRequestActivityOutput` → serializable stored in history
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
import {
|
|
153
|
+
AbstractHttpRequestActivity,
|
|
154
|
+
type HttpRequestActivityInput,
|
|
155
|
+
type HttpRequestActivityOutput,
|
|
156
|
+
} from '@t4h.framework/http'
|
|
157
|
+
import type { Serializable } from '@t4h.framework/core'
|
|
158
|
+
|
|
159
|
+
class FetchStatusActivity extends AbstractHttpRequestActivity<
|
|
160
|
+
[endpoint: string],
|
|
161
|
+
{ endpoint: string },
|
|
162
|
+
{ status: number },
|
|
163
|
+
{ status: number }
|
|
164
|
+
> {
|
|
165
|
+
public async toInput(endpoint: string) {
|
|
166
|
+
return { endpoint }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
protected async toHttpInput(input: { endpoint: string }): Promise<HttpRequestActivityInput> {
|
|
170
|
+
return { url: input.endpoint, method: 'GET' }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
protected async toHttpOutput(output: HttpRequestActivityOutput): Promise<{ status: number }> {
|
|
174
|
+
return { status: output.status }
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public toOutput(output: { status: number }) {
|
|
178
|
+
return output
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Static helpers (for tests or advanced form building):
|
|
184
|
+
|
|
185
|
+
- `AbstractHttpRequestActivity.getContent(body)`
|
|
186
|
+
- `AbstractHttpRequestActivity.append(form, input, currentKey?)`
|
|
187
|
+
- `AbstractHttpRequestActivity.getFormData(input)`
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## HttpClient and `http`
|
|
192
|
+
|
|
193
|
+
`HttpClient` wraps `HttpRequestActivity` via `History.bind`. Calls inside a workflow are **reconciler-driven** (replay-safe); they throw `PushActivity` when history needs a new step.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { http } from '@t4h.framework/http'
|
|
197
|
+
|
|
198
|
+
// GET
|
|
199
|
+
const response = await http.get('https://api.example.com/users')
|
|
200
|
+
const users = await response.body.json()
|
|
201
|
+
|
|
202
|
+
// POST JSON
|
|
203
|
+
await http.post('https://api.example.com/users', {
|
|
204
|
+
json: { name: 'John', email: 'john@example.com' },
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
// Base URL client (does not mutate singleton)
|
|
208
|
+
const api = http.extend({ baseUrl: 'https://api.example.com' })
|
|
209
|
+
const list = await api.get('/users')
|
|
210
|
+
|
|
211
|
+
// Instance with default auth
|
|
212
|
+
const client = new HttpClient({
|
|
213
|
+
baseUrl: 'https://api.example.com',
|
|
214
|
+
auth: { username: 'user', password: 'pass' },
|
|
215
|
+
})
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Methods: `request(url, config?)`, `get`, `post(url, body, config?)`, `put`, `patch`, `delete`. Per-request `auth` in config merges over client `config.auth`.
|
|
219
|
+
|
|
220
|
+
Workflow example (`examples/basic/src/workflows/simple.ts`):
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { Workflow } from '@t4h.framework/core'
|
|
224
|
+
import { http } from '@t4h.framework/http'
|
|
225
|
+
|
|
226
|
+
export const simple = new Workflow({ id: 'simple' }, async () => {
|
|
227
|
+
await http.post('https://example.com/webhook', {
|
|
228
|
+
json: { status: 'ok' },
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Response and Body
|
|
236
|
+
|
|
237
|
+
`HttpRequestActivity` exposes `Response`:
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
response.status // number
|
|
241
|
+
response.headers // Record<string, string | string[] | undefined>
|
|
242
|
+
response.body // Body instance
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
`Body` (backed by `Binary` from filesystem claim):
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
response.body.contentType
|
|
249
|
+
response.body.contentLength
|
|
250
|
+
await response.body.text()
|
|
251
|
+
await response.body.json<T>() // only if content-type matches */json or */*+json
|
|
252
|
+
await response.body.stream()
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
`body.json()` throws `Invalid content type` for non-JSON types (e.g. `text/plain`, `text/html`).
|
|
256
|
+
|
|
257
|
+
Serializable shape: `{ binary: ... }` via `toSerializable` / `fromSerializable`.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Authentication
|
|
262
|
+
|
|
263
|
+
### Basic (inline)
|
|
264
|
+
|
|
265
|
+
```typescript
|
|
266
|
+
await http.get('https://api.example.com/data', {
|
|
267
|
+
auth: { username: 'user', password: 'pass' },
|
|
268
|
+
})
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Custom HttpAuth
|
|
272
|
+
|
|
273
|
+
Subclass `HttpAuth` (extends `SerializableClass`), implement `getAuthorizationHeader()`, and optional `toSerializable` / `fromSerializable` for workflow persistence.
|
|
274
|
+
|
|
275
|
+
### OAuth2 client credentials
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
import { http, OAuth2ClientCredentials } from '@t4h.framework/http'
|
|
279
|
+
|
|
280
|
+
const auth = new OAuth2ClientCredentials({
|
|
281
|
+
tokenUrl: 'https://auth.example.com/token',
|
|
282
|
+
clientId: 'my-client-id',
|
|
283
|
+
clientSecret: 'my-client-secret',
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
await http.get('https://api.example.com/data', { auth })
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### OAuth2 resource owner password
|
|
290
|
+
|
|
291
|
+
```typescript
|
|
292
|
+
import { OAuth2GrantResourceOwnerPassword } from '@t4h.framework/http'
|
|
293
|
+
|
|
294
|
+
const auth = new OAuth2GrantResourceOwnerPassword({
|
|
295
|
+
tokenUrl: 'https://auth.example.com/token',
|
|
296
|
+
clientId: 'my-client-id',
|
|
297
|
+
clientSecret: 'my-client-secret',
|
|
298
|
+
username: 'user',
|
|
299
|
+
password: 'pass',
|
|
300
|
+
})
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
OAuth2 flow: POST `application/x-www-form-urlencoded` to `tokenUrl` via `HttpClientRequestClaim`; cache token; refresh with `grant_type=refresh_token` when expired if `refresh_token` present; header format `${token_type} ${access_token}`.
|
|
304
|
+
|
|
305
|
+
Requires `CacheClaim` + `HttpClientRequestClaim` in the runtime.
|
|
306
|
+
|
|
307
|
+
---
|
|
308
|
+
|
|
309
|
+
## Testing
|
|
310
|
+
|
|
311
|
+
Run package tests: `yarn test` in `packages/http` (Vitest).
|
|
312
|
+
|
|
313
|
+
### 1. Unit-test activity `run` with mocked claims
|
|
314
|
+
|
|
315
|
+
Pattern from `AbstractHttpRequestActivity.spec.ts`:
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import { Claim } from '@t4h.framework/core'
|
|
319
|
+
import { FileSystemClaim } from '@t4h.framework/fs'
|
|
320
|
+
import { Readable } from 'node:stream'
|
|
321
|
+
import { HttpClientRequestClaim } from '@t4h.framework/http'
|
|
322
|
+
|
|
323
|
+
const mockRequest = vi.fn().mockResolvedValue({
|
|
324
|
+
status: 200,
|
|
325
|
+
headers: { 'content-type': 'application/json' },
|
|
326
|
+
body: Readable.from(Buffer.from('{"ok":true}')),
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
const mockWrite = vi.fn().mockImplementation(async (_path, readable) => {
|
|
330
|
+
const chunks = await readable.toArray()
|
|
331
|
+
return new MockBinary(Buffer.concat(chunks), 'application/json')
|
|
332
|
+
})
|
|
333
|
+
|
|
334
|
+
const result = await Claim.run(
|
|
335
|
+
[
|
|
336
|
+
{ provide: HttpClientRequestClaim, value: { request: mockRequest } },
|
|
337
|
+
{ provide: FileSystemClaim, value: { write: mockWrite, read: vi.fn() } },
|
|
338
|
+
],
|
|
339
|
+
() => new MyActivity().run(input),
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
await expect(result.body.json()).resolves.toEqual({ ok: true })
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Assert `mockRequest` received `url`, `method`, merged headers, and JSON buffer for `{ json: ... }` bodies.
|
|
346
|
+
|
|
347
|
+
### 2. Assert HttpClient schedules HttpRequestActivity
|
|
348
|
+
|
|
349
|
+
Pattern from `HttpClient.spec.ts`:
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
import { History, PushActivity } from '@t4h.framework/core'
|
|
353
|
+
import { HttpRequestActivity } from '@t4h.framework/http'
|
|
354
|
+
|
|
355
|
+
async function captureTrigger(fn: () => unknown) {
|
|
356
|
+
try {
|
|
357
|
+
await History.run([], fn)
|
|
358
|
+
} catch (error) {
|
|
359
|
+
if (error instanceof PushActivity) return error
|
|
360
|
+
throw error
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const trigger = await captureTrigger(() => http.post('/users', { json: { name: 'Tony' } }))
|
|
365
|
+
expect(trigger.activity.constructor).toBe(HttpRequestActivity)
|
|
366
|
+
expect(trigger.input).toMatchObject({ method: 'POST', body: { json: { name: 'Tony' } } })
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### 3. Integration-test workflows with mocked claims
|
|
370
|
+
|
|
371
|
+
Use `WorkflowTesting.run` with explicit claim providers and spies on mock implementations:
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
import { WorkflowTesting } from '@t4h.framework/core/testing'
|
|
375
|
+
import { HttpClientRequestClaim, type HttpClientRequestClaimInput } from '@t4h.framework/http'
|
|
376
|
+
|
|
377
|
+
const mockRequest = vi.fn().mockResolvedValue({ status: 200, headers: {}, body: Readable.from('{}') })
|
|
378
|
+
|
|
379
|
+
await WorkflowTesting.run(workflow, input, {
|
|
380
|
+
claims: [
|
|
381
|
+
{ provide: HttpClientRequestClaim, value: { request: mockRequest } as HttpClientRequestClaim },
|
|
382
|
+
{ provide: FileSystemClaim, value: mockFs },
|
|
383
|
+
],
|
|
384
|
+
})
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Inspect `mockRequest.mock.calls` for URLs, methods, and bodies. See **framework-core** skill for `WorkflowTesting` options.
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Checklist for agents
|
|
392
|
+
|
|
393
|
+
1. Prefer **`http` / `HttpClient`** in workflows unless you need a typed custom activity.
|
|
394
|
+
2. Never call `fetch` directly in workflow code if the step must be replayable — use the package APIs.
|
|
395
|
+
3. Ensure runtime provides **`HttpClientRequestClaim`** and **`FileSystemClaim`** (or pass mocks in tests).
|
|
396
|
+
4. Use **`{ json: ... }`**, **`{ text: ... }`**, or **`{ form: ... }`** for bodies — not raw `Buffer` on activity input.
|
|
397
|
+
5. Read responses with **`await response.body.json()`** or **`text()`**; check `status` explicitly (no automatic throw on 4xx/5xx).
|
|
398
|
+
6. For OAuth, wire **`CacheClaim`** and use exported grant classes only.
|
|
399
|
+
7. When adding tests, mirror **`Claim.run`** + claim mocks or **`History.run`** + **`PushActivity`** patterns from `packages/http/src/**/__tests__`.
|
|
400
|
+
8. Do not document or import APIs not exported from `@t4h.framework/http`.
|
|
401
|
+
|
|
402
|
+
See also: `packages/http/README.md`, `examples/basic/src/workflows/simple.ts`.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CacheClaim } from '@t4h.framework/cache';
|
|
2
|
-
import { Claim } from '@t4h.framework/core';
|
|
3
|
-
import { SerializableClass } from '../../../core/dist/models/SerializableHelper.js';
|
|
2
|
+
import { Claim, SerializableClass } from '@t4h.framework/core';
|
|
4
3
|
declare const HTTP_AUTH_CLAIMS_KEY: unique symbol;
|
|
5
4
|
export declare abstract class HttpAuth extends SerializableClass {
|
|
6
5
|
readonly [HTTP_AUTH_CLAIMS_KEY]: Claim<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpAuth.d.ts","sourceRoot":"","sources":["../../src/models/HttpAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"HttpAuth.d.ts","sourceRoot":"","sources":["../../src/models/HttpAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,QAAA,MAAM,oBAAoB,eAA6B,CAAA;AAEvD,8BAAsB,QAAS,SAAQ,iBAAiB;IACtD,SAAgB,CAAC,oBAAoB,CAAC;;OAEpC;aAEc,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC;CAC1D"}
|
package/dist/models/HttpAuth.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CacheClaim } from '@t4h.framework/cache';
|
|
2
|
-
import { Claim } from '@t4h.framework/core';
|
|
3
|
-
import { SerializableClass } from '../../../core/dist/models/SerializableHelper.js';
|
|
2
|
+
import { Claim, SerializableClass } from '@t4h.framework/core';
|
|
4
3
|
const HTTP_AUTH_CLAIMS_KEY = Symbol('http-auth-claims');
|
|
5
4
|
export class HttpAuth extends SerializableClass {
|
|
6
5
|
[HTTP_AUTH_CLAIMS_KEY] = new Claim({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpAuth.js","sourceRoot":"","sources":["../../src/models/HttpAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"HttpAuth.js","sourceRoot":"","sources":["../../src/models/HttpAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,MAAM,oBAAoB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA;AAEvD,MAAM,OAAgB,QAAS,SAAQ,iBAAiB;IACtC,CAAC,oBAAoB,CAAC,GAAG,IAAI,KAAK,CAAC;QACjD,KAAK,EAAE,UAAU;KAClB,CAAC,CAAA;CAGH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,sBAAsB,EAEvB,MAAM,qCAAqC,CAAA;AAE5C,wBAAgB,aAAa,CAC3B,cAAc,GAAE,OAAO,CAAC,sBAAsB,CAAM,uEAYrD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { mockClaim } from '@t4h.framework/core/testing';
|
|
3
|
+
import { HttpClientRequestClaim, } from '../models/HttpClientRequestClaim.js';
|
|
4
|
+
export function mockHttpClaim(implementation = {}) {
|
|
5
|
+
const defaultResponse = {
|
|
6
|
+
status: 200,
|
|
7
|
+
headers: { 'content-type': 'application/json' },
|
|
8
|
+
body: Readable.from(Buffer.from('{}')),
|
|
9
|
+
};
|
|
10
|
+
return mockClaim(HttpClientRequestClaim, {
|
|
11
|
+
request: async () => defaultResponse,
|
|
12
|
+
...implementation,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAEvD,OAAO,EACL,sBAAsB,GAEvB,MAAM,qCAAqC,CAAA;AAE5C,MAAM,UAAU,aAAa,CAC3B,iBAAkD,EAAE;IAEpD,MAAM,eAAe,GAAiC;QACpD,MAAM,EAAE,GAAG;QACX,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACvC,CAAA;IAED,OAAO,SAAS,CAAC,sBAAsB,EAAE;QACvC,OAAO,EAAE,KAAK,IAAI,EAAE,CAAC,eAAe;QACpC,GAAG,cAAc;KAClB,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t4h.framework/http",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"types": "./dist/http.d.ts",
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"LICENSE"
|
|
23
|
+
"LICENSE",
|
|
24
|
+
".ai"
|
|
24
25
|
],
|
|
25
26
|
"scripts": {
|
|
26
27
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -37,18 +38,18 @@
|
|
|
37
38
|
"uuidv7": "^1.1.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@t4h.framework/cache": "^0.
|
|
41
|
-
"@t4h.framework/core": "^0.
|
|
42
|
-
"@t4h.framework/fs": "^0.
|
|
41
|
+
"@t4h.framework/cache": "^0.4.0",
|
|
42
|
+
"@t4h.framework/core": "^0.7.0",
|
|
43
|
+
"@t4h.framework/fs": "^0.4.0",
|
|
43
44
|
"@types/type-is": "^1.6.7",
|
|
44
45
|
"@vitest/coverage-v8": "^4.0.18",
|
|
45
46
|
"typescript": "^5.9.3",
|
|
46
47
|
"vitest": "^4.0.18"
|
|
47
48
|
},
|
|
48
49
|
"peerDependencies": {
|
|
49
|
-
"@t4h.framework/cache": "^0.
|
|
50
|
-
"@t4h.framework/core": "^0.
|
|
51
|
-
"@t4h.framework/fs": "^0.
|
|
50
|
+
"@t4h.framework/cache": "^0.4.0",
|
|
51
|
+
"@t4h.framework/core": "^0.7.0",
|
|
52
|
+
"@t4h.framework/fs": "^0.4.0"
|
|
52
53
|
},
|
|
53
54
|
"packageManager": "yarn@4.12.0",
|
|
54
55
|
"engines": {
|