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

Function extractPayloads

packages/platform/src/HttpApi.ts:395–433  ·  view source on GitHub ↗
(topAst: AST.AST)

Source from the content-addressed store, hash-verified

393}
394
395const extractPayloads = (topAst: AST.AST): ReadonlyMap<string, {
396 readonly encoding: HttpApiSchema.Encoding
397 readonly ast: AST.AST
398}> => {
399 const members = new Map<string, {
400 encoding: HttpApiSchema.Encoding
401 ast: AST.AST
402 }>()
403 function process(ast: AST.AST) {
404 if (ast._tag === "NeverKeyword") {
405 return
406 }
407 ast = AST.annotations(ast, {
408 ...HttpApiSchema.extractAnnotations(topAst.annotations),
409 ...ast.annotations
410 })
411 const encoding = HttpApiSchema.getEncoding(ast)
412 const contentType = HttpApiSchema.getMultipart(ast) || HttpApiSchema.getMultipartStream(ast)
413 ? "multipart/form-data"
414 : encoding.contentType
415 const current = members.get(contentType)
416 if (current === undefined) {
417 members.set(contentType, {
418 encoding,
419 ast
420 })
421 } else {
422 current.ast = AST.Union.make([current.ast, ast])
423 }
424 }
425 if (topAst._tag === "Union") {
426 for (const type of topAst.types) {
427 process(type)
428 }
429 } else {
430 process(topAst)
431 }
432 return members
433}
434
435const getDescriptionOrIdentifier = (ast: AST.PropertySignature | AST.AST): Option.Option<string> => {
436 const annotations = "to" in ast ?

Callers 1

reflectFunction · 0.85

Calls 1

processFunction · 0.70

Tested by

no test coverage detected