@sprucelabs/spruce-cli 19.2.4 → 20.0.1

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.
Files changed (25) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js +2 -1
  3. package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js.map +1 -1
  4. package/build/__tests__/behavioral/views/CreatingASkillView.test.js +1 -1
  5. package/build/__tests__/behavioral/views/CreatingASkillView.test.js.map +1 -1
  6. package/build/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.d.ts +4 -0
  7. package/build/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.js +97 -19
  8. package/build/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.js.map +1 -1
  9. package/build/errors/SpruceError.js +2 -2
  10. package/build/errors/SpruceError.js.map +1 -1
  11. package/build/features/cache/actions/EnableAction.js +3 -1
  12. package/build/features/cache/actions/EnableAction.js.map +1 -1
  13. package/build/features/view/actions/SyncAction.js +2 -0
  14. package/build/features/view/actions/SyncAction.js.map +1 -1
  15. package/build/utilities/introspection.utility.d.ts +8 -4
  16. package/build/utilities/introspection.utility.js +189 -46
  17. package/build/utilities/introspection.utility.js.map +1 -1
  18. package/package.json +24 -24
  19. package/src/__tests__/behavioral/EnablingAndDisablingCache.test.ts +1 -0
  20. package/src/__tests__/behavioral/views/CreatingASkillView.test.ts +1 -1
  21. package/src/__tests__/behavioral/views/plugins/CreatingAViewPlugin.test.ts +55 -2
  22. package/src/errors/SpruceError.ts +3 -1
  23. package/src/features/cache/actions/EnableAction.ts +6 -1
  24. package/src/features/view/actions/SyncAction.ts +2 -0
  25. package/src/utilities/introspection.utility.ts +233 -79
