@useairfoil/effect-vcr 0.4.2 → 0.4.4

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.
Files changed (34) hide show
  1. package/README.md +15 -5
  2. package/dist/{cassette-store-CnXX5OLB.js → cassette-store-BF9e0rz3.js} +5 -7
  3. package/dist/cassette-store-BF9e0rz3.js.map +1 -0
  4. package/dist/{cassette-store-BunkvLoV.d.ts → cassette-store-BMtcjh5h.d.ts} +29 -5
  5. package/dist/cassette-store.d.ts +2 -2
  6. package/dist/cassette-store.js +2 -1
  7. package/dist/{file-system-cassette-store-LXpwwrw3.d.ts → file-system-cassette-store-ClYAuH7U.d.ts} +3 -3
  8. package/dist/{file-system-cassette-store-zWkrhhlO.js → file-system-cassette-store-CyOsu3z5.js} +3 -3
  9. package/dist/{file-system-cassette-store-zWkrhhlO.js.map → file-system-cassette-store-CyOsu3z5.js.map} +1 -1
  10. package/dist/file-system-cassette-store.d.ts +3 -3
  11. package/dist/file-system-cassette-store.js +4 -3
  12. package/dist/index.d.ts +5 -5
  13. package/dist/index.js +6 -6
  14. package/dist/types-DMuz_JGd.js +45 -0
  15. package/dist/types-DMuz_JGd.js.map +1 -0
  16. package/dist/types-XZehMu_v.d.ts +138 -0
  17. package/dist/types.d.ts +2 -2
  18. package/dist/types.js +2 -2
  19. package/dist/{vcr-http-client-BaMxQun5.js → vcr-http-client-Ba0WYPV9.js} +143 -66
  20. package/dist/vcr-http-client-Ba0WYPV9.js.map +1 -0
  21. package/dist/{vcr-http-client-aedmnq0C.d.ts → vcr-http-client-BveeoOoW.d.ts} +4 -4
  22. package/dist/vcr-http-client.d.ts +3 -3
  23. package/dist/vcr-http-client.js +4 -3
  24. package/dist/{vitest-state-BOynp4Va.js → vitest-state-CiW5dzXZ.js} +1 -1
  25. package/dist/{vitest-state-BOynp4Va.js.map → vitest-state-CiW5dzXZ.js.map} +1 -1
  26. package/package.json +6 -5
  27. package/src/cassette-store.ts +15 -11
  28. package/src/sanitize.ts +166 -48
  29. package/src/types.ts +40 -26
  30. package/src/vcr-http-client.ts +33 -30
  31. package/dist/cassette-store-CnXX5OLB.js.map +0 -1
  32. package/dist/types-BsuPrIpu.js +0 -1
  33. package/dist/types-DWwkMzxG.d.ts +0 -85
  34. package/dist/vcr-http-client-BaMxQun5.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"vcr-http-client-BaMxQun5.js","names":["record: Record<string, string>","record","filtered: Record<string, string>","next: Record<string, unknown>","record: Record<string, string>","record","next: Cassette"],"sources":["../src/sanitize.ts","../src/vcr-http-client.ts"],"sourcesContent":["import { Effect, Option } from \"effect\";\nimport stableStringify from \"json-stable-stringify\";\n\nimport type { VcrRequest, VcrResponse } from \"./types\";\n\n/**\n * Normalize header names to match HttpClient's lowercase behavior.\n */\nconst normalizeHeaderKey = (key: string) => key.toLowerCase();\n\n/**\n * Canonicalize headers: lowercase keys and stable ordering.\n */\nconst toHeaderRecord = (headers?: Record<string, string>) => {\n if (!headers) return undefined;\n const entries = Object.entries(headers).map(\n ([key, value]) => [normalizeHeaderKey(key), value] as const,\n );\n entries.sort(([a], [b]) => a.localeCompare(b));\n const record: Record<string, string> = {};\n for (const [key, value] of entries) {\n record[key] = value;\n }\n return record;\n};\n\n/**\n * Remove specified header names (case-insensitive).\n */\nconst omitHeaderKeys = (\n headers: Record<string, string> | undefined,\n ignore: ReadonlyArray<string> | undefined,\n): Option.Option<Record<string, string>> => {\n if (!headers) return Option.none();\n if (!ignore || ignore.length === 0) return Option.some(headers);\n const ignoreSet = new Set(ignore.map(normalizeHeaderKey));\n const filtered: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (!ignoreSet.has(normalizeHeaderKey(key))) {\n filtered[key] = value;\n }\n }\n return Option.some(filtered);\n};\n\n/**\n * Best-effort JSON parse; returns undefined for non-JSON bodies.\n */\nconst tryParseJson = Option.liftThrowable((input: string) => JSON.parse(input));\n\n/**\n * Recursively drop keys from JSON objects to build stable request keys.\n */\nconst stripKeys = (value: unknown, ignore: Set<string>): unknown => {\n if (Array.isArray(value)) {\n return value.map((item) => stripKeys(item, ignore));\n }\n if (value && typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n const next: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(record)) {\n if (!ignore.has(key)) {\n next[key] = stripKeys(entry, ignore);\n }\n }\n return next;\n }\n return value;\n};\n\n/**\n * Remove JSON keys from a string body when possible.\n */\nconst omitBodyKeys = (\n body: string | undefined,\n ignore: ReadonlyArray<string> | undefined,\n): Option.Option<string> => {\n if (!body) return Option.none();\n return Option.some(\n tryParseJson(body).pipe(\n Option.match({\n onNone: () => body,\n onSome: (parsed) => {\n if (!ignore || ignore.length === 0) {\n return stableStringify(parsed) ?? body;\n }\n const ignoreSet = new Set(ignore);\n return stableStringify(stripKeys(parsed, ignoreSet)) ?? body;\n },\n }),\n ),\n );\n};\n\n/**\n * Normalize request for matching: header canonicalization + JSON body filtering.\n */\nexport const sanitizeRequest = (\n request: VcrRequest,\n options: {\n readonly ignoreHeaders?: ReadonlyArray<string>;\n readonly ignoreBodyKeys?: ReadonlyArray<string>;\n },\n): VcrRequest => {\n const filteredHeaders = omitHeaderKeys(request.headers, options.ignoreHeaders);\n return {\n ...request,\n headers: toHeaderRecord(Option.getOrUndefined(filteredHeaders)),\n body: Option.getOrUndefined(omitBodyKeys(request.body, options.ignoreBodyKeys)),\n };\n};\n\n/**\n * Compute the stable request key used for cassette lookups.\n */\nexport const buildRequestKey = (\n request: VcrRequest,\n options: {\n readonly ignoreHeaders?: ReadonlyArray<string>;\n readonly ignoreBodyKeys?: ReadonlyArray<string>;\n },\n): Effect.Effect<string> =>\n Effect.sync(() => {\n const sanitized = sanitizeRequest(request, {\n ignoreHeaders: options.ignoreHeaders,\n ignoreBodyKeys: options.ignoreBodyKeys,\n });\n return (\n stableStringify({\n method: sanitized.method.toUpperCase(),\n url: sanitized.url,\n headers: sanitized.headers ?? {},\n body: sanitized.body ?? \"\",\n }) ??\n JSON.stringify({\n method: sanitized.method.toUpperCase(),\n url: sanitized.url,\n headers: sanitized.headers ?? {},\n body: sanitized.body ?? \"\",\n })\n );\n });\n\n/**\n * Remove sensitive request data before persisting to a cassette.\n */\nexport const redactRequest = (\n request: VcrRequest,\n options: {\n readonly redactHeaders?: ReadonlyArray<string>;\n readonly redactBodyKeys?: ReadonlyArray<string>;\n },\n): VcrRequest => ({\n ...request,\n headers: Option.getOrUndefined(omitHeaderKeys(request.headers, options.redactHeaders)),\n body: Option.getOrUndefined(omitBodyKeys(request.body, options.redactBodyKeys)),\n});\n\n/**\n * Remove sensitive response data before persisting to a cassette.\n */\nexport const redactResponse = (\n response: VcrResponse,\n options: {\n readonly redactHeaders?: ReadonlyArray<string>;\n readonly redactBodyKeys?: ReadonlyArray<string>;\n },\n): VcrResponse => ({\n ...response,\n headers: Option.getOrUndefined(omitHeaderKeys(response.headers, options.redactHeaders)),\n body: Option.getOrElse(omitBodyKeys(response.body, options.redactBodyKeys), () => response.body),\n});\n","import { Config, Data, Effect, Option, Path } from \"effect\";\nimport {\n HttpClient,\n HttpClientError,\n type HttpClientRequest,\n HttpClientResponse,\n} from \"effect/unstable/http\";\n\nimport type { Cassette, CassetteFile, VcrConfig, VcrEntry, VcrRequest, VcrResponse } from \"./types\";\n\nimport { CassetteStore, type CassetteStoreService, createEmptyCassette } from \"./cassette-store\";\nimport { buildRequestKey, redactRequest, redactResponse } from \"./sanitize\";\nimport { getVitestState } from \"./vitest-state\";\n\n/**\n * Decoder for Uint8Array request bodies when building cassette keys.\n */\nconst decoder = new TextDecoder();\n\nexport class VcrHttpClientError extends Data.TaggedError(\"VcrHttpClientError\")<{\n readonly message: string;\n readonly cause?: unknown;\n}> {}\n\nconst toCassetteFileName = (name: string): string =>\n name.endsWith(\".cassette\") ? name : `${name}.cassette`;\n\n/**\n * Resolve the cassette file name and export key.\n *\n * If explicit cassetteName are provided, use them and default to\n * the \"default\" export. Otherwise infer from Vitest state:\n * - <file-name>.cassette file name\n * - export key = current test name (describe > test)\n */\nconst resolveCassetteLocation = Effect.fnUntraced(function* (config: VcrConfig) {\n const path = yield* Path.Path;\n if (config.cassetteName) {\n return {\n name: toCassetteFileName(config.cassetteName),\n exportKey: \"default\",\n };\n }\n\n const { testPath, currentTestName } = getVitestState();\n if (!testPath || !currentTestName) {\n return yield* Effect.fail(\n new VcrHttpClientError({\n message:\n \"VCR cassette path could not be inferred. Provide cassetteName when not running in Vitest.\",\n }),\n );\n }\n\n const fileName = path.basename(testPath, \".ts\");\n const cassetteName = `${fileName}.cassette`;\n\n return {\n name: cassetteName,\n exportKey: currentTestName,\n };\n});\n\n/**\n * Apply defaults for common VCR behavior while preserving explicit overrides.\n */\nconst normalizeConfig = (config: VcrConfig): VcrConfig => ({\n vcrName: config.vcrName,\n cassetteName: config.cassetteName,\n mode: config.mode ?? \"auto\",\n matchIgnore: {\n requestHeaders: [\"authorization\"],\n ...config.matchIgnore,\n },\n redact: {\n requestHeaders: [\"authorization\"],\n ...config.redact,\n },\n match: config.match,\n});\n\nconst AckDisableVcrConfig = Config.option(Config.string(\"ACK_DISABLE_VCR\")).pipe(\n Config.map((value) =>\n Option.match(value, {\n onNone: () => new Set<string>(),\n onSome: (raw) =>\n raw === \"*\"\n ? \"*\"\n : new Set(\n raw\n .split(\",\")\n .map((segment) => segment.trim().toLowerCase())\n .filter((segment) => segment.length > 0),\n ),\n }),\n ),\n);\n\nconst shouldDisableVcr = (name: string | undefined, disabled: \"*\" | Set<string>): boolean => {\n if (disabled === \"*\") return true;\n if (!name) return false;\n const normalized = name.trim().toLowerCase();\n return disabled.has(normalized);\n};\n\n/**\n * Convert store or replay failures into HttpClient transport errors.\n */\nconst toRequestError = (\n request: HttpClientRequest.HttpClientRequest,\n cause: unknown,\n description?: string,\n) =>\n new HttpClientError.HttpClientError({\n reason: new HttpClientError.TransportError({\n request,\n cause,\n description,\n }),\n });\n\n/**\n * Convert header map to a plain record for JSON persistence.\n */\nconst recordFromHeaders = (headers: Record<string, string>) => {\n const record: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n record[key] = value;\n }\n return record;\n};\n\n/**\n * Serialize an Effect HttpClientRequest into a cassette request shape.\n *\n * Note: some body variants (Stream, FormData) are not safely serializable\n * without consuming the body, so we store placeholders to avoid breaking\n * live requests.\n */\nconst toVcrRequest = (request: HttpClientRequest.HttpClientRequest): VcrRequest => {\n const headers = recordFromHeaders(request.headers as Record<string, string>);\n const body = (() => {\n switch (request.body._tag) {\n case \"Empty\":\n return \"\";\n case \"Uint8Array\":\n return decoder.decode(request.body.body);\n case \"Raw\": {\n const raw = request.body.body as unknown;\n if (typeof raw === \"string\") return raw;\n if (raw instanceof Uint8Array) return decoder.decode(raw);\n try {\n return JSON.stringify(raw);\n } catch {\n return \"[raw]\";\n }\n }\n case \"FormData\":\n return \"[form-data]\";\n case \"Stream\":\n return \"[stream]\";\n }\n })();\n\n return {\n method: request.method,\n url: request.url,\n headers,\n body,\n };\n};\n\n/**\n * Serialize an Effect HttpClientResponse into a cassette response shape.\n */\nconst toVcrResponse = (\n response: HttpClientResponse.HttpClientResponse,\n body: string,\n): VcrResponse => ({\n status: response.status,\n body,\n headers: recordFromHeaders(response.headers as Record<string, string>),\n});\n\n/**\n * Load a cassette and map store errors into HttpClient errors.\n */\nconst readCassetteFile = (\n store: CassetteStoreService,\n name: string,\n request: HttpClientRequest.HttpClientRequest,\n) => store.load(name).pipe(Effect.mapError((error) => toRequestError(request, error)));\n\n/**\n * Load a cassette or initialize a new one if missing.\n */\nconst loadOrInitCassetteFile = (\n store: CassetteStoreService,\n name: string,\n request: HttpClientRequest.HttpClientRequest,\n) => store.loadOrInit(name).pipe(Effect.mapError((error) => toRequestError(request, error)));\n\n/**\n * Persist the updated cassette.\n */\nconst saveCassetteFile = (\n store: CassetteStoreService,\n name: string,\n cassette: CassetteFile,\n request: HttpClientRequest.HttpClientRequest,\n) => store.save(name, cassette).pipe(Effect.mapError((error) => toRequestError(request, error)));\n\n/**\n * Load a named cassette export from the file, or return a fresh empty cassette.\n */\nconst readCassetteExport = (\n store: CassetteStoreService,\n name: string,\n exportKey: string,\n request: HttpClientRequest.HttpClientRequest,\n) =>\n readCassetteFile(store, name, request).pipe(\n Effect.flatMap((file) => {\n const found = file.exports[exportKey];\n if (found) return Effect.succeed(found);\n return createEmptyCassette();\n }),\n );\n\n/**\n * Locate a cassette entry by custom matcher or stable request key.\n */\nconst findEntry = (\n request: VcrRequest,\n cassette: Cassette,\n config: VcrConfig,\n): Effect.Effect<VcrEntry | undefined> => {\n if (config.match) {\n return Effect.succeed(\n Object.values(cassette.entries).find((entry) => config.match?.(request, entry)),\n );\n }\n return buildRequestKey(request, {\n ignoreHeaders: config.matchIgnore?.requestHeaders,\n ignoreBodyKeys: config.matchIgnore?.requestBodyKeys,\n }).pipe(Effect.map((key) => cassette.entries[key]));\n};\n\nconst replayResponse = (\n request: HttpClientRequest.HttpClientRequest,\n entry: VcrEntry,\n): HttpClientResponse.HttpClientResponse => {\n const web = new Response(entry.response.body, {\n status: entry.response.status,\n headers: entry.response.headers,\n });\n return HttpClientResponse.fromWeb(request, web);\n};\n\n/**\n * Replay a response from cassette data using HttpClientResponse.fromWeb.\n */\nconst replay = (\n store: CassetteStoreService,\n request: HttpClientRequest.HttpClientRequest,\n vcrRequest: VcrRequest,\n config: VcrConfig,\n name: string,\n exportKey: string,\n) =>\n readCassetteExport(store, name, exportKey, request).pipe(\n Effect.flatMap((cassette) =>\n findEntry(vcrRequest, cassette, config).pipe(\n Effect.flatMap((entry) => {\n if (!entry) {\n return Effect.fail(\n new HttpClientError.HttpClientError({\n reason: new HttpClientError.TransportError({\n request,\n description: `VCR replay missing entry for ${request.method} ${request.url}`,\n }),\n }),\n );\n }\n\n return Effect.succeed(replayResponse(request, entry));\n }),\n ),\n ),\n );\n\n/**\n * Record a live response into the cassette and return the original response.\n */\nconst record = Effect.fnUntraced(function* (\n store: CassetteStoreService,\n request: HttpClientRequest.HttpClientRequest,\n vcrRequest: VcrRequest,\n effect: Effect.Effect<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError>,\n config: VcrConfig,\n name: string,\n exportKey: string,\n): Effect.fn.Return<HttpClientResponse.HttpClientResponse, HttpClientError.HttpClientError> {\n const response = yield* effect;\n const body = yield* response.text;\n const vcrResponse = toVcrResponse(response, body);\n\n const sanitizedRequest = config.redact\n ? redactRequest(vcrRequest, {\n redactHeaders: config.redact.requestHeaders,\n redactBodyKeys: config.redact.requestBodyKeys,\n })\n : vcrRequest;\n const sanitizedResponse = config.redact\n ? redactResponse(vcrResponse, {\n redactHeaders: config.redact.responseHeaders,\n redactBodyKeys: config.redact.responseBodyKeys,\n })\n : vcrResponse;\n\n const file = yield* loadOrInitCassetteFile(store, name, request);\n const cassette = file.exports[exportKey] ?? (yield* createEmptyCassette());\n const key = yield* buildRequestKey(vcrRequest, {\n ignoreHeaders: config.matchIgnore?.requestHeaders,\n ignoreBodyKeys: config.matchIgnore?.requestBodyKeys,\n });\n const next: Cassette = {\n ...cassette,\n entries: {\n ...cassette.entries,\n [key]: {\n request: sanitizedRequest,\n response: sanitizedResponse,\n },\n },\n };\n const nextFile: CassetteFile = {\n ...file,\n exports: {\n ...file.exports,\n [exportKey]: next,\n },\n };\n yield* saveCassetteFile(store, name, nextFile, request);\n return response;\n});\n\n/**\n * Build a VCR-aware HttpClient that replays or records per config.\n */\nconst makeVcrHttpClient = Effect.fnUntraced(function* (config: VcrConfig = {}) {\n const live = yield* HttpClient.HttpClient;\n const normalized = normalizeConfig(config);\n\n const isCi = yield* Config.boolean(\"CI\").pipe(Config.withDefault(false));\n\n const disabledVcrs = yield* AckDisableVcrConfig;\n if (shouldDisableVcr(normalized.vcrName, disabledVcrs)) {\n return live;\n }\n\n const store = yield* CassetteStore;\n\n const { name, exportKey } = yield* resolveCassetteLocation(normalized);\n\n return live.pipe(\n HttpClient.transform(\n Effect.fnUntraced(function* (effect, request) {\n const vcrRequest = toVcrRequest(request);\n if (normalized.mode === \"replay\") {\n return yield* replay(store, request, vcrRequest, normalized, name, exportKey);\n }\n\n if (normalized.mode === \"record\") {\n return yield* record(store, request, vcrRequest, effect, normalized, name, exportKey);\n }\n\n const available = yield* store\n .exists(name)\n .pipe(Effect.mapError((error) => toRequestError(request, error)));\n\n if (!available) {\n if (isCi) {\n return yield* Effect.fail(\n new HttpClientError.HttpClientError({\n reason: new HttpClientError.TransportError({\n request,\n description: \"VCR cassette missing in CI for auto mode\",\n }),\n }),\n );\n }\n\n return yield* record(store, request, vcrRequest, effect, normalized, name, exportKey);\n }\n\n const cassette = yield* readCassetteExport(store, name, exportKey, request);\n const entry = yield* findEntry(vcrRequest, cassette, normalized);\n\n if (entry) {\n return replayResponse(request, entry);\n }\n\n return yield* record(store, request, vcrRequest, effect, normalized, name, exportKey);\n }),\n ),\n );\n});\n\n/**\n * Layer that provides a VCR-wrapped HttpClient.\n */\nexport const layer = (config: VcrConfig = {}) =>\n HttpClient.layerMergedContext(makeVcrHttpClient(config));\n"],"mappings":";;;;;;;;;;;AAQA,MAAM,sBAAsB,QAAgB,IAAI,aAAa;;;;AAK7D,MAAM,kBAAkB,YAAqC;AAC3D,KAAI,CAAC,QAAS,QAAO;CACrB,MAAM,UAAU,OAAO,QAAQ,QAAQ,CAAC,KACrC,CAAC,KAAK,WAAW,CAAC,mBAAmB,IAAI,EAAE,MAAM,CACnD;AACD,SAAQ,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;CAC9C,MAAMA,WAAiC,EAAE;AACzC,MAAK,MAAM,CAAC,KAAK,UAAU,QACzB,UAAO,OAAO;AAEhB,QAAOC;;;;;AAMT,MAAM,kBACJ,SACA,WAC0C;AAC1C,KAAI,CAAC,QAAS,QAAO,OAAO,MAAM;AAClC,KAAI,CAAC,UAAU,OAAO,WAAW,EAAG,QAAO,OAAO,KAAK,QAAQ;CAC/D,MAAM,YAAY,IAAI,IAAI,OAAO,IAAI,mBAAmB,CAAC;CACzD,MAAMC,W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