MCPcopy Index your code
hub / github.com/Effect-TS/effect / schemaJson

Function schemaJson

packages/platform/src/internal/httpClientResponse.ts:158–178  ·  view source on GitHub ↗
(schema: Schema.Schema<A, I, R>, options?: ParseOptions | undefined)

Source from the content-addressed store, hash-verified

156
157/** @internal */
158export const schemaJson = <
159 R,
160 I extends {
161 readonly status?: number | undefined
162 readonly headers?: Readonly<Record<string, string>> | undefined
163 readonly body?: unknown | undefined
164 },
165 A
166>(schema: Schema.Schema<A, I, R>, options?: ParseOptions | undefined) => {
167 const parse = Schema.decodeUnknown(schema, options)
168 return (self: ClientResponse.HttpClientResponse): Effect.Effect<A, Error.ResponseError | ParseResult.ParseError, R> =>
169 Effect.flatMap(
170 self.json,
171 (body) =>
172 parse({
173 status: self.status,
174 headers: self.headers,
175 body
176 })
177 )
178}
179
180/** @internal */
181export const schemaNoBody = <

Callers

nothing calls this directly

Calls 1

parseFunction · 0.70

Tested by

no test coverage detected