@codeyam/codeyam-cli 0.1.0-staging.323686 → 0.1.0-staging.4813bf3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +5 -5
- package/analyzer-template/packages/ai/index.ts +7 -1
- package/analyzer-template/packages/ai/package.json +2 -2
- package/analyzer-template/packages/ai/src/lib/analyzeScope.ts +62 -18
- package/analyzer-template/packages/ai/src/lib/astScopes/astScopeAnalyzer.ts +67 -9
- package/analyzer-template/packages/ai/src/lib/astScopes/patterns/forInStatementHandler.ts +10 -17
- package/analyzer-template/packages/ai/src/lib/astScopes/processExpression.ts +409 -50
- package/analyzer-template/packages/ai/src/lib/astScopes/sharedPatterns.ts +28 -0
- package/analyzer-template/packages/ai/src/lib/astScopes/types.ts +21 -6
- package/analyzer-template/packages/ai/src/lib/dataStructure/ScopeDataStructure.ts +992 -249
- package/analyzer-template/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.ts +5 -1
- 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 +31 -3
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.ts +37 -15
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/coerceObjectsToPrimitivesBySchema.ts +70 -0
- package/analyzer-template/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.ts +126 -11
- 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 +367 -96
- package/analyzer-template/packages/ai/src/lib/dataStructureChunking.ts +33 -15
- package/analyzer-template/packages/ai/src/lib/generateEntityDataStructure.ts +58 -3
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarioData.ts +315 -6
- package/analyzer-template/packages/ai/src/lib/generateEntityScenarios.ts +9 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlows.ts +49 -5
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionalEffects.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromConditionals.ts +649 -142
- package/analyzer-template/packages/ai/src/lib/generateExecutionFlowsFromJsxUsages.ts +1 -1
- package/analyzer-template/packages/ai/src/lib/isolateScopes.ts +51 -3
- package/analyzer-template/packages/ai/src/lib/mergeJsonTypeDefinitions.ts +5 -0
- package/analyzer-template/packages/ai/src/lib/mergeStatements.ts +90 -96
- package/analyzer-template/packages/ai/src/lib/promptGenerators/collapseNullableObjects.ts +118 -0
- package/analyzer-template/packages/ai/src/lib/promptGenerators/gatherAttributesMap.ts +10 -7
- package/analyzer-template/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.ts +24 -4
- package/analyzer-template/packages/ai/src/lib/resolvePathToControllable.ts +25 -13
- package/analyzer-template/packages/ai/src/lib/worker/SerializableDataStructure.ts +4 -3
- package/analyzer-template/packages/analyze/index.ts +2 -0
- package/analyzer-template/packages/analyze/src/lib/FileAnalyzer.ts +65 -59
- package/analyzer-template/packages/analyze/src/lib/ProjectAnalyzer.ts +113 -26
- 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 +89 -9
- package/analyzer-template/packages/analyze/src/lib/files/analyze/analyzeEntities.ts +19 -4
- package/analyzer-template/packages/analyze/src/lib/files/analyze/gatherEntityMap.ts +4 -2
- package/analyzer-template/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.ts +0 -3
- package/analyzer-template/packages/analyze/src/lib/files/analyzeRemixRoute.ts +4 -5
- package/analyzer-template/packages/analyze/src/lib/files/getImportedExports.ts +14 -12
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/TransformationTracer.ts +1315 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.ts +61 -13
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.ts +37 -0
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateDataStructure.ts +229 -19
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.ts +117 -9
- package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts +459 -39
- 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/package.json +1 -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 +6 -0
- package/analyzer-template/packages/database/src/lib/kysely/tables/debugReportsTable.ts +1 -1
- package/analyzer-template/packages/database/src/lib/kysely/tables/labsRequestsTable.ts +52 -0
- 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/userScenarioToDb.ts +1 -1
- 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 +2 -0
- 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 +3 -0
- 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/tables/debugReportsTable.d.ts +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/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/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/ScenariosDataStructure.d.ts +5 -5
- 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/package.json +1 -1
- package/analyzer-template/packages/types/src/types/ProjectMetadata.ts +7 -0
- package/analyzer-template/packages/types/src/types/ScenariosDataStructure.ts +6 -5
- package/analyzer-template/packages/types/src/types/ScopeAnalysis.ts +6 -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/ScenariosDataStructure.d.ts +5 -5
- 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/project/constructMockCode.ts +90 -10
- package/analyzer-template/project/writeMockDataTsx.ts +181 -8
- package/analyzer-template/project/writeScenarioComponents.ts +60 -12
- package/analyzer-template/project/writeSimpleRoot.ts +21 -11
- package/background/src/lib/local/createLocalAnalyzer.js +1 -1
- package/background/src/lib/local/createLocalAnalyzer.js.map +1 -1
- package/background/src/lib/virtualized/project/constructMockCode.js +75 -4
- package/background/src/lib/virtualized/project/constructMockCode.js.map +1 -1
- package/background/src/lib/virtualized/project/writeMockDataTsx.js +162 -4
- package/background/src/lib/virtualized/project/writeMockDataTsx.js.map +1 -1
- package/background/src/lib/virtualized/project/writeScenarioComponents.js +60 -15
- package/background/src/lib/virtualized/project/writeScenarioComponents.js.map +1 -1
- package/background/src/lib/virtualized/project/writeSimpleRoot.js +21 -11
- package/background/src/lib/virtualized/project/writeSimpleRoot.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 +2 -0
- 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 +4 -2
- package/codeyam-cli/src/commands/analyze.js.map +1 -1
- package/codeyam-cli/src/commands/baseline.js +2 -0
- package/codeyam-cli/src/commands/baseline.js.map +1 -1
- package/codeyam-cli/src/commands/debug.js +9 -5
- package/codeyam-cli/src/commands/debug.js.map +1 -1
- package/codeyam-cli/src/commands/default.js +31 -20
- 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 +17 -26
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- package/codeyam-cli/src/commands/recapture.js +2 -0
- package/codeyam-cli/src/commands/recapture.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/test-startup.js +2 -0
- 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/utils/__tests__/setupClaudeCodeSettings.test.js +128 -86
- package/codeyam-cli/src/utils/__tests__/setupClaudeCodeSettings.test.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 +5 -0
- package/codeyam-cli/src/utils/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/utils/generateReport.js +2 -2
- package/codeyam-cli/src/utils/install-skills.js +70 -45
- 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/progress.js +7 -0
- package/codeyam-cli/src/utils/progress.js.map +1 -1
- package/codeyam-cli/src/utils/queue/job.js +4 -0
- package/codeyam-cli/src/utils/queue/job.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 +115 -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 +1 -0
- package/codeyam-cli/src/utils/rules/index.js.map +1 -1
- package/codeyam-cli/src/utils/rules/parser.js +2 -25
- package/codeyam-cli/src/utils/rules/parser.js.map +1 -1
- 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 +16 -11
- package/codeyam-cli/src/utils/rules/staleness.js.map +1 -1
- 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 -44
- package/codeyam-cli/src/utils/setupClaudeCodeSettings.js.map +1 -1
- package/codeyam-cli/src/webserver/app/lib/database.js +15 -3
- package/codeyam-cli/src/webserver/app/lib/database.js.map +1 -1
- package/codeyam-cli/src/webserver/backgroundServer.js +24 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/CopyButton-CA3JxPb7.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-DsN1wKrm.js → EntityItem-B86KKU7e.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-DLqD3qNt.js → EntityTypeBadge-B5ctlSYt.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-Ba2JVPzP.js → EntityTypeIcon-BqY8gDAW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-C8lyxW9k.js → InlineSpinner-ClaLpuOo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-aht4aafF.js → InteractivePreview-BDhPilK7.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-CVtiBnY5.js → LibraryFunctionPreview-VeqEBv9v.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-B0GLXMsr.js → LoadingDots-Bs7Nn1Jr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-xgeCVgSM.js → LogViewer-Bm3PmcCz.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-OApQuNyq.js → ReportIssueModal-CgMEzchJ.js} +3 -8
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-DuDvi0jm.js → SafeScreenshot-Gq3Ocjo6.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-DzccYyI8.js → ScenarioViewer-CBui0id_.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-DyFZkK0l.js → TruncatedFilePath-CiwXDxLh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BwqWJOgH.js → _index-B3TDXxnk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-BwavGCpm.js → activity.(_tab)-BtBFH820.js} +6 -11
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-CN61MOMa.js +11 -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.labs-unlock-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-PttOB2SF.js +6 -0
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-Cx24_aWc.js → chevron-down-TJp6ofnp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-EPOLDU6W-CXRTFQ3F.js → chunk-JZWAC4HX-JE9ZIoBl.js} +12 -12
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-BOARzkeR.js → circle-check-CXhHQYrI.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/copy-6y9ALfGT.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-BdhJEx6B.js → createLucideIcon-Ca9fAY46.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-BBnGWYga.js → dev.empty-C0epRiVn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-BJUiQqZF.js → entity._sha._-BVnB8a9L.js} +10 -10
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DavjRmOY.js → entity._sha.scenarios._scenarioId.fullscreen-CBoafmVs.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-D1T4TGjf.js → entity._sha_.create-scenario-DGgZjdFg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-CTBG2mmz.js → entity._sha_.edit._scenarioId-38yPijoD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-CS2cb_eZ.js → entry.client-BSHEfydn.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-DMJ7zii9.js → fileTableUtils-DCPhhSMo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-CJ6lTdTA.js → files-0N0YJQv7.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-CPTZZ-JZ.js → git-DXnyr8uP.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CKT08Djd.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-lzqtyFU8.js → index-CcsFv748.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-B1h680n5.js → index-ChN9-fAY.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/labs-BLJ7HxOC.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-B7B9V-bu.js → loader-circle-CTqLEAGU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-b171b9d3.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-CCQd4aZA.js +78 -0
- package/codeyam-cli/src/webserver/build/client/assets/pause-D6vreykR.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/root-CHhiHoo_.js +62 -0
- package/codeyam-cli/src/webserver/build/client/assets/{search-CxXUmBSd.js → search-B8VUL8nl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BejnUJ6R.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DwFIBT09.js → simulations-CPoAg7Zo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/terminal-BrCP7uQo.js +11 -0
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-B6LgvRJg.js → triangle-alert-BZz2NjYa.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-C1v1PQzo.js → useCustomSizes-DNwUduNu.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-aSv48UbS.js → useLastLogLine-COky1GVF.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DYxHZQuP.js → useReportContext-CpZgwliL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-mBRpZPiu.js → useToast-Bv9JFvUO.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-DVzYx8PN.js → index-8Fv-lH1-.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-Akn3iYFP.js +257 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/{codeyam:debug.md → codeyam-debug.md} +1 -1
- package/codeyam-cli/templates/codeyam-diagnose.md +481 -0
- package/codeyam-cli/templates/codeyam-memory-hook.sh +19 -20
- package/codeyam-cli/templates/codeyam-memory.md +392 -0
- package/codeyam-cli/templates/codeyam-new-rule.md +13 -0
- package/codeyam-cli/templates/{codeyam:setup.md → codeyam-setup.md} +13 -1
- package/codeyam-cli/templates/{codeyam:sim.md → codeyam-sim.md} +1 -1
- package/codeyam-cli/templates/{codeyam:test.md → codeyam-test.md} +1 -1
- package/codeyam-cli/templates/{codeyam:verify.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 +2 -2
- package/packages/ai/index.js +3 -2
- package/packages/ai/index.js.map +1 -1
- package/packages/ai/src/lib/analyzeScope.js +50 -13
- package/packages/ai/src/lib/analyzeScope.js.map +1 -1
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.js +54 -8
- package/packages/ai/src/lib/astScopes/astScopeAnalyzer.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/processExpression.js +317 -44
- 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/dataStructure/ScopeDataStructure.js +763 -171
- package/packages/ai/src/lib/dataStructure/ScopeDataStructure.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.js +5 -1
- package/packages/ai/src/lib/dataStructure/equivalencyManagers/frameworks/JavascriptFrameworkManager.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 +33 -3
- package/packages/ai/src/lib/dataStructure/helpers/cleanKnownObjectFunctions.js.map +1 -1
- package/packages/ai/src/lib/dataStructure/helpers/cleanNonObjectFunctions.js +36 -11
- 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 +113 -11
- package/packages/ai/src/lib/dataStructure/helpers/convertDotNotation.js.map +1 -1
- 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 +309 -84
- package/packages/ai/src/lib/dataStructure/helpers/fillInSchemaGapsAndUnknowns.js.map +1 -1
- package/packages/ai/src/lib/dataStructureChunking.js +26 -11
- package/packages/ai/src/lib/dataStructureChunking.js.map +1 -1
- package/packages/ai/src/lib/generateEntityDataStructure.js +46 -2
- package/packages/ai/src/lib/generateEntityDataStructure.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarioData.js +227 -4
- package/packages/ai/src/lib/generateEntityScenarioData.js.map +1 -1
- package/packages/ai/src/lib/generateEntityScenarios.js +7 -1
- package/packages/ai/src/lib/generateEntityScenarios.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlows.js +26 -4
- package/packages/ai/src/lib/generateExecutionFlows.js.map +1 -1
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js +447 -80
- package/packages/ai/src/lib/generateExecutionFlowsFromConditionals.js.map +1 -1
- package/packages/ai/src/lib/isolateScopes.js +39 -3
- 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 +70 -51
- 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 +10 -4
- package/packages/ai/src/lib/promptGenerators/gatherAttributesMap.js.map +1 -1
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js +17 -2
- package/packages/ai/src/lib/promptGenerators/generateEntityScenarioDataGenerator.js.map +1 -1
- package/packages/ai/src/lib/resolvePathToControllable.js +24 -14
- package/packages/ai/src/lib/resolvePathToControllable.js.map +1 -1
- package/packages/ai/src/lib/worker/SerializableDataStructure.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 +60 -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/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 +65 -7
- package/packages/analyze/src/lib/files/analyze/analyzeEntities/prepareDataStructures.js.map +1 -1
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.js +17 -4
- package/packages/analyze/src/lib/files/analyze/analyzeEntities.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 +0 -3
- package/packages/analyze/src/lib/files/analyze/validateDependencyAnalyses.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/getImportedExports.js +11 -7
- 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 +56 -10
- package/packages/analyze/src/lib/files/scenarios/enrichArrayTypesFromChildSignatures.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js +33 -8
- package/packages/analyze/src/lib/files/scenarios/gatherDataForMocks.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js +150 -17
- package/packages/analyze/src/lib/files/scenarios/generateDataStructure.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js +56 -8
- package/packages/analyze/src/lib/files/scenarios/generateExecutionFlows.js.map +1 -1
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.js +399 -31
- package/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.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/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 +3 -0
- package/packages/database/src/lib/kysely/db.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/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/scripts/finalize-analyzer.cjs +8 -76
- package/codeyam-cli/src/webserver/build/client/assets/copy-Bb-80kDT.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/file-code-Dhef1kWN.js +0 -6
- package/codeyam-cli/src/webserver/build/client/assets/globals-D3yhhV8x.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-7522edd4.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-yxFcrxBX.js +0 -92
- package/codeyam-cli/src/webserver/build/client/assets/root-eVAaavTS.js +0 -62
- package/codeyam-cli/src/webserver/build/client/assets/settings-CS5f3WzT.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-4Cr0uToj.js +0 -257
- package/codeyam-cli/templates/codeyam:diagnose.md +0 -803
- package/codeyam-cli/templates/codeyam:memory.md +0 -462
- package/codeyam-cli/templates/codeyam:new-rule.md +0 -13
package/analyzer-template/packages/analyze/src/lib/files/scenarios/mergeInDependentDataStructure.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
} from '~codeyam/ai';
|
|
5
5
|
import { cleanKnownObjectFunctionsFromMapping } from '~codeyam/ai';
|
|
6
6
|
import { DataStructure, Entity, ReadonlyAnalysis } from '~codeyam/types';
|
|
7
|
+
import { transformationTracer } from './TransformationTracer';
|
|
7
8
|
|
|
8
9
|
export interface DataStructureInfo {
|
|
9
10
|
signatureSchema: { [key: string]: string };
|
|
@@ -40,6 +41,59 @@ function getTypeParameter(functionName: string): string | null {
|
|
|
40
41
|
return null;
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
// Primitive types that should not have child paths
|
|
45
|
+
const PRIMITIVE_TYPES = new Set([
|
|
46
|
+
'number',
|
|
47
|
+
'string',
|
|
48
|
+
'boolean',
|
|
49
|
+
'null',
|
|
50
|
+
'undefined',
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
// Check if a type string represents a primitive type
|
|
54
|
+
// Handles union types like "string | undefined" or "number | null"
|
|
55
|
+
function isPrimitiveType(typeStr: string): boolean {
|
|
56
|
+
if (PRIMITIVE_TYPES.has(typeStr)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
// Check union types - if ALL parts of the union are primitives, it's primitive
|
|
60
|
+
// e.g., "string | undefined" -> ["string", "undefined"] -> both are primitive -> true
|
|
61
|
+
// e.g., "object | null" -> ["object", "null"] -> object is not primitive -> false
|
|
62
|
+
if (typeStr.includes('|')) {
|
|
63
|
+
const parts = typeStr.split('|').map((p) => p.trim());
|
|
64
|
+
return parts.every((part) => PRIMITIVE_TYPES.has(part));
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Extract signature index from a path like "signature[0]" or "signature[0].foo"
|
|
70
|
+
// Returns the index number or undefined if not a signature path
|
|
71
|
+
function extractSignatureIndex(path: string): number | undefined {
|
|
72
|
+
const match = path.match(/^signature\[(\d+)\]/);
|
|
73
|
+
return match ? parseInt(match[1], 10) : undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check if a new schema path would go through a primitive type
|
|
77
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', then
|
|
78
|
+
// 'entities[].scenarioCount.sha' would go through a primitive and should be rejected
|
|
79
|
+
function wouldGoThroughPrimitive(
|
|
80
|
+
newPath: string,
|
|
81
|
+
schema: { [key: string]: string },
|
|
82
|
+
): boolean {
|
|
83
|
+
const pathParts = splitOutsideParenthesesAndArrays(newPath);
|
|
84
|
+
|
|
85
|
+
// Check each prefix of the path (excluding the full path itself)
|
|
86
|
+
for (let i = 1; i < pathParts.length; i++) {
|
|
87
|
+
const prefixPath = joinParenthesesAndArrays(pathParts.slice(0, i));
|
|
88
|
+
const prefixType = schema[prefixPath];
|
|
89
|
+
if (prefixType && isPrimitiveType(prefixType)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
43
97
|
// Check if schemaPathPart matches or is a function call variant of pathPart
|
|
44
98
|
// e.g., 'isEntityBeingAnalyzed(entity.sha)' matches 'isEntityBeingAnalyzed'
|
|
45
99
|
function pathPartMatches(pathPart: string, schemaPathPart: string): boolean {
|
|
@@ -57,10 +111,14 @@ function bestValueFromOptions(options: Array<string | undefined>) {
|
|
|
57
111
|
options = options.filter(Boolean) as string[];
|
|
58
112
|
|
|
59
113
|
const known = options.find((o) => !o.includes('unknown'));
|
|
60
|
-
if (known)
|
|
114
|
+
if (known) {
|
|
115
|
+
return known;
|
|
116
|
+
}
|
|
61
117
|
|
|
62
118
|
const notUnknown = options.find((o) => o !== 'unknown');
|
|
63
|
-
if (notUnknown)
|
|
119
|
+
if (notUnknown) {
|
|
120
|
+
return notUnknown;
|
|
121
|
+
}
|
|
64
122
|
|
|
65
123
|
return options[0] ?? 'unknown';
|
|
66
124
|
}
|
|
@@ -152,10 +210,21 @@ export default function mergeInDependentDataStructure({
|
|
|
152
210
|
equivalentPostfixes: Record<string, string>;
|
|
153
211
|
}[] = [];
|
|
154
212
|
|
|
213
|
+
// Pre-build a lookup map from cleaned function name to dependency for O(1) lookups.
|
|
214
|
+
// This avoids O(n) linear search in findRelevantDependency which was causing O(n²) performance.
|
|
215
|
+
const dependencyByCleanedName = new Map<
|
|
216
|
+
string,
|
|
217
|
+
(typeof importedExports)[0]
|
|
218
|
+
>();
|
|
219
|
+
for (const dep of importedExports) {
|
|
220
|
+
const cleanedName = cleanFunctionName(dep.name);
|
|
221
|
+
if (!dependencyByCleanedName.has(cleanedName)) {
|
|
222
|
+
dependencyByCleanedName.set(cleanedName, dep);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
155
226
|
const findRelevantDependency = (functionName: any) => {
|
|
156
|
-
return
|
|
157
|
-
(d) => cleanFunctionName(d.name) === cleanFunctionName(functionName),
|
|
158
|
-
);
|
|
227
|
+
return dependencyByCleanedName.get(cleanFunctionName(functionName));
|
|
159
228
|
};
|
|
160
229
|
|
|
161
230
|
const findRelevantDependentDataStructure = (functionName: any) => {
|
|
@@ -192,8 +261,17 @@ export default function mergeInDependentDataStructure({
|
|
|
192
261
|
return mergedDataStructure.dependencySchemas[filePath][name];
|
|
193
262
|
};
|
|
194
263
|
|
|
195
|
-
const cleanSchema = (
|
|
196
|
-
|
|
264
|
+
const cleanSchema = (
|
|
265
|
+
schema: { [key: string]: string },
|
|
266
|
+
context?: Record<string, any>,
|
|
267
|
+
) => {
|
|
268
|
+
transformationTracer.traceSchemaTransform(
|
|
269
|
+
rootScopeName,
|
|
270
|
+
'cleanKnownObjectFunctionsFromMapping',
|
|
271
|
+
schema,
|
|
272
|
+
cleanKnownObjectFunctionsFromMapping,
|
|
273
|
+
context,
|
|
274
|
+
);
|
|
197
275
|
};
|
|
198
276
|
|
|
199
277
|
const translatePath = (path: string, dependencyName: string) => {
|
|
@@ -266,10 +344,21 @@ export default function mergeInDependentDataStructure({
|
|
|
266
344
|
let equivalentSchemaPathsEntry:
|
|
267
345
|
| (typeof equivalentSchemaPaths)[0]
|
|
268
346
|
| undefined;
|
|
347
|
+
|
|
348
|
+
// Collect the signature indices from the new roots we want to add
|
|
349
|
+
const newRootSignatureIndices = new Set<number>();
|
|
350
|
+
for (const root of equivalentRoots) {
|
|
351
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
352
|
+
if (idx !== undefined) {
|
|
353
|
+
newRootSignatureIndices.add(idx);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
269
357
|
for (const pathInfo of allPaths) {
|
|
270
358
|
if (!equivalentSchemaPathsEntry) {
|
|
271
|
-
equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) =>
|
|
272
|
-
|
|
359
|
+
equivalentSchemaPathsEntry = equivalentSchemaPaths.find((esp) => {
|
|
360
|
+
// First check: does this entry have a matching root?
|
|
361
|
+
const hasMatchingRoot = esp.equivalentRoots.some(
|
|
273
362
|
(er) =>
|
|
274
363
|
er.schemaRootPath === pathInfo.path &&
|
|
275
364
|
(er.function?.name ===
|
|
@@ -277,30 +366,106 @@ export default function mergeInDependentDataStructure({
|
|
|
277
366
|
(!er.function &&
|
|
278
367
|
cleanFunctionName(pathInfo.functionName) ===
|
|
279
368
|
rootScopeName)),
|
|
280
|
-
)
|
|
281
|
-
|
|
369
|
+
);
|
|
370
|
+
if (!hasMatchingRoot) return false;
|
|
371
|
+
|
|
372
|
+
// Second check: would adding our new roots create a signature index conflict?
|
|
373
|
+
// An entry should NOT contain roots with different signature indices from the same function.
|
|
374
|
+
if (newRootSignatureIndices.size > 0) {
|
|
375
|
+
// Get all signature indices in the existing entry (grouped by function)
|
|
376
|
+
const existingIndicesByFunction = new Map<string, Set<number>>();
|
|
377
|
+
for (const er of esp.equivalentRoots) {
|
|
378
|
+
const funcKey = er.function
|
|
379
|
+
? `${er.function.name}::${er.function.filePath}`
|
|
380
|
+
: '__self__';
|
|
381
|
+
const idx = extractSignatureIndex(er.schemaRootPath);
|
|
382
|
+
if (idx !== undefined) {
|
|
383
|
+
if (!existingIndicesByFunction.has(funcKey)) {
|
|
384
|
+
existingIndicesByFunction.set(funcKey, new Set());
|
|
385
|
+
}
|
|
386
|
+
existingIndicesByFunction.get(funcKey)!.add(idx);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Check if adding our new roots would create a conflict
|
|
391
|
+
for (const newRoot of equivalentRoots) {
|
|
392
|
+
const funcKey = newRoot.function
|
|
393
|
+
? `${newRoot.function.name}::${newRoot.function.filePath}`
|
|
394
|
+
: '__self__';
|
|
395
|
+
const newIdx = extractSignatureIndex(newRoot.schemaRootPath);
|
|
396
|
+
if (newIdx !== undefined) {
|
|
397
|
+
const existingIndices =
|
|
398
|
+
existingIndicesByFunction.get(funcKey);
|
|
399
|
+
if (existingIndices && existingIndices.size > 0) {
|
|
400
|
+
// If this function already has signature indices, check for conflict
|
|
401
|
+
if (!existingIndices.has(newIdx)) {
|
|
402
|
+
// Conflict: entry has indices like [1] but we want to add [2]
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return true;
|
|
411
|
+
});
|
|
282
412
|
}
|
|
283
413
|
}
|
|
284
414
|
|
|
285
415
|
if (!equivalentSchemaPathsEntry) {
|
|
416
|
+
// Before creating a new entry, filter out roots that have conflicting
|
|
417
|
+
// signature indices from the same function. An entry should never contain
|
|
418
|
+
// roots with different signature indices from the same function.
|
|
419
|
+
// This prevents the bug where signature[1], signature[2], signature[4]
|
|
420
|
+
// all get merged together due to incorrect sourceEquivalencies.
|
|
421
|
+
let filteredRoots = equivalentRoots;
|
|
422
|
+
if (newRootSignatureIndices.size > 1) {
|
|
423
|
+
// There are multiple signature indices - we need to filter to keep only
|
|
424
|
+
// one consistent set. We'll keep the roots that match the PRIMARY index
|
|
425
|
+
// (the first signature index we encounter from self, or the lowest index).
|
|
426
|
+
|
|
427
|
+
// First, determine the primary index - prefer the self root's index
|
|
428
|
+
let primaryIndex: number | undefined;
|
|
429
|
+
for (const root of equivalentRoots) {
|
|
430
|
+
if (!root.function) {
|
|
431
|
+
// This is a self root
|
|
432
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
433
|
+
if (idx !== undefined) {
|
|
434
|
+
primaryIndex = idx;
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
// If no self root has a signature index, use the lowest index
|
|
440
|
+
if (primaryIndex === undefined) {
|
|
441
|
+
primaryIndex = Math.min(...newRootSignatureIndices);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// Filter roots: keep if no signature index OR signature index matches primary
|
|
445
|
+
filteredRoots = equivalentRoots.filter((root) => {
|
|
446
|
+
const idx = extractSignatureIndex(root.schemaRootPath);
|
|
447
|
+
return idx === undefined || idx === primaryIndex;
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
286
451
|
equivalentSchemaPathsEntry = {
|
|
287
|
-
equivalentRoots,
|
|
452
|
+
equivalentRoots: filteredRoots,
|
|
288
453
|
equivalentPostfixes: {},
|
|
289
454
|
};
|
|
290
455
|
equivalentSchemaPaths.push(equivalentSchemaPathsEntry);
|
|
291
456
|
} else {
|
|
292
457
|
equivalentSchemaPathsEntry.equivalentRoots.push(...equivalentRoots);
|
|
293
458
|
}
|
|
459
|
+
|
|
460
|
+
// Deduplicate roots using a Set for O(n) instead of O(n²)
|
|
461
|
+
const seenRoots = new Set<string>();
|
|
294
462
|
equivalentSchemaPathsEntry.equivalentRoots =
|
|
295
|
-
equivalentSchemaPathsEntry.equivalentRoots.filter(
|
|
296
|
-
(er
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
e.function?.name === er.function?.name,
|
|
302
|
-
),
|
|
303
|
-
);
|
|
463
|
+
equivalentSchemaPathsEntry.equivalentRoots.filter((er) => {
|
|
464
|
+
const key = er.schemaRootPath + '::' + (er.function?.name ?? '');
|
|
465
|
+
if (seenRoots.has(key)) return false;
|
|
466
|
+
seenRoots.add(key);
|
|
467
|
+
return true;
|
|
468
|
+
});
|
|
304
469
|
|
|
305
470
|
return equivalentSchemaPathsEntry;
|
|
306
471
|
};
|
|
@@ -476,6 +641,26 @@ export default function mergeInDependentDataStructure({
|
|
|
476
641
|
allPaths.push(...derivedBasePaths);
|
|
477
642
|
|
|
478
643
|
const entry = findOrCreateEquivalentSchemaPathsEntry(allPaths);
|
|
644
|
+
|
|
645
|
+
// Trace equivalency gathering - helps debug why paths may not be connected
|
|
646
|
+
if (allPaths.length > 1) {
|
|
647
|
+
transformationTracer.operation(rootScopeName, {
|
|
648
|
+
operation: 'gatherEquivalency',
|
|
649
|
+
stage: 'gathering',
|
|
650
|
+
path: translatedPath,
|
|
651
|
+
context: {
|
|
652
|
+
sourceFunction: functionName,
|
|
653
|
+
equivalentPaths: allPaths.map((p) => ({
|
|
654
|
+
path: p.path,
|
|
655
|
+
function: p.functionName,
|
|
656
|
+
})),
|
|
657
|
+
equivalentRoots: entry.equivalentRoots.map((r) => ({
|
|
658
|
+
path: r.schemaRootPath,
|
|
659
|
+
function: r.function?.name,
|
|
660
|
+
})),
|
|
661
|
+
},
|
|
662
|
+
});
|
|
663
|
+
}
|
|
479
664
|
for (const equivalentRoot of entry.equivalentRoots) {
|
|
480
665
|
const dataStructures =
|
|
481
666
|
equivalentRoot.function &&
|
|
@@ -606,13 +791,29 @@ export default function mergeInDependentDataStructure({
|
|
|
606
791
|
schemaPathParts.slice(matchedUpToIndex),
|
|
607
792
|
);
|
|
608
793
|
|
|
609
|
-
entry.equivalentPostfixes[postfix]
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
794
|
+
const previousValue = entry.equivalentPostfixes[postfix];
|
|
795
|
+
const newValue = schema[schemaPath];
|
|
796
|
+
entry.equivalentPostfixes[postfix] = previousValue
|
|
797
|
+
? bestValueFromOptions([previousValue, newValue])
|
|
798
|
+
: newValue;
|
|
799
|
+
|
|
800
|
+
// Trace postfix gathering - shows where type info comes from
|
|
801
|
+
if (entry.equivalentPostfixes[postfix] !== previousValue) {
|
|
802
|
+
transformationTracer.operation(rootScopeName, {
|
|
803
|
+
operation: 'gatherPostfix',
|
|
804
|
+
stage: 'gathering',
|
|
805
|
+
path: postfix || '(root)',
|
|
806
|
+
before: previousValue,
|
|
807
|
+
after: entry.equivalentPostfixes[postfix],
|
|
808
|
+
context: {
|
|
809
|
+
sourceSchemaPath: schemaPath,
|
|
810
|
+
sourceFunction:
|
|
811
|
+
equivalentRoot.function?.name || rootScopeName,
|
|
812
|
+
equivalentRootPath: equivalentRoot.schemaRootPath,
|
|
813
|
+
rawValue: newValue,
|
|
814
|
+
},
|
|
815
|
+
});
|
|
816
|
+
}
|
|
616
817
|
}
|
|
617
818
|
}
|
|
618
819
|
}
|
|
@@ -672,14 +873,14 @@ export default function mergeInDependentDataStructure({
|
|
|
672
873
|
const postfix = joinParenthesesAndArrays(
|
|
673
874
|
schemaPathParts.slice(basePathParts.length),
|
|
674
875
|
);
|
|
675
|
-
|
|
676
|
-
postfix
|
|
677
|
-
]
|
|
876
|
+
const newValue = entry.equivalentPostfixes[postfix]
|
|
678
877
|
? bestValueFromOptions([
|
|
679
878
|
entry.equivalentPostfixes[postfix],
|
|
680
879
|
dataStructure.returnValueSchema[schemaPath],
|
|
681
880
|
])
|
|
682
881
|
: dataStructure.returnValueSchema[schemaPath];
|
|
882
|
+
|
|
883
|
+
entry.equivalentPostfixes[postfix] = newValue;
|
|
683
884
|
}
|
|
684
885
|
}
|
|
685
886
|
}
|
|
@@ -734,6 +935,10 @@ export default function mergeInDependentDataStructure({
|
|
|
734
935
|
equivalentRootFunction: (typeof equivalentSchemaPaths)[0]['equivalentRoots'][0]['function'],
|
|
735
936
|
) => {
|
|
736
937
|
let postfix: string | undefined;
|
|
938
|
+
|
|
939
|
+
// Get the signature index we're looking for (if any)
|
|
940
|
+
const lookingForSignatureIndex = extractSignatureIndex(schemaSubPath);
|
|
941
|
+
|
|
737
942
|
const equivalentEntry = mergedEquivalentSchemaPaths.find((esp) =>
|
|
738
943
|
esp.equivalentRoots.some((er) => {
|
|
739
944
|
if (
|
|
@@ -746,6 +951,35 @@ export default function mergeInDependentDataStructure({
|
|
|
746
951
|
}
|
|
747
952
|
|
|
748
953
|
if (schemaSubPath === er.schemaRootPath) {
|
|
954
|
+
// Additional check: if we're looking for a signature path, make sure
|
|
955
|
+
// the entry doesn't already have DIFFERENT signature indices.
|
|
956
|
+
// This prevents entries with signature[1], signature[2], signature[4]
|
|
957
|
+
// from all being merged together.
|
|
958
|
+
if (lookingForSignatureIndex !== undefined) {
|
|
959
|
+
const hasConflictingSignatureIndex = esp.equivalentRoots.some(
|
|
960
|
+
(otherRoot) => {
|
|
961
|
+
// Only check roots from the same function
|
|
962
|
+
if (
|
|
963
|
+
otherRoot.function?.name !== equivalentRootFunction?.name ||
|
|
964
|
+
otherRoot.function?.filePath !==
|
|
965
|
+
equivalentRootFunction?.filePath
|
|
966
|
+
) {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
const otherIndex = extractSignatureIndex(
|
|
970
|
+
otherRoot.schemaRootPath,
|
|
971
|
+
);
|
|
972
|
+
return (
|
|
973
|
+
otherIndex !== undefined &&
|
|
974
|
+
otherIndex !== lookingForSignatureIndex
|
|
975
|
+
);
|
|
976
|
+
},
|
|
977
|
+
);
|
|
978
|
+
if (hasConflictingSignatureIndex) {
|
|
979
|
+
return false;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
749
983
|
postfix = er.postfix;
|
|
750
984
|
return true;
|
|
751
985
|
}
|
|
@@ -880,7 +1114,44 @@ export default function mergeInDependentDataStructure({
|
|
|
880
1114
|
equivalentSchemaPaths = mergeAllEquivalentSchemaPaths();
|
|
881
1115
|
|
|
882
1116
|
for (const esp of equivalentSchemaPaths) {
|
|
883
|
-
|
|
1117
|
+
// Pre-compute which postfixes have children to avoid O(n²) lookups in the inner loop.
|
|
1118
|
+
// A postfix "has children" if there are other postfixes that extend it.
|
|
1119
|
+
const postfixesWithChildren = new Set<string>();
|
|
1120
|
+
const postfixKeys = Object.keys(esp.equivalentPostfixes);
|
|
1121
|
+
|
|
1122
|
+
// Check for empty postfix having children (any other postfixes exist)
|
|
1123
|
+
if (postfixKeys.length > 1 && '' in esp.equivalentPostfixes) {
|
|
1124
|
+
postfixesWithChildren.add('');
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// Check for array element postfixes having children using a prefix set.
|
|
1128
|
+
// This avoids O(n²) scans across large postfix lists.
|
|
1129
|
+
// e.g., 'currentEntities[]' has children if a path like 'currentEntities[].sha' exists.
|
|
1130
|
+
const postfixPrefixSet = new Set<string>();
|
|
1131
|
+
for (const postfixPath of postfixKeys) {
|
|
1132
|
+
if (!postfixPath) continue;
|
|
1133
|
+
const parts = splitOutsideParenthesesAndArrays(postfixPath);
|
|
1134
|
+
for (let i = 1; i < parts.length; i++) {
|
|
1135
|
+
postfixPrefixSet.add(joinParenthesesAndArrays(parts.slice(0, i)));
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
for (const postfixPath of postfixKeys) {
|
|
1139
|
+
if (postfixPath.endsWith('[]') && postfixPrefixSet.has(postfixPath)) {
|
|
1140
|
+
postfixesWithChildren.add(postfixPath);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
// Deduplicate equivalentRoots that would write to the same schema paths.
|
|
1145
|
+
// Roots with the same (function, schemaRootPath, postfix) are redundant.
|
|
1146
|
+
const seenRootKeys = new Set<string>();
|
|
1147
|
+
const uniqueRoots = esp.equivalentRoots.filter((root) => {
|
|
1148
|
+
const key = `${root.function?.filePath ?? ''}::${root.function?.name ?? ''}::${root.schemaRootPath}::${root.postfix ?? ''}`;
|
|
1149
|
+
if (seenRootKeys.has(key)) return false;
|
|
1150
|
+
seenRootKeys.add(key);
|
|
1151
|
+
return true;
|
|
1152
|
+
});
|
|
1153
|
+
|
|
1154
|
+
for (const equivalentRoot of uniqueRoots) {
|
|
884
1155
|
let merged:
|
|
885
1156
|
| {
|
|
886
1157
|
signatureSchema: { [key: string]: string };
|
|
@@ -905,9 +1176,21 @@ export default function mergeInDependentDataStructure({
|
|
|
905
1176
|
)) {
|
|
906
1177
|
let relevantPostfix = postfixPath;
|
|
907
1178
|
if (equivalentRoot.postfix) {
|
|
1179
|
+
// Check if postfixPath starts with equivalentRoot.postfix at a path boundary.
|
|
1180
|
+
// Must ensure exact path part match - "entityCode" should NOT match "entity" prefix.
|
|
1181
|
+
// Valid: "entity.foo" starts with "entity" (boundary at '.')
|
|
1182
|
+
// Valid: "entity[0]" starts with "entity" (boundary at '[')
|
|
1183
|
+
// Invalid: "entityCode" starts with "entity" (no boundary, different property)
|
|
908
1184
|
if (!postfixPath.startsWith(equivalentRoot.postfix)) {
|
|
909
1185
|
continue;
|
|
910
1186
|
}
|
|
1187
|
+
// Additional check: ensure the match is at a path boundary
|
|
1188
|
+
const nextChar = postfixPath[equivalentRoot.postfix.length];
|
|
1189
|
+
if (nextChar !== undefined && nextChar !== '.' && nextChar !== '[') {
|
|
1190
|
+
// The postfixPath continues with more characters that aren't a path separator.
|
|
1191
|
+
// This means "entity" matched "entityCode" which is wrong - they're different properties.
|
|
1192
|
+
continue;
|
|
1193
|
+
}
|
|
911
1194
|
|
|
912
1195
|
const postFixPathParts =
|
|
913
1196
|
splitOutsideParenthesesAndArrays(postfixPath);
|
|
@@ -924,10 +1207,90 @@ export default function mergeInDependentDataStructure({
|
|
|
924
1207
|
relevantPostfix,
|
|
925
1208
|
]);
|
|
926
1209
|
|
|
1210
|
+
// Skip paths that would go through a primitive type
|
|
1211
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', skip 'entities[].scenarioCount.sha'
|
|
1212
|
+
if (wouldGoThroughPrimitive(newSchemaPath, schema)) {
|
|
1213
|
+
transformationTracer.operation(rootScopeName, {
|
|
1214
|
+
operation: 'skipPrimitivePath',
|
|
1215
|
+
stage: 'merged',
|
|
1216
|
+
path: newSchemaPath,
|
|
1217
|
+
context: {
|
|
1218
|
+
reason: 'would go through primitive type',
|
|
1219
|
+
postfixValue,
|
|
1220
|
+
},
|
|
1221
|
+
});
|
|
1222
|
+
continue;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
// Skip setting primitive type when there are child postfixes that indicate structure.
|
|
1226
|
+
// This prevents downgrading an object/array element to a primitive type.
|
|
1227
|
+
// Uses pre-computed postfixesWithChildren Set for O(1) lookup instead of O(n) iteration.
|
|
1228
|
+
const hasChildPostfixes =
|
|
1229
|
+
(relevantPostfix === '' || relevantPostfix.endsWith('[]')) &&
|
|
1230
|
+
postfixesWithChildren.has(postfixPath);
|
|
1231
|
+
if (PRIMITIVE_TYPES.has(postfixValue) && hasChildPostfixes) {
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
// Don't overwrite a more specific type with a less specific one
|
|
1236
|
+
// This can happen when nested roots share entries with their parent roots
|
|
1237
|
+
const existingType = schema[newSchemaPath];
|
|
1238
|
+
if (existingType) {
|
|
1239
|
+
// Don't overwrite a primitive type with 'object' or 'array'
|
|
1240
|
+
// e.g., if schema has 'entities[].scenarioCount': 'number', don't overwrite with 'object'
|
|
1241
|
+
if (
|
|
1242
|
+
PRIMITIVE_TYPES.has(existingType) &&
|
|
1243
|
+
(postfixValue === 'object' || postfixValue === 'array')
|
|
1244
|
+
) {
|
|
1245
|
+
transformationTracer.operation(rootScopeName, {
|
|
1246
|
+
operation: 'skipTypeDowngrade',
|
|
1247
|
+
stage: 'merged',
|
|
1248
|
+
path: newSchemaPath,
|
|
1249
|
+
context: {
|
|
1250
|
+
reason: 'would overwrite primitive with object/array',
|
|
1251
|
+
existingType,
|
|
1252
|
+
newType: postfixValue,
|
|
1253
|
+
},
|
|
1254
|
+
});
|
|
1255
|
+
continue;
|
|
1256
|
+
}
|
|
1257
|
+
// Don't overwrite a complex/union type with a primitive
|
|
1258
|
+
// e.g., if schema has 'scenarios[]': 'Scenario | null', don't overwrite with 'string'
|
|
1259
|
+
if (
|
|
1260
|
+
!PRIMITIVE_TYPES.has(existingType) &&
|
|
1261
|
+
PRIMITIVE_TYPES.has(postfixValue)
|
|
1262
|
+
) {
|
|
1263
|
+
transformationTracer.operation(rootScopeName, {
|
|
1264
|
+
operation: 'skipTypeDowngrade',
|
|
1265
|
+
stage: 'merged',
|
|
1266
|
+
path: newSchemaPath,
|
|
1267
|
+
context: {
|
|
1268
|
+
reason: 'would overwrite complex type with primitive',
|
|
1269
|
+
existingType,
|
|
1270
|
+
newType: postfixValue,
|
|
1271
|
+
},
|
|
1272
|
+
});
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
// Log the successful postfix merge
|
|
1278
|
+
transformationTracer.operation(rootScopeName, {
|
|
1279
|
+
operation: 'mergePostfix',
|
|
1280
|
+
stage: 'merged',
|
|
1281
|
+
path: newSchemaPath,
|
|
1282
|
+
before: existingType,
|
|
1283
|
+
after: postfixValue,
|
|
1284
|
+
context: {
|
|
1285
|
+
schemaRootPath: equivalentRoot.schemaRootPath,
|
|
1286
|
+
postfix: relevantPostfix,
|
|
1287
|
+
dependency: equivalentRoot.function?.name,
|
|
1288
|
+
},
|
|
1289
|
+
});
|
|
927
1290
|
schema[newSchemaPath] = postfixValue;
|
|
928
1291
|
}
|
|
929
1292
|
|
|
930
|
-
cleanSchema(schema);
|
|
1293
|
+
cleanSchema(schema, { stage: 'afterMergePostfix' });
|
|
931
1294
|
}
|
|
932
1295
|
}
|
|
933
1296
|
|
|
@@ -1049,6 +1412,14 @@ export default function mergeInDependentDataStructure({
|
|
|
1049
1412
|
`${dependency.name}().functionCallReturnValue`,
|
|
1050
1413
|
);
|
|
1051
1414
|
}
|
|
1415
|
+
transformationTracer.operation(rootScopeName, {
|
|
1416
|
+
operation: 'normalizeReturnValuePath',
|
|
1417
|
+
stage: 'merged',
|
|
1418
|
+
path: normalizedPath,
|
|
1419
|
+
before: path,
|
|
1420
|
+
after: normalizedPath,
|
|
1421
|
+
context: { dependency: dependency.name, value },
|
|
1422
|
+
});
|
|
1052
1423
|
depSchema.returnValueSchema[normalizedPath] = value;
|
|
1053
1424
|
}
|
|
1054
1425
|
|
|
@@ -1133,7 +1504,10 @@ export default function mergeInDependentDataStructure({
|
|
|
1133
1504
|
}
|
|
1134
1505
|
}
|
|
1135
1506
|
|
|
1136
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1507
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1508
|
+
stage: 'afterMockedDependencyMerge',
|
|
1509
|
+
dependency: dependency.name,
|
|
1510
|
+
});
|
|
1137
1511
|
|
|
1138
1512
|
// Pull signature requirements from downstream functions into the mocked return value.
|
|
1139
1513
|
// When a mocked function's return flows into another function's signature (via usageEquivalencies),
|
|
@@ -1210,7 +1584,10 @@ export default function mergeInDependentDataStructure({
|
|
|
1210
1584
|
}
|
|
1211
1585
|
}
|
|
1212
1586
|
|
|
1213
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1587
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1588
|
+
stage: 'afterSignatureRequirementsMerge',
|
|
1589
|
+
dependency: dependency.name,
|
|
1590
|
+
});
|
|
1214
1591
|
}
|
|
1215
1592
|
|
|
1216
1593
|
// Process the input dependencySchemas FIRST (before child dependentAnalyses).
|
|
@@ -1251,7 +1628,45 @@ export default function mergeInDependentDataStructure({
|
|
|
1251
1628
|
// from the copied schema. Without this, method call paths on primitives like
|
|
1252
1629
|
// "projectSlug.replace(...)" would cause convertDotNotation to create nested
|
|
1253
1630
|
// object structures instead of preserving the primitive type.
|
|
1254
|
-
cleanSchema(depSchema.returnValueSchema
|
|
1631
|
+
cleanSchema(depSchema.returnValueSchema, {
|
|
1632
|
+
stage: 'afterDependencySchemaCopy',
|
|
1633
|
+
filePath,
|
|
1634
|
+
dependency: name,
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
// TYPE REFINEMENT: Check if dependentAnalyses has a more specific type for this dependency.
|
|
1639
|
+
// When a parent passes `entity.filePath` (string | undefined) to a child component
|
|
1640
|
+
// that requires `filePath: string`, we should use the child's more specific type.
|
|
1641
|
+
// This prevents mock data from having undefined values for required props.
|
|
1642
|
+
//
|
|
1643
|
+
// This runs REGARDLESS of whether equivalencies already processed the schema,
|
|
1644
|
+
// because equivalencies copy the parent's type (string | undefined), not the child's
|
|
1645
|
+
// required type (string).
|
|
1646
|
+
const depSchema = findOrCreateDependentSchemas({ filePath, name });
|
|
1647
|
+
const childAnalysis = dependentAnalyses[filePath]?.[name];
|
|
1648
|
+
const childSignatureSchema =
|
|
1649
|
+
childAnalysis?.metadata?.mergedDataStructure?.signatureSchema;
|
|
1650
|
+
|
|
1651
|
+
if (childSignatureSchema) {
|
|
1652
|
+
for (const path in depSchema.signatureSchema) {
|
|
1653
|
+
const parentType = depSchema.signatureSchema[path];
|
|
1654
|
+
const childType = childSignatureSchema[path];
|
|
1655
|
+
|
|
1656
|
+
if (parentType && childType) {
|
|
1657
|
+
// Check if parent has optional type and child has required type
|
|
1658
|
+
const parentIsOptional =
|
|
1659
|
+
parentType.includes('| undefined') ||
|
|
1660
|
+
parentType.includes('| null');
|
|
1661
|
+
const childIsOptional =
|
|
1662
|
+
childType.includes('| undefined') || childType.includes('| null');
|
|
1663
|
+
|
|
1664
|
+
// If child requires a more specific type (not optional), use it
|
|
1665
|
+
if (parentIsOptional && !childIsOptional) {
|
|
1666
|
+
depSchema.signatureSchema[path] = childType;
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1255
1670
|
}
|
|
1256
1671
|
|
|
1257
1672
|
// For functions with multiple different type parameters, also create separate entries
|
|
@@ -1288,7 +1703,12 @@ export default function mergeInDependentDataStructure({
|
|
|
1288
1703
|
srcSchema.returnValueSchema[path];
|
|
1289
1704
|
}
|
|
1290
1705
|
}
|
|
1291
|
-
cleanSchema(variantSchema.returnValueSchema
|
|
1706
|
+
cleanSchema(variantSchema.returnValueSchema, {
|
|
1707
|
+
stage: 'afterTypeVariantCopy',
|
|
1708
|
+
filePath,
|
|
1709
|
+
dependency: name,
|
|
1710
|
+
variant,
|
|
1711
|
+
});
|
|
1292
1712
|
}
|
|
1293
1713
|
}
|
|
1294
1714
|
}
|
|
@@ -1352,8 +1772,8 @@ export default function mergeInDependentDataStructure({
|
|
|
1352
1772
|
// Merge in the nested dependency schemas
|
|
1353
1773
|
for (const path in nestedDepSchema.returnValueSchema) {
|
|
1354
1774
|
if (!(path in targetDepSchema.returnValueSchema)) {
|
|
1355
|
-
|
|
1356
|
-
|
|
1775
|
+
const value = nestedDepSchema.returnValueSchema[path];
|
|
1776
|
+
targetDepSchema.returnValueSchema[path] = value;
|
|
1357
1777
|
}
|
|
1358
1778
|
}
|
|
1359
1779
|
|