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

Function isSingleStringType

packages/platform/src/HttpApiBuilder.ts:610–635  ·  view source on GitHub ↗
(ast: AST.AST, key?: PropertyKey)

Source from the content-addressed store, hash-verified

608}
609
610function isSingleStringType(ast: AST.AST, key?: PropertyKey): boolean {
611 switch (ast._tag) {
612 case "StringKeyword":
613 case "Literal":
614 case "TemplateLiteral":
615 case "Enums":
616 return true
617 case "TypeLiteral": {
618 if (key !== undefined) {
619 const ps = ast.propertySignatures.find((ps) => ps.name === key)
620 return ps !== undefined
621 ? isSingleStringType(ps.type, key)
622 : ast.indexSignatures.some((is) => Schema.is(Schema.make(is.parameter))(key) && isSingleStringType(is.type))
623 }
624 return false
625 }
626 case "Union":
627 return ast.types.some((type) => isSingleStringType(type, key))
628 case "Suspend":
629 return isSingleStringType(ast.f(), key)
630 case "Refinement":
631 case "Transformation":
632 return isSingleStringType(ast.from, key)
633 }
634 return false
635}
636
637/**
638 * Normalizes the url parameters so that if a key is expected to be an array,

Callers 1

normalizeUrlParamsFunction · 0.85

Calls 3

isMethod · 0.65
makeMethod · 0.65
fMethod · 0.65

Tested by

no test coverage detected