moonflower 1.4.4 → 1.4.6
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 +101 -92
- package/dist/openapi/analyzerModule/nodeParsers.mjs.map +1 -1
- package/dist/openapi/analyzerModule/test/TestCase.d.ts +4 -0
- package/dist/openapi/analyzerModule/test/TestCase.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/openapi/analyzerModule/nodeParsers.ts +24 -12
- package/src/openapi/analyzerModule/test/TestCase.ts +4 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.data.ts +31 -0
- package/src/openapi/analyzerModule/test/openApiAnalyzer.zod.spec.ts +78 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ts-morph"),S=require("../../utils/logger.cjs"),_=require("../manager/OpenApiManager.cjs"),b=new WeakMap,K=t=>{const i=b.get(t);if(i)return i;if(t.getKind()===e.SyntaxKind.Identifier){const s=t.asKind(e.SyntaxKind.Identifier).getImplementations()[0]?.getNode();if(s){const a=s.getParent().getLastChild();if(a===t)throw new Error("Recursive implementation found");const l=K(a);return b.set(t,l),l}const d=t.asKind(e.SyntaxKind.Identifier).getDefinitions()[0]?.getNode();if(d){const a=d.getParent().getLastChild();if(a===t)throw new Error("Recursive implementation found");const l=K(a);return b.set(t,l),l}throw new Error("No implementation nor definition available")}return b.set(t,t),t},T=t=>{const i=t.getChildrenOfKind(e.SyntaxKind.Identifier);return i.length===2?K(i[1]):t.getChildren().reverse().find(d=>d.getKind()!==e.SyntaxKind.GreaterThanToken&&d.getKind()!==e.SyntaxKind.CommaToken&&d.getKind()!==e.SyntaxKind.SemicolonToken)},P=t=>{const i=t.getFirstChildByKind(e.SyntaxKind.SyntaxList);return i.isKind(e.SyntaxKind.SyntaxList)?x(i.getFirstChild()):x(i)},x=t=>{const i=t.getSymbol()?.getName();if(i&&_.OpenApiManager.getInstance().hasExposedModel(i))return[{role:"ref",shape:i,optional:!1}];const s=K(t);if(s.asKind(e.SyntaxKind.UndefinedKeyword))return"undefined";const n=s.asKind(e.SyntaxKind.LiteralType);if(n){if(n.getFirstChildByKind(e.SyntaxKind.TrueKeyword))return"true";if(n.getFirstChildByKind(e.SyntaxKind.FalseKeyword))return"false"}if(s.asKind(e.SyntaxKind.BooleanKeyword)||s.asKind(e.SyntaxKind.TrueKeyword)||s.asKind(e.SyntaxKind.FalseKeyword))return"boolean";if(s.asKind(e.SyntaxKind.StringKeyword)||s.asKind(e.SyntaxKind.StringLiteral))return"string";if(s.asKind(e.SyntaxKind.NumberKeyword)||s.asKind(e.SyntaxKind.NumericLiteral))return"number";if(s.asKind(e.SyntaxKind.BigIntKeyword)||s.asKind(e.SyntaxKind.BigIntLiteral))return"bigint";const r=s.asKind(e.SyntaxKind.TypeLiteral);if(r)return r.getFirstChildByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertySignature).map(O=>{const v=O.getFirstChildByKind(e.SyntaxKind.Identifier),V=T(O),j=v.getNextSiblingIfKind(e.SyntaxKind.QuestionToken);return{role:"property",identifier:v.getText(),shape:x(V),optional:V.getType().isNullable()||!!j}});const o=s.asKind(e.SyntaxKind.TypeReference);if(o)return x(o.getFirstChild());if(s.asKind(e.SyntaxKind.PropertyAccessExpression)){const E=K(s.getLastChild());return g(E.asKind(e.SyntaxKind.CallExpression).getReturnType(),E)}const c=s.asKind(e.SyntaxKind.UnionType);if(c)return g(c.getType(),s);const f=s.asKind(e.SyntaxKind.TypeQuery);if(f)return x(f.getLastChild());const A=s.asKind(e.SyntaxKind.QualifiedName);if(A)return x(A.getLastChild());const C=s.asKind(e.SyntaxKind.CallExpression);if(C)return g(C.getReturnType(),C);const F=s.asKind(e.SyntaxKind.AwaitExpression);if(F)return x(F.getChildAtIndex(1));const L=s.asKind(e.SyntaxKind.AsExpression);if(L)return x(L.getChildAtIndex(2));const R=s.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${R}] Unknown node type: ${s.getKindName()}`),"unknown_1"},U=t=>t.getFirstDescendantByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).map(n=>{const a=n.getFirstChild(),l=(()=>{if(a.isKind(e.SyntaxKind.Identifier))return a.getText();if(a.isKind(e.SyntaxKind.StringLiteral))return a.getLiteralText();const r=n.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${r}] Unknown identifier name: ${a.getText()}`),"unknown_30"})(),u=n.getLastChild(),p=K(u);return{role:"property",identifier:l,shape:m(p),optional:I(p),description:h(p,"description"),errorMessage:h(p,"errorMessage")}})||[],N=t=>{const i=t.asKind(e.SyntaxKind.CallExpression);return i?(i.getReturnType().getSymbol()?.getName()??"").startsWith("Zod"):!1},w=t=>{const i=t.asKind(e.SyntaxKind.CallExpression),s=i.getReturnType(),d=s.getSymbol()?.getName()??"";if(d==="ZodNumber")return"number";if(d==="ZodString")return"string";if(d==="ZodBoolean")return"boolean";if(d==="ZodBigInt")return"bigint";if(d==="ZodObject"){const l=i.getFirstChildByKind(e.SyntaxKind.SyntaxList)?.getFirstChild()?.asKind(e.SyntaxKind.ObjectLiteralExpression);if(!l)return"unknown_zod_object";const u=l.getFirstChildByKind(e.SyntaxKind.SyntaxList);return u?u.getChildrenOfKind(e.SyntaxKind.PropertyAssignment).map(r=>{const o=r.getFirstChildByKind(e.SyntaxKind.Identifier).getText(),y=r.getLastChild();return{role:"property",identifier:o,shape:N(y)?w(y):m(y),optional:!1}}):[]}if(d==="ZodArray"){const a=i.getFirstChildByKind(e.SyntaxKind.SyntaxList)?.getFirstChild();return a?[{role:"array",shape:N(a)?w(a):m(a),optional:!1}]:"unknown_zod_array"}if(d==="ZodEnum"){const a=s.getTypeArguments();if(a.length>0){const p=a[0].getProperties().map(r=>({role:"union_entry",shape:g(r.getTypeAtLocation(i),i,[]),optional:!1}));if(p.length===1)return p[0].shape;if(p.length>1)return[{role:"union",shape:p,optional:!1}]}return"unknown_zod_enum"}if(d==="ZodOptional"){const a=i.getFirstChildByKind(e.SyntaxKind.PropertyAccessExpression)?.getFirstChildByKind(e.SyntaxKind.CallExpression);return a&&N(a)?w(a):"unknown_zod_optional"}const n=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${n}] Unknown zod type: ${d}`),"unknown_zod"},m=t=>{if(N(t))return w(t);const i=t.getParent().getFirstChildByKind(e.SyntaxKind.AsExpression);if(i){const r=i.getLastChildByKind(e.SyntaxKind.TypeReference);return P(r)}const s=t.getParent().getFirstChildByKind(e.SyntaxKind.TypeReference);if(s)return P(s);if(t.getParent().getChildrenOfKind(e.SyntaxKind.SyntaxList).length>=2){const r=t.getParent().getFirstChildByKind(e.SyntaxKind.SyntaxList).getFirstChild();return x(r)}const d=t.getParent().getFirstChildByKind(e.SyntaxKind.CallExpression);if(d){const r=K(d.getFirstChildByKind(e.SyntaxKind.SyntaxList).getFirstChild()),o=r.getParent().getFirstChildByKind(e.SyntaxKind.TypeReference);if(o)return g(o.getType(),o,[]);const y=r.getParent().getFirstChildByKind(e.SyntaxKind.ObjectLiteralExpression);if(y)return m(y);if(r.getKind()===e.SyntaxKind.CallExpression||r.getKind()===e.SyntaxKind.IntersectionType)return m(r);const c=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${c}] Unknown call expression argument: ${r.getKindName()}`),"unknown_3"}const a=t.getFirstChildByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).find(r=>r.getFirstChildByKind(e.SyntaxKind.Identifier)?.getText()==="parse");if(a){const r=T(a).asKind(e.SyntaxKind.ArrowFunction).getReturnType();return g(r,a)}const l=t.getFirstChildByKind(e.SyntaxKind.SyntaxList)?.getFirstChildByKind(e.SyntaxKind.ImportType);if(l){const r=l.getLastChildByKind(e.SyntaxKind.GreaterThanToken).getChildIndex(),o=l.getChildAtIndex(r-1);return x(o.getFirstChild())}const u=t.isKind(e.SyntaxKind.IntersectionType)?t:t.getParent()?.isKind(e.SyntaxKind.VariableDeclaration)?t.getParent()?.getFirstChildByKind(e.SyntaxKind.IntersectionType):null;if(u){const r=u.getFirstChildByKind(e.SyntaxKind.TypeReference);if(r)return P(r)}const p=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${p}] Unknown import type node`),"unknown_2"},I=t=>{if(N(t))return(t.asKind(e.SyntaxKind.CallExpression).getReturnType().getSymbol()?.getName()??"")==="ZodOptional";const i=t.asKind(e.SyntaxKind.CallExpression);if(i){const n=i.getFirstChildByKind(e.SyntaxKind.Identifier);if(n?.getText()==="OptionalParam")return!0;if(n?.getText()==="RequiredParam")return!1;const a=i.getFirstChildByKind(e.SyntaxKind.SyntaxList),l=K(a.getFirstChild());return I(l)}return t.getFirstDescendantByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).some(n=>n.getFirstDescendantByKind(e.SyntaxKind.Identifier).getText()==="optional"?T(n).getKind()===e.SyntaxKind.TrueKeyword:!1)},h=(t,i)=>{if(N(t))return"";const s=K(t),d=s.asKind(e.SyntaxKind.CallExpression);if(d){const o=d.getLastChildByKind(e.SyntaxKind.SyntaxList);return h(o,i)}const n=s.asKind(e.SyntaxKind.SyntaxList);if(n)return n.getChildren().map(y=>h(y,i)).find(y=>!!y&&y!=="unknown_25")||"";const a=s.asKind(e.SyntaxKind.ObjectLiteralExpression);if(a){const y=k(a).find(c=>c.identifier===i);return y?Array.isArray(y.value)?"array":y.value||"":""}const l=s.asKind(e.SyntaxKind.IntersectionType);if(l)return l.getTypeNodes().flatMap(o=>h(o,i)).filter(o=>!!o&&o!=="unknown_25")[0]||"unknown_27";const u=s.asKind(e.SyntaxKind.TypeLiteral);if(u)return h(u.getFirstChildByKind(e.SyntaxKind.SyntaxList),i);const p=s.asKind(e.SyntaxKind.PropertySignature);if(p&&s.getFirstDescendantByKind(e.SyntaxKind.Identifier).getText()===i)return T(p).getFirstDescendantByKind(e.SyntaxKind.StringLiteral).getLiteralText();const r=s.getSourceFile().getFilePath().split("/").pop();return S.Logger.dev(`[${r}] Unknown property string value node ${s.getKindName()}`),"unknown_25"},D=t=>{const i=t.getSymbol();if(!t.isObject()||!i)return!1;const s=t.getTypeArguments();return i.getName()==="Promise"&&s.length===1},g=(t,i,s=[])=>{const d=t.getAliasSymbol()?.getName();if(d&&_.OpenApiManager.getInstance().hasExposedModel(d))return[{role:"ref",shape:d,optional:!1}];const n=D(t)?t.getTypeArguments()[0]:t;if(s.some(r=>r===n))return"circular";const a=s.concat(n);if(n.getText()==="void")return"void";if(n.isAny())return"any";if(n.isUnknown())return"unknown";if(n.isNull())return"null";if(n.isUndefined())return"undefined";if(n.isBoolean()||n.isBooleanLiteral())return"boolean";if(n.isStringLiteral())return[{role:"literal_string",shape:String(n.getLiteralValue()),optional:!1}];if(n.isNumberLiteral())return[{role:"literal_number",shape:String(n.getLiteralValue()),optional:!1}];if(n.isString()||n.isTemplateLiteral())return"string";if(n.isNumber())return"number";if(n.getText()==="bigint")return"bigint";if(n.isTuple())return[{role:"tuple",shape:n.getTupleElements().map(r=>({role:"tuple_entry",shape:g(r,i,a),optional:!1})),optional:!1}];if(n.isArray())return[{role:"array",shape:g(n.getArrayElementType(),i,a),optional:!1}];if(n.isObject()){const r=n.getNumberIndexType(),y=n.getBaseTypes()?.find(c=>c.isArray());if(y)return[{role:"array",shape:g(y.getArrayElementType()??r,i,a),optional:!1}]}const l=n.getSymbol()?.getName(),u=new Set(["Buffer","Uint8Array","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","ArrayBuffer","SharedArrayBuffer","ReadableStream"]);if(n.isObject()&&l&&u.has(l))return[{role:"buffer",shape:"buffer",optional:!1}];if(n.isObject()&&l==="RegExp")return"string";if(n.isObject()&&l==="Map"){const o=n.getTypeArguments()[1];return[{role:"record",shape:o?g(o,i,a):"unknown",optional:!1}]}if(n.isObject()&&l==="Set"){const o=n.getTypeArguments()[0];return[{role:"array",shape:o?g(o,i,a):"unknown",optional:!1}]}if(n.isObject()&&n.getProperties().length===0){const r=n.getAliasTypeArguments()[1]??n.getStringIndexType();if(r)return[{role:"record",shape:g(r,i,a),optional:!1}]}if(n.isObject())return l==="Date"||n.getText()==="Date"?"Date":n.getProperties().map(r=>{const o=r.getValueDeclaration()||r.getDeclarations()[0];if(!o)return{role:"property",identifier:r.getName(),shape:g(r.getTypeAtLocation(i),i,a),optional:!1};if(!(o.asKind(e.SyntaxKind.PropertySignature)||o.asKind(e.SyntaxKind.PropertyAssignment)||o.asKind(e.SyntaxKind.ShorthandPropertyAssignment)))return{role:"property",identifier:r.getName(),shape:g(r.getTypeAtLocation(i),i,a),optional:!1};const c=r.getTypeAtLocation(i).isNullable(),f=g(r.getTypeAtLocation(i),i,a);return{role:"property",identifier:r.getName(),shape:f,optional:c}}).filter(r=>r.shape!=="undefined");if(n.isUnion()){const o=n.getUnionTypes().map(f=>({role:"union_entry",shape:g(f,i,a),optional:!1})).filter((f,A,C)=>!C.find((F,L)=>F.shape===f.shape&&L>A)),y=o.some(f=>f.shape==="undefined"),c=o.filter(f=>f.shape!=="undefined");return c.length===1?c[0].shape:[{role:"union",shape:c,optional:y}]}if(n.isIntersection())return n.getIntersectionTypes().map(y=>g(y,i,a)).filter(y=>typeof y!="string").reduce((y,c)=>[...y,...c],[]);const p=i.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${p}] Unknown type shape node ${t.getText()}`),"unknown_5"},B=t=>{if(t.isKind(e.SyntaxKind.Identifier))return B(K(t));if(t.isKind(e.SyntaxKind.StringLiteral))return t.getLiteralValue();if(t.isKind(e.SyntaxKind.ArrayLiteralExpression))return t.forEachChildAsArray().map(s=>B(s));if(t.isKind(e.SyntaxKind.PropertyAccessExpression))return B(T(t));if(t.isKind(e.SyntaxKind.ObjectLiteralExpression))return k(t);const i=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.dev(`[${i}] Unknown literal value node ${t.getKindName()}`),"unknown_6"},M=t=>{const i=t.getFirstDescendantByKind(e.SyntaxKind.CallExpression);if(!i)return null;const s=i.getArguments()[0];if(!s)return null;const d=s.getType();return d.isStringLiteral()?d.getLiteralValue():null},k=t=>t.getFirstDescendantByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).map(n=>{const l=n.getFirstDescendantByKind(e.SyntaxKind.Identifier).getText(),u=n.getLastChild(),p=K(u),r=B(p);return{identifier:l,value:r}})||[];exports.findNodeImplementation=K;exports.findPropertyAssignmentValueNode=T;exports.getProperTypeShape=g;exports.getRecursiveNodeShape=x;exports.getShapeOfValidatorLiteral=U;exports.getTypeReferenceShape=P;exports.getValidatorPropertyOptionality=I;exports.getValidatorPropertyShape=m;exports.getValidatorPropertyStringValue=h;exports.getValuesOfObjectLiteral=k;exports.resolveEndpointPath=M;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("ts-morph"),S=require("../../utils/logger.cjs"),_=require("../manager/OpenApiManager.cjs"),P=new WeakMap,K=t=>{const i=P.get(t);if(i)return i;if(t.getKind()===e.SyntaxKind.Identifier){const s=t.asKind(e.SyntaxKind.Identifier).getImplementations()[0]?.getNode();if(s){const a=s.getParent().getLastChild();if(a===t)throw new Error("Recursive implementation found");const l=K(a);return P.set(t,l),l}const d=t.asKind(e.SyntaxKind.Identifier).getDefinitions()[0]?.getNode();if(d){const a=d.getParent().getLastChild();if(a===t)throw new Error("Recursive implementation found");const l=K(a);return P.set(t,l),l}throw new Error("No implementation nor definition available")}return P.set(t,t),t},T=t=>{const i=t.getChildrenOfKind(e.SyntaxKind.Identifier);return i.length===2?K(i[1]):t.getChildren().reverse().find(d=>d.getKind()!==e.SyntaxKind.GreaterThanToken&&d.getKind()!==e.SyntaxKind.CommaToken&&d.getKind()!==e.SyntaxKind.SemicolonToken)},w=t=>{const i=t.getFirstChildByKind(e.SyntaxKind.SyntaxList);return i.isKind(e.SyntaxKind.SyntaxList)?x(i.getFirstChild()):x(i)},x=t=>{const i=t.getSymbol()?.getName();if(i&&_.OpenApiManager.getInstance().hasExposedModel(i))return[{role:"ref",shape:i,optional:!1}];const s=K(t);if(s.asKind(e.SyntaxKind.UndefinedKeyword))return"undefined";const n=s.asKind(e.SyntaxKind.LiteralType);if(n){if(n.getFirstChildByKind(e.SyntaxKind.TrueKeyword))return"true";if(n.getFirstChildByKind(e.SyntaxKind.FalseKeyword))return"false"}if(s.asKind(e.SyntaxKind.BooleanKeyword)||s.asKind(e.SyntaxKind.TrueKeyword)||s.asKind(e.SyntaxKind.FalseKeyword))return"boolean";if(s.asKind(e.SyntaxKind.StringKeyword)||s.asKind(e.SyntaxKind.StringLiteral))return"string";if(s.asKind(e.SyntaxKind.NumberKeyword)||s.asKind(e.SyntaxKind.NumericLiteral))return"number";if(s.asKind(e.SyntaxKind.BigIntKeyword)||s.asKind(e.SyntaxKind.BigIntLiteral))return"bigint";const r=s.asKind(e.SyntaxKind.TypeLiteral);if(r)return r.getFirstChildByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertySignature).map(O=>{const v=O.getFirstChildByKind(e.SyntaxKind.Identifier),V=T(O),j=v.getNextSiblingIfKind(e.SyntaxKind.QuestionToken);return{role:"property",identifier:v.getText(),shape:x(V),optional:V.getType().isNullable()||!!j}});const o=s.asKind(e.SyntaxKind.TypeReference);if(o)return x(o.getFirstChild());if(s.asKind(e.SyntaxKind.PropertyAccessExpression)){const E=K(s.getLastChild());return u(E.asKind(e.SyntaxKind.CallExpression).getReturnType(),E)}const c=s.asKind(e.SyntaxKind.UnionType);if(c)return u(c.getType(),s);const f=s.asKind(e.SyntaxKind.TypeQuery);if(f)return x(f.getLastChild());const F=s.asKind(e.SyntaxKind.QualifiedName);if(F)return x(F.getLastChild());const C=s.asKind(e.SyntaxKind.CallExpression);if(C)return u(C.getReturnType(),C);const L=s.asKind(e.SyntaxKind.AwaitExpression);if(L)return x(L.getChildAtIndex(1));const b=s.asKind(e.SyntaxKind.AsExpression);if(b)return x(b.getChildAtIndex(2));const R=s.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${R}] Unknown node type: ${s.getKindName()}`),"unknown_1"},U=t=>t.getFirstDescendantByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).map(n=>{const a=n.getFirstChild(),l=(()=>{if(a.isKind(e.SyntaxKind.Identifier))return a.getText();if(a.isKind(e.SyntaxKind.StringLiteral))return a.getLiteralText();const r=n.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${r}] Unknown identifier name: ${a.getText()}`),"unknown_30"})(),p=n.getLastChild(),g=K(p);return{role:"property",identifier:l,shape:N(g),optional:I(g),description:m(g,"description"),errorMessage:m(g,"errorMessage")}})||[],h=t=>{const i=t.asKind(e.SyntaxKind.CallExpression);return i?(i.getReturnType().getSymbol()?.getName()??"").startsWith("Zod"):!1},A=t=>{const i=t.asKind(e.SyntaxKind.CallExpression),s=i.getReturnType(),d=s.getSymbol()?.getName()??"";if(d==="ZodNumber")return"number";if(d==="ZodString")return"string";if(d==="ZodBoolean")return"boolean";if(d==="ZodBigInt")return"bigint";if(d==="ZodObject"){const l=i.getFirstChildByKind(e.SyntaxKind.SyntaxList)?.getFirstChild()?.asKind(e.SyntaxKind.ObjectLiteralExpression);if(!l)return"unknown_zod_object";const p=l.getFirstChildByKind(e.SyntaxKind.SyntaxList);return p?p.getChildrenOfKind(e.SyntaxKind.PropertyAssignment).map(r=>{const o=r.getFirstChildByKind(e.SyntaxKind.Identifier).getText(),y=r.getLastChild();return{role:"property",identifier:o,shape:h(y)?A(y):N(y),optional:!1}}):[]}if(d==="ZodArray"){const a=i.getFirstChildByKind(e.SyntaxKind.SyntaxList)?.getFirstChild();if(a)return[{role:"array",shape:h(a)?A(a):N(a),optional:!1}];const p=i.getFirstChildByKind(e.SyntaxKind.PropertyAccessExpression)?.getFirstChildByKind(e.SyntaxKind.CallExpression);return p&&h(p)?[{role:"array",shape:A(p),optional:!1}]:"unknown_zod_array"}if(d==="ZodEnum"){const a=s.getTypeArguments();if(a.length>0){const g=a[0].getProperties().map(r=>({role:"union_entry",shape:u(r.getTypeAtLocation(i),i,[]),optional:!1}));if(g.length===1)return g[0].shape;if(g.length>1)return[{role:"union",shape:g,optional:!1}]}return"unknown_zod_enum"}if(d==="ZodOptional"){const a=i.getFirstChildByKind(e.SyntaxKind.PropertyAccessExpression)?.getFirstChildByKind(e.SyntaxKind.CallExpression);return a&&h(a)?A(a):"unknown_zod_optional"}const n=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${n}] Unknown zod type: ${d}`),"unknown_zod"},N=t=>{if(h(t))return A(t);const i=t.getParent().getFirstChildByKind(e.SyntaxKind.AsExpression);if(i){const r=i.getLastChildByKind(e.SyntaxKind.TypeReference);return w(r)}const s=t.getParent().getFirstChildByKind(e.SyntaxKind.TypeReference);if(s)return w(s);if(t.getParent().getChildrenOfKind(e.SyntaxKind.SyntaxList).length>=2){const r=t.getParent().getFirstChildByKind(e.SyntaxKind.SyntaxList).getFirstChild();return x(r)}const d=t.getParent().getFirstChildByKind(e.SyntaxKind.CallExpression);if(d){const r=K(d.getFirstChildByKind(e.SyntaxKind.SyntaxList).getFirstChild()),o=r.getParent().getFirstChildByKind(e.SyntaxKind.TypeReference);if(o)return u(o.getType(),o,[]);const y=r.getParent().getFirstChildByKind(e.SyntaxKind.ObjectLiteralExpression);if(y)return N(y);if(r.getKind()===e.SyntaxKind.CallExpression||r.getKind()===e.SyntaxKind.IntersectionType)return N(r);const c=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${c}] Unknown call expression argument: ${r.getKindName()}`),"unknown_3"}const a=t.getFirstChildByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).find(r=>r.getFirstChildByKind(e.SyntaxKind.Identifier)?.getText()==="parse");if(a){const r=T(a).asKind(e.SyntaxKind.ArrowFunction).getReturnType();return u(r,a)}const l=t.getFirstChildByKind(e.SyntaxKind.SyntaxList)?.getFirstChildByKind(e.SyntaxKind.ImportType);if(l){const r=l.getLastChildByKind(e.SyntaxKind.GreaterThanToken).getChildIndex(),o=l.getChildAtIndex(r-1);return x(o.getFirstChild())}const p=t.isKind(e.SyntaxKind.IntersectionType)?t:t.getParent()?.isKind(e.SyntaxKind.VariableDeclaration)?t.getParent()?.getFirstChildByKind(e.SyntaxKind.IntersectionType):null;if(p){const r=p.getFirstChildByKind(e.SyntaxKind.TypeReference);if(r)return w(r)}const g=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${g}] Unknown import type node`),"unknown_2"},I=t=>{if(h(t))return(t.asKind(e.SyntaxKind.CallExpression).getReturnType().getSymbol()?.getName()??"")==="ZodOptional";const i=t.asKind(e.SyntaxKind.CallExpression);if(i){const n=i.getFirstChildByKind(e.SyntaxKind.Identifier);if(n?.getText()==="OptionalParam")return!0;if(n?.getText()==="RequiredParam")return!1;const a=i.getFirstChildByKind(e.SyntaxKind.SyntaxList),l=K(a.getFirstChild());return I(l)}return t.getFirstDescendantByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).some(n=>n.getFirstDescendantByKind(e.SyntaxKind.Identifier).getText()==="optional"?T(n).getKind()===e.SyntaxKind.TrueKeyword:!1)},m=(t,i)=>{if(h(t))return"";const s=K(t),d=s.asKind(e.SyntaxKind.CallExpression);if(d){const o=d.getLastChildByKind(e.SyntaxKind.SyntaxList);return m(o,i)}const n=s.asKind(e.SyntaxKind.SyntaxList);if(n)return n.getChildren().map(y=>m(y,i)).find(y=>!!y&&y!=="unknown_25")||"";const a=s.asKind(e.SyntaxKind.ObjectLiteralExpression);if(a){const y=k(a).find(c=>c.identifier===i);return y?Array.isArray(y.value)?"array":y.value||"":""}const l=s.asKind(e.SyntaxKind.IntersectionType);if(l)return l.getTypeNodes().flatMap(o=>m(o,i)).filter(o=>!!o&&o!=="unknown_25")[0]||"unknown_27";const p=s.asKind(e.SyntaxKind.TypeLiteral);if(p)return m(p.getFirstChildByKind(e.SyntaxKind.SyntaxList),i);const g=s.asKind(e.SyntaxKind.PropertySignature);if(g&&s.getFirstDescendantByKind(e.SyntaxKind.Identifier).getText()===i)return T(g).getFirstDescendantByKind(e.SyntaxKind.StringLiteral).getLiteralText();const r=s.getSourceFile().getFilePath().split("/").pop();return S.Logger.dev(`[${r}] Unknown property string value node ${s.getKindName()}`),"unknown_25"},D=t=>{const i=t.getSymbol();if(!t.isObject()||!i)return!1;const s=t.getTypeArguments();return i.getName()==="Promise"&&s.length===1},u=(t,i,s=[])=>{const d=t.getAliasSymbol()?.getName();if(d&&_.OpenApiManager.getInstance().hasExposedModel(d))return[{role:"ref",shape:d,optional:!1}];const n=D(t)?t.getTypeArguments()[0]:t;if(s.some(r=>r===n))return"circular";const a=s.concat(n);if(n.getText()==="void")return"void";if(n.isAny())return"any";if(n.isUnknown())return"unknown";if(n.isNull())return"null";if(n.isUndefined())return"undefined";if(n.isBoolean()||n.isBooleanLiteral())return"boolean";if(n.isStringLiteral())return[{role:"literal_string",shape:String(n.getLiteralValue()),optional:!1}];if(n.isNumberLiteral())return[{role:"literal_number",shape:String(n.getLiteralValue()),optional:!1}];if(n.isString()||n.isTemplateLiteral())return"string";if(n.isNumber())return"number";if(n.getText()==="bigint")return"bigint";if(n.isTuple())return[{role:"tuple",shape:n.getTupleElements().map(r=>({role:"tuple_entry",shape:u(r,i,a),optional:!1})),optional:!1}];if(n.isArray())return[{role:"array",shape:u(n.getArrayElementType(),i,a),optional:!1}];if(n.isObject()){const r=n.getNumberIndexType(),y=n.getBaseTypes()?.find(c=>c.isArray());if(y)return[{role:"array",shape:u(y.getArrayElementType()??r,i,a),optional:!1}]}const l=n.getSymbol()?.getName(),p=new Set(["Buffer","Uint8Array","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","ArrayBuffer","SharedArrayBuffer","ReadableStream"]);if(n.isObject()&&l&&p.has(l))return[{role:"buffer",shape:"buffer",optional:!1}];if(n.isObject()&&l==="RegExp")return"string";if(n.isObject()&&l==="Map"){const o=n.getTypeArguments()[1];return[{role:"record",shape:o?u(o,i,a):"unknown",optional:!1}]}if(n.isObject()&&l==="Set"){const o=n.getTypeArguments()[0];return[{role:"array",shape:o?u(o,i,a):"unknown",optional:!1}]}if(n.isObject()&&n.getProperties().length===0){const r=n.getAliasTypeArguments()[1]??n.getStringIndexType();if(r)return[{role:"record",shape:u(r,i,a),optional:!1}]}if(n.isObject())return l==="Date"||n.getText()==="Date"?"Date":n.getProperties().map(r=>{const o=r.getValueDeclaration()||r.getDeclarations()[0];if(!o)return{role:"property",identifier:r.getName(),shape:u(r.getTypeAtLocation(i),i,a),optional:!1};if(!(o.asKind(e.SyntaxKind.PropertySignature)||o.asKind(e.SyntaxKind.PropertyAssignment)||o.asKind(e.SyntaxKind.ShorthandPropertyAssignment)))return{role:"property",identifier:r.getName(),shape:u(r.getTypeAtLocation(i),i,a),optional:!1};const c=r.getTypeAtLocation(i).isNullable(),f=u(r.getTypeAtLocation(i),i,a);return{role:"property",identifier:r.getName(),shape:f,optional:c}}).filter(r=>r.shape!=="undefined");if(n.isUnion()){const o=n.getUnionTypes().map(f=>({role:"union_entry",shape:u(f,i,a),optional:!1})).filter((f,F,C)=>!C.find((L,b)=>L.shape===f.shape&&b>F)),y=o.some(f=>f.shape==="undefined"),c=o.filter(f=>f.shape!=="undefined");return c.length===1?c[0].shape:[{role:"union",shape:c,optional:y}]}if(n.isIntersection())return n.getIntersectionTypes().map(y=>u(y,i,a)).filter(y=>typeof y!="string").reduce((y,c)=>[...y,...c],[]);const g=i.getSourceFile().getFilePath().split("/").pop();return S.Logger.warn(`[${g}] Unknown type shape node ${t.getText()}`),"unknown_5"},B=t=>{if(t.isKind(e.SyntaxKind.Identifier))return B(K(t));if(t.isKind(e.SyntaxKind.StringLiteral))return t.getLiteralValue();if(t.isKind(e.SyntaxKind.ArrayLiteralExpression))return t.forEachChildAsArray().map(s=>B(s));if(t.isKind(e.SyntaxKind.PropertyAccessExpression))return B(T(t));if(t.isKind(e.SyntaxKind.ObjectLiteralExpression))return k(t);const i=t.getSourceFile().getFilePath().split("/").pop();return S.Logger.dev(`[${i}] Unknown literal value node ${t.getKindName()}`),"unknown_6"},M=t=>{const i=t.getFirstDescendantByKind(e.SyntaxKind.CallExpression);if(!i)return null;const s=i.getArguments()[0];if(!s)return null;const d=s.getType();return d.isStringLiteral()?d.getLiteralValue():null},k=t=>t.getFirstDescendantByKind(e.SyntaxKind.SyntaxList).getChildrenOfKind(e.SyntaxKind.PropertyAssignment).map(n=>{const l=n.getFirstDescendantByKind(e.SyntaxKind.Identifier).getText(),p=n.getLastChild(),g=K(p),r=B(g);return{identifier:l,value:r}})||[];exports.findNodeImplementation=K;exports.findPropertyAssignmentValueNode=T;exports.getProperTypeShape=u;exports.getRecursiveNodeShape=x;exports.getShapeOfValidatorLiteral=U;exports.getTypeReferenceShape=w;exports.getValidatorPropertyOptionality=I;exports.getValidatorPropertyShape=N;exports.getValidatorPropertyStringValue=m;exports.getValuesOfObjectLiteral=k;exports.resolveEndpointPath=M;
|
|
2
2
|
//# sourceMappingURL=nodeParsers.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeParsers.cjs","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\tif (typeName === 'ZodEnum') {\n\t\tconst typeArgs = returnType.getTypeArguments()\n\t\tif (typeArgs.length > 0) {\n\t\t\tconst enumType = typeArgs[0]\n\t\t\tconst properties = enumType.getProperties()\n\t\t\tconst shapes: ShapeOfUnionEntry[] = properties.map((prop) => ({\n\t\t\t\trole: 'union_entry' as const,\n\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(callExpression), callExpression, []),\n\t\t\t\toptional: false,\n\t\t\t}))\n\t\t\tif (shapes.length === 1) {\n\t\t\t\treturn shapes[0].shape\n\t\t\t}\n\t\t\tif (shapes.length > 1) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\trole: 'union' as const,\n\t\t\t\t\t\tshape: shapes,\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t\treturn 'unknown_zod_enum'\n\t}\n\n\tif (typeName === 'ZodOptional') {\n\t\tconst innerCallExpression = callExpression\n\t\t\t.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)\n\t\t\t?.getFirstChildByKind(SyntaxKind.CallExpression)\n\t\tif (innerCallExpression && isZodCallExpression(innerCallExpression)) {\n\t\t\treturn getZodCallShape(innerCallExpression)\n\t\t}\n\t\treturn 'unknown_zod_optional'\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\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\t\tconst returnType = callExpression.getReturnType()\n\t\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\t\tif (typeName === 'ZodOptional') {\n\t\t\treturn true\n\t\t}\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","returnType","objectLiteral","syntaxList","prop","argNode","typeArgs","shapes","innerCallExpression","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","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","total","current","getLiteralValueOfNode","resolveEndpointPath","firstArg","argType","targetNode"],"mappings":"2LAgBMA,MAA0B,QAEnBC,EAA0BC,GAAqB,CACrD,MAAAC,EAASH,EAAoB,IAAIE,CAAI,EAC3C,GAAIC,EACI,OAAAA,EAGR,GAAID,EAAK,YAAcE,EAAAA,WAAW,WAAY,CACvC,MAAAC,EAAqBH,EAAK,OAAOE,EAA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AAgC/B,EAAK,YAAa,CAAA,EAAE,EAEpE,WACR,EAEa2G,EAAuB3G,GAA8B,CACjE,MAAM0C,EAAiB1C,EAAK,yBAAyBE,EAAAA,WAAW,cAAc,EAC1E,GAAA,CAACwC,EAAuB,OAAA,KAE5B,MAAMkE,EAAWlE,EAAe,aAAa,EAAE,CAAC,EAC5C,GAAA,CAACkE,EAAiB,OAAA,KAEhB,MAAAC,EAAUD,EAAS,QAAQ,EAC7B,OAAAC,EAAQ,kBACJA,EAAQ,gBAAgB,EAGzB,IACR,EAEarC,EAA4BtC,GACjBA,EAAkB,yBAAyBhC,EAAAA,WAAW,UAAU,EAChD,kBAAkBA,EAAAA,WAAW,kBAAkB,EAEnD,IAAKF,GAAS,CAE1C,MAAAoC,EADiBpC,EAAK,yBAAyBE,EAAAA,WAAW,UAAU,EACpC,QAAQ,EAExCE,EAAsBJ,EAAK,aAAa,EACxC8G,EAAa/G,EAAuBK,CAAmB,EACvDkE,EAAQoC,EAAsBI,CAAU,EAEvC,MAAA,CACN,WAAY1E,EACZ,MAAAkC,CACD,CAAA,CACA,GAEoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"nodeParsers.cjs","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\tconst elementShape = isZodCallExpression(argNode)\n\t\t\t\t? getZodCallShape(argNode)\n\t\t\t\t: getValidatorPropertyShape(argNode)\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'array' as const,\n\t\t\t\t\tshape: elementShape,\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\t// Handle chained form: z.string().array()\n\t\tconst propertyAccess = callExpression.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)\n\t\tconst receiverCall = propertyAccess?.getFirstChildByKind(SyntaxKind.CallExpression)\n\t\tif (receiverCall && isZodCallExpression(receiverCall)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'array' as const,\n\t\t\t\t\tshape: getZodCallShape(receiverCall),\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\treturn 'unknown_zod_array'\n\t}\n\n\tif (typeName === 'ZodEnum') {\n\t\tconst typeArgs = returnType.getTypeArguments()\n\t\tif (typeArgs.length > 0) {\n\t\t\tconst enumType = typeArgs[0]\n\t\t\tconst properties = enumType.getProperties()\n\t\t\tconst shapes: ShapeOfUnionEntry[] = properties.map((prop) => ({\n\t\t\t\trole: 'union_entry' as const,\n\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(callExpression), callExpression, []),\n\t\t\t\toptional: false,\n\t\t\t}))\n\t\t\tif (shapes.length === 1) {\n\t\t\t\treturn shapes[0].shape\n\t\t\t}\n\t\t\tif (shapes.length > 1) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\trole: 'union' as const,\n\t\t\t\t\t\tshape: shapes,\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t\treturn 'unknown_zod_enum'\n\t}\n\n\tif (typeName === 'ZodOptional') {\n\t\tconst innerCallExpression = callExpression\n\t\t\t.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)\n\t\t\t?.getFirstChildByKind(SyntaxKind.CallExpression)\n\t\tif (innerCallExpression && isZodCallExpression(innerCallExpression)) {\n\t\t\treturn getZodCallShape(innerCallExpression)\n\t\t}\n\t\treturn 'unknown_zod_optional'\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\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\t\tconst returnType = callExpression.getReturnType()\n\t\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\t\tif (typeName === 'ZodOptional') {\n\t\t\treturn true\n\t\t}\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","returnType","objectLiteral","syntaxList","prop","argNode","receiverCall","typeArgs","shapes","innerCallExpression","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","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","total","current","getLiteralValueOfNode","resolveEndpointPath","firstArg","argType","targetNode"],"mappings":"2LAgBMA,MAA0B,QAEnBC,EAA0BC,GAAqB,CACrD,MAAAC,EAASH,EAAoB,IAAIE,CAAI,EAC3C,GAAIC,EACI,OAAAA,EAGR,GAAID,EAAK,YAAcE,EAAAA,WAAW,WAA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EAAE,CAAC,uBAAuB,CAAC,KACjD,CAAC,eAAe,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC,EAgCnE,CAAA;AA6HD,eAAO,MAAM,yBAAyB,qBAAsB,IAAI,KAAG,WAAW,CAAC,OAAO,CA6GrF,CAAA;AAED,eAAO,MAAM,+BAA+B,SAAU,IAAI,KAAG,OAsC5D,CAAA;AAED,eAAO,MAAM,+BAA+B,oBAC1B,IAAI,QACf,aAAa,GAAG,cAAc,KAClC,MA6DF,CAAA;AAWD,eAAO,MAAM,kBAAkB,kBACf,IAAI,cACP,IAAI,UACT,IAAI,EAAE,KACX,WAAW,CAAC,OAAO,CA8QrB,CAAA;AAqBD,eAAO,MAAM,mBAAmB,SAAU,IAAI,KAAG,MAAM,GAAG,IAazD,CAAA;AAED,eAAO,MAAM,wBAAwB,sBAAuB,IAAI,CAAC,EAAE,CAAC,uBAAuB,CAAC;;;GAmB3F,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SyntaxKind as e } from "ts-morph";
|
|
2
2
|
import { Logger as K } from "../../utils/logger.mjs";
|
|
3
3
|
import { OpenApiManager as v } from "../manager/OpenApiManager.mjs";
|
|
4
|
-
const
|
|
5
|
-
const i =
|
|
4
|
+
const w = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
5
|
+
const i = w.get(t);
|
|
6
6
|
if (i)
|
|
7
7
|
return i;
|
|
8
8
|
if (t.getKind() === e.Identifier) {
|
|
@@ -12,7 +12,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
12
12
|
if (o === t)
|
|
13
13
|
throw new Error("Recursive implementation found");
|
|
14
14
|
const d = h(o);
|
|
15
|
-
return
|
|
15
|
+
return w.set(t, d), d;
|
|
16
16
|
}
|
|
17
17
|
const l = t.asKind(e.Identifier).getDefinitions()[0]?.getNode();
|
|
18
18
|
if (l) {
|
|
@@ -20,12 +20,12 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
20
20
|
if (o === t)
|
|
21
21
|
throw new Error("Recursive implementation found");
|
|
22
22
|
const d = h(o);
|
|
23
|
-
return
|
|
23
|
+
return w.set(t, d), d;
|
|
24
24
|
}
|
|
25
25
|
throw new Error("No implementation nor definition available");
|
|
26
26
|
}
|
|
27
|
-
return
|
|
28
|
-
},
|
|
27
|
+
return w.set(t, t), t;
|
|
28
|
+
}, A = (t) => {
|
|
29
29
|
const i = t.getChildrenOfKind(e.Identifier);
|
|
30
30
|
return i.length === 2 ? h(i[1]) : t.getChildren().reverse().find(
|
|
31
31
|
(l) => l.getKind() !== e.GreaterThanToken && l.getKind() !== e.CommaToken && l.getKind() !== e.SemicolonToken
|
|
@@ -64,7 +64,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
64
64
|
const r = s.asKind(e.TypeLiteral);
|
|
65
65
|
if (r)
|
|
66
66
|
return r.getFirstChildByKind(e.SyntaxList).getChildrenOfKind(e.PropertySignature).map((I) => {
|
|
67
|
-
const k = I.getFirstChildByKind(e.Identifier), O =
|
|
67
|
+
const k = I.getFirstChildByKind(e.Identifier), O = A(I), U = k.getNextSiblingIfKind(e.QuestionToken);
|
|
68
68
|
return {
|
|
69
69
|
role: "property",
|
|
70
70
|
identifier: k.getText(),
|
|
@@ -77,26 +77,26 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
77
77
|
return m(a.getFirstChild());
|
|
78
78
|
if (s.asKind(e.PropertyAccessExpression)) {
|
|
79
79
|
const E = h(s.getLastChild());
|
|
80
|
-
return
|
|
80
|
+
return c(E.asKind(e.CallExpression).getReturnType(), E);
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
return f
|
|
82
|
+
const f = s.asKind(e.UnionType);
|
|
83
|
+
if (f)
|
|
84
|
+
return c(f.getType(), s);
|
|
85
85
|
const y = s.asKind(e.TypeQuery);
|
|
86
86
|
if (y)
|
|
87
87
|
return m(y.getLastChild());
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
return m(
|
|
88
|
+
const F = s.asKind(e.QualifiedName);
|
|
89
|
+
if (F)
|
|
90
|
+
return m(F.getLastChild());
|
|
91
91
|
const C = s.asKind(e.CallExpression);
|
|
92
92
|
if (C)
|
|
93
|
-
return
|
|
94
|
-
const
|
|
95
|
-
if (F)
|
|
96
|
-
return m(F.getChildAtIndex(1));
|
|
97
|
-
const b = s.asKind(e.AsExpression);
|
|
93
|
+
return c(C.getReturnType(), C);
|
|
94
|
+
const b = s.asKind(e.AwaitExpression);
|
|
98
95
|
if (b)
|
|
99
|
-
return m(b.getChildAtIndex(
|
|
96
|
+
return m(b.getChildAtIndex(1));
|
|
97
|
+
const L = s.asKind(e.AsExpression);
|
|
98
|
+
if (L)
|
|
99
|
+
return m(L.getChildAtIndex(2));
|
|
100
100
|
const V = s.getSourceFile().getFilePath().split("/").pop();
|
|
101
101
|
return K.warn(`[${V}] Unknown node type: ${s.getKindName()}`), "unknown_1";
|
|
102
102
|
}, z = (t) => t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).map((n) => {
|
|
@@ -107,19 +107,19 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
107
107
|
return o.getLiteralText();
|
|
108
108
|
const r = n.getSourceFile().getFilePath().split("/").pop();
|
|
109
109
|
return K.warn(`[${r}] Unknown identifier name: ${o.getText()}`), "unknown_30";
|
|
110
|
-
})(),
|
|
110
|
+
})(), g = n.getLastChild(), u = h(g);
|
|
111
111
|
return {
|
|
112
112
|
role: "property",
|
|
113
113
|
identifier: d,
|
|
114
|
-
shape: x(
|
|
115
|
-
optional: _(
|
|
116
|
-
description:
|
|
117
|
-
errorMessage:
|
|
114
|
+
shape: x(u),
|
|
115
|
+
optional: _(u),
|
|
116
|
+
description: T(u, "description"),
|
|
117
|
+
errorMessage: T(u, "errorMessage")
|
|
118
118
|
};
|
|
119
|
-
}) || [],
|
|
119
|
+
}) || [], N = (t) => {
|
|
120
120
|
const i = t.asKind(e.CallExpression);
|
|
121
121
|
return i ? (i.getReturnType().getSymbol()?.getName() ?? "").startsWith("Zod") : !1;
|
|
122
|
-
},
|
|
122
|
+
}, S = (t) => {
|
|
123
123
|
const i = t.asKind(e.CallExpression), s = i.getReturnType(), l = s.getSymbol()?.getName() ?? "";
|
|
124
124
|
if (l === "ZodNumber")
|
|
125
125
|
return "number";
|
|
@@ -133,23 +133,32 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
133
133
|
const d = i.getFirstChildByKind(e.SyntaxList)?.getFirstChild()?.asKind(e.ObjectLiteralExpression);
|
|
134
134
|
if (!d)
|
|
135
135
|
return "unknown_zod_object";
|
|
136
|
-
const
|
|
137
|
-
return
|
|
136
|
+
const g = d.getFirstChildByKind(e.SyntaxList);
|
|
137
|
+
return g ? g.getChildrenOfKind(e.PropertyAssignment).map((r) => {
|
|
138
138
|
const a = r.getFirstChildByKind(e.Identifier).getText(), p = r.getLastChild();
|
|
139
139
|
return {
|
|
140
140
|
role: "property",
|
|
141
141
|
identifier: a,
|
|
142
|
-
shape:
|
|
142
|
+
shape: N(p) ? S(p) : x(p),
|
|
143
143
|
optional: !1
|
|
144
144
|
};
|
|
145
145
|
}) : [];
|
|
146
146
|
}
|
|
147
147
|
if (l === "ZodArray") {
|
|
148
148
|
const o = i.getFirstChildByKind(e.SyntaxList)?.getFirstChild();
|
|
149
|
-
|
|
149
|
+
if (o)
|
|
150
|
+
return [
|
|
151
|
+
{
|
|
152
|
+
role: "array",
|
|
153
|
+
shape: N(o) ? S(o) : x(o),
|
|
154
|
+
optional: !1
|
|
155
|
+
}
|
|
156
|
+
];
|
|
157
|
+
const g = i.getFirstChildByKind(e.PropertyAccessExpression)?.getFirstChildByKind(e.CallExpression);
|
|
158
|
+
return g && N(g) ? [
|
|
150
159
|
{
|
|
151
160
|
role: "array",
|
|
152
|
-
shape:
|
|
161
|
+
shape: S(g),
|
|
153
162
|
optional: !1
|
|
154
163
|
}
|
|
155
164
|
] : "unknown_zod_array";
|
|
@@ -157,18 +166,18 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
157
166
|
if (l === "ZodEnum") {
|
|
158
167
|
const o = s.getTypeArguments();
|
|
159
168
|
if (o.length > 0) {
|
|
160
|
-
const
|
|
169
|
+
const u = o[0].getProperties().map((r) => ({
|
|
161
170
|
role: "union_entry",
|
|
162
|
-
shape:
|
|
171
|
+
shape: c(r.getTypeAtLocation(i), i, []),
|
|
163
172
|
optional: !1
|
|
164
173
|
}));
|
|
165
|
-
if (
|
|
166
|
-
return
|
|
167
|
-
if (
|
|
174
|
+
if (u.length === 1)
|
|
175
|
+
return u[0].shape;
|
|
176
|
+
if (u.length > 1)
|
|
168
177
|
return [
|
|
169
178
|
{
|
|
170
179
|
role: "union",
|
|
171
|
-
shape:
|
|
180
|
+
shape: u,
|
|
172
181
|
optional: !1
|
|
173
182
|
}
|
|
174
183
|
];
|
|
@@ -177,13 +186,13 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
177
186
|
}
|
|
178
187
|
if (l === "ZodOptional") {
|
|
179
188
|
const o = i.getFirstChildByKind(e.PropertyAccessExpression)?.getFirstChildByKind(e.CallExpression);
|
|
180
|
-
return o &&
|
|
189
|
+
return o && N(o) ? S(o) : "unknown_zod_optional";
|
|
181
190
|
}
|
|
182
191
|
const n = t.getSourceFile().getFilePath().split("/").pop();
|
|
183
192
|
return K.warn(`[${n}] Unknown zod type: ${l}`), "unknown_zod";
|
|
184
193
|
}, x = (t) => {
|
|
185
|
-
if (
|
|
186
|
-
return
|
|
194
|
+
if (N(t))
|
|
195
|
+
return S(t);
|
|
187
196
|
const i = t.getParent().getFirstChildByKind(e.AsExpression);
|
|
188
197
|
if (i) {
|
|
189
198
|
const r = i.getLastChildByKind(e.TypeReference);
|
|
@@ -202,35 +211,35 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
202
211
|
l.getFirstChildByKind(e.SyntaxList).getFirstChild()
|
|
203
212
|
), a = r.getParent().getFirstChildByKind(e.TypeReference);
|
|
204
213
|
if (a)
|
|
205
|
-
return
|
|
214
|
+
return c(a.getType(), a, []);
|
|
206
215
|
const p = r.getParent().getFirstChildByKind(e.ObjectLiteralExpression);
|
|
207
216
|
if (p)
|
|
208
217
|
return x(p);
|
|
209
218
|
if (r.getKind() === e.CallExpression || r.getKind() === e.IntersectionType)
|
|
210
219
|
return x(r);
|
|
211
|
-
const
|
|
212
|
-
return K.warn(`[${
|
|
220
|
+
const f = t.getSourceFile().getFilePath().split("/").pop();
|
|
221
|
+
return K.warn(`[${f}] Unknown call expression argument: ${r.getKindName()}`), "unknown_3";
|
|
213
222
|
}
|
|
214
223
|
const o = t.getFirstChildByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).find((r) => r.getFirstChildByKind(e.Identifier)?.getText() === "parse");
|
|
215
224
|
if (o) {
|
|
216
|
-
const r =
|
|
217
|
-
return
|
|
225
|
+
const r = A(o).asKind(e.ArrowFunction).getReturnType();
|
|
226
|
+
return c(r, o);
|
|
218
227
|
}
|
|
219
228
|
const d = t.getFirstChildByKind(e.SyntaxList)?.getFirstChildByKind(e.ImportType);
|
|
220
229
|
if (d) {
|
|
221
230
|
const r = d.getLastChildByKind(e.GreaterThanToken).getChildIndex(), a = d.getChildAtIndex(r - 1);
|
|
222
231
|
return m(a.getFirstChild());
|
|
223
232
|
}
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
const r =
|
|
233
|
+
const g = t.isKind(e.IntersectionType) ? t : t.getParent()?.isKind(e.VariableDeclaration) ? t.getParent()?.getFirstChildByKind(e.IntersectionType) : null;
|
|
234
|
+
if (g) {
|
|
235
|
+
const r = g.getFirstChildByKind(e.TypeReference);
|
|
227
236
|
if (r)
|
|
228
237
|
return P(r);
|
|
229
238
|
}
|
|
230
|
-
const
|
|
231
|
-
return K.warn(`[${
|
|
239
|
+
const u = t.getSourceFile().getFilePath().split("/").pop();
|
|
240
|
+
return K.warn(`[${u}] Unknown import type node`), "unknown_2";
|
|
232
241
|
}, _ = (t) => {
|
|
233
|
-
if (
|
|
242
|
+
if (N(t))
|
|
234
243
|
return (t.asKind(e.CallExpression).getReturnType().getSymbol()?.getName() ?? "") === "ZodOptional";
|
|
235
244
|
const i = t.asKind(e.CallExpression);
|
|
236
245
|
if (i) {
|
|
@@ -242,32 +251,32 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
242
251
|
const o = i.getFirstChildByKind(e.SyntaxList), d = h(o.getFirstChild());
|
|
243
252
|
return _(d);
|
|
244
253
|
}
|
|
245
|
-
return t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).some((n) => n.getFirstDescendantByKind(e.Identifier).getText() === "optional" ?
|
|
246
|
-
},
|
|
247
|
-
if (
|
|
254
|
+
return t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).some((n) => n.getFirstDescendantByKind(e.Identifier).getText() === "optional" ? A(n).getKind() === e.TrueKeyword : !1);
|
|
255
|
+
}, T = (t, i) => {
|
|
256
|
+
if (N(t))
|
|
248
257
|
return "";
|
|
249
258
|
const s = h(t), l = s.asKind(e.CallExpression);
|
|
250
259
|
if (l) {
|
|
251
260
|
const a = l.getLastChildByKind(e.SyntaxList);
|
|
252
|
-
return
|
|
261
|
+
return T(a, i);
|
|
253
262
|
}
|
|
254
263
|
const n = s.asKind(e.SyntaxList);
|
|
255
264
|
if (n)
|
|
256
|
-
return n.getChildren().map((p) =>
|
|
265
|
+
return n.getChildren().map((p) => T(p, i)).find((p) => !!p && p !== "unknown_25") || "";
|
|
257
266
|
const o = s.asKind(e.ObjectLiteralExpression);
|
|
258
267
|
if (o) {
|
|
259
|
-
const p = R(o).find((
|
|
268
|
+
const p = R(o).find((f) => f.identifier === i);
|
|
260
269
|
return p ? Array.isArray(p.value) ? "array" : p.value || "" : "";
|
|
261
270
|
}
|
|
262
271
|
const d = s.asKind(e.IntersectionType);
|
|
263
272
|
if (d)
|
|
264
|
-
return d.getTypeNodes().flatMap((a) =>
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
return
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
return
|
|
273
|
+
return d.getTypeNodes().flatMap((a) => T(a, i)).filter((a) => !!a && a !== "unknown_25")[0] || "unknown_27";
|
|
274
|
+
const g = s.asKind(e.TypeLiteral);
|
|
275
|
+
if (g)
|
|
276
|
+
return T(g.getFirstChildByKind(e.SyntaxList), i);
|
|
277
|
+
const u = s.asKind(e.PropertySignature);
|
|
278
|
+
if (u && s.getFirstDescendantByKind(e.Identifier).getText() === i)
|
|
279
|
+
return A(u).getFirstDescendantByKind(
|
|
271
280
|
e.StringLiteral
|
|
272
281
|
).getLiteralText();
|
|
273
282
|
const r = s.getSourceFile().getFilePath().split("/").pop();
|
|
@@ -278,7 +287,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
278
287
|
return !1;
|
|
279
288
|
const s = t.getTypeArguments();
|
|
280
289
|
return i.getName() === "Promise" && s.length === 1;
|
|
281
|
-
},
|
|
290
|
+
}, c = (t, i, s = []) => {
|
|
282
291
|
const l = t.getAliasSymbol()?.getName();
|
|
283
292
|
if (l && v.getInstance().hasExposedModel(l))
|
|
284
293
|
return [
|
|
@@ -332,7 +341,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
332
341
|
role: "tuple",
|
|
333
342
|
shape: n.getTupleElements().map((r) => ({
|
|
334
343
|
role: "tuple_entry",
|
|
335
|
-
shape:
|
|
344
|
+
shape: c(r, i, o),
|
|
336
345
|
optional: !1
|
|
337
346
|
})),
|
|
338
347
|
optional: !1
|
|
@@ -342,17 +351,17 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
342
351
|
return [
|
|
343
352
|
{
|
|
344
353
|
role: "array",
|
|
345
|
-
shape:
|
|
354
|
+
shape: c(n.getArrayElementType(), i, o),
|
|
346
355
|
optional: !1
|
|
347
356
|
}
|
|
348
357
|
];
|
|
349
358
|
if (n.isObject()) {
|
|
350
|
-
const r = n.getNumberIndexType(), p = n.getBaseTypes()?.find((
|
|
359
|
+
const r = n.getNumberIndexType(), p = n.getBaseTypes()?.find((f) => f.isArray());
|
|
351
360
|
if (p)
|
|
352
361
|
return [
|
|
353
362
|
{
|
|
354
363
|
role: "array",
|
|
355
|
-
shape:
|
|
364
|
+
shape: c(
|
|
356
365
|
p.getArrayElementType() ?? r,
|
|
357
366
|
i,
|
|
358
367
|
o
|
|
@@ -361,7 +370,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
361
370
|
}
|
|
362
371
|
];
|
|
363
372
|
}
|
|
364
|
-
const d = n.getSymbol()?.getName(),
|
|
373
|
+
const d = n.getSymbol()?.getName(), g = /* @__PURE__ */ new Set([
|
|
365
374
|
"Buffer",
|
|
366
375
|
"Uint8Array",
|
|
367
376
|
"Int8Array",
|
|
@@ -378,7 +387,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
378
387
|
"SharedArrayBuffer",
|
|
379
388
|
"ReadableStream"
|
|
380
389
|
]);
|
|
381
|
-
if (n.isObject() && d &&
|
|
390
|
+
if (n.isObject() && d && g.has(d))
|
|
382
391
|
return [
|
|
383
392
|
{
|
|
384
393
|
role: "buffer",
|
|
@@ -393,7 +402,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
393
402
|
return [
|
|
394
403
|
{
|
|
395
404
|
role: "record",
|
|
396
|
-
shape: a ?
|
|
405
|
+
shape: a ? c(a, i, o) : "unknown",
|
|
397
406
|
optional: !1
|
|
398
407
|
}
|
|
399
408
|
];
|
|
@@ -403,7 +412,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
403
412
|
return [
|
|
404
413
|
{
|
|
405
414
|
role: "array",
|
|
406
|
-
shape: a ?
|
|
415
|
+
shape: a ? c(a, i, o) : "unknown",
|
|
407
416
|
optional: !1
|
|
408
417
|
}
|
|
409
418
|
];
|
|
@@ -414,7 +423,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
414
423
|
return [
|
|
415
424
|
{
|
|
416
425
|
role: "record",
|
|
417
|
-
shape:
|
|
426
|
+
shape: c(r, i, o),
|
|
418
427
|
optional: !1
|
|
419
428
|
}
|
|
420
429
|
];
|
|
@@ -426,44 +435,44 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
426
435
|
return {
|
|
427
436
|
role: "property",
|
|
428
437
|
identifier: r.getName(),
|
|
429
|
-
shape:
|
|
438
|
+
shape: c(r.getTypeAtLocation(i), i, o),
|
|
430
439
|
optional: !1
|
|
431
440
|
};
|
|
432
441
|
if (!(a.asKind(e.PropertySignature) || a.asKind(e.PropertyAssignment) || a.asKind(e.ShorthandPropertyAssignment)))
|
|
433
442
|
return {
|
|
434
443
|
role: "property",
|
|
435
444
|
identifier: r.getName(),
|
|
436
|
-
shape:
|
|
445
|
+
shape: c(r.getTypeAtLocation(i), i, o),
|
|
437
446
|
optional: !1
|
|
438
447
|
};
|
|
439
|
-
const
|
|
448
|
+
const f = r.getTypeAtLocation(i).isNullable(), y = c(r.getTypeAtLocation(i), i, o);
|
|
440
449
|
return {
|
|
441
450
|
role: "property",
|
|
442
451
|
identifier: r.getName(),
|
|
443
452
|
shape: y,
|
|
444
|
-
optional:
|
|
453
|
+
optional: f
|
|
445
454
|
};
|
|
446
455
|
}).filter((r) => r.shape !== "undefined");
|
|
447
456
|
if (n.isUnion()) {
|
|
448
457
|
const a = n.getUnionTypes().map((y) => ({
|
|
449
458
|
role: "union_entry",
|
|
450
|
-
shape:
|
|
459
|
+
shape: c(y, i, o),
|
|
451
460
|
optional: !1
|
|
452
461
|
})).filter(
|
|
453
|
-
(y,
|
|
454
|
-
), p = a.some((y) => y.shape === "undefined"),
|
|
455
|
-
return
|
|
462
|
+
(y, F, C) => !C.find((b, L) => b.shape === y.shape && L > F)
|
|
463
|
+
), p = a.some((y) => y.shape === "undefined"), f = a.filter((y) => y.shape !== "undefined");
|
|
464
|
+
return f.length === 1 ? f[0].shape : [
|
|
456
465
|
{
|
|
457
466
|
role: "union",
|
|
458
|
-
shape:
|
|
467
|
+
shape: f,
|
|
459
468
|
optional: p
|
|
460
469
|
}
|
|
461
470
|
];
|
|
462
471
|
}
|
|
463
472
|
if (n.isIntersection())
|
|
464
|
-
return n.getIntersectionTypes().map((p) =>
|
|
465
|
-
const
|
|
466
|
-
return K.warn(`[${
|
|
473
|
+
return n.getIntersectionTypes().map((p) => c(p, i, o)).filter((p) => typeof p != "string").reduce((p, f) => [...p, ...f], []);
|
|
474
|
+
const u = i.getSourceFile().getFilePath().split("/").pop();
|
|
475
|
+
return K.warn(`[${u}] Unknown type shape node ${t.getText()}`), "unknown_5";
|
|
467
476
|
}, B = (t) => {
|
|
468
477
|
if (t.isKind(e.Identifier))
|
|
469
478
|
return B(h(t));
|
|
@@ -472,7 +481,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
472
481
|
if (t.isKind(e.ArrayLiteralExpression))
|
|
473
482
|
return t.forEachChildAsArray().map((s) => B(s));
|
|
474
483
|
if (t.isKind(e.PropertyAccessExpression))
|
|
475
|
-
return B(
|
|
484
|
+
return B(A(t));
|
|
476
485
|
if (t.isKind(e.ObjectLiteralExpression))
|
|
477
486
|
return R(t);
|
|
478
487
|
const i = t.getSourceFile().getFilePath().split("/").pop();
|
|
@@ -485,7 +494,7 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
485
494
|
const l = s.getType();
|
|
486
495
|
return l.isStringLiteral() ? l.getLiteralValue() : null;
|
|
487
496
|
}, R = (t) => t.getFirstDescendantByKind(e.SyntaxList).getChildrenOfKind(e.PropertyAssignment).map((n) => {
|
|
488
|
-
const d = n.getFirstDescendantByKind(e.Identifier).getText(),
|
|
497
|
+
const d = n.getFirstDescendantByKind(e.Identifier).getText(), g = n.getLastChild(), u = h(g), r = B(u);
|
|
489
498
|
return {
|
|
490
499
|
identifier: d,
|
|
491
500
|
value: r
|
|
@@ -493,14 +502,14 @@ const L = /* @__PURE__ */ new WeakMap(), h = (t) => {
|
|
|
493
502
|
}) || [];
|
|
494
503
|
export {
|
|
495
504
|
h as findNodeImplementation,
|
|
496
|
-
|
|
497
|
-
|
|
505
|
+
A as findPropertyAssignmentValueNode,
|
|
506
|
+
c as getProperTypeShape,
|
|
498
507
|
m as getRecursiveNodeShape,
|
|
499
508
|
z as getShapeOfValidatorLiteral,
|
|
500
509
|
P as getTypeReferenceShape,
|
|
501
510
|
_ as getValidatorPropertyOptionality,
|
|
502
511
|
x as getValidatorPropertyShape,
|
|
503
|
-
|
|
512
|
+
T as getValidatorPropertyStringValue,
|
|
504
513
|
R as getValuesOfObjectLiteral,
|
|
505
514
|
Q as resolveEndpointPath
|
|
506
515
|
};
|
|
@@ -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\tif (typeName === 'ZodEnum') {\n\t\tconst typeArgs = returnType.getTypeArguments()\n\t\tif (typeArgs.length > 0) {\n\t\t\tconst enumType = typeArgs[0]\n\t\t\tconst properties = enumType.getProperties()\n\t\t\tconst shapes: ShapeOfUnionEntry[] = properties.map((prop) => ({\n\t\t\t\trole: 'union_entry' as const,\n\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(callExpression), callExpression, []),\n\t\t\t\toptional: false,\n\t\t\t}))\n\t\t\tif (shapes.length === 1) {\n\t\t\t\treturn shapes[0].shape\n\t\t\t}\n\t\t\tif (shapes.length > 1) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\trole: 'union' as const,\n\t\t\t\t\t\tshape: shapes,\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t\treturn 'unknown_zod_enum'\n\t}\n\n\tif (typeName === 'ZodOptional') {\n\t\tconst innerCallExpression = callExpression\n\t\t\t.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)\n\t\t\t?.getFirstChildByKind(SyntaxKind.CallExpression)\n\t\tif (innerCallExpression && isZodCallExpression(innerCallExpression)) {\n\t\t\treturn getZodCallShape(innerCallExpression)\n\t\t}\n\t\treturn 'unknown_zod_optional'\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\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\t\tconst returnType = callExpression.getReturnType()\n\t\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\t\tif (typeName === 'ZodOptional') {\n\t\t\treturn true\n\t\t}\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","returnType","objectLiteral","syntaxList","prop","argNode","typeArgs","shapes","innerCallExpression","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","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","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,GAC7BA;AAAA,IAAA;AAGF,UAAAC,IAAiBN,EAAK,OAAOE,EAAW,UAAU,EAAG,eAAe,EAAE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AAK,sBAAsB,IAAI,CAACS,MAAUiG,EAAsBjG,CAAK,CAAC;AACnE,MAAAT,EAAK,OAAOE,EAAW,wBAAwB;AAClD,WAAAwG,EAAsBnG,EAAgCP,CAAI,CAAC;AACxD,MAAAA,EAAK,OAAOE,EAAW,uBAAuB;AACxD,WAAOsE,EAAyBxE,CAAI;AAG/B,QAAA+B,IAAW/B,EAAK,cAAc,EAAE,cAAc,MAAM,GAAG,EAAE,IAAI;AACnE,SAAAgC,EAAO,IAAI,IAAID,CAAQ,gCAAgC/B,EAAK,YAAa,CAAA,EAAE,GAEpE;AACR,GAEa2G,IAAsB,CAAC3G,MAA8B;AACjE,QAAM0C,IAAiB1C,EAAK,yBAAyBE,EAAW,cAAc;AAC1E,MAAA,CAACwC,EAAuB,QAAA;AAE5B,QAAMkE,IAAWlE,EAAe,aAAa,EAAE,CAAC;AAC5C,MAAA,CAACkE,EAAiB,QAAA;AAEhB,QAAAC,IAAUD,EAAS,QAAQ;AAC7B,SAAAC,EAAQ,oBACJA,EAAQ,gBAAgB,IAGzB;AACR,GAEarC,IAA2B,CAACtC,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,GACxC8G,IAAa/G,EAAuBK,CAAmB,GACvDkE,IAAQoC,EAAsBI,CAAU;AAEvC,SAAA;AAAA,IACN,YAAY1E;AAAA,IACZ,OAAAkC;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\tconst elementShape = isZodCallExpression(argNode)\n\t\t\t\t? getZodCallShape(argNode)\n\t\t\t\t: getValidatorPropertyShape(argNode)\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'array' as const,\n\t\t\t\t\tshape: elementShape,\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\t// Handle chained form: z.string().array()\n\t\tconst propertyAccess = callExpression.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)\n\t\tconst receiverCall = propertyAccess?.getFirstChildByKind(SyntaxKind.CallExpression)\n\t\tif (receiverCall && isZodCallExpression(receiverCall)) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\trole: 'array' as const,\n\t\t\t\t\tshape: getZodCallShape(receiverCall),\n\t\t\t\t\toptional: false,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\treturn 'unknown_zod_array'\n\t}\n\n\tif (typeName === 'ZodEnum') {\n\t\tconst typeArgs = returnType.getTypeArguments()\n\t\tif (typeArgs.length > 0) {\n\t\t\tconst enumType = typeArgs[0]\n\t\t\tconst properties = enumType.getProperties()\n\t\t\tconst shapes: ShapeOfUnionEntry[] = properties.map((prop) => ({\n\t\t\t\trole: 'union_entry' as const,\n\t\t\t\tshape: getProperTypeShape(prop.getTypeAtLocation(callExpression), callExpression, []),\n\t\t\t\toptional: false,\n\t\t\t}))\n\t\t\tif (shapes.length === 1) {\n\t\t\t\treturn shapes[0].shape\n\t\t\t}\n\t\t\tif (shapes.length > 1) {\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\trole: 'union' as const,\n\t\t\t\t\t\tshape: shapes,\n\t\t\t\t\t\toptional: false,\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t}\n\t\t}\n\t\treturn 'unknown_zod_enum'\n\t}\n\n\tif (typeName === 'ZodOptional') {\n\t\tconst innerCallExpression = callExpression\n\t\t\t.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)\n\t\t\t?.getFirstChildByKind(SyntaxKind.CallExpression)\n\t\tif (innerCallExpression && isZodCallExpression(innerCallExpression)) {\n\t\t\treturn getZodCallShape(innerCallExpression)\n\t\t}\n\t\treturn 'unknown_zod_optional'\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\tconst callExpression = node.asKind(SyntaxKind.CallExpression)!\n\t\tconst returnType = callExpression.getReturnType()\n\t\tconst typeName = returnType.getSymbol()?.getName() ?? ''\n\t\tif (typeName === 'ZodOptional') {\n\t\t\treturn true\n\t\t}\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","returnType","objectLiteral","syntaxList","prop","argNode","receiverCall","typeArgs","shapes","innerCallExpression","inlineValidatorAsExpression","typeReference","childTypeReferenceNode","typeNode","childCallExpressionNode","callExpressionArgument","thingyNode","parsePropertyAssignment","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","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,GAC7BA;AAAA,IAAA;AAGF,UAAAC,IAAiBN,EAAK,OAAOE,EAAW,UAAU,EAAG,eAAe,EAAE,CAAC,GAAG,QAAQ;AACxF,QAAII,GAAgB;AAEb,YAAAF,IADuBE,EAAe,UAAU,EACL,aAAa;AAC9D,UAAIF,MAAwBJ;AACrB,cAAA,IAAI,MAAM,gCAAgC;AAE3C,YAAAK,IAASN,EAAuBK,CAAmB;AACrC,aAAAN,EAAA,IAAIE,GAAMK,CAAM,GAC7BA;AAAA,IAAA;AAEF,UAAA,IAAI,MAAM,4CAA4C;AAAA,EAAA;AAGzC,SAAAP,EAAA,IAAIE,GAAMA,CAAI,GAC3BA;AACR,GAEaO,IAAkC,CAC9CP,MAMU;AACV,QAAMQ,IAAqBR,EAAK,kBAAkBE,EAAW,UAAU;AACnE,SAAAM,EAAmB,WAAW,IAC1BT,EAAuBS,EAAmB,CAAC,CAAC,IAE1BR,EAAK,YAAY,EAAE,QAAQ,EAC5B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E,SAAAgC,EAAO,IAAI,IAAID,CAAQ,gCAAgC/B,EAAK,YAAa,CAAA,EAAE,GAEpE;AACR,GAEa4G,IAAsB,CAAC5G,MAA8B;AACjE,QAAM0C,IAAiB1C,EAAK,yBAAyBE,EAAW,cAAc;AAC1E,MAAA,CAACwC,EAAuB,QAAA;AAE5B,QAAMmE,IAAWnE,EAAe,aAAa,EAAE,CAAC;AAC5C,MAAA,CAACmE,EAAiB,QAAA;AAEhB,QAAAC,IAAUD,EAAS,QAAQ;AAC7B,SAAAC,EAAQ,oBACJA,EAAQ,gBAAgB,IAGzB;AACR,GAEarC,IAA2B,CAACvC,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,GACxC+G,IAAahH,EAAuBK,CAAmB,GACvDmE,IAAQoC,EAAsBI,CAAU;AAEvC,SAAA;AAAA,IACN,YAAY3E;AAAA,IACZ,OAAAmC;AAAA,EACD;AAAA,CACA,KAEoB,CAAC;"}
|
|
@@ -7,6 +7,10 @@ export declare const TestCase: {
|
|
|
7
7
|
readonly parsesInlineZodEnum: "parses-inline-zod-enum";
|
|
8
8
|
readonly parsesZodOptional: "parses-zod-optional";
|
|
9
9
|
readonly parsesAliasedZodSchema: "parses-aliased-zod-schema";
|
|
10
|
+
readonly parsesZodQueryStringArray: "parses-zod-query-string-array";
|
|
11
|
+
readonly parsesZodQueryNumberArray: "parses-zod-query-number-array";
|
|
12
|
+
readonly parsesZodQueryObjectArray: "parses-zod-query-object-array";
|
|
13
|
+
readonly parsesZodQueryOptionalArray: "parses-zod-query-optional-array";
|
|
10
14
|
readonly parsesReturnRecordStringUnknown: "parses-return-record-string-unknown";
|
|
11
15
|
readonly parsesReturnObjectWithRecordProperty: "parses-return-object-with-record-property";
|
|
12
16
|
readonly parsesBufferReturnedFromFunction: "parses-buffer-returned-from-function";
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BX,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "moonflower",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "tenebrie",
|
|
6
6
|
"license": "MIT",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"yargs": "^17.7.2"
|
|
132
132
|
},
|
|
133
133
|
"peerDependencies": {
|
|
134
|
-
"@koa/router": "^
|
|
134
|
+
"@koa/router": "^13.1.1",
|
|
135
135
|
"koa": "^3.2.0",
|
|
136
136
|
"koa-bodyparser": "^4.4.1",
|
|
137
137
|
"ts-morph": "^28.0.0",
|
|
@@ -308,19 +308,31 @@ const getZodCallShape = (node: Node): ShapeOfType['shape'] => {
|
|
|
308
308
|
|
|
309
309
|
if (typeName === 'ZodArray') {
|
|
310
310
|
const argNode = callExpression.getFirstChildByKind(SyntaxKind.SyntaxList)?.getFirstChild()
|
|
311
|
-
if (
|
|
312
|
-
|
|
311
|
+
if (argNode) {
|
|
312
|
+
const elementShape = isZodCallExpression(argNode)
|
|
313
|
+
? getZodCallShape(argNode)
|
|
314
|
+
: getValidatorPropertyShape(argNode)
|
|
315
|
+
return [
|
|
316
|
+
{
|
|
317
|
+
role: 'array' as const,
|
|
318
|
+
shape: elementShape,
|
|
319
|
+
optional: false,
|
|
320
|
+
},
|
|
321
|
+
]
|
|
313
322
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
// Handle chained form: z.string().array()
|
|
324
|
+
const propertyAccess = callExpression.getFirstChildByKind(SyntaxKind.PropertyAccessExpression)
|
|
325
|
+
const receiverCall = propertyAccess?.getFirstChildByKind(SyntaxKind.CallExpression)
|
|
326
|
+
if (receiverCall && isZodCallExpression(receiverCall)) {
|
|
327
|
+
return [
|
|
328
|
+
{
|
|
329
|
+
role: 'array' as const,
|
|
330
|
+
shape: getZodCallShape(receiverCall),
|
|
331
|
+
optional: false,
|
|
332
|
+
},
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
return 'unknown_zod_array'
|
|
324
336
|
}
|
|
325
337
|
|
|
326
338
|
if (typeName === 'ZodEnum') {
|
|
@@ -7,6 +7,10 @@ export const TestCase = {
|
|
|
7
7
|
parsesInlineZodEnum: 'parses-inline-zod-enum',
|
|
8
8
|
parsesZodOptional: 'parses-zod-optional',
|
|
9
9
|
parsesAliasedZodSchema: 'parses-aliased-zod-schema',
|
|
10
|
+
parsesZodQueryStringArray: 'parses-zod-query-string-array',
|
|
11
|
+
parsesZodQueryNumberArray: 'parses-zod-query-number-array',
|
|
12
|
+
parsesZodQueryObjectArray: 'parses-zod-query-object-array',
|
|
13
|
+
parsesZodQueryOptionalArray: 'parses-zod-query-optional-array',
|
|
10
14
|
parsesReturnRecordStringUnknown: 'parses-return-record-string-unknown',
|
|
11
15
|
parsesReturnObjectWithRecordProperty: 'parses-return-object-with-record-property',
|
|
12
16
|
parsesBufferReturnedFromFunction: 'parses-buffer-returned-from-function',
|
|
@@ -3,6 +3,7 @@ import { z } from 'zod'
|
|
|
3
3
|
import { z as valibot } from 'zod'
|
|
4
4
|
|
|
5
5
|
import { usePathParams } from '../../../hooks/usePathParams'
|
|
6
|
+
import { useQueryParams } from '../../../hooks/useQueryParams'
|
|
6
7
|
import { useRequestBody } from '../../../hooks/useRequestBody'
|
|
7
8
|
import { Router } from '../../../router/Router'
|
|
8
9
|
import { OptionalParam } from '../../../validators/ParamWrappers'
|
|
@@ -116,3 +117,33 @@ router.post(`/test/${TestCase.parsesZodOptional}`, (ctx) => {
|
|
|
116
117
|
optionalNumber: z.number().optional(),
|
|
117
118
|
})
|
|
118
119
|
})
|
|
120
|
+
|
|
121
|
+
router.get(`/test/${TestCase.parsesZodQueryStringArray}`, (ctx) => {
|
|
122
|
+
useQueryParams(ctx, {
|
|
123
|
+
tags: z.array(z.string()),
|
|
124
|
+
otherTags: z.string().array(),
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
router.get(`/test/${TestCase.parsesZodQueryNumberArray}`, (ctx) => {
|
|
129
|
+
useQueryParams(ctx, {
|
|
130
|
+
ids: z.array(z.number()),
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
router.get(`/test/${TestCase.parsesZodQueryObjectArray}`, (ctx) => {
|
|
135
|
+
useQueryParams(ctx, {
|
|
136
|
+
items: z.array(
|
|
137
|
+
z.object({
|
|
138
|
+
name: z.string(),
|
|
139
|
+
value: z.number(),
|
|
140
|
+
}),
|
|
141
|
+
),
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
router.get(`/test/${TestCase.parsesZodQueryOptionalArray}`, (ctx) => {
|
|
146
|
+
useQueryParams(ctx, {
|
|
147
|
+
tags: z.array(z.string()).optional(),
|
|
148
|
+
})
|
|
149
|
+
})
|
|
@@ -237,6 +237,84 @@ describe('OpenApi Analyzer (Zod Validator)', () => {
|
|
|
237
237
|
])
|
|
238
238
|
expect(endpoint.objectBody[0].optional).toEqual(false)
|
|
239
239
|
})
|
|
240
|
+
|
|
241
|
+
it('parses zod query string array validators', () => {
|
|
242
|
+
const endpoint = analyzeEndpointById(TestCase.parsesZodQueryStringArray)
|
|
243
|
+
|
|
244
|
+
expect(endpoint.requestQuery[0].identifier).toEqual('tags')
|
|
245
|
+
expect(endpoint.requestQuery[0].signature).toEqual([
|
|
246
|
+
{
|
|
247
|
+
role: 'array',
|
|
248
|
+
shape: 'string',
|
|
249
|
+
optional: false,
|
|
250
|
+
},
|
|
251
|
+
])
|
|
252
|
+
expect(endpoint.requestQuery[0].optional).toEqual(false)
|
|
253
|
+
expect(endpoint.requestQuery[1].identifier).toEqual('otherTags')
|
|
254
|
+
expect(endpoint.requestQuery[1].signature).toEqual([
|
|
255
|
+
{
|
|
256
|
+
role: 'array',
|
|
257
|
+
shape: 'string',
|
|
258
|
+
optional: false,
|
|
259
|
+
},
|
|
260
|
+
])
|
|
261
|
+
expect(endpoint.requestQuery[1].optional).toEqual(false)
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
it('parses zod query number array validators', () => {
|
|
265
|
+
const endpoint = analyzeEndpointById(TestCase.parsesZodQueryNumberArray)
|
|
266
|
+
|
|
267
|
+
expect(endpoint.requestQuery[0].identifier).toEqual('ids')
|
|
268
|
+
expect(endpoint.requestQuery[0].signature).toEqual([
|
|
269
|
+
{
|
|
270
|
+
role: 'array',
|
|
271
|
+
shape: 'number',
|
|
272
|
+
optional: false,
|
|
273
|
+
},
|
|
274
|
+
])
|
|
275
|
+
expect(endpoint.requestQuery[0].optional).toEqual(false)
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
it('parses zod query object array validators', () => {
|
|
279
|
+
const endpoint = analyzeEndpointById(TestCase.parsesZodQueryObjectArray)
|
|
280
|
+
|
|
281
|
+
expect(endpoint.requestQuery[0].identifier).toEqual('items')
|
|
282
|
+
expect(endpoint.requestQuery[0].signature).toEqual([
|
|
283
|
+
{
|
|
284
|
+
role: 'array',
|
|
285
|
+
shape: [
|
|
286
|
+
{
|
|
287
|
+
identifier: 'name',
|
|
288
|
+
optional: false,
|
|
289
|
+
role: 'property',
|
|
290
|
+
shape: 'string',
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
identifier: 'value',
|
|
294
|
+
optional: false,
|
|
295
|
+
role: 'property',
|
|
296
|
+
shape: 'number',
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
optional: false,
|
|
300
|
+
},
|
|
301
|
+
])
|
|
302
|
+
expect(endpoint.requestQuery[0].optional).toEqual(false)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('parses zod query optional array validators', () => {
|
|
306
|
+
const endpoint = analyzeEndpointById(TestCase.parsesZodQueryOptionalArray)
|
|
307
|
+
|
|
308
|
+
expect(endpoint.requestQuery[0].identifier).toEqual('tags')
|
|
309
|
+
expect(endpoint.requestQuery[0].signature).toEqual([
|
|
310
|
+
{
|
|
311
|
+
role: 'array',
|
|
312
|
+
shape: 'string',
|
|
313
|
+
optional: false,
|
|
314
|
+
},
|
|
315
|
+
])
|
|
316
|
+
expect(endpoint.requestQuery[0].optional).toEqual(true)
|
|
317
|
+
})
|
|
240
318
|
})
|
|
241
319
|
})
|
|
242
320
|
})
|