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

Function schemaFromArrayBuffer

packages/platform/src/HttpApiClient.ts:479–501  ·  view source on GitHub ↗
(
  ast: AST.AST,
  encoding: HttpApiSchema.Encoding
)

Source from the content-addressed store, hash-verified

477const parseJsonArrayBuffer = Schema.compose(StringFromArrayBuffer, parseJsonOrVoid)
478
479const schemaFromArrayBuffer = (
480 ast: AST.AST,
481 encoding: HttpApiSchema.Encoding
482): Schema.Schema<any, ArrayBuffer> => {
483 if (ast._tag === "Union") {
484 return Schema.Union(...ast.types.map((ast) => schemaFromArrayBuffer(ast, HttpApiSchema.getEncoding(ast, encoding))))
485 }
486 const schema = Schema.make(ast)
487 switch (encoding.kind) {
488 case "Json": {
489 return Schema.compose(parseJsonArrayBuffer, schema)
490 }
491 case "UrlParams": {
492 return Schema.compose(StringFromArrayBuffer, UrlParams.schemaParse(schema as any)) as any
493 }
494 case "Uint8Array": {
495 return Schema.compose(Uint8ArrayFromArrayBuffer, schema)
496 }
497 case "Text": {
498 return Schema.compose(StringFromArrayBuffer, schema)
499 }
500 }
501}
502
503const statusOrElse = (response: HttpClientResponse.HttpClientResponse) =>
504 Effect.fail(

Callers 1

schemaToResponseFunction · 0.85

Calls 2

mapMethod · 0.65
makeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…