@@ -1 +1 @@
1
- {"version":3,"file":"introspection.utility.js","names":["_lodash","_interopRequireDefault","require","tsutils","_interopRequireWildcard","ts","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","F","s","done","value","_e","f","TypeError","normalCompletion","didErr","err","step","next","_e2","minLen","_arrayLikeToArray","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","serializeSymbol","options","checker","symbol","doc","getName","documentation","displayPartsToString","getDocumentationComment","valueDeclaration","type","typeToString","getTypeOfSymbolAtLocation","serializeSignature","signature","parameters","map","p","returnType","getReturnType","introspectionUtil","introspect","tsFiles","filePaths","program","createProgram","getTypeChecker","introspects","_loop","tsFile","sourceFile","getSourceFile","results","classes","interfaces","_","includes","fileName","forEachChild","node","isClassDeclaration","getSymbolAtLocation","_parentClassSymbol","_parentClassSymbol2","_details$constructors","details","constructorType","parentClassSymbol","heritageClauses","getTypeAtLocation","types","getSymbol","parentClassName","text","parentClassPath","parent","replace","isAbstractClass","isModifierFlagSet","ModifierFlags","Abstract","constructors","getConstructSignatures","push","className","classPath","staticProperties","pluckStaticProperties","optionsInterfaceName","isAbstract","isInterfaceDeclaration","interfaceName","_default","exports","staticProps","_iterator","members","_step","_member$name","_member$initializer","member","escapedText","initializer"],"sources":["../../src/utilities/introspection.utility.ts"],"sourcesContent":["import _ from 'lodash'\nimport * as tsutils from 'tsutils'\nimport * as ts from 'typescript'\n\nexport interface IntrospectionClass {\n\tclassName: string\n\tclassPath: string\n\tparentClassName: string | undefined\n\tparentClassPath: string | undefined\n\toptionsInterfaceName: string | undefined\n\tisAbstract: boolean\n\tstaticProperties: StaticProperties\n}\n\ntype StaticProperties = Record<string, any>\n\ninterface IntrospectionInterface {\n\tinterfaceName: string\n}\n\nexport interface Introspection {\n\tclasses: IntrospectionClass[]\n\tinterfaces: IntrospectionInterface[]\n}\n\ninterface DocEntry {\n\tname?: string\n\tfileName?: string\n\tdocumentation?: string\n\ttype?: string\n\tconstructors?: DocEntry[]\n\tparameters?: DocEntry[]\n\treturnType?: string\n}\n\nconst serializeSymbol = (options: {\n\tchecker: ts.TypeChecker\n\tsymbol: ts.Symbol\n}): DocEntry => {\n\tconst { checker, symbol } = options\n\tconst doc: DocEntry = {\n\t\tname: symbol.getName(),\n\t\tdocumentation: ts.displayPartsToString(\n\t\t\tsymbol.getDocumentationComment(checker)\n\t\t),\n\t}\n\n\tif (symbol.valueDeclaration) {\n\t\tdoc.type = checker.typeToString(\n\t\t\tchecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration)\n\t\t)\n\t}\n\n\treturn doc\n}\n\nconst serializeSignature = (options: {\n\tchecker: ts.TypeChecker\n\tsignature: ts.Signature\n}) => {\n\tconst { checker, signature } = options\n\treturn {\n\t\tparameters: signature.parameters.map((p) =>\n\t\t\tserializeSymbol({ symbol: p, checker })\n\t\t),\n\t\treturnType: checker.typeToString(signature.getReturnType()),\n\t\tdocumentation: ts.displayPartsToString(\n\t\t\tsignature.getDocumentationComment(checker)\n\t\t),\n\t}\n}\n\nconst introspectionUtil = {\n\tintrospect(tsFiles: string[]): Introspection[] {\n\t\tconst filePaths = tsFiles\n\t\tconst program = ts.createProgram(filePaths, {})\n\t\tconst checker = program.getTypeChecker()\n\n\t\t// for building results\n\t\tconst introspects: Introspection[] = []\n\n\t\tfor (let i = 0; i < filePaths.length; i += 1) {\n\t\t\tconst tsFile = filePaths[i]\n\t\t\tconst sourceFile = program.getSourceFile(tsFile)\n\t\t\tconst results: Introspection = { classes: [], interfaces: [] }\n\t\t\tif (sourceFile && _.includes(filePaths, sourceFile.fileName)) {\n\t\t\t\tts.forEachChild(sourceFile, (node) => {\n\t\t\t\t\t// if this is a class declaration\n\t\t\t\t\tif (ts.isClassDeclaration(node) && node.name) {\n\t\t\t\t\t\tconst symbol = checker.getSymbolAtLocation(node.name)\n\n\t\t\t\t\t\tif (symbol?.valueDeclaration) {\n\t\t\t\t\t\t\tconst details = serializeSymbol({ checker, symbol })\n\t\t\t\t\t\t\t// Get the construct signatures\n\t\t\t\t\t\t\tconst constructorType = checker.getTypeOfSymbolAtLocation(\n\t\t\t\t\t\t\t\tsymbol,\n\t\t\t\t\t\t\t\tsymbol.valueDeclaration\n\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\tlet parentClassSymbol: ts.Symbol | undefined\n\t\t\t\t\t\t\tif (node.heritageClauses && node.heritageClauses[0]) {\n\t\t\t\t\t\t\t\tparentClassSymbol = checker\n\t\t\t\t\t\t\t\t\t.getTypeAtLocation(node.heritageClauses[0].types[0])\n\t\t\t\t\t\t\t\t\t.getSymbol()\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst parentClassName =\n\t\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\t\tparentClassSymbol?.valueDeclaration?.name?.text\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tconst parentClassPath = parentClassSymbol?.parent\n\t\t\t\t\t\t\t\t?.getName()\n\t\t\t\t\t\t\t\t.replace('\"', '')\n\n\t\t\t\t\t\t\tconst isAbstractClass = tsutils.isModifierFlagSet(\n\t\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\t\tts.ModifierFlags.Abstract\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tdetails.constructors = constructorType\n\t\t\t\t\t\t\t\t.getConstructSignatures()\n\t\t\t\t\t\t\t\t.map((s) => serializeSignature({ signature: s, checker }))\n\n\t\t\t\t\t\t\tresults.classes.push({\n\t\t\t\t\t\t\t\tclassName: node.name.text,\n\t\t\t\t\t\t\t\tclassPath: sourceFile.fileName,\n\t\t\t\t\t\t\t\tparentClassName,\n\t\t\t\t\t\t\t\tparentClassPath,\n\t\t\t\t\t\t\t\tstaticProperties: pluckStaticProperties(node),\n\t\t\t\t\t\t\t\toptionsInterfaceName:\n\t\t\t\t\t\t\t\t\tdetails.constructors?.[0].parameters?.[0]?.type,\n\t\t\t\t\t\t\t\tisAbstract: isAbstractClass,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (ts.isInterfaceDeclaration(node)) {\n\t\t\t\t\t\tresults.interfaces.push({\n\t\t\t\t\t\t\tinterfaceName: node.name.text,\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tintrospects.push(results)\n\t\t}\n\n\t\treturn introspects\n\t},\n}\n\nexport default introspectionUtil\n\nfunction pluckStaticProperties(node: ts.ClassDeclaration): StaticProperties {\n\tconst staticProps: StaticProperties = {}\n\n\tfor (const member of node.members) {\n\t\t//@ts-ignore\n\t\tconst name = member.name?.escapedText\n\t\t//@ts-ignore\n\t\tconst value = member.initializer?.text\n\n\t\tif (name && value) {\n\t\t\tstaticProps[name] = value\n\t\t}\n\t}\n\n\treturn staticProps\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,EAAA,GAAAD,uBAAA,CAAAF,OAAA;AAAgC,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,yBAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,gBAAAK,OAAA,CAAAL,CAAA,0BAAAA,CAAA,sBAAAA,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAA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AA;EAAA;EAED,OAAO8F,WAAW;AACnB","ignoreList":[]}
1
+ {"version":3,"file":"introspection.utility.js","names":["_path","require","_spruceSkillUtils","_lodash","_interopRequireDefault","tsutils","_interopRequireWildcard","ts","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","_typeof","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_createForOfIteratorHelper","o","allowArrayLike","it","Symbol","iterator","Array","isArray","_unsupportedIterableToArray","length","F","s","done","value","_e","f","TypeError","normalCompletion","didErr","err","step","next","_e2","minLen","_arrayLikeToArray","prototype","toString","slice","constructor","name","from","test","arr","len","arr2","serializeSymbol","options","checker","symbol","doc","getName","documentation","displayPartsToString","getDocumentationComment","valueDeclaration","type","typeToString","getTypeOfSymbolAtLocation","serializeSignature","signature","parameters","map","p","returnType","getReturnType","introspectionUtil","introspect","tsFiles","_this","filePaths","program","createProgram","getTypeChecker","introspects","_loop","tsFile","sourceFile","getSourceFile","results","classes","interfaces","_","includes","fileName","hasClassDefinition","exports","getExports","firstExport","declaration","getClassDeclarationFromImportedFile","dirname","_results$classes","_results$interfaces","_getDeclarationsFromN","getDeclarationsFromNode","push","apply","_toConsumableArray2","_firstExport$exportCl","className","exportClause","elements","propertyName","text","classPath","isAbstract","optionsInterfaceName","undefined","parentClassName","parentClassPath","staticProperties","forEachChild","node","_results$classes2","_results$interfaces2","_getDeclarationsFromN2","traverse","isExportDeclaration","exportDeclaration","dirName","isNamedExports","_iterator","_step","_loop2","element","moduleSpecifier","diskUtil","resolveFile","replace","v","declarationSourceFile","isClassDeclaration","_iterator2","getChildren","_step2","child","result","_ret","hasClass","_default","getSymbolAtLocation","_parentClassSymbol","_parentClassSymbol2","_details$constructors","details","constructorType","parentClassSymbol","heritageClauses","getTypeAtLocation","types","getSymbol","parent","isAbstractClass","isModifierFlagSet","ModifierFlags","Abstract","constructors","getConstructSignatures","pluckStaticProperties","isInterfaceDeclaration","interfaceName","staticProps","_iterator3","members","_step3","_member$name","_member$initializer","member","escapedText","initializer"],"sources":["../../src/utilities/introspection.utility.ts"],"sourcesContent":["import { dirname } from 'path'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport _ from 'lodash'\nimport * as tsutils from 'tsutils'\nimport * as ts from 'typescript'\n\nconst serializeSymbol = (options: {\n\tchecker: ts.TypeChecker\n\tsymbol: ts.Symbol\n}): DocEntry => {\n\tconst { checker, symbol } = options\n\tconst doc: DocEntry = {\n\t\tname: symbol.getName(),\n\t\tdocumentation: ts.displayPartsToString(\n\t\t\tsymbol.getDocumentationComment(checker)\n\t\t),\n\t}\n\n\tif (symbol.valueDeclaration) {\n\t\tdoc.type = checker.typeToString(\n\t\t\tchecker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration)\n\t\t)\n\t}\n\n\treturn doc\n}\n\nconst serializeSignature = (options: {\n\tchecker: ts.TypeChecker\n\tsignature: ts.Signature\n}) => {\n\tconst { checker, signature } = options\n\treturn {\n\t\tparameters: signature.parameters.map((p) =>\n\t\t\tserializeSymbol({ symbol: p, checker })\n\t\t),\n\t\treturnType: checker.typeToString(signature.getReturnType()),\n\t\tdocumentation: ts.displayPartsToString(\n\t\t\tsignature.getDocumentationComment(checker)\n\t\t),\n\t}\n}\n\nconst introspectionUtil = {\n\tintrospect(tsFiles: string[]): Introspection[] {\n\t\tconst filePaths = tsFiles\n\t\tconst program = ts.createProgram(filePaths, {})\n\t\tconst checker = program.getTypeChecker()\n\n\t\t// for building results\n\t\tconst introspects: Introspection[] = []\n\n\t\tfor (let i = 0; i < filePaths.length; i += 1) {\n\t\t\tconst tsFile = filePaths[i]\n\t\t\tconst sourceFile = program.getSourceFile(tsFile)\n\t\t\tconst results: Introspection = { classes: [], interfaces: [] }\n\t\t\tif (sourceFile && _.includes(filePaths, sourceFile.fileName)) {\n\t\t\t\tif (!this.hasClassDefinition(sourceFile)) {\n\t\t\t\t\tconst exports = this.getExports(sourceFile)\n\t\t\t\t\tconst firstExport = exports[0]\n\t\t\t\t\tif (firstExport) {\n\t\t\t\t\t\tconst declaration = this.getClassDeclarationFromImportedFile(\n\t\t\t\t\t\t\tfirstExport,\n\t\t\t\t\t\t\tdirname(tsFile),\n\t\t\t\t\t\t\tprogram\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tif (declaration) {\n\t\t\t\t\t\t\tconst { classes, interfaces } = getDeclarationsFromNode(\n\t\t\t\t\t\t\t\tdeclaration,\n\t\t\t\t\t\t\t\tchecker,\n\t\t\t\t\t\t\t\tsourceFile\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\tresults.classes.push(...classes)\n\t\t\t\t\t\t\tresults.interfaces.push(...interfaces)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t// must have imported from somewhere else (another node module)\n\t\t\t\t\t\t\tconst className = //@ts-ignore\n\t\t\t\t\t\t\t\tfirstExport.exportClause?.elements?.[0]?.propertyName?.text\n\n\t\t\t\t\t\t\tif (className) {\n\t\t\t\t\t\t\t\tresults.classes.push({\n\t\t\t\t\t\t\t\t\tclassName,\n\t\t\t\t\t\t\t\t\tclassPath: tsFile,\n\t\t\t\t\t\t\t\t\tisAbstract: false,\n\t\t\t\t\t\t\t\t\toptionsInterfaceName: undefined,\n\t\t\t\t\t\t\t\t\tparentClassName: undefined,\n\t\t\t\t\t\t\t\t\tparentClassPath: undefined,\n\t\t\t\t\t\t\t\t\tstaticProperties: {},\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tts.forEachChild(sourceFile, (node) => {\n\t\t\t\t\t\tconst { classes, interfaces } = getDeclarationsFromNode(\n\t\t\t\t\t\t\tnode,\n\t\t\t\t\t\t\tchecker,\n\t\t\t\t\t\t\tsourceFile\n\t\t\t\t\t\t)\n\n\t\t\t\t\t\tresults.classes.push(...classes)\n\t\t\t\t\t\tresults.interfaces.push(...interfaces)\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tintrospects.push(results)\n\t\t}\n\n\t\treturn introspects\n\t},\n\n\tgetExports(sourceFile: ts.SourceFile): ts.Node[] {\n\t\tconst exports: ts.Node[] = []\n\n\t\tconst traverse = (node: ts.Node) => {\n\t\t\tif (ts.isExportDeclaration(node)) {\n\t\t\t\texports.push(node)\n\t\t\t}\n\n\t\t\tts.forEachChild(node, traverse)\n\t\t}\n\n\t\ttraverse(sourceFile)\n\n\t\treturn exports\n\t},\n\n\tgetClassDeclarationFromImportedFile(\n\t\texportDeclaration: ts.Node,\n\t\tdirName: string,\n\t\tprogram: ts.Program\n\t): ts.ClassDeclaration | undefined {\n\t\tif (!ts.isExportDeclaration(exportDeclaration)) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tconst exportClause = exportDeclaration.exportClause\n\t\tif (!exportClause || !ts.isNamedExports(exportClause)) {\n\t\t\treturn undefined\n\t\t}\n\n\t\tfor (const element of exportClause.elements) {\n\t\t\tif (element.propertyName) {\n\t\t\t\tconst propertyName = element.propertyName.text\n\t\t\t\tconst moduleSpecifier = (\n\t\t\t\t\texportDeclaration.moduleSpecifier as ts.StringLiteral\n\t\t\t\t).text\n\n\t\t\t\tconst sourceFile = diskUtil.resolveFile(\n\t\t\t\t\tdirName,\n\t\t\t\t\tmoduleSpecifier.replace(/^\\.\\//, '')\n\t\t\t\t)\n\n\t\t\t\tif (!sourceFile) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\n\t\t\t\t// Load the source file containing the class declaration\n\t\t\t\tconst declarationSourceFile = program.getSourceFile(sourceFile)\n\t\t\t\tif (!declarationSourceFile) {\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\n\t\t\t\tconst traverse = (node: ts.Node): ts.ClassDeclaration | undefined => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tts.isClassDeclaration(node) &&\n\t\t\t\t\t\tnode.name &&\n\t\t\t\t\t\tnode.name.text === propertyName\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn node\n\t\t\t\t\t}\n\n\t\t\t\t\tfor (const child of node.getChildren(declarationSourceFile)) {\n\t\t\t\t\t\tconst result = traverse(child)\n\t\t\t\t\t\tif (result) {\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\treturn undefined\n\t\t\t\t}\n\n\t\t\t\treturn traverse(declarationSourceFile)\n\t\t\t}\n\t\t}\n\n\t\treturn undefined\n\t},\n\n\thasClassDefinition(sourceFile: ts.SourceFile): boolean {\n\t\tlet hasClass = false\n\n\t\tconst traverse = (node: ts.Node) => {\n\t\t\tif (ts.isClassDeclaration(node)) {\n\t\t\t\thasClass = true\n\t\t\t}\n\n\t\t\tif (!hasClass) {\n\t\t\t\tts.forEachChild(node, traverse)\n\t\t\t}\n\t\t}\n\n\t\ttraverse(sourceFile)\n\n\t\treturn hasClass\n\t},\n}\n\nexport default introspectionUtil\n\nfunction getDeclarationsFromNode(\n\tnode: ts.Node,\n\tchecker: ts.TypeChecker,\n\tsourceFile: ts.SourceFile\n) {\n\tconst classes: IntrospectionClass[] = []\n\tconst interfaces: IntrospectionInterface[] = []\n\n\t// if this is a class declaration\n\tif (ts.isClassDeclaration(node) && node.name) {\n\t\tconst symbol = checker.getSymbolAtLocation(node.name)\n\n\t\tif (symbol?.valueDeclaration) {\n\t\t\tconst details = serializeSymbol({ checker, symbol })\n\t\t\t// Get the construct signatures\n\t\t\tconst constructorType = checker.getTypeOfSymbolAtLocation(\n\t\t\t\tsymbol,\n\t\t\t\tsymbol.valueDeclaration\n\t\t\t)\n\n\t\t\tlet parentClassSymbol: ts.Symbol | undefined\n\t\t\tif (node.heritageClauses && node.heritageClauses[0]) {\n\t\t\t\tparentClassSymbol = checker\n\t\t\t\t\t.getTypeAtLocation(node.heritageClauses[0].types[0])\n\t\t\t\t\t.getSymbol()\n\t\t\t}\n\n\t\t\tconst parentClassName =\n\t\t\t\t// @ts-ignore\n\t\t\t\tparentClassSymbol?.valueDeclaration?.name?.text\n\t\t\t// @ts-ignore\n\t\t\tconst parentClassPath = parentClassSymbol?.parent\n\t\t\t\t?.getName()\n\t\t\t\t.replace('\"', '')\n\n\t\t\tconst isAbstractClass = tsutils.isModifierFlagSet(\n\t\t\t\tnode,\n\t\t\t\tts.ModifierFlags.Abstract\n\t\t\t)\n\t\t\tdetails.constructors = constructorType\n\t\t\t\t.getConstructSignatures()\n\t\t\t\t.map((s) => serializeSignature({ signature: s, checker }))\n\n\t\t\tclasses.push({\n\t\t\t\tclassName: node.name.text,\n\t\t\t\tclassPath: sourceFile.fileName,\n\t\t\t\tparentClassName,\n\t\t\t\tparentClassPath,\n\t\t\t\tstaticProperties: pluckStaticProperties(node),\n\t\t\t\toptionsInterfaceName: details.constructors?.[0].parameters?.[0]?.type,\n\t\t\t\tisAbstract: isAbstractClass,\n\t\t\t})\n\t\t}\n\t} else if (ts.isInterfaceDeclaration(node)) {\n\t\tinterfaces.push({\n\t\t\tinterfaceName: node.name.text,\n\t\t})\n\t}\n\treturn { classes, interfaces }\n}\n\nfunction pluckStaticProperties(node: ts.ClassDeclaration): StaticProperties {\n\tconst staticProps: StaticProperties = {}\n\n\tfor (const member of node.members) {\n\t\t//@ts-ignore\n\t\tconst name = member.name?.escapedText\n\t\t//@ts-ignore\n\t\tconst value = member.initializer?.text\n\n\t\tif (name && value) {\n\t\t\tstaticProps[name] = value\n\t\t}\n\t}\n\n\treturn staticProps\n}\n\nexport interface IntrospectionClass {\n\tclassName: string\n\tclassPath: string\n\tparentClassName: string | undefined\n\tparentClassPath: string | undefined\n\toptionsInterfaceName: string | undefined\n\tisAbstract: boolean\n\tstaticProperties: StaticProperties\n}\n\ntype StaticProperties = Record<string, any>\n\ninterface IntrospectionInterface {\n\tinterfaceName: string\n}\n\nexport interface Introspection {\n\tclasses: IntrospectionClass[]\n\tinterfaces: IntrospectionInterface[]\n}\n\ninterface DocEntry {\n\tname?: string\n\tfileName?: string\n\tdocumentation?: string\n\ttype?: string\n\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CAAC0K,sBAAsB,CAAC/C,IAAI,CAAC,EAAE;IAC3ChC,UAAU,CAACe,IAAI,CAAC;MACfiE,aAAa,EAAEhD,IAAI,CAACzE,IAAI,CAACgE;IAC1B,CAAC,CAAC;EACH;EACA,OAAO;IAAExB,OAAO,EAAPA,OAAO;IAAEC,UAAU,EAAVA;EAAW,CAAC;AAC/B;AAEA,SAAS8E,qBAAqBA,CAAC9C,IAAyB,EAAoB;EAC3E,IAAMiD,WAA6B,GAAG,CAAC,CAAC;EAAA,IAAAC,UAAA,GAAAxJ,0BAAA,CAEnBsG,IAAI,CAACmD,OAAO;IAAAC,MAAA;EAAA;IAAjC,KAAAF,UAAA,CAAA7I,CAAA,MAAA+I,MAAA,GAAAF,UAAA,CAAAnK,CAAA,IAAAuB,IAAA,GAAmC;MAAA,IAAA+I,YAAA,EAAAC,mBAAA;MAAA,IAAxBC,MAAM,GAAAH,MAAA,CAAA7I,KAAA;MAChB;MACA,IAAMgB,IAAI,IAAA8H,YAAA,GAAGE,MAAM,CAAChI,IAAI,cAAA8H,YAAA,uBAAXA,YAAA,CAAaG,WAAW;MACrC;MACA,IAAMjJ,KAAK,IAAA+I,mBAAA,GAAGC,MAAM,CAACE,WAAW,cAAAH,mBAAA,uBAAlBA,mBAAA,CAAoB/D,IAAI;MAEtC,IAAIhE,IAAI,IAAIhB,KAAK,EAAE;QAClB0I,WAAW,CAAC1H,IAAI,CAAC,GAAGhB,KAAK;MAC1B;IACD;EAAC,SAAAM,GAAA;IAAAqI,UAAA,CAAA3K,CAAA,CAAAsC,GAAA;EAAA;IAAAqI,UAAA,CAAAzI,CAAA;EAAA;EAED,OAAOwI,WAAW;AACnB","ignoreList":[]}
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  ]
18
18
  },
