MCPcopy Create free account
hub / github.com/Effect-TS/effect / extractResponseContent

Function extractResponseContent

packages/effect/src/unstable/httpapi/HttpApi.ts:305–326  ·  view source on GitHub ↗
(
  schemas: Array<Schema.Top>,
  getStatus: (schema: Schema.Constraint) => number
)

Source from the content-addressed store, hash-verified

303// -------------------------------------------------------------------------------------
304
305const extractResponseContent = (
306 schemas: Array<Schema.Top>,
307 getStatus: (schema: Schema.Constraint) => number
308): ReadonlyMap<number, [Schema.Top, ...Array<Schema.Top>]> => {
309 const map = new Map<number, [Schema.Top, ...Array<Schema.Top>]>()
310
311 schemas.forEach(add)
312
313 return map
314
315 function add(schema: Schema.Top) {
316 const body = HttpApiSchema.isWithHeaders(schema) ? schema.schema : schema
317 if (HttpApiSchema.isStreamSchema(body)) return
318 const status = getStatus(schema)
319 const schemas = map.get(status)
320 if (schemas === undefined) {
321 map.set(status, [schema])
322 } else {
323 schemas.push(schema)
324 }
325 }
326}
327
328/**
329 * Adds additional schemas to components/schemas.

Callers 1

reflectFunction · 0.85

Calls 1

forEachMethod · 0.65

Tested by

no test coverage detected