@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.
- package/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +7 -4
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +14 -1
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +120 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +2 -1
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +91 -35
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +110 -74
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +11 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +24 -17
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +214 -39
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +54 -1
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +72 -6
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +12 -5
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +39 -23
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +14 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/asts/nodes/isAsyncFunction.ts +67 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +73 -69
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +22 -6
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +9 -5
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +49 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +399 -52
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +128 -2
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +114 -70
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +34 -129
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +155 -79
- package/analyzer-template/packages/aws/codebuild/index.ts +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts +11 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js +29 -18
- package/analyzer-template/packages/aws/dist/src/lib/codebuild/waitForBuild.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts +8 -18
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/analyzer-template/packages/aws/dist/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.d.ts.map +1 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js +8 -1
- package/analyzer-template/packages/aws/dist/src/lib/s3/uploadFileToS3.js.map +1 -1
- package/analyzer-template/packages/aws/package.json +1 -1
- package/analyzer-template/packages/aws/src/lib/codebuild/waitForBuild.ts +43 -19
- package/analyzer-template/packages/aws/src/lib/ecs/ecsDefineContainer.ts +3 -3
- package/analyzer-template/packages/aws/src/lib/ecs/ecsTaskFactory.ts +17 -69
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/generate/index.ts +3 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.ts +17 -1
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.ts +193 -0
- package/analyzer-template/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.ts +73 -0
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/entitiesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.d.ts +3 -0
- package/analyzer-template/packages/github/dist/generate/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/index.js +3 -0
- package/analyzer-template/packages/github/dist/generate/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts +9 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts +20 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts +8 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/analyzer-template/packages/github/dist/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js +10 -0
- package/analyzer-template/packages/github/dist/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js +3 -0
- package/analyzer-template/packages/github/dist/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +6 -0
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/src/lib/loadOrCreateCommit.ts +14 -0
- package/analyzer-template/packages/github/src/lib/syncPrimaryBranch.ts +2 -0
- package/analyzer-template/packages/process/index.ts +2 -0
- package/analyzer-template/packages/process/package.json +12 -0
- package/analyzer-template/packages/process/tsconfig.json +8 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +6 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Entity.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +6 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/playwright/capture.ts +37 -18
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/constructMockCode.ts +781 -140
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +3 -6
- package/analyzer-template/project/orchestrateCapture.ts +10 -3
- package/analyzer-template/project/reconcileMockDataKeys.ts +28 -100
- package/analyzer-template/project/runAnalysis.ts +5 -0
- package/analyzer-template/project/serverOnlyModules.ts +127 -2
- package/analyzer-template/project/start.ts +5 -3
- package/analyzer-template/project/startScenarioCapture.ts +6 -0
- package/analyzer-template/project/writeMockDataTsx.ts +50 -22
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +162 -100
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +11 -35
- package/analyzer-template/scripts/comboWorkerLoop.cjs +1 -0
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/background/src/lib/local/createLocalAnalyzer.js +1 -29
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/local/execAsync.js +1 -1
- package/background/src/lib/local/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/common/execAsync.js +1 -1
- package/background/src/lib/virtualized/common/execAsync.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +718 -127
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +3 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +7 -4
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +25 -61
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +4 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +106 -3
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -1
- package/background/src/lib/virtualized/project/start.js +5 -3
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +7 -0
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +52 -23
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js +15 -0
- package/background/src/lib/virtualized/project/writeScenarioClientWrapper.js.map +1 -0
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +136 -83
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioFiles.js +19 -0
- package/background/src/lib/virtualized/project/writeScenarioFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +11 -34
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/codeyam-cli/src/cli.js +5 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +1 -1
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +177 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/status.js +23 -1
- package/codeyam-cli/src/commands/status.js.map +1 -1
- package/codeyam-cli/src/commands/test-startup.js +1 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/wipe.js +108 -0
- package/codeyam-cli/src/commands/wipe.js.map +1 -0
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/git.js +79 -0
- package/codeyam-cli/src/utils/git.js.map +1 -0
- package/codeyam-cli/src/utils/queue/job.js +104 -0
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/wipe.js +128 -0
- package/codeyam-cli/src/utils/wipe.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +66 -17
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-wXL1Z2Aq.js → EntityItem-Cmysw5OP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CzGX-miz.js → EntityTypeBadge-DLqD3qNt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-CXFKsCOD.js → EntityTypeIcon-CAneekK2.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-D-9pXIaY.js → InteractivePreview-Cu16OUmx.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CBQPrpT0.js → LibraryFunctionPreview-CVtiBnY5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-D1CdlbrV.js → LoadingDots-B0GLXMsr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-wDPcZNKx.js → LogViewer-xgeCVgSM.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-4lcOlid-.js → ReportIssueModal-DcAUIpD_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-BfmDgXxG.js → SafeScreenshot-DuDvi0jm.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BMKg0SAF.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-6J7zDUD5.js → TruncatedFilePath-DyFZkK0l.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-DSmTpjmK.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-BF_aK4y6.js +32 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-BYimnrHg.js → chevron-down-Cx24_aWc.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-EPOLDU6W-CXRTFQ3F.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-CaVsIRxt.js → circle-check-BOARzkeR.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-CgUsG7ib.js → createLucideIcon-BdhJEx6B.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-DW_hdGUc.js → dev.empty-RJCf3Tvw.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-zUEpfPsu.js → entity._sha._-D0-YwkBh.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-EylcgScH.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D_3ero5o.js → entity._sha_.create-scenario-DMe7kvgo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CfLCUi9S.js → entity._sha_.edit._scenarioId-C1H_a_Y3.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-DKJyZfAY.js → entry.client-CS2cb_eZ.js} +6 -6
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DAtOlaWE.js → fileTableUtils-DMJ7zii9.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-ClR0d32A.js → files-BW7Cyeyi.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-D62Lxxmv.js → git-CZu4fif0.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/globals-wHVy_II5.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-CzNNiTkw.js → index-B1h680n5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-BosqDOlH.js → index-lzqtyFU8.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-CNp9QFCX.js → loader-circle-B7B9V-bu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{manifest-09d684be.js → manifest-2d191949.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-FHgpM6gc.js +56 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-DDGjYAMJ.js → search-CxXUmBSd.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{settings-DgTyB-Wg.js → settings-6D8k8Jp5.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CDJZnWhN.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CBc5dE1s.js → triangle-alert-B6LgvRJg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-BMIGFP-m.js → useCustomSizes-Dv18q8LD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useInteractiveMode-Dk_FQqWJ.js → useInteractiveMode-0ToGk4K3.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-BqPPNjAl.js → useLastLogLine-aSv48UbS.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DsJbgMY9.js → useReportContext-1BX144Eg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-DWHcCcl1.js → useToast-mBRpZPiu.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-CV6i1S1A.js → index-pU0o5t1o.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-YzfkRwdn.js +178 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/codeyam-setup-skill.md +138 -3
- package/codeyam-cli/templates/debug-codeyam.md +7 -2
- package/package.json +5 -5
- package/packages/ai/src/lib/astScopes/processExpression.js +13 -1
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/checkAllAttributes.js +24 -9
- package/packages/ai/src/lib/checkAllAttributes.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +94 -18
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +2 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +51 -23
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +70 -54
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +11 -0
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js +86 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.js.map +1 -0
- package/packages/ai/src/lib/deepEqual.js +32 -0
- package/packages/ai/src/lib/deepEqual.js.map +1 -0
- package/packages/ai/src/lib/findMatchingAttribute.js +20 -16
- package/packages/ai/src/lib/findMatchingAttribute.js.map +1 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +168 -41
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +42 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +59 -3
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +6 -6
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +32 -23
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +20 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +15 -0
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/index.js +1 -0
- package/packages/analyze/src/lib/asts/nodes/index.js.map +1 -1
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js +52 -0
- package/packages/analyze/src/lib/asts/nodes/isAsyncFunction.js.map +1 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +59 -50
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +6 -0
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js +2 -0
- package/packages/analyze/src/lib/files/analyze/findOrCreateEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +14 -4
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +7 -6
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +44 -10
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js +85 -0
- package/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +314 -52
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +97 -2
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +88 -52
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +26 -98
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +141 -75
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js +2 -2
- package/packages/aws/src/lib/ecs/ecsDefineContainer.js.map +1 -1
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js +17 -61
- package/packages/aws/src/lib/ecs/ecsTaskFactory.js.map +1 -1
- package/packages/generate/index.js +3 -0
- package/packages/generate/index.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js +16 -1
- package/packages/generate/src/lib/componentScenarioPage/componentScenarioPageNext.js.map +1 -1
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js +189 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioClientWrapper.js.map +1 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js +53 -0
- package/packages/generate/src/lib/componentScenarioPage/generateScenarioServerComponent.js.map +1 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js +89 -0
- package/packages/generate/src/lib/scenarioComponentForServer.js.map +1 -0
- package/packages/github/src/lib/loadOrCreateCommit.js +10 -0
- package/packages/github/src/lib/loadOrCreateCommit.js.map +1 -1
- package/packages/github/src/lib/syncPrimaryBranch.js +3 -0
- package/packages/github/src/lib/syncPrimaryBranch.js.map +1 -1
- package/packages/process/index.js +3 -0
- package/packages/process/index.js.map +1 -0
- package/packages/process/src/GlobalProcessManager.js.map +1 -0
- package/{background/src/lib/process → packages/process/src}/ProcessManager.js +1 -1
- package/packages/process/src/ProcessManager.js.map +1 -0
- package/packages/process/src/index.js.map +1 -0
- package/packages/process/src/managedExecAsync.js.map +1 -0
- package/analyzer-template/process/INTEGRATION_COMPLETE.md +0 -333
- package/analyzer-template/process/INTEGRATION_EXAMPLE.md +0 -525
- package/analyzer-template/process/README.md +0 -507
- package/background/src/lib/process/GlobalProcessManager.js.map +0 -1
- package/background/src/lib/process/ProcessManager.js.map +0 -1
- package/background/src/lib/process/index.js.map +0 -1
- package/background/src/lib/process/managedExecAsync.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js +0 -238
- package/codeyam-cli/scripts/fixtures/cal.com/universal-mocks/packages/prisma/index.js.map +0 -1
- package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js +0 -7
- package/codeyam-cli/scripts/fixtures/formbricks/universal-mocks/apps/web/lib/instance/service.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CUxUNEEC.js +0 -15
- package/codeyam-cli/src/webserver/build/client/assets/_index-DHImXdXq.js +0 -11
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-2mG6mjVb.js +0 -32
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JMJ3UQ3L-BambyYE_.js +0 -51
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DyB90fWk.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-C6vQASxy.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-BxJUvKau.js +0 -56
- package/codeyam-cli/src/webserver/build/client/assets/simulations-CoNWGt0K.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BDlyhfrv.js +0 -175
- /package/analyzer-template/{process → packages/process/src}/GlobalProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/ProcessManager.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/index.ts +0 -0
- /package/analyzer-template/{process → packages/process/src}/managedExecAsync.ts +0 -0
- /package/{background/src/lib/process → packages/process/src}/GlobalProcessManager.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/index.js +0 -0
- /package/{background/src/lib/process → packages/process/src}/managedExecAsync.js +0 -0
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
convertDotNotation,
|
|
4
4
|
fillInDirectSchemaGapsAndUnknowns,
|
|
5
5
|
joinParenthesesAndArrays,
|
|
6
|
+
mergeJsonTypeDefinitions,
|
|
6
7
|
splitOutsideParenthesesAndArrays,
|
|
7
8
|
} from '~codeyam/ai';
|
|
8
9
|
import { DataStructure, JsonTypeDefinition } from '~codeyam/types';
|
|
@@ -15,6 +16,65 @@ function cleanFunctionName(name: string): string {
|
|
|
15
16
|
return name?.split('<')[0];
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Escapes special regex characters in a string.
|
|
21
|
+
*/
|
|
22
|
+
function escapeRegExp(str: string): string {
|
|
23
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Counts only DIRECT function calls, excluding method chains on return values.
|
|
28
|
+
*
|
|
29
|
+
* When a hook returns an object with methods that are later called, the analysis
|
|
30
|
+
* tracks those as call signatures like 'useAuth().functionCallReturnValue.signOut()'.
|
|
31
|
+
* These are NOT separate calls to useAuth - they're method invocations on the return value.
|
|
32
|
+
*
|
|
33
|
+
* This function filters out such method chains to get the true count of direct calls.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // One direct call, one method on return value
|
|
37
|
+
* countDirectCalls(['useAuth()', 'useAuth().functionCallReturnValue.signOut()']) // => 1
|
|
38
|
+
*
|
|
39
|
+
* // Two direct calls
|
|
40
|
+
* countDirectCalls(['useFetcher()', 'useFetcher()']) // => 2
|
|
41
|
+
*/
|
|
42
|
+
function countDirectCalls(calls: string[]): number {
|
|
43
|
+
return calls.filter((sig) => !sig.includes('.functionCallReturnValue.'))
|
|
44
|
+
.length;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Checks if all direct calls (non-method-chain calls) are identical.
|
|
49
|
+
* This happens when destructuring a hook call:
|
|
50
|
+
* const { authLoading, signOut } = useAuth();
|
|
51
|
+
* produces calls: ['useAuth()', 'useAuth()'] (same signature repeated)
|
|
52
|
+
*
|
|
53
|
+
* In this case, we should use the full unqualified schema since there's
|
|
54
|
+
* really only ONE function call, not multiple different calls.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Same call repeated (from destructuring)
|
|
58
|
+
* allDirectCallsIdentical(['useAuth()', 'useAuth()']) // => true
|
|
59
|
+
*
|
|
60
|
+
* // Different calls
|
|
61
|
+
* allDirectCallsIdentical(['useFetcher<User>()', 'useFetcher<Report>()']) // => false
|
|
62
|
+
*
|
|
63
|
+
* // Single call
|
|
64
|
+
* allDirectCallsIdentical(['useAuth()']) // => true
|
|
65
|
+
*
|
|
66
|
+
* // With method chain (method chain is ignored)
|
|
67
|
+
* allDirectCallsIdentical(['useAuth()', 'useAuth().functionCallReturnValue.signOut()']) // => true
|
|
68
|
+
*/
|
|
69
|
+
function allDirectCallsIdentical(calls: string[]): boolean {
|
|
70
|
+
const directCalls = calls.filter(
|
|
71
|
+
(sig) => !sig.includes('.functionCallReturnValue.'),
|
|
72
|
+
);
|
|
73
|
+
if (directCalls.length === 0) return true;
|
|
74
|
+
const firstCall = directCalls[0];
|
|
75
|
+
return directCalls.every((call) => call === firstCall);
|
|
76
|
+
}
|
|
77
|
+
|
|
18
78
|
/**
|
|
19
79
|
* Preprocesses the schema to:
|
|
20
80
|
* 1. Filter out all signature paths
|
|
@@ -108,18 +168,23 @@ function processCall(
|
|
|
108
168
|
hookCallIndex: number,
|
|
109
169
|
): { key: string; value: JsonTypeDefinition } | null {
|
|
110
170
|
const callName = importedExport.calls?.[callIndex] ?? importedExport.name;
|
|
171
|
+
|
|
111
172
|
// Determine if we should use variable-qualified schema or base schema.
|
|
112
173
|
// Use variable-qualified schema when:
|
|
113
|
-
// 1. variableNameOccurrence is defined (we're processing multiple calls
|
|
114
|
-
// 2.
|
|
174
|
+
// 1. variableNameOccurrence is defined (we're processing multiple DISTINCT calls), OR
|
|
175
|
+
// 2. Single call with single variable name (directCallCount === 1 && varNamesLength === 1)
|
|
115
176
|
// Use base schema when:
|
|
116
|
-
// - calls
|
|
177
|
+
// - Multiple calls that are all identical (destructuring case: const { a, b } = useHook())
|
|
178
|
+
// - directCallCount !== varNamesLength (rest spread or method chain case)
|
|
117
179
|
// This is important for rest spread destructuring like: const { x, y, ...data } = useLoaderData()
|
|
118
180
|
// where data.queueState.jobs should come from the base schema, not from a variable-qualified schema.
|
|
119
|
-
|
|
181
|
+
// Also important: method chains like useAuth().functionCallReturnValue.signOut() should NOT count
|
|
182
|
+
// as separate calls - only direct hook calls count.
|
|
183
|
+
const directCallCount = countDirectCalls(importedExport.calls ?? []);
|
|
120
184
|
const varNamesLength = importedExport.callVariableNames?.length ?? 0;
|
|
121
185
|
const shouldUseVariableQualifiedSchema =
|
|
122
|
-
variableNameOccurrence !== undefined ||
|
|
186
|
+
variableNameOccurrence !== undefined ||
|
|
187
|
+
(directCallCount === 1 && varNamesLength === 1);
|
|
123
188
|
const variableName = shouldUseVariableQualifiedSchema
|
|
124
189
|
? importedExport.callVariableNames?.[callIndex]
|
|
125
190
|
: undefined;
|
|
@@ -134,15 +199,30 @@ function processCall(
|
|
|
134
199
|
? `${variableName}[${variableNameOccurrence}]`
|
|
135
200
|
: variableName;
|
|
136
201
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
202
|
+
// Schema lookup order (most specific to least specific):
|
|
203
|
+
// 1. Call signature (e.g., 'useLoaderData<typeof loader>()')
|
|
204
|
+
// 2. Variable-qualified key with index (e.g., 'useFetcher::fetcher[1]')
|
|
205
|
+
// 3. Variable-qualified key without index (e.g., 'useFetcher::fetcher')
|
|
206
|
+
// 4. Base name (e.g., 'useLoaderData')
|
|
140
207
|
|
|
141
|
-
let rawSchema =
|
|
142
|
-
|
|
143
|
-
|
|
208
|
+
let rawSchema: Record<string, string> = {};
|
|
209
|
+
|
|
210
|
+
// 1. Try call signature first (most specific - new format)
|
|
211
|
+
if (callName !== importedExport.name) {
|
|
212
|
+
rawSchema =
|
|
213
|
+
dependencySchemas?.[importedExport.filePath]?.[callName]
|
|
214
|
+
?.returnValueSchema ?? {};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 2. Try variable-qualified key with index
|
|
218
|
+
if (Object.keys(rawSchema).length === 0 && indexedVariableName) {
|
|
219
|
+
const indexedKey = `${importedExport.name}::${indexedVariableName}`;
|
|
220
|
+
rawSchema =
|
|
221
|
+
dependencySchemas?.[importedExport.filePath]?.[indexedKey]
|
|
222
|
+
?.returnValueSchema ?? {};
|
|
223
|
+
}
|
|
144
224
|
|
|
145
|
-
//
|
|
225
|
+
// 3. Try variable-qualified key without index (fallback for indexed lookup)
|
|
146
226
|
if (
|
|
147
227
|
Object.keys(rawSchema).length === 0 &&
|
|
148
228
|
variableNameOccurrence !== undefined &&
|
|
@@ -155,15 +235,53 @@ function processCall(
|
|
|
155
235
|
?.returnValueSchema ?? {};
|
|
156
236
|
}
|
|
157
237
|
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
238
|
+
// 4. Get base name schema and merge with call-specific schema
|
|
239
|
+
// The base schema often has more complete array element details that the
|
|
240
|
+
// call-specific schema might be missing. Instead of using as fallback only
|
|
241
|
+
// when empty, MERGE both schemas so we get the most complete picture.
|
|
242
|
+
//
|
|
243
|
+
// HOWEVER: For type-parameterized calls where the base schema contains paths
|
|
244
|
+
// from MULTIPLE DIFFERENT type parameters, DON'T merge to avoid contamination.
|
|
245
|
+
// The call-specific schema (rawSchema) is already isolated and complete.
|
|
246
|
+
const baseSchema =
|
|
247
|
+
dependencySchemas?.[importedExport.filePath]?.[importedExport.name]
|
|
248
|
+
?.returnValueSchema ?? {};
|
|
249
|
+
|
|
250
|
+
// Check if this is a type-parameterized call with a call-specific schema
|
|
251
|
+
const hasTypeParams = callName.includes('<') && callName.includes('>');
|
|
252
|
+
const hasCallSpecificSchema = Object.keys(rawSchema).length > 0;
|
|
253
|
+
|
|
254
|
+
// Check if the base schema has multiple DIFFERENT type parameter variants
|
|
255
|
+
// If so, merging would bring in wrong fields from other variants
|
|
256
|
+
let baseHasMultipleTypeParamVariants = false;
|
|
257
|
+
if (hasTypeParams && hasCallSpecificSchema) {
|
|
258
|
+
const baseFunctionName = cleanFunctionName(callName.split('(')[0]);
|
|
259
|
+
const typeParamVariantsInBase = new Set<string>();
|
|
260
|
+
|
|
261
|
+
for (const path of Object.keys(baseSchema)) {
|
|
262
|
+
// Look for paths like "useFetcher<TypeA>(...)" or "useFetcher<TypeB>(...)"
|
|
263
|
+
const match = path.match(
|
|
264
|
+
new RegExp(`^${escapeRegExp(baseFunctionName)}<([^>]+)>\\(`),
|
|
265
|
+
);
|
|
266
|
+
if (match) {
|
|
267
|
+
typeParamVariantsInBase.add(match[1]);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
baseHasMultipleTypeParamVariants = typeParamVariantsInBase.size > 1;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// For type-parameterized calls where the base schema has MULTIPLE different type
|
|
274
|
+
// parameter variants, use ONLY the call-specific schema to avoid contamination.
|
|
275
|
+
// Otherwise, merge with base schema for complete coverage (e.g., array element details).
|
|
276
|
+
const mergedSchema =
|
|
277
|
+
hasCallSpecificSchema && hasTypeParams && baseHasMultipleTypeParamVariants
|
|
278
|
+
? rawSchema // Use ONLY the call-specific schema when base has mixed type params
|
|
279
|
+
: Object.keys(rawSchema).length === 0
|
|
280
|
+
? baseSchema
|
|
281
|
+
: { ...baseSchema, ...rawSchema };
|
|
164
282
|
|
|
165
283
|
// Preprocess to filter signatures and extract functionCallReturnValue
|
|
166
|
-
let preprocessedSchema = preprocessSchemaForMocks(
|
|
284
|
+
let preprocessedSchema = preprocessSchemaForMocks(mergedSchema);
|
|
167
285
|
|
|
168
286
|
const functionNames: string[] = [];
|
|
169
287
|
|
|
@@ -297,29 +415,11 @@ function processCall(
|
|
|
297
415
|
? `${baseSchemaKey}::${variableName}`
|
|
298
416
|
: baseSchemaKey;
|
|
299
417
|
|
|
300
|
-
// Build output key
|
|
301
|
-
//
|
|
302
|
-
//
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
// Canonical key format: EntityName::hookName::index
|
|
306
|
-
// This ensures consistent keys regardless of variable names chosen during analysis
|
|
307
|
-
const hookName = cleanFunctionName(importedExport.name);
|
|
308
|
-
outputKey = `${options.entityName}::${hookName}::${hookCallIndex}`;
|
|
309
|
-
} else if (variableName) {
|
|
310
|
-
// Legacy format: "variableName <- functionName"
|
|
311
|
-
// This reads naturally as "variableName receives from functionName"
|
|
312
|
-
// When a variable name is reused (variableNameOccurrence > 0), disambiguate with index
|
|
313
|
-
const disambiguator =
|
|
314
|
-
variableNameOccurrence !== undefined && variableNameOccurrence > 0
|
|
315
|
-
? `[${variableNameOccurrence}]`
|
|
316
|
-
: '';
|
|
317
|
-
outputKey = `${variableName}${disambiguator} <- ${importedExport.name}`;
|
|
318
|
-
} else if (isObjectStyle) {
|
|
319
|
-
outputKey = importedExport.name;
|
|
320
|
-
} else {
|
|
321
|
-
outputKey = callName;
|
|
322
|
-
}
|
|
418
|
+
// Build output key - use the ORIGINAL CALL SIGNATURE from the code
|
|
419
|
+
// This makes it clear to the LLM exactly which call needs which data.
|
|
420
|
+
// Example: useFetcher<{ data: UserData }>() vs useFetcher<{ data: ReportData }>()
|
|
421
|
+
// Example: db.select(usersQuery) vs db.select(postsQuery)
|
|
422
|
+
const outputKey = callName;
|
|
323
423
|
|
|
324
424
|
// Try to find return value - check with variable qualifier first, then without
|
|
325
425
|
let returnValue = schema[schemaKey];
|
|
@@ -334,6 +434,34 @@ function processCall(
|
|
|
334
434
|
returnValue = schema['functionCallReturnValue'];
|
|
335
435
|
}
|
|
336
436
|
|
|
437
|
+
// Handle method-chain style calls (e.g., createClient().from("workouts").select("*") or db.select(query))
|
|
438
|
+
// After convertDotNotation, the schema is nested: { "createClient()": { "from(...)": { ... } } }
|
|
439
|
+
// We need to navigate the nested structure using the call signature parts.
|
|
440
|
+
// For object-style dependencies (isObjectStyle=true), the baseSchemaKey is just the object name (e.g., "db"),
|
|
441
|
+
// so returnValue might be the parent object, not the actual return value of the method chain.
|
|
442
|
+
// We should always try method-chain navigation for calls with dots and parens.
|
|
443
|
+
if (callName.includes('.') && callName.includes('(')) {
|
|
444
|
+
const callParts = splitOutsideParenthesesAndArrays(callName);
|
|
445
|
+
let current: unknown = schema;
|
|
446
|
+
for (const part of callParts) {
|
|
447
|
+
if (
|
|
448
|
+
current &&
|
|
449
|
+
typeof current === 'object' &&
|
|
450
|
+
!Array.isArray(current) &&
|
|
451
|
+
part in (current as Record<string, unknown>)
|
|
452
|
+
) {
|
|
453
|
+
current = (current as Record<string, unknown>)[part];
|
|
454
|
+
} else {
|
|
455
|
+
current = undefined;
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
// Use method-chain result if found, otherwise keep previous returnValue
|
|
460
|
+
if (current !== undefined) {
|
|
461
|
+
returnValue = current as typeof returnValue;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
337
465
|
if (!returnValue) {
|
|
338
466
|
return null;
|
|
339
467
|
}
|
|
@@ -341,6 +469,27 @@ function processCall(
|
|
|
341
469
|
return { key: outputKey, value: returnValue as JsonTypeDefinition };
|
|
342
470
|
}
|
|
343
471
|
|
|
472
|
+
/**
|
|
473
|
+
* Adds a result to the accumulator, merging schemas if the key already exists.
|
|
474
|
+
* This handles the case where the same call signature appears multiple times
|
|
475
|
+
* (e.g., two calls to useFetcher() with the same generic type).
|
|
476
|
+
*/
|
|
477
|
+
function addResultToAccumulator(
|
|
478
|
+
acc: { [key: string]: JsonTypeDefinition },
|
|
479
|
+
key: string,
|
|
480
|
+
value: JsonTypeDefinition,
|
|
481
|
+
): void {
|
|
482
|
+
if (acc[key]) {
|
|
483
|
+
// Key already exists - merge the schemas
|
|
484
|
+
acc[key] = mergeJsonTypeDefinitions(
|
|
485
|
+
acc[key] as Record<string, unknown>,
|
|
486
|
+
value as Record<string, unknown>,
|
|
487
|
+
) as JsonTypeDefinition;
|
|
488
|
+
} else {
|
|
489
|
+
acc[key] = value;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
344
493
|
export default function gatherDataForMocks(
|
|
345
494
|
importedExports: {
|
|
346
495
|
filePath?: string;
|
|
@@ -363,14 +512,121 @@ export default function gatherDataForMocks(
|
|
|
363
512
|
// Get the clean hook name for indexing
|
|
364
513
|
const hookName = cleanFunctionName(importedExport.name);
|
|
365
514
|
|
|
366
|
-
// Check if we have multiple calls with variable names
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
515
|
+
// Check if we have multiple DISTINCT direct calls with variable names.
|
|
516
|
+
// Important: Only count direct calls to the function, not method chains on its return value.
|
|
517
|
+
// For example, ['useAuth()', 'useAuth().functionCallReturnValue.signOut()'] has only 1 direct call.
|
|
518
|
+
//
|
|
519
|
+
// ALSO: If all direct calls are IDENTICAL (same signature repeated), this is from
|
|
520
|
+
// destructuring like `const { a, b } = useHook()` and we should use the FULL unqualified
|
|
521
|
+
// schema, not iterate through partial variable-qualified schemas.
|
|
522
|
+
const directCallCount = countDirectCalls(importedExport.calls ?? []);
|
|
523
|
+
const hasMultipleDistinctCalls =
|
|
524
|
+
directCallCount > 1 &&
|
|
370
525
|
importedExport.callVariableNames &&
|
|
371
|
-
importedExport.callVariableNames.length ===
|
|
526
|
+
importedExport.callVariableNames.length === directCallCount &&
|
|
527
|
+
!allDirectCallsIdentical(importedExport.calls ?? []);
|
|
528
|
+
|
|
529
|
+
// Check for multiple distinct method-chain calls WITHOUT callVariableNames.
|
|
530
|
+
// This pattern is common with tRPC, Supabase, etc. where a single import
|
|
531
|
+
// (e.g., `trpc`) is used with multiple different method chains (e.g.,
|
|
532
|
+
// `trpc.useUtils()`, `trpc.quote.getQuotesByOrg.useQuery()`).
|
|
533
|
+
// These should each get their own entry in dataForMocks.
|
|
534
|
+
//
|
|
535
|
+
// IMPORTANT: This is DIFFERENT from the rest spread pattern where a function
|
|
536
|
+
// like useLoaderData is called directly, and other calls are method chains
|
|
537
|
+
// on its return value (e.g., `useLoaderData<typeof loader>()` with
|
|
538
|
+
// `useLoaderData<typeof loader>().uncommittedEntitiesList.filter(...)`).
|
|
539
|
+
// In that case, all the additional calls start with the base function call.
|
|
540
|
+
const directCalls = (importedExport.calls ?? []).filter(
|
|
541
|
+
(sig) => !sig.includes('.functionCallReturnValue.'),
|
|
542
|
+
);
|
|
543
|
+
const uniqueDirectCalls = [...new Set(directCalls)];
|
|
544
|
+
|
|
545
|
+
// Check if any call is a direct invocation of the import (e.g., `useLoaderData<typeof loader>()`)
|
|
546
|
+
// as opposed to all being property accesses (e.g., `trpc.useUtils()`, `trpc.quote.xxx()`).
|
|
547
|
+
// If there's a direct function call, the other calls are likely method chains on its result.
|
|
548
|
+
const baseName = importedExport.name;
|
|
549
|
+
const hasDirectFunctionCall = directCalls.some((sig) => {
|
|
550
|
+
// Pattern: baseName() or baseName<...>()
|
|
551
|
+
// This matches "useLoaderData()", "useLoaderData<typeof loader>()", etc.
|
|
552
|
+
// but NOT "trpc.useUtils()" which has a dot before the parens
|
|
553
|
+
const baseCallPattern = new RegExp(`^${baseName}(<[^>]*>)?\\(`);
|
|
554
|
+
return baseCallPattern.test(sig);
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
const hasMultipleDistinctMethodChains =
|
|
558
|
+
!hasMultipleDistinctCalls &&
|
|
559
|
+
uniqueDirectCalls.length > 1 &&
|
|
560
|
+
!allDirectCallsIdentical(directCalls) &&
|
|
561
|
+
!hasDirectFunctionCall; // Exclude rest spread patterns
|
|
562
|
+
|
|
563
|
+
if (hasMultipleDistinctMethodChains) {
|
|
564
|
+
// For multiple method-chain calls on the same import, create a NESTED structure
|
|
565
|
+
// under the base import name. This allows constructMockCode to generate a
|
|
566
|
+
// combined mock object with all method chains.
|
|
567
|
+
//
|
|
568
|
+
// Example: For calls ['trpc.useUtils()', 'trpc.quote.getQuotesByOrg.useQuery()'],
|
|
569
|
+
// create: { "trpc": { "useUtils()": {...}, "quote": { "getQuotesByOrg": { "useQuery()": {...} } } } }
|
|
570
|
+
const nestedResult: Record<string, unknown> = {};
|
|
571
|
+
|
|
572
|
+
for (let i = 0; i < uniqueDirectCalls.length; i++) {
|
|
573
|
+
// Find the index of this call in the original calls array
|
|
574
|
+
const callIndex = (importedExport.calls ?? []).indexOf(
|
|
575
|
+
uniqueDirectCalls[i],
|
|
576
|
+
);
|
|
577
|
+
if (callIndex === -1) continue;
|
|
372
578
|
|
|
373
|
-
|
|
579
|
+
const hookCallIndex = hookCallIndices[hookName] ?? 0;
|
|
580
|
+
hookCallIndices[hookName] = hookCallIndex + 1;
|
|
581
|
+
|
|
582
|
+
const processResult = processCall(
|
|
583
|
+
importedExport,
|
|
584
|
+
dependencySchemas,
|
|
585
|
+
callIndex,
|
|
586
|
+
undefined,
|
|
587
|
+
options,
|
|
588
|
+
hookCallIndex,
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
if (processResult) {
|
|
592
|
+
// The key is like "trpc.useUtils()" or "trpc.quote.getQuotesByOrg.useQuery()"
|
|
593
|
+
// We need to nest the value at the path AFTER the base name
|
|
594
|
+
const callSignature = processResult.key;
|
|
595
|
+
|
|
596
|
+
// Split the call signature into path parts, handling parens
|
|
597
|
+
// e.g., "trpc.useUtils()" -> ["trpc", "useUtils()"]
|
|
598
|
+
// e.g., "trpc.quote.getQuotesByOrg.useQuery()" -> ["trpc", "quote", "getQuotesByOrg", "useQuery()"]
|
|
599
|
+
const pathParts = splitOutsideParenthesesAndArrays(callSignature);
|
|
600
|
+
|
|
601
|
+
// Skip the base name (first part) and nest the value at the remaining path
|
|
602
|
+
if (pathParts.length > 1 && pathParts[0] === baseName) {
|
|
603
|
+
const nestedPath = pathParts.slice(1);
|
|
604
|
+
|
|
605
|
+
// Set the value at the nested path, merging with existing structure
|
|
606
|
+
let current = nestedResult;
|
|
607
|
+
for (let j = 0; j < nestedPath.length - 1; j++) {
|
|
608
|
+
const part = nestedPath[j];
|
|
609
|
+
if (!(part in current)) {
|
|
610
|
+
current[part] = {};
|
|
611
|
+
}
|
|
612
|
+
current = current[part] as Record<string, unknown>;
|
|
613
|
+
}
|
|
614
|
+
// Set the leaf value
|
|
615
|
+
const leafKey = nestedPath[nestedPath.length - 1];
|
|
616
|
+
current[leafKey] = processResult.value;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// Add the nested result under the base import name
|
|
622
|
+
if (Object.keys(nestedResult).length > 0) {
|
|
623
|
+
addResultToAccumulator(
|
|
624
|
+
acc,
|
|
625
|
+
baseName,
|
|
626
|
+
nestedResult as JsonTypeDefinition,
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
} else if (hasMultipleDistinctCalls) {
|
|
374
630
|
// Track how many times each variable name has been seen
|
|
375
631
|
// to disambiguate keys when the same variable is reused
|
|
376
632
|
const variableNameCounts: Record<string, number> = {};
|
|
@@ -396,15 +652,16 @@ export default function gatherDataForMocks(
|
|
|
396
652
|
hookCallIndex,
|
|
397
653
|
);
|
|
398
654
|
if (processResult) {
|
|
399
|
-
acc
|
|
655
|
+
addResultToAccumulator(acc, processResult.key, processResult.value);
|
|
400
656
|
}
|
|
401
657
|
}
|
|
402
658
|
} else {
|
|
403
|
-
//
|
|
659
|
+
// Single calls, or multiple identical calls (from destructuring)
|
|
404
660
|
// Get the current hook call index and increment for next call
|
|
405
661
|
const hookCallIndex = hookCallIndices[hookName] ?? 0;
|
|
406
662
|
hookCallIndices[hookName] = hookCallIndex + 1;
|
|
407
663
|
|
|
664
|
+
// First, try to get result from unqualified schema
|
|
408
665
|
const processResult = processCall(
|
|
409
666
|
importedExport,
|
|
410
667
|
dependencySchemas,
|
|
@@ -413,8 +670,98 @@ export default function gatherDataForMocks(
|
|
|
413
670
|
options,
|
|
414
671
|
hookCallIndex,
|
|
415
672
|
);
|
|
416
|
-
|
|
417
|
-
|
|
673
|
+
|
|
674
|
+
// Check if we got a meaningful result (not empty object or null)
|
|
675
|
+
// Arrays are always meaningful (even empty ones represent valid data structure)
|
|
676
|
+
const hasUnqualifiedResult =
|
|
677
|
+
processResult &&
|
|
678
|
+
processResult.value !== null &&
|
|
679
|
+
(typeof processResult.value !== 'object' ||
|
|
680
|
+
Array.isArray(processResult.value) ||
|
|
681
|
+
Object.keys(processResult.value as object).length > 0);
|
|
682
|
+
|
|
683
|
+
// Check if we have multiple callVariableNames that are DIFFERENT
|
|
684
|
+
// (e.g., from parent + child components using the same hook differently)
|
|
685
|
+
// In this case, we should also merge in variable-qualified schemas
|
|
686
|
+
// to capture all destructured properties from both parent and child.
|
|
687
|
+
const uniqueCallVarNames = new Set(
|
|
688
|
+
importedExport.callVariableNames ?? [],
|
|
689
|
+
);
|
|
690
|
+
const hasDifferentVarNames =
|
|
691
|
+
importedExport.callVariableNames &&
|
|
692
|
+
importedExport.callVariableNames.length > 1 &&
|
|
693
|
+
uniqueCallVarNames.size > 1 &&
|
|
694
|
+
// Only merge variable-qualified schemas when calls are all identical
|
|
695
|
+
// (e.g., useFlags() repeated). Don't do this for method chains
|
|
696
|
+
// or rest spread cases where calls.length !== callVariableNames.length
|
|
697
|
+
allDirectCallsIdentical(importedExport.calls ?? []);
|
|
698
|
+
|
|
699
|
+
if (hasUnqualifiedResult) {
|
|
700
|
+
let finalValue = processResult.value;
|
|
701
|
+
|
|
702
|
+
// If we have different variable names (e.g., from parent and child components),
|
|
703
|
+
// also merge in variable-qualified schemas to ensure we capture all properties.
|
|
704
|
+
// This handles the case where parent uses useFlags().enableNewAdminDashboard
|
|
705
|
+
// and child uses useFlags().flagShowReferenceIdOnQuoteTable.
|
|
706
|
+
if (hasDifferentVarNames) {
|
|
707
|
+
let mergedValue = processResult.value as JsonTypeDefinition;
|
|
708
|
+
for (let i = 0; i < importedExport.callVariableNames!.length; i++) {
|
|
709
|
+
const varQualifiedResult = processCall(
|
|
710
|
+
importedExport,
|
|
711
|
+
dependencySchemas,
|
|
712
|
+
i,
|
|
713
|
+
0, // Use 0 to trigger variable-qualified lookup
|
|
714
|
+
options,
|
|
715
|
+
hookCallIndex,
|
|
716
|
+
);
|
|
717
|
+
if (varQualifiedResult && varQualifiedResult.value) {
|
|
718
|
+
mergedValue = mergeJsonTypeDefinitions(
|
|
719
|
+
mergedValue as Record<string, unknown>,
|
|
720
|
+
varQualifiedResult.value as Record<string, unknown>,
|
|
721
|
+
) as JsonTypeDefinition;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
finalValue = mergedValue;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
addResultToAccumulator(
|
|
728
|
+
acc,
|
|
729
|
+
processResult.key,
|
|
730
|
+
finalValue as JsonTypeDefinition,
|
|
731
|
+
);
|
|
732
|
+
} else if (
|
|
733
|
+
directCallCount > 1 &&
|
|
734
|
+
allDirectCallsIdentical(importedExport.calls ?? []) &&
|
|
735
|
+
importedExport.callVariableNames &&
|
|
736
|
+
importedExport.callVariableNames.length > 0
|
|
737
|
+
) {
|
|
738
|
+
// No unqualified schema exists, but we have multiple identical calls with variable names
|
|
739
|
+
// Merge all the variable-qualified schemas together
|
|
740
|
+
const callSignature =
|
|
741
|
+
importedExport.calls?.[0] ?? `${importedExport.name}()`;
|
|
742
|
+
let mergedValue: JsonTypeDefinition = {};
|
|
743
|
+
|
|
744
|
+
for (let i = 0; i < importedExport.callVariableNames.length; i++) {
|
|
745
|
+
const varQualifiedResult = processCall(
|
|
746
|
+
importedExport,
|
|
747
|
+
dependencySchemas,
|
|
748
|
+
i,
|
|
749
|
+
0, // Use 0 to trigger variable-qualified lookup
|
|
750
|
+
options,
|
|
751
|
+
hookCallIndex,
|
|
752
|
+
);
|
|
753
|
+
if (varQualifiedResult && varQualifiedResult.value) {
|
|
754
|
+
// Deep merge the value into the accumulated result
|
|
755
|
+
mergedValue = mergeJsonTypeDefinitions(
|
|
756
|
+
mergedValue,
|
|
757
|
+
varQualifiedResult.value,
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
if (Object.keys(mergedValue as object).length > 0) {
|
|
763
|
+
addResultToAccumulator(acc, callSignature, mergedValue);
|
|
764
|
+
}
|
|
418
765
|
}
|
|
419
766
|
}
|
|
420
767
|
|