opencode-agent[bot] 4 месяцев назад
Родитель
Сommit
4fc538378d

+ 7 - 9
packages/http-recorder/README.md

@@ -34,9 +34,7 @@ const program = Effect.gen(function* () {
 Effect.runPromise(program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one"))))
 
 // Record. Hits the upstream and writes the cassette.
-Effect.runPromise(
-  program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one", { mode: "record" }))),
-)
+Effect.runPromise(program.pipe(Effect.provide(HttpRecorder.cassetteLayer("users/get-one", { mode: "record" }))))
 ```
 
 Set the mode from the environment in your test setup:
@@ -190,12 +188,12 @@ const audit = Effect.gen(function* () {
 
 ```ts
 type RecordReplayOptions = {
-  mode?: "record" | "replay" | "passthrough"   // default: "replay"
-  directory?: string                            // default: <cwd>/test/fixtures/recordings
-  metadata?: Record<string, unknown>            // merged into cassette.metadata
-  redactor?: Redactor                           // default: Redactor.defaults()
-  dispatch?: "match" | "sequential"             // default: "match"
-  match?: (incoming, recorded) => boolean       // custom matcher
+  mode?: "record" | "replay" | "passthrough" // default: "replay"
+  directory?: string // default: <cwd>/test/fixtures/recordings
+  metadata?: Record<string, unknown> // merged into cassette.metadata
+  redactor?: Redactor // default: Redactor.defaults()
+  dispatch?: "match" | "sequential" // default: "match"
+  match?: (incoming, recorded) => boolean // custom matcher
 }
 ```
 

+ 0 - 1
packages/http-recorder/src/cassette.ts

@@ -111,4 +111,3 @@ export const layer = (options: { readonly directory?: string } = {}) =>
       return Service.of({ path: pathFor, read, write, append, exists, list, scan: cassetteSecretFindings })
     }),
   )
-

+ 8 - 1
packages/http-recorder/src/effect.ts

@@ -44,7 +44,14 @@ const decodeResponseBody = (snapshot: ResponseSnapshot) =>
   snapshot.bodyEncoding === "base64" ? Buffer.from(snapshot.body, "base64") : snapshot.body
 
 export const redactedErrorRequest = (request: HttpClientRequest.HttpClientRequest) =>
-  HttpClientRequest.makeWith(request.method, redactUrl(request.url), UrlParams.empty, Option.none(), Headers.empty, HttpBody.empty)
+  HttpClientRequest.makeWith(
+    request.method,
+    redactUrl(request.url),
+    UrlParams.empty,
+    Option.none(),
+    Headers.empty,
+    HttpBody.empty,
+  )
 
 const transportError = (request: HttpClientRequest.HttpClientRequest, description: string) =>
   new HttpClientError.HttpClientError({

+ 9 - 1
packages/http-recorder/src/index.ts

@@ -1,4 +1,12 @@
-export type { CassetteMetadata, HttpInteraction, Interaction, RequestSnapshot, ResponseSnapshot, WebSocketFrame, WebSocketInteraction } from "./schema"
+export type {
+  CassetteMetadata,
+  HttpInteraction,
+  Interaction,
+  RequestSnapshot,
+  ResponseSnapshot,
+  WebSocketFrame,
+  WebSocketInteraction,
+} from "./schema"
 export { hasCassetteSync } from "./storage"
 export { defaultMatcher, type RequestMatcher } from "./matching"
 export { cassetteSecretFindings, redactHeaders, redactUrl, type SecretFinding } from "./redaction"

+ 3 - 1
packages/http-recorder/src/recorder.ts

@@ -51,7 +51,9 @@ export const makeReplayState = <T>(
         if (used === 0) return
         const interactions = yield* load.pipe(Effect.orDie)
         if (used < interactions.length)
-          yield* Effect.die(new Error(`Unused recorded interactions in ${name}: used ${used} of ${interactions.length}`))
+          yield* Effect.die(
+            new Error(`Unused recorded interactions in ${name}: used ${used} of ${interactions.length}`),
+          )
       }),
     )