moonflower 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/openapi/analyzerModule/nodeParsers.cjs +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.cjs.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.d.ts.map +1 -1
- package/dist/openapi/analyzerModule/nodeParsers.mjs +243 -190
- package/dist/openapi/analyzerModule/nodeParsers.mjs.map +1 -1
- package/dist/openapi/analyzerModule/test/TestCase.d.ts +10 -0
- package/dist/openapi/analyzerModule/test/TestCase.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/openapi/analyzerModule/nodeParsers.ts +70 -2
- package/src/openapi/analyzerModule/test/TestCase.ts +10 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.data.ts +78 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.spec.ts +93 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeParsers.mjs","sources":["../../../src/openapi/analyzerModule/nodeParsers.ts"],"sourcesContent":["import {\n\tNode,\n\tPropertyAccessExpression,\n\tPropertyAssignment,\n\tPropertySignature,\n\tShorthandPropertyAssignment,\n\tSyntaxKind,\n\tts,\n\tType,\n\tTypeReferenceNode,\n} from 'ts-morph'\n\nimport { Logger } from '../../utils/logger'\nimport { OpenApiManager } from '../manager/OpenApiManager'\nimport { ShapeOfProperty, ShapeOfType, ShapeOfUnionEntry } from './types'\n\nconst implementationCache = new WeakMap<Node, Node>()\n\nexport const findNodeImplementation = (node: Node): Node => {\n\tconst cached = implementationCache.get(node)\n\tif (cached) {\n\t\treturn cached\n\t}\n\n\tif (node.getKind() === SyntaxKind.Identifier) {\n\t\tconst implementationNode = node.asKind(SyntaxKind.Identifier)!.getImplementations()[0]?.getNode()\n\t\tif (implementationNode) {\n\t\t\tconst implementationParentNode = implementationNode.getParent()!\n\t\t\tconst assignmentValueNode = implementationParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\n\t\tconst definitionNode = node.asKind(SyntaxKind.Identifier)!.getDefinitions()[0]?.getNode()\n\t\tif (definitionNode) {\n\t\t\tconst definitionParentNode = definitionNode.getParent()!\n\t\t\tconst assignmentValueNode = definitionParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\t\tthrow new Error('No implementation nor definition available')\n\t}\n\n\timplementationCache.set(node, node)\n\treturn node\n}\n\nexport const findPropertyAssignmentValueNode = (\n\tnode:\n\t\t| PropertyAssignment\n\t\t| TypeReferenceNode\n\t\t| PropertySignature\n\t\t| PropertyAccessExpression\n\t\t| ShorthandPropertyAssignment,\n): Node => {\n\tconst identifierChildren = node.getChildrenOfKind(SyntaxKind.Identifier)\n\tif (identifierChildren.length === 2) {\n\t\treturn findNodeImplementation(identifierChildren[1])\n\t}\n\tconst lastMatchingChild = node.getChildren().reverse()\n\treturn lastMatchingChild.find(\n\t\t(child) =>\n\t\t\tchild.getKind() !== SyntaxKind.GreaterThanToken &&\n\t\t\tchild.getKind() !== SyntaxKind.CommaToken &&\n\t\t\tchild.getKind() !== SyntaxKind.SemicolonToken,\n\t)!\n}\n\nexport const getTypeReferenceShape = (node: TypeReferenceNode): ShapeOfType['shape'] => {\n\tconst firstChild = node.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tif (firstChild.isKind(SyntaxKind.SyntaxList)) {\n\t\treturn getRecursiveNodeShape(firstChild.getFirstChild()!)\n\t} else {\n\t\treturn getRecursiveNodeShape(firstChild)\n\t}\n}\n\nexport const getRecursiveNodeShape = (nodeOrReference: Node): ShapeOfType['shape'] => {\n\tconst typeName = nodeOrReference.getSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\t// Undefined\n\tconst undefinedNode = node.asKind(SyntaxKind.UndefinedKeyword)\n\tif (undefinedNode) {\n\t\treturn 'undefined'\n\t}\n\n\t// Literal type\n\tconst literalNode = node.asKind(SyntaxKind.LiteralType)\n\tif (literalNode) {\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.TrueKeyword)) {\n\t\t\treturn 'true'\n\t\t}\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.FalseKeyword)) {\n\t\t\treturn 'false'\n\t\t}\n\t}\n\n\t// Boolean literal\n\tconst booleanLiteralNode =\n\t\tnode.asKind(SyntaxKind.BooleanKeyword) ||\n\t\tnode.asKind(SyntaxKind.TrueKeyword) ||\n\t\tnode.asKind(SyntaxKind.FalseKeyword)\n\tif (booleanLiteralNode) {\n\t\treturn 'boolean'\n\t}\n\n\t// String literal\n\tconst stringLiteralNode = node.asKind(SyntaxKind.StringKeyword) || node.asKind(SyntaxKind.StringLiteral)\n\tif (stringLiteralNode) {\n\t\treturn 'string'\n\t}\n\n\t// Number literal\n\tconst numberLiteralNode = node.asKind(SyntaxKind.NumberKeyword) || node.asKind(SyntaxKind.NumericLiteral)\n\tif (numberLiteralNode) {\n\t\treturn 'number'\n\t}\n\n\t// BigInt literal\n\tconst bigIntNode = node.asKind(SyntaxKind.BigIntKeyword) || node.asKind(SyntaxKind.BigIntLiteral)\n\tif (bigIntNode) {\n\t\treturn 'bigint'\n\t}\n\n\t// Type literal\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\tconst properties = typeLiteralNode\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getChildrenOfKind(SyntaxKind.PropertySignature)\n\n\t\tconst propertyShapes = properties.map((propNode) => {\n\t\t\tconst identifier = propNode.getFirstChildByKind(SyntaxKind.Identifier)!\n\t\t\tconst valueNode = findPropertyAssignmentValueNode(propNode)\n\t\t\tconst questionMarkToken = identifier.getNextSiblingIfKind(SyntaxKind.QuestionToken)\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier: identifier.getText(),\n\t\t\t\tshape: getRecursiveNodeShape(valueNode),\n\t\t\t\toptional: valueNode.getType().isNullable() || !!questionMarkToken,\n\t\t\t}\n\t\t})\n\t\treturn propertyShapes\n\t}\n\n\t// Type reference\n\tconst typeReferenceNode = node.asKind(SyntaxKind.TypeReference)\n\tif (typeReferenceNode) {\n\t\treturn getRecursiveNodeShape(typeReferenceNode.getFirstChild()!)\n\t}\n\n\t// Property access expression\n\tconst propertyAccessNode = node.asKind(SyntaxKind.PropertyAccessExpression)\n\tif (propertyAccessNode) {\n\t\tconst lastChild = findNodeImplementation(node.getLastChild()!)\n\t\treturn getProperTypeShape(lastChild.asKind(SyntaxKind.CallExpression)!.getReturnType(), lastChild)\n\t}\n\n\t// Union type\n\tconst unionTypeNode = node.asKind(SyntaxKind.UnionType)\n\tif (unionTypeNode) {\n\t\treturn getProperTypeShape(unionTypeNode.getType(), node)\n\t}\n\n\t// Typeof query\n\tconst typeQueryNode = node.asKind(SyntaxKind.TypeQuery)\n\tif (typeQueryNode) {\n\t\treturn getRecursiveNodeShape(typeQueryNode.getLastChild()!)\n\t}\n\n\t// Qualified name\n\tconst qualifiedNameNode = node.asKind(SyntaxKind.QualifiedName)\n\tif (qualifiedNameNode) {\n\t\treturn getRecursiveNodeShape(qualifiedNameNode.getLastChild()!)\n\t}\n\n\t// Call expression\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\treturn getProperTypeShape(callExpressionNode.getReturnType(), callExpressionNode)\n\t}\n\n\t// Await expression\n\tconst awaitExpressionNode = node.asKind(SyntaxKind.AwaitExpression)\n\tif (awaitExpressionNode) {\n\t\treturn getRecursiveNodeShape(awaitExpressionNode.getChildAtIndex(1)!)\n\t}\n\n\t// 'As' Expression\n\tconst asExpressionNode = node.asKind(SyntaxKind.AsExpression)\n\tif (asExpressionNode) {\n\t\treturn getRecursiveNodeShape(asExpressionNode.getChildAtIndex(2)!)\n\t}\n\n\t// TODO\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown node type: ${node.getKindName()}`)\n\treturn 'unknown_1'\n}\n\nexport const getShapeOfValidatorLiteral = (\n\tobjectLiteralNode: Node<ts.ObjectLiteralExpression>,\n): (ShapeOfProperty & { description: string; errorMessage: string })[] => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstChild()!\n\t\tconst identifierName = (() => {\n\t\t\tif (identifierNode.isKind(SyntaxKind.Identifier)) {\n\t\t\t\treturn identifierNode.getText()\n\t\t\t}\n\t\t\tif (identifierNode.isKind(SyntaxKind.StringLiteral)) {\n\t\t\t\treturn identifierNode.getLiteralText()\n\t\t\t}\n\t\t\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\t\t\tLogger.warn(`[${fileName}] Unknown identifier name: ${identifierNode.getText()}`)\n\t\t\treturn 'unknown_30'\n\t\t})()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst innerLiteralNode = findNodeImplementation(assignmentValueNode)\n\n\t\treturn {\n\t\t\trole: 'property' as const,\n\t\t\tidentifier: identifierName,\n\t\t\tshape: getValidatorPropertyShape(innerLiteralNode),\n\t\t\toptional: getValidatorPropertyOptionality(innerLiteralNode),\n\t\t\tdescription: getValidatorPropertyStringValue(innerLiteralNode, 'description'),\n\t\t\terrorMessage: getValidatorPropertyStringValue(innerLiteralNode, 'errorMessage'),\n\t\t}\n\t})\n\n\treturn properties || []\n}\n\nconst isZodCallExpression = (node: Node): boolean => {\n\tconst callExpression = node.asKind(SyntaxKind.CallExpression)\n\tif (!callExpression) {\n\t\treturn false\n\t}\n\tconst returnType = callExpression.getReturnType()\n\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\treturn typeName.startsWith('Zod')\n}\n\nconst getZodCallShape = (node: Node): ShapeOfType['shape'] => {\n\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\tconst returnType = callExpression.getReturnType()\n\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\n\tif (typeName === 'ZodNumber') {\n\t\treturn 'number'\n\t}\n\tif (typeName === 'ZodString') {\n\t\treturn 'string'\n\t}\n\tif (typeName === 'ZodBoolean') {\n\t\treturn 'boolean'\n\t}\n\tif (typeName === 'ZodBigInt') {\n\t\treturn 'bigint'\n\t}\n\n\tif (typeName === 'ZodObject') {\n\t\tconst argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()\n\t\tconst objectLiteral = argNode?.asKind(SyntaxKind.ObjectLiteralExpression)\n\t\tif (!objectLiteral) {\n\t\t\treturn 'unknown_zod_object'\n\t\t}\n\t\tconst syntaxList = objectLiteral.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\tif (!syntaxList) {\n\t\t\treturn []\n\t\t}\n\t\tconst properties = syntaxList.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\t\treturn properties.map((prop) => {\n\t\t\tconst identifier = prop.getFirstChildByKind(SyntaxKind.Identifier)!.getText()\n\t\t\tconst valueNode = prop.getLastChild()!\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier,\n\t\t\t\tshape: isZodCallExpression(valueNode)\n\t\t\t\t\t? getZodCallShape(valueNode)\n\t\t\t\t\t: getValidatorPropertyShape(valueNode),\n\t\t\t\toptional: false,\n\t\t\t}\n\t\t})\n\t}\n\n\tif (typeName === 'ZodArray') {\n\t\tconst argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()\n\t\tif (!argNode) {\n\t\t\treturn 'unknown_zod_array'\n\t\t}\n\t\tconst elementShape = isZodCallExpression(argNode)\n\t\t\t? getZodCallShape(argNode)\n\t\t\t: getValidatorPropertyShape(argNode)\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: elementShape,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown zod type: ${typeName}`)\n\treturn 'unknown_zod'\n}\n\nexport const getValidatorPropertyShape = (innerLiteralNode: Node): ShapeOfType['shape'] => {\n\t// Zod validator (e.g. z.number(), z.string(), z.object({...}), z.array(...))\n\tif (isZodCallExpression(innerLiteralNode)) {\n\t\treturn getZodCallShape(innerLiteralNode)\n\t}\n\n\t// Inline definition with `as Validator<...>` clause\n\tconst inlineValidatorAsExpression = innerLiteralNode\n\t\t.getParent()!\n\t\t.getFirstChildByKind(SyntaxKind.AsExpression)\n\tif (inlineValidatorAsExpression) {\n\t\tconst typeReference = inlineValidatorAsExpression.getLastChildByKind(SyntaxKind.TypeReference)!\n\t\treturn getTypeReferenceShape(typeReference)\n\t}\n\n\t// Variable with `: Validator<...>` clause\n\tconst childTypeReferenceNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.TypeReference)\n\tif (childTypeReferenceNode) {\n\t\treturn getTypeReferenceShape(childTypeReferenceNode)\n\t}\n\n\t// `RequiredParam<...>` inline call expression\n\tif (innerLiteralNode.getParent()!.getChildrenOfKind(SyntaxKind.SyntaxList).length >= 2) {\n\t\tconst typeNode = innerLiteralNode\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getFirstChild()!\n\t\treturn getRecursiveNodeShape(typeNode)\n\t}\n\n\t// `RequestParam | RequiredParam | OptionalParam` call expression\n\tconst childCallExpressionNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.CallExpression)\n\tif (childCallExpressionNode) {\n\t\tconst callExpressionArgument = findNodeImplementation(\n\t\t\tchildCallExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!.getFirstChild()!,\n\t\t)\n\n\t\t// Param is a type reference\n\t\tconst typeReferenceNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.TypeReference)!\n\t\tif (typeReferenceNode) {\n\t\t\treturn getProperTypeShape(typeReferenceNode.getType(), typeReferenceNode, [])\n\t\t}\n\n\t\tconst thingyNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.ObjectLiteralExpression)!\n\t\tif (thingyNode) {\n\t\t\treturn getValidatorPropertyShape(thingyNode)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.CallExpression) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.IntersectionType) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\t\tLogger.warn(`[${fileName}] Unknown call expression argument: ${callExpressionArgument.getKindName()}`)\n\t\treturn 'unknown_3'\n\t}\n\n\t// Attempting to infer type from `parse` function\n\tconst innerNodePropertyAssignments = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\tconst parsePropertyAssignment = innerNodePropertyAssignments.find((prop) => {\n\t\treturn prop.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === 'parse'\n\t})\n\tif (parsePropertyAssignment) {\n\t\tconst returnType = findPropertyAssignmentValueNode(parsePropertyAssignment)\n\t\t\t.asKind(SyntaxKind.ArrowFunction)!\n\t\t\t.getReturnType()\n\t\treturn getProperTypeShape(returnType, parsePropertyAssignment)\n\t}\n\n\t// Import statement\n\tconst importTypeNode = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\t?.getFirstChildByKind(SyntaxKind.ImportType)\n\tif (importTypeNode) {\n\t\tconst indexOfGreaterThanToken = importTypeNode\n\t\t\t.getLastChildByKind(SyntaxKind.GreaterThanToken)!\n\t\t\t.getChildIndex()\n\t\tconst targetSyntaxList = importTypeNode.getChildAtIndex(indexOfGreaterThanToken - 1)\n\t\treturn getRecursiveNodeShape(targetSyntaxList.getFirstChild()!)\n\t}\n\n\t// Intersection type with Validator\n\tconst intersectionType = innerLiteralNode.isKind(SyntaxKind.IntersectionType)\n\t\t? innerLiteralNode\n\t\t: innerLiteralNode.getParent()?.isKind(SyntaxKind.VariableDeclaration)\n\t\t\t? innerLiteralNode.getParent()?.getFirstChildByKind(SyntaxKind.IntersectionType)\n\t\t\t: null\n\n\tif (intersectionType) {\n\t\tconst validatorType = intersectionType.getFirstChildByKind(SyntaxKind.TypeReference)\n\t\tif (validatorType) {\n\t\t\treturn getTypeReferenceShape(validatorType)\n\t\t}\n\t}\n\n\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown import type node`)\n\n\treturn 'unknown_2'\n}\n\nexport const getValidatorPropertyOptionality = (node: Node): boolean => {\n\tif (isZodCallExpression(node)) {\n\t\treturn false\n\t}\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst identifierNode = callExpressionNode.getFirstChildByKind(SyntaxKind.Identifier)\n\t\tif (identifierNode?.getText() === 'OptionalParam') {\n\t\t\treturn true\n\t\t} else if (identifierNode?.getText() === 'RequiredParam') {\n\t\t\treturn false\n\t\t}\n\n\t\tconst syntaxListNode = callExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\tconst literalExpression = findNodeImplementation(syntaxListNode.getFirstChild()!)\n\t\treturn getValidatorPropertyOptionality(literalExpression)\n\t}\n\n\tconst syntaxListNode = node.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\treturn assignmentNodes.some((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tif (identifierName === 'optional') {\n\t\t\tconst value = findPropertyAssignmentValueNode(node)\n\t\t\treturn value.getKind() === SyntaxKind.TrueKeyword\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const getValidatorPropertyStringValue = (\n\tnodeOrReference: Node,\n\tname: 'description' | 'errorMessage',\n): string => {\n\tif (isZodCallExpression(nodeOrReference)) {\n\t\treturn ''\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst targetChild = callExpressionNode.getLastChildByKind(SyntaxKind.SyntaxList)!\n\t\treturn getValidatorPropertyStringValue(targetChild, name)\n\t}\n\n\tconst syntaxListNode = node.asKind(SyntaxKind.SyntaxList)\n\tif (syntaxListNode) {\n\t\tconst children = syntaxListNode.getChildren().map((c) => getValidatorPropertyStringValue(c, name))\n\t\treturn children.find((value) => !!value && value !== 'unknown_25') || ''\n\t}\n\n\tconst objectLiteralNode = node.asKind(SyntaxKind.ObjectLiteralExpression)\n\tif (objectLiteralNode) {\n\t\tconst values = getValuesOfObjectLiteral(objectLiteralNode)\n\t\tconst targetValue = values.find((value) => value.identifier === name)\n\t\tif (!targetValue) {\n\t\t\treturn ''\n\t\t}\n\t\tif (Array.isArray(targetValue.value)) {\n\t\t\treturn 'array'\n\t\t}\n\t\treturn targetValue.value || ''\n\t}\n\n\tconst intersectionTypeNode = node.asKind(SyntaxKind.IntersectionType)\n\tif (intersectionTypeNode) {\n\t\treturn (\n\t\t\tintersectionTypeNode\n\t\t\t\t.getTypeNodes()\n\t\t\t\t.flatMap((t) => getValidatorPropertyStringValue(t, name))\n\t\t\t\t.filter((v) => !!v && v !== 'unknown_25')[0] || 'unknown_27'\n\t\t)\n\t}\n\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\treturn getValidatorPropertyStringValue(typeLiteralNode.getFirstChildByKind(SyntaxKind.SyntaxList)!, name)\n\t}\n\n\tconst propertySignatureNode = node.asKind(SyntaxKind.PropertySignature)\n\tif (propertySignatureNode) {\n\t\tconst identifier = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tif (identifier.getText() === name) {\n\t\t\tconst targetNode = findPropertyAssignmentValueNode(propertySignatureNode).getFirstDescendantByKind(\n\t\t\t\tSyntaxKind.StringLiteral,\n\t\t\t)!\n\t\t\treturn targetNode.getLiteralText()\n\t\t}\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown property string value node ${node.getKindName()}`)\n\treturn 'unknown_25'\n}\n\nconst isPromise = (type: Type) => {\n\tconst symbol = type.getSymbol()\n\tif (!type.isObject() || !symbol) {\n\t\treturn false\n\t}\n\tconst args = type.getTypeArguments()\n\treturn symbol.getName() === 'Promise' && args.length === 1\n}\n\nexport const getProperTypeShape = (\n\ttypeOrPromise: Type,\n\tatLocation: Node,\n\tstack: Type[] = [],\n): ShapeOfType['shape'] => {\n\tconst typeName = typeOrPromise.getAliasSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst type = isPromise(typeOrPromise) ? typeOrPromise.getTypeArguments()[0] : typeOrPromise\n\n\tif (stack.some((previousType) => previousType === type)) {\n\t\treturn 'circular'\n\t}\n\n\tconst nextStack = stack.concat(type)\n\n\tif (type.getText() === 'void') {\n\t\treturn 'void'\n\t}\n\n\tif (type.isAny()) {\n\t\treturn 'any'\n\t}\n\n\tif (type.isUnknown()) {\n\t\treturn 'unknown'\n\t}\n\n\tif (type.isNull()) {\n\t\treturn 'null'\n\t}\n\n\tif (type.isUndefined()) {\n\t\treturn 'undefined'\n\t}\n\n\tif (type.isBoolean() || type.isBooleanLiteral()) {\n\t\treturn 'boolean'\n\t}\n\n\tif (type.isStringLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_string' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isNumberLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_number' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isString() || type.isTemplateLiteral()) {\n\t\treturn 'string'\n\t}\n\n\tif (type.isNumber()) {\n\t\treturn 'number'\n\t}\n\n\tif (type.getText() === 'bigint') {\n\t\treturn 'bigint'\n\t}\n\n\tif (type.isTuple()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'tuple' as const,\n\t\t\t\tshape: type.getTupleElements().map((t) => ({\n\t\t\t\t\trole: 'tuple_entry' as const,\n\t\t\t\t\tshape: getProperTypeShape(t, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t})),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isArray()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: getProperTypeShape(type.getArrayElementType()!, atLocation, nextStack),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst typeSymbolName = type.getSymbol()?.getName()\n\tif (type.isObject() && (typeSymbolName === 'Buffer' || typeSymbolName === 'Uint8Array')) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'buffer' as const,\n\t\t\t\tshape: 'buffer',\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && type.getProperties().length === 0) {\n\t\tconst targetType = type.getAliasTypeArguments()[1] ?? type.getStringIndexType()\n\t\tif (targetType) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'record' as const,\n\t\t\t\t\tshape: getProperTypeShape(targetType, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t}\n\n\tif (type.isObject()) {\n\t\tif (type.getText() === 'Date') {\n\t\t\treturn 'Date'\n\t\t}\n\t\treturn type\n\t\t\t.getProperties()\n\t\t\t.map((prop) => {\n\t\t\t\tconst valueDeclaration = prop.getValueDeclaration() || prop.getDeclarations()[0]!\n\t\t\t\tif (!valueDeclaration) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst valueDeclarationNode =\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertySignature) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertyAssignment) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n\t\t\t\tif (!valueDeclarationNode) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst isOptional = prop.getTypeAtLocation(atLocation).isNullable()\n\n\t\t\t\tconst shape = getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack)\n\t\t\t\treturn {\n\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\tshape: shape,\n\t\t\t\t\toptional: isOptional,\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((val) => val.shape !== 'undefined')\n\t}\n\n\tif (type.isUnion()) {\n\t\tconst unfilteredShapes: ShapeOfUnionEntry[] = type.getUnionTypes().map((type) => ({\n\t\t\trole: 'union_entry',\n\t\t\tshape: getProperTypeShape(type, atLocation, nextStack),\n\t\t\toptional: false,\n\t\t}))\n\n\t\tconst dedupedShapes = unfilteredShapes.filter(\n\t\t\t(type, index, arr) => !arr.find((dup, dupIndex) => dup.shape === type.shape && dupIndex > index),\n\t\t)\n\t\tconst isNullable = dedupedShapes.some((shape) => shape.shape === 'undefined')\n\t\tconst shapes = dedupedShapes.filter((shape) => shape.shape !== 'undefined')\n\t\tif (shapes.length === 1) {\n\t\t\treturn shapes[0].shape\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'union',\n\t\t\t\tshape: shapes,\n\t\t\t\toptional: isNullable,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isIntersection()) {\n\t\tconst children = type.getIntersectionTypes()\n\t\tconst shapesOfChildren = children\n\t\t\t.map((child) => getProperTypeShape(child, atLocation, nextStack))\n\t\t\t.filter((shape) => typeof shape !== 'string') as ShapeOfProperty[][]\n\t\treturn shapesOfChildren.reduce<ShapeOfType[]>((total, current) => [...total, ...current], [])\n\t}\n\n\tconst fileName = atLocation.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown type shape node ${typeOrPromise.getText()}`)\n\treturn 'unknown_5'\n}\n\nconst getLiteralValueOfNode = (node: Node): string | string[] | unknown[] => {\n\tif (node.isKind(SyntaxKind.Identifier)) {\n\t\treturn getLiteralValueOfNode(findNodeImplementation(node))\n\t} else if (node.isKind(SyntaxKind.StringLiteral)) {\n\t\treturn node.getLiteralValue()\n\t} else if (node.isKind(SyntaxKind.ArrayLiteralExpression)) {\n\t\treturn node.forEachChildAsArray().map((child) => getLiteralValueOfNode(child)) as string[]\n\t} else if (node.isKind(SyntaxKind.PropertyAccessExpression)) {\n\t\treturn getLiteralValueOfNode(findPropertyAssignmentValueNode(node))\n\t} else if (node.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\treturn getValuesOfObjectLiteral(node)\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown literal value node ${node.getKindName()}`)\n\n\treturn 'unknown_6'\n}\n\nexport const resolveEndpointPath = (node: Node): string | null => {\n\tconst callExpression = node.getFirstDescendantByKind(SyntaxKind.CallExpression)\n\tif (!callExpression) return null\n\n\tconst firstArg = callExpression.getArguments()[0]\n\tif (!firstArg) return null\n\n\tconst argType = firstArg.getType()\n\tif (argType.isStringLiteral()) {\n\t\treturn argType.getLiteralValue() as string\n\t}\n\n\treturn null\n}\n\nexport const getValuesOfObjectLiteral = (objectLiteralNode: Node<ts.ObjectLiteralExpression>) => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst targetNode = findNodeImplementation(assignmentValueNode)\n\t\tconst value = getLiteralValueOfNode(targetNode)\n\n\t\treturn {\n\t\t\tidentifier: identifierName,\n\t\t\tvalue,\n\t\t}\n\t})\n\n\treturn properties || []\n}\n"],"names":["implementationCache","findNodeImplementation","node","cached","SyntaxKind","implementationNode","assignmentValueNode","result","definitionNode","findPropertyAssignmentValueNode","identifierChildren","child","getTypeReferenceShape","firstChild","getRecursiveNodeShape","nodeOrReference","typeName","OpenApiManager","literalNode","typeLiteralNode","propNode","identifier","valueNode","questionMarkToken","typeReferenceNode","lastChild","getProperTypeShape","unionTypeNode","typeQueryNode","qualifiedNameNode","callExpressionNode","awaitExpressionNode","asExpressionNode","fileName","Logger","getShapeOfValidatorLiteral","objectLiteralNode","identifierNode","identifierName","innerLiteralNode","getValidatorPropertyShape","getValidatorPropertyOptionality","getValidatorPropertyStringValue","isZodCallExpression","callExpression","getZodCallShape","objectLiteral","syntaxList","prop","argNode","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","returnType","importTypeNode","indexOfGreaterThanToken","targetSyntaxList","intersectionType","validatorType","syntaxListNode","literalExpression","name","targetChild","c","value","targetValue","getValuesOfObjectLiteral","intersectionTypeNode","t","v","propertySignatureNode","isPromise","type","symbol","args","typeOrPromise","atLocation","stack","previousType","nextStack","typeSymbolName","targetType","valueDeclaration","isOptional","shape","val","dedupedShapes","index","arr","dup","dupIndex","isNullable","shapes","total","current","getLiteralValueOfNode","resolveEndpointPath","firstArg","argType","targetNode"],"mappings":";;;AAgBA,MAAMA,wBAA0B,QAAoB,GAEvCC,IAAyB,CAACC,MAAqB;AACrD,QAAAC,IAASH,EAAoB,IAAIE,CAAI;AAC3C,MAAIC;AACI,WAAAA;AAGR,MAAID,EAAK,cAAcE,EAAW,YAAY;AACvC,UAAAC,IAAqBH,EAAK,OAAOE,EAAW,UAAU,EAAG,mBAAmB,EAAE,CAAC,GAAG,QAAQ;AAChG,QAAIC,GAAoB;AAEjB,YAAAC,IAD2BD,EAAmB,UAAU,EACT,aAAa;AAClE,UAAIC,MAAwBJ;AACrB,cAAA,IAAI,MAAM,gCAAgC;AAE3C,YAAAK,IAASN,EAAuBK,CAAmB;AACrC,aAAAN,E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C5C,MAAA,CAAC0D,EAAiB,QAAA;AAEhB,QAAAC,IAAUD,EAAS,QAAQ;AAC7B,SAAAC,EAAQ,oBACJA,EAAQ,gBAAgB,IAGzB;AACR,GAEahC,IAA2B,CAACnC,MACjBA,EAAkB,yBAAyBhC,EAAW,UAAU,EAChD,kBAAkBA,EAAW,kBAAkB,EAEnD,IAAI,CAACF,MAAS;AAE1C,QAAAoC,IADiBpC,EAAK,yBAAyBE,EAAW,UAAU,EACpC,QAAQ,GAExCE,IAAsBJ,EAAK,aAAa,GACxCsG,IAAavG,EAAuBK,CAAmB,GACvD+D,IAAQ+B,EAAsBI,CAAU;AAEvC,SAAA;AAAA,IACN,YAAYlE;AAAA,IACZ,OAAA+B;AAAA,EACD;AAAA,CACA,KAEoB,CAAC;"}
|
|
1
|
+
{"version":3,"file":"nodeParsers.mjs","sources":["../../../src/openapi/analyzerModule/nodeParsers.ts"],"sourcesContent":["import {\n\tNode,\n\tPropertyAccessExpression,\n\tPropertyAssignment,\n\tPropertySignature,\n\tShorthandPropertyAssignment,\n\tSyntaxKind,\n\tts,\n\tType,\n\tTypeReferenceNode,\n} from 'ts-morph'\n\nimport { Logger } from '../../utils/logger'\nimport { OpenApiManager } from '../manager/OpenApiManager'\nimport { ShapeOfProperty, ShapeOfType, ShapeOfUnionEntry } from './types'\n\nconst implementationCache = new WeakMap<Node, Node>()\n\nexport const findNodeImplementation = (node: Node): Node => {\n\tconst cached = implementationCache.get(node)\n\tif (cached) {\n\t\treturn cached\n\t}\n\n\tif (node.getKind() === SyntaxKind.Identifier) {\n\t\tconst implementationNode = node.asKind(SyntaxKind.Identifier)!.getImplementations()[0]?.getNode()\n\t\tif (implementationNode) {\n\t\t\tconst implementationParentNode = implementationNode.getParent()!\n\t\t\tconst assignmentValueNode = implementationParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\n\t\tconst definitionNode = node.asKind(SyntaxKind.Identifier)!.getDefinitions()[0]?.getNode()\n\t\tif (definitionNode) {\n\t\t\tconst definitionParentNode = definitionNode.getParent()!\n\t\t\tconst assignmentValueNode = definitionParentNode.getLastChild()!\n\t\t\tif (assignmentValueNode === node) {\n\t\t\t\tthrow new Error('Recursive implementation found')\n\t\t\t}\n\t\t\tconst result = findNodeImplementation(assignmentValueNode)\n\t\t\timplementationCache.set(node, result)\n\t\t\treturn result\n\t\t}\n\t\tthrow new Error('No implementation nor definition available')\n\t}\n\n\timplementationCache.set(node, node)\n\treturn node\n}\n\nexport const findPropertyAssignmentValueNode = (\n\tnode:\n\t\t| PropertyAssignment\n\t\t| TypeReferenceNode\n\t\t| PropertySignature\n\t\t| PropertyAccessExpression\n\t\t| ShorthandPropertyAssignment,\n): Node => {\n\tconst identifierChildren = node.getChildrenOfKind(SyntaxKind.Identifier)\n\tif (identifierChildren.length === 2) {\n\t\treturn findNodeImplementation(identifierChildren[1])\n\t}\n\tconst lastMatchingChild = node.getChildren().reverse()\n\treturn lastMatchingChild.find(\n\t\t(child) =>\n\t\t\tchild.getKind() !== SyntaxKind.GreaterThanToken &&\n\t\t\tchild.getKind() !== SyntaxKind.CommaToken &&\n\t\t\tchild.getKind() !== SyntaxKind.SemicolonToken,\n\t)!\n}\n\nexport const getTypeReferenceShape = (node: TypeReferenceNode): ShapeOfType['shape'] => {\n\tconst firstChild = node.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\tif (firstChild.isKind(SyntaxKind.SyntaxList)) {\n\t\treturn getRecursiveNodeShape(firstChild.getFirstChild()!)\n\t} else {\n\t\treturn getRecursiveNodeShape(firstChild)\n\t}\n}\n\nexport const getRecursiveNodeShape = (nodeOrReference: Node): ShapeOfType['shape'] => {\n\tconst typeName = nodeOrReference.getSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\t// Undefined\n\tconst undefinedNode = node.asKind(SyntaxKind.UndefinedKeyword)\n\tif (undefinedNode) {\n\t\treturn 'undefined'\n\t}\n\n\t// Literal type\n\tconst literalNode = node.asKind(SyntaxKind.LiteralType)\n\tif (literalNode) {\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.TrueKeyword)) {\n\t\t\treturn 'true'\n\t\t}\n\t\tif (literalNode.getFirstChildByKind(SyntaxKind.FalseKeyword)) {\n\t\t\treturn 'false'\n\t\t}\n\t}\n\n\t// Boolean literal\n\tconst booleanLiteralNode =\n\t\tnode.asKind(SyntaxKind.BooleanKeyword) ||\n\t\tnode.asKind(SyntaxKind.TrueKeyword) ||\n\t\tnode.asKind(SyntaxKind.FalseKeyword)\n\tif (booleanLiteralNode) {\n\t\treturn 'boolean'\n\t}\n\n\t// String literal\n\tconst stringLiteralNode = node.asKind(SyntaxKind.StringKeyword) || node.asKind(SyntaxKind.StringLiteral)\n\tif (stringLiteralNode) {\n\t\treturn 'string'\n\t}\n\n\t// Number literal\n\tconst numberLiteralNode = node.asKind(SyntaxKind.NumberKeyword) || node.asKind(SyntaxKind.NumericLiteral)\n\tif (numberLiteralNode) {\n\t\treturn 'number'\n\t}\n\n\t// BigInt literal\n\tconst bigIntNode = node.asKind(SyntaxKind.BigIntKeyword) || node.asKind(SyntaxKind.BigIntLiteral)\n\tif (bigIntNode) {\n\t\treturn 'bigint'\n\t}\n\n\t// Type literal\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\tconst properties = typeLiteralNode\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getChildrenOfKind(SyntaxKind.PropertySignature)\n\n\t\tconst propertyShapes = properties.map((propNode) => {\n\t\t\tconst identifier = propNode.getFirstChildByKind(SyntaxKind.Identifier)!\n\t\t\tconst valueNode = findPropertyAssignmentValueNode(propNode)\n\t\t\tconst questionMarkToken = identifier.getNextSiblingIfKind(SyntaxKind.QuestionToken)\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier: identifier.getText(),\n\t\t\t\tshape: getRecursiveNodeShape(valueNode),\n\t\t\t\toptional: valueNode.getType().isNullable() || !!questionMarkToken,\n\t\t\t}\n\t\t})\n\t\treturn propertyShapes\n\t}\n\n\t// Type reference\n\tconst typeReferenceNode = node.asKind(SyntaxKind.TypeReference)\n\tif (typeReferenceNode) {\n\t\treturn getRecursiveNodeShape(typeReferenceNode.getFirstChild()!)\n\t}\n\n\t// Property access expression\n\tconst propertyAccessNode = node.asKind(SyntaxKind.PropertyAccessExpression)\n\tif (propertyAccessNode) {\n\t\tconst lastChild = findNodeImplementation(node.getLastChild()!)\n\t\treturn getProperTypeShape(lastChild.asKind(SyntaxKind.CallExpression)!.getReturnType(), lastChild)\n\t}\n\n\t// Union type\n\tconst unionTypeNode = node.asKind(SyntaxKind.UnionType)\n\tif (unionTypeNode) {\n\t\treturn getProperTypeShape(unionTypeNode.getType(), node)\n\t}\n\n\t// Typeof query\n\tconst typeQueryNode = node.asKind(SyntaxKind.TypeQuery)\n\tif (typeQueryNode) {\n\t\treturn getRecursiveNodeShape(typeQueryNode.getLastChild()!)\n\t}\n\n\t// Qualified name\n\tconst qualifiedNameNode = node.asKind(SyntaxKind.QualifiedName)\n\tif (qualifiedNameNode) {\n\t\treturn getRecursiveNodeShape(qualifiedNameNode.getLastChild()!)\n\t}\n\n\t// Call expression\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\treturn getProperTypeShape(callExpressionNode.getReturnType(), callExpressionNode)\n\t}\n\n\t// Await expression\n\tconst awaitExpressionNode = node.asKind(SyntaxKind.AwaitExpression)\n\tif (awaitExpressionNode) {\n\t\treturn getRecursiveNodeShape(awaitExpressionNode.getChildAtIndex(1)!)\n\t}\n\n\t// 'As' Expression\n\tconst asExpressionNode = node.asKind(SyntaxKind.AsExpression)\n\tif (asExpressionNode) {\n\t\treturn getRecursiveNodeShape(asExpressionNode.getChildAtIndex(2)!)\n\t}\n\n\t// TODO\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown node type: ${node.getKindName()}`)\n\treturn 'unknown_1'\n}\n\nexport const getShapeOfValidatorLiteral = (\n\tobjectLiteralNode: Node<ts.ObjectLiteralExpression>,\n): (ShapeOfProperty & { description: string; errorMessage: string })[] => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstChild()!\n\t\tconst identifierName = (() => {\n\t\t\tif (identifierNode.isKind(SyntaxKind.Identifier)) {\n\t\t\t\treturn identifierNode.getText()\n\t\t\t}\n\t\t\tif (identifierNode.isKind(SyntaxKind.StringLiteral)) {\n\t\t\t\treturn identifierNode.getLiteralText()\n\t\t\t}\n\t\t\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\t\t\tLogger.warn(`[${fileName}] Unknown identifier name: ${identifierNode.getText()}`)\n\t\t\treturn 'unknown_30'\n\t\t})()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst innerLiteralNode = findNodeImplementation(assignmentValueNode)\n\n\t\treturn {\n\t\t\trole: 'property' as const,\n\t\t\tidentifier: identifierName,\n\t\t\tshape: getValidatorPropertyShape(innerLiteralNode),\n\t\t\toptional: getValidatorPropertyOptionality(innerLiteralNode),\n\t\t\tdescription: getValidatorPropertyStringValue(innerLiteralNode, 'description'),\n\t\t\terrorMessage: getValidatorPropertyStringValue(innerLiteralNode, 'errorMessage'),\n\t\t}\n\t})\n\n\treturn properties || []\n}\n\nconst isZodCallExpression = (node: Node): boolean => {\n\tconst callExpression = node.asKind(SyntaxKind.CallExpression)\n\tif (!callExpression) {\n\t\treturn false\n\t}\n\tconst returnType = callExpression.getReturnType()\n\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\treturn typeName.startsWith('Zod')\n}\n\nconst getZodCallShape = (node: Node): ShapeOfType['shape'] => {\n\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\tconst returnType = callExpression.getReturnType()\n\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\n\tif (typeName === 'ZodNumber') {\n\t\treturn 'number'\n\t}\n\tif (typeName === 'ZodString') {\n\t\treturn 'string'\n\t}\n\tif (typeName === 'ZodBoolean') {\n\t\treturn 'boolean'\n\t}\n\tif (typeName === 'ZodBigInt') {\n\t\treturn 'bigint'\n\t}\n\n\tif (typeName === 'ZodObject') {\n\t\tconst argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()\n\t\tconst objectLiteral = argNode?.asKind(SyntaxKind.ObjectLiteralExpression)\n\t\tif (!objectLiteral) {\n\t\t\treturn 'unknown_zod_object'\n\t\t}\n\t\tconst syntaxList = objectLiteral.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\tif (!syntaxList) {\n\t\t\treturn []\n\t\t}\n\t\tconst properties = syntaxList.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\t\treturn properties.map((prop) => {\n\t\t\tconst identifier = prop.getFirstChildByKind(SyntaxKind.Identifier)!.getText()\n\t\t\tconst valueNode = prop.getLastChild()!\n\t\t\treturn {\n\t\t\t\trole: 'property' as const,\n\t\t\t\tidentifier,\n\t\t\t\tshape: isZodCallExpression(valueNode)\n\t\t\t\t\t? getZodCallShape(valueNode)\n\t\t\t\t\t: getValidatorPropertyShape(valueNode),\n\t\t\t\toptional: false,\n\t\t\t}\n\t\t})\n\t}\n\n\tif (typeName === 'ZodArray') {\n\t\tconst argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()\n\t\tif (!argNode) {\n\t\t\treturn 'unknown_zod_array'\n\t\t}\n\t\tconst elementShape = isZodCallExpression(argNode)\n\t\t\t? getZodCallShape(argNode)\n\t\t\t: getValidatorPropertyShape(argNode)\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: elementShape,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown zod type: ${typeName}`)\n\treturn 'unknown_zod'\n}\n\nexport const getValidatorPropertyShape = (innerLiteralNode: Node): ShapeOfType['shape'] => {\n\t// Zod validator (e.g. z.number(), z.string(), z.object({...}), z.array(...))\n\tif (isZodCallExpression(innerLiteralNode)) {\n\t\treturn getZodCallShape(innerLiteralNode)\n\t}\n\n\t// Inline definition with `as Validator<...>` clause\n\tconst inlineValidatorAsExpression = innerLiteralNode\n\t\t.getParent()!\n\t\t.getFirstChildByKind(SyntaxKind.AsExpression)\n\tif (inlineValidatorAsExpression) {\n\t\tconst typeReference = inlineValidatorAsExpression.getLastChildByKind(SyntaxKind.TypeReference)!\n\t\treturn getTypeReferenceShape(typeReference)\n\t}\n\n\t// Variable with `: Validator<...>` clause\n\tconst childTypeReferenceNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.TypeReference)\n\tif (childTypeReferenceNode) {\n\t\treturn getTypeReferenceShape(childTypeReferenceNode)\n\t}\n\n\t// `RequiredParam<...>` inline call expression\n\tif (innerLiteralNode.getParent()!.getChildrenOfKind(SyntaxKind.SyntaxList).length >= 2) {\n\t\tconst typeNode = innerLiteralNode\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t\t.getFirstChild()!\n\t\treturn getRecursiveNodeShape(typeNode)\n\t}\n\n\t// `RequestParam | RequiredParam | OptionalParam` call expression\n\tconst childCallExpressionNode = innerLiteralNode.getParent()!.getFirstChildByKind(SyntaxKind.CallExpression)\n\tif (childCallExpressionNode) {\n\t\tconst callExpressionArgument = findNodeImplementation(\n\t\t\tchildCallExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!.getFirstChild()!,\n\t\t)\n\n\t\t// Param is a type reference\n\t\tconst typeReferenceNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.TypeReference)!\n\t\tif (typeReferenceNode) {\n\t\t\treturn getProperTypeShape(typeReferenceNode.getType(), typeReferenceNode, [])\n\t\t}\n\n\t\tconst thingyNode = callExpressionArgument\n\t\t\t.getParent()!\n\t\t\t.getFirstChildByKind(SyntaxKind.ObjectLiteralExpression)!\n\t\tif (thingyNode) {\n\t\t\treturn getValidatorPropertyShape(thingyNode)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.CallExpression) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tif (callExpressionArgument.getKind() === SyntaxKind.IntersectionType) {\n\t\t\treturn getValidatorPropertyShape(callExpressionArgument)\n\t\t}\n\n\t\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\t\tLogger.warn(`[${fileName}] Unknown call expression argument: ${callExpressionArgument.getKindName()}`)\n\t\treturn 'unknown_3'\n\t}\n\n\t// Attempting to infer type from `parse` function\n\tconst innerNodePropertyAssignments = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\t.getChildrenOfKind(SyntaxKind.PropertyAssignment)\n\tconst parsePropertyAssignment = innerNodePropertyAssignments.find((prop) => {\n\t\treturn prop.getFirstChildByKind(SyntaxKind.Identifier)?.getText() === 'parse'\n\t})\n\tif (parsePropertyAssignment) {\n\t\tconst returnType = findPropertyAssignmentValueNode(parsePropertyAssignment)\n\t\t\t.asKind(SyntaxKind.ArrowFunction)!\n\t\t\t.getReturnType()\n\t\treturn getProperTypeShape(returnType, parsePropertyAssignment)\n\t}\n\n\t// Import statement\n\tconst importTypeNode = innerLiteralNode\n\t\t.getFirstChildByKind(SyntaxKind.SyntaxList)\n\t\t?.getFirstChildByKind(SyntaxKind.ImportType)\n\tif (importTypeNode) {\n\t\tconst indexOfGreaterThanToken = importTypeNode\n\t\t\t.getLastChildByKind(SyntaxKind.GreaterThanToken)!\n\t\t\t.getChildIndex()\n\t\tconst targetSyntaxList = importTypeNode.getChildAtIndex(indexOfGreaterThanToken - 1)\n\t\treturn getRecursiveNodeShape(targetSyntaxList.getFirstChild()!)\n\t}\n\n\t// Intersection type with Validator\n\tconst intersectionType = innerLiteralNode.isKind(SyntaxKind.IntersectionType)\n\t\t? innerLiteralNode\n\t\t: innerLiteralNode.getParent()?.isKind(SyntaxKind.VariableDeclaration)\n\t\t\t? innerLiteralNode.getParent()?.getFirstChildByKind(SyntaxKind.IntersectionType)\n\t\t\t: null\n\n\tif (intersectionType) {\n\t\tconst validatorType = intersectionType.getFirstChildByKind(SyntaxKind.TypeReference)\n\t\tif (validatorType) {\n\t\t\treturn getTypeReferenceShape(validatorType)\n\t\t}\n\t}\n\n\tconst fileName = innerLiteralNode.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown import type node`)\n\n\treturn 'unknown_2'\n}\n\nexport const getValidatorPropertyOptionality = (node: Node): boolean => {\n\tif (isZodCallExpression(node)) {\n\t\treturn false\n\t}\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst identifierNode = callExpressionNode.getFirstChildByKind(SyntaxKind.Identifier)\n\t\tif (identifierNode?.getText() === 'OptionalParam') {\n\t\t\treturn true\n\t\t} else if (identifierNode?.getText() === 'RequiredParam') {\n\t\t\treturn false\n\t\t}\n\n\t\tconst syntaxListNode = callExpressionNode.getFirstChildByKind(SyntaxKind.SyntaxList)!\n\t\tconst literalExpression = findNodeImplementation(syntaxListNode.getFirstChild()!)\n\t\treturn getValidatorPropertyOptionality(literalExpression)\n\t}\n\n\tconst syntaxListNode = node.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\treturn assignmentNodes.some((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tif (identifierName === 'optional') {\n\t\t\tconst value = findPropertyAssignmentValueNode(node)\n\t\t\treturn value.getKind() === SyntaxKind.TrueKeyword\n\t\t}\n\t\treturn false\n\t})\n}\n\nexport const getValidatorPropertyStringValue = (\n\tnodeOrReference: Node,\n\tname: 'description' | 'errorMessage',\n): string => {\n\tif (isZodCallExpression(nodeOrReference)) {\n\t\treturn ''\n\t}\n\n\tconst node = findNodeImplementation(nodeOrReference)\n\n\tconst callExpressionNode = node.asKind(SyntaxKind.CallExpression)\n\tif (callExpressionNode) {\n\t\tconst targetChild = callExpressionNode.getLastChildByKind(SyntaxKind.SyntaxList)!\n\t\treturn getValidatorPropertyStringValue(targetChild, name)\n\t}\n\n\tconst syntaxListNode = node.asKind(SyntaxKind.SyntaxList)\n\tif (syntaxListNode) {\n\t\tconst children = syntaxListNode.getChildren().map((c) => getValidatorPropertyStringValue(c, name))\n\t\treturn children.find((value) => !!value && value !== 'unknown_25') || ''\n\t}\n\n\tconst objectLiteralNode = node.asKind(SyntaxKind.ObjectLiteralExpression)\n\tif (objectLiteralNode) {\n\t\tconst values = getValuesOfObjectLiteral(objectLiteralNode)\n\t\tconst targetValue = values.find((value) => value.identifier === name)\n\t\tif (!targetValue) {\n\t\t\treturn ''\n\t\t}\n\t\tif (Array.isArray(targetValue.value)) {\n\t\t\treturn 'array'\n\t\t}\n\t\treturn targetValue.value || ''\n\t}\n\n\tconst intersectionTypeNode = node.asKind(SyntaxKind.IntersectionType)\n\tif (intersectionTypeNode) {\n\t\treturn (\n\t\t\tintersectionTypeNode\n\t\t\t\t.getTypeNodes()\n\t\t\t\t.flatMap((t) => getValidatorPropertyStringValue(t, name))\n\t\t\t\t.filter((v) => !!v && v !== 'unknown_25')[0] || 'unknown_27'\n\t\t)\n\t}\n\n\tconst typeLiteralNode = node.asKind(SyntaxKind.TypeLiteral)\n\tif (typeLiteralNode) {\n\t\treturn getValidatorPropertyStringValue(typeLiteralNode.getFirstChildByKind(SyntaxKind.SyntaxList)!, name)\n\t}\n\n\tconst propertySignatureNode = node.asKind(SyntaxKind.PropertySignature)\n\tif (propertySignatureNode) {\n\t\tconst identifier = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tif (identifier.getText() === name) {\n\t\t\tconst targetNode = findPropertyAssignmentValueNode(propertySignatureNode).getFirstDescendantByKind(\n\t\t\t\tSyntaxKind.StringLiteral,\n\t\t\t)!\n\t\t\treturn targetNode.getLiteralText()\n\t\t}\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown property string value node ${node.getKindName()}`)\n\treturn 'unknown_25'\n}\n\nconst isPromise = (type: Type) => {\n\tconst symbol = type.getSymbol()\n\tif (!type.isObject() || !symbol) {\n\t\treturn false\n\t}\n\tconst args = type.getTypeArguments()\n\treturn symbol.getName() === 'Promise' && args.length === 1\n}\n\nexport const getProperTypeShape = (\n\ttypeOrPromise: Type,\n\tatLocation: Node,\n\tstack: Type[] = [],\n): ShapeOfType['shape'] => {\n\tconst typeName = typeOrPromise.getAliasSymbol()?.getName()\n\tif (typeName && OpenApiManager.getInstance().hasExposedModel(typeName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'ref',\n\t\t\t\tshape: typeName,\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tconst type = isPromise(typeOrPromise) ? typeOrPromise.getTypeArguments()[0] : typeOrPromise\n\n\tif (stack.some((previousType) => previousType === type)) {\n\t\treturn 'circular'\n\t}\n\n\tconst nextStack = stack.concat(type)\n\n\tif (type.getText() === 'void') {\n\t\treturn 'void'\n\t}\n\n\tif (type.isAny()) {\n\t\treturn 'any'\n\t}\n\n\tif (type.isUnknown()) {\n\t\treturn 'unknown'\n\t}\n\n\tif (type.isNull()) {\n\t\treturn 'null'\n\t}\n\n\tif (type.isUndefined()) {\n\t\treturn 'undefined'\n\t}\n\n\tif (type.isBoolean() || type.isBooleanLiteral()) {\n\t\treturn 'boolean'\n\t}\n\n\tif (type.isStringLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_string' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isNumberLiteral()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'literal_number' as const,\n\t\t\t\tshape: String(type.getLiteralValue()!),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isString() || type.isTemplateLiteral()) {\n\t\treturn 'string'\n\t}\n\n\tif (type.isNumber()) {\n\t\treturn 'number'\n\t}\n\n\tif (type.getText() === 'bigint') {\n\t\treturn 'bigint'\n\t}\n\n\tif (type.isTuple()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'tuple' as const,\n\t\t\t\tshape: type.getTupleElements().map((t) => ({\n\t\t\t\t\trole: 'tuple_entry' as const,\n\t\t\t\t\tshape: getProperTypeShape(t, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t})),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isArray()) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: getProperTypeShape(type.getArrayElementType()!, atLocation, nextStack),\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\t// Handles `interface Foo extends Array<T>` (e.g. Prisma's JsonArray)\n\t// which fails type.isArray() but is still array-like\n\tif (type.isObject()) {\n\t\tconst arrayElementType = type.getNumberIndexType()\n\t\tconst baseTypes = type.getBaseTypes()\n\t\tconst arrayBase = baseTypes?.find((base) => base.isArray())\n\t\tif (arrayBase) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'array' as const,\n\t\t\t\t\tshape: getProperTypeShape(\n\t\t\t\t\t\tarrayBase.getArrayElementType() ?? arrayElementType!,\n\t\t\t\t\t\tatLocation,\n\t\t\t\t\t\tnextStack,\n\t\t\t\t\t),\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t}\n\n\tconst typeSymbolName = type.getSymbol()?.getName()\n\n\tconst bufferLikeTypes = new Set([\n\t\t'Buffer',\n\t\t'Uint8Array',\n\t\t'Int8Array',\n\t\t'Uint8ClampedArray',\n\t\t'Int16Array',\n\t\t'Uint16Array',\n\t\t'Int32Array',\n\t\t'Uint32Array',\n\t\t'Float32Array',\n\t\t'Float64Array',\n\t\t'BigInt64Array',\n\t\t'BigUint64Array',\n\t\t'ArrayBuffer',\n\t\t'SharedArrayBuffer',\n\t\t'ReadableStream',\n\t])\n\n\tif (type.isObject() && typeSymbolName && bufferLikeTypes.has(typeSymbolName)) {\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'buffer' as const,\n\t\t\t\tshape: 'buffer',\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && typeSymbolName === 'RegExp') {\n\t\treturn 'string'\n\t}\n\n\tif (type.isObject() && typeSymbolName === 'Map') {\n\t\tconst typeArgs = type.getTypeArguments()\n\t\tconst valueType = typeArgs[1]\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'record' as const,\n\t\t\t\tshape: valueType ? getProperTypeShape(valueType, atLocation, nextStack) : 'unknown',\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && typeSymbolName === 'Set') {\n\t\tconst typeArgs = type.getTypeArguments()\n\t\tconst elementType = typeArgs[0]\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'array' as const,\n\t\t\t\tshape: elementType ? getProperTypeShape(elementType, atLocation, nextStack) : 'unknown',\n\t\t\t\toptional: false,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isObject() && type.getProperties().length === 0) {\n\t\tconst targetType = type.getAliasTypeArguments()[1] ?? type.getStringIndexType()\n\t\tif (targetType) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'record' as const,\n\t\t\t\t\tshape: getProperTypeShape(targetType, atLocation, nextStack),\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t}\n\n\tif (type.isObject()) {\n\t\tif (typeSymbolName === 'Date' || type.getText() === 'Date') {\n\t\t\treturn 'Date'\n\t\t}\n\t\treturn type\n\t\t\t.getProperties()\n\t\t\t.map((prop) => {\n\t\t\t\tconst valueDeclaration = prop.getValueDeclaration() || prop.getDeclarations()[0]!\n\t\t\t\tif (!valueDeclaration) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tconst valueDeclarationNode =\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertySignature) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.PropertyAssignment) ||\n\t\t\t\t\tvalueDeclaration.asKind(SyntaxKind.ShorthandPropertyAssignment)\n\n\t\t\t\tif (!valueDeclarationNode) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack),\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst isOptional = prop.getTypeAtLocation(atLocation).isNullable()\n\n\t\t\t\tconst shape = getProperTypeShape(prop.getTypeAtLocation(atLocation), atLocation, nextStack)\n\t\t\t\treturn {\n\t\t\t\t\trole: 'property' as const,\n\t\t\t\t\tidentifier: prop.getName(),\n\t\t\t\t\tshape: shape,\n\t\t\t\t\toptional: isOptional,\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((val) => val.shape !== 'undefined')\n\t}\n\n\tif (type.isUnion()) {\n\t\tconst unfilteredShapes: ShapeOfUnionEntry[] = type.getUnionTypes().map((type) => ({\n\t\t\trole: 'union_entry',\n\t\t\tshape: getProperTypeShape(type, atLocation, nextStack),\n\t\t\toptional: false,\n\t\t}))\n\n\t\tconst dedupedShapes = unfilteredShapes.filter(\n\t\t\t(type, index, arr) => !arr.find((dup, dupIndex) => dup.shape === type.shape && dupIndex > index),\n\t\t)\n\t\tconst isNullable = dedupedShapes.some((shape) => shape.shape === 'undefined')\n\t\tconst shapes = dedupedShapes.filter((shape) => shape.shape !== 'undefined')\n\t\tif (shapes.length === 1) {\n\t\t\treturn shapes[0].shape\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\trole: 'union',\n\t\t\t\tshape: shapes,\n\t\t\t\toptional: isNullable,\n\t\t\t},\n\t\t]\n\t}\n\n\tif (type.isIntersection()) {\n\t\tconst children = type.getIntersectionTypes()\n\t\tconst shapesOfChildren = children\n\t\t\t.map((child) => getProperTypeShape(child, atLocation, nextStack))\n\t\t\t.filter((shape) => typeof shape !== 'string') as ShapeOfProperty[][]\n\t\treturn shapesOfChildren.reduce<ShapeOfType[]>((total, current) => [...total, ...current], [])\n\t}\n\n\tconst fileName = atLocation.getSourceFile().getFilePath().split('/').pop()\n\tLogger.warn(`[${fileName}] Unknown type shape node ${typeOrPromise.getText()}`)\n\treturn 'unknown_5'\n}\n\nconst getLiteralValueOfNode = (node: Node): string | string[] | unknown[] => {\n\tif (node.isKind(SyntaxKind.Identifier)) {\n\t\treturn getLiteralValueOfNode(findNodeImplementation(node))\n\t} else if (node.isKind(SyntaxKind.StringLiteral)) {\n\t\treturn node.getLiteralValue()\n\t} else if (node.isKind(SyntaxKind.ArrayLiteralExpression)) {\n\t\treturn node.forEachChildAsArray().map((child) => getLiteralValueOfNode(child)) as string[]\n\t} else if (node.isKind(SyntaxKind.PropertyAccessExpression)) {\n\t\treturn getLiteralValueOfNode(findPropertyAssignmentValueNode(node))\n\t} else if (node.isKind(SyntaxKind.ObjectLiteralExpression)) {\n\t\treturn getValuesOfObjectLiteral(node)\n\t}\n\n\tconst fileName = node.getSourceFile().getFilePath().split('/').pop()\n\tLogger.dev(`[${fileName}] Unknown literal value node ${node.getKindName()}`)\n\n\treturn 'unknown_6'\n}\n\nexport const resolveEndpointPath = (node: Node): string | null => {\n\tconst callExpression = node.getFirstDescendantByKind(SyntaxKind.CallExpression)\n\tif (!callExpression) return null\n\n\tconst firstArg = callExpression.getArguments()[0]\n\tif (!firstArg) return null\n\n\tconst argType = firstArg.getType()\n\tif (argType.isStringLiteral()) {\n\t\treturn argType.getLiteralValue() as string\n\t}\n\n\treturn null\n}\n\nexport const getValuesOfObjectLiteral = (objectLiteralNode: Node<ts.ObjectLiteralExpression>) => {\n\tconst syntaxListNode = objectLiteralNode.getFirstDescendantByKind(SyntaxKind.SyntaxList)!\n\tconst assignmentNodes = syntaxListNode.getChildrenOfKind(SyntaxKind.PropertyAssignment)!\n\n\tconst properties = assignmentNodes.map((node) => {\n\t\tconst identifierNode = node.getFirstDescendantByKind(SyntaxKind.Identifier)!\n\t\tconst identifierName = identifierNode.getText()\n\n\t\tconst assignmentValueNode = node.getLastChild()!\n\t\tconst targetNode = findNodeImplementation(assignmentValueNode)\n\t\tconst value = getLiteralValueOfNode(targetNode)\n\n\t\treturn {\n\t\t\tidentifier: identifierName,\n\t\t\tvalue,\n\t\t}\n\t})\n\n\treturn properties || []\n}\n"],"names":["implementationCache","findNodeImplementation","node","cached","SyntaxKind","implementationNode","assignmentValueNode","result","definitionNode","findPropertyAssignmentValueNode","identifierChildren","child","getTypeReferenceShape","firstChild","getRecursiveNodeShape","nodeOrReference","typeName","OpenApiManager","literalNode","typeLiteralNode","propNode","identifier","valueNode","questionMarkToken","typeReferenceNode","lastChild","getProperTypeShape","unionTypeNode","typeQueryNode","qualifiedNameNode","callExpressionNode","awaitExpressionNode","asExpressionNode","fileName","Logger","getShapeOfValidatorLiteral","objectLiteralNode","identifierNode","identifierName","innerLiteralNode","getValidatorPropertyShape","getValidatorPropertyOptionality","getValidatorPropertyStringValue","isZodCallExpression","callExpression","getZodCallShape","objectLiteral","syntaxList","prop","argNode","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","returnType","importTypeNode","indexOfGreaterThanToken","targetSyntaxList","intersectionType","validatorType","syntaxListNode","literalExpression","name","targetChild","c","value","targetValue","getValuesOfObjectLiteral","intersectionTypeNode","t","v","propertySignatureNode","isPromise","type","symbol","args","typeOrPromise","atLocation","stack","previousType","nextStack","arrayElementType","arrayBase","base","typeSymbolName","bufferLikeTypes","valueType","elementType","targetType","valueDeclaration","isOptional","shape","val","dedupedShapes","index","arr","dup","dupIndex","isNullable","shapes","total","current","getLiteralValueOfNode","resolveEndpointPath","firstArg","argType","targetNode"],"mappings":";;;AAgBA,MAAMA,wBAA0B,QAAoB,GAEvCC,IAAyB,CAACC,MAAqB;AACrD,QAAAC,IAASH,EAAoB,IAAIE,CAAI;AAC3C,MAAIC;AACI,WAAAA;AAGR,MAAID,EAAK,cAAcE,EAAW,YAAY;AACvC,UAAAC,IAAqBH,EAAK,OAAOE,EAAW,UAAU,EAAG,mBAAmB,EAAE,CAAC,GAAG,QAAQ;AAChG,QAAIC,GAAoB;AAEjB,YAAAC,IAD2BD,EAAmB,UAAU,EACT,aAAa;AAClE,UAAIC,MAAwBJ;AACrB,cAAA,IAAI,MAAM,gCAAgC;AAE3C,YAAAK,IAASN,EAAuBK,CAAmB;AACrC,aAAAN,EAAA,IAAIE,GAAMK,CAAM,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,EAChD,kBAAkBA,EAAW,kBAAkB,EAEnD,IAAI,CAACF,MAAS;AAE1C,QAAAoC,IADiBpC,EAAK,yBAAyBE,EAAW,UAAU,EACpC,QAAQ,GAExCE,IAAsBJ,EAAK,aAAa,GACxC4G,IAAa7G,EAAuBK,CAAmB,GACvD+D,IAAQqC,EAAsBI,CAAU;AAEvC,SAAA;AAAA,IACN,YAAYxE;AAAA,IACZ,OAAA+B;AAAA,EACD;AAAA,CACA,KAEoB,CAAC;"}
|
|
@@ -8,5 +8,15 @@ export declare const TestCase: {
|
|
|
8
8
|
readonly parsesReturnRecordStringUnknown: "parses-return-record-string-unknown";
|
|
9
9
|
readonly parsesReturnObjectWithRecordProperty: "parses-return-object-with-record-property";
|
|
10
10
|
readonly parsesBufferReturnedFromFunction: "parses-buffer-returned-from-function";
|
|
11
|
+
readonly parsesDateReturnedFromFunction: "parses-date-returned-from-function";
|
|
12
|
+
readonly parsesMapReturnedFromFunction: "parses-map-returned-from-function";
|
|
13
|
+
readonly parsesSetReturnedFromFunction: "parses-set-returned-from-function";
|
|
14
|
+
readonly parsesRegExpReturnedFromFunction: "parses-regexp-returned-from-function";
|
|
15
|
+
readonly parsesErrorReturnedFromFunction: "parses-error-returned-from-function";
|
|
16
|
+
readonly parsesInt8ArrayReturnedFromFunction: "parses-int8array-returned-from-function";
|
|
17
|
+
readonly parsesFloat32ArrayReturnedFromFunction: "parses-float32array-returned-from-function";
|
|
18
|
+
readonly parsesArrayBufferReturnedFromFunction: "parses-arraybuffer-returned-from-function";
|
|
19
|
+
readonly parsesReadableStreamReturnedFromFunction: "parses-readablestream-returned-from-function";
|
|
20
|
+
readonly parsesPrismaJsonObjectReturnedFromFunction: "parses-prisma-jsonobject-returned-from-function";
|
|
11
21
|
};
|
|
12
22
|
//# sourceMappingURL=TestCase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestCase.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/test/TestCase.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"TestCase.d.ts","sourceRoot":"","sources":["../../../../src/openapi/analyzerModule/test/TestCase.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;CAoBX,CAAA"}
|
package/package.json
CHANGED
|
@@ -652,8 +652,48 @@ export const getProperTypeShape = (
|
|
|
652
652
|
]
|
|
653
653
|
}
|
|
654
654
|
|
|
655
|
+
// Handles `interface Foo extends Array<T>` (e.g. Prisma's JsonArray)
|
|
656
|
+
// which fails type.isArray() but is still array-like
|
|
657
|
+
if (type.isObject()) {
|
|
658
|
+
const arrayElementType = type.getNumberIndexType()
|
|
659
|
+
const baseTypes = type.getBaseTypes()
|
|
660
|
+
const arrayBase = baseTypes?.find((base) => base.isArray())
|
|
661
|
+
if (arrayBase) {
|
|
662
|
+
return [
|
|
663
|
+
{
|
|
664
|
+
role: 'array' as const,
|
|
665
|
+
shape: getProperTypeShape(
|
|
666
|
+
arrayBase.getArrayElementType() ?? arrayElementType!,
|
|
667
|
+
atLocation,
|
|
668
|
+
nextStack,
|
|
669
|
+
),
|
|
670
|
+
optional: false,
|
|
671
|
+
},
|
|
672
|
+
]
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
|
|
655
676
|
const typeSymbolName = type.getSymbol()?.getName()
|
|
656
|
-
|
|
677
|
+
|
|
678
|
+
const bufferLikeTypes = new Set([
|
|
679
|
+
'Buffer',
|
|
680
|
+
'Uint8Array',
|
|
681
|
+
'Int8Array',
|
|
682
|
+
'Uint8ClampedArray',
|
|
683
|
+
'Int16Array',
|
|
684
|
+
'Uint16Array',
|
|
685
|
+
'Int32Array',
|
|
686
|
+
'Uint32Array',
|
|
687
|
+
'Float32Array',
|
|
688
|
+
'Float64Array',
|
|
689
|
+
'BigInt64Array',
|
|
690
|
+
'BigUint64Array',
|
|
691
|
+
'ArrayBuffer',
|
|
692
|
+
'SharedArrayBuffer',
|
|
693
|
+
'ReadableStream',
|
|
694
|
+
])
|
|
695
|
+
|
|
696
|
+
if (type.isObject() && typeSymbolName && bufferLikeTypes.has(typeSymbolName)) {
|
|
657
697
|
return [
|
|
658
698
|
{
|
|
659
699
|
role: 'buffer' as const,
|
|
@@ -663,6 +703,34 @@ export const getProperTypeShape = (
|
|
|
663
703
|
]
|
|
664
704
|
}
|
|
665
705
|
|
|
706
|
+
if (type.isObject() && typeSymbolName === 'RegExp') {
|
|
707
|
+
return 'string'
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
if (type.isObject() && typeSymbolName === 'Map') {
|
|
711
|
+
const typeArgs = type.getTypeArguments()
|
|
712
|
+
const valueType = typeArgs[1]
|
|
713
|
+
return [
|
|
714
|
+
{
|
|
715
|
+
role: 'record' as const,
|
|
716
|
+
shape: valueType ? getProperTypeShape(valueType, atLocation, nextStack) : 'unknown',
|
|
717
|
+
optional: false,
|
|
718
|
+
},
|
|
719
|
+
]
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
if (type.isObject() && typeSymbolName === 'Set') {
|
|
723
|
+
const typeArgs = type.getTypeArguments()
|
|
724
|
+
const elementType = typeArgs[0]
|
|
725
|
+
return [
|
|
726
|
+
{
|
|
727
|
+
role: 'array' as const,
|
|
728
|
+
shape: elementType ? getProperTypeShape(elementType, atLocation, nextStack) : 'unknown',
|
|
729
|
+
optional: false,
|
|
730
|
+
},
|
|
731
|
+
]
|
|
732
|
+
}
|
|
733
|
+
|
|
666
734
|
if (type.isObject() && type.getProperties().length === 0) {
|
|
667
735
|
const targetType = type.getAliasTypeArguments()[1] ?? type.getStringIndexType()
|
|
668
736
|
if (targetType) {
|
|
@@ -677,7 +745,7 @@ export const getProperTypeShape = (
|
|
|
677
745
|
}
|
|
678
746
|
|
|
679
747
|
if (type.isObject()) {
|
|
680
|
-
if (type.getText() === 'Date') {
|
|
748
|
+
if (typeSymbolName === 'Date' || type.getText() === 'Date') {
|
|
681
749
|
return 'Date'
|
|
682
750
|
}
|
|
683
751
|
return type
|
|
@@ -8,4 +8,14 @@ export const TestCase = {
|
|
|
8
8
|
parsesReturnRecordStringUnknown: 'parses-return-record-string-unknown',
|
|
9
9
|
parsesReturnObjectWithRecordProperty: 'parses-return-object-with-record-property',
|
|
10
10
|
parsesBufferReturnedFromFunction: 'parses-buffer-returned-from-function',
|
|
11
|
+
parsesDateReturnedFromFunction: 'parses-date-returned-from-function',
|
|
12
|
+
parsesMapReturnedFromFunction: 'parses-map-returned-from-function',
|
|
13
|
+
parsesSetReturnedFromFunction: 'parses-set-returned-from-function',
|
|
14
|
+
parsesRegExpReturnedFromFunction: 'parses-regexp-returned-from-function',
|
|
15
|
+
parsesErrorReturnedFromFunction: 'parses-error-returned-from-function',
|
|
16
|
+
parsesInt8ArrayReturnedFromFunction: 'parses-int8array-returned-from-function',
|
|
17
|
+
parsesFloat32ArrayReturnedFromFunction: 'parses-float32array-returned-from-function',
|
|
18
|
+
parsesArrayBufferReturnedFromFunction: 'parses-arraybuffer-returned-from-function',
|
|
19
|
+
parsesReadableStreamReturnedFromFunction: 'parses-readablestream-returned-from-function',
|
|
20
|
+
parsesPrismaJsonObjectReturnedFromFunction: 'parses-prisma-jsonobject-returned-from-function',
|
|
11
21
|
} as const
|
|
@@ -574,3 +574,81 @@ const getImageData = (): Uint8Array => Buffer.from('foo')
|
|
|
574
574
|
router.get(`/test/${TestCase.parsesBufferReturnedFromFunction}`, () => {
|
|
575
575
|
return useReturnValue(getImageData(), 200, 'image/webp')
|
|
576
576
|
})
|
|
577
|
+
|
|
578
|
+
// Date returned from a function (simulates service/ORM layer)
|
|
579
|
+
const getDateFromService = (): Date => new Date()
|
|
580
|
+
|
|
581
|
+
router.get(`/test/${TestCase.parsesDateReturnedFromFunction}`, () => {
|
|
582
|
+
return { createdAt: getDateFromService() }
|
|
583
|
+
})
|
|
584
|
+
|
|
585
|
+
// Map returned from a function
|
|
586
|
+
const getMapFromService = (): Map<string, number> => new Map()
|
|
587
|
+
|
|
588
|
+
router.get(`/test/${TestCase.parsesMapReturnedFromFunction}`, () => {
|
|
589
|
+
return { data: getMapFromService() }
|
|
590
|
+
})
|
|
591
|
+
|
|
592
|
+
// Set returned from a function
|
|
593
|
+
const getSetFromService = (): Set<string> => new Set()
|
|
594
|
+
|
|
595
|
+
router.get(`/test/${TestCase.parsesSetReturnedFromFunction}`, () => {
|
|
596
|
+
return { data: getSetFromService() }
|
|
597
|
+
})
|
|
598
|
+
|
|
599
|
+
// RegExp returned from a function
|
|
600
|
+
const getRegExpFromService = (): RegExp => /foo/
|
|
601
|
+
|
|
602
|
+
router.get(`/test/${TestCase.parsesRegExpReturnedFromFunction}`, () => {
|
|
603
|
+
return { data: getRegExpFromService() }
|
|
604
|
+
})
|
|
605
|
+
|
|
606
|
+
// Error returned from a function
|
|
607
|
+
const getErrorFromService = (): Error => new Error('foo')
|
|
608
|
+
|
|
609
|
+
router.get(`/test/${TestCase.parsesErrorReturnedFromFunction}`, () => {
|
|
610
|
+
return { data: getErrorFromService() }
|
|
611
|
+
})
|
|
612
|
+
|
|
613
|
+
// Int8Array returned from a function
|
|
614
|
+
const getInt8ArrayFromService = (): Int8Array => new Int8Array()
|
|
615
|
+
|
|
616
|
+
router.get(`/test/${TestCase.parsesInt8ArrayReturnedFromFunction}`, () => {
|
|
617
|
+
return useReturnValue(getInt8ArrayFromService(), 200, 'application/octet-stream')
|
|
618
|
+
})
|
|
619
|
+
|
|
620
|
+
// Float32Array returned from a function
|
|
621
|
+
const getFloat32ArrayFromService = (): Float32Array => new Float32Array()
|
|
622
|
+
|
|
623
|
+
router.get(`/test/${TestCase.parsesFloat32ArrayReturnedFromFunction}`, () => {
|
|
624
|
+
return useReturnValue(getFloat32ArrayFromService(), 200, 'application/octet-stream')
|
|
625
|
+
})
|
|
626
|
+
|
|
627
|
+
// ArrayBuffer returned from a function
|
|
628
|
+
const getArrayBufferFromService = (): ArrayBuffer => new ArrayBuffer(8)
|
|
629
|
+
|
|
630
|
+
router.get(`/test/${TestCase.parsesArrayBufferReturnedFromFunction}`, () => {
|
|
631
|
+
return useReturnValue(getArrayBufferFromService(), 200, 'application/octet-stream')
|
|
632
|
+
})
|
|
633
|
+
|
|
634
|
+
// ReadableStream returned from a function
|
|
635
|
+
const getReadableStreamFromService = (): ReadableStream<Uint8Array> => new ReadableStream()
|
|
636
|
+
|
|
637
|
+
router.get(`/test/${TestCase.parsesReadableStreamReturnedFromFunction}`, () => {
|
|
638
|
+
return useReturnValue(getReadableStreamFromService(), 200, 'application/octet-stream')
|
|
639
|
+
})
|
|
640
|
+
|
|
641
|
+
// Deliberate syntax edge case to simulate Prisma's JsonValue
|
|
642
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
643
|
+
interface PrismaJsonArray extends Array<PrismaJsonValue> {}
|
|
644
|
+
type PrismaJsonValue =
|
|
645
|
+
| string
|
|
646
|
+
| number
|
|
647
|
+
| boolean
|
|
648
|
+
| { [Key in string]?: PrismaJsonValue }
|
|
649
|
+
| PrismaJsonArray
|
|
650
|
+
| null
|
|
651
|
+
|
|
652
|
+
router.get(`/test/${TestCase.parsesPrismaJsonObjectReturnedFromFunction}`, () => {
|
|
653
|
+
return {} as { data: PrismaJsonValue | null }
|
|
654
|
+
})
|
|
@@ -1029,6 +1029,99 @@ describe('OpenApi Analyzer', () => {
|
|
|
1029
1029
|
)
|
|
1030
1030
|
expect(valueProperty.shape).toEqual([{ role: 'buffer', shape: 'buffer', optional: false }])
|
|
1031
1031
|
})
|
|
1032
|
+
it('handles Date returned from external function', () => {
|
|
1033
|
+
const endpoint = analyzeEndpointById(TestCase.parsesDateReturnedFromFunction)
|
|
1034
|
+
expect(endpoint.responses[0].signature).toEqual([
|
|
1035
|
+
{
|
|
1036
|
+
identifier: 'createdAt',
|
|
1037
|
+
optional: false,
|
|
1038
|
+
role: 'property',
|
|
1039
|
+
shape: 'Date',
|
|
1040
|
+
},
|
|
1041
|
+
])
|
|
1042
|
+
})
|
|
1043
|
+
it('handles Map returned from external function', () => {
|
|
1044
|
+
const endpoint = analyzeEndpointById(TestCase.parsesMapReturnedFromFunction)
|
|
1045
|
+
const dataProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1046
|
+
(prop: any) => prop.identifier === 'data',
|
|
1047
|
+
)
|
|
1048
|
+
// Map<string, number> should be represented as a record, not expanded into internal properties
|
|
1049
|
+
expect(dataProperty.shape).toEqual([{ role: 'record', shape: 'number', optional: false }])
|
|
1050
|
+
})
|
|
1051
|
+
it('handles Set returned from external function', () => {
|
|
1052
|
+
const endpoint = analyzeEndpointById(TestCase.parsesSetReturnedFromFunction)
|
|
1053
|
+
const dataProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1054
|
+
(prop: any) => prop.identifier === 'data',
|
|
1055
|
+
)
|
|
1056
|
+
// Set<string> should be represented as an array, not expanded into internal properties
|
|
1057
|
+
expect(dataProperty.shape).toEqual([{ role: 'array', shape: 'string', optional: false }])
|
|
1058
|
+
})
|
|
1059
|
+
it('handles RegExp returned from external function', () => {
|
|
1060
|
+
const endpoint = analyzeEndpointById(TestCase.parsesRegExpReturnedFromFunction)
|
|
1061
|
+
const dataProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1062
|
+
(prop: any) => prop.identifier === 'data',
|
|
1063
|
+
)
|
|
1064
|
+
// RegExp should be represented as a string, not expanded into internal properties
|
|
1065
|
+
expect(dataProperty.shape).toEqual('string')
|
|
1066
|
+
})
|
|
1067
|
+
it('handles Error returned from external function', () => {
|
|
1068
|
+
const endpoint = analyzeEndpointById(TestCase.parsesErrorReturnedFromFunction)
|
|
1069
|
+
const dataProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1070
|
+
(prop: any) => prop.identifier === 'data',
|
|
1071
|
+
)
|
|
1072
|
+
// Error has a small, reasonable property set — expanding is acceptable
|
|
1073
|
+
expect(dataProperty.shape).toEqual([
|
|
1074
|
+
{ identifier: 'name', optional: false, role: 'property', shape: 'string' },
|
|
1075
|
+
{ identifier: 'message', optional: false, role: 'property', shape: 'string' },
|
|
1076
|
+
{ identifier: 'stack', optional: true, role: 'property', shape: 'string' },
|
|
1077
|
+
])
|
|
1078
|
+
})
|
|
1079
|
+
it('handles Int8Array returned from external function', () => {
|
|
1080
|
+
const endpoint = analyzeEndpointById(TestCase.parsesInt8ArrayReturnedFromFunction)
|
|
1081
|
+
const valueProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1082
|
+
(prop: any) => prop.identifier === 'value',
|
|
1083
|
+
)
|
|
1084
|
+
// Int8Array should be treated as buffer, not expanded
|
|
1085
|
+
expect(valueProperty.shape).toEqual([{ role: 'buffer', shape: 'buffer', optional: false }])
|
|
1086
|
+
})
|
|
1087
|
+
it('handles Float32Array returned from external function', () => {
|
|
1088
|
+
const endpoint = analyzeEndpointById(TestCase.parsesFloat32ArrayReturnedFromFunction)
|
|
1089
|
+
const valueProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1090
|
+
(prop: any) => prop.identifier === 'value',
|
|
1091
|
+
)
|
|
1092
|
+
// Float32Array should be treated as buffer, not expanded
|
|
1093
|
+
expect(valueProperty.shape).toEqual([{ role: 'buffer', shape: 'buffer', optional: false }])
|
|
1094
|
+
})
|
|
1095
|
+
it('handles ArrayBuffer returned from external function', () => {
|
|
1096
|
+
const endpoint = analyzeEndpointById(TestCase.parsesArrayBufferReturnedFromFunction)
|
|
1097
|
+
const valueProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1098
|
+
(prop: any) => prop.identifier === 'value',
|
|
1099
|
+
)
|
|
1100
|
+
// ArrayBuffer should be treated as buffer, not expanded
|
|
1101
|
+
expect(valueProperty.shape).toEqual([{ role: 'buffer', shape: 'buffer', optional: false }])
|
|
1102
|
+
})
|
|
1103
|
+
it('handles ReadableStream returned from external function', () => {
|
|
1104
|
+
const endpoint = analyzeEndpointById(TestCase.parsesReadableStreamReturnedFromFunction)
|
|
1105
|
+
const valueProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1106
|
+
(prop: any) => prop.identifier === 'value',
|
|
1107
|
+
)
|
|
1108
|
+
// ReadableStream should be treated as buffer, not expanded
|
|
1109
|
+
expect(valueProperty.shape).toEqual([{ role: 'buffer', shape: 'buffer', optional: false }])
|
|
1110
|
+
})
|
|
1111
|
+
it('handles interface-based JsonArray (Prisma pattern) without leaking Array properties', () => {
|
|
1112
|
+
const endpoint = analyzeEndpointById(TestCase.parsesPrismaJsonObjectReturnedFromFunction)
|
|
1113
|
+
expect(endpoint.responses[0].status).toEqual(200)
|
|
1114
|
+
const dataProperty = (endpoint.responses[0].signature as any[]).find(
|
|
1115
|
+
(prop: any) => prop.identifier === 'data',
|
|
1116
|
+
)
|
|
1117
|
+
// The union should contain an array entry, not expanded Array prototype properties
|
|
1118
|
+
const unionShape = dataProperty.shape[0].shape
|
|
1119
|
+
const arrayEntry = unionShape.find(
|
|
1120
|
+
(entry: any) => Array.isArray(entry.shape) && entry.shape[0]?.role === 'array',
|
|
1121
|
+
)
|
|
1122
|
+
expect(arrayEntry).toBeDefined()
|
|
1123
|
+
expect(arrayEntry.shape[0].role).toEqual('array')
|
|
1124
|
+
})
|
|
1032
1125
|
it('handles content type of normal object', () => {
|
|
1033
1126
|
const endpoint = analyzeEndpointById('a47c9a37-a6cb-45bd-9460-e58562f179d4')
|
|
1034
1127
|
expect(endpoint.responses[0].status).toEqual(200)
|