MCPcopy Index your code
hub / github.com/anomalyco/opencode / declaredErrorFields

Function declaredErrorFields

packages/httpapi-codegen/src/index.ts:945–965  ·  view source on GitHub ↗
(schema: Schema.Top)

Source from the content-addressed store, hash-verified

943}
944
945function declaredErrorFields(schema: Schema.Top) {
946 if (!SchemaAST.isDeclaration(schema.ast) || schema.ast.annotations?.["~effect/Schema/Class"] === undefined) {
947 return undefined
948 }
949 const fields = schema.ast.typeParameters[0]
950 if (!SchemaAST.isObjects(fields) || fields.indexSignatures.length > 0) return undefined
951 const key = fields.propertySignatures.find((field) => field.name === "_tag" || field.name === "name")?.name
952 if (key !== "_tag" && key !== "name") return undefined
953 const tag = fields.propertySignatures.find((field) => field.name === key)?.type
954 if (tag === undefined || !SchemaAST.isLiteral(tag) || typeof tag.literal !== "string") return undefined
955 return {
956 key,
957 tag: tag.literal,
958 identifier: SchemaAST.resolveIdentifier(schema.ast) ?? tag.literal,
959 fields: fields.propertySignatures.flatMap((field) =>
960 field.name === key || typeof field.name !== "string"
961 ? []
962 : [[field.name, Schema.make(field.type), SchemaAST.isOptional(field.type)] as const],
963 ),
964 }
965}
966
967function isDataEnvelope(schema: Schema.Top) {
968 if (isStreamSchema(schema) || HttpApiSchema.isNoContent(schema.ast)) return false

Callers 3

assertPromiseEndpointFunction · 0.85
renderPromiseTypesFunction · 0.85
taggedErrorFieldsFunction · 0.85

Calls 2

findMethod · 0.65
makeMethod · 0.45

Tested by

no test coverage detected