19
19
  "license": "MIT",
20
- "version": "19.2.4",
20
+ "version": "20.0.1",
21
21
  "bin": {
22
22
  "spruce": "./build/index.js"
23
23
  },
@@ -75,18 +75,18 @@
75
75
  "@babel/plugin-proposal-decorators": "^7.24.1",
76
76
  "@babel/runtime": "^7.24.1",
77
77
  "@jest/reporters": "^29.7.0",
78
- "@sprucelabs/error": "^5.1.79",
78
+ "@sprucelabs/error": "^5.1.82",
79
79
  "@sprucelabs/globby": "^1.0.21",
80
- "@sprucelabs/heartwood-view-controllers": "^109.5.0",
81
- "@sprucelabs/jest-json-reporter": "^7.0.186",
82
- "@sprucelabs/mercury-client": "^41.0.346",
83
- "@sprucelabs/mercury-event-emitter": "^41.0.346",
84
- "@sprucelabs/mercury-types": "^46.0.266",
85
- "@sprucelabs/schema": "^29.4.28",
86
- "@sprucelabs/spruce-core-schemas": "^39.0.262",
87
- "@sprucelabs/spruce-event-utils": "^38.1.6",
88
- "@sprucelabs/spruce-skill-utils": "^30.3.24",
89
- "@sprucelabs/spruce-templates": "^19.2.4",
80
+ "@sprucelabs/heartwood-view-controllers": "^109.7.0",
81
+ "@sprucelabs/jest-json-reporter": "^7.0.188",
82
+ "@sprucelabs/mercury-client": "^41.0.351",
83
+ "@sprucelabs/mercury-event-emitter": "^41.0.351",
84
+ "@sprucelabs/mercury-types": "^46.0.269",
85
+ "@sprucelabs/schema": "^29.4.31",
86
+ "@sprucelabs/spruce-core-schemas": "^39.0.265",
87
+ "@sprucelabs/spruce-event-utils": "^38.1.10",
88
+ "@sprucelabs/spruce-skill-utils": "^30.3.27",
89
+ "@sprucelabs/spruce-templates": "^20.0.1",
90
90
  "@typescript-eslint/eslint-plugin": "^5.27.1",
91
91
  "@typescript-eslint/parser": "^5.27.1",
92
92
  "cfonts": "^3.2.0",
@@ -109,20 +109,20 @@
109
109
  "terminal-kit": "sprucelabsai/terminal-kit",
110
110
  "tree-kill": "^1.2.2",
111
111
  "tsutils": "^3.21.0",
112
- "typescript": "^5.4.2",
112
+ "typescript": "^5.4.3",
113
113
  "uuid": "^9.0.1"
114
114
  },
115
115
  "devDependencies": {
116
- "@sprucelabs/data-stores": "^26.4.56",
116
+ "@sprucelabs/data-stores": "^26.4.58",
117
117
  "@sprucelabs/jest-sheets-reporter": "^3.0.26",
118
- "@sprucelabs/mercury-core-events": "^22.2.50",
119
- "@sprucelabs/resolve-path-aliases": "^1.1.290",
120
- "@sprucelabs/spruce-conversation-plugin": "^60.1.301",
121
- "@sprucelabs/spruce-deploy-plugin": "^60.1.301",
122
- "@sprucelabs/spruce-store-plugin": "^60.1.301",
123
- "@sprucelabs/spruce-test-fixtures": "^60.1.301",
124
- "@sprucelabs/test": "^8.0.44",
125
- "@sprucelabs/test-utils": "^4.0.126",
118
+ "@sprucelabs/mercury-core-events": "^22.2.54",
119
+ "@sprucelabs/resolve-path-aliases": "^1.1.291",
120
+ "@sprucelabs/spruce-conversation-plugin": "^61.0.0",
121
+ "@sprucelabs/spruce-deploy-plugin": "^61.0.0",
122
+ "@sprucelabs/spruce-store-plugin": "^61.0.0",
123
+ "@sprucelabs/spruce-test-fixtures": "^61.0.0",
124
+ "@sprucelabs/test": "^8.0.45",
125
+ "@sprucelabs/test-utils": "^4.0.129",
126
126
  "@types/blessed": "^0.1.25",
127
127
  "@types/eslint": "^8.56.6",
128
128
  "@types/fs-extra": "^11.0.4",
@@ -135,7 +135,7 @@
135
135
  "@types/semver": "^7.5.8",
136
136
  "@types/sha1": "^1.1.5",
137
137
  "@types/slug": "^5.0.8",
138
- "@types/superagent": "^8.1.4",
138
+ "@types/superagent": "^8.1.5",
139
139
  "@types/terminal-kit": "^2.5.6",
140
140
  "@types/uuid": "^9.0.8",
141
141
  "chokidar-cli": "^3.0.0",
@@ -590,5 +590,5 @@
590
590
  "terminal-kit"
591
591
  ]
592
592
  },
593
- "gitHead": "65e7067ed8eda36189be2162170a3d469cd70bb5"
593
+ "gitHead": "19fa45255f1b3e1b38cd2c157f000fc28dbfc320"
594
594
  }
@@ -41,6 +41,7 @@ export default class EnablingAndDisablingCacheTest extends AbstractCliTest {
41
41
  protected static async returnsErrorWhenDockerNotEnabled() {
42
42
  CommandService.fakeCommand(/npm config/gis, {
43
43
  code: 1,
44
+ stderr: 'which',
44
45
  })
45
46
 
46
47
  const results = await this.Action('cache', 'enable').execute({})
@@ -255,7 +255,7 @@ import { vcDiskUtil } from '@sprucelabs/spruce-test-fixtures'
255
255
  AuthenticatorImpl.setStorage(new StubStorage())
256
256
 
257
257
  const vcFactory = ViewControllerFactory.Factory({
258
- controllerMap: vcDiskUtil.loadViewControllersAndBuildMap('testing-views', __dirname),
258
+ controllerMap: vcDiskUtil.loadViewControllersAndBuildMap('testing-views', __dirname).map,
259
259
  device: {} as any,
260
260
  connectToApi: async () => {
261
261
  return 'yes' as any
@@ -83,7 +83,7 @@ export default class CreatingAViewPluginTest extends AbstractSkillTest {
83
83
 
84
84
  @test()
85
85
  protected static async updatesViewCombinedWithPluginsAsExpected() {
86
- const expected = `export const pluginClasses = {
86
+ const expected = `export const pluginsByName = {
87
87
  aThird: AThirdViewPlugin,
88
88
  another: AnotherViewPlugin,
89
89
  test: TestViewPlugin,
@@ -92,7 +92,60 @@ export default class CreatingAViewPluginTest extends AbstractSkillTest {
92
92
  `
93
93
 
94
94
  this.assertCombinedFileIncludes(expected)
95
- this.assertCombinedFileIncludes('heartwood(vcs, pluginClasses)')
95
+ this.assertCombinedFileIncludes('heartwood(vcs, pluginsByName)')
96
+ }
97
+
98
+ @test()
99
+ protected static async viewPluginCanImportAnotherViewPlugin() {
100
+ this.writeFile('export class ExternalViewPlugin {}', 'external.ts')
101
+ this.writeFile(
102
+ `export { ExternalViewPlugin as default } from './external'`,
103
+ 'actual.view.plugin.ts'
104
+ )
105
+
106
+ await this.syncViews()
107
+
108
+ const expected = `export const pluginsByName = {
109
+ actual: ExternalViewPlugin,
110
+ aThird: AThirdViewPlugin,
111
+ another: AnotherViewPlugin,
112
+ test: TestViewPlugin,
113
+ testCamel: TestCamelViewPlugin,
114
+ }
115
+ `
116
+
117
+ this.assertCombinedFileIncludes(expected)
118
+ }
119
+
120
+ @test()
121
+ protected static async canImportPluginFromExternalLibrary() {
122
+ this.writeFile(
123
+ "export { CardViewController as default } from '@sprucelabs/heartwood-view-controllers'",
124
+ 'card.view.plugin.ts'
125
+ )
126
+
127
+ await this.syncViews()
128
+
129
+ const expected = `export const pluginsByName = {
130
+ actual: ExternalViewPlugin,
131
+ card: CardViewController,
132
+ aThird: AThirdViewPlugin,
133
+ another: AnotherViewPlugin,
134
+ test: TestViewPlugin,
135
+ testCamel: TestCamelViewPlugin,
136
+ }
137
+ `
138
+ this.assertCombinedFileIncludes(expected)
139
+ }
140
+
141
+ private static async syncViews() {
142
+ await this.Action('view', 'sync').execute({})
143
+ }
144
+
145
+ private static writeFile(content: string, fileName: string) {
146
+ const actualPlugiContent = content
147
+ const actualDestination = this.resolvePath('src', fileName)
148
+ diskUtil.writeFile(actualDestination, actualPlugiContent)
96
149
  }
97
150
 
98
151
  private static assertCombinedFileIncludes(expected: string) {
@@ -235,7 +235,9 @@ export default class SpruceError extends AbstractSpruceError<ErrorOptions> {
235
235
  break
236
236
 
237
237
  case 'DOCKER_NOT_STARTED':
238
- message = 'Docker has not been started! Start it and try again!'
238
+ message =
239
+ 'Docker has not been started (or you are trying to run this command in a monorepo)! Start it and try again (or move out of a monorepo)! Originial error:\n\n' +
240
+ options.originalError?.stack
239
241
  break
240
242
 
241
243
  case 'SCHEMA_TEMPLATE_ITEM_BUILDING_FAILED':
@@ -36,9 +36,11 @@ export default class EnableCacheAction extends AbstractAction<OptionsSchema> {
36
36
  }
37
37
  } catch (err: any) {
38
38
  let error = err
39
+
39
40
  if (err.options?.cmd?.includes('which')) {
40
41
  error = new SpruceError({
41
42
  code: 'MISSING_DEPENDENCIES',
43
+ originalError: err,
42
44
  dependencies: [
43
45
  {
44
46
  name: 'Docker',
@@ -47,7 +49,10 @@ export default class EnableCacheAction extends AbstractAction<OptionsSchema> {
47
49
  ],
48
50
  })
49
51
  } else {
50
- error = new SpruceError({ code: 'DOCKER_NOT_STARTED' })
52
+ error = new SpruceError({
53
+ code: 'DOCKER_NOT_STARTED',
54
+ originalError: err,
55
+ })
51
56
  }
52
57
 
53
58
  return {
@@ -49,6 +49,8 @@ export default class SyncAction extends AbstractAction<OptionsSchema> {
49
49
  viewPluginItems.push(plugin)
50
50
  } else if (svc) {
51
51
  svcTemplateItems.push(svc)
52
+ } else {
53
+ throw new Error('Unexpected class type.')
52
54
  }
53
55
  }
54
56
  })
@@ -1,38 +1,9 @@
1
+ import { dirname } from 'path'
2
+ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
1
3
  import _ from 'lodash'
2
4
  import * as tsutils from 'tsutils'
3
5
  import * as ts from 'typescript'
4
6
 
5
- export interface IntrospectionClass {
6
- className: string
7
- classPath: string
8
- parentClassName: string | undefined
9
- parentClassPath: string | undefined
10
- optionsInterfaceName: string | undefined
11
- isAbstract: boolean
12
- staticProperties: StaticProperties
13
- }
14
-
15
- type StaticProperties = Record<string, any>
16
-
17
- interface IntrospectionInterface {
18
- interfaceName: string
19
- }
20
-
21
- export interface Introspection {
22
- classes: IntrospectionClass[]
23
- interfaces: IntrospectionInterface[]
24
- }
25
-
26
- interface DocEntry {
27
- name?: string
28
- fileName?: string
29
- documentation?: string
30
- type?: string
31
- constructors?: DocEntry[]
32
- parameters?: DocEntry[]
33
- returnType?: string
34
- }
35
-
36
7
  const serializeSymbol = (options: {
37
8
  checker: ts.TypeChecker
38
9
  symbol: ts.Symbol
@@ -84,59 +55,54 @@ const introspectionUtil = {
84
55
  const sourceFile = program.getSourceFile(tsFile)
85
56
  const results: Introspection = { classes: [], interfaces: [] }
86
57
  if (sourceFile && _.includes(filePaths, sourceFile.fileName)) {
87
- ts.forEachChild(sourceFile, (node) => {
88
- // if this is a class declaration
89
- if (ts.isClassDeclaration(node) && node.name) {
90
- const symbol = checker.getSymbolAtLocation(node.name)
91
-
92
- if (symbol?.valueDeclaration) {
93
- const details = serializeSymbol({ checker, symbol })
94
- // Get the construct signatures
95
- const constructorType = checker.getTypeOfSymbolAtLocation(
96
- symbol,
97
- symbol.valueDeclaration
58
+ if (!this.hasClassDefinition(sourceFile)) {
59
+ const exports = this.getExports(sourceFile)
60
+ const firstExport = exports[0]
61
+ if (firstExport) {
62
+ const declaration = this.getClassDeclarationFromImportedFile(
63
+ firstExport,
64
+ dirname(tsFile),
65
+ program
66
+ )
67
+
68
+ if (declaration) {
69
+ const { classes, interfaces } = getDeclarationsFromNode(
70
+ declaration,
71
+ checker,
72
+ sourceFile
98
73
  )
74
+ results.classes.push(...classes)
75
+ results.interfaces.push(...interfaces)
76
+ } else {
77
+ // must have imported from somewhere else (another node module)
78
+ const className = //@ts-ignore
79
+ firstExport.exportClause?.elements?.[0]?.propertyName?.text
99
80
 
100
- let parentClassSymbol: ts.Symbol | undefined
101
- if (node.heritageClauses && node.heritageClauses[0]) {
102
- parentClassSymbol = checker
103
- .getTypeAtLocation(node.heritageClauses[0].types[0])
104
- .getSymbol()
81
+ if (className) {
82
+ results.classes.push({
83
+ className,
84
+ classPath: tsFile,
85
+ isAbstract: false,
86
+ optionsInterfaceName: undefined,
87
+ parentClassName: undefined,
88
+ parentClassPath: undefined,
89
+ staticProperties: {},
90
+ })
105
91
  }
106
-
107
- const parentClassName =
108
- // @ts-ignore
109
- parentClassSymbol?.valueDeclaration?.name?.text
110
- // @ts-ignore
111
- const parentClassPath = parentClassSymbol?.parent
112
- ?.getName()
113
- .replace('"', '')
114
-
115
- const isAbstractClass = tsutils.isModifierFlagSet(
116
- node,
117
- ts.ModifierFlags.Abstract
118
- )
119
- details.constructors = constructorType
120
- .getConstructSignatures()
121
- .map((s) => serializeSignature({ signature: s, checker }))
122
-
123
- results.classes.push({
124
- className: node.name.text,
125
- classPath: sourceFile.fileName,
126
- parentClassName,
127
- parentClassPath,
128
- staticProperties: pluckStaticProperties(node),
129
- optionsInterfaceName:
130
- details.constructors?.[0].parameters?.[0]?.type,
131
- isAbstract: isAbstractClass,
132
- })
133
92
  }
134
- } else if (ts.isInterfaceDeclaration(node)) {
135
- results.interfaces.push({
136
- interfaceName: node.name.text,
137
- })
138
93
  }
139
- })
94
+ } else {
95
+ ts.forEachChild(sourceFile, (node) => {
96
+ const { classes, interfaces } = getDeclarationsFromNode(
97
+ node,
98
+ checker,
99
+ sourceFile
100
+ )
101
+
102
+ results.classes.push(...classes)
103
+ results.interfaces.push(...interfaces)
104
+ })
105
+ }
140
106
  }
141
107
 
142
108
  introspects.push(results)
@@ -144,10 +110,167 @@ const introspectionUtil = {
144
110
 
145
111
  return introspects
146
112
  },
113
+
114
+ getExports(sourceFile: ts.SourceFile): ts.Node[] {
115
+ const exports: ts.Node[] = []
116
+
117
+ const traverse = (node: ts.Node) => {
118
+ if (ts.isExportDeclaration(node)) {
119
+ exports.push(node)
120
+ }
121
+
122
+ ts.forEachChild(node, traverse)
123
+ }
124
+
125
+ traverse(sourceFile)
126
+
127
+ return exports
128
+ },
129
+
130
+ getClassDeclarationFromImportedFile(
131
+ exportDeclaration: ts.Node,
132
+ dirName: string,
133
+ program: ts.Program
134
+ ): ts.ClassDeclaration | undefined {
135
+ if (!ts.isExportDeclaration(exportDeclaration)) {
136
+ return undefined
137
+ }
138
+
139
+ const exportClause = exportDeclaration.exportClause
140
+ if (!exportClause || !ts.isNamedExports(exportClause)) {
141
+ return undefined
142
+ }
143
+
144
+ for (const element of exportClause.elements) {
145
+ if (element.propertyName) {
146
+ const propertyName = element.propertyName.text
147
+ const moduleSpecifier = (
148
+ exportDeclaration.moduleSpecifier as ts.StringLiteral
149
+ ).text
150
+
151
+ const sourceFile = diskUtil.resolveFile(
152
+ dirName,
153
+ moduleSpecifier.replace(/^\.\//, '')
154
+ )
155
+
156
+ if (!sourceFile) {
157
+ return undefined
158
+ }
159
+
160
+ // Load the source file containing the class declaration
161
+ const declarationSourceFile = program.getSourceFile(sourceFile)
162
+ if (!declarationSourceFile) {
163
+ return undefined
164
+ }
165
+
166
+ const traverse = (node: ts.Node): ts.ClassDeclaration | undefined => {
167
+ if (
168
+ ts.isClassDeclaration(node) &&
169
+ node.name &&
170
+ node.name.text === propertyName
171
+ ) {
172
+ return node
173
+ }
174
+
175
+ for (const child of node.getChildren(declarationSourceFile)) {
176
+ const result = traverse(child)
177
+ if (result) {
178
+ return result
179
+ }
180
+ }
181
+
182
+ return undefined
183
+ }
184
+
185
+ return traverse(declarationSourceFile)
186
+ }
187
+ }
188
+
189
+ return undefined
190
+ },
191
+
192
+ hasClassDefinition(sourceFile: ts.SourceFile): boolean {
193
+ let hasClass = false
194
+
195
+ const traverse = (node: ts.Node) => {
196
+ if (ts.isClassDeclaration(node)) {
197
+ hasClass = true
198
+ }
199
+
200
+ if (!hasClass) {
201
+ ts.forEachChild(node, traverse)
202
+ }
203
+ }
204
+
205
+ traverse(sourceFile)
206
+
207
+ return hasClass
208
+ },
147
209
  }
148
210
 
149
211
  export default introspectionUtil
150
212
 
213
+ function getDeclarationsFromNode(
214
+ node: ts.Node,
215
+ checker: ts.TypeChecker,
216
+ sourceFile: ts.SourceFile
217
+ ) {
218
+ const classes: IntrospectionClass[] = []
219
+ const interfaces: IntrospectionInterface[] = []
220
+
221
+ // if this is a class declaration
222
+ if (ts.isClassDeclaration(node) && node.name) {
223
+ const symbol = checker.getSymbolAtLocation(node.name)
224
+
225
+ if (symbol?.valueDeclaration) {
226
+ const details = serializeSymbol({ checker, symbol })
227
+ // Get the construct signatures
228
+ const constructorType = checker.getTypeOfSymbolAtLocation(
229
+ symbol,
230
+ symbol.valueDeclaration
231
+ )
232
+
233
+ let parentClassSymbol: ts.Symbol | undefined
234
+ if (node.heritageClauses && node.heritageClauses[0]) {
235
+ parentClassSymbol = checker
236
+ .getTypeAtLocation(node.heritageClauses[0].types[0])
237
+ .getSymbol()
238
+ }
239
+
240
+ const parentClassName =
241
+ // @ts-ignore
242
+ parentClassSymbol?.valueDeclaration?.name?.text
243
+ // @ts-ignore
244
+ const parentClassPath = parentClassSymbol?.parent
245
+ ?.getName()
246
+ .replace('"', '')
247
+
248
+ const isAbstractClass = tsutils.isModifierFlagSet(
249
+ node,
250
+ ts.ModifierFlags.Abstract
251
+ )
252
+ details.constructors = constructorType
253
+ .getConstructSignatures()
254
+ .map((s) => serializeSignature({ signature: s, checker }))
255
+
256
+ classes.push({
257
+ className: node.name.text,
258
+ classPath: sourceFile.fileName,
259
+ parentClassName,
260
+ parentClassPath,
261
+ staticProperties: pluckStaticProperties(node),
262
+ optionsInterfaceName: details.constructors?.[0].parameters?.[0]?.type,
263
+ isAbstract: isAbstractClass,
264
+ })
265
+ }
266
+ } else if (ts.isInterfaceDeclaration(node)) {
267
+ interfaces.push({
268
+ interfaceName: node.name.text,
269
+ })
270
+ }
271
+ return { classes, interfaces }
272
+ }
273
+
151
274
  function pluckStaticProperties(node: ts.ClassDeclaration): StaticProperties {
152
275
  const staticProps: StaticProperties = {}
153
276
 
@@ -164,3 +287,34 @@ function pluckStaticProperties(node: ts.ClassDeclaration): StaticProperties {
164
287
 
165
288
  return staticProps
166
289
  }
290
+
291
+ export interface IntrospectionClass {
292
+ className: string
293
+ classPath: string
294
+ parentClassName: string | undefined
295
+ parentClassPath: string | undefined
296
+ optionsInterfaceName: string | undefined
297
+ isAbstract: boolean
298
+ staticProperties: StaticProperties
299
+ }
300
+
301
+ type StaticProperties = Record<string, any>
302
+
303
+ interface IntrospectionInterface {
304
+ interfaceName: string
305
+ }
306
+
307
+ export interface Introspection {
308
+ classes: IntrospectionClass[]
309
+ interfaces: IntrospectionInterface[]
310
+ }
311
+
312
+ interface DocEntry {
313
+ name?: string
314
+ fileName?: string
315
+ documentation?: string
316
+ type?: string
317
+ constructors?: DocEntry[]
318
+ parameters?: DocEntry[]
319
+ returnType?: string
320
+ }