feat(http-recorder): prepare public beta release (#31018)
This commit is contained in:
parent
ba57718b05
commit
54f4974546
36 changed files with 2254 additions and 690 deletions
|
|
@ -1,4 +1,21 @@
|
|||
import { Schema } from "effect"
|
||||
import type {
|
||||
CassetteMetadata,
|
||||
HttpInteraction,
|
||||
RequestSnapshot,
|
||||
ResponseSnapshot,
|
||||
WebSocketEvent,
|
||||
WebSocketInteraction,
|
||||
} from "./types.js"
|
||||
|
||||
export type {
|
||||
CassetteMetadata,
|
||||
HttpInteraction,
|
||||
RequestSnapshot,
|
||||
ResponseSnapshot,
|
||||
WebSocketEvent,
|
||||
WebSocketInteraction,
|
||||
} from "./types.js"
|
||||
|
||||
export const RequestSnapshotSchema = Schema.Struct({
|
||||
method: Schema.String,
|
||||
|
|
@ -6,7 +23,6 @@ export const RequestSnapshotSchema = Schema.Struct({
|
|||
headers: Schema.Record(Schema.String, Schema.String),
|
||||
body: Schema.String,
|
||||
})
|
||||
export type RequestSnapshot = Schema.Schema.Type<typeof RequestSnapshotSchema>
|
||||
|
||||
export const ResponseSnapshotSchema = Schema.Struct({
|
||||
status: Schema.Number,
|
||||
|
|
@ -14,23 +30,28 @@ export const ResponseSnapshotSchema = Schema.Struct({
|
|||
body: Schema.String,
|
||||
bodyEncoding: Schema.optional(Schema.Literals(["text", "base64"])),
|
||||
})
|
||||
export type ResponseSnapshot = Schema.Schema.Type<typeof ResponseSnapshotSchema>
|
||||
|
||||
export const CassetteMetadataSchema = Schema.Record(Schema.String, Schema.Unknown)
|
||||
export type CassetteMetadata = Schema.Schema.Type<typeof CassetteMetadataSchema>
|
||||
|
||||
export const HttpInteractionSchema = Schema.Struct({
|
||||
transport: Schema.tag("http"),
|
||||
request: RequestSnapshotSchema,
|
||||
response: ResponseSnapshotSchema,
|
||||
})
|
||||
export type HttpInteraction = Schema.Schema.Type<typeof HttpInteractionSchema>
|
||||
|
||||
export const WebSocketFrameSchema = Schema.Union([
|
||||
Schema.Struct({ kind: Schema.tag("text"), body: Schema.String }),
|
||||
Schema.Struct({ kind: Schema.tag("binary"), body: Schema.String, bodyEncoding: Schema.Literal("base64") }),
|
||||
export const WebSocketEventSchema = Schema.Union([
|
||||
Schema.Struct({
|
||||
direction: Schema.Literals(["client", "server"]),
|
||||
kind: Schema.tag("text"),
|
||||
body: Schema.String,
|
||||
}),
|
||||
Schema.Struct({
|
||||
direction: Schema.Literals(["client", "server"]),
|
||||
kind: Schema.tag("binary"),
|
||||
body: Schema.String,
|
||||
bodyEncoding: Schema.Literal("base64"),
|
||||
}),
|
||||
])
|
||||
export type WebSocketFrame = Schema.Schema.Type<typeof WebSocketFrameSchema>
|
||||
|
||||
export const WebSocketInteractionSchema = Schema.Struct({
|
||||
transport: Schema.tag("websocket"),
|
||||
|
|
@ -38,10 +59,8 @@ export const WebSocketInteractionSchema = Schema.Struct({
|
|||
url: Schema.String,
|
||||
headers: Schema.Record(Schema.String, Schema.String),
|
||||
}),
|
||||
client: Schema.Array(WebSocketFrameSchema),
|
||||
server: Schema.Array(WebSocketFrameSchema),
|
||||
events: Schema.Array(WebSocketEventSchema),
|
||||
})
|
||||
export type WebSocketInteraction = Schema.Schema.Type<typeof WebSocketInteractionSchema>
|
||||
|
||||
export const InteractionSchema = Schema.Union([HttpInteractionSchema, WebSocketInteractionSchema]).pipe(
|
||||
Schema.toTaggedUnion("transport"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue