@codeyam/codeyam-cli 0.1.0-staging.b8a55ba → 0.1.0-staging.d0ad4ae

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 (340) hide show
  1. package/analyzer-template/.build-info.json +7 -7
  2. package/analyzer-template/common/execAsync.ts +1 -1
  3. package/analyzer-template/log.txt +3 -3
  4. package/analyzer-template/package.json +7 -4
  5. package/analyzer-template/packages/ai/package.json +1 -1
  6. package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +14 -1
  7. package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
  8. package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +120 -19
  9. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
  10. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +91 -35
  11. package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +110 -74
  12. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +11 -0
  13. package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
  14. package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
  15. package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +24 -17
  16. package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +214 -39
  17. package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +54 -1
  18. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +72 -6
  19. package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +12 -5
  20. package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +39 -23
  21. package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -0
  22. package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
  23. package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
  24. package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
  25. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +73 -69
  26. package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +6 -0
  27. package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
  28. package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +22 -6
  29. package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +9 -5
  30. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +49 -11
  31. package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
  32. package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +399 -52
  33. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +128 -2
  34. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +114 -70
  35. package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +34 -129
  36. package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +155 -79
  37. package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
  38. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
  39. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
  40. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
  41. package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
  42. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
  43. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
  44. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
  45. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  46. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
  47. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
  48. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
  49. package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  50. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
  51. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
  52. package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
  53. package/analyzer-template/packages/aws/package.json +1 -1
  54. package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
  55. package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
  56. package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
  57. package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
  58. package/analyzer-template/packages/generate/index.ts +3 -0
  59. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
  60. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
  61. package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
  62. package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
  63. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
  64. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
  65. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +1 -0
  66. package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
  67. package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
  68. package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
  69. package/analyzer-template/packages/github/dist/generate/index.js +3 -0
  70. package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
  71. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
  72. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  73. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  74. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
  75. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
  76. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  77. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  78. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
  79. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
  80. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  81. package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  82. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
  83. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
  84. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
  85. package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  86. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
  87. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
  88. package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
  89. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
  90. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
  91. package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
  92. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
  93. package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
  94. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +6 -0
  95. package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
  96. package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
  97. package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
  98. package/analyzer-template/packages/process/index.ts +2 -0
  99. package/analyzer-template/packages/process/package.json +12 -0
  100. package/analyzer-template/packages/process/tsconfig.json +8 -0
  101. package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
  102. package/analyzer-template/packages/types/src/types/Scenario.ts +6 -0
  103. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
  104. package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
  105. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +6 -0
  106. package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
  107. package/analyzer-template/playwright/capture.ts +37 -18
  108. package/analyzer-template/playwright/waitForServer.ts +21 -6
  109. package/analyzer-template/project/constructMockCode.ts +781 -140
  110. package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
  111. package/analyzer-template/project/orchestrateCapture.ts +10 -3
  112. package/analyzer-template/project/reconcileMockDataKeys.ts +28 -100
  113. package/analyzer-template/project/runAnalysis.ts +5 -0
  114. package/analyzer-template/project/serverOnlyModules.ts +127 -2
  115. package/analyzer-template/project/start.ts +5 -3
  116. package/analyzer-template/project/startScenarioCapture.ts +6 -0
  117. package/analyzer-template/project/writeMockDataTsx.ts +50 -22
  118. package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
  119. package/analyzer-template/project/writeScenarioComponents.ts +162 -100
  120. package/analyzer-template/project/writeScenarioFiles.ts +26 -0
  121. package/analyzer-template/project/writeSimpleRoot.ts +11 -35
  122. package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
  123. package/analyzer-template/scripts/defaultCmd.sh +9 -0
  124. package/background/src/lib/local/createLocalAnalyzer.js +1 -29
  125. package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
  126. package/background/src/lib/local/execAsync.js +1 -1
  127. package/background/src/lib/local/execAsync.js.map +1 -1
  128. package/background/src/lib/virtualized/common/execAsync.js +1 -1
  129. package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
  130. package/background/src/lib/virtualized/project/constructMockCode.js +718 -127
  131. package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
  132. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
  133. package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
  134. package/background/src/lib/virtualized/project/orchestrateCapture.js +7 -4
  135. package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
  136. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +25 -61
  137. package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
  138. package/background/src/lib/virtualized/project/runAnalysis.js +4 -0
  139. package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
  140. package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
  141. package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
  142. package/background/src/lib/virtualized/project/start.js +5 -3
  143. package/background/src/lib/virtualized/project/start.js.map +1 -1
  144. package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
  145. package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
  146. package/background/src/lib/virtualized/project/writeMockDataTsx.js +52 -23
  147. package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
  148. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
  149. package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
  150. package/background/src/lib/virtualized/project/writeScenarioComponents.js +136 -83
  151. package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
  152. package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
  153. package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
  154. package/background/src/lib/virtualized/project/writeSimpleRoot.js +11 -34
  155. package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
  156. package/codeyam-cli/src/cli.js +5 -1
  157. package/codeyam-cli/src/cli.js.map +1 -1
  158. package/codeyam-cli/src/commands/analyze.js +1 -1
  159. package/codeyam-cli/src/commands/analyze.js.map +1 -1
  160. package/codeyam-cli/src/commands/baseline.js +177 -0
  161. package/codeyam-cli/src/commands/baseline.js.map +1 -0
  162. package/codeyam-cli/src/commands/status.js +23 -1
  163. package/codeyam-cli/src/commands/status.js.map +1 -1
  164. package/codeyam-cli/src/commands/test-startup.js +1 -1
  165. package/codeyam-cli/src/commands/test-startup.js.map +1 -1
  166. package/codeyam-cli/src/commands/wipe.js +108 -0
  167. package/codeyam-cli/src/commands/wipe.js.map +1 -0
  168. package/codeyam-cli/src/utils/database.js +91 -5
  169. package/codeyam-cli/src/utils/database.js.map +1 -1
  170. package/codeyam-cli/src/utils/git.js +79 -0
  171. package/codeyam-cli/src/utils/git.js.map +1 -0
  172. package/codeyam-cli/src/utils/queue/job.js +104 -0
  173. package/codeyam-cli/src/utils/queue/job.js.map +1 -1
  174. package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
  175. package/codeyam-cli/src/utils/wipe.js +128 -0
  176. package/codeyam-cli/src/utils/wipe.js.map +1 -0
  177. package/codeyam-cli/src/webserver/app/lib/database.js +66 -17
  178. package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
  179. package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-wXL1Z2Aq.js → EntityItem-Cmysw5OP.js} +1 -1
  180. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CzGX-miz.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
  181. package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CXFKsCOD.js → EntityTypeIcon-CAneekK2.js} +1 -1
  182. package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-D-9pXIaY.js → InteractivePreview-Cu16OUmx.js} +2 -2
  183. package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CBQPrpT0.js → LibraryFunctionPreview-CVtiBnY5.js} +1 -1
  184. package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-B0GLXMsr.js} +1 -1
  185. package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-xgeCVgSM.js} +1 -1
  186. package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-4lcOlid-.js → ReportIssueModal-DcAUIpD_.js} +1 -1
  187. package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-DuDvi0jm.js} +1 -1
  188. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BMKg0SAF.js +15 -0
  189. package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
  190. package/codeyam-cli/src/webserver/build/client/assets/_index-DSmTpjmK.js +11 -0
  191. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BF_aK4y6.js +32 -0
  192. package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BYimnrHg.js → chevron-down-Cx24_aWc.js} +1 -1
  193. package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
  194. package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-BOARzkeR.js} +1 -1
  195. package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CgUsG7ib.js → createLucideIcon-BdhJEx6B.js} +1 -1
  196. package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-DW_hdGUc.js → dev.empty-RJCf3Tvw.js} +1 -1
  197. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-zUEpfPsu.js → entity._sha._-D0-YwkBh.js} +12 -12
  198. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-EylcgScH.js +1 -0
  199. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D_3ero5o.js → entity._sha_.create-scenario-DMe7kvgo.js} +1 -1
  200. package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-C1H_a_Y3.js} +1 -1
  201. package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-CS2cb_eZ.js} +6 -6
  202. package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-DMJ7zii9.js} +1 -1
  203. package/codeyam-cli/src/webserver/build/client/assets/{files-ClR0d32A.js → files-BW7Cyeyi.js} +1 -1
  204. package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-CZu4fif0.js} +2 -2
  205. package/codeyam-cli/src/webserver/build/client/assets/globals-wHVy_II5.css +1 -0
  206. package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-B1h680n5.js} +1 -1
  207. package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-lzqtyFU8.js} +1 -1
  208. package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-B7B9V-bu.js} +1 -1
  209. package/codeyam-cli/src/webserver/build/client/assets/{manifest-09d684be.js → manifest-2d191949.js} +1 -1
  210. package/codeyam-cli/src/webserver/build/client/assets/root-FHgpM6gc.js +56 -0
  211. package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-CxXUmBSd.js} +1 -1
  212. package/codeyam-cli/src/webserver/build/client/assets/{settings-DgTyB-Wg.js → settings-6D8k8Jp5.js} +1 -1
  213. package/codeyam-cli/src/webserver/build/client/assets/simulations-CDJZnWhN.js +1 -0
  214. package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-B6LgvRJg.js} +1 -1
  215. package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-BMIGFP-m.js → useCustomSizes-Dv18q8LD.js} +1 -1
  216. package/codeyam-cli/src/webserver/build/client/assets/{useInteractiveMode-Dk_FQqWJ.js → useInteractiveMode-0ToGk4K3.js} +1 -1
  217. package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.js → useLastLogLine-aSv48UbS.js} +1 -1
  218. package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DsJbgMY9.js → useReportContext-1BX144Eg.js} +1 -1
  219. package/codeyam-cli/src/webserver/build/client/assets/{useToast-DWHcCcl1.js → useToast-mBRpZPiu.js} +1 -1
  220. package/codeyam-cli/src/webserver/build/server/assets/{index-CV6i1S1A.js → index-pU0o5t1o.js} +1 -1
  221. package/codeyam-cli/src/webserver/build/server/assets/server-build-YzfkRwdn.js +178 -0
  222. package/codeyam-cli/src/webserver/build/server/index.js +1 -1
  223. package/codeyam-cli/src/webserver/build-info.json +5 -5
  224. package/codeyam-cli/templates/codeyam-setup-skill.md +138 -3
  225. package/codeyam-cli/templates/debug-codeyam.md +7 -2
  226. package/package.json +5 -5
  227. package/packages/ai/src/lib/astScopes/processExpression.js +13 -1
  228. package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
  229. package/packages/ai/src/lib/checkAllAttributes.js +24 -9
  230. package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
  231. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +94 -18
  232. package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
  233. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
  234. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
  235. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +51 -23
  236. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
  237. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +70 -54
  238. package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
  239. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +11 -0
  240. package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
  241. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
  242. package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
  243. package/packages/ai/src/lib/deepEqual.js +32 -0
  244. package/packages/ai/src/lib/deepEqual.js.map +1 -0
  245. package/packages/ai/src/lib/findMatchingAttribute.js +20 -16
  246. package/packages/ai/src/lib/findMatchingAttribute.js.map +1 -1
  247. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +168 -41
  248. package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
  249. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +42 -1
  250. package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
  251. package/packages/ai/src/lib/generateChangesEntityScenarioData.js +59 -3
  252. package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
  253. package/packages/ai/src/lib/generateChangesEntityScenarios.js +6 -6
  254. package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
  255. package/packages/ai/src/lib/generateEntityScenarioData.js +32 -23
  256. package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
  257. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +20 -1
  258. package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
  259. package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
  260. package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
  261. package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
  262. package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
  263. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
  264. package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
  265. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +59 -50
  266. package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
  267. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -0
  268. package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
  269. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
  270. package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
  271. package/packages/analyze/src/lib/files/analyzeChange.js +14 -4
  272. package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
  273. package/packages/analyze/src/lib/files/analyzeEntity.js +7 -6
  274. package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
  275. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +44 -10
  276. package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
  277. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
  278. package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
  279. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +314 -52
  280. package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
  281. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +97 -2
  282. package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
  283. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +88 -52
  284. package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
  285. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +26 -98
  286. package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
  287. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +141 -75
  288. package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
  289. package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
  290. package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
  291. package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
  292. package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
  293. package/packages/generate/index.js +3 -0
  294. package/packages/generate/index.js.map +1 -1
  295. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
  296. package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
  297. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
  298. package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
  299. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
  300. package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
  301. package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
  302. package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
  303. package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
  304. package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
  305. package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
  306. package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
  307. package/packages/process/index.js +3 -0
  308. package/packages/process/index.js.map +1 -0
  309. package/packages/process/src/GlobalProcessManager.js.map +1 -0
  310. package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
  311. package/packages/process/src/ProcessManager.js.map +1 -0
  312. package/packages/process/src/index.js.map +1 -0
  313. package/packages/process/src/managedExecAsync.js.map +1 -0
  314. package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
  315. package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
  316. package/analyzer-template/process/README.md +0 -507
  317. package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
  318. package/background/src/lib/process/ProcessManager.js.map +0 -1
  319. package/background/src/lib/process/index.js.map +0 -1
  320. package/background/src/lib/process/managedExecAsync.js.map +0 -1
  321. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
  322. package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
  323. package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js +0 -7
  324. package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js.map +0 -1
  325. package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
  326. package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
  327. package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-2mG6mjVb.js +0 -32
  328. package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
  329. package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
  330. package/codeyam-cli/src/webserver/build/client/assets/globals-C6vQASxy.css +0 -1
  331. package/codeyam-cli/src/webserver/build/client/assets/root-BxJUvKau.js +0 -56
  332. package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
  333. package/codeyam-cli/src/webserver/build/server/assets/server-build-BDlyhfrv.js +0 -175
  334. /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
  335. /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
  336. /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
  337. /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
  338. /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
  339. /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
  340. /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
@@ -63,27 +63,38 @@ export default function enrichArrayTypesFromChildSignatures(importedExports, dep
63
63
  if (mockedArrayPaths.length === 0)
64
64
  return;
65
65
  // Find all non-mocked child components and extract their signature fields
66
+ // We check both direct imports AND all schemas in dependencySchemas because
67
+ // transitive dependencies (e.g., SurveyCard imported by SurveysList imported by SurveysPage)
68
+ // may have signature schemas that we need to use for enrichment.
66
69
  const childSignatureFields = [];
67
- for (const importedExport of importedExports) {
68
- // Skip mocked dependencies - we want child components
69
- if (importedExport.isMocked || !importedExport.filePath)
70
- continue;
71
- const schema = dependencySchemas?.[importedExport.filePath]?.[importedExport.name]
72
- ?.signatureSchema;
73
- if (!schema)
74
- continue;
75
- // Extract signature[0].* fields (first prop of child component)
70
+ // Helper to extract prop fields from a signature schema
71
+ const extractPropFields = (schema) => {
76
72
  const propFields = {};
77
73
  for (const [path, type] of Object.entries(schema)) {
78
74
  // Match signature[0].propName.field patterns
79
75
  const match = path.match(/^signature\[0\]\.(\w+)\.(.+)$/);
80
76
  if (match) {
81
- const [, propName, fieldPath] = match;
77
+ const [, , fieldPath] = match;
82
78
  // Store as "fieldPath" without the prop name prefix
83
79
  // e.g., signature[0].survey.updatedAt -> updatedAt
84
80
  propFields[fieldPath] = type;
85
81
  }
86
82
  }
83
+ return propFields;
84
+ };
85
+ // First, check direct imports (non-mocked)
86
+ const processedSchemas = new Set();
87
+ for (const importedExport of importedExports) {
88
+ // Skip mocked dependencies - we want child components
89
+ if (importedExport.isMocked || !importedExport.filePath)
90
+ continue;
91
+ const schemaKey = `${importedExport.filePath}::${importedExport.name}`;
92
+ processedSchemas.add(schemaKey);
93
+ const schema = dependencySchemas?.[importedExport.filePath]?.[importedExport.name]
94
+ ?.signatureSchema;
95
+ if (!schema)
96
+ continue;
97
+ const propFields = extractPropFields(schema);
87
98
  if (Object.keys(propFields).length > 0) {
88
99
  childSignatureFields.push({
89
100
  filePath: importedExport.filePath,
@@ -92,6 +103,29 @@ export default function enrichArrayTypesFromChildSignatures(importedExports, dep
92
103
  });
93
104
  }
94
105
  }
106
+ // Also check all schemas in dependencySchemas for transitive child components
107
+ // that may not be in importedExports but have signature schemas with prop fields
108
+ if (dependencySchemas) {
109
+ for (const [filePath, entities] of Object.entries(dependencySchemas)) {
110
+ for (const [entityName, schemas] of Object.entries(entities)) {
111
+ const schemaKey = `${filePath}::${entityName}`;
112
+ // Skip already processed schemas
113
+ if (processedSchemas.has(schemaKey))
114
+ continue;
115
+ const signatureSchema = schemas?.signatureSchema;
116
+ if (!signatureSchema)
117
+ continue;
118
+ const propFields = extractPropFields(signatureSchema);
119
+ if (Object.keys(propFields).length > 0) {
120
+ childSignatureFields.push({
121
+ filePath,
122
+ entityName,
123
+ propFields,
124
+ });
125
+ }
126
+ }
127
+ }
128
+ }
95
129
  if (childSignatureFields.length === 0)
96
130
  return;
97
131
  // Enrich mocked dependency arrays with child signature fields
@@ -1 +1 @@
1
- {"version":3,"file":"enrichArrayTypesFromChildSignatures.js","sourceRoot":"","sources":["../../../../../../../../packages/analyze/src/lib/files/scenar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I,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"enrichArrayTypesFromChildSignatures.js","sourceRoot":"","sources":["../../../../../../../../packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,mCAAmC,CACzD,eAIG,EACH,iBAAqD;IAErD,uDAAuD;IACvD,MAAM,gBAAgB,GAIhB,EAAE,CAAC;IAET,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC7C,IAAI,CAAC,cAAc,CAAC,QAAQ,IAAI,CAAC,cAAc,CAAC,QAAQ;YAAE,SAAS;QAEnE,MAAM,MAAM,GACV,iBAAiB,EAAE,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC;YACjE,EAAE,iBAAiB,CAAC;QACxB,IAAI,CAAC,MAAM;YAAE,SAAS;QAEtB,oFAAoF;QACpF,+EAA+E;QAC/E,yCAAyC;QACzC,kDAAkD;QAClD,oGAAoG;QACpG,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,IAAI,KAAK,OAAO;gBAAE,SAAS;YAE/B,wEAAwE;YACxE,kEAAkE;YAClE,wFAAwF;YACxF,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5B,SAAS;YACX,CAAC;YAED,+EAA+E;YAC/E,kFAAkF;YAClF,IAAI,IAAI,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;gBAC9C,SAAS;YACX,CAAC;YAED,0FAA0F;YAC1F,0DAA0D;YAC1D,wEAAwE;YACxE,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YACxE,IAAI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AAE,CAAC;gBAC/C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACtB,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;gBAC1B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Enriches mocked dependency return value types using sourceEquivalencies.
3
+ *
4
+ * When a mocked dependency returns a value with an `unknown` type, and that value
5
+ * is passed to a child component, we can infer the type from the child's signature.
6
+ * The sourceEquivalencies track this data flow.
7
+ *
8
+ * Example:
9
+ * - trpc.quote.getQuoteQuestionAnswers.useQuery().functionCallReturnValue.data is `unknown`
10
+ * - sourceEquivalencies shows this data flows to QuoteHeaderExcel().signature[0].questionAnswers
11
+ * - QuoteHeaderExcel's signatureSchema says signature[0].questionAnswers is `array | undefined`
12
+ * - Therefore, data should be `array | undefined`
13
+ *
14
+ * Without this enrichment, fillInDirectSchemaGapsAndUnknowns will guess the type
15
+ * based on the property name, often incorrectly (e.g., 'data' becomes 'number'
16
+ * because pluralize.isPlural('data') returns true).
17
+ */
18
+ export default function enrichUnknownTypesFromSourceEquivalencies(isolatedDependencySchemas, mergedDependencySchemas, mockedImports) {
19
+ // Build a map of mocked dependency schemas for quick lookup
20
+ const mockedSchemas = new Map();
21
+ for (const imp of mockedImports) {
22
+ if (!imp.isMocked || !imp.filePath)
23
+ continue;
24
+ const schema = mergedDependencySchemas?.[imp.filePath]?.[imp.name]?.returnValueSchema;
25
+ if (schema) {
26
+ mockedSchemas.set(`${imp.filePath}:${imp.name}`, schema);
27
+ }
28
+ }
29
+ if (mockedSchemas.size === 0)
30
+ return;
31
+ // Iterate over all sourceEquivalencies in all dependency schemas
32
+ for (const filePath in isolatedDependencySchemas) {
33
+ for (const entityName in isolatedDependencySchemas[filePath]) {
34
+ const depSchema = isolatedDependencySchemas[filePath][entityName];
35
+ const sourceEquivs = depSchema.sourceEquivalencies;
36
+ if (!sourceEquivs)
37
+ continue;
38
+ // For each sourceEquivalency: key is destination, value contains sources
39
+ for (const [destinationPath, sources] of Object.entries(sourceEquivs)) {
40
+ // Parse the destination to get the child entity name and signature path
41
+ // e.g., "QuoteHeaderExcel().signature[0].questionAnswers" ->
42
+ // entityName: "QuoteHeaderExcel", sigPath: "signature[0].questionAnswers"
43
+ const destMatch = destinationPath.match(/^(\w+)\(\)\.(.+)$/);
44
+ if (!destMatch)
45
+ continue;
46
+ const [, destEntityName, destSigPath] = destMatch;
47
+ // Find the child's signatureSchema to get the destination type
48
+ let destType;
49
+ for (const depFilePath in mergedDependencySchemas) {
50
+ const childSchema = mergedDependencySchemas[depFilePath][destEntityName];
51
+ if (childSchema?.signatureSchema?.[destSigPath]) {
52
+ destType = childSchema.signatureSchema[destSigPath];
53
+ break;
54
+ }
55
+ }
56
+ if (!destType || destType === 'unknown')
57
+ continue;
58
+ // Now check each source to see if it's a mocked dependency with unknown type
59
+ for (const source of sources) {
60
+ const { scopeNodeName, schemaPath } = source;
61
+ // Find which mocked dependency this belongs to
62
+ for (const [key, schema] of mockedSchemas) {
63
+ const [mockedFilePath, mockedName] = key.split(':');
64
+ // Check if this source path is in the mocked dependency's schema
65
+ // The schemaPath contains the full path like:
66
+ // "trpc.quote.getQuoteQuestionAnswers.useQuery(...).functionCallReturnValue.data"
67
+ // We need to find it in the returnValueSchema
68
+ if (schema[schemaPath] === 'unknown') {
69
+ // Found an unknown type that flows to a known type!
70
+ schema[schemaPath] = destType;
71
+ }
72
+ // Also check without the functionCallReturnValue part
73
+ // (some schemas might have the transformed path)
74
+ const transformedPath = schemaPath.replace(/\.functionCallReturnValue/g, '');
75
+ if (transformedPath !== schemaPath &&
76
+ schema[transformedPath] === 'unknown') {
77
+ schema[transformedPath] = destType;
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ //# sourceMappingURL=enrichUnknownTypesFromSourceEquivalencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enrichUnknownTypesFromSourceEquivalencies.js","sourceRoot":"","sources":["../../../../../../../../packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,yCAAyC,CAC/D,yBAA6D,EAC7D,uBAA2D,EAC3D,aAAwE;IAExE,4DAA4D;IAC5D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkC,CAAC;IAChE,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ;YAAE,SAAS;QAC7C,MAAM,MAAM,GACV,uBAAuB,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,iBAAiB,CAAC;QACzE,IAAI,MAAM,EAAE,CAAC;YACX,aAAa,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;IAED,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAErC,iEAAiE;IACjE,KAAK,MAAM,QAAQ,IAAI,yBAAyB,EAAE,CAAC;QACjD,KAAK,MAAM,UAAU,IAAI,yBAAyB,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D,MAAM,SAAS,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC;YAClE,MAAM,YAAY,GAAG,SAAS,CAAC,mBAAmB,CAAC;YACnD,IAAI,CAAC,YAAY;gBAAE,SAAS;YAE5B,yEAAyE;YACzE,KAAK,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtE,wEAAwE;gBACxE,6DAA6D;gBAC7D,4EAA4E;gBAC5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U;4BAC9B,MAAM,CAAC,eAAe,CAAC,KAAK,SAAS,EACrC,CAAC;4BACD,MAAM,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC;wBACrC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,5 +1,5 @@
1
1
  // import { writeFile } from 'fs/promises';
2
- import { convertDotNotation, fillInDirectSchemaGapsAndUnknowns, joinParenthesesAndArrays, splitOutsideParenthesesAndArrays, } from "../../../../../../packages/ai/index.js";
2
+ import { convertDotNotation, fillInDirectSchemaGapsAndUnknowns, joinParenthesesAndArrays, mergeJsonTypeDefinitions, splitOutsideParenthesesAndArrays, } from "../../../../../../packages/ai/index.js";
3
3
  /**
4
4
  * Strips generic type parameters from a function name.
5
5
  * e.g., "useFetcher<BranchEntityDiffResult>" -> "useFetcher"
@@ -7,6 +7,61 @@ import { convertDotNotation, fillInDirectSchemaGapsAndUnknowns, joinParenthesesA
7
7
  function cleanFunctionName(name) {
8
8
  return name?.split('<')[0];
9
9
  }
10
+ /**
11
+ * Escapes special regex characters in a string.
12
+ */
13
+ function escapeRegExp(str) {
14
+ return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
15
+ }
16
+ /**
17
+ * Counts only DIRECT function calls, excluding method chains on return values.
18
+ *
19
+ * When a hook returns an object with methods that are later called, the analysis
20
+ * tracks those as call signatures like 'useAuth().functionCallReturnValue.signOut()'.
21
+ * These are NOT separate calls to useAuth - they're method invocations on the return value.
22
+ *
23
+ * This function filters out such method chains to get the true count of direct calls.
24
+ *
25
+ * @example
26
+ * // One direct call, one method on return value
27
+ * countDirectCalls(['useAuth()', 'useAuth().functionCallReturnValue.signOut()']) // => 1
28
+ *
29
+ * // Two direct calls
30
+ * countDirectCalls(['useFetcher()', 'useFetcher()']) // => 2
31
+ */
32
+ function countDirectCalls(calls) {
33
+ return calls.filter((sig) => !sig.includes('.functionCallReturnValue.'))
34
+ .length;
35
+ }
36
+ /**
37
+ * Checks if all direct calls (non-method-chain calls) are identical.
38
+ * This happens when destructuring a hook call:
39
+ * const { authLoading, signOut } = useAuth();
40
+ * produces calls: ['useAuth()', 'useAuth()'] (same signature repeated)
41
+ *
42
+ * In this case, we should use the full unqualified schema since there's
43
+ * really only ONE function call, not multiple different calls.
44
+ *
45
+ * @example
46
+ * // Same call repeated (from destructuring)
47
+ * allDirectCallsIdentical(['useAuth()', 'useAuth()']) // => true
48
+ *
49
+ * // Different calls
50
+ * allDirectCallsIdentical(['useFetcher<User>()', 'useFetcher<Report>()']) // => false
51
+ *
52
+ * // Single call
53
+ * allDirectCallsIdentical(['useAuth()']) // => true
54
+ *
55
+ * // With method chain (method chain is ignored)
56
+ * allDirectCallsIdentical(['useAuth()', 'useAuth().functionCallReturnValue.signOut()']) // => true
57
+ */
58
+ function allDirectCallsIdentical(calls) {
59
+ const directCalls = calls.filter((sig) => !sig.includes('.functionCallReturnValue.'));
60
+ if (directCalls.length === 0)
61
+ return true;
62
+ const firstCall = directCalls[0];
63
+ return directCalls.every((call) => call === firstCall);
64
+ }
10
65
  /**
11
66
  * Preprocesses the schema to:
12
67
  * 1. Filter out all signature paths
@@ -66,15 +121,19 @@ function processCall(importedExport, dependencySchemas, callIndex, variableNameO
66
121
  const callName = importedExport.calls?.[callIndex] ?? importedExport.name;
67
122
  // Determine if we should use variable-qualified schema or base schema.
68
123
  // Use variable-qualified schema when:
69
- // 1. variableNameOccurrence is defined (we're processing multiple calls with matching variable names), OR
70
- // 2. calls.length equals callVariableNames.length (single call with single variable name)
124
+ // 1. variableNameOccurrence is defined (we're processing multiple DISTINCT calls), OR
125
+ // 2. Single call with single variable name (directCallCount === 1 && varNamesLength === 1)
71
126
  // Use base schema when:
72
- // - calls.length !== callVariableNames.length (rest spread or method chain case)
127
+ // - Multiple calls that are all identical (destructuring case: const { a, b } = useHook())
128
+ // - directCallCount !== varNamesLength (rest spread or method chain case)
73
129
  // This is important for rest spread destructuring like: const { x, y, ...data } = useLoaderData()
74
130
  // where data.queueState.jobs should come from the base schema, not from a variable-qualified schema.
75
- const callsLength = importedExport.calls?.length ?? 0;
131
+ // Also important: method chains like useAuth().functionCallReturnValue.signOut() should NOT count
132
+ // as separate calls - only direct hook calls count.
133
+ const directCallCount = countDirectCalls(importedExport.calls ?? []);
76
134
  const varNamesLength = importedExport.callVariableNames?.length ?? 0;
77
- const shouldUseVariableQualifiedSchema = variableNameOccurrence !== undefined || callsLength === varNamesLength;
135
+ const shouldUseVariableQualifiedSchema = variableNameOccurrence !== undefined ||
136
+ (directCallCount === 1 && varNamesLength === 1);
78
137
  const variableName = shouldUseVariableQualifiedSchema
79
138
  ? importedExport.callVariableNames?.[callIndex]
80
139
  : undefined;
@@ -86,12 +145,26 @@ function processCall(importedExport, dependencySchemas, callIndex, variableNameO
86
145
  variableNameOccurrence > 0
87
146
  ? `${variableName}[${variableNameOccurrence}]`
88
147
  : variableName;
89
- const schemaLookupKey = indexedVariableName
90
- ? `${importedExport.name}::${indexedVariableName}`
91
- : importedExport.name;
92
- let rawSchema = dependencySchemas?.[importedExport.filePath]?.[schemaLookupKey]
93
- ?.returnValueSchema ?? {};
94
- // If no schema found with indexed key, try without the index as fallback
148
+ // Schema lookup order (most specific to least specific):
149
+ // 1. Call signature (e.g., 'useLoaderData<typeof loader>()')
150
+ // 2. Variable-qualified key with index (e.g., 'useFetcher::fetcher[1]')
151
+ // 3. Variable-qualified key without index (e.g., 'useFetcher::fetcher')
152
+ // 4. Base name (e.g., 'useLoaderData')
153
+ let rawSchema = {};
154
+ // 1. Try call signature first (most specific - new format)
155
+ if (callName !== importedExport.name) {
156
+ rawSchema =
157
+ dependencySchemas?.[importedExport.filePath]?.[callName]
158
+ ?.returnValueSchema ?? {};
159
+ }
160
+ // 2. Try variable-qualified key with index
161
+ if (Object.keys(rawSchema).length === 0 && indexedVariableName) {
162
+ const indexedKey = `${importedExport.name}::${indexedVariableName}`;
163
+ rawSchema =
164
+ dependencySchemas?.[importedExport.filePath]?.[indexedKey]
165
+ ?.returnValueSchema ?? {};
166
+ }
167
+ // 3. Try variable-qualified key without index (fallback for indexed lookup)
95
168
  if (Object.keys(rawSchema).length === 0 &&
96
169
  variableNameOccurrence !== undefined &&
97
170
  variableNameOccurrence > 0 &&
@@ -101,13 +174,44 @@ function processCall(importedExport, dependencySchemas, callIndex, variableNameO
101
174
  dependencySchemas?.[importedExport.filePath]?.[nonIndexedKey]
102
175
  ?.returnValueSchema ?? {};
103
176
  }
104
- // If no schema found with variable-qualified key, fall back to base name
105
- const fallbackSchema = Object.keys(rawSchema).length === 0
106
- ? (dependencySchemas?.[importedExport.filePath]?.[importedExport.name]
107
- ?.returnValueSchema ?? {})
108
- : rawSchema;
177
+ // 4. Get base name schema and merge with call-specific schema
178
+ // The base schema often has more complete array element details that the
179
+ // call-specific schema might be missing. Instead of using as fallback only
180
+ // when empty, MERGE both schemas so we get the most complete picture.
181
+ //
182
+ // HOWEVER: For type-parameterized calls where the base schema contains paths
183
+ // from MULTIPLE DIFFERENT type parameters, DON'T merge to avoid contamination.
184
+ // The call-specific schema (rawSchema) is already isolated and complete.
185
+ const baseSchema = dependencySchemas?.[importedExport.filePath]?.[importedExport.name]
186
+ ?.returnValueSchema ?? {};
187
+ // Check if this is a type-parameterized call with a call-specific schema
188
+ const hasTypeParams = callName.includes('<') && callName.includes('>');
189
+ const hasCallSpecificSchema = Object.keys(rawSchema).length > 0;
190
+ // Check if the base schema has multiple DIFFERENT type parameter variants
191
+ // If so, merging would bring in wrong fields from other variants
192
+ let baseHasMultipleTypeParamVariants = false;
193
+ if (hasTypeParams && hasCallSpecificSchema) {
194
+ const baseFunctionName = cleanFunctionName(callName.split('(')[0]);
195
+ const typeParamVariantsInBase = new Set();
196
+ for (const path of Object.keys(baseSchema)) {
197
+ // Look for paths like "useFetcher<TypeA>(...)" or "useFetcher<TypeB>(...)"
198
+ const match = path.match(new RegExp(`^${escapeRegExp(baseFunctionName)}<([^>]+)>\\(`));
199
+ if (match) {
200
+ typeParamVariantsInBase.add(match[1]);
201
+ }
202
+ }
203
+ baseHasMultipleTypeParamVariants = typeParamVariantsInBase.size > 1;
204
+ }
205
+ // For type-parameterized calls where the base schema has MULTIPLE different type
206
+ // parameter variants, use ONLY the call-specific schema to avoid contamination.
207
+ // Otherwise, merge with base schema for complete coverage (e.g., array element details).
208
+ const mergedSchema = hasCallSpecificSchema && hasTypeParams && baseHasMultipleTypeParamVariants
209
+ ? rawSchema // Use ONLY the call-specific schema when base has mixed type params
210
+ : Object.keys(rawSchema).length === 0
211
+ ? baseSchema
212
+ : { ...baseSchema, ...rawSchema };
109
213
  // Preprocess to filter signatures and extract functionCallReturnValue
110
- let preprocessedSchema = preprocessSchemaForMocks(fallbackSchema);
214
+ let preprocessedSchema = preprocessSchemaForMocks(mergedSchema);
111
215
  const functionNames = [];
112
216
  const isFunctionNameWithoutFunction = (path, functionName) => {
113
217
  // Check if path starts with functionName but isn't a function call
@@ -212,31 +316,11 @@ function processCall(importedExport, dependencySchemas, callIndex, variableNameO
212
316
  const schemaKey = variableName
213
317
  ? `${baseSchemaKey}::${variableName}`
214
318
  : baseSchemaKey;
215
- // Build output key
216
- // When entityName is provided, use canonical key format for consistency across scenarios
217
- // Otherwise, use the variable-based format for backward compatibility
218
- let outputKey;
219
- if (options?.entityName) {
220
- // Canonical key format: EntityName::hookName::index
221
- // This ensures consistent keys regardless of variable names chosen during analysis
222
- const hookName = cleanFunctionName(importedExport.name);
223
- outputKey = `${options.entityName}::${hookName}::${hookCallIndex}`;
224
- }
225
- else if (variableName) {
226
- // Legacy format: "variableName <- functionName"
227
- // This reads naturally as "variableName receives from functionName"
228
- // When a variable name is reused (variableNameOccurrence > 0), disambiguate with index
229
- const disambiguator = variableNameOccurrence !== undefined && variableNameOccurrence > 0
230
- ? `[${variableNameOccurrence}]`
231
- : '';
232
- outputKey = `${variableName}${disambiguator} <- ${importedExport.name}`;
233
- }
234
- else if (isObjectStyle) {
235
- outputKey = importedExport.name;
236
- }
237
- else {
238
- outputKey = callName;
239
- }
319
+ // Build output key - use the ORIGINAL CALL SIGNATURE from the code
320
+ // This makes it clear to the LLM exactly which call needs which data.
321
+ // Example: useFetcher<{ data: UserData }>() vs useFetcher<{ data: ReportData }>()
322
+ // Example: db.select(usersQuery) vs db.select(postsQuery)
323
+ const outputKey = callName;
240
324
  // Try to find return value - check with variable qualifier first, then without
241
325
  let returnValue = schema[schemaKey];
242
326
  if (!returnValue && variableName) {
@@ -249,11 +333,51 @@ function processCall(importedExport, dependencySchemas, callIndex, variableNameO
249
333
  if (!returnValue) {
250
334
  returnValue = schema['functionCallReturnValue'];
251
335
  }
336
+ // Handle method-chain style calls (e.g., createClient().from("workouts").select("*") or db.select(query))
337
+ // After convertDotNotation, the schema is nested: { "createClient()": { "from(...)": { ... } } }
338
+ // We need to navigate the nested structure using the call signature parts.
339
+ // For object-style dependencies (isObjectStyle=true), the baseSchemaKey is just the object name (e.g., "db"),
340
+ // so returnValue might be the parent object, not the actual return value of the method chain.
341
+ // We should always try method-chain navigation for calls with dots and parens.
342
+ if (callName.includes('.') && callName.includes('(')) {
343
+ const callParts = splitOutsideParenthesesAndArrays(callName);
344
+ let current = schema;
345
+ for (const part of callParts) {
346
+ if (current &&
347
+ typeof current === 'object' &&
348
+ !Array.isArray(current) &&
349
+ part in current) {
350
+ current = current[part];
351
+ }
352
+ else {
353
+ current = undefined;
354
+ break;
355
+ }
356
+ }
357
+ // Use method-chain result if found, otherwise keep previous returnValue
358
+ if (current !== undefined) {
359
+ returnValue = current;
360
+ }
361
+ }
252
362
  if (!returnValue) {
253
363
  return null;
254
364
  }
255
365
  return { key: outputKey, value: returnValue };
256
366
  }
367
+ /**
368
+ * Adds a result to the accumulator, merging schemas if the key already exists.
369
+ * This handles the case where the same call signature appears multiple times
370
+ * (e.g., two calls to useFetcher() with the same generic type).
371
+ */
372
+ function addResultToAccumulator(acc, key, value) {
373
+ if (acc[key]) {
374
+ // Key already exists - merge the schemas
375
+ acc[key] = mergeJsonTypeDefinitions(acc[key], value);
376
+ }
377
+ else {
378
+ acc[key] = value;
379
+ }
380
+ }
257
381
  export default function gatherDataForMocks(importedExports, dependencySchemas, options) {
258
382
  // Track the global index for each hook name across all imports
259
383
  // This enables canonical keys like EntityName::useLoaderData::0, EntityName::useFetcher::0, etc.
@@ -263,12 +387,94 @@ export default function gatherDataForMocks(importedExports, dependencySchemas, o
263
387
  return acc;
264
388
  // Get the clean hook name for indexing
265
389
  const hookName = cleanFunctionName(importedExport.name);
266
- // Check if we have multiple calls with variable names
267
- const hasMultipleCalls = importedExport.calls &&
268
- importedExport.calls.length > 1 &&
390
+ // Check if we have multiple DISTINCT direct calls with variable names.
391
+ // Important: Only count direct calls to the function, not method chains on its return value.
392
+ // For example, ['useAuth()', 'useAuth().functionCallReturnValue.signOut()'] has only 1 direct call.
393
+ //
394
+ // ALSO: If all direct calls are IDENTICAL (same signature repeated), this is from
395
+ // destructuring like `const { a, b } = useHook()` and we should use the FULL unqualified
396
+ // schema, not iterate through partial variable-qualified schemas.
397
+ const directCallCount = countDirectCalls(importedExport.calls ?? []);
398
+ const hasMultipleDistinctCalls = directCallCount > 1 &&
269
399
  importedExport.callVariableNames &&
270
- importedExport.callVariableNames.length === importedExport.calls.length;
271
- if (hasMultipleCalls) {
400
+ importedExport.callVariableNames.length === directCallCount &&
401
+ !allDirectCallsIdentical(importedExport.calls ?? []);
402
+ // Check for multiple distinct method-chain calls WITHOUT callVariableNames.
403
+ // This pattern is common with tRPC, Supabase, etc. where a single import
404
+ // (e.g., `trpc`) is used with multiple different method chains (e.g.,
405
+ // `trpc.useUtils()`, `trpc.quote.getQuotesByOrg.useQuery()`).
406
+ // These should each get their own entry in dataForMocks.
407
+ //
408
+ // IMPORTANT: This is DIFFERENT from the rest spread pattern where a function
409
+ // like useLoaderData is called directly, and other calls are method chains
410
+ // on its return value (e.g., `useLoaderData<typeof loader>()` with
411
+ // `useLoaderData<typeof loader>().uncommittedEntitiesList.filter(...)`).
412
+ // In that case, all the additional calls start with the base function call.
413
+ const directCalls = (importedExport.calls ?? []).filter((sig) => !sig.includes('.functionCallReturnValue.'));
414
+ const uniqueDirectCalls = [...new Set(directCalls)];
415
+ // Check if any call is a direct invocation of the import (e.g., `useLoaderData<typeof loader>()`)
416
+ // as opposed to all being property accesses (e.g., `trpc.useUtils()`, `trpc.quote.xxx()`).
417
+ // If there's a direct function call, the other calls are likely method chains on its result.
418
+ const baseName = importedExport.name;
419
+ const hasDirectFunctionCall = directCalls.some((sig) => {
420
+ // Pattern: baseName() or baseName<...>()
421
+ // This matches "useLoaderData()", "useLoaderData<typeof loader>()", etc.
422
+ // but NOT "trpc.useUtils()" which has a dot before the parens
423
+ const baseCallPattern = new RegExp(`^${baseName}(<[^>]*>)?\\(`);
424
+ return baseCallPattern.test(sig);
425
+ });
426
+ const hasMultipleDistinctMethodChains = !hasMultipleDistinctCalls &&
427
+ uniqueDirectCalls.length > 1 &&
428
+ !allDirectCallsIdentical(directCalls) &&
429
+ !hasDirectFunctionCall; // Exclude rest spread patterns
430
+ if (hasMultipleDistinctMethodChains) {
431
+ // For multiple method-chain calls on the same import, create a NESTED structure
432
+ // under the base import name. This allows constructMockCode to generate a
433
+ // combined mock object with all method chains.
434
+ //
435
+ // Example: For calls ['trpc.useUtils()', 'trpc.quote.getQuotesByOrg.useQuery()'],
436
+ // create: { "trpc": { "useUtils()": {...}, "quote": { "getQuotesByOrg": { "useQuery()": {...} } } } }
437
+ const nestedResult = {};
438
+ for (let i = 0; i < uniqueDirectCalls.length; i++) {
439
+ // Find the index of this call in the original calls array
440
+ const callIndex = (importedExport.calls ?? []).indexOf(uniqueDirectCalls[i]);
441
+ if (callIndex === -1)
442
+ continue;
443
+ const hookCallIndex = hookCallIndices[hookName] ?? 0;
444
+ hookCallIndices[hookName] = hookCallIndex + 1;
445
+ const processResult = processCall(importedExport, dependencySchemas, callIndex, undefined, options, hookCallIndex);
446
+ if (processResult) {
447
+ // The key is like "trpc.useUtils()" or "trpc.quote.getQuotesByOrg.useQuery()"
448
+ // We need to nest the value at the path AFTER the base name
449
+ const callSignature = processResult.key;
450
+ // Split the call signature into path parts, handling parens
451
+ // e.g., "trpc.useUtils()" -> ["trpc", "useUtils()"]
452
+ // e.g., "trpc.quote.getQuotesByOrg.useQuery()" -> ["trpc", "quote", "getQuotesByOrg", "useQuery()"]
453
+ const pathParts = splitOutsideParenthesesAndArrays(callSignature);
454
+ // Skip the base name (first part) and nest the value at the remaining path
455
+ if (pathParts.length > 1 && pathParts[0] === baseName) {
456
+ const nestedPath = pathParts.slice(1);
457
+ // Set the value at the nested path, merging with existing structure
458
+ let current = nestedResult;
459
+ for (let j = 0; j < nestedPath.length - 1; j++) {
460
+ const part = nestedPath[j];
461
+ if (!(part in current)) {
462
+ current[part] = {};
463
+ }
464
+ current = current[part];
465
+ }
466
+ // Set the leaf value
467
+ const leafKey = nestedPath[nestedPath.length - 1];
468
+ current[leafKey] = processResult.value;
469
+ }
470
+ }
471
+ }
472
+ // Add the nested result under the base import name
473
+ if (Object.keys(nestedResult).length > 0) {
474
+ addResultToAccumulator(acc, baseName, nestedResult);
475
+ }
476
+ }
477
+ else if (hasMultipleDistinctCalls) {
272
478
  // Track how many times each variable name has been seen
273
479
  // to disambiguate keys when the same variable is reused
274
480
  const variableNameCounts = {};
@@ -283,18 +489,74 @@ export default function gatherDataForMocks(importedExports, dependencySchemas, o
283
489
  hookCallIndices[hookName] = hookCallIndex + 1;
284
490
  const processResult = processCall(importedExport, dependencySchemas, i, occurrence, options, hookCallIndex);
285
491
  if (processResult) {
286
- acc[processResult.key] = processResult.value;
492
+ addResultToAccumulator(acc, processResult.key, processResult.value);
287
493
  }
288
494
  }
289
495
  }
290
496
  else {
291
- // Original behavior for single calls or calls without variable names
497
+ // Single calls, or multiple identical calls (from destructuring)
292
498
  // Get the current hook call index and increment for next call
293
499
  const hookCallIndex = hookCallIndices[hookName] ?? 0;
294
500
  hookCallIndices[hookName] = hookCallIndex + 1;
501
+ // First, try to get result from unqualified schema
295
502
  const processResult = processCall(importedExport, dependencySchemas, 0, undefined, options, hookCallIndex);
296
- if (processResult) {
297
- acc[processResult.key] = processResult.value;
503
+ // Check if we got a meaningful result (not empty object or null)
504
+ // Arrays are always meaningful (even empty ones represent valid data structure)
505
+ const hasUnqualifiedResult = processResult &&
506
+ processResult.value !== null &&
507
+ (typeof processResult.value !== 'object' ||
508
+ Array.isArray(processResult.value) ||
509
+ Object.keys(processResult.value).length > 0);
510
+ // Check if we have multiple callVariableNames that are DIFFERENT
511
+ // (e.g., from parent + child components using the same hook differently)
512
+ // In this case, we should also merge in variable-qualified schemas
513
+ // to capture all destructured properties from both parent and child.
514
+ const uniqueCallVarNames = new Set(importedExport.callVariableNames ?? []);
515
+ const hasDifferentVarNames = importedExport.callVariableNames &&
516
+ importedExport.callVariableNames.length > 1 &&
517
+ uniqueCallVarNames.size > 1 &&
518
+ // Only merge variable-qualified schemas when calls are all identical
519
+ // (e.g., useFlags() repeated). Don't do this for method chains
520
+ // or rest spread cases where calls.length !== callVariableNames.length
521
+ allDirectCallsIdentical(importedExport.calls ?? []);
522
+ if (hasUnqualifiedResult) {
523
+ let finalValue = processResult.value;
524
+ // If we have different variable names (e.g., from parent and child components),
525
+ // also merge in variable-qualified schemas to ensure we capture all properties.
526
+ // This handles the case where parent uses useFlags().enableNewAdminDashboard
527
+ // and child uses useFlags().flagShowReferenceIdOnQuoteTable.
528
+ if (hasDifferentVarNames) {
529
+ let mergedValue = processResult.value;
530
+ for (let i = 0; i < importedExport.callVariableNames.length; i++) {
531
+ const varQualifiedResult = processCall(importedExport, dependencySchemas, i, 0, // Use 0 to trigger variable-qualified lookup
532
+ options, hookCallIndex);
533
+ if (varQualifiedResult && varQualifiedResult.value) {
534
+ mergedValue = mergeJsonTypeDefinitions(mergedValue, varQualifiedResult.value);
535
+ }
536
+ }
537
+ finalValue = mergedValue;
538
+ }
539
+ addResultToAccumulator(acc, processResult.key, finalValue);
540
+ }
541
+ else if (directCallCount > 1 &&
542
+ allDirectCallsIdentical(importedExport.calls ?? []) &&
543
+ importedExport.callVariableNames &&
544
+ importedExport.callVariableNames.length > 0) {
545
+ // No unqualified schema exists, but we have multiple identical calls with variable names
546
+ // Merge all the variable-qualified schemas together
547
+ const callSignature = importedExport.calls?.[0] ?? `${importedExport.name}()`;
548
+ let mergedValue = {};
549
+ for (let i = 0; i < importedExport.callVariableNames.length; i++) {
550
+ const varQualifiedResult = processCall(importedExport, dependencySchemas, i, 0, // Use 0 to trigger variable-qualified lookup
551
+ options, hookCallIndex);
552
+ if (varQualifiedResult && varQualifiedResult.value) {
553
+ // Deep merge the value into the accumulated result
554
+ mergedValue = mergeJsonTypeDefinitions(mergedValue, varQualifiedResult.value);
555
+ }
556
+ }
557
+ if (Object.keys(mergedValue).length > 0) {
558
+ addResultToAccumulator(acc, callSignature, mergedValue);
559
+ }
298
560
  }
299
561
  }
300
562
  return acc;