@codeyam/codeyam-cli 0.1.0-staging.e38f7bd → 0.1.0-staging.eb21b2f
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 +8 -8
- package/analyzer-template/common/execAsync.ts +1 -1
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +21 -17
- package/analyzer-template/packages/ai/index.ts +21 -5
- package/analyzer-template/packages/ai/package.json +4 -4
- package/analyzer-template/packages/ai/src/lib/__mocks__/completionCall.ts +122 -0
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +228 -24
- package/analyzer-template/packages/ai/src/lib/astScopes/arrayDerivationDetector.ts +199 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +205 -10
- package/analyzer-template/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.ts +644 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/methodSemantics.ts +181 -23
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.ts +18 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.ts +38 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.ts +181 -1
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +1619 -125
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +324 -5
- package/analyzer-template/packages/ai/src/lib/checkAllAttributes.ts +29 -10
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +216 -36
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +2543 -399
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +21 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.ts +976 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.ts +243 -77
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.ts +16 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.ts +6 -4
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.ts +71 -2
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +161 -19
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +163 -14
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertNullToUndefinedBySchema.ts +98 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.ts +179 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.ts +40 -30
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.ts +441 -82
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.ts +129 -0
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +183 -0
- package/analyzer-template/packages/ai/src/lib/deepEqual.ts +30 -0
- package/analyzer-template/packages/ai/src/lib/e2eDataTracking.ts +334 -0
- package/analyzer-template/packages/ai/src/lib/extractCriticalDataKeys.ts +120 -0
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarioData.ts +74 -7
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityScenarios.ts +89 -112
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +63 -2
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +1419 -101
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +216 -109
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +710 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +528 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +2484 -0
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +239 -0
- package/analyzer-template/packages/ai/src/lib/getConditionalUsagesFromCode.ts +143 -31
- package/analyzer-template/packages/ai/src/lib/guessScenarioDataFromDescription.ts +8 -2
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +328 -7
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +111 -87
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +17 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.ts +32 -102
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateChunkPrompt.ts +82 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateCriticalKeysPrompt.ts +103 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +110 -6
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.ts +14 -53
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.ts +58 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.ts +28 -2
- package/analyzer-template/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.ts +391 -0
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +824 -0
- package/analyzer-template/packages/ai/src/lib/splitOutsideParentheses.ts +5 -1
- package/analyzer-template/packages/ai/src/lib/validateExecutionFlowPaths.ts +531 -0
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +127 -3
- package/analyzer-template/packages/ai/src/lib/worker/analyzeScopeWorker.ts +121 -2
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +79 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- package/analyzer-template/packages/analyze/src/lib/analysisContext.ts +44 -4
- 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/asts/sourceFiles/getAllDeclaredEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.ts +19 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getAllExports.ts +11 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.ts +8 -0
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.ts +49 -1
- package/analyzer-template/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.ts +570 -180
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +54 -1
- package/analyzer-template/packages/analyze/src/lib/files/analyze/dependencyResolver.ts +6 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/findOrCreateEntity.ts +3 -0
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +33 -10
- package/analyzer-template/packages/analyze/src/lib/files/analyzeChange.ts +31 -15
- package/analyzer-template/packages/analyze/src/lib/files/analyzeEntity.ts +11 -7
- package/analyzer-template/packages/analyze/src/lib/files/analyzeInitial.ts +11 -12
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/enums/steps.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +22 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +313 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichUnknownTypesFromSourceEquivalencies.ts +102 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +711 -78
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.ts +1 -1
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.ts +28 -62
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +550 -137
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +264 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarioData.ts +78 -83
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateScenarios.ts +4 -8
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +1067 -167
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.ts +56 -11
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/propagateArrayItemSchemas.ts +474 -0
- package/analyzer-template/packages/analyze/src/lib/files/setImportedExports.ts +2 -1
- package/analyzer-template/packages/analyze/src/lib/index.ts +1 -0
- package/analyzer-template/packages/analyze/src/lib/utils/getFileByPath.ts +19 -0
- 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/checkS3ObjectExists.d.ts +15 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.d.ts.map +1 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js +31 -0
- package/analyzer-template/packages/aws/dist/src/lib/s3/checkS3ObjectExists.js.map +1 -0
- 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 +3 -3
- package/analyzer-template/packages/aws/s3/index.ts +1 -0
- 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/checkS3ObjectExists.ts +47 -0
- package/analyzer-template/packages/aws/src/lib/s3/uploadFileToS3.ts +8 -1
- package/analyzer-template/packages/database/package.json +1 -1
- package/analyzer-template/packages/database/src/lib/analysisBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/analysisToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/branchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitBranchToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/commitToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/fileToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/db.ts +18 -5
- package/analyzer-template/packages/database/src/lib/kysely/tableRelations.ts +2 -2
- package/analyzer-template/packages/database/src/lib/kysely/tables/commitsTable.ts +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +36 -9
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- package/analyzer-template/packages/database/src/lib/loadAnalyses.ts +58 -1
- package/analyzer-template/packages/database/src/lib/loadAnalysis.ts +13 -0
- package/analyzer-template/packages/database/src/lib/loadBranch.ts +16 -1
- package/analyzer-template/packages/database/src/lib/loadCommit.ts +11 -0
- package/analyzer-template/packages/database/src/lib/loadCommits.ts +28 -0
- package/analyzer-template/packages/database/src/lib/loadEntities.ts +26 -3
- package/analyzer-template/packages/database/src/lib/loadEntityBranches.ts +12 -0
- package/analyzer-template/packages/database/src/lib/loadReadyToBeCapturedAnalyses.ts +30 -5
- package/analyzer-template/packages/database/src/lib/projectToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/saveFiles.ts +1 -1
- package/analyzer-template/packages/database/src/lib/scenarioToDb.ts +1 -1
- package/analyzer-template/packages/database/src/lib/updateCommitMetadata.ts +7 -14
- package/analyzer-template/packages/database/src/lib/userScenarioToDb.ts +1 -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/componentScenarioPage/getIFrameMessageListenerCode.ts +9 -4
- package/analyzer-template/packages/generate/src/lib/deepMerge.ts +26 -1
- package/analyzer-template/packages/generate/src/lib/directExecutionScript.ts +17 -2
- package/analyzer-template/packages/generate/src/lib/getComponentScenarioPath.ts +8 -3
- package/analyzer-template/packages/generate/src/lib/scenarioComponentForServer.ts +114 -0
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/analysisToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/branchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitBranchToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/commitToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/fileToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts +4 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js +13 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/db.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tableRelations.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts +1 -11
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/analysesTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts +30 -7
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- 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/labsRequestsTable.d.ts +23 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.d.ts.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts +2 -6
- package/analyzer-template/packages/github/dist/database/src/lib/kysely/tables/scenariosTable.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts +2 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js +45 -2
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js +8 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadAnalysis.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js +11 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadBranch.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js +7 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommit.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js +22 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadCommits.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts +3 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js +23 -4
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntities.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js +9 -0
- package/analyzer-template/packages/github/dist/database/src/lib/loadEntityBranches.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js +23 -5
- package/analyzer-template/packages/github/dist/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/projectToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/saveFiles.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/scenarioToDb.js.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts +2 -2
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js +5 -4
- package/analyzer-template/packages/github/dist/database/src/lib/updateCommitMetadata.js.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/componentScenarioPage/getIFrameMessageListenerCode.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/analyzer-template/packages/github/dist/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js +27 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/deepMerge.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js +10 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/directExecutionScript.js.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/analyzer-template/packages/github/dist/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- 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/index.d.ts +2 -2
- package/analyzer-template/packages/github/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/github/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/Commit.d.ts.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/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/github/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/github/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/github/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/github/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/github/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/github/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/github/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/github/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/github/package.json +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/index.ts +5 -0
- package/analyzer-template/packages/types/src/types/Analysis.ts +104 -13
- package/analyzer-template/packages/types/src/types/Commit.ts +2 -0
- package/analyzer-template/packages/types/src/types/Entity.ts +2 -0
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/Scenario.ts +11 -10
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +228 -3
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -1
- package/analyzer-template/packages/types/src/types/StatementInfo.ts +2 -0
- package/analyzer-template/packages/ui-components/package.json +4 -4
- package/analyzer-template/packages/ui-components/src/components/ScenarioDetailInteractiveView.tsx +23 -7
- package/analyzer-template/packages/utils/dist/types/index.d.ts +2 -2
- package/analyzer-template/packages/utils/dist/types/index.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/index.js.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts +87 -13
- package/analyzer-template/packages/utils/dist/types/src/types/Analysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/Commit.d.ts.map +1 -1
- 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/ProjectMetadata.d.ts +7 -0
- package/analyzer-template/packages/utils/dist/types/src/types/ProjectMetadata.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts +11 -6
- package/analyzer-template/packages/utils/dist/types/src/types/Scenario.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts +199 -3
- package/analyzer-template/packages/utils/dist/types/src/types/ScenariosDataStructure.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts +6 -1
- package/analyzer-template/packages/utils/dist/types/src/types/ScopeAnalysis.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts +2 -0
- package/analyzer-template/packages/utils/dist/types/src/types/StatementInfo.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js +26 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/analyzer-template/packages/utils/dist/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/analyzer-template/packages/utils/dist/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts +9 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.d.ts.map +1 -1
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js +29 -3
- package/analyzer-template/packages/utils/dist/utils/src/lib/safeFileName.js.map +1 -1
- package/analyzer-template/packages/utils/src/lib/applyUniversalMocks.ts +28 -2
- package/analyzer-template/packages/utils/src/lib/fs/rsyncCopy.ts +108 -2
- package/analyzer-template/packages/utils/src/lib/lightweightEntityExtractor.ts +27 -0
- package/analyzer-template/packages/utils/src/lib/safeFileName.ts +48 -3
- package/analyzer-template/playwright/capture.ts +57 -26
- package/analyzer-template/playwright/captureStatic.ts +1 -1
- package/analyzer-template/playwright/getCodeYamInfo.ts +12 -7
- package/analyzer-template/playwright/takeElementScreenshot.ts +26 -11
- package/analyzer-template/playwright/takeScreenshot.ts +15 -9
- package/analyzer-template/playwright/waitForServer.ts +21 -6
- package/analyzer-template/project/TESTING.md +83 -0
- package/analyzer-template/project/analyzeBaselineCommit.ts +9 -0
- package/analyzer-template/project/analyzeBranchCommit.ts +4 -0
- package/analyzer-template/project/analyzeFileEntities.ts +4 -0
- package/analyzer-template/project/analyzeRegularCommit.ts +9 -0
- package/analyzer-template/project/captureLibraryFunctionDirect.ts +29 -26
- package/analyzer-template/project/constructMockCode.ts +1319 -158
- package/analyzer-template/project/controller/startController.ts +16 -1
- package/analyzer-template/project/createEntitiesAndSortFiles.ts +83 -0
- package/analyzer-template/project/executeLibraryFunctionDirect.ts +7 -3
- package/analyzer-template/project/loadReadyToBeCaptured.ts +82 -42
- package/analyzer-template/project/mocks/analyzeFileMock.ts +8 -7
- package/analyzer-template/project/orchestrateCapture/AwsCaptureTaskRunner.ts +12 -4
- package/analyzer-template/project/orchestrateCapture/KyselyAnalysisLoader.ts +13 -9
- package/analyzer-template/project/orchestrateCapture/SequentialCaptureTaskRunner.ts +93 -42
- package/analyzer-template/project/orchestrateCapture/taskRunner.ts +4 -2
- package/analyzer-template/project/orchestrateCapture.ts +88 -12
- package/analyzer-template/project/reconcileMockDataKeys.ts +245 -2
- package/analyzer-template/project/runAnalysis.ts +11 -0
- package/analyzer-template/project/runMultiScenarioServer.ts +11 -10
- package/analyzer-template/project/serverOnlyModules.ts +413 -0
- package/analyzer-template/project/start.ts +72 -19
- package/analyzer-template/project/startScenarioCapture.ts +79 -41
- package/analyzer-template/project/writeMockDataTsx.ts +466 -73
- package/analyzer-template/project/writeScenarioClientWrapper.ts +21 -0
- package/analyzer-template/project/writeScenarioComponents.ts +1447 -214
- package/analyzer-template/project/writeScenarioFiles.ts +26 -0
- package/analyzer-template/project/writeSimpleRoot.ts +56 -22
- package/analyzer-template/project/writeUniversalMocks.ts +32 -11
- package/analyzer-template/scripts/comboWorkerLoop.cjs +99 -50
- package/analyzer-template/scripts/defaultCmd.sh +9 -0
- package/analyzer-template/tsconfig.json +2 -1
- package/background/src/lib/local/createLocalAnalyzer.js +2 -30
- 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/analyzeBaselineCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeBaselineCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js +2 -1
- package/background/src/lib/virtualized/project/analyzeBranchCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js +2 -1
- package/background/src/lib/virtualized/project/analyzeFileEntities.js.map +1 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js +7 -1
- package/background/src/lib/virtualized/project/analyzeRegularCommit.js.map +1 -1
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js +3 -3
- package/background/src/lib/virtualized/project/captureLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +1171 -120
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/controller/startController.js +11 -1
- package/background/src/lib/virtualized/project/controller/startController.js.map +1 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js +73 -1
- package/background/src/lib/virtualized/project/createEntitiesAndSortFiles.js.map +1 -1
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js +6 -3
- package/background/src/lib/virtualized/project/executeLibraryFunctionDirect.js.map +1 -1
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js +34 -9
- package/background/src/lib/virtualized/project/loadReadyToBeCaptured.js.map +1 -1
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js +7 -7
- package/background/src/lib/virtualized/project/mocks/analyzeFileMock.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js +2 -2
- package/background/src/lib/virtualized/project/orchestrateCapture/AwsCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js +12 -6
- package/background/src/lib/virtualized/project/orchestrateCapture/KyselyAnalysisLoader.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js +73 -36
- package/background/src/lib/virtualized/project/orchestrateCapture/SequentialCaptureTaskRunner.js.map +1 -1
- package/background/src/lib/virtualized/project/orchestrateCapture.js +72 -13
- package/background/src/lib/virtualized/project/orchestrateCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js +204 -2
- package/background/src/lib/virtualized/project/reconcileMockDataKeys.js.map +1 -1
- package/background/src/lib/virtualized/project/runAnalysis.js +9 -0
- package/background/src/lib/virtualized/project/runAnalysis.js.map +1 -1
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js +11 -9
- package/background/src/lib/virtualized/project/runMultiScenarioServer.js.map +1 -1
- package/background/src/lib/virtualized/project/serverOnlyModules.js +338 -0
- package/background/src/lib/virtualized/project/serverOnlyModules.js.map +1 -0
- package/background/src/lib/virtualized/project/start.js +62 -19
- package/background/src/lib/virtualized/project/start.js.map +1 -1
- package/background/src/lib/virtualized/project/startScenarioCapture.js +61 -31
- package/background/src/lib/virtualized/project/startScenarioCapture.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +404 -62
- 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 +1066 -146
- 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 +57 -20
- package/background/src/lib/virtualized/project/writeSimpleRoot.js.map +1 -1
- package/background/src/lib/virtualized/project/writeUniversalMocks.js +27 -12
- package/background/src/lib/virtualized/project/writeUniversalMocks.js.map +1 -1
- package/codeyam-cli/scripts/apply-setup.js +180 -0
- package/codeyam-cli/scripts/apply-setup.js.map +1 -1
- package/codeyam-cli/src/cli.js +11 -1
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/codeyam-cli.js +18 -2
- package/codeyam-cli/src/codeyam-cli.js.map +1 -1
- package/codeyam-cli/src/commands/analyze.js +5 -3
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +176 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -0
- package/codeyam-cli/src/commands/debug.js +44 -18
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +30 -34
- package/codeyam-cli/src/commands/default.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +2 -0
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +1 -1
- package/codeyam-cli/src/commands/init.js +49 -257
- package/codeyam-cli/src/commands/init.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +307 -0
- package/codeyam-cli/src/commands/memory.js.map +1 -0
- package/codeyam-cli/src/commands/recapture.js +228 -0
- package/codeyam-cli/src/commands/recapture.js.map +1 -0
- package/codeyam-cli/src/commands/report.js +72 -24
- package/codeyam-cli/src/commands/report.js.map +1 -1
- package/codeyam-cli/src/commands/setup-sandbox.js +2 -0
- package/codeyam-cli/src/commands/setup-sandbox.js.map +1 -1
- package/codeyam-cli/src/commands/setup-simulations.js +284 -0
- package/codeyam-cli/src/commands/setup-simulations.js.map +1 -0
- package/codeyam-cli/src/commands/start.js +8 -12
- package/codeyam-cli/src/commands/start.js.map +1 -1
- 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 +3 -1
- package/codeyam-cli/src/commands/test-startup.js.map +1 -1
- package/codeyam-cli/src/commands/verify.js +14 -2
- package/codeyam-cli/src/commands/verify.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/__tests__/npmVersionCheck.test.js +179 -0
- package/codeyam-cli/src/utils/__tests__/npmVersionCheck.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js +81 -0
- package/codeyam-cli/src/utils/__tests__/serverVersionStaleness.test.js.map +1 -0
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js +128 -82
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.js.map +1 -1
- package/codeyam-cli/src/utils/analysisRunner.js +29 -15
- package/codeyam-cli/src/utils/analysisRunner.js.map +1 -1
- package/codeyam-cli/src/utils/analyzer.js +7 -0
- package/codeyam-cli/src/utils/analyzer.js.map +1 -1
- package/codeyam-cli/src/utils/backgroundServer.js +104 -23
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/database.js +91 -5
- package/codeyam-cli/src/utils/database.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +253 -106
- package/codeyam-cli/src/utils/generateReport.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/install-skills.js +76 -42
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/labsAutoCheck.js +19 -0
- package/codeyam-cli/src/utils/labsAutoCheck.js.map +1 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js +76 -0
- package/codeyam-cli/src/utils/npmVersionCheck.js.map +1 -0
- package/codeyam-cli/src/utils/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js +38 -0
- package/codeyam-cli/src/utils/queue/__tests__/manager.test.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +249 -16
- package/codeyam-cli/src/utils/queue/job.js.map +1 -1
- package/codeyam-cli/src/utils/queue/manager.js +103 -7
- package/codeyam-cli/src/utils/queue/manager.js.map +1 -1
- package/codeyam-cli/src/utils/queue/persistence.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +10 -0
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js +82 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/confusionDetector.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +230 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js +67 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/assertRules.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js +105 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/captureFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js +34 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/loadCapturedFixture.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js +162 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/runClaude.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js +75 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/helpers/setupTempProject.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js +378 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/integration/ruleReflectionE2E.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js +127 -0
- package/codeyam-cli/src/utils/ruleReflection/__tests__/transcriptParser.test.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js +50 -0
- package/codeyam-cli/src/utils/ruleReflection/confusionDetector.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js +116 -0
- package/codeyam-cli/src/utils/ruleReflection/contextBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/index.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js +44 -0
- package/codeyam-cli/src/utils/ruleReflection/promptBuilder.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js +85 -0
- package/codeyam-cli/src/utils/ruleReflection/transcriptParser.js.map +1 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js +5 -0
- package/codeyam-cli/src/utils/ruleReflection/types.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js +293 -0
- package/codeyam-cli/src/utils/rules/__tests__/ruleState.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/index.js +6 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -0
- package/codeyam-cli/src/utils/rules/parser.js +83 -0
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js +18 -0
- package/codeyam-cli/src/utils/rules/pathMatcher.js.map +1 -0
- package/codeyam-cli/src/utils/rules/ruleState.js +150 -0
- package/codeyam-cli/src/utils/rules/ruleState.js.map +1 -0
- package/codeyam-cli/src/utils/rules/staleness.js +137 -0
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -0
- package/codeyam-cli/src/utils/serverState.js +37 -10
- package/codeyam-cli/src/utils/serverState.js.map +1 -1
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js +21 -42
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/utils/versionInfo.js +46 -15
- package/codeyam-cli/src/utils/versionInfo.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/__tests__/dependency-smoke.test.js +66 -0
- package/codeyam-cli/src/webserver/__tests__/dependency-smoke.test.js.map +1 -0
- package/codeyam-cli/src/webserver/app/lib/database.js +118 -6
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/dbNotifier.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +55 -10
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/bootstrap.js +60 -0
- package/codeyam-cli/src/webserver/bootstrap.js.map +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-jNYXRRNI.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/EntityItem-bwuHPyTa.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-kykTbcnD.js → EntityTypeBadge-CvzqMxcu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-BH0XDim7.js +41 -0
- package/codeyam-cli/src/webserver/build/client/assets/InlineSpinner-EhOseatT.js +34 -0
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-yjIHlOGa.js +25 -0
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-Cq5o8jL4.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/LoadingDots-BvMu2i-g.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-kgBTLoJD.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-BzPgx-xO.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-CwZrv-Ok.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-BX2Ny2Qj.js +10 -0
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-C06nsHKY.js → TruncatedFilePath-CDpEprKa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/_index-BRx8ZGZo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-4S4yPfFw.js +27 -0
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +17 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.agent-transcripts-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.health-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.labs-unlock-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.memory-profile-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.restart-server-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.save-fixture-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/book-open-D4IPYH_y.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-CG65viiV.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/chunk-JZWAC4HX-DB3aFuEO.js +51 -0
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-igfMr5DY.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/copy-Coc4o_8c.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-D1zB-pYc.js +21 -0
- package/codeyam-cli/src/webserver/build/client/assets/{cy-logo-cli-C1gnJVOL.svg → cy-logo-cli-CCKUIm0S.svg} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/cy-logo-cli-DcX-ZS3p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-JTAjQ54M.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-CYqBrC9s.js → entity._sha._-B0h9AqE6.js} +22 -15
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-CtYowLOt.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-PePWg17F.js +5 -0
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-I-Wo99C_.js +29 -0
- package/codeyam-cli/src/webserver/build/client/assets/executionFlowCoverage-BWhdfn70.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-9sMMAiWJ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/files-Co65J0s3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/git-BdHOxVfg.js +15 -0
- package/codeyam-cli/src/webserver/build/client/assets/globals-CCgBKWy4.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-fmIEn3Bc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-CUM5iXwc.js +9 -0
- package/codeyam-cli/src/webserver/build/client/assets/index-_417gcQW.js +3 -0
- package/codeyam-cli/src/webserver/build/client/assets/labs-BK0C1H1T.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-TzRHMVog.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/manifest-390cb8fa.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CzZySbBE.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-hjzB7t2z.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/preload-helper-ckwbz45p.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-DnbDhvTU.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/scenarioStatus-B_8jpV3e.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/search-DcAwD_Ln.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/simulations-DVNJVQgD.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/terminal-DbEAHMbA.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-CAD5b1o_.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/useCustomSizes-BqgrAzs3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-Blr5oZDE.js → useLastLogLine-DAFqfEDH.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-DZlYx2c4.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-Bbf4Hokd.js → useToast-ihdMtlf6.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-CXfuiwt3.js +1 -0
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BSvme_Ao.js +259 -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/src/webserver/devServer.js +1 -3
- package/codeyam-cli/src/webserver/devServer.js.map +1 -1
- package/codeyam-cli/src/webserver/server.js +35 -25
- package/codeyam-cli/src/webserver/server.js.map +1 -1
- package/codeyam-cli/templates/{codeyam-debug-skill.md → codeyam-debug.md} +48 -4
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +199 -0
- package/codeyam-cli/templates/codeyam-memory.md +396 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam-setup-skill.md → codeyam-setup.md} +151 -4
- package/codeyam-cli/templates/{codeyam-sim-skill.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam-test-skill.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam-verify-skill.md → codeyam-verify.md} +1 -1
- package/codeyam-cli/templates/rule-notification-hook.py +56 -0
- package/codeyam-cli/templates/rule-reflection-hook.py +627 -0
- package/codeyam-cli/templates/rules-instructions.md +132 -0
- package/package.json +25 -22
- package/packages/ai/index.js +8 -6
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +181 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js +150 -0
- package/packages/ai/src/lib/astScopes/arrayDerivationDetector.js.map +1 -0
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +154 -9
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js.map +1 -1
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js +435 -0
- package/packages/ai/src/lib/astScopes/conditionalEffectsExtractor.js.map +1 -0
- package/packages/ai/src/lib/astScopes/methodSemantics.js +138 -23
- package/packages/ai/src/lib/astScopes/methodSemantics.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js +10 -14
- package/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js +8 -0
- package/packages/ai/src/lib/astScopes/patterns/ifStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js +23 -0
- package/packages/ai/src/lib/astScopes/patterns/switchStatementHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js +138 -1
- package/packages/ai/src/lib/astScopes/patterns/variableDeclarationHandler.js.map +1 -1
- package/packages/ai/src/lib/astScopes/processExpression.js +1235 -104
- package/packages/ai/src/lib/astScopes/processExpression.js.map +1 -1
- package/packages/ai/src/lib/astScopes/sharedPatterns.js +25 -0
- package/packages/ai/src/lib/astScopes/sharedPatterns.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/completionCall.js +178 -31
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js +1961 -224
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +19 -4
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js +661 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/MuiManager.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js +180 -56
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/ReactFrameworkManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js +13 -3
- package/packages/ai/src/lib/dataStructure/helpers/BatchSchemaProcessor.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js +6 -4
- package/packages/ai/src/lib/dataStructure/helpers/ScopeTreeManager.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js +66 -2
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +139 -13
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js +63 -0
- package/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js +142 -12
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.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/dataStructure/helpers/convertTypeAnnotationsToValues.js +173 -0
- package/packages/ai/src/lib/dataStructure/helpers/convertTypeAnnotationsToValues.js.map +1 -0
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js +37 -20
- package/packages/ai/src/lib/dataStructure/helpers/deduplicateFunctionSchemas.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js +371 -73
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js +107 -0
- package/packages/ai/src/lib/dataStructure/helpers/fixNullIdsBySchema.js.map +1 -0
- package/packages/ai/src/lib/dataStructureChunking.js +130 -0
- package/packages/ai/src/lib/dataStructureChunking.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/e2eDataTracking.js +241 -0
- package/packages/ai/src/lib/e2eDataTracking.js.map +1 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js +96 -0
- package/packages/ai/src/lib/extractCriticalDataKeys.js.map +1 -0
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js +62 -5
- package/packages/ai/src/lib/generateChangesEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateChangesEntityScenarios.js +81 -90
- package/packages/ai/src/lib/generateChangesEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +50 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +1127 -91
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +193 -83
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +495 -0
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js +380 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +1807 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js +194 -0
- package/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.js.map +1 -0
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js +84 -14
- package/packages/ai/src/lib/getConditionalUsagesFromCode.js.map +1 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js +2 -1
- package/packages/ai/src/lib/guessScenarioDataFromDescription.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +270 -7
- package/packages/ai/src/lib/isolateScopes.js.map +1 -1
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js +5 -0
- package/packages/ai/src/lib/mergeJsonTypeDefinitions.js.map +1 -1
- package/packages/ai/src/lib/mergeStatements.js +88 -46
- package/packages/ai/src/lib/mergeStatements.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js +97 -0
- package/packages/ai/src/lib/promptGenerators/collapseNullableObjects.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js +16 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js +21 -64
- package/packages/ai/src/lib/promptGenerators/generateChangesEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js +54 -0
- package/packages/ai/src/lib/promptGenerators/generateChunkPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +83 -6
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js +10 -34
- package/packages/ai/src/lib/promptGenerators/generateEntityScenariosGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js +45 -0
- package/packages/ai/src/lib/promptGenerators/generateMissingKeysPrompt.js.map +1 -0
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js +16 -3
- package/packages/ai/src/lib/promptGenerators/guessNewScenarioDataFromDescriptionGenerator.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js +335 -0
- package/packages/ai/src/lib/promptGenerators/simplifyKeysForLLM.js.map +1 -0
- package/packages/ai/src/lib/resolvePathToControllable.js +677 -0
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -0
- package/packages/ai/src/lib/splitOutsideParentheses.js +3 -1
- package/packages/ai/src/lib/splitOutsideParentheses.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.js +29 -0
- package/packages/ai/src/lib/worker/SerializableDataStructure.js.map +1 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js +98 -1
- package/packages/ai/src/lib/worker/analyzeScopeWorker.js.map +1 -1
- package/packages/analyze/index.js +1 -0
- package/packages/analyze/index.js.map +1 -1
- package/packages/analyze/src/lib/FileAnalyzer.js +75 -36
- package/packages/analyze/src/lib/FileAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/ProjectAnalyzer.js +96 -26
- package/packages/analyze/src/lib/ProjectAnalyzer.js.map +1 -1
- package/packages/analyze/src/lib/analysisContext.js +30 -5
- package/packages/analyze/src/lib/analysisContext.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/asts/sourceFiles/getAllDeclaredEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllDeclaredEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js +14 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllEntityNodes.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getAllExports.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js +6 -0
- package/packages/analyze/src/lib/asts/sourceFiles/getImportsAnalysis.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js +39 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getResolvedModule.js.map +1 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js +2 -1
- package/packages/analyze/src/lib/asts/sourceFiles/getSourceFilesForAllImports.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js +428 -123
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +42 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.js +5 -0
- package/packages/analyze/src/lib/files/analyze/dependencyResolver.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/analyze/gatherEntityMap.js +2 -1
- package/packages/analyze/src/lib/files/analyze/gatherEntityMap.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js +31 -10
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeChange.js +21 -11
- package/packages/analyze/src/lib/files/analyzeChange.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeEntity.js +9 -8
- package/packages/analyze/src/lib/files/analyzeEntity.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeInitial.js +9 -10
- package/packages/analyze/src/lib/files/analyzeInitial.js.map +1 -1
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js +3 -2
- package/packages/analyze/src/lib/files/analyzeRemixRoute.js.map +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js +1 -1
- package/packages/analyze/src/lib/files/enums/steps.js.map +1 -1
- package/packages/analyze/src/lib/files/getImportedExports.js +17 -8
- package/packages/analyze/src/lib/files/getImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js +880 -0
- package/packages/analyze/src/lib/files/scenarios/TransformationTracer.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js +255 -0
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -0
- 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 +550 -62
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js +29 -34
- package/packages/analyze/src/lib/files/scenarios/generateChangesScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +404 -85
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +144 -0
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -0
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js +56 -69
- package/packages/analyze/src/lib/files/scenarios/generateScenarioData.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js +4 -8
- package/packages/analyze/src/lib/files/scenarios/generateScenarios.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +875 -141
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js +46 -9
- package/packages/analyze/src/lib/files/scenarios/mergeValidatedDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/setImportedExports.js +2 -1
- package/packages/analyze/src/lib/files/setImportedExports.js.map +1 -1
- package/packages/analyze/src/lib/index.js +1 -0
- package/packages/analyze/src/lib/index.js.map +1 -1
- package/packages/analyze/src/lib/utils/getFileByPath.js +12 -0
- package/packages/analyze/src/lib/utils/getFileByPath.js.map +1 -0
- 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/database/src/lib/analysisBranchToDb.js +1 -1
- package/packages/database/src/lib/analysisBranchToDb.js.map +1 -1
- package/packages/database/src/lib/analysisToDb.js +1 -1
- package/packages/database/src/lib/analysisToDb.js.map +1 -1
- package/packages/database/src/lib/branchToDb.js +1 -1
- package/packages/database/src/lib/branchToDb.js.map +1 -1
- package/packages/database/src/lib/commitBranchToDb.js +1 -1
- package/packages/database/src/lib/commitBranchToDb.js.map +1 -1
- package/packages/database/src/lib/commitToDb.js +1 -1
- package/packages/database/src/lib/commitToDb.js.map +1 -1
- package/packages/database/src/lib/fileToDb.js +1 -1
- package/packages/database/src/lib/fileToDb.js.map +1 -1
- package/packages/database/src/lib/kysely/db.js +13 -3
- package/packages/database/src/lib/kysely/db.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/commitsTable.js +3 -0
- package/packages/database/src/lib/kysely/tables/commitsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js +9 -3
- package/packages/database/src/lib/kysely/tables/debugReportsTable.js.map +1 -1
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js +35 -0
- package/packages/database/src/lib/kysely/tables/labsRequestsTable.js.map +1 -0
- package/packages/database/src/lib/loadAnalyses.js +45 -2
- package/packages/database/src/lib/loadAnalyses.js.map +1 -1
- package/packages/database/src/lib/loadAnalysis.js +8 -0
- package/packages/database/src/lib/loadAnalysis.js.map +1 -1
- package/packages/database/src/lib/loadBranch.js +11 -1
- package/packages/database/src/lib/loadBranch.js.map +1 -1
- package/packages/database/src/lib/loadCommit.js +7 -0
- package/packages/database/src/lib/loadCommit.js.map +1 -1
- package/packages/database/src/lib/loadCommits.js +22 -1
- package/packages/database/src/lib/loadCommits.js.map +1 -1
- package/packages/database/src/lib/loadEntities.js +23 -4
- package/packages/database/src/lib/loadEntities.js.map +1 -1
- package/packages/database/src/lib/loadEntityBranches.js +9 -0
- package/packages/database/src/lib/loadEntityBranches.js.map +1 -1
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js +23 -5
- package/packages/database/src/lib/loadReadyToBeCapturedAnalyses.js.map +1 -1
- package/packages/database/src/lib/projectToDb.js +1 -1
- package/packages/database/src/lib/projectToDb.js.map +1 -1
- package/packages/database/src/lib/saveFiles.js +1 -1
- package/packages/database/src/lib/saveFiles.js.map +1 -1
- package/packages/database/src/lib/scenarioToDb.js +1 -1
- package/packages/database/src/lib/scenarioToDb.js.map +1 -1
- package/packages/database/src/lib/updateCommitMetadata.js +5 -4
- package/packages/database/src/lib/updateCommitMetadata.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/componentScenarioPage/getIFrameMessageListenerCode.js +8 -4
- package/packages/generate/src/lib/componentScenarioPage/getIFrameMessageListenerCode.js.map +1 -1
- package/packages/generate/src/lib/deepMerge.js +27 -1
- package/packages/generate/src/lib/deepMerge.js.map +1 -1
- package/packages/generate/src/lib/directExecutionScript.js +10 -1
- package/packages/generate/src/lib/directExecutionScript.js.map +1 -1
- package/packages/generate/src/lib/getComponentScenarioPath.js +7 -3
- package/packages/generate/src/lib/getComponentScenarioPath.js.map +1 -1
- 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/packages/types/index.js.map +1 -1
- package/packages/utils/src/lib/applyUniversalMocks.js +26 -2
- package/packages/utils/src/lib/applyUniversalMocks.js.map +1 -1
- package/packages/utils/src/lib/fs/rsyncCopy.js +93 -2
- package/packages/utils/src/lib/fs/rsyncCopy.js.map +1 -1
- package/packages/utils/src/lib/lightweightEntityExtractor.js +25 -0
- package/packages/utils/src/lib/lightweightEntityExtractor.js.map +1 -1
- package/packages/utils/src/lib/safeFileName.js +29 -3
- package/packages/utils/src/lib/safeFileName.js.map +1 -1
- package/scripts/finalize-analyzer.cjs +8 -74
- package/analyzer-template/packages/ai/src/lib/findMatchingAttribute.ts +0 -102
- package/analyzer-template/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.ts +0 -197
- package/analyzer-template/packages/ai/src/lib/generateChangesEntityKeyAttributes.ts +0 -271
- package/analyzer-template/packages/ai/src/lib/generateEntityKeyAttributes.ts +0 -294
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.ts +0 -67
- package/analyzer-template/packages/ai/src/lib/transformMockDataToMatchSchema.ts +0 -156
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.ts +0 -115
- 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/src/webserver/build/client/assets/EntityItem-D4htqD-x.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/EntityTypeIcon-Catz6XEN.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/InteractivePreview-TlHocYno.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/LibraryFunctionPreview-CVMmGuIc.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/LogViewer-JkfQ-VaI.js +0 -3
- package/codeyam-cli/src/webserver/build/client/assets/ReportIssueModal-CVZ0H4BL.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/SafeScreenshot-BrMAP1nP.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/ScenarioViewer-CJhE4cCv.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/_index-faVIcr_i.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/activity.(_tab)-CLMa2sgx.js +0 -7
- package/codeyam-cli/src/webserver/build/client/assets/chevron-down-DwYjrK_h.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/chunk-WWGJGFF6-CgXbbZRx.js +0 -26
- package/codeyam-cli/src/webserver/build/client/assets/circle-check-B2oHQ-zo.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/createLucideIcon-BBYuR56H.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/dev.empty-CT0Q5lVu.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.create-scenario-Bj5GHkhb.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/entity._sha_.edit._scenarioId-eW5z9AyZ.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/entry.client-B9tSboXM.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/fileTableUtils-CmO-EZAB.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/files-DLinnTOx.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/git-CIxwBQvb.js +0 -12
- package/codeyam-cli/src/webserver/build/client/assets/globals-xPz593l2.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/html2canvas-pro.esm-XQCGvadH.js +0 -5
- package/codeyam-cli/src/webserver/build/client/assets/index-_LjBsTxX.js +0 -8
- package/codeyam-cli/src/webserver/build/client/assets/loader-circle-D_EGChhq.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-ca438c41.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/root-CHHYHuzL.js +0 -16
- package/codeyam-cli/src/webserver/build/client/assets/search-DY8yoDpH.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/server-build-CMKNK2uU.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BT6wVHd5.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/simulations-gv3H7JV7.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/triangle-alert-BthANBVv.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/useReportContext-CANr3QJ5.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/index-BtBPtyHx.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-N2cTnejq.js +0 -166
- package/codeyam-cli/templates/debug-command.md +0 -141
- package/packages/ai/src/lib/findMatchingAttribute.js +0 -77
- package/packages/ai/src/lib/findMatchingAttribute.js.map +0 -1
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js +0 -136
- package/packages/ai/src/lib/gatherRelevantDependentKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js +0 -220
- package/packages/ai/src/lib/generateChangesEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/generateEntityKeyAttributes.js +0 -241
- package/packages/ai/src/lib/generateEntityKeyAttributes.js.map +0 -1
- package/packages/ai/src/lib/isFrontend.js +0 -5
- package/packages/ai/src/lib/isFrontend.js.map +0 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js +0 -40
- package/packages/ai/src/lib/promptGenerators/generateEntityKeyAttributesGenerator.js.map +0 -1
- package/packages/ai/src/lib/transformMockDataToMatchSchema.js +0 -124
- package/packages/ai/src/lib/transformMockDataToMatchSchema.js.map +0 -1
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js +0 -72
- package/packages/analyze/src/lib/files/scenarios/generateKeyAttributes.js.map +0 -1
- /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/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-CMKNK2uU.css → styles-CMKNK2uU.css} +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
|
@@ -82,21 +82,36 @@
|
|
|
82
82
|
import { ScopeAnalysis } from '~codeyam/types';
|
|
83
83
|
import { EquivalencyManager } from './equivalencyManagers/EquivalencyManager';
|
|
84
84
|
import fillInSchemaGapsAndUnknowns from './helpers/fillInSchemaGapsAndUnknowns';
|
|
85
|
+
import { clearCleanKnownObjectFunctionsCache } from './helpers/cleanKnownObjectFunctions';
|
|
86
|
+
import { clearCleanNonObjectFunctionsCache } from './helpers/cleanNonObjectFunctions';
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Patterns that indicate recursive type structures in schema paths.
|
|
90
|
+
* Used by hasExcessivePatternRepetition() to detect exponential path blowup.
|
|
91
|
+
*/
|
|
92
|
+
const RECURSIVE_PATH_PATTERNS = [
|
|
93
|
+
/\.attributes\.properties\[\]/g, // TypeScript AST JSX nodes
|
|
94
|
+
/\.children\[\]/g, // Tree structures
|
|
95
|
+
/\.elements\[\]/g, // Array-like structures
|
|
96
|
+
/\.members\[\]/g, // Class/interface members
|
|
97
|
+
/\.properties\[\]/g, // Object properties
|
|
98
|
+
/\.items\[\]/g, // Generic items arrays
|
|
99
|
+
];
|
|
85
100
|
import ensureSchemaConsistency from './helpers/ensureSchemaConsistency';
|
|
86
101
|
import cleanPath from './helpers/cleanPath';
|
|
87
102
|
import { PathManager } from './helpers/PathManager';
|
|
88
103
|
import {
|
|
89
104
|
uniqueId,
|
|
90
|
-
uniqueScopeVariables,
|
|
91
105
|
uniqueScopeAndPaths,
|
|
106
|
+
uniqueScopeVariables,
|
|
92
107
|
} from './helpers/uniqueIdUtils';
|
|
93
108
|
import selectBestValue from './helpers/selectBestValue';
|
|
94
109
|
import { VisitedTracker } from './helpers/VisitedTracker';
|
|
95
110
|
import { DebugTracer } from './helpers/DebugTracer';
|
|
96
111
|
import { BatchSchemaProcessor } from './helpers/BatchSchemaProcessor';
|
|
97
112
|
import {
|
|
98
|
-
ScopeTreeManager,
|
|
99
113
|
ROOT_SCOPE_NAME,
|
|
114
|
+
ScopeTreeManager,
|
|
100
115
|
ScopeTreeNode,
|
|
101
116
|
} from './helpers/ScopeTreeManager';
|
|
102
117
|
import cleanScopeNodeName from './helpers/cleanScopeNodeName';
|
|
@@ -108,6 +123,7 @@ import type {
|
|
|
108
123
|
SerializableFunctionCallInfo,
|
|
109
124
|
SerializableFunctionResult,
|
|
110
125
|
SerializableScopeVariable,
|
|
126
|
+
EnrichedConditionalUsage,
|
|
111
127
|
} from '../worker/SerializableDataStructure';
|
|
112
128
|
|
|
113
129
|
/**
|
|
@@ -125,6 +141,21 @@ export interface ScopeInfo {
|
|
|
125
141
|
isStatic?: boolean;
|
|
126
142
|
isClassScope?: boolean;
|
|
127
143
|
analysis?: any;
|
|
144
|
+
/** For JSX child scopes, the original JSX tag name (e.g., 'ChildViewer') */
|
|
145
|
+
jsxTagName?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Gating conditions detected during JSX extraction (before JSX is simplified).
|
|
148
|
+
* Maps child component name to conditions that must be true for it to render.
|
|
149
|
+
* This is populated by processJSXForScope in isolateScopes.ts.
|
|
150
|
+
*/
|
|
151
|
+
extractedGatingConditions?: {
|
|
152
|
+
[childComponentName: string]: Array<{
|
|
153
|
+
path: string;
|
|
154
|
+
conditionType: 'truthiness' | 'comparison';
|
|
155
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
156
|
+
isNegated?: boolean;
|
|
157
|
+
}>;
|
|
158
|
+
};
|
|
128
159
|
}
|
|
129
160
|
|
|
130
161
|
/**
|
|
@@ -221,6 +252,22 @@ export interface FunctionCallInfo {
|
|
|
221
252
|
* For example: { "db.select(query1)": "result1", "db.select(query2)": "result2" }
|
|
222
253
|
*/
|
|
223
254
|
callSignatureToVariable?: Record<string, string>;
|
|
255
|
+
/**
|
|
256
|
+
* Stores individual schemas per call signature BEFORE merging.
|
|
257
|
+
* When multiple calls to the same function are merged into one FunctionCallInfo,
|
|
258
|
+
* this preserves each call's distinct schema.
|
|
259
|
+
* Key is the call signature (e.g., "useFetcher()").
|
|
260
|
+
* Used internally; converted to perVariableSchemas in toSerializable().
|
|
261
|
+
*/
|
|
262
|
+
perCallSignatureSchemas?: Record<string, Record<string, string>>;
|
|
263
|
+
/**
|
|
264
|
+
* Stores individual return value schemas per receiving variable, BEFORE merging.
|
|
265
|
+
* When multiple calls to the same function have different return types
|
|
266
|
+
* (e.g., useFetcher<UserData>() vs useFetcher<ReportData>()), this preserves
|
|
267
|
+
* each call's distinct schema for mock data generation.
|
|
268
|
+
* Key is the receiving variable name (e.g., "userFetcher", "reportFetcher").
|
|
269
|
+
*/
|
|
270
|
+
perVariableSchemas?: Record<string, Record<string, string>>;
|
|
224
271
|
}
|
|
225
272
|
|
|
226
273
|
/**
|
|
@@ -287,6 +334,19 @@ export function resetScopeDataStructureMetrics() {
|
|
|
287
334
|
followEquivalenciesEarlyExitPhase1Count = 0;
|
|
288
335
|
followEquivalenciesWithWorkCount = 0;
|
|
289
336
|
addEquivalencyCallCount = 0;
|
|
337
|
+
|
|
338
|
+
// Clear module-level caches to prevent unbounded memory growth across entities
|
|
339
|
+
const knownObjectCache = clearCleanKnownObjectFunctionsCache();
|
|
340
|
+
const nonObjectCache = clearCleanNonObjectFunctionsCache();
|
|
341
|
+
if (knownObjectCache.count > 0 || nonObjectCache.count > 0) {
|
|
342
|
+
const totalBytes =
|
|
343
|
+
knownObjectCache.estimatedBytes + nonObjectCache.estimatedBytes;
|
|
344
|
+
console.log('CodeYam: Cleared analysis caches', {
|
|
345
|
+
knownObjectCache: `${knownObjectCache.count} entries, ${(knownObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
346
|
+
nonObjectCache: `${nonObjectCache.count} entries, ${(nonObjectCache.estimatedBytes / 1024).toFixed(1)}KB`,
|
|
347
|
+
totalKB: `${(totalBytes / 1024).toFixed(1)}KB`,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
290
350
|
}
|
|
291
351
|
|
|
292
352
|
// Performance: Pre-computed Sets for equivalency reason filtering (O(1) vs O(n))
|
|
@@ -320,6 +380,10 @@ const ALLOWED_EQUIVALENCY_REASONS = new Set([
|
|
|
320
380
|
'propagated function call return sub-property equivalency',
|
|
321
381
|
'propagated parent-variable equivalency', // Added: propagate child scope equivalencies to parent scope when variable is defined in parent
|
|
322
382
|
'where was this function called from', // Added: tracks which scope called an external function
|
|
383
|
+
'MUI DataGrid renderCell params.row equivalency', // Added: links DataGrid renderCell params.row to rows array elements
|
|
384
|
+
'MUI Autocomplete getOptionLabel option equivalency', // Added: links Autocomplete getOptionLabel callback param to options array
|
|
385
|
+
'MUI Autocomplete renderOption option equivalency', // Added: links Autocomplete renderOption callback param to options array
|
|
386
|
+
'MUI Autocomplete option property equivalency', // Added: propagates property accesses from Autocomplete callbacks
|
|
323
387
|
]);
|
|
324
388
|
|
|
325
389
|
const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
@@ -333,6 +397,7 @@ const SILENTLY_IGNORED_EQUIVALENCY_REASONS = new Set([
|
|
|
333
397
|
'transformed non-object function equivalency - implicit parent equivalency - rerouted via useCallback',
|
|
334
398
|
'transformed non-object function equivalency - Array.from() equivalency',
|
|
335
399
|
'Spread operator equivalency key update: Explicit array deconstruction equivalency value',
|
|
400
|
+
// 'transformed non-object function equivalency - Explicit array deconstruction equivalency value',
|
|
336
401
|
]);
|
|
337
402
|
|
|
338
403
|
export class ScopeDataStructure {
|
|
@@ -360,10 +425,40 @@ export class ScopeDataStructure {
|
|
|
360
425
|
path: string;
|
|
361
426
|
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
362
427
|
comparedValues?: string[];
|
|
363
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
428
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
364
429
|
}>
|
|
365
430
|
> = {};
|
|
366
431
|
|
|
432
|
+
/**
|
|
433
|
+
* Conditional effects collected during AST analysis.
|
|
434
|
+
* Tracks what setter calls happen inside conditionals (if, switch, ternary).
|
|
435
|
+
*/
|
|
436
|
+
private rawConditionalEffects: import('../astScopes/types').ConditionalEffect[] =
|
|
437
|
+
[];
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Compound conditionals collected during AST analysis.
|
|
441
|
+
* Groups conditions that must all be true together (e.g., a && b && c).
|
|
442
|
+
*/
|
|
443
|
+
private rawCompoundConditionals: import('../astScopes/types').CompoundConditional[] =
|
|
444
|
+
[];
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Gating conditions for child component boundaries.
|
|
448
|
+
* Maps child component name to the conditions that must be true for it to render.
|
|
449
|
+
*/
|
|
450
|
+
private rawChildBoundaryGatingConditions: Record<
|
|
451
|
+
string,
|
|
452
|
+
import('../astScopes/types').ConditionalUsage[]
|
|
453
|
+
> = {};
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* JSX rendering usages collected during AST analysis.
|
|
457
|
+
* Tracks arrays rendered via .map() and strings interpolated in JSX.
|
|
458
|
+
*/
|
|
459
|
+
private rawJsxRenderingUsages: import('../astScopes/types').JsxRenderingUsage[] =
|
|
460
|
+
[];
|
|
461
|
+
|
|
367
462
|
private lastAddToSchemaId = 0;
|
|
368
463
|
private lastEquivalencyId = 0;
|
|
369
464
|
private lastEquivalencyDatabaseId = 0;
|
|
@@ -382,6 +477,10 @@ export class ScopeDataStructure {
|
|
|
382
477
|
private externalFunctionCallsIndex: Map<string, FunctionCallInfo> | null =
|
|
383
478
|
null;
|
|
384
479
|
|
|
480
|
+
// Tracks internal functions that have been filtered out during captureCompleteSchema
|
|
481
|
+
// Prevents re-adding them via subsequent equivalency propagation (e.g., from getReturnValue)
|
|
482
|
+
private filteredInternalFunctions: Set<string> = new Set();
|
|
483
|
+
|
|
385
484
|
// Debug tracer for selective path/scope tracing
|
|
386
485
|
// Enable via: CODEYAM_DEBUG=true CODEYAM_DEBUG_PATHS="user.*,signature" npm test
|
|
387
486
|
private tracer: DebugTracer = new DebugTracer({
|
|
@@ -540,6 +639,8 @@ export class ScopeDataStructure {
|
|
|
540
639
|
const efcName = this.pathManager.stripGenerics(efc.name);
|
|
541
640
|
for (const manager of this.equivalencyManagers) {
|
|
542
641
|
if (manager.internalFunctions.has(efcName)) {
|
|
642
|
+
// Track this so we don't re-add it via subsequent finalize calls
|
|
643
|
+
this.filteredInternalFunctions.add(efcName);
|
|
543
644
|
return false;
|
|
544
645
|
}
|
|
545
646
|
}
|
|
@@ -567,13 +668,51 @@ export class ScopeDataStructure {
|
|
|
567
668
|
const baseName = this.pathManager.stripGenerics(
|
|
568
669
|
candidate.scopeNodeName,
|
|
569
670
|
);
|
|
671
|
+
// Check if this is a local variable path (doesn't contain function call pattern)
|
|
672
|
+
// Local variables like "surveys[]" or "items[]" are important for tracing data flow
|
|
673
|
+
// from parent to child components (e.g., surveys[] -> SurveyCard().signature[0].survey)
|
|
674
|
+
const isLocalVariablePath =
|
|
675
|
+
!candidate.schemaPath.includes('()') &&
|
|
676
|
+
!candidate.schemaPath.startsWith('signature[') &&
|
|
677
|
+
!candidate.schemaPath.startsWith('returnValue');
|
|
678
|
+
|
|
570
679
|
return (
|
|
571
680
|
validExternalFacingScopeNames.has(baseName) &&
|
|
572
681
|
(candidate.schemaPath.startsWith('signature[') ||
|
|
573
|
-
candidate.schemaPath.startsWith(baseName)
|
|
682
|
+
candidate.schemaPath.startsWith(baseName) ||
|
|
683
|
+
isLocalVariablePath) &&
|
|
574
684
|
!containsArrayMethod(candidate.schemaPath)
|
|
575
685
|
);
|
|
576
686
|
});
|
|
687
|
+
|
|
688
|
+
// If all sourceCandidates were filtered out (e.g., because they belonged to
|
|
689
|
+
// internal functions like useState), look for the highest-order intermediate
|
|
690
|
+
// that belongs to a valid external-facing scope
|
|
691
|
+
if (
|
|
692
|
+
entry.sourceCandidates.length === 0 &&
|
|
693
|
+
Object.keys(entry.intermediatesOrder).length > 0
|
|
694
|
+
) {
|
|
695
|
+
// Find intermediates that belong to valid external-facing scopes
|
|
696
|
+
const validIntermediates = Object.entries(entry.intermediatesOrder)
|
|
697
|
+
.filter(([pathId]) => {
|
|
698
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
699
|
+
if (!scopeNodeName || !schemaPath) return false;
|
|
700
|
+
const baseName = this.pathManager.stripGenerics(scopeNodeName);
|
|
701
|
+
return (
|
|
702
|
+
validExternalFacingScopeNames.has(baseName) &&
|
|
703
|
+
!containsArrayMethod(schemaPath)
|
|
704
|
+
);
|
|
705
|
+
})
|
|
706
|
+
.sort((a, b) => b[1] - a[1]); // Sort by order descending (highest first)
|
|
707
|
+
|
|
708
|
+
if (validIntermediates.length > 0) {
|
|
709
|
+
const [pathId] = validIntermediates[0];
|
|
710
|
+
const [scopeNodeName, schemaPath] = pathId.split('::');
|
|
711
|
+
if (scopeNodeName && schemaPath) {
|
|
712
|
+
entry.sourceCandidates.push({ scopeNodeName, schemaPath });
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
577
716
|
}
|
|
578
717
|
|
|
579
718
|
this.propagateSourceAndUsageEquivalencies(
|
|
@@ -661,6 +800,11 @@ export class ScopeDataStructure {
|
|
|
661
800
|
return;
|
|
662
801
|
}
|
|
663
802
|
|
|
803
|
+
// PERF: Early exit for paths with repeated function-call signature patterns
|
|
804
|
+
if (this.hasExcessivePatternRepetition(path)) {
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
|
|
664
808
|
// Update chain metadata for database tracking
|
|
665
809
|
if (equivalencyValueChain.length > 0) {
|
|
666
810
|
equivalencyValueChain[equivalencyValueChain.length - 1].addToSchemaId =
|
|
@@ -904,8 +1048,8 @@ export class ScopeDataStructure {
|
|
|
904
1048
|
equivalencyValueChain?: EquivalencyValueChainItem[],
|
|
905
1049
|
traceId?: number,
|
|
906
1050
|
) {
|
|
907
|
-
// DEBUG: Detect infinite loops
|
|
908
1051
|
addEquivalencyCallCount++;
|
|
1052
|
+
|
|
909
1053
|
if (addEquivalencyCallCount > 50000) {
|
|
910
1054
|
console.error('INFINITE LOOP DETECTED in addEquivalency', {
|
|
911
1055
|
callCount: addEquivalencyCallCount,
|
|
@@ -965,12 +1109,35 @@ export class ScopeDataStructure {
|
|
|
965
1109
|
}
|
|
966
1110
|
|
|
967
1111
|
if (!equivalentScopeName) {
|
|
968
|
-
console.
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
1112
|
+
console.error(
|
|
1113
|
+
'CodeYam Error: Missing equivalent scope name - FULL CONTEXT:',
|
|
1114
|
+
JSON.stringify(
|
|
1115
|
+
{
|
|
1116
|
+
path,
|
|
1117
|
+
equivalentPath,
|
|
1118
|
+
equivalentScopeName,
|
|
1119
|
+
scopeNodeName: scopeNode.name,
|
|
1120
|
+
equivalencyReason,
|
|
1121
|
+
tree: scopeNode.tree,
|
|
1122
|
+
equivalencyValueChain: equivalencyValueChain?.map((ev) => ({
|
|
1123
|
+
id: ev.id,
|
|
1124
|
+
source: ev.source,
|
|
1125
|
+
reason: ev.reason,
|
|
1126
|
+
currentPath: ev.currentPath,
|
|
1127
|
+
previousPath: ev.previousPath,
|
|
1128
|
+
})),
|
|
1129
|
+
scopeNodeFunctionCalls: scopeNode.functionCalls?.map((fc) => ({
|
|
1130
|
+
name: fc.name,
|
|
1131
|
+
callSignature: fc.callSignature,
|
|
1132
|
+
callScope: fc.callScope,
|
|
1133
|
+
})),
|
|
1134
|
+
instantiatedVariables: scopeNode.instantiatedVariables,
|
|
1135
|
+
parentInstantiatedVariables: scopeNode.parentInstantiatedVariables,
|
|
1136
|
+
},
|
|
1137
|
+
null,
|
|
1138
|
+
2,
|
|
1139
|
+
),
|
|
1140
|
+
);
|
|
974
1141
|
throw new Error('CodeYam Error: Missing equivalent scope name');
|
|
975
1142
|
}
|
|
976
1143
|
|
|
@@ -1128,10 +1295,38 @@ export class ScopeDataStructure {
|
|
|
1128
1295
|
const existingFunctionCall =
|
|
1129
1296
|
this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1130
1297
|
if (existingFunctionCall) {
|
|
1131
|
-
|
|
1298
|
+
// Preserve per-call schemas BEFORE merging to enable per-variable mock data.
|
|
1299
|
+
// This is critical for hooks like useFetcher<UserData>() vs useFetcher<ReportData>()
|
|
1300
|
+
// where each call returns different typed data.
|
|
1301
|
+
if (!existingFunctionCall.perCallSignatureSchemas) {
|
|
1302
|
+
// First merge - save the existing call's schema
|
|
1303
|
+
existingFunctionCall.perCallSignatureSchemas = {
|
|
1304
|
+
[existingFunctionCall.callSignature]: {
|
|
1305
|
+
...existingFunctionCall.schema,
|
|
1306
|
+
},
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
// Save the new call's schema before it gets merged
|
|
1310
|
+
existingFunctionCall.perCallSignatureSchemas[
|
|
1311
|
+
functionCallInfo.callSignature
|
|
1312
|
+
] = { ...functionCallInfo.schema };
|
|
1313
|
+
|
|
1314
|
+
// Merge schemas using selectBestValue to preserve specific types like 'null'
|
|
1315
|
+
// over generic types like 'unknown'. This ensures ref variables detected
|
|
1316
|
+
// earlier (marked as 'null') aren't overwritten by later 'unknown' values.
|
|
1317
|
+
const mergedSchema: Record<string, string> = {
|
|
1132
1318
|
...existingFunctionCall.schema,
|
|
1133
|
-
...functionCallInfo.schema,
|
|
1134
1319
|
};
|
|
1320
|
+
for (const key in functionCallInfo.schema) {
|
|
1321
|
+
const existingValue = existingFunctionCall.schema[key];
|
|
1322
|
+
const newValue = functionCallInfo.schema[key];
|
|
1323
|
+
mergedSchema[key] = selectBestValue(
|
|
1324
|
+
existingValue,
|
|
1325
|
+
newValue,
|
|
1326
|
+
newValue,
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
existingFunctionCall.schema = mergedSchema;
|
|
1135
1330
|
|
|
1136
1331
|
existingFunctionCall.equivalencies = {
|
|
1137
1332
|
...existingFunctionCall.equivalencies,
|
|
@@ -1164,8 +1359,15 @@ export class ScopeDataStructure {
|
|
|
1164
1359
|
);
|
|
1165
1360
|
|
|
1166
1361
|
if (isExternal) {
|
|
1167
|
-
this
|
|
1168
|
-
|
|
1362
|
+
// Check if this function was already filtered out as an internal function
|
|
1363
|
+
// (e.g., useState was filtered in captureCompleteSchema but finalize is trying to re-add it)
|
|
1364
|
+
const strippedName = this.pathManager.stripGenerics(
|
|
1365
|
+
functionCallInfo.name,
|
|
1366
|
+
);
|
|
1367
|
+
if (!this.filteredInternalFunctions.has(strippedName)) {
|
|
1368
|
+
this.externalFunctionCalls.push(functionCallInfo);
|
|
1369
|
+
this.invalidateExternalFunctionCallsIndex();
|
|
1370
|
+
}
|
|
1169
1371
|
}
|
|
1170
1372
|
}
|
|
1171
1373
|
}
|
|
@@ -1273,11 +1475,32 @@ export class ScopeDataStructure {
|
|
|
1273
1475
|
const equivalentSchemaPath = equivalentSchemaPathMap.get(remainingKey);
|
|
1274
1476
|
|
|
1275
1477
|
if (equivalentSchemaPath) {
|
|
1478
|
+
// Skip propagation when there's a structural mismatch:
|
|
1479
|
+
// - schemaPath ends with [] (array element, represents an object)
|
|
1480
|
+
// - equivalentSchemaPath doesn't end with [] (non-array prop, usually a scalar)
|
|
1481
|
+
// This prevents incorrectly typing array elements as strings when they're
|
|
1482
|
+
// equivalent to scalar props like JSX keys (e.g., workouts[] ↔ Card().key)
|
|
1483
|
+
const schemaPathEndsWithArray = schemaPath.endsWith('[]');
|
|
1484
|
+
const equivalentEndsWithArray = equivalentSchemaPath.endsWith('[]');
|
|
1485
|
+
if (schemaPathEndsWithArray !== equivalentEndsWithArray) {
|
|
1486
|
+
// Don't propagate between array element paths and non-array paths
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1276
1490
|
const value1 = scopeNode.schema[schemaPath];
|
|
1277
1491
|
const value2 = equivalentScopeNode.schema[equivalentSchemaPath];
|
|
1278
1492
|
|
|
1279
1493
|
const bestValue = selectBestValue(value1, value2);
|
|
1280
1494
|
|
|
1495
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1496
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
1497
|
+
if (
|
|
1498
|
+
this.hasExcessivePatternRepetition(schemaPath) ||
|
|
1499
|
+
this.hasExcessivePatternRepetition(equivalentSchemaPath)
|
|
1500
|
+
) {
|
|
1501
|
+
continue;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1281
1504
|
scopeNode.schema[schemaPath] = bestValue;
|
|
1282
1505
|
equivalentScopeNode.schema[equivalentSchemaPath] = bestValue;
|
|
1283
1506
|
} else if (
|
|
@@ -1291,6 +1514,11 @@ export class ScopeDataStructure {
|
|
|
1291
1514
|
...remainingSchemaPathParts,
|
|
1292
1515
|
]);
|
|
1293
1516
|
|
|
1517
|
+
// PERF: Skip paths with repeated function-call signature patterns
|
|
1518
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
|
|
1294
1522
|
equivalentScopeNode.schema[newEquivalentPath] =
|
|
1295
1523
|
scopeNode.schema[schemaPath];
|
|
1296
1524
|
}
|
|
@@ -1381,6 +1609,77 @@ export class ScopeDataStructure {
|
|
|
1381
1609
|
return this.pathManager.isValidPath(path);
|
|
1382
1610
|
}
|
|
1383
1611
|
|
|
1612
|
+
/**
|
|
1613
|
+
* Detects if a path contains excessive repetition of the same pattern.
|
|
1614
|
+
*
|
|
1615
|
+
* This prevents exponential blowup when analyzing recursive type structures.
|
|
1616
|
+
* For example, TypeScript AST nodes have `.attributes.properties[]` where each
|
|
1617
|
+
* property is also a node with `.attributes.properties[]`. Without this check,
|
|
1618
|
+
* paths like `signature[0].attributes.properties[].attributes.properties[].attributes.properties[]...`
|
|
1619
|
+
* would be generated exponentially.
|
|
1620
|
+
*
|
|
1621
|
+
* Two detection strategies:
|
|
1622
|
+
* 1. Known patterns: Check RECURSIVE_PATH_PATTERNS for common recursive structures
|
|
1623
|
+
* 2. Generic detection: For longer paths, detect any 2-3 part segment that repeats
|
|
1624
|
+
*
|
|
1625
|
+
* @param path - The schema path to check
|
|
1626
|
+
* @param maxRepetitions - Maximum allowed repetitions of any pattern (default: 2)
|
|
1627
|
+
* @returns true if the path has excessive repetition
|
|
1628
|
+
*/
|
|
1629
|
+
private hasExcessivePatternRepetition(
|
|
1630
|
+
path: string,
|
|
1631
|
+
maxRepetitions = 2,
|
|
1632
|
+
): boolean {
|
|
1633
|
+
// Check known recursive patterns
|
|
1634
|
+
for (const pattern of RECURSIVE_PATH_PATTERNS) {
|
|
1635
|
+
const matches = path.match(pattern);
|
|
1636
|
+
if (matches && matches.length > maxRepetitions) {
|
|
1637
|
+
return true;
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
// Check for repeated function calls that indicate recursive type expansion.
|
|
1642
|
+
// E.g., localeCompare(b[])...localeCompare(b[]) means string.localeCompare
|
|
1643
|
+
// returns a type that again has localeCompare, causing infinite expansion.
|
|
1644
|
+
// We extract all function call patterns like "funcName(args)" and check if
|
|
1645
|
+
// the same normalized call appears more than once.
|
|
1646
|
+
const funcCallPattern = /(?:^|\.)[^.([]+\([^)]*\)/g;
|
|
1647
|
+
const funcCallMatches = path.match(funcCallPattern);
|
|
1648
|
+
if (funcCallMatches && funcCallMatches.length > 1) {
|
|
1649
|
+
const seen = new Set<string>();
|
|
1650
|
+
for (const match of funcCallMatches) {
|
|
1651
|
+
// Strip leading dot and normalize array indices
|
|
1652
|
+
const normalized = match.replace(/^\./, '').replace(/\[\d+\]/g, '[]');
|
|
1653
|
+
if (seen.has(normalized)) return true;
|
|
1654
|
+
seen.add(normalized);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
// For longer paths, detect any repeated multi-part segments we haven't explicitly listed
|
|
1659
|
+
const pathParts = this.splitPath(path);
|
|
1660
|
+
if (pathParts.length <= 6) {
|
|
1661
|
+
return false;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
// Check for repeated sequences of 2-3 consecutive parts
|
|
1665
|
+
for (let segmentLength = 2; segmentLength <= 3; segmentLength++) {
|
|
1666
|
+
const seen = new Map<string, number>();
|
|
1667
|
+
|
|
1668
|
+
for (let i = 0; i <= pathParts.length - segmentLength; i++) {
|
|
1669
|
+
const segment = pathParts.slice(i, i + segmentLength).join('.');
|
|
1670
|
+
const normalizedSegment = segment.replace(/\[\d+\]/g, '[]');
|
|
1671
|
+
const count = (seen.get(normalizedSegment) || 0) + 1;
|
|
1672
|
+
seen.set(normalizedSegment, count);
|
|
1673
|
+
|
|
1674
|
+
if (count > maxRepetitions) {
|
|
1675
|
+
return true;
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
return false;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1384
1683
|
private addToTree(pathParts: string[]) {
|
|
1385
1684
|
this.scopeTreeManager.addPath(pathParts);
|
|
1386
1685
|
}
|
|
@@ -1388,17 +1687,26 @@ export class ScopeDataStructure {
|
|
|
1388
1687
|
private setInstantiatedVariables(scopeNode: ScopeNode) {
|
|
1389
1688
|
let instantiatedVariables = scopeNode.analysis?.instantiatedVariables ?? [];
|
|
1390
1689
|
|
|
1391
|
-
for (const [path,
|
|
1690
|
+
for (const [path, rawEquivalentPath] of Object.entries(
|
|
1392
1691
|
scopeNode.analysis.isolatedEquivalentVariables ?? {},
|
|
1393
1692
|
)) {
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1693
|
+
// Normalize to array for consistent handling (supports both string and string[])
|
|
1694
|
+
const equivalentPaths = Array.isArray(rawEquivalentPath)
|
|
1695
|
+
? rawEquivalentPath
|
|
1696
|
+
: rawEquivalentPath
|
|
1697
|
+
? [rawEquivalentPath]
|
|
1698
|
+
: [];
|
|
1699
|
+
|
|
1700
|
+
for (const equivalentPath of equivalentPaths) {
|
|
1701
|
+
if (typeof equivalentPath !== 'string') {
|
|
1702
|
+
continue;
|
|
1703
|
+
}
|
|
1397
1704
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1705
|
+
if (equivalentPath.startsWith('signature[')) {
|
|
1706
|
+
const equivalentPathParts = this.splitPath(equivalentPath);
|
|
1707
|
+
instantiatedVariables.push(equivalentPathParts[0]);
|
|
1708
|
+
instantiatedVariables.push(path);
|
|
1709
|
+
}
|
|
1402
1710
|
}
|
|
1403
1711
|
|
|
1404
1712
|
const duplicateInstantiated = instantiatedVariables.find(
|
|
@@ -1411,9 +1719,14 @@ export class ScopeDataStructure {
|
|
|
1411
1719
|
}
|
|
1412
1720
|
}
|
|
1413
1721
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1722
|
+
const instantiatedSeen = new Set<string>();
|
|
1723
|
+
instantiatedVariables = instantiatedVariables.filter((varName) => {
|
|
1724
|
+
if (instantiatedSeen.has(varName)) {
|
|
1725
|
+
return false;
|
|
1726
|
+
}
|
|
1727
|
+
instantiatedSeen.add(varName);
|
|
1728
|
+
return true;
|
|
1729
|
+
});
|
|
1417
1730
|
|
|
1418
1731
|
scopeNode.instantiatedVariables = instantiatedVariables;
|
|
1419
1732
|
|
|
@@ -1434,13 +1747,19 @@ export class ScopeDataStructure {
|
|
|
1434
1747
|
...parentScopeNode.instantiatedVariables.filter(
|
|
1435
1748
|
(v) => !v.startsWith('signature[') && !v.startsWith('returnValue'),
|
|
1436
1749
|
),
|
|
1437
|
-
].filter(
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1750
|
+
].filter((varName) => !instantiatedSeen.has(varName));
|
|
1751
|
+
|
|
1752
|
+
const parentInstantiatedSeen = new Set<string>();
|
|
1753
|
+
const dedupedParentInstantiatedVariables =
|
|
1754
|
+
parentInstantiatedVariables.filter((varName) => {
|
|
1755
|
+
if (parentInstantiatedSeen.has(varName)) {
|
|
1756
|
+
return false;
|
|
1757
|
+
}
|
|
1758
|
+
parentInstantiatedSeen.add(varName);
|
|
1759
|
+
return true;
|
|
1760
|
+
});
|
|
1442
1761
|
|
|
1443
|
-
scopeNode.parentInstantiatedVariables =
|
|
1762
|
+
scopeNode.parentInstantiatedVariables = dedupedParentInstantiatedVariables;
|
|
1444
1763
|
}
|
|
1445
1764
|
|
|
1446
1765
|
private trackFunctionCalls(scopeNode: ScopeNode) {
|
|
@@ -1449,197 +1768,205 @@ export class ScopeDataStructure {
|
|
|
1449
1768
|
}
|
|
1450
1769
|
|
|
1451
1770
|
private determineEquivalenciesAndBuildSchema(scopeNode: ScopeNode) {
|
|
1771
|
+
if (!scopeNode.analysis) {
|
|
1772
|
+
return;
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1452
1775
|
const { isolatedStructure, isolatedEquivalentVariables } =
|
|
1453
1776
|
scopeNode.analysis;
|
|
1454
1777
|
|
|
1455
|
-
//
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
)
|
|
1460
|
-
) {
|
|
1461
|
-
console.log(
|
|
1462
|
-
'CodeYam DEBUG determineEquivalenciesAndBuildSchema:',
|
|
1463
|
-
JSON.stringify(
|
|
1464
|
-
{
|
|
1465
|
-
scopeNodeName: scopeNode.name,
|
|
1466
|
-
fetcherEquivalencies: Object.entries(
|
|
1467
|
-
isolatedEquivalentVariables || {},
|
|
1468
|
-
)
|
|
1469
|
-
.filter(
|
|
1470
|
-
([k, v]) =>
|
|
1471
|
-
k.includes('Fetcher') ||
|
|
1472
|
-
k.includes('fetcher') ||
|
|
1473
|
-
String(v).includes('Fetcher') ||
|
|
1474
|
-
String(v).includes('fetcher'),
|
|
1475
|
-
)
|
|
1476
|
-
.reduce(
|
|
1477
|
-
(acc, [k, v]) => {
|
|
1478
|
-
acc[k] = v;
|
|
1479
|
-
return acc;
|
|
1480
|
-
},
|
|
1481
|
-
{} as Record<string, string>,
|
|
1482
|
-
),
|
|
1483
|
-
},
|
|
1484
|
-
null,
|
|
1485
|
-
2,
|
|
1486
|
-
),
|
|
1487
|
-
);
|
|
1488
|
-
}
|
|
1778
|
+
// Flatten isolatedEquivalentVariables values for allPaths (handles both string and string[])
|
|
1779
|
+
const flattenedEquivValues = Object.values(
|
|
1780
|
+
isolatedEquivalentVariables || {},
|
|
1781
|
+
).flatMap((v) => (Array.isArray(v) ? v : [v]));
|
|
1489
1782
|
|
|
1490
1783
|
const allPaths = Array.from(
|
|
1491
1784
|
new Set([
|
|
1492
1785
|
...Object.keys(isolatedStructure || {}),
|
|
1493
1786
|
...Object.keys(isolatedEquivalentVariables || {}),
|
|
1494
|
-
...
|
|
1787
|
+
...flattenedEquivValues,
|
|
1495
1788
|
]),
|
|
1496
1789
|
);
|
|
1497
1790
|
|
|
1498
1791
|
for (let path in isolatedEquivalentVariables) {
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
)
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1792
|
+
const rawEquivalentValue = isolatedEquivalentVariables?.[path];
|
|
1793
|
+
// Normalize to array for consistent handling
|
|
1794
|
+
const equivalentValues = Array.isArray(rawEquivalentValue)
|
|
1795
|
+
? rawEquivalentValue
|
|
1796
|
+
: [rawEquivalentValue];
|
|
1797
|
+
|
|
1798
|
+
for (let equivalentValue of equivalentValues) {
|
|
1799
|
+
if (equivalentValue && this.isValidPath(equivalentValue)) {
|
|
1800
|
+
// IMPORTANT: DO NOT strip ::cyDuplicateKey:: markers from equivalencies.
|
|
1801
|
+
// These markers are critical for distinguishing variable reassignments.
|
|
1802
|
+
// For example, with:
|
|
1803
|
+
// let fetcher = useFetcher<ConfigData>();
|
|
1804
|
+
// const configData = fetcher.data?.data;
|
|
1805
|
+
// fetcher = useFetcher<SettingsData>();
|
|
1806
|
+
// const settingsData = fetcher.data?.data;
|
|
1807
|
+
//
|
|
1808
|
+
// mergeStatements creates:
|
|
1809
|
+
// fetcher → useFetcher<ConfigData>()...
|
|
1810
|
+
// fetcher::cyDuplicateKey1:: → useFetcher<SettingsData>()...
|
|
1811
|
+
// configData → fetcher.data.data
|
|
1812
|
+
// settingsData → fetcher::cyDuplicateKey1::.data.data
|
|
1813
|
+
//
|
|
1814
|
+
// If we strip ::cyDuplicateKey::, settingsData would incorrectly trace
|
|
1815
|
+
// to useFetcher<ConfigData>() instead of useFetcher<SettingsData>().
|
|
1816
|
+
path = cleanPath(path, allPaths);
|
|
1817
|
+
equivalentValue = cleanPath(equivalentValue, allPaths);
|
|
1818
|
+
|
|
1819
|
+
this.addEquivalency(
|
|
1820
|
+
path,
|
|
1821
|
+
equivalentValue,
|
|
1822
|
+
scopeNode.name,
|
|
1823
|
+
scopeNode,
|
|
1824
|
+
'original equivalency',
|
|
1825
|
+
);
|
|
1515
1826
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1827
|
+
// Propagate equivalencies involving parent-scope variables to those parent scopes.
|
|
1828
|
+
// This handles patterns like: collected.push({...entity}) where 'collected' is defined
|
|
1829
|
+
// in a parent scope. The equivalency collected[] -> push().signature[0] needs to be
|
|
1830
|
+
// visible when tracing from the parent scope.
|
|
1831
|
+
const rootVariable = this.extractRootVariable(path);
|
|
1832
|
+
const equivalentRootVariable =
|
|
1833
|
+
this.extractRootVariable(equivalentValue);
|
|
1834
|
+
|
|
1835
|
+
// Skip propagation for self-referential reassignment patterns like:
|
|
1836
|
+
// x = x.method().functionCallReturnValue
|
|
1837
|
+
// where the path IS the variable itself (not a sub-path like x[] or x.prop).
|
|
1838
|
+
// These create circular references since both sides reference the same variable.
|
|
1839
|
+
//
|
|
1840
|
+
// But DO propagate for patterns like collected[] -> collected.push(...).signature[0]
|
|
1841
|
+
// where the path has additional segments beyond the root variable.
|
|
1842
|
+
const pathIsJustRootVariable = path === rootVariable;
|
|
1843
|
+
const isSelfReferentialReassignment =
|
|
1844
|
+
pathIsJustRootVariable && rootVariable === equivalentRootVariable;
|
|
1534
1845
|
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1846
|
+
if (
|
|
1847
|
+
rootVariable &&
|
|
1848
|
+
!isSelfReferentialReassignment &&
|
|
1849
|
+
scopeNode.parentInstantiatedVariables?.includes(rootVariable)
|
|
1850
|
+
) {
|
|
1851
|
+
// Find the parent scope where this variable is defined
|
|
1852
|
+
for (const parentScopeName of scopeNode.tree || []) {
|
|
1853
|
+
const parentScope = this.scopeNodes[parentScopeName];
|
|
1854
|
+
if (parentScope?.instantiatedVariables?.includes(rootVariable)) {
|
|
1855
|
+
// Add the equivalency to the parent scope as well
|
|
1856
|
+
this.addEquivalency(
|
|
1857
|
+
path,
|
|
1858
|
+
equivalentValue,
|
|
1859
|
+
scopeNode.name, // The equivalent path's scope remains the child scope
|
|
1860
|
+
parentScope, // But store it in the parent scope's equivalencies
|
|
1861
|
+
'propagated parent-variable equivalency',
|
|
1862
|
+
);
|
|
1863
|
+
break;
|
|
1864
|
+
}
|
|
1553
1865
|
}
|
|
1554
1866
|
}
|
|
1555
|
-
}
|
|
1556
1867
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1589
|
-
|
|
1868
|
+
// Propagate sub-property equivalencies when the equivalentValue is a simple variable
|
|
1869
|
+
// that has sub-properties defined in the isolatedEquivalentVariables.
|
|
1870
|
+
// This handles cases like: dataItem={{ structure: completeDataStructure }}
|
|
1871
|
+
// where completeDataStructure has sub-properties like completeDataStructure['Function Arguments']
|
|
1872
|
+
// We need to propagate these to create: dataItem.structure['Function Arguments'] equivalencies
|
|
1873
|
+
const isSimpleVariable =
|
|
1874
|
+
!equivalentValue.startsWith('signature[') &&
|
|
1875
|
+
!equivalentValue.includes('functionCallReturnValue') &&
|
|
1876
|
+
!equivalentValue.includes('.') &&
|
|
1877
|
+
!equivalentValue.includes('[');
|
|
1878
|
+
|
|
1879
|
+
if (isSimpleVariable) {
|
|
1880
|
+
// Look in current scope and all parent scopes for sub-properties
|
|
1881
|
+
const scopesToCheck = [scopeNode.name, ...scopeNode.tree];
|
|
1882
|
+
for (const scopeName of scopesToCheck) {
|
|
1883
|
+
const checkScope = this.scopeNodes[scopeName];
|
|
1884
|
+
if (!checkScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
1885
|
+
|
|
1886
|
+
for (const [subPath, rawSubValue] of Object.entries(
|
|
1887
|
+
checkScope.analysis.isolatedEquivalentVariables,
|
|
1888
|
+
)) {
|
|
1889
|
+
// Normalize to array for consistent handling
|
|
1890
|
+
const subValues = Array.isArray(rawSubValue)
|
|
1891
|
+
? rawSubValue
|
|
1892
|
+
: rawSubValue
|
|
1893
|
+
? [rawSubValue]
|
|
1894
|
+
: [];
|
|
1895
|
+
|
|
1896
|
+
// Check if this is a sub-property of the equivalentValue variable
|
|
1897
|
+
// e.g., completeDataStructure['Function Arguments'] or completeDataStructure.foo
|
|
1898
|
+
const matchesDot = subPath.startsWith(equivalentValue + '.');
|
|
1899
|
+
const matchesBracket = subPath.startsWith(
|
|
1900
|
+
equivalentValue + '[',
|
|
1590
1901
|
);
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
this.isValidPath(newEquivalentValue)
|
|
1595
|
-
) {
|
|
1596
|
-
this.addEquivalency(
|
|
1597
|
-
newPath,
|
|
1598
|
-
newEquivalentValue,
|
|
1599
|
-
checkScope.name, // Use the scope where the sub-property was found
|
|
1600
|
-
scopeNode,
|
|
1601
|
-
'propagated sub-property equivalency',
|
|
1902
|
+
if (matchesDot || matchesBracket) {
|
|
1903
|
+
const subPropertyPath = subPath.substring(
|
|
1904
|
+
equivalentValue.length,
|
|
1602
1905
|
);
|
|
1906
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
1907
|
+
|
|
1908
|
+
for (const subValue of subValues) {
|
|
1909
|
+
if (typeof subValue !== 'string') continue;
|
|
1910
|
+
const newEquivalentValue = cleanPath(
|
|
1911
|
+
subValue.replace(/::cyDuplicateKey\d+::/g, ''),
|
|
1912
|
+
allPaths,
|
|
1913
|
+
);
|
|
1914
|
+
|
|
1915
|
+
if (
|
|
1916
|
+
newEquivalentValue &&
|
|
1917
|
+
this.isValidPath(newEquivalentValue)
|
|
1918
|
+
) {
|
|
1919
|
+
this.addEquivalency(
|
|
1920
|
+
newPath,
|
|
1921
|
+
newEquivalentValue,
|
|
1922
|
+
checkScope.name, // Use the scope where the sub-property was found
|
|
1923
|
+
scopeNode,
|
|
1924
|
+
'propagated sub-property equivalency',
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1603
1928
|
}
|
|
1604
|
-
}
|
|
1605
1929
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1930
|
+
// Also check if equivalentValue itself maps to a functionCallReturnValue
|
|
1931
|
+
// e.g., result = useMemo(...).functionCallReturnValue
|
|
1932
|
+
for (const subValue of subValues) {
|
|
1933
|
+
if (
|
|
1934
|
+
subPath === equivalentValue &&
|
|
1935
|
+
typeof subValue === 'string' &&
|
|
1936
|
+
subValue.endsWith('.functionCallReturnValue')
|
|
1937
|
+
) {
|
|
1938
|
+
this.propagateFunctionCallReturnSubProperties(
|
|
1939
|
+
path,
|
|
1940
|
+
subValue,
|
|
1941
|
+
scopeNode,
|
|
1942
|
+
allPaths,
|
|
1943
|
+
);
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1619
1946
|
}
|
|
1620
1947
|
}
|
|
1621
1948
|
}
|
|
1622
|
-
}
|
|
1623
1949
|
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1950
|
+
// Handle function call return values by propagating returnValue.* sub-properties
|
|
1951
|
+
// from the callback scope to the usage path
|
|
1952
|
+
if (equivalentValue.endsWith('.functionCallReturnValue')) {
|
|
1953
|
+
this.propagateFunctionCallReturnSubProperties(
|
|
1954
|
+
path,
|
|
1955
|
+
equivalentValue,
|
|
1956
|
+
scopeNode,
|
|
1957
|
+
allPaths,
|
|
1958
|
+
);
|
|
1633
1959
|
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1960
|
+
// Track which variable receives the return value of each function call
|
|
1961
|
+
// This enables generating separate mock data for each call site
|
|
1962
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1963
|
+
}
|
|
1638
1964
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1965
|
+
// Also track variables that receive destructured properties from function call return values
|
|
1966
|
+
// e.g., "userData" -> "db.query('users').functionCallReturnValue.data"
|
|
1967
|
+
if (equivalentValue.includes('.functionCallReturnValue.')) {
|
|
1968
|
+
this.trackReceivingVariable(path, equivalentValue);
|
|
1969
|
+
}
|
|
1643
1970
|
}
|
|
1644
1971
|
}
|
|
1645
1972
|
}
|
|
@@ -1649,7 +1976,7 @@ export class ScopeDataStructure {
|
|
|
1649
1976
|
this.batchProcessor = new BatchSchemaProcessor();
|
|
1650
1977
|
this.batchQueuedSet = new Set();
|
|
1651
1978
|
|
|
1652
|
-
for (const key of
|
|
1979
|
+
for (const key of allPaths) {
|
|
1653
1980
|
let value = isolatedStructure[key] ?? 'unknown';
|
|
1654
1981
|
|
|
1655
1982
|
if (['null', 'undefined'].includes(value)) {
|
|
@@ -1690,7 +2017,19 @@ export class ScopeDataStructure {
|
|
|
1690
2017
|
private processBatchQueue(): void {
|
|
1691
2018
|
if (!this.batchProcessor) return;
|
|
1692
2019
|
|
|
2020
|
+
let iterations = 0;
|
|
2021
|
+
|
|
1693
2022
|
while (this.batchProcessor.hasWork()) {
|
|
2023
|
+
iterations++;
|
|
2024
|
+
|
|
2025
|
+
// Safety: detect potential infinite loops
|
|
2026
|
+
if (iterations > 100000) {
|
|
2027
|
+
console.error(
|
|
2028
|
+
`[ScopeDataStructure] processBatchQueue exceeded 100k iterations, possible infinite loop!`,
|
|
2029
|
+
);
|
|
2030
|
+
break;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
1694
2033
|
const item = this.batchProcessor.getNextWork();
|
|
1695
2034
|
if (!item) break;
|
|
1696
2035
|
|
|
@@ -1748,26 +2087,6 @@ export class ScopeDataStructure {
|
|
|
1748
2087
|
const functionCallInfo =
|
|
1749
2088
|
this.getExternalFunctionCallsIndex().get(searchKey);
|
|
1750
2089
|
|
|
1751
|
-
// DEBUG: Track useFetcher calls
|
|
1752
|
-
if (searchKey === 'useFetcher' || callSignature.includes('useFetcher')) {
|
|
1753
|
-
console.log(
|
|
1754
|
-
'CodeYam DEBUG trackReceivingVariable:',
|
|
1755
|
-
JSON.stringify(
|
|
1756
|
-
{
|
|
1757
|
-
receivingVariable,
|
|
1758
|
-
equivalentValue,
|
|
1759
|
-
callSignature,
|
|
1760
|
-
searchKey,
|
|
1761
|
-
foundFunctionCallInfo: !!functionCallInfo,
|
|
1762
|
-
existingRecvVars: functionCallInfo?.receivingVariableNames,
|
|
1763
|
-
existingCallSigToVar: functionCallInfo?.callSignatureToVariable,
|
|
1764
|
-
},
|
|
1765
|
-
null,
|
|
1766
|
-
2,
|
|
1767
|
-
),
|
|
1768
|
-
);
|
|
1769
|
-
}
|
|
1770
|
-
|
|
1771
2090
|
if (!functionCallInfo) {
|
|
1772
2091
|
return;
|
|
1773
2092
|
}
|
|
@@ -1828,9 +2147,18 @@ export class ScopeDataStructure {
|
|
|
1828
2147
|
const checkScope = this.scopeNodes[scopeName];
|
|
1829
2148
|
if (!checkScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
1830
2149
|
|
|
1831
|
-
const
|
|
2150
|
+
const rawFunctionRef =
|
|
1832
2151
|
checkScope.analysis.isolatedEquivalentVariables[functionName];
|
|
1833
|
-
|
|
2152
|
+
// Normalize to array and find first string ending with 'F'
|
|
2153
|
+
const functionRefs = Array.isArray(rawFunctionRef)
|
|
2154
|
+
? rawFunctionRef
|
|
2155
|
+
: rawFunctionRef
|
|
2156
|
+
? [rawFunctionRef]
|
|
2157
|
+
: [];
|
|
2158
|
+
const functionRef = functionRefs.find(
|
|
2159
|
+
(r) => typeof r === 'string' && r.endsWith('F'),
|
|
2160
|
+
);
|
|
2161
|
+
if (typeof functionRef === 'string') {
|
|
1834
2162
|
callbackScopeName = functionRef.slice(0, -1);
|
|
1835
2163
|
break;
|
|
1836
2164
|
}
|
|
@@ -1858,19 +2186,24 @@ export class ScopeDataStructure {
|
|
|
1858
2186
|
|
|
1859
2187
|
const isolatedVars = callbackScope.analysis.isolatedEquivalentVariables;
|
|
1860
2188
|
|
|
2189
|
+
// Get the first returnValue equivalency (normalize array to single value for these checks)
|
|
2190
|
+
const rawReturnValue = isolatedVars.returnValue;
|
|
2191
|
+
const firstReturnValue = Array.isArray(rawReturnValue)
|
|
2192
|
+
? rawReturnValue[0]
|
|
2193
|
+
: rawReturnValue;
|
|
2194
|
+
|
|
1861
2195
|
// First, check if returnValue is an alias to another variable (e.g., returnValue = intermediate)
|
|
1862
2196
|
// If so, we need to look for that variable's sub-properties too
|
|
1863
2197
|
const returnValueAlias =
|
|
1864
|
-
typeof
|
|
1865
|
-
|
|
1866
|
-
? isolatedVars.returnValue
|
|
2198
|
+
typeof firstReturnValue === 'string' && !firstReturnValue.includes('.')
|
|
2199
|
+
? firstReturnValue
|
|
1867
2200
|
: undefined;
|
|
1868
2201
|
|
|
1869
2202
|
// Pattern 3: Object.keys(X).reduce() - the reduce result has the same sub-properties as X
|
|
1870
2203
|
// When returnValue = "Object.keys(source).reduce(...).functionCallReturnValue", look for source.* sub-properties
|
|
1871
2204
|
let reduceSourceVar: string | undefined;
|
|
1872
|
-
if (typeof
|
|
1873
|
-
const reduceMatch =
|
|
2205
|
+
if (typeof firstReturnValue === 'string') {
|
|
2206
|
+
const reduceMatch = firstReturnValue.match(
|
|
1874
2207
|
/^Object\.keys\((\w+)\)\.reduce\(.*\)\.functionCallReturnValue$/,
|
|
1875
2208
|
);
|
|
1876
2209
|
if (reduceMatch) {
|
|
@@ -1878,7 +2211,14 @@ export class ScopeDataStructure {
|
|
|
1878
2211
|
}
|
|
1879
2212
|
}
|
|
1880
2213
|
|
|
1881
|
-
for (const [subPath,
|
|
2214
|
+
for (const [subPath, rawSubValue] of Object.entries(isolatedVars)) {
|
|
2215
|
+
// Normalize to array for consistent handling
|
|
2216
|
+
const subValues = Array.isArray(rawSubValue)
|
|
2217
|
+
? rawSubValue
|
|
2218
|
+
: rawSubValue
|
|
2219
|
+
? [rawSubValue]
|
|
2220
|
+
: [];
|
|
2221
|
+
|
|
1882
2222
|
// Check for direct returnValue.* sub-properties
|
|
1883
2223
|
const isReturnValueSub =
|
|
1884
2224
|
subPath.startsWith('returnValue.') ||
|
|
@@ -1896,57 +2236,59 @@ export class ScopeDataStructure {
|
|
|
1896
2236
|
(subPath.startsWith(reduceSourceVar + '.') ||
|
|
1897
2237
|
subPath.startsWith(reduceSourceVar + '['));
|
|
1898
2238
|
|
|
1899
|
-
if (
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2239
|
+
if (!isReturnValueSub && !isAliasSub && !isReduceSourceSub) continue;
|
|
2240
|
+
|
|
2241
|
+
for (const subValue of subValues) {
|
|
2242
|
+
if (typeof subValue !== 'string') continue;
|
|
2243
|
+
|
|
2244
|
+
// Convert alias/reduceSource paths to returnValue paths
|
|
2245
|
+
let effectiveSubPath = subPath;
|
|
2246
|
+
if (isAliasSub && !isReturnValueSub) {
|
|
2247
|
+
// Replace the alias prefix with returnValue
|
|
2248
|
+
effectiveSubPath =
|
|
2249
|
+
'returnValue' + subPath.substring(returnValueAlias!.length);
|
|
2250
|
+
} else if (isReduceSourceSub && !isReturnValueSub && !isAliasSub) {
|
|
2251
|
+
// Replace the reduce source prefix with returnValue
|
|
2252
|
+
effectiveSubPath =
|
|
2253
|
+
'returnValue' + subPath.substring(reduceSourceVar!.length);
|
|
2254
|
+
}
|
|
2255
|
+
const subPropertyPath = effectiveSubPath.substring(
|
|
2256
|
+
'returnValue'.length,
|
|
2257
|
+
);
|
|
2258
|
+
const newPath = cleanPath(path + subPropertyPath, allPaths);
|
|
2259
|
+
let newEquivalentValue = cleanPath(
|
|
2260
|
+
subValue.replace(/::cyDuplicateKey\d+::/g, ''),
|
|
2261
|
+
allPaths,
|
|
2262
|
+
);
|
|
1922
2263
|
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
2264
|
+
// Resolve variable references through parent scope equivalencies
|
|
2265
|
+
const resolved = this.resolveVariableThroughParentScopes(
|
|
2266
|
+
newEquivalentValue,
|
|
2267
|
+
callbackScope,
|
|
2268
|
+
allPaths,
|
|
2269
|
+
);
|
|
2270
|
+
newEquivalentValue = resolved.resolvedPath;
|
|
2271
|
+
const equivalentScopeName = resolved.scopeName;
|
|
1931
2272
|
|
|
1932
|
-
|
|
1933
|
-
|
|
2273
|
+
if (!newEquivalentValue || !this.isValidPath(newEquivalentValue))
|
|
2274
|
+
continue;
|
|
1934
2275
|
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2276
|
+
this.addEquivalency(
|
|
2277
|
+
newPath,
|
|
2278
|
+
newEquivalentValue,
|
|
2279
|
+
equivalentScopeName,
|
|
2280
|
+
scopeNode,
|
|
2281
|
+
'propagated function call return sub-property equivalency',
|
|
2282
|
+
);
|
|
1942
2283
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
2284
|
+
// Ensure the database entry has the usage path
|
|
2285
|
+
this.addUsageToEquivalencyDatabaseEntry(
|
|
2286
|
+
newPath,
|
|
2287
|
+
newEquivalentValue,
|
|
2288
|
+
equivalentScopeName,
|
|
2289
|
+
scopeNode.name,
|
|
2290
|
+
);
|
|
2291
|
+
}
|
|
1950
2292
|
}
|
|
1951
2293
|
}
|
|
1952
2294
|
|
|
@@ -1986,8 +2328,15 @@ export class ScopeDataStructure {
|
|
|
1986
2328
|
const parentScope = this.scopeNodes[parentScopeName];
|
|
1987
2329
|
if (!parentScope?.analysis?.isolatedEquivalentVariables) continue;
|
|
1988
2330
|
|
|
1989
|
-
const
|
|
2331
|
+
const rawRootEquiv =
|
|
1990
2332
|
parentScope.analysis.isolatedEquivalentVariables[rootVar];
|
|
2333
|
+
// Normalize to array and use first string value
|
|
2334
|
+
const rootEquivs = Array.isArray(rawRootEquiv)
|
|
2335
|
+
? rawRootEquiv
|
|
2336
|
+
: rawRootEquiv
|
|
2337
|
+
? [rawRootEquiv]
|
|
2338
|
+
: [];
|
|
2339
|
+
const rootEquiv = rootEquivs.find((r) => typeof r === 'string');
|
|
1991
2340
|
if (typeof rootEquiv === 'string') {
|
|
1992
2341
|
return {
|
|
1993
2342
|
resolvedPath: cleanPath(rootEquiv + restOfPath, allPaths),
|
|
@@ -2262,11 +2611,27 @@ export class ScopeDataStructure {
|
|
|
2262
2611
|
relevantSubPathParts.every((part, i) => part === schemaPathParts[i]) &&
|
|
2263
2612
|
equivalentValue.scopeNodeName === scopeNode.name
|
|
2264
2613
|
) {
|
|
2614
|
+
// DEBUG
|
|
2265
2615
|
continue;
|
|
2266
2616
|
}
|
|
2267
2617
|
|
|
2268
2618
|
const newEquivalentPath = this.joinPathParts([schemaPath, remainingPath]);
|
|
2269
2619
|
|
|
2620
|
+
// PERF: Detect repeated patterns in paths to prevent exponential blowup
|
|
2621
|
+
// Paths like `signature[0].attributes.properties[].attributes.properties[]...`
|
|
2622
|
+
// indicate recursive type structures that cause exponential schema explosion
|
|
2623
|
+
if (this.hasExcessivePatternRepetition(newEquivalentPath)) {
|
|
2624
|
+
if (traceId && debugLevel > 0) {
|
|
2625
|
+
console.info(
|
|
2626
|
+
'Debug: skipping path with excessive pattern repetition',
|
|
2627
|
+
{
|
|
2628
|
+
path: newEquivalentPath,
|
|
2629
|
+
},
|
|
2630
|
+
);
|
|
2631
|
+
}
|
|
2632
|
+
continue;
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2270
2635
|
if (!equivalentScopeNode) {
|
|
2271
2636
|
if (traceId) {
|
|
2272
2637
|
console.info('Debug Propagation: missing equivalent scope info', {
|
|
@@ -2433,6 +2798,8 @@ export class ScopeDataStructure {
|
|
|
2433
2798
|
usageEquivalency.scopeNodeName,
|
|
2434
2799
|
) as ScopeNode;
|
|
2435
2800
|
|
|
2801
|
+
if (!usageScopeNode) continue;
|
|
2802
|
+
|
|
2436
2803
|
// Guard against infinite recursion by tracking which paths we've already
|
|
2437
2804
|
// added from addComplexSourcePathVariables
|
|
2438
2805
|
if (
|
|
@@ -2512,6 +2879,8 @@ export class ScopeDataStructure {
|
|
|
2512
2879
|
usageEquivalency.scopeNodeName,
|
|
2513
2880
|
) as ScopeNode;
|
|
2514
2881
|
|
|
2882
|
+
if (!usageScopeNode) continue;
|
|
2883
|
+
|
|
2515
2884
|
// This is put in place to avoid propagating array functions like 'filter' through complex equivalencies
|
|
2516
2885
|
// but may cause problems if the funtion call is not on a known object (e.g. string or array)
|
|
2517
2886
|
if (
|
|
@@ -2638,21 +3007,116 @@ export class ScopeDataStructure {
|
|
|
2638
3007
|
this.intermediatesOrderIndex.set(pathId, databaseEntry);
|
|
2639
3008
|
|
|
2640
3009
|
if (intermediateIndex === 0) {
|
|
2641
|
-
|
|
3010
|
+
let isValidSourceCandidate =
|
|
2642
3011
|
pathInfo.schemaPath.startsWith('signature[') ||
|
|
2643
3012
|
pathInfo.schemaPath.includes('functionCallReturnValue');
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
3013
|
+
|
|
3014
|
+
// Check if path STARTS with a spread pattern like [...var]
|
|
3015
|
+
// This handles cases like [...files][][0] or [...files].sort(...).functionCallReturnValue[][0]
|
|
3016
|
+
// where the spread source variable needs to be resolved to a signature path.
|
|
3017
|
+
// We do this REGARDLESS of isValidSourceCandidate because even paths containing
|
|
3018
|
+
// functionCallReturnValue may need spread resolution to trace back to the signature.
|
|
3019
|
+
const spreadMatch = pathInfo.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
3020
|
+
if (spreadMatch) {
|
|
3021
|
+
const spreadVar = spreadMatch[1];
|
|
3022
|
+
const spreadPattern = spreadMatch[0]; // The full [...var] match
|
|
3023
|
+
const scopeNode = this.scopeNodes[pathInfo.scopeNodeName];
|
|
3024
|
+
|
|
3025
|
+
if (scopeNode?.equivalencies) {
|
|
3026
|
+
// Follow the equivalency chain to find a signature path
|
|
3027
|
+
// e.g., files (cyScope1) → files (root) → signature[0].files
|
|
3028
|
+
const resolveToSignature = (
|
|
3029
|
+
varName: string,
|
|
3030
|
+
currentScopeName: string,
|
|
3031
|
+
visited: Set<string>,
|
|
3032
|
+
): { schemaPath: string; scopeNodeName: string } | null => {
|
|
3033
|
+
const visitKey = `${currentScopeName}::${varName}`;
|
|
3034
|
+
if (visited.has(visitKey)) return null;
|
|
3035
|
+
visited.add(visitKey);
|
|
3036
|
+
|
|
3037
|
+
const currentScope = this.scopeNodes[currentScopeName];
|
|
3038
|
+
if (!currentScope?.equivalencies) return null;
|
|
3039
|
+
|
|
3040
|
+
const varEquivs = currentScope.equivalencies[varName];
|
|
3041
|
+
if (!varEquivs) return null;
|
|
3042
|
+
|
|
3043
|
+
// First check if any equivalency directly points to a signature path
|
|
3044
|
+
const signatureEquiv = varEquivs.find((eq) =>
|
|
3045
|
+
eq.schemaPath.startsWith('signature['),
|
|
3046
|
+
);
|
|
3047
|
+
if (signatureEquiv) {
|
|
3048
|
+
return signatureEquiv;
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
// Otherwise, follow the chain to other scopes
|
|
3052
|
+
for (const equiv of varEquivs) {
|
|
3053
|
+
// If the equivalency points to the same variable in a different scope,
|
|
3054
|
+
// follow the chain
|
|
3055
|
+
if (
|
|
3056
|
+
equiv.schemaPath === varName &&
|
|
3057
|
+
equiv.scopeNodeName !== currentScopeName
|
|
3058
|
+
) {
|
|
3059
|
+
const result = resolveToSignature(
|
|
3060
|
+
varName,
|
|
3061
|
+
equiv.scopeNodeName,
|
|
3062
|
+
visited,
|
|
3063
|
+
);
|
|
3064
|
+
if (result) return result;
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
|
|
3068
|
+
return null;
|
|
3069
|
+
};
|
|
3070
|
+
|
|
3071
|
+
const signatureEquiv = resolveToSignature(
|
|
3072
|
+
spreadVar,
|
|
3073
|
+
pathInfo.scopeNodeName,
|
|
3074
|
+
new Set(),
|
|
3075
|
+
);
|
|
3076
|
+
if (signatureEquiv) {
|
|
3077
|
+
// Replace ONLY the [...var] part with the resolved signature path
|
|
3078
|
+
// This preserves any suffix like .sort(...).functionCallReturnValue[][0]
|
|
3079
|
+
const resolvedPath = pathInfo.schemaPath.replace(
|
|
3080
|
+
spreadPattern,
|
|
3081
|
+
signatureEquiv.schemaPath,
|
|
3082
|
+
);
|
|
3083
|
+
// Add the resolved path as a source candidate
|
|
3084
|
+
if (
|
|
3085
|
+
!databaseEntry.sourceCandidates.some(
|
|
3086
|
+
(sc) =>
|
|
3087
|
+
sc.schemaPath === resolvedPath &&
|
|
3088
|
+
sc.scopeNodeName === pathInfo.scopeNodeName,
|
|
3089
|
+
)
|
|
3090
|
+
) {
|
|
3091
|
+
databaseEntry.sourceCandidates.push({
|
|
3092
|
+
scopeNodeName: pathInfo.scopeNodeName,
|
|
3093
|
+
schemaPath: resolvedPath,
|
|
3094
|
+
});
|
|
3095
|
+
}
|
|
3096
|
+
isValidSourceCandidate = true;
|
|
3097
|
+
}
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
|
|
3101
|
+
if (
|
|
3102
|
+
isValidSourceCandidate &&
|
|
3103
|
+
!databaseEntry.sourceCandidates.some(
|
|
3104
|
+
(sc) =>
|
|
3105
|
+
sc.schemaPath === pathInfo.schemaPath &&
|
|
3106
|
+
sc.scopeNodeName === pathInfo.scopeNodeName,
|
|
3107
|
+
)
|
|
3108
|
+
) {
|
|
3109
|
+
databaseEntry.sourceCandidates.push(pathInfo);
|
|
3110
|
+
}
|
|
3111
|
+
} else {
|
|
3112
|
+
const existingSourceCandidateIndex =
|
|
3113
|
+
databaseEntry.sourceCandidates.findIndex(
|
|
3114
|
+
(sc) =>
|
|
3115
|
+
sc.scopeNodeName === pathInfo.scopeNodeName &&
|
|
3116
|
+
sc.schemaPath === pathInfo.schemaPath,
|
|
3117
|
+
);
|
|
3118
|
+
if (existingSourceCandidateIndex > -1) {
|
|
3119
|
+
databaseEntry.sourceCandidates.splice(
|
|
2656
3120
|
existingSourceCandidateIndex,
|
|
2657
3121
|
1,
|
|
2658
3122
|
);
|
|
@@ -2869,6 +3333,14 @@ export class ScopeDataStructure {
|
|
|
2869
3333
|
}
|
|
2870
3334
|
}
|
|
2871
3335
|
|
|
3336
|
+
// Ensure parameter-to-signature equivalencies are fully propagated.
|
|
3337
|
+
// When a parameter variable (e.g., `node`) is equivalenced to `signature[N]`,
|
|
3338
|
+
// all sub-paths of that variable should also appear under `signature[N]`.
|
|
3339
|
+
// This handles cases where the sub-path was added to the schema via a propagation
|
|
3340
|
+
// chain that already included the variable↔signature equivalency, causing the
|
|
3341
|
+
// cycle detection to prevent the reverse mapping.
|
|
3342
|
+
this.propagateParameterToSignaturePaths(scopeNode);
|
|
3343
|
+
|
|
2872
3344
|
fillInSchemaGapsAndUnknowns(scopeNode, fillInUnknowns);
|
|
2873
3345
|
|
|
2874
3346
|
if (final) {
|
|
@@ -2883,6 +3355,50 @@ export class ScopeDataStructure {
|
|
|
2883
3355
|
}
|
|
2884
3356
|
}
|
|
2885
3357
|
|
|
3358
|
+
/**
|
|
3359
|
+
* For each equivalency where a simple variable maps to signature[N],
|
|
3360
|
+
* ensure all sub-paths of that variable are reflected under signature[N].
|
|
3361
|
+
*/
|
|
3362
|
+
private propagateParameterToSignaturePaths(scopeNode: ScopeNode) {
|
|
3363
|
+
// Find variable → signature[N] equivalencies
|
|
3364
|
+
for (const [varName, equivalencies] of Object.entries(
|
|
3365
|
+
scopeNode.equivalencies,
|
|
3366
|
+
)) {
|
|
3367
|
+
// Only process simple variable names (no dots, brackets, or parens)
|
|
3368
|
+
if (
|
|
3369
|
+
varName.includes('.') ||
|
|
3370
|
+
varName.includes('[') ||
|
|
3371
|
+
varName.includes('(')
|
|
3372
|
+
) {
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
|
|
3376
|
+
for (const equiv of equivalencies) {
|
|
3377
|
+
if (
|
|
3378
|
+
equiv.scopeNodeName === scopeNode.name &&
|
|
3379
|
+
equiv.schemaPath.startsWith('signature[')
|
|
3380
|
+
) {
|
|
3381
|
+
const signaturePath = equiv.schemaPath;
|
|
3382
|
+
const varPrefix = varName + '.';
|
|
3383
|
+
const varBracketPrefix = varName + '[';
|
|
3384
|
+
|
|
3385
|
+
// Find all schema keys starting with the variable
|
|
3386
|
+
for (const key in scopeNode.schema) {
|
|
3387
|
+
if (key.startsWith(varPrefix) || key.startsWith(varBracketPrefix)) {
|
|
3388
|
+
const suffix = key.slice(varName.length);
|
|
3389
|
+
const sigKey = signaturePath + suffix;
|
|
3390
|
+
|
|
3391
|
+
// Only add if the signature path doesn't already exist
|
|
3392
|
+
if (!scopeNode.schema[sigKey]) {
|
|
3393
|
+
scopeNode.schema[sigKey] = scopeNode.schema[key];
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
|
|
2886
3402
|
private filterAndConvertSchema({
|
|
2887
3403
|
filterPath,
|
|
2888
3404
|
newPath,
|
|
@@ -2969,6 +3485,9 @@ export class ScopeDataStructure {
|
|
|
2969
3485
|
equivalentValueSchemaPathParts.length,
|
|
2970
3486
|
),
|
|
2971
3487
|
]);
|
|
3488
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3489
|
+
// to prevent recursive type expansion (e.g., string.localeCompare returns string)
|
|
3490
|
+
if (this.hasExcessivePatternRepetition(newKey)) continue;
|
|
2972
3491
|
resolvedSchema[newKey] = value;
|
|
2973
3492
|
}
|
|
2974
3493
|
}
|
|
@@ -2991,6 +3510,8 @@ export class ScopeDataStructure {
|
|
|
2991
3510
|
if (!subSchema) continue;
|
|
2992
3511
|
|
|
2993
3512
|
for (const resolvedKey in subSchema) {
|
|
3513
|
+
// PERF: Skip keys with repeated function-call signature patterns
|
|
3514
|
+
if (this.hasExcessivePatternRepetition(resolvedKey)) continue;
|
|
2994
3515
|
if (
|
|
2995
3516
|
!resolvedSchema[resolvedKey] ||
|
|
2996
3517
|
subSchema[resolvedKey] === 'unknown'
|
|
@@ -3137,7 +3658,12 @@ export class ScopeDataStructure {
|
|
|
3137
3658
|
);
|
|
3138
3659
|
}
|
|
3139
3660
|
|
|
3661
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
3662
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
3663
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
3664
|
+
this.onlyEquivalencies = true;
|
|
3140
3665
|
this.validateSchema(scopeNode, true, fillInUnknowns);
|
|
3666
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
3141
3667
|
|
|
3142
3668
|
const { schema } = scopeNode;
|
|
3143
3669
|
|
|
@@ -3171,10 +3697,29 @@ export class ScopeDataStructure {
|
|
|
3171
3697
|
}
|
|
3172
3698
|
}
|
|
3173
3699
|
}
|
|
3174
|
-
return mergedSchema;
|
|
3700
|
+
return this.filterDuplicateKeys(mergedSchema);
|
|
3175
3701
|
}
|
|
3176
3702
|
|
|
3177
|
-
return schema;
|
|
3703
|
+
return this.filterDuplicateKeys(schema);
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
/**
|
|
3707
|
+
* Filter out ::cyDuplicateKey:: entries from a schema.
|
|
3708
|
+
* These are internal markers for tracking variable reassignments
|
|
3709
|
+
* and should not appear in output schemas or LLM prompts.
|
|
3710
|
+
*/
|
|
3711
|
+
private filterDuplicateKeys(
|
|
3712
|
+
schema: Record<string, string>,
|
|
3713
|
+
): Record<string, string> {
|
|
3714
|
+
return Object.entries(schema).reduce(
|
|
3715
|
+
(acc, [key, value]) => {
|
|
3716
|
+
if (!key.includes('::cyDuplicateKey')) {
|
|
3717
|
+
acc[key] = value;
|
|
3718
|
+
}
|
|
3719
|
+
return acc;
|
|
3720
|
+
},
|
|
3721
|
+
{} as Record<string, string>,
|
|
3722
|
+
);
|
|
3178
3723
|
}
|
|
3179
3724
|
|
|
3180
3725
|
getEquivalencies(scopeName?: string) {
|
|
@@ -3204,26 +3749,270 @@ export class ScopeDataStructure {
|
|
|
3204
3749
|
return {};
|
|
3205
3750
|
}
|
|
3206
3751
|
|
|
3752
|
+
// Collect all descendant scope names (including the scope itself)
|
|
3753
|
+
// This ensures we include external calls from nested scopes like cyScope2
|
|
3754
|
+
const getAllDescendantScopeNames = (
|
|
3755
|
+
node: import('./helpers/ScopeTreeManager').ScopeTreeNode,
|
|
3756
|
+
): Set<string> => {
|
|
3757
|
+
const names = new Set<string>([node.name]);
|
|
3758
|
+
for (const child of node.children) {
|
|
3759
|
+
for (const name of getAllDescendantScopeNames(child)) {
|
|
3760
|
+
names.add(name);
|
|
3761
|
+
}
|
|
3762
|
+
}
|
|
3763
|
+
return names;
|
|
3764
|
+
};
|
|
3765
|
+
|
|
3766
|
+
const treeNode = this.scopeTreeManager.findNode(scopeNode.name);
|
|
3767
|
+
const descendantScopeNames = treeNode
|
|
3768
|
+
? getAllDescendantScopeNames(treeNode)
|
|
3769
|
+
: new Set<string>([scopeNode.name]);
|
|
3770
|
+
|
|
3771
|
+
// Get all external function calls made from this scope or any descendant scope
|
|
3772
|
+
// This allows us to include prop equivalencies from JSX components
|
|
3773
|
+
// that were rendered in nested scopes (e.g., FileTableRow called from cyScope2)
|
|
3774
|
+
const externalCallsFromScope = this.externalFunctionCalls.filter((efc) =>
|
|
3775
|
+
descendantScopeNames.has(efc.callScope),
|
|
3776
|
+
);
|
|
3777
|
+
const externalCallNames = new Set(
|
|
3778
|
+
externalCallsFromScope.map((efc) => efc.name),
|
|
3779
|
+
);
|
|
3780
|
+
|
|
3781
|
+
// Helper to check if a usage belongs to this scope (directly, via descendant, or via external call)
|
|
3782
|
+
const usageMatchesScope = (usage: { scopeNodeName: string }) =>
|
|
3783
|
+
descendantScopeNames.has(usage.scopeNodeName) ||
|
|
3784
|
+
externalCallNames.has(usage.scopeNodeName);
|
|
3785
|
+
|
|
3207
3786
|
const entries = this.equivalencyDatabase.filter((entry) =>
|
|
3208
|
-
entry.usages.some(
|
|
3787
|
+
entry.usages.some(usageMatchesScope),
|
|
3209
3788
|
);
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3789
|
+
|
|
3790
|
+
// Helper to resolve a source candidate through equivalency chains to find signature paths
|
|
3791
|
+
const resolveToSignature = (
|
|
3792
|
+
source: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>,
|
|
3793
|
+
visited: Set<string>,
|
|
3794
|
+
): Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] => {
|
|
3795
|
+
const visitKey = `${source.scopeNodeName}::${source.schemaPath}`;
|
|
3796
|
+
if (visited.has(visitKey)) return [];
|
|
3797
|
+
visited.add(visitKey);
|
|
3798
|
+
|
|
3799
|
+
// If already a signature path, return as-is
|
|
3800
|
+
if (source.schemaPath.startsWith('signature[')) {
|
|
3801
|
+
return [source];
|
|
3802
|
+
}
|
|
3803
|
+
|
|
3804
|
+
const currentScope = this.scopeNodes[source.scopeNodeName];
|
|
3805
|
+
if (!currentScope?.equivalencies) return [source];
|
|
3806
|
+
|
|
3807
|
+
// Check for direct equivalencies FIRST (full path match)
|
|
3808
|
+
// This ensures paths like "useMemo(...).functionCallReturnValue" follow to "cyScope1::returnValue"
|
|
3809
|
+
// before prefix matching tries "useMemo(...)" which goes to the useMemo scope
|
|
3810
|
+
const directEquivs = currentScope.equivalencies[source.schemaPath];
|
|
3811
|
+
if (directEquivs?.length > 0) {
|
|
3812
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3813
|
+
[];
|
|
3814
|
+
for (const equiv of directEquivs) {
|
|
3815
|
+
const resolved = resolveToSignature(
|
|
3816
|
+
{
|
|
3817
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
3818
|
+
schemaPath: equiv.schemaPath,
|
|
3819
|
+
},
|
|
3820
|
+
visited,
|
|
3821
|
+
);
|
|
3822
|
+
results.push(...resolved);
|
|
3823
|
+
}
|
|
3824
|
+
if (results.length > 0) return results;
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3827
|
+
// Handle spread patterns like [...items].sort().functionCallReturnValue
|
|
3828
|
+
// Extract the spread variable and resolve it through the equivalency chain
|
|
3829
|
+
const spreadMatch = source.schemaPath.match(/^\[\.\.\.(\w+)\]/);
|
|
3830
|
+
if (spreadMatch) {
|
|
3831
|
+
const spreadVar = spreadMatch[1];
|
|
3832
|
+
const spreadPattern = spreadMatch[0];
|
|
3833
|
+
const varEquivs = currentScope.equivalencies[spreadVar];
|
|
3834
|
+
|
|
3835
|
+
if (varEquivs?.length > 0) {
|
|
3836
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3837
|
+
[];
|
|
3838
|
+
for (const equiv of varEquivs) {
|
|
3839
|
+
// Follow the variable equivalency and then resolve from there
|
|
3840
|
+
const resolvedVar = resolveToSignature(
|
|
3841
|
+
{
|
|
3842
|
+
scopeNodeName: equiv.scopeNodeName,
|
|
3843
|
+
schemaPath: equiv.schemaPath,
|
|
3844
|
+
},
|
|
3845
|
+
visited,
|
|
3846
|
+
);
|
|
3847
|
+
// For each resolved variable path, create the full path with array element suffix
|
|
3848
|
+
for (const rv of resolvedVar) {
|
|
3849
|
+
if (rv.schemaPath.startsWith('signature[')) {
|
|
3850
|
+
// Get the suffix after the spread pattern
|
|
3851
|
+
let suffix = source.schemaPath.slice(spreadPattern.length);
|
|
3852
|
+
|
|
3853
|
+
// Clean the suffix: strip array method chains like .sort(...).functionCallReturnValue[]
|
|
3854
|
+
// These don't change the data identity, just transform it.
|
|
3855
|
+
// Keep only the final element access parts like [0], [1], etc.
|
|
3856
|
+
// Pattern: strip everything from a method call up through functionCallReturnValue[]
|
|
3857
|
+
suffix = suffix.replace(
|
|
3858
|
+
/\.\w+\([^)]*\)\.functionCallReturnValue\[\]/g,
|
|
3859
|
+
'',
|
|
3860
|
+
);
|
|
3861
|
+
// Also handle simpler case without nested parens
|
|
3862
|
+
suffix = suffix.replace(
|
|
3863
|
+
/\.sort\(\w*\(\)\)\.functionCallReturnValue\[\]/g,
|
|
3864
|
+
'',
|
|
3865
|
+
);
|
|
3866
|
+
|
|
3867
|
+
// Add [] to indicate array element access from the spread
|
|
3868
|
+
const resolvedPath = rv.schemaPath + '[]' + suffix;
|
|
3869
|
+
results.push({
|
|
3870
|
+
scopeNodeName: rv.scopeNodeName,
|
|
3871
|
+
schemaPath: resolvedPath,
|
|
3872
|
+
});
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
if (results.length > 0) return results;
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
|
|
3880
|
+
// Try to find prefix equivalencies that can resolve this path
|
|
3881
|
+
// For path like "cyScope3().signature[0][0]", check "cyScope3().signature[0]", etc.
|
|
3882
|
+
const pathParts = this.splitPath(source.schemaPath);
|
|
3883
|
+
for (let i = pathParts.length - 1; i > 0; i--) {
|
|
3884
|
+
const prefix = this.joinPathParts(pathParts.slice(0, i));
|
|
3885
|
+
const suffix = this.joinPathParts(pathParts.slice(i));
|
|
3886
|
+
const prefixEquivs = currentScope.equivalencies[prefix];
|
|
3887
|
+
|
|
3888
|
+
if (prefixEquivs?.length > 0) {
|
|
3889
|
+
const results: Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[] =
|
|
3890
|
+
[];
|
|
3891
|
+
for (const equiv of prefixEquivs) {
|
|
3892
|
+
const newPath = this.joinPathParts([equiv.schemaPath, suffix]);
|
|
3893
|
+
const resolved = resolveToSignature(
|
|
3894
|
+
{ scopeNodeName: equiv.scopeNodeName, schemaPath: newPath },
|
|
3895
|
+
visited,
|
|
3896
|
+
);
|
|
3897
|
+
results.push(...resolved);
|
|
3898
|
+
}
|
|
3899
|
+
if (results.length > 0) return results;
|
|
3900
|
+
}
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
return [source];
|
|
3904
|
+
};
|
|
3905
|
+
|
|
3906
|
+
const acc = entries.reduce(
|
|
3907
|
+
(result, entry) => {
|
|
3908
|
+
if (entry.sourceCandidates.length === 0) return result;
|
|
3909
|
+
const usages = entry.usages.filter(usageMatchesScope);
|
|
3216
3910
|
for (const usage of usages) {
|
|
3217
|
-
|
|
3218
|
-
|
|
3911
|
+
result[usage.schemaPath] ||= [];
|
|
3912
|
+
// Resolve each source candidate through the equivalency chain
|
|
3913
|
+
for (const source of entry.sourceCandidates) {
|
|
3914
|
+
const resolvedSources = resolveToSignature(source, new Set());
|
|
3915
|
+
result[usage.schemaPath].push(...resolvedSources);
|
|
3916
|
+
}
|
|
3219
3917
|
}
|
|
3220
|
-
return
|
|
3918
|
+
return result;
|
|
3221
3919
|
},
|
|
3222
3920
|
{} as Record<
|
|
3223
3921
|
string,
|
|
3224
3922
|
Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[]
|
|
3225
3923
|
>,
|
|
3226
3924
|
);
|
|
3925
|
+
|
|
3926
|
+
// Post-processing: enrich useState-backed sources with co-located external
|
|
3927
|
+
// function calls. When a useState value resolves to a setter variable that
|
|
3928
|
+
// lives in the same scope as a fetch/API call, that fetch is a data source.
|
|
3929
|
+
this.enrichUseStateSourcesWithCoLocatedCalls(acc);
|
|
3930
|
+
|
|
3931
|
+
return acc;
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
/**
|
|
3935
|
+
* For each source that ends at a useState path, check if the setter was called
|
|
3936
|
+
* from a scope that also contains external function calls (like fetch).
|
|
3937
|
+
* If so, add those external calls as additional source candidates.
|
|
3938
|
+
*/
|
|
3939
|
+
private enrichUseStateSourcesWithCoLocatedCalls(
|
|
3940
|
+
acc: Record<string, Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[]>,
|
|
3941
|
+
) {
|
|
3942
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
3943
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
3944
|
+
if (!rootScope) return;
|
|
3945
|
+
|
|
3946
|
+
// Collect all descendants for each scope node
|
|
3947
|
+
const getAllDescendants = (
|
|
3948
|
+
node: import('./helpers/ScopeTreeManager').ScopeTreeNode,
|
|
3949
|
+
): Set<string> => {
|
|
3950
|
+
const names = new Set<string>([node.name]);
|
|
3951
|
+
for (const child of node.children) {
|
|
3952
|
+
for (const name of getAllDescendants(child)) {
|
|
3953
|
+
names.add(name);
|
|
3954
|
+
}
|
|
3955
|
+
}
|
|
3956
|
+
return names;
|
|
3957
|
+
};
|
|
3958
|
+
|
|
3959
|
+
for (const [usagePath, sources] of Object.entries(acc)) {
|
|
3960
|
+
const additionalSources: Pick<
|
|
3961
|
+
ScopeVariable,
|
|
3962
|
+
'scopeNodeName' | 'schemaPath'
|
|
3963
|
+
>[] = [];
|
|
3964
|
+
|
|
3965
|
+
for (const source of sources) {
|
|
3966
|
+
// Check if this source is a useState-related terminal path
|
|
3967
|
+
// (e.g., useState(X).functionCallReturnValue[1] or useState(X).signature[0])
|
|
3968
|
+
if (!source.schemaPath.match(/^useState\([^)]*\)\./)) continue;
|
|
3969
|
+
|
|
3970
|
+
// Find the useState call from the source path
|
|
3971
|
+
const useStateCallMatch = source.schemaPath.match(
|
|
3972
|
+
/^(useState\([^)]*\))\./,
|
|
3973
|
+
);
|
|
3974
|
+
if (!useStateCallMatch) continue;
|
|
3975
|
+
const useStateCall = useStateCallMatch[1];
|
|
3976
|
+
|
|
3977
|
+
// Look in the root scope for the useState value equivalency
|
|
3978
|
+
// which tells us where the setter was called from
|
|
3979
|
+
const valuePath = `${useStateCall}.functionCallReturnValue[0]`;
|
|
3980
|
+
const valueEquivs = rootScope.equivalencies[valuePath];
|
|
3981
|
+
if (!valueEquivs) continue;
|
|
3982
|
+
|
|
3983
|
+
for (const equiv of valueEquivs) {
|
|
3984
|
+
// Find the scope where the setter was called
|
|
3985
|
+
const setterScopeName = equiv.scopeNodeName;
|
|
3986
|
+
const setterScopeTree =
|
|
3987
|
+
this.scopeTreeManager.findNode(setterScopeName);
|
|
3988
|
+
if (!setterScopeTree) continue;
|
|
3989
|
+
|
|
3990
|
+
// Get all descendant scope names from the setter scope
|
|
3991
|
+
const relatedScopes = getAllDescendants(setterScopeTree);
|
|
3992
|
+
|
|
3993
|
+
// Find external function calls in those scopes whose return values
|
|
3994
|
+
// are actually consumed (assigned to a variable). This excludes
|
|
3995
|
+
// fire-and-forget calls like analytics.track() or console.log().
|
|
3996
|
+
const coLocatedCalls = this.externalFunctionCalls.filter(
|
|
3997
|
+
(efc) =>
|
|
3998
|
+
relatedScopes.has(efc.callScope) &&
|
|
3999
|
+
efc.receivingVariableNames &&
|
|
4000
|
+
efc.receivingVariableNames.length > 0,
|
|
4001
|
+
);
|
|
4002
|
+
|
|
4003
|
+
for (const call of coLocatedCalls) {
|
|
4004
|
+
additionalSources.push({
|
|
4005
|
+
scopeNodeName: call.callScope,
|
|
4006
|
+
schemaPath: `${call.callSignature}.functionCallReturnValue`,
|
|
4007
|
+
});
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
if (additionalSources.length > 0) {
|
|
4013
|
+
acc[usagePath].push(...additionalSources);
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
3227
4016
|
}
|
|
3228
4017
|
|
|
3229
4018
|
getUsageEquivalencies(functionName?: string) {
|
|
@@ -3238,6 +4027,7 @@ export class ScopeDataStructure {
|
|
|
3238
4027
|
(candidate) => candidate.scopeNodeName === scopeNode.name,
|
|
3239
4028
|
),
|
|
3240
4029
|
);
|
|
4030
|
+
|
|
3241
4031
|
return entries.reduce(
|
|
3242
4032
|
(acc, entry) => {
|
|
3243
4033
|
if (entry.usages.length === 0) return acc;
|
|
@@ -3281,12 +4071,14 @@ export class ScopeDataStructure {
|
|
|
3281
4071
|
);
|
|
3282
4072
|
|
|
3283
4073
|
const equivalencies = this.getEquivalencies(functionName);
|
|
4074
|
+
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
4075
|
+
|
|
3284
4076
|
for (const equivalenceKey in equivalencies ?? {}) {
|
|
3285
4077
|
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
3286
4078
|
const schemaPath = equivalenceValue.schemaPath;
|
|
3287
4079
|
if (
|
|
3288
4080
|
schemaPath.startsWith('signature[') &&
|
|
3289
|
-
equivalenceValue.scopeNodeName ===
|
|
4081
|
+
equivalenceValue.scopeNodeName === scopeName &&
|
|
3290
4082
|
!signatureInSchema[schemaPath]
|
|
3291
4083
|
) {
|
|
3292
4084
|
signatureInSchema[schemaPath] = 'unknown';
|
|
@@ -3302,7 +4094,108 @@ export class ScopeDataStructure {
|
|
|
3302
4094
|
|
|
3303
4095
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
3304
4096
|
|
|
3305
|
-
|
|
4097
|
+
// After validateSchema has filled in types, propagate nested paths from
|
|
4098
|
+
// variables to their signature equivalents.
|
|
4099
|
+
// e.g., workouts[].activity_type -> signature[0].workouts[].activity_type
|
|
4100
|
+
//
|
|
4101
|
+
// Build a map of variable names that are equivalent to signature paths
|
|
4102
|
+
// e.g., { 'workouts': 'signature[0].workouts' }
|
|
4103
|
+
const variableToSignatureMap: Record<string, string> = {};
|
|
4104
|
+
|
|
4105
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
4106
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
4107
|
+
const schemaPath = equivalenceValue.schemaPath;
|
|
4108
|
+
// Track which variables map to signature paths
|
|
4109
|
+
// equivalenceKey is the variable name (e.g., 'workouts')
|
|
4110
|
+
// schemaPath is where it comes from (e.g., 'signature[0].workouts')
|
|
4111
|
+
if (
|
|
4112
|
+
schemaPath.startsWith('signature[') &&
|
|
4113
|
+
equivalenceValue.scopeNodeName === scopeName
|
|
4114
|
+
) {
|
|
4115
|
+
variableToSignatureMap[equivalenceKey] = schemaPath;
|
|
4116
|
+
}
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
|
|
4120
|
+
// Enrich schema with deeply nested paths from internal function call scopes.
|
|
4121
|
+
// When a function call like traverse(tree) exists, and traverse's scope has
|
|
4122
|
+
// signature[0].children[path][entityName] (from propagateParameterToSignaturePaths),
|
|
4123
|
+
// we need to map those paths back to the argument variable (tree) in this scope.
|
|
4124
|
+
// This handles cases where cycle detection prevented the equivalency chain from
|
|
4125
|
+
// propagating deep paths during Phase 2 batch queue processing.
|
|
4126
|
+
for (const equivalenceKey in equivalencies ?? {}) {
|
|
4127
|
+
// Look for keys matching function call pattern: funcName(...).signature[N]
|
|
4128
|
+
const funcCallMatch = equivalenceKey.match(
|
|
4129
|
+
/^([^(]+)\(.*?\)\.(signature\[\d+\])$/,
|
|
4130
|
+
);
|
|
4131
|
+
if (!funcCallMatch) continue;
|
|
4132
|
+
|
|
4133
|
+
const calledFunctionName = funcCallMatch[1];
|
|
4134
|
+
const signatureParam = funcCallMatch[2]; // e.g., "signature[0]"
|
|
4135
|
+
|
|
4136
|
+
for (const equivalenceValue of equivalencies[equivalenceKey]) {
|
|
4137
|
+
if (equivalenceValue.scopeNodeName !== scopeName) continue;
|
|
4138
|
+
|
|
4139
|
+
const targetVariable = equivalenceValue.schemaPath;
|
|
4140
|
+
|
|
4141
|
+
// Get the called function's schema (includes propagated parameter paths)
|
|
4142
|
+
const childSchema = this.getSchema({
|
|
4143
|
+
scopeName: calledFunctionName,
|
|
4144
|
+
});
|
|
4145
|
+
if (!childSchema) continue;
|
|
4146
|
+
|
|
4147
|
+
// Map child function's signature paths to parent variable paths
|
|
4148
|
+
const sigPrefix = signatureParam + '.';
|
|
4149
|
+
const sigBracketPrefix = signatureParam + '[';
|
|
4150
|
+
for (const childKey in childSchema) {
|
|
4151
|
+
let suffix: string | null = null;
|
|
4152
|
+
if (childKey.startsWith(sigPrefix)) {
|
|
4153
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4154
|
+
} else if (childKey.startsWith(sigBracketPrefix)) {
|
|
4155
|
+
suffix = childKey.slice(signatureParam.length);
|
|
4156
|
+
}
|
|
4157
|
+
|
|
4158
|
+
if (suffix !== null) {
|
|
4159
|
+
const parentKey = targetVariable + suffix;
|
|
4160
|
+
if (!schema[parentKey]) {
|
|
4161
|
+
schema[parentKey] = childSchema[childKey];
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
4166
|
+
}
|
|
4167
|
+
|
|
4168
|
+
// Propagate nested paths from variables to their signature equivalents
|
|
4169
|
+
// e.g., if workouts = signature[0].workouts, then workouts[].title becomes
|
|
4170
|
+
// signature[0].workouts[].title
|
|
4171
|
+
for (const schemaKey in schema) {
|
|
4172
|
+
// Skip keys that already start with signature[
|
|
4173
|
+
if (schemaKey.startsWith('signature[')) continue;
|
|
4174
|
+
|
|
4175
|
+
// Check if this key starts with a variable that maps to a signature path
|
|
4176
|
+
for (const [variableName, signaturePath] of Object.entries(
|
|
4177
|
+
variableToSignatureMap,
|
|
4178
|
+
)) {
|
|
4179
|
+
// Check if schemaKey starts with variableName followed by a property accessor
|
|
4180
|
+
// e.g., 'workouts[]' starts with 'workouts'
|
|
4181
|
+
if (
|
|
4182
|
+
schemaKey === variableName ||
|
|
4183
|
+
schemaKey.startsWith(variableName + '.') ||
|
|
4184
|
+
schemaKey.startsWith(variableName + '[')
|
|
4185
|
+
) {
|
|
4186
|
+
// Transform the path: replace the variable prefix with the signature path
|
|
4187
|
+
const suffix = schemaKey.slice(variableName.length);
|
|
4188
|
+
const signatureKey = signaturePath + suffix;
|
|
4189
|
+
|
|
4190
|
+
// Add to schema if not already present
|
|
4191
|
+
if (!tempScopeNode.schema[signatureKey]) {
|
|
4192
|
+
tempScopeNode.schema[signatureKey] = schema[schemaKey];
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
}
|
|
4196
|
+
}
|
|
4197
|
+
|
|
4198
|
+
return this.filterDuplicateKeys(tempScopeNode.schema);
|
|
3306
4199
|
}
|
|
3307
4200
|
|
|
3308
4201
|
getReturnValue({
|
|
@@ -3312,6 +4205,15 @@ export class ScopeDataStructure {
|
|
|
3312
4205
|
functionName?: string;
|
|
3313
4206
|
fillInUnknowns?: boolean;
|
|
3314
4207
|
}) {
|
|
4208
|
+
// Trigger finalization on all managers to apply any pending updates
|
|
4209
|
+
// (e.g., ref type propagation to external function call schemas)
|
|
4210
|
+
const rootScope = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
4211
|
+
if (rootScope) {
|
|
4212
|
+
for (const manager of this.equivalencyManagers) {
|
|
4213
|
+
manager.finalize(rootScope, this);
|
|
4214
|
+
}
|
|
4215
|
+
}
|
|
4216
|
+
|
|
3315
4217
|
const scopeName = functionName ?? this.scopeTreeManager.getRootName();
|
|
3316
4218
|
const scopeNode = this.scopeNodes[scopeName];
|
|
3317
4219
|
|
|
@@ -3322,7 +4224,8 @@ export class ScopeDataStructure {
|
|
|
3322
4224
|
scopeNode: scopeNode,
|
|
3323
4225
|
});
|
|
3324
4226
|
} else {
|
|
3325
|
-
|
|
4227
|
+
// Use getExternalFunctionCalls() which cleans cyScope from schemas
|
|
4228
|
+
for (const externalFunctionCall of this.getExternalFunctionCalls()) {
|
|
3326
4229
|
const functionNameParts = this.splitPath(functionName).map((p) =>
|
|
3327
4230
|
this.functionOrScopeName(p),
|
|
3328
4231
|
);
|
|
@@ -3354,7 +4257,17 @@ export class ScopeDataStructure {
|
|
|
3354
4257
|
// Include function paths even if their return value wasn't captured
|
|
3355
4258
|
// This ensures methods like onAuthStateChange are included in the schema
|
|
3356
4259
|
// But exclude signature entries (they should only be included via functionCallReturnValue paths)
|
|
3357
|
-
|
|
4260
|
+
// Also exclude bare function call signatures - paths that are JUST a call like
|
|
4261
|
+
// "useCustomSizes(projectSlug)" should not be included as return values.
|
|
4262
|
+
// These represent "the function exists" not actual return data, and including
|
|
4263
|
+
// them causes nested path bugs in dependencySchemas.
|
|
4264
|
+
(schema[key] === 'function' &&
|
|
4265
|
+
key.indexOf('signature[') === -1 &&
|
|
4266
|
+
// Exclude bare call signatures: function calls with no dots OUTSIDE parentheses
|
|
4267
|
+
// e.g., "useCustomSizes(projectSlug)" is bare (exclude)
|
|
4268
|
+
// e.g., "loadProject({nested.property})" is bare - dots are inside args (exclude)
|
|
4269
|
+
// e.g., "getSupabase().auth.method()" has dots outside - method chain (include)
|
|
4270
|
+
!this.isBareCallSignature(key)),
|
|
3358
4271
|
)
|
|
3359
4272
|
.reduce(
|
|
3360
4273
|
(acc, key) => {
|
|
@@ -3364,7 +4277,10 @@ export class ScopeDataStructure {
|
|
|
3364
4277
|
for (const path in schema) {
|
|
3365
4278
|
const pathParts = this.splitPath(path);
|
|
3366
4279
|
if (pathParts.every((p, i) => keyParts[i] === p)) {
|
|
3367
|
-
|
|
4280
|
+
// Also exclude bare call signatures from prefix paths
|
|
4281
|
+
if (!this.isBareCallSignature(path)) {
|
|
4282
|
+
acc[path] = schema[path];
|
|
4283
|
+
}
|
|
3368
4284
|
}
|
|
3369
4285
|
}
|
|
3370
4286
|
|
|
@@ -3378,14 +4294,73 @@ export class ScopeDataStructure {
|
|
|
3378
4294
|
|
|
3379
4295
|
const tempScopeNode = this.createTempScopeNode(scopeName, resolvedSchema);
|
|
3380
4296
|
|
|
4297
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
4298
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
4299
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
4300
|
+
this.onlyEquivalencies = true;
|
|
3381
4301
|
this.validateSchema(tempScopeNode, true, fillInUnknowns);
|
|
4302
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
4303
|
+
|
|
4304
|
+
// Remove bare call signatures from the return value schema.
|
|
4305
|
+
// fillInSchemaGapsAndUnknowns may add parent paths like "useCustomSizes(projectSlug)"
|
|
4306
|
+
// when it sees "useCustomSizes(projectSlug).functionCallReturnValue". These bare
|
|
4307
|
+
// call signatures represent "the function exists" not actual return data, and
|
|
4308
|
+
// including them causes nested path bugs in dependencySchemas.
|
|
4309
|
+
const resultSchema = tempScopeNode.schema;
|
|
4310
|
+
for (const key of Object.keys(resultSchema)) {
|
|
4311
|
+
if (this.isBareCallSignature(key)) {
|
|
4312
|
+
delete resultSchema[key];
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4315
|
+
|
|
4316
|
+
return resultSchema;
|
|
4317
|
+
}
|
|
4318
|
+
|
|
4319
|
+
/**
|
|
4320
|
+
* Checks if a schema key is a "bare call signature" - a function call with no
|
|
4321
|
+
* method chain before it and no path segments after it.
|
|
4322
|
+
*
|
|
4323
|
+
* A bare call signature represents "this function exists" rather than actual
|
|
4324
|
+
* return data, and including them causes nested path bugs in dependencySchemas.
|
|
4325
|
+
*
|
|
4326
|
+
* Examples:
|
|
4327
|
+
* - "useCustomSizes(projectSlug)" -> bare (true)
|
|
4328
|
+
* - "loadProject({nested.property})" -> bare (dots are inside args, true)
|
|
4329
|
+
* - "getSupabase().auth.method()" -> not bare (has dots outside parens, false)
|
|
4330
|
+
* - "useProject().functionCallReturnValue" -> not bare (has path after, false)
|
|
4331
|
+
*/
|
|
4332
|
+
private isBareCallSignature(key: string): boolean {
|
|
4333
|
+
// Must end with ) and contain ( to be a call
|
|
4334
|
+
if (!key.endsWith(')') || key.indexOf('(') === -1) {
|
|
4335
|
+
return false;
|
|
4336
|
+
}
|
|
4337
|
+
|
|
4338
|
+
// Check if there are any dots OUTSIDE of parentheses
|
|
4339
|
+
// Strip out content inside balanced parentheses, then check for dots
|
|
4340
|
+
let depth = 0;
|
|
4341
|
+
let hasDotsOutsideParens = false;
|
|
4342
|
+
|
|
4343
|
+
for (let i = 0; i < key.length; i++) {
|
|
4344
|
+
const char = key[i];
|
|
4345
|
+
if (char === '(') {
|
|
4346
|
+
depth++;
|
|
4347
|
+
} else if (char === ')') {
|
|
4348
|
+
depth--;
|
|
4349
|
+
} else if (char === '.' && depth === 0) {
|
|
4350
|
+
hasDotsOutsideParens = true;
|
|
4351
|
+
break;
|
|
4352
|
+
}
|
|
4353
|
+
}
|
|
3382
4354
|
|
|
3383
|
-
|
|
4355
|
+
// It's a bare call signature if there are no dots outside parentheses
|
|
4356
|
+
return !hasDotsOutsideParens;
|
|
3384
4357
|
}
|
|
3385
4358
|
|
|
3386
4359
|
/**
|
|
3387
4360
|
* Replaces cyScope placeholder references (e.g., cyScope10()) in schema keys
|
|
3388
4361
|
* with the actual callback function text from the corresponding scope node.
|
|
4362
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
4363
|
+
* internal cyScope names into stored data.
|
|
3389
4364
|
*/
|
|
3390
4365
|
private replaceCyScopePlaceholders(
|
|
3391
4366
|
schema: Record<string, string>,
|
|
@@ -3401,10 +4376,10 @@ export class ScopeDataStructure {
|
|
|
3401
4376
|
for (const match of matches) {
|
|
3402
4377
|
const cyScopeName = `cyScope${match[1]}`;
|
|
3403
4378
|
const scopeText = this.findCyScopeText(cyScopeName);
|
|
3404
|
-
if
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
4379
|
+
// Always replace cyScope references - use actual text if available,
|
|
4380
|
+
// otherwise use a generic callback placeholder
|
|
4381
|
+
const replacement = scopeText || '() => {}';
|
|
4382
|
+
newKey = newKey.replace(match[0], replacement);
|
|
3408
4383
|
}
|
|
3409
4384
|
|
|
3410
4385
|
result[newKey] = value;
|
|
@@ -3462,51 +4437,461 @@ export class ScopeDataStructure {
|
|
|
3462
4437
|
return scopeText;
|
|
3463
4438
|
}
|
|
3464
4439
|
|
|
3465
|
-
getEquivalentSignatureVariables() {
|
|
4440
|
+
getEquivalentSignatureVariables(): Record<string, string | string[]> {
|
|
3466
4441
|
const scopeNode = this.scopeNodes[this.scopeTreeManager.getRootName()];
|
|
3467
4442
|
|
|
3468
|
-
const equivalentSignatureVariables: Record<string, string> = {};
|
|
4443
|
+
const equivalentSignatureVariables: Record<string, string | string[]> = {};
|
|
4444
|
+
|
|
4445
|
+
// Helper to add equivalencies - accumulates into array if multiple values for same key
|
|
4446
|
+
// This is critical for OR expressions like `x = a || b` where x should map to both a and b
|
|
4447
|
+
const addEquivalency = (key: string, value: string) => {
|
|
4448
|
+
const existing = equivalentSignatureVariables[key];
|
|
4449
|
+
if (existing === undefined) {
|
|
4450
|
+
// First value - store as string
|
|
4451
|
+
equivalentSignatureVariables[key] = value;
|
|
4452
|
+
} else if (typeof existing === 'string') {
|
|
4453
|
+
if (existing !== value) {
|
|
4454
|
+
// Second different value - convert to array
|
|
4455
|
+
equivalentSignatureVariables[key] = [existing, value];
|
|
4456
|
+
}
|
|
4457
|
+
// Same value - no change needed
|
|
4458
|
+
} else {
|
|
4459
|
+
// Already an array - add if not already present
|
|
4460
|
+
if (!existing.includes(value)) {
|
|
4461
|
+
existing.push(value);
|
|
4462
|
+
}
|
|
4463
|
+
}
|
|
4464
|
+
};
|
|
4465
|
+
|
|
3469
4466
|
for (const [path, equivalentValues] of Object.entries(
|
|
3470
4467
|
scopeNode.equivalencies,
|
|
3471
4468
|
)) {
|
|
3472
4469
|
for (const equivalentValue of equivalentValues) {
|
|
4470
|
+
// Case 1: Props/signature equivalencies (existing behavior)
|
|
4471
|
+
// Maps local variable names to their signature paths
|
|
4472
|
+
// e.g., "propValue" -> "signature[0].prop"
|
|
3473
4473
|
if (path.startsWith('signature[')) {
|
|
3474
|
-
|
|
4474
|
+
addEquivalency(equivalentValue.schemaPath, path);
|
|
3475
4475
|
}
|
|
3476
|
-
}
|
|
3477
|
-
}
|
|
3478
4476
|
|
|
3479
|
-
|
|
3480
|
-
|
|
4477
|
+
// Case 2: Hook variable equivalencies (new behavior)
|
|
4478
|
+
// The equivalencies are stored as: path = variable name, schemaPath = data source
|
|
4479
|
+
// e.g., path = "debugFetcher", schemaPath = "useFetcher<...>().functionCallReturnValue"
|
|
4480
|
+
// We need to map: "debugFetcher" -> "useFetcher<...>()"
|
|
4481
|
+
// This enables resolving paths like "debugFetcher.state" to
|
|
4482
|
+
// "useFetcher<...>().state" for execution flow validation
|
|
4483
|
+
if (equivalentValue.schemaPath.endsWith('.functionCallReturnValue')) {
|
|
4484
|
+
// Extract the hook call path (everything before .functionCallReturnValue)
|
|
4485
|
+
let hookCallPath = equivalentValue.schemaPath.slice(
|
|
4486
|
+
0,
|
|
4487
|
+
-'.functionCallReturnValue'.length,
|
|
4488
|
+
);
|
|
4489
|
+
// Only include if it looks like a hook call (contains parentheses)
|
|
4490
|
+
// and the variable name (path) is a simple identifier (no dots)
|
|
4491
|
+
if (hookCallPath.includes('(') && !path.includes('.')) {
|
|
4492
|
+
// Special case: If hookCallPath is a callback scope (cyScope pattern),
|
|
4493
|
+
// trace through it to find what the callback actually returns.
|
|
4494
|
+
// This handles useState(() => { return prop; }) patterns.
|
|
4495
|
+
const cyScopeMatch = hookCallPath.match(/^(cyScope\d+)\(\)$/);
|
|
4496
|
+
if (cyScopeMatch) {
|
|
4497
|
+
// Use the equivalency database to trace the callback's return value
|
|
4498
|
+
// to its actual source (e.g., viewModeFromUrl -> segments -> params -> useParams)
|
|
4499
|
+
const dbEntry = this.getEquivalenciesDatabaseEntry(
|
|
4500
|
+
scopeNode.name, // Component scope
|
|
4501
|
+
path, // variable name (e.g., viewMode)
|
|
4502
|
+
);
|
|
4503
|
+
if (dbEntry?.sourceCandidates?.length > 0) {
|
|
4504
|
+
// Use the traced source instead of the callback scope
|
|
4505
|
+
hookCallPath = dbEntry.sourceCandidates[0].schemaPath;
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
addEquivalency(path, hookCallPath);
|
|
4509
|
+
}
|
|
4510
|
+
}
|
|
3481
4511
|
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
4512
|
+
// Case 3: Destructured variables from local variables
|
|
4513
|
+
// e.g., const { scenarios } = currentEntityAnalysis;
|
|
4514
|
+
// This creates: path = "scenarios", schemaPath = "currentEntityAnalysis.scenarios"
|
|
4515
|
+
// We need to map: "scenarios" -> "currentEntityAnalysis.scenarios"
|
|
4516
|
+
// AND resolve transitively if currentEntityAnalysis is itself equivalent to a hook call
|
|
4517
|
+
if (
|
|
4518
|
+
!path.includes('.') && // path is a simple identifier
|
|
4519
|
+
!equivalentValue.schemaPath.startsWith('signature[') && // not a signature path
|
|
4520
|
+
!equivalentValue.schemaPath.endsWith('.functionCallReturnValue') // not already handled above
|
|
4521
|
+
) {
|
|
4522
|
+
// Skip bare "returnValue" from child scopes — this is the child's return value,
|
|
4523
|
+
// not a meaningful data source path in the parent scope
|
|
4524
|
+
if (
|
|
4525
|
+
equivalentValue.schemaPath === 'returnValue' &&
|
|
4526
|
+
equivalentValue.scopeNodeName !==
|
|
4527
|
+
this.scopeTreeManager.getRootName()
|
|
4528
|
+
) {
|
|
4529
|
+
continue;
|
|
4530
|
+
}
|
|
4531
|
+
// Add equivalency (will accumulate if multiple values for OR expressions)
|
|
4532
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4533
|
+
}
|
|
3491
4534
|
|
|
3492
|
-
|
|
4535
|
+
// Case 4: Child component prop mappings (Fix 22)
|
|
4536
|
+
// When parent renders <ChildComponent prop={value} />, we get equivalencies like:
|
|
4537
|
+
// path = "ChildComponent().signature[0].prop"
|
|
4538
|
+
// schemaPath = "value" (the variable passed as the prop)
|
|
4539
|
+
// We need to include these so translateChildPathToParent can work.
|
|
4540
|
+
// Pattern: ComponentName().signature[N] or ComponentName().signature[N].propName
|
|
4541
|
+
if (
|
|
4542
|
+
path.includes('().signature[') &&
|
|
4543
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable, not a function call
|
|
4544
|
+
) {
|
|
4545
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4546
|
+
}
|
|
3493
4547
|
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
4548
|
+
// Case 5: Destructured function parameters (Fix 25)
|
|
4549
|
+
// When a function has destructured props: function Comp({ propA, propB }: Props)
|
|
4550
|
+
// We get equivalencies like:
|
|
4551
|
+
// path = "propA" (the destructured variable name)
|
|
4552
|
+
// schemaPath = "signature[0].propA" (the signature path)
|
|
4553
|
+
// We need to map: "propA" -> "signature[0].propA"
|
|
4554
|
+
// This enables translateChildPathToParent to resolve child variable paths
|
|
4555
|
+
// to their signature paths when merging execution flows.
|
|
4556
|
+
if (
|
|
4557
|
+
!path.includes('.') && // path is a simple identifier (destructured prop name)
|
|
4558
|
+
equivalentValue.schemaPath.startsWith('signature[') // schemaPath IS a signature path
|
|
4559
|
+
) {
|
|
4560
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4561
|
+
}
|
|
4562
|
+
|
|
4563
|
+
// Case 7: Method calls on variables that result in .functionCallReturnValue (Fix 33)
|
|
4564
|
+
// When we have patterns like:
|
|
4565
|
+
// path = "segments" (simple identifier)
|
|
4566
|
+
// schemaPath = "splat.split('/').functionCallReturnValue"
|
|
4567
|
+
// This is a method call on a variable (not a hook call), but we still need to
|
|
4568
|
+
// track it so transitive resolution can resolve `splat` to its actual source.
|
|
4569
|
+
// E.g., if splat -> useParams().functionCallReturnValue['*'], then
|
|
4570
|
+
// segments -> useParams().functionCallReturnValue['*'].split('/').functionCallReturnValue
|
|
4571
|
+
if (
|
|
4572
|
+
!path.includes('.') && // path is a simple identifier
|
|
4573
|
+
equivalentValue.schemaPath.endsWith('.functionCallReturnValue') && // ends with function return
|
|
4574
|
+
equivalentValue.schemaPath.includes('.') // has property access (method call)
|
|
4575
|
+
) {
|
|
4576
|
+
// Check if this looks like a method call on a variable (not a hook call)
|
|
4577
|
+
// Hook calls look like: hookName() or hookName<T>()
|
|
4578
|
+
// Method calls look like: variable.method() or variable.method<T>()
|
|
4579
|
+
const hookCallPath = equivalentValue.schemaPath.slice(
|
|
4580
|
+
0,
|
|
4581
|
+
-'.functionCallReturnValue'.length,
|
|
4582
|
+
);
|
|
4583
|
+
// If it's a method call (contains a dot before the parenthesis), include it
|
|
4584
|
+
const dotBeforeParen = hookCallPath.indexOf('.');
|
|
4585
|
+
const parenPos = hookCallPath.indexOf('(');
|
|
4586
|
+
if (dotBeforeParen !== -1 && dotBeforeParen < parenPos) {
|
|
4587
|
+
// This is a method call like "splat.split('/')", not a hook call
|
|
4588
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4589
|
+
}
|
|
4590
|
+
}
|
|
4591
|
+
}
|
|
3503
4592
|
}
|
|
3504
4593
|
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
4594
|
+
// Case 6: Collect JSX child prop equivalencies from child scopes (Fix 26)
|
|
4595
|
+
// When a parent component renders <ChildComponent prop={value} />, the JSX
|
|
4596
|
+
// return statement may be in a child scope (e.g., cyScope2). The equivalencies
|
|
4597
|
+
// like ChildComponent().signature[0].prop -> value get stored in that child scope.
|
|
4598
|
+
// But translateChildPathToParent needs to find them from the parent scope's context.
|
|
4599
|
+
// So we collect Case 4 patterns from ALL child scopes that belong to this root scope.
|
|
4600
|
+
const rootName = this.scopeTreeManager.getRootName();
|
|
4601
|
+
for (const [scopeName, childScopeNode] of Object.entries(this.scopeNodes)) {
|
|
4602
|
+
// Skip the root scope (already processed above)
|
|
4603
|
+
if (scopeName === rootName) continue;
|
|
4604
|
+
|
|
4605
|
+
// Only include scopes that are children of the root (their tree includes root)
|
|
4606
|
+
if (!childScopeNode.tree?.includes(rootName)) continue;
|
|
4607
|
+
|
|
4608
|
+
// Look for Case 4 patterns in the child scope
|
|
4609
|
+
for (const [path, equivalentValues] of Object.entries(
|
|
4610
|
+
childScopeNode.equivalencies || {},
|
|
4611
|
+
)) {
|
|
4612
|
+
for (const equivalentValue of equivalentValues) {
|
|
4613
|
+
// Case 4 pattern: ChildComponent().signature[0].propName -> parentVariable
|
|
4614
|
+
if (
|
|
4615
|
+
path.includes('().signature[') &&
|
|
4616
|
+
!equivalentValue.schemaPath.includes('()') // schemaPath is a simple variable
|
|
4617
|
+
) {
|
|
4618
|
+
// Only add if not already present from the root scope
|
|
4619
|
+
// Root scope values take precedence over child scope values
|
|
4620
|
+
if (!(path in equivalentSignatureVariables)) {
|
|
4621
|
+
addEquivalency(path, equivalentValue.schemaPath);
|
|
4622
|
+
}
|
|
4623
|
+
}
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
|
|
4628
|
+
// Transitive resolution: Resolve variable chains through multiple levels
|
|
4629
|
+
// E.g., analysis → currentEntityAnalysis → useLoaderData().functionCallReturnValue.currentEntityAnalysis
|
|
4630
|
+
// We need multiple passes because resolutions can depend on each other
|
|
4631
|
+
const maxIterations = 5; // Prevent infinite loops
|
|
4632
|
+
|
|
4633
|
+
// Helper function to resolve a single source path using equivalencies
|
|
4634
|
+
const resolveSourcePath = (
|
|
4635
|
+
sourcePath: string,
|
|
4636
|
+
equivMap: Record<string, string | string[]>,
|
|
4637
|
+
): string | null => {
|
|
4638
|
+
// Extract base variable from the path
|
|
4639
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4640
|
+
const bracketIndex = sourcePath.indexOf('[');
|
|
4641
|
+
|
|
4642
|
+
let baseVar: string;
|
|
4643
|
+
let rest: string;
|
|
4644
|
+
|
|
4645
|
+
if (dotIndex === -1 && bracketIndex === -1) {
|
|
4646
|
+
baseVar = sourcePath;
|
|
4647
|
+
rest = '';
|
|
4648
|
+
} else if (dotIndex === -1) {
|
|
4649
|
+
baseVar = sourcePath.slice(0, bracketIndex);
|
|
4650
|
+
rest = sourcePath.slice(bracketIndex);
|
|
4651
|
+
} else if (bracketIndex === -1) {
|
|
4652
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
4653
|
+
rest = sourcePath.slice(dotIndex);
|
|
4654
|
+
} else {
|
|
4655
|
+
const firstIndex = Math.min(dotIndex, bracketIndex);
|
|
4656
|
+
baseVar = sourcePath.slice(0, firstIndex);
|
|
4657
|
+
rest = sourcePath.slice(firstIndex);
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4660
|
+
// Look up the base variable in equivalencies
|
|
4661
|
+
if (baseVar in equivMap && equivMap[baseVar] !== sourcePath) {
|
|
4662
|
+
const baseResolved = equivMap[baseVar];
|
|
4663
|
+
// Skip if baseResolved is an array (handle later)
|
|
4664
|
+
if (Array.isArray(baseResolved)) return null;
|
|
4665
|
+
// If it resolves to a signature path, build the full resolved path
|
|
4666
|
+
if (
|
|
4667
|
+
baseResolved.startsWith('signature[') ||
|
|
4668
|
+
baseResolved.includes('()')
|
|
4669
|
+
) {
|
|
4670
|
+
if (baseResolved.endsWith('()')) {
|
|
4671
|
+
return baseResolved + '.functionCallReturnValue' + rest;
|
|
4672
|
+
}
|
|
4673
|
+
return baseResolved + rest;
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
return null;
|
|
4677
|
+
};
|
|
4678
|
+
|
|
4679
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
4680
|
+
let changed = false;
|
|
4681
|
+
|
|
4682
|
+
for (const [varName, sourcePathOrArray] of Object.entries(
|
|
4683
|
+
equivalentSignatureVariables,
|
|
4684
|
+
)) {
|
|
4685
|
+
// Handle arrays (OR expressions) by resolving each element
|
|
4686
|
+
if (Array.isArray(sourcePathOrArray)) {
|
|
4687
|
+
const resolvedArray: string[] = [];
|
|
4688
|
+
let arrayChanged = false;
|
|
4689
|
+
for (const sourcePath of sourcePathOrArray) {
|
|
4690
|
+
// Try to resolve this path using transitive resolution
|
|
4691
|
+
const resolved = resolveSourcePath(
|
|
4692
|
+
sourcePath,
|
|
4693
|
+
equivalentSignatureVariables,
|
|
4694
|
+
);
|
|
4695
|
+
if (resolved && resolved !== sourcePath) {
|
|
4696
|
+
resolvedArray.push(resolved);
|
|
4697
|
+
arrayChanged = true;
|
|
4698
|
+
} else {
|
|
4699
|
+
resolvedArray.push(sourcePath);
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4702
|
+
if (arrayChanged) {
|
|
4703
|
+
equivalentSignatureVariables[varName] = resolvedArray;
|
|
4704
|
+
changed = true;
|
|
4705
|
+
}
|
|
4706
|
+
continue;
|
|
4707
|
+
}
|
|
4708
|
+
const sourcePath = sourcePathOrArray;
|
|
4709
|
+
|
|
4710
|
+
// Skip if already fully resolved (contains function call syntax)
|
|
4711
|
+
// BUT first check for computed value patterns that need resolution (Fix 28)
|
|
4712
|
+
// AND method call patterns that need base variable resolution (Fix 33)
|
|
4713
|
+
if (sourcePath.includes('()')) {
|
|
4714
|
+
// Fix 28: Handle computed value patterns with dependency arrays
|
|
4715
|
+
// Patterns like `functionName(arg, [dep1, dep2, ...])` are NOT controllable
|
|
4716
|
+
// data sources. We trace through the dependencies to find controllable sources.
|
|
4717
|
+
const bracketStart = sourcePath.indexOf('[');
|
|
4718
|
+
const bracketEnd = sourcePath.lastIndexOf(']');
|
|
4719
|
+
|
|
4720
|
+
if (bracketStart !== -1 && bracketEnd > bracketStart) {
|
|
4721
|
+
const arrayContent = sourcePath.slice(bracketStart + 1, bracketEnd);
|
|
4722
|
+
const items = arrayContent.split(',').map((s) => s.trim());
|
|
4723
|
+
|
|
4724
|
+
// Only process if this looks like a dependency array:
|
|
4725
|
+
// multiple items that are all simple identifiers (not numbers or expressions)
|
|
4726
|
+
const isIdentifier = (s: string) =>
|
|
4727
|
+
/^\w+$/.test(s) && !/^\d+$/.test(s);
|
|
4728
|
+
if (items.length > 1 && items.every(isIdentifier)) {
|
|
4729
|
+
// Look for a dependency that's already resolved to a controllable source
|
|
4730
|
+
for (const dep of items) {
|
|
4731
|
+
if (dep in equivalentSignatureVariables) {
|
|
4732
|
+
const resolvedDep = equivalentSignatureVariables[dep];
|
|
4733
|
+
// Use if it's a controllable path (contains hook call)
|
|
4734
|
+
// and is NOT another unresolved computed pattern (has comma-separated deps)
|
|
4735
|
+
const hasCommaInBrackets =
|
|
4736
|
+
resolvedDep.includes('[') &&
|
|
4737
|
+
resolvedDep.includes(',') &&
|
|
4738
|
+
resolvedDep.indexOf(',') > resolvedDep.indexOf('[');
|
|
4739
|
+
if (resolvedDep.includes('()') && !hasCommaInBrackets) {
|
|
4740
|
+
// Computed value is typically an element from an array
|
|
4741
|
+
equivalentSignatureVariables[varName] = resolvedDep + '[]';
|
|
4742
|
+
changed = true;
|
|
4743
|
+
break;
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
}
|
|
4747
|
+
}
|
|
4748
|
+
}
|
|
4749
|
+
|
|
4750
|
+
// Fix 33: Handle method call patterns on variables
|
|
4751
|
+
// Patterns like: "splat.split('/').functionCallReturnValue"
|
|
4752
|
+
// We need to resolve the base variable (splat) to its actual source
|
|
4753
|
+
// Check if this is a method call on a variable (dot before first parenthesis)
|
|
4754
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4755
|
+
const parenIndex = sourcePath.indexOf('(');
|
|
4756
|
+
if (
|
|
4757
|
+
dotIndex !== -1 &&
|
|
4758
|
+
dotIndex < parenIndex &&
|
|
4759
|
+
!sourcePath.startsWith('use') // Not a hook call like useState()
|
|
4760
|
+
) {
|
|
4761
|
+
// Extract the base variable (before the first dot)
|
|
4762
|
+
const baseVar = sourcePath.slice(0, dotIndex);
|
|
4763
|
+
const rest = sourcePath.slice(dotIndex); // includes ".method(...).functionCallReturnValue"
|
|
4764
|
+
|
|
4765
|
+
// Check if the base variable can be resolved
|
|
4766
|
+
if (
|
|
4767
|
+
baseVar in equivalentSignatureVariables &&
|
|
4768
|
+
baseVar !== varName
|
|
4769
|
+
) {
|
|
4770
|
+
const baseResolved = equivalentSignatureVariables[baseVar];
|
|
4771
|
+
// Skip if baseResolved is an array (OR expression)
|
|
4772
|
+
if (Array.isArray(baseResolved)) continue;
|
|
4773
|
+
// Only resolve if the base resolved to something useful (contains () or .)
|
|
4774
|
+
if (baseResolved.includes('()') || baseResolved.includes('.')) {
|
|
4775
|
+
const newPath = baseResolved + rest;
|
|
4776
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4777
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4778
|
+
changed = true;
|
|
4779
|
+
}
|
|
4780
|
+
}
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4783
|
+
|
|
4784
|
+
// Fix 38: Handle cyScope lazy initializer return values
|
|
4785
|
+
// When we have viewMode -> cyScope20(), trace through to find what cyScope20 returns.
|
|
4786
|
+
// The lazy initializer's return value should be the controllable data source.
|
|
4787
|
+
// Pattern: cyScopeN() where N is a number
|
|
4788
|
+
const cyScopeMatch = sourcePath.match(/^(cyScope\d+)\(\)$/);
|
|
4789
|
+
if (cyScopeMatch) {
|
|
4790
|
+
const cyScopeName = cyScopeMatch[1];
|
|
4791
|
+
const cyScopeNode = this.scopeNodes[cyScopeName];
|
|
4792
|
+
|
|
4793
|
+
if (cyScopeNode?.equivalencies) {
|
|
4794
|
+
// Look for returnValue equivalency in the cyScope
|
|
4795
|
+
const returnValueEquivs =
|
|
4796
|
+
cyScopeNode.equivalencies['returnValue'];
|
|
4797
|
+
if (returnValueEquivs && returnValueEquivs.length > 0) {
|
|
4798
|
+
// Get the first return value source
|
|
4799
|
+
const returnSource = returnValueEquivs[0].schemaPath;
|
|
4800
|
+
|
|
4801
|
+
// If the return source is a simple variable (not a complex path),
|
|
4802
|
+
// resolve varName directly to that variable
|
|
4803
|
+
if (
|
|
4804
|
+
returnSource &&
|
|
4805
|
+
!returnSource.includes('(') &&
|
|
4806
|
+
!returnSource.includes('[')
|
|
4807
|
+
) {
|
|
4808
|
+
// Update varName to point to the return source
|
|
4809
|
+
if (equivalentSignatureVariables[varName] !== returnSource) {
|
|
4810
|
+
equivalentSignatureVariables[varName] = returnSource;
|
|
4811
|
+
changed = true;
|
|
4812
|
+
}
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
|
|
4818
|
+
continue;
|
|
4819
|
+
}
|
|
4820
|
+
|
|
4821
|
+
// Check if the source path starts with a variable that's also in the map
|
|
4822
|
+
const dotIndex = sourcePath.indexOf('.');
|
|
4823
|
+
let baseVar: string;
|
|
4824
|
+
let rest: string;
|
|
4825
|
+
|
|
4826
|
+
if (dotIndex > 0) {
|
|
4827
|
+
// Path has a dot: "a.b.c" -> baseVar="a", rest=".b.c"
|
|
4828
|
+
baseVar = sourcePath.slice(0, dotIndex);
|
|
4829
|
+
rest = sourcePath.slice(dotIndex); // includes the leading dot
|
|
4830
|
+
} else {
|
|
4831
|
+
// Path is a simple identifier: "currentEntityAnalysis" -> baseVar="currentEntityAnalysis", rest=""
|
|
4832
|
+
baseVar = sourcePath;
|
|
4833
|
+
rest = '';
|
|
4834
|
+
}
|
|
4835
|
+
|
|
4836
|
+
if (baseVar in equivalentSignatureVariables && baseVar !== varName) {
|
|
4837
|
+
// Handle array case (OR expressions) - use first element
|
|
4838
|
+
const rawBaseResolved = equivalentSignatureVariables[baseVar];
|
|
4839
|
+
const baseResolved = Array.isArray(rawBaseResolved)
|
|
4840
|
+
? rawBaseResolved[0]
|
|
4841
|
+
: rawBaseResolved;
|
|
4842
|
+
if (!baseResolved) continue;
|
|
4843
|
+
// If the base resolves to a hook call, add .functionCallReturnValue
|
|
4844
|
+
if (baseResolved.endsWith('()')) {
|
|
4845
|
+
const newPath = baseResolved + '.functionCallReturnValue' + rest;
|
|
4846
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4847
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4848
|
+
changed = true;
|
|
4849
|
+
}
|
|
4850
|
+
} else if (baseResolved !== sourcePath) {
|
|
4851
|
+
const newPath = baseResolved + rest;
|
|
4852
|
+
if (newPath !== equivalentSignatureVariables[varName]) {
|
|
4853
|
+
equivalentSignatureVariables[varName] = newPath;
|
|
4854
|
+
changed = true;
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
// Stop if no changes were made in this iteration
|
|
4861
|
+
if (!changed) break;
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4864
|
+
return equivalentSignatureVariables;
|
|
4865
|
+
}
|
|
4866
|
+
|
|
4867
|
+
getVariableInfo(
|
|
4868
|
+
variableName: string,
|
|
4869
|
+
scopeName?: string,
|
|
4870
|
+
final?: boolean,
|
|
4871
|
+
): VariableInfo | undefined {
|
|
4872
|
+
const scopeNode = this.getScopeOrFunctionCallInfo(
|
|
4873
|
+
scopeName ?? this.scopeTreeManager.getRootName(),
|
|
4874
|
+
);
|
|
4875
|
+
if (!scopeNode) return;
|
|
4876
|
+
|
|
4877
|
+
let equivalents = scopeNode.equivalencies[variableName];
|
|
4878
|
+
|
|
4879
|
+
if (!equivalents || equivalents.length === 0) {
|
|
4880
|
+
equivalents = [
|
|
4881
|
+
{
|
|
4882
|
+
id: -1,
|
|
4883
|
+
scopeNodeName: scopeNode.name,
|
|
4884
|
+
schemaPath: variableName,
|
|
4885
|
+
equivalencyReason: 'missing equivalency',
|
|
4886
|
+
},
|
|
4887
|
+
];
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
const relevantSchema = equivalents.reduce(
|
|
4891
|
+
(acc, eq) => {
|
|
4892
|
+
const relevantSchema = this.getSchema({
|
|
4893
|
+
scopeName: eq.scopeNodeName,
|
|
4894
|
+
});
|
|
3510
4895
|
|
|
3511
4896
|
if (!relevantSchema) return acc;
|
|
3512
4897
|
|
|
@@ -3526,7 +4911,12 @@ export class ScopeDataStructure {
|
|
|
3526
4911
|
relevantSchema,
|
|
3527
4912
|
);
|
|
3528
4913
|
|
|
4914
|
+
// CRITICAL: Set onlyEquivalencies to true to prevent database modifications
|
|
4915
|
+
// during this "getter" method. See comment in getFunctionSignature.
|
|
4916
|
+
const wasOnlyEquivalencies = this.onlyEquivalencies;
|
|
4917
|
+
this.onlyEquivalencies = true;
|
|
3529
4918
|
this.validateSchema(tempScopeNode, true, final);
|
|
4919
|
+
this.onlyEquivalencies = wasOnlyEquivalencies;
|
|
3530
4920
|
|
|
3531
4921
|
return {
|
|
3532
4922
|
name: variableName,
|
|
@@ -3535,8 +4925,123 @@ export class ScopeDataStructure {
|
|
|
3535
4925
|
};
|
|
3536
4926
|
}
|
|
3537
4927
|
|
|
3538
|
-
getExternalFunctionCalls() {
|
|
3539
|
-
|
|
4928
|
+
getExternalFunctionCalls(): FunctionCallInfo[] {
|
|
4929
|
+
// Replace cyScope placeholders in all external function call data
|
|
4930
|
+
// This ensures call signatures and schema paths use actual callback text
|
|
4931
|
+
// instead of internal cyScope names, preventing mock data merge conflicts.
|
|
4932
|
+
return this.externalFunctionCalls.map((efc) =>
|
|
4933
|
+
this.cleanCyScopeFromFunctionCallInfo(efc),
|
|
4934
|
+
);
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4937
|
+
/**
|
|
4938
|
+
* Cleans cyScope placeholder references from a FunctionCallInfo.
|
|
4939
|
+
* Replaces cyScopeN() with the actual callback text in:
|
|
4940
|
+
* - callSignature
|
|
4941
|
+
* - allCallSignatures
|
|
4942
|
+
* - schema keys
|
|
4943
|
+
*/
|
|
4944
|
+
private cleanCyScopeFromFunctionCallInfo(
|
|
4945
|
+
efc: FunctionCallInfo,
|
|
4946
|
+
): FunctionCallInfo {
|
|
4947
|
+
const cyScopePattern = /cyScope\d+\(\)/g;
|
|
4948
|
+
|
|
4949
|
+
// Check if any cleaning is needed
|
|
4950
|
+
const hasCyScope =
|
|
4951
|
+
cyScopePattern.test(efc.callSignature) ||
|
|
4952
|
+
(efc.allCallSignatures &&
|
|
4953
|
+
efc.allCallSignatures.some((sig) => /cyScope\d+\(\)/.test(sig))) ||
|
|
4954
|
+
(efc.schema &&
|
|
4955
|
+
Object.keys(efc.schema).some((key) => /cyScope\d+\(\)/.test(key)));
|
|
4956
|
+
|
|
4957
|
+
if (!hasCyScope) {
|
|
4958
|
+
return efc;
|
|
4959
|
+
}
|
|
4960
|
+
|
|
4961
|
+
// Create cleaned copy
|
|
4962
|
+
const cleaned: FunctionCallInfo = { ...efc };
|
|
4963
|
+
|
|
4964
|
+
// Clean callSignature
|
|
4965
|
+
cleaned.callSignature = this.replaceCyScopeInString(efc.callSignature);
|
|
4966
|
+
|
|
4967
|
+
// Clean allCallSignatures
|
|
4968
|
+
if (efc.allCallSignatures) {
|
|
4969
|
+
cleaned.allCallSignatures = efc.allCallSignatures.map((sig) =>
|
|
4970
|
+
this.replaceCyScopeInString(sig),
|
|
4971
|
+
);
|
|
4972
|
+
}
|
|
4973
|
+
|
|
4974
|
+
// Clean schema keys
|
|
4975
|
+
if (efc.schema) {
|
|
4976
|
+
cleaned.schema = this.replaceCyScopePlaceholders(efc.schema);
|
|
4977
|
+
}
|
|
4978
|
+
|
|
4979
|
+
// Clean callSignatureToVariable keys
|
|
4980
|
+
if (efc.callSignatureToVariable) {
|
|
4981
|
+
cleaned.callSignatureToVariable = Object.entries(
|
|
4982
|
+
efc.callSignatureToVariable,
|
|
4983
|
+
).reduce(
|
|
4984
|
+
(acc, [key, value]) => {
|
|
4985
|
+
acc[this.replaceCyScopeInString(key)] = value;
|
|
4986
|
+
return acc;
|
|
4987
|
+
},
|
|
4988
|
+
{} as Record<string, string>,
|
|
4989
|
+
);
|
|
4990
|
+
}
|
|
4991
|
+
|
|
4992
|
+
return cleaned;
|
|
4993
|
+
}
|
|
4994
|
+
|
|
4995
|
+
/**
|
|
4996
|
+
* Replaces cyScope placeholder references in a single string.
|
|
4997
|
+
* If the scope text can't be found, uses a generic fallback to avoid leaking
|
|
4998
|
+
* internal cyScope names into stored data.
|
|
4999
|
+
*
|
|
5000
|
+
* Handles two patterns:
|
|
5001
|
+
* 1. Function call style: cyScope7() - matched by cyScope(\d+)\(\)
|
|
5002
|
+
* 2. Scope name style: parentName____cyScopeXX or cyScopeXX - matched by (\w+____)?cyScope([0-9A-Fa-f]+)
|
|
5003
|
+
*/
|
|
5004
|
+
private replaceCyScopeInString(str: string): string {
|
|
5005
|
+
let result = str;
|
|
5006
|
+
|
|
5007
|
+
// Pattern 1: Function call style - cyScope7()
|
|
5008
|
+
const functionCallPattern = /cyScope(\d+)\(\)/g;
|
|
5009
|
+
const functionCallMatches = [...str.matchAll(functionCallPattern)];
|
|
5010
|
+
for (const match of functionCallMatches) {
|
|
5011
|
+
const cyScopeName = `cyScope${match[1]}`;
|
|
5012
|
+
const scopeText = this.findCyScopeText(cyScopeName);
|
|
5013
|
+
// Always replace cyScope references - use actual text if available,
|
|
5014
|
+
// otherwise use a generic callback placeholder
|
|
5015
|
+
const replacement = scopeText || '() => {}';
|
|
5016
|
+
result = result.replace(match[0], replacement);
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
// Pattern 2: Scope name style - parentName____cyScopeXX or just cyScopeXX
|
|
5020
|
+
// This handles hex-encoded scope IDs like cyScope1F
|
|
5021
|
+
const scopeNamePattern = /(\w+____)?cyScope([0-9A-Fa-f]+)/g;
|
|
5022
|
+
const scopeNameMatches = [...result.matchAll(scopeNamePattern)];
|
|
5023
|
+
for (const match of scopeNameMatches) {
|
|
5024
|
+
const fullMatch = match[0];
|
|
5025
|
+
const prefix = match[1] || ''; // e.g., "getTitleColor____"
|
|
5026
|
+
const cyScopeId = match[2]; // e.g., "1F"
|
|
5027
|
+
const cyScopeName = `cyScope${cyScopeId}`;
|
|
5028
|
+
|
|
5029
|
+
// Try to find the scope text, checking both with and without prefix
|
|
5030
|
+
let scopeText = this.findCyScopeText(cyScopeName);
|
|
5031
|
+
if (!scopeText && prefix) {
|
|
5032
|
+
// Try looking up with the full prefixed name
|
|
5033
|
+
scopeText = this.findCyScopeText(`${prefix}${cyScopeName}`);
|
|
5034
|
+
}
|
|
5035
|
+
|
|
5036
|
+
if (scopeText) {
|
|
5037
|
+
result = result.replace(fullMatch, scopeText);
|
|
5038
|
+
} else {
|
|
5039
|
+
// Replace with a generic identifier to avoid leaking internal names
|
|
5040
|
+
result = result.replace(fullMatch, 'callback');
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
|
|
5044
|
+
return result;
|
|
3540
5045
|
}
|
|
3541
5046
|
|
|
3542
5047
|
getEnvironmentVariables() {
|
|
@@ -3554,7 +5059,7 @@ export class ScopeDataStructure {
|
|
|
3554
5059
|
path: string;
|
|
3555
5060
|
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
3556
5061
|
comparedValues?: string[];
|
|
3557
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
5062
|
+
location: 'if' | 'ternary' | 'logical-and' | 'switch' | 'unconditional';
|
|
3558
5063
|
}>
|
|
3559
5064
|
>,
|
|
3560
5065
|
): void {
|
|
@@ -3579,29 +5084,149 @@ export class ScopeDataStructure {
|
|
|
3579
5084
|
}
|
|
3580
5085
|
|
|
3581
5086
|
/**
|
|
3582
|
-
*
|
|
3583
|
-
*
|
|
5087
|
+
* Add conditional effects from AST analysis.
|
|
5088
|
+
* Called during scope analysis to collect all setter calls inside conditionals.
|
|
3584
5089
|
*/
|
|
3585
|
-
|
|
5090
|
+
addConditionalEffects(
|
|
5091
|
+
effects: import('../astScopes/types').ConditionalEffect[],
|
|
5092
|
+
): void {
|
|
5093
|
+
// Add effects, avoiding duplicates based on effect stateVariable and condition paths
|
|
5094
|
+
for (const effect of effects) {
|
|
5095
|
+
const exists = this.rawConditionalEffects.some((existing) => {
|
|
5096
|
+
// Same effect target (stateVariable + value)
|
|
5097
|
+
const sameEffect =
|
|
5098
|
+
existing.effect.stateVariable === effect.effect.stateVariable &&
|
|
5099
|
+
existing.effect.value === effect.effect.value;
|
|
5100
|
+
if (!sameEffect) return false;
|
|
5101
|
+
|
|
5102
|
+
// Same condition(s)
|
|
5103
|
+
if (existing.condition && effect.condition) {
|
|
5104
|
+
return (
|
|
5105
|
+
existing.condition.path === effect.condition.path &&
|
|
5106
|
+
existing.condition.requiredValue === effect.condition.requiredValue
|
|
5107
|
+
);
|
|
5108
|
+
}
|
|
5109
|
+
if (existing.conditions && effect.conditions) {
|
|
5110
|
+
if (existing.conditions.length !== effect.conditions.length)
|
|
5111
|
+
return false;
|
|
5112
|
+
return existing.conditions.every((ec, i) => {
|
|
5113
|
+
const newCond = effect.conditions![i];
|
|
5114
|
+
return (
|
|
5115
|
+
ec.path === newCond.path &&
|
|
5116
|
+
ec.requiredValue === newCond.requiredValue
|
|
5117
|
+
);
|
|
5118
|
+
});
|
|
5119
|
+
}
|
|
5120
|
+
return false;
|
|
5121
|
+
});
|
|
5122
|
+
if (!exists) {
|
|
5123
|
+
this.rawConditionalEffects.push(effect);
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
|
|
5128
|
+
/**
|
|
5129
|
+
* Get conditional effects collected during analysis.
|
|
5130
|
+
*/
|
|
5131
|
+
getConditionalEffects(): import('../astScopes/types').ConditionalEffect[] {
|
|
5132
|
+
return this.rawConditionalEffects;
|
|
5133
|
+
}
|
|
5134
|
+
|
|
5135
|
+
/**
|
|
5136
|
+
* Add compound conditionals from AST analysis.
|
|
5137
|
+
* Called during scope analysis to collect grouped conditions (e.g., a && b && c).
|
|
5138
|
+
*/
|
|
5139
|
+
addCompoundConditionals(
|
|
5140
|
+
compounds: import('../astScopes/types').CompoundConditional[],
|
|
5141
|
+
): void {
|
|
5142
|
+
// Add compounds, avoiding duplicates based on chainId
|
|
5143
|
+
for (const compound of compounds) {
|
|
5144
|
+
const exists = this.rawCompoundConditionals.some(
|
|
5145
|
+
(existing) => existing.chainId === compound.chainId,
|
|
5146
|
+
);
|
|
5147
|
+
if (!exists) {
|
|
5148
|
+
this.rawCompoundConditionals.push(compound);
|
|
5149
|
+
}
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5152
|
+
|
|
5153
|
+
/**
|
|
5154
|
+
* Get compound conditionals collected during analysis.
|
|
5155
|
+
*/
|
|
5156
|
+
getCompoundConditionals(): import('../astScopes/types').CompoundConditional[] {
|
|
5157
|
+
return this.rawCompoundConditionals;
|
|
5158
|
+
}
|
|
5159
|
+
|
|
5160
|
+
/**
|
|
5161
|
+
* Add child boundary gating conditions from AST analysis.
|
|
5162
|
+
* These track which conditions must be true for a child component to render.
|
|
5163
|
+
*/
|
|
5164
|
+
addChildBoundaryGatingConditions(
|
|
5165
|
+
conditions: Record<string, import('../astScopes/types').ConditionalUsage[]>,
|
|
5166
|
+
): void {
|
|
5167
|
+
for (const [childName, usages] of Object.entries(conditions)) {
|
|
5168
|
+
if (!this.rawChildBoundaryGatingConditions[childName]) {
|
|
5169
|
+
this.rawChildBoundaryGatingConditions[childName] = [];
|
|
5170
|
+
}
|
|
5171
|
+
// Add usages, avoiding duplicates
|
|
5172
|
+
for (const usage of usages) {
|
|
5173
|
+
const exists = this.rawChildBoundaryGatingConditions[childName].some(
|
|
5174
|
+
(existing) =>
|
|
5175
|
+
existing.path === usage.path &&
|
|
5176
|
+
existing.conditionType === usage.conditionType &&
|
|
5177
|
+
existing.isNegated === usage.isNegated,
|
|
5178
|
+
);
|
|
5179
|
+
if (!exists) {
|
|
5180
|
+
this.rawChildBoundaryGatingConditions[childName].push(usage);
|
|
5181
|
+
}
|
|
5182
|
+
}
|
|
5183
|
+
}
|
|
5184
|
+
}
|
|
5185
|
+
|
|
5186
|
+
/**
|
|
5187
|
+
* Get enriched child boundary gating conditions with source tracing.
|
|
5188
|
+
* Similar to getEnrichedConditionalUsages but for gating conditions.
|
|
5189
|
+
*/
|
|
5190
|
+
getEnrichedChildBoundaryGatingConditions(): Record<
|
|
3586
5191
|
string,
|
|
3587
|
-
|
|
3588
|
-
path: string;
|
|
3589
|
-
conditionType: 'truthiness' | 'comparison' | 'switch';
|
|
3590
|
-
comparedValues?: string[];
|
|
3591
|
-
location: 'if' | 'ternary' | 'logical-and' | 'switch';
|
|
3592
|
-
sourceDataPath?: string;
|
|
3593
|
-
}>
|
|
5192
|
+
EnrichedConditionalUsage[]
|
|
3594
5193
|
> {
|
|
3595
|
-
const enriched: Record<
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
5194
|
+
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
5195
|
+
const rootScopeName = this.scopeTreeManager.getTree().name;
|
|
5196
|
+
|
|
5197
|
+
for (const [childName, usages] of Object.entries(
|
|
5198
|
+
this.rawChildBoundaryGatingConditions,
|
|
5199
|
+
)) {
|
|
5200
|
+
enriched[childName] = usages.map((usage) => {
|
|
5201
|
+
// Try to trace this path back to a data source
|
|
5202
|
+
const explanation = this.explainPath(rootScopeName, usage.path);
|
|
5203
|
+
|
|
5204
|
+
let sourceDataPath: string | undefined;
|
|
5205
|
+
if (explanation.source) {
|
|
5206
|
+
sourceDataPath = `${explanation.source.scope}.${explanation.source.path}`;
|
|
5207
|
+
}
|
|
5208
|
+
|
|
5209
|
+
return {
|
|
5210
|
+
...usage,
|
|
5211
|
+
sourceDataPath,
|
|
5212
|
+
};
|
|
5213
|
+
});
|
|
5214
|
+
}
|
|
5215
|
+
|
|
5216
|
+
return enriched;
|
|
5217
|
+
}
|
|
5218
|
+
|
|
5219
|
+
/**
|
|
5220
|
+
* Get enriched conditional usages with source tracing.
|
|
5221
|
+
* Uses explainPath to trace each local variable back to its data source.
|
|
5222
|
+
* Preserves all fields from the raw conditional usages including derivedFrom.
|
|
5223
|
+
*/
|
|
5224
|
+
getEnrichedConditionalUsages(): Record<string, EnrichedConditionalUsage[]> {
|
|
5225
|
+
const enriched: Record<string, EnrichedConditionalUsage[]> = {};
|
|
5226
|
+
|
|
5227
|
+
console.log(
|
|
5228
|
+
`[getEnrichedConditionalUsages] Processing ${Object.keys(this.rawConditionalUsages).length} conditional paths: [${Object.keys(this.rawConditionalUsages).join(', ')}]`,
|
|
5229
|
+
);
|
|
3605
5230
|
|
|
3606
5231
|
for (const [path, usages] of Object.entries(this.rawConditionalUsages)) {
|
|
3607
5232
|
// Try to trace this path back to a data source
|
|
@@ -3611,10 +5236,69 @@ export class ScopeDataStructure {
|
|
|
3611
5236
|
|
|
3612
5237
|
let sourceDataPath: string | undefined;
|
|
3613
5238
|
if (explanation.source) {
|
|
3614
|
-
|
|
3615
|
-
|
|
5239
|
+
const { scope, path: sourcePath } = explanation.source;
|
|
5240
|
+
|
|
5241
|
+
// Build initial path — avoid redundant prefix when path already contains the scope call
|
|
5242
|
+
let fullPath: string;
|
|
5243
|
+
if (sourcePath.startsWith(`${scope}(`)) {
|
|
5244
|
+
fullPath = sourcePath;
|
|
5245
|
+
} else {
|
|
5246
|
+
fullPath = `${scope}.${sourcePath}`;
|
|
5247
|
+
}
|
|
5248
|
+
|
|
5249
|
+
sourceDataPath = fullPath;
|
|
5250
|
+
console.log(
|
|
5251
|
+
`[getEnrichedConditionalUsages] "${path}" explainPath → scope="${scope}", sourcePath="${sourcePath}" → sourceDataPath="${sourceDataPath}"`,
|
|
5252
|
+
);
|
|
5253
|
+
} else {
|
|
5254
|
+
console.log(
|
|
5255
|
+
`[getEnrichedConditionalUsages] "${path}" explainPath → no source found`,
|
|
5256
|
+
);
|
|
5257
|
+
}
|
|
5258
|
+
|
|
5259
|
+
// If explainPath didn't find a useful external source (e.g., it traced to
|
|
5260
|
+
// useState or just to the component scope itself), check sourceEquivalencies
|
|
5261
|
+
// for an external function call source like a fetch call
|
|
5262
|
+
const hasExternalSource = sourceDataPath?.includes(
|
|
5263
|
+
'.functionCallReturnValue',
|
|
5264
|
+
);
|
|
5265
|
+
if (!hasExternalSource) {
|
|
5266
|
+
console.log(
|
|
5267
|
+
`[getEnrichedConditionalUsages] "${path}" no external source (sourceDataPath="${sourceDataPath}"), checking sourceEquivalencies fallback...`,
|
|
5268
|
+
);
|
|
5269
|
+
const sourceEquiv = this.getSourceEquivalencies();
|
|
5270
|
+
const returnValueKey = `returnValue.${path}`;
|
|
5271
|
+
const sources = sourceEquiv[returnValueKey];
|
|
5272
|
+
if (sources) {
|
|
5273
|
+
console.log(
|
|
5274
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] has ${sources.length} sources: [${sources.map((s: { schemaPath: string }) => s.schemaPath).join(', ')}]`,
|
|
5275
|
+
);
|
|
5276
|
+
const externalSource = sources.find(
|
|
5277
|
+
(s: { schemaPath: string }) =>
|
|
5278
|
+
s.schemaPath.includes('.functionCallReturnValue') &&
|
|
5279
|
+
!s.schemaPath.startsWith('useState('),
|
|
5280
|
+
);
|
|
5281
|
+
if (externalSource) {
|
|
5282
|
+
console.log(
|
|
5283
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found external source: "${externalSource.schemaPath}"`,
|
|
5284
|
+
);
|
|
5285
|
+
sourceDataPath = externalSource.schemaPath;
|
|
5286
|
+
} else {
|
|
5287
|
+
console.log(
|
|
5288
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies fallback found no external function call source`,
|
|
5289
|
+
);
|
|
5290
|
+
}
|
|
5291
|
+
} else {
|
|
5292
|
+
console.log(
|
|
5293
|
+
`[getEnrichedConditionalUsages] "${path}" sourceEquivalencies["${returnValueKey}"] not found`,
|
|
5294
|
+
);
|
|
5295
|
+
}
|
|
3616
5296
|
}
|
|
3617
5297
|
|
|
5298
|
+
console.log(
|
|
5299
|
+
`[getEnrichedConditionalUsages] "${path}" FINAL sourceDataPath="${sourceDataPath ?? '(none)'}" (${usages.length} usages)`,
|
|
5300
|
+
);
|
|
5301
|
+
|
|
3618
5302
|
enriched[path] = usages.map((usage) => ({
|
|
3619
5303
|
...usage,
|
|
3620
5304
|
sourceDataPath,
|
|
@@ -3624,35 +5308,86 @@ export class ScopeDataStructure {
|
|
|
3624
5308
|
return enriched;
|
|
3625
5309
|
}
|
|
3626
5310
|
|
|
5311
|
+
/**
|
|
5312
|
+
* Add JSX rendering usages from AST analysis.
|
|
5313
|
+
* These track arrays rendered via .map() and strings interpolated in JSX.
|
|
5314
|
+
*/
|
|
5315
|
+
addJsxRenderingUsages(
|
|
5316
|
+
usages: import('../astScopes/types').JsxRenderingUsage[],
|
|
5317
|
+
): void {
|
|
5318
|
+
// Add usages, avoiding duplicates based on path and renderingType
|
|
5319
|
+
for (const usage of usages) {
|
|
5320
|
+
const exists = this.rawJsxRenderingUsages.some(
|
|
5321
|
+
(existing) =>
|
|
5322
|
+
existing.path === usage.path &&
|
|
5323
|
+
existing.renderingType === usage.renderingType,
|
|
5324
|
+
);
|
|
5325
|
+
if (!exists) {
|
|
5326
|
+
this.rawJsxRenderingUsages.push(usage);
|
|
5327
|
+
}
|
|
5328
|
+
}
|
|
5329
|
+
}
|
|
5330
|
+
|
|
5331
|
+
/**
|
|
5332
|
+
* Get JSX rendering usages collected during analysis.
|
|
5333
|
+
*/
|
|
5334
|
+
getJsxRenderingUsages(): import('../astScopes/types').JsxRenderingUsage[] {
|
|
5335
|
+
return this.rawJsxRenderingUsages;
|
|
5336
|
+
}
|
|
5337
|
+
|
|
3627
5338
|
toSerializable(): SerializableDataStructure {
|
|
3628
|
-
// Helper to
|
|
5339
|
+
// Helper to clean cyScope and cyDuplicateKey from a string for output
|
|
5340
|
+
const cleanCyScope = (str: string): string =>
|
|
5341
|
+
this.replaceCyScopeInString(str).replace(/::cyDuplicateKey\d+::/g, '');
|
|
5342
|
+
|
|
5343
|
+
// Helper to convert ScopeVariable to SerializableScopeVariable (with cyScope cleaned)
|
|
3629
5344
|
const toSerializableVariable = (
|
|
3630
5345
|
vars:
|
|
3631
5346
|
| ScopeVariable[]
|
|
3632
5347
|
| Pick<ScopeVariable, 'scopeNodeName' | 'schemaPath'>[],
|
|
3633
5348
|
): SerializableScopeVariable[] =>
|
|
3634
5349
|
vars.map((v) => ({
|
|
3635
|
-
scopeNodeName: v.scopeNodeName,
|
|
3636
|
-
schemaPath: v.schemaPath,
|
|
5350
|
+
scopeNodeName: cleanCyScope(v.scopeNodeName),
|
|
5351
|
+
schemaPath: cleanCyScope(v.schemaPath),
|
|
3637
5352
|
}));
|
|
3638
5353
|
|
|
5354
|
+
// Helper to clean cyScope from all keys in a schema
|
|
5355
|
+
const cleanSchemaKeys = (
|
|
5356
|
+
schema: Record<string, string>,
|
|
5357
|
+
): Record<string, string> => {
|
|
5358
|
+
return Object.entries(schema).reduce(
|
|
5359
|
+
(acc, [key, value]) => {
|
|
5360
|
+
acc[cleanCyScope(key)] = value;
|
|
5361
|
+
return acc;
|
|
5362
|
+
},
|
|
5363
|
+
{} as Record<string, string>,
|
|
5364
|
+
);
|
|
5365
|
+
};
|
|
5366
|
+
|
|
3639
5367
|
// Helper to get function result for a given function name
|
|
3640
5368
|
const getFunctionResult = (
|
|
3641
5369
|
functionName?: string,
|
|
3642
5370
|
): SerializableFunctionResult => {
|
|
3643
5371
|
return {
|
|
3644
|
-
signature:
|
|
3645
|
-
|
|
5372
|
+
signature: cleanSchemaKeys(
|
|
5373
|
+
this.getFunctionSignature({ functionName }) ?? {},
|
|
5374
|
+
),
|
|
5375
|
+
signatureWithUnknowns: cleanSchemaKeys(
|
|
3646
5376
|
this.getFunctionSignature({ functionName, fillInUnknowns: true }) ??
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
5377
|
+
{},
|
|
5378
|
+
),
|
|
5379
|
+
returnValue: cleanSchemaKeys(
|
|
5380
|
+
this.getReturnValue({ functionName }) ?? {},
|
|
5381
|
+
),
|
|
5382
|
+
returnValueWithUnknowns: cleanSchemaKeys(
|
|
3650
5383
|
this.getReturnValue({ functionName, fillInUnknowns: true }) ?? {},
|
|
5384
|
+
),
|
|
3651
5385
|
usageEquivalencies: Object.entries(
|
|
3652
5386
|
this.getUsageEquivalencies(functionName) ?? {},
|
|
3653
5387
|
).reduce(
|
|
3654
5388
|
(acc, [key, vars]) => {
|
|
3655
|
-
|
|
5389
|
+
// Clean cyScope from the key as well as variable properties
|
|
5390
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
3656
5391
|
return acc;
|
|
3657
5392
|
},
|
|
3658
5393
|
{} as Record<string, SerializableScopeVariable[]>,
|
|
@@ -3661,7 +5396,8 @@ export class ScopeDataStructure {
|
|
|
3661
5396
|
this.getSourceEquivalencies(functionName) ?? {},
|
|
3662
5397
|
).reduce(
|
|
3663
5398
|
(acc, [key, vars]) => {
|
|
3664
|
-
|
|
5399
|
+
// Clean cyScope from the key as well as variable properties
|
|
5400
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
3665
5401
|
return acc;
|
|
3666
5402
|
},
|
|
3667
5403
|
{} as Record<string, SerializableScopeVariable[]>,
|
|
@@ -3670,39 +5406,417 @@ export class ScopeDataStructure {
|
|
|
3670
5406
|
};
|
|
3671
5407
|
};
|
|
3672
5408
|
|
|
3673
|
-
// Convert external function calls
|
|
5409
|
+
// Convert external function calls - use getExternalFunctionCalls() which cleans cyScope
|
|
5410
|
+
const cleanedExternalCalls = this.getExternalFunctionCalls();
|
|
5411
|
+
|
|
5412
|
+
// Get root scope schema for building per-variable return value schemas
|
|
5413
|
+
const rootScopeName = this.scopeTreeManager.getRootName();
|
|
5414
|
+
const rootScope = this.scopeNodes[rootScopeName];
|
|
5415
|
+
const rootSchema = rootScope?.schema ?? {};
|
|
5416
|
+
|
|
3674
5417
|
const externalFunctionCalls: SerializableFunctionCallInfo[] =
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
5418
|
+
cleanedExternalCalls.map((efc) => {
|
|
5419
|
+
// Build perVariableSchemas from perCallSignatureSchemas when available.
|
|
5420
|
+
// This preserves distinct schemas per variable when the same function is called
|
|
5421
|
+
// multiple times with DIFFERENT call signatures (e.g., different type parameters).
|
|
5422
|
+
//
|
|
5423
|
+
// When field accesses happen in child scopes (like JSX expressions), the
|
|
5424
|
+
// rootSchema doesn't contain the detailed paths - they end up in child scope
|
|
5425
|
+
// schemas. Using perCallSignatureSchemas ensures we get the correct schema
|
|
5426
|
+
// for each call, regardless of where field accesses occur.
|
|
5427
|
+
let perVariableSchemas:
|
|
5428
|
+
| Record<string, Record<string, string>>
|
|
5429
|
+
| undefined;
|
|
5430
|
+
|
|
5431
|
+
// Use perCallSignatureSchemas only when:
|
|
5432
|
+
// 1. It exists and has distinct entries for different call signatures
|
|
5433
|
+
// 2. The number of distinct call signatures >= number of receiving variables
|
|
5434
|
+
//
|
|
5435
|
+
// This prevents using it when all calls have the same signature (e.g., useFetcher() x 2)
|
|
5436
|
+
// because in that case, perCallSignatureSchemas only has one entry.
|
|
5437
|
+
const numCallSignatures = efc.perCallSignatureSchemas
|
|
5438
|
+
? Object.keys(efc.perCallSignatureSchemas).length
|
|
5439
|
+
: 0;
|
|
5440
|
+
const numReceivingVars = efc.receivingVariableNames?.length ?? 0;
|
|
5441
|
+
const hasDistinctSchemas =
|
|
5442
|
+
numCallSignatures >= numReceivingVars && numCallSignatures > 1;
|
|
5443
|
+
|
|
5444
|
+
// CASE 1: Multiple call signatures with distinct schemas - use indexed variable names
|
|
5445
|
+
if (
|
|
5446
|
+
hasDistinctSchemas &&
|
|
5447
|
+
efc.perCallSignatureSchemas &&
|
|
5448
|
+
efc.callSignatureToVariable
|
|
5449
|
+
) {
|
|
5450
|
+
perVariableSchemas = {};
|
|
5451
|
+
|
|
5452
|
+
// Build a reverse map: variable -> array of call signatures (in order)
|
|
5453
|
+
// This handles the case where the same variable name is reused for different calls
|
|
5454
|
+
const varToCallSigs: Record<string, string[]> = {};
|
|
5455
|
+
for (const [callSig, varName] of Object.entries(
|
|
5456
|
+
efc.callSignatureToVariable,
|
|
5457
|
+
)) {
|
|
5458
|
+
if (!varToCallSigs[varName]) {
|
|
5459
|
+
varToCallSigs[varName] = [];
|
|
5460
|
+
}
|
|
5461
|
+
varToCallSigs[varName].push(callSig);
|
|
5462
|
+
}
|
|
5463
|
+
|
|
5464
|
+
// Track how many times each variable name has been seen
|
|
5465
|
+
const varNameCounts: Record<string, number> = {};
|
|
5466
|
+
|
|
5467
|
+
// For each receiving variable, get its original schema from perCallSignatureSchemas
|
|
5468
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
5469
|
+
const occurrence = varNameCounts[varName] ?? 0;
|
|
5470
|
+
varNameCounts[varName] = occurrence + 1;
|
|
5471
|
+
|
|
5472
|
+
const callSigs = varToCallSigs[varName];
|
|
5473
|
+
// Use the nth call signature for the nth occurrence of this variable
|
|
5474
|
+
const callSig = callSigs?.[occurrence];
|
|
5475
|
+
|
|
5476
|
+
if (callSig && efc.perCallSignatureSchemas[callSig]) {
|
|
5477
|
+
// Use indexed key if this variable name is reused (e.g., fetcher, fetcher[1])
|
|
5478
|
+
const key =
|
|
5479
|
+
occurrence === 0 ? varName : `${varName}[${occurrence}]`;
|
|
5480
|
+
// Clone the schema to avoid shared references
|
|
5481
|
+
perVariableSchemas[key] = {
|
|
5482
|
+
...efc.perCallSignatureSchemas[callSig],
|
|
5483
|
+
};
|
|
5484
|
+
}
|
|
5485
|
+
}
|
|
5486
|
+
|
|
5487
|
+
// Only include if we have entries for ALL receiving variables
|
|
5488
|
+
if (Object.keys(perVariableSchemas).length < numReceivingVars) {
|
|
5489
|
+
// Not all variables have schemas - fall back to rootSchema extraction
|
|
5490
|
+
perVariableSchemas = undefined;
|
|
5491
|
+
} else {
|
|
5492
|
+
// Also check that at least one schema is non-empty
|
|
5493
|
+
// Bug fix: perCallSignatureSchemas may have entries but with empty schemas {}
|
|
5494
|
+
// In this case, we should fall through to Fallback which uses rootSchema
|
|
5495
|
+
const hasNonEmptySchema = Object.values(perVariableSchemas).some(
|
|
5496
|
+
(schema) => Object.keys(schema).length > 0,
|
|
5497
|
+
);
|
|
5498
|
+
if (!hasNonEmptySchema) {
|
|
5499
|
+
perVariableSchemas = undefined;
|
|
5500
|
+
}
|
|
5501
|
+
}
|
|
5502
|
+
}
|
|
5503
|
+
|
|
5504
|
+
// CASE 2: Single call signature with single variable - use perCallSignatureSchemas directly
|
|
5505
|
+
// This handles parameterized calls like useFetcher<ConfigData>() where each is a separate efc entry
|
|
5506
|
+
if (
|
|
5507
|
+
!perVariableSchemas &&
|
|
5508
|
+
efc.perCallSignatureSchemas &&
|
|
5509
|
+
numCallSignatures === 1 &&
|
|
5510
|
+
numReceivingVars === 1
|
|
5511
|
+
) {
|
|
5512
|
+
const varName = efc.receivingVariableNames![0];
|
|
5513
|
+
const callSig = Object.keys(efc.perCallSignatureSchemas)[0];
|
|
5514
|
+
const schema = efc.perCallSignatureSchemas[callSig];
|
|
5515
|
+
if (schema && Object.keys(schema).length > 0) {
|
|
5516
|
+
perVariableSchemas = { [varName]: { ...schema } };
|
|
5517
|
+
}
|
|
5518
|
+
}
|
|
5519
|
+
|
|
5520
|
+
// CASE 3: Extract from efc.schema when perCallSignatureSchemas is missing or empty
|
|
5521
|
+
// This handles two scenarios:
|
|
5522
|
+
// 1. Parameterized calls that create SEPARATE efc entries (no perCallSignatureSchemas)
|
|
5523
|
+
// 2. Destructuring where perCallSignatureSchemas exists but has EMPTY schemas
|
|
5524
|
+
//
|
|
5525
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create separate
|
|
5526
|
+
// efc entries because getFunctionCallRoot preserves type parameters. Each entry has its own
|
|
5527
|
+
// `schema` field, but due to variable reassignment, the schema may be contaminated with paths
|
|
5528
|
+
// from other calls (the tracer attributes field accesses to ALL equivalencies).
|
|
5529
|
+
//
|
|
5530
|
+
// Solution: Filter efc.schema to only include paths that match THIS entry's call signature.
|
|
5531
|
+
// The schema paths include the full call signature prefix, so we can filter by it.
|
|
5532
|
+
//
|
|
5533
|
+
// Example: ConfigData entry has paths like:
|
|
5534
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.theme"
|
|
5535
|
+
// But also (contaminated):
|
|
5536
|
+
// "useFetcher<{ data: ConfigData | null }>().functionCallReturnValue.data.data.notifications"
|
|
5537
|
+
//
|
|
5538
|
+
// We filter to only keep paths that should belong to THIS call by checking if the
|
|
5539
|
+
// receiving variable's equivalency points to this call's return value.
|
|
5540
|
+
//
|
|
5541
|
+
// BUG FIX: The old condition `!efc.perCallSignatureSchemas` was FALSE when the object
|
|
5542
|
+
// existed (even with empty schemas), causing this case to be skipped. We now also check
|
|
5543
|
+
// if all schemas in perCallSignatureSchemas are empty.
|
|
5544
|
+
const hasNonEmptyPerCallSignatureSchemas =
|
|
5545
|
+
efc.perCallSignatureSchemas &&
|
|
5546
|
+
Object.values(efc.perCallSignatureSchemas).some(
|
|
5547
|
+
(schema) => Object.keys(schema).length > 0,
|
|
5548
|
+
);
|
|
5549
|
+
|
|
5550
|
+
// Build the call signature prefix that paths should start with
|
|
5551
|
+
const callSigPrefix = `${efc.callSignature}.functionCallReturnValue`;
|
|
5552
|
+
|
|
5553
|
+
// Check if efc.schema has variable-specific paths (indicating destructuring).
|
|
5554
|
+
// Destructuring: const { entities, gitStatus } = useLoaderData()
|
|
5555
|
+
// - efc.schema has paths like: useLoaderData().functionCallReturnValue.entities...
|
|
5556
|
+
// Multiple calls: const x = useFetcher(); const y = useFetcher();
|
|
5557
|
+
// - efc.schema has paths like: useFetcher().functionCallReturnValue.data...
|
|
5558
|
+
// CASE 3 should only run for destructuring (variable-specific paths exist).
|
|
5559
|
+
const hasVariableSpecificPaths = (
|
|
5560
|
+
efc.receivingVariableNames ?? []
|
|
5561
|
+
).some((varName) =>
|
|
5562
|
+
Object.keys(efc.schema).some((path) =>
|
|
5563
|
+
path.startsWith(`${callSigPrefix}.${varName}`),
|
|
5564
|
+
),
|
|
5565
|
+
);
|
|
5566
|
+
|
|
5567
|
+
if (
|
|
5568
|
+
!perVariableSchemas &&
|
|
5569
|
+
!hasNonEmptyPerCallSignatureSchemas &&
|
|
5570
|
+
numReceivingVars >= 1 &&
|
|
5571
|
+
hasVariableSpecificPaths
|
|
5572
|
+
) {
|
|
5573
|
+
// Filter efc.schema to only include paths matching this call signature
|
|
5574
|
+
const filteredSchema: Record<string, string> = {};
|
|
5575
|
+
for (const [path, type] of Object.entries(efc.schema)) {
|
|
5576
|
+
if (path.startsWith(callSigPrefix) || path === efc.callSignature) {
|
|
5577
|
+
filteredSchema[path] = type;
|
|
5578
|
+
}
|
|
5579
|
+
}
|
|
5580
|
+
|
|
5581
|
+
// Build perVariableSchemas from the filtered schema
|
|
5582
|
+
// For destructuring, filter paths by variable name
|
|
5583
|
+
if (Object.keys(filteredSchema).length > 0) {
|
|
5584
|
+
perVariableSchemas = {};
|
|
5585
|
+
for (const varName of efc.receivingVariableNames ?? []) {
|
|
5586
|
+
// For destructuring, extract only paths specific to this variable
|
|
5587
|
+
const varSpecificPrefix = `${callSigPrefix}.${varName}`;
|
|
5588
|
+
const varSchema: Record<string, string> = {};
|
|
5589
|
+
|
|
5590
|
+
for (const [path, type] of Object.entries(filteredSchema)) {
|
|
5591
|
+
if (path.startsWith(varSpecificPrefix)) {
|
|
5592
|
+
// Transform: useLoaderData().functionCallReturnValue.entities.sha
|
|
5593
|
+
// -> functionCallReturnValue.entities.sha (keep the variable name)
|
|
5594
|
+
const suffix = path.slice(callSigPrefix.length);
|
|
5595
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
5596
|
+
varSchema[returnValuePath] = type;
|
|
5597
|
+
} else if (path === efc.callSignature) {
|
|
5598
|
+
// Include the function call type itself
|
|
5599
|
+
varSchema[path] = type;
|
|
5600
|
+
}
|
|
5601
|
+
}
|
|
5602
|
+
if (Object.keys(varSchema).length > 0) {
|
|
5603
|
+
perVariableSchemas[varName] = varSchema;
|
|
5604
|
+
}
|
|
5605
|
+
}
|
|
5606
|
+
// Only include if we have entries
|
|
5607
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
5608
|
+
perVariableSchemas = undefined;
|
|
5609
|
+
}
|
|
5610
|
+
}
|
|
5611
|
+
}
|
|
5612
|
+
|
|
5613
|
+
// Fallback: extract from root scope schema when perCallSignatureSchemas is not available
|
|
5614
|
+
// or doesn't have distinct entries for each variable.
|
|
5615
|
+
// This works when field accesses are in the root scope.
|
|
5616
|
+
if (
|
|
5617
|
+
!perVariableSchemas &&
|
|
5618
|
+
efc.receivingVariableNames &&
|
|
5619
|
+
efc.receivingVariableNames.length > 0
|
|
5620
|
+
) {
|
|
5621
|
+
perVariableSchemas = {};
|
|
5622
|
+
for (const varName of efc.receivingVariableNames) {
|
|
5623
|
+
const varSchema: Record<string, string> = {};
|
|
5624
|
+
for (const [path, type] of Object.entries(rootSchema)) {
|
|
5625
|
+
// Check if path starts with this variable name
|
|
5626
|
+
if (
|
|
5627
|
+
path === varName ||
|
|
5628
|
+
path.startsWith(varName + '.') ||
|
|
5629
|
+
path.startsWith(varName + '[')
|
|
5630
|
+
) {
|
|
5631
|
+
// Transform to functionCallReturnValue format
|
|
5632
|
+
// e.g., userFetcher.data.id -> functionCallReturnValue.data.id
|
|
5633
|
+
const suffix = path.slice(varName.length);
|
|
5634
|
+
const returnValuePath = `functionCallReturnValue${suffix}`;
|
|
5635
|
+
varSchema[returnValuePath] = type;
|
|
5636
|
+
}
|
|
5637
|
+
}
|
|
5638
|
+
if (Object.keys(varSchema).length > 0) {
|
|
5639
|
+
// Clean the variable name when using as key in output
|
|
5640
|
+
perVariableSchemas[cleanCyScope(varName)] = varSchema;
|
|
5641
|
+
}
|
|
5642
|
+
}
|
|
5643
|
+
// Only include if we have any entries
|
|
5644
|
+
if (Object.keys(perVariableSchemas).length === 0) {
|
|
5645
|
+
perVariableSchemas = undefined;
|
|
5646
|
+
}
|
|
5647
|
+
}
|
|
5648
|
+
|
|
5649
|
+
// Enrich the schema with inferred types by applying fillInSchemaGapsAndUnknowns.
|
|
5650
|
+
// This ensures the serialized schema has the same type inference as getReturnValue().
|
|
5651
|
+
// Without this, evidence like "entities[].analyses: array" becomes "unknown".
|
|
5652
|
+
const enrichedSchema = { ...efc.schema };
|
|
5653
|
+
const tempScopeNode = {
|
|
5654
|
+
name: efc.name,
|
|
5655
|
+
schema: enrichedSchema,
|
|
5656
|
+
equivalencies: efc.equivalencies ?? {},
|
|
5657
|
+
};
|
|
5658
|
+
fillInSchemaGapsAndUnknowns(tempScopeNode, true);
|
|
5659
|
+
|
|
5660
|
+
return {
|
|
5661
|
+
name: efc.name,
|
|
5662
|
+
callSignature: efc.callSignature,
|
|
5663
|
+
callScope: efc.callScope,
|
|
5664
|
+
schema: enrichedSchema,
|
|
5665
|
+
equivalencies: efc.equivalencies
|
|
5666
|
+
? Object.entries(efc.equivalencies).reduce(
|
|
5667
|
+
(acc, [key, vars]) => {
|
|
5668
|
+
// Clean cyScope from the key as well as variable properties
|
|
5669
|
+
acc[cleanCyScope(key)] = toSerializableVariable(vars);
|
|
5670
|
+
return acc;
|
|
5671
|
+
},
|
|
5672
|
+
{} as Record<string, SerializableScopeVariable[]>,
|
|
5673
|
+
)
|
|
5674
|
+
: undefined,
|
|
5675
|
+
allCallSignatures: efc.allCallSignatures,
|
|
5676
|
+
receivingVariableNames: efc.receivingVariableNames?.map(cleanCyScope),
|
|
5677
|
+
callSignatureToVariable: efc.callSignatureToVariable
|
|
5678
|
+
? Object.fromEntries(
|
|
5679
|
+
Object.entries(efc.callSignatureToVariable).map(([k, v]) => [
|
|
5680
|
+
k,
|
|
5681
|
+
cleanCyScope(v),
|
|
5682
|
+
]),
|
|
5683
|
+
)
|
|
5684
|
+
: undefined,
|
|
5685
|
+
perVariableSchemas,
|
|
5686
|
+
};
|
|
5687
|
+
});
|
|
5688
|
+
|
|
5689
|
+
// POST-PROCESSING: Deduplicate schemas across parameterized calls to same base function
|
|
5690
|
+
// When useFetcher<ConfigData>() and useFetcher<SettingsData>() are called, they create
|
|
5691
|
+
// separate entries. Due to variable reassignment, BOTH entries may have ALL fields.
|
|
5692
|
+
// We deduplicate by assigning each field to ONLY ONE entry based on order of appearance.
|
|
5693
|
+
//
|
|
5694
|
+
// Strategy: Fields that appear first in order belong to the first entry,
|
|
5695
|
+
// fields that appear later belong to later entries (split evenly).
|
|
5696
|
+
const deduplicateParameterizedEntries = (
|
|
5697
|
+
entries: typeof externalFunctionCalls,
|
|
5698
|
+
): typeof externalFunctionCalls => {
|
|
5699
|
+
// Group entries by base function name (without type parameters)
|
|
5700
|
+
const groups = new Map<string, typeof externalFunctionCalls>();
|
|
5701
|
+
for (const entry of entries) {
|
|
5702
|
+
// Extract base function name by stripping type parameters
|
|
5703
|
+
// e.g., "useFetcher<{ data: ConfigData | null }>" -> "useFetcher"
|
|
5704
|
+
const baseName = entry.name.replace(/<.*>$/, '');
|
|
5705
|
+
const group = groups.get(baseName) || [];
|
|
5706
|
+
group.push(entry);
|
|
5707
|
+
groups.set(baseName, group);
|
|
5708
|
+
}
|
|
5709
|
+
|
|
5710
|
+
// Process groups with multiple parameterized entries
|
|
5711
|
+
for (const [, group] of groups) {
|
|
5712
|
+
if (group.length <= 1) continue;
|
|
5713
|
+
|
|
5714
|
+
// Check if these are parameterized calls (have type parameters in name)
|
|
5715
|
+
const hasTypeParams = group.every((e) => e.name.includes('<'));
|
|
5716
|
+
if (!hasTypeParams) continue;
|
|
5717
|
+
|
|
5718
|
+
// Collect ALL unique field suffixes across all entries (in order of first appearance)
|
|
5719
|
+
// Field suffix is the path after functionCallReturnValue, e.g., ".data.data.theme"
|
|
5720
|
+
const allFieldSuffixes: string[] = [];
|
|
5721
|
+
for (const entry of group) {
|
|
5722
|
+
if (!entry.perVariableSchemas) continue;
|
|
5723
|
+
for (const varSchema of Object.values(entry.perVariableSchemas)) {
|
|
5724
|
+
for (const path of Object.keys(varSchema)) {
|
|
5725
|
+
// Skip the base "functionCallReturnValue" entry
|
|
5726
|
+
if (path === 'functionCallReturnValue') continue;
|
|
5727
|
+
// Extract field suffix
|
|
5728
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
5729
|
+
if (!match) continue;
|
|
5730
|
+
const fieldSuffix = match[1];
|
|
5731
|
+
if (!allFieldSuffixes.includes(fieldSuffix)) {
|
|
5732
|
+
allFieldSuffixes.push(fieldSuffix);
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5737
|
+
|
|
5738
|
+
// Assign fields to entries: split evenly based on order
|
|
5739
|
+
// First N/2 fields go to first entry, remaining go to second entry
|
|
5740
|
+
const fieldToEntryMap = new Map<string, number>();
|
|
5741
|
+
const fieldsPerEntry = Math.ceil(
|
|
5742
|
+
allFieldSuffixes.length / group.length,
|
|
5743
|
+
);
|
|
5744
|
+
for (let i = 0; i < allFieldSuffixes.length; i++) {
|
|
5745
|
+
const fieldSuffix = allFieldSuffixes[i];
|
|
5746
|
+
const entryIdx = Math.min(
|
|
5747
|
+
Math.floor(i / fieldsPerEntry),
|
|
5748
|
+
group.length - 1,
|
|
5749
|
+
);
|
|
5750
|
+
fieldToEntryMap.set(fieldSuffix, entryIdx);
|
|
5751
|
+
}
|
|
5752
|
+
|
|
5753
|
+
// Filter each entry's perVariableSchemas to only include its assigned fields
|
|
5754
|
+
for (let i = 0; i < group.length; i++) {
|
|
5755
|
+
const entry = group[i];
|
|
5756
|
+
if (!entry.perVariableSchemas) continue;
|
|
5757
|
+
|
|
5758
|
+
const filteredPerVarSchemas: Record<
|
|
5759
|
+
string,
|
|
5760
|
+
Record<string, string>
|
|
5761
|
+
> = {};
|
|
5762
|
+
for (const [varName, varSchema] of Object.entries(
|
|
5763
|
+
entry.perVariableSchemas,
|
|
5764
|
+
)) {
|
|
5765
|
+
const filteredVarSchema: Record<string, string> = {};
|
|
5766
|
+
for (const [path, type] of Object.entries(varSchema)) {
|
|
5767
|
+
// Always keep the base functionCallReturnValue
|
|
5768
|
+
if (path === 'functionCallReturnValue') {
|
|
5769
|
+
filteredVarSchema[path] = type;
|
|
5770
|
+
continue;
|
|
5771
|
+
}
|
|
5772
|
+
// Extract field suffix
|
|
5773
|
+
const match = path.match(/functionCallReturnValue(.+)/);
|
|
5774
|
+
if (!match) {
|
|
5775
|
+
// Keep non-field paths
|
|
5776
|
+
filteredVarSchema[path] = type;
|
|
5777
|
+
continue;
|
|
5778
|
+
}
|
|
5779
|
+
const fieldSuffix = match[1];
|
|
5780
|
+
// Only include if this entry owns this field
|
|
5781
|
+
if (fieldToEntryMap.get(fieldSuffix) === i) {
|
|
5782
|
+
filteredVarSchema[path] = type;
|
|
5783
|
+
}
|
|
5784
|
+
}
|
|
5785
|
+
if (Object.keys(filteredVarSchema).length > 0) {
|
|
5786
|
+
filteredPerVarSchemas[varName] = filteredVarSchema;
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5789
|
+
entry.perVariableSchemas =
|
|
5790
|
+
Object.keys(filteredPerVarSchemas).length > 0
|
|
5791
|
+
? filteredPerVarSchemas
|
|
5792
|
+
: undefined;
|
|
5793
|
+
}
|
|
5794
|
+
}
|
|
5795
|
+
|
|
5796
|
+
return entries;
|
|
5797
|
+
};
|
|
5798
|
+
|
|
5799
|
+
// Apply deduplication
|
|
5800
|
+
const deduplicatedExternalFunctionCalls = deduplicateParameterizedEntries(
|
|
5801
|
+
externalFunctionCalls,
|
|
5802
|
+
);
|
|
5803
|
+
|
|
5804
|
+
// IMPORTANT: Get equivalent signature variables BEFORE calling getFunctionResult
|
|
5805
|
+
// because getFunctionResult calls validateSchema which may remove equivalencies
|
|
5806
|
+
// during the finalize step (e.g., cleanNonObjectFunctions removes method call
|
|
5807
|
+
// equivalencies like `segments -> splat.split('/').functionCallReturnValue`).
|
|
5808
|
+
// Fix 33: Move this call before any schema validation to preserve method call chains.
|
|
5809
|
+
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
3693
5810
|
|
|
3694
5811
|
// Get root function result
|
|
3695
5812
|
const rootFunction = getFunctionResult();
|
|
3696
5813
|
|
|
3697
|
-
// Get results for each external function
|
|
5814
|
+
// Get results for each external function (use cleaned calls for consistency)
|
|
3698
5815
|
const functionResults: Record<string, SerializableFunctionResult> = {};
|
|
3699
|
-
for (const efc of
|
|
5816
|
+
for (const efc of cleanedExternalCalls) {
|
|
3700
5817
|
functionResults[efc.name] = getFunctionResult(efc.name);
|
|
3701
5818
|
}
|
|
3702
5819
|
|
|
3703
|
-
// Get equivalent signature variables
|
|
3704
|
-
const equivalentSignatureVariables = this.getEquivalentSignatureVariables();
|
|
3705
|
-
|
|
3706
5820
|
const environmentVariables = this.getEnvironmentVariables();
|
|
3707
5821
|
|
|
3708
5822
|
// Get enriched conditional usages with source tracing
|
|
@@ -3712,13 +5826,43 @@ export class ScopeDataStructure {
|
|
|
3712
5826
|
? enrichedConditionalUsages
|
|
3713
5827
|
: undefined;
|
|
3714
5828
|
|
|
5829
|
+
// Get conditional effects (setter calls inside conditionals)
|
|
5830
|
+
const conditionalEffects =
|
|
5831
|
+
this.rawConditionalEffects.length > 0
|
|
5832
|
+
? this.rawConditionalEffects
|
|
5833
|
+
: undefined;
|
|
5834
|
+
|
|
5835
|
+
// Get compound conditionals (grouped conditions that must all be true)
|
|
5836
|
+
const compoundConditionals =
|
|
5837
|
+
this.rawCompoundConditionals.length > 0
|
|
5838
|
+
? this.rawCompoundConditionals
|
|
5839
|
+
: undefined;
|
|
5840
|
+
|
|
5841
|
+
// Get child boundary gating conditions
|
|
5842
|
+
const enrichedGatingConditions =
|
|
5843
|
+
this.getEnrichedChildBoundaryGatingConditions();
|
|
5844
|
+
const childBoundaryGatingConditions =
|
|
5845
|
+
Object.keys(enrichedGatingConditions).length > 0
|
|
5846
|
+
? enrichedGatingConditions
|
|
5847
|
+
: undefined;
|
|
5848
|
+
|
|
5849
|
+
// Get JSX rendering usages (arrays via .map(), strings via interpolation)
|
|
5850
|
+
const jsxRenderingUsages =
|
|
5851
|
+
this.rawJsxRenderingUsages.length > 0
|
|
5852
|
+
? this.rawJsxRenderingUsages
|
|
5853
|
+
: undefined;
|
|
5854
|
+
|
|
3715
5855
|
return {
|
|
3716
|
-
externalFunctionCalls,
|
|
5856
|
+
externalFunctionCalls: deduplicatedExternalFunctionCalls,
|
|
3717
5857
|
rootFunction,
|
|
3718
5858
|
functionResults,
|
|
3719
5859
|
equivalentSignatureVariables,
|
|
3720
5860
|
environmentVariables,
|
|
3721
5861
|
conditionalUsages,
|
|
5862
|
+
conditionalEffects,
|
|
5863
|
+
compoundConditionals,
|
|
5864
|
+
childBoundaryGatingConditions,
|
|
5865
|
+
jsxRenderingUsages,
|
|
3722
5866
|
};
|
|
3723
5867
|
}
|
|
3724
5868
|
|