feat(http-recorder): sync recorder v0.3 (#35619)
This commit is contained in:
parent
05e8d5be73
commit
3dd29094f4
47 changed files with 2697 additions and 2207 deletions
46
packages/http-recorder/src/api.ts
Normal file
46
packages/http-recorder/src/api.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/** JSON-compatible cassette metadata value. */
|
||||
export type JsonValue =
|
||||
| null
|
||||
| boolean
|
||||
| number
|
||||
| string
|
||||
| ReadonlyArray<JsonValue>
|
||||
| { readonly [key: string]: JsonValue }
|
||||
|
||||
/** Additional JSON metadata stored with a cassette. */
|
||||
export type CassetteMetadata = Readonly<Record<string, JsonValue>>
|
||||
|
||||
/** The normalized HTTP request representation used for matching. */
|
||||
export interface RequestSnapshot {
|
||||
readonly method: string
|
||||
readonly url: string
|
||||
readonly headers: Record<string, string>
|
||||
readonly body: string
|
||||
}
|
||||
|
||||
/** Returns whether an incoming HTTP request matches a recorded request. */
|
||||
export type RequestMatcher = (incoming: RequestSnapshot, recorded: RequestSnapshot) => boolean
|
||||
|
||||
/** Additive redaction and header-preservation policy. */
|
||||
export interface RedactOptions {
|
||||
readonly headers?: ReadonlyArray<string>
|
||||
readonly allowRequestHeaders?: ReadonlyArray<string>
|
||||
readonly allowResponseHeaders?: ReadonlyArray<string>
|
||||
readonly queryParameters?: ReadonlyArray<string>
|
||||
readonly jsonFields?: ReadonlyArray<string>
|
||||
readonly url?: (url: string) => string
|
||||
readonly body?: (body: string) => string
|
||||
}
|
||||
|
||||
/** Options shared by HTTP recorder layers. */
|
||||
export interface RecorderOptions {
|
||||
readonly directory?: string
|
||||
readonly metadata?: CassetteMetadata
|
||||
readonly redact?: RedactOptions
|
||||
readonly match?: RequestMatcher
|
||||
}
|
||||
|
||||
/** Recorder configuration for Effect socket and WebSocket layers. */
|
||||
export type SocketRecorderOptions = Omit<RecorderOptions, "match">
|
||||
|
||||
export * as Api from "./api.js"
|
||||
Loading…
Add table
Add a link
Reference in a new